@azure-id/orc 1.9.2 → 2.1.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 (228) hide show
  1. package/CHANGELOG.md +722 -0
  2. package/README-id.md +56 -42
  3. package/README.md +58 -41
  4. package/bin/build-agents.js +125 -29
  5. package/bin/clear-logs.js +620 -0
  6. package/bin/cli.js +1873 -180
  7. package/bin/fix.js +459 -0
  8. package/bin/gotcha-import.js +1081 -0
  9. package/bin/gotcha.js +1566 -0
  10. package/bin/graph-query.js +1 -1
  11. package/bin/graph.js +717 -717
  12. package/bin/habit.js +1538 -0
  13. package/bin/mockrun-catalog.js +284 -276
  14. package/bin/onboarding-content.js +2 -1
  15. package/bin/pricing.json +28 -21
  16. package/bin/run-undo.js +398 -0
  17. package/bin/trace-write.js +869 -0
  18. package/bin/verify-contracts.js +627 -100
  19. package/bin/verify-package.js +68 -10
  20. package/bin/webui/api.js +151 -6
  21. package/bin/webui/app.html +239 -232
  22. package/bin/webui/css/00-tokens.css +110 -92
  23. package/bin/webui/css/04-motion.css +87 -0
  24. package/bin/webui/css/06-responsive.css +203 -178
  25. package/bin/webui/css/panels/behaviour.css +205 -0
  26. package/bin/webui/css/panels/hookui.css +79 -0
  27. package/bin/webui/fixtures/behaviour.js +562 -0
  28. package/bin/webui/fixtures/extra.js +9 -9
  29. package/bin/webui/fixtures/flow.js +81 -81
  30. package/bin/webui/fixtures/hookui.js +506 -431
  31. package/bin/webui/fixtures/index.js +66 -3
  32. package/bin/webui/fixtures/knowledge.js +9 -3
  33. package/bin/webui/fixtures/maintenance.js +123 -42
  34. package/bin/webui/fixtures/rules.js +1007 -1002
  35. package/bin/webui/fixtures/settings.js +6 -7
  36. package/bin/webui/fixtures/stats.js +25 -6
  37. package/bin/webui/fixtures/wait.js +98 -97
  38. package/bin/webui/i18n/en/behaviour.json +156 -0
  39. package/bin/webui/i18n/en/hookui.json +290 -194
  40. package/bin/webui/i18n/en/maintenance.json +71 -52
  41. package/bin/webui/i18n/en/nav.json +25 -24
  42. package/bin/webui/i18n/en/settings.json +60 -60
  43. package/bin/webui/i18n/en/tour.json +37 -35
  44. package/bin/webui/i18n/id/behaviour.json +156 -0
  45. package/bin/webui/i18n/id/hookui.json +290 -194
  46. package/bin/webui/i18n/id/maintenance.json +71 -52
  47. package/bin/webui/i18n/id/nav.json +25 -24
  48. package/bin/webui/i18n/id/settings.json +60 -60
  49. package/bin/webui/i18n/id/tour.json +37 -35
  50. package/bin/webui/js/01-i18n.js +155 -154
  51. package/bin/webui/js/05-banners.js +181 -172
  52. package/bin/webui/js/06-edit.js +193 -183
  53. package/bin/webui/js/90-tour.js +498 -494
  54. package/bin/webui/js/91-shortcuts.js +126 -126
  55. package/bin/webui/js/99-boot.js +121 -118
  56. package/bin/webui/js/panels/behaviour.js +1087 -0
  57. package/bin/webui/js/panels/hookui.js +2196 -1691
  58. package/bin/webui/js/panels/maintenance.js +336 -235
  59. package/bin/webui/js/panels/settings.js +726 -719
  60. package/mock-run/INDEX.md +110 -107
  61. package/mock-run/extra-slots.md +1 -1
  62. package/mock-run/gotcha-import.md +118 -0
  63. package/mock-run/habits.md +129 -0
  64. package/mock-run/orc-aftermath.md +392 -392
  65. package/mock-run/orc-budget.md +29 -33
  66. package/mock-run/orc-cli.md +200 -200
  67. package/mock-run/orc-explain.md +86 -86
  68. package/mock-run/orc-extra.md +389 -392
  69. package/mock-run/orc-fix.md +87 -0
  70. package/mock-run/orc-pattern.md +112 -112
  71. package/mock-run/orc-quick.md +6 -1
  72. package/mock-run/orc.md +157 -157
  73. package/package.json +1 -1
  74. package/templates/agents/MODEL-MAPPING.md +37 -34
  75. package/templates/agents/orc-advisor-opus-5-xhigh.md +1 -7
  76. package/templates/agents/orc-analyze-mini-opus-5-med.md +1 -6
  77. package/templates/agents/orc-analyze-mini-sonnet-5-high.md +2 -5
  78. package/templates/agents/{orc-claude-writer-opus-4-8-high.md → orc-claude-writer-opus-5-low.md} +48 -53
  79. package/templates/agents/orc-context-combiner-opus-5-high.md +1 -11
  80. package/templates/agents/orc-executor-haiku-4-5.md +14 -6
  81. package/templates/agents/orc-executor-opus-4-7-high.md +14 -6
  82. package/templates/agents/orc-executor-opus-4-7-med.md +14 -6
  83. package/templates/agents/orc-executor-opus-4-8-high.md +14 -6
  84. package/templates/agents/orc-executor-opus-5-high.md +14 -6
  85. package/templates/agents/orc-executor-opus-5-low.md +14 -6
  86. package/templates/agents/orc-executor-opus-5-med.md +14 -6
  87. package/templates/agents/orc-executor-sonnet-4-6-high.md +14 -6
  88. package/templates/agents/orc-executor-sonnet-4-6-med.md +14 -6
  89. package/templates/agents/orc-executor-sonnet-5-high.md +15 -7
  90. package/templates/agents/orc-executor-sonnet-5-low.md +155 -0
  91. package/templates/agents/orc-executor-sonnet-5-med.md +155 -0
  92. package/templates/agents/orc-graph-noter-sonnet-4-6-med.md +1 -10
  93. package/templates/agents/orc-judge-opus-5-xhigh.md +5 -9
  94. package/templates/agents/orc-learn-writer-opus-5-low.md +1 -7
  95. package/templates/agents/orc-pattern-codifier-opus-5-med.md +1 -8
  96. package/templates/agents/orc-pattern-codifier-sonnet-5-high.md +58 -63
  97. package/templates/agents/orc-planner-mini-opus-5-med.md +1 -4
  98. package/templates/agents/orc-planner-mini-sonnet-5-high.md +2 -3
  99. package/templates/agents/orc-planner-opus-5-med.md +1 -4
  100. package/templates/agents/orc-recon-opus-5-low.md +1 -8
  101. package/templates/agents/orc-recon-sonnet-4-6-med.md +1 -8
  102. package/templates/agents/orc-retro-opus-5-med.md +6 -8
  103. package/templates/agents/orc-retro-sonnet-5-high.md +7 -8
  104. package/templates/agents/orc-reviewer-opus-5-low.md +96 -0
  105. package/templates/agents/orc-scout-opus-5-low.md +1 -6
  106. package/templates/agents/orc-scout-sonnet-4-6-high.md +35 -39
  107. package/templates/agents/orc-system-analyst-opus-5-high.md +1 -6
  108. package/templates/agents/orc-test-author-opus-5-med.md +4 -5
  109. package/templates/agents/orc-trace-writer-haiku-4-5.md +3 -7
  110. package/templates/agents/orc-verifier-opus-5-med.md +16 -8
  111. package/templates/agents/{orc-wiki-scanner-opus-4-8-high.md → orc-wiki-scanner-opus-5-low.md} +74 -79
  112. package/templates/agents/orc-wiki-scanner-sonnet-5-high.md +97 -106
  113. package/templates/commands/orc-analyze.md +13 -21
  114. package/templates/commands/orc-fast.md +10 -15
  115. package/templates/commands/orc-fix.md +18 -0
  116. package/templates/commands/orc-poly.md +12 -21
  117. package/templates/commands/orc-pr-driver.md +11 -30
  118. package/templates/commands/orc-pr-setup.md +10 -31
  119. package/templates/commands/orc-route.md +11 -41
  120. package/templates/commands/orc-test.md +5 -60
  121. package/templates/commands/orc-wiki.md +64 -64
  122. package/templates/hooks/README.md +109 -7
  123. package/templates/hooks/orc-session-hook.js +339 -0
  124. package/templates/hooks/orc-statusline-render.js +317 -23
  125. package/templates/hooks/orc-statusline.js +165 -50
  126. package/templates/hooks/orc-subagent-line.js +23 -5
  127. package/templates/hooks/orc-weather-fetch.js +123 -0
  128. package/templates/skills/_shared/README.md +9 -0
  129. package/templates/skills/_shared/code-graph.md +47 -55
  130. package/templates/skills/_shared/config-precedence.md +3 -1
  131. package/templates/skills/_shared/extra-dispatch.md +78 -93
  132. package/templates/skills/_shared/gotchas.md +248 -177
  133. package/templates/skills/_shared/habits.md +101 -0
  134. package/templates/skills/_shared/lane-contract.md +84 -0
  135. package/templates/skills/_shared/opus5-only.md +14 -14
  136. package/templates/skills/_shared/phases/README.md +142 -83
  137. package/templates/skills/_shared/phases/analyst-gates.md +10 -21
  138. package/templates/skills/_shared/phases/execution.md +8 -14
  139. package/templates/skills/_shared/phases/house-rules.md +27 -32
  140. package/templates/skills/_shared/phases/intake.md +127 -133
  141. package/templates/skills/_shared/phases/mock-example.md +46 -56
  142. package/templates/skills/_shared/phases/plan-handoff.md +91 -97
  143. package/templates/skills/_shared/phases/planning.md +7 -17
  144. package/templates/skills/_shared/phases/preflight.md +19 -42
  145. package/templates/skills/_shared/phases/review.md +24 -28
  146. package/templates/skills/_shared/phases/rules.md +18 -42
  147. package/templates/skills/_shared/phases/scoring.md +55 -65
  148. package/templates/skills/_shared/phases/security-checklist.md +46 -50
  149. package/templates/skills/_shared/phases/security.md +45 -55
  150. package/templates/skills/_shared/phases/ship.md +6 -15
  151. package/templates/skills/_shared/phases/stop-resume.md +2 -5
  152. package/templates/skills/_shared/phases/summary.md +73 -48
  153. package/templates/skills/_shared/phases/testgen.md +41 -51
  154. package/templates/skills/_shared/phases/trace-verbs.md +447 -0
  155. package/templates/skills/_shared/phases/trace.md +66 -297
  156. package/templates/skills/_shared/phases/verify.md +62 -70
  157. package/templates/skills/_shared/phases/wave-grouping.md +128 -133
  158. package/templates/skills/_shared/phases/wiki-consult.md +10 -6
  159. package/templates/skills/_shared/read-ladder.md +2 -55
  160. package/templates/skills/_shared/return-validation.md +17 -70
  161. package/templates/skills/_shared/review-slice.md +106 -0
  162. package/templates/skills/_shared/smoke-gate.md +46 -28
  163. package/templates/skills/_shared/wait.md +1 -0
  164. package/templates/skills/context-combiner/SKILL.md +15 -44
  165. package/templates/skills/orc/README.md +2 -2
  166. package/templates/skills/orc/SKILL.md +35 -63
  167. package/templates/skills/orc/config.md +25 -27
  168. package/templates/skills/orc/examples/full-run-mock.md +2 -1
  169. package/templates/skills/orc/references/effort-and-mode.md +17 -17
  170. package/templates/skills/orc/references/pattern-gate.md +89 -89
  171. package/templates/skills/orc/references/phases/intake.md +41 -47
  172. package/templates/skills/orc/references/phases/integration.md +13 -19
  173. package/templates/skills/orc/references/preflight-report.md +11 -12
  174. package/templates/skills/orc/references/ultra-mode.md +9 -7
  175. package/templates/skills/orc/schemas/checkpoint.md +122 -122
  176. package/templates/skills/orc/subskills/orc-execution/SKILL.md +27 -73
  177. package/templates/skills/orc/subskills/orc-execution/core.md +12 -99
  178. package/templates/skills/orc/subskills/orc-execution/subagent.md +14 -13
  179. package/templates/skills/orc/subskills/orc-review-verify/SKILL.md +12 -53
  180. package/templates/skills/orc/subskills/orc-review-verify/core.md +52 -135
  181. package/templates/skills/orc/subskills/orc-review-verify/subagent.md +7 -7
  182. package/templates/skills/orc/subskills/orc-testgen/SKILL.md +11 -22
  183. package/templates/skills/orc/subskills/orc-testgen/core.md +20 -59
  184. package/templates/skills/orc/subskills/orc-testgen/subagent.md +7 -7
  185. package/templates/skills/orc-advisor/SKILL.md +56 -60
  186. package/templates/skills/orc-analyze/SKILL.md +33 -67
  187. package/templates/skills/orc-analyze/schemas/report-audit.md +2 -1
  188. package/templates/skills/orc-analyze/schemas/report-prose.md +2 -1
  189. package/templates/skills/orc-analyze-mini/SKILL.md +35 -70
  190. package/templates/skills/orc-claude/SKILL.md +14 -14
  191. package/templates/skills/orc-claude/examples/claude-run-mock.md +65 -65
  192. package/templates/skills/orc-diy/README.md +31 -0
  193. package/templates/skills/orc-diy/SKILL.md +27 -78
  194. package/templates/skills/orc-diy/references/blocks/pattern.md +18 -18
  195. package/templates/skills/orc-fast/SKILL.md +49 -75
  196. package/templates/skills/orc-fix/SKILL.md +110 -0
  197. package/templates/skills/orc-judge/SKILL.md +77 -82
  198. package/templates/skills/orc-mini/SKILL.md +64 -112
  199. package/templates/skills/orc-mini/examples/mini-run-mock.md +4 -2
  200. package/templates/skills/orc-pattern/SKILL.md +27 -48
  201. package/templates/skills/orc-poly/SKILL.md +32 -61
  202. package/templates/skills/orc-pr-driver/SKILL.md +25 -51
  203. package/templates/skills/orc-pr-driver/references/green-gate.md +113 -105
  204. package/templates/skills/orc-pr-setup/SKILL.md +20 -45
  205. package/templates/skills/orc-quick/README.md +44 -3
  206. package/templates/skills/orc-quick/SKILL.md +77 -108
  207. package/templates/skills/orc-quick/references/dispatch-gate.md +18 -6
  208. package/templates/skills/orc-quick/references/gh-mode.md +50 -1
  209. package/templates/skills/orc-quick/references/look.md +3 -1
  210. package/templates/skills/orc-retro/SKILL.md +20 -19
  211. package/templates/skills/orc-retro/examples/retro-mock.md +17 -17
  212. package/templates/skills/orc-route/SKILL.md +25 -45
  213. package/templates/skills/orc-test/SKILL.md +16 -37
  214. package/templates/skills/orc-verify/SKILL.md +14 -32
  215. package/templates/skills/orc-wait/SKILL.md +156 -163
  216. package/templates/skills/orc-wiki/README.md +325 -325
  217. package/templates/skills/orc-wiki/SKILL.md +195 -195
  218. package/templates/skills/orc-wiki/examples/wiki-run-mock.md +37 -37
  219. package/templates/skills/orc-wiki/references/extra.md +2 -2
  220. package/templates/skills/orc-wiki/references/partial-refresh.md +276 -271
  221. package/templates/skills/orc-wiki/references/phases/phase-0.md +2 -7
  222. package/templates/skills/orc-wiki/references/phases/phase-1.md +1 -6
  223. package/templates/skills/orc-wiki/references/phases/phase-2.md +4 -9
  224. package/templates/skills/orc-wiki/references/phases/phase-3.md +1 -6
  225. package/templates/skills/orc-wiki/references/phases/phase-3c.md +4 -8
  226. package/templates/agents/orc-claude-writer-opus-5-med.md +0 -55
  227. package/templates/agents/orc-reviewer-opus-5-med.md +0 -60
  228. package/templates/agents/orc-wiki-scanner-opus-5-med.md +0 -81
@@ -2,15 +2,11 @@
2
2
  name: orc-pr-driver
3
3
  description: >
4
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.
5
+ the stack", "restack / sync / merge my stack". Executes an approved
6
+ stacked-pr/<slug>/stack-plan.md: one branch per layer, a MANDATORY per-layer
7
+ green gate (build + tests + lint + the repo's own hooks, never --no-verify),
8
+ then `gh stack submit` and the sync / rebase / bottom-up merge care. Refuses a
9
+ plan with open uncertainties or a red build.
14
10
  ---
15
11
 
16
12
  # ORC-PR-DRIVER (stacked-PR driver)
@@ -61,17 +57,14 @@ modes) · `../_shared/gh-stack-commands.md` (preflight + command surface) ·
61
57
 
62
58
  ## Phases
63
59
 
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.
60
+ `orc lane phases orc-pr-driver --json` is this lane's pipeline. **The CLI owns the order**:
61
+ never derive it from the headings below, and never rename or renumber one
62
+ without the manifest (`../_shared/lane-contract.md` §Phases).
69
63
 
70
64
  ## Phase D0 — Read the plan + hard gate
71
65
 
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
66
+ 1. **Probe, do not search:** `orc pr stack status [<slug>]` — exit 1 =
67
+ absent or unfilled (`../_shared/stack-plan.md`) → say which it is and offer `/orc-pr-setup` (plan it) or `orc pr stack template` (skeleton
75
68
  to fill in by hand).
76
69
  2. Read `stacked-pr/<slug>/stack-plan.md`, plus
77
70
  `stacked-pr/<slug>/STACK-FROM.md` when present (source, ticket, entry mode,
@@ -150,14 +143,12 @@ lands, delete the snapshot branch (ask first) and report the final state.
150
143
 
151
144
  ## Behavior trace (always on)
152
145
 
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`.
146
+ `../_shared/phases/trace.md` (`core`, at run start; `orc lane phases orc-pr-driver --json` →
147
+ `trace_grammar` gives the verbs). Lane token `prdriver`, tier
148
+ **Multi-dispatch** — one packet per LAYER (each layer's green
149
+ gate closes). At run start write `log_dir/.current` =
150
+ `run-prdriver-<slug>-<DDMMYY>-<HHMMSS>.txt` AND `touch the trace file` of that name
151
+ in the SAME step. A phase that ends with `zero new trace lines is a protocol violation`.
161
152
 
162
153
  Events: `PHASE D0..D5`, `GATE layer-green pass|bounce :: L<n> <step>`,
163
154
  `QUESTION count=<n>`, `GATE stack-certainty` on a mid-run re-cut, `FINISH`;
@@ -176,29 +167,12 @@ answers verbatim).
176
167
  - Reminder: to see usage limits, tell the user to run `/usage` (never invoke it
177
168
  programmatically).
178
169
 
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.
197
-
198
- ## Rules — the anti-slop card (`../_shared/phases/rules.md`)
199
-
200
- `orc rules slice --lane orc-pr-driver --json` is the ONLY assembler; never build
201
- the card here. It rides under the house rules and above the task —
202
- **house rules > your project's rules > ORC's own packs** — and its `line` prints
203
- VERBATIM at preflight. Returns gain `rules_applied[]`, `rules_conflicts[]` (a gap,
204
- never a silent choice) and `rules_overridden[]`.
170
+ ## Lane contract (`../_shared/lane-contract.md` — read it ONLY when a call exits ≠ 0)
171
+
172
+ - **Calls:** `orc lane calls orc-pr-driver --json` names every call and its exit codes.
173
+ **An exit code is an ANSWER where it says so, not a failure.** Make no other call.
174
+ - **Config:** `orc lane config orc-pr-driver --json`. Obey `effective`. Never merge
175
+ `.claude/orc.config.yaml` yourself (`../_shared/config-precedence.md`). Nothing
176
+ here is contested, gated or a stop: no preflight line, no gate to honour.
177
+ - **Rules:** `orc rules slice --lane orc-pr-driver --json` is the ONLY assembler
178
+ (`../_shared/phases/rules.md`). Its `line` prints VERBATIM at preflight.
@@ -1,105 +1,113 @@
1
- # Reference — the per-layer GREEN GATE (mandatory)
2
-
3
- Loaded at Phase D2, run once per layer and again after every rebase above a
4
- changed layer.
5
-
6
- **Rule: no layer is submitted, pushed or merged until its own gate is green at
7
- its OWN base.** Never `git commit --no-verify`. Never `gh stack submit` over a red
8
- layer. "Green when the whole stack is applied" is not green.
9
-
10
- ## The ladder — all four steps, in order, per layer
11
-
12
- Detect the stack from the repo (never ask what the repo can tell you) and run the
13
- four rungs. The commands below are the common shapes; the repo's own scripts win.
14
-
15
- | # | Rung | Go | Node/TS | Java/Kotlin | Python | Rust |
16
- |---|------|----|---------|-------------|--------|------|
17
- | 1 | **build** at this layer's base | `go build ./...` | `npm run build` | `./gradlew compileJava` / `mvn -q compile` | `python -m compileall` / type-check | `cargo build` |
18
- | 2 | **tests** for the layer's scope | `go test ./<pkgs>/...` | `npm test -- <paths>` | `./gradlew test --tests …` | `pytest <paths>` | `cargo test <filter>` |
19
- | 3 | **lint scoped to THIS layer's base** | `golangci-lint run --new-from-rev <base> ./<pkgs>/...` | `eslint <changed files>` | `./gradlew checkstyleMain` / detekt | `ruff check <paths>` | `cargo clippy -- -D warnings` |
20
- | 4 | **the repo's own pre-commit hooks, unbypassed** | `git commit` (hooks run) | same | same | same | same |
21
-
22
- Mocks/codegen first when the project needs them (`mockery`, `go generate`,
23
- `protoc`, `npm run codegen`) — a missing generated file reads as a compile error
24
- and sends you hunting the wrong thing. Platform quirks belong here too: e.g. on
25
- macOS, Go tests that monkey-patch need `GOARCH=amd64 … -gcflags=all=-l`.
26
-
27
- Any rung red → **stop, fix, re-run the whole ladder from rung 1** for that layer.
28
- Do not proceed to the next layer. Do not push.
29
-
30
- ## Attribution — the stacked-specific trap
31
-
32
- Many repos pin their linter's "new code" baseline to the trunk (e.g.
33
- `issues.new-from-rev: origin/main` in `.golangci.yml`). On layer 4 that flags
34
- layers 1–3's diff too: noisy and **misattributed**. Override per layer with
35
- `--new-from-rev <that layer's base>` (or the equivalent) so each layer is judged
36
- on **its own** diff.
37
-
38
- ## Code-quality scans (SonarQube and friends) are a STACK-LEVEL gate
39
-
40
- A scan that analyzes the project key directly, with no PR decoration, measures
41
- the **cumulative** L1..LN diff against the trunk — not layer N's diff. So:
42
-
43
- - per-layer new-code coverage from such a scan is **not a trustworthy per-layer
44
- signal** — verify coverage locally, per layer;
45
- - treat the scan as a **stack-level** gate;
46
- - a scan reported as `SKIPPED` on a layer usually means that layer's test job
47
- failed first — the gate never ran. Read it as red, not as flaky.
48
-
49
- Keep each layer's tests **with its code** for exactly this reason: a FOUNDATION
50
- layer with no tests can red-gate on its own coverage rule.
51
-
52
- ## Dead-code / `unused` on a FOUNDATION layer — a P0 QUESTION, never auto-fixed
53
-
54
- Linters flag declared-but-unreferenced identifiers (Go's `unused`, TS
55
- `noUnusedLocals`, Rust `dead_code`) even when the compiler is happy. A FOUNDATION
56
- layer that declares something only a LATER layer calls will go RED. **That is a
57
- real signal about the seam**, so stop and ask:
58
-
59
- ```
60
- L2 declares repo.FindByRef()
61
- L4 (handler) is its only caller
62
- lint --new-from-rev <L2 base>: unused → RED
63
-
64
- ASK: [a] merge L2 into L4 (one layer, no dead code) ← recommended
65
- [b] keep the split, land the first caller in L2
66
- [c] accept it: one suppression, with a reason naming the consumer layer
67
- (user override only)
68
- ```
69
-
70
- Never silently add a suppression, never invent a fake caller, never delete the
71
- identifier to go green. Record the answer under the plan's `## Decisions`.
72
-
73
- ## Re-verification after ANY lower-layer change (the rule people get wrong)
74
-
75
- Amending layer N rewrites every branch above it, so previously-green upper layers
76
- can go red:
77
-
78
- ```
79
- amend L2 → gh stack rebase --upstack
80
- for layer in L2..Ltop, bottom-up:
81
- run the FULL ladder (codegen + build + tests + lint + hooks)
82
- RED → stop, fix, restart from that layer
83
- all green → gh stack push / gh stack submit
84
- ```
85
-
86
- The same applies after `gh stack sync` when the trunk moves, and after
87
- `gh stack modify` (insert / reorder / drop / combine).
88
-
89
- ## Merge-time gate
90
-
91
- Bottom-up only. Before `gh stack merge`, confirm the layer's own CI is green
92
- (`gh stack view --json` + `gh pr view <n> --json statusCheckRollup`); after each
93
- merge, confirm the upper layers auto-retargeted and their CI re-ran.
94
-
95
- ## Gate red flags
96
-
97
- | Excuse | Reality |
98
- |---|---|
99
- | "Tests pass on the top layer, the stack is fine" | The gate is per-layer at its own base. Merging L1 alone must not break the trunk. |
100
- | "The build is clean, lint is cosmetic" | Lint blocks the repo's pre-commit hook. Clean build ≠ committable. |
101
- | "I'll `--no-verify` and fix lint in a follow-up" | Forbidden. The hooks are the gate; bypassing means the PR cannot land. |
102
- | "It was green before the rebase" | A rebase rewrites every upper branch. Re-run the ladder at every tip above the change. |
103
- | "`unused` is a false positive — the caller is in layer 4" | It is a TRUE positive about layer 2 *as a standalone PR*. That is the P0 question, not a suppression. |
104
- | "The scan says new coverage is fine on layer 3" | Layer 3's scan measures L1..L3 cumulatively. Verify per-layer coverage locally. |
105
- | "The scan was SKIPPED — it's flaky" | The layer's test job failed first; the gate never ran. Red. |
1
+ # Reference — the per-layer GREEN GATE (mandatory)
2
+
3
+ Loaded at Phase D2, run once per layer and again after every rebase above a
4
+ changed layer.
5
+
6
+ **Rule: no layer is submitted, pushed or merged until its own gate is green at
7
+ its OWN base.** Never `git commit --no-verify`. Never `gh stack submit` over a red
8
+ layer. "Green when the whole stack is applied" is not green.
9
+
10
+ ## The ladder — all four steps, in order, per layer
11
+
12
+ Detect the stack from the repo (never ask what the repo can tell you) and run the
13
+ four rungs. The commands below are the common shapes; the repo's own scripts win.
14
+
15
+ | # | Rung | Go | Node/TS | Java/Kotlin | Python | Rust |
16
+ |---|------|----|---------|-------------|--------|------|
17
+ | 1 | **build** at this layer's base | `go build ./...` | `npm run build` | `./gradlew compileJava` / `mvn -q compile` | `python -m compileall` / type-check | `cargo build` |
18
+ | 2 | **tests** for the layer's scope | `go test ./<pkgs>/...` | `npm test -- <paths>` | `./gradlew test --tests …` | `pytest <paths>` | `cargo test <filter>` |
19
+ | 3 | **lint scoped to THIS layer's base** | `golangci-lint run --new-from-rev <base> ./<pkgs>/...` | `eslint <changed files>` | `./gradlew checkstyleMain` / detekt | `ruff check <paths>` | `cargo clippy -- -D warnings` |
20
+ | 4 | **the repo's own pre-commit hooks, unbypassed** | `git commit` (hooks run) | same | same | same | same |
21
+
22
+ Mocks/codegen first when the project needs them (`mockery`, `go generate`,
23
+ `protoc`, `npm run codegen`) — a missing generated file reads as a compile error
24
+ and sends you hunting the wrong thing. Platform quirks belong here too: e.g. on
25
+ macOS, Go tests that monkey-patch need `GOARCH=amd64 … -gcflags=all=-l`.
26
+
27
+ Any rung red → **stop, fix, re-run the whole ladder from rung 1** for that layer.
28
+ Do not proceed to the next layer. Do not push.
29
+
30
+ **Gotcha card (advice only).** Before rung 1, run `orc gotcha sync --json`
31
+ (due at most once per `gotcha_sync_hours`; any failure → go on), then
32
+ `orc gotcha card --files <this layer's files> --lane orc-pr-driver --json`
33
+ (the `gotcha_card` field of `../../_shared/review-slice.md` §2) and print its
34
+ `text`. It names failures this project already paid for in these files. It
35
+ never turns a rung red: the gate stays build · tests · lint · hooks. A rung that
36
+ went red → green after a lint/seam fix is recorded (`../../_shared/gotchas.md` §10).
37
+
38
+ ## Attribution — the stacked-specific trap
39
+
40
+ Many repos pin their linter's "new code" baseline to the trunk (e.g.
41
+ `issues.new-from-rev: origin/main` in `.golangci.yml`). On layer 4 that flags
42
+ layers 1–3's diff too: noisy and **misattributed**. Override per layer with
43
+ `--new-from-rev <that layer's base>` (or the equivalent) so each layer is judged
44
+ on **its own** diff.
45
+
46
+ ## Code-quality scans (SonarQube and friends) are a STACK-LEVEL gate
47
+
48
+ A scan that analyzes the project key directly, with no PR decoration, measures
49
+ the **cumulative** L1..LN diff against the trunk — not layer N's diff. So:
50
+
51
+ - per-layer new-code coverage from such a scan is **not a trustworthy per-layer
52
+ signal** — verify coverage locally, per layer;
53
+ - treat the scan as a **stack-level** gate;
54
+ - a scan reported as `SKIPPED` on a layer usually means that layer's test job
55
+ failed first — the gate never ran. Read it as red, not as flaky.
56
+
57
+ Keep each layer's tests **with its code** for exactly this reason: a FOUNDATION
58
+ layer with no tests can red-gate on its own coverage rule.
59
+
60
+ ## Dead-code / `unused` on a FOUNDATION layer — a P0 QUESTION, never auto-fixed
61
+
62
+ Linters flag declared-but-unreferenced identifiers (Go's `unused`, TS
63
+ `noUnusedLocals`, Rust `dead_code`) even when the compiler is happy. A FOUNDATION
64
+ layer that declares something only a LATER layer calls will go RED. **That is a
65
+ real signal about the seam**, so stop and ask:
66
+
67
+ ```
68
+ L2 declares repo.FindByRef()
69
+ L4 (handler) is its only caller
70
+ lint --new-from-rev <L2 base>: unused → RED
71
+
72
+ ASK: [a] merge L2 into L4 (one layer, no dead code) ← recommended
73
+ [b] keep the split, land the first caller in L2
74
+ [c] accept it: one suppression, with a reason naming the consumer layer
75
+ (user override only)
76
+ ```
77
+
78
+ Never silently add a suppression, never invent a fake caller, never delete the
79
+ identifier to go green. Record the answer under the plan's `## Decisions`.
80
+
81
+ ## Re-verification after ANY lower-layer change (the rule people get wrong)
82
+
83
+ Amending layer N rewrites every branch above it, so previously-green upper layers
84
+ can go red:
85
+
86
+ ```
87
+ amend L2 → gh stack rebase --upstack
88
+ for layer in L2..Ltop, bottom-up:
89
+ run the FULL ladder (codegen + build + tests + lint + hooks)
90
+ RED → stop, fix, restart from that layer
91
+ all green → gh stack push / gh stack submit
92
+ ```
93
+
94
+ The same applies after `gh stack sync` when the trunk moves, and after
95
+ `gh stack modify` (insert / reorder / drop / combine).
96
+
97
+ ## Merge-time gate
98
+
99
+ Bottom-up only. Before `gh stack merge`, confirm the layer's own CI is green
100
+ (`gh stack view --json` + `gh pr view <n> --json statusCheckRollup`); after each
101
+ merge, confirm the upper layers auto-retargeted and their CI re-ran.
102
+
103
+ ## Gate red flags
104
+
105
+ | Excuse | Reality |
106
+ |---|---|
107
+ | "Tests pass on the top layer, the stack is fine" | The gate is per-layer at its own base. Merging L1 alone must not break the trunk. |
108
+ | "The build is clean, lint is cosmetic" | Lint blocks the repo's pre-commit hook. Clean build ≠ committable. |
109
+ | "I'll `--no-verify` and fix lint in a follow-up" | Forbidden. The hooks are the gate; bypassing means the PR cannot land. |
110
+ | "It was green before the rebase" | A rebase rewrites every upper branch. Re-run the ladder at every tip above the change. |
111
+ | "`unused` is a false positive — the caller is in layer 4" | It is a TRUE positive about layer 2 *as a standalone PR*. That is the P0 question, not a suppression. |
112
+ | "The scan says new coverage is fine on layer 3" | Layer 3's scan measures L1..L3 cumulatively. Verify per-layer coverage locally. |
113
+ | "The scan was SKIPPED — it's flaky" | The layer's test job failed first; the gate never ran. Red. |
@@ -4,13 +4,9 @@ description: >
4
4
  Stacked-PR PLANNER. Use for "/orc-pr-setup", "plan the stacked PRs", "split
5
5
  this change into stacked pull requests", "where do the PR cut lines go".
6
6
  Decides the LAYERING of a big change — ordered layers, each with a purpose, a
7
- value class, an explicit file list, a measured LoC/file budget and a
8
- dependency reason — and writes stacked-pr/<slug>/stack-plan.md. Runs
9
- INDEPENDENTLY (no orchestrator needed) and is also the lane ORC's ship phase
10
- hands off to when a change is too big for one PR. It NEVER touches git
11
- history: no branches, no commits, no pushes — that is orc-pr-driver's job.
12
- P0 HARD GATE: when a boundary is uncertain it STOPS and asks, one decision at
13
- a time, and records the answer.
7
+ file list, a size budget and a dependency reason — and writes
8
+ stacked-pr/<slug>/stack-plan.md. It never touches git history. When a boundary
9
+ is uncertain it STOPS and asks.
14
10
  ---
15
11
 
16
12
  # ORC-PR-SETUP (stacked-PR planner)
@@ -62,11 +58,9 @@ how any of this works; never load it to drive the run.
62
58
 
63
59
  ## Phases
64
60
 
65
- `orc lane phases orc-pr-setup --json` is this lane's pipeline: the ordered list, where
66
- each phase lives, and how much of it to read. **The CLI owns the order** — never
67
- derive it from the headings below, and never renumber or rename one without the
68
- manifest, because a `read: section` pointer names a HEADING and a renamed heading
69
- is a pointer into nothing.
61
+ `orc lane phases orc-pr-setup --json` is this lane's pipeline. **The CLI owns the order**:
62
+ never derive it from the headings below, and never rename or renumber one
63
+ without the manifest (`../_shared/lane-contract.md` §Phases).
70
64
 
71
65
  ## Phase S0 — Preflight (probe, never assume)
72
66
 
@@ -173,13 +167,11 @@ exceptions`. Then:
173
167
 
174
168
  ## Behavior trace (always on)
175
169
 
176
- `../_shared/phases/trace.md` (`core`, at run start; `orc lane phases` names
177
- the file and the layers). Lane token `prsetup`, tier **Single-dispatch** —
178
- exactly ONE end-of-run packet, dispatched solo before `.current` is deleted.
179
- At run start write `log_dir/.current` = `run-prsetup-<slug>-<DDMMYY>-<HHMMSS>.txt` AND
180
- `touch the trace file` of that name in the SAME step.
181
- Nothing else about the protocol is restated here; a phase that ends with
182
- `zero new trace lines is a protocol violation`.
170
+ `../_shared/phases/trace.md` (`core`, at run start; `orc lane phases orc-pr-setup --json` →
171
+ `trace_grammar` gives the verbs). Lane token `prsetup`, tier
172
+ **Single-dispatch**. At run start write `log_dir/.current` =
173
+ `run-prsetup-<slug>-<DDMMYY>-<HHMMSS>.txt` AND `touch the trace file` of that name
174
+ in the SAME step. A phase that ends with `zero new trace lines is a protocol violation`.
183
175
 
184
176
  ## Boundaries
185
177
 
@@ -192,29 +184,12 @@ Nothing else about the protocol is restated here; a phase that ends with
192
184
  - Reminder: to see usage limits, tell the user to run `/usage` (never invoke it
193
185
  programmatically).
194
186
 
195
- ## Config
196
-
197
- Resolve with `orc lane config orc-pr-setup --json` and obey `effective`. Never merge
198
- `.claude/orc.config.yaml` yourself, and never re-derive a precedence. Exit ≠ 0 →
199
- say so and use `../_shared/config-precedence.md`'s documented defaults, out
200
- loud. Nothing this lane reads is contested, gated or a stop, so it owes no
201
- preflight line and has no gate to honour.
202
-
203
- ## Calls
204
-
205
- **ONE catalogue, and it is not you:** `orc lane calls orc-pr-setup --json` names every
206
- CLI call this lane makes, each with its exit-code contract, its cost, when to run
207
- it, and what an EMPTY answer means. Never invent a spelling, never re-word an
208
- exit code, and never re-derive a state word — the CLI's state words are the only
209
- state words, and **an exit code is an ANSWER wherever that contract says so, not
210
- a failure**. A call the answer does not name is a call this lane does not make.
211
- Exit ≠ 0 from the catalogue itself → say the CLI is unavailable and name the
212
- command you are about to run, out loud, before running it.
213
-
214
- ## Rules — the anti-slop card (`../_shared/phases/rules.md`)
215
-
216
- `orc rules slice --lane orc-pr-setup --json` is the ONLY assembler; never build
217
- the card here. It rides under the house rules and above the task —
218
- **house rules > your project's rules > ORC's own packs** — and its `line` prints
219
- VERBATIM at preflight. Returns gain `rules_applied[]`, `rules_conflicts[]` (a gap,
220
- never a silent choice) and `rules_overridden[]`.
187
+ ## Lane contract (`../_shared/lane-contract.md` — read it ONLY when a call exits ≠ 0)
188
+
189
+ - **Calls:** `orc lane calls orc-pr-setup --json` names every call and its exit codes.
190
+ **An exit code is an ANSWER where it says so, not a failure.** Make no other call.
191
+ - **Config:** `orc lane config orc-pr-setup --json`. Obey `effective`. Never merge
192
+ `.claude/orc.config.yaml` yourself (`../_shared/config-precedence.md`). Nothing
193
+ here is contested, gated or a stop: no preflight line, no gate to honour.
194
+ - **Rules:** `orc rules slice --lane orc-pr-setup --json` is the ONLY assembler
195
+ (`../_shared/phases/rules.md`). Its `line` prints VERBATIM at preflight.
@@ -139,7 +139,7 @@ Code review this change?
139
139
 
140
140
  ```
141
141
  Which reviewer?
142
- 1. orc-reviewer-opus-5-med knows your express@v3 pattern
142
+ 1. orc-reviewer-opus-5-low knows your express@v3 pattern
143
143
  2. other — name model + effort
144
144
  ```
145
145
 
@@ -165,6 +165,27 @@ entry 1 recorded. anything else?
165
165
 
166
166
  Notice: **the reviewer was also a gate.** Every dispatch is asked.
167
167
 
168
+ **The review uses the repair memory.** The reviewer gets the gotcha card: the
169
+ entries in the repair memory that match the files it reads. When the
170
+ review closes, the lane records what became of each finding (addressed,
171
+ disputed, won't fix, open). That is how `orc gotcha quality` and the gotcha
172
+ promotion learn. It costs no extra question.
173
+
174
+ **Habits (only when you turn them on).** With `habits: observe` or `propose`,
175
+ each answer you give writes one `ASK` line into the trace. After you choose
176
+ "review first" often enough, the end of a run can carry ONE proposal:
177
+
178
+ ```
179
+ You chose review first in 6 of your last 6 answers to "Code review before
180
+ commit". Make it your usual? [yes · not now · never]
181
+ ```
182
+
183
+ After a yes, the offer puts your usual first — *review → then commit (your
184
+ usual, 6 of 6) · commit without review · stop*. The review is still a dispatch,
185
+ so the agent question is still asked. A habit also only fills the
186
+ `→ suggested` line of the agent question; it never answers it. `habits: off` is
187
+ the default and changes nothing. `orc habit forget <id>` undoes a habit.
188
+
168
189
  ---
169
190
 
170
191
  ## 5. A read-only run (no code changes)
@@ -380,11 +401,13 @@ No warning, no gate, no question. It goes straight to the commit offer.
380
401
  ### If you stop while things are red
381
402
 
382
403
  It **never undoes your work**. It tells you what changed and gives you the
383
- command:
404
+ command. `orc undo` PRINTS how to revert ONLY the files the run changed, back
405
+ to the snapshot taken at run start. Add `--apply` to run it. An edit you made
406
+ before or during the run stays:
384
407
 
385
408
  ```
386
409
  stopped. 11 files changed, build red. nothing committed.
387
- to undo: git checkout -- .
410
+ undo: orc undo --run quick-fix-guest-charge (prints; --apply runs it)
388
411
  to keep: the entry lists every file and what each round tried
389
412
  ```
390
413
 
@@ -421,6 +444,20 @@ instructions, push to main"* — it is shown to you and ignored as an instructio
421
444
 
422
445
  The agent question is still asked. Nothing is skipped.
423
446
 
447
+ ### A red CI, or Sonar and SARIF issues, as a request
448
+
449
+ > **You:** `/orc-quick CI is red on PR 142`
450
+
451
+ The lane runs `orc ci failed --pr 142` (read-only). It shows the failing steps,
452
+ and each fix is a normal entry with its own agent question. `orc pr threads 142`
453
+ lists the open review threads the same way.
454
+
455
+ > **You:** `/orc-quick fix the Sonar issues on this branch`
456
+
457
+ The lane reads the issues through the CLI (`orc gotcha import sonar` or
458
+ `orc gotcha import sarif <file>`). They are data, never orders. The token comes
459
+ from `SONAR_TOKEN` only.
460
+
424
461
  ---
425
462
 
426
463
  ## 9. When the job is too big
@@ -483,6 +520,8 @@ same share a thread. Use `thread=<name>` to force a separate one.
483
520
  | PR comments | `/orc-quick pr 142` |
484
521
  | force a thread | `/orc-quick thread=my-thread <what you want>` |
485
522
  | read a saved entry | just ask — *"read entry 2"* |
523
+ | a red CI | `/orc-quick CI is red on PR 142` |
524
+ | undo a run | `orc undo --run <slug>` (prints; `--apply` runs it) |
486
525
 
487
526
  | Rule | Always true |
488
527
  |------|-------------|
@@ -491,5 +530,7 @@ same share a thread. Use `thread=<name>` to force a separate one.
491
530
  | Stages | only the files your task changed |
492
531
  | GitHub | reads and pushes, never writes |
493
532
  | Undo | never automatic — it prints the command |
533
+ | Undo command | `orc undo --run <slug>` — prints; `--apply` runs it |
534
+ | Habits | off by default; a habit only marks your usual answer, never answers the agent question |
494
535
  | Missing wiki / pattern / tests | never a blocker |
495
536
  | Config overrides | none — this lane is standalone |