@azure-id/orc 0.56.1 → 1.0.0

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 (153) hide show
  1. package/CHANGELOG.md +2367 -2218
  2. package/README-id.md +49 -107
  3. package/README.md +45 -133
  4. package/bin/build-agents.js +18 -11
  5. package/bin/cli.js +33060 -29855
  6. package/bin/onboarding-content.js +0 -3
  7. package/bin/test-run.js +491 -0
  8. package/bin/verify-contracts.js +4256 -3277
  9. package/bin/verify-package.js +563 -498
  10. package/bin/webui/api.js +1186 -1163
  11. package/bin/webui/app.html +9 -0
  12. package/bin/webui/css/06-responsive.css +120 -108
  13. package/bin/webui/css/panels/extra.css +29 -0
  14. package/bin/webui/css/panels/lanes.css +134 -0
  15. package/bin/webui/css/panels/settings.css +79 -3
  16. package/bin/webui/fixtures/extra.js +2036 -1934
  17. package/bin/webui/fixtures/flow.js +2 -2
  18. package/bin/webui/fixtures/index.js +503 -486
  19. package/bin/webui/fixtures/lanes.js +218 -0
  20. package/bin/webui/fixtures/settings.js +261 -34
  21. package/bin/webui/fixtures/stats.js +3 -3
  22. package/bin/webui/i18n/TERMS.md +135 -134
  23. package/bin/webui/i18n/en/extra.json +345 -313
  24. package/bin/webui/i18n/en/lanes.json +29 -0
  25. package/bin/webui/i18n/en/nav.json +1 -0
  26. package/bin/webui/i18n/en/overview.json +2 -0
  27. package/bin/webui/i18n/en/settings.json +16 -5
  28. package/bin/webui/i18n/id/extra.json +345 -313
  29. package/bin/webui/i18n/id/lanes.json +29 -0
  30. package/bin/webui/i18n/id/nav.json +1 -0
  31. package/bin/webui/i18n/id/overview.json +2 -0
  32. package/bin/webui/i18n/id/settings.json +15 -4
  33. package/bin/webui/js/01-i18n.js +1 -0
  34. package/bin/webui/js/panels/extra.js +3199 -3011
  35. package/bin/webui/js/panels/lanes.js +259 -0
  36. package/bin/webui/js/panels/overview.js +10 -0
  37. package/bin/webui/js/panels/settings.js +149 -3
  38. package/package.json +39 -39
  39. package/templates/agents/MODEL-MAPPING.md +23 -35
  40. package/templates/agents/orc-executor-opus-4-7-high.md +1 -1
  41. package/templates/agents/orc-executor-opus-4-7-med.md +1 -1
  42. package/templates/agents/orc-executor-opus-4-8-high.md +1 -1
  43. package/templates/agents/orc-executor-opus-5-high.md +1 -1
  44. package/templates/agents/orc-executor-opus-5-low.md +1 -1
  45. package/templates/agents/orc-executor-opus-5-med.md +1 -1
  46. package/templates/agents/orc-retro-opus-5-med.md +73 -73
  47. package/templates/agents/orc-retro-sonnet-5-high.md +72 -72
  48. package/templates/agents/orc-trace-writer-haiku-4-5.md +107 -107
  49. package/templates/commands/orc-route.md +1 -1
  50. package/templates/commands/orc.md +1 -1
  51. package/templates/skills/_shared/README.md +7 -3
  52. package/templates/skills/_shared/config-precedence.md +198 -0
  53. package/templates/skills/_shared/drift-recovery.md +1 -1
  54. package/templates/skills/_shared/extra-dispatch.md +159 -7
  55. package/templates/skills/_shared/interview.md +1 -1
  56. package/templates/skills/_shared/opus5-only.md +9 -7
  57. package/templates/skills/_shared/phases/README.md +82 -0
  58. package/templates/skills/{orc/references → _shared/phases}/analyst-gates.md +15 -3
  59. package/templates/skills/_shared/phases/execution.md +143 -0
  60. package/templates/skills/{orc/references → _shared/phases}/house-rules.md +13 -1
  61. package/templates/skills/{orc/references → _shared/phases}/intake.md +15 -2
  62. package/templates/skills/_shared/phases/mock-example.md +56 -0
  63. package/templates/skills/{orc/references → _shared/phases}/plan-handoff.md +16 -3
  64. package/templates/skills/_shared/phases/planning.md +135 -0
  65. package/templates/skills/_shared/phases/preflight.md +76 -0
  66. package/templates/skills/_shared/phases/review.md +53 -0
  67. package/templates/skills/_shared/phases/scoring.md +65 -0
  68. package/templates/skills/{orc/references → _shared/phases}/security-checklist.md +12 -1
  69. package/templates/skills/_shared/phases/security.md +55 -0
  70. package/templates/skills/_shared/phases/ship.md +88 -0
  71. package/templates/skills/{orc/references/stop-and-resume.md → _shared/phases/stop-resume.md} +169 -160
  72. package/templates/skills/_shared/phases/summary.md +48 -0
  73. package/templates/skills/_shared/phases/testgen.md +51 -0
  74. package/templates/skills/{orc/references/trace-protocol.md → _shared/phases/trace.md} +49 -6
  75. package/templates/skills/_shared/phases/verify.md +70 -0
  76. package/templates/skills/{orc/references → _shared/phases}/wave-grouping.md +14 -2
  77. package/templates/skills/{orc/references → _shared/phases}/wiki-consult.md +13 -1
  78. package/templates/skills/_shared/read-ladder.md +48 -0
  79. package/templates/skills/context-combiner/SKILL.md +214 -187
  80. package/templates/skills/orc/README.md +148 -150
  81. package/templates/skills/orc/SKILL.md +70 -358
  82. package/templates/skills/orc/config.md +137 -389
  83. package/templates/skills/orc/examples/full-run-mock.md +1 -1
  84. package/templates/skills/orc/references/effort-and-mode.md +16 -18
  85. package/templates/skills/orc/references/phases/intake.md +47 -0
  86. package/templates/skills/orc/references/phases/integration.md +19 -0
  87. package/templates/skills/orc/references/preflight-report.md +4 -4
  88. package/templates/skills/orc/references/ultra-mode.md +117 -123
  89. package/templates/skills/orc/schemas/planning-output.md +279 -279
  90. package/templates/skills/orc/subskills/orc-planner/SKILL.md +260 -264
  91. package/templates/skills/orc/subskills/orc-pr/stack-gate.md +4 -1
  92. package/templates/skills/orc-aftermath/SKILL.md +153 -136
  93. package/templates/skills/orc-analyze/SKILL.md +247 -220
  94. package/templates/skills/orc-analyze/references/branching.md +51 -51
  95. package/templates/skills/orc-analyze/references/thin-input.md +1 -1
  96. package/templates/skills/orc-analyze-mini/SKILL.md +128 -112
  97. package/templates/skills/orc-boundary/SKILL.md +244 -208
  98. package/templates/skills/orc-brainstorm/SKILL.md +372 -339
  99. package/templates/skills/orc-budget/SKILL.md +243 -225
  100. package/templates/skills/orc-challenge/README.md +1 -1
  101. package/templates/skills/orc-challenge/SKILL.md +293 -255
  102. package/templates/skills/orc-challenge/examples/council-full-roster.md +1 -1
  103. package/templates/skills/orc-claude/SKILL.md +216 -199
  104. package/templates/skills/orc-diy/README.md +2 -1
  105. package/templates/skills/orc-diy/SKILL.md +129 -70
  106. package/templates/skills/orc-diy/references/blocks/analyze.md +1 -1
  107. package/templates/skills/orc-diy/references/compile.md +21 -7
  108. package/templates/skills/orc-diy/references/flow-schema.md +2 -2
  109. package/templates/skills/orc-doc/SKILL.md +44 -7
  110. package/templates/skills/orc-explain/SKILL.md +19 -0
  111. package/templates/skills/orc-export/SKILL.md +26 -5
  112. package/templates/skills/orc-fast/SKILL.md +215 -187
  113. package/templates/skills/orc-grill/SKILL.md +233 -207
  114. package/templates/skills/orc-handoff/SKILL.md +223 -204
  115. package/templates/skills/orc-learn/SKILL.md +176 -156
  116. package/templates/skills/orc-mini/SKILL.md +41 -23
  117. package/templates/skills/orc-pact/SKILL.md +250 -218
  118. package/templates/skills/orc-pattern/SKILL.md +149 -124
  119. package/templates/skills/orc-poly/SKILL.md +237 -216
  120. package/templates/skills/orc-poly/references/gather.md +1 -1
  121. package/templates/skills/orc-pr-driver/SKILL.md +196 -167
  122. package/templates/skills/orc-pr-driver/references/orc-run-split.md +1 -1
  123. package/templates/skills/orc-pr-setup/SKILL.md +212 -184
  124. package/templates/skills/orc-quick/README.md +2 -2
  125. package/templates/skills/orc-quick/SKILL.md +45 -12
  126. package/templates/skills/orc-quick/references/dispatch-gate.md +2 -3
  127. package/templates/skills/orc-retro/SKILL.md +244 -222
  128. package/templates/skills/orc-retro/examples/retro-mock.md +171 -171
  129. package/templates/skills/orc-route/SKILL.md +183 -165
  130. package/templates/skills/orc-verify/SKILL.md +100 -86
  131. package/templates/skills/orc-wiki/SKILL.md +55 -206
  132. package/templates/skills/orc-wiki/references/phases/phase-0.md +71 -0
  133. package/templates/skills/orc-wiki/references/phases/phase-1.md +35 -0
  134. package/templates/skills/orc-wiki/references/phases/phase-2.md +52 -0
  135. package/templates/skills/orc-wiki/references/phases/phase-3.md +57 -0
  136. package/templates/skills/orc-wiki/references/phases/phase-3c.md +36 -0
  137. package/templates/agents/orc-advisor-fable-5.md +0 -50
  138. package/templates/agents/orc-analyst-fable-5.md +0 -115
  139. package/templates/agents/orc-judge-fable-5.md +0 -79
  140. package/templates/agents/orc-planner-fable-5.md +0 -152
  141. package/templates/agents/orc-reviewer-fable-5.md +0 -57
  142. package/templates/skills/_shared/fable5-override.md +0 -56
  143. package/templates/skills/orc-diy/references/blocks/execution.md +0 -42
  144. package/templates/skills/orc-diy/references/blocks/mock-example.md +0 -22
  145. package/templates/skills/orc-diy/references/blocks/planning.md +0 -34
  146. package/templates/skills/orc-diy/references/blocks/review.md +0 -18
  147. package/templates/skills/orc-diy/references/blocks/scoring.md +0 -16
  148. package/templates/skills/orc-diy/references/blocks/security.md +0 -25
  149. package/templates/skills/orc-diy/references/blocks/ship.md +0 -25
  150. package/templates/skills/orc-diy/references/blocks/summary.md +0 -18
  151. package/templates/skills/orc-diy/references/blocks/testgen.md +0 -17
  152. package/templates/skills/orc-diy/references/blocks/trace.md +0 -28
  153. package/templates/skills/orc-diy/references/blocks/verify.md +0 -25
@@ -1,167 +1,196 @@
1
- ---
2
- name: orc-pr-driver
3
- description: >
4
- Stacked-PR DRIVER. Use for "/orc-pr-driver", "build the stacked PRs", "submit
5
- the stack", "restack / sync / merge my stack". Takes an approved
6
- stacked-pr/<slug>/stack-plan.md — written by /orc-pr-setup, generated by
7
- `orc pr stack template` and filled in by hand, or handed over by ORC's ship
8
- phase — and executes it: one branch per layer, only that layer's files, a
9
- MANDATORY per-layer green gate (build + tests + lint scoped to the layer's own
10
- base + the repo's own hooks, never --no-verify), then `gh stack submit`, PR
11
- bodies from the resolved template, and the ongoing sync / rebase / conflict /
12
- bottom-up merge care. Refuses to run on a plan with unanswered uncertainties,
13
- a missing ticket or a red build.
14
- ---
15
-
16
- # ORC-PR-DRIVER (stacked-PR driver)
17
-
18
- The half that touches git. `orc-pr-setup` decides WHERE the cut lines go; this
19
- lane makes the layers real and keeps the stack healthy until every layer is
20
- merged.
21
-
22
- Its whole discipline is one sentence: **no layer is submitted, pushed or merged
23
- until its own gate is green at its own base.** A layer that only builds when the
24
- whole stack is applied is not a reviewable layer, and merging the layer below it
25
- breaks the trunk.
26
-
27
- **Tier.** Not effort-gated (the guard matches the exact skill name `orc`), so it
28
- runs at whatever tier the chat is on.
29
-
30
- **Human guide:** this skill's own `README.md` (step-by-step walkthrough, the green
31
- gate per language, merge order, troubleshooting table) — point the USER there when
32
- they ask how any of this works; never load it to drive the run.
33
-
34
- **Load at their phase, never preloaded:**
35
- `../_shared/stack-plan.md` (plan schema, probe, budgets, `STACK-FROM`, entry
36
- modes) · `../_shared/gh-stack-commands.md` (preflight + command surface) ·
37
- `../_shared/pr-templates.md` (per-layer body rules) ·
38
- `references/green-gate.md` (the mandatory ladder) ·
39
- `references/orc-run-split.md` (splitting an already-built worktree, file-granular) ·
40
- `references/conflict-playbook.md` (sync, rebase, modify, merge).
41
-
42
- ## Hard rules
43
-
44
- 1. **Never `git commit --no-verify`.** The repo's hooks ARE the gate; bypassing
45
- them means the PR cannot land anyway.
46
- 2. **Never `gh stack submit` over a red layer**, and never push one.
47
- 3. **Green means green at the layer's OWN base** — not "green once the whole
48
- stack is applied".
49
- 4. **After ANY lower-layer change, re-run the full ladder at every tip above it**,
50
- bottom-up. "It was green when I cut it" is not evidence — a rebase rewrites
51
- every upper branch.
52
- 5. **Merge bottom-up only.** Never merge a middle layer while an unmerged layer
53
- sits below it.
54
- 6. **Hunk surgery is forbidden.** Splits are file-granular; a file that seems to
55
- belong in two layers is a question, not a manual diff edit.
56
- 7. **Never fabricate a green.** No `//nolint`, no fake caller, no deleted
57
- identifier to silence a linter (`references/green-gate.md` — that is a P0
58
- question about the seam).
59
- 8. **The plan is the contract.** Re-cutting a seam mid-run means updating the
60
- plan file (and its `## Decisions`) in the same step.
61
-
62
- ## Phase D0 — Read the plan + hard gate
63
-
64
- 1. **Probe, do not search:** `orc pr stack status [<slug>]` exit 0 = READY,
65
- exit 1 = absent or unfilled (`../_shared/stack-plan.md`). Exit 1 say which
66
- it is and offer `/orc-pr-setup` (plan it) or `orc pr stack template` (skeleton
67
- to fill in by hand).
68
- 2. Read `stacked-pr/<slug>/stack-plan.md`, plus
69
- `stacked-pr/<slug>/STACK-FROM.md` when present (source, ticket, entry mode,
70
- template, run dir, `BUILD-GREEN`).
71
- 3. **REFUSE to run** — name the exact missing field, then stop — on: an
72
- unanswered UNCERTAIN in `## Decisions`, a missing ticket, a layer with no
73
- purpose or no value class, a FOUNDATION layer naming no consumer,
74
- fewer than 2 layers, or `BUILD-GREEN: false`. Never fill a field in for the user.
75
- 4. Re-validate the budgets against the real numbers (`git diff --numstat`,
76
- exclusions applied). A layer that grew past a ceiling since planning → surface
77
- it and ask: split it here, or log an accepted exception.
78
- 5. Preflight per `../_shared/gh-stack-commands.md` (gh · auth · extension ·
79
- **not a fork** · trunk · protections · merge queue). A hard fail → one
80
- regular PR, and say so plainly.
81
-
82
- ## Phase D1 Snapshot (entry mode `orc-run` only)
83
-
84
- The change already exists in the worktree, so **preserve it before touching
85
- branches** `references/orc-run-split.md` is the exact procedure: commit the
86
- whole change to a scratch snapshot branch, verify the snapshot contains every
87
- changed path from `git status --short`, and only then move to the trunk. Every
88
- layer is later materialized with `git checkout <snapshot> -- <that layer's
89
- files>`; deletions are applied as `git rm`. The snapshot branch stays until the
90
- last layer mergesit is the undo button.
91
-
92
- `greenfield` skips this phase: each layer's code is written in its own layer.
93
-
94
- ## Phase D2 Build the stack, layer by layer
95
-
96
- `gh stack init -b <trunk>` then, per layer, bottom-up:
97
-
98
- 1. `gh stack add -m "<ticket> <layer title>"` (branch name from the plan).
99
- 2. Materialize **only that layer's files** — `git checkout <snapshot> -- <files>`
100
- (orc-run) or write them (greenfield). Nothing from another layer, ever.
101
- 3. **Run the FULL green-gate ladder** (`references/green-gate.md`): build →
102
- tests (the layer's scope) lint attributed to **this layer's base** → the
103
- repo's own pre-commit hooks, unbypassed. Any step red → stop, fix, re-run the
104
- ladder from step 1 for that layer. Do not proceed, do not push.
105
- 4. Commit through the hooks. Record the layer's gate status (`GREEN`) back into
106
- the plan file.
107
- 5. Report one line per layer to the user: `L<n> <branch> <files> files, <LoC>
108
- LoC GATE GREEN`.
109
-
110
- A layer that cannot go green alone is a **seam defect, not a lint problem**: stop
111
- and ask (merge it into its consumer · land the first caller here · accept with an
112
- explicit, reason-carrying suppression user's call only), then record the answer
113
- in the plan's `## Decisions`.
114
-
115
- ## Phase D3Submit
116
-
117
- 1. `gh stack submit` → then **verify with `gh stack view --json`**: the bases
118
- chain correctly (bottom trunk, each upper the branch below) and each PR's
119
- diff really is only its own layer.
120
- 2. Fill each PR body from the resolved template per `../_shared/pr-templates.md`,
121
- including the four per-layer facts: layer `n` of `N` + ticket · purpose +
122
- value class · **deliberately NOT here** → which layer has it ·
123
- excluded-from-budget files, listed.
124
- 3. Show the user the stack map, each PR's URL, and the review order hint.
125
-
126
- ## Phase D4 Maintain
127
-
128
- `references/conflict-playbook.md`. In short: `gh stack sync` after the trunk
129
- moves · `gh stack rebase --upstack` after amending a lower layer, then **re-run
130
- the ladder at every tip above, bottom-up** (hard rule 4) · `gh stack modify` to
131
- insert / reorder / drop / combine when review demands it (prefer it, and
132
- fixup-on-top, over history rewrites mid-review a force-push destroys a
133
- reviewer's in-progress context).
134
-
135
- ## Phase D5 — Merge (bottom-up, gated)
136
-
137
- Before each `gh stack merge`: confirm via `gh stack view --json` +
138
- `gh pr view <n> --json statusCheckRollup` that **that layer's own CI is green**.
139
- After each merge: confirm the upper layers auto-retargeted and their CI re-ran.
140
- Never merge a middle layer with unmerged layers below it. When the last layer
141
- lands, delete the snapshot branch (ask first) and report the final state.
142
-
143
- ## Behavior trace (PERMANENT every ORC entry point traces; always on)
144
-
145
- Resolve `log_dir` (`../orc/config.md` default `.claude/orc.config.yaml`) at
146
- start and follow `../orc/references/trace-protocol.md`: write
147
- `log_dir/.current` = `run-prdriver-<slug>-<DDMMYY>-<HHMMSS>.txt` and
148
- `touch the trace file` of that name in the SAME step, first. Narration is
149
- dispatched, not remembered: dispatch the trace writer at every **layer
150
- boundary** (one packet per layer close, per the multi-dispatch tier) and once at
151
- run end. Events with their REAL timestamps: `PHASE D0..D5`,
152
- `GATE layer-green pass|bounce :: L<n> <step>`, `QUESTION count=<n>`,
153
- `GATE stack-certainty` on a mid-run re-cut, `FINISH`; `decisions` carries the WHY
154
- (seam calls, accepted exceptions, the user's answers verbatim). A phase ending
155
- with `zero new trace lines is a protocol violation`.
156
-
157
- ## Boundaries
158
-
159
- - **Never plans the layering.** No plan `/orc-pr-setup` or
160
- `orc pr stack template`. It executes a plan; it does not invent one.
161
- - **Never bypasses a gate** — no `--no-verify`, no red submit, no red merge.
162
- - **Never rewrites the user's work silently:** the snapshot branch exists before
163
- any branch switch, and it survives until the stack is merged.
164
- - Out of scope: cross-repo stacks (unsupported by GitHub) and retrofitting an
165
- already-open PR into a stack.
166
- - Reminder: to see usage limits, tell the user to run `/usage` (never invoke it
167
- programmatically).
1
+ ---
2
+ name: orc-pr-driver
3
+ description: >
4
+ Stacked-PR DRIVER. Use for "/orc-pr-driver", "build the stacked PRs", "submit
5
+ the stack", "restack / sync / merge my stack". Takes an approved
6
+ stacked-pr/<slug>/stack-plan.md — written by /orc-pr-setup, generated by
7
+ `orc pr stack template` and filled in by hand, or handed over by ORC's ship
8
+ phase — and executes it: one branch per layer, only that layer's files, a
9
+ MANDATORY per-layer green gate (build + tests + lint scoped to the layer's own
10
+ base + the repo's own hooks, never --no-verify), then `gh stack submit`, PR
11
+ bodies from the resolved template, and the ongoing sync / rebase / conflict /
12
+ bottom-up merge care. Refuses to run on a plan with unanswered uncertainties,
13
+ a missing ticket or a red build.
14
+ ---
15
+
16
+ # ORC-PR-DRIVER (stacked-PR driver)
17
+
18
+ The half that touches git. `orc-pr-setup` decides WHERE the cut lines go; this
19
+ lane makes the layers real and keeps the stack healthy until every layer is
20
+ merged.
21
+
22
+ Its whole discipline is one sentence: **no layer is submitted, pushed or merged
23
+ until its own gate is green at its own base.** A layer that only builds when the
24
+ whole stack is applied is not a reviewable layer, and merging the layer below it
25
+ breaks the trunk.
26
+
27
+ **Tier.** Not effort-gated (the guard matches the exact skill name `orc`), so it
28
+ runs at whatever tier the chat is on.
29
+
30
+ **Human guide:** this skill's own `README.md` (step-by-step walkthrough, the green
31
+ gate per language, merge order, troubleshooting table) — point the USER there when
32
+ they ask how any of this works; never load it to drive the run.
33
+
34
+ **Load at their phase, never preloaded:**
35
+ `../_shared/stack-plan.md` (plan schema, probe, budgets, `STACK-FROM`, entry
36
+ modes) · `../_shared/gh-stack-commands.md` (preflight + command surface) ·
37
+ `../_shared/pr-templates.md` (per-layer body rules) ·
38
+ `references/green-gate.md` (the mandatory ladder) ·
39
+ `references/orc-run-split.md` (splitting an already-built worktree, file-granular) ·
40
+ `references/conflict-playbook.md` (sync, rebase, modify, merge).
41
+
42
+ ## Hard rules
43
+
44
+ 1. **Never `git commit --no-verify`.** The repo's hooks ARE the gate; bypassing
45
+ them means the PR cannot land anyway.
46
+ 2. **Never `gh stack submit` over a red layer**, and never push one.
47
+ 3. **Green means green at the layer's OWN base** — not "green once the whole
48
+ stack is applied".
49
+ 4. **After ANY lower-layer change, re-run the full ladder at every tip above it**,
50
+ bottom-up. "It was green when I cut it" is not evidence — a rebase rewrites
51
+ every upper branch.
52
+ 5. **Merge bottom-up only.** Never merge a middle layer while an unmerged layer
53
+ sits below it.
54
+ 6. **Hunk surgery is forbidden.** Splits are file-granular; a file that seems to
55
+ belong in two layers is a question, not a manual diff edit.
56
+ 7. **Never fabricate a green.** No `//nolint`, no fake caller, no deleted
57
+ identifier to silence a linter (`references/green-gate.md` — that is a P0
58
+ question about the seam).
59
+ 8. **The plan is the contract.** Re-cutting a seam mid-run means updating the
60
+ plan file (and its `## Decisions`) in the same step.
61
+
62
+ ## Phases
63
+
64
+ `orc lane phases orc-pr-driver --json` is this lane's pipeline: the ordered list, where
65
+ each phase lives, and how much of it to read. **The CLI owns the order** — never
66
+ derive it from the headings below, and never renumber or rename one without the
67
+ manifest, because a `read: section` pointer names a HEADING and a renamed heading
68
+ is a pointer into nothing.
69
+
70
+ ## Phase D0 — Read the plan + hard gate
71
+
72
+ 1. **Probe, do not search:** `orc pr stack status [<slug>]` exit 0 = READY,
73
+ exit 1 = absent or unfilled (`../_shared/stack-plan.md`). Exit 1 say which
74
+ it is and offer `/orc-pr-setup` (plan it) or `orc pr stack template` (skeleton
75
+ to fill in by hand).
76
+ 2. Read `stacked-pr/<slug>/stack-plan.md`, plus
77
+ `stacked-pr/<slug>/STACK-FROM.md` when present (source, ticket, entry mode,
78
+ template, run dir, `BUILD-GREEN`).
79
+ 3. **REFUSE to run** name the exact missing field, then stop on: an
80
+ unanswered UNCERTAIN in `## Decisions`, a missing ticket, a layer with no
81
+ purpose or no value class, a FOUNDATION layer naming no consumer,
82
+ fewer than 2 layers, or `BUILD-GREEN: false`. Never fill a field in for the user.
83
+ 4. Re-validate the budgets against the real numbers (`git diff --numstat`,
84
+ exclusions applied). A layer that grew past a ceiling since planning → surface
85
+ it and ask: split it here, or log an accepted exception.
86
+ 5. Preflight per `../_shared/gh-stack-commands.md` (gh · auth · extension ·
87
+ **not a fork** · trunk · protections · merge queue). A hard fail → one
88
+ regular PR, and say so plainly.
89
+
90
+ ## Phase D1Snapshot (entry mode `orc-run` only)
91
+
92
+ The change already exists in the worktree, so **preserve it before touching
93
+ branches** — `references/orc-run-split.md` is the exact procedure: commit the
94
+ whole change to a scratch snapshot branch, verify the snapshot contains every
95
+ changed path from `git status --short`, and only then move to the trunk. Every
96
+ layer is later materialized with `git checkout <snapshot> -- <that layer's
97
+ files>`; deletions are applied as `git rm`. The snapshot branch stays until the
98
+ last layer merges it is the undo button.
99
+
100
+ `greenfield` skips this phase: each layer's code is written in its own layer.
101
+
102
+ ## Phase D2 Build the stack, layer by layer
103
+
104
+ `gh stack init -b <trunk>` then, per layer, bottom-up:
105
+
106
+ 1. `gh stack add -m "<ticket> <layer title>"` (branch name from the plan).
107
+ 2. Materialize **only that layer's files** `git checkout <snapshot> -- <files>`
108
+ (orc-run) or write them (greenfield). Nothing from another layer, ever.
109
+ 3. **Run the FULL green-gate ladder** (`references/green-gate.md`): build →
110
+ tests (the layer's scope) lint attributed to **this layer's base** the
111
+ repo's own pre-commit hooks, unbypassed. Any step red stop, fix, re-run the
112
+ ladder from step 1 for that layer. Do not proceed, do not push.
113
+ 4. Commit through the hooks. Record the layer's gate status (`GREEN`) back into
114
+ the plan file.
115
+ 5. Report one line per layer to the user: `L<n> <branch> <files> files, <LoC>
116
+ LoC — GATE GREEN`.
117
+
118
+ A layer that cannot go green alone is a **seam defect, not a lint problem**: stop
119
+ and ask (merge it into its consumer · land the first caller here · accept with an
120
+ explicit, reason-carrying suppression user's call only), then record the answer
121
+ in the plan's `## Decisions`.
122
+
123
+ ## Phase D3 — Submit
124
+
125
+ 1. `gh stack submit` → then **verify with `gh stack view --json`**: the bases
126
+ chain correctly (bottom trunk, each upper → the branch below) and each PR's
127
+ diff really is only its own layer.
128
+ 2. Fill each PR body from the resolved template per `../_shared/pr-templates.md`,
129
+ including the four per-layer facts: layer `n` of `N` + ticket · purpose +
130
+ value class · **deliberately NOT here** which layer has it ·
131
+ excluded-from-budget files, listed.
132
+ 3. Show the user the stack map, each PR's URL, and the review order hint.
133
+
134
+ ## Phase D4 — Maintain
135
+
136
+ `references/conflict-playbook.md`. In short: `gh stack sync` after the trunk
137
+ moves · `gh stack rebase --upstack` after amending a lower layer, then **re-run
138
+ the ladder at every tip above, bottom-up** (hard rule 4) · `gh stack modify` to
139
+ insert / reorder / drop / combine when review demands it (prefer it, and
140
+ fixup-on-top, over history rewrites mid-review a force-push destroys a
141
+ reviewer's in-progress context).
142
+
143
+ ## Phase D5Merge (bottom-up, gated)
144
+
145
+ Before each `gh stack merge`: confirm via `gh stack view --json` +
146
+ `gh pr view <n> --json statusCheckRollup` that **that layer's own CI is green**.
147
+ After each merge: confirm the upper layers auto-retargeted and their CI re-ran.
148
+ Never merge a middle layer with unmerged layers below it. When the last layer
149
+ lands, delete the snapshot branch (ask first) and report the final state.
150
+
151
+ ## Behavior trace (always on)
152
+
153
+ `../_shared/phases/trace.md` (`core`, at run start; `orc lane phases` names
154
+ the file and the layers). Lane token `prdriver`, tier **Multi-dispatch** —
155
+ one packet per LAYER boundary (each layer's green gate closes) + the
156
+ end-of-run packet.
157
+ At run start write `log_dir/.current` = `run-prdriver-<slug>-<DDMMYY>-<HHMMSS>.txt` AND
158
+ `touch the trace file` of that name in the SAME step.
159
+ Nothing else about the protocol is restated here; a phase that ends with
160
+ `zero new trace lines is a protocol violation`.
161
+
162
+ Events: `PHASE D0..D5`, `GATE layer-green pass|bounce :: L<n> <step>`,
163
+ `QUESTION count=<n>`, `GATE stack-certainty` on a mid-run re-cut, `FINISH`;
164
+ `decisions` carries the WHY (seam calls, accepted exceptions, the user's
165
+ answers verbatim).
166
+
167
+ ## Boundaries
168
+
169
+ - **Never plans the layering.** No plan → `/orc-pr-setup` or
170
+ `orc pr stack template`. It executes a plan; it does not invent one.
171
+ - **Never bypasses a gate** — no `--no-verify`, no red submit, no red merge.
172
+ - **Never rewrites the user's work silently:** the snapshot branch exists before
173
+ any branch switch, and it survives until the stack is merged.
174
+ - Out of scope: cross-repo stacks (unsupported by GitHub) and retrofitting an
175
+ already-open PR into a stack.
176
+ - Reminder: to see usage limits, tell the user to run `/usage` (never invoke it
177
+ programmatically).
178
+
179
+ ## Config
180
+
181
+ Resolve with `orc lane config orc-pr-driver --json` and obey `effective`. Never merge
182
+ `.claude/orc.config.yaml` yourself, and never re-derive a precedence. Exit ≠ 0 →
183
+ say so and use `../_shared/config-precedence.md`'s documented defaults, out
184
+ loud. Nothing this lane reads is contested, gated or a stop, so it owes no
185
+ preflight line and has no gate to honour.
186
+
187
+ ## Calls
188
+
189
+ **ONE catalogue, and it is not you:** `orc lane calls orc-pr-driver --json` names every
190
+ CLI call this lane makes, each with its exit-code contract, its cost, when to run
191
+ it, and what an EMPTY answer means. Never invent a spelling, never re-word an
192
+ exit code, and never re-derive a state word — the CLI's state words are the only
193
+ state words, and **an exit code is an ANSWER wherever that contract says so, not
194
+ a failure**. A call the answer does not name is a call this lane does not make.
195
+ Exit ≠ 0 from the catalogue itself → say the CLI is unavailable and name the
196
+ command you are about to run, out loud, before running it.
@@ -35,7 +35,7 @@ Any path in `git status --short` that is missing from that diff → **STOP**. Do
35
35
  proceed with a partial snapshot.
36
36
 
37
37
  Note the excluded-but-listed paths (generated code, lockfiles, vendored trees —
38
- `../_shared/stack-plan.md`): they are still real files that must land in some
38
+ `../../_shared/stack-plan.md`): they are still real files that must land in some
39
39
  layer, they just do not count toward a budget.
40
40
 
41
41
  ## Step 2 — start the stack from the trunk