* test(#3333): fold the runtime & install surface fix-* cluster — Wave 1 Folds 11 legacy tests/fix-*.test.cjs regression files into their module's main test suite: 6 folded into existing suites (host-integration-descriptors, effort-surface-axis, trae-imperative-reference, hermes-skills-migration, gsd-agent-isolation-guard), 5 renamed to become the module's sole suite (cursor-hook-workspace-roots, cursor-subagent-isolation, lint-compiled-artifact-sync, hooks-commonjs-marker, shared-hooks-dir-resolution). All 195 test() blocks preserved with zero drops; lint-test-file-count.cjs and eslint remain clean. No production code changed. Wave 1 of 7 in #3315 (H3 of epic #3053). * test(#3333): replace try/finally with t.after() in isolation-guard tests CONTRIBUTING.md bans try/finally inside test bodies (masks failures, not an approved pattern). The fold in the prior commit carried 27 instances forward verbatim from the deleted fix-3045-dispatch-isolation-resolver.test.cjs into an otherwise-clean file. Converts each to the approved per-test t.after() cleanup pattern — same cleanup call, registered instead of finally-wrapped. No assertion, fixture, or test-name change; test( count unchanged at 50. Found by the Standards review pass on Wave 1 (#3333, H3 of epic #3053). * fix(#3333): restore raw NUL byte mangled by the fold in hermes-skills-migration.test.cjs The prior fold commit copied fix-2284-hermes-agent-delegate-task-projection's "collision-robust" test via a text-based Read/Write pipeline, which silently turned a raw NUL byte (0x00) embedded in two string literals into a regular space character. That corrupted the test's actual purpose (proving a NUL byte survives a string-rewrite operation untouched) and produced a genuine gsd-test failure: `24 !== 1` for `out.split(' ').length`, because splitting on a space finds every space in the sentence instead of the single NUL byte the test meant to isolate. Root-caused by diffing the raw bytes (via `git cat-file blob` + `cat -v`) between the pre-fold source and the folded target — confirmed exactly two bytes differ. Restored via a byte-precise patch (latin1 round-trip) touching only those two lines; test( count and every other byte unchanged. * fix(#3333): use \x00 escape sequence instead of a raw NUL byte in test fixture The prior commit restored a byte-exact raw NUL byte matching the original fix-2284 source, and the production function (applyClaudeCodeBrandSwap) was confirmed correct in a standalone repro. But the same raw byte still failed through gsd-test's remote pipeline. Root cause is upstream of gsd-core: some step in that transfer path does not carry a raw 0x00 byte through untouched. A raw embedded NUL byte was never necessary here — `\x00` as a 4-character escape sequence in the source text produces the identical runtime character (U+0000) without ever putting a raw byte in the tracked file, sidestepping any byte-oriented transfer step. Applied at both call sites (the fixture string and the split() delimiter). No behavior change; test( count unchanged at 76. * fix(#3333): harden copyWithPathReplacement against a source file vanishing mid-copy (TOCTOU) Surfaced by this PR's own gsd-test run: tests/install-minimal-hooks.test.cjs and tests/opencode-command-dir-plural.test.cjs intermittently crashed with ENOENT reading gsd-core/workflows/zzz-e5-drift-fixture.md. Root cause is unrelated to test-file consolidation — tests/planning-prompt-drift.test.cjs writes that fixture directly into the real, shared gsd-core/workflows/ tree (main() hardcodes its scan root to the real repo) and deletes it in t.after(); copyWithPathReplacement's readdirSync-then-read loop has no protection against the listed file vanishing before it gets there, so a concurrently-running install path can crash entirely on what is otherwise a completely benign race. Fixed by skipping (not crashing on) a listed entry that no longer exists by the time the loop reaches it. Added a regression test that deterministically reproduces the race (readdirSync snapshot still lists the file; it is deleted immediately after) and proves both outcomes: no throw, and the vanished entry's destination is never partially written. Per CLAUDE.md's no-defer rule, a defect surfaced while verifying this PR is fixed inline rather than deferred — this overrides one-concern-per-PR. * fix(#3333): fix third NUL-byte-mangled occurrence missed by prior fix passes The fold originally mangled three raw-NUL-byte occurrences to spaces, not two — the earlier byte-restore and escape-sequence commits both only targeted the fixture string and the split() delimiter, missing out.includes('[ ]') a few lines below (should read out.includes('[\x00]')). A remote gsd-test run kept failing on this exact assertion even after both prior fixes, which is what surfaced the miss. Verified via a standalone repro using the file's real (not retyped) fixture content: all six assertions in the collision-robust test now pass. Zero raw NUL bytes remain in the file; test( count unchanged at 76. * chore(#3333): add changeset for the copyWithPathReplacement TOCTOU fix Fixed-type fragment for the production defect fixed inline in this PR (bin/install.js's copyWithPathReplacement). Exempt from docs/ requirements per CONTRIBUTING.md (only Added/Changed/Deprecated/Removed require it). * chore(#3333): backfill changeset PR number (pr:0 -> pr:3341) --------- Co-authored-by: sim <sim@local>
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
// allow-test-rule: source-text-is-the-product (see #2481)
|
||||
// allow-test-rule: source-text-is-the-product (see #2481, #2615)
|
||||
// The final describe block asserts on gsd-core/workflows/review.md's text. A
|
||||
// workflow .md IS what the runtime loads — its literal command lines are the
|
||||
// deployed contract, and there is no runtime seam that executes review.md here.
|
||||
// The #2615 matrix-parity block below is the same kind of contract assertion:
|
||||
// docs/reference/host-integration-capability-matrix.md IS the cited source of
|
||||
// truth for every descriptor axis (ADR-1239), so asserting a shipped axis
|
||||
// value appears there and matches is a contract assertion, not a source grep.
|
||||
// Every other block in this file is behavioral (CLI + module surface).
|
||||
|
||||
/**
|
||||
@@ -37,6 +41,31 @@ const {
|
||||
_HOST_INTEGRATION_VOCAB,
|
||||
validateRuntimeBody,
|
||||
} = require(path.join(REPO_ROOT, 'gsd-core', 'bin', 'lib', 'capability-validator.cjs'));
|
||||
const registry = require(path.join(REPO_ROOT, 'gsd-core', 'bin', 'lib', 'capability-registry.cjs'));
|
||||
|
||||
// #2615: the host-integration capability matrix, normalized so CRLF checkouts
|
||||
// (Windows autocrlf) don't break the row regexes below.
|
||||
const MATRIX = path.join(REPO_ROOT, 'docs', 'reference', 'host-integration-capability-matrix.md');
|
||||
const MATRIX_TEXT = fs.readFileSync(MATRIX, 'utf-8').replace(/\r\n/g, '\n');
|
||||
|
||||
/** Extract a `## <host>` section body, stopping at the next top-level host heading. */
|
||||
function matrixSection(host) {
|
||||
const start = MATRIX_TEXT.indexOf(`\n## ${host}\n`);
|
||||
if (start === -1) return null;
|
||||
const rest = MATRIX_TEXT.slice(start + 1);
|
||||
const end = rest.indexOf('\n## ');
|
||||
return end === -1 ? rest : rest.slice(0, end);
|
||||
}
|
||||
|
||||
/** Read the value cell of a `| <axis> | <value> | …` row. */
|
||||
function matrixAxisValue(body, axis) {
|
||||
const row = body.split(/\r?\n/).find((l) => l.startsWith(`| ${axis} |`));
|
||||
return row ? row.split('|')[2].trim() : null;
|
||||
}
|
||||
|
||||
const MATRIX_RUNTIMES = Object.keys(registry.runtimes).filter(
|
||||
(id) => registry.runtimes[id]?.runtime?.hostIntegration,
|
||||
);
|
||||
|
||||
/**
|
||||
* A real shipped descriptor with one hostIntegration axis stripped.
|
||||
@@ -427,3 +456,47 @@ describe('#2481 review workflow resolves effort per reviewer', () => {
|
||||
assert.deepStrictEqual(argvEffort, ['claude', 'codex', 'opencode']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#2615: the matrix documents the effortSurface axis', () => {
|
||||
test('the axes legend defines effortSurface and its vocabulary', () => {
|
||||
const legendRow = MATRIX_TEXT.split(/\r?\n/).find((l) => l.startsWith('| `effortSurface` |'));
|
||||
assert.ok(legendRow, 'the axes legend must define effortSurface (#2615)');
|
||||
for (const member of ['`argv`', '`none`', '`undocumented`']) {
|
||||
assert.ok(legendRow.includes(member),
|
||||
`the legend must document the ${member} vocabulary member (#2615)`);
|
||||
}
|
||||
});
|
||||
|
||||
test('there is at least one runtime to check', () => {
|
||||
// Guards the loops below against silently asserting nothing.
|
||||
assert.ok(MATRIX_RUNTIMES.length >= 18, `expected the full runtime corpus, got ${MATRIX_RUNTIMES.length}`);
|
||||
});
|
||||
|
||||
for (const id of MATRIX_RUNTIMES) {
|
||||
describe(`runtime: ${id}`, () => {
|
||||
test('has a matrix section', () => {
|
||||
assert.ok(matrixSection(id), `${id}: every installed runtime needs a matrix section (ADR-1239)`);
|
||||
});
|
||||
|
||||
test('documents effortSurface, and the value matches the descriptor', () => {
|
||||
const body = matrixSection(id);
|
||||
assert.ok(body, `${id}: missing matrix section`);
|
||||
|
||||
const documented = matrixAxisValue(body, 'effortSurface');
|
||||
assert.ok(documented, `${id}: the matrix must carry an effortSurface row (#2615)`);
|
||||
|
||||
const declared = registry.runtimes[id].runtime.hostIntegration.effortSurface;
|
||||
if (declared === undefined) {
|
||||
// kimi-code declares no value: its mechanism (`/effort`) is interactive-only
|
||||
// and neither `argv` nor `none` describes it. The matrix must say so rather
|
||||
// than invent a value.
|
||||
assert.match(documented, /not declared/i,
|
||||
`${id}: an absent descriptor value must be documented as absent, not guessed (#2615)`);
|
||||
} else {
|
||||
assert.equal(documented, declared,
|
||||
`${id}: the matrix effortSurface value must match the shipped descriptor`);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user