shapeup-sdlc 1.7.0 → 3.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 (98) hide show
  1. package/.claude/settings.local.example.json +5 -5
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/AGENTS.md +17 -3
  4. package/README.md +124 -103
  5. package/SECURITY.md +37 -30
  6. package/bin/init.mjs +77 -47
  7. package/bin/lib/grant.mjs +145 -0
  8. package/commands/build.md +7 -6
  9. package/commands/ship.md +29 -16
  10. package/commands/wire.md +1 -1
  11. package/hooks/dispatch-receipt.mjs +195 -0
  12. package/hooks/gate-intake.mjs +3 -3
  13. package/hooks/gate-zerowork.mjs +25 -24
  14. package/hooks/hooks.json +9 -48
  15. package/hooks/lib/decision.mjs +19 -8
  16. package/hooks/safety-spine.mjs +3 -3
  17. package/hooks/sandbox-guard.mjs +84 -40
  18. package/{skills/tech-lead/scripts/compile-order.mjs → kernel/compile.mjs} +283 -41
  19. package/{skills/tech-lead/scripts/gate-answers.mjs → kernel/gate.mjs} +58 -14
  20. package/kernel/harness.mjs +134 -0
  21. package/{skills/tech-lead/scripts/fit-check.mjs → kernel/init/fit.mjs} +15 -12
  22. package/{skills/tech-lead/scripts/init-run.mjs → kernel/init/run.mjs} +152 -31
  23. package/{skills/tech-lead/scripts → kernel}/lib/argv.mjs +52 -31
  24. package/{skills/tech-lead/scripts/lib/contract-md.mjs → kernel/lib/contract.mjs} +251 -7
  25. package/kernel/lib/paths.mjs +491 -0
  26. package/kernel/probe/concurrency.mjs +510 -0
  27. package/{skills/tech-lead/scripts/aegis-digest.mjs → kernel/probe/digest.mjs} +9 -10
  28. package/kernel/probe/eval.mjs +77 -0
  29. package/kernel/probe/leg.mjs +125 -0
  30. package/{skills/tech-lead/scripts/resume-state.mjs → kernel/probe/resume.mjs} +204 -63
  31. package/{skills/tech-lead/scripts → kernel/probe}/stats.mjs +93 -11
  32. package/kernel/probe/t0.mjs +66 -0
  33. package/{skills/ba-pitch-analyzer/scripts/board-derive.mjs → kernel/reduce/board.mjs} +99 -23
  34. package/kernel/reduce/graph.mjs +437 -0
  35. package/{skills/tech-lead/scripts/hill-derive.mjs → kernel/reduce/hill.mjs} +28 -9
  36. package/kernel/reduce/ingest.mjs +633 -0
  37. package/{hooks/slop-cleaner.mjs → kernel/reduce/leftovers.mjs} +40 -57
  38. package/{skills/tech-lead/scripts/ship-report.mjs → kernel/reduce/ship.mjs} +61 -13
  39. package/{skills/tech-lead/scripts/run-snapshot.mjs → kernel/reduce/snapshot.mjs} +21 -15
  40. package/{skills/spec-evaluator/scripts/verdict-ledger.mjs → kernel/reduce/verdict.mjs} +13 -7
  41. package/kernel/report/export.mjs +325 -0
  42. package/kernel/report/facts.mjs +347 -0
  43. package/{skills/tech-lead/scripts/budget-check.mjs → kernel/verify/budget.mjs} +15 -12
  44. package/kernel/verify/dispatch.mjs +114 -0
  45. package/{skills/tech-lead/scripts/validate-envelope.mjs → kernel/verify/envelope.mjs} +20 -15
  46. package/{skills/tech-lead/scripts/lib → kernel/verify}/ratchet-tree.mjs +36 -14
  47. package/kernel/verify/skills.mjs +125 -0
  48. package/kernel/verify/spec.mjs +559 -0
  49. package/{skills/tech-lead/scripts/t0-verify.mjs → kernel/verify/t0.mjs} +134 -24
  50. package/{skills/tech-lead/scripts/trace-lint.mjs → kernel/verify/trace.mjs} +26 -11
  51. package/oracles/http-oracle.mjs +1 -1
  52. package/oracles/process-oracle.mjs +1 -1
  53. package/oracles/snapshot-oracle.mjs +1 -1
  54. package/oracles/test-oracle.mjs +1 -1
  55. package/package.json +11 -9
  56. package/skills/ba-pitch-analyzer/SKILL.md +5 -5
  57. package/skills/ba-pitch-analyzer/assets/templates/_index.tmpl.md +1 -1
  58. package/skills/ba-pitch-analyzer/assets/templates/api-feasibility.tmpl.md +12 -7
  59. package/skills/ba-pitch-analyzer/assets/templates/contracts/third-party-api.contract.tmpl.md +6 -3
  60. package/skills/ba-pitch-analyzer/assets/templates/cross-context/migration-plan.tmpl.md +5 -4
  61. package/skills/ba-pitch-analyzer/assets/templates/cross-context/team-handoff.tmpl.md +23 -13
  62. package/skills/ba-pitch-analyzer/assets/templates/scope-summary.tmpl.md +17 -12
  63. package/skills/ba-pitch-analyzer/assets/templates/synthesis.tmpl.md +17 -38
  64. package/skills/ba-pitch-analyzer/assets/templates/task.tmpl.md +3 -0
  65. package/skills/ba-pitch-analyzer/references/contract-patterns.md +8 -4
  66. package/skills/ba-pitch-analyzer/references/doc-schemas.md +2 -0
  67. package/skills/ba-pitch-analyzer/references/task-generation.md +2 -2
  68. package/skills/qa-edge-hunter/SKILL.md +7 -3
  69. package/skills/scope-architect/SKILL.md +40 -6
  70. package/skills/solution-architect/SKILL.md +19 -4
  71. package/skills/spec-evaluator/SKILL.md +12 -2
  72. package/skills/task-executor/SKILL.md +7 -6
  73. package/skills/tech-lead/SKILL.md +50 -38
  74. package/skills/tech-lead/references/gates.md +69 -20
  75. package/skills/tech-lead/references/protocol.md +832 -0
  76. package/skills/tech-lead/schemas/domain.schema.json +341 -66
  77. package/skills/tech-lead/schemas/work-order.schema.json +11 -2
  78. package/skills/tech-lead/schemas/work-result.schema.json +1 -1
  79. package/skills/tech-lead/workflows/shapeup-run.js +1313 -750
  80. package/hooks/anti-rationalization.mjs +0 -238
  81. package/hooks/compact-snapshot.mjs +0 -47
  82. package/hooks/gate-deadline.mjs +0 -147
  83. package/hooks/gate-l2.mjs +0 -161
  84. package/hooks/session-rehydrate.mjs +0 -108
  85. package/skills/ba-pitch-analyzer/scripts/spec-lint.mjs +0 -239
  86. package/skills/spec-evaluator/README.md +0 -93
  87. package/skills/tech-lead/README.md +0 -71
  88. package/skills/tech-lead/references/delegation.md +0 -261
  89. package/skills/tech-lead/references/hard-rules.md +0 -34
  90. package/skills/tech-lead/references/invocation.md +0 -45
  91. package/skills/tech-lead/references/ledger-schema.md +0 -213
  92. package/skills/tech-lead/references/round-protocol.md +0 -234
  93. package/skills/tech-lead/references/state-model.md +0 -66
  94. package/skills/tech-lead/scripts/ingest-result.mjs +0 -258
  95. package/skills/tech-lead/scripts/lib/is-main.mjs +0 -81
  96. package/skills/tech-lead/scripts/lib/paths.mjs +0 -280
  97. package/skills/tech-lead/scripts/run-workflow.mjs +0 -381
  98. package/skills/translator/README.md +0 -66
@@ -0,0 +1,832 @@
1
+ # Protocol — the round loop, the delegation shape, and the invariants behind both
2
+
3
+ Three things that only make sense together: what a round DOES, how each step is dispatched, and
4
+ which rules the code enforces so a model does not have to remember them.
5
+
6
+ On a spec with committed scope contracts all of this is CODE —
7
+ `skills/tech-lead/workflows/shapeup-run.js`. This file is the readable rationale for why that code
8
+ is shaped the way it is, plus the verbatim prose path for the lanes the script does not cover
9
+ (`--tiny`, and any spec with no `scopes/*.md` yet).
10
+
11
+ ---
12
+
13
+ # Part 1 — The round loop
14
+
15
+ The orchestration loop in detail. A "round" is one BUILD phase followed by exactly one
16
+ EVAL phase. The feature is done when an EVAL round returns PASS.
17
+
18
+ > `tasks/_index.md` referenced throughout this file lives in the LOCAL gitignored root
19
+ > (`.shapeup/<slug>/tasks/`, v3.2), not the
20
+ > SHARED spec dir. See tech-lead SKILL.md GATE L1b for the bootstrap step that regenerates it
21
+ > when missing.
22
+
23
+ **On a spec with committed scope contracts, this loop is now CODE, not prose** —
24
+ `skills/tech-lead/workflows/shapeup-run.js`'s own `while (round <= args.budgets.maxRounds)` loop
25
+ implements exactly the shape below (PASS → ship; `max_rounds` exceeded → GATE H `breaker: outer`;
26
+ else the next round builds bugs only), with the EVAL-timing rule, the regression rule, and the
27
+ three-level breaker all enforced as branches in that script rather than described here for a model
28
+ to follow. Read that script's own comments for the mechanics; this file keeps the historical
29
+ rationale and the parts of the protocol the script does not cover (ESCALATE adjudication,
30
+ discovered-task reconciliation mid-BUILD — see its banner
31
+ for the full list) — and, unchanged, the loop below for a `--tiny` run or a spec with no scope
32
+ contracts, which `shapeup-run.js` is out of scope for by design.
33
+
34
+ ```
35
+ round r = 1
36
+ loop:
37
+ BUILD(r) # see r=1 vs r>1 below
38
+ assert board 100% done # GATE L2 — advisory: the hook warns, you decide
39
+ verdict, bugs = EVAL(r) # ONE spec-evaluator --feature pass
40
+ if verdict == PASS:
41
+ SHIP; break
42
+ if r >= max_rounds:
43
+ ESCALATE(bugs); break # honest stop — no infinite loop
44
+ r = r + 1 # next round builds bugs only
45
+ ```
46
+
47
+ ## BUILD(r) semantics
48
+
49
+ | | r = 1 (initial build) | r > 1 (fix build) |
50
+ |--|----------------------|-------------------|
51
+ | Input | the whole task board | the bug list from EVAL(r-1) |
52
+ | Scope | every ready task, dependency/layer order, until board all ✅ | only the tasks/areas named by bugs |
53
+ | Command | compile-order `--next` → task-executor `--order` → ingest, looped | compile-order `--task <id> --operation fix` → dispatch → ingest, per bug |
54
+ | Passing areas | n/a | never touched |
55
+ | SPIKEs | resolved first (they block) | only if a bug is a SPIKE finding |
56
+
57
+ Re-opening tasks in r>1: the fix order's WorkResult reports the task `partial` while failing
58
+ and `done` when re-verified; ingest-result flips the board accordingly. The board reflects the
59
+ churn so the next EVAL sees a green board again.
60
+
61
+ Discovered Tasks:
62
+ If WorkResults carry `discoveries[]` during BUILD, ingest-result appends them to the discovery
63
+ ledger (`.shapeup/<slug>/discovery/ledger.md`) and the build loop pauses after the current
64
+ tasks are done. Compile + dispatch a reconcile order (ba-pitch-analyzer, operation: reconcile).
65
+ This reconciles them into new tasks and invariants and updates the board; the tech lead bumps
66
+ `discovered_rounds` in harness-run.md, then routes back to GATE L1b (Board Review) for PO
67
+ approval of the new tasks and estimates before resuming the BUILD loop.
68
+
69
+ ## The EVAL timing rule (the core constraint)
70
+
71
+ EVAL fires **once** per round and **only** when GATE L2 has confirmed the board is 100% done.
72
+ It is never:
73
+ - called per task,
74
+ - called inside the BUILD loop,
75
+ - called on a partial board.
76
+
77
+ ## Regression rule (r > 1) — QA-meeting Bước 1c
78
+
79
+ A fix round changes code; a fix can break what passed. Therefore EVAL(r>1) scope is **not**
80
+ just the fixed bugs:
81
+
82
+ ```
83
+ EVAL(r) for r > 1:
84
+ touched_UCs = every UC referenced (use_case_refs) by a task re-opened in BUILD(r)
85
+ scope = fixed bugs' criteria
86
+ + FULL re-run of `## Test Surface` rows for every touched UC
87
+ (test-surface-conformance dimension, when active)
88
+ + completeness re-check (cheap, static)
89
+ untouched UCs' surfaces: NOT re-run (their code didn't change; re-probing everything
90
+ every round would turn cheap end-of-round QA into a full-suite tax)
91
+ ```
92
+
93
+ Pre-v2.9 specs (no Test Surface anywhere): the rule degrades to bug-criteria-only, as
94
+ before — and the verdict report notes `regression coverage: none (no test surface)`.
95
+ Honest reporting over silent coverage claims.
96
+
97
+ ## QA edge hunt (post-PASS, pre-ship)
98
+
99
+ When EVAL(r) returns PASS for the **first** time in a run, the orchestrator delegates one
100
+ `/qa-edge-hunter` pass before SHIP (skippable via `--no-qa`, same spirit as `--no-eval`).
101
+ QA is a pure worker: no verdict, no score, no gate — it writes `~` findings to
102
+ `discovery/ledger.md` and a `qa/hunt-report.md`. Triage happens at SHIP/GATE L4:
103
+ - all findings stay `~` → SHIP; findings carry over as raw ideas (debt-free).
104
+ - PO/TL promote any to must-have → a fix round r+1 (those items only) → EVAL
105
+ never a second full hunt) → back to L4.
106
+ - Circuit breaker applies: out of rounds/appetite → ship with `~` findings recorded.
107
+ QA never runs on a FAIL round — a build that hasn't passed conformance isn't worth
108
+ edge-hunting yet.
109
+
110
+ Rationale (from the long-running harness work): a single end-of-round QA pass over the
111
+ running feature is cheap relative to the build (minutes vs hours) and catches the
112
+ last-mile defects, whereas grading every task multiplies evaluator cost for little gain
113
+ once the generator is competent. If the build round didn't finish, there is nothing
114
+ coherent to evaluate yet.
115
+
116
+ ## Stop conditions
117
+ 1. **PASS** — EVAL(r) verdict is PASS → SHIP.
118
+ 2. **max_rounds (OUTER breaker)** — r would exceed `--max-rounds` (default 3) without PASS →
119
+ ESCALATE: print the residual bug list, the rounds used, and hand the decision to the PO
120
+ (scope contracts present: also `/scope-hammer --breaker outer`). Do not start another
121
+ build round automatically.
122
+ 3. **attempt_budget (INNER breaker, scope contracts only)** — a single scope's T0 attempt
123
+ loop exhausts `--attempts` (default 5) without reaching a trial that is both `kept` and
124
+ T0-green, **or** `no_progress_k` consecutive trials come back non-`kept` (the stagnation
125
+ term, default 2 — `harness compile` prints it as a JSON breaker object on stderr) →
126
+ does NOT stop the round; queues a hammer PROPOSAL for GATE H and moves to the next scope
127
+ in sequence. See "Three-level circuit breaker" below.
128
+ 4. **wall_clock_budget (DEADLINE breaker, opt-in)** — elapsed seconds since the run receipt
129
+ exceed `--wall-clock-budget` → do NOT start another build round or another scope; go
130
+ straight to GATE H (`/scope-hammer --breaker deadline`). Checked with
131
+ `harness verify budget` at every round boundary and enforced by `harness verify budget`,
132
+ which denies a `task-executor` dispatch past the deadline while leaving `spec-evaluator`,
133
+ `scope-hammer` and `qa-edge-hunter` reachable — a run past its deadline
134
+ must still be able to judge, hammer, and close. Off unless configured.
135
+ 5. **Hard error** — a sub-skill fails irrecoverably (e.g. spec folder gone, app won't
136
+ build at all) → stop and report; do not retry blindly.
137
+ 6. **User halt** — at any L-gate the user can stop the run; the ledger preserves state for
138
+ `--from` resume.
139
+
140
+ ## Three-level circuit breaker
141
+
142
+ ```
143
+ OUTER round_budget (max_rounds) — the six-week-timebox analog. Decremented once per
144
+ round at GATE L2, regardless of how many scopes it
145
+ covered. Hitting 0 → GATE H immediately (§ above).
146
+ INNER attempt_budget (per scope) — decremented once per T0 attempt inside BUILD round r.
147
+ Hitting its cap WITHOUT a T0-green result trips the
148
+ inner breaker for that scope only: the scope is queued
149
+ as a hammer PROPOSAL (not a hard stop) and the round
150
+ moves on to the next scope in the L1b sequence.
151
+ no_progress_k (default 2) is COMPOSED INTO this same
152
+ breaker rather than added beside it as a fourth budget:
153
+ attempt_budget counts attempts and cannot see that the
154
+ last two produced nothing, so k consecutive non-`kept`
155
+ trials queue the same GATE H proposal early.
156
+ DEADLINE wall_clock_budget_s — elapsed seconds since the run receipt. Opt-in; off
157
+ unless set at L0. Tripping routes to GATE H with
158
+ --breaker deadline. Enforced by `harness verify budget`.
159
+ ```
160
+
161
+ **Why the third one exists — and it corrects an earlier diagnosis.** A run killed at an external
162
+ time cap looks like a stall from outside: no verdict, nothing to show. The natural reading is that
163
+ it hung at a gate. Often the transcript says otherwise — steady turns, steady writes, gate markers
164
+ advancing, zero stall signals. The run was working when the clock ran out.
165
+
166
+ Both existing breakers count *events*, not time: `round_budget` moves once per round,
167
+ `attempt_budget` once per T0 attempt. Neither can observe that round 1 has been running for
168
+ twenty-nine minutes, so a run can burn its entire wall clock with both breakers untouched. The
169
+ cost is not the missing verdict — it is that a run killed from *outside* ships nothing, not even the
170
+ scopes that were already green. A breaker that trips from the inside routes to GATE H, where
171
+ scope-hammer compares the shippable subset against the baseline and ships what works. Same clock,
172
+ different ending.
173
+ Nesting rationale: a struggling scope should not freeze every other scope's progress
174
+ in the same round — only running out of *rounds* (the real six-week analog) stops the whole
175
+ run. A scope that trips its inner breaker still gets judged fairly at GATE H: scope-hammer
176
+ compares "ship without this scope" against the baseline, same as any other cut candidate — it
177
+ is never silently dropped, and it is never allowed to block scopes that ARE working.
178
+
179
+ ## Isolated attempt loop — one T0 attempt, in detail (scope contracts only)
180
+
181
+ **This is `shapeup-run.js`'s inner per-scope loop, as code**, with one addition the prose below
182
+ never had: before opening a scope's attempt loop, the script checks whether THIS round already
183
+ has a green T0 verdict for that scope on disk, and skips it when it does — the resumability a
184
+ mid-BUILD kill needs, that a session narrating this loop from memory could never guarantee.
185
+
186
+ Whichever runs it, the loop is a **ratchet**: every attempt is scored against the last kept one,
187
+ and the working tree moves forward only when the score strictly improves. `harness verify t0` makes
188
+ that decision and acts on the tree itself, inside the runtime — its caller reads the decision, it
189
+ never makes it.
190
+
191
+ ```
192
+ compile-order --scope … --round N --attempt M
193
+ → zero-memory WorkOrder (scope contract + this scope's
194
+ tasks + digested errors + ledger decisions +
195
+ trial_history: the last 8 trials for this scope, each
196
+ with score, status, delta and top-3 digest, CROSSING the
197
+ round boundary — compiled facts, no chat history by
198
+ construction)
199
+ dispatch task-executor --order … → code within substrate; WorkResult in results/
200
+ ingest-result <result> → board/ledger writes
201
+ (a worker cannot escalate) → WorkResult carries no escalates field. A phase that
202
+ cannot finish leaves no artifact, the post-condition
203
+ fails, and the run ABORTS naming the phase. Resolve it
204
+ yourself and record the answer in round-ledger.md, which
205
+ the NEXT attempt's fresh context reads back.
206
+ harness verify t0 → fixtures + DB probe + (on green) seesaw, then scores the
207
+ attempt against the baseline trial and snapshots or
208
+ restores the tree. Branch on `status` from its stdout
209
+ JSON — the tree action has ALREADY happened:
210
+ kept strictly better, INCLUDING red-but-improved (2/5 → 4/5 fixtures — the whole point
211
+ of the ratchet). Tree snapshotted to refs/shapeup/<scope_id>/kept.
212
+ overall=green → the attempt loop breaks; scope reaches DOWNHILL_EXECUTION.
213
+ Still red → loop, and attempt M+1 now builds ON attempt M.
214
+ reverted not better. A tie on a RED score is not better either — but a tie on a GREEN one
215
+ KEEPS, because a spec-conformance fix cannot raise a score that is already at
216
+ full marks, and reverting it would discard exactly the work a fix round exists
217
+ to do. Tree already restored from the last kept
218
+ snapshot. Subsumes the retired stash-and-retry branch: a FINISHED scope's broken
219
+ fixture raises score.regressions and reverts through this same rule, which
220
+ is why seesaw runs before anything is declared green.
221
+ rather than the code. Tree kept, baseline reset. Not a verdict, not a failure.
222
+ crash a fixture command failed to spawn or timed out; tree restored. Fix the fixture,
223
+ not the code.
224
+ (on any red, `discovered_tasks` carries the AEGIS {file, line, core_message} triples, which
225
+ compile-order folds into the NEXT attempt's order as digested_errors — no separate dispatch)
226
+ ```
227
+
228
+ **The exit code is not the branch selector.** `harness verify t0` exits 0 on T0-green and 1 on
229
+ T0-red (2 on bad argv), mirroring the `oracles/*` convention — so a `kept` red-but-improved
230
+ attempt, the exact case the ratchet exists for, exits 1. Branch on `status` from the stdout
231
+ JSON; never on `$?`, and never wire this call into a `set -e` / `&&` chain that would read a
232
+ non-zero exit as "stop".
233
+
234
+ This replaces the old flat per-task loop for any scope that has a contract;
235
+ scopes/specs without one keep the v0.2.6 behavior verbatim (see BUILD(r) table above).
236
+
237
+ ## --no-eval (skip evaluation)
238
+ A tech-lead judgment, surfaced at GATE L2: if the feature is clearly within what the model
239
+ builds reliably solo, the evaluator is optional overhead. With `--no-eval`, after GATE L2
240
+ the run goes straight to SHIP with verdict `not-evaluated` recorded in the ledger and a
241
+ clear note that nothing was verified beyond task-executor's own per-AC evidence checks.
242
+
243
+ ## Round-cost intuition
244
+ Build dominates; eval is cheap. Expect each EVAL round to cost a small fraction of a BUILD
245
+ round. This is why running eval once per round (not per task) is the right trade: you pay a
246
+ little QA at the end of each build and keep the expensive build coherent in between.
247
+
248
+ <!-- test requirement -->
249
+ kept|reverted|rebased|crash, decided in harness verify t0 decideStatus()
250
+
251
+ ---
252
+
253
+ # Part 2 — Delegation
254
+
255
+ The tech lead invokes the build-phase skills and reads their handoff files. It never
256
+ reimplements their logic. Each sub-skill keeps its own gates; pass `--auto` to a sub-skill
257
+ only when the run's auto level is `--auto` or `--unattended`.
258
+
259
+ ## Invocation mechanism — Agent, not Skill
260
+
261
+ Every "Invoke:" line below means: call the **Agent** tool — a real subagent, on its own
262
+ context and (where a role is named) its own model — whose prompt tells it to run
263
+ `Skill(shapeup-sdlc-plugin:<name>)` with the given args and report back the artifacts. It does
264
+ **not** mean the tech lead calls the `Skill` tool itself. A direct `Skill` call executes
265
+ inline, in the tech lead's own turn, on the tech lead's own model — that silently drops GATE
266
+ L0.8's model matrix (there is no per-role model left to route once the call is inline) and
267
+ breaks the isolation the zero-memory-handoff design (`protocol.md`, the compiled
268
+ WorkOrder in `orders/r<N>-a<M>.json`) already assumes every worker below has.
269
+
270
+ Standard shape (pure-skill architecture v1.0 — the envelope port):
271
+ ```
272
+ 1. node "${CLAUDE_PLUGIN_ROOT}/kernel/harness.mjs" compile <mode flags> # → orders/<id>.json
273
+ 2. Agent({
274
+ description: "<short task description>",
275
+ subagent_type: "general-purpose",
276
+ model: "<role model resolved at GATE L0.8>",
277
+ prompt: "Call Skill(shapeup-sdlc-plugin:<skill>) --order <orders/<id>.json>.
278
+ Report back: the WorkResult path (.shapeup/<slug>/results/<id>.json)."
279
+ })
280
+ 3. node "${CLAUDE_PLUGIN_ROOT}/kernel/harness.mjs" reduce ingest .shapeup/<slug>/results/<id>.json
281
+ ```
282
+ The WorkOrder carries everything the worker may rely on (payload, decisions, digested errors,
283
+ substrate write-contract); the WorkResult carries everything the worker used to write into
284
+ shared files. `harness verify envelope` runs as a PreToolUse hook on Skill|Agent and DENIES a
285
+ dispatch whose `--order` file is missing or schema-invalid. Workers write only their own
286
+ domain artifacts inside their substrate — never boards, ledgers, or run-state.
287
+
288
+ Role → model, resolved once at GATE L0.8 from the `orch`/`exec`/`eval`/`qa` matrix
289
+ (`harness verify t0` is mechanical tooling run directly via Bash, never an Agent — zero LLM
290
+ tokens):
291
+
292
+ | Skill | L0.8 role | Why this tier |
293
+ |-------|-----------|---------------|
294
+ | translator | exec | one-shot text transform — builder tier |
295
+ | orient (Scout) | exec | reads/spikes code — builder tier, not judgment |
296
+ | ba-pitch-analyzer | exec | planner — builder tier, not judgment |
297
+ | scope-architect | exec | scope-contract author (sole writer of scopes/*.md) — builder tier |
298
+ | task-executor | exec | the builder itself |
299
+ | spec-evaluator | eval | the single judge (judge ≠ doer) — keep its own matrix key even if a PO points it at the same model as `exec`, so it can be split later without a harness change |
300
+ | qa-edge-hunter | qa | cheapest tier by design — exploratory breadth over depth |
301
+ | scope-hammer | exec | census + baseline comparison, proposes only — not a verdict |
302
+ | coach | exec | categorization gate, not a verdict |
303
+
304
+ The tech lead itself is `orch` — this conversation, never delegated to.
305
+
306
+ The order is **Orient (7) → Map Scopes (8) → Build (9) → Eval**, faithful to Shape Up: the
307
+ team orients before any board exists, so the planner's board is reality-born. The tech lead
308
+ is the **sole writer of run-state** (`harness-run.md`) — it passes each worker the run
309
+ metadata it needs (`feature`, `spec`, `stack`, `discovered_rounds`, `--auto`) as **args**;
310
+ workers keep only their own product-idempotency key and emit domain artifacts.
311
+
312
+ ## 0. LANGUAGE GATE → translator (GATE L0, only if non-English)
313
+ ```
314
+ Invoke via Agent (model: exec): Skill(shapeup-sdlc-plugin:translator) --check "<intake path>"
315
+ # detect-only, writes nothing
316
+ English → skip; ORIENT against the original.
317
+ non-English → Agent (model: exec): Skill(shapeup-sdlc-plugin:translator) "<intake path>" [--auto]
318
+ # full pass
319
+ Writes: <name>.en.md (English copy; original untouched) + glossary.md
320
+ + translation-report.md.
321
+ ORIENT against the <name>.en.md copy.
322
+ Read back: the detect table (--check) / the .en.md path + residual scan result (full pass).
323
+ Authority: translator normalizes language only — it does not orient/plan/build/judge. The tech
324
+ lead never translates itself; it only detects and sequences this step before ORIENT.
325
+ ```
326
+
327
+ ## 1. ORIENT → orient (the Scout, step 7) — runs BEFORE planning
328
+ ```
329
+ Invoke via Agent (model: exec): Skill(shapeup-sdlc-plugin:orient)
330
+ --pitch "<kicked-off pitch path>" --spec <path> --stack "<hint>" [--auto]
331
+ Owns: its own GATE O-A/O-B (or runs straight through under --auto)
332
+ Writes: .shapeup/<slug>/orient/ → code-surface.md, spike-<area>.md, discovered-seed.md, hill-signal.md (LOCAL run-trace)
333
+ Read back: hill-signal.md (render the area-level Hill at GATE L1a) + the spiked area/result.
334
+ Why first: at Orient time NO board exists; the Scout's map + discovered seed make the planner's
335
+ board reality-born instead of imagined. The four artifacts are the orient→ba contract.
336
+ Authority: pure worker — no code, no board, no run-state, no reporting.
337
+ ```
338
+
339
+ ## 2. MAP SCOPES → ba-pitch-analyzer + scope-architect (step 8, orient-informed)
340
+ ```
341
+ Order A (the spec tree + board):
342
+ compile-order --operation analyze --slug <slug> --worker ba-pitch-analyzer
343
+ --payload '{"pitch": "<path>", "lens": "<lens>", "orient_dir": ".shapeup/<slug>/orient/"}'
344
+ Agent (model: exec): Skill(shapeup-sdlc-plugin:ba-pitch-analyzer) --order <path>
345
+ The order hands it code-surface.md (Phase-1 ingest, no re-scan), discovered-seed.md (task
346
+ gen from reality), spike-<area>.md (feasibility/contracts).
347
+ Writes (its substrate): spec_folder → _index.md, domain-model.md, ux-behavior.md, usecases/*,
348
+ contracts/*.contract.md, scope-summary.md (+ api-feasibility.md if third-party) and the
349
+ Returns: WorkResult (artifacts list + discoveries) → ingest-result.
350
+ Order B (the scope contracts):
351
+ compile-order --operation map-scopes --slug <slug> --worker scope-architect
352
+ Agent (model: exec): Skill(shapeup-sdlc-plugin:scope-architect) --order <path>
353
+ Writes (its substrate): shapeup/<slug>/scopes/*.md + scope-board.md — sole
354
+ writer. Lint mechanically: node "${CLAUDE_PLUGIN_ROOT}/kernel/harness.mjs" verify spec <slug> (PA1/PA2 +
355
+ substrate disjointness + the spec anchor: SCOPE-ANCHOR/TIER-DIRECTION/SCOPE-DEPS) before GATE L1b.
356
+ Read back: .shapeup/<slug>/tasks/_index.md (the board) + scope-summary.md (Done-when)
357
+ + the spec-lint verdict.
358
+ Pass-through rule: do not coach the planner to over-specify implementation — keep tech high-level.
359
+ ```
360
+
361
+ ## 2b. RECONCILE → ba-pitch-analyzer (discovered task reconciliation, operation: reconcile)
362
+ ```
363
+ compile-order --operation reconcile --slug <slug> --worker ba-pitch-analyzer
364
+ --payload '{"discovered_ledger": ".shapeup/<slug>/discovery/ledger.md"}'
365
+ Agent (model: exec): Skill(shapeup-sdlc-plugin:ba-pitch-analyzer) --order <path>
366
+ Effect: reconciles raw ledger discoveries into board tasks + appended UC invariants/TS rows,
367
+ inside the reconcile write-contract (frozen zone enforced by the sandbox hook, not
368
+ prose). Appetite Guard runs mechanically: node "${CLAUDE_PLUGIN_ROOT}/kernel/harness.mjs" reduce board.
369
+ Returns: WorkResult → ingest-result (which updates the board and bumps discovered_rounds in
370
+ harness-run.md — the worker holds no counter).
371
+ Read back: updated tasks/_index.md + scope-summary.md before routing back to GATE L1b.
372
+ ```
373
+
374
+ Agent (model: exec): Skill(shapeup-sdlc-plugin:ba-pitch-analyzer) --order <path>
375
+ Effect: regenerates the LOCAL task board fresh from the committed usecases/domain-model/scopes
376
+ — no ledger, no reconciliation. Status bootstraps from committed T0/hill facts at
377
+ SCOPE granularity; unlocks recomputed by node "${CLAUDE_PLUGIN_ROOT}/kernel/harness.mjs" reduce board --write.
378
+ Read back: the freshly regenerated tasks/_index.md before entering BUILD.
379
+ ```
380
+
381
+ ## 3. BUILD → task-executor (always through the envelope port)
382
+ ```
383
+ r=1 loop:
384
+ compile-order --next --slug <slug> [--test-cmd "<cmd>"] # exit 2 = no ready task
385
+ Agent (model: exec), one fresh subagent per order:
386
+ Skill(shapeup-sdlc-plugin:task-executor) --order <path>
387
+ ingest-result <results/<id>.json> # ticks ACs, marks done, updates board, propagates unblocks
388
+ Repeat until compile-order --next reports no ready task (board all ✅).
389
+
390
+ r>1 (fix) per bug:
391
+ compile-order --task <id> --slug <slug> --operation fix --payload '{"bugs": [<entries>]}'
392
+ → dispatch + ingest as above. Scope the change to the bug only.
393
+
394
+ Scope contracts present (isolated attempt loop, per scope, per attempt):
395
+ compile-order --scope shapeup/<slug>/scopes/<id>.md --round <N> --attempt <M>
396
+ → orders/r<N>-a<M>.json inlines the scope contract, this scope's tasks, promoted ledger
397
+ decisions, the previous attempt's AEGIS triples, and `trial_history` — the last 8 trials
398
+ for this scope (score, status, delta, top-3 digest), CROSSING the round boundary so a fix
399
+ round cannot re-propose a change the build round already reverted. The zero-memory
400
+ handoff, compiled from facts only. Dispatch a fresh Agent per attempt (the isolation
401
+ boundary):
402
+ Skill(shapeup-sdlc-plugin:task-executor) --order <path>
403
+ ingest-result — a WorkResult with status "escalated" leaves its artifact unwritten → see 3b below.
404
+
405
+ Read back: ingest-result's summary line (tasks updated, ACs ticked, unblocked, discoveries) — not raw board
406
+ files. SPIKE tasks close before the tasks they block can build (compile-order enforces the
407
+ dependency order).
408
+ ```
409
+
410
+ ## 3b. A worker that cannot finish (scope contracts present, mid-attempt)
411
+ ```
412
+ There is NO adjudication dispatch. A worker has no port for "I cannot decide this": WorkResult
413
+ carries no escalates field, so the question never reaches you as data.
414
+ What you see: the phase produces no artifact. The workflow's post-condition
415
+ (harness probe resume --require <phase>) fails and the run ABORTS, naming the phase.
416
+ Do: read the phase's result file to find what it could not complete, resolve it yourself —
417
+ by amending the spec, widening the scope contract, or answering the ambiguity in the
418
+ round-ledger "Decisions" table — then relaunch. The fast-forward re-dispatches only
419
+ what is still unfinished.
420
+ Why it aborts rather than pauses: nothing persists an answer between launches, so a pause
421
+ would relaunch into the same order and hit the same wall. Aborting puts the question
422
+ in front of a human once instead of looping silently.
423
+ ```
424
+
425
+ ## 3c. T0 verify → `harness verify t0` (skill-local; scope contracts present, every attempt)
426
+ ```
427
+ Invoke via Bash directly — NOT an Agent, this is deterministic tooling, not a worker:
428
+ node "${CLAUDE_PLUGIN_ROOT}/kernel/harness.mjs" verify t0 shapeup/<slug>/scopes/<scope-id>.md
429
+ --round <N> --attempt <M> --seesaw-registry .shapeup/<slug>/seesaw/registry.json
430
+ Effect: runs the scope's e2e fixtures + DB probe, then (on green) the seesaw regression check
431
+ over every FINISHED scope's fixtures. Writes the verdict artifact spec-evaluator's
432
+ T0-citation rule will require a citation to, appends one row to t0/trials.jsonl, and — this
433
+ is the ratchet — scores the attempt against the last kept trial and snapshots or
434
+ restores the working tree ITSELF. Zero LLM tokens — deterministic tooling, not a
435
+ judge (this is what keeps "T1 once per round" true even though verification runs
436
+ every attempt).
437
+ Read back: the stdout JSON — {path, sha256, trial, overall, regression, score, status,
438
+ baseline_trial, delta, tree_ref}. `status` (kept|reverted|rebased|crash) is what
439
+ drives the attempt-loop branch in protocol.md "Isolated attempt loop"; by the
440
+ time you read it the tree action has already happened. Never branch on the process
441
+ exit code: it carries the T0 binary (0 green / 1 red / 2 bad argv, the oracles/*
442
+ convention), so a `kept` red-but-improved attempt, the ratchet's own signature case,
443
+ exits 1. On red, its `discovered_tasks` field is
444
+ the AEGIS digest to fold into the next brief — no separate digester dispatch needed
445
+ (harness verify t0 calls its sibling harness probe digest internally on failure).
446
+ ```
447
+
448
+ ## 4. EVAL → spec-evaluator (once per round)
449
+ ```
450
+ compile-order --operation evaluate --slug <slug> --worker spec-evaluator --round <r>
451
+ --payload '{"dimensions": ["spec-conformance"], "run_cmd": "<cmd>", "t0_artifacts": [...]}'
452
+ Invoke via Agent (model: eval), ONCE, after GATE L2:
453
+ Skill(shapeup-sdlc-plugin:spec-evaluator) --order <path>
454
+ Effect: one feature-level pass over the running app against all AC + Done-when; writes
455
+ evaluation/EVAL-FEATURE-<slug>.md (verdict + bug list) + its WorkResult (criteria
456
+ verdicts, refuted boxes, T0 citations). It touches NO task file and NO board.
457
+ ingest-result <results/evaluate-r<r>.json>: appends the .verdicts JSONL ledger, un-ticks the
458
+ refuted AC boxes, sets eval_verdict frontmatter — the judge returns data, ingest writes.
459
+ Read back: EVAL-FEATURE-<slug>.md → verdict (pass|fail) + the bug list (each bug has
460
+ task ref, severity, file:line, expected vs actual).
461
+ ```
462
+
463
+ > Dependency note: this uses spec-evaluator's **feature-level** pass (`--feature <slug>`),
464
+ > which evaluates the whole board in one session rather than one task at a time. If your
465
+ > installed spec-evaluator is the per-task v0.1, add the `--feature` mode (a small v0.2
466
+ > patch: iterate the board's AC/Done-when in one probe+grade session, emit one
467
+ > EVAL-FEATURE report) before wiring the tech lead to it. The per-task invocation still
468
+ > works for ad-hoc checks, but the round loop expects one feature pass.
469
+
470
+ ## 5. SHIP / GATE H → scope-hammer
471
+ ```
472
+ Invoke via Agent (model: exec): Skill(shapeup-sdlc-plugin:scope-hammer)
473
+ --slug <slug> [--baseline <path>] [--breaker outer|inner --scope <id>]
474
+ Effect: GATE H0 census (scopes + QA findings + discovered ledger + advisor-overflow flags) →
475
+ H1 baseline comparison (never vs. a perfect ideal) → H2 cut list + verdict.
476
+ Read back: the proposed cut list + verdict (SHIP now | SHIP after fixing ship-blocking items |
477
+ CANNOT SHIP). The tech lead records the PO's decision in round-ledger.md and performs
478
+ the actual close (SHIP S.1 onward) — scope-hammer proposes, it never ships.
479
+ ```
480
+
481
+ ## Authority boundaries (do not cross)
482
+ - The Scout orients; it never plans, builds, or judges — it hands raw material to the planner.
483
+ - The planner decides scope; the tech lead confirms it with the PO at GATE L1b.
484
+ - The generator reports task outcomes in its WorkResult; `harness reduce ingest` flips `status:
485
+ done` from that report. The tech lead confirms the feature-level close at GATE L4.
486
+ - The evaluator issues verdicts only; it never closes tasks. Judge ≠ doer.
487
+ - The tech lead decides *when* and *whether* each skill runs and how rounds proceed, owns
488
+ run-state + the Hill report — it does not decide *what* a task contains or *whether* a
489
+ single AC passes.
490
+
491
+ ## Handoff files (the shared state)
492
+ | File | Written by | Read by |
493
+ |------|-----------|---------|
494
+ | `<name>.en.md` + `glossary.md` | translator (L0, if non-English) | tech lead (ORIENT input), Scout, planner |
495
+ | `orient/code-surface.md` | Scout (step 7) | planner Phase 1 (ingest, no re-scan) |
496
+ | `orient/spike-<area>.md` | Scout (step 7) | planner Phase 1b/contracts; tech lead (L1a) |
497
+ | `orient/discovered-seed.md` | Scout (step 7) | planner Phase 6 (task gen) |
498
+ | `orient/hill-signal.md` | Scout (step 7) | tech lead (renders L1a Hill) |
499
+ | `orders/<id>.json` (WorkOrder) | **harness compile (mechanical)** | every worker (its ONLY pipeline input), validate-envelope hook |
500
+ | `results/<id>.json` (WorkResult) | the dispatched worker (its ONLY pipeline output) | harness reduce ingest (the single writer of everything below it) |
501
+ | `.shapeup/<slug>/tasks/*` (LOCAL board, v3.2) | **harness reduce ingest** (status, AC ticks, unblocks) + planner orders (task bodies) | tech lead (board status), compile-order (next task, ACs) |
502
+ | `discovery/ledger.md` | **harness reduce ingest** (from workers' `discoveries[]`) | reconcile orders (ba), scope-hammer (H0 census) |
503
+ | `scope-summary.md` | planner (analyze/reconcile orders) | tech lead (Done-when), evaluator (Done-when criteria) |
504
+ | `evaluation/EVAL-FEATURE-<slug>.md` + `.verdicts-*.jsonl` | evaluator (report) / **harness reduce ingest** (verdict ledger, un-ticks) | tech lead (verdict), next fix order (bug list) |
505
+ | `harness-run.md` | **tech lead (sole writer)** | tech lead (round ledger + Hill + run-state), PO (audit) |
506
+ | `scopes/<scope-id>.md` | `scope-architect` (sole writer) | tech lead (substrate/sequence), sandbox hook (write-whitelist), compile-order (inlined into orders) |
507
+ | `t0/verdicts/r<N>-a<M>-t<T>.json` | `harness verify t0` (skill-local, mechanical — not a worker) | spec-evaluator (required citation), tech lead (hill derivation), compile-order (digested errors) |
508
+ | `t0/trials.jsonl` (the ratchet ledger, append-only, `baseline_trial` as the parent link) | `harness verify t0` (one row per attempt: score, status, delta, tree_ref) | compile-order (`trial_history` into the next order), ship-report (T0 + Ratchet sections), `harness probe stats --ratchet` |
509
+ | `round-ledger.md` | **tech lead (sole writer)** | compile-order (decisions into every order), PO (audit) |
510
+ | `hill/<scope-id>.yml` + `hill-chart.md` | **tech lead (sole writer)** | PO ("status without asking"), scope-hammer (H0 census) |
511
+
512
+ > The single-writer rule is closed mechanically: no worker writes `run-state.md`, the board, or the ledger. A worker
513
+ > performing a shared-state write is a defect — route it back through its WorkResult.
514
+
515
+ ---
516
+
517
+ # Part 3 — The invariants
518
+
519
+ Moved out of `SKILL.md` when the round loop became a launchable script:
520
+ most of what this table used to guard against — a partial board reaching EVAL, a gate crossed
521
+ on the model's own authority, an evaluator called mid-BUILD — is now a property of
522
+ `skills/tech-lead/workflows/shapeup-run.js`'s code, not a rule a model has to remember to obey.
523
+ The table stays as the readable rationale for WHY the code is shaped the way it is; the runtime
524
+ guarantee lives in the script and, where noted, in a hook.
525
+
526
+ | Rule | Rationale |
527
+ |------|-----------|
528
+ | Orchestrates Building only (steps 7–11); shaping/betting/kick-off are PO-personal, upstream | Intake is a kicked-off pitch, not a raw idea — the tech lead does no shaping/planning-authority work |
529
+ | ORIENT (step 7) runs before MAP SCOPES (step 8) | Roadmap: no pre-divided tasks at kick-off; the team orients first so the board is reality-born |
530
+ | Intake must be English before ORIENT; tech lead does NOT translate — it delegates to `translator` at GATE L0 | Translation is a separate single-purpose skill; the intake conversation only detects + sequences it, before RunArgs is ever compiled |
531
+ | Every worker dispatch goes through the envelope port: compile-order → `--order` → ingest-result; shared state is written ONLY by ingest | The single-writer rule is mechanically true: a worker that writes boards/ledgers/run-state is a defect, and a malformed envelope is denied by the validate-envelope hook before it can corrupt run truth. `shapeup-run.js` uses this same shape for every operation in the central registry — orient, wire, analyze, map-scopes, evaluate, hunt, hammer alike |
532
+ | Progress is reported by Hill position, never by counting tasks | The roadmap forbids task-counting; a 90%-done slice can still be stuck uphill on the one unknown that matters |
533
+ | Evaluator runs once per round, only after GATE L2 (board 100% done) | The whole point: cheap end-of-round QA, never per task. `shapeup-run.js`'s round loop dispatches spec-evaluator exactly once per iteration, after the GATE L2 resolution — there is no code path that calls it from inside the scope attempt loop |
534
+ | Evaluator never called inside the BUILD loop | Keeps the build coherent and the run cheap |
535
+ | r>1 builds bugs only, never the whole board | Don't re-do passing work; minimize churn — see protocol.md's regression rule for what DOES re-run (touched UCs' full Test Surface) |
536
+ | Stop at max_rounds; escalate honestly | No infinite fix loops; `shapeup-run.js` returns `{status: "gate_h", breaker: "outer"}` rather than looping past the budget |
537
+ | Tech lead delegates, never reimplements a sub-skill | Stays thin; each skill keeps its own gates and authority |
538
+ | Every delegation to a sub-skill (except the mechanical `harness verify t0`/`harness compile`/`harness reduce ingest`) is a fresh Agent on the L0.8-resolved model | Isolation the zero-memory-handoff design assumes; a direct inline call would silently drop the model matrix — see references/protocol.md "Invocation mechanism" |
539
+ | Planner stays high-level on tech | Spec errors cascade into every build round |
540
+ | Never auto-deploy; "shipped" never silently means "deployed" | Deploy is outward-facing, PO-gated; record "deploy pending (PO)" otherwise |
541
+ | "Shipped" names the dims NOT evaluated | `RunReturn`'s `dims_not_evaluated` field carries this; the L4 sign-off block shows it, never silently drops it |
542
+ | Every gate emits the canonical `⏸ GATE LN — Title` block before any narrative | Composed by the workflow (`gateBlock()`), emitted VERBATIM by the skill — conversational re-summary is not a gate |
543
+ | In interactive/--auto: a `paused` return stops and waits for PO confirmation | Never auto-proceed past a gate; the PO must cross each threshold explicitly — see "The pause protocol" in SKILL.md |
544
+ | At GATE L3 FAIL: name scope (task + failed criterion), never prescribe fix options | Root cause analysis and fix paths belong to the implementer, not the orchestrator |
545
+ | SHIP harvest records facts only — copies existing structured output, never computes a new verdict/score | A self-computed score = a second judge behind spec-evaluator (breaks single-judge, invites Goodhart); the eval suite interprets, harvest records |
546
+ | Three-level circuit breaker: attempt_budget (inner, per scope) nests inside round_budget (outer), with an opt-in wall_clock_budget_s deadline | An exhausted scope queues a GATE H hammer proposal, it never blocks the round; only round_budget hitting 0 stops the whole run; the deadline breaker (checked every round boundary in `shapeup-run.js`) routes to GATE H so a run out of clock still ships what is green instead of being killed from outside |
547
+ | The tech lead never hand-edits a scope contract | scope-architect is its sole writer (single-writer-per-file) |
548
+ | Substrate-disjointness + PA1/PA2 lints are re-asserted at GATE L1b (harness verify spec) even when scope-architect already checked them | A human may have hand-approved past a 🔴 at the architect's checkpoint; `shapeup-run.js` runs spec-lint itself, in code, before resolving L1b |
549
+ | Hill phase is read from mechanical facts (T0/T1/seesaw), never declared by a worker | Closes the self-reported-confidence risk outright — facts move dots, not authors |
550
+ | GATE H is delegated to scope-hammer, never adjudicated inline by the tech lead | Keeps the orchestrator thin; census/baseline-comparison/cut-list logic has one owner |
551
+
552
+ ---
553
+
554
+ # Part 4 — State
555
+
556
+ Two halves of one question, folded into this file when the references consolidation retired the
557
+ standalone `state.md`: who owns which artifact (state ownership), and the shape of what the tech
558
+ lead itself writes — `harness-run.md`, the run's own ledger.
559
+
560
+ ## State ownership (D6, mechanically closed in v1.0)
561
+
562
+ Workers are stateless; the orchestrator layer is the **sole writer of ALL run-state**. Every
563
+ worker receives a structured **WorkOrder** envelope (`.shapeup/<slug>/orders/`, compiled by
564
+ `harness compile`) and returns a **WorkResult** envelope (`results/`); the deterministic
565
+ `harness reduce ingest` performs every shared-state write — board status, AC ticks, unblock
566
+ propagation, discovery-ledger appends, verdict bookkeeping.
567
+
568
+ No worker writes `run-state.md`, `tasks/_index.md`, or the ledger. Everything a worker used to
569
+ write into shared files, it now returns as data.
570
+
571
+ The tech lead owns `harness-run.md` — rounds, gate decisions, Hill positions, verdicts,
572
+ `discovered_rounds`, config, language record. The board (`tasks/_index.md`, LOCAL root — v3.2) is
573
+ **execution truth**, maintained exclusively through ingest.
574
+
575
+ **The run receipt (v1.4).** `harness init run` opens the run and writes
576
+ `.shapeup/<slug>/receipt.json` plus `.shapeup/active-scope` before any gate. The
577
+ receipt is the mechanical fact that a run *started* — distinct from every other artifact here,
578
+ which records what a run *did*. That distinction is load-bearing: the guards that check a run's
579
+ progress (the ship report's census) are all scoped to an active run, so before the receipt
580
+ existed, a run that never started was invisible to every one of them. `hooks/gate-zerowork.mjs`
581
+ reads only the receipt's presence, which is why it can see a total failure that leaves no other
582
+ trace. See `references/gates.md` — GATE L0.1.
583
+
584
+ ## Central domain registry
585
+
586
+ Every record type and payload field that crosses a skill boundary is defined exactly once in
587
+ `skills/tech-lead/schemas/domain.schema.json` — the envelope schemas (`work-order.schema.json`,
588
+ `work-result.schema.json`) only `$ref` it. The registry annotates each entity's tier
589
+ (SHARED/LOCAL), location, sole writer, and readers, carries the machine-readable ERD (`x-erd`),
590
+ and maps which payload fields each worker may rely on (`x-payload-by-worker`).
591
+
592
+ A new cross-boundary field is added THERE first (structural test #24 enforces the map's
593
+ consistency); a skill inventing its own undeclared field is a defect — the orchestrator, not the
594
+ worker, owns the vocabulary.
595
+
596
+ ## Two ledgers, split by promotion timing
597
+
598
+ (Addendum §F.3 — only when scope contracts exist.)
599
+
600
+ `harness-run.md` stays the LOCAL (`.shapeup/<slug>/`, gitignored) full run trace: it can be
601
+ rebuilt or lost without consequence.
602
+
603
+ A second, committed `round-ledger.md` (`shapeup/<slug>/round-ledger.md`, SHARED,
604
+ Tier A) holds only what must survive a crash or a `.shapeup/` wipe:
605
+
606
+ - the resolved model/budget matrix (L0.8/L0.9),
607
+ - the **Decisions** table — every gate crossing and every PO answer to a blocked phase,
608
+ promoted the instant it is given, never batched to round close.
609
+
610
+ Gate crossings resolved from a **gate answer set** (`harness gate`) are written here
611
+ with their source — `preset:ci`, `file:.shapeup/gate-answers.json` — and the set's
612
+ `authorized_by`. A headless run that ships must always be able to name the human behind its
613
+ sign-off; that name lives here and nowhere else.
614
+
615
+ The tech lead is the sole writer of both. `round-ledger.md` is simply the subset that must never
616
+ live only in a session or a gitignored file. No scope contracts → `round-ledger.md` is not
617
+ written, and `harness-run.md`'s "Decisions log" is the only ledger, exactly as in v0.2.6.
618
+
619
+ ## The ledger schema
620
+
621
+ The tech lead's run record. One per feature, lives in the LOCAL run-trace root
622
+ `.shapeup/<slug>/harness-run.md` (hidden, gitignorable — it is ephemeral run-state,
623
+ not a shared deliverable). It is the structured
624
+ artifact that carries state across rounds and across sessions (so `--from` can resume), and
625
+ the PO's audit of how the feature was built.
626
+
627
+ **The tech lead is the sole writer of this file.** It is the authoritative
628
+ run-state for the whole build phase — rounds, gate decisions, Hill positions, verdicts,
629
+ `discovered_rounds`, config, language record. Workers never write here; the tech lead passes
630
+ them what they need (`feature`, `spec`, `stack`, `discovered_rounds`) as args. The board
631
+ (`tasks/_index.md`) remains the planner/generator's execution truth that the tech lead reads.
632
+
633
+ ## Frontmatter
634
+ ```yaml
635
+ ---
636
+ type: harness-run
637
+ feature: [slug]
638
+ spec_folder: [path to SHARED spec deliverable, e.g. shapeup/<slug>/spec/]
639
+ lens: lite | standard | cross-context
640
+ eval_dimensions: [spec-conformance] # the set from GATE L0.5 (init-run --dimensions); every EVAL order is compiled from THIS line
641
+ max_rounds: 3
642
+ auto_level: interactive | auto | unattended
643
+ status: orienting | mapping | building | evaluating | shipped | escalated
644
+ final_verdict: ~ | pass | fail | not-evaluated
645
+ rounds_used: [N]
646
+ discovered_rounds: [N]
647
+ deploy: ~ | deployed | pending-po
648
+ started_at: [ISO]
649
+ closed_at: ~ | [ISO]
650
+ ---
651
+ ```
652
+
653
+ ## Round table (the spine)
654
+ Mirrors the long-running harness cost table — one row per phase, so you can see where time
655
+ and tokens go and that EVAL is cheap relative to BUILD.
656
+
657
+ ```
658
+ ## Rounds
659
+ | Phase | Round | Result | Duration | Notes |
660
+ |------------------|-------|-------------------|----------|-------|
661
+ | Orient | — | spiked VNPay seam | 18 min | spike resolved; 9 discovered tasks seeded |
662
+ | Map Scopes | — | 14 tasks, 5 layers| 5 min | orient-informed; 1 SPIKE (VNPay) |
663
+ | Build | 1 | 14/14 ✅ | 2 h 10 m | all tasks closed |
664
+ | Eval | 1 | FAIL — 3 bugs | 9 min | EVAL-FEATURE-checkout-vnpay.md |
665
+ | Build | 2 | 3 bugs fixed | 22 min | bug-only re-build |
666
+ | Eval | 2 | PASS | 8 min | verdict pass |
667
+ | Ship | — | built & verified | — | dims: spec-conformance; deploy pending (PO) |
668
+ ```
669
+
670
+ ## Hill report (the progress narrative — NOT task counts)
671
+ The roadmap forbids reporting progress by counting tasks: a 90%-done slice can still be stuck
672
+ uphill on the one unknown that matters. So the tech lead reports each slice's **position on
673
+ the hill**, derived mechanically from open unknowns. Render it at every round boundary
674
+ (area-level at GATE L1a — before slices exist; slice-level from GATE L1b onward).
675
+
676
+ ```
677
+ ## Hill — round 1
678
+ | Slice | Position | Derived from |
679
+ |--------------|-------------|--------------|
680
+ | S1-spine | 🔽 downhill | spike closed + spine render-AC passed (crest crossed); 2 known tasks left |
681
+ | S2-filters | 🔼 uphill | SPIKE-003 open: pagination approach unproven |
682
+ | S3-export | 🔼 uphill | contract ⏳ TBD: file-format field |
683
+ ```
684
+
685
+ Position triggers:
686
+ - 🔼 **Uphill** — open SPIKE / `⏳ TBD` contract / unresolved discovered task / approach unproven.
687
+ - ⛰️ **Crest** — all unknowns resolved AND a concrete board fact (the spine slice's render-AC passes).
688
+ - 🔽 **Downhill** — only known work remains, no open unknowns.
689
+ - ✅ **Done** — slice clickable-done.
690
+
691
+ Source: `orient/hill-signal.md` (area-level, at L1a) then the board + open SPIKE/contract state
692
+ (slice-level, L1b onward). If slice IDs aren't on the board yet, report at
693
+ task-group level and note the fallback here.
694
+
695
+ ## Decisions log
696
+ Every L-gate decision, for traceability.
697
+ ```
698
+ ## Decisions
699
+ - GATE L1a: Orient accepted; spiked VNPay seam (resolved); S2-filters flagged uphill.
700
+ - GATE L1b: PO accepted board; cut "guest checkout" task to phase 2.
701
+ - GATE L2 (r1): board green; ran eval (feature not trivial).
702
+ - GATE L3 (r1): FAIL → approved bug-only round 2.
703
+ - GATE L3 (r2): PASS → ship.
704
+ - GATE L4: built & verified; deploy pending (PO); closed.
705
+ ```
706
+
707
+ ## Bug carry-over (when FAIL)
708
+ Links the current round's bug list so the next BUILD round has its worklist.
709
+ ```
710
+ ## Open bugs (round 1 → fix in round 2)
711
+ → see evaluation/EVAL-FEATURE-checkout-vnpay.md
712
+ - BUG-1 critical SC-DONE-WHEN apps/web/checkout/Pay.tsx:84
713
+ - BUG-2 major SC-ERR apps/api/payments/handler.ts:51
714
+ - BUG-3 minor SC-NONGO apps/api/shared/auth.ts:12
715
+ ```
716
+
717
+ ## Escalation block (only if max_rounds hit without PASS)
718
+ ```
719
+ ## Escalation
720
+ Rounds used: 3/3 — still FAIL. Residual bugs: [N].
721
+ Recommendation: [cut scope of feature X | accept minor bugs | extend max_rounds with PO approval].
722
+ Decision owner: PO.
723
+ ```
724
+
725
+ ## Rules
726
+ - The ledger is append-mostly: each round adds rows, never rewrites history.
727
+ - `status` + `final_verdict` are the resume anchors for `--from`.
728
+ - A `not-evaluated` final verdict (from `--no-eval`) is recorded plainly — never silently
729
+ upgraded to `pass`.
730
+
731
+ ## `round-ledger.md` (committed, Tier A — scope contracts only)
732
+
733
+ Lives at `shapeup/<slug>/round-ledger.md` (SHARED root, tracked). Not a replacement
734
+ for `harness-run.md` — a small, committed **subset** of it: the two things that must survive
735
+ a `.shapeup/` wipe or a crash. Absent on specs with no scope
736
+ contracts; `harness-run.md`'s existing Decisions log stays the only ledger there.
737
+
738
+ ```yaml
739
+ ---
740
+ type: round-ledger
741
+ feature: [slug]
742
+ models: # L0.8 resolved matrix, recorded once, source noted
743
+ orch: [model] (source: flags|settings.local|settings.json|default)
744
+ exec: [model] (source: ...)
745
+ eval: [model] (source: ...)
746
+ qa: [model] (source: ...)
747
+ digester: script | sonnet
748
+ budgets:
749
+ round_budget: [N] # outer breaker
750
+ attempt_budget: [N] # inner breaker, per scope
751
+ ---
752
+ ```
753
+
754
+ ```
755
+ ## Decisions
756
+ | Round | Scope | Kind | Question | Answer | Resolved by |
757
+ |-------|-------|------|----------|--------|-------------|
758
+ | 2 | cart-creation | design-decision | cart-total rounding | round half-up | PO (interactive) |
759
+ | 2 | cart-creation | substrate-expansion | needs packages/shared/http.ts | approved → shared_substrate | PO (interactive) |
760
+ ```
761
+ **Promotion timing:** a row is appended the INSTANT the PO answers —
762
+ never batched to round close. This is the file `task-executor`'s isolated briefs read back
763
+ (the zero-memory handoff): an answer given once in round 2 must still be known in round 5's
764
+ fresh-context attempt without replaying any chat history.
765
+
766
+ ## Harvest row — `metrics/<machine-id>.jsonl` (written at SHIP)
767
+
768
+ `harness-run.md` is ephemeral run-state — needed live for `--from` resume, the
769
+ FAIL-loop, and QA reconcile; worthless after ship. At SHIP the tech-lead **harvests**
770
+ the durable-mineable *signals* out of it into one append-only row:
771
+
772
+ ```
773
+ .shapeup/metrics/<machine-id>.jsonl # one row = one e2e run; LOCAL (gitignored)
774
+ ```
775
+
776
+ Path note: `metrics/` lives under the LOCAL root with the rest of the run trace — moved
777
+ there by ADR-0001, because a committed shard keyed on `$HOSTNAME` only grows and puts a
778
+ person's machine name in the repo. It outlives any single run (the per-slug run dirs are
779
+ superseded run by run; the shard only appends), which is what makes it the durable signal
780
+ feed. Sharded per machine so shards can be pooled deliberately without colliding on one
781
+ filename; the read plane is `harness probe stats`, or `cat .shapeup/metrics/*.jsonl`.
782
+ `schema_version` makes an old row readable by later skill versions.
783
+
784
+ ### Two hard rules (same discipline as the Test Surface: *derived, never invented*)
785
+ 1. **Harvest only fields that already exist as structured output at ship time.** If a
786
+ field forces the tech-lead to *evaluate something new* → reject (judgment in disguise).
787
+ 2. **Harvest records facts, never computes a new verdict.** A self-computed
788
+ `run_quality_score` would be a second judge behind `spec-evaluator` → breaks the
789
+ single-judge rule and invites Goodhart. The eval suite *interprets* downstream;
790
+ harvest *records*.
791
+
792
+ Scope: the harvest feeds **only the e2e pipeline measurement**. The per-skill functional
793
+ fixtures run in isolation and do not consume it.
794
+
795
+ ### Row schema (one JSON object per line)
796
+ | Field | Existing source (copied, never re-graded) | Signal |
797
+ |---|---|---|
798
+ | `schema_version` | constant `1` | forward-compat |
799
+ | `run_id` | `receipt.json` (copied verbatim) | **the join key** — the row's only link to the run trace that produced it, and to the S.7 export. Every other field here is a count, and `feature_slug` groups two runs of one feature together rather than apart |
800
+ | `feature_slug` | run-state frontmatter | identity |
801
+ | `terminal_state` | run-state final: `shipped` / `circuit_broken` / `abandoned` | circuit-breaker outcome |
802
+ | `round_count` | round table | effort-to-PASS |
803
+ | `final_audit_score` | final EVAL report (copied, not re-graded) | conformance |
804
+ | `surprise_count` | `.shapeup/<slug>/discovery/ledger.md` | shaping quality — scope drift |
805
+ | `spike_unresolved_count` | `SPIKE-UNRESOLVED` markers at bet | shaping quality — open risk into bet |
806
+ | `scope_cut_count` | `~` items cut at SHIP S.0 | appetite pressure / scope hammer |
807
+ | `qa_findings` | `.shapeup/<slug>/qa/hunt-report.md` + triage → `{total, promoted, held}` | edge quality |
808
+ | `slice_count` | breadboard B5 (≤9) | **normalizer / denominator** |
809
+ | `sources` | path to each **SHARED** source artifact — never a LOCAL `.shapeup/` path (the run-trace is superseded run by run, so a LOCAL path dangles by the time anyone reads the row; SHARED paths resolve on any clone — tier-direction rule) | auditability |
810
+
811
+ - `slice_count` is the **denominator**: `round_count=4` on a 2-slice feature is alarming,
812
+ on a 9-slice feature is normal. Without it, e2e comparisons are apples-to-oranges.
813
+ Enables `round-per-slice`, `surprise-per-slice`.
814
+ - `spike_unresolved_count` + `surprise_count` measure two of the three downhill
815
+ conditions (open-risk-remaining, scope-drift-from-breadboard). A good shaping run
816
+ drives both toward 0 — measured from the build trace, no manual grading.
817
+ - **Rejected fields:** `time_spent` / velocity (no clock; Shape Up forbids counting hours
818
+ — `round_count` is the legitimate effort proxy) and `run_quality_score` (second judge).
819
+ This rejection is **unchanged** by the run-economics measurement (`harness probe stats
820
+ --economics`): cost and wall-clock are properties of a machine run, derived on demand
821
+ from the exported trace, and they deliberately do not enter this row. A signal feed that
822
+ carried a duration would become a velocity feed on the next person who read it.
823
+
824
+ ### Row template
825
+ ```json
826
+ {"schema_version":1,"run_id":"checkout-vnpay-20260813T091233Z-c714ea8d","feature_slug":"checkout-vnpay","terminal_state":"shipped","round_count":2,"final_audit_score":"PASS","surprise_count":3,"spike_unresolved_count":0,"scope_cut_count":1,"qa_findings":{"total":5,"promoted":1,"held":4},"slice_count":4,"sources":["shapeup/checkout-vnpay/shaping/shaping.md","shapeup/checkout-vnpay/shaping/breadboard.md"]}
827
+ ```
828
+
829
+ LOCAL artifacts (the EVAL report, discovery ledger, QA hunt report) are *harvest-time reads*:
830
+ their **values** are copied into the row's fields (`final_audit_score`, `surprise_count`,
831
+ `qa_findings`) but their paths are never recorded in `sources` — they are gitignored and
832
+ wiped, so a committed pointer to them is dead on arrival.