@morning-start/dsh-code-toolkit 0.28.1 → 0.31.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.
@@ -1,128 +1,138 @@
1
1
  # Dispatch: parallel work without collisions
2
2
 
3
- ## When parallel actually helps
3
+ ## What parallel buys, and what it costs
4
4
 
5
- Parallelism pays when the slices can be **decided independently** and their write
6
- sets are **disjoint**. It does not pay when:
5
+ **The test is shape, not cost.** Two or more ready items, disjoint paths, a gate each, and more
6
+ than a one-line edit per slice — that is a wave; dispatch it. One item, shared files, or one gate
7
+ for all of them is not a wave, whatever the size. The costs below decide only whether a wave that
8
+ already passes the shape test should be split *further*.
7
9
 
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.
10
+ Parallelism pays when slices can be **decided independently** and their write sets are
11
+ **disjoint**. It does not pay when:
12
+
13
+ - the slices share a file, a schema or a generated artifact;
14
+ - every slice needs the same gate (you run it N+1 times anyway);
15
+ - the work is one coupled change — a rename, a signature change — however many files it
16
+ touches;
17
+ - the order matters: migrations, schema changes;
18
+ - the slices do not exist yet — dispatch then produces collisions, not speed;
19
+ - the briefs and merges cost more than the work.
13
20
 
14
21
  The default is one agent: you. Dispatch is for width, not for speed.
15
22
 
16
23
  ## Two lanes
17
24
 
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:
25
+ **Analysis — read-only, fan out freely.** Independent questions: "how does module A handle
26
+ errors", "which call sites break if B changes". Each child returns findings with `file:line`
27
+ and what it could not determine. A child that edits has broken the lane. One question per
28
+ child; a broad question comes back broad.
26
29
 
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.
30
+ **Build — writes, exclusive ownership.** Each child owns an explicit path list, exclusive for
31
+ the whole dispatch: two children never touch the same path, even at different times. **Shared
32
+ files belong to one owner** — normally you: barrels, manifests, lockfiles, config, shared test
33
+ helpers, generated code. Partition by module or directory, never by line range: two children
34
+ editing different regions of one file is still two writers on one path, and the second write
35
+ wins. A child that needs a shared file reports the need instead of editing it.
31
36
 
32
- ### Build lane — writes, exclusive ownership
37
+ ## The mechanism
33
38
 
34
- Use it only when the write sets are disjoint and each slice has its own gate.
39
+ | Slice | Mechanism |
40
+ | --- | --- |
41
+ | Analysis of an area | `subagent` |
42
+ | A build slice with disjoint paths | `subagent` |
43
+ | The slice *is* a review / simplify / scrub pass | `/code-review sub`, `/code-simplify sub`, `/code-scrub sub` |
44
+
45
+ - **One mechanism per slice.** Hand-rolling a review brief for paths you also pass to
46
+ `/code-review sub` produces two reports of one change and no way to choose between them.
47
+ - **The child does not see this conversation.** `subagent` starts empty: task, paths, gate and
48
+ output shape go in the prompt. `subagent_fork` inherits history — use it only when the slice
49
+ needs that history, and say which part to trust.
50
+ - **The plugin's own `sub` runs are single-flight.** A second `/code-review sub` in one session
51
+ is refused while one runs; wait for the report or cancel. Your `subagent` dispatches are not
52
+ capped that way — the cap is your write-set discipline.
53
+ - **`workflow` has a bar**: the person explicitly asks for a workflow, or the wave is large
54
+ enough that hand-dispatch stops paying. Below it, a script to write and debug costs more than
55
+ three `subagent` calls.
56
+ - A **delegated child is refused** `subagent`, `workflow`, the messaging tools and the schedule
57
+ tools, and cannot read or change reminders. A slice that needs sub-slices is two waves from
58
+ here.
59
+
60
+ ## Waves and the dispatch table
61
+
62
+ The plan decides what runs together: an item is **ready** when every number in its `deps` is
63
+ `[x]` and it has no `owner`. One wave is the ready items with disjoint write sets. If two items
64
+ look independent but neither can name the other's gate, they are not a wave.
65
+
66
+ The root writes the table; children never do — the ledger is a shared file, and two writers on
67
+ it is exactly the collision this page is about:
35
68
 
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.
69
+ ```markdown
70
+ ## Dispatch
71
+ | child | lane | paths | gate | state | entry |
72
+ | --- | --- | --- | --- | --- | --- |
73
+ | agent-import | build | src/import/** | `node --test test/import` | running | — |
74
+ | agent-copy | analysis | src/, docs/ | — | returned | 4 |
75
+ ```
42
76
 
43
- ## Partitioning
77
+ `owner` goes on the plan item in the same edit as the row: that is what tells a resumed run to
78
+ collect instead of dispatching again. `state` runs `running` → `returned` → `merged`, or
79
+ `failed` with the reason; `entry` is the entry number that recorded the result.
44
80
 
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.
81
+ ## Running a wave
47
82
 
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.
83
+ 1. **Write the rows and the owners first, then dispatch.** A child that finishes before you
84
+ recorded it is a result you re-derive tomorrow.
85
+ 2. **Dispatch in one message** so they run concurrently.
86
+ 3. **Do your own item while they run.** A wave you block on is a serial loop with extra steps.
87
+ 4. **Collect with `wait_agent`**; `list_agents` says who is still running, `send_message` steers
88
+ a drifting child instead of killing it.
89
+ 5. **Merge, then prove.** Run the whole gate on the merged tree yourself, record one entry, tick
90
+ the items with it, and move the owners to `merged`.
51
91
 
52
- ## The mechanism
92
+ **Caps, because context is the real budget:** at most three children per wave, and every brief
93
+ requires a report of at most 20 lines. A six-page report costs what doing the work costs and
94
+ teaches less.
53
95
 
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.
96
+ **A failed child is read, not ignored.** `failed` with the gate output goes in the row; the item
97
+ keeps its `owner` only if you re-dispatch the same child, otherwise clear the owner and reopen
98
+ it. A partial result is `[~]` with the blocker, never `[x]`.
78
99
 
79
100
  ## The brief
80
101
 
81
- Every dispatch states, in the prompt:
82
-
83
102
  ```markdown
84
103
  - Lane: analysis (read-only) | build (writes)
85
104
  - Task: one sentence
86
105
  - May read: <paths or "the repository">
87
106
  - May write: <exact paths, or "none">
88
107
  - Must not touch: <shared files, other slices>
89
- - Gate: `<command>` (build lane only; the exact command and its expected shape)
108
+ - Gate: `<command>` (build lane only, with its expected shape)
90
109
  - Output: findings with file:line and evidence | changed files + gate output
91
- - If blocked: stop and report the blocker; do not edit outside scope
110
+ - If blocked: stop and report; do not edit outside scope
92
111
  ```
93
112
 
94
- A brief that omits "may write" is not a brief; it is an invitation to collide.
113
+ A brief without "may write" is an invitation to collide. When the slice needs a specialist, the
114
+ brief also carries the expert paragraph — `references/experts.md` has the pattern and a worked
115
+ example.
116
+
117
+ Two things the brief must carry that are easy to forget, both found in a live run:
95
118
 
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.
119
+ - **Every constraint you were given for yourself.** If the work may not run git, or add a
120
+ dependency, or leave the tree, the child needs that sentence too. It inherits your words, not
121
+ your instructions — a run that banned git for itself still had two children run `git status`,
122
+ because the brief never said it.
123
+ - **The command, not an expected count.** "`npm run test:alpha`" is checkable; "expect pass 3" is
124
+ a guess the child has to correct for you — both children in that run did, and were right.
99
125
 
100
126
  ## Merging
101
127
 
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.
128
+ 1. Read each result against its brief; an agent that wrote outside its scope made a conflict,
129
+ not a contribution — check `git status` before trusting it.
105
130
  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.
131
+ 3. Run the whole gate. A red merged gate is normal: two locally correct changes can disagree at
132
+ the seam. Resolve it yourself — do not ask the two children to negotiate.
133
+ 4. Record one entry per dispatch: agent, lane, paths, gate, merged or rejected, and why.
134
+
135
+ The rest is a decision, not a retry: a blocker means record the dead end and either widen the
136
+ scope or do it yourself; two analyses that disagree are settled by a third read, not a
137
+ majority; a build child whose gate stays red gets a smaller slice, not the same brief again; a
138
+ thin report means the brief was thin.
@@ -2,8 +2,7 @@
2
2
 
3
3
  ## What counts as evidence
4
4
 
5
- Evidence is something another person could re-run and get the same answer. In
6
- order of strength:
5
+ Evidence is something another person could re-run and get the same answer. In order of strength:
7
6
 
8
7
  1. A command and its exit status (`node --test` → `pass 12 / fail 0`, exit 0).
9
8
  2. A command and its output, quoted exactly, including the failing line.
@@ -11,41 +10,35 @@ order of strength:
11
10
  4. A screenshot or rendered value, when the claim is visual.
12
11
  5. Nothing. "I checked" is not a level of evidence.
13
12
 
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.
13
+ Record the command, not the interpretation. `npm test` with no output does not prove it passed; a
14
+ truncated output proves nothing.
16
15
 
17
16
  ## Choosing the gate
18
17
 
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.
18
+ The gate is the command that would fail if the claim were false. Ask "if I were wrong, what would
19
+ go red?" — if the answer is "nothing", the gate is decorative.
21
20
 
22
21
  - 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).
22
+ - Guard added → the check itself, plus the proof below.
23
+ - Refactor with no behavior change → the suite that covered it before.
24
+ - Documentation or contract → the checker that reads the document.
27
25
  - Environment or wiring → the command that boots the thing and prints its state.
28
26
 
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.
27
+ Prefer a real exit status: a gate piped into a pager or a formatter can lose it. Run it bare, or
28
+ check the status explicitly.
32
29
 
33
30
  ## Proving a guard
34
31
 
35
- A new guard is a claim about the future: "this cannot regress unnoticed". Prove
36
- it the way you prove any claim:
32
+ A new guard is a claim about the future. Prove it the way you prove any claim:
37
33
 
38
34
  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.
35
+ 2. Run it. It must fail, and the failure must point at the broken thing.
36
+ 3. Restore, run again: it must pass.
41
37
 
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.
38
+ A green step 2 means the guard tests nothing — often it matches a literal the code never produces,
39
+ or the branch it checks is unreachable. Make restoring part of the proof: record the exact line
40
+ before editing, or keep the edit as one anchored replacement. A proof that leaves the repository
41
+ broken is worse than none.
49
42
 
50
43
  ## Recording a dead end
51
44
 
@@ -57,23 +50,22 @@ leaves the repository broken is worse than no proof.
57
50
  - Next: write the probe as a file instead of a one-liner
58
51
  ```
59
52
 
60
- The command and the output are what make it useful. "Didn't work" costs the next
61
- iteration the same discovery again.
53
+ The command and the output are what make it useful. "Didn't work" costs the next iteration the same
54
+ discovery.
62
55
 
63
56
  ## Reach the real entry point
64
57
 
65
- A gate proves the thing you named. It does not prove the feature a person starts.
66
- When the change touches an entry point — a command, a route, a screen, a scheduled
67
- job — one iteration must go through it the way a person does:
58
+ A gate proves the thing you named, not the feature a person starts. When the change touches an
59
+ entry point — a command, a route, a screen, a scheduled job — one iteration goes through it the way
60
+ a person does:
68
61
 
69
- - **the real entry point**, not the module the test imports: type the command, open
70
- the screen, call the route;
71
- - **real data**, not only the fixture: a document with history, a project with a
72
- ledger, an input with the awkward characters;
73
- - **look at the result**: what was printed, what the state is now, whether the effect
74
- survived the process. A screenshot is fine; it does not replace the state.
62
+ - **the real entry point**, not the module a test imports: type the command, open the screen, call
63
+ the route;
64
+ - **real data**, not only the fixture: a document with history, an input with awkward characters;
65
+ - **look at the result**: what printed, what the state is now, whether the effect survived the
66
+ process. A screenshot is fine; it does not replace the state.
75
67
 
76
- Record it like any other evidence — what you did, what you expected, what happened:
68
+ Record it like any evidence:
77
69
 
78
70
  ```markdown
79
71
  - Command: `node src/app.js export 3`
@@ -82,47 +74,39 @@ Record it like any other evidence — what you did, what you expected, what happ
82
74
  - State: export → fake; the renderer test passes but nothing reaches it
83
75
  ```
84
76
 
85
- If the environment cannot run the entry point — no browser, no server, no device —
86
- say that in the unverified list. "The tests pass" is then the whole claim, and it
87
- should be the whole sentence.
77
+ If the environment cannot run the entry point — no browser, server or device — that goes in the
78
+ unverified list, and "the tests pass" is then the whole claim.
88
79
 
89
80
  ## Assumptions about the host
90
81
 
91
- Anything you believe about the host, the platform, or a third party is a claim. The
92
- cheap way to settle one is a probe, and one probe usually answers several questions.
82
+ Anything you believe about the host, the platform or a third party is a claim. One probe usually
83
+ settles several.
93
84
 
94
- - **Read the installed code first.** The version in `node_modules` or in the running
95
- application beats the documentation, which beats your memory.
96
- - **Probe when reading is not enough.** The smallest script that prints the fact you
97
- need: does the API accept this shape, does the event fire with these fields, does
98
- the path resolve on this platform. Keep the probe file; a second question usually
99
- arrives.
100
- - **Record the answer with the question**, e.g. `steer()` rejects a partial message
101
- → `Error: message.id is required`. That line is what stops the next iteration from
102
- re-deriving it.
103
- - **Until it runs, it is unverified.** Put it in the unverified list with the batch
104
- that depends on it, rather than building three steps on top of a guess.
85
+ - **Read the installed code first.** The version in `node_modules` or inside the running application
86
+ beats the documentation, which beats your memory.
87
+ - **Probe when reading is not enough.** The smallest script that prints the fact: does the API
88
+ accept this shape, does the event fire with these fields, does the path resolve here. Keep the
89
+ probe file — a second question usually arrives.
90
+ - **Record the answer with the question**, e.g. `steer()` rejects a partial message →
91
+ `Error: message.id is required`. That line stops the next iteration from re-deriving it.
92
+ - **Until it runs, it is unverified.** Put it in the unverified list with the batch that depends on
93
+ it, rather than building three steps on a guess.
105
94
 
106
- A design or a plan that rests on an unrun assumption is not wrong to exist; it is
107
- wrong to be reported as settled.
95
+ A plan resting on an unrun assumption is fine; reporting it as settled is not.
108
96
 
109
97
  ## Two recurring self-inflicted failures
110
98
 
111
- - **Loose anchors.** Replacing by a short string that appears twice deletes the
112
- wrong block, or deletes half of one. Confirm the anchor is unique (and that it
113
- is inside the function you meant) before replacing; read the region after.
114
- - **Inline quoting.** Long `node -e` / shell one-liners lose quotes, backticks,
115
- and newlines in ways that look like logic errors. Write a small script file
116
- instead; it is faster than the third attempt at escaping.
99
+ - **Loose anchors.** Replacing by a string that appears twice deletes the wrong block, or half of
100
+ one. Confirm the anchor is unique and inside the function you meant; read the region afterwards.
101
+ - **Inline quoting.** Long `node -e` or shell one-liners lose quotes, backticks and newlines in ways
102
+ that look like logic errors. Write a script file; it is faster than the third escaping attempt.
117
103
 
118
104
  ## The unverified list
119
105
 
120
- Keep it short, specific, and visible in the final report. Each item says what was
121
- not checked and why it could not be:
106
+ Short, specific, visible in the final report — each item says what was not checked and why:
122
107
 
123
108
  - "Dark theme not checked — no dark renderer in this environment."
124
109
  - "Migration path not run — requires a database this workspace does not have."
125
110
  - "Real-device layout not checked — only the headless viewport was rendered."
126
111
 
127
- An item on this list is honest. An item missing from it is a claim the user will
128
- believe.
112
+ An item on this list is honest. An item missing from it is a claim the user will believe.
@@ -1,51 +1,46 @@
1
1
  # Writing an expert
2
2
 
3
- An expert is a paragraph in a brief, not a file. It has one job: make a child
4
- agent that cannot see this conversation behave like a specialist instead of a
5
- generalist who happened to be handed a task.
3
+ An expert is a paragraph in a brief, not a file. Its job: make a child that cannot see this
4
+ conversation behave like a specialist instead of a generalist who happened to be handed a task.
6
5
 
7
- The failure mode is always the same. A vague brief gets a vague answer, the
8
- parent reads it as "nothing found", and the slice is quietly unverified. The
9
- expert paragraph is what prevents that.
6
+ **Why not the host's equivalent.** DSH does compose agents — the agent preset — but a preset is
7
+ user-level configuration chosen before a session starts, not something a running loop can create
8
+ for one slice. A paragraph goes in that child's brief, applies to that child only, and dies with
9
+ it. Do not write a persona file for an expert; nothing would load it.
10
+
11
+ The failure mode is always the same: a vague brief gets a vague answer, the parent reads it as
12
+ "nothing found", and the slice is quietly unverified.
10
13
 
11
14
  ## The five parts
12
15
 
13
- Every expert description has these, in this order. Omit one and the child fills
14
- the gap with its own defaults.
15
-
16
- 1. **Identity and bar.** Who it is and what standard it holds. Not "you are a
17
- senior engineer" — that is a costume. "You audit migrations for irreversible
18
- operations; a migration that cannot be rolled back is a defect, not a
19
- preference" is a bar.
20
- 2. **What it looks at.** The exact inputs: which paths, which files, which
21
- commands. A specialist is defined by its inputs more than by its adjectives.
22
- 3. **What counts as a finding.** The criteria, with the threshold spelled out.
23
- "Flag any `ALTER` that drops a column or narrows a type" beats "look for
24
- risky migrations".
25
- 4. **What is not a finding.** The exclusion list. This is the part people skip,
26
- and it is the part that decides whether the report is usable. Name the
27
- tempting false positives explicitly.
28
- 5. **Output shape.** One line per finding, or a table, or a verdict plus
29
- evidence. Fixed shape, so the parent can merge N experts without reading N
30
- essays.
16
+ In this order. Omit one and the child fills the gap with its own defaults.
17
+
18
+ 1. **Identity and bar.** Who it is and what standard it holds. Not "you are a senior engineer" —
19
+ that is a costume. "You audit migrations for irreversible operations; a migration that cannot
20
+ be rolled back is a defect, not a preference" is a bar.
21
+ 2. **What it looks at.** The exact inputs: paths, files, commands. A specialist is defined by its
22
+ inputs more than by its adjectives.
23
+ 3. **What counts as a finding.** The criteria with the threshold spelled out. "Flag any `ALTER`
24
+ that drops a column or narrows a type" beats "look for risky migrations".
25
+ 4. **What is not a finding.** The exclusion list. People skip it, and it decides whether the report
26
+ is usable — name the tempting false positives explicitly.
27
+ 5. **Output shape.** One line per finding, or a table, or a verdict plus evidence. Fixed, so the
28
+ parent can merge N experts without reading N essays.
31
29
 
32
30
  ## Rules that make an expert usable
33
31
 
34
- - **One question.** An expert that is asked two things answers the easier one.
35
- If the slice needs two questions, that is two experts.
36
- - **Give it the evidence path, not the answer.** "Check whether `resolve()` can
37
- return null by reading its callers" produces work. "Is there a null bug?"
38
- produces a guess.
39
- - **State the bar, not the vibe.** "Be thorough" and "be careful" are not
40
- instructions a model can follow; a threshold is.
41
- - **Name the false positives.** The expert should know what a plausible-looking
42
- non-finding looks like in this codebase, or it will report them.
43
- - **Make the output copy-pasteable.** The parent merges by reading; a shape that
44
- cannot be merged is a shape that will be summarized badly.
45
- - **No delegation.** The expert reports; it does not spawn. Depth is the
46
- parent's decision, not the child's.
47
- - **Read-only unless stated.** An expert that writes needs an explicit path
48
- list; without one it reports.
32
+ - **One question.** An expert asked two things answers the easier one; two questions are two
33
+ experts. Keep the question small enough that its answer fits on a screen.
34
+ - **Give it the evidence path, not the answer.** "Check whether `resolve()` can return null by
35
+ reading its callers" produces work; "is there a null bug?" produces a guess.
36
+ - **State the bar, not the vibe.** "Be thorough" is not an instruction a model can follow; a
37
+ threshold is.
38
+ - **Make the output copy-pasteable.** The parent merges by reading; a shape that cannot be merged
39
+ will be summarized badly.
40
+ - **No delegation.** The expert reports; it does not spawn. Depth is the parent's decision.
41
+ - **Read-only unless stated.** An expert that writes needs an explicit path list; without one it
42
+ reports. Shared files stay with the parent.
43
+ - **Two to four in parallel** is the useful range — past that the briefs cost more than the work.
49
44
 
50
45
  ## A worked example
51
46
 
@@ -74,31 +69,20 @@ rolled back>`. If nothing qualifies, output `no findings` and the commands you
74
69
  ran. Do not edit anything.
75
70
  ```
76
71
 
77
- The difference is not length. The weak version leaves the child to invent the
78
- bar, the inputs, the threshold and the shape; the strong one leaves it only the
79
- work.
72
+ The difference is not length. The weak version leaves the child to invent the bar, the inputs, the
73
+ threshold and the shape; the strong one leaves it only the work.
80
74
 
81
75
  ## When to create one mid-run
82
76
 
83
- An expert is worth creating the moment a step needs knowledge the loop does not
84
- have. The signals:
85
-
86
- - **An unfamiliar subsystem.** You can read it, but reading it well would take
87
- longer than briefing someone who only reads it.
88
- - **A domain rule you cannot verify from the code.** A wire format, a schema, a
89
- regulation, a third-party contract. The expert's job is to state the rule and
90
- where it comes from, not to guess.
91
- - **Width.** Five modules need the same question answered; one expert per module
92
- finishes in the time one expert takes to do all five.
93
- - **A second pair of eyes on a risky change** — but only for the change, not as
94
- a vote on your reasoning.
77
+ The moment a step needs knowledge the loop does not have. The signals: an unfamiliar subsystem
78
+ where reading it well takes longer than briefing someone who only reads it; a domain rule you
79
+ cannot verify from the code (a wire format, a schema, a regulation) — the expert states the rule
80
+ and where it came from, it does not guess; width, where five modules need the same question; a
81
+ second pair of eyes on a risky change, for the change only, not as a vote on your reasoning.
95
82
 
96
- The signals that it is **not** worth it:
97
-
98
- - The next step is one file you have already read.
99
- - You would spend more time writing the brief than doing the work.
100
- - You are using the expert to avoid deciding something you already know.
101
- - The slice has no boundary you can state in paths.
83
+ Not worth it when: the next step is one file you already read; the brief would cost more than the
84
+ work; you are using the expert to avoid deciding something you already know; the slice has no
85
+ boundary you can state in paths.
102
86
 
103
87
  ## The lifecycle of an expert
104
88
 
@@ -107,35 +91,24 @@ brief (in the ledger) → dispatch → work in parallel → merge against the br
107
91
  → run the whole gate → record the entry
108
92
  ```
109
93
 
110
- Each arrow is a place where the run can fail quietly:
94
+ Each arrow is a place where the run fails quietly:
111
95
 
112
96
  | Stage | The quiet failure | The check that catches it |
113
97
  |---|---|---|
114
98
  | brief | vague bar, no exclusion list | can you name what it must *not* report? |
115
- | dispatch | two experts on one path | every path in the brief is disjoint from every other |
99
+ | dispatch | two experts on one path | every path is disjoint from every other |
116
100
  | work | the expert edits outside its scope | `git status` before you trust the result |
117
- | merge | you accept a claim without its evidence | every finding cites a file:line and a command |
101
+ | merge | a claim accepted without its evidence | every finding cites a file:line and a command |
118
102
  | gate | per-expert green, merged red | you run the whole gate yourself |
119
- | record | the same bad brief reused | the ledger entry names the expert and the outcome |
120
-
121
- ## Sizing
122
-
123
- - **One expert per question**, and a question small enough that its answer fits
124
- in a screen. If the answer would need a section, split it.
125
- - **Two to four experts in parallel** is the useful range. Past that the briefs
126
- cost more than the work, and the merge becomes the bottleneck.
127
- - **The parent keeps the shared files.** Experts read them; the parent writes
128
- them. An expert that needs a shared file edited reports the need.
103
+ | record | the same bad brief reused | the entry names the expert and the outcome |
129
104
 
130
105
  ## What the ledger records
131
106
 
132
- One line per dispatch, with the expert's name so the next iteration can tell
133
- which expert was wrong:
107
+ One line per dispatch, naming the expert so the next iteration can tell which one was wrong:
134
108
 
135
109
  ```markdown
136
110
  - Dispatch: migration-auditor (analysis, migrations/**, read-only) → 3 findings, merged 2
137
111
  ```
138
112
 
139
- If an expert's findings keep getting rejected at merge, the expert paragraph is
140
- wrong, not the child. Fix the bar or the exclusion list, and say which in the
141
- next entry.
113
+ If an expert's findings keep getting rejected at merge, the paragraph is wrong, not the child. Fix
114
+ the bar or the exclusion list, and say which in the next entry.