teamsmith 0.0.0-stage → 0.1.2

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 (245) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +158 -2
  3. package/bin/team.mjs +59 -0
  4. package/install.sh +94 -0
  5. package/package.json +37 -4
  6. package/skills/teamsmith/CHANGELOG.md +763 -0
  7. package/skills/teamsmith/SKILL.md +312 -0
  8. package/skills/teamsmith/extension/team-bg.ts +435 -0
  9. package/skills/teamsmith/extension/team-inbox-watch.ts +1412 -0
  10. package/skills/teamsmith/extension/team-notify.ts +663 -0
  11. package/skills/teamsmith/references/agent-adapters.md +643 -0
  12. package/skills/teamsmith/references/config.md +477 -0
  13. package/skills/teamsmith/references/meeting.md +124 -0
  14. package/skills/teamsmith/references/memory.md +133 -0
  15. package/skills/teamsmith/references/migration.md +227 -0
  16. package/skills/teamsmith/references/openspec.md +222 -0
  17. package/skills/teamsmith/references/philosophy.md +95 -0
  18. package/skills/teamsmith/references/protocol.md +712 -0
  19. package/skills/teamsmith/references/troubleshooting.md +1384 -0
  20. package/skills/teamsmith/references/workflows.md +448 -0
  21. package/skills/teamsmith/scripts/lib/cmd-agents.sh +1709 -0
  22. package/skills/teamsmith/scripts/lib/cmd-bg.sh +284 -0
  23. package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +311 -0
  24. package/skills/teamsmith/scripts/lib/cmd-config.sh +1156 -0
  25. package/skills/teamsmith/scripts/lib/cmd-death.sh +562 -0
  26. package/skills/teamsmith/scripts/lib/cmd-docs.sh +149 -0
  27. package/skills/teamsmith/scripts/lib/cmd-draft.sh +124 -0
  28. package/skills/teamsmith/scripts/lib/cmd-init.sh +212 -0
  29. package/skills/teamsmith/scripts/lib/cmd-meeting.sh +904 -0
  30. package/skills/teamsmith/scripts/lib/cmd-outbox.sh +196 -0
  31. package/skills/teamsmith/scripts/lib/cmd-project.sh +642 -0
  32. package/skills/teamsmith/scripts/lib/cmd-review.sh +1393 -0
  33. package/skills/teamsmith/scripts/lib/cmd-status.sh +1399 -0
  34. package/skills/teamsmith/scripts/lib/cmd-update.sh +191 -0
  35. package/skills/teamsmith/scripts/lib/cmd-watch.sh +1681 -0
  36. package/skills/teamsmith/scripts/lib/common.sh +4964 -0
  37. package/skills/teamsmith/scripts/lib/draft-entry.sh +51 -0
  38. package/skills/teamsmith/scripts/lib/outbox.sh +2042 -0
  39. package/skills/teamsmith/scripts/lib/tmux-argv.sh +165 -0
  40. package/skills/teamsmith/scripts/monitor.mjs +616 -0
  41. package/skills/teamsmith/scripts/panel/README.md +192 -0
  42. package/skills/teamsmith/scripts/panel/build.sh +47 -0
  43. package/skills/teamsmith/scripts/panel/bun.lock +109 -0
  44. package/skills/teamsmith/scripts/panel/draft-send.sh +68 -0
  45. package/skills/teamsmith/scripts/panel/package.json +24 -0
  46. package/skills/teamsmith/scripts/panel/panel.js +388 -0
  47. package/skills/teamsmith/scripts/panel/src/App.tsx +2150 -0
  48. package/skills/teamsmith/scripts/panel/src/clipboard.ts +154 -0
  49. package/skills/teamsmith/scripts/panel/src/compose.ts +691 -0
  50. package/skills/teamsmith/scripts/panel/src/data.ts +555 -0
  51. package/skills/teamsmith/scripts/panel/src/format.ts +50 -0
  52. package/skills/teamsmith/scripts/panel/src/layout.ts +2562 -0
  53. package/skills/teamsmith/scripts/panel/src/main.tsx +894 -0
  54. package/skills/teamsmith/scripts/panel/src/markdown.ts +340 -0
  55. package/skills/teamsmith/scripts/panel/src/sanitize.ts +42 -0
  56. package/skills/teamsmith/scripts/panel/src/settings.ts +154 -0
  57. package/skills/teamsmith/scripts/panel/src/strings/en.ts +416 -0
  58. package/skills/teamsmith/scripts/panel/src/strings/index.ts +65 -0
  59. package/skills/teamsmith/scripts/panel/src/strings/types.ts +9 -0
  60. package/skills/teamsmith/scripts/panel/src/strings/zh.ts +414 -0
  61. package/skills/teamsmith/scripts/panel/src/theme.ts +116 -0
  62. package/skills/teamsmith/scripts/panel/src/types.ts +652 -0
  63. package/skills/teamsmith/scripts/panel/src/width.ts +105 -0
  64. package/skills/teamsmith/scripts/panel/tsconfig.json +16 -0
  65. package/skills/teamsmith/scripts/shim/signal-gate +156 -0
  66. package/skills/teamsmith/scripts/shim/tmux +403 -0
  67. package/skills/teamsmith/scripts/team +143 -0
  68. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +147 -0
  69. package/skills/teamsmith/templates/BOARD.md.tmpl +18 -0
  70. package/skills/teamsmith/templates/DECISIONS.md.tmpl +22 -0
  71. package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +25 -0
  72. package/skills/teamsmith/templates/PROTOCOL.md.tmpl +84 -0
  73. package/skills/teamsmith/templates/ROADMAP.md.tmpl +29 -0
  74. package/skills/teamsmith/templates/config.sh.tmpl +106 -0
  75. package/skills/teamsmith/templates/memory-seed.md.tmpl +46 -0
  76. package/skills/teamsmith/templates/pm-prompt.md.tmpl +110 -0
  77. package/skills/teamsmith/templates/report.md.tmpl +36 -0
  78. package/skills/teamsmith/templates/task.md.tmpl +65 -0
  79. package/skills/teamsmith/templates/threads-README.md +17 -0
  80. package/skills/teamsmith/tests/bg-ledger-harness.mjs +682 -0
  81. package/skills/teamsmith/tests/bg-ledger.sh +307 -0
  82. package/skills/teamsmith/tests/checkout-shape-probe.sh +800 -0
  83. package/skills/teamsmith/tests/config-cli.sh +1562 -0
  84. package/skills/teamsmith/tests/container-tmux.sh +493 -0
  85. package/skills/teamsmith/tests/coverage-inventory.sh +173 -0
  86. package/skills/teamsmith/tests/death-cause.sh +564 -0
  87. package/skills/teamsmith/tests/delivery-truth.sh +1231 -0
  88. package/skills/teamsmith/tests/fake-tui.py +450 -0
  89. package/skills/teamsmith/tests/fixtures/delivery-truth-real/README.md +60 -0
  90. package/skills/teamsmith/tests/fixtures/delivery-truth-real/judge-second.py +139 -0
  91. package/skills/teamsmith/tests/fixtures/delivery-truth-real/mock-server.py +29 -0
  92. package/skills/teamsmith/tests/fixtures/delivery-truth-real/observe.ts +20 -0
  93. package/skills/teamsmith/tests/fixtures/delivery-truth-real/run-case.sh +79 -0
  94. package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +175 -0
  95. package/skills/teamsmith/tests/fixtures/p55/flip-p49.sh +229 -0
  96. package/skills/teamsmith/tests/fixtures/p71-incident/README.md +22 -0
  97. package/skills/teamsmith/tests/fixtures/p71-incident/dev2.seen +8 -0
  98. package/skills/teamsmith/tests/fixtures/p71-incident/dev2.wake +9 -0
  99. package/skills/teamsmith/tests/fixtures/p71-incident/pm-nudges.wake +3 -0
  100. package/skills/teamsmith/tests/fixtures/signal-lint-cases.txt +40 -0
  101. package/skills/teamsmith/tests/flip-glue.sh +162 -0
  102. package/skills/teamsmith/tests/flip-m12-26c.sh +129 -0
  103. package/skills/teamsmith/tests/flip-m12.sh +185 -0
  104. package/skills/teamsmith/tests/flip-m16.sh +166 -0
  105. package/skills/teamsmith/tests/flip-m17.sh +204 -0
  106. package/skills/teamsmith/tests/flip-m33.sh +284 -0
  107. package/skills/teamsmith/tests/flip-m34.sh +96 -0
  108. package/skills/teamsmith/tests/flip-m37.sh +185 -0
  109. package/skills/teamsmith/tests/flip-m4.3.sh +375 -0
  110. package/skills/teamsmith/tests/flip-m43.sh +128 -0
  111. package/skills/teamsmith/tests/flip-m44.sh +262 -0
  112. package/skills/teamsmith/tests/flip-m45.sh +244 -0
  113. package/skills/teamsmith/tests/flip-m46.sh +238 -0
  114. package/skills/teamsmith/tests/flip-m48.sh +304 -0
  115. package/skills/teamsmith/tests/flip-m6.2.sh +205 -0
  116. package/skills/teamsmith/tests/flip-m6.3.sh +283 -0
  117. package/skills/teamsmith/tests/flip-m6.4.sh +267 -0
  118. package/skills/teamsmith/tests/flip-m6.5.sh +113 -0
  119. package/skills/teamsmith/tests/flip-m7.1.sh +135 -0
  120. package/skills/teamsmith/tests/flip-m7.2.sh +321 -0
  121. package/skills/teamsmith/tests/flip-p144.sh +112 -0
  122. package/skills/teamsmith/tests/flip-p156.sh +133 -0
  123. package/skills/teamsmith/tests/flip-p158.sh +301 -0
  124. package/skills/teamsmith/tests/flip-p160.sh +182 -0
  125. package/skills/teamsmith/tests/flip-p171.sh +249 -0
  126. package/skills/teamsmith/tests/flip-p18.1.sh +95 -0
  127. package/skills/teamsmith/tests/flip-p20.sh +286 -0
  128. package/skills/teamsmith/tests/flip-p201.sh +249 -0
  129. package/skills/teamsmith/tests/flip-p210.sh +239 -0
  130. package/skills/teamsmith/tests/flip-p211.sh +152 -0
  131. package/skills/teamsmith/tests/flip-p217.sh +288 -0
  132. package/skills/teamsmith/tests/flip-p22.sh +123 -0
  133. package/skills/teamsmith/tests/flip-p23.sh +239 -0
  134. package/skills/teamsmith/tests/flip-p25.sh +165 -0
  135. package/skills/teamsmith/tests/flip-p71.sh +184 -0
  136. package/skills/teamsmith/tests/flip-p72.sh +202 -0
  137. package/skills/teamsmith/tests/frames/README.md +176 -0
  138. package/skills/teamsmith/tests/frames/p78-conversation-rule-below-box.txt +6 -0
  139. package/skills/teamsmith/tests/frames/p78-cursor-mid-draft.txt +6 -0
  140. package/skills/teamsmith/tests/frames/p78-draft-rule-below-cursor-line.txt +6 -0
  141. package/skills/teamsmith/tests/frames/p78-draft-rule-below-cursor.txt +6 -0
  142. package/skills/teamsmith/tests/frames/p78-draft-rule-blank-region.txt +6 -0
  143. package/skills/teamsmith/tests/frames/p78-draft-rule-only.txt +5 -0
  144. package/skills/teamsmith/tests/frames/p78-spinner-row-below-cursor.txt +6 -0
  145. package/skills/teamsmith/tests/frames/p78-wider-rule-below-cursor.txt +6 -0
  146. package/skills/teamsmith/tests/frames/p86-f1-mixed-width-disjoint-box.txt +8 -0
  147. package/skills/teamsmith/tests/frames/p86-f1-narrower-width-disjoint-box.txt +8 -0
  148. package/skills/teamsmith/tests/frames/p86-f1-spinner-top-disjoint-box.txt +8 -0
  149. package/skills/teamsmith/tests/frames/pi-0.85.1-update-banner.txt +30 -0
  150. package/skills/teamsmith/tests/frames/pi-0.87.0-draft-half-sentence.txt +30 -0
  151. package/skills/teamsmith/tests/frames/pi-0.87.0-empty-box.txt +30 -0
  152. package/skills/teamsmith/tests/frames/pi-0.87.0-one-line-draft.txt +30 -0
  153. package/skills/teamsmith/tests/frames/pi-0.87.0-project-trust-prompt.txt +30 -0
  154. package/skills/teamsmith/tests/frames/pi-0.99.2-empty-editor.txt +32 -0
  155. package/skills/teamsmith/tests/frames/pi-0.99.2-human-draft.txt +32 -0
  156. package/skills/teamsmith/tests/frames/pi-1.0.0-git-error-in-box.txt +32 -0
  157. package/skills/teamsmith/tests/gate-guard.sh +112 -0
  158. package/skills/teamsmith/tests/guard-matrix.sh +233 -0
  159. package/skills/teamsmith/tests/install-shape.sh +731 -0
  160. package/skills/teamsmith/tests/ledger-ban.sh +612 -0
  161. package/skills/teamsmith/tests/lib/box-judge.sh +68 -0
  162. package/skills/teamsmith/tests/lib/checkout-shape.sh +129 -0
  163. package/skills/teamsmith/tests/lib/loop-scan.awk +114 -0
  164. package/skills/teamsmith/tests/lib/pty-wait.sh +676 -0
  165. package/skills/teamsmith/tests/lib/section-guard.sh +855 -0
  166. package/skills/teamsmith/tests/lib/shell-lex.pl +261 -0
  167. package/skills/teamsmith/tests/lib/tmp-root.sh +528 -0
  168. package/skills/teamsmith/tests/lib/tmux-cap.sh +35 -0
  169. package/skills/teamsmith/tests/lib/tmux-iso-call-probe.sh +81 -0
  170. package/skills/teamsmith/tests/lib/tmux-iso-probe.sh +46 -0
  171. package/skills/teamsmith/tests/lib/tmux-iso.sh +381 -0
  172. package/skills/teamsmith/tests/load-experiment.sh +290 -0
  173. package/skills/teamsmith/tests/loop-inventory.tsv +84 -0
  174. package/skills/teamsmith/tests/panel-b2-slow-stub.sh +19 -0
  175. package/skills/teamsmith/tests/panel-b2.sh +1183 -0
  176. package/skills/teamsmith/tests/panel-b3-pty-mouse.py +240 -0
  177. package/skills/teamsmith/tests/panel-b3-pty-tmux-mouse.py +138 -0
  178. package/skills/teamsmith/tests/panel-b3-stub.sh +279 -0
  179. package/skills/teamsmith/tests/panel-b3.sh +1301 -0
  180. package/skills/teamsmith/tests/panel-choices.sh +572 -0
  181. package/skills/teamsmith/tests/panel-clipboard-model.ts +187 -0
  182. package/skills/teamsmith/tests/panel-compose-model.ts +290 -0
  183. package/skills/teamsmith/tests/panel-contrast.mjs +81 -0
  184. package/skills/teamsmith/tests/panel-cpu-premise.sh +173 -0
  185. package/skills/teamsmith/tests/panel-cpu.sh +391 -0
  186. package/skills/teamsmith/tests/panel-flip-m54.sh +207 -0
  187. package/skills/teamsmith/tests/panel-flip-p123.sh +278 -0
  188. package/skills/teamsmith/tests/panel-flip-p125.sh +318 -0
  189. package/skills/teamsmith/tests/panel-flip-p128.sh +259 -0
  190. package/skills/teamsmith/tests/panel-keyprobe-pty.py +99 -0
  191. package/skills/teamsmith/tests/panel-keyprobe-stub.sh +41 -0
  192. package/skills/teamsmith/tests/panel-keyprobe.sh +82 -0
  193. package/skills/teamsmith/tests/panel-keyprobe.tsx +116 -0
  194. package/skills/teamsmith/tests/panel-knobs.sh +83 -0
  195. package/skills/teamsmith/tests/panel-p21.sh +2181 -0
  196. package/skills/teamsmith/tests/panel-snapshots.sh +802 -0
  197. package/skills/teamsmith/tests/panel-strings.mjs +195 -0
  198. package/skills/teamsmith/tests/perf.sh +740 -0
  199. package/skills/teamsmith/tests/pm-box-real.sh +350 -0
  200. package/skills/teamsmith/tests/pulse-nudge-key.sh +563 -0
  201. package/skills/teamsmith/tests/routes.sh +1652 -0
  202. package/skills/teamsmith/tests/section-budgets.tsv +150 -0
  203. package/skills/teamsmith/tests/section-guard.sh +231 -0
  204. package/skills/teamsmith/tests/section-needs-audit.sh +94 -0
  205. package/skills/teamsmith/tests/section-paths.tsv +142 -0
  206. package/skills/teamsmith/tests/section-select.sh +655 -0
  207. package/skills/teamsmith/tests/signal-gate.sh +366 -0
  208. package/skills/teamsmith/tests/signal-lint-legacy.txt +14 -0
  209. package/skills/teamsmith/tests/signal-lint.pl +416 -0
  210. package/skills/teamsmith/tests/skill-load.mjs +65 -0
  211. package/skills/teamsmith/tests/smoke.sh +19711 -0
  212. package/skills/teamsmith/tests/snapshots/zh-dark-120-detail.txt +32 -0
  213. package/skills/teamsmith/tests/snapshots/zh-dark-120-p4.txt +32 -0
  214. package/skills/teamsmith/tests/snapshots/zh-dark-120.txt +32 -0
  215. package/skills/teamsmith/tests/snapshots/zh-dark-160-p4.txt +32 -0
  216. package/skills/teamsmith/tests/snapshots/zh-dark-160.txt +32 -0
  217. package/skills/teamsmith/tests/snapshots/zh-dark-59-detail.txt +32 -0
  218. package/skills/teamsmith/tests/snapshots/zh-dark-59-p4.txt +32 -0
  219. package/skills/teamsmith/tests/snapshots/zh-dark-59.txt +32 -0
  220. package/skills/teamsmith/tests/snapshots/zh-dark-99-p4.txt +32 -0
  221. package/skills/teamsmith/tests/snapshots/zh-dark-99.txt +32 -0
  222. package/skills/teamsmith/tests/snapshots/zh-light-120-detail.txt +32 -0
  223. package/skills/teamsmith/tests/snapshots/zh-light-120-p4.txt +32 -0
  224. package/skills/teamsmith/tests/snapshots/zh-light-120.txt +32 -0
  225. package/skills/teamsmith/tests/snapshots/zh-light-160-p4.txt +32 -0
  226. package/skills/teamsmith/tests/snapshots/zh-light-160.txt +32 -0
  227. package/skills/teamsmith/tests/snapshots/zh-light-59-detail.txt +32 -0
  228. package/skills/teamsmith/tests/snapshots/zh-light-59-p4.txt +32 -0
  229. package/skills/teamsmith/tests/snapshots/zh-light-59.txt +32 -0
  230. package/skills/teamsmith/tests/snapshots/zh-light-99-p4.txt +32 -0
  231. package/skills/teamsmith/tests/snapshots/zh-light-99.txt +32 -0
  232. package/skills/teamsmith/tests/spec-ledger-refs.tsv +78 -0
  233. package/skills/teamsmith/tests/spec-refs.sh +826 -0
  234. package/skills/teamsmith/tests/task-header-model.sh +267 -0
  235. package/skills/teamsmith/tests/team-bg-flip.sh +239 -0
  236. package/skills/teamsmith/tests/team-bg-harness.mjs +392 -0
  237. package/skills/teamsmith/tests/team-bg-stop.sh +434 -0
  238. package/skills/teamsmith/tests/team-inbox-watch-flip.sh +191 -0
  239. package/skills/teamsmith/tests/team-inbox-watch-harness.mjs +1559 -0
  240. package/skills/teamsmith/tests/tmp-hygiene.sh +1190 -0
  241. package/skills/teamsmith/tests/tmux-lint-legacy.txt +31 -0
  242. package/skills/teamsmith/tests/tmux-lint.pl +604 -0
  243. package/skills/teamsmith-init/SKILL.md +100 -0
  244. package/skills/teamsmith-init/references/bootstrap.md +74 -0
  245. package/skills/teamsmith-init/templates/bootstrap-prompt.md.tmpl +46 -0
@@ -0,0 +1,1384 @@
1
+ # Troubleshooting (hard-won lessons)
2
+
3
+ Run `team doctor` first; then look at the extension log with `tail -f $(grep TEAM_NOTIFY_LOG .pi/team/config.sh)`.
4
+
5
+ ---
6
+
7
+ ## 1. The PM never receives an agent's "turn ended" notification
8
+ > On a real TUI, delivery is confirmed by the payload leaving the input box **and** appearing as an echo bubble in the conversation area (V10-F1): a cleared-but-unsent draft never counts as delivered, and an unconfirmed entry is never deleted (it moves to `held/` with a durable copy).
9
+
10
+
11
+ Check in order of likelihood:
12
+
13
+ 1. **The extension is not loaded**: in a linked worktree Pi does **not** auto-discover the project-local
14
+ `.pi/extensions/`. `team dispatch` must pass `-e <skill>/extension/team-notify.ts`. When you start an agent by
15
+ hand you have to add it yourself.
16
+ 2. **cwd is not under the worktree**: the extension only fires inside `<root>/<TEAM_WORKTREES_DIR>/...`. If you change
17
+ `TEAM_WORKTREES_DIR` you must update the configuration too (the extension reads the same `config.sh`).
18
+ 3. **The window name equals the PM window name**: it is skipped (to prevent self-triggering loops). An agent window
19
+ must be named after the agent — `team dispatch` already guarantees that.
20
+ 4. **tmux session mismatch**: the extension compares `#{session_name}` with `TEAM_SESSION`. The PM session must live
21
+ in the session of the same name.
22
+ 5. **Deduplication**: an identical briefing within `TEAM_NOTIFY_DEDUP_SEC` (default 20s) is only sent once. Set it to
23
+ 0 while debugging.
24
+ 6. **The PM window does not exist**: the message only lands in the inbox, nothing is typed into a window.
25
+ `team doctor` warns about this.
26
+ 7. **Not inside tmux**: `TMUX_PANE` is empty → the extension cannot determine the window name and skips. Either run
27
+ inside tmux, or set `TEAM_NOTIFY_TMUX=0` and set the window name for the agent explicitly (not supported today,
28
+ a known limitation).
29
+ 8. **The turn never ended**: a notification means exactly one thing — *this agent's turn ended and it is waiting for
30
+ the PM*. A settle triggered by an internal lifecycle event (compaction, session restart, reload) while the agent
31
+ is still working on the same task is **not** emitted at all (it is only written to `TEAM_NOTIFY_LOG`), and a run
32
+ that was interrupted (Esc, provider error) is emitted with an explicit `interrupted` tag and **never** carries the
33
+ unfinished turn's text as its summary. So a line without a summary is deliberate: there was no completed turn to
34
+ quote, and the old behaviour (reporting the turn's opening line as if it were a conclusion) is what made a busy
35
+ agent look stopped.
36
+
37
+ ## 2. An agent session "cannot be found again" / its memory broke
38
+
39
+ A Pi session belongs to a **cwd**: `--session-id` can only be reused under the same project path.
40
+
41
+ - Never move or rename an agent's worktree; never `rm -rf .worktrees/<agent>` and recreate it at a different path.
42
+ - If you already did, use `team dispatch <agent> ... --fresh` (a new session) and note in the agent's thread why it
43
+ had to start over.
44
+ - Session id rule: `<TEAM_SESSION>-<agent>` (`--fresh` appends a timestamp).
45
+
46
+ ## 3. Notification text used to get glued to what the PM is typing
47
+
48
+ **There are two delivery channels (M30), and only one of them can touch a box.** A **built-in Pi session**
49
+ (worker or PM) that loaded `extension/team-inbox-watch.ts` receives team messages through the **inbox-watch
50
+ channel**: the sender writes the durable inbox line and appends one pointer line to
51
+ `state/inbox-watch/<key>.wake`; the session's own extension reads it and calls
52
+ `pi.sendMessage({customType:'team-inbox'}, …, {triggerTurn:true, deliverAs:'followUp'})`, which enters the
53
+ conversation like a queued follow-up. The input box is never read and never typed into. Every other target —
54
+ a custom adapter, a Pi session started without the extension, a registration whose pid is dead or whose cwd
55
+ is another project — takes the **delivery guard** below, which is the only code allowed to type into a pane.
56
+
57
+ The Pi channel exists because five draft-race incidents (2026-09, all on real Pi 0.85.1) showed that the box
58
+ heuristic cannot be made reliable enough: D20 is where the guard came from (an automated message glued onto a
59
+ human's draft); in M17 a payload was judged to have raced a draft while the PM had in fact just finished a long
60
+ gate and its box was empty; in M24 a knock sat in an idle PM's box overnight while the 28 pulse nudges that
61
+ followed were held behind it; and the same class of failure came back after each fix — the fifth incident, with
62
+ a plain 460-code-point payload, is what triggered the channel change (M30). The user's call was to stop patching
63
+ the detector for the Pi path and change the channel instead. The guard stays for every target that has no
64
+ extension API to watch a file.
65
+
66
+ Readiness is **evidence, not configuration**: the extension writes `state/inbox-watch/<key>.reg`
67
+ (`target=<session>:<window>`, `inbox=<name>`, `pid`, `cwd`, `heartbeat`). A sender routes to the watch channel
68
+ only when a registration matches that exact target, its pid is alive and its `cwd` is inside this project — a
69
+ fresh `heartbeat` is only the fallback when `cwd` is missing (bounded by `TEAM_INBOX_WATCH_STALE`, default
70
+ 300 s), because a heartbeat is not an identity. So "this is a Pi session with a watcher" is proven by the
71
+ session itself instead of guessed from `TEAM_AGENT_CMD` (an internal seam (frozen): reserved for a possible future
72
+ non-Pi adapter, no compatibility promise).
73
+
74
+ Honest edges of the Pi channel (visible, never silent):
75
+
76
+ - **A wake is not "read".** The wake is queued into the session; if the session dies before it reaches the
77
+ model, nobody is woken — the durable inbox line and its unread count are what the pulse picks up on its next
78
+ tick, exactly as before. The channel never claims a delivery it cannot see: `team say` reports
79
+ `pi 监视通道` (`watched`), never `已确认送达`.
80
+ - **A session restart re-baselines the wake spool.** Lines written *before* `session_start` never wake anybody
81
+ (otherwise every restart would replay history), and a line written during a reload gap is not woken either;
82
+ both fall back to the pulse.
83
+ - **The wake carries a pointer, not the payload**: kind, sender, inbox file and a truncated preview
84
+ (`TEAM_INBOX_WATCH_PREVIEW`, default 160 chars). The full text stays in the inbox; a burst merges into one
85
+ message and at most five lines are listed (`… and N more`).
86
+ - **The follow-up is delivered at a safe point.** `deliverAs:'followUp'` waits until the agent has no pending
87
+ tool calls, so a wake never interrupts a running tool call; that is pi's own queue, not a new polling loop.
88
+ The extension's ledger (`state/inbox-watch.log`) records `started` / `wake n=…` / `stopped` lines.
89
+
90
+ **The delivery guard** (the paste path) locates the target pane's input box before typing and reads **every content row
91
+ of the box** — including rows below the cursor, because a draft typed after a leading newline or recalled with `Up`
92
+ sits below the cursor row. If the box already holds text, the sender writes **no key at all**: the message goes
93
+ into `state/outbox/` as one immutable entry and is delivered when the box is free (`team outbox list` shows what is
94
+ waiting, `team outbox flush` drains it, and every watchdog tick drives one drain as well). A message deferred behind a
95
+ **trusted** non-empty box is reported as **`queued`** (exit 0), never as delivered. The two impediment outcomes below —
96
+ `geometry-untrusted` and `queue-stalled` — are instead reported as **`held`** with the machine reason and a **non-zero
97
+ exit**, because no trustworthy read exists to say "you have a draft" and there is nothing to promise about clearing it.
98
+
99
+ What this means for you:
100
+
101
+ - On a built-in Pi session the box question does not arise: messages land in the inbox and wake the session.
102
+ The queue below is what a non-Pi target, a Pi session without the watcher, or the explicit escape hatch uses.
103
+ - Keep typing. Your draft stays in the box; the notice waits outside it.
104
+ - If the queue bothers you: `team outbox drop <n|all>` discards entries, and `team status` / `team digest` print one
105
+ `outbox …` line as long as anything is waiting (nothing when it is empty).
106
+ - `team say <agent> "…" --now` (and `team outbox flush --now`) deliberately types into a non-empty box — that is
107
+ the old behaviour on purpose, and it appends one line to `state/outbox/forced.log`. Use it only when you really
108
+ want the text glued.
109
+ - The human entry point is `team draft pm`: an editor window on `state/draft-pm.md` (nothing automated ever types
110
+ into it); saving and quitting enqueues the file through the same guarded path and prints the acknowledgement in
111
+ that window. `team draft send <file>` is the headless form of the same thing.
112
+
113
+ Honest edges (documented, not hidden):
114
+
115
+ - **A whitespace-only draft is one known miss, and it is not the only one.** The guard reads the pane, and
116
+ `tmux capture-pane` trims trailing blanks, so a box holding only spaces looks empty and the message is
117
+ delivered (i.e. glued to your spaces). The same class of hole — a dirty box read as empty — has these members,
118
+ so this list, not any absolute claim, is the boundary: equal-width draft rule rows (a pasted separator clipped
119
+ to the pane width, or a table border) and spinner-shaped draft rows are **fixed** (the top border is the
120
+ highest qualifying row, so such a row is content and the box reads busy; V9-A4/A5/A8), a cursor resting on the
121
+ draft's own equal-width rule row is **fixed** (the bottom border is searched strictly below the cursor row;
122
+ V9-A10), and a lower candidate whose paired top border lies entirely below the cursor is **fixed** (P86: such a
123
+ candidate is skipped and the search continues with the nearer candidates, so the located box always contains the
124
+ cursor row); **still open** are the whitespace-only draft, the two shape-based members named in the
125
+ status-row bullet below (a draft whose only row is a verbatim clone of the status-row shape with the cursor
126
+ parked on another row — reads as chrome → empty; and an unrecognised future status-row spelling — reads busy,
127
+ never empty), and the P86 residual: on a clipping TUI whose frame holds, below the box, a second pair of
128
+ full-rule rows of a **different** width (so that pair cannot pair with anything above the cursor), the nearest
129
+ admitted candidate can still be a rule row the draft itself drew, and that frame reads empty. The measured shape
130
+ is `rule(A) / blank (cursor) / rule(A) / blank / rule(B) / text / rule(B) / footer` with A≠B (P86 report); it is
131
+ the same mixed-width clipping class as the P74/P84 shapes and the fix's stated promise is only "the located box
132
+ contains the cursor row", not "no frame reads empty".
133
+ - **Confirmation means the payload left the box AND the conversation shows a new copy of it (V9-B5).** After the
134
+ `Enter` the drain reads the box back AND counts the payload's signature in the conversation area above the box
135
+ (first non-blank line, whitespace-stripped, compared byte-wise, or a `[paste #N +K lines]` bubble whose `+K`
136
+ matches the payload's line count): more copies than before typing = delivered. **An empty box alone is not
137
+ proof** — a TUI can swallow the `Enter` (overlay, escape handling, redraw), clearing the box while the message
138
+ never reaches the conversation; an older version of this guard reported exactly that shape as delivered and
139
+ deleted the entry (zero submissions, no inbox row — the message was silently lost). Now such a send is
140
+ reported **unconfirmed** and the entry goes to `held/` **immediately** (not after the TTL) and is **terminal** —
141
+ never pasted a second time, `flush --now` included. A TUI that never echoes submissions (static footer)
142
+ degrades honestly the same way: the `Enter` did land once, the tool just cannot prove it — the held entry and
143
+ its durable inbox copy are there for you to verify and `team outbox drop`.
144
+ - **The row above the bottom border is read as content unless it is provably the box's own status row.** Pi
145
+ 0.85.1 drew its model/provider/thinking status row (the ` k3 Kimi Coding max` shape) **inside** the box, on
146
+ exactly that row; Pi 0.87.0 moved it to a line **below** the box, so a **single-line draft** now lives there.
147
+ The row is excluded only when **both** tests pass: the cursor is not resting on it AND its text matches the
148
+ measured status-row shape (one leading space, a model token without spaces, two spaces, the provider display
149
+ name, two spaces, a thinking level from Pi's set — the two measured samples are
150
+ ` deepseek-flash Deepseek max` and ` k3 Kimi Coding max`). Everything else is content and the box reads
151
+ **busy**: a row the cursor rests on is content whatever its text (Pi's cursor never rests on the box's own
152
+ status row, and a human's text can be shaped like anything), and so is a border-adjacent row whose spelling is
153
+ not recognised — an unknown future status-row spelling reads busy (a conservative hold), never empty (V9-C1).
154
+ Two members of this class stay open and are named here rather than implied away: the **whitespace-only draft**
155
+ (the capture trims trailing blanks — see the bullet above) and a draft whose **only** row is a verbatim
156
+ status-row clone with the cursor parked on another row (by shape it is indistinguishable from the box's own
157
+ chrome). The 0.87.0 layout (status row below the box) is supported, and the 0.85.1 sample stays excluded by
158
+ shape — the old exclusion by slot is gone, so every draft that used to be invisible is either now visible or
159
+ requires that exact clone.
160
+ - **Giving up the `Enter` never leaves our text in your box (M17).** When the pre-`Enter` re-check cannot
161
+ confirm that the box holds only our payload, the drain first asks one more question: does the box hold *only*
162
+ what we typed? Verbatim, a single `[paste #N +K lines]` placeholder whose `+K` matches, the prefix/suffix
163
+ display window, an empty box, or the whole box being our own half-rendered placeholder frame all count as
164
+ ours — then the drain clears it with Pi's own editor keys (`ctrl+a` line start + `ctrl+k` delete-to-line-end /
165
+ join-next-line, repeated; independent of where the cursor sits, and an idempotent no-op on an empty box) and
166
+ verifies the box ended up empty before holding the entry. The outcome is recorded in the hold reason:
167
+ `draft-raced-retracted` means nothing of ours is left in the box. If anything else is in the box — your draft,
168
+ a second folded paste, an unreadable box — **not one key is sent** (leave it, never delete it) and the hold reason is
169
+ `draft-raced-left`: our payload may sit in the box next to your text, exactly as before, and the log line says
170
+ `框里已有人的内容,未动`. Both are **terminal**: the payload reached the box once and may have ridden your own
171
+ `Enter` to the agent, so no automatic path, `flush --now` included, ever pastes it again; the entry stays in
172
+ `held/` until you drop it or re-send the content yourself. `team status` / `team digest` show the split on their
173
+ `outbox …` line (`held N:已收回 X · 留在框里 Y`), and `team outbox list` plus the panel's queue page show the
174
+ per-entry reason.
175
+ - **The retraction keys are Pi's bindings, and the retraction is verified.** The clear uses the editor's own
176
+ `ctrl+a`/`ctrl+k` semantics (Pi 0.85.1). On a TUI that binds them differently the clear may not take effect;
177
+ the drain reads the box back and, if anything is still there, reports the hold as `draft-raced-left` (residue
178
+ in the box) rather than claiming a retraction it cannot see. The window between the “box holds only ours”
179
+ read and the clear keys is one command wide — same class of residual window as check → type, documented here
180
+ rather than hidden.
181
+ - **Rule-looking rows inside your own draft are not borders.** A pasted markdown separator or table border is a
182
+ `─` row; the guard takes the **highest** qualifying row above the cursor as the top border and the **lowest**
183
+ qualifying row below it as the bottom border, and it admits that bottom border only when the top border it pairs
184
+ with sits **strictly above the cursor row** (so the located box always contains the cursor row; a candidate whose
185
+ pairing lies entirely below the cursor is skipped and the search continues with the nearer candidates — P86). The
186
+ bottom border is a full-rule row of equal width, or the E3-era spinner shape where a
187
+ spinner-shaped top border is admissible; the bottom search is strictly below the cursor, V9-A10), so a short draft
188
+ rule row — and also an equal-width or wider one (V9-A4/A5/A8/A10) — counts as box content and the box reads
189
+ busy. Three documented costs: on a TUI that **clips** long lines to the pane width, an over-long draft line can
190
+ read as an equal-width rule row and enlarge the located box (the verdict errs to busy, never to gluing; real Pi
191
+ 0.85.1 wraps one column short of the border width, so the shape is unreachable there); the `── ␣…`-plus-long-trailing-rule
192
+ shape is accepted as a top-border candidate on purpose (it was measured on the E3 Pi), so a draft line with that
193
+ exact shape reads as box content and the box reads busy — never as a border; and a full-rule row **below** the
194
+ located box that still pairs with a top border above the cursor (a rule the conversation draws, or any chrome rule
195
+ row under the box — `p78-conversation-rule-below-box.txt`) enlarges the box over that row
196
+ and the rows between it and the box's own bottom border, so the box reads busy and delivery waits — the mirror of
197
+ the top border's cost, on the same conservative side. That last cost is **not reachable in either measured
198
+ layout**: on every stored real capture (Pi 0.85.1 and 0.87.0, `tests/frames/`) the pane's lowest full-rule row is
199
+ the box's own bottom border and no full-rule row sits below it (the rows below it are the box's own footer/status
200
+ rows; the trust-prompt frame is an overlay with no box at all, and the overlay path takes precedence). It is also
201
+ not separable in principle: a frame whose draft is exactly one rule row and a frame whose conversation draws a
202
+ rule row immediately below an empty box are the **same bytes** (sha256 `e463c80c…f5053a6`), so one rule must
203
+ serve both readings, and the conservative one (a rule row below the cursor is content → busy) is the one that
204
+ cannot glue. The working row of Pi 0.85.1 is a different shape altogether
205
+ (` ⠋ Blanching… · 0s`, braille glyph plus text, drawn on its own row **above** the box, top border still a full
206
+ rule): it is not a border candidate, tier1 keeps locating the box, and if a future TUI ever moved that row into
207
+ the border position the pairing would find no box and the pane would be typed as today with one warning
208
+ (V9-D2) — never a silent hold.
209
+ - **Folded pastes are checked by shape, not by stripping.** The box counts as "only ours" when it holds exactly
210
+ ONE `[paste #N +K lines]` placeholder whose `+K` equals the payload's line count. Two folded pastes (yours and
211
+ ours) always count as a race (V8-N4). Residue: if your own paste folded with the same line count as ours, the
212
+ two are geometrically indistinguishable — but then your payload is visible in the box, and you are holding the
213
+ pane.
214
+ - **Half-rendered frames are waited out.** While the TUI is still drawing a folded paste (`[paste #N +1` without
215
+ the completed placeholder, occupying a whole line), the guard neither settles nor calls it a race — it waits
216
+ (about a second, bounded) for the render to finish (V8-N3). The test matches a whole line, never a substring,
217
+ and the payload itself is checked verbatim first — so a message whose own text contains `[paste #` delivers
218
+ normally (V8-N2/V9-B1). If the wait is exhausted while the frame is still half-drawn, the payload is
219
+ **retracted** (the whole box is our own half-frame, so the clear keys are safe) and the entry is held as
220
+ `draft-raced-retracted`; if anything else appeared in the box by then, not one key is sent and the hold is
221
+ `draft-raced-left`.
222
+ - **Two narrow acceptance windows, on purpose.** (a) When the visible box holds only a prefix/suffix of the
223
+ payload, the re-check accepts it (scrolling and truncated display windows look exactly like that; V8-N6). If
224
+ an `Enter` lands in that window while the paste is still arriving — yours or the drain's own — a partial paste
225
+ can be submitted; the submission is not credited as confirmed (no new conversation copy), so the entry is held
226
+ as `unconfirmed` and never re-pasted, with the full payload in its durable inbox copy — nothing is silently
227
+ deleted, the affected entry is visible and can be re-sent (V8-N6/V9-B3; V9-C5 measured the drain's-own-`Enter`
228
+ branch: the entry is held, not deleted).
229
+ (b) Notification-shaped text inside the conversation transcript could in principle be misread as
230
+ box content if the borders were mis-paired (V8-N5) — measured: when a spinner-shaped row stands in as the top
231
+ border, conversation text below it IS read as box content and the verdict is **busy** (a conservative hold,
232
+ not `UNKNOWN`; V9-C2), while a transcript without any rule-looking row simply pairs no box and fails safe to
233
+ `UNKNOWN`.
234
+ - **A pane whose input box cannot be located** (a non-Pi TUI, a theme that breaks the geometry) is treated as
235
+ "deliver as today" plus one warning line — never as a permanent hold, and nothing is queued for it. Because no
236
+ box can be read there, no submission proof can be collected either: such a delivery is reported as
237
+ **unknown-shape, unconfirmed** (`输入框形状未知:按旧行为投递`), never as `已确认送达` (V9-C3).
238
+ - **Check → type is not atomic.** The guard re-checks immediately before typing and again (by fingerprint) before
239
+ pressing Enter, and holds the message when a draft appeared in between; the residual window is one command wide
240
+ (no retry loop).
241
+ - **A stalled render is retracted, not left in the box (M17; this supersedes the V9-B6 recovery).** When the TUI
242
+ draws a folded paste slower than the bounded wait, the drain sends no `Enter`, clears our half-drawn placeholder
243
+ back out of the box, and holds the entry with reason `draft-raced-retracted` — terminal, because the payload was
244
+ in the box once and any later automatic paste could double-send. An entry an **older** teamsmith already held
245
+ with reason `stall-timeout` (the payload still in the box as a completed `[paste #N +K lines]` placeholder) is
246
+ still finished by the next drain: it presses the single missing `Enter` while the box holds only that payload
247
+ and never pastes it again; if the box no longer holds only the payload, the entry stays in `held/` for you to
248
+ verify and drop or re-send.
249
+ - **Expiry holds, it never types:** after `TEAM_DEFER_TTL` (default 300 s) an undeliverable entry moves to
250
+ `state/outbox/held/` with a line in `state/outbox/HOLDING.log`, and a later drain still delivers it once the box
251
+ clears (unless its reason is `draft-raced-left`, `draft-raced-retracted` or `unconfirmed`, which are terminal). The payload is always already durable in the
252
+ recipient's inbox (or `state/nudges.log` for a wake) by the time the hold completes, so an expired hold can
253
+ never lose a message — and a delivery the drain confirmed never appears in the inbox at all.
254
+ - **The real Pi editor suffix is located from a closed layout shape, not from the highest rule (delivery-truth,
255
+ 2026-10).** Pi 0.99.2 draws the editor as *bottom rule / cwd line (with the measured optional `(branch)`
256
+ decoration) / context status line* (`1.2%/128k (auto) …`), and the conversation area above it can carry a
257
+ full-width rule row of its own — the P138/P147 real capture has one at row 21. The legacy highest-rule pairing
258
+ took that transcript rule as the editor's top border, read the conversation as box content and reported BUSY
259
+ on an **idle, empty editor**: `team say` exited 0 with "clear the box and it will be delivered automatically"
260
+ while nothing would ever deliver it (the P147 red). The guard now admits a narrower candidate domain only when
261
+ the frame is a supported Pi layout: the last two rows are the cwd line and the measured status grammar; the
262
+ equal-width rule directly above them is the bottom border; and exactly one equal-width rule above the cursor
263
+ bounds an editor whose content rows fit the renderer's measured width and height (a full-width rule inside a
264
+ candidate rectangle disqualifies it, which is what rejects the transcript rule and admits the editor top).
265
+ The footer directory must agree with the target pane's runtime cwd. Zero or several surviving rectangles, a
266
+ missing/short bottom rule, or a content row wider than the pane (a clipping or scrolled TUI, a draft whose own
267
+ rule row makes the rectangle ambiguous) are **`geometry-untrusted`**: no key is sent, the payload is moved to
268
+ `state/outbox/held/` with that reason plus its durable inbox copy, the sender exits non-zero and names the
269
+ entry and the recovery command, and `team say` asserts no draft and promises no automatic delivery. Recovery
270
+ is `team outbox flush` once the layout is supported again (the entry is never-typed, so it may be retried; a
271
+ terminal `draft-raced*`/`unconfirmed` entry never is). Real captures and the red side (`admission shadowed
272
+ off` → the same bytes read `[21 30]`/BUSY) are pinned in `tests/frames/` and
273
+ `tests/delivery-truth.sh --section frames --mutations`.
274
+ - **A trusted empty box that keeps not progressing becomes a visible stall (delivery-truth, 2026-10).** A
275
+ never-typed entry that reads a **trusted empty** box but makes no progress (the paste fails, or a delivery
276
+ attempt returns it to the queue) records one observation in an atomic sidecar under
277
+ `state/outbox/diagnostics/<entry>.json` — schema, target, verdict, trust, `consecutive_empty`, first/last
278
+ observation time, impediment reason and the durable full-text path. The **third consecutive eligible
279
+ evaluation** (the evaluation owns the entry's claim, the target is alive and the entry is FIFO-eligible)
280
+ moves it to `held/` with reason **`queue-stalled`**; the sidecar and `team outbox list` / `team status` /
281
+ `team digest` show the count and reason, and the command exits non-zero. Counting is deliberately narrow: a
282
+ BUSY/working read resets the count to zero (a real draft or a working target is not this defect), queueing
283
+ during work, offline targets and lock contention are never counted, and observers (`outbox list`, `status`,
284
+ `digest`, the panel) never advance a count, capture a pane or touch the queue. `queue-stalled` is a
285
+ never-typed hold: unlike the terminal `draft-raced*`/`unconfirmed` holds it is retried, but only by an
286
+ explicit `team outbox flush` (the pulse tick leaves the visible hold alone instead of hammering it), and the
287
+ entry's payload and immutable header are never rewritten. `TEAM_DEFER_TTL` remains a backstop, not the first
288
+ signal of this defect.
289
+ - **Manual `notify`'s three pointers name one file (delivery-truth, 2026-10).** `team notify <recipient>` writes
290
+ the durable line to `docs/team/inbox/<recipient>.md`; the queue entry's declaration and the wake pointer now
291
+ carry **that same recipient** (the old code declared and woke `pm`, the knock target, so a notify to `dev`
292
+ woke a PM session that pointed at a nonexistent `pm.md`). The PM is still the **knock destination** — the wake
293
+ reaches the PM; the durable message lives in the recipient's inbox. A durable append that fails exits
294
+ non-zero, emits no wake and writes no "inbox written" declaration (the `--inbox-written` contract).
295
+ - **The console shows impediments read-only.** `panel.outbox.impeded` and `panel.outbox.impediments` (JSON),
296
+ the status band and the messages page (TUI and `team monitor --print`) name the count and reasons
297
+ (`geometry-untrusted`, `queue-stalled`), each item's entry id, target and last observation time. A missing or
298
+ unreadable diagnostic renders as `unavailable` — never as zero impediments — and none of these observers
299
+ captures a pane, advances a drain observation or retries a delivery.
300
+
301
+ If a notification really did get glued (e.g. the whitespace-only case), the mitigations from before still apply:
302
+ answer with a short sentence right after reading it, lower the volume with `TEAM_INBOX_MAX_CHARS`, or set
303
+ `TEAM_NOTIFY_TMUX=0` and read `team digest` yourself — or run that session on a built-in Pi launch path, where
304
+ the box is not part of the delivery channel at all.
305
+
306
+ ## 4. `team dispatch` refuses to dispatch
307
+
308
+ Beyond the table below, the three refusals that cost the most retries — a worktree on another task's branch, a
309
+ brief header line that does not parse, and a review without `--dir` — have their own section with paste-ready
310
+ fixes: §27.
311
+
312
+ | Error | Cause | What to do |
313
+ |---|---|---|
314
+ | only X MB of swap left | the `TEAM_MIN_FREE_SWAP_MB` floor (default 1024) | wait for a seat to finish (`team ps` shows who is running) — or paste the refusal's own `修法:TEAM_MIN_FREE_SWAP_MB=0 team dispatch …` line; that override trades the safety net away for this launch and is printed as a real risk, not a formality |
315
+ | the temp root (or the worktree filesystem) is below the disk floor | the disk/inode leg: `TEAM_TMP_MIN_FREE_MB` (default 1024) / `TEAM_TMP_MIN_FREE_INODES` (default 100000) over the filesystems a worker will write to (the temp root and the agent's worktree) | the refusal names the path, the measured bytes/inodes, the threshold and the remedy (temp root: `bash skills/teamsmith/tests/tmp-hygiene.sh --status`, then `--sweep`; worktree: free that path); a leg is turned off with `TEAM_TMP_MIN_FREE_MB=0` / `TEAM_TMP_MIN_FREE_INODES=0`, or permanently through the audited writer `team config set <KEY> 0 --allow-danger --yes` — see §25 |
316
+ | available memory X MB < 2048 | a warning only (RAM is tight) | you may continue; lower concurrency if it feels sluggish. To silence it completely: `TEAM_WARN_AVAIL_MB=0` |
317
+ | available memory + free swap only X MB | the hard `TEAM_MIN_TOTAL_MB` floor | the machine really is out of resources: stop an agent first; the refusal prints the matching `TEAM_MIN_TOTAL_MB=0 …` route if you accept the risk |
318
+ | MemAvailable down to X MB | the hard `TEAM_MIN_AVAIL_MB` floor (default 1024) | stop or wait for a seat first; the printed `修法:TEAM_MIN_AVAIL_MB=0 team dispatch …` line is the explicit override |
319
+ | model X concurrency limit N | `TEAM_MODEL_LIMITS` | wait, or temporarily `TEAM_MODEL_LIMITS="" team dispatch ...` |
320
+ | unknown agent | not in the roster | grow the roster through its one audited entry: `team add-agent <a> --register` (or hand-edit `TEAM_AGENTS` in `.pi/team/config.sh`) |
321
+ | worktree does not exist | `add-agent` was never run | dispatch creates it automatically, but an explicit `team add-agent <a> --register` is preferable (for a seat already in the roster the flag is a visible no-op) |
322
+ | window exists → replacing | the previous turn is still running | dispatch only after checking: replacing interrupts it (ask for progress with `team say` first) |
323
+ | the session does not fit the model window | the resume guard: session size (JSONL bytes ÷ 4) exceeds the selected model's window, or the conservative `TEAM_SESSION_WARN_TOKENS` when the window cannot be resolved | `--fresh` for a new session, or `--allow-overflow` if you really mean to reuse it (it warns loudly) |
324
+ | the agent still carries another unfinished task | the stacking guard: `state/<agent>.env` records task X, X has no non-`FAIL` review record, its branch tip is not in the protected branch and the board is not `done`/`closed`/`dropped`, while the worktree sits on a task branch | finish X first (`team resume --agent <a>`, then verify/merge) — or take the window over on purpose with `--force`; see 4e below |
325
+ | the task id matches more than one brief | two files `docs/team/tasks/<ID>-*.md` (a title change created a second slug); the branch name would come from the stale one | rename/remove the stale brief or give it its own id: dispatch refuses instead of picking one by glob order |
326
+ | the launch could not be confirmed | the pane never wrote the per-attempt launch proof, so tmux/the pane swallowed the command | see 4b below |
327
+ | the harness started but the agent exited immediately (`exit=…`) | a **custom adapter** CLI that could not start (missing binary/flag/auth, or a first word the window's login shell cannot resolve) | the CLI's own output, the rendered command and the resolved binary are in `state/dispatch-<agent>-launch-failed.log`; see 4d below |
328
+
329
+ ### 4a. An agent loops on `Context full` / connection errors right after a resume
330
+
331
+ Symptom: the dispatch succeeds, the pane immediately prints `Context full — /ctx-flush or /clear to continue.` and
332
+ then a stream of `Connection error.` with `↑0 ↓0` tokens, while `team roster` still reports the agent as running —
333
+ the process is alive, it just cannot do anything.
334
+
335
+ Cause: the session was resumed with a model whose context window is smaller than the history it carries. Observed
336
+ live: ~361k tokens of history (a 1.6 MB session JSONL) resumed with a 272k-window model.
337
+
338
+ What the tool does now: dispatch estimates the session size (JSONL bytes ÷ 4 — crude on purpose) and refuses when it
339
+ exceeds the window it resolved for the selected model, naming both ways out. `team roster`/`team ps` show the same
340
+ numbers next to the model, so the mismatch is visible before dispatching.
341
+
342
+ What to do:
343
+
344
+ - usual case: `team dispatch <agent> <ID> <brief> --fresh` (new session; the old history stays in its own file);
345
+ - you really want the history (e.g. you also moved to a bigger-window model): add `--allow-overflow`;
346
+ - already wedged: kill the window (`tmux kill-window -t <session>:<agent>`) and dispatch again with `--fresh`; the
347
+ pane is the truth, `roster`'s "running" only proves the process exists.
348
+
349
+ ### 4b. `team dispatch` says the launch could not be confirmed
350
+
351
+ A dispatch no longer reports success just because tmux accepted the command. The pane harness writes a per-attempt
352
+ nonce immediately before it execs the agent, and only that proof counts. Without it the tool kills the window,
353
+ retries once, and — if the retry also fails — reports the failure, kills the window again and says what to check.
354
+ The window is left in a known state: it does not exist (`roster` shows "no window").
355
+
356
+ Observed shape (live incident): a dispatch into a wedged pane printed "window exists → replacing" and reported
357
+ success, but the command only landed in the stuck process's input buffer — the new session id never appeared and
358
+ nothing ever ran.
359
+
360
+ What to do:
361
+
362
+ - reproduce it by hand: `team dispatch … --print` prints the exact command; run it in the pane and read the output;
363
+ - usual causes: the binary, provider or model is unavailable, the old session is wedged (`--fresh`), the machine is
364
+ out of memory or disk;
365
+ - with a custom `TEAM_PI_BIN`: make sure it is an absolute path and executable from the pane;
366
+ - if the launch proof arrives but the agent has **already exited** (the dispatch prints a warning carrying the
367
+ agent's exit code, and `roster` shows "pi exited"), that is the honest `pi exited` state: `team resume --agent <a>`
368
+ continues the task. That exit code is written by the window harness itself when the agent process returns, so the
369
+ warning does not depend on how long the pane takes to come back to a shell (and `TEAM_DISPATCH_ALIVE_SEC` is the
370
+ time the dispatch waits for that record, not a sleep before a single look at the pane).
371
+
372
+ ### 4c. `digest` says a report is "not committed yet"
373
+
374
+ The report exists only in the agent's working tree, and the reviewer reads the report from a checkout of the task
375
+ branch — so the signal would arrive before it is actionable. The tool therefore lists it as "report not committed
376
+ (spelling out that review is not the next step)" instead of pointing at `team review <ID>`; nothing is dropped. Ask
377
+ the agent to commit it, and the normal "awaiting review" line plus the review command come back.
378
+
379
+ The same restraint applies to a **committed** report whose task is still `todo`/`wip` on the board while the seat that owns it is running: it is not counted as an actionable "awaiting review" item (the author may still commit to the branch), although `digest [3]` still lists it — the count comes back as soon as the seat stops or the board moves on.
380
+
381
+ ### 4d. A worker adapter's CLI never started (`exit=…`)
382
+
383
+ The worker adapter below is the internal seam (frozen) — reserved for a possible future non-Pi adapter, with no
384
+ compatibility promise — so this section is a maintenance diagnostic, not a support offer.
385
+
386
+ A dispatch proves two different things, and it now reports them separately: the **harness** started (the per-attempt
387
+ spawn proof) and the **agent** started (the exit event `state/dispatch-<agent>.exit`). With `TEAM_AGENT_CMD` set, an
388
+ immediate **non-zero** exit is a failed dispatch — it prints `派单失败:harness 起来了,但 agent 立刻退出了(exit=<code>)`,
389
+ leaves the window in place (the CLI's own error stays on screen) and writes
390
+ `state/dispatch-<agent>-launch-failed.log`: the rendered command, the resolved executable, the exit code and the
391
+ window's last non-blank lines (captured by the harness the moment the CLI exited, so a shell that clears the screen
392
+ does not erase it). Nothing is recorded against the task — `roster` will not show it as running the task.
393
+
394
+ Common causes: the template's first word is a bare name that does not resolve on the caller's `PATH` either (dispatch
395
+ refuses that earlier), `TEAM_AGENT_BIN` names a different binary than the template runs, the CLI's flags/auth are
396
+ wrong, or a wrapper script is missing. Reproduce by hand with the `render :` line in the diagnostic. `exit=127`
397
+ means "command not found" *inside the window's login shell*; `exit=1`/`exit=2` are usually the CLI rejecting its
398
+ arguments. An adapter that exits **0** right away is not a failure: script-style CLIs finish and exit, and dispatch
399
+ says so.
400
+
401
+ ### 4e. `team dispatch` refuses because the agent still has an unfinished task
402
+
403
+ This is the guard for the D16 accident shape: one agent carried M9.2 while the PM dispatched P2 to the same agent,
404
+ which replaced the window/session and forced a hand-over. The tool knew the agent's task and branch the whole time.
405
+ Now, before starting anything, dispatch reads `state/<agent>.env` (the task the agent was dispatched for), the board
406
+ row for that task and the branch the worktree is on. If that task is another id and it is not finished — no non-`FAIL`
407
+ review record, its branch tip is not an ancestor of the protected branch, and the board is not `done`/`closed`/
408
+ `dropped` — the dispatch is refused (before any window is touched) and the refusal prints the task, its board status,
409
+ the branch the worktree is on, why the task still counts as unfinished, and the two ways forward:
410
+
411
+ ```bash
412
+ bash <skill>/scripts/team resume --agent dev # finish what is already there (then review/merge)
413
+ bash <skill>/scripts/team dispatch dev T2.1 <brief> --force # take the window over on purpose
414
+ ```
415
+
416
+ `--force` is the explicit override: the dispatch output states what it covers (which task gives way) and
417
+ `state/watchdog.log` gets an audit line, so an intentional takeover is never silent. It covers **only** this refusal —
418
+ a worktree still parked on the old task's branch is refused by the branch-identity guard (F16), which is a different
419
+ problem: move the worktree to the new task's branch with git first. Two paths are deliberately not refused:
420
+ re-dispatching the agent's **own** task (that is `resume`, not stacking) and any previous task that is reviewed,
421
+ merged or decided by the board. When the state cannot be determined — no `state/<agent>.env`, an empty `task=`, no
422
+ worktree, a detached/unreadable branch — dispatch proceeds and prints one line naming the missing signal; it does not
423
+ guess. A dispatch whose id matches two briefs is refused for the same reason (`docs/team/tasks/<ID>-*.md`), with both
424
+ paths listed: clean up the briefs instead of letting glob order choose the scope.
425
+
426
+ ### 4f. Dispatch warns that this seat burned its last round (or produced nothing)
427
+
428
+ Before a launch — `--print` included — dispatch prints a visible, non-blocking `⚠` line when either leg of the
429
+ seat's last round is judgeable and bad, and prints **nothing** when it cannot judge (silence, never a guess):
430
+
431
+ - **death leg**: the seat's latest record in `state/deaths.log` is classified `quota` or `balance` by the death
432
+ reader; the warning names the classification, the source, the time and the raw evidence line (for example
433
+ `weekly usage limit exceeded (403)`). Check the quota/balance, or move the seat to another model, before
434
+ re-dispatching;
435
+ - **zero-output leg**: `state/<agent>.env` records the previous round's `sid` and the session file's size **at
436
+ launch**; if that same file is still exactly that size, the round wrote nothing and the warning says so in the
437
+ tool's own coarse vocabulary (`0 bytes ≈ 0 tokens`), naming the session file.
438
+
439
+ Both are hints: they never change the exit status, never block and never open a window by themselves. The size is
440
+ recorded *before* the worker can run, so bytes written during that round are never counted as the previous round's
441
+ output; a missing record, an unreadable file or an unparsable value keeps the leg silent. Read the line before
442
+ re-dispatching: a `quota` death usually means the next launch dies the same way, and a zero-output round usually
443
+ means the previous dispatch never got going — the same refusal repeats until its fix is applied.
444
+
445
+ ## 5. git worktree errors
446
+
447
+ - `fatal: '<branch>' is already checked out`: that branch lives in another worktree. Find it with `git worktree list`,
448
+ or use a detached checkout for verification (which is what `team review` does).
449
+ - A stale worktree lock: `git worktree prune`.
450
+ - Cannot remove it (dirty): run `git -C <wt> status` first, and only use `team teardown --purge --force` once you are
451
+ sure nothing is worth keeping.
452
+
453
+ ## 6. Merging and deciding "is it merged?"
454
+
455
+ - After `git merge --squash` the task branch is **not** an ancestor of the protected branch, so `git branch --merged`
456
+ cannot tell you anything. Trust the `BOARD.md` status plus the `reviews/<ID>.md` record, not ancestry. `roster` and
457
+ `digest` go one step further for the **usual** squash case: when the branch tip's tree equals the tree of one of the
458
+ last `TEAM_SQUASH_LOOKBACK` commits on the protected branch, they report "already merged (squash, same content)"
459
+ and stop suggesting a push. It is a heuristic — an older squash, or one that also changed something else, shows up
460
+ as `ahead N` again (the safe direction: the signal comes back, it is never suppressed silently).
461
+ - Conflicts: `git merge --squash` leaves the conflict state behind; inspect it with
462
+ `git status --porcelain | grep '^U'`, then either `git add -A && git commit` or `git merge --abort` to start over.
463
+ - Before merging, the main worktree must be clean and on the protected branch — deliberately so: it stops an agent's
464
+ dirty state from slipping into the merge commit.
465
+
466
+ ## 7. forge (github / gitlab)
467
+
468
+ - `gh` 401/403: the PAT file path/permissions/scope. Merging needs `pull-requests: write`, which many PATs do not
469
+ have → fall back to a local squash + a comment + closing the PR (see `workflows.md` F).
470
+ - GitLab 403: the token needs the `api` scope and at least the Developer role; if the MR target branch is protected,
471
+ the Developer role may be unable to merge.
472
+ - When using a real tool, inject on demand (`GH_TOKEN="$(< .gh-pat)" gh …`); do not `export GH_TOKEN` permanently and
473
+ do not `cat` a token onto the screen or into a log.
474
+
475
+ ## 8. A report does not match reality
476
+
477
+ - Symptom: the report says "tests pass", verification fails.
478
+ - Action: paste the failing output into the thread → send it back → add "you must reproduce the failing test first" to
479
+ the brief.
480
+ - At the process level: `team review` must actually run the gates (do not fall into always passing `--no-gates`).
481
+ - The same agent making the same kind of mistake repeatedly: switch to a different model family for the independent
482
+ verification, or make the acceptance commands copy-pasteable.
483
+
484
+ ## 9. An agent crossed the boundary and edited someone else's directory
485
+
486
+ - Immediately `team say <agent> "stop: <path> is not yours, roll your change back (git checkout -- <path>)"`.
487
+ - Add an explicit ownership line to `OWNERSHIP.md`/the brief — most crossings come from a brief that did not say.
488
+ - If the crossing was already committed: reject it during verification and have the agent `git revert` it, or redo the
489
+ branch.
490
+
491
+ ## 11. Other known traps
492
+
493
+ - **The skill was not injected into the system prompt**: pi only writes skills into the system prompt when a tool that
494
+ can read files (`read` or `bash`) is available. Running with `--no-tools` means not seeing the skill is normal, not
495
+ a failed installation. How to verify: `bash tests/smoke.sh` or `bun tests/skill-load.mjs` (loads this skill through
496
+ pi's own parser, zero model calls).
497
+ - **Where the inbox is really written**: the notify extension prefers the git main worktree (an agent's worktree has
498
+ its own copy of `config.sh`), so inboxes always end up in the main worktree's `<docs>/inbox/`; if a log shows the
499
+ root pointing at a worktree path, the extension is too old.
500
+ - **Suspect paths or a mismatched config**: run `team paths` first (it prints main_root / worktree / docs / session /
501
+ pm_window).
502
+ - **`TEAM_PI_BIN`**: point it at an absolute path when pi is not on PATH (or when you want a fake pi for self-tests).
503
+ - **A live fixture sleeps instead of waiting for the state it asserts**: the same class has now cost M7.2, M7.5 and
504
+ M9.7. A fixed `sleep` followed by one sample of `team_pm_state` (or of a log file) turns a nondeterministic
505
+ transition into a fake red: §11b3's `attempts 行带决策证据` failed because a freshly recreated window was still
506
+ `unknown:zsh` when the watch sampled it (the old `make_pm_idle` polled `pane_current_command` and then slept
507
+ 0.5 s), and §11i-D's squash heuristic lost one run in ~8. `tests/smoke.sh` waits with a deadline for the real
508
+ condition instead (`pm_state_until`, `pm_state_until_not`, `wait_session_gone`, `wait_window_gone`,
509
+ `d43_digest_until`) and names the last state seen on timeout. Two rules: when the condition involves a freshly
510
+ created tmux pane, require it to **hold** (two samples ~0.5 s apart) — the instant right after `new-window` can
511
+ report a false `idle:*` before the pane has exec'd its command; and never let the wait replace the assertion's
512
+ failure path — a persistent regression must still be red, just later and with better evidence.
513
+
514
+ ## 11. Keep-alive and liveness decisions
515
+
516
+ - **How "the PM is running" is decided**: only a **proof** counts (M6.5). The PM is running when either
517
+ ① this tool started it and `state/pm.pid` still points at a live process whose cwd is inside the project, or
518
+ ② the process in the PM window is the configured agent binary (resolved the same way `dispatch` resolves it:
519
+ `TEAM_AGENT_BIN` > first word of `TEAM_AGENT_CMD` > `TEAM_PI_BIN`) and its cwd is in the project.
520
+ Everything else is reported as `foreign:<cmd>` (the occupant's cwd is not this project: `team up` refuses to
521
+ overwrite it unless `TEAM_REPLACE_FOREIGN_PM=1`) or `unknown:<cmd>` (cwd is inside the project but it is not the
522
+ agent: a just-created pane, a `sleep`, an editor). `unknown` is **not** a PM, so it never suppresses starting one —
523
+ `team up` replaces it and says so. `pulse status`, `ps`, `digest` and the monitor panel use the same proof, so
524
+ no surface prints "the PM is running" without it.
525
+ Why this is strict: the old rule ("the window exists and its foreground process is not a shell") reported a
526
+ *just-created* pane — where `pane_current_command` is still `tmux` — as `running:tmux`. `team up` then printed
527
+ "PM is running" without starting anything, `pulse status` repeated it, and the project's own smoke suite went
528
+ from green to 7 failures after the machine restarted. Status is a promise: a liveness signal that is inferred
529
+ instead of proven hides the exact failure the tool exists to surface.
530
+ - **A shell wrapper still counts as the PM**: `team_pm_state` looks at the pane's own process *and* its direct
531
+ children and matches any word of the command line against the agent binary, so `bash /path/to/pi …`
532
+ (or a Pi started through a login shell) is recognised as the agent. A child that is *not* the agent does not make
533
+ the window a PM.
534
+ - **team up respawns the PM window's pane**: only when no PM is running there — an empty prompt (`idle`) or a
535
+ non-PM process whose cwd is inside the project (`unknown`). Do not treat the PM window as a normal terminal; to
536
+ start working manually, re-run the agent in that window or simply let the pulse bring it up.
537
+ Note: the agent is the pane's own process (we `exec` it), so when it exits the pane closes and the window
538
+ disappears — exactly the `missing` case the pulse reports (corresponding to the `TEAM_PULSE_REBUILD_TMUX`
539
+ switch). After a successful start the pid is written to `state/pm.pid`, which is what makes a later
540
+ "is it still alive?" question a fact rather than a guess (the read-only commands only read it).
541
+ - **Typing only happens when something is really running**: `say`/`notify`/the extension refuse when the target window
542
+ sits at an empty prompt (otherwise the text would be executed by the shell as a command) and only write the inbox
543
+ for the PM to read later.
544
+ - **What the pulse actually manages**: it recomputes the pending work on a timer (unread notifications / reports
545
+ awaiting verification / board todo·wip / blocked / agents with an unfinished task that stopped), and **only wakes the
546
+ PM when there is pending work** (nudge it while running; `pi -c` when it is not). With nothing pending it does
547
+ nothing at all.
548
+ It will not resume agents for you, does not create tmux sessions/windows (unless `TEAM_PULSE_REBUILD_TMUX=1`), and
549
+ does not merge code.
550
+ - **The PM keeps being woken / does not want to be woken**: `team standby on --reason "…"` deliberately stands the PM
551
+ down (both "there really is nothing to do without a human" and "stuck waiting for someone" qualify); `team standby
552
+ off` resumes. While on standby the backlog is still recorded in `state/watchdog.log`.
553
+ - **Wake-up frequency**: every 15 minutes by default (`TEAM_PULSE_INTERVAL=900`, 300~3600 recommended); repeated
554
+ reminders for the same pending work are limited by `TEAM_PULSE_NUDGE_GAP`. To go slower or faster, change these two
555
+ values.
556
+ - **The PM was "woken twice"**: the instant notification at the end of an agent's turn (the notify extension) and the
557
+ pulse's timed reminder are two different things — the latter is a fallback for unprocessed pending work. Handle
558
+ or ack the pending work and it stops.
559
+ - **The pulse says "PM not found (missing) … run team up manually"**: the tmux session/window is gone (you closed
560
+ the window, the machine rebooted) and by default it does not touch tmux. Fix it with `team up`; to have it handle
561
+ this itself, set `TEAM_PULSE_REBUILD_TMUX=1`.
562
+ - **A stopped agent is not resumed automatically** (by design): the PM looks with `team resume --dry-run` and then
563
+ resumes with `team resume`; a human can also do `team up --agents` to bring them along in one go.
564
+ - **The PM was starting and the pulse stayed quiet**: that is deliberate (M7.2). Between `respawn-pane` and the
565
+ start's evidence, the PM pane is a shell running the start command, not a PM. `state/pm.pid.starting` marks that
566
+ attempt and every surface reports `starting:<age>`; a tick that sees it logs `PM 正在启动 → 不重复拉起` and neither
567
+ starts a second PM nor counts a restart (a second `respawn-pane` would kill the PM that was coming up, and the
568
+ quota would count one start twice). If the window stays in `starting` for longer than `TEAM_PM_START_WAIT + 5s` the
569
+ marker has expired — run `team up` again; `team pulse status` names the evidence (`pm.pid.starting` age and
570
+ starter, or the recorded pid with its `proof`). The same applies to manual starts: `team up` refuses to respawn
571
+ over a start that is still in flight and says so.
572
+ - **"PM restarted N times" but I only saw one restart**: `state/pm-restarts.log` has one line per **real** start
573
+ (epoch, timestamp, evidence). Every attempt (successful or not) is recorded in `state/pm-start-attempts.log`; a
574
+ failed or timed-out attempt is also logged in `state/watchdog.log` with `未计入配额` and consumes no *restart*
575
+ quota, so the restart count is a fact and not a count of attempts. The hourly limit (`TEAM_PULSE_MAX_RESTARTS`)
576
+ applies to the attempts file too — a loop that keeps respawning without ever confirming is refused, and the warning
577
+ names both numbers. Read `watchdog.log` for the decisions and `state/pm.pid.starting` for an attempt that is still
578
+ in flight.
579
+ - **The PM keeps crashing**: the automatic-restart quota (`TEAM_PULSE_MAX_RESTARTS`, default 5/hour) stops it and
580
+ warns, so a crash loop cannot drag the machine down; look in `state/watchdog.log` and the PM window output for the
581
+ cause first (common: model quota exhausted, a config typo, a missing dependency).
582
+ - **The pulse window of the tmux backend was closed**: reopen it with `team pulse up`; `team pulse logs`
583
+ shows a screen snapshot; when the lower half of the monitor says "no node/bun/tsx on this machine: skipping the agent
584
+ activity stream" → install node or bun (the team status part is unaffected).
585
+ - **The pulse itself stopped**: `team pulse status` shows whether the window is still there; `team pulse up`
586
+ rebuilds it (there is only one backend, so there is no container to inspect).
587
+ - **Everything is silent after a machine reboot**: the tmux server and its windows are gone → `team up` restores both
588
+ (PM window + pulse window) in one shot; `team pulse up` can start the pulse alone as well.
589
+ - **`ExecStart`/script permissions**: this skill is always invoked as `bash <path>` and does not depend on the
590
+ executable bit (but `scripts/team` is still +x, and `team smoke` checks it).
591
+
592
+ ## 11b. A seat window is a corpse (the pane died, the window stayed)
593
+
594
+ Since P55, `dispatch`/`resume` windows keep their pane after the process in it exits — including a SIGKILL — so the
595
+ seat's last screen and tmux's exit evidence survive the death. Reading such a seat:
596
+
597
+ - **The four seat conditions** (`team roster`, `team status <ID>`, and the machine agents block):
598
+ `running` (an agent is proven alive in the pane — the M6.5/M37 proof rule, unchanged), `exited` (window and pane
599
+ alive, no agent — `team resume --agent` continues it), `dead` (the pane is dead, the window is its corpse; roster
600
+ shows `▲ 已死 signal=9`-style with the evidence inline), `absent` (no window). A dead pane is **never** reported as
601
+ running, and `team say` to it does not press a single key — the message lands in `docs/team/inbox/<agent>.md` and
602
+ the output says the seat is dead.
603
+ - **Since P210 the proof rule itself (not only this reader) refuses the two shapes that used to read as "running"**
604
+ (they are the same verdict everywhere: `team resume`, the "stopped agent" pending count, the P109 "the seat is
605
+ still working" suppression): a **corpse** pane (its `pane_pid` is a stale number the kernel hands to some other
606
+ process — this host wraps its 4M pid space in hours, so that number can well belong to a live `pi`), and a pane
607
+ whose **foreground command is a bare shell** (then only a *direct child* counts as the agent — the dispatch harness
608
+ shape `bash ─ kind:pi` still proves a live seat). The 2026-10-03→04 P103 was missed for 26 hours exactly because a
609
+ corpse pane read as `running` and the patrol therefore kept saying "nothing to do".
610
+ - **Where the scene comes from** (`team status <ID>` prints it labelled with its source and time): the retained corpse
611
+ pane read with its scrollback (`capture-pane -p -S -` — the visible screen alone can lose the last line), then
612
+ `state/dispatch-<agent>-pane-dead.txt` (captured when a later dispatch replaced the corpse), then
613
+ `state/dispatch-<agent>-tail.txt` (captured by the harness when the agent exited; read as the last
614
+ `TEAM_AGENT_SCENE_LINES` lines **after trailing blank lines are trimmed** — a capture ends with the pane's empty
615
+ lower half — and a file with no non-blank line says `来源里没有可读内容` instead of printing an empty block). Bounded by
616
+ `TEAM_AGENT_SCENE_LINES` (default 40); `0` means no scene block by configuration (the section says so in one line —
617
+ `按 TEAM_AGENT_SCENE_LINES=0:不打印画面` — and reads none of the three sources, instead of letting `tail -n 0`'s
618
+ immediate exit give the writer SIGPIPE and abort `team status` at rc=141, P88's F1).
619
+ - **`signal=9` vs `status=<n>`**: tmux's evidence tells you *how* the pane died — `signal=<n>` means the process was
620
+ killed by that signal (9 = SIGKILL, typically the OOM killer or an operator), `status=<n>` means it exited with that
621
+ code on its own. One of the two is always empty; whichever tmux knows is the one shown.
622
+ - **A kept window is not an anomaly**: after `team close <ID> --keep-window` the seat's recorded task is cleared, so
623
+ digest/doctor/pending stop naming it as an abnormal exit while roster still shows its honest condition.
624
+ `team teardown --agent <agent>` removes the corpse like any other window.
625
+ - **Why the seat died** (`team status <ID>`, `team digest` [1] and the panel agents block also carry this): the same
626
+ scene reader's bounded tail plus the newest pi session JSONL for the seat's worktree is classified into a closed
627
+ set — `quota`, `balance`, `rate_limit`, `window`, `auth`, `normal`, `unknown` — with the source (`pane`/`session`/
628
+ `recorded`) and the raw evidence line. A category needs both an error frame and the category's wording (prose does
629
+ not classify); missing evidence is `unknown` (reported, never invented); a clean exit is `normal` (silent); the
630
+ cause belongs to the **current** launch only (a restart never inherits the old one); and the patrol records the
631
+ death in `state/deaths.log` and knocks exactly once per abnormal death (standby defers instead of losing it).
632
+ `TEAM_DEATH_SCAN_LINES` (default 40) bounds the pane-side tail.
633
+ - **Why the PM window has no retention**: the PM/pulse windows deliberately do **not** get `remain-on-exit` — if the
634
+ PM pane dies, its window disappears and the pulse's liveness check restarts it fresh, instead of leaving a corpse
635
+ that the auto-restart would mistake for a live PM. Retention is for seats a human has to read; supervision is for
636
+ seats the machine has to restart.
637
+
638
+ ## 12. General Pi traps
639
+
640
+ - **A test conclusion must come from a real run of this round**: put the command and the tail of its output into the
641
+ report, and the PM re-runs it.
642
+ - Type-only imports (`import type`) are mandatory in projects with `verbatimModuleSyntax` and the like — such project
643
+ rules belong in `AGENTS.md`, otherwise weaker models trip over them again and again.
644
+ - Screen scraping is unreliable (TUI refreshes/line wraps), so never treat tmux scrollback as evidence; reports and
645
+ logs are.
646
+ - A long task with no progress: have the agent drop a status line into the report every 30 minutes, or ask for
647
+ progress with `team say`.
648
+ - Strong models are slow and quota-limited: run one at a time (`TEAM_MODEL_LIMITS`), and do not dispatch two at once.
649
+
650
+ ## 13. team doctor fails on a required dependency
651
+
652
+ Both magic-context and OpenSpec are required dependencies (D10): `doctor` fails when one is missing, `dispatch`
653
+ warns one line without blocking the worker.
654
+
655
+ | Symptom (check label) | Fix |
656
+ |---|---|
657
+ | the PM memory check reports that magic-context is not detected | install the Pi package `@cortexkit/pi-magic-context`; if the settings file lives somewhere unusual, point `TEAM_PI_SETTINGS_FILE` at it; for an environment that genuinely cannot have it, set `TEAM_REQUIRE_MAGIC_CONTEXT=0` (doctor then warns instead of failing) |
658
+ | the OpenSpec CLI check cannot resolve the binary | install the OpenSpec CLI and put it on `PATH`, or set `TEAM_OPENSPEC_BIN` to its absolute path; `TEAM_REQUIRE_OPENSPEC=0` downgrades it to a warning |
659
+ | the OpenSpec spec-directory check reports a missing `openspec/` | run `openspec init --tools none` in the project (the spec root is `TEAM_SPEC_DIR`, relative to the main worktree) |
660
+
661
+ ## 14. The PM does not come up with my CLI
662
+
663
+ `team up` — and the pulse's restart path — starts the PM with `TEAM_PM_CMD`, or with the built-in Pi command
664
+ when that key is empty. That key is part of the same internal seam (frozen) — reserved for a possible future
665
+ non-Pi adapter, no compatibility promise — so the rows below are maintenance diagnostics, not a support offer.
666
+ A custom PM CLI that refuses to start almost always fails in one of these places:
667
+
668
+ | Symptom | Cause / fix |
669
+ |---|---|
670
+ | `TEAM_PM_CMD` is rejected with an unknown-placeholder error *before* anything is started | the template uses a token that is not a PM placeholder, or a near-miss such as `{ cwd }`. The PM set is `{cwd}` `{session_id}` `{model}` `{provider}` `{prompt_file}` `{prompt}` `{skill_dir}` `{extra_args}` `{resume_args}`; `{notify_ext}` and `{summary}` are **worker** placeholders and are rejected here |
671
+ | the error says the template is blank or multi-line | an adapter template is exactly one non-blank line — the second line would be executed as its own command by the window shell |
672
+ | `找不到 PM 可执行文件:<word>` ("cannot find the PM executable") | `TEAM_PM_BIN`, or the template's **first word**, does not resolve on *this* shell's `PATH`. The first word must be a bare executable name: no quotes, no `VAR=…` prefix, no `cd … &&`. A bare name that *does* resolve is fine — teamsmith renders the absolute path into the window command (see the next row) |
673
+ | `team up` says `PM 已启动` but the window shows the CLI's own error and `state/pm.pid` stays empty / dies | the CLI started and exited (unknown flag, missing auth, model not available). Read `state/pm-launch-failed.log`: the tool writes the window's last output, the rendered command, the resolved executable and the CLI's exit code (e.g. `exit : 7`) on the failure path, and `team up` then exits non-zero. The window is **not** killed any more, so the CLI's own error stays visible in `tmux attach -t <session>`; the briefing that was passed is `state/pm-prompt.md`. Reproduce the command by hand: `bash -c '. <skill>/scripts/lib/common.sh; team_load_config; team_pm_launch_cmd <main>/.pi/team/state/pm-prompt.md <main>/.pi/team/state/pm.pid.spawn'` in the project root, then run it in a shell |
674
+ | `team pulse status` reports `unknown:<cmd>` for the PM window right after a manual start | the foreground process is neither a shell nor the PM binary. Check that `TEAM_PM_BIN` names the CLI you actually ran; a wrapper that starts the CLI as a **child** (no `exec`) is reported this way — see the wrapper caveat in `references/agent-adapters.md` §2. A wrapper that `exec`s the CLI is fine: `team up` then reports `proof=spawn` |
675
+ | `team up` cannot find the CLI even though it works in your shell | it is a bare name that resolves on **your** `PATH`, so the tool renders the absolute path it resolved to and the window uses that — nothing to do. If it renders nothing absolute (the name is unresolvable here), set `TEAM_PM_BIN` to an absolute path |
676
+ | `team up` exits non-zero and `state/pm-launch-failed.log` says the CLI exited immediately | that is the honest report of a failed start (the window's login shell `PATH` is not your interactive `PATH`; an unknown flag/auth error is the CLI's own). The file also holds the first non-blank lines of the window, so `state/pm-launch-tail.txt` and the pane stay readable |
677
+
678
+ ## 15. A restart lost the PM's context
679
+
680
+ The PM only continues its previous conversation if its CLI is told to; teamsmith never guesses on the PM's behalf.
681
+
682
+ | Case | What happens | Fix |
683
+ |---|---|---|
684
+ | built-in Pi, `TEAM_PM_SESSION_ID` empty | `pi -c` continues the previous session in the main worktree — history kept | nothing (this is the default) |
685
+ | built-in Pi, `TEAM_PM_SESSION_ID=<id>` | that session id is continued (`--session-id <id>`) | keep the id stable per project |
686
+ | custom `TEAM_PM_CMD`, `TEAM_PM_RESUME_ARGS` empty | the restart is a **fresh** session; `team up` says `这次启动**不延续** PM 的历史上下文` and points at `docs/team/**` + `team inbox` | accept it — the durable record *is* the handoff, and the briefing starts with `team digest` — or configure the resume arguments (next row) |
687
+ | custom `TEAM_PM_CMD`, `TEAM_PM_RESUME_ARGS` set but the template has no `{resume_args}` | the arguments are **not** passed; `team up` reports `lost:… 没有 {resume_args}` | reference the placeholder where the CLI expects it, e.g. `TEAM_PM_CMD='codex {resume_args} {prompt}'` (for codex: `TEAM_PM_RESUME_ARGS='resume --last'`) |
688
+ | the CLI has its own session store and you restored that instead | teamsmith's `{session_id}` is *teamsmith's* dispatch id, not the vendor's session id | keep using the vendor's own resume flag as above; `team thread <agent> "…"` and `docs/team/**` stay the portable handoff |
689
+ | you want a **new** conversation this once (e.g. to leave the init session behind as the kickoff record) | `team up --fresh-pm` skips every continuity path for this launch: built-in Pi drops `-c` **and** `--session-id`, a custom template renders `{resume_args}` empty. It is the highest priority for that launch (`TEAM_PM_SESSION_ID` / `TEAM_PM_RESUME_ARGS` do not apply), it is never written into the config, and the old session file stays in history | run `team up --fresh-pm`; `team up --print` shows `会话判定:fresh:--fresh-pm(…)` and the exact command (no `-c`) before you commit to it |
690
+ | `team up` prints `检测到同目录(…)还有 N 个活着的 pi 会话:pid …` | a session whose cwd is the main worktree is still running — most often the `teamsmith-init` conversation, which lives in exactly that directory. The default `-c` would continue *its* session file from a second process (two writers, history can overwrite itself). The probe is read-only and does **not** block the start | exit that session first, or start the PM with `team up --fresh-pm`; the warning is advisory, so `team up` still starts the PM |
691
+
692
+ `team up --print` never starts anything: it prints the briefing, then `会话判定:<fresh:…|continued:…|lost:…>` and the fully rendered launch command, so "will this continue the old conversation, and with which flags?" is answerable without touching tmux.
693
+
694
+ ## 16. The panel (`team monitor`) does not start, or looks wrong
695
+
696
+ The panel is a committed Ink bundle (`scripts/panel/panel.js`) run by a JavaScript runtime. Four things explain
697
+ almost every report:
698
+
699
+ | Symptom | Cause / fix |
700
+ |---|---|
701
+ | `team monitor` exits non-zero with `缺少 JS 运行时` / `JS 运行时版本过低`, and `team pulse up` refuses to create a window | **No runtime is a hard failure, not a degraded panel** (an empty panel reported as success is the false green this project refuses). Install `node` ≥ 20 or `bun` ≥ 1.3, or point `TEAM_JS_BIN` at an absolute path. `TEAM_REQUIRE_JS=0` only downgrades the `team doctor` row — the panel still needs a runtime in every mode |
702
+ | `team doctor` fails with `JS 运行时` but `node --version` works in your shell | the window/shell `PATH` is not your interactive one (a runtime installed under `~/.bun/bin` is the usual case). Set `TEAM_JS_BIN=/absolute/path/to/node` (or to bun); `team paths` prints the resolved `js_runner` |
703
+ | the activity column appeared and the layout looks more crowded than before | this is the one deliberate default change of the panel rewrite (v1.38.0): `TEAM_MONITOR_ACTIVITY` now defaults to `1`. `team monitor --no-activity` switches it off for one run, `TEAM_MONITOR_ACTIVITY=0` for the project — that restores the pre-v1.38.0 layout exactly |
704
+ | the panel renders nothing useful in a plain terminal, a pipe or a `less` session | `TEAM_MONITOR_UI=text` forces the plain-text frame (no escape sequences, no screen clear); stdout not being a TTY already selects it automatically. `team monitor --print` is the same frame as a one-shot observer, and `team monitor --json` is the machine-readable form |
705
+ | you edited something under `scripts/panel/src/` and the panel did not change | the sources are never on the runtime path — `panel.js` is what runs. A maintainer rebuilds it with `bun install --frozen-lockfile && bash skills/teamsmith/scripts/panel/build.sh` (needs the network and Bun ≥ 1.3), then commits the regenerated bundle. `node skills/teamsmith/scripts/panel/panel.js --version` and the bundle header name the pinned versions and the build command, so a stale artifact is visible without rebuilding |
706
+
707
+ ## 17. A long task (a gate, a build) has nobody to tell when it finishes
708
+
709
+ `TEAM_GATES` on a real project can take tens of minutes. Run it inside the agent's turn and the turn is occupied;
710
+ walk away and nobody knows it finished. A run **selected** for a known diff is much cheaper: `bash
711
+ skills/teamsmith/tests/smoke.sh --paths <path…>` runs the sections that path affects and lists the ones it did not run
712
+ (see [protocol.md](protocol.md) §9b-2) — the *full* suite is still the delivery/review gate.
713
+
714
+ **Lane 0 · the team's own lane (default on the built-in Pi paths, nothing to install).** Both the worker and the PM
715
+ Pi commands load `extension/team-bg.ts`, which gives the session `team_bg_run` / `team_bg_wait`: a detached job
716
+ with a bounded `state/bg/<id>.log`, exactly one merged wake-up per batch of finished jobs, silence for harvested
717
+ jobs, and one `settled-with-unharvested=<n>` line per turn end in `state/bg.log`. Runbook:
718
+ [workflows.md](workflows.md) §E2. There are two lanes, and both ship with teamsmith — the skill never asks anyone to install a third-party plugin.
719
+ When the team lane is not available (a custom adapter without `{bg_ext}`), use the tmux-window lane:
720
+
721
+ | | Lane A · the team's own background lane (`team-bg`) | Lane B · a background tmux window |
722
+ |---|---|---|
723
+ | What runs | the **agent** starts the job, ends its turn, and is woken when the job exits | the PM starts the command in a dedicated tmux window and reads the tail — or the runner writes one inbox line (`team notify pm --from <agent> --from-file <file>`) when it is done |
724
+ | Who gets woken | the bundled extension wakes the agent session that started the job | the PM looks at the window / reads the inbox |
725
+ | Cost | none — the extension ships with the skill | one window, no dependency |
726
+ | Watch out | the four rules below are what the extension enforces | a stray window is easy to lose: name it, and make it print a one-line verdict at the end (`echo "GATES rc=$? <ID>"`) |
727
+
728
+ `team doctor` reports which harness this project runs (`harness`) and which plugins the project already carries —
729
+ that second row is labelled `已装插件 packages` and is **information, never a recommendation**. The only package
730
+ teamsmith asks for is magic-context, and `doctor` checks it on its own row.
731
+
732
+ Four rules the background lane has to enforce. They come from the failure modes the ecosystem's background-job
733
+ extensions wrote down in their issue trackers:
734
+
735
+ 1. **The agent must start the job.** A job a human starts directly does not wake a model turn when it finishes; only
736
+ an agent-side start wakes the agent that is waiting for the result.
737
+ 2. **Merge the notifications.** Several jobs finishing together must arrive as one notice; one notice per job means
738
+ one extra turn per job.
739
+ 3. **Deliver when idle.** The completion notice must land when the agent has no tool call in flight (a
740
+ `followUp`-style delivery), not in the middle of one.
741
+ 4. **Already harvested → say nothing.** If the agent waited for the job, it already has the result; notifying again
742
+ spends a turn on information it has.
743
+
744
+ That is why the lane is implemented in-house (no third-party package on the team’s critical path), with an
745
+ explicit harvest ledger under `state/` (`state/bg.log` + `state/bg/<id>.log`): the rules have to be enforced by the
746
+ code that owns the jobs, not by convention.
747
+
748
+ ## 18. tmux isolation: the gate, the "fake isolation" shapes, and the container rule
749
+
750
+ Every PM/worker window puts `scripts/shim/tmux` first on `PATH` (M36; the grant model was rebuilt in M67). The
751
+ shim logs every call to `state/tmux-calls.log` (time, resolved socket, `TMUX`/`TMUX_TMPDIR`, argv, pid/ppid/cwd,
752
+ action) and **decides a destructive call by the object it targets**: on the **default socket**
753
+ (`/tmp/tmux-<uid>/default` — the server every project on the machine shares) `kill-server` and `kill-session -a`
754
+ are always refused (exit 64), and `kill-session`/`kill-window`/`kill-pane` run only when the effective `-t` (last
755
+ one wins; `-t x` and `-tx`) names a session that is literally the caller's own `TEAM_SESSION` **and** that identity
756
+ is bound to the caller (`TEAM_ROOT` or `TEAM_MAIN_ROOT` resolves to the caller's cwd or an ancestor of it).
757
+ Everything unprovable is refused. **No environment variable grants anything**: `TEAM_ALLOW_DESTRUCTIVE_TMUX` is
758
+ retired — the shim does not read it, the CLI no longer exports it, it stays in the settings schema as a
759
+ non-writable tombstone, and `team doctor` names the residue when a running server's global environment still
760
+ carries it. The single in-band escape is the argv token `--teamsmith-allow-destructive`, placed **before** the
761
+ subcommand: it is consumed and stripped before the exec, never exported, and logged `act=explicit-flag` (after the
762
+ subcommand the same word is data, e.g. a `send-keys` payload). The actions are exactly `pass`, `allowed-owned`,
763
+ `refused` and `explicit-flag`. Read-only commands are never refused.
764
+
765
+ That log is a **traffic record**, not project ledger state: its content is the caller's own argv and resolved
766
+ socket, so the gate's fixture-trace scan (`real_ledger_hits` in `tests/smoke.sh`) excludes exactly that path — a
767
+ fixture's session name recorded there is the log doing its job, while every other file under `state/` (and every
768
+ name-sharing sibling, e.g. `state/tmux-calls.log.1`) stays in scope. The scan's second exclusion is the gate's
769
+ background-job logs, and it is exact too: only **`.pi/team/state/bg/**`** is out — a `bg/` directory anywhere else
770
+ (`docs/team/inbox/bg/`, `state/nested/bg/`) is ledger state and is named. The log is bounded: past 2000
771
+ call lines the oldest are dropped and the newest 1000 stay, and when that happens the surviving file's **first
772
+ line** is a rotation marker `<ISO time> · rotation · dropped=<N>` — the cumulative number of call lines no longer
773
+ in the file, counted from the last marker whose `N` was readable — so a call missing from the log can be told
774
+ apart from one that never happened. The marker is not a call line (it carries no `act=`), it does not count toward
775
+ the 2000-line bound and it never survives the next rotation; when a marker's `N` cannot be read (empty,
776
+ non-numeric, or too large to parse back without overflow) the count restarts at zero — the gate never writes a
777
+ number it did not read back.
778
+
779
+ The gate models tmux's **real** resolution, fallbacks included (tmux 3.7: the socket template is the path list
780
+ `$TMUX_TMPDIR:/tmp/`, each item env-expanded and `realpath()`-ed, the first usable item wins — M41 measured the
781
+ whole matrix). So "I set `TMUX_TMPDIR`" is *not* isolation by itself:
782
+
783
+ | what the command says | what tmux really does | verdict |
784
+ |---|---|---|
785
+ | `TMUX_TMPDIR=<dir that does not exist>` with `kill-server` | silently falls back to `/tmp/tmux-<uid>/default` | **fake isolation** — this kills the shared server; the gate refuses (`exit 64`) and names the reason (6th death, 2026-09-19) |
786
+ | `TMUX_TMPDIR=<a regular file>` (or a dir with no room to `mkdir`) | errors out before creating a server (never falls back) | no private server either; the gate conservatively refuses — `mkdir -p` the directory |
787
+ | `TMUX_TMPDIR=<existing directory>` | `<dir>/tmux-<uid>/default` | real private server; the gate passes it (`act=pass`) |
788
+
789
+ The safe incantation for destructive tmux work on the host is exactly:
790
+
791
+ ```sh
792
+ env -u TMUX -u TMUX_PANE TMUX_TMPDIR=<a directory you already mkdir -p'ed> tmux …
793
+ ```
794
+
795
+ Two hard rules follow (2026-09-19: the 6th and the 8th default-server deaths):
796
+
797
+ 1. **Destructive fixtures and probes go into the container**:
798
+ `bash skills/teamsmith/tests/container-tmux.sh -- <cmd>`. The host socket directory is not mounted inside, so an
799
+ unisolated `kill-server` cannot reach the host by construction. On the host only the "private directory already
800
+ `mkdir -p`ed" shape above is allowed, and it must go through the shim's `PATH`; a fixture that probes a
801
+ **refusal or an allowed-owned verdict** against the default socket pins `TEAM_TMUX_REAL` to an argv-recording
802
+ stub, so a wrong verdict executes a shell script and never a server (M67).
803
+ 2. **Never call tmux by absolute path for anything destructive.** The gate is a `PATH` executable: `/usr/bin/tmux
804
+ kill-server` bypasses both the log and the refusal (the 8th death was exactly that, with an uncreated
805
+ `TMUX_TMPDIR`). `tests/tmux-lint.pl` reds any literal absolute-path mutating call, even when it carries `-L/-S`
806
+ evidence. `command tmux` / `env tmux` are **not** bypasses (they still resolve through `PATH`); a variable holding
807
+ the resolved real binary (`"$REAL_TMUX"`, `${TMUX_BIN}`) is the intended exception and is judged by the normal
808
+ isolation rules.
809
+
810
+ ### 18.1 The gate's own precondition (P162): prove isolation before any destructive call
811
+
812
+ The rules above are the *product's* gate (the shim). The suite had the same hole in its own fixtures: on
813
+ 2026-10-02 the shared server died four times, each death overlapping a gate run, while our tmux audit showed zero
814
+ kill-class calls — the shape of a fixture whose private socket silently did not take effect. So the suite now
815
+ proves before it acts.
816
+
817
+ `tests/lib/tmux-iso.sh` decides exactly three conditions:
818
+
819
+ 1. **The target path exists and belongs to this run** — `TMUX_TMPDIR` is an existing directory (or the `-L` name
820
+ makes the socket private while the directory is `/tmp`), the socket path is within the AF_UNIX limit of 107
821
+ bytes, and with `--own-root` the path is under that root; a live server's socket file must be present.
822
+ 2. **The socket tmux itself resolves is that one** — observed with `display-message -p '#{socket_path}'`; when no
823
+ server is up, the path the real tmux names in its own `error connecting to …` / `no server running on …`
824
+ message. The proof is about the path a kill would hit, not about server liveness (a teardown often runs after
825
+ the last session is gone).
826
+ 3. **It is not the shared default** (`/tmp/tmux-<uid>/default`) and not the caller's own default socket.
827
+
828
+ Any failure is a **hard stop**: one loud line, one audit line (section, which condition, the actual socket), the
829
+ section recorded as `SKIP(前置不成立:…)`, `exit 2` — and the destructive call never runs. There is no bypass:
830
+ `--force` and every `TEAM_*` variable are ignored (`TEAM_TMUX_ISO_LOG` only moves the audit line). In
831
+ `tests/smoke.sh` a `tmux()` wrapper routes every in-process `kill-server`/`kill-session`/`kill-window`/`kill-pane`
832
+ through it (non-destructive calls pass through unchanged), `0c`'s isolation self-check became a precondition, the
833
+ `EXIT` trap's teardown uses the soft form (loud refusal, never `exit` inside a trap), and the fixtures
834
+ (`pm-box-real.sh`, `flip-*`, `panel-*`, `death-cause.sh`, `lib/tmux-cap.sh`) use the same library.
835
+
836
+ Section `0h` pins the falsifiable sides: `TMUX_TMPDIR` pointing at a nonexistent directory (the #1250 fallback
837
+ shape), a socket path over 107 bytes, the reverse leg (normal isolation → a real private `kill-server`), a shadow
838
+ mutation that forces the predicate true (the red sides must stop firing), no-bypass probes, and a nested smoke on
839
+ a deep `TMPDIR` that hard-stops in `0c` and records that section as `SKIP`. `tests/container-tmux.sh` is
840
+ deliberately untouched: its destructive calls run inside the disposable container, which is isolation by
841
+ construction.
842
+
843
+ What to do when you hit it: read the audit line (it names the actual socket), `mkdir -p` the directory you meant,
844
+ and pass `--own-root`/`--caller-tmpdir`; never work around the stop by exporting a variable — that path does not
845
+ exist.
846
+
847
+ ## 19. A command refuses because of an inherited identity ("the directory owns the identity")
848
+
849
+ `team` derives the project from the directory it runs in (`--root <dir>` if given, otherwise the cwd): root = the git
850
+ worktree, main worktree = its git common dir, project name/session = that project's config. Inherited `TEAM_*`
851
+ identity variables (`TEAM_ROOT`, `TEAM_MAIN_ROOT`, `TEAM_PROJECT`, `TEAM_SESSION`) never win over that silently.
852
+
853
+ Two real incidents on 2026-09-19, same shape: a shell carried **this** project's identity while sitting in another
854
+ project's directory. `team up` was refused after resolving the wrong project (the guard held, but the user had to
855
+ clean their environment), and a pulse started that way rendered **this** project's board inside the other project —
856
+ no guard, no warning, silently the wrong project.
857
+
858
+ What you see today, and what to do:
859
+
860
+ | Symptom | Cause / fix |
861
+ |---|---|
862
+ | `身份冲突被拒:当前目录属于 'X',而继承的环境指向别的项目` and a refusal to run | the inherited identity names another project. `env -u TEAM_ROOT -u TEAM_MAIN_ROOT -u TEAM_PROJECT -u TEAM_SESSION team <cmd>` — or `cd` to the project you actually mean. Read-only forms (`team paths`, `--print`, `--dry-run`, `status`, `inbox`, …) always resolve by the directory and print the mismatch instead of refusing; `TEAM_ALLOW_FOREIGN_IDENTITY=1 team <cmd>` runs anyway and records it in `state/watchdog.log` |
863
+ | an agent inside its worktree was refused, or `team notify` stopped working in a worker window | it should not: a **sibling worktree of the same project** (the PM's main-worktree `TEAM_ROOT` with a cwd inside `.worktrees/<agent>`) is not a mismatch — the check compares projects (git common dir), not paths |
864
+ | a panel/pulse renders another project's board, or `team pulse up` puts the window in the wrong session | fixed by the same rule: windows started by the CLI carry the **destination** directory's identity, and the panel strips inherited identity variables from every child it spawns. If you still see a foreign board, read the panel's own one-line warning (stderr of the pulse window, plus `state/panel.log`) — it names the ignored value |
865
+
866
+ ## 20. The same inbox wake arrives twice (replayed messages)
867
+
868
+ **Symptom**: an agent (usually the PM) gets the same “N new team message(s)” wake more than once within
869
+ seconds, and `state/inbox-watch.log` shows consecutive `wake n=42 …` lines with identical `kinds=` while
870
+ `total=` jumps by the whole batch each time.
871
+
872
+ **What happened**: the watcher's spool (`state/inbox-watch/<key>.wake`) **shrank** underneath it — something
873
+ outside the repo truncated/rewrote/replaced the file (an editor save, a sync tool, a manual cleanup). Every
874
+ in-repo writer appends (`>>`), so a smaller file is always external. Before M43 the watcher answered a shrink
875
+ with a silent `offset = 0` and re-read the whole file: one external rewrite = one full replay.
876
+
877
+ **Since M43/P81** this is bounded and auditable, and repeats are impossible: the shrink itself gets a ledger
878
+ line, a rescan from 0 drops anything the **delivery journal** (`state/inbox-watch/<key>.deliver`) already
879
+ covers (that journal, not `<key>.seen`, is the durable memory — recorded *before* every send and surviving
880
+ restarts), genuinely-new lines are capped to the last `TEAM_INBOX_WATCH_REPLAY_MAX` (default 20) with the
881
+ skip counts stated in the wake text, and an all-replay rescan sends **no wake** at all. `total=` counts
882
+ real deliveries only. Semantics, journal format and the full counter list:
883
+ `references/agent-adapters.md` §4a.1 / §4a.1c.
884
+
885
+ **If you still see duplicates**: check the ledger for `spool shrink` / `rescan` / `replay suppressed` lines —
886
+ they tell you exactly what was re-read, suppressed, and delivered. No such lines + duplicates = a second
887
+ watcher is registered for the same target (look for two `started target=…` lines without an intervening
888
+ `stopped`, i.e. a zombie session that never logged its shutdown) — or the duplicate came from the session
889
+ side (a queued `followUp` copy presented late). **The wake text tells them apart**: each wake prints its own
890
+ `#<seq>` and every row carries the source line's absolute time and its identity. Two rows with identical
891
+ payload text but different ids/source times are two distinct lines (the pulse's re-nudge shape); an
892
+ identity seen twice in the wake texts is a replay you can name and prove from the journal file.
893
+
894
+ **“Was it actually delivered?” is now a file question (P81).** Read
895
+ `state/inbox-watch/<key>.deliver` next to the wake's `seq=`: `sent seq=<n>` means the session API accepted
896
+ that wake, `failed seq=<n>` means the message never entered the session (it is retried once per tick, until
897
+ the freshness horizon), and `intent seq=<n>` with neither means the outcome is unknown — the line is **never**
898
+ re-sent (ledger `inflight assumed n=`), so if you see no `sent`, treat the wake as unconfirmed and re-read
899
+ the durable inbox line instead of waiting for a second doorbell. The other journal counters an operator may
900
+ meet: `deliver blocked` (the journal could not be written → nothing was sent, by design), `torn tail` (a
901
+ crash in the middle of a record → unknown outcome, never re-sent), `recovery n=` (a previous session read the
902
+ line and died before sending → exactly one recovery wake), `unprovable n=` (the identity is older than the
903
+ journal's compaction floor → never woken again), `replay suppressed n= reason=<normal|rescan>`,
904
+ `retry stale=<n>`, `baseline swallowed n=` and `journal compacted … floor=`. Anchor docs and the exact record
905
+ shapes: `references/agent-adapters.md` §4a.1c.
906
+
907
+ **A repeated shrink with nothing delivered is a defect, not a busy spool.** When the ledger shows
908
+ `spool shrink …` again and again while `rescan … deliver=0`, the offset is not converging — that is the
909
+ 2026-09-19 shape (a byte-wise preview cut writing an invalid line, plus a decode→re-encode offset that
910
+ overshot the file size by one byte). The invariants that make it impossible are in
911
+ `references/agent-adapters.md` §4a.1b; if you see the pattern again, treat it as a bug in the watcher's offset
912
+ arithmetic, not as "the spool is being rewritten".
913
+
914
+ **Lines that are too old do not wake you — on any path.** The durable inbox file keeps them; the wake is
915
+ skipped (`classify stale=<n> …`, and a *recovered* line that has since gone stale is counted `stale=1`, not
916
+ `recovery=`). `TEAM_INBOX_WATCH_STALE_SEC` (default 900) sets that horizon.
917
+
918
+ ## 21. pi announces a new version → the input box reads as BUSY
919
+
920
+ **Symptom**: a PM/worker Pi pane is idle with an empty box, yet `team say` / `team notify` report **`queued`**
921
+ (the message lands in `state/outbox/` instead of the box), and the real-pi fixture says so:
922
+
923
+ ```
924
+ ✗ M28 容器里跑真 pi 体检:输入框判据 + 收回在真实现场成立(找不到 [RETRACT=ok])
925
+ ✗ M28 容器里跑真 pi 体检:空闲空框被判 EMPTY(没被误判成忙)(找不到 [verdict=EMPTY])
926
+ ```
927
+
928
+ The fixture's frame shows why — three lines of chat chrome sit **above** the box:
929
+
930
+ ```
931
+ ──────────────────────────────────────────────────────────── ← banner DynamicBorder
932
+ Update Available
933
+ New version 0.86.0 is available. Run pi update
934
+ Changelog: https://pi.dev/changelog
935
+ ──────────────────────────────────────────────────────────── ← banner DynamicBorder
936
+ ──────────────────────────────────────────────────────────── ← the real box top border
937
+ deepseek-flash Deepseek max ← hint row (inside the box)
938
+ ──────────────────────────────────────────────────────────── ← box bottom border
939
+ ```
940
+
941
+ **Cause** (real, not a fixture flake): pi's update banner is drawn into the chat container with
942
+ `DynamicBorder`, which renders **the same thing as the box borders: one full-width row of `─`, equal in
943
+ width to the pane**. The reader anchors the box by taking the **highest** equal-width `─` row above the
944
+ cursor (deliberately conservative: a draft may draw an equal-width rule *inside* the box, and treating that
945
+ as the top border would exclude the draft → empty → paste into a non-empty box). With a banner present the
946
+ highest row is the banner's opening border, so the box becomes everything down to the bottom border: its
947
+ content is the banner text plus the box's own top border → `BUSY` → queued.
948
+
949
+ **Since M45** the two measured banners are recognized and excluded from the geometry (and from the transcript
950
+ the delivery confirmation searches): the block is only accepted when the opening `─` row is followed by the
951
+ paired header lines (`Update Available` + `New version … is available. Run pi update`, or
952
+ `Package Updates Available` + `Package updates are available. Run pi update --extensions`), the row directly
953
+ above the closing equal-width `─` row is the matching tail (`Changelog: …` / a `- <package>` item preceded by
954
+ `Packages:`), and the block lies entirely above the cursor. The release note inside the block is arbitrary
955
+ markdown and is never matched by content. If skipping the marked rows leaves **no box at all**, the geometry
956
+ falls back to the unmarked (conservative) behaviour — never to `NONE`, because `NONE` means the guard is off
957
+ and the next paste would land in a human's draft.
958
+
959
+ **What to do** (none of this is required for the guard to work — since M45 it tolerates the banner):
960
+
961
+ - Nothing. The banner is cosmetic: the box reader skips the recognized banner blocks, so an idle box keeps
962
+ reading as `EMPTY` while the notice is on screen. The real-pi fixture proves it on the live thing:
963
+ `bash tests/pm-box-real.sh` runs pi **with its update checks on** (the user's call: never suppress the
964
+ notice) and prints `banner=present|absent`, `banner_rows=[…]` (which block rows were recognized) and
965
+ `M45 idle-read=EMPTY`; it exits non-zero when the idle box is not read as empty. `M45_REQUIRE_BANNER=1`
966
+ additionally demands that this run really had a banner, so an evidence run cannot silently degrade into a
967
+ banner-free frame.
968
+ - `pi update` if you simply want the notice gone (it is only shown while a newer release exists).
969
+ - If you *choose* to silence the checks (nothing in the gate does): **`PI_SKIP_VERSION_CHECK=1`** disables the
970
+ Pi version check (`docs/settings.md`); `--offline` / `PI_OFFLINE=1` additionally disables the extension
971
+ **package** update check (`Package Updates Available`), which `PI_SKIP_VERSION_CHECK` does not cover.
972
+ Neither is used by the fixture — the banner shape is part of what is being tested.
973
+
974
+ **Honest edge (not covered)**: only these two banner shapes are recognized. Other chrome built from the same
975
+ `DynamicBorder` primitive — pi's own post-update **`What's New`** block (a rule, the header, arbitrary
976
+ changelog markdown, a rule), extension "custom message" boxes — still enlarges the box and therefore still
977
+ reads as `BUSY` (queued, never glued). It cannot be resolved by shape alone: a rule pair with text in between
978
+ is indistinguishable from a draft that draws rule lines itself, and the conservative direction is to treat it
979
+ as content. The failure mode is a **bounded queue**, not a glued message: messages wait in `state/outbox/`
980
+ (`team status` / `team digest` show the line) and go out once the block leaves the frame (it is chat history,
981
+ so it scrolls away as the session talks; `What's New` only appears on the first start after an update).
982
+ Report such a frame (`bash skills/teamsmith/tests/pm-box-real.sh --keep`) so the shape can be added as a
983
+ measured case next to these two.
984
+
985
+ ## 22. Messages are not sent automatically: check the watcher registration first
986
+
987
+ **Symptom**: `team say`, a web knock or a worker's turn-end notification never reaches the PM (the PM
988
+ "looks alive"), and messages pile up in the PM's box or in `state/outbox/`.
989
+
990
+ **Why this shape exists**: a Pi session receives automated messages through the inbox-watch extension
991
+ (`extension/team-inbox-watch.ts`; §3 and `references/agent-adapters.md` §4a). At `session_start` the
992
+ extension writes a readiness registration (`state/inbox-watch/<key>.reg`); senders route through the watch
993
+ channel only while that registration is alive. Without it, delivery silently falls back to the paste path —
994
+ which defers while the box holds a draft and can end in a `draft-raced-left` hold. The fallback itself is by
995
+ design; a **silent** fallback is not (M46).
996
+
997
+ **First three commands**:
998
+
999
+ | Command | What to look for |
1000
+ |---|---|
1001
+ | `team doctor` | the `投递通道 inbox-watch` line — `pass` means the PM's registration is alive, a `!` line names the reason and the restart |
1002
+ | `team status` / `team digest` | one `投递通道降级: …` line, same reason |
1003
+ | `team outbox list` | what is waiting; held entries whose target window no longer exists are marked `target=gone` |
1004
+
1005
+ The pulse panel shows the same warning as a line under the status band (the `delivery_warning` field).
1006
+
1007
+ **Where the reason is recorded**: when the extension skips setup it writes `state/inbox-watch/<key>.skip`
1008
+ (`target`, `session`, `window`, `expect`, `reason`, `detail`, `pid`, `cwd`, `heartbeat`) and a
1009
+ `skip setup: …` line in `state/inbox-watch.log`. A record is believed only while the process that wrote it
1010
+ is alive and its `cwd` is inside this project (cwd missing → fresh heartbeat); a leftover from a dead
1011
+ process is ignored, and a successful registration deletes the records for its target.
1012
+
1013
+ **The two reasons you will actually see**:
1014
+
1015
+ - `会话名不符`: the project's `TEAM_SESSION` does not match the real tmux session name (the project was
1016
+ copied/renamed, or the PM was started inside a differently named session). The extension refuses to serve
1017
+ a session this project does not own; fix the name (rename the session or correct `TEAM_SESSION`) and the
1018
+ registration appears on the next `team up` / `team resume`.
1019
+ - `PM 进程在跑但没有注册(扩展未加载 / 进程启动早于扩展安装)`: the PM's pi process never loaded the
1020
+ extension (started without `-e <skill>/extension/team-inbox-watch.ts`, or with an older skill). Restart
1021
+ the process (`team up` for the PM, `team resume <agent>` for a worker).
1022
+
1023
+ This is not `/reload` work. Pi hot-reloads extensions from its auto-discovery locations
1024
+ (`~/.pi/agent/extensions/`, `.pi/extensions/`); `pi -e` is a startup argument ("used for quick tests" in
1025
+ Pi's own extension docs). The teamsmith launch paths pass all extensions with `-e`, so after an extension is
1026
+ added — or after its startup-time behaviour changes — the session must be restarted. `/reload` still
1027
+ refreshes the *skill text* (`SKILL.md` / `references/**`); it does not make a missing `-e` extension appear.
1028
+ An earlier revision of this skill told the reader to wait for `/reload`, which is what kept a worker in a neighbouring project
1029
+ PM waiting while its messages silently took the paste path.
1030
+
1031
+ **The watcher never treats another project's state as home**: its state directory is anchored to the
1032
+ project derived from the process's cwd (the git main worktree). An inherited `TEAM_STATE_DIR` that points at
1033
+ another teamsmith project's state is refused, and the refusal is recorded in the derived project's ledger
1034
+ (`TEAM_IDENTITY_CONFLICT inherited TEAM_STATE_DIR=…`).
1035
+
1036
+ **The slow path is not a dead end**: while no watcher is registered, queued entries are retried by the next
1037
+ drain (every guarded send, every pulse tick, and `team outbox flush`), so a busy box delays messages instead
1038
+ of stranding them. Two cleanup exits exist for the leftovers: a held entry whose payload is no longer in the
1039
+ target box is recorded as `residue-clear … why=box-clear|target-gone` in `outbox/HOLDING.log` by the next
1040
+ drain (the status line stops claiming a residue that is gone), and held entries whose target window no
1041
+ longer exists are dropped by the explicit `team outbox drop gone` (it names every file it drops). Nothing
1042
+ ever re-pastes a `draft-raced`/`unconfirmed` entry — that is terminal by spec; if its payload is still
1043
+ sitting in a human's box, the human submits or clears it, or drops the entry.
1044
+
1045
+ ---
1046
+
1047
+ ### 22b. The watcher registered *unsuccessfully*: the degraded record and the inotify quota (M53)
1048
+
1049
+ Registration can fail for a reason outside the project: the host's per-user inotify watch budget is
1050
+ exhausted (on this box Syncthing and `codium` hold most of `fs.inotify.max_user_watches`), so a **new**
1051
+ process's `fs.watch` throws `ENOSPC` while already-registered processes keep working. That asymmetry is what
1052
+ "some sessions receive, some do not" looks like.
1053
+
1054
+ **What the failure now leaves behind** (all of it auditable):
1055
+
1056
+ | Trace | Where | Fields |
1057
+ |---|---|---|
1058
+ | ledger line | `state/inbox-watch.log` | `errno=…`, `watches=<used|unknown>/<max>`, `poll_ms=…`, `fallback=polling`, and `forced=1` when a fixture produced it |
1059
+ | durable record | `state/inbox-watch/<key>.degraded` | `reason=watch-unavailable`, `errno`, `watches`, `poll_ms`, `forced`, `since`, `pid`, `cwd`, `heartbeat` |
1060
+
1061
+ A record is believed only while the writing process is alive and its `cwd` is inside this project — **a stale
1062
+ record is not evidence**, and a successful registration (or a clean exit) deletes it.
1063
+
1064
+ **Delivery continues**: the poll timer stays installed on the failure path, so a new spool line still wakes
1065
+ the session once per poll interval, with the **same message shape** as the watch path. The fallback is a
1066
+ proven guarantee, not an accident — the harness forces the failure and asserts the wake within one interval
1067
+ (S22/S23), and removing the poll timer in a throwaway copy turns that assertion red.
1068
+
1069
+ **Where to look, and what to do**:
1070
+
1071
+ | Command | What you get |
1072
+ |---|---|
1073
+ | `team doctor` | the degraded-channel warning (only for a *live* record) **and** the `inotify 额度` headroom line: quota, used, and a probe verdict |
1074
+ | `team status` / `team digest` | the same sentence, one line |
1075
+ | fix | raise the budget — `sudo sysctl -w fs.inotify.max_user_watches=524288` (persist it), or stop the watcher that holds tens of thousands of watches (e.g. Syncthing's "Watch for Changes" on large trees) |
1076
+
1077
+ Without a runtime the doctor line says `unavailable` and **never** `ok`. The gate follows the same rule: an
1078
+ unavailable watcher premise prints a **visible SKIP** with the measured quota, and
1079
+ `TEAM_IW_REQUIRE_WATCH=1` turns that same premise into a red — so CI can be strict while a developer's box
1080
+ stays honest.
1081
+
1082
+ ## 23. Two BOARD.md rows share one id (or the kanban cursor froze on one of them)
1083
+
1084
+ **What you see**: the console's board page (and the work page's board block) highlights two rows at once and
1085
+ `↑`/`↓` stops on the first of them; `board ls`, `digest` and `doctor` print
1086
+ `BOARD 有重复 ID:M4.3 ×2、M6.3 ×2、V1.1 ×2`; `team board add <ID> …` refuses with
1087
+ `BOARD 里已经有 <ID>(状态 todo · 「…」):没有改动`.
1088
+
1089
+ **Why it happens**: the places that matter address a BOARD.md row by its **id** — the pending-report
1090
+ heuristic, `reviews/<ID>.md`, `team board set <ID> <status>` — and historical boards really do share ids
1091
+ (different tasks under one milestone id: this project's own board carries `M4.3`, `M6.3` and `V1.1` twice).
1092
+ The console used to key its focus by the bare id too, so two such rows lit up together and the walk never
1093
+ left the first one (M48; the brief that built the board row could also be created and then `board add`ed a
1094
+ second time).
1095
+
1096
+ **What the tool does now** (nothing to do to keep working):
1097
+
1098
+ - the console's focus is a `{lane, id, nth}` **row** reference: `↑`/`↓` walks every drawn row — two rows
1099
+ with one id are two stops — only the focused row carries the `›` cursor, and a row that left the board
1100
+ falls back to the first row with that id, then its lane's first card, then the first lane;
1101
+ - `team board add <ID> …` refuses a second row for an existing id, names that row's status and title, and
1102
+ leaves the file byte-identical (the same "a refusal writes nothing" rule as `board set` with an unknown id);
1103
+ its refusal names the right entry for the common intent — `team board assign <ID> <agent>` gives a row an agent
1104
+ **in place** (no second row, no other column touched; the old way to "assign" was to add a row, which is how
1105
+ these duplicates appeared);
1106
+ - `--allow-dup` is the explicit escape hatch: the row is written and `state/watchdog.log` gets an audit line;
1107
+ - `board ls`, `team digest` and `team doctor` report the duplicates they find (doctor warns, it does not fail).
1108
+
1109
+ **How to handle a duplicate**:
1110
+
1111
+ - **one task, two rows** → fix the id (rename the row, or fold the duplicate into one): `board add` refuses the
1112
+ next attempt, and both `board set <ID> <status>` and `board assign <ID> <agent>` address by id — they write
1113
+ **every** row carrying that id, so a status or an agent you set lands on both rows;
1114
+ - **a row needs an agent** → `team board assign <ID> <agent>` (not another `board add`; that one is refused);
1115
+ - **two tasks that genuinely share a milestone id** → leave the data alone (that is what this project does) and
1116
+ pass `--allow-dup` for new rows; remember that `reviews/<ID>.md` and the pending-report heuristic are keyed by
1117
+ the id too, so both rows share one review namespace, and the detail view opens the same document for both.
1118
+
1119
+ The fixtures that pin this are `tests/panel-b3.sh board` (two rows with one id: one cursor, both reachable,
1120
+ both walks) and `tests/smoke.sh` §4c (refusal, `--allow-dup`, the three visible reports); `tests/flip-m48.sh`
1121
+ proves both go red when the row identity / the check is removed.
1122
+
1123
+ ## 24. The performance suite refuses to call itself the "reference environment" — the trust boundary (M66 → M69 → M73)
1124
+
1125
+ `bash skills/teamsmith/tests/perf.sh --in-container` records its verdicts under the name "reference
1126
+ environment" only when the pinned image itself proves that is where it runs. Three pieces of evidence, all
1127
+ baked into the `ci/Containerfile` image and required by `perf.sh`, each named when missing or wrong (exit 3,
1128
+ before the lock or any measurement — a host mistake never even touches the lock):
1129
+
1130
+ 1. the env signal `TEAM_PERF_PINNED_CONTAINER=1` (the image's `ENV`) — necessary but never sufficient: an
1131
+ exported variable is forgeable from the host (M64 F2, verified: the host exported the signal and the
1132
+ suite described the host's node as the "reference environment");
1133
+ 2. the marker file `/etc/teamsmith-gate-image`, byte-for-byte equal to the closed token (the image's `RUN`
1134
+ drops it in the rootfs; `/run/.containerenv` cannot play this role — the dev host is itself a distrobox
1135
+ and carries that file too);
1136
+ 3. the marker file must **not be a mount point** (`perf.sh` parses `/proc/self/mounts`): the token is
1137
+ public — it sits in `ci/Containerfile`, and `perf.sh` can only trust content that arrived with the image,
1138
+ so anyone can `-v`-mount a byte-identical file and matching content proves the file, not the rootfs
1139
+ (M64 F2 round three: foreign image + mounted token + ENV=1 ran the whole suite green under the reference
1140
+ name). In the real image the marker lives on the overlayfs root and has no mounts-table entry; the
1141
+ suite's own wrapper mounts only `/work` (and the main repo for worktree `.git` resolution), never the
1142
+ marker.
1143
+
1144
+ **In scope (visibly refused)** — every *accidental* shape: a bare host run (M66), host-exported variables
1145
+ (M69), a stale image without the marker (M69, told to rebuild), tampered marker content (M69), and a mounted
1146
+ marker (M73).
1147
+
1148
+ **Out of scope (cannot and need not be defended)** — a caller who *controls the container runtime and
1149
+ deliberately* bakes the public token into a self-built image (or forges the mounts table to hide one). An
1150
+ in-container self-check has a hard ceiling: this is "self-describing, trustworthy against accidents", not a
1151
+ proof against someone who owns the runtime. Every verdict still carries the full environment
1152
+ self-description (mode, cores, quota, load, JS/tmux versions, revision), so a suspicious conclusion can
1153
+ always be re-checked against the source it came from.
1154
+
1155
+ Seeing exit 3 with one of these named → rebuild the image
1156
+ (`<engine> build -f ci/Containerfile -t teamsmith-gate:local .`, the command `perf.sh` itself prints) or
1157
+ re-run `perf.sh --host` instead (non-reference: the verdict is not acceptance evidence). Host numbers are
1158
+ never recorded under the reference name.
1159
+
1160
+ ## 25. The gate goes red for a reason that is not the code: the temp root is full
1161
+
1162
+ The fixtures' temp root is a **shared** filesystem — `${TMPDIR:-/tmp}`, a 15 GB tmpfs on this host, used by every
1163
+ agent's gate run. On 2026-09-22 09:50 it was 100 % full (0 bytes free **and** the inode table full), and
1164
+ `tests/panel-p21.sh choices` produced an ENOSPC red whose verdict was about the code while the cause was the
1165
+ filesystem. Measure before believing a red whose failure text mentions "No space left on device",
1166
+ `mktemp: failed to create directory`, or a fixture dying while writing its own scene.
1167
+
1168
+ ```sh
1169
+ bash skills/teamsmith/tests/tmp-hygiene.sh --status # roots + size/files/age/owner + occupancy + headroom
1170
+ bash skills/teamsmith/tests/tmp-hygiene.sh --sweep # reclaim stale, unoccupied roots (--dry-run first)
1171
+ ```
1172
+
1173
+ `--status` lists only the family entries whose **ownership is proven** (directories named `teamsmith-*`/`review-*`;
1174
+ a bare `review-<ID>` name is not evidence — it needs this repo's git trace, or — only when the directory carries no
1175
+ git trace at all — a board/`docs/team/reviews` record; a `.git`/`gitdir` pointing at another repo **or an
1176
+ unreadable one is a rebuttal**, so an ID that also exists here cannot claim it; for `teamsmith-*` the run ledger's
1177
+ `repo=` attributes it), plus the family's files and the gate's dot-prefixed diagnostics marked as *not a root*, and
1178
+ the temp root's free/total bytes and inodes. Foreign/unproven family directories are **named line by line** with
1179
+ their reason (`[foreign] <path> —— the git trace points elsewhere`, `[unproven] …`), and every run prints which
1180
+ copy of the tool it is (`工具:<path> · rev <hash>`) — an unmerged copy in another worktree is visible at a glance.
1181
+ `--sweep` proves a candidate is unoccupied (`/proc` scan of cwd/fd/exe, `lsof` as fallback) before deleting anything,
1182
+ skips occupied roots whatever their age (`--age N`, default 30 minutes via `TEAM_TMP_SWEEP_AGE`), never `rm -rf`s a
1183
+ registered git worktree, **skips and names** a candidate whose safe precondition fails (a `review-<ID>` whose
1184
+ verification record is missing or uncommitted) while reclaiming the rest, and prints the whole inventory before the
1185
+ first deletion (exit 0 when something was done — skips are listed; exit 3 when every candidate was blocked and
1186
+ nothing was done). `--status` also counts tmux-side residue — orphan private servers whose socket is gone and stale
1187
+ non-`default` sockets with no listener older than the age threshold; `--sweep --tmux-sockets` clears them, the
1188
+ default never touches them, and `default` is never a candidate. `team doctor` carries the same headroom as one row per judged filesystem (the temp root and the worktrees root — one row when they share a filesystem; free/total bytes and inodes, warning only, thresholds `TEAM_TMP_MIN_FREE_MB` / `TEAM_TMP_MIN_FREE_INODES`), so a filling tmpfs is visible *before* it turns into a red. The same floor is a **dispatch refusal** (P144): the refusal names the path, the figures, the threshold, the `tmp-hygiene.sh` remedy and the explicit override, and `TEAM_TMP_MIN_FREE_MB=0` / `TEAM_TMP_MIN_FREE_INODES=0` (or the audited `team config set <KEY> 0 --allow-danger --yes`) turn that leg off while the other keeps judging.
1189
+
1190
+ **Why the roots exist at all**: every fixture creates its temp root through the single owner helper
1191
+ `tests/lib/tmp-root.sh` (`${TMPDIR:-/tmp}/teamsmith-<kind>.XXXXXX`), which writes an owner marker inside and a run
1192
+ ledger outside, reclaims on normal exit **and** `INT`/`TERM`, and keeps only when asked (`TEAM_TMP_KEEP=1`, which
1193
+ prints the path). Pointing a fixture elsewhere is `TMPDIR=/var/tmp bash tests/config-cli.sh`; a fixture template
1194
+ that hardcodes `/tmp` is a gate finding (`tests/tmp-hygiene.sh --lint` runs inside the gate), and the gate itself
1195
+ asserts that no root its run created survives it.
1196
+
1197
+ **What to do when a gate dies mid-run** (`SIGKILL` cannot be caught, so a root survives): run the sweep above; the
1198
+ marker inside each root names the creating pid, its start time and the kind, and any process still holding the root
1199
+ (cwd/fd/exe) is printed and skipped — do not delete a root another agent is using. The root of the leak was 607
1200
+ `config-cli.*` roots (3.2 GB) that kept being created and never reclaimed; the fix is the ownership rule above,
1201
+ not a periodic cleanup daemon.
1202
+
1203
+ **A red that is not the code, part 2: the tree moved while the gate ran (P158).** On 2026-10-02 a
1204
+ `fast-full-capture` run reported 138 reds because a merge (P147) landed in the same checkout while it was
1205
+ running; every red fell in the sections whose files the merge touched, and the diagnosis first blamed the
1206
+ fixtures, then the product. The gate now fingerprints the tree (`HEAD` + the sha256 of
1207
+ `git status --porcelain --untracked-files=all`, untracked included) in `<run tmp>/run-fingerprint.txt` when it
1208
+ starts and compares it after the last section. A changed tree prints the one-line verdict
1209
+ `本次运行无效:树在跑动中被改动(HEAD A→B / 脏文件 N→M)` next to the result line, keeps every ✓/✗ it already printed, and exits **4** — that is not
1210
+ a verdict on the code, so wait for the tree to be stable and rerun once; do not start bisecting the reds. The
1211
+ fingerprint covers the whole worktree on purpose (not just the files the suite read), so a record under
1212
+ `docs/team/**` committed mid-run invalidates the run too. A tree that is not a git checkout prints one visible
1213
+ note instead. The flip fixture is `tests/flip-p158.sh` (section `0i` runs it).
1214
+
1215
+ ## 26. `team review <ID> --post-merge` says both sides touched — read the content first
1216
+
1217
+ **Symptom**: after a squash merge the post-merge check exits non-zero and names paths, for example
1218
+
1219
+ ```console
1220
+ $ bash skills/teamsmith/scripts/team review <ID> --post-merge
1221
+ review P82 --post-merge:分支 task/P82-sender-apply(tip a4fb5a3f)vs main(tip 43a731c6)
1222
+ ✗ 两边都动过、版本对不上(main 那一版不来自这条分支,分支这一版 main 也没有过)—— 自己看一眼,别直接取:
1223
+ docs/team/threads/dev-bob.md
1224
+ skills/teamsmith/tests/smoke.sh
1225
+ 修法:重新合并这条分支(squash 或新 PR)+ 重跑门禁,再 board set P82 done
1226
+ ```
1227
+
1228
+ **Why this is expected**: when the PM resolved a conflict during the squash merge, those files legitimately
1229
+ differ from the branch. `docs/team/threads/dev-bob.md` had entries merged in time order and `smoke.sh` had the
1230
+ branch's section renumbered.
1231
+
1232
+ **Since P95 the comparison basis is the task's own squash commit, not the protected branch's tip.** The check
1233
+ first locates that commit on the protected branch — the convention is the subject starting with `<ID>:` / `<ID> `
1234
+ (the squash commit's usual shape) or, failing that, a commit carrying an `Agent:` trailer whose subject names the
1235
+ task — and then diffs the branch against *it*. Later tasks merged into the protected branch and the PM's own
1236
+ conflict resolution therefore stop counting as "the branch moved on". The same P82 run now reads:
1237
+
1238
+ ```console
1239
+ review P82 --post-merge:分支 task/P82-sender-apply(tip a4fb5a3f)vs main 的合并提交 0af22bcc0c(P82: apply notify-sender-identity — …)
1240
+ 基准 = 这个任务的 squash 提交(main 的 tip 是 1ab75e28):后来者合进 main 的内容不再计入
1241
+ 解冲突形状(4 个路径):合并提交那一版与分支这一版互不来自对方 —— 这不是「代码没合并」:
1242
+ docs/team/threads/dev-bob.md
1243
+ …
1244
+ 做什么:按内容核对(`git diff 0af22bcc0c..task/P82-sender-apply -- <路径>` / grep 关键符号)确认分支的改动确实进了合并提交;
1245
+ 记录若确实晚到,按内容取(整份 `git checkout task/P82-sender-apply -- <路径>` 会覆盖 main 上解冲突那一版)
1246
+ ```
1247
+ and exits 0. What the command says now:
1248
+
1249
+ | Output | Exit | Meaning / what to do |
1250
+ |---|---|---|
1251
+ | late records list + a `git checkout … && git commit` recipe | 0 | the branch committed paths under `<docs>/` that the squash commit never saw → run the printed command as-is: it now also commits, and the commit is limited to the paths it names (unrelated staged work stays put), so the very next run already goes quiet. Before P96/F1 the recipe stopped at `checkout`/`git rm`, and running it left the record in the index only — the same take-it advice then came back on every run (P96's F1) |
1252
+ | `代码有未合并的改动 —— 不能只取记录,必须重新合并并重跑门禁` | ≠ 0 | the branch carries *code* the squash commit does not → re-merge (squash or a new PR) and re-run the gates (D49) |
1253
+ | `解冲突形状` + a list of paths | 0 | both sides changed the path and neither version comes from the other's history — the normal shape when the PM resolved a conflict during the squash. It is **not** "the code was not merged", but neither side is a superset of the other: verify by content (`git diff <squash>..<branch> -- <path>`, `grep` the symbol) before taking anything. A whole-file `git checkout <branch> -- <path>` overwrites the merged version — in the P82 case the protected branch's `docs/team/threads/<agent>.md` carries PM entries the branch never had |
1254
+ | `未找到这个任务的合并提交` | old behaviour | the branch was never squash-merged (no commit matches either convention) → the tool falls back to comparing against the protected branch's tip, says so on the spot, and a never-merged branch then reports its code as not merged — the honest answer |
1255
+
1256
+ **What to do**: read the verdict first. `解冲突形状` is a content question (`grep` the symbol, read
1257
+ `git diff <squash>..<branch> -- <path>`), not a re-merge instruction; take a record only when the branch's
1258
+ version is genuinely newer, and never blanket-`checkout` a path whose merged version carries content the branch
1259
+ lacks. When the tool does report `代码有未合并的改动`, re-merge the branch and re-run the gates (D49). The
1260
+ `--pre-merge` counterpart (P76/D45) covers the other half of the same trap: records that were never committed
1261
+ at all. The take-the-records recipe is printed as one `&&` chain that ends in a commit — run it verbatim; if you
1262
+ retype it, keep the commit, or the record stays in the index and the check keeps asking for it (P96/F1).
1263
+
1264
+ **When a task landed on the protected branch in several commits** (a propose commit, a partial merge and a
1265
+ final one, say), the check first narrows by the `Agent:` trailer and then takes the **newest** candidate as the
1266
+ basis — in a linear history that commit contains the earlier ones, so it can only make the comparison stricter,
1267
+ never laxer — and it prints `注:这个任务在 <branch> 上有 N 个候选合并提交 … 取最新的那个` naming the commit
1268
+ it used in the header line.
1269
+
1270
+
1271
+ **When the whole suite runs red inside a container but green on the host** — a run of several hundred
1272
+ environment-shaped failures (no `flock --close`, no `perl`, nobody can resolve the git common dir) is the
1273
+ container, not the deliverable. The suite needs a full environment: the skill's own tmux fixture image
1274
+ (`teamsmith-tmux-test:alpine`) carries tmux and little else, so it is for tmux probes only. The pinned gate
1275
+ image (`ci/Containerfile`) is the one built for the suite: `tests/smoke.sh` and `tests/perf.sh` are what run inside it, and `tests/container-tmux.sh` is the helper for the few probes that need a disposable server. A `git worktree` cannot be mounted for a container
1276
+ run either: its `.git` is a pointer file to the main checkout, so every git-dependent fixture fails. Mount an
1277
+ independent `git clone` instead, and give the container `--pid=host` as the CI workflow does.
1278
+
1279
+ ## 27. Common rejections and how to fix them
1280
+
1281
+ Three refusals cause most of the friction for a project that is still learning teamsmith from the briefs alone: a
1282
+ worktree sitting on the wrong task branch, a task-brief header line that does not parse, and a review run without
1283
+ the checkout it refuses to prepare itself. Each one is decided **before** a window opens or any git command runs,
1284
+ so a refusal leaves the worktree, the board and `state/<agent>.env` exactly as they were. §4 covers the other
1285
+ dispatch refusals; this section names the shape, the reason and the exact command that clears it.
1286
+
1287
+ **Every blocker found in the same pre-launch pass is reported in one refusal.** Each item names its artifact and
1288
+ reason and carries a paste-able `修法:<command>` or `改行:<exact line>`, and the last line counts the blockers. The
1289
+ command is the **whole** line — there is no trailing explanation to strip, and nothing after it may be typed along
1290
+ with it.
1291
+
1292
+ ### 27a. The worktree is on a branch that does not belong to this task
1293
+
1294
+ Task mode refuses a dispatch whose worktree sits on another task's branch (the check also runs for `--print`, so
1295
+ the printed plan can never describe a wrong target):
1296
+
1297
+ ```console
1298
+ $ bash <skill>/scripts/team dispatch dev P137 docs/team/tasks/P137-references.md
1299
+ ✗ /path/to/project/.worktrees/dev 停在不属于本任务(P137)的分支上:
1300
+ ✗ 现在的分支:task/P136-propose | 本任务要的分支:task/P137-references
1301
+ 切过去:git -C /path/to/project/.worktrees/dev switch task/P137-references
1302
+ (拒绝的理由:复验/交付记录会以工作树的分支为证据,不能张冠李戴)
1303
+ ```
1304
+
1305
+ **How the expected name is derived.** In the default task mode the branch is `task/<ID>-<slug>` (protocol.md
1306
+ §8b). The slug comes from the **task title** — the `任务` column of `BOARD.md` when the row exists, otherwise the
1307
+ first `# <ID> · …` heading of `docs/team/tasks/<ID>-*.md`:
1308
+
1309
+ 1. lowercase;
1310
+ 2. every run of characters outside `[a-z0-9]` collapses into one `-`;
1311
+ 3. leading/trailing `-` are trimmed and the result is cut to 28 characters;
1312
+ 4. if nothing survives (a title with no ASCII letters or digits — an all-CJK one, for example), the slug falls
1313
+ back to the ID: `task/P134-p134`.
1314
+
1315
+ Because the title can change (a phase word added, say), one task can legitimately have had two names over its
1316
+ life — `task/P134-p134` → `task/P134-propose`. Resuming the **same** task (`state/<agent>.env` still records it)
1317
+ accepts any `task/<ID>-*`; a **new** task must sit on exactly the name computed for it. That mismatch is what the
1318
+ refusal above reports.
1319
+
1320
+ **When the name comes from `--branch` or the brief.** `dispatch --branch <name>` wins over the brief's `branch:`
1321
+ line, which wins over the title derivation; `team task` writes the derived name into the brief as its `branch:`
1322
+ line, so the target is fixed before any worktree exists. Without `--branch`, a worktree on **this task's own**
1323
+ branch is accepted even when its slug differs (`task/P134-p134` vs `task/P134-propose` — the same task, a title
1324
+ that changed), and both names are printed; with `--branch`, only the declared name is accepted, because the
1325
+ explicit declaration wins. The printed plan states the resolved name and its source, and the launch prompt names
1326
+ the branch the guard actually accepted — read it before assuming the worker was told the wrong branch.
1327
+
1328
+ **The fix.** The refusal prints one of the two commands below with the real worktree and branch; the skill never
1329
+ runs git itself:
1330
+
1331
+ ```bash
1332
+ git -C <worktree> switch <expected-name> # the branch already exists
1333
+ git -C <worktree> switch -c <expected-name> <protected-branch> # cut it off the protected branch
1334
+ ```
1335
+
1336
+ **Why it has to refuse.** The verification record and the delivery ledger cite the worktree's branch as the thing
1337
+ they describe. On the wrong branch a review stamps another task's commits and merge/`close` sees the wrong diff
1338
+ (`M6.3 F16`); the refusal states it in one line: the record must not name the wrong head.
1339
+
1340
+ ### 27b. A task-brief header line is refused
1341
+
1342
+ `team dispatch` reads four header lines before it opens a window (rules collected in protocol.md §5b). The
1343
+ accepted/refused contrast, including the two shapes real users hit first — a parenthetical `change:` and a
1344
+ middle-dot `deltas:` list:
1345
+
1346
+ | Line | Accepted | Refused | How it clears |
1347
+ |---|---|---|---|
1348
+ | `change:` | exactly one token — `change: panel`, `change: -`; a note needs whitespace before `#`: `change: panel # it owns that capability` | `change: panel(说明)` (a parenthetical explanation is outside the token shape `[A-Za-z0-9][A-Za-z0-9._-]*`), `change: alpha, beta`, two `change:` lines | edit the line to one id (or `-`). **No `--force`** here: one task implementing two changes is a mis-dispatch |
1349
+ | `deltas:` | a comma list of tokens — `deltas: capability-a, capability-b`; `deltas: -` for "writes no delta" | `deltas: capability-a · capability-b` (the middle dot is neither a separator nor a token character), `deltas: capability-a,` (a trailing comma is an empty item), two `deltas:` lines | edit to a comma list or `-`. An **absent** line is read as the whole change's delta set, never as "none" |
1350
+ | `specs:` (with `change: -`) | a capability that resolves — `specs: verification`; with a requirement — `specs: verification#Gates run under a hard timeout` (the file must carry `### Requirement: Gates run under a hard timeout`) | a capability that does not resolve, or a requirement name that is not a `### Requirement:` heading in the file; the refusal prints the path it looked in | fix the name, or declare `anchor:` instead |
1351
+ | `anchor:` (with `change: -`) | `anchor: none (infra) — <non-empty reason>` (an em dash; `–`, `--`, `-` also parse as the separator) | `anchor: none`, `anchor: none (infra)` with no reason, any other value | write the full form with a real reason, or a resolving `specs:` entry |
1352
+
1353
+ Two details worth knowing: a present-but-invalid `anchor:` takes precedence and a valid `specs:` line next to it
1354
+ is never tried, so remove the bad anchor instead of hoping the other line wins; and only ` #` (a `#` preceded by
1355
+ whitespace) starts a comment, which is why `specs: capability#Requirement` keeps its `#` as the separator.
1356
+ `--force` does not cover all of them: the `change:` rule and a **malformed** `deltas:` line have no escape (the
1357
+ latter decides the single-writer check, so it is never read as an empty set); `anchor:` is overridden with a
1358
+ warning plus one audit line, and so is a **valid** `deltas:` list that collides with an unfinished sibling's —
1359
+ that overlap is the single-writer rule of protocol.md §5b, not a parse error. Every one of them names the
1360
+ offending line, so the fix stays local to the brief.
1361
+
1362
+ ### 27c. `team review` refuses without `--dir`: the one-command independent review
1363
+
1364
+ `team review` runs the gates against a checkout **the PM prepared** and writes the verdict record itself; it does
1365
+ not create the checkout and does not run git. One command line covers both steps:
1366
+
1367
+ ```bash
1368
+ git -C <root> worktree add --detach /tmp/review-<ID> <task-branch> && \
1369
+ bash <skill>/scripts/team review <ID> --dir /tmp/review-<ID> # add --strong for the structural checks
1370
+ ```
1371
+
1372
+ Both forms write `docs/team/reviews/<ID>.md` (HEAD, diffstat, commit list, gate tail, verdict checklist) — the
1373
+ record that `team board set <ID> done` and the merge step read. The details that bite:
1374
+
1375
+ - `--dir` is the **root** of the checkout; a subdirectory is refused with the path it resolved.
1376
+ - The checkout must be clean and sit at the branch under review; a dirty or mismatched one is refused, and the
1377
+ refusal names the matching `TEAM_REVIEW_ALLOW_DIRTY=1` / `TEAM_REVIEW_ANY_DIR=1` override.
1378
+ - `--no-gates` records `SKIPPED` and is **not** evidence — `digest` keeps listing the task as awaiting
1379
+ verification.
1380
+ - `--pre-merge` / `--post-merge` are different checks (they inspect the task worktree and the protected branch
1381
+ directly) and do not take `--dir`; the recipe above is for the full review.
1382
+ - A container run cannot mount a `git worktree` — its `.git` is a pointer file to the main checkout, so every
1383
+ git-dependent fixture fails. Check the branch out with `git clone -b <task-branch> <root> /tmp/review-<ID>`
1384
+ instead and pass that clone's root to `--dir` (see the note at the end of §26; give the run `--pid=host`).