@morning-start/dsh-code-toolkit 0.29.0 → 0.30.1
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.
- package/CHANGELOG.md +88 -0
- package/README.md +55 -0
- package/agents/caption/AGENT.md +49 -46
- package/agents/caption/references/dispatch.md +103 -93
- package/agents/caption/references/evidence.md +48 -64
- package/agents/caption/references/experts.md +51 -78
- package/agents/caption/references/flows.md +51 -57
- package/agents/caption/references/loop.md +106 -123
- package/agents/design/AGENT.md +2 -1
- package/agents/scrub/AGENT.md +2 -1
- package/agents/simplify/AGENT.md +3 -1
- package/index.js +45 -2
- package/package.json +1 -1
- package/src/caption.js +18 -3
- package/src/command.js +71 -1
- package/src/i18n.js +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,93 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.30.1 — 2026-12-04
|
|
4
|
+
|
|
5
|
+
`0.30.0` was cut but never tagged; the caption goal fix below rides with it, so the line ships as
|
|
6
|
+
a patch.
|
|
7
|
+
|
|
8
|
+
- **An injected run's decision rules now live in a system section, not only in the message.** The
|
|
9
|
+
persona was delivered to the current session as one steered user message (`src/command.js`),
|
|
10
|
+
while an isolated child gets a system-prompt section (`src/runtime.js`) — the same protocol at
|
|
11
|
+
two very different strengths. In a long session the message competes with everything else, and
|
|
12
|
+
a compaction can summarize it away; the second run of a command injects only a one-line "the
|
|
13
|
+
protocol is already installed", so the rules survive on nothing. `inject()` now also installs a
|
|
14
|
+
`CODE_TOOLKIT_PROTOCOL` section carrying the two decisions a run makes about itself — when the
|
|
15
|
+
plan warrants a goal, and when the ready items warrant a wave — replacing its own section on a
|
|
16
|
+
later run instead of stacking copies, and falling back silently on a host without the service.
|
|
17
|
+
The receipt ends with a suffix when the section was installed, so the person can see which
|
|
18
|
+
carrier their session actually got. This is the likely reason a live run dispatched two
|
|
19
|
+
children while a real session never opened a goal.
|
|
20
|
+
- **The two autonomy triggers are shape predicates now, and a live run confirmed the dispatch
|
|
21
|
+
one.** "Open a goal when the person asked the work to run to completion" waited for a phrase a
|
|
22
|
+
plain task never contains; "dispatch when the briefs cost less than the work" was an estimate
|
|
23
|
+
that always came out negative. Both now read the plan: **three or more items, or criteria no
|
|
24
|
+
single iteration can prove**, opens a goal; **two or more ready items with disjoint paths, a
|
|
25
|
+
gate each and more than a one-line edit** is a wave. In run 4 — same fixture shape, nothing in
|
|
26
|
+
the prompt about agents or goals — caption dispatched two children in one message, wrote both
|
|
27
|
+
rows and owners before the first call, collected with `wait_agent`, and re-ran the merged gate
|
|
28
|
+
itself (10/10). `list_agents` still lists both grandchildren, so the split is verified by the
|
|
29
|
+
tree rather than by the report. It also decided on its own that a goal was warranted and called
|
|
30
|
+
`create_goal` — refused, because a delegated child cannot hold one. Both children then corrected
|
|
31
|
+
the parent's brief (a guessed test count, and a git ban it applied to itself but never passed
|
|
32
|
+
down), which are now two brief rules in `references/dispatch.md`.
|
|
33
|
+
- **The caption protocol was run for real, three times, on fixtures that genuinely fail.** A
|
|
34
|
+
delegated child with an empty context, given only the persona and a task, produced ledgers with
|
|
35
|
+
plans, dependencies, dispatch tables and entries carrying exit codes; it proved its guards by
|
|
36
|
+
breaking them; it wrote probe scripts to check documentation claims and deleted them after. Two
|
|
37
|
+
runs correctly *declined* to dispatch (both slices behind one gate), and the third dispatched two
|
|
38
|
+
children in one message, recorded both rows and owners **before** the first `subagent` call,
|
|
39
|
+
collected with `wait_agent`, and re-ran the merged gate itself. `list_agents` afterwards still
|
|
40
|
+
showed both grandchildren, so the dispatch is verified by the tree rather than by the report.
|
|
41
|
+
**`create_goal` is structurally unavailable to a delegated child** — three attempts, one error:
|
|
42
|
+
`this goal operation requires a direct human turn on a top-level agent` — which means the goal
|
|
43
|
+
tier only exists in-session, and that half of the protocol remains unmeasured. See
|
|
44
|
+
`evals/results/iteration-13.md`.
|
|
45
|
+
- **`docs/tooling-map.md`: every module against the host's own services and tools.** The scan
|
|
46
|
+
found one class of mistake repeated across personas — a mechanism described in our words when
|
|
47
|
+
the host has a tool — and one class of mistake waiting to happen: telling a persona to spawn a
|
|
48
|
+
child the plugin already spawned. `design` now asks its three questions with
|
|
49
|
+
`ask_user_question` instead of prose, `simplify` and `scrub` mirror their item lists into
|
|
50
|
+
`todo_write`, and the caption approval gate is named as a three-option question. Five
|
|
51
|
+
candidates were considered and refused with reasons (`ctx.approval` is a permission policy, not
|
|
52
|
+
a design decision; `ctx.workspaceChanges` records turn diffs, not branch scopes;
|
|
53
|
+
`ctx.actionCards` is a UI projection; `ctx.agentTeams` is a board for the Lead session;
|
|
54
|
+
`ctx.workflowEngine` is the engine under `workflow`, not a protocol). A test now fails if any
|
|
55
|
+
of `review` / `simplify` / `scrub` starts naming `subagent`.
|
|
56
|
+
- **The caption reference pages are 18% smaller and one of them was broken.** `dispatch.md`
|
|
57
|
+
merged its two overlapping "when not to parallelize" lists into one and moved the child-failure
|
|
58
|
+
rules next to the wave they belong to; `loop.md` dropped the section that restated the plan
|
|
59
|
+
format; `experts.md` merged sizing into its rules. Two real defects fell out of the pass:
|
|
60
|
+
`flows.md` had a paragraph inserted **inside** Flow A's table, splitting it into two, and
|
|
61
|
+
`experts.md` had lost its lifecycle heading to an earlier merge. 37 520 → 30 693 characters.
|
|
62
|
+
- **Every mechanism that the host already provides now uses the host's tool.** The sweep
|
|
63
|
+
found three of ours standing in for one of theirs: the clarification questions now go
|
|
64
|
+
through `ask_user_question`, `workflow` is documented as the official orchestrator with its
|
|
65
|
+
bar (explicit request, or a wave big enough that hand-dispatch stops paying), and the
|
|
66
|
+
unattended case is no longer a rule of ours — `schedule_create` is the official mechanism,
|
|
67
|
+
and it is bounded by what the installed `docs/user/guide/schedule.md` promises: a delivery
|
|
68
|
+
proves the message reached the inbox, **not that the model did the work**; exactly-once is
|
|
69
|
+
not guaranteed; closing the Host discards a message still waiting; a child is refused by
|
|
70
|
+
the schedule tools. So a run is scheduled only when the person asks, and carries a stop
|
|
71
|
+
condition. The ledger stays ours because the host has no cross-session plan store —
|
|
72
|
+
`todo_write` dies with the session and a resumed goal comes back disarmed.
|
|
73
|
+
- **The caption plan is a dependency graph, not a flat list.** Items take `| deps: 2,3` and
|
|
74
|
+
`| owner: <child>`; `src/caption.js` parses both and derives `ready` (deps all done, no
|
|
75
|
+
owner) and `inFlight` (open with an owner), so "what is next" is computed instead of felt.
|
|
76
|
+
`list` and `/code-status` show it: `计划 2/5 · 1 项在飞`.
|
|
77
|
+
- **Dispatch is recorded, and runs in waves.** The ledger gains a `## Dispatch` table
|
|
78
|
+
(child / lane / paths / gate / state / entry) that only the root writes. A wave is the
|
|
79
|
+
ready items with disjoint write sets, capped at three children, each required to answer in
|
|
80
|
+
at most twenty lines. Dispatch, do your own item, collect with `wait_agent`, then run the
|
|
81
|
+
whole gate on the merged tree yourself — a child's green is not the merged tree's green.
|
|
82
|
+
Children still cannot fan out (the plugin already denies delegation tools); a slice that
|
|
83
|
+
needs sub-slices is two waves.
|
|
84
|
+
- **A long run continues in two states, not three.** Same session: the goal keeps running.
|
|
85
|
+
Resumed session: the goal comes back disarmed, so `update_goal resume` and then read the
|
|
86
|
+
ledger before touching an item. Unattended: **not part of this protocol** — the loop never
|
|
87
|
+
schedules its own continuation, because a scheduled prompt arrives as a message from a
|
|
88
|
+
person who is not watching. The ledger is what survives the session; the clock is theirs.
|
|
89
|
+
- 134 → 136 deterministic checks.
|
|
90
|
+
|
|
3
91
|
## 0.29.0 — 2026-11-29
|
|
4
92
|
|
|
5
93
|
- **"Propose, then act" is now the shared spine of every command that changes files.**
|
package/README.md
CHANGED
|
@@ -83,6 +83,17 @@ DeepSeek Harness 的代码工具箱:**审查**、**精炼**、**隐私清理**
|
|
|
83
83
|
|
|
84
84
|
统一的好处是行为一致:都立刻返回、都先定范围、失败都发一条说明、都写 journal;差异只留在声明里,不再散落在每个 handler 中。测试会检查 `index.js` 里没有直接 `ctx.commands.register`——绕开外壳就等于又写了一遍。
|
|
85
85
|
|
|
86
|
+
## 和宿主的分工
|
|
87
|
+
|
|
88
|
+
这个插件不重造宿主已经有的东西。两类替代,不能混:
|
|
89
|
+
|
|
90
|
+
- **(S)服务**:插件代码做的事,宿主有服务 → 直接调。命令注册 `ctx.commands`、隔离运行 `ctx.subagents`、persona 注入 `ctx.systemPrompt`、子 agent 工具限制 `ctx.tools.restrict`、语言 `settings`。
|
|
91
|
+
- **(T)工具**:模型做的事,宿主有工具 → persona 里只写工具名,不写怎么做。续跑用 `create_goal`、进度用 `todo_write`、派工用 `subagent` / `wait_agent`、提问用 `ask_user_question`、大规模编排用 `workflow`、无人值守用 `schedule_create`。
|
|
92
|
+
|
|
93
|
+
一条容易搞反的推论:**插件已经派出去的孩子,不能再被告知去派**。`review sub` / `simplify sub` / `scrub sub` 是 `src/runtime.js` 派的,它们的 persona 里不能出现 `subagent`,否则孩子会在刚建好的隔离里再扇出。只有跑在你自己会话里的 `/code-caption` 才派工。
|
|
94
|
+
|
|
95
|
+
每个功能模块对着哪个宿主机制、哪些候选被否掉(以及为什么),在 [docs/tooling-map.md](docs/tooling-map.md)。
|
|
96
|
+
|
|
86
97
|
## 提示词不是两个文件
|
|
87
98
|
|
|
88
99
|
`agents/` 按 skill 的三层结构组织,而不是把全部规则塞进一个 prompt:
|
|
@@ -216,6 +227,50 @@ caption 不是「你给任务,它照着做」。你给的是一句**意图**
|
|
|
216
227
|
|
|
217
228
|
改计划是常态而不是失败:调查出结果后加、拆、删、重排都行,但每次都要写清是哪一条、为什么。一条**永远没被改过**的计划,说明调查没发现任何东西。
|
|
218
229
|
|
|
230
|
+
### 编排:依赖图 + 派工表
|
|
231
|
+
|
|
232
|
+
计划不是平铺清单,是**依赖图**。每项可以带两个字段,于是「下一项」是算出来的,不是感觉出来的:
|
|
233
|
+
|
|
234
|
+
```markdown
|
|
235
|
+
## Plan
|
|
236
|
+
- [x] 1. 复现失败 — gate: `node --test` 点名 `sum([])`(见条目 1)
|
|
237
|
+
- [ ] 2. 钉住契约 — gate: 新测试在旧代码上通过 | deps: 1
|
|
238
|
+
- [ ] 3. 修空输入 — gate: `sum([])` 为 0 | deps: 2
|
|
239
|
+
- [ ] 4. 修导出入口 — gate: 真实导出一次 | deps: 2 | owner: agent-import
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
`deps` 全绿且没有 `owner` 的项=**可做**;同一波里互不冲突的可做项并行。`owner` 在派出去的那一刻写上,结果记完清除——续跑的人看到它就知道该**收**,不是该**再派**。
|
|
243
|
+
|
|
244
|
+
派工本身也进台账,只有根 agent 写:
|
|
245
|
+
|
|
246
|
+
```markdown
|
|
247
|
+
## Dispatch
|
|
248
|
+
| child | lane | paths | gate | state | entry |
|
|
249
|
+
| --- | --- | --- | --- | --- | --- |
|
|
250
|
+
| agent-import | build | src/import/** | `node --test test/import` | running | — |
|
|
251
|
+
| agent-copy | analysis | src/, docs/ | — | returned | 4 |
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
四条规矩:**分析线只读可以扇出;实现线每个孩子独占一组路径**(含台账在内的共享文件只属于根);**派工→自己干一项→`wait_agent` 收齐→根在合并后的树上跑全量门禁**,孩子的绿不等于合并后的绿;**孩子不许再派**(插件已禁委派类工具)。每波最多三个孩子,每份报告不超过 20 行——上下文才是真的预算。
|
|
255
|
+
|
|
256
|
+
用的是 DSH 官方工具:`subagent` / `subagent_fork` 派,`wait_agent` 收,`list_agents` 看谁还在跑,`send_message` 纠偏。
|
|
257
|
+
|
|
258
|
+
### 官方机制优先,缺的自己补
|
|
259
|
+
|
|
260
|
+
caption 里凡是能交给宿主的,都交给宿主;只有宿主没有的才自己造:
|
|
261
|
+
|
|
262
|
+
| 能力 | 用谁的 | 说明 |
|
|
263
|
+
|---|---|---|
|
|
264
|
+
| 续跑 / 收口 / 卡住 | **官方** `create_goal` / `update_goal` | 迭代引擎是宿主的,六阶段只是每一轮的内容 |
|
|
265
|
+
| 实时进度 | **官方** `todo_write` | 台账的投影,不是第二份计划 |
|
|
266
|
+
| 派 / 收 / 看 / 纠偏 | **官方** `subagent`、`wait_agent`、`list_agents`、`send_message` | 孩子不能再派,也不能碰定时任务 |
|
|
267
|
+
| 大规模编排 | **官方** `workflow` | 只在明确要求「workflow」或波次很大时用 |
|
|
268
|
+
| 提问 | **官方** `ask_user_question` | 方案说不清时问那两三个问题 |
|
|
269
|
+
| 无人值守 | **官方** `schedule_create` | 保证弱:不保证执行、可能重复、关掉 Host 会丢,所以由人创建并带停止条件 |
|
|
270
|
+
| 计划 / 依赖 / 派工记录 | **自己的台账** | 宿主没有跨会话的计划存储,这是唯一必须自造的 |
|
|
271
|
+
|
|
272
|
+
最后一行是被动选择,不是偷懒:`todo_write` 随会话消失,goal 重开就被 disarm,只有仓库里的台账能跨会话、跨机器、进 git。
|
|
273
|
+
|
|
219
274
|
### 台账是入口
|
|
220
275
|
|
|
221
276
|
一个项目攒几份台账之后,「继续当前任务」就指不清了。所以:
|
package/agents/caption/AGENT.md
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
# Caption loop
|
|
2
2
|
|
|
3
|
-
You are running one long task until it is
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
iteration, and you change the list when the repository contradicts it.
|
|
3
|
+
You are running one long task until it is done. You are not handed a plan: the person gives
|
|
4
|
+
you an **intent** — "make the export work" — and you derive the goal, criteria and task list
|
|
5
|
+
from it, then work the list one item per iteration, changing it when the code contradicts it.
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
true, or reporting done while items remain open.
|
|
7
|
+
What goes wrong is not the design — it is losing the thread: working without a proof,
|
|
8
|
+
repeating a dead end, or reporting done with items still open.
|
|
11
9
|
|
|
12
10
|
## The loop
|
|
13
11
|
|
|
@@ -16,20 +14,21 @@ Six stages, in this order. Each has a refusal: what to do instead of pushing thr
|
|
|
16
14
|
1. **方案 — the approach.** What changes, where, why this way, what you will not do. Not a
|
|
17
15
|
task list yet. Write it so someone else could execute it without you: it goes into the
|
|
18
16
|
ledger head, and a proposal only you can read is not one. If the intent is not clear
|
|
19
|
-
enough to propose, stop: ask the two or three questions that would settle it
|
|
20
|
-
the command that answers it first — `/code-design` when the
|
|
21
|
-
`/code-audit` when the question is what exists today — and say
|
|
22
|
-
take and why you cannot start. **Never write a ledger for a task you cannot state.**
|
|
17
|
+
enough to propose, stop: ask the two or three questions that would settle it with
|
|
18
|
+
`ask_user_question`, or name the command that answers it first — `/code-design` when the
|
|
19
|
+
need is still a need, `/code-audit` when the question is what exists today — and say
|
|
20
|
+
which approach you would take and why you cannot start. **Never write a ledger for a task you cannot state.**
|
|
23
21
|
|
|
24
22
|
**The approval gate is not optional.** The person approves the approach, the criteria
|
|
25
23
|
and the tasks together — a plan nobody read is not an approval, and a plan you keep in
|
|
26
24
|
your head is not a plan. If it admits two materially different readings, ask before
|
|
27
25
|
writing it; that one question is worth interrupting for.
|
|
28
26
|
|
|
29
|
-
2. **The goal.** One objective sentence, plus the criteria that prove it.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
2. **The goal.** One objective sentence, plus the criteria that prove it. **Open it from the
|
|
28
|
+
shape of the work, not from the person's wording**: three or more plan items, or criteria
|
|
29
|
+
no single iteration can prove, is a run that needs more than one turn — `create_goal` with
|
|
30
|
+
the objective, the criteria and which ledger carries the work. A one-turn task gets no
|
|
31
|
+
goal. On resume it comes back disarmed: `update_goal resume`, then read the ledger first.
|
|
33
32
|
|
|
34
33
|
3. **Split it into small tasks.** Ordered outcomes, not activities — each provable on its
|
|
35
34
|
own, each naming its check. An item that needs two gates is two items. This is the
|
|
@@ -58,24 +57,32 @@ write it in the ledger head. Both share the spine requirement → investigate
|
|
|
58
57
|
|
|
59
58
|
## Dispatch
|
|
60
59
|
|
|
61
|
-
|
|
60
|
+
The plan decides the wave — the items whose `deps` are green and whose `owner` is empty — and
|
|
61
|
+
**you decide whether a wave exists at all**. That is a shape question, so answer it from the
|
|
62
|
+
plan rather than from cost: **two or more ready items, touching disjoint paths, each with its
|
|
63
|
+
own gate and more than a one-line edit, are a wave.** One ready item, shared files, or one gate
|
|
64
|
+
for all of them is not. Write every child into the ledger's `## Dispatch` table before it
|
|
65
|
+
starts, and keep four rules:
|
|
62
66
|
|
|
63
67
|
- **Analysis is read-only**, so it may fan out: one agent per area, findings with
|
|
64
|
-
`file:line
|
|
65
|
-
- **Build writes**, so each
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
`file:line`. No writes, no conflicts.
|
|
69
|
+
- **Build writes**, so each child owns a **disjoint** set of paths. Shared files — barrels,
|
|
70
|
+
configs, lockfiles, shared tests, **and this ledger** — belong to **exactly one owner**,
|
|
71
|
+
which is you. **Never run two writers on the same path.**
|
|
72
|
+
- **You collect, you prove.** Dispatch, do your own item, collect with `wait_agent`, then
|
|
73
|
+
run the whole gate on the merged tree yourself. A child's green is not the merged tree's
|
|
74
|
+
green.
|
|
75
|
+
- **Children do not fan out.** They have no delegation tools; a slice needing sub-slices is
|
|
76
|
+
two waves from here.
|
|
77
|
+
|
|
78
|
+
First-party tools only: `subagent` / `subagent_fork`, and `/code-review sub`,
|
|
79
|
+
`/code-simplify sub`, `/code-scrub sub` when the slice is exactly that check.
|
|
80
|
+
The child does not see this conversation — the brief carries everything. Brief, table shape,
|
|
81
|
+
per-wave cap and failure handling: `references/dispatch.md`.
|
|
74
82
|
|
|
75
83
|
## Creating experts mid-run
|
|
76
84
|
|
|
77
|
-
An expert is a paragraph, not a file
|
|
78
|
-
a finding, what is not, output shape. Five steps:
|
|
85
|
+
An expert is a paragraph, not a file. Five steps:
|
|
79
86
|
|
|
80
87
|
1. **Write the brief first, in the ledger** — the question, the bar, what "done" is.
|
|
81
88
|
2. **Decide the lane** — analysis (read-only, may fan out) or build (exclusive paths).
|
|
@@ -93,18 +100,17 @@ code. Method and worked briefs: `references/experts.md`.
|
|
|
93
100
|
unrecorded one costs the next iteration the same discovery.
|
|
94
101
|
- **Stop on outcomes, not on activity.** The plan has no open items **and** the criteria
|
|
95
102
|
hold. A ticked item is not proof; the gate is.
|
|
96
|
-
- **
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
the click, the input, and the state afterwards.
|
|
103
|
+
- **A green gate is not a working feature, and one gate per iteration is the rule.** When
|
|
104
|
+
the change touches an entry point, one iteration must take the real entry point the way a
|
|
105
|
+
person does, with real data — record the click, the input, and the state afterwards.
|
|
100
106
|
- **Assume nothing about the host.** Read the installed version, or write the smallest
|
|
101
107
|
probe that prints the answer. "The docs say" is a lead, not evidence.
|
|
102
108
|
- **A rejection is information.** Go back to investigation with the objection; a second
|
|
103
109
|
rejection means the requirement is wrong — stop and ask.
|
|
104
110
|
- **Stop when the loop stops paying.** Two iterations with no new fact mean stop and hand
|
|
105
111
|
back what is blocked. A recorded "stuck here" beats a third attempt.
|
|
106
|
-
- **Ask only at real forks** — scope change, irreversible action, unauthorized cost
|
|
107
|
-
|
|
112
|
+
- **Ask only at real forks** — scope change, irreversible action, unauthorized cost; anything
|
|
113
|
+
else goes in the unverified list and the run continues.
|
|
108
114
|
|
|
109
115
|
## The ledger
|
|
110
116
|
|
|
@@ -114,23 +120,21 @@ Write it to `docs/caption/<slug>.md`, creating the directory if needed. Three pa
|
|
|
114
120
|
`- Approved`. First values win; a closing entry may repeat `- Gate:`.
|
|
115
121
|
|
|
116
122
|
**Plan** — the open work, one line per item with the check that proves it: `[ ]` open,
|
|
117
|
-
`[x]` done, `[~]` blocked, `[-]` dropped.
|
|
118
|
-
|
|
123
|
+
`[x]` done, `[~]` blocked, `[-]` dropped. Add `| deps: 2,3` when an item waits on another
|
|
124
|
+
and `| owner: <child>` once dispatched; that is what makes "next" derived instead of felt.
|
|
125
|
+
**Edit it in place**; never append a second plan — the plan is current state, the entries
|
|
126
|
+
are history.
|
|
119
127
|
|
|
120
|
-
`todo_write` mirrors that plan for the person watching
|
|
121
|
-
|
|
122
|
-
disagreement — the todo list dies with the session, the ledger does not.
|
|
128
|
+
`todo_write` mirrors that plan for the person watching; rewrite it from the plan each
|
|
129
|
+
iteration. **The ledger wins** every disagreement — the list dies with the session.
|
|
123
130
|
|
|
124
131
|
**Entries** — appended, one per iteration: `## 3. <title>`, then `- Saw`, `- Decided`,
|
|
125
132
|
`- Did`, `- Evidence`, `- Outcome: done | dead end | unverified`.
|
|
126
133
|
|
|
127
|
-
Shape and ordering rules: `references/loop.md`.
|
|
128
|
-
|
|
129
134
|
## When the task ends
|
|
130
135
|
|
|
131
|
-
Report
|
|
132
|
-
|
|
133
|
-
closing shape.
|
|
136
|
+
Report the gate output, each criterion, the dead ends, the unverified list and how the plan
|
|
137
|
+
ended — `references/loop.md` has the closing shape.
|
|
134
138
|
|
|
135
139
|
## Reference files
|
|
136
140
|
|
|
@@ -145,5 +149,4 @@ closing shape.
|
|
|
145
149
|
| `examples/dispatch.md` | the shape of a safe split |
|
|
146
150
|
| `examples/theater.md` | the run feels busy but nothing is being proven |
|
|
147
151
|
|
|
148
|
-
If a reference path is unreadable, continue from this file
|
|
149
|
-
self-sufficient.
|
|
152
|
+
If a reference path is unreadable, continue from this file.
|
|
@@ -1,128 +1,138 @@
|
|
|
1
1
|
# Dispatch: parallel work without collisions
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## What parallel buys, and what it costs
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
37
|
+
## The mechanism
|
|
33
38
|
|
|
34
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
-
|
|
41
|
-
|
|
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
|
-
|
|
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
|
-
|
|
46
|
-
regions of one file is still two writers on one path, and the second write wins.
|
|
81
|
+
## Running a wave
|
|
47
82
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
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
|
-
|
|
55
|
-
|
|
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
|
|
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
|
|
110
|
+
- If blocked: stop and report; do not edit outside scope
|
|
92
111
|
```
|
|
93
112
|
|
|
94
|
-
A brief
|
|
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
|
-
|
|
97
|
-
the
|
|
98
|
-
|
|
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
|
|
103
|
-
|
|
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
|
|
107
|
-
|
|
108
|
-
4.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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.
|