Skip to content

Commit 1802c5c

Browse files
committed
chore(wheelhouse): cascade template@e670893ac860d1aa90bcd8994759534ffc503adb
1 parent df771e6 commit 1802c5c

69 files changed

Lines changed: 5814 additions & 2630 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.config/fleet/oxlintrc.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.config/fleet/tsconfig.check.json

Lines changed: 1 addition & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.config/repo/external-tools.json

Lines changed: 53 additions & 49 deletions
Large diffs are not rendered by default.

.config/repo/socket-wheelhouse.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"schemaVersion": 1,
77
"repoName": "socket-cli",
88
"bundle": {
9-
"ref": "fleet-pack-34b047176c416cd46f1919ad0bba35a0bb7b84b3",
10-
"cascadeSha": "34b047176c416cd46f1919ad0bba35a0bb7b84b3"
9+
"ref": "fleet-pack-e670893ac860d1aa90bcd8994759534ffc503adb",
10+
"cascadeSha": "e670893ac860d1aa90bcd8994759534ffc503adb"
1111
},
1212
"repo": {
1313
"type": "mono"

.config/repo/vitest.config.mts

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ const repoResolveConditions = resolveVitestConditions()
279279
// Lane resolution. The runner sets FLEET_LANE (bare `pnpm test` → 'fast'); the
280280
// filter also applies under coverage. An unset lane traverses every lane.
281281
const vitestLanes = readVitestLanes()
282+
const fastLaneGlobs = vitestLanes.fast
282283
const slowLaneGlobs = vitestLanes.slow ?? []
283284
const midLaneGlobs = vitestLanes.mid ?? []
284285
const activeLane = process.env['FLEET_LANE']
@@ -361,9 +362,9 @@ const config = defineConfig({
361362
'test/fleet/scripts/setup.mts',
362363
'test/repo/scripts/setup.mts',
363364
].filter(p => existsSync(p)),
364-
// `--lane mid|slow` runs ONLY that lane (include = its globs); every other
365-
// run (bare-fast, --all, scoped, cover) uses the full-suite glob and lets
366-
// the exclude below drop the fast-lane's mid+slow. `**/`-anchored so a
365+
// Explicit fast membership makes mid the complement of fast and slow.
366+
// Legacy configs retain implicit fast membership and explicit mid globs.
367+
// `**/`-anchored so a
367368
// monorepo's nested `packages/<name>/test/**` trees are discovered from this
368369
// one root config — a bare `test/**/*.test...` only anchors at the repo
369370
// root, silently missing every sub-package's tests (each scoped `vitest run`
@@ -373,11 +374,13 @@ const config = defineConfig({
373374
? [...FUZZ_GLOBS]
374375
: conformanceTier
375376
? laneToTestGlobs(conformanceGlobs)
376-
: laneFilterActive && activeLane === 'mid'
377-
? laneToTestGlobs(midLaneGlobs)
378-
: laneFilterActive && activeLane === 'slow'
379-
? laneToTestGlobs(slowLaneGlobs)
380-
: ['**/test/**/*.test.{js,ts,mjs,mts,cjs}'],
377+
: laneFilterActive && activeLane === 'fast' && fastLaneGlobs
378+
? laneToTestGlobs(fastLaneGlobs)
379+
: laneFilterActive && activeLane === 'mid' && !fastLaneGlobs
380+
? laneToTestGlobs(midLaneGlobs)
381+
: laneFilterActive && activeLane === 'slow'
382+
? laneToTestGlobs(slowLaneGlobs)
383+
: ['**/test/**/*.test.{js,ts,mjs,mts,cjs}'],
381384
// Vitest treats `test/**` as `**/test/**`, so without an explicit
382385
// exclude it picks up every nested `test/` directory in the repo
383386
// — including the `.git-hooks/test/`, the oxlint plugin's per-rule
@@ -434,14 +437,13 @@ const config = defineConfig({
434437
// settings file's `vitest.nodeTestExclude`. The same key feeds
435438
// prefer-vitest-guard's allowlist so the two never drift.
436439
...repoNodeTestExcludeGlobs(),
437-
// Fast lane (`--lane fast`, the bare `pnpm test` default) skips the mid +
438-
// slow lane globs (heavy/isolated suites) for a quick local loop. Inert
439-
// for an unset lane. Coverage explicitly selects each lane in turn;
440-
// `--lane mid|slow` scopes via the
441-
// include above instead, so no exclusion is applied for them here.
440+
// With explicit fast membership, mid owns every test outside fast and
441+
// slow. Legacy configs keep fast as the complement of mid and slow.
442442
...(laneFilterActive && activeLane === 'fast'
443443
? [...midLaneGlobs, ...slowLaneGlobs]
444-
: []),
444+
: laneFilterActive && activeLane === 'mid' && fastLaneGlobs
445+
? [...fastLaneGlobs, ...slowLaneGlobs]
446+
: []),
445447
],
446448
// Some repos in the fleet (scaffolding-only, hook-only, etc.) ship
447449
// this config but don't yet have a `test/` directory — vitest's
@@ -514,7 +516,8 @@ const config = defineConfig({
514516
// drifted copy here.
515517
coverage: {
516518
enabled: isCoverageEnabled,
517-
...resolveCoverageConfig(),
519+
// Ordinary tests do not need the workspace scan for coverage aliases.
520+
...(isCoverageEnabled ? resolveCoverageConfig() : {}),
518521
},
519522
},
520523
})

.config/repo/vitest.settings.mts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,16 @@ export interface VitestRepoConfig {
4444
* (.config/repo/socket-wheelhouse.json; see paths.mts's resolver order for the
4545
* fallbacks). `slow` = heavy suites (subprocess-per-case, e.g. hook integration
4646
* specs); `mid` = isolated in-process suites (env-mutating / vi.mock /
47-
* fs-heavy); `fast` = the implicit complement, pure in-process. The runner's
47+
* fs-heavy); `fast` = pure in-process. When `fast` is declared, `mid` becomes
48+
* the complement of `fast` and `slow`, so unclassified tests remain covered.
49+
* Without it, `fast` remains the complement of `mid` and `slow`. The runner's
4850
* `--lane <fast|mid|slow>` flag (scripts/fleet/test.mts) selects one, and bare
4951
* `pnpm test` defaults to `fast` for a quick local loop. The lane filter is
5052
* active under coverage too. An unset FLEET_LANE traverses every lane; the
5153
* coverage runner selects each lane in turn and merges their reports.
5254
*/
5355
export interface VitestLanes {
56+
fast?: string[] | undefined
5457
mid?: string[] | undefined
5558
slow?: string[] | undefined
5659
}
@@ -131,7 +134,11 @@ export function readNonIsolatedGlobs(): string[] {
131134
export function readVitestLanes(): VitestLanes {
132135
const lanes = readVitestSettings().lanes
133136
return lanes !== null && typeof lanes === 'object' && !Array.isArray(lanes)
134-
? { mid: stringArray(lanes.mid), slow: stringArray(lanes.slow) }
137+
? {
138+
...(Array.isArray(lanes.fast) ? { fast: stringArray(lanes.fast) } : {}),
139+
mid: stringArray(lanes.mid),
140+
slow: stringArray(lanes.slow),
141+
}
135142
: {}
136143
}
137144

.git-hooks/_shared/canonical-fork-scan.mts renamed to .git-hooks/_shared/canonical/fork-scan.mts

Lines changed: 62 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
import { spawnSync } from '@socketsecurity/lib-stable/process/spawn/child'
2-
import { existsSync, readdirSync, readFileSync } from 'node:fs'
2+
import { existsSync, lstatSync, readdirSync, readFileSync } from 'node:fs'
33
import path from 'node:path'
4+
import { readCanonicalIndexEntry, readCanonicalTreeEntry } from './git.mts'
5+
import { canonicalMemberCopyMatches } from './proof.mts'
6+
import type { CanonicalIndexEntry } from './git.mts'
47

58
import {
69
fleetCanonicalEntries,
710
isOperatorLocalPath,
811
isPerRepoMarkerPath,
9-
} from '../../.claude/hooks/fleet/_shared/fleet-fork.mts'
10-
import { textHasFleetBlockMarkers } from '../../.claude/hooks/fleet/_shared/fleet-markers.mts'
12+
} from '../../../.claude/hooks/fleet/_shared/fleet-fork.mts'
13+
import {
14+
findFleetRegions,
15+
textHasFleetBlockMarkers,
16+
} from '../../../.claude/hooks/fleet/_shared/fleet-markers.mts'
1117

1218
// Each child names one capability or member, never an arbitrary generated
1319
// bucket. Generated universal files map directly to the destination tree.
@@ -62,19 +68,27 @@ export function templateTwinPaths(repoRoot: string, file: string): string[] {
6268
export function matchesTemplateTwin(
6369
repoRoot: string,
6470
file: string,
65-
content: string,
71+
content: string | Uint8Array,
72+
mode = '100644',
6673
): boolean {
6774
const candidates = templateTwinPaths(repoRoot, file)
6875
for (let i = 0, { length } = candidates; i < length; i += 1) {
69-
let twin: string
7076
try {
71-
twin = readFileSync(candidates[i]!, 'utf8')
77+
const stat = lstatSync(candidates[i]!)
78+
const candidateMode = stat.mode & 0o111 ? '100755' : '100644'
79+
if (!stat.isFile() || candidateMode !== mode) {
80+
continue
81+
}
82+
if (
83+
readFileSync(candidates[i]!).equals(
84+
typeof content === 'string' ? Buffer.from(content) : content,
85+
)
86+
) {
87+
return true
88+
}
7289
} catch {
7390
continue
7491
}
75-
if (twin === content) {
76-
return true
77-
}
7892
}
7993
return false
8094
}
@@ -199,27 +213,48 @@ export function scanCanonicalForkPaths(
199213
if (!isCanonical) {
200214
continue
201215
}
202-
if (matchesMergeParentIndex(repoRoot, file)) {
203-
continue
204-
}
205-
// Fleet-block allowance: a canonical file carrying `<fleet-canonical>`
206-
// markers is only PART fleet-managed — content outside the markers is
207-
// repo-owned, so staging it is normal repo work, not a fork.
208-
let content = ''
209-
try {
210-
content = readFileSync(path.join(repoRoot, file), 'utf8')
211-
} catch {
212-
// Unreadable (permissions, binary) — fall through as non-exempt; a
213-
// canonical path staged unreadable is still worth surfacing.
214-
}
215-
if (textHasFleetBlockMarkers(content)) {
216-
continue
217-
}
218-
// Byte-identical to canonical is propagation, not divergence.
219-
if (matchesTemplateTwin(repoRoot, file, content)) {
216+
const entry = readCanonicalIndexEntry(repoRoot, file)
217+
if (entry && stagedCanonicalFileIsAllowed(repoRoot, file, entry)) {
220218
continue
221219
}
222220
findings.push({ file })
223221
}
224222
return findings
225223
}
224+
225+
function fleetRegionBodies(content: Uint8Array): string[] {
226+
const text = Buffer.from(content).toString('utf8')
227+
if (!textHasFleetBlockMarkers(text)) {
228+
return []
229+
}
230+
const lines = text.split(/(?<=\n)/u)
231+
return findFleetRegions(lines).map(region =>
232+
lines.slice(region.start, region.end + 1).join(''),
233+
)
234+
}
235+
236+
function stagedCanonicalFileIsAllowed(
237+
repoRoot: string,
238+
file: string,
239+
entry: CanonicalIndexEntry,
240+
): boolean {
241+
if (matchesMergeParentIndex(repoRoot, file)) {
242+
return true
243+
}
244+
const baseline = readCanonicalTreeEntry(repoRoot, 'HEAD', file)
245+
if (baseline && baseline.mode === entry.mode) {
246+
const before = fleetRegionBodies(baseline.content)
247+
const after = fleetRegionBodies(entry.content)
248+
if (
249+
before.length > 0 &&
250+
before.length === after.length &&
251+
before.every((body, index) => body === after[index])
252+
) {
253+
return true
254+
}
255+
}
256+
return (
257+
matchesTemplateTwin(repoRoot, file, entry.content, entry.mode) ||
258+
canonicalMemberCopyMatches(repoRoot, file, entry)
259+
)
260+
}

0 commit comments

Comments
 (0)