its-magic 0.1.2-9 → 0.1.2

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 (232) hide show
  1. package/README.md +1602 -755
  2. package/bin/its-magic.js +121 -11
  3. package/bin/postinstall.js +21 -0
  4. package/installer.ps1 +759 -0
  5. package/installer.py +981 -0
  6. package/installer.sh +649 -0
  7. package/package.json +18 -14
  8. package/scripts/check_intake_template_parity.py +284 -0
  9. package/scripts/doc_profile_lib.py +415 -0
  10. package/scripts/guard_installer_publish.py +88 -0
  11. package/scripts/intake_bug_routing_guard.py +67 -0
  12. package/scripts/intake_evidence_lib.py +802 -0
  13. package/scripts/intake_evidence_validate.py +73 -0
  14. package/scripts/materialize_codebase_map.py +184 -0
  15. package/scripts/remote_config_summary.py +243 -0
  16. package/template/.cursor/agents/curator.mdc +35 -0
  17. package/template/.cursor/agents/dev.mdc +29 -0
  18. package/template/.cursor/agents/po.mdc +141 -0
  19. package/template/.cursor/agents/qa.mdc +28 -0
  20. package/template/.cursor/agents/release.mdc +28 -0
  21. package/template/.cursor/agents/security.mdc +98 -0
  22. package/template/.cursor/agents/tech-lead.mdc +57 -0
  23. package/template/.cursor/commands/architecture.md +127 -0
  24. package/template/.cursor/commands/ask.md +55 -0
  25. package/template/.cursor/commands/auto.md +533 -0
  26. package/template/.cursor/commands/discovery.md +47 -0
  27. package/template/.cursor/commands/execute.md +343 -0
  28. package/template/.cursor/commands/intake.md +323 -0
  29. package/template/.cursor/commands/map-codebase.md +46 -0
  30. package/template/.cursor/commands/memory-audit.md +175 -0
  31. package/template/.cursor/commands/milestone-complete.md +51 -0
  32. package/template/.cursor/commands/milestone-start.md +59 -0
  33. package/template/.cursor/commands/pause.md +64 -0
  34. package/{.cursor/commands/gsd-phase-context.md → template/.cursor/commands/phase-context.md} +6 -2
  35. package/template/.cursor/commands/plan-verify.md +34 -0
  36. package/template/.cursor/commands/qa.md +226 -0
  37. package/template/.cursor/commands/quick.md +41 -0
  38. package/template/.cursor/commands/refresh-context.md +82 -0
  39. package/template/.cursor/commands/release.md +505 -0
  40. package/template/.cursor/commands/research.md +49 -0
  41. package/template/.cursor/commands/resume.md +67 -0
  42. package/template/.cursor/commands/security-review.md +81 -0
  43. package/template/.cursor/commands/sprint-plan.md +103 -0
  44. package/template/.cursor/commands/status-reconcile.md +95 -0
  45. package/template/.cursor/commands/verify-work.md +152 -0
  46. package/template/.cursor/dev-environment.json.example +22 -0
  47. package/{.cursor → template/.cursor}/hooks/README.md +3 -2
  48. package/{.cursor/hooks/gsd-hook.py → template/.cursor/hooks/hook.py} +15 -6
  49. package/template/.cursor/hooks.json +26 -0
  50. package/template/.cursor/remote.json +31 -0
  51. package/template/.cursor/rules/caveman.mdc +184 -0
  52. package/template/.cursor/rules/coding-standards.mdc +39 -0
  53. package/template/.cursor/rules/core.mdc +111 -0
  54. package/template/.cursor/rules/handoffs.mdc +27 -0
  55. package/template/.cursor/rules/quality.mdc +49 -0
  56. package/template/.cursor/scratchpad.local.example.md +323 -0
  57. package/template/.cursor/scratchpad.md +324 -0
  58. package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/SKILL.md +2 -2
  59. package/template/.cursorignore +6 -0
  60. package/template/.env.example +28 -0
  61. package/template/.github/workflows/ci.yml +194 -0
  62. package/{.github → template/.github}/workflows/deploy.yml +5 -2
  63. package/template/.its-magic-version +1 -0
  64. package/template/README.md +1602 -0
  65. package/template/decisions/DEC-0001.md +11 -0
  66. package/template/decisions/DEC-0002.md +11 -0
  67. package/template/docs/developer/README.md +44 -0
  68. package/template/docs/engineering/architecture.md +9 -0
  69. package/template/docs/engineering/artifact-ordering-policy.md +48 -0
  70. package/template/docs/engineering/artifact-ownership-policy.md +57 -0
  71. package/template/docs/engineering/auto-orchestration-reference.md +1211 -0
  72. package/{docs → template/docs}/engineering/codebase-map.md +0 -5
  73. package/template/docs/engineering/compatibility-report.md +20 -0
  74. package/template/docs/engineering/compatibility-signals.md +7 -0
  75. package/template/docs/engineering/component-scope-report.md +16 -0
  76. package/template/docs/engineering/component-scope.md +19 -0
  77. package/template/docs/engineering/context/installer-owned-paths.manifest +96 -0
  78. package/template/docs/engineering/context/readme-section-affinity.json +30 -0
  79. package/template/docs/engineering/decisions.md +16 -0
  80. package/template/docs/engineering/legacy-drift-audit.md +21 -0
  81. package/template/docs/engineering/manifests/components/api-gateway.manifest.yaml +12 -0
  82. package/template/docs/engineering/manifests/registry.manifest.yaml +20 -0
  83. package/template/docs/engineering/manifests/repo.manifest.yaml +11 -0
  84. package/template/docs/engineering/phase-context.md +16 -0
  85. package/template/docs/engineering/release-targets.json +123 -0
  86. package/template/docs/engineering/research.md +29 -0
  87. package/template/docs/engineering/runbook.md +2320 -0
  88. package/template/docs/engineering/runtime-connectivity.md +81 -0
  89. package/template/docs/engineering/security-review.md +33 -0
  90. package/template/docs/engineering/spec-pack/README.md +20 -0
  91. package/template/docs/engineering/state-archive/README.md +15 -0
  92. package/template/docs/engineering/state.md +20 -0
  93. package/template/docs/engineering/status-normalization-report.md +19 -0
  94. package/template/docs/engineering/token-cost-parity-manifest.md +16 -0
  95. package/template/docs/engineering/us-0084-remote-e2e.md +44 -0
  96. package/template/docs/product/acceptance.md +1 -0
  97. package/template/docs/product/backlog.md +5 -0
  98. package/template/docs/product/vision.md +11 -0
  99. package/template/docs/user-guides/README.md +40 -0
  100. package/{handoffs → template/handoffs}/dev_to_qa.md +0 -3
  101. package/{handoffs → template/handoffs}/po_to_tl.md +0 -3
  102. package/{handoffs → template/handoffs}/qa_to_dev.md +1 -2
  103. package/template/handoffs/release_notes.md +51 -0
  104. package/template/handoffs/release_queue.md +47 -0
  105. package/template/handoffs/release_to_dev.md +31 -0
  106. package/template/handoffs/releases/Sxxxx-release-notes.md +62 -0
  107. package/template/handoffs/resume_brief.md +14 -0
  108. package/{handoffs → template/handoffs}/tl_to_dev.md +0 -2
  109. package/template/handoffs/token_cost_runs/README.md +26 -0
  110. package/template/its_magic/.its-magic-version +1 -0
  111. package/template/its_magic/README.md +9 -0
  112. package/template/scripts/auto_outer_driver.py +521 -0
  113. package/template/scripts/caveman_compress_input.py +903 -0
  114. package/template/scripts/check_downstream_ci_guard.py +67 -0
  115. package/template/scripts/check_intake_template_parity.py +284 -0
  116. package/template/scripts/check_token_cost_parity.py +69 -0
  117. package/template/scripts/dev_environment_lib.py +463 -0
  118. package/template/scripts/doc_profile_lib.py +415 -0
  119. package/template/scripts/downstream_ci_guard_lib.py +222 -0
  120. package/template/scripts/enforce-triad-hot-surface.py +753 -0
  121. package/template/scripts/guard_installer_publish.py +88 -0
  122. package/template/scripts/intake_bug_resume_brief_refresh.py +303 -0
  123. package/template/scripts/intake_bug_routing_guard.py +67 -0
  124. package/template/scripts/intake_evidence_lib.py +802 -0
  125. package/template/scripts/intake_evidence_validate.py +73 -0
  126. package/template/scripts/materialize_codebase_map.py +184 -0
  127. package/template/scripts/pack_json_validate.py +130 -0
  128. package/template/scripts/project_readme_coverage_lib.py +417 -0
  129. package/template/scripts/readme_feature_coverage_lib.py +608 -0
  130. package/template/scripts/remote_config_summary.py +243 -0
  131. package/template/scripts/sync_push_gates.py +198 -0
  132. package/template/scripts/token_cost_compare.py +40 -0
  133. package/template/scripts/token_cost_lib.py +108 -0
  134. package/template/scripts/uat_probe_lib.py +868 -0
  135. package/template/scripts/validate-and-push.ps1 +280 -0
  136. package/template/scripts/validate-and-push.sh +243 -0
  137. package/template/scripts/validate_doc_profile.py +103 -0
  138. package/template/scripts/validate_project_readme_coverage.py +151 -0
  139. package/template/scripts/validate_readme_feature_coverage.py +140 -0
  140. package/template/sprints/S0001/progress.md +1 -0
  141. package/template/sprints/S0001/qa-findings.md +9 -0
  142. package/template/sprints/S0001/release-findings.md +24 -0
  143. package/template/sprints/S0001/sprint.md +9 -0
  144. package/template/sprints/S0001/summary.md +7 -0
  145. package/template/sprints/S0001/tasks.md +1 -0
  146. package/template/sprints/S0001/uat.json +6 -0
  147. package/template/sprints/S0001/uat.md +5 -0
  148. package/template/sprints/quick/Q0001/summary.md +1 -0
  149. package/{sprints → template/sprints}/quick/Q0001/task.json +0 -1
  150. package/.cursor/agents/curator.mdc +0 -21
  151. package/.cursor/agents/dev.mdc +0 -20
  152. package/.cursor/agents/po.mdc +0 -19
  153. package/.cursor/agents/qa.mdc +0 -19
  154. package/.cursor/agents/release.mdc +0 -19
  155. package/.cursor/agents/tech-lead.mdc +0 -21
  156. package/.cursor/commands/gsd-architecture.md +0 -29
  157. package/.cursor/commands/gsd-auto.md +0 -27
  158. package/.cursor/commands/gsd-discovery.md +0 -27
  159. package/.cursor/commands/gsd-execute.md +0 -32
  160. package/.cursor/commands/gsd-intake.md +0 -28
  161. package/.cursor/commands/gsd-map-codebase.md +0 -25
  162. package/.cursor/commands/gsd-milestone-complete.md +0 -24
  163. package/.cursor/commands/gsd-milestone-start.md +0 -26
  164. package/.cursor/commands/gsd-pause.md +0 -25
  165. package/.cursor/commands/gsd-plan-verify.md +0 -26
  166. package/.cursor/commands/gsd-qa.md +0 -28
  167. package/.cursor/commands/gsd-quick.md +0 -24
  168. package/.cursor/commands/gsd-refresh-context.md +0 -26
  169. package/.cursor/commands/gsd-release.md +0 -29
  170. package/.cursor/commands/gsd-research.md +0 -28
  171. package/.cursor/commands/gsd-resume.md +0 -26
  172. package/.cursor/commands/gsd-sprint-plan.md +0 -30
  173. package/.cursor/commands/gsd-verify-work.md +0 -25
  174. package/.cursor/hooks.json +0 -26
  175. package/.cursor/plans/cursor-gsd-team-kit_8cfee9b8.plan.md +0 -57
  176. package/.cursor/remote.json +0 -18
  177. package/.cursor/rules/gsd-core.mdc +0 -18
  178. package/.cursor/rules/gsd-handoffs.mdc +0 -10
  179. package/.cursor/rules/gsd-quality.mdc +0 -15
  180. package/.cursor/scratchpad.md +0 -34
  181. package/.github/workflows/ci.yml +0 -47
  182. package/decisions/DEC-0001.md +0 -21
  183. package/decisions/DEC-0002.md +0 -21
  184. package/docs/engineering/architecture.md +0 -354
  185. package/docs/engineering/decisions.md +0 -6
  186. package/docs/engineering/research.md +0 -11
  187. package/docs/engineering/runbook.md +0 -32
  188. package/docs/engineering/state.md +0 -33
  189. package/docs/product/acceptance.md +0 -6
  190. package/docs/product/backlog.md +0 -7
  191. package/docs/product/vision.md +0 -46
  192. package/gsd-installer.ps1 +0 -189
  193. package/gsd-installer.py +0 -195
  194. package/gsd-installer.sh +0 -201
  195. package/handoffs/release_notes.md +0 -14
  196. package/handoffs/resume_brief.md +0 -8
  197. package/milestones/M0001/milestone.json +0 -7
  198. package/milestones/M0001/phases.json +0 -9
  199. package/milestones/M0001/progress.md +0 -3
  200. package/milestones/M0001/summary.md +0 -3
  201. package/scripts/generate-release-notes.ps1 +0 -74
  202. package/scripts/generate-release-notes.sh +0 -63
  203. package/scripts/release-all.ps1 +0 -423
  204. package/scripts/release-all.sh +0 -226
  205. package/sprints/S0001/progress.md +0 -4
  206. package/sprints/S0001/qa-findings.md +0 -113
  207. package/sprints/S0001/sprint.md +0 -70
  208. package/sprints/S0001/summary.md +0 -46
  209. package/sprints/S0001/tasks.md +0 -35
  210. package/sprints/S0001/uat.json +0 -8
  211. package/sprints/S0001/uat.md +0 -8
  212. package/sprints/quick/Q0001/summary.md +0 -3
  213. /package/{.cursor/rules/gsd-escalation.mdc → template/.cursor/rules/escalation.mdc} +0 -0
  214. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/acceptance.json +0 -0
  215. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/acceptance.md +0 -0
  216. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/architecture.json +0 -0
  217. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/architecture.md +0 -0
  218. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/decision.json +0 -0
  219. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/decision.md +0 -0
  220. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/handoff.json +0 -0
  221. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/handoff.md +0 -0
  222. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/milestone.json +0 -0
  223. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/phase-context.json +0 -0
  224. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/plan-verify.json +0 -0
  225. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/sprint.json +0 -0
  226. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/sprint.md +0 -0
  227. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/story.json +0 -0
  228. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/story.md +0 -0
  229. /package/{.cursor/skills/gsd-team → template/.cursor/skills/its-magic}/templates/uat.json +0 -0
  230. /package/{docs → template/docs}/engineering/context/phase-template.json +0 -0
  231. /package/{docs → template/docs}/engineering/dependencies.json +0 -0
  232. /package/{sprints → template/sprints}/S0001/plan-verify.json +0 -0
@@ -0,0 +1,533 @@
1
+ ---
2
+ description: "its-magic auto: deterministic continuation orchestrator."
3
+ ---
4
+
5
+ # /auto
6
+
7
+ ## Subagents
8
+ - curator
9
+ - tech-lead
10
+
11
+ ## Execution model
12
+ - `/auto` is a **spawn-only orchestrator**: it schedules materialization, spawns
13
+ fresh **phase-role** subagents, and verifies phase boundaries—it **must not**
14
+ execute lifecycle phase work, perform phase-role duties, or author **phase
15
+ deliverables** in the orchestrator context.
16
+ - For each phase, **spawn a fresh subagent** for that phase’s canonical role;
17
+ phase output must arrive only via artifacts and handoff files (no in-turn
18
+ orchestrator execution of that phase).
19
+ - Phase context transfer happens only through artifacts and handoff files.
20
+ - Scope is process/workflow orchestration only. Do not claim runtime product
21
+ orchestration changes.
22
+ - **Bug-queue mode** (**`US-0087`**) uses the same **spawn-only** contract: the
23
+ orchestrator schedules materialization and spawns phase-role subagents per
24
+ bug segment—it **must not** run **`execute`**, **`qa`**, or other lifecycle
25
+ phases in the orchestrator turn. Violations → **`AUTO_ORCHESTRATOR_PHASE_EXECUTION`**
26
+ (**`BUG-0006`**, **`US-0069`**, **`DEC-0051`**).
27
+
28
+ ## Spawn-boundary integrity (BUG-0006)
29
+
30
+ - **Forbidden**: treating the orchestrator turn as the executor of a lifecycle
31
+ phase (for example running **`architecture`**, **`execute`**, **`qa`**, or any
32
+ other **`phase_id`** in the orchestrator instead of spawning the required
33
+ subagent).
34
+ - **Fail fast** with **`AUTO_ORCHESTRATOR_PHASE_EXECUTION`**. **Remediation**:
35
+ stop; spawn a **fresh** subagent for the canonical **`phase_id`** and **`role`**
36
+ per the phase→role matrix (**DEC-0051**); do not merge phase output into
37
+ orchestrator turns. **Distinct from** **`PHASE_CONTEXT_ISOLATION_VIOLATION`**
38
+ (wrong writer / isolation break) and **`RUNTIME_PROOF_*`** / **`PHASE_ROLE_*`**
39
+ families—do not overload those codes for a missing-spawn violation.
40
+
41
+ ## Orchestrator post-subagent continuation mandate (BUG-0012 / DEC-0081)
42
+
43
+ **Orchestrator context only** — phase-role commands still **stop** and hand off via
44
+ artifacts (**BUG-0006**). When **`/auto`** runs as orchestrator, **post-subagent continuation**
45
+ is **not** optional when the next phase, drain-advance target, or relaxable retry within
46
+ budget is schedulable.
47
+
48
+ After any foreground phase-role subagent returns, orchestrator **MUST Task-spawn** the next
49
+ phase-role subagent per **US-0069** preflight. Orchestrator **must not** treat phase-role
50
+ handoff as run terminal; **phase-role stop is not run terminal** for the orchestrator when
51
+ continuation is schedulable.
52
+
53
+ | Actor | After phase completes |
54
+ |-------|----------------------|
55
+ | Phase-role subagent (`po`, `tech-lead`, `dev`, `qa`, …) | **Stop** — hand off via artifacts only (**BUG-0006**) |
56
+ | **`/auto` orchestrator** | **Continue** — orchestrator **MUST Task-spawn** when schedulable (**DEC-0080** / **BUG-0012**) |
57
+
58
+ Orchestrator **must not** emit mandatory re-**`/auto`**, mandatory **`auto_outer_driver.py`**, or
59
+ **`segment exhausted`** terminal prose when continuation is schedulable.
60
+
61
+ **Required contract literals** (regression anchors): **`orchestrator MUST Task-spawn`**,
62
+ **`post-subagent continuation`**, **`phase-role stop is not run terminal`**,
63
+ **`native chain supersedes Option B`**.
64
+
65
+ ## Continuous multi-phase execution (US-0088)
66
+
67
+ A single `/auto` orchestrated run advances through **all phases** in the
68
+ **intersected resolved schedule** (reference **Step 5**) until a
69
+ **deterministic stop condition** fires. The orchestrator does **not** stop after
70
+ spawning one phase unless the stop matrix requires it.
71
+
72
+ **native chain supersedes Option B** under **`AUTO_FLOW_MODE=full_autonomy`** + IDE + Task
73
+ available — native in-chat chain is **primary**; **Outer-driver equivalence (AC-1, Option B)**
74
+ applies **only** when **`NATIVE_CHAIN_UNAVAILABLE`** or headless/CI/`--invoke-cmd` context.
75
+ When a single Cursor `/auto` invocation cannot schedule multiple fresh subagent turns
76
+ (product/runtime constraint), a **documented outer driver** (operator script or manual
77
+ re-invocation with `start-from` / refreshed `resume_brief`) is **deterministically equivalent**
78
+ (**fallback only**) provided: same intersected phase order, same isolation + strict-proof
79
+ attestation per phase (**DEC-0038**), same stop reasons, and same `resume_brief` + `state.md`
80
+ refresh at every boundary. Operators must follow the runbook recipe
81
+ (**`docs/engineering/runbook.md`** § Continuous `/auto` + backlog drain).
82
+
83
+ **Deterministic stop matrix** (see also architecture `# US-0088`):
84
+
85
+ | Condition | Behavior |
86
+ |-----------|----------|
87
+ | Next phase exists, no hard stop | **Continue** — preflight US-0069, spawn next phase |
88
+ | `decision_gate` | **Stop** (non-suppressible) |
89
+ | `error` / missing critical input | **Stop** (non-suppressible) |
90
+ | `AUTO_PAUSE_REQUEST` / `pause` | **Stop** at safe boundary (non-suppressible) |
91
+ | `AUTO_LOOP_MAX_CYCLES` / `loop_max` | **Stop** (non-suppressible) |
92
+ | `blocked` (sync/scope gate) | **Stop** (non-suppressible) |
93
+ | US lifecycle DONE / sprint segment complete | **IDE `full_autonomy`**: orchestrator **must** drain-advance in-chat (no operator re-`/auto`). **Other modes / fallback**: stop segment; `AUTO_BACKLOG_DRAIN=1` may advance (recompute phase plan — **reference Step 5**) |
94
+ | `BACKLOG_MAX_STORIES_REACHED` | **Stop** (non-suppressible) |
95
+
96
+ `stop_reason` vocabulary: `completed`, `decision_gate`, `missing_input`,
97
+ `pause_request`, `loop_max`, `error`, `blocked`.
98
+
99
+ ## Native in-chat auto-chain (US-0095 / DEC-0080)
100
+
101
+ When **`AUTO_FLOW_MODE=full_autonomy`** runs in **Cursor IDE**, the orchestrator
102
+ **self-chains in-chat** across intersected lifecycle phases and backlog-drain
103
+ segment boundaries via a **foreground sequential** Task/subagent loop in the
104
+ **same /auto orchestrator session** — without mandatory outer driver or manual
105
+ re-invocation between segments.
106
+
107
+ ### Activation gate
108
+
109
+ | # | Condition |
110
+ |---|-----------|
111
+ | 1 | Merged scratchpad **`AUTO_FLOW_MODE=full_autonomy`** (exact literal) |
112
+ | 2 | Invocation context = **Cursor IDE** (default Agent panel `/auto` without `--invoke-cmd`) |
113
+ | 3 | Task tool available for foreground subagent spawn |
114
+
115
+ Set **`native_chain_active=true`** in `state.md` phase boundary when all hold.
116
+ Set **`native_chain_continuing=true`** when orchestrator scheduled next spawn/advance **this**
117
+ boundary. Set **`drain_advance_action=spawned|skipped|not_applicable`** on drain-advance
118
+ boundaries (**`skipped`** when budget > 0 + OPEN item exists is **invalid**). When
119
+ **`native_chain_continuing=true`**, **`stop_reason`** must **not** be
120
+ **`completed (segment exhausted)`** and operator prose must **not** mandate re-**`/auto`**.
121
+
122
+ ### Continuation loop (reference Step 5 — IDE primary)
123
+
124
+ 1. Resolve next `phase_id` from intersected schedule or drain-advance target.
125
+ 2. **US-0069** preflight (role matrix + capability gate).
126
+ 3. **Spawn fresh subagent** (Task tool, foreground — blocks until done).
127
+ 4. Verify isolation evidence + **DEC-0038** strict-proof tuple in `state.md`.
128
+ 5. Increment **`outer_cycle_index`**; check **`AUTO_LOOP_MAX_CYCLES`**.
129
+ 6. Branch stop matrix → continue spawn, drain-advance, block-retry, or hard stop.
130
+
131
+ **Loop invariants** (spawn-only — **BUG-0006** unchanged):
132
+
133
+ 1. Orchestrator **must not** stop after one phase or one story segment solely due to Cursor turn boundaries when continuation is schedulable.
134
+ 2. Each phase completes only via **fresh subagent spawn** + artifacts — orchestrator **must not** execute phase-role work in-band (**`AUTO_ORCHESTRATOR_PHASE_EXECUTION`** forbidden).
135
+ 3. **`stop_reason=completed (segment exhausted)`** is **invalid** when next phase, drain target, or relaxable retry is schedulable.
136
+
137
+ Preflight/post checks per **US-0069** / **DEC-0051** at every boundary.
138
+
139
+ ### Fail-closed: `NATIVE_CHAIN_UNAVAILABLE`
140
+
141
+ Emit when Task tool denied, spawn depth limit hit, or IDE context cannot schedule foreground subagent. Hard stop for native path. Optional fallback hint only: `python scripts/auto_outer_driver.py --repo .` (**optional** / **fallback** for headless/CI). **Non-suppressible** under **`AUTO_QUIET=1`**.
142
+
143
+ ### IDE drain-advance-without-pause
144
+
145
+ Deterministic **7-step** algorithm when **`full_autonomy`** + drain policy active (**`AUTO_BACKLOG_DRAIN=1`** or bug-queue per **US-0087** mutex).
146
+
147
+ **Trigger** (all required): `stop_phase=refresh-context`; `stop_reason=completed`; drain enabled; budget remaining.
148
+
149
+ | Step | Action |
150
+ |------|--------|
151
+ | **1** | **READ** latest phase-boundary block in `docs/engineering/state.md` |
152
+ | **2** | **ASSERT** **DEC-0069** pairing — completed phase refreshed **`resume_brief`** + **`state.md`**; stale → **`RESUME_BRIEF_STALE`** (fail-closed, no advance) |
153
+ | **3** | **SELECT** next work item (story or bug per drain mutex) |
154
+ | **4** | **RELOAD** scratchpad; **MATERIALIZE** `resolved_phase_plan` (**US-0070**) |
155
+ | **5** | **PREPEND** `handoffs/resume_brief.md` with segment pointers |
156
+ | **6** | **APPEND** `state.md` materialization breadcrumb for new segment |
157
+ | **7** | **IMMEDIATELY** spawn first phase subagent — **without operator re-`/auto`**, **no** mandatory outer-driver instruction |
158
+
159
+ **Between steps 6 and 7** (no operator stop): orchestrator **must not** emit operator wait
160
+ instructions, set **`stop_reason=completed (segment exhausted)`** when drain budget > 0 and
161
+ eligible OPEN item exists, or skip Task-spawn for step **7**. Attest
162
+ **`drain_advance_action=spawned|skipped|not_applicable`** on `state.md` phase boundary;
163
+ **`skipped`** when budget > 0 + OPEN item exists is **invalid** (regression).
164
+
165
+ **DEC-0069 pairing mandate**: every phase boundary and drain advance **must** refresh **`resume_brief`** + **`state.md`** before scheduling in-chat continuation. Stale brief → **`RESUME_BRIEF_STALE`** fail-closed (no advance). Orchestrator **MUST Task-spawn** next phase — **`/auto`** is orchestrator context label, not operator re-invocation instruction.
166
+
167
+ ### Native-chain stop matrix (US-0095)
168
+
169
+ Native chain **does not weaken** **DEC-0078** hard gates. Hard stops (no relaxation): **`decision_gate`**, isolation/strict-proof violations, security deny, **`BACKLOG_MAX_STORIES_REACHED`**, **`AUTO_LOOP_MAX_CYCLES`**, unrecoverable **`error`**, **`pause_request`**. Relaxable transient stops per **DEC-0078** when configured.
170
+
171
+ ### `AUTO_QUIET` under native chain (US-0095)
172
+
173
+ | Event | `AUTO_QUIET=0` | `AUTO_QUIET=1` |
174
+ |-------|----------------|----------------|
175
+ | Routine phase PASS | May notify | **Suppress** |
176
+ | In-chat phase continuation | Compact breadcrumb OK | **Suppress** |
177
+ | Drain advance | Segment notify OK | **Suppress** routine prose; **no** outer-driver wait |
178
+ | Gates, caps, errors, **`NATIVE_CHAIN_UNAVAILABLE`** | **Always** | **Always** |
179
+
180
+ **Forbidden** in IDE-primary `full_autonomy` prose: mandatory `run the outer driver`; `re-run /auto` between drain segments; `segment exhausted` as terminal when continuation pending; unqualified `python scripts/auto_outer_driver.py`.
181
+
182
+ Full detail: **`docs/engineering/auto-orchestration-reference.md`**.
183
+
184
+ ## Full-autonomy mode + outer driver (US-0092 / DEC-0078)
185
+
186
+ **`AUTO_FLOW_MODE=full_autonomy`** (exact literal, default-off) enables hands-off
187
+ orchestration. **IDE primary path** (US-0095): run **`/auto` once in Cursor** —
188
+ native in-chat auto-chain above. **Optional fallback**: stdlib outer driver
189
+ **`scripts/auto_outer_driver.py`** for headless/CI or when **`NATIVE_CHAIN_UNAVAILABLE`**.
190
+
191
+ The driver **loops hook invocations** — spawn-only preserved (**BUG-0006**); it
192
+ never performs phase-role work. Headless/CI recipe: set scratchpad keys → run
193
+ `python scripts/auto_outer_driver.py --repo .` once (**fallback** for headless/CI) → interpret exit table in
194
+ **`docs/engineering/runbook.md`** § **Full-autonomy outer driver (US-0092)** (**fallback**).
195
+
196
+ **Drain-advance-without-pause**: with **`full_autonomy`** + **`AUTO_BACKLOG_DRAIN=1`**
197
+ (or bug-queue policy), segment completion schedules the next OPEN story/bug
198
+ **immediately** **without operator re-`/auto`**; **`resume_brief`** +
199
+ **`state.md`** refresh per **DEC-0069** at every boundary.
200
+
201
+ ### Full-autonomy stop matrix (US-0092)
202
+
203
+ **Invariant**: **`full_autonomy`** relaxes recoverable transient stops and operator
204
+ re-invocation, not governance gates. **`RELEASE_PUBLISH_MODE=auto`** remains
205
+ explicit opt-in for publish (unchanged default-off).
206
+
207
+ | Condition | US-0088 (all modes) | `full_autonomy` delta |
208
+ |-----------|---------------------|------------------------|
209
+ | Next phase, no hard stop | Continue inner `/auto` | Native chain continues in-chat; outer driver **re-invokes** only on **`NATIVE_CHAIN_UNAVAILABLE`** / headless **fallback** |
210
+ | `decision_gate` | Hard stop | **No change — hard** |
211
+ | Unrecoverable `error` | Hard stop | **No change — hard** |
212
+ | Critical `missing_input` | Hard stop | **No change — hard** |
213
+ | Transient `missing_input` (recoverable) | Hard stop | **Relaxable** — bounded block-retry (`AUTO_BLOCK_RETRY_MAX`) |
214
+ | `pause_request` / `AUTO_PAUSE_REQUEST` | Hard stop | **No change — hard** |
215
+ | `loop_max` / `AUTO_LOOP_MAX_CYCLES` | Hard stop | **No change — hard** |
216
+ | `blocked` — transient/sync | Hard stop | **Relaxable** when ledger classifies recoverable |
217
+ | `blocked` — isolation / strict-proof / ownership | Hard stop | **No change — hard** |
218
+ | UAT/QA fail | Hard stop (operator) | **Relaxable** when `AUTO_IMPLEMENTATION_LOOP=1` |
219
+ | Segment complete + `AUTO_BACKLOG_DRAIN=1` | Advance (may need manual re-`/auto` in non-native modes) | **Drain-without-pause** — immediate in-chat continuation; **no** operator re-`/auto` |
220
+ | `BACKLOG_MAX_STORIES_REACHED` | Hard stop | **No change — hard** |
221
+ | `AUTO_SCHEDULER_CONFLICT` | Hard stop | **No change — hard** |
222
+ | Security deny (`.env`, intake evidence mutation) | Hard deny | **No change — hard** |
223
+
224
+ Block-retry ledger: append-only **`handoffs/auto_block_retry/<orchestrator_run_id>.jsonl`**
225
+ (names-only; cap exhaustion → exit **6** `BLOCK_RETRY_CAP_EXHAUSTED`). See architecture
226
+ **`# US-0092`** and **`docs/engineering/auto-orchestration-reference.md`**.
227
+
228
+ ## Full specification (US-0080 / DEC-0062)
229
+
230
+ Long prose, expanded mode semantics, and **Steps 1–13** detail live in
231
+ **`docs/engineering/auto-orchestration-reference.md`** (jointly normative). This file
232
+ keeps **contract excerpts** required for regression parity and default `/auto` loads.
233
+
234
+ ## Per-phase isolation enforcement (US-0048 / DEC-0029)
235
+
236
+ - Orchestrator must not write phase deliverables (`PHASE_CONTEXT_ISOLATION_VIOLATION`).
237
+ - Each spawned phase appends isolation evidence to `docs/engineering/state.md`
238
+ with `phase_id`, `role`, `fresh_context_marker`, `timestamp`, `evidence_ref`.
239
+ - Fail closed on missing/invalid/stale evidence.
240
+
241
+ Reason codes: `PHASE_CONTEXT_ISOLATION_MISSING`, `PHASE_CONTEXT_ISOLATION_VIOLATION`,
242
+ `ISOLATION_EVIDENCE_STALE`, `ISOLATION_EVIDENCE_INVALID`.
243
+
244
+ ## Strict runtime proof enforcement (US-0056 / DEC-0038)
245
+
246
+ - Each completed phase supplies tuple: `orchestrator_run_id`, `runtime_proof_id`,
247
+ `phase_id`, `role`, `proof_issued_at`, `proof_ttl_seconds`, `proof_hash`
248
+ (hash = SHA-256 sorted-key JSON per **DEC-0038**).
249
+ - `runtime_proof_id` unique per phase run; enforce TTL freshness and linkage.
250
+
251
+ Reason codes: `RUNTIME_PROOF_MISSING`, `RUNTIME_PROOF_INVALID`, `RUNTIME_PROOF_REUSED`,
252
+ `RUNTIME_PROOF_STALE`, `RUNTIME_PROOF_AMBIGUOUS_LINK`.
253
+
254
+ ## Strict phase role enforcement (US-0069 / DEC-0051)
255
+
256
+ Post-hoc markers alone are insufficient: preflight expected role, capability gate,
257
+ post-completion match of isolation + strict-proof `role`, execute default deny unless
258
+ override governance is satisfied.
259
+
260
+ ### Canonical phase→role matrix (fixed defaults)
261
+
262
+ | phase_id | Allowed roles | Default when no valid alternate policy |
263
+ |----------|-----------------|----------------------------------------|
264
+ | `intake` | `po` | `po` |
265
+ | `discovery` | `po` | `po` |
266
+ | `research` | `po`, `tech-lead` | `tech-lead` |
267
+ | `architecture` | `tech-lead` | `tech-lead` |
268
+ | `sprint-plan` | `tech-lead` | `tech-lead` |
269
+ | `plan-verify` | `qa`, `tech-lead` | `qa` |
270
+ | `execute` | `dev` (override path only) | `dev` |
271
+ | `qa` | `qa` | `qa` |
272
+ | `verify-work` | `qa` | `qa` |
273
+ | `release` | `release` | `release` |
274
+ | `refresh-context` | `curator`, `po` | `curator` |
275
+
276
+ Alternate-role keys (merged scratchpad): `AUTO_ROLE_RESEARCH`, `AUTO_ROLE_PLAN_VERIFY`,
277
+ `AUTO_ROLE_REFRESH_CONTEXT` — single-valued resolution per **DEC-0051** (see reference).
278
+
279
+ Execute override: requires `AUTO_EXECUTE_ROLE_OVERRIDE=allowed_non_dev_execute` **and**
280
+ parseable `EXECUTE_OVERRIDE_GOVERNANCE_REF`.
281
+
282
+ Role reason codes: `PHASE_ROLE_CAPABILITY_MISSING`, `PHASE_ROLE_MISMATCH`.
283
+
284
+ ## Mode-scoped delivery resolver — step 0 (US-0096 / DEC-0082)
285
+
286
+ **Before** **Configurable phase selection policy (US-0070 / DEC-0052)**, **resolve_delivery_mode**
287
+ from precedence: argv `delivery-mode=` → backlog row `delivery_mode` (when
288
+ `AUTO_DELIVERY_ROUTING=backlog_then_scratchpad`) → scratchpad `DELIVERY_MODE` → **`standard`**.
289
+
290
+ | `delivery_mode` | `resolved_phase_plan` | `reinstatement_mode` | `memory_layer` |
291
+ |-----------------|----------------------|---------------------|----------------|
292
+ | `standard` | Full **DEC-0052** chain | `dec0052_default` | `standard` |
293
+ | `ultra_lean` | `[spec, plan, build+verify, ship]` | `none` | `pack` |
294
+ | `mega_quick` | `[quick]` when eligible (+1 on test failure) | `none` | `quick` |
295
+
296
+ **reinstatement applies only when delivery_mode=standard**. **`AUTO_PHASE_*`** applies **only**
297
+ when `delivery_mode=standard`; non-standard + non-default **`AUTO_PHASE_*`** →
298
+ **`PHASE_POLICY_CONFLICT`** (fail closed).
299
+
300
+ **`DELIVERY_MODE_SWITCH_MID_STORY`**: fail closed — complete segment in one mode.
301
+
302
+ Persist breadcrumbs at each phase boundary in `state.md` + top `resume_brief` pointer:
303
+ **`delivery_mode`**, **`resolved_phase_plan`**, **`reinstatement_mode`**, **`memory_layer`**.
304
+
305
+ ### `ultra_lean` macro-phases (US-0096 / DEC-0082)
306
+
307
+ Four macro-phases — **no** eleven-phase reinstatement when `delivery_mode=ultra_lean`:
308
+
309
+ | Macro | Merged canonical phases | Default role |
310
+ |-------|------------------------|--------------|
311
+ | **`spec`** | intake + discovery | **po** |
312
+ | **`plan`** | research + architecture + sprint-plan | **tech-lead** |
313
+ | **`build+verify`** | execute + qa + verify-work | **dev** / **qa** |
314
+ | **`ship`** | release + refresh-context | **release** / **curator** |
315
+
316
+ **`AUTO_IMPLEMENTATION_LOOP`** preserved inside **`build+verify`**. QA merges AC checklist + UAT
317
+ in one spawn.
318
+
319
+ ### `mega_quick` routing (US-0096 / DEC-0082)
320
+
321
+ When `DELIVERY_MODE=mega_quick` and eligible, materialize **`["quick"]`** only. Ineligible →
322
+ **`DELIVERY_MODE_INELIGIBLE`** + specific **`MEGA_QUICK_*`** code:
323
+
324
+ | Code | Rule |
325
+ |------|------|
326
+ | **`MEGA_QUICK_BUG_SEGMENT`** | Story-only (no bug segment) |
327
+ | **`MEGA_QUICK_AC_TOO_BROAD`** | AC ≤ 3 |
328
+ | **`MEGA_QUICK_ARCHITECTURE_REQUIRED`** | No companion DEC required |
329
+ | **`MEGA_QUICK_SPRINT_EXISTS`** | No active `sprints/Sxxxx/` for story |
330
+ | **`MEGA_QUICK_STORY_OVERRIDE`** | Row `delivery_mode` consistent when routing enabled |
331
+ | **`MEGA_QUICK_MULTI_COMPONENT`** | Single component or `COMPONENT_SCOPE_MODE=0` |
332
+ | **`MEGA_QUICK_GATE_ESCALATION`** | No elevated gates beyond default `/quick` |
333
+
334
+ Artifacts: **`sprints/quick/Qxxxx/task.json`** + **`summary.md`**. Second spawn on test
335
+ failure only. Closure requires **`acceptance_met: true`** + green tests.
336
+
337
+ ## Configurable phase selection policy (US-0070 / DEC-0052)
338
+
339
+ Treat **resolved phase plan** as fail-closed schedule from merged scratchpad **before**
340
+ resume / `start-from` intersection. Canonical lifecycle:
341
+
342
+ `intake` → `discovery` → `research` → `architecture` → `sprint-plan` →
343
+ `plan-verify` → `execute` → `qa` → `verify-work` → `release` → `refresh-context`
344
+
345
+ Selectors and reinstatement: see reference. Phase-plan reason codes include
346
+ `PHASE_POLICY_CONFLICT`, `PHASE_PLAN_UNKNOWN_PHASE`, `START_FROM_PHASE_PLAN_EMPTY_INTERSECTION`.
347
+
348
+ Phase boundary visibility (**AC-10**): record `resolved_phase_plan` snapshot,
349
+ `skipped_phases`, `phase_boundary`, `next_scheduled_phase` on `state.md`. For
350
+ bug-queue segments, also record **`segment_work_item_kind`**, **`active_bug_id`**,
351
+ **`bug_queue_position`**, **`bug_queue_remaining`**, **`backlog_drain_active`**,
352
+ **`bug_queue_active`** per **`docs/engineering/architecture.md`** **`# US-0087`**
353
+ and **`docs/engineering/auto-orchestration-reference.md`**.
354
+
355
+ ## Inputs
356
+
357
+ - **Narrow-read (US-0053 / US-0096 Tranche A)**: Start at `docs/engineering/phase-context.md`
358
+ and the story section anchor in vision/architecture/decisions when a heading exists; forbid
359
+ full-file reads when a section heading exists.
360
+
361
+ Merged scratchpad (**US-0073** / **DEC-0055**), automation flags (`AUTO_*`, `SECURITY_REVIEW`,
362
+ `TEAM_*`), phase-plan keys `AUTO_PHASE_PLAN`, `AUTO_PHASE_EXCLUDE`, `AUTO_PHASE_INCLUDE`,
363
+ `AUTO_PHASE_PROFILE`, `AUTO_PHASE_HIGH_RISK_ACK`, product/engineering docs,
364
+ optional `start-from=<phase>`, optional **`bug-target=BUG-####`** or
365
+ **`bug-target=all-open`**, optional `--execute-bulk`, `handoffs/resume_brief.md`,
366
+ `docs/engineering/state.md`.
367
+
368
+ ## Automation remote routing contract (US-0086)
369
+
370
+ - Automation-only gate: `AUTO_REMOTE_AUTOMATION_PROFILE=deterministic_v1` enables
371
+ target routing; `off` keeps manual/local behavior unchanged.
372
+ - Explicit intent literal is constrained to: `start container <target_id>`.
373
+ - Deterministic precedence when profile is enabled:
374
+ 1. explicit intent target id resolution,
375
+ 2. canonical target validation (`targets[].id` exists and is enabled),
376
+ 3. documented heuristic fallback,
377
+ 4. local default when no remote target is selected.
378
+ - Fail-closed reason codes (do not overload):
379
+ `REMOTE_AUTOMATION_MODE_OFF`, `REMOTE_TARGET_UNKNOWN`,
380
+ `REMOTE_TARGET_DISABLED`, `REMOTE_TARGET_UNROUTABLE`.
381
+ - Mode-off guardrail: never silently reroute `TEST_COMMAND` to remote when
382
+ automation profile is disabled.
383
+
384
+ ## Canonical status contract (US-0045)
385
+
386
+ Story status authority: `docs/product/backlog.md` only; do not infer readiness from
387
+ contradictory derived views.
388
+
389
+ ## Outputs (artifacts)
390
+
391
+ Phase artifacts, `docs/engineering/state.md`, `handoffs/resume_brief.md` when stopped,
392
+ QA loop handoffs when applicable, continuation breadcrumbs including `resolution_source`
393
+ (`argument|resume_brief|state_fallback`) and related resume metadata per reference.
394
+
395
+ ## Stop conditions
396
+
397
+ Deterministic stop reasons (see **Stop matrix** in `## Continuous multi-phase
398
+ execution (US-0088)` above): `completed`, `decision_gate`, `missing_input`,
399
+ `pause_request`, `loop_max`, `error`, `blocked`.
400
+
401
+ ## Optional backlog-drain mode (US-0044 / DEC-0022)
402
+
403
+ Canonical controls: `AUTO_BACKLOG_DRAIN`, `AUTO_BACKLOG_MAX_STORIES`, `AUTO_BACKLOG_ON_BLOCK`,
404
+ `AUTO_STORY_SELECTION`. When `AUTO_BACKLOG_DRAIN=1`, each story advances through
405
+ **multiple phases** until its terminal boundary (**reference Step 5**); the
406
+ orchestrator **recomputes** the materialized phase plan at each **story boundary**
407
+ and selects the **next eligible OPEN story** per `AUTO_STORY_SELECTION`.
408
+ Reason codes include `BACKLOG_MAX_STORIES_REACHED`. Full semantics: reference.
409
+
410
+ ## Optional bug-queue mode (US-0087)
411
+
412
+ Canonical **argv** literals (exact strings; **no aliases** in v1):
413
+ - **`bug-target=BUG-####`** (example: **`bug-target=BUG-0007`**) — single defect from
414
+ **`docs/product/backlog.md`** **`## Bug issues (canonical)`** with status **OPEN**.
415
+ - **`bug-target=all-open`** — deterministic **OPEN**-only queue, ascending **numeric**
416
+ **`BUG-####`** sort, optional cap **`AUTO_BUG_MAX_ITEMS`** (see reference).
417
+
418
+ Scratchpad keys (**default-off**): **`AUTO_BUG_QUEUE`**, **`AUTO_BUG_TARGET`**,
419
+ **`AUTO_BUG_MAX_ITEMS`**, **`AUTO_BUG_ON_BLOCK`** — full semantics: reference +
420
+ **`architecture.md`** **`# US-0087`**.
421
+
422
+ **Scheduler mutex**: if merged scratchpad has **`AUTO_BACKLOG_DRAIN=1`** **and**
423
+ **`AUTO_BUG_QUEUE=1`** **and** this invocation has **no** explicit **`bug-target=`**
424
+ argv token → fail closed with **`AUTO_SCHEDULER_CONFLICT`** (use
425
+ **`[AUTO_RESUME_ERROR] AUTO_SCHEDULER_CONFLICT: ...`** form per reference). When
426
+ **`bug-target=`** argv is present, it **selects** the bug scheduler for this run;
427
+ **`AUTO_BACKLOG_DRAIN`** must **not** also drive story selection for that same
428
+ materialized run.
429
+
430
+ Fail-closed codes (orthogonal to existing resume/phase codes; do **not** overload):
431
+ - **`AUTO_BUG_QUEUE_EMPTY`** — **`all-open`** (or equivalent) and zero **OPEN** bugs.
432
+ - **`AUTO_BUG_TARGET_UNKNOWN`** — malformed id, wrong pattern, or id missing from canonical bug section.
433
+ - **`AUTO_BUG_TARGET_NOT_OPEN`** — known id exists but status is not **OPEN** (e.g. **DONE**).
434
+
435
+ ## Optional bulk execute mode (US-0047 / DEC-0024)
436
+
437
+ Explicit `--execute-bulk` or `AUTO_EXECUTE_BULK=1`. Reason codes include
438
+ `EXEC_BULK_MAX_ITEMS_REACHED`, `EXEC_TEAM_SCOPE_BLOCKED`, `EXEC_TEAM_SCOPE_SKIPPED`. Full
439
+ semantics: reference.
440
+
441
+ ## Sync policy contract (US-0038 / DEC-0018)
442
+
443
+ Phase-completion boundary evaluation only. **Guarded auto-push eligibility chain**
444
+ (checklist in reference). Reason codes include `BRANCH_NOT_ALLOWLISTED`, `TEST_COMMAND_MISSING`,
445
+ `SYNC_PUSHED`. Full list: reference.
446
+
447
+ ## Canonical `start-from` phase IDs
448
+
449
+ `intake`, `discovery`, `research`, `architecture`, `sprint-plan`, `plan-verify`,
450
+ `execute`, `qa`, `verify-work`, `release`, `refresh-context` — aliases invalid.
451
+
452
+ ## Deterministic resume-source precedence
453
+
454
+ Resolve nominal start phase and scheduler inputs in strict order (**`US-0087`**
455
+ extends scratchpad vs **`resume_brief`** ordering — full matrix: reference):
456
+
457
+ 1. Explicit `/auto start-from=<phase>`
458
+ 2. Explicit **`bug-target=`** argv token when present (parsed **before** merged
459
+ scratchpad scheduler keys; selects bug scheduler for this run).
460
+ 3. Merged scratchpad (**`US-0073`** / **`DEC-0055`**) — including **`AUTO_BACKLOG_DRAIN`**,
461
+ **`AUTO_BUG_QUEUE`**, **`AUTO_BUG_TARGET`**, etc.
462
+ 4. `handoffs/resume_brief.md`
463
+ 5. Conservative `docs/engineering/state.md` fallback
464
+ 6. Fail fast on ambiguity/conflict/unrecoverable inputs (including
465
+ **`AUTO_SCHEDULER_CONFLICT`** when both schedulers are enabled in scratchpad
466
+ without **`bug-target=`** argv resolution).
467
+
468
+ If `resume_brief.md` is present but stale or unparseable, fail fast instead
469
+ of silently falling back.
470
+
471
+ ## Fail-fast error code contract
472
+
473
+ All resume-resolution failures must use:
474
+
475
+ [AUTO_RESUME_ERROR] <code>: <summary>. Source=<source>. Fix: <action>.
476
+
477
+ Required codes:
478
+ - `INVALID_START_FROM`
479
+ - `RESUME_BRIEF_MISSING`
480
+ - `RESUME_BRIEF_STALE`
481
+ - `RESUME_BRIEF_UNPARSEABLE`
482
+ - `RESUME_STATE_CONFLICT`
483
+ - `STATE_PHASE_AMBIGUOUS`
484
+ - `STATE_PHASE_UNRECOVERABLE`
485
+
486
+ Bug-queue extensions (**`US-0087`**; same **`[AUTO_RESUME_ERROR]`** envelope when
487
+ used for resume/materialization failures):
488
+
489
+ - `AUTO_SCHEDULER_CONFLICT`
490
+ - `AUTO_BUG_QUEUE_EMPTY`
491
+ - `AUTO_BUG_TARGET_UNKNOWN`
492
+ - `AUTO_BUG_TARGET_NOT_OPEN`
493
+
494
+ ## Steps (compact; full detail in reference)
495
+
496
+ 1. Read automation flags from merged scratchpad and **materialize the resolved
497
+ phase plan** per **Configurable phase selection policy (US-0070 / DEC-0052)**; append
498
+ plan breadcrumbs to `docs/engineering/state.md` **before** first spawn.
499
+ 2. Parse `start-from` / **`bug-target=`** / `--execute-bulk`; resolve scheduler
500
+ mutex (**`AUTO_SCHEDULER_CONFLICT`** when applicable); resolve nominal start phase;
501
+ intersect with plan.
502
+ 3. Record continuation metadata (`invocation_mode=auto`, `requested_start_from`,
503
+ `resolved_start_phase`, `resolution_source`, `resolution_status`, `timestamp`).
504
+ 4. Spawn fresh subagents per intersected schedule; enforce **US-0069** preflight/post checks.
505
+ 5. **Multi-phase continuation** (normative detail: **reference Step 5** in
506
+ **`docs/engineering/auto-orchestration-reference.md`** `## Steps` item 5):
507
+ advance through **all remaining phases** in the intersected resolved schedule
508
+ order until a **deterministic stop condition** fires (see **Stop matrix** in
509
+ `## Continuous multi-phase execution (US-0088)` above). When
510
+ `AUTO_BACKLOG_DRAIN=1`, repeat the story lifecycle for the next eligible OPEN
511
+ story, **reloading** scratchpad and **recomputing** the materialized phase
512
+ plan at each story boundary.
513
+ Outer-driver equivalence applies when **`NATIVE_CHAIN_UNAVAILABLE`**, headless/CI, or
514
+ `--invoke-cmd` prevents in-chat scheduling (**AC-1 Option B** — **fallback only**;
515
+ **native chain supersedes Option B** in IDE **`full_autonomy`**).
516
+ `stop_reason`: `completed|decision_gate|missing_input|pause_request|loop_max|error|blocked`.
517
+ 6. Isolation evidence verification at each boundary (**reference** step 11a).
518
+ 7. At each phase boundary, verify strict runtime attestation tuple exists
519
+ and is valid for the completed phase (`orchestrator_run_id`, `runtime_proof_id`,
520
+ `phase_id`, `role`, `proof_issued_at`, `proof_ttl_seconds`, `proof_hash`)
521
+ (**reference** step 11b).
522
+ 8. Sync verdict recording when eligible — reference step 12.
523
+ 9. Backlog-drain / bulk per-item summaries when enabled — reference step 13.
524
+
525
+ ## Backward compatibility
526
+
527
+ Default manual/interactive unchanged; `/resume` remains valid; deterministic precedence
528
+ applies for `/auto` continuation.
529
+
530
+ ## Deterministic artifact ordering guard (US-0058 / DEC-0040)
531
+
532
+ Follow `docs/engineering/artifact-ordering-policy.md` (`state.md` append-bottom, etc.);
533
+ `ARTIFACT_ORDERING_ANCHOR_AMBIGUOUS` fail-closed.
@@ -0,0 +1,47 @@
1
+ ---
2
+ description: "its-magic discovery: collect design/UX inspiration and scope updates."
3
+ ---
4
+
5
+ # /discovery
6
+
7
+ ## Subagents
8
+ - po
9
+
10
+ ## Execution model
11
+ - Run `/discovery` in a fresh PO subagent context.
12
+ - After writing outputs, stop and hand off to `/research` in a new
13
+ subagent/chat.
14
+
15
+ ## Inputs
16
+
17
+ - **Narrow-read (US-0053 / US-0096 Tranche A)**: Start at docs/engineering/phase-context.md
18
+ and the story section anchor in vision/architecture/decisions when a heading exists; forbid
19
+ full-file reads when a section heading exists.
20
+ - Design/UX references
21
+ - Competitive/market notes
22
+
23
+ ## Outputs (artifacts)
24
+ - `docs/product/vision.md`
25
+ - `docs/product/backlog.md`
26
+ - `handoffs/po_to_tl.md`
27
+
28
+ ## Stop conditions
29
+ - Missing references
30
+ - Decision gate triggered
31
+
32
+ ## Steps
33
+ 1. Capture references and UX notes in vision.
34
+ 2. Add new stories or updates to backlog.
35
+ 3. Refresh the PO -> TL handoff.
36
+ 4. Triad hot-surface gate (DEC-0054) when `handoffs/po_to_tl.md` is mutated:
37
+ - run `python scripts/enforce-triad-hot-surface.py --rollover` then `--check`
38
+ from repository root,
39
+ - on failure stop with `STATE_ARCHIVE_REQUIRED` or
40
+ `ARTIFACT_HOT_SURFACE_OVERSIZE`,
41
+ - record verification tuple fields when rollover occurred (see runbook).
42
+
43
+ 5. Default minimal-read posture: start at `docs/engineering/phase-context.md`,
44
+ then vision/backlog/tail of `handoffs/po_to_tl.md` per runbook table; escalate
45
+ only to a named archive `pack_ref` when unresolved (`CONTEXT_BUDGET_EXCEEDED`
46
+ on unbounded reads).
47
+