Skip to content

Commit aaae38b

Browse files
committed
chore(vscode): reconcile remote fleet cascade
2 parents 3f8a202 + d5f708b commit aaae38b

58 files changed

Lines changed: 7015 additions & 2941 deletions

Some content is hidden

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

‎.claude/output-styles/fleet.md‎

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/.prettierignore‎

Lines changed: 5 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.config/fleet/oxlintrc.json‎

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.config/repo/socket-wheelhouse.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@
6666
"trustPolicy": "no-downgrade"
6767
},
6868
"bundle": {
69-
"ref": "fleet-pack-a0655ecd6c19fe5e2bd0c7ca89cb37187e1d56f2",
70-
"cascadeSha": "a0655ecd6c19fe5e2bd0c7ca89cb37187e1d56f2"
69+
"ref": "fleet-pack-011e1c67ce8860fdf7dca52a45e1a8d6620379e6",
70+
"cascadeSha": "011e1c67ce8860fdf7dca52a45e1a8d6620379e6"
7171
},
7272
"bornTested": {
7373
"grandfathered": [
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
import { canonicalOriginAllowed } from './source.mts'
2+
import crypto from 'node:crypto'
3+
import { readFileSync, statSync } from 'node:fs'
4+
import path from 'node:path'
5+
import process from 'node:process'
6+
import { spawnSync } from '@socketsecurity/lib-stable/process/spawn/child'
7+
import { canonicalPathIsSafe } from './git.mts'
8+
import type { CanonicalIndexEntry } from './git.mts'
9+
10+
function record(value: unknown): Record<string, unknown> | undefined {
11+
return value !== null && typeof value === 'object' && !Array.isArray(value)
12+
? Object.fromEntries(Object.entries(value))
13+
: undefined
14+
}
15+
16+
function unscopedTarget(
17+
manifest: Record<string, unknown>,
18+
file: string,
19+
): boolean {
20+
for (const field of [
21+
'capabilityScopedFiles',
22+
'conditionalScopedFiles',
23+
'shapeScopedFiles',
24+
]) {
25+
const groups = manifest[field]
26+
if (groups === undefined) {
27+
continue
28+
}
29+
if (!Array.isArray(groups)) {
30+
return false
31+
}
32+
for (const value of groups) {
33+
const files = record(value)?.['files']
34+
if (!Array.isArray(files) || files.includes(file)) {
35+
return false
36+
}
37+
}
38+
}
39+
return true
40+
}
41+
42+
export function canonicalBundleBytesMatch(
43+
ref: string,
44+
file: string,
45+
entry: CanonicalIndexEntry,
46+
manifest: unknown,
47+
): boolean {
48+
const parsed = record(manifest)
49+
const files = record(parsed?.['files'])
50+
const expected = files?.[file]
51+
return (
52+
/^fleet-pack-[0-9a-f]{40}$/u.test(ref) &&
53+
parsed?.['templateSha'] === ref.slice('fleet-pack-'.length) &&
54+
unscopedTarget(parsed, file) &&
55+
canonicalPathIsSafe(file) &&
56+
entry.mode === '100644' &&
57+
typeof expected === 'string' &&
58+
/^[0-9a-f]{64}$/u.test(expected) &&
59+
crypto.hash('sha256', entry.content, 'hex') === expected
60+
)
61+
}
62+
63+
const manifests = new Map<string, unknown>()
64+
function fetchManifest(member: string, ref: string): unknown {
65+
const key = `${member}:${ref}`
66+
if (!manifests.has(key)) {
67+
const result = spawnSync(
68+
process.execPath,
69+
[path.join(member, 'scripts/fleet/pack/canonical-proof.mts'), ref],
70+
{
71+
cwd: member,
72+
encoding: 'utf8',
73+
stdio: ['ignore', 'pipe', 'pipe'],
74+
timeout: 30_000,
75+
maxBuffer: 4_194_304,
76+
},
77+
)
78+
if (result.status !== 0) {
79+
return undefined
80+
}
81+
const lines = result.stdout.trim().split(/\r?\n/u)
82+
const manifest: unknown = JSON.parse(lines.at(-1) ?? '')
83+
if (record(manifest)?.['templateSha'] !== ref.slice('fleet-pack-'.length)) {
84+
return undefined
85+
}
86+
manifests.set(key, manifest)
87+
}
88+
return manifests.get(key)
89+
}
90+
91+
export function canonicalBundleCopyMatches(
92+
member: string,
93+
file: string,
94+
entry: CanonicalIndexEntry,
95+
options: {
96+
fetchManifest?: ((member: string, ref: string) => unknown) | undefined
97+
} = {},
98+
): boolean {
99+
if (!canonicalOriginAllowed(member)) {
100+
return false
101+
}
102+
try {
103+
const appliedPath = path.join(
104+
member,
105+
'.cache/fleet/socket-wheelhouse/bundle-applied',
106+
)
107+
if (statSync(appliedPath).size > 128) {
108+
return false
109+
}
110+
const ref = readFileSync(appliedPath, 'utf8').trim()
111+
if (!/^fleet-pack-[0-9a-f]{40}$/u.test(ref)) {
112+
return false
113+
}
114+
return canonicalBundleBytesMatch(
115+
ref,
116+
file,
117+
entry,
118+
(options.fetchManifest ?? fetchManifest)(member, ref),
119+
)
120+
} catch {
121+
return false
122+
}
123+
}

‎.git-hooks/_shared/canonical/proof.mts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { canonicalBundleCopyMatches } from './bundle.mts'
12
/**
23
* @file Prove stage-zero bytes from signed producer trees or ordered template
34
* patches.
@@ -345,6 +346,9 @@ export function canonicalMemberCopyMatches(
345346
}
346347
}
347348
}
349+
if (canonicalBundleCopyMatches(member, file, entry)) {
350+
return true
351+
}
348352
const receipt = readCanonicalReceipt(member)
349353
return (
350354
canonicalRecipeCopyMatches(member, file, entry, receipt) ||

‎.git-hooks/_shared/canonical/replacements.mts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ function replaceUniqueRun(
104104
const index = text.indexOf(run.before)
105105
if (
106106
index < 0 ||
107-
(index > 0 && text[index - 1] !== '\n') ||
107+
(index > 0 && text.charCodeAt(index - 1) !== 10) /* '\n' */ ||
108108
text.indexOf(run.before, index + 1) !== -1 ||
109109
(!run.before.endsWith('\n') && index + run.before.length !== text.length)
110110
) {

‎.git-hooks/_shared/push-repo-gates.mts‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ import {
4242
// One owner for the path, per `paths-are-constructed-once`: a cascaded file is
4343
// tracked twice (source + live mirror), so a literal spelled here counts as
4444
// two construction sites on its own.
45-
import { TYPECHECK_CACHE_DIR } from '../../scripts/fleet/paths.mts'
45+
import { HEAVY_JOB_BUSY_EXIT_CODE } from '../../scripts/fleet/process/heavy-job/admission.mts'
46+
import {
47+
FLEET_TYPE_SCRIPT,
48+
TYPECHECK_CACHE_DIR,
49+
} from '../../scripts/fleet/paths.mts'
4650

4751
import type { TypecheckVerdict } from './typecheck-cache.mts'
4852
import { scanSoakExcludeDateAnnotations } from './scan-supply-chain.mts'
@@ -403,16 +407,16 @@ function runTypeCheckOnce(cacheKey: string): TypecheckVerdict {
403407
// Captured rather than inherited so the diagnostics can be ATTRIBUTED. tsc
404408
// reads the working tree, which in a shared checkout holds a co-session's
405409
// half-finished edits — errors this push neither caused nor can fix.
406-
const r = spawnSync(
407-
process.execPath,
408-
[TSC_BIN, '--noEmit', '-p', TYPE_CHECK_TSCONFIG],
409-
{ stdioString: true },
410-
)
410+
const r = spawnSync(process.execPath, [FLEET_TYPE_SCRIPT], {
411+
stdioString: true,
412+
})
411413
const verdict: TypecheckVerdict = {
412414
output: `${String(r.stdout ?? '')}${String(r.stderr ?? '')}`,
413415
status: r.status ?? 1,
414416
}
415-
writeTypecheckVerdict(TYPECHECK_CACHE_DIR, cacheKey, verdict)
417+
if (verdict.status !== HEAVY_JOB_BUSY_EXIT_CODE) {
418+
writeTypecheckVerdict(TYPECHECK_CACHE_DIR, cacheKey, verdict)
419+
}
416420
return verdict
417421
} finally {
418422
held?.release()

‎.git-hooks/_shared/scan-core.mts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const LEGACY_ZIZMOR_MARKER_RE = /(?:#|\/\*|\/\/)\s*zizmor:\s*[\w-]+/
8888
// Anything else falls through to `#` (shell / YAML / TOML / Dockerfile /
8989
// Makefile / Python / Ruby / etc).
9090
const SLASH_COMMENT_EXT_RE =
91-
/\.(m?ts|tsx|cts|m?js|jsx|cjs|rs|go|c|cc|cpp|cxx|h|hpp|java|swift|kt|scala|dart|php|css|scss|less)$/i
91+
/\.(?:m?ts|tsx|cts|m?js|jsx|cjs|rs|go|c|cc|cpp|cxx|h|hpp|java|swift|kt|scala|dart|php|css|scss|less)$/i
9292

9393
/**
9494
* The suppression a contributor should paste into `filePath` to waive `rule`.
@@ -148,17 +148,17 @@ export function suppressionCoversLine(
148148
// (multi-line JSDoc bodies use leading ` * ` which we already match).
149149
// - Lines whose entire interesting content sits inside a backtick span
150150
// (markdown / template-literal example).
151-
const COMMENT_LINE_RE = /^\s*(#|\*|\/\/)/
151+
const COMMENT_LINE_RE = /^\s*(?:#|\*|\/\/)/
152152
// Matches a JSDoc tag (@example, @param, @returns/@return, @see, @link) at a word boundary.
153-
const JSDOC_TAG_RE = /@(example|link|param|returns?|see)\b/
153+
const JSDOC_TAG_RE = /@(?:example|link|param|returns?|see)\b/
154154

155155
export function isInsideBackticks(line: string, needleRe: RegExp): boolean {
156156
// Find every backtick-delimited span on the line and test if the
157157
// pattern only appears within those spans. Conservative: if any
158158
// hit is *outside* a span, treat the line as runtime code.
159159
const spans: Array<[number, number]> = []
160160
for (let i = 0; i < line.length; i++) {
161-
if (line[i] === '`') {
161+
if (line.charCodeAt(i) === 96 /* '`' */) {
162162
const end = line.indexOf('`', i + 1)
163163
if (end < 0) {
164164
break

‎.git-hooks/_shared/scan-supply-chain.mts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// lockdown check, the soak-exclude date-annotation check, and the AI-config
33
// poison-fingerprint warner. Gate-free string logic built on scan-core.
44

5+
import { maskStringContents } from '../../scripts/fleet/hooks/guard-block-shape.mts'
56
import { scanLines } from './scan-core.mts'
67

78
import type { LineHit } from './scan-core.mts'
@@ -39,7 +40,8 @@ const BAD_PERMISSION_MODE_RE =
3940
const BYPASS_PERMISSIONS_RE = /\bbypassPermissions\b/
4041

4142
export const scanProgrammaticClaudeLockdown = (text: string): LineHit[] => {
42-
if (!CLAUDE_DRIVER_RE.test(text)) {
43+
const executable = maskStringContents(text)
44+
if (!CLAUDE_DRIVER_RE.test(executable)) {
4345
return []
4446
}
4547
// A forbidden mode anywhere is an immediate fail, pointed at its line.
@@ -60,7 +62,12 @@ export const scanProgrammaticClaudeLockdown = (text: string): LineHit[] => {
6062
if (missing.length === 0) {
6163
return []
6264
}
63-
return scanLines(text, CLAUDE_DRIVER_RE)
65+
const lines = text.split(/\r?\n/)
66+
const hits = scanLines(executable, CLAUDE_DRIVER_RE)
67+
for (const hit of hits) {
68+
hit.line = lines[hit.lineNumber - 1]!
69+
}
70+
return hits
6471
}
6572

6673
// ── Soak-exclude date annotations (HARD block, pnpm-workspace.yaml) ──

0 commit comments

Comments
 (0)