feat(#1137): migrate review verification hooks to capabilities (#1147)

* feat(#1137): migrate review verification hooks to capabilities

* chore(#1147): add changeset
This commit is contained in:
Tom Boucher
2026-06-12 21:24:09 -04:00
committed by GitHub
parent 44024aa535
commit 1b880fefd7
25 changed files with 951 additions and 109 deletions

View File

@@ -143,13 +143,15 @@ For each REQ-ID, determine status using all three sources:
## 5.5. Nyquist Compliance Discovery
Skip if `workflow.nyquist_validation` is explicitly `false` (absent = enabled).
Skip if the Nyquist capability is inactive.
```bash
NYQUIST_CONFIG=$(gsd_run query config-get workflow.nyquist_validation --raw --default true 2>/dev/null)
VERIFY_POST_HOOKS_JSON=$(gsd_run loop render-hooks verify:post --raw)
```
If `false`: skip entirely.
Resolve active step hooks from `VERIFY_POST_HOOKS_JSON` where `kind == "step"` and `ref.skill == "validate-phase"`.
If no active validate-phase step hook exists: skip entirely.
For each phase directory, check `*-VALIDATION.md`. If exists, parse frontmatter (`nyquist_compliant`, `wave_0_complete`).

View File

@@ -453,17 +453,22 @@ Skill(skill="gsd-execute-phase", args="${PHASE_NUM} --no-transition")
Auto-invoke code review and fix chain. Autonomous mode chains both review and fix (unlike execute-phase/quick which only suggest fix).
**Config gate:**
**Capability dispatch:**
```bash
CODE_REVIEW_ENABLED=$(gsd_run query config-get workflow.code_review 2>/dev/null || echo "true")
```
If `"false"`: display "Code review skipped (workflow.code_review=false)" and proceed to 3d.
```
Skill(skill="gsd-code-review", args="${PHASE_NUM}")
EXECUTE_POST_HOOKS_JSON=$(gsd_run loop render-hooks execute:post --raw)
```
Parse status from REVIEW.md frontmatter. If "clean" or "skipped": proceed to 3d. If findings found: auto-invoke:
Resolve active step hooks from `EXECUTE_POST_HOOKS_JSON` where `kind == "step"` and `ref.skill == "code-review"`.
If no active code-review step hook exists: display "Code review skipped (code-review capability inactive)" and proceed to 3d. This covers `workflow.code_review=false` through the Capability Registry; do not query the code-review toggle directly here.
For each active code-review step hook, dispatch the skill using the registry-provided stem:
```
Skill(skill="gsd-${ref.skill}", args="${PHASE_NUM}")
```
Parse status from REVIEW.md frontmatter. If "clean" or "skipped": proceed to 3d. If findings found after the capability-dispatched review, auto-invoke the consolidated fix entry point:
```
Skill(skill="gsd-code-review", args="${PHASE_NUM} --fix --auto")
```

View File

@@ -74,21 +74,23 @@ FIX_REPORT_PATH="${PHASE_DIR}/${PADDED_PHASE}-REVIEW-FIX.md"
</step>
<step name="check_config_gate">
Check if code review is enabled via config:
Check if code review is active via the capability registry:
```bash
CODE_REVIEW_ENABLED=$(gsd_run query config-get workflow.code_review 2>/dev/null || echo "true")
EXECUTE_POST_HOOKS_JSON=$(gsd_run loop render-hooks execute:post --raw)
```
If CODE_REVIEW_ENABLED is "false":
Resolve active step hooks from `EXECUTE_POST_HOOKS_JSON` where `kind == "step"` and `ref.skill == "code-review"`.
If no active code-review step hook exists:
```
Code review fix skipped (workflow.code_review=false in config)
Code review fix skipped (code-review capability inactive)
```
Exit workflow.
Default is true — only skip on explicit false. This check runs AFTER phase validation so invalid phase errors are shown first.
Default is active through the Capability Registry schema — only skip when the registry resolves no active code-review step hook. This check runs AFTER phase validation so invalid phase errors are shown first.
Note: This reuses the `workflow.code_review` config key rather than introducing a separate `workflow.code_review_fix` key. Rationale: fixes are meaningless without review, so a single toggle makes sense. If independent control is needed later, a separate key can be added in v2.
Note: This reuses the code-review capability activation rather than introducing a separate code-review-fix capability. Rationale: fixes are meaningless without review, so a single activation boundary makes sense. If independent control is needed later, a separate key can be added in v2.
</step>
<step name="check_review_exists">
@@ -491,7 +493,7 @@ echo "════════════════════════
<success_criteria>
- [ ] Phase validated before config gate check
- [ ] Config gate checked (workflow.code_review)
- [ ] Capability gate checked (execute:post code-review hook)
- [ ] REVIEW.md existence verified (error if missing)
- [ ] REVIEW.md status checked (skip if clean/skipped)
- [ ] Agent spawned with correct config (review_path, fix_scope, fix_report_path)

View File

@@ -73,19 +73,21 @@ fi
</step>
<step name="check_config_gate">
Check if code review is enabled via config:
Check if code review is active via the capability registry:
```bash
CODE_REVIEW_ENABLED=$(gsd_run query config-get workflow.code_review 2>/dev/null || echo "true")
EXECUTE_POST_HOOKS_JSON=$(gsd_run loop render-hooks execute:post --raw)
```
If CODE_REVIEW_ENABLED is "false":
Resolve active step hooks from `EXECUTE_POST_HOOKS_JSON` where `kind == "step"` and `ref.skill == "code-review"`.
If no active code-review step hook exists:
```
Code review skipped (workflow.code_review=false in config)
Code review skipped (code-review capability inactive)
```
Exit workflow.
Default is true — only skip on explicit false. This check runs AFTER phase validation so invalid phase errors are shown first.
Default is active through the Capability Registry schema — only skip when the registry resolves no active code-review step hook. This check runs AFTER phase validation so invalid phase errors are shown first.
</step>
<step name="resolve_depth">
@@ -678,7 +680,7 @@ If `--files` validation fails unexpectedly on macOS, install coreutils or use ab
<success_criteria>
- [ ] Phase validated before config gate check
- [ ] Config gate checked (workflow.code_review)
- [ ] Capability gate checked (execute:post code-review hook)
- [ ] --fix/--all/--auto flags parsed via code-review-flags.cjs typed IR (not ad-hoc bash)
- [ ] Depth resolved with validation (quick|standard|deep)
- [ ] File scope computed with 3 tiers: --files > SUMMARY.md > git diff

View File

@@ -1061,20 +1061,22 @@ After all waves:
**Security gate check:**
```bash
SECURITY_CFG=$(gsd_run query config-get workflow.security_enforcement --raw 2>/dev/null || echo "true")
VERIFY_POST_HOOKS_JSON=$(gsd_run loop render-hooks verify:post --raw)
SECURITY_FILE=$(ls "${PHASE_DIR}"/*-SECURITY.md 2>/dev/null | head -1)
```
If `SECURITY_CFG` is `false`: skip.
Resolve active step hooks from `VERIFY_POST_HOOKS_JSON` where `kind == "step"` and `ref.skill == "secure-phase"`.
If `SECURITY_CFG` is `true` AND `SECURITY_FILE` is empty (no SECURITY.md yet):
If no active secure-phase step hook exists: skip.
If an active secure-phase step hook exists AND `SECURITY_FILE` is empty (no SECURITY.md yet):
Include in the next-steps routing output:
```
⚠ Security enforcement enabled — run before advancing:
/gsd:secure-phase {PHASE} ${GSD_WS}
```
If `SECURITY_CFG` is `true` AND SECURITY.md exists: check frontmatter `threats_open`. If > 0:
If an active secure-phase step hook exists AND SECURITY.md exists: check frontmatter `threats_open`. If > 0:
```
⚠ Security gate: {threats_open} threats open
/gsd:secure-phase {PHASE} — resolve before advancing
@@ -1166,18 +1168,20 @@ Selected wave finished successfully. This phase still has incomplete plans, so p
</step>
<step name="code_review_gate" required="true">
**This step is REQUIRED and must not be skipped.** Auto-invoke code review on the phase's source changes. Advisory only — never blocks execution flow.
**This step is REQUIRED to evaluate the capability hook.** When the code-review capability is active, auto-invoke code review on the phase's source changes. Advisory only — never blocks execution flow.
**Config gate:**
**Capability gate:**
```bash
CODE_REVIEW_ENABLED=$(gsd_run query config-get workflow.code_review 2>/dev/null || echo "true")
EXECUTE_POST_HOOKS_JSON=$(gsd_run loop render-hooks execute:post --raw)
```
If `CODE_REVIEW_ENABLED` is `"false"`: display "Code review skipped (workflow.code_review=false)" and proceed to next step.
Resolve active step hooks from `EXECUTE_POST_HOOKS_JSON` where `kind == "step"` and `ref.skill == "code-review"`.
If no active code-review step hook exists: display "Code review skipped (code-review capability inactive)" and proceed to next step.
**Invoke review:**
```
Skill(skill="gsd-code-review", args="${PHASE_NUMBER}")
Skill(skill="gsd-${ref.skill}", args="${PHASE_NUMBER}")
```
**Check results using deterministic path (not glob):**

View File

@@ -577,17 +577,19 @@ test -f "${PHASE_DIR}/${PADDED_PHASE}-VALIDATION.md" && echo "VALIDATION_CREATED
## 5.55. Security Threat Model Gate
> Skip if `workflow.security_enforcement` is explicitly `false`. Absent = enabled.
> Capability-driven dispatch. Resolves active `plan:pre` hooks via the capability registry; the security hook's `when` condition is evaluated by the registry.
```bash
SECURITY_CFG=$(gsd_run query config-get workflow.security_enforcement --raw 2>/dev/null || echo "true")
PLAN_PRE_HOOKS_JSON=$(gsd_run loop render-hooks plan:pre --raw)
SECURITY_ASVS=$(gsd_run query config-get workflow.security_asvs_level --raw 2>/dev/null || echo "1")
SECURITY_BLOCK=$(gsd_run query config-get workflow.security_block_on --raw 2>/dev/null || echo "high")
```
**If `SECURITY_CFG` is `false`:** Skip to step 5.6.
Resolve active contribution hooks from `PLAN_PRE_HOOKS_JSON` where `kind == "contribution"` and `capId == "security"`.
**If `SECURITY_CFG` is `true`:** Display banner:
**If no active security contribution hook exists:** Skip to step 5.6.
**If an active security contribution hook exists:** Display banner:
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

View File

@@ -776,11 +776,14 @@ Note: For quick tasks producing multiple plans (rare), spawn executors in parall
Skip this step entirely if `$FULL_MODE` is false.
**Config gate:**
**Capability gate:**
```bash
CODE_REVIEW_ENABLED=$(gsd_run query config-get workflow.code_review 2>/dev/null || echo "true")
EXECUTE_POST_HOOKS_JSON=$(gsd_run loop render-hooks execute:post --raw)
```
If `"false"`, skip with message "Code review skipped (workflow.code_review=false)".
Resolve active step hooks from `EXECUTE_POST_HOOKS_JSON` where `kind == "step"` and `ref.skill == "code-review"`.
If no active code-review step hook exists, skip with message "Code review skipped (code-review capability inactive)".
**Scope files from executor's commits:**
```bash

View File

@@ -26,10 +26,12 @@ Parse: `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `padded_phase`.
```bash
AUDITOR_MODEL=$(gsd_run query resolve-model gsd-security-auditor --raw)
SECURITY_CFG=$(gsd_run query config-get workflow.security_enforcement --raw 2>/dev/null || echo "true")
VERIFY_POST_HOOKS_JSON=$(gsd_run loop render-hooks verify:post --raw)
```
If `SECURITY_CFG` is `false`: exit with "Security enforcement disabled. Enable via /gsd:settings."
Resolve active step hooks from `VERIFY_POST_HOOKS_JSON` where `kind == "step"` and `ref.skill == "secure-phase"`.
If no active secure-phase step hook exists: exit with "Security enforcement disabled. Enable via /gsd:settings."
Display banner: `GSD > SECURE PHASE {N}: {name}`

View File

@@ -26,10 +26,12 @@ Parse: `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `padded_phase`.
```bash
AUDITOR_MODEL=$(gsd_run query resolve-model gsd-nyquist-auditor --raw)
NYQUIST_CFG=$(gsd_run query config-get workflow.nyquist_validation --raw --default true)
VERIFY_POST_HOOKS_JSON=$(gsd_run loop render-hooks verify:post --raw)
```
If `NYQUIST_CFG` is `false`: exit with "Nyquist validation is disabled. Enable via /gsd:settings."
Resolve active step hooks from `VERIFY_POST_HOOKS_JSON` where `kind == "step"` and `ref.skill == "validate-phase"`.
If no active validate-phase step hook exists: exit with "Nyquist validation is disabled. Enable via /gsd:settings."
Display banner: `GSD > VALIDATE PHASE {N}: {name}`

View File

@@ -457,16 +457,31 @@ Present summary:
**If issues == 0:**
```bash
SECURITY_CFG=$(gsd_run query config-get workflow.security_enforcement --raw 2>/dev/null || echo "true")
VERIFY_POST_HOOKS_JSON=$(gsd_run loop render-hooks verify:post --raw)
SECURITY_FILE=$(ls "${PHASE_DIR}"/*-SECURITY.md 2>/dev/null | head -1)
```
If `SECURITY_CFG` is `true` AND `SECURITY_FILE` is empty:
```
⚠ Security enforcement enabled — /gsd:secure-phase {phase} has not run.
Run before advancing to the next phase.
Resolve active step hooks from `VERIFY_POST_HOOKS_JSON` where `kind == "step"` and `ref.skill == "secure-phase"`.
All tests passed. Ready to continue.
If an active secure-phase step hook exists AND `SECURITY_FILE` is empty, dispatch the registry-provided skill stem:
```
Skill(skill="gsd-${ref.skill}", args="{phase}")
```
After the skill returns, refresh `SECURITY_FILE`:
```bash
SECURITY_FILE=$(ls "${PHASE_DIR}"/*-SECURITY.md 2>/dev/null | head -1)
```
If `SECURITY_FILE` is still empty, stop before phase advancement and present:
```
⚠ Security enforcement enabled — /gsd:secure-phase {phase} did not produce SECURITY.md.
Resolve the security review failure before advancing to the next phase.
All tests passed, but phase advancement is blocked until security review produces SECURITY.md.
- `/gsd:secure-phase {phase}` — security review (required before advancing)
- `/gsd:plan-phase {next}` — Plan next phase
@@ -474,13 +489,13 @@ All tests passed. Ready to continue.
- `/gsd:ui-review {phase}` — visual quality audit (if frontend files were modified)
```
If `SECURITY_CFG` is `true` AND `SECURITY_FILE` exists: check frontmatter `threats_open`. If > 0:
If an active secure-phase step hook exists AND `SECURITY_FILE` exists: check frontmatter `threats_open`. If > 0:
```
⚠ Security gate: {threats_open} threats open
/gsd:secure-phase {phase} — resolve before advancing
```
If `SECURITY_CFG` is `false` OR (`SECURITY_FILE` exists AND `threats_open` is `0`):
If no active secure-phase step hook exists OR (`SECURITY_FILE` exists AND `threats_open` is `0`):
**Auto-transition: mark phase complete in ROADMAP.md and STATE.md**