@opengsd/gsd-core 1.5.0-rc.2 → 1.5.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/agents/gsd-mempalace-curator.md +47 -0
  3. package/bin/install.js +25 -7
  4. package/commands/gsd/mempalace-capture.md +71 -0
  5. package/commands/gsd/mempalace-recall.md +102 -0
  6. package/commands/gsd/ns-context.md +4 -2
  7. package/gemini-extension.json +1 -1
  8. package/gsd-core/bin/gsd-tools.cjs +110 -92
  9. package/gsd-core/bin/lib/capability-activation.cjs +86 -0
  10. package/gsd-core/bin/lib/capability-registry.cjs +1468 -11
  11. package/gsd-core/bin/lib/capability-state.cjs +31 -18
  12. package/gsd-core/bin/lib/check-command-router.cjs +328 -1
  13. package/gsd-core/bin/lib/clusters.cjs +2 -0
  14. package/gsd-core/bin/lib/command-roster.cjs +19 -0
  15. package/gsd-core/bin/lib/commands.cjs +33 -10
  16. package/gsd-core/bin/lib/config-loader.cjs +7 -8
  17. package/gsd-core/bin/lib/config-schema.cjs +32 -3
  18. package/gsd-core/bin/lib/config.cjs +1 -2
  19. package/gsd-core/bin/lib/core.cjs +5 -2
  20. package/gsd-core/bin/lib/init.cjs +8 -5
  21. package/gsd-core/bin/lib/install-profiles.cjs +2 -1
  22. package/gsd-core/bin/lib/loop-resolver.cjs +157 -16
  23. package/gsd-core/bin/lib/model-resolver.cjs +47 -5
  24. package/gsd-core/bin/lib/phase.cjs +71 -11
  25. package/gsd-core/bin/lib/profile-output.cjs +45 -4
  26. package/gsd-core/bin/lib/profile-pipeline-command-router.cjs +138 -0
  27. package/gsd-core/bin/lib/roadmap.cjs +97 -7
  28. package/gsd-core/bin/lib/runtime-artifact-conversion.cjs +1700 -0
  29. package/gsd-core/bin/lib/runtime-artifact-layout.cjs +20 -28
  30. package/gsd-core/bin/lib/runtime-config-adapter-registry.cjs +27 -19
  31. package/gsd-core/bin/lib/runtime-homes.cjs +26 -20
  32. package/gsd-core/bin/lib/state-command-router.cjs +15 -3
  33. package/gsd-core/bin/lib/state-document.cjs +46 -1
  34. package/gsd-core/bin/lib/state.cjs +221 -35
  35. package/gsd-core/bin/lib/verify.cjs +19 -4
  36. package/gsd-core/bin/shared/config-defaults.manifest.json +1 -2
  37. package/gsd-core/bin/shared/config-schema.manifest.json +0 -18
  38. package/gsd-core/bin/shared/model-catalog.json +1 -0
  39. package/gsd-core/references/loop-hook-dispatch.md +61 -0
  40. package/gsd-core/templates/config.json +1 -1
  41. package/gsd-core/workflows/audit-milestone.md +5 -3
  42. package/gsd-core/workflows/autonomous.md +10 -5
  43. package/gsd-core/workflows/code-review-fix.md +9 -7
  44. package/gsd-core/workflows/code-review.md +8 -6
  45. package/gsd-core/workflows/discuss-phase.md +14 -0
  46. package/gsd-core/workflows/execute-phase.md +82 -143
  47. package/gsd-core/workflows/help/modes/full.md +3 -1
  48. package/gsd-core/workflows/new-project.md +3 -3
  49. package/gsd-core/workflows/plan-phase.md +89 -221
  50. package/gsd-core/workflows/profile-user.md +3 -1
  51. package/gsd-core/workflows/progress.md +58 -1
  52. package/gsd-core/workflows/quick.md +9 -6
  53. package/gsd-core/workflows/review.md +19 -2
  54. package/gsd-core/workflows/secure-phase.md +4 -2
  55. package/gsd-core/workflows/settings-advanced.md +2 -0
  56. package/gsd-core/workflows/ship.md +57 -0
  57. package/gsd-core/workflows/validate-phase.md +4 -2
  58. package/gsd-core/workflows/verify-work.md +27 -11
  59. package/package.json +3 -2
  60. package/scripts/affected-tests-lib.cjs +16 -4
  61. package/scripts/gen-capability-registry.cjs +359 -48
  62. package/scripts/gen-inventory-manifest.cjs +1 -4
  63. package/scripts/gen-loop-host-contract.cjs +55 -0
  64. package/scripts/issue-version-gate.cjs +140 -0
  65. package/scripts/lint-allow-test-rule-refs.allowlist.json +326 -0
  66. package/scripts/lint-allow-test-rule-refs.cjs +162 -0
  67. package/scripts/lint-test-file-count.allowlist.json +8 -0
  68. package/scripts/release-tarball-smoke.cjs +7 -1
  69. package/scripts/run-tests.cjs +74 -14
@@ -74,21 +74,23 @@ FIX_REPORT_PATH="${PHASE_DIR}/${PADDED_PHASE}-REVIEW-FIX.md"
74
74
  </step>
75
75
 
76
76
  <step name="check_config_gate">
77
- Check if code review is enabled via config:
77
+ Check if code review is active via the capability registry:
78
78
 
79
79
  ```bash
80
- CODE_REVIEW_ENABLED=$(gsd_run query config-get workflow.code_review 2>/dev/null || echo "true")
80
+ EXECUTE_POST_HOOKS_JSON=$(gsd_run loop render-hooks execute:post --raw)
81
81
  ```
82
82
 
83
- If CODE_REVIEW_ENABLED is "false":
83
+ Resolve active step hooks from `EXECUTE_POST_HOOKS_JSON` where `kind == "step"` and `ref.skill == "code-review"`.
84
+
85
+ If no active code-review step hook exists:
84
86
  ```
85
- Code review fix skipped (workflow.code_review=false in config)
87
+ Code review fix skipped (code-review capability inactive)
86
88
  ```
87
89
  Exit workflow.
88
90
 
89
- Default is true — only skip on explicit false. This check runs AFTER phase validation so invalid phase errors are shown first.
91
+ 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.
90
92
 
91
- 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.
93
+ 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.
92
94
  </step>
93
95
 
94
96
  <step name="check_review_exists">
@@ -491,7 +493,7 @@ echo "════════════════════════
491
493
 
492
494
  <success_criteria>
493
495
  - [ ] Phase validated before config gate check
494
- - [ ] Config gate checked (workflow.code_review)
496
+ - [ ] Capability gate checked (execute:post code-review hook)
495
497
  - [ ] REVIEW.md existence verified (error if missing)
496
498
  - [ ] REVIEW.md status checked (skip if clean/skipped)
497
499
  - [ ] Agent spawned with correct config (review_path, fix_scope, fix_report_path)
@@ -73,19 +73,21 @@ fi
73
73
  </step>
74
74
 
75
75
  <step name="check_config_gate">
76
- Check if code review is enabled via config:
76
+ Check if code review is active via the capability registry:
77
77
 
78
78
  ```bash
79
- CODE_REVIEW_ENABLED=$(gsd_run query config-get workflow.code_review 2>/dev/null || echo "true")
79
+ EXECUTE_POST_HOOKS_JSON=$(gsd_run loop render-hooks execute:post --raw)
80
80
  ```
81
81
 
82
- If CODE_REVIEW_ENABLED is "false":
82
+ Resolve active step hooks from `EXECUTE_POST_HOOKS_JSON` where `kind == "step"` and `ref.skill == "code-review"`.
83
+
84
+ If no active code-review step hook exists:
83
85
  ```
84
- Code review skipped (workflow.code_review=false in config)
86
+ Code review skipped (code-review capability inactive)
85
87
  ```
86
88
  Exit workflow.
87
89
 
88
- Default is true — only skip on explicit false. This check runs AFTER phase validation so invalid phase errors are shown first.
90
+ 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.
89
91
  </step>
90
92
 
91
93
  <step name="resolve_depth">
@@ -678,7 +680,7 @@ If `--files` validation fails unexpectedly on macOS, install coreutils or use ab
678
680
 
679
681
  <success_criteria>
680
682
  - [ ] Phase validated before config gate check
681
- - [ ] Config gate checked (workflow.code_review)
683
+ - [ ] Capability gate checked (execute:post code-review hook)
682
684
  - [ ] --fix/--all/--auto flags parsed via code-review-flags.cjs typed IR (not ad-hoc bash)
683
685
  - [ ] Depth resolved with validation (quick|standard|deep)
684
686
  - [ ] File scope computed with 3 tiers: --files > SUMMARY.md > git diff
@@ -293,6 +293,13 @@ Read `@~/.claude/gsd-core/references/scout-codebase.md` — it contains the phas
293
293
  3. Build internal `<codebase_context>` per the reference's output schema
294
294
  </step>
295
295
 
296
+ <step name="dispatch_discuss_pre_hooks">
297
+ ```bash
298
+ DISCUSS_PRE_HOOKS_JSON=$(gsd_run loop render-hooks discuss:pre --raw)
299
+ ```
300
+ Apply each entry in `activeHooks` per @~/.claude/gsd-core/references/loop-hook-dispatch.md. Empty list → continue to `analyze_phase`.
301
+ </step>
302
+
296
303
  <step name="analyze_phase">
297
304
  Analyze the phase to identify gray areas. Use both `prior_decisions` and `codebase_context` to ground the analysis.
298
305
 
@@ -405,6 +412,13 @@ The template documents variable substitutions and conditional sections. Substitu
405
412
  Write the file.
406
413
  </step>
407
414
 
415
+ <step name="dispatch_discuss_post_hooks">
416
+ ```bash
417
+ DISCUSS_POST_HOOKS_JSON=$(gsd_run loop render-hooks discuss:post --raw)
418
+ ```
419
+ Apply each entry in `activeHooks` per @~/.claude/gsd-core/references/loop-hook-dispatch.md. Empty list → continue to `confirm_creation`.
420
+ </step>
421
+
408
422
  <step name="confirm_creation">
409
423
  Present summary and next steps:
410
424
 
@@ -177,7 +177,8 @@ Resolve `MVP_MODE` once via the centralized `phase.mvp-mode` query verb (precede
177
177
  MVP_FLAG_ARG=""
178
178
  if [[ "$ARGUMENTS" =~ (^|[[:space:]])--mvp([[:space:]]|$) ]]; then MVP_FLAG_ARG="--cli-flag"; fi
179
179
  MVP_MODE=$(gsd_run query phase.mvp-mode "${PHASE_NUMBER}" $MVP_FLAG_ARG --pick active)
180
- TDD_MODE=$(gsd_run query config-get workflow.tdd_mode 2>/dev/null || echo "false")
180
+ EXECUTE_POST_HOOKS_JSON=$(gsd_run loop render-hooks execute:post --raw)
181
+ TDD_MODE=$(gsd_run loop render-hooks execute:post --active-cap tdd)
181
182
  ```
182
183
 
183
184
  <step name="safe_resume_gate">
@@ -898,6 +899,51 @@ increases monotonically across waves. `{status}` is `complete` (success),
898
899
 
899
900
  **If no plan in this wave used worktrees** (project-level `USE_WORKTREES=false` OR `WAVE_WORKTREE_PLANS` is empty): sequential agents already updated STATE.md and ROADMAP.md themselves — skip this step.
900
901
 
902
+ 5.75. **Execute:wave:post capability dispatch:**
903
+
904
+ After worktree merge, post-merge tests, and tracking updates, dispatch capability hooks registered at `execute:wave:post`. The primary hook is the `ui.safety-gate` gate from the UI capability — it verifies that any frontend files changed in this wave conform to the UI-SPEC contract.
905
+
906
+ ```bash
907
+ WAVE_POST_HOOKS_JSON=$(gsd_run loop render-hooks execute:wave:post --raw)
908
+ ```
909
+
910
+ Read the `activeHooks` array from `WAVE_POST_HOOKS_JSON` in-context (do NOT pipe through a shell parser).
911
+
912
+ **If `activeHooks` is empty or absent:** Skip silently to step 5.8.
913
+
914
+ **For each active entry where `kind == "gate"`** (process in array order), run the gate check:
915
+
916
+ ```bash
917
+ GATE_RESULT=$(gsd_run check ${hook.check.query} "${PHASE_NUMBER}" --raw)
918
+ CHECK_EXIT=$?
919
+ ```
920
+
921
+ **Step 1 — did the CHECK COMMAND itself succeed?**
922
+
923
+ If the check command failed (non-zero `CHECK_EXIT`, empty output, or unparseable JSON):
924
+ - `onError == "halt"` → treat as a fatal error: stop wave completion, do NOT proceed to step 5.8, and surface: `⚠ Gate check command failed ({hook.capId}): command error. Resolve before continuing.`
925
+ - `onError == "skip"` → log a warning and continue to the next hook. Do NOT read `GATE_RESULT.block`.
926
+
927
+ **Step 2 — read `GATE_RESULT.block` (boolean).** This step is only reached when the command succeeded.
928
+
929
+ - **Blocking gate (`hook.blocking == true`) AND `GATE_RESULT.block == true`:** HALT — stop wave completion, do NOT proceed to step 5.8, and present:
930
+
931
+ ```
932
+ ⚠ Wave {N} blocked by capability gate ({hook.capId}): {GATE_RESULT.message}
933
+ Resolve before continuing to next wave.
934
+ ```
935
+
936
+ This halt is **not** bypassed by `onError` — `onError` only covers command errors (step 1 above), not the gate's block decision.
937
+
938
+ - **Non-blocking gate (`hook.blocking == false`):** never halts. If `GATE_RESULT.block` is `true` (or non-empty `message`), print `⚠ {hook.capId} advisory (wave {N}): {GATE_RESULT.message}`, then:
939
+ - If `GATE_RESULT.spawn_mapper == true` OR `GATE_RESULT.directive == "auto-remap"`: spawn `gsd-codebase-mapper` per `execute-phase/steps/codebase-drift-gate.md`; pass `--paths {GATE_RESULT.affected_paths}`. Continue regardless (wave NOT failed by remap failure).
940
+ - Otherwise: continue after advisory.
941
+ - If block `false` and no `message`: continue silently.
942
+
943
+ - **Blocking gate (`hook.blocking == true`) AND `GATE_RESULT.block == false`:** continue silently.
944
+
945
+ **When all active gates are processed without a blocking halt:** continue to step 5.8.
946
+
901
947
  5.8. **Handle test gate failures (when `WAVE_FAILURE_COUNT > 0`):**
902
948
 
903
949
  ```
@@ -1061,79 +1107,28 @@ After all waves:
1061
1107
 
1062
1108
  **Security gate check:**
1063
1109
  ```bash
1064
- SECURITY_CFG=$(gsd_run query config-get workflow.security_enforcement --raw 2>/dev/null || echo "true")
1110
+ VERIFY_POST_HOOKS_JSON=$(gsd_run loop render-hooks verify:post --raw)
1065
1111
  SECURITY_FILE=$(ls "${PHASE_DIR}"/*-SECURITY.md 2>/dev/null | head -1)
1066
1112
  ```
1067
1113
 
1068
- If `SECURITY_CFG` is `false`: skip.
1114
+ Resolve active step hooks from `VERIFY_POST_HOOKS_JSON` where `kind == "step"` and `ref.skill == "secure-phase"`.
1115
+
1116
+ If no active secure-phase step hook exists: skip.
1069
1117
 
1070
- If `SECURITY_CFG` is `true` AND `SECURITY_FILE` is empty (no SECURITY.md yet):
1118
+ If an active secure-phase step hook exists AND `SECURITY_FILE` is empty (no SECURITY.md yet):
1071
1119
  Include in the next-steps routing output:
1072
1120
  ```
1073
1121
  ⚠ Security enforcement enabled — run before advancing:
1074
1122
  /gsd:secure-phase {PHASE} ${GSD_WS}
1075
1123
  ```
1076
1124
 
1077
- If `SECURITY_CFG` is `true` AND SECURITY.md exists: check frontmatter `threats_open`. If > 0:
1125
+ If an active secure-phase step hook exists AND SECURITY.md exists: check frontmatter `threats_open`. If > 0:
1078
1126
  ```
1079
1127
  ⚠ Security gate: {threats_open} threats open
1080
1128
  /gsd:secure-phase {PHASE} — resolve before advancing
1081
1129
  ```
1082
1130
  </step>
1083
1131
 
1084
- <step name="tdd_review_checkpoint">
1085
- **Optional step — TDD collaborative review.**
1086
-
1087
- ```bash
1088
- TDD_MODE=$(gsd_run query config-get workflow.tdd_mode 2>/dev/null || echo "false")
1089
- ```
1090
-
1091
- **Skip if `TDD_MODE` is `false`.**
1092
-
1093
- When `TDD_MODE` is `true`, check whether any completed plans in this phase have `type: tdd` in their frontmatter:
1094
-
1095
- ```bash
1096
- TDD_PLANS=$(grep -rl "^type: tdd" "${PHASE_DIR}"/*-PLAN.md 2>/dev/null | wc -l | tr -d ' ')
1097
- ```
1098
-
1099
- **If `TDD_PLANS` > 0:** Insert end-of-phase collaborative review checkpoint.
1100
-
1101
- 1. Collect all SUMMARY.md files for TDD plans
1102
- 2. For each TDD plan summary, verify the RED/GREEN/REFACTOR gate sequence:
1103
- - RED gate: A failing test commit exists (`test(...)` commit with MUST-fail evidence)
1104
- - GREEN gate: An implementation commit exists (`feat(...)` commit making tests pass)
1105
- - REFACTOR gate: Optional cleanup commit (`refactor(...)` commit, tests still pass)
1106
- 3. If any TDD plan is missing the RED or GREEN gate commits, flag it:
1107
- ```
1108
- ⚠ TDD gate violation: Plan {plan_id} missing {RED|GREEN} phase commit.
1109
- Expected commit pattern: test({phase}-{plan}): ... → feat({phase}-{plan}): ...
1110
- ```
1111
- 4. Present collaborative review summary:
1112
- ```
1113
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1114
- TDD REVIEW — Phase {X}
1115
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1116
-
1117
- TDD Plans: {TDD_PLANS} | Gate violations: {count}
1118
-
1119
- | Plan | RED | GREEN | REFACTOR | Status |
1120
- |------|-----|-------|----------|--------|
1121
- | {id} | ✓ | ✓ | ✓ | Pass |
1122
- | {id} | ✓ | ✗ | — | FAIL |
1123
- ```
1124
-
1125
- **Escalation under MVP+TDD.** When `MVP_MODE=true` AND `TDD_MODE=true`, the review verdict escalates from advisory to **blocking**: missing RED or GREEN gate commits prevent marking the phase complete.
1126
- ```text
1127
- Phase blocked: {N} TDD plan(s) violate the RED→GREEN gate sequence under MVP+TDD.
1128
- Resolve and re-run /gsd execute-phase, or override with
1129
- /gsd execute-phase {phase} --force-mvp-gate to ship anyway.
1130
- ```
1131
- `--force-mvp-gate` is the escape hatch (documented, not yet implemented). Policy is:
1132
- - `MVP_MODE=true` AND `TDD_MODE=true`: violations are **blocking** unless explicitly overridden.
1133
- - otherwise: violations are advisory/non-blocking and are surfaced for review.
1134
- The verifier agent (step `verify_phase_goal`) still checks TDD discipline in both cases.
1135
- </step>
1136
-
1137
1132
  <step name="handle_partial_wave_execution">
1138
1133
  If `WAVE_FILTER` was used, re-run plan discovery after execution:
1139
1134
 
@@ -1166,18 +1161,20 @@ Selected wave finished successfully. This phase still has incomplete plans, so p
1166
1161
  </step>
1167
1162
 
1168
1163
  <step name="code_review_gate" required="true">
1169
- **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.
1164
+ **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. Also dispatches advisory execute:post gate hooks (e.g. tdd.review-checkpoint).
1170
1165
 
1171
- **Config gate:**
1166
+ **Capability gate:**
1172
1167
  ```bash
1173
- CODE_REVIEW_ENABLED=$(gsd_run query config-get workflow.code_review 2>/dev/null || echo "true")
1168
+ EXECUTE_POST_HOOKS_JSON=${EXECUTE_POST_HOOKS_JSON:-$(gsd_run loop render-hooks execute:post --raw)}
1174
1169
  ```
1175
1170
 
1176
- If `CODE_REVIEW_ENABLED` is `"false"`: display "Code review skipped (workflow.code_review=false)" and proceed to next step.
1171
+ Resolve active step hooks from `EXECUTE_POST_HOOKS_JSON` where `kind == "step"` and `ref.skill == "code-review"`.
1172
+
1173
+ If no active code-review step hook exists: display "Code review skipped (code-review capability inactive)" and proceed to gate dispatch.
1177
1174
 
1178
1175
  **Invoke review:**
1179
1176
  ```
1180
- Skill(skill="gsd-code-review", args="${PHASE_NUMBER}")
1177
+ Skill(skill="gsd-${ref.skill}", args="${PHASE_NUMBER}")
1181
1178
  ```
1182
1179
 
1183
1180
  **Check results using deterministic path (not glob):**
@@ -1193,9 +1190,28 @@ Code review found issues. Consider running:
1193
1190
  /gsd:code-review ${PHASE_NUMBER} --fix
1194
1191
  ```
1195
1192
 
1196
- **Error handling:** If the Skill invocation fails or throws, catch the error, display "Code review encountered an error (non-blocking): {error}" and proceed to next step. Review failures must never block execution.
1193
+ **Error handling:** If the Skill invocation fails or throws, catch the error, display "Code review encountered an error (non-blocking): {error}" and proceed to gate dispatch. Review failures must never block execution.
1194
+
1195
+ **Execute:post gate hook dispatch.** After code review, dispatch all active gate hooks from `EXECUTE_POST_HOOKS_JSON` where `kind == "gate"`:
1197
1196
 
1198
- Regardless of review result, ALWAYS proceed to close_parent_artifacts → regression_gate → verify_phase_goal.
1197
+ For each active gate hook:
1198
+ ```bash
1199
+ GATE_RESULT=$(gsd_run check ${hook.check.query} "${PHASE_NUMBER}" --raw)
1200
+ CHECK_EXIT=$?
1201
+ ```
1202
+
1203
+ **Gate evaluation** uses the same two-step contract as `execute:wave:post` above: **Step 1** — if the check command failed (non-zero `CHECK_EXIT`, empty/unparseable output), `onError == "halt"` stops and surfaces the error, `onError == "skip"` warns and continues to the next hook (do not read `block`). **Step 2** (command succeeded) — a blocking gate (`hook.blocking == true`) halts on `GATE_RESULT.block == true` with its message/table (never bypassed by `onError`); an advisory gate (`hook.blocking == false`) shows its `table`/summary when `block == true` or `message` is non-empty, then continues; a blocking gate with `block == false` continues silently.
1204
+
1205
+ **TDD review escalation (overrides the advisory default for the `tdd.review-checkpoint` gate only).** The tdd `execute:post` gate is declared `blocking: false`, so by the generic contract above it displays its `message`/table and continues. There is ONE documented exception (see `~/.claude/gsd-core/references/execute-mvp-tdd.md`): when `MVP_MODE=true` AND `TDD_MODE=true` AND `GATE_RESULT.block == true` (one or more TDD plans miss a RED or GREEN gate commit), the end-of-phase TDD review escalates from advisory to **blocking under MVP+TDD** — refuse to mark the phase complete and present:
1206
+
1207
+ ```
1208
+ Phase blocked: {N} TDD plan(s) violate the RED→GREEN gate sequence under MVP+TDD.
1209
+ Resolve and re-run /gsd execute-phase, or override with /gsd execute-phase {phase} --force-mvp-gate to ship anyway.
1210
+ ```
1211
+
1212
+ (`--force-mvp-gate` is the documented, not-yet-implemented escape hatch.) Outside MVP+TDD, TDD-review violations remain advisory (table shown, execution continues).
1213
+
1214
+ **Proceed rule:** If `MVP_MODE && TDD_MODE && GATE_RESULT.block == true` for `tdd.review-checkpoint`: STOP — do NOT proceed to `close_parent_artifacts`, `regression_gate`, `verify_phase_goal`, or `phase.complete`. Otherwise proceed normally.
1199
1215
  </step>
1200
1216
 
1201
1217
  <step name="close_parent_artifacts">
@@ -1318,84 +1334,7 @@ Options:
1318
1334
  3. Abort phase — roll back and re-plan
1319
1335
  ```
1320
1336
 
1321
- Use AskUserQuestion to present the options.
1322
- </step>
1323
-
1324
- <step name="schema_drift_gate">
1325
- Post-execution schema drift detection. Catches false-positive verification where
1326
- build/types pass because TypeScript types come from config, not the live database.
1327
-
1328
- **Run after execution completes but BEFORE verification marks success.**
1329
-
1330
- ```bash
1331
- SCHEMA_DRIFT=$(gsd_run query verify.schema-drift "${PHASE_NUMBER}" 2>/dev/null)
1332
- ```
1333
-
1334
- Parse JSON result for: `drift_detected`, `blocking`, `schema_files`, `orms`, `unpushed_orms`, `message`.
1335
-
1336
- **If `drift_detected` is false:** Skip to verify_phase_goal.
1337
-
1338
- **If `drift_detected` is true AND `blocking` is true:**
1339
-
1340
- Check for override:
1341
- ```bash
1342
- SKIP_SCHEMA=$(echo "${GSD_SKIP_SCHEMA_CHECK:-false}")
1343
- ```
1344
-
1345
- **If `SKIP_SCHEMA` is `true`:**
1346
-
1347
- Display:
1348
- ```
1349
- ⚠ Schema drift detected but GSD_SKIP_SCHEMA_CHECK=true — bypassing gate.
1350
-
1351
- Schema files changed: {schema_files}
1352
- ORMs requiring push: {unpushed_orms}
1353
-
1354
- Proceeding to verification (database may be out of sync).
1355
- ```
1356
- → Continue to verify_phase_goal.
1357
-
1358
- **If `SKIP_SCHEMA` is not `true`:**
1359
-
1360
- BLOCK verification. Display:
1361
-
1362
- ```
1363
- ## BLOCKED: Schema Drift Detected
1364
-
1365
- Schema-relevant files changed during this phase but no database push command
1366
- was executed. Build and type checks pass because TypeScript types come from
1367
- config, not the live database — verification would produce a false positive.
1368
-
1369
- Schema files changed: {schema_files}
1370
- ORMs requiring push: {unpushed_orms}
1371
-
1372
- Required push commands:
1373
- {For each unpushed ORM, show the push command from the message}
1374
-
1375
- Options:
1376
- 1. Run push command now (recommended) — execute the push, then re-verify
1377
- 2. Skip schema check (GSD_SKIP_SCHEMA_CHECK=true) — bypass this gate
1378
- 3. Abort — stop execution and investigate
1379
- ```
1380
-
1381
- If `TEXT_MODE` is true, present as a plain-text numbered list. Otherwise use AskUserQuestion.
1382
-
1383
- **If user selects option 1:** Present the specific push command(s) to run. After user confirms execution, re-run the schema drift check. If it passes, continue to verify_phase_goal.
1384
-
1385
- **If user selects option 2:** Set override and continue to verify_phase_goal.
1386
-
1387
- **If user selects option 3:** Stop execution. Report partial completion.
1388
- </step>
1389
-
1390
- <step name="codebase_drift_gate">
1391
- Post-execution structural drift detection (#2003). Non-blocking by contract:
1392
- any internal error here MUST fall through to `verify_phase_goal`. The phase
1393
- is never failed by this gate.
1394
-
1395
- Load and follow the full step spec from
1396
- `gsd-core/workflows/execute-phase/steps/codebase-drift-gate.md` —
1397
- covers the SDK call, JSON contract, `warn` vs `auto-remap` branches, mapper
1398
- spawn template, and the two `workflow.drift_*` config keys.
1337
+ If `TEXT_MODE` is true, present as a plain-text numbered list and ask the user to type their choice number. Otherwise, use AskUserQuestion to present the options.
1399
1338
  </step>
1400
1339
 
1401
1340
  <step name="verify_phase_goal">
@@ -606,6 +606,8 @@ The commands above cover the most common day-to-day flows. Every command listed
606
606
  ### Knowledge & Context
607
607
 
608
608
  - **`/gsd:graphify [build|query <term>|status|diff]`** — Build, query, and inspect the project knowledge graph in `.planning/graphs/`.
609
+ - **`/gsd:mempalace-recall`** — Recall prior decisions, patterns, and surprises from MemPalace before planning.
610
+ - **`/gsd:mempalace-capture [artifact-type]`** — File a phase artifact into MemPalace and mirror decision facts into its temporal KG.
609
611
  - **`/gsd:thread [list [--open|--resolved] | close <slug> | status <slug> | name | description]`** — Manage persistent context threads for cross-session work.
610
612
  - **`/gsd:profile-user [--questionnaire] [--refresh]`** — Generate developer behavioral profile and create Claude-discoverable artifacts.
611
613
  - **`/gsd:stats`** — Display project statistics: phases, plans, requirements, git metrics, and timeline.
@@ -626,7 +628,7 @@ The commands above cover the most common day-to-day flows. Every command listed
626
628
 
627
629
  These six skills exist primarily for the model to perform two-stage hierarchical routing across 60+ skills. You can invoke them directly when you want to browse a category interactively.
628
630
 
629
- - **`/gsd-context`** — Codebase intelligence routing (map, graphify, docs, learnings).
631
+ - **`/gsd-context`** — Codebase intelligence routing (map, graphify, docs, learnings, mempalace).
630
632
  - **`/gsd-ideate`** — Exploration / capture routing (explore, sketch, spike, spec, capture).
631
633
  - **`/gsd-manage`** — Configuration and workspace routing (workstreams, thread, update, ship, inbox).
632
634
  - **`/gsd-project`** — Project-lifecycle routing (milestones, audits, summary).
@@ -111,7 +111,7 @@ else RUNTIME="claude"; fi
111
111
 
112
112
  Set the instruction file variable:
113
113
  ```bash
114
- if [ "$RUNTIME" = "codex" ]; then INSTRUCTION_FILE="AGENTS.md"; else INSTRUCTION_FILE="CLAUDE.md"; fi
114
+ if [ "$RUNTIME" = "codex" ]; then INSTRUCTION_FILE="AGENTS.md"; else INSTRUCTION_FILE=".claude/CLAUDE.md"; fi
115
115
  ```
116
116
 
117
117
  All subsequent references to the project instruction file use `$INSTRUCTION_FILE`.
@@ -1533,7 +1533,7 @@ PHASE1_HAS_UI=$(echo "$PHASE1_SECTION" | grep -qi "UI hint.*yes" && echo "true"
1533
1533
  - `.planning/REQUIREMENTS.md`
1534
1534
  - `.planning/ROADMAP.md`
1535
1535
  - `.planning/STATE.md`
1536
- - `$INSTRUCTION_FILE` (`AGENTS.md` for Codex, `CLAUDE.md` for all other runtimes)
1536
+ - `$INSTRUCTION_FILE` (`AGENTS.md` for Codex, `.claude/CLAUDE.md` for all other runtimes)
1537
1537
 
1538
1538
  </output>
1539
1539
 
@@ -1555,7 +1555,7 @@ PHASE1_HAS_UI=$(echo "$PHASE1_SECTION" | grep -qi "UI hint.*yes" && echo "true"
1555
1555
  - [ ] ROADMAP.md created with phases, requirement mappings, success criteria
1556
1556
  - [ ] STATE.md initialized
1557
1557
  - [ ] REQUIREMENTS.md traceability updated
1558
- - [ ] `$INSTRUCTION_FILE` generated with GSD workflow guidance (AGENTS.md for Codex, CLAUDE.md otherwise)
1558
+ - [ ] `$INSTRUCTION_FILE` generated with GSD workflow guidance (AGENTS.md for Codex, `.claude/CLAUDE.md` otherwise; an existing hand-crafted file without GSD markers is left untouched unless `--force`)
1559
1559
  - [ ] User knows next step is `/gsd:discuss-phase 1`
1560
1560
 
1561
1561
  **Atomic commits:** Each phase commits its artifacts immediately. If context is lost, artifacts persist.