enh(#3866): dispatch step and contribution hooks at verify:pre (#3869)

* test(#3866): pin that verify:pre must dispatch every hook kind

verify-work.md's verify_pre_hooks step dispatches only `kind == "gate"`, so
getWiredKinds reports verify:pre -> {gate} and gen-capability-registry rejects
any capability declaring a step or contribution there. The verify lane is
therefore closed to capabilities that want to contribute to what UAT covers
rather than refuse to let it start.

Failing-first: the step, contribution, and exact-kind-set rows are RED; the
pre-existing gate row is a green regression pin so the new arms cannot orphan
the arm verify:pre already had.

Refs #3866

* feat(#3866): dispatch step and contribution hooks at verify:pre

verify_pre_hooks dispatched `kind == "gate"` only, so getWiredKinds reported
verify:pre -> {gate} and gen-capability-registry's validateHooksWired rejected
any capability declaring a step or contribution there. A capability could
refuse to let UAT start; it could not contribute to what UAT covers.

Add contribution and step arms mirroring execute:wave:post, deferring to
references/loop-hook-dispatch.md and carrying its ref.command in-context
validation guard ahead of any shell-use prose. A verify:pre step is advisory:
it never blocks the start of UAT and an erroring step is routed by its own
onError. The gate arm and its check guard are untouched.

Give extract_tests an additive consumption seam for the artefacts those steps
declare via the existing steps[].produces field -- no new registry field, no
new ordering, no invented filename. Manifest-supplied artefact names are
validated in-context against an allowlist and resolved only inside PHASE_DIR.
With no producing step the derivation is unchanged, pinned by test rather than
asserted in prose.

Review findings folded in: the artefact-name allowlist (isolated adversarial
pass), the artefact-shape contract and the seam-inertness tests (spec axis),
and the reference/how-to split so one constraint has one source of truth
(standards axis).

Closes #3866

* chore(#3866): backfill changeset PR number

---------

Co-authored-by: sim <sim@local>
This commit is contained in:
Tom Boucher
2026-08-25 18:07:29 -04:00
committed by GitHub
parent 7bbbe495d7
commit 86fa2917d7
7 changed files with 216 additions and 3 deletions

View File

@@ -297,6 +297,81 @@ describe('ADR-857 phase 6 — capabilities must not bake install paths into the
}
});
// ─── #3866: the verify:pre produced-artefact seam must be strictly additive ──
//
// The lane opened at verify:pre lets a capability step produce an artefact that
// extract_tests consumes. The contract that makes that safe is that the seam is
// INERT when nothing is produced: derivation must be unchanged for every project
// that has no such capability — which is every project on `next` today. These
// assert the workflow prose an executing agent actually reads (verify-work.md is
// Markdown, not a source path, so local/no-source-grep does not apply).
test('the verify:pre produced-artefact seam is conditional, and the pre-existing derivation paths are not nested inside it (#3866)', () => {
const wf = readRepoFile('gsd-core/workflows/verify-work.md');
const seamIdx = wf.indexOf('Verify:pre produced-artefact seam');
assert.ok(seamIdx > 0, 'verify-work.md must carry the verify:pre produced-artefact seam');
// The seam must open with its own skip-when-absent guard, so an agent reading
// it top-down never falls into the merge on a project with no producing step.
const seamHead = wf.slice(seamIdx, seamIdx + 400);
assert.match(
seamHead, /VERIFY_PRE_PRODUCED/,
'the seam must name the variable it is conditional on',
);
assert.match(
seamHead, /empty or absent/,
'the seam must state the empty/absent case before describing any merge',
);
// Both pre-existing derivation paths must still exist, and must sit OUTSIDE the
// seam: the coverage classifier before it, the legacy prose fallback after it.
// If either migrated inside the seam it would become conditional on a producing
// step existing — the exact regression "byte-identical when no artefact exists"
// rules out.
const coverageIdx = wf.indexOf('uat.classify-coverage');
const legacyIdx = wf.indexOf('Extract testable deliverables from SUMMARY.md');
assert.ok(coverageIdx > 0, 'the #1602 coverage classifier must still be invoked');
assert.ok(legacyIdx > 0, 'the legacy prose-extraction fallback must still exist');
assert.ok(
coverageIdx < seamIdx,
'coverage classification must run before the seam, not inside it',
);
assert.ok(
legacyIdx > seamIdx,
'the legacy fallback must follow the seam and stay unguarded by it',
);
});
test('the verify:pre produced-artefact seam validates manifest-supplied artefact names in-context (#3866)', () => {
const wf = readRepoFile('gsd-core/workflows/verify-work.md');
const seamIdx = wf.indexOf('Verify:pre produced-artefact seam');
assert.ok(seamIdx > 0, 'verify-work.md must carry the verify:pre produced-artefact seam');
const seam = wf.slice(seamIdx, legacyEnd(wf, seamIdx));
// `produces` names come from a third-party capability manifest. The seam must
// carry an explicit in-context allowlist, the same shape loop-hook-dispatch.md
// requires of `ref.command` — not a vague "it is a name, not a path".
assert.match(
seam, /\^\[A-Za-z0-9\]\[A-Za-z0-9\._-\]\*\$/,
'the seam must pin an explicit allowlist regex for artefact names',
);
assert.match(
seam, /never\*{0,2}\s*by pasting it into a\s*\n?\s*shell command|never\*{0,2} by pasting it into a shell/,
'the seam must forbid shell-side validation of the manifest value',
);
assert.match(
seam, /\$PHASE_DIR/,
'the seam must confine resolution to the phase directory',
);
});
/** End of the seam region: the next top-level bold heading after it. */
function legacyEnd(wf, seamIdx) {
const next = wf.indexOf('**Extract testable deliverables', seamIdx);
return next > seamIdx ? next : Math.min(wf.length, seamIdx + 3000);
}
test('every declared gate check.query returns a uniform boolean `block` field', () => {
// FIX A regression guard: every gate check command must return a top-level
// boolean `block` field so the host-loop dispatch can read a single consistent