* test(#3335): fold the workflow-content & phase-lifecycle fix-* cluster — Wave 3 Folds 13 legacy fix-*.test.cjs regression files (131 test() blocks) into their module's main suite, per H3 (#3315) of the test-hygiene epic (#3053): - 6 files with no prior target coverage: renamed (git mv) into new suites (spike-manifest-scoping, ship-note, add-todo, workflow-jq-dependency, resolve-execution-dynamic-routing, clock) - 7 files merged into 5 pre-existing suites (worktree-base-ref x2, model-resolver, phase-locator x2, frontmatter, verification-status), deduplicated against existing coverage Zero net test-coverage loss: every source assertion preserved or verified as a genuine pre-existing duplicate. No production code changed. Last fix-* wave (Wave 1 #3341, Wave 2 #3342 already merged); 4 issue-* waves remain in #3315. * test(#3335): fix orthogonal-review findings — Wave 3 fold Standards-axis review + Memtrace graph pass found real defects in the just-folded suites, all fixed here: - phase-locator.test.cjs: pinned an unseeded fast-check property test (CONTRIBUTING.md determinism requirement), matching the sibling test's seed:7 convention. - phase-locator.test.cjs: added assert.ok() presence guards after 9 data.plans.find() calls that were dereferenced unguarded, inconsistent with 5 sibling tests in the same file that already guard correctly. Latent robustness gap — an omitted plan would throw an opaque TypeError instead of a clear assertion failure. - Standardized the fold-wrapper convention (block-scoped __foldDescribe) across worktree-base-ref.test.cjs, verification-status.test.cjs, and phase-locator.test.cjs to match the pattern already established in frontmatter.test.cjs and model-resolver.test.cjs from earlier folds. - worktree-base-ref.test.cjs: moved a mid-file require to the top-of-file require block. - Eliminated duplicated env-isolation helpers: model-resolver.test.cjs and phase-locator.test.cjs each reimplemented GSD_WORKSTREAM/GSD_PROJECT save-restore independently; factored a shared isolateWorkstreamEnv()/ restoreWorkstreamEnv() into tests/helpers.cjs and pointed both call sites at it. No test() count changed in any file. No production code touched. --------- Co-authored-by: sim <sim@local>
This commit is contained in:
@@ -1201,3 +1201,120 @@ describe('#2868: verification status CLI drives the execute-phase stranded-phase
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
{
|
||||
const { describe: __foldDescribe } = require('node:test');
|
||||
__foldDescribe('folded:fix-3174-quick-verification-status-read', () => {
|
||||
// allow-test-rule: source-text-is-the-product see #3174
|
||||
// Workflow .md / agent .md / command .md / reference .md files — their text
|
||||
// IS what the runtime loads. Testing text content tests the deployed contract.
|
||||
// Per CONTRIBUTING.md exception matrix.
|
||||
//
|
||||
// #3174: quick's verification step used to read the verifier's result with a
|
||||
// raw `grep "^status:" F | cut -d: -f2 | tr -d ' '` and route it through arms
|
||||
// passed / human_needed / gaps_found only. That read failed two ways, both
|
||||
// measured against the old pipeline: it matched NO arm on a missing report,
|
||||
// most off-schema values, a `status:` line in both frontmatter and prose, or
|
||||
// (on a CRLF checkout) a valid `passed` arriving as `passed\r`; and it
|
||||
// matched the SUCCESS arm when it should not have on a stale `passed`
|
||||
// report (staleness was never evaluated), a report whose only `status:` line
|
||||
// sits in its prose, or an off-schema value carrying a colon
|
||||
// (`passed:bogus`), which `cut -d: -f2` splits at that colon. The unanchored
|
||||
// match is the DEFECT.FRONTMATTER-SCALAR-BROAD-GREP class the code side
|
||||
// already fixed by name. These tests pin the five properties that keep the
|
||||
// replacement honest.
|
||||
describe('quick verification status read (#3174)', () => {
|
||||
const QUICK_VERIFICATION = path.join(
|
||||
__dirname, '..', 'gsd-core', 'workflows', 'quick', 'steps', 'quick-verification.md',
|
||||
);
|
||||
// The canonical launcher preamble. scripts/sync-runtime-launcher.cjs rewrites
|
||||
// every workflow's bootstrap from this file, so THIS is the authority — not
|
||||
// whichever sibling step file happens to carry a copy today.
|
||||
const LAUNCHER_SNIPPET = path.join(
|
||||
__dirname, '..', 'gsd-core', 'workflows', '_runtime-launcher.snippet.sh',
|
||||
);
|
||||
|
||||
const SHIM_ANCHOR = '_GSD_SHIM_NAME="gsd-tools.cjs"';
|
||||
|
||||
test('status is read through the canonical query, not a raw frontmatter grep', () => {
|
||||
const content = fs.readFileSync(QUICK_VERIFICATION, 'utf-8');
|
||||
const queryIdx = content.indexOf('gsd_run query verification.status "${QUICK_DIR}"');
|
||||
|
||||
assert.ok(queryIdx !== -1, 'quick-verification.md must read status via the verification.status query');
|
||||
assert.ok(
|
||||
!content.includes('grep "^status:"'),
|
||||
'the raw frontmatter-scalar grep must not return — it matches body lines too (DEFECT.FRONTMATTER-SCALAR-BROAD-GREP)',
|
||||
);
|
||||
});
|
||||
|
||||
test('the query call is preceded by the runtime shim bootstrap in this step file', () => {
|
||||
// Step files are read and executed as their own units, so quick.md's
|
||||
// bootstrap does not reach here. Without this the call resolves to
|
||||
// nothing, 2>/dev/null swallows it, and the default arm is taken forever.
|
||||
const content = fs.readFileSync(QUICK_VERIFICATION, 'utf-8');
|
||||
const shimIdx = content.indexOf(SHIM_ANCHOR);
|
||||
const queryIdx = content.indexOf('gsd_run query verification.status');
|
||||
|
||||
assert.ok(shimIdx !== -1, 'the step file must carry its own runtime shim bootstrap');
|
||||
assert.ok(queryIdx > shimIdx, 'the shim bootstrap must precede the gsd_run call');
|
||||
});
|
||||
|
||||
test('the shim bootstrap is the canonical launcher preamble, not a fork of it', () => {
|
||||
// Anchored on _runtime-launcher.snippet.sh rather than on a sibling step
|
||||
// file: sync-runtime-launcher.cjs regenerates every workflow from the
|
||||
// snippet, so a synchronized launcher update keeps this green (correct),
|
||||
// and a sibling that legitimately stops calling gsd_run cannot fail us.
|
||||
const lineWithShim = (file) => fs.readFileSync(file, 'utf-8')
|
||||
.split(/\r?\n/)
|
||||
.find((line) => line.startsWith(SHIM_ANCHOR));
|
||||
|
||||
const mine = lineWithShim(QUICK_VERIFICATION);
|
||||
const canonical = lineWithShim(LAUNCHER_SNIPPET);
|
||||
|
||||
assert.ok(canonical, '_runtime-launcher.snippet.sh must carry the canonical preamble');
|
||||
assert.equal(mine, canonical, 'the bootstrap must match the canonical launcher snippet verbatim');
|
||||
});
|
||||
|
||||
test('status extraction does not depend on jq', () => {
|
||||
// #2589: a `| jq -r '.field'` pipe yields an empty variable with no
|
||||
// diagnostic wherever jq is absent (the Windows/Git-Bash default), which
|
||||
// would route a passing verification into the recovery arm.
|
||||
//
|
||||
// Scoped to the executable fence on purpose: the surrounding prose cites
|
||||
// the jq form in order to explain why it is not used, and an assertion
|
||||
// over the whole file would fire on its own rationale.
|
||||
const content = fs.readFileSync(QUICK_VERIFICATION, 'utf-8');
|
||||
const fences = content.match(/```bash\r?\n[\s\S]*?```/g) || [];
|
||||
const statusFence = fences.find((f) => f.includes('gsd_run query verification.status'));
|
||||
|
||||
assert.ok(statusFence, 'the status read must live in a bash fence');
|
||||
assert.ok(
|
||||
statusFence.includes('--pick status'),
|
||||
'the bare status must be picked by the query itself',
|
||||
);
|
||||
assert.ok(!/\|\s*jq\b/.test(statusFence), 'the status-read fence must not pipe through jq');
|
||||
});
|
||||
|
||||
test('the routing table carries a terminal arm for missing / unknown / stale', () => {
|
||||
const content = fs.readFileSync(QUICK_VERIFICATION, 'utf-8');
|
||||
const gapsIdx = content.indexOf('| `gaps_found` |');
|
||||
const fallbackIdx = content.indexOf('| anything else');
|
||||
|
||||
assert.ok(gapsIdx !== -1, 'the three verifier-status arms must remain');
|
||||
assert.ok(fallbackIdx > gapsIdx, 'a terminal arm must follow the verifier-status arms');
|
||||
|
||||
const fallbackRow = content.slice(fallbackIdx, content.indexOf('\n', fallbackIdx));
|
||||
for (const sentinel of ['missing', 'unknown', 'stale']) {
|
||||
assert.ok(
|
||||
fallbackRow.includes(sentinel),
|
||||
`the terminal arm must name the ${sentinel} sentinel the query can return`,
|
||||
);
|
||||
}
|
||||
assert.ok(
|
||||
fallbackRow.includes('VERIFICATION_STATUS'),
|
||||
'the terminal arm must set the display string consumed by the quick index row and banner',
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user