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

@@ -4997,6 +4997,59 @@ describe('#1196 — discuss loop wiring + wired-point guard', () => {
);
});
// ─── #3866: the verify lane must be open to every hook kind ────────────────
//
// verify-work.md's verify_pre_hooks step historically dispatched only
// `kind == "gate"`, so getWiredKinds reported verify:pre → {gate} and any
// capability wanting to DO something before UAT (rather than block it) was
// rejected at registry-build time. The rows below are the machine-observable
// contract: what a capability may declare at verify:pre.
test('boundary: cap declaring a verify:pre step is accepted against real getWiredKinds(ROOT) (#3866)', () => {
const cap = makeCapWithStep('verify:pre');
const { getWiredKinds } = require('../scripts/gen-loop-host-contract.cjs');
const errs = validateHooksWired(cap, getWiredKinds(ROOT));
assert.deepEqual(
errs, [],
'verify:pre must dispatch step hooks — a capability can contribute to what UAT covers, ' +
`not only refuse to let it start. Errors: ${errs.join('; ')}`,
);
});
test('boundary: cap declaring a verify:pre contribution is accepted against real getWiredKinds(ROOT) (#3866)', () => {
const cap = makeCapWithContribution('verify:pre');
const { getWiredKinds } = require('../scripts/gen-loop-host-contract.cjs');
const errs = validateHooksWired(cap, getWiredKinds(ROOT));
assert.deepEqual(
errs, [],
`verify:pre must dispatch contribution hooks. Errors: ${errs.join('; ')}`,
);
});
test('regression: cap declaring a verify:pre gate stays accepted after the step/contribution arms land (#3866)', () => {
// The pre-existing gate arm is the one behavior verify:pre already had.
// Adding arms above it must not orphan or narrow it.
const cap = makeCapWithGate('verify:pre');
const { getWiredKinds } = require('../scripts/gen-loop-host-contract.cjs');
const errs = validateHooksWired(cap, getWiredKinds(ROOT));
assert.deepEqual(
errs, [],
`the verify:pre gate arm must survive the new kind arms. Errors: ${errs.join('; ')}`,
);
});
test('verify:pre dispatch text covers exactly the three hook kinds, no more (#3866)', () => {
// Asserts the VALUE, not `.has(...)`: a scanner that over-credits (or a
// future fourth token creeping into HOOK_KINDS) fails here too.
const { getWiredKinds, HOOK_KINDS } = require('../scripts/gen-loop-host-contract.cjs');
const covered = getWiredKinds(ROOT).get('verify:pre');
assert.ok(covered, 'verify:pre must have a render-hooks call site in the host loop');
assert.deepEqual(
[...covered].sort(), [...HOOK_KINDS].sort(),
`verify:pre must cover every hook kind; got ${JSON.stringify([...covered].sort())}`,
);
});
test('invalid points (not in VALID_LOOP_POINTS) are not flagged as "unwired" (already caught by schema validator)', () => {
const cap = {
id: 'test-cap',