@hexagen-monaco/sync 0.12.1 → 0.13.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/README.md +429 -0
  2. package/dist/cli.js +6250 -401
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/arch/edit.d.ts.map +1 -1
  5. package/dist/commands/contract/evaluate.d.ts +45 -0
  6. package/dist/commands/contract/evaluate.d.ts.map +1 -0
  7. package/dist/commands/contract/index.d.ts +24 -0
  8. package/dist/commands/contract/index.d.ts.map +1 -0
  9. package/dist/commands/evidence/check.d.ts +31 -0
  10. package/dist/commands/evidence/check.d.ts.map +1 -0
  11. package/dist/commands/evidence/index.d.ts +3 -0
  12. package/dist/commands/evidence/index.d.ts.map +1 -0
  13. package/dist/commands/evidence/pack.d.ts +41 -0
  14. package/dist/commands/evidence/pack.d.ts.map +1 -0
  15. package/dist/commands/grant/build.d.ts +53 -0
  16. package/dist/commands/grant/build.d.ts.map +1 -0
  17. package/dist/commands/grant/canonical.d.ts +27 -0
  18. package/dist/commands/grant/canonical.d.ts.map +1 -0
  19. package/dist/commands/grant/check.d.ts +26 -0
  20. package/dist/commands/grant/check.d.ts.map +1 -0
  21. package/dist/commands/grant/duration.d.ts +8 -0
  22. package/dist/commands/grant/duration.d.ts.map +1 -0
  23. package/dist/commands/grant/index.d.ts +2 -0
  24. package/dist/commands/grant/index.d.ts.map +1 -0
  25. package/dist/commands/grant/issue.d.ts +23 -0
  26. package/dist/commands/grant/issue.d.ts.map +1 -0
  27. package/dist/commands/grant/key-init.d.ts +16 -0
  28. package/dist/commands/grant/key-init.d.ts.map +1 -0
  29. package/dist/commands/grant/revoke.d.ts +35 -0
  30. package/dist/commands/grant/revoke.d.ts.map +1 -0
  31. package/dist/commands/grant/show.d.ts +18 -0
  32. package/dist/commands/grant/show.d.ts.map +1 -0
  33. package/dist/commands/grant/sign.d.ts +3 -0
  34. package/dist/commands/grant/sign.d.ts.map +1 -0
  35. package/dist/commands/grant/signing-key.d.ts +22 -0
  36. package/dist/commands/grant/signing-key.d.ts.map +1 -0
  37. package/dist/commands/grant/verify.d.ts +45 -0
  38. package/dist/commands/grant/verify.d.ts.map +1 -0
  39. package/dist/commands/grant/workspace.d.ts +11 -0
  40. package/dist/commands/grant/workspace.d.ts.map +1 -0
  41. package/dist/commands/observe/imports/jsonc.d.ts +6 -0
  42. package/dist/commands/observe/imports/jsonc.d.ts.map +1 -0
  43. package/dist/commands/observe/imports/pass.d.ts +45 -0
  44. package/dist/commands/observe/imports/pass.d.ts.map +1 -0
  45. package/dist/commands/observe/imports/resolve.d.ts +44 -0
  46. package/dist/commands/observe/imports/resolve.d.ts.map +1 -0
  47. package/dist/commands/observe/imports/safe-read.d.ts +30 -0
  48. package/dist/commands/observe/imports/safe-read.d.ts.map +1 -0
  49. package/dist/commands/observe/imports/scan.d.ts +59 -0
  50. package/dist/commands/observe/imports/scan.d.ts.map +1 -0
  51. package/dist/commands/observe/index.d.ts +59 -0
  52. package/dist/commands/observe/index.d.ts.map +1 -0
  53. package/dist/commands/observe/same-path.d.ts +9 -0
  54. package/dist/commands/observe/same-path.d.ts.map +1 -0
  55. package/dist/commands/observe/walk.d.ts +29 -0
  56. package/dist/commands/observe/walk.d.ts.map +1 -0
  57. package/dist/commands/shared/brownfield-sidecar.d.ts +68 -0
  58. package/dist/commands/shared/brownfield-sidecar.d.ts.map +1 -0
  59. package/dist/commands/shared/git-exclude.d.ts +36 -0
  60. package/dist/commands/shared/git-exclude.d.ts.map +1 -0
  61. package/dist/commands/shared/glob.d.ts +29 -0
  62. package/dist/commands/shared/glob.d.ts.map +1 -0
  63. package/dist/commands/shared/ignore.d.ts +32 -0
  64. package/dist/commands/shared/ignore.d.ts.map +1 -0
  65. package/dist/commands/shared/sidecar-out.d.ts +6 -0
  66. package/dist/commands/shared/sidecar-out.d.ts.map +1 -0
  67. package/dist/commands/shared/sidecar-write.d.ts +2 -0
  68. package/dist/commands/shared/sidecar-write.d.ts.map +1 -0
  69. package/dist/commands/slice/index.d.ts +23 -0
  70. package/dist/commands/slice/index.d.ts.map +1 -0
  71. package/dist/commands/workbook/allow-list.d.ts +27 -0
  72. package/dist/commands/workbook/allow-list.d.ts.map +1 -0
  73. package/dist/commands/workbook/export.d.ts +41 -0
  74. package/dist/commands/workbook/export.d.ts.map +1 -0
  75. package/dist/commands/workbook/index.d.ts +3 -0
  76. package/dist/commands/workbook/index.d.ts.map +1 -0
  77. package/dist/commands/workbook/zip-read.d.ts +7 -0
  78. package/dist/commands/workbook/zip-read.d.ts.map +1 -0
  79. package/dist/fs-utils.d.ts.map +1 -1
  80. package/dist/generators/root-file-templates.d.ts +5 -4
  81. package/dist/generators/root-file-templates.d.ts.map +1 -1
  82. package/dist/generators/root-files.d.ts.map +1 -1
  83. package/dist/index.js +351 -36
  84. package/dist/index.js.map +1 -1
  85. package/dist/templates/agents-md/findings/0001-session-log-grows-unbounded.md +35 -0
  86. package/dist/templates/ci-github-actions/findings/0001-ci-runners-have-no-zsh.md +34 -0
  87. package/dist/templates/orchestration/README.md +88 -0
  88. package/dist/templates/orchestration/files/.agents/skills/orchestrate-wave/SKILL.md +511 -0
  89. package/dist/templates/orchestration/files/.agents/skills/orchestrate-wave/references/briefs.md +178 -0
  90. package/dist/templates/orchestration/files/.agents/skills/orchestrate-wave/references/rationale.md +520 -0
  91. package/dist/templates/orchestration/files/.agents/skills/orchestrate-wave/scripts/wave-event.sh +17 -0
  92. package/dist/templates/orchestration/files/.github/workflows/gate.yml +66 -0
  93. package/dist/templates/orchestration/findings/0001-relative-runbook-links-escape-the-skill.md +48 -0
  94. package/dist/templates/orchestration/findings/0002-interpolation-hazard-in-graphql-line.md +46 -0
  95. package/dist/templates/orchestration/manifest.json +41 -0
  96. package/dist/types/manifest/monorepo.d.ts +4 -0
  97. package/dist/types/manifest/monorepo.d.ts.map +1 -1
  98. package/package.json +1 -1
@@ -0,0 +1,520 @@
1
+ # Orchestrate-wave — rationale
2
+
3
+ Evidence and detailed mechanism for the rules in `../SKILL.md`. Headings mirror SKILL.md's
4
+ sections; each subheading names the rule it backs.
5
+
6
+ ## Opening
7
+
8
+ ### Cast authority and the retired launcher
9
+
10
+ - **The current seats are in the overlay's `cast.md`, and it is the authority** — this file
11
+ does not restate them, because a restatement drifts: it named one model as the implementer long
12
+ after the roster moved to another primary with the first as the reserve. Whatever the seat,
13
+ **record the worktree tip first** and watch the provider's quota. Reviewers stay in-house: a second
14
+ `Agent` that is **not** the implementer. There is **no lane launcher**: a detached-launch script
15
+ was deleted because its launch killed the lanes it started (the mechanism is in the Implement
16
+ stage, below). Launch every lane yourself and emit its event in the call immediately before — the
17
+ wave-event bin is the emitter.
18
+
19
+ ## Naming waves and lanes
20
+
21
+ ### The identifier grammar and why both halves are used
22
+
23
+ The wave-event bin accepts `[A-Za-z0-9_-]+` for both, so an identifier can carry the plan's
24
+ id **and** say what the lane does. Use both — the id is what a PR, a record and the plan agree on;
25
+ the name is what a human reads on the status page at a glance.
26
+
27
+ ```text
28
+ wave: <plan-slug>-w<NN> <plan-slug>-w03
29
+ lane: <plan-id>-<what-it-does> <plan-id>-parse-input <plan-id>-report-export
30
+ ```
31
+
32
+ ### Never a bare id, or a wave with no plan slug
33
+
34
+ **Not** a bare id with no prefix, and not a wave with no plan slug. A reader six weeks out has
35
+ no idea what a bare number was, and the id alone makes the status page a lookup table against a
36
+ planning document. Keep the id first so sorting still groups a plan's lanes in order.
37
+
38
+ ## Two preconditions that cost the most when skipped
39
+
40
+ ### Run mutations through the mutation bin, not by hand
41
+
42
+ **Run mutations through `hexagen-orchestration-mutate`, not by hand.** The tool takes the
43
+ before- and after-text from **files**, so no shell quoting can alter them; matches **literal text
44
+ with no regex**; refuses unless the text occurs exactly once; refuses a no-op; confirms the file
45
+ holds the **intended** mutation before running anything; restores unconditionally, loudly if the
46
+ restore itself fails; and reports the command's **exit code first**, with the verdict in words:
47
+
48
+ ### Two exit codes are in play; do not confuse them
49
+
50
+ **Two exit codes are in play; do not confuse them.** The **test command's** code is what
51
+ decides the verdict — non-zero means the mutation was caught, zero means it survived — and the tool
52
+ prints it as the report's first line. **The tool's own** code is the verdict already reduced for a
53
+ caller to gate on: **`0` caught, `1` survived, `2` refused**, and a refusal names the rule that
54
+ refused. So a caught mutation shows `exit code: 1` in the report while the mutation bin itself exits
55
+ `0`. That is deliberate: the harness exits zero when it did its job.
56
+
57
+ ### The --because flag and equivalent mutants
58
+
59
+ `--because` is required on purpose: stating the prediction **before** seeing the result is the only
60
+ guard against an equivalent mutant, and two of this repository's were exactly that. Each rule the
61
+ tool enforces exists because the same mistake was made by hand — a pattern that missed an `&&` at a
62
+ line end, a character class terminated by a semicolon inside a string, and a green-looking test list
63
+ read as a survival when the run had exited `1`.
64
+
65
+ ### A mutation is read from the file, never written from memory
66
+
67
+ **A mutation is read from the file, never written from memory.** Copy the literal text you intend
68
+ to change, apply it, then **confirm the edit landed** — `git diff` non-empty *and* the intended line
69
+ actually different — before you run anything. Five mutations misfired in one session and **four of
70
+ them looked like passes**: a regex that missed an `&&` sitting at a line end; a `[^;]*` class
71
+ terminated by a semicolon inside a string literal; a target that turned out to be a static HTML
72
+ placeholder rather than the runtime fallback; a test file that did not contain the tests being
73
+ claimed; and two mutants that were genuinely equivalent. A mutation that fails to apply, or that
74
+ changes nothing observable, **is not evidence** — redo it, or record it as equivalent and say why.
75
+
76
+ ### Then read the right signal
77
+
78
+ **Then read the right signal.** A mutation can be caught by the *run* rather than by a named test:
79
+ removing a stream's `error` handler left every test in the file passing and the run exited `1` on an
80
+ unhandled `EISDIR`. Grepping the output for failing test names read that as surviving. **Take the
81
+ command's exit code**, and treat a green-looking test list with a non-zero exit as caught.
82
+
83
+ ### A fix round is verified to have landed before its PR merges
84
+
85
+ **A wrapper that reports commits per lane** against the tip it recorded before dispatch, and
86
+ distinguishes *no commits* from *could not tell*, is the mechanical form of the rule below. Read
87
+ that line when a wrapper reports it, and derive it yourself when nothing does.
88
+
89
+ **A fix round is verified to have landed before its PR merges.** Check for the commit, not the exit
90
+ code — and **record the tip before you dispatch**, because `origin/main..HEAD` also lists the
91
+ implementation commits and so stays non-empty for a round that did nothing:
92
+
93
+ ```bash
94
+ BEFORE=$(git -C "<worktree>" rev-parse HEAD) # BEFORE the fix round runs
95
+ # … dispatch the fix round, wait for its EXIT marker …
96
+ git -C "<worktree>" log --oneline "$BEFORE"..HEAD # empty ⇒ the round committed NOTHING
97
+ ```
98
+
99
+ The case that makes this concrete: a branch carried the earlier round's commit as well as the
100
+ fix, so `origin/main..HEAD` would have looked healthy even if the second round had written nothing
101
+ at all.
102
+
103
+ Four lanes once exited `0` having written nothing — two answered with a plan, two read
104
+ files and stopped. **A pull request was merged with four verified defects still in it** because
105
+ its fix round reported success and committed nothing. An exit code is not evidence of work, which is
106
+ the same rule this file already applies to lane reports.
107
+
108
+ ### Dispose of a class once, not a thread at a time
109
+
110
+ **Dispose of a class once, not a thread at a time.** When three or more threads share one premise,
111
+ write the mechanism once, link it from each thread, and resolve them together. Three threads on one
112
+ PR restated a single wrong claim and got three separate replies; the reader needed it once.
113
+
114
+ ## The rule everything else rests on
115
+
116
+ ### Run the commit count first, and do not skip it because the seat said SUCCESS
117
+
118
+ **Run the commit count first, and do not skip it because the seat said `SUCCESS`.** A seat's
119
+ own verdict is not evidence of work: on one day a lane reported `EXIT 0` *and*
120
+ `"status":"SUCCESS"` after six minutes, having made **zero commits** — it launched
121
+ the test suite as its first act and narrated waiting for it. The overlay's `cast.md` carries the
122
+ detail. Zero commits is a stuck lane no matter how the run describes itself.
123
+
124
+ ### yarn install --immutable
125
+
126
+ **`yarn install --immutable`.** The local gate never runs it, so a lane that adds a workspace
127
+ dependency passes every check locally and fails in CI on a stale lockfile — its green report is true
128
+ and useless. **Say in the brief whether a lane may add a dependency**, and if it may, that the
129
+ regenerated `yarn.lock` travels with it. The never-edit rule means *do not hand-edit* the lockfile,
130
+ not that a dependency can never be added; `.architecture/manifest.yaml` is where to check whether the
131
+ edge is already sanctioned before assuming it is not.
132
+
133
+ ### The byte-level scan
134
+
135
+ **The byte-level scan**, where a project's gate carries one, is its own step rather than part of
136
+ another, deliberately. It is cheap and runnable locally, so a lane should meet it before CI does.
137
+ The scaffolded config does not add it: the gate is a subset of CI, and only a `yarn <script>` step
138
+ can skip, so a scaffolded bin step marked optional would still be a required one wherever the bin is
139
+ not installed. Adding the step is the project's own decision. **Note it is NOT inside the typecheck step** — that chain type-checks the tool, it does not run
140
+ the scan; a typecheck on a tree containing a raw NUL exits 0, measured. Nothing else in a usual gate
141
+ set looks at bytes, and a raw `\x00` inside a string literal can survive build, typecheck, lint,
142
+ format check and a full test run with nothing noticing.
143
+
144
+ ### The other two: a conditional no-op and a route-registry guard
145
+
146
+ The other two: a conditional no-op step (a step whose script the project does not have, which
147
+ the gate reports as `SKIPPED` and counts, and which only a step the config marks optional may be) and
148
+ a **route-registry guard**, which runs the framework's own route preparation and fails if a test file
149
+ has been registered as an application route. Its own comment in the workflow says it catches "a
150
+ runtime fault the build and coverage gate don't catch". **A lane that adds or moves a test file into
151
+ a scanned directory must also run the framework's route preparation itself.**
152
+
153
+ ### A green local gate is not a green CI
154
+
155
+ A green local gate is not a green CI. Found by the hexagen-monaco orchestrator, which
156
+ hit the same class in its own repo: it ran the stated gate, passed, and reddened `main` on
157
+ `typecheck:test` — a step the stated gate never included. **Rule: when you write a gate into a
158
+ brief, diff it against the CI workflow first. Whatever CI runs and the gate does not, name in the
159
+ brief as what a green does not cover.**
160
+
161
+ ### Which gates are machinery, and which are you
162
+
163
+ **Which gates are machinery, and which are you.** Know the difference before trusting the green:
164
+
165
+ | Gate | Enforced by |
166
+ |---|---|
167
+ | the plan verifier | **CI.** A lane dispatched against a closed gap fails the build. |
168
+ | a lane retiring its own premise | **CI**, as a consequence of the above: a shipped lane that leaves its fence behind fails its own PR. |
169
+ | the mutation verifier on a **changed** manifest | **CI** (the manifest verifier). |
170
+ | **a manifest existing at all** | **you.** Nothing can require one without punishing the docs PR, the refactor and the premise audit that legitimately have none. It is a line in every lane brief, and it stops being applied the moment an orchestrator forgets to write it. |
171
+ | the handoff check | **you**, when you set up a two-stage lane. |
172
+
173
+ The two in the last rows are habits, not gates. Say so when you hand this over.
174
+
175
+ ### A two-stage lane hands over a handoff file, not a claim
176
+
177
+ **A two-stage lane hands over a handoff file, not a claim.** Stage 1 writes
178
+ `.agents/handoff/<lane>.json` binding every rule in its brief to the test that pins it, and the
179
+ handoff check refuses the handoff unless **every rule names a test that exists and is
180
+ currently failing**. A missing rule caps the implementation at stage 1's completeness and leaves no
181
+ trace in coverage; a test that already passes pins nothing, because stage 2 can satisfy it by
182
+ changing nothing. Both have happened: one stage-1 author wrote twelve tests for eight states, missed
183
+ three conditions from its own brief, and the lane shipped reporting a failing PR as `merged` at
184
+ 100 % coverage.
185
+
186
+ ### And every lane brief opens by asking the lane to prove the defect before changing anything
187
+
188
+ This exists because the orchestrator's briefs are wrong often enough to matter: a brief this week
189
+ described a client-side sort as absent when it had shipped, and the only seat that found the real
190
+ defect was the one that went and looked before writing code. A lane that cannot reproduce the defect
191
+ has found something more valuable than the fix — and the alternative is a lane that implements the
192
+ brief's mistake faithfully, which costs the full cycle and passes review.
193
+
194
+ ## Before you dispatch
195
+
196
+ ### 3. Prove each seat with a trivial dispatch, not a chat probe
197
+
198
+ 3. **Prove each seat with a trivial DISPATCH, not a chat probe — and give a failing seat one
199
+ attempt per wave.** A one-word probe measures the wrong thing. On one day two seats
200
+ both answered `ready` and then wrote **0 bytes with no process** on a real lane, while a third
201
+ errored outright. Three failures, three model ids, one broken run
202
+ path — while a seat on a different binary ran first time, which is what located the fault. A probe
203
+ that passes and a dispatch that dies look identical until you spend a cycle.
204
+
205
+ So: prove a seat by asking it to edit a scratch file in the lane worktree and exit, then check
206
+ the file changed — **and delete it before dispatching the lane, verifying the tree is clean
207
+ again.** A probe artefact left behind is worse than no probe: `git status --porcelain` in that
208
+ worktree is what the next step reads to derive lane status, so an untracked scratch file reads as
209
+ lane activity, and a lane that later stages with a broad pattern can commit it. Found by two
210
+ reviewers independently on the PR that introduced this rule. And when a seat fails a real dispatch,
211
+ **switch rather than debug** — one
212
+ attempt per wave. Two extra cycles were spent rediscovering a rule written after the
213
+ first failure.
214
+
215
+ ### Grep the lane id against every plan, not only its own
216
+
217
+ - **Grep the lane id against every plan, not only its own.** `grep -rniw '<ID>' <planDir>/`
218
+ is one command and it is the whole check. Match on word boundaries, **not** on `**<ID>**`: ids
219
+ are written `| **K9** |` in a table, `**Lane K9**` in prose and bare in a sentence, and a
220
+ pattern that assumes one spelling reports "no collision" for the two forms it cannot see —
221
+ which is worse than not running it, because it is evidence that is not evidence. Lane ids are the
222
+ join key for the session-log
223
+ citation, the plan's shipped note, the mutation manifest filename
224
+ (`.agents/manifests/<lane>.json`), the wave-status row and the premise fence's own name, so a
225
+ collision silently merges two lanes' histories and the plan verifier can evaluate one plan's fence
226
+ against the other's claim. It has happened twice, and both
227
+ times the colliding ids were **bare sequential** ones; prefixing with the plan's arc is what has
228
+ kept the other arcs clean.
229
+ BSD `grep -E` has no `\b`, so the original word-boundary pattern (`grep -rniE '\b<ID>\b'`) was
230
+ silent on every tree here — `-w` is the portable way to match a whole word, which is why the
231
+ command above uses it.
232
+
233
+ ### Check the gap is still open before dispatching the lane that closes it
234
+
235
+ - **Check the gap is still open before dispatching the lane that closes it.** A recorded
236
+ finding is a claim about the past. `git log --oneline -- <the test file the fix would touch>` and a
237
+ grep for the defect's own numbers cost seconds; re-deriving an inventory with
238
+ `merge-base --is-ancestor` does **not** cover this, because that method proves what shipped
239
+ and cannot see that a recorded gap was closed by something it did not cite. A lane was
240
+ scheduled against a ceiling overcount that a merged fix had already corrected, with the reported
241
+ numbers pinned in a test named after them.
242
+
243
+ ### Four defects came from briefs that failed exactly this
244
+
245
+ Four defects came from briefs that failed exactly this, and in every case the lane
246
+ implemented what was written:
247
+ - A brief was told to cover a document surface "**in full**" against a list naming two of its five
248
+ fields; the three it omitted each changed what renders. Found by a bot as a High.
249
+ - A brief's test list omitted a field, so the 100%-branch gate failed on the untaken
250
+ arm of a conditional spread — a field the brief *did* cover but nothing proved reached it.
251
+ - A brief named no precision hazard, so a version past the safe-integer range
252
+ could resolve to a **different stored version than the caller pinned**.
253
+ - A lane was briefed as "a past-wave lane is not counted as needing a human" — true as a sentence,
254
+ wrong as a rule, because age came only from log and event timestamps while liveness and PR
255
+ checks were live-probed. Two fact sets, different ages, no carve-out.
256
+
257
+ ### 8. Every fence you write must be TIMED and shown to decide, before it lands
258
+
259
+ 8. **Every fence you write must be TIMED and shown to decide, before it lands.** `plan:verify`
260
+ kills a premise at **10 seconds** and reports `TIMED-OUT — not stale, make the premise decide
261
+ quickly`. A premise with no verdict protects nothing: it neither holds nor flips, it just turns
262
+ the gate red for a reason unrelated to the lane. So for each fence, run it, record the wall time
263
+ in a comment beside it, and keep it in **milliseconds** — a fence is a probe, not a scan.
264
+ Verify three things, not one: that it **holds today** (the gap is open), that it **can flip**
265
+ (construct the closed state and watch it change), and that it **answers fast**.
266
+
267
+ ### Timed fences that failed (three that failed differently)
268
+
269
+ Three fences failed this way, each differently, and the pattern is worth knowing:
270
+ - **Too slow.** A fence flattened a large file with `tr` and ran a bounded repeat against the single
271
+ resulting line — catastrophic backtracking, killed at the timeout. Bounded to the function body,
272
+ it answered in milliseconds.
273
+ - **Too narrow.** A fence asked whether a config file existed — half of its own section's title,
274
+ and the half that closes first. It went stale on the config-only commit while hundreds of files
275
+ were still unformatted, which would have forced a single huge commit.
276
+ - **Too slow again, from the opposite direction.** The replacement ran a formatter check over
277
+ hundreds of files: seconds locally, timed out on the runner. Local timing is not the test; the
278
+ runner is slower and contended.
279
+
280
+ ### 9. Send the plan to the plan reviewer
281
+
282
+ 9. **Send the plan to the plan reviewer** — the seat the overlay's `cast.md` names — **before
283
+ dispatching any lane from it**, whenever the plan *introduces or rewrites lanes* or *changes a
284
+ premise*. It is read-only by construction, so it returns a review and cannot patch around what it
285
+ finds. On its first use it caught a rule in an **already-dispatched** brief that contradicted both
286
+ the plan and the code — a counter the brief tracks per item where the plan defines it per group —
287
+ which the lane would otherwise have pinned in a test. The lane was stopped with nothing committed.
288
+ Nothing else needs this seat; it is not a review gate on prose.
289
+
290
+ ## The six stages
291
+
292
+ ### Yarn Berry hardlinks package contents from a shared global cache
293
+
294
+ A package manager that hardlinks package contents from a shared global cache means concurrent
295
+ installs across worktrees can evict or relink an entry while another checkout is holding it, and
296
+ the victim is the checkout nobody is installing into: the **main checkout**, which silently loses a
297
+ native binary while keeping the package directory. Platform-specific optional dependencies are what
298
+ break, because they are the large binaries.
299
+
300
+ So: serialise installs; skip them **only for a lane that runs no local command needing
301
+ dependencies** — which in practice means a docs-only lane and very little else. **A deletion lane
302
+ is not one of them**: a lane that deletes a test file must prove the *remaining* suite still
303
+ passes, and that is exactly the command that needs `node_modules`. And
304
+ **after a wave's installs, verify the main checkout still has its native binaries** rather than
305
+ letting the owner's next dev start find out:
306
+
307
+ ### What the stripped-binary check found
308
+
309
+ Run on a given day it found **two more** beyond the two that had already broken the owner's
310
+ `yarn dev`: a task runner's platform binary — which is why that day's dev run opened by repairing
311
+ itself — and a bundler binding nothing had asked for yet and would have failed later, with no
312
+ obvious cause.
313
+
314
+ **The superseded form of the check, kept as the counter-example it became.** It walked the glob and
315
+ printed only what it found stripped, so a tree where the glob matched nothing printed nothing and
316
+ exited with the status of its last test. A loop over nothing proved nothing, and that read as
317
+ healthy. The skill's current form counts what it discovered and fails when that is zero. Do not
318
+ paste this one:
319
+
320
+ ```sh
321
+ # Names any platform package left with metadata only, and is silent when healthy.
322
+ #
323
+ # `find node_modules -name '*.node' | head` is NOT a check: a stripped package simply
324
+ # contributes no line, so the command prints the survivors and exits 0 — it reports what
325
+ # exists, never what is missing. Nor is "has a .node file" the test: @esbuild ships
326
+ # `bin/esbuild`, @img/sharp-libvips ships `lib/`, and both are healthy with no .node at
327
+ # all. The payload test below has neither false negative nor false positive on this repo.
328
+ for d in node_modules/@*/*darwin*/ node_modules/*darwin*/; do
329
+ [ -d "$d" ] || continue
330
+ n=$(find "$d" -type f ! -name '*.json' ! -name '*.md' ! -name 'LICENSE*' | wc -l)
331
+ [ "$n" -eq 0 ] && echo "STRIPPED: $d"
332
+ done
333
+ ```
334
+
335
+ ### A lane is not done until the PR exists, and lanes routinely stop one step short
336
+
337
+ **A lane is not done until the PR exists, and lanes routinely stop one step short.** On
338
+ one day two lanes each committed clean, verified work and never pushed or opened a PR, and one
339
+ paused four separate times mid-verification waiting on its own background job. Write
340
+ "commit, push, and open the PR with `gh pr create`" as the explicit final instruction in every
341
+ brief — and when a lane stops anyway, **finish it mechanically yourself** after verifying the
342
+ diff. That is a legitimate orchestrator action, not a fix the lane owes you; what is not
343
+ legitimate is reporting the lane done because it said so.
344
+
345
+ ### Emit the event in the tool call immediately before the launch
346
+
347
+ Emit the event in the tool call **immediately before** the launch, with nothing between them —
348
+ never afterwards, and never "as you go", which is what an orchestrator reads and skips. It cannot
349
+ literally be the same call on the primary path: an `Agent` dispatch and a shell call to the
350
+ wave-event bin are different tools by construction, so a rule demanding one call is
351
+ unfollowable, and an unfollowable rule teaches that rules are optional. The property that matters
352
+ is that **no lane is ever launched without its event already written**; the adjacency is how you
353
+ get there. **There is no launcher that emits for you, and there will not be one.** A script that
354
+ emitted and launched in one call existed until it was deleted: it killed every lane it
355
+ started, twice, when both lanes dispatched through it wrote 0 bytes
356
+ with no process while every directly-launched lane that day worked. **The mechanism, so nobody
357
+ rebuilds it:** `nohup` only ignores `SIGHUP` and `disown` only drops the shell's job-table entry —
358
+ neither calls `setpgid`, so a lane launched that way stays in the **caller's process group**. A
359
+ launcher that then *waits* holds the tool call open past its timeout, and the harness signals the
360
+ whole group, taking the lanes with it. A direct `nohup … & disown` survives precisely because the
361
+ tool call **returns immediately** and a finished call is never group-killed. Atomicity bought this
362
+ way costs the lane; adjacency from a direct launch is the supported shape.
363
+
364
+ Emission is therefore yours. On one day four of five lanes ran through the `Agent` tool or a
365
+ direct CLI and nobody emitted for them, so the wave-status page showed **one event for the whole
366
+ wave** and 30+ events had to be backfilled afterwards with a note that their timestamps were
367
+ recording times, not event times. A stage with no event did not happen, and a backfilled one
368
+ cannot be trusted for timing.
369
+
370
+ ### Every brief carries the checkpoint rule
371
+
372
+ **Every brief carries the checkpoint rule**: commit the failing tests locally the moment they
373
+ have been seen to fail, commit again after each green step, push only when the gate passes. On one
374
+ day provider failures (one 522, six 429s) killed seven lane runs. The two that had written
375
+ nothing to disk lost the whole run; every other one resumed from what it had committed — or, once,
376
+ from uncommitted files that happened to survive in the worktree, which is luck, not a method.
377
+ **This is a scoped exception to `.agents/testing.md` ("a red suite blocks the commit"), confirmed by
378
+ the owner,** and it covers checkpoint commits on a lane's own branch only. The branch is
379
+ pushed only when the gate passes on its head, so no pushed head and no CI run is red; the red
380
+ checkpoints do travel to the lane branch on `origin` as history, and never reach `main`, because
381
+ PRs squash-merge. Do not rewrite history to hide them — that is the destructive step checkpoints prevent.
382
+
383
+ ### 3. Remediate
384
+
385
+ 3. **Remediate.** Merge verified findings into a fix brief (Template C), listing refuted items with
386
+ reasons. **After any interrupted or killed `mutate:verify`, scan for a stranded mutation before
387
+ anything commits**: a mutation applies a change to the source and restores it at the end, so a
388
+ run that dies in the middle leaves the source mutated and the next commit ships it. The check is
389
+ five lines — for each manifest entry, assert its `before` text is present and its `after` text is
390
+ not. It ran four times on one day (0 stranded each time) and is cheap enough to be
391
+ unconditional; a killed verification is the one moment the working tree can be silently wrong.
392
+
393
+ ### The merge bin enforces this
394
+
395
+ and **zero review threads are unresolved**. **The merge bin enforces this**: once the
396
+ required check has concluded green on the head it pushed, it waits a bounded settle period for the
397
+ review bots, then refuses to merge
398
+ while any review thread is unresolved
399
+ — naming each open thread's first-comment author and an excerpt — and re-reads the PR's head
400
+ immediately before `gh pr merge`, refusing if it is no longer the SHA whose checks were read. The
401
+ decision itself lives in the package's own sweep bin, because it
402
+ has to be tested and the runners have no zsh; the script is only its caller. A page of threads
403
+ that could not be read is "could not decide" and refuses — never a silent zero.
404
+ **The settle period is a wait, not a proof that the bots reviewed the final head.** Only bots that
405
+ re-run on push can post on a refreshed head; some review-bot workflows trigger on
406
+ `opened`/`reopened`/`ready_for_review` only, and nothing checks that any bot ran. The script enforces
407
+ two things — no unresolved threads and an unchanged head — and a PR whose final head deserves a bot's
408
+ eyes still needs you to confirm the bot posted on it.
409
+
410
+ ### The merge bin enforces this (evidence)
411
+
412
+ On one day a merge gated on CI alone raced the bots — nothing was missed that time, but only by
413
+ luck — and the full condition later held back a PR whose final-head review found a real defect
414
+ the gate could not see.
415
+
416
+ ## House rules that bite here
417
+
418
+ ### Never spawn a funded model seat to reproduce a defect
419
+
420
+ - **Never spawn a funded model seat to reproduce a defect.** External model CLIs bill the
421
+ owner. A lane once demonstrated the launcher's process-group kill by launching one real paid run
422
+ against the owner's account — about four seconds of a paid seat,
423
+ disclosed unprompted, for a fact a stub would have shown just as well. The dispatch mechanics being
424
+ probed (does the child survive a group signal?) are a property of `setpgid`, `nohup` and `disown`,
425
+ not of any model: `sleep 60` reproduces them exactly. The existing rules named the owner's dev
426
+ servers and their credits and did not name this, so write it into every brief: **reproduce
427
+ dispatch and launcher behaviour with a stub process, never a paid CLI.** A seat is for doing the
428
+ lane's work, not for demonstrating that a launcher kills it.
429
+
430
+ ### Touching a manifest arms it
431
+
432
+ - **Touching a manifest arms it.** CI replays only the manifests a change *touches* — the
433
+ workflow's **manifest-replay** step, which runs the manifest verifier
434
+ against a named diff base (named, not cited by line: a line number in a rule about anchors
435
+ rotting is the joke writing itself) — so editing one for an unrelated reason pulls it into the replay
436
+ set and every anchor in it must then resolve.
437
+
438
+ **The corollary used to be worse than the inconvenience.** A manifest
439
+ nobody touched was never checked again, so its evidence rotted in silence: a full audit found
440
+ **dead anchors across a third of the manifests — a double-digit percentage of all mutation claims**,
441
+ and three manifests dead outright. Repairing
442
+ them exposed **three mutations recorded `caught` that actually survived** — one live on `main` the
443
+ whole time, invisible because a dead sibling made its manifest refuse to replay at all.
444
+
445
+ **The anchor check now covers every anchor in every manifest** — a string count, no build, no
446
+ tests, all of them in under a second — and runs ahead of the replay, so a dead
447
+ anchor costs one second instead of twenty minutes. Anchors no longer rot in silence. **The replay
448
+ is still diff-scoped**, so the rest of this rule stands: touching a manifest still arms its full
449
+ replay.
450
+
451
+ **The same check now asks the second question: does the `command`'s `-t` still
452
+ select a test?** `vitest -t` is a REGEX, and a pattern that matches nothing skips every test and
453
+ **exits 0**, which the mutation verifier reads as `survived`. That is worse than a dead anchor — a dead
454
+ anchor refuses, this one answers, confidently and wrongly. It did so twice: a title's round
455
+ brackets pasted into the pattern, where the parentheses are a capture group and not two literal
456
+ characters (182 tests skipped, exit 0, "survived"), and three entries after a rename of the test
457
+ they name. The check proves a pattern live from the test file's syntax where it can (no spawn) and
458
+ escalates the rest — a `test.each` title formatted per case, a title that is an expression — to the
459
+ runner's own test listing, so it condemns nothing it has not seen refused. **When you write a
460
+ `-t`, verify it selects
461
+ before you record it**, and escape the metacharacters in a title you are
462
+ copying.
463
+
464
+ A mutation whose subject was *deleted* can carry **`"retired": "<why>"`** with a required reason,
465
+ skipped by both the check and the replay. Retiring is a claim: an unexplained one is
466
+ indistinguishable from abandoning a test that was catching something, and retiring a mutation that
467
+ *survives* is `verdict: "survived"` with a coat of paint. Re-anchor when the code moved; retire
468
+ only when it is gone.
469
+
470
+ - **Before `git reset --hard`, save the diff.** `git diff > /tmp/<name>.patch` (and
471
+ `git diff --cached` if anything is staged) first. A hard reset silently destroys uncommitted work,
472
+ and the moment it costs most is the one where you are resetting *because* something went wrong —
473
+
474
+ ### Before git reset --hard, save the diff
475
+
476
+ - **Before `git reset --hard`, save the diff.** `git diff > /tmp/<name>.patch` (and
477
+ `git diff --cached` if anything is staged) first. A hard reset silently destroys uncommitted work,
478
+ and the moment it costs most is the one where you are resetting *because* something went wrong —
479
+ which is exactly when the work you are discarding was the fix. It cost a hardened script here that
480
+ had to be written twice. **Commit before you test, not after**, for the same reason.
481
+
482
+ ### A mutation you did not confirm applied is not a mutation
483
+
484
+ - **A mutation you did not confirm applied is not a mutation.** Before believing a green run means
485
+ "this test is weak", check the edit landed — `grep` for the mutated text, or diff the file. A
486
+ `sed`/`perl` substitution that silently misses produces a passing suite that is indistinguishable
487
+ from a vacuous test, and the wrong conclusion is expensive in both directions. Observed twice in
488
+ one wave.
489
+
490
+ ## Process rules added by the parity plan
491
+
492
+ ### Review tiering follows the plan row's risk
493
+
494
+ A normal-risk lane's row and brief are short, and a second pass over each finds the same things as
495
+ the first, so they get one combined pass. A high-risk lane's failures cost more than the reviews do,
496
+ so each of its row, brief and pre-PR reviews stays its own pass with its own context. The review bots
497
+ stay on every PR at either tier because they have found real defects after the model reviewer
498
+ approved.
499
+
500
+ ### A lane's result is verified on a second host
501
+
502
+ A result checked only on the host that produced it inherits that host's faults: a stale cache, a
503
+ missing dependency that happens to be present, a CPU the goldens do not fit. For a remote lane host
504
+ the orchestrator's own host is the second one. For a local lane host there is no other machine to
505
+ hand, so CI is the second host, and CI's conclusion on the final head is what is read.
506
+
507
+ ### A fix round resumes the lane's own session
508
+
509
+ A resumed round keeps what the lane already learned about its own diff and takes fewer steps than a
510
+ fresh one. When the branch has moved under the session (a merge, a refresh), a plain resume would
511
+ carry a stale picture of the tree, so the round forks the session instead. The flags are an
512
+ orchestrator-side detail of one transport, so a brief never names them. Two forks started in the
513
+ same second collide in opencode's sqlite ("database is locked"), hence the stagger.
514
+
515
+ ### Install probes
516
+
517
+ Concurrent installs on one host can leave a dependency's postinstall output unwritten while
518
+ the install itself exits 0, and nothing then says so until a lane needs the binary. A probe makes
519
+ the absence a refusal at worktree setup. The repair runs once and is followed by a second check, so
520
+ a repair that does nothing cannot be mistaken for a fix.
@@ -0,0 +1,17 @@
1
+ #!/bin/sh
2
+ # Dispatch helper for orchestrators emitting wave-status events around direct dispatch.
3
+ #
4
+ # Usage:
5
+ # wave-event.sh [<logdir>] <wave> <lane> <stage> <event> [--pr N] [--round N] [--detail '<json>']
6
+ # wave-event.sh --logdir <dir> <wave> <lane> <stage> <event> [--pr N] [--round N] [--detail '<json>']
7
+ #
8
+ # Standalone dispatch examples (logdir defaults to the wave's directory under the
9
+ # config.yaml waveLogDir, or an existing /tmp/wave-<wave>):
10
+ # wave-event.sh <wave> <lane> dispatch started
11
+ # wave-event.sh <wave> <lane> implement settled --pr <PR_NUMBER>
12
+ # wave-event.sh <wave> <lane> implement failed --detail '{"reason":"killed"}'
13
+ #
14
+ # This shim resolves nothing by path. The emitter is the package's own binary, so
15
+ # the script works from any directory, any worktree, and after any move — there is
16
+ # no directory count to keep correct.
17
+ exec hexagen-orchestration-wave-event "$@"
@@ -0,0 +1,66 @@
1
+ name: Gate
2
+
3
+ # Generated by the hexagen orchestration template. This workflow runs ONE step:
4
+ # `hexagen-orchestration-gate`, which reads `.agents/orchestration/config.yaml`
5
+ # and runs the gate steps that file names, in order, stopping at the first
6
+ # failure by name. There is no second copy of the step list to keep in sync —
7
+ # `config.yaml` is the only place it appears.
8
+ #
9
+ # `--no-install` is deliberate: if the devDependency is missing, CI fails loudly
10
+ # rather than silently fetching an arbitrary version from the registry. For local
11
+ # convenience add a "gate": "hexagen-orchestration-gate" script to package.json
12
+ # by hand; this workflow does not use it, so CI and a human run the same bin.
13
+ on:
14
+ push:
15
+ branches: ["**"]
16
+ pull_request:
17
+ branches: [main]
18
+ workflow_dispatch:
19
+
20
+ # Read-only: this workflow only checks out code and runs the gate, so the token it
21
+ # receives needs no write scope.
22
+ permissions:
23
+ contents: read
24
+
25
+ jobs:
26
+ gate:
27
+ name: Gate
28
+ runs-on: ubuntu-latest
29
+ steps:
30
+ - uses: actions/checkout@v5
31
+
32
+ # Corepack MUST run before setup-node: setup-node@v5 probes the
33
+ # package-manager cache with the runner's global Yarn (Classic 1.22),
34
+ # which hard-errors on a packageManager-pinned yarn@4 project. Enabling
35
+ # Corepack first makes `yarn` resolve to the pinned shim.
36
+ - name: Enable Corepack
37
+ run: corepack enable
38
+
39
+ # Read the pinned version from package.json's `packageManager` at runtime
40
+ # so CI can never drift from what the project declares (no baked version). A project
41
+ # without the field fails here with a clear message instead of an empty corepack argument.
42
+ - name: Prepare package manager
43
+ run: |
44
+ pm=$(node -p "require('./package.json').packageManager || ''")
45
+ [ -n "$pm" ] || { echo "::error::package.json has no packageManager field; corepack cannot pin the package manager"; exit 1; }
46
+ corepack prepare "$pm" --activate
47
+
48
+ - uses: actions/setup-node@v5
49
+ with:
50
+ node-version: "{node_version}"
51
+ # No `cache: yarn` — and the v5 auto-probe is disabled explicitly:
52
+ # setup-node@v5 otherwise still runs the global Yarn Classic
53
+ # (`yarn cache dir`) to locate the store, which fails on a
54
+ # packageManager-pinned project. Committing yarn.lock does NOT make it
55
+ # safe: the hazard is the probe, not the lockfile. There is no Turbo
56
+ # cache here — it belongs to ci-github-actions' own workflow.
57
+ package-manager-cache: false
58
+
59
+ # `--immutable`, unlike ci-github-actions' first run: gate.yml is added
60
+ # after `yarn add`, by which point the project has a lockfile to install
61
+ # against. See the template README's checklist order.
62
+ - name: Install dependencies
63
+ run: "yarn install --immutable"
64
+
65
+ - name: Run the gate
66
+ run: npx --no-install hexagen-orchestration-gate
@@ -0,0 +1,48 @@
1
+ ---
2
+ id: 0001
3
+ subject: orchestration
4
+ subjectKind: template
5
+ subjectVersion: "1.0.0"
6
+ fixedIn: "1.0.0"
7
+ class: host-assumption
8
+ severity: high
9
+ surface: docs
10
+ status: fixed
11
+ ---
12
+
13
+ ## What happens
14
+
15
+ The skill this template emits points at two runbooks by relative path, climbing out of the skill
16
+ directory to reach them: `docs/workflows/delegated-implementation-pipeline.md` for the stage detail
17
+ and prompt templates A-D, and `docs/workflows/orchestrator-kickoff-prompt.md` for the kickoff. A
18
+ relative path that escapes the emitting directory only resolves when the skill is read from the one
19
+ repository that happens to carry both files at those relative depths.
20
+
21
+ Everywhere else the link is dead. The file lands at `.agents/skills/orchestrate-wave/`, three
22
+ directories deep under the project root, so the upward climb the link performs points outside the project
23
+ entirely, and the anchor fragment that named a specific heading has nothing to resolve against. A
24
+ skill whose runbook reference is dead is a skill whose stage detail is missing, and the failure is
25
+ silent: the link renders as ordinary text and the reader never learns a runbook was supposed to be
26
+ there.
27
+
28
+ The same fragility has a second cost. The prose named the runbooks by path and by document title,
29
+ and the skill ordered "Template A" and "Template C" by name without saying where they live, so
30
+ there was no single place a re-sync would edit.
31
+
32
+ ## Minimal repro
33
+
34
+ Install `orchestration` into a project that has no `docs/workflows/delegated-implementation-pipeline.md`.
35
+ Read the emitted SKILL.md at its stage-detail paragraph: the runbook it points at does not exist in
36
+ the project, and neither does the heading the anchor fragment names.
37
+
38
+ ## Fix
39
+
40
+ Ship the runbooks the skill actually needs, inside the skill, and point at them relatively from
41
+ where the skill lands. The four prompt templates this skill orders by name (A, B, C, D) ship as
42
+ `references/briefs.md`, a sibling reference file like `references/rationale.md`, and the skill names
43
+ that path. The remaining runbook prose stays optional and project-owned: the contract says to read
44
+ it where the project ships it, which is true of no path in particular.
45
+
46
+ The residual assumption is stated rather than relied on: the reference is a sibling of the skill,
47
+ not an upward climb, so it resolves identically whether the skill is read from
48
+ `.agents/skills/orchestrate-wave/` or from a copy the project keeps elsewhere.