fix(#1522): enforce canonical verification before phase transition (#1548)

* fix: require fresh phase verification before transition

* no-mistakes(review): Fix canonical verification closeout gates

* no-mistakes(review): Fix verify-work frontmatter promotion command

* no-mistakes(review): Fix stale verification gates

* no-mistakes(review): Fix canonical verification routing gates

* no-mistakes(review): Fix verification dependency and runtime routing gates

* no-mistakes(review): Block stale verification bypasses

* fix: handle large init manager outputs in verification workflows

* chore: update changeset pr number

* fix(verify-work): use fresh verification.status for stale gate

The stale check after UAT used phase_completion.verification_status from
session-start INIT while human_needed promotion already queried fresh
verification.status. Align the stale gate with the canonical query so
mid-session verification refresh is not ignored.

* fix(init): skip roadmap-checked phases when selecting next_phase

Roadmap-only phases without a disk directory were still promoted to
next_phase when their checkbox was already checked. Exclude
checkboxComplete phases so progress routing does not point at work the
roadmap already marks done.

* fix: gaps_found not overridden by stale, transition uses canonical verification

- verification.cts: check gaps_found before stale so gap-closure routing
  is not masked by a newer summary mtime
- phase.cts: remove redundant findStaleVerificationSummary — readVerificationStatus
  already handles stale detection
- transition.md: replace raw grep on file content with verification.status query
  to avoid false-positive blocks from body text matching

* ci: retrigger tests after rebase

* fix(transition): replace gsd_run advisory check with awk frontmatter extraction

The runtime launcher is not defined until the update_roadmap_and_state step
bash block (~line 165). The early verify_completion block used gsd_run to
query verification.status, which violated the runtime-launcher-parity test:
'preamble appears AFTER the first gsd_run reference'.

Replace the gsd_run call with an awk-based frontmatter extractor that reads
only the status: field between the two --- fences. This avoids both the
preamble-ordering constraint and the original false-positive grep bug where
body text like 'previous_status: gaps_found' would match a full-text regex.

The phase.complete gate at update_roadmap_and_state is the canonical
enforcement point; this early check is advisory only.

Also update workflow-size-baseline.json for the updated transition.md size.

Fixes: runtime-launcher-parity test (B)

Co-authored-by: Codesmith <codesmith-bot@users.noreply.github.com>

* fix: re-check verification under planning lock in phase complete

Move readVerificationStatus into withPlanningLock so stale verification
cannot slip through when a SUMMARY.md is written between the gate and
the roadmap/state mutation. Return the blocked status from the lock
callback and emit the error after release to avoid leaving .lock behind.

* fix(transition): gate on canonical verification.status including stale

Replace awk frontmatter read with verification.status query so transition
blocks when summaries are newer than VERIFICATION.md, matching phase.complete
and other workflows (autonomous, progress, verify-work).

* Fix workflow verification gates for yolo transition and stale routing

Require VERIFY_STATUS passed before yolo/interactive transition advance.
Route stale verification recovery to verify-work, matching canonical projection.

* fix(transition): use verification.status query for stale-aware advisory check

The awk-based check read raw frontmatter status: passed, which misses the
stale case where summaries are newer than the VERIFICATION.md file even
though the frontmatter still says passed. The stale status is computed from
file modification times, not stored in frontmatter.

Move the preamble to the verify_completion bash block (the first block with
a gsd_run call) so gsd_run query verification.status can be used for the
advisory check. This gives the full readVerificationStatus logic including
mtime-based staleness detection, matching the enforcement gate at phase.complete.

Capture full JSON (VERIFY_JSON) so next_action can be included in the
advisory output alongside the status.

Also update workflow-size-baseline.json for the updated transition.md size.

Co-authored-by: Codesmith <codesmith-bot@users.noreply.github.com>

* ci: trigger test matrix for 525b946

Co-authored-by: Codesmith <codesmith-bot@users.noreply.github.com>

* fix(transition): restore awk frontmatter extraction for pre-shim verification check

The gsd_run launcher shim is not defined until line ~163 of transition.md,
so the verification debt check at line ~80 cannot use gsd_run. Restore the
awk-based frontmatter extraction that correctly reads status without needing
the runtime, and restore the shim at its proper location before
phase.complete.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(#1522): clarify transition verification gate wording

* fix(#1522): update transition workflow size baseline

* fix(#1522): update workflow-size-baseline after rebase onto next

Co-authored-by: Codesmith <codesmith-bot@users.noreply.github.com>

* fix(#1522): guard findStaleVerificationSummary FS calls + thread opts.fs seam (review)

Address review blocker B1 on #1548: findStaleVerificationSummary ran fs.readdirSync
and two fs.statSync calls unguarded between readVerificationStatus's try/catch sections,
so a TOCTOU race (a SUMMARY listed by scanPhasePlans then removed before statSync) or any
FS error threw uncaught into callers NOT under the planning lock (init.manager /
init.progress / uat-predicate). Wrap the body in try/catch degrading to 'not stale', and
thread the injectable opts.fs seam (add statSync to FsLike, pass fsImpl from the caller)
for parity with readVerificationStatus's no-throw contract and testability. Also adds the
Verification Module glossary entry to CONTEXT.md (review B3).

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Codesmith <codesmith-bot@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Tom Boucher <trekkie@nomorestars.com>
This commit is contained in:
Jeremy McSpadden
2026-06-24 12:19:10 -05:00
committed by GitHub
parent eef8f9b8c3
commit 77c7b4fc9d
36 changed files with 1354 additions and 209 deletions

View File

@@ -61,7 +61,7 @@ fi
When `--only` is set, also set `FROM_PHASE` to the same value so existing filter logic applies.
When `--interactive` is set, discuss runs inline with questions (not auto-answered). On Codex, where a backgrounded agent can still spawn subagents, plan and execute are dispatched as background agents — keeping the main context lean (only discuss conversations accumulate) and enabling overlap. On every other runtime (Claude Code and all other non-Codex runtimes), backgrounded agents cannot reliably nest subagents, so plan and execute run inline to preserve worktree isolation and independent verification, and phases run sequentially with their work accumulating in the main context. Either way, user input is preserved on all design decisions.
When `--interactive` is set, discuss runs inline with questions. On Codex, where a backgrounded agent can still spawn subagents, plan and execute are dispatched as background agents — keeping the main context lean (only discuss conversations accumulate) and enabling overlap. On every other runtime (Claude Code and all other non-Codex runtimes), backgrounded agents cannot reliably nest subagents, so plan and execute run inline to preserve worktree isolation and independent verification, and phases run sequentially with their work accumulating in the main context. Either way, user input is preserved on all design decisions.
When `PLAN_STRATEGY=converge`, the planning step MUST invoke the plan-review convergence workflow instead of `gsd-plan-phase`. `--cross-ai` is an alias for `--converge`. Forward `CONVERGENCE_ARGS` exactly as parsed so reviewer flags and `--max-cycles N` retain the same meaning as they have on `/gsd:plan-review-convergence`.
@@ -123,18 +123,19 @@ If `PLAN_STRATEGY` is `converge`, display: `Planning: Plan-review convergence en
Run phase discovery:
```bash
ROADMAP=$(gsd_run query roadmap.analyze)
INIT_MANAGER=$(gsd_run query init.manager)
if [[ "$INIT_MANAGER" == @file:* ]]; then INIT_MANAGER=$(cat "${INIT_MANAGER#@file:}"); fi
```
Parse the JSON `phases` array.
**Filter to incomplete phases:** Keep only phases where `disk_status !== "complete"` OR `roadmap_complete === false`.
**Filter to incomplete phases:** Keep `phase_complete !== true`, including implemented phases with `verification_status !== "passed"`.
**Apply `--from N` filter:** If `FROM_PHASE` was provided, additionally filter out phases where `number < FROM_PHASE` (use numeric comparison — handles decimal phases like "5.1").
**Apply `--from N`:** If set, filter out phases where `number < FROM_PHASE` (numeric compare; handles "5.1").
**Apply `--to N` filter:** If `TO_PHASE` was provided, additionally filter out phases where `number > TO_PHASE` (use numeric comparison). This limits execution to phases up through the target phase.
**Apply `--to N`:** If set, filter out phases where `number > TO_PHASE` (numeric compare).
**Apply `--only N` filter:** If `ONLY_PHASE` was provided, additionally filter OUT phases where `number != ONLY_PHASE`. This means the phase list will contain exactly one phase (or zero if already complete).
**Apply `--only N`:** If set, filter out phases where `number != ONLY_PHASE`.
**If `TO_PHASE` is set and no phases remain** (all phases up to N are already completed):
@@ -477,58 +478,51 @@ Skill(skill="gsd-code-review", args="${PHASE_NUM} --fix --auto")
**3d. Post-Execution Routing**
**If `INTERACTIVE` is set:** Wait for the execute agent to complete before reading verification results.
After execute-phase returns (or the execute agent completes), read the verification result:
After execute, read canonical verification:
```bash
VERIFY_STATUS=$(grep "^status:" "${PHASE_DIR}"/*-VERIFICATION.md 2>/dev/null | head -1 | cut -d: -f2 | tr -d ' ')
VERIFY_STATUS=$(gsd_run query verification.status "${PHASE_DIR}" 2>/dev/null | jq -r '.status//empty')
```
Where `PHASE_DIR` comes from the `init phase-op` call already made in step 3a. If the variable is not in scope, re-fetch:
If `PHASE_DIR` is absent, re-fetch `init.phase-op ${PHASE_NUM}` and parse `phase_dir`.
```bash
PHASE_STATE=$(gsd_run query init.phase-op ${PHASE_NUM})
```
Parse `phase_dir` from the JSON.
**If VERIFY_STATUS is empty** (no VERIFICATION.md or no status field):
Go to handle_blocker: "Execute phase ${PHASE_NUM} did not produce verification results."
If `VERIFY_STATUS` is empty, handle_blocker: "No verification results for phase ${PHASE_NUM}."
**If `passed`:**
Display:
```
Phase ${PHASE_NUM} ✅ ${PHASE_NAME} — Verification passed
```
Display `Phase ${PHASE_NUM} ✅ ${PHASE_NAME} — Verification passed`, run `@~/.claude/gsd-core/workflows/transition.md`, then Proceed to iterate step.
Proceed to iterate step.
**If `stale`:** handle_blocker: "Stale verification for phase ${PHASE_NUM}."
**If `human_needed`:**
Read the human_verification section from VERIFICATION.md to get the count and items requiring manual testing.
**Text mode (`workflow.text_mode: true` in config or `--text` flag):** Set `TEXT_MODE=true` if `--text` is present in `$ARGUMENTS` OR `text_mode` from init JSON is `true`. When TEXT_MODE is active, replace every `AskUserQuestion` call with a plain-text numbered list and ask the user to type their choice number. This is required for non-Claude runtimes (OpenAI Codex, Gemini CLI, etc.) where `AskUserQuestion` is not available.
Display the items, then ask user via AskUserQuestion:
Read `human_verification` items. In text mode (`--text` or init `text_mode=true`), replace AskUserQuestion with a numbered list and typed choice. Otherwise display items and ask:
- **question:** "Phase ${PHASE_NUM} has items needing manual verification. Validate now or continue to next phase?"
- **options:** "Validate now" / "Continue without validation"
On **"Validate now"**: Present the specific items from VERIFICATION.md's human_verification section. After user reviews, ask:
On **"Validate now"**: Present items, then ask:
- **question:** "Validation result?"
- **options:** "All good — continue" / "Found issues"
On "All good — continue": Display `Phase ${PHASE_NUM} ✅ Human validation passed` and proceed to iterate step.
On "All good — continue": set VERIFICATION frontmatter `status: passed`, display `Phase ${PHASE_NUM} ✅ Human validation passed`, run `@~/.claude/gsd-core/workflows/transition.md`, then iterate.
On "Found issues": Go to handle_blocker with the user's reported issues as the description.
On **"Continue without validation"**: Display `Phase ${PHASE_NUM} ⏭ Human validation deferred` and proceed to iterate step.
On **"Continue without validation"**: record an explicit deferred state and stop autonomous mode:
```markdown
## Deferred Verification
| Phase | State | Resume |
|-------|-------|--------|
| ${PHASE_NUM} | verification_deferred_human | /gsd:verify-work ${PHASE_NUM} |
```
Append/update this STATE.md section, display `Phase ${PHASE_NUM} ⏭ verification_deferred_human — resume with /gsd:verify-work ${PHASE_NUM}`, then handle_blocker: "Human verification deferred for phase ${PHASE_NUM}."
**If `gaps_found`:**
Read gap summary from VERIFICATION.md (score and missing items). Display:
Read gap score/items from VERIFICATION.md. Display:
```
⚠ Phase ${PHASE_NUM}: ${PHASE_NAME} — Gaps Found
Score: {N}/{M} must-haves verified
@@ -538,13 +532,13 @@ Ask user via AskUserQuestion:
- **question:** "Gaps found in phase ${PHASE_NUM}. How to proceed?"
- **options:** "Run gap closure" / "Continue without fixing" / "Stop autonomous mode"
On **"Run gap closure"**: Execute gap closure cycle (limit: 1 attempt):
On **"Run gap closure"**: one gap-closure attempt:
```
Skill(skill="gsd-plan-phase", args="${PHASE_NUM} --gaps")
```
Verify gap plans were created — re-run `init phase-op ${PHASE_NUM}` and check `has_plans`. If no new gap plans → go to handle_blocker: "Gap closure planning for phase ${PHASE_NUM} did not produce plans."
Re-run `init phase-op ${PHASE_NUM}`; if `has_plans` is false, handle_blocker: "Gap closure planning for phase ${PHASE_NUM} did not produce plans."
Re-execute:
```
@@ -553,27 +547,39 @@ Skill(skill="gsd-execute-phase", args="${PHASE_NUM} --no-transition")
Re-read verification status:
```bash
VERIFY_STATUS=$(grep "^status:" "${PHASE_DIR}"/*-VERIFICATION.md 2>/dev/null | head -1 | cut -d: -f2 | tr -d ' ')
VERIFY_STATUS=$(gsd_run query verification.status "${PHASE_DIR}" 2>/dev/null | jq -r '.status//empty')
```
If `passed` or `human_needed`: Route normally (continue or ask user as above).
If `passed` or `human_needed`: route normally.
If `stale`: handle_blocker: "Stale verification for phase ${PHASE_NUM}."
If still `gaps_found` after this retry: Display "Gaps persist after closure attempt." and ask via AskUserQuestion:
- **question:** "Gap closure did not fully resolve issues. How to proceed?"
- **options:** "Continue anyway" / "Stop autonomous mode"
On "Continue anyway": Proceed to iterate step.
On "Continue anyway": record `verification_deferred_gaps` using the table below, display `Phase ${PHASE_NUM} ⏭ verification_deferred_gaps — resume with /gsd:plan-phase ${PHASE_NUM} --gaps`, then handle_blocker: "Verification gaps deferred for phase ${PHASE_NUM}."
On "Stop autonomous mode": Go to handle_blocker.
This limits gap closure to 1 automatic retry to prevent infinite loops.
This limits gap closure to 1 retry.
On **"Continue without fixing"**: Display `Phase ${PHASE_NUM} ⏭ Gaps deferred` and proceed to iterate step.
On **"Continue without fixing"**: record an explicit deferred state and stop autonomous mode:
```markdown
## Deferred Verification
| Phase | State | Resume |
|-------|-------|--------|
| ${PHASE_NUM} | verification_deferred_gaps | /gsd:plan-phase ${PHASE_NUM} --gaps |
```
Append/update this STATE.md section, display `Phase ${PHASE_NUM} ⏭ verification_deferred_gaps — resume with /gsd:plan-phase ${PHASE_NUM} --gaps`, then handle_blocker: "Verification gaps deferred for phase ${PHASE_NUM}."
On **"Stop autonomous mode"**: Go to handle_blocker with "User stopped — gaps remain in phase ${PHASE_NUM}".
**3d.5. UI Review (Frontend Phases)**
> Run after any successful execution routing (passed, human_needed accepted, or gaps deferred/accepted) — before proceeding to the iterate step.
> Run only after `passed` or human verification was updated to `passed`.
Resolve the active post-verification hooks and the UI-SPEC gate:
@@ -632,16 +638,17 @@ Read and execute: `$HOME/.claude/gsd-core/references/autonomous-smart-discuss.md
Resume with: /gsd:autonomous --from ${next_incomplete_phase}
```
Proceed directly to lifecycle step (which handles partial completion — skips audit/complete/cleanup since not all phases are done). Exit cleanly.
Proceed to lifecycle step (partial completion skips audit/complete/cleanup). Exit cleanly.
**Otherwise:** After each phase completes, re-read ROADMAP.md to catch phases inserted mid-execution (decimal phases like 5.1):
**Otherwise:** After each phase, re-read manager projection:
```bash
ROADMAP=$(gsd_run query roadmap.analyze)
INIT_MANAGER=$(gsd_run query init.manager)
if [[ "$INIT_MANAGER" == @file:* ]]; then INIT_MANAGER=$(cat "${INIT_MANAGER#@file:}"); fi
```
Re-filter incomplete phases using the same logic as discover_phases:
- Keep phases where `disk_status !== "complete"` OR `roadmap_complete === false`
- Keep phases where `phase_complete !== true` or `verification_status !== "passed"`
- Apply `--from N` filter if originally provided
- Apply `--to N` filter if originally provided
- Sort by number ascending

View File

@@ -72,27 +72,44 @@ If user chooses [A] (Acknowledge):
...
```
Sanitize all slug and status values via `sanitizeForDisplay()` before writing. Never inject raw file content into STATE.md.
3. Record in MILESTONES.md entry: `Known deferred items at close: {count} (see STATE.md Deferred Items)`
3. Set `closeout_type=override_closeout` and record `Known verification overrides: {count} (see STATE.md Deferred Items)` in the MILESTONES.md entry.
4. Proceed with milestone close.
If output shows all clear (no open items): print `All artifact types clear.` and proceed.
If output shows all clear (no open items): set `closeout_type=verified_closeout`, print `All artifact types clear.`, and proceed.
SECURITY: Audit JSON output is structured data from the `audit-open` query handler (same JSON contract as legacy `gsd-tools.cjs audit-open`) — validated and sanitized at source. When writing to STATE.md, item slugs and descriptions are sanitized via `sanitizeForDisplay()` before inclusion. Never inject raw user-supplied content into STATE.md without sanitization.
</step>
<step name="verify_readiness">
**Use `roadmap analyze` for comprehensive readiness check:**
**Use `init.manager` for canonical readiness check:**
```bash
ROADMAP=$(gsd_run query roadmap.analyze)
INIT_MANAGER=$(gsd_run query init.manager)
if [[ "$INIT_MANAGER" == @file:* ]]; then INIT_MANAGER=$(cat "${INIT_MANAGER#@file:}"); fi
```
This returns all phases with plan/summary counts and disk status. Use this to verify:
This returns all phases with implementation and verification projection. Use this to verify:
- Which phases belong to this milestone?
- All phases complete (all plans have summaries)? Check `disk_status === 'complete'` for each.
- `all_phases_verified`: all milestone phases have `phase_complete === true` and `verification_status === 'passed'`.
- `progress_percent` should be 100%.
Compute readiness from `INIT_MANAGER`, not from roadmap counts:
```bash
ALL_PHASES_VERIFIED=$(printf '%s' "$INIT_MANAGER" | jq -r '[
.phases[] | select((.number | tostring | test("^999(\\.|$)") | not))
| (.phase_complete == true and .verification_status == "passed")
] | all')
```
If not all_phases_verified, verified_closeout must not proceed. Set `closeout_type=override_closeout`, show each phase whose `phase_complete !== true` or `verification_status !== 'passed'`, and require an explicit user choice:
1. **Proceed anyway** — record verification overrides in MILESTONES.md/STATE.md
2. **Run verification first** — `/gsd:verify-work {phase}` or `/gsd:execute-phase {phase}`
3. **Abort** — return to development
Only set `closeout_type=verified_closeout` when `ALL_PHASES_VERIFIED` is `true`.
**Requirements completion check (REQUIRED before presenting):**
Parse REQUIREMENTS.md traceability table:
@@ -110,7 +127,9 @@ Includes:
- Phase 3: Core Features (3/3 plans complete)
- Phase 4: Polish (1/1 plan complete)
Total: {phase_count} phases, {total_plans} plans, all complete
Total: {phase_count} phases, {total_plans} plans
Verification: {all_phases_verified ? "all phases verified" : "override needed"}
Closeout type: {closeout_type}
Requirements: {N}/{M} v1 requirements checked off
```
@@ -128,7 +147,7 @@ MUST present 3 options:
2. **Run audit first** — `/gsd:audit-milestone` to assess gap severity
3. **Abort** — return to development
If user selects "Proceed anyway": note incomplete requirements in MILESTONES.md under `### Known Gaps` with REQ-IDs and descriptions.
If user selects "Proceed anyway": set `closeout_type=override_closeout`; note incomplete requirements in MILESTONES.md under `### Known Gaps` with REQ-IDs and descriptions.
<config-check>

View File

@@ -72,6 +72,7 @@ Build dashboard from JSON. Symbols: `✓` done, `◆` active, `○` pending, `·
**Status mapping** (disk_status → D P E Status):
- `complete` → `✓ ✓ ✓` `✓ Complete`
- `executed` → `✓ ✓ ◆` `◆ Verification required`
- `partial` → `✓ ✓ ◆` `◆ Executing...`
- `planned` → `✓ ✓ ○` `○ Ready to execute`
- `discussed` → `✓ ○ ·` `○ Ready to plan`
@@ -135,7 +136,7 @@ If `all_complete` is true:
║ MILESTONE COMPLETE ║
╚══════════════════════════════════════════════════════════════╝
All {phase_count} phases done. Ready for final steps:
All {phase_count} phases verified complete. Ready for final steps:
→ /gsd:verify-work — run acceptance testing
→ /gsd:complete-milestone — archive and wrap up
```
@@ -158,8 +159,9 @@ Handle responses:
**Building options:**
1. Collect all background actions (execute and plan recommendations) — there can be multiple of each.
2. Collect the inline action (discuss recommendation, if any — there will be at most one since discuss is sequential).
3. Build compound options:
2. Collect verification actions (`verify`) for implementation-complete phases whose canonical verification has not passed.
3. Collect the inline action (discuss recommendation, if any — there will be at most one since discuss is sequential).
4. Build compound options:
**If there are ANY recommended actions (background, inline, or both):**
Create ONE primary "Continue" option that dispatches ALL of them together:
@@ -169,10 +171,11 @@ Handle responses:
Continue:
→ Execute Phase 32 (background)
→ Plan Phase 34 (background)
→ Verify Phase 33
→ Discuss Phase 35 (inline)
```
- This dispatches all background agents first, then runs the inline discuss (if any).
- If there is no inline discuss, the dashboard refreshes after spawning background agents.
- This dispatches all background agents first, runs verification actions inline, then runs the inline discuss (if any).
- If there is no inline discuss, the dashboard refreshes after spawning background agents and inline verification.
**Important:** The Continue option must include EVERY action from `recommended_actions` — not just 2. If there are 3 actions, list 3. If there are 5, list 5.
@@ -221,8 +224,15 @@ Go to exit step.
When the user selects a compound option, behavior depends on the runtime — the Plan Phase N / Execute Phase N handlers below resolve it via `gsd_run query config-get runtime`:
- **On Codex:** **Spawn all background agents first** (plan/execute) — dispatch them in parallel using the Plan Phase N / Execute Phase N handlers below — then run the inline discuss; the background agents continue while you discuss.
- **Otherwise (Claude Code or any other non-Codex runtime):** a backgrounded agent cannot reliably nest the pipeline's subagents, so run the chosen plan/execute step(s) **inline** via their handlers below (in order), then run the inline discuss. There is no overlap.
- **On Codex:** **Spawn all background agents first** (plan/execute) — dispatch them in parallel using the Plan Phase N / Execute Phase N handlers below — then run verification actions, then run the inline discuss; the background agents continue while you verify/discuss.
- **On Claude Code or any other non-Codex runtime:** run the chosen plan/execute step(s) **inline** via their handlers below (in order), then run verification actions, then run the inline discuss. There is no overlap.
Inline verification:
For each verification recommendation, dispatch by the recommended action's `command`:
- If `command` contains `execute-phase`, run `Skill(skill="gsd-execute-phase", args="{PHASE_NUM} {manager_flags.execute}")`.
- If `command` contains `verify-work`, run `Skill(skill="gsd-verify-work", args="{PHASE_NUM}")`.
- If `command` is missing or unrecognized, stop and show the recommendation row instead of guessing.
Inline discuss:

View File

@@ -273,7 +273,7 @@ This is a WARNING, not a blocker — routing proceeds normally. The debt is visi
**Step 1.7: Check verification status for the current phase**
A phase whose verification ended `gaps_found` or `human_needed` is NOT complete, even when every PLAN.md has a matching SUMMARY.md. The count-based status (`roadmap.analyze`) only sees plans/summaries, so without this check such a phase is reported complete and routing skips straight to the next phase. When the phase appears count-complete (`summaries = plans AND plans > 0`), consult the verification report (the same `verification.status` gate `ship` and `execute-phase` use, from #651):
A phase whose verification is missing, unknown, `gaps_found`, or `human_needed` is NOT complete, even when every PLAN.md has a matching SUMMARY.md. The count-based status (`roadmap.analyze`) only sees plans/summaries, so without this check such a phase is reported complete and routing skips straight to the next phase. When the phase appears count-complete (`summaries = plans AND plans > 0`), consult the verification report (the same `verification.status` gate `ship` and `execute-phase` use, from #651):
```bash
PHASE_DIR=".planning/phases/[current-phase-dir]"
@@ -282,7 +282,7 @@ VERIFICATION_STATUS=$(printf '%s' "$VERIFICATION" | jq -r '.status' 2>/dev/null
VERIFICATION_NEXT_ACTION=$(printf '%s' "$VERIFICATION" | jq -r '.next_action' 2>/dev/null || echo "")
```
Track: `verification_status` — the `.status` field (`passed | gaps_found | human_needed | missing | unknown`). The query already handles a missing VERIFICATION.md (returns `missing`) and unexpected values, so no per-status file probing is needed. `passed`, `missing` (not yet verified), and `unknown` route as complete (Step 3) — `missing` with an advisory that the phase is unverified; `gaps_found` and `human_needed` route back to close the verification debt (Step 2).
Track: `verification_status` — the `.status` field (`passed | stale | gaps_found | human_needed | missing | unknown`). The query/projection handles a missing VERIFICATION.md (`missing`), unexpected values, and stale verification (`stale`, when summaries are newer than verification). Only `passed` routes as phase complete (Step 3); every other status routes back to close verification debt (Step 2).
**Step 2: Route based on counts**
@@ -291,12 +291,15 @@ Track: `verification_status` — the `.status` field (`passed | gaps_found | hum
| uat_partial > 0 | UAT testing incomplete | Go to **Route E.2** |
| uat_with_gaps > 0 | UAT gaps need fix plans | Go to **Route E** |
| summaries < plans | Unexecuted plans exist | Go to **Route A** |
| summaries = plans AND plans > 0 AND verification_status = missing | Phase executed; verification report missing | Go to **Route V.missing** |
| summaries = plans AND plans > 0 AND verification_status = unknown | Phase executed; verification status unknown | Go to **Route V.unknown** |
| summaries = plans AND plans > 0 AND verification_status = stale | Phase executed; verification is stale | Go to **Route V.stale** |
| summaries = plans AND plans > 0 AND verification_status = gaps_found | Phase executed; verification found gaps | Go to **Route V.gaps** |
| summaries = plans AND plans > 0 AND verification_status = human_needed | Phase executed; awaiting human verification | Go to **Route V.human** |
| summaries = plans AND plans > 0 | Phase complete (verification passed, missing, or n/a) | Go to Step 3 |
| summaries = plans AND plans > 0 AND verification_status = passed | Phase complete (verification passed) | Go to Step 3 |
| plans = 0 | Phase not yet planned | Go to **Route B** |
Rows are evaluated top to bottom; the first matching row wins. The two `verification_status` rows must precede the general `summaries = plans` row so a non-`passed` verification is not reported as complete.
Rows are evaluated top to bottom; the first matching row wins. The `verification_status` rows must precede the passed row so non-`passed` verification is not reported as complete.
---
@@ -448,6 +451,36 @@ UAT.md exists with `status: partial` — testing session ended before all items
---
**Route V.missing: verification report missing**
All plans have summaries, but canonical verification has not passed. The phase is implementation-complete, not phase-complete.
```
`/gsd:execute-phase {phase} ${GSD_WS}` — re-run execution verification
```
---
**Route V.unknown: verification status unknown**
VERIFICATION.md has an unexpected status. The phase is implementation-complete, not phase-complete.
```
`/gsd:execute-phase {phase} ${GSD_WS}` — regenerate verification
```
---
**Route V.stale: verification is stale**
VERIFICATION.md has `status: passed`, but one or more SUMMARY.md files are newer than the verification report. The phase is implementation-complete, not phase-complete.
```
`/gsd:verify-work {phase} ${GSD_WS}` — re-run verification against the latest summaries
```
---
**Route V.gaps: verification found gaps (gaps_found)**
VERIFICATION.md exists with `status: gaps_found` — verification identified gaps that need fix plans. The phase is NOT complete.

View File

@@ -77,26 +77,28 @@ cat .planning/config.json 2>/dev/null || true
**Check for verification debt in this phase:**
```bash
# Count outstanding items in current phase
OUTSTANDING=""
for f in .planning/phases/XX-current/*-UAT.md .planning/phases/XX-current/*-VERIFICATION.md; do
[ -f "$f" ] || continue
grep -q "result: pending\|result: blocked\|status: partial\|status: human_needed\|status: diagnosed" "$f" && OUTSTANDING="$OUTSTANDING\n$(basename $f)"
done
# Run a preliminary frontmatter check via awk — the runtime launcher is not yet
# defined at this step, so avoid any runtime tool calls here.
# awk extracts only the status: field between the two --- fences to avoid
# false positives from historical body text (e.g. previous_status: gaps_found).
VERIFY_STATUS=$(awk 'NR==1&&/^---$/{in_fm=1;next}in_fm&&/^---$/{exit}in_fm&&/^status: /{print $2}' \
.planning/phases/XX-current/*-VERIFICATION.md 2>/dev/null | head -1)
```
**If OUTSTANDING is not empty:**
**If VERIFY_STATUS is not `passed`:**
Append to the completion confirmation message (regardless of mode):
Stop before confirming:
```
Outstanding verification items in this phase:
{list filenames}
Verification incomplete: ${VERIFY_STATUS:-missing}
These will carry forward as debt. Review: `/gsd:audit-uat`
Resolve before transition. Review: `/gsd:audit-uat`
```
This does NOT block transition — it ensures the user sees the debt before confirming.
This preliminary check blocks obviously unresolved verification before the
launcher is available. `gsd-tools.cjs query phase.complete` remains the
authoritative stale-aware gate and fail-closes unless canonical verification
status is `passed`.
**If all plans complete:**

View File

@@ -143,13 +143,9 @@ Full review: {path to UI-REVIEW.md}
## ▶ Next
`/clear` then one of:
`/clear` then:
- `/gsd:verify-work {N}` — UAT testing
- `/gsd:plan-phase {N+1}` — plan next phase
- `/gsd:verify-work {N}` — UAT testing
- `/gsd:plan-phase {N+1}` — plan next phase
- `/gsd:verify-work {N}` — UAT testing before phase completion
───────────────────────────────────────────────────────────────
```

View File

@@ -527,6 +527,50 @@ If an active secure-phase step hook exists AND `SECURITY_FILE` exists: check fro
If no active secure-phase step hook exists OR (`SECURITY_FILE` exists AND `threats_open` is `0`):
If execution verification is waiting only on human UAT and this session recorded zero issues, canonicalize the report before the shared completion predicate:
```bash
PHASE_DIR=$(printf '%s' "$INIT" | jq -r '.phase_dir // empty')
VERIFICATION_FILE=$(ls "${PHASE_DIR}"/*-VERIFICATION.md 2>/dev/null | head -1)
VERIFICATION_STATUS=$(gsd_run query verification.status "$PHASE_DIR" 2>/dev/null)
VERIFICATION_STATUS_VALUE=$(printf '%s' "$VERIFICATION_STATUS" | jq -r '.status // empty' 2>/dev/null || echo "")
PHASE_VERIFICATION_STATUS="$VERIFICATION_STATUS_VALUE"
if [ "$VERIFICATION_STATUS_VALUE" = "human_needed" ]; then
gsd_run query frontmatter.set "$VERIFICATION_FILE" --field status --value passed
fi
```
If `PHASE_VERIFICATION_STATUS` is `stale`, stop before phase advancement and present:
```
All UAT tests passed, but phase advancement is blocked until canonical verification is fresh.
Blocking completion:
verification is stale
- `/gsd:verify-work {phase}` — re-run verification against the latest summaries
```
Otherwise, check the shared UAT-plus-verification completion predicate before transition:
```bash
PHASE_COMPLETE=$(gsd_run phase uat-passed "{phase}" --require-verification)
PHASE_COMPLETE_PASSED=$(printf '%s' "$PHASE_COMPLETE" | jq -r '.passed' 2>/dev/null || echo "false")
PHASE_COMPLETE_BLOCKERS=$(printf '%s' "$PHASE_COMPLETE" | jq -r '.blockers[]?' 2>/dev/null || true)
```
If `PHASE_COMPLETE_PASSED` is not `true`, stop before phase advancement and present:
```
All UAT tests passed, but phase advancement is blocked until canonical verification passes.
Blocking completion:
{PHASE_COMPLETE_BLOCKERS}
- `/gsd:execute-phase {phase}` — regenerate execution verification
- `/gsd:verify-work {phase}` — resume UAT if blockers remain
```
**Auto-transition: mark phase complete in ROADMAP.md and STATE.md**
Execute the transition workflow inline (do NOT use Task — the orchestrator context already holds the UAT results and phase data needed for accurate transition):