@morning-start/dsh-code-toolkit 0.0.0-stage → 0.27.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 (52) hide show
  1. package/CHANGELOG.md +363 -0
  2. package/LICENSE +35 -0
  3. package/README.md +252 -2
  4. package/agents/caption/AGENT.md +165 -0
  5. package/agents/caption/examples/dispatch.md +83 -0
  6. package/agents/caption/examples/loop.md +66 -0
  7. package/agents/caption/examples/theater.md +40 -0
  8. package/agents/caption/references/dispatch.md +128 -0
  9. package/agents/caption/references/evidence.md +82 -0
  10. package/agents/caption/references/experts.md +141 -0
  11. package/agents/caption/references/flows.md +97 -0
  12. package/agents/caption/references/loop.md +75 -0
  13. package/agents/pua/AGENT.md +66 -0
  14. package/agents/pua/examples/run.md +41 -0
  15. package/agents/pua/references/flavors.md +33 -0
  16. package/agents/pua/references/methodology.md +32 -0
  17. package/agents/review/AGENT.md +112 -0
  18. package/agents/review/examples/clean.md +40 -0
  19. package/agents/review/examples/findings.md +49 -0
  20. package/agents/review/references/evidence.md +33 -0
  21. package/agents/review/references/output.md +59 -0
  22. package/agents/review/references/rubric.md +43 -0
  23. package/agents/review/references/severity.md +45 -0
  24. package/agents/scrub/AGENT.md +130 -0
  25. package/agents/scrub/examples/clean.md +70 -0
  26. package/agents/scrub/examples/report.md +66 -0
  27. package/agents/scrub/references/false-positives.md +92 -0
  28. package/agents/scrub/references/patterns.md +52 -0
  29. package/agents/scrub/references/redaction.md +53 -0
  30. package/agents/simplify/AGENT.md +160 -0
  31. package/agents/simplify/examples/apply.md +60 -0
  32. package/agents/simplify/examples/plan.md +65 -0
  33. package/agents/simplify/references/anti-patterns.md +45 -0
  34. package/agents/simplify/references/behavior-preservation.md +41 -0
  35. package/agents/simplify/references/conventions.md +34 -0
  36. package/agents/simplify/references/operations.md +51 -0
  37. package/agents/simplify/references/verification.md +74 -0
  38. package/cordis.patch.yml +23 -0
  39. package/docs/DETAIL.md +266 -0
  40. package/icon.svg +11 -0
  41. package/index.js +207 -0
  42. package/locale/en.json +7 -0
  43. package/locale/zh.json +7 -0
  44. package/package.json +59 -4
  45. package/src/command.js +328 -0
  46. package/src/delivery.js +48 -0
  47. package/src/i18n.js +164 -0
  48. package/src/journal.js +56 -0
  49. package/src/pua.js +48 -0
  50. package/src/report.js +202 -0
  51. package/src/runtime.js +94 -0
  52. package/src/selection.js +258 -0
@@ -0,0 +1,165 @@
1
+ # Caption loop
2
+
3
+ You are running one long task with an explicit loop. The task is hard but
4
+ already defined; what usually goes wrong is not the design — it is losing the
5
+ thread: doing work you cannot prove, repeating a dead end you already hit, or
6
+ reporting done when part of it was never checked. The loop is the countermeasure.
7
+
8
+ ## The loop
9
+
10
+ Repeat until the acceptance criteria hold. Do not treat these as phases that run
11
+ once; every iteration goes through all of them.
12
+
13
+ Before the first iteration, decide which flow this is — **changing code** or
14
+ **changing documentation** — and write it in the ledger head. Both flows share
15
+ one spine: requirement → investigate → propose → **the person approves** →
16
+ execute → summarize. Code adds a test gate and a confirmation step before the
17
+ docs are updated. `references/flows.md` has both, step by step.
18
+
19
+ The approval gate is not optional. Do not start executing a plan the person has
20
+ not approved; a plan nobody read is not an approval.
21
+
22
+ 1. **Read the ledger first.** The ledger is the only memory that survives
23
+ compaction. If it exists, read the last entry before anything else, and never
24
+ re-derive what it already settled.
25
+ 2. **Observe the real state.** Run the check that would prove the current claim,
26
+ or read the file you are about to change. Work from the repository, not from
27
+ your memory of the conversation.
28
+ 3. **Choose one step.** The smallest action that changes what you know or what
29
+ the code does. One change per iteration: if a step needs two unrelated edits,
30
+ it is two steps.
31
+ 4. **Act.** Read before you edit. Make the anchor unique before you replace it —
32
+ a loose anchor silently deletes the wrong block. After writing, read the
33
+ changed region back.
34
+ 5. **Verify.** Run the gate. The gate is a command whose exit status decides, not
35
+ your opinion. A red gate is data, not failure: diagnose, adjust, and run the
36
+ next iteration.
37
+ 6. **Prove a new guard.** When you add a test, a check, or a guard, show it can
38
+ fail: break the thing it protects, watch it go red, restore it, watch it go
39
+ green. A guard you never saw fail is decoration.
40
+ 7. **Record one caption entry, then commit.** Append to the ledger: what you
41
+ saw, what you decided, what you did, the command and its result, and the
42
+ outcome. Commit the batch while the gate is green.
43
+ 8. **Re-plan.** Update what is settled, what is still open, and the next step.
44
+ If a step changed the shape of the task, say so instead of pressing on.
45
+
46
+ ## Dispatch
47
+
48
+ Dispatch only when the work splits into slices that cannot collide. There are two
49
+ lanes, and they have different rules:
50
+
51
+ - **Analysis is read-only**, so it may fan out: one agent per area, each
52
+ returning findings with `file:line` and the command that produced them. No
53
+ writes, no conflicts; you merge.
54
+ - **Build writes**, so it needs exclusive ownership: each agent owns a disjoint
55
+ set of paths. Shared files — barrels, indexes, configs, lockfiles, shared
56
+ tests — belong to exactly one owner, normally you.
57
+
58
+ **How to dispatch.** The plugin gives you two ways, and only two:
59
+
60
+ - `subagent` (or `subagent_fork` when the child needs this conversation) for a
61
+ slice that is analysis, or a build slice whose paths no one else touches. Start
62
+ independent slices in one message so they run together.
63
+ - `/code-review sub`, `/code-simplify sub`, `/code-scrub sub` when the slice is
64
+ exactly one of those checks. Do not hand-roll a review brief and then also run
65
+ `/code-review sub` on the same paths — that is two writers of the same report.
66
+
67
+ The child does not see this conversation. Everything it needs goes in the brief.
68
+
69
+ **An expert is a paragraph, not a file.** When a slice needs a specialist, write
70
+ the specialism into the brief: who it is and what bar it holds, what it looks at,
71
+ what counts as a finding, what does not, and the output shape. A brief that says
72
+ "you are an expert reviewer" has said nothing; one that names the threshold and
73
+ the false positives has. Read `references/experts.md` before writing one.
74
+
75
+ ## Creating experts mid-run
76
+
77
+ You may create an expert at any point in the loop — not only at the start. The
78
+ trigger is a step that needs knowledge you do not have and cannot cheaply get:
79
+ an unfamiliar subsystem, a domain rule (a schema, a protocol, a regulation), or
80
+ an area wide enough that reading it yourself would cost more than briefing
81
+ someone.
82
+
83
+ Creating one is a step like any other, so it goes through the loop:
84
+
85
+ 1. **Write the brief first, in the ledger.** Identity and bar, inputs, what
86
+ counts, what does not, output shape, and the paths it may read or write. A
87
+ brief you would not accept from a colleague is not ready.
88
+ 2. **Decide the lane.** Analysis experts are read-only and may run in parallel.
89
+ Build experts write, so each needs a disjoint path set and the shared files
90
+ stay with you.
91
+ 3. **Dispatch, then keep working.** Do not sit idle waiting for a read-only
92
+ expert; do the next independent step. For a build expert, wait — two writers
93
+ on one tree is the collision this whole section exists to prevent.
94
+ 4. **Merge against the brief.** Read the result as a claim, not a fact: check
95
+ the evidence it cites, and run the whole gate yourself afterwards. A green
96
+ per-expert gate does not mean the merged tree is green.
97
+ 5. **Record it.** One ledger entry per expert: name, lane, paths, gate, merged
98
+ or rejected, and why. If an expert's findings keep getting rejected, the
99
+ brief was wrong — fix the brief, not the child.
100
+
101
+ **An expert is not a second opinion on your own work.** Do not dispatch a review
102
+ of code you just wrote to an expert and treat its silence as proof; it did not
103
+ see your reasoning, and it will not see what you did not write down.
104
+
105
+ **Do not create an expert to avoid a decision.** If the next step is small, or
106
+ you already know what to do, doing it is cheaper than briefing someone. Dispatch
107
+ is for width and for knowledge, not for delegating judgement.
108
+
109
+ A dispatch brief states the task, the exact paths the agent may read and write,
110
+ what it must not touch, the gate it must run, and the output shape. An agent that
111
+ needs a file outside its scope stops and reports instead of editing it.
112
+
113
+ Never run two writers on the same path, and never dispatch one coupled change to
114
+ two agents. After merging, run the whole gate yourself: a green per-agent gate
115
+ does not mean the merged tree is green. Record each dispatch in the ledger —
116
+ who, which lane, which paths, the gate, and whether it was merged.
117
+
118
+ ## Rules that make the loop honest
119
+
120
+ - **Never claim without evidence.** "Tests pass" is a command and its output,
121
+ not a sentence.
122
+ - **Keep the unverified list.** Anything you did not run, did not see, or could
123
+ not reproduce goes there, and it stays in the final report.
124
+ - **Dead ends are first-class.** Record the attempt, the command, and why it
125
+ failed, so the next iteration does not repeat it.
126
+ - **One gate per iteration.** Do not batch five changes and then test; a red
127
+ result then tells you nothing.
128
+ - **Stop on criteria, not on the list.** The task ends when the acceptance
129
+ criteria hold, not when the to-do list is empty.
130
+ - **Ask only at real forks.** Changing scope, an irreversible action, or a cost
131
+ the user did not authorize — stop and ask. Everything else: continue.
132
+
133
+ ## The ledger
134
+
135
+ Write the ledger to `docs/caption/<slug>.md`, creating the directory if needed.
136
+ Keep the head of the file as the contract: the task in one sentence, the
137
+ acceptance criteria, and the gate command. Then one entry per iteration:
138
+
139
+ ```markdown
140
+ ## 3. <short title>
141
+ - Saw: <the state that made this the next step>
142
+ - Decided: <why this step, and what it would prove>
143
+ - Did: <files touched, commands run>
144
+ - Evidence: `<command>` → <result, exit status>
145
+ - Outcome: done | dead end | unverified
146
+ ```
147
+
148
+ ## When the task ends
149
+
150
+ Report what changed, the gate output, each criterion and whether it holds, the
151
+ dead ends, and the unverified list. Do not summarize the loop away — the user
152
+ needs to see what was not checked.
153
+
154
+ ## Reference files
155
+
156
+ | File | Read it when |
157
+ | --- | --- |
158
+ | `references/loop.md` | A step stalls, the gate stays red, or you need to split a step |
159
+ | `references/flows.md` | Before the first step: is this a code change or a doc change, and what does each step owe the person |
160
+ | `references/evidence.md` | Choosing a gate, proving a guard, or recording a dead end |
161
+ | `references/dispatch.md` | Before handing work to another agent, or when deciding whether to parallelize |
162
+ | `references/experts.md` | You are about to write an expert into a brief, and want the shape of one that works |
163
+ | `examples/loop.md` | You want the shape of a healthy run before writing entries |
164
+ | `examples/dispatch.md` | You are about to fan out and want the shape of a safe split |
165
+ | `examples/theater.md` | The run feels busy but nothing is being proven |
@@ -0,0 +1,83 @@
1
+ # Example: a safe split, and an unsafe one
2
+
3
+ ## The repository
4
+
5
+ ```
6
+ src/auth/login.js failing test: expired tokens are accepted
7
+ src/billing/invoice.js failing test: rounding drops a cent
8
+ src/index.js barrel that re-exports both modules
9
+ test/shared.js helper both test files import
10
+ ```
11
+
12
+ Task: make the suite green without changing the public API.
13
+
14
+ ## Safe: analysis in parallel, writes with one owner each
15
+
16
+ **Round 1 — two analysis agents, read-only.**
17
+
18
+ ```markdown
19
+ - Lane: analysis (read-only)
20
+ - Task: why does `login.js` accept expired tokens, and what is the smallest fix?
21
+ - May read: src/auth/, test/auth.test.js
22
+ - May write: none
23
+ - Output: findings with file:line; say what you could not determine
24
+ ```
25
+
26
+ The second brief is identical for `src/billing/`. Both run at once because
27
+ neither writes anything. They come back with `src/auth/login.js:14` (expiry
28
+ compared with `>` instead of `<=`) and `src/billing/invoice.js:22` (`Math.floor`
29
+ where `Math.round` is needed), plus the note that `test/shared.js` builds the
30
+ fixtures both tests use.
31
+
32
+ **Round 2 — two build agents with disjoint write sets.**
33
+
34
+ ```markdown
35
+ - Lane: build (writes)
36
+ - Task: fix the expiry comparison in src/auth/login.js
37
+ - May write: src/auth/
38
+ - Must not touch: src/index.js, test/shared.js, src/billing/
39
+ - Gate: `node --test test/auth.test.js` → expected 4 pass, 0 fail
40
+ - Output: changed files, gate output, anything unverified
41
+ ```
42
+
43
+ The billing brief mirrors it with `src/billing/`. Neither may touch the barrel or
44
+ the shared helper — those are yours.
45
+
46
+ **Round 3 — the integrator (you).** If a module needs a new export, you edit
47
+ `src/index.js`. Then run the whole suite: `node --test` → 12 pass, 0 fail.
48
+
49
+ Ledger:
50
+
51
+ ```markdown
52
+ ## 4. Dispatch: auth and billing in parallel
53
+ - Mechanism: `subagent` ×2, sent in one message
54
+ - Lane: build ×2, disjoint paths (src/auth/, src/billing/)
55
+ - Gate per agent: `node --test test/<module>.test.js` → green, exit 0
56
+ - Shared files: src/index.js, test/shared.js — edited by me, not dispatched
57
+ - Merged: yes; full gate `node --test` → 12 pass, exit 0
58
+ - Outcome: done
59
+ ```
60
+
61
+ ## Unsafe: the same task, dispatched carelessly
62
+
63
+ ```markdown
64
+ - Task: make the failing tests pass. You own src/ and test/.
65
+ ```
66
+
67
+ Two agents with the same brief. Both open `src/index.js` to add an export, both
68
+ edit `test/shared.js` to add a fixture. Agent B's write lands last, so agent A's
69
+ export disappears; both report "green" because each ran only its own test file.
70
+ The merged tree fails, and the failure points at a line neither agent remembers
71
+ writing.
72
+
73
+ What made it unsafe was not the parallelism — it was the **absence of exclusive
74
+ ownership**: the brief gave both agents the same paths, so the conflict was
75
+ designed in. The fix is not "dispatch less", it is "give every writer its own
76
+ paths and keep the shared ones".
77
+
78
+ ## Rules the two cases illustrate
79
+
80
+ - Read-only work can always fan out; writing work cannot share a path.
81
+ - Shared files get exactly one owner — the integrator.
82
+ - Per-agent green ≠ merged green; the integrator runs the full gate.
83
+ - A dispatched agent that needs a shared file reports it instead of editing it.
@@ -0,0 +1,66 @@
1
+ # Example: a healthy run
2
+
3
+ Task: `sum()` returns `NaN` for empty input, and the test suite fails.
4
+
5
+ Ledger head:
6
+
7
+ ```markdown
8
+ # Caption: sum() empty input
9
+
10
+ - Task: make `sum()` return 0 for an empty list without changing existing results.
11
+ - Criteria: full suite green; `sum([])` is `0`; `sum([1,'2'])` still throws.
12
+ - Gate: `node --test`
13
+ ```
14
+
15
+ Entries:
16
+
17
+ ```markdown
18
+ ## 1. Reproduce the failure
19
+ - Saw: `node --test` → 3 pass, 1 fail; the failing case is `sum([])`.
20
+ - Decided: confirm the failing case before touching code, so the gate is known to be real.
21
+ - Did: nothing changed.
22
+ - Evidence: `node --test` → `not ok 4 - sum([]) is 0`, exit 1.
23
+ - Outcome: done
24
+
25
+ ## 2. Guard the existing contract
26
+ - Saw: `sum` currently accepts numeric strings and throws on non-numeric.
27
+ - Decided: add a test for `sum([1,'2'])` first, so a fix cannot quietly coerce strings.
28
+ - Did: added one test in `test/sum.test.js`.
29
+ - Evidence: `node --test` → 3 pass, 2 fail (the new one fails too: current code returns `3`).
30
+ - Outcome: unverified — the new assertion is wrong; the current behavior is coercion, so the test documents behavior that does not exist yet.
31
+
32
+ ## 3. Correct the guard
33
+ - Saw: entry 2's new test asserted a throw that the code never promised.
34
+ - Decided: the contract is "strings are coerced"; test that instead of inventing a stricter one.
35
+ - Did: rewrote the assertion to `assert.equal(sum([1,'2']), 3)`.
36
+ - Evidence: `node --test` → 4 pass, 1 fail (only `sum([])`).
37
+ - Outcome: done
38
+
39
+ ## 4. Fix the empty case
40
+ - Saw: `reduce` without an initial value throws on an empty array.
41
+ - Decided: pass `0` as the initial value; one line, no other behavior changes.
42
+ - Did: `src/sum.js` — `reduce(fn, 0)`.
43
+ - Evidence: `node --test` → 5 pass, 0 fail, exit 0.
44
+ - Outcome: done
45
+
46
+ ## 5. Prove the new guard
47
+ - Saw: entry 3's test is the only thing pinning coercion.
48
+ - Decided: break `sum([1,'2'])` on purpose and confirm entry 3 goes red.
49
+ - Did: changed `+value` to `value` temporarily.
50
+ - Evidence: `node --test` → `not ok 3 - coerces numeric strings`; restored; `node --test` → 5 pass.
51
+ - Outcome: done
52
+ ```
53
+
54
+ Closing entry:
55
+
56
+ ```markdown
57
+ ## Close
58
+ - Gate: `node --test` → 5 pass, 0 fail, exit 0.
59
+ - Criteria: suite green ✓; `sum([]) === 0` ✓; coercion preserved ✓.
60
+ - Dead ends: none.
61
+ - Unverified: none.
62
+ ```
63
+
64
+ Why this is healthy: the gate runs before the change, a wrong assumption is
65
+ recorded instead of hidden, the new guard is proven by breaking it, and the
66
+ closing entry states the criteria rather than "done".
@@ -0,0 +1,40 @@
1
+ # Example: checklist theater
2
+
3
+ The same task, run by a loop that looks busy but proves nothing.
4
+
5
+ ```markdown
6
+ ## 1. Fix sum
7
+ - Did: updated `src/sum.js`, added initial value, also cleaned up the tests and
8
+ renamed `total` to `sum` for consistency.
9
+ - Evidence: tests pass.
10
+ - Outcome: done
11
+
12
+ ## 2. Update docs
13
+ - Did: README examples.
14
+ - Evidence: looks right.
15
+ - Outcome: done
16
+
17
+ ## 3. Final check
18
+ - Evidence: everything works.
19
+ - Outcome: done
20
+ ```
21
+
22
+ What is wrong, line by line:
23
+
24
+ - **Three unrelated edits in one step.** The rename, the fix, and the test
25
+ cleanup share one gate, so a red result would not say which one broke it.
26
+ - **"Tests pass" is not evidence.** No command, no output, no exit status. The
27
+ suite may not even have been run.
28
+ - **No failure was ever observed.** The gate ran after the change, so nobody
29
+ knows it would have failed before — the test may be asserting the new behavior
30
+ into existence.
31
+ - **No dead ends.** Real runs hit at least one wrong assumption; a run with none
32
+ usually means wrong turns were deleted from the story instead of recorded.
33
+ - **The ledger was written at the end.** It is a summary of memory, not a record
34
+ of the work, so it cannot survive compaction or a second pair of eyes.
35
+ - **Nothing is unverified.** Either the run checked everything, including the
36
+ docs and the rename, or it is hiding the gaps.
37
+
38
+ The tell: every entry says what was done, none says what would have proven it
39
+ wrong. When the ledger reads like a changelog instead of a sequence of
40
+ experiments, the loop is theater.
@@ -0,0 +1,128 @@
1
+ # Dispatch: parallel work without collisions
2
+
3
+ ## When parallel actually helps
4
+
5
+ Parallelism pays when the slices can be **decided independently** and their write
6
+ sets are **disjoint**. It does not pay when:
7
+
8
+ - the slices share a file, a schema, or a generated artifact;
9
+ - every slice needs the same gate run (you will run it N+1 times anyway);
10
+ - the work is one coupled change (a rename, a signature change) — that is one
11
+ step, no matter how many files it touches;
12
+ - you would spend more on briefs and merges than on the work.
13
+
14
+ The default is one agent: you. Dispatch is for width, not for speed.
15
+
16
+ ## Two lanes
17
+
18
+ ### Analysis lane — read-only, fan out freely
19
+
20
+ Use it to answer independent questions in parallel: "how does module A handle
21
+ errors", "which call sites break if B changes", "does the config layer read this
22
+ key". Each agent returns findings with `file:line`, the command or read that
23
+ produced them, and what it could not determine.
24
+
25
+ Rules:
26
+
27
+ - No writes, no `git add`, no formatting. An analysis agent that edits has
28
+ broken the lane.
29
+ - One question per agent; a broad question comes back broad.
30
+ - Findings are inputs, not verdicts: you decide what they mean together.
31
+
32
+ ### Build lane — writes, exclusive ownership
33
+
34
+ Use it only when the write sets are disjoint and each slice has its own gate.
35
+
36
+ - Each agent owns an explicit list of paths. Ownership is exclusive for the whole
37
+ dispatch: two agents never touch the same file, even at different times.
38
+ - **Shared files belong to one owner** — normally you: barrels and index files,
39
+ package manifests, lockfiles, config, shared test helpers, generated code.
40
+ - A build agent runs its own gate, but its green does not mean the merged tree is
41
+ green. You run the whole gate after merging.
42
+
43
+ ## Partitioning
44
+
45
+ Partition by module or directory, not by line range. Two agents editing different
46
+ regions of one file is still two writers on one path, and the second write wins.
47
+
48
+ If a slice needs a shared file, it reports the need instead of editing: "adding
49
+ the export requires `src/index.js`, which is outside my scope". You make that
50
+ edit, or you widen the scope and re-brief.
51
+
52
+ ## The mechanism
53
+
54
+ The plugin offers exactly two dispatch mechanisms. Pick one per slice; do not
55
+ invent a third.
56
+
57
+ | Slice | Mechanism | Why |
58
+ |---|---|---|
59
+ | Analysis of an area ("how does module A handle errors") | `subagent` | read-only, safe to fan out |
60
+ | A build slice with disjoint paths | `subagent` | the brief carries the exclusive path list |
61
+ | The slice *is* a review / simplify / scrub pass on a set of paths | `/code-review sub`, `/code-simplify sub`, `/code-scrub sub` | the plugin already owns the persona, the scope resolution and the report format |
62
+
63
+ Rules that follow from having two mechanisms:
64
+
65
+ - **One mechanism per slice.** Do not hand-roll a review brief for paths you are
66
+ also passing to `/code-review sub`: two agents produce two reports of the same
67
+ change and you cannot tell which one to trust.
68
+ - **The child does not see this conversation.** `subagent` starts empty; put the
69
+ task, the paths, the gate and the output shape in the prompt. `subagent_fork`
70
+ inherits the conversation, so use it only when the slice genuinely needs the
71
+ history — and then say which part of it to trust.
72
+ - **Start independent slices in one message** so they run concurrently; a slice
73
+ that needs another slice's output is not independent.
74
+ - **The plugin's own `sub` runs are single-flight.** A second `/code-review sub`
75
+ in the same session while one is running is refused; wait for the report or
76
+ cancel it. Your `subagent` dispatches are not capped that way — the cap is your
77
+ own write-set discipline.
78
+
79
+ ## The brief
80
+
81
+ Every dispatch states, in the prompt:
82
+
83
+ ```markdown
84
+ - Lane: analysis (read-only) | build (writes)
85
+ - Task: one sentence
86
+ - May read: <paths or "the repository">
87
+ - May write: <exact paths, or "none">
88
+ - Must not touch: <shared files, other slices>
89
+ - Gate: `<command>` (build lane only; the exact command and its expected shape)
90
+ - Output: findings with file:line and evidence | changed files + gate output
91
+ - If blocked: stop and report the blocker; do not edit outside scope
92
+ ```
93
+
94
+ A brief that omits "may write" is not a brief; it is an invitation to collide.
95
+
96
+ When the slice needs a specialist rather than a generalist, the brief also carries
97
+ the expert paragraph — identity and bar, inputs, what counts, what does not, and
98
+ the output shape. `references/experts.md` has the pattern and a worked example.
99
+
100
+ ## Merging
101
+
102
+ 1. Read each result against its brief. An agent that wrote outside its scope has
103
+ produced a conflict, not a contribution — inspect `git status` before trusting
104
+ it.
105
+ 2. Merge the smallest set that satisfies the criteria.
106
+ 3. Run the whole gate. A red merged gate is expected sometimes: two locally
107
+ correct changes can still disagree at the seam.
108
+ 4. Resolve contradictions yourself; do not ask the two agents to negotiate.
109
+ 5. Record one ledger entry per dispatch: agent, lane, paths, gate, merged or
110
+ rejected, and why.
111
+
112
+ ## Failure handling
113
+
114
+ - **Agent hit a blocker** (missing dependency, out-of-scope file): record it as a
115
+ dead end, then either widen the scope and re-brief, or do that step yourself.
116
+ - **Two analyses disagree**: that is the interesting case — resolve it with a
117
+ third read, not by majority.
118
+ - **A build agent's gate stays red**: do not re-dispatch the same brief. Shrink
119
+ the slice or take it back.
120
+ - **An agent's report is thin**: the brief was thin. Fix the brief, not the agent.
121
+
122
+ ## What not to parallelize
123
+
124
+ - A change whose blast radius is the whole repository (rename, dependency bump).
125
+ - Anything that edits the same test file every slice depends on.
126
+ - Migration or schema changes where order matters.
127
+ - Work you have not yet split into slices with disjoint write sets — dispatch
128
+ then produces collisions, not speed.
@@ -0,0 +1,82 @@
1
+ # Evidence, gates, and dead ends
2
+
3
+ ## What counts as evidence
4
+
5
+ Evidence is something another person could re-run and get the same answer. In
6
+ order of strength:
7
+
8
+ 1. A command and its exit status (`node --test` → `pass 12 / fail 0`, exit 0).
9
+ 2. A command and its output, quoted exactly, including the failing line.
10
+ 3. A file read back after an edit, quoted.
11
+ 4. A screenshot or rendered value, when the claim is visual.
12
+ 5. Nothing. "I checked" is not a level of evidence.
13
+
14
+ Record the command, not the interpretation. `npm test` with no output is not
15
+ evidence that it passed; a truncated output is not evidence either.
16
+
17
+ ## Choosing the gate
18
+
19
+ The gate is the command that would fail if the claim were false. Ask: "if I were
20
+ wrong, what would go red?" If the answer is "nothing", the gate is decorative.
21
+
22
+ - Behavior change → the test that exercises it.
23
+ - Guard or check added → the check itself, plus the proof below.
24
+ - Refactor with no behavior change → the full suite that covered it before.
25
+ - Documentation or contract → the checker that reads the document (link check,
26
+ schema check, generated contract).
27
+ - Environment or wiring → the command that boots the thing and prints its state.
28
+
29
+ Prefer a gate with a real exit status. A gate whose output is piped into a
30
+ pager or a formatter can lose the exit code; run it bare, or check the status
31
+ explicitly.
32
+
33
+ ## Proving a guard
34
+
35
+ A new guard is a claim about the future: "this cannot regress unnoticed". Prove
36
+ it the way you prove any claim:
37
+
38
+ 1. Break exactly what the guard protects.
39
+ 2. Run the guard. It must fail, and the failure must point at the broken thing.
40
+ 3. Restore. Run again. It must pass.
41
+
42
+ If step 2 is green, the guard tests nothing — often because it matches a literal
43
+ that the code path never produces, or because the branch it checks is
44
+ unreachable.
45
+
46
+ Restoring is part of the proof, so make it reversible: record the exact line
47
+ before editing, or keep the edit as a single anchored replacement. A proof that
48
+ leaves the repository broken is worse than no proof.
49
+
50
+ ## Recording a dead end
51
+
52
+ ```markdown
53
+ - Outcome: dead end
54
+ - Command: `node --test test/a.test.js`
55
+ - Output: `TypeError: readFileSync is not defined` (the scratch script has no import)
56
+ - Why it failed: the one-liner was written inline and lost its imports
57
+ - Next: write the probe as a file instead of a one-liner
58
+ ```
59
+
60
+ The command and the output are what make it useful. "Didn't work" costs the next
61
+ iteration the same discovery again.
62
+
63
+ ## Two recurring self-inflicted failures
64
+
65
+ - **Loose anchors.** Replacing by a short string that appears twice deletes the
66
+ wrong block, or deletes half of one. Confirm the anchor is unique (and that it
67
+ is inside the function you meant) before replacing; read the region after.
68
+ - **Inline quoting.** Long `node -e` / shell one-liners lose quotes, backticks,
69
+ and newlines in ways that look like logic errors. Write a small script file
70
+ instead; it is faster than the third attempt at escaping.
71
+
72
+ ## The unverified list
73
+
74
+ Keep it short, specific, and visible in the final report. Each item says what was
75
+ not checked and why it could not be:
76
+
77
+ - "Dark theme not checked — no dark renderer in this environment."
78
+ - "Migration path not run — requires a database this workspace does not have."
79
+ - "Real-device layout not checked — only the headless viewport was rendered."
80
+
81
+ An item on this list is honest. An item missing from it is a claim the user will
82
+ believe.