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,712 @@
1
+ # Protocol: why a Pi agent team is organised this way
2
+
3
+ This document is the "why" behind the team protocol section of `AGENTS.md`. The rules themselves are short; the
4
+ reasons are what stop a future you (and future agents) from treating them as bureaucracy to route around.
5
+
6
+ > **The belief layer lives in [philosophy.md](philosophy.md)** (8 judgement standards plus their failure modes). This
7
+ > file explains "why the rules are what they are", that one explains "why this role should think this way". When the
8
+ > two disagree the creed wins, and the rule gets fixed afterwards.
9
+
10
+ ---
11
+
12
+ ## 1. Roles: the PM is not "a smarter agent", it is the only role allowed to merge
13
+
14
+ | | PM (orchestrator) | worker agent |
15
+ |---|---|---|
16
+ | Context | long-lived, across tasks, holds the roadmap and the decision history | one stretch per task, focused on implementation |
17
+ | Output | briefs, decision log, verification records, merges | code, tests, reports, PR/MR |
18
+ | Authority | the protected branch, forge writes, repository settings | its own task branch |
19
+
20
+ Splitting "writing code" from "judging whether the code is acceptable" across different sessions is what creates
21
+ **independent verification**: the agent's report is a **claim**, the gate results the PM obtains on an independent
22
+ worktree are **evidence**.
23
+
24
+ > A real CEP lesson: a report claimed 28/28 tests passing, the PM re-ran it and 4 specs failed (the cause was a value
25
+ > import used to import a pure type under `verbatimModuleSyntax`). Conclusion: a report ≠ evidence, verification has
26
+ > to be institutionalised.
27
+
28
+ ## 2. The evidence model (three layers, each more trustworthy than the last)
29
+
30
+ 1. **Claim**: the conclusion an agent writes in its report (least trustworthy).
31
+ 2. **Checkable artefact**: commits, test files, log files, diffs.
32
+ 3. **Independent verification**: the result the PM gets by running the same commands on **another checkout** (most
33
+ trustworthy).
34
+
35
+ Any "passes/done" has to land in layers 2 and 3. The acceptance commands in a brief plus the PM's `team review` are
36
+ the implementation of that chain.
37
+
38
+ ## 3. Isolation: worktree + branch + a long-lived cwd
39
+
40
+ - **One worktree per agent** (long-lived), with a new branch per task inside it.
41
+ - Why long-lived: a Pi session is keyed by **cwd**. Move the worktree path and the old session cannot be found again
42
+ (CEP has been there).
43
+ - Why not "one worktree per task": sessions fragment, and both follow-up questions and resuming from a checkpoint get
44
+ harder; a long-lived worktree lets the agent keep its memory.
45
+ - The main worktree (main) belongs to the PM alone: merges, verification and documentation happen there, so nobody
46
+ fights an agent over the workspace.
47
+
48
+ ## 4. The wake-up loop: an asynchronous agent must be able to wake the PM by itself
49
+
50
+ The PM cannot poll (wastes context, high latency) and should not wait for the user to relay things. The mechanism
51
+ (`extension/team-notify.ts`):
52
+
53
+ ```
54
+ agent turn ends (Pi's agent_settled: the point where it will not continue on its own)
55
+ ├─ append <root>/<docs>/inbox/<agent>.md ← durable, the PM can read it at any time
56
+ └─ enqueue into <root>/.pi/team/state/outbox/ (one immutable entry) and drain it
57
+ ```
58
+
59
+ Guards and limitations:
60
+ - It only fires when the cwd is under `<worktrees>/`; when the window name equals the PM window name it is skipped (to
61
+ prevent a self-triggering loop).
62
+ - **In a linked worktree Pi does not auto-discover the project-local `.pi/extensions/`**, so `team dispatch` must load
63
+ it explicitly with `-e <skill>/extension/team-notify.ts` (measured on CEP).
64
+ - **The knock goes through the delivery guard** (`delivery-guard`, see `troubleshooting.md` §3): the extension calls
65
+ `team outbox enqueue --dedup <its own key>` + one `team outbox flush` instead of typing, so a notice can no longer
66
+ be concatenated with what the human is typing. On a dirty PM box the entry waits in `state/outbox/`; the extension
67
+ never falls back to `send-keys`, and a failed enqueue is logged while the inbox line stays.
68
+ - The inbox is transient state (gitignored); the durable record is still the report + verification + decision log.
69
+ - The same briefing is sent once per `TEAM_NOTIFY_DEDUP_SEC` seconds: Pi may settle several times inside one stretch
70
+ of work.
71
+ - **A notice names the revision it describes** (R2/P139; width and branch proof fixed by P160): the durable inbox
72
+ line and the knock payload carry `task=<ID> tip=<12-hex>` — the **first twelve hex characters of the branch tip,
73
+ truncated by the sender itself** (`git rev-parse HEAD | cut -c1-12`; the extension's `TIP_WIDTH`), never a Git
74
+ abbreviation whose width follows `core.abbrev` or the object count, so one HEAD has one spelling in both senders.
75
+ The stamp is written only when the branch can **prove** it is a task: `task/<ID>-…` and the ID exists in
76
+ `state/<agent>.env` (`task=<ID>`), on the board, or as a task brief. An ordinary seat branch (`agent/<seat>`), a
77
+ protected-branch or detached worktree and a manual `team notify` outside a worktree stamp nothing — the identifier
78
+ is never invented from a branch or seat name.
79
+ - **The receiver never needs a checkout**: the notice is stale when the board row is `done`/`closed`, or when the
80
+ HEAD recorded in `docs/team/reviews/<ID>.md` and the tip name the same revision — one is a prefix of the other
81
+ (the record `team review` writes today is nine hex wide; a hand-written one may carry the full id; the twelve-wide
82
+ wire form is what keeps the decision stable across Git settings).
83
+ - For a proactive notification (blocked, someone else's bug) use `team notify <agent> "<one line>"`, which arrives
84
+ earlier than the automatic one. The **recipient** names the durable inbox file (`docs/team/inbox/<agent>.md`);
85
+ the PM is still the **knock destination** — the queue entry's declaration and the wake pointer both name that
86
+ same recipient file, and a durable append that fails exits non-zero without a wake.
87
+ - The **other** injected extension is `extension/team-bg.ts` (M27) — not notification, but the team's own
88
+ background lane: `team_bg_run` starts a detached job (bounded `state/bg/<id>.log`), `team_bg_wait <id>` harvests
89
+ it, a harvested job stays silent, several finishing jobs arrive as one message, and every turn end appends
90
+ `settled-with-unharvested=<n>` to `state/bg.log` (runbook: `workflows.md` §E2).
91
+ - **The identity record** (P159): the extension writes `state/bg/<id>.job` **before** it returns the id — `id`,
92
+ `pid`, `pgid`, `start` (the start-time fingerprint from `/proc/<pid>/stat`), `cwd`, `log`, `cmd`.
93
+ `team bg list` prints one row per record of **this** project's state directory and signals nothing;
94
+ `team bg stop <id>` signals exactly the recorded job and prints what it signalled. Identity is
95
+ `(pid, start-time)`: the pid must be alive **and** the fingerprint must match, so a reused pid is refused
96
+ (exit 5) instead of killed. With `pgid == pid` it signals the process group `TERM`, then `KILL` after
97
+ `TEAM_BG_STOP_GRACE` seconds; with a different group it signals the pid alone and says descendants were not
98
+ reached. One `stop` line lands in `state/bg.log`; exit codes are 0 stopped-or-already-gone / 2 usage /
99
+ 3 no record / 4 malformed record / 5 identity mismatch / 6 still alive. Every refusal signals nothing, and the
100
+ lane never searches by name, command line, process tree, another worktree or another project.
101
+ - **The signal gate** (P159/P167; the shape behind D37/D57/D72): the launch prefix puts `scripts/shim` first on a
102
+ window's `PATH`, where `pkill`, `killall`, `pgrep` and `pidof` are the gate. It classifies the **whole argv**,
103
+ never the presence of one flag. `pkill` and `killall` refuse every selecting form (`-f`, `-x`, `-P`, `-u`,
104
+ `killall <name>`). `pgrep` passes only two explicit positive scalar IDs (`-g N`, `-P N`) and the three
105
+ full-command count spellings (`-fc P`, `-f -c P`, `-c -f P`) that return a number rather than a PID list;
106
+ `pidof` selects by name by definition, so only its informational token passes. Everything else is refused with
107
+ exit 64 and an empty stdout — default name selection, a PID-producing pattern, owner selection (`-u`/`-U`/`-G`),
108
+ zero or implicit IDs, lists, inversion, added predicates, unrecognised spellings, `pidof` selection, and any
109
+ inherited environment token. A refusal prints the tool, its full argv, why a name or a command-line pattern is
110
+ not an identity, and the safe routes (`team bg list`, `team bg stop <id>`, `kill <recorded pid>`), and it
111
+ resolves and executes nothing. An allowed call passes through to the real executable of the **same name** —
112
+ the inherited `TEAM_SIGNAL_REAL` pin, normally the real `pkill`, never routes a `pgrep`/`pidof` call — with
113
+ argv, stdout, stderr and exit status preserved. A `-g`/`-P` query is a diagnostic, not proof: the PIDs it
114
+ prints were not recorded by any spawner, and a count is not a PID, so neither is signalling authority. The gate
115
+ deliberately does **not** wrap `kill`, `ps` or `fuser`, and it is a `PATH` shim: absolute paths
116
+ (`/usr/bin/pgrep`), a shell without the gate directory first, shell functions and any other source of a PID
117
+ list stay outside its reach. That half is held by the static lint over the repository's own scripts and
118
+ fixtures (`tests/signal-lint.pl`: red on a name/pattern selection, clean on `kill "$pid"`). Every intercepted
119
+ call appends one line to `state/signal-calls.log` (`TEAM_SIGNAL_CALLS_LOG`), and a refusal is also copied byte
120
+ for byte into `<log>.forensics` so it outlives the call log's rotation.
121
+
122
+ ## 5. Task briefs: written for "a weak model without context"
123
+
124
+ The default development model is a cheap, fast one (e.g. `deepseek/deepseek-flash`). It **will not correct an
125
+ ambiguous requirement on its own**, so a brief has to be self-contained:
126
+
127
+ - Background: why this is being done, where the relevant docs are (do not paste large chunks of code).
128
+ - Deliverables: file paths plus key signatures/behaviour, item by item.
129
+ - Boundaries: spell out what **not** to do (this prevents more drift than saying what to do).
130
+ - Acceptance: **copy-pasteable commands**, plus the report requirements.
131
+ - A fixed report format (deliverables/evidence/deviations/next steps), so the PM can read it mechanically.
132
+
133
+ ## 5b. The change is the assignment unit (four dispatch guards)
134
+
135
+ `1 change : N tasks` — the change (proposal, design, delta, tasks, archive) is the dispatch unit, and a task is one
136
+ batch or one phase inside it; several briefs, agents or apply batches may share a change. The brief's header is the
137
+ foreign key, and `team dispatch` reads it **before it opens a window**:
138
+
139
+ 1. **One change id.** `change:` holds exactly one token (or `-`). A comma list, two whitespace-separated ids or a
140
+ second `change:` line is refused with the offending line; there is **no override** — a task that implements two
141
+ changes is a mis-dispatch, not a preference, and the old "silently use the first line" behaviour is what this
142
+ rule removes.
143
+ 2. **A change-less brief declares its anchor.** With `change: -` the brief must either name a `specs:` entry that
144
+ resolves (`<capability>[#<requirement>]` in `openspec/specs/<capability>/spec.md`) or say out loud
145
+ `anchor: none (infra) — <reason>`. An unresolvable capability, a missing requirement or a bare `none (infra)` is
146
+ refused with both accepted forms and the path that was looked for; `--force` proceeds with a warning and one
147
+ audit line. This is policy B: disagreement with a rule is expressed by anchoring it, not by silence.
148
+ 3. **One delta file, one writer.** Two unfinished tasks of the same change must not write the same
149
+ `openspec/changes/<change>/specs/<capability>/spec.md`. A brief declares what it will write with `deltas:`
150
+ (comma-separated capabilities, `-` for none); **an absent line is not "none"** — it is read as the whole delta
151
+ set, so silence can never be used to slip past the guard. The refusal names the sibling, its board status, the
152
+ shared file and both declarations; `--force` overrides with one audit line. `team change status <id>` prints the
153
+ declared and the actually-touched files per task, so a declaration that lies is visible.
154
+ 4. **The verifier is not an author.** A `verify` dispatch is refused when its agent also authored an `apply` task
155
+ of the same change (mapped tasks whose board status is `dropped` are excluded and named). `--force` proceeds
156
+ with a warning that the verification is no longer independent. A mapped task whose brief cannot be read or whose
157
+ header has no `agent:` is a **missing signal**: the guard says which signal is missing and proceeds — an
158
+ unknowable author is never reported as a clean one. The same predicate puts `self-verify: <agent>` on the task
159
+ in `team change status`.
160
+
161
+ All four run before the stack guard and before any window or board write, so a refusal leaves the task's status
162
+ exactly as it was. The readiness view and the archive gate share one predicate (`team change status <id>` exits 0
163
+ iff at least one task is mapped and every mapped task is finished): an `archive` task cannot be set `done` while a
164
+ sibling of its change is unfinished, and the existing `TEAM_BOARD_DONE_FORCE=1` override still records itself.
165
+
166
+ ### 5b-1. One refusal, every blocker, a fix that runs
167
+
168
+ Every pre-launch guard that can be decided without side effects is judged in **one pass**, and the driver prints
169
+ **one** refusal: the blockers in guard order, each naming the artifact it is about (brief, worktree, seat, model or
170
+ session) and its reason, each followed by the lines that clear it — `修法:<command>` (a command with real values:
171
+ worktree path, branch name, task id) or `改行:<exact line>` (the brief header line to write) — and a final
172
+ `共 N 个阻塞项` line. The refusal opens with the first blocker's own first line (there is no separate banner), and
173
+ nothing is written before it passes: no window, no `state/<agent>.env`, no board change, not even a branch switch.
174
+ A guard whose precondition is missing says so instead of being reported as passed. In a printed route the command
175
+ stands **alone on its line** — an explanation, if any, is a separate line — because a trailing parenthetical is
176
+ exactly how a printed fix turned into `✗ dispatch: 未知参数 --force(…)` for real users.
177
+
178
+ `--force` keeps each guard's own meaning: an overridable blocker becomes a warning plus exactly one
179
+ `state/watchdog.log` audit line (written only after a launch really happened, never for `--print`), while a blocker
180
+ with no override still refuses. A printed route is a promise, not decoration: `tests/routes.sh` applies every
181
+ `修法:`/`改行:` family in a fixture and reddens when a route stops clearing its blocker or is no longer honored.
182
+
183
+ ## 6. Model strategy: cheap models do the work, a different family does the adversarial verification
184
+
185
+ | Use | Selection principle |
186
+ |---|---|
187
+ | Implementation/tests/docs | a cheap model without concurrency limits; a good brief is enough |
188
+ | Independent verification/adversarial analysis | switch model families (to avoid the same blind spots), e.g. the grok family |
189
+ | Heavy review/hard problems | subscription quota is tight → cap concurrency with `TEAM_MODEL_LIMITS`, run one at a time |
190
+ | Long-context hard problems | slow and concurrency-limited; only when the PM explicitly asks |
191
+
192
+ `team dispatch` checks `TEAM_MODEL_LIMITS` and capacity before dispatching: the rules (from two OOM incidents on CEP,
193
+ one of which hit RAM and zram bottom at the same time):
194
+
195
+ | Line | Default | Meaning |
196
+ |---|---|---|
197
+ | `TEAM_MIN_AVAIL_MB` | 1024 | **hard line**: refuse to dispatch below this `MemAvailable` (that CEP machine sets 4096) |
198
+ | `TEAM_MIN_FREE_SWAP_MB` | 1024 | **hard line**: refuse to dispatch below this much free **disk swap** (**zram excluded**) |
199
+ | `TEAM_MIN_TOTAL_MB` | 512 | hard line: `MemAvailable + free disk swap` |
200
+ | `TEAM_WARN_AVAIL_MB` | 4096 | warn only: RAM is tight, slowness is allowed |
201
+ | `TEAM_ZRAM_WARN_PCT` | 85 | warn only: zram usage is too high (zram pages live in RAM, so it is a source of slowness, not a safety net) |
202
+
203
+ Why zram is looked at separately: the "free space" of `/dev/zram0` is really compressed pages in RAM, and once full it
204
+ stays essentially full; counting it towards the concurrency budget systematically overestimates the headroom, and when
205
+ an OOM happens RAM and zram bottom out together.
206
+
207
+ ## 7. Security red lines (non-negotiable)
208
+
209
+ - A token is injected only when the PM **calls a real tool** (e.g. `GH_TOKEN="$(< .gh-pat)" gh …`); it is never echoed
210
+ and never lands in a project file or a log.
211
+ The skill is fully decoupled from forges: it does not probe gh/glab, does not read tokens and does not open PR/MRs
212
+ for you (v1.12.0).
213
+ - Agents may not: push the protected branch, force-push, merge, rebase/delete someone else's branch, change repository
214
+ settings.
215
+ - Agents may not read credential/account files (such as `~/.pi/agent/auth.json`).
216
+ - Any operation that changes shared/remote state needs `--yes` (explicit user authorization). The skill never decides
217
+ for the user.
218
+
219
+ ## 8. Periodic patrol: no "watch everything", only waking people up
220
+
221
+ The pulse (called `watchdog` before v1.36.0 — the old command/window/variable names still work as aliases and
222
+ fallbacks until v2.0.0) is not a keep-alive heartbeat but a **metronome**: on a timer it asks "is there work for
223
+ the PM right now".
224
+
225
+ - Every 15 minutes by default (`TEAM_PULSE_INTERVAL=900`, 300~3600 recommended) it computes the pending work: unread
226
+ notifications / reports awaiting verification / board todo·wip / blocked / agents with an unfinished task that
227
+ stopped.
228
+ - **Pending work** → wake the PM (nudge it if it is running; if not, start it with `pi -c` and the kick-off prompt
229
+ `@state/pm-prompt.md`); **nothing pending** → do not wake it, do not start it — the PM is not required to run
230
+ continuously, and being quiet is a valid state.
231
+ - **Who resumes a stopped agent** (the one question this paragraph exists to settle): **the pulse never
232
+ does.** A stopped agent with an unfinished task is *reported* as pending work; starting it is the PM's call
233
+ (`team resume --agent <a>`, or `team resume` for all). The single exception is a human's rescue command:
234
+ `team up` recovers the PM window and, **only with `--agents`**, also resumes the agents that stopped with an
235
+ unfinished task (that is why a session restore can bring workers back without the PM asking). The watchdog
236
+ spec pins the pulse half of this as a scenario ("A stopped agent is not resumed") — if you ever see a resumed
237
+ worker you did not ask for, look for a `team up --agents` / `team resume` in the log, not in the patrol.
238
+ - **"The PM is running" is a proof, not an inference**: either `state/pm.pid` (recorded by the start path) points at
239
+ a live process whose cwd is inside the project, or the process in the PM window is the configured agent binary and
240
+ its cwd is in the project. A window occupied by anything else is `foreign:<cmd>` (another project's cwd — not
241
+ overwritten without `TEAM_REPLACE_FOREIGN_PM=1`) or `unknown:<cmd>` (in-project cwd, but not the agent). `unknown`
242
+ never suppresses starting the PM: a freshly created, empty pane is not a running PM, and claiming otherwise is how
243
+ `team up` once printed "PM is running" while starting nothing (M6.5).
244
+ - **`starting` is a state of its own (M7.2)**: between `respawn-pane` and the moment a start's evidence lands, the PM
245
+ pane is a shell running the start command — in-project, but not the agent. While that start is in flight the tool
246
+ keeps `state/pm.pid.starting` (epoch, starter pid, target; fresh for `TEAM_PM_START_WAIT + 5s`) and every surface
247
+ reports `starting:<age>`: it is not "running" (there is no proof yet) and it is **not** "no PM" either. A tick that
248
+ sees it neither nudges nor starts a second PM — a second `respawn-pane` would kill the PM that is just coming up,
249
+ and the restart quota would count one start twice. A stale marker (the starter crashed) is ignored: it is evidence,
250
+ never a lock.
251
+ - **One tick, one state read**: the patrol derives every conclusion (nudge / start / stay quiet) from a single
252
+ `team_pm_state` read, and `state/pm-restarts.log` records **real restarts only** — the quota is checked before
253
+ starting, the line (epoch, timestamp, evidence) is written after a successful start. Every attempt is recorded in
254
+ `state/pm-start-attempts.log` with the evidence, and the quota counts both files (`TEAM_PULSE_MAX_RESTARTS` per
255
+ hour), so a start loop that spawns but never confirms cannot run away while "the PM was restarted N times in the
256
+ last hour" stays a fact and not a count of attempts. A failed or timed-out attempt is logged in
257
+ `state/watchdog.log` as not counted. `pulse status`, `digest`, `ps` and the monitor panel print the same state
258
+ and name the evidence behind it (`state/pm.pid=<pid> proof=spawn|argv`, the starting marker, the empty prompt, the
259
+ occupant).
260
+
261
+ What each liveness state means and what the PM should do:
262
+
263
+ | state | meaning | what to do |
264
+ |---|---|---|
265
+ | `running:<pid\|cmd>` | proof: the recorded pid is alive with an in-project cwd (`proof=spawn` / `proof=argv`), or the window's process is the configured agent binary | nothing; a nudge means "there is pending work" |
266
+ | `starting:<age>` | a start is in flight (fresh `state/pm.pid.starting`) | nothing — the tick will not start a second PM; wait for `running` (the marker expires after `TEAM_PM_START_WAIT + 5s`) |
267
+ | `idle:<shell>` | empty prompt | `team up`, or let the pulse start it when there is pending work |
268
+ | `unknown:<cmd>` | in-project occupant that is not the agent (fresh pane, `sleep`, editor) | `team up` replaces it; it never suppresses a start |
269
+ | `foreign:<cmd>` | occupant whose cwd belongs to another project | close that window, or `TEAM_REPLACE_FOREIGN_PM=1 team up` |
270
+ | `missing` | the PM window does not exist | `team up`; `TEAM_PULSE_REBUILD_TMUX=1` lets the pulse rebuild it |
271
+
272
+ `busy` is not a liveness state of its own: a pane whose foreground process is the agent is `running`, and a pane that is
273
+ merely busy with something else in this project (the pre-`exec` start command, a `sleep`, an editor) is `unknown:<cmd>`
274
+ — it does not suppress starting the PM. The internal pane-busy probe is only used to tell an empty prompt (`idle`) from
275
+ an occupant (`unknown`).
276
+ - The PM can stand down deliberately: `team standby on --reason "…"` (nothing to do / a human has to step in), after
277
+ which it is not woken; a backlog is still logged; once a human has dealt with it, `team standby off`.
278
+ - Repeated reminders for the same batch are limited by `TEAM_PULSE_NUDGE_GAP`; a PM that is busy can simply ignore a
279
+ reminder.
280
+ - Division of labour with instant notifications: the notification at the end of an agent's turn is **instant** (the
281
+ notify extension: write the inbox + knock on the PM window); the pulse's reminder is a **timed fallback**: as
282
+ long as that batch is unread/unhandled, the next round (or a change in pending work) raises it again.
283
+ - Boundaries: it does not manage tmux layout by default (`TEAM_PULSE_REBUILD_TMUX=0`, a lost session/window is only
284
+ reported; with the knob set to 1 it rebuilds the session and the PM window **when it notices they are gone** --
285
+ which cannot help if the tmux *server* died, because the patrol itself lives in a pane of that server). It does
286
+ **not** leave agents alone, though: a seat that has stopped while its task is unfinished is auto-dispatched back
287
+ onto the same task (`cmd-watch.sh`'s resume path, one `resume agent=<a> task=<id>` line in `watchdog.log` per
288
+ attempt). It does not manage model quota and never merges automatically. Runaway protection: the auto-start quota
289
+ of 5 per hour plus the pulse's own pid lock.
290
+
291
+ Why the boundaries are drawn this narrow: an "everything-managing" daemon would manipulate tmux layout, agent
292
+ lifecycles and model quota at the same time, and when something breaks nobody can tell who corrupted the state;
293
+ furthermore, the more "keep-alive" it does, the easier it is to silently paper over something that should have needed
294
+ a human.
295
+
296
+ ## 8b. Branch model: one branch per task (default)
297
+
298
+ - `TEAM_BRANCH_MODE=task` (default): `dispatch` cuts `task/<ID>-<slug>` off the protected branch inside the agent's
299
+ long-lived worktree; `review/merge/close` all operate on that task branch → **the verification scope is one task's
300
+ diff**, the rollback granularity is one task, and the PR description is a reference to the brief. After a task is
301
+ `close`d the worktree returns to `detached@protected branch`, so the next task starts clean.
302
+ - `TEAM_BRANCH_MODE=agent`: one long-lived branch `agent/<name>` per agent (fits long refactors, or a team where each
303
+ agent only ever does one thing).
304
+ - **The branch a task runs on has one declared name**, resolved in this order: `dispatch --branch <name>`, else the
305
+ brief's `branch:` line, else the derivation from the title; `team task` writes the derived name into the brief as
306
+ its `branch:` line, so a later title change does not move the target under a running task. Dispatch prints the
307
+ resolved name **and its source** before the launch (`--print` too). Without `--branch`, a worktree sitting on
308
+ **this task's** branch is accepted even when its slug differs (both names are printed — the slug is a display
309
+ detail, not the identity of the work); with `--branch` the worktree must be on exactly that name, because the
310
+ explicit declaration wins. The launch prompt names the branch the guard actually accepted and
311
+ `state/<agent>.env: branch=` records the same one, so the worker, the ledger and the worktree tell one story.
312
+ - When the worktree is dirty, switching branches is refused (otherwise the previous task's changes leak into the new
313
+ task); that is a hard rule, not a reminder.
314
+
315
+ ## 8c. The pulse's scope: it serves the current tmux session only
316
+
317
+ - The pulse (`team monitor` in the `pulse` window) only answers questions about this session: who is running,
318
+ what task they are on, what is pending, how the capacity looks; it **never digs through another agent's session
319
+ content** (that is what the PM reads via `inbox`/reports/`digest`).
320
+ - The session activity stream is opt-in: `team monitor --activity` (and it only lists live windows in this session).
321
+ It is off by default for a very practical reason: 6 agents ≈ ~9MB of JSONL read per render (measured 7MB→67MB RSS,
322
+ refreshed every 3s), and the noise covers up the state you actually needed to see.
323
+ - The panel refreshes every 5s by default while the patrol beat stays `TEAM_PULSE_INTERVAL` (900s by default).
324
+ - **What counts as "pending work"**: unread notifications / reports awaiting verification / a `blocked` row / agents
325
+ that stopped (with a task that was never delivered).
326
+ The board's `todo/wip` **do not count by default** — a backlog is always there and knocking every 15 minutes would
327
+ be pure noise; to include the backlog in reminders set `TEAM_PULSE_PENDING_BOARD=1` (the panel and the digest always
328
+ show them anyway).
329
+
330
+ ## 8d. Board and report parsing must tolerate human edits
331
+
332
+ Three places CEP hit in practice, all of which now have explicit tolerance rules:
333
+
334
+ - **BOARD column count**: `ID/task/Agent/branch/dependency/status` are located **by header name**, so columns may be
335
+ inserted by hand (e.g. an `Issue` column); `board ls` reports a "non-standard column layout" but keeps working;
336
+ `team board set` only writes the status column and never touches a column you added; new rows are aligned to the
337
+ existing column count (unknown columns stay empty). Parsing used to be positional, and after adding a column it
338
+ would read a `—` as the title.
339
+ - **Duplicate ids**: a board row is identified by `(id, nth)` — the n-th row carrying that id — because a board
340
+ may share an id between tasks. The console walks the focus positionally, so two rows with one id are two
341
+ stops and each can be selected alone; `board add` refuses a second row for an existing id unless `--allow-dup`
342
+ is passed (audited in `state/watchdog.log`), and `board ls` / `digest` / `doctor` report the duplicates
343
+ (doctor warns, it does not fail). `board set <ID> <status>` and `board assign <ID> <agent>` address a row by
344
+ **id** and write **every** row carrying it (that has always been the CLI's rule; the row-level identity above
345
+ is the console's) — which is exactly why a *new* duplicate is refused at the door.
346
+ - **The pending-report heuristic**: a file under `reports/*.md` only counts as awaiting verification when its
347
+ file-name prefix is a task ID **and** its title is `# <ID> · …` **and** that ID is on the BOARD (or has a brief);
348
+ the PM's own milestone/closure reports (`P2-closure.md` and the like) are grouped by `digest` under "ignored
349
+ non-task reports" — not silently dropped, and not nagged about either.
350
+ - **merge conflicts**: on failure the unmerged files are listed directly (`UU/AA/DD/AU/UA/DU/UD`) together with a hint
351
+ about `--no-renames` (add/add is often git's rename detection pairing `reports/<ID>-x.md` with `reviews/<ID>.md`).
352
+ It no longer just drops a "conflict/failed" on you to re-run by hand.
353
+
354
+ ## 8e. A BOARD status only becomes done after the code really reached the protected branch
355
+
356
+ CEP has been there: on a failed conflict path the BOARD had already been marked `done` while the code never reached
357
+ `main` (the PR was still open) — a status contradicting the facts is more dangerous than the failure itself. The
358
+ current order and the closing move:
359
+
360
+ **Before the merge, land the worktree's records.** `git merge --squash` carries the branch's *committed* content
361
+ only, but a worker often leaves its report, evidence package or `<docs>/` edit **uncommitted** in its worktree
362
+ (`??`/` M`) — the merge succeeds, the record stays behind, and reusing the worktree destroys it (2026-09-22:
363
+ P36/P40/P42/P65/P67). The digest already warns about unlanded records (M31/P47), but the merge flow never runs the
364
+ digest, so the check lives on the merge step itself:
365
+
366
+ ```bash
367
+ team review <ID> --pre-merge
368
+ ```
369
+
370
+ It resolves the task branch (state → refs), finds the worktree checked out on it, and prints every `<docs>/**`
371
+ path there that is not committed — each line as `<agent>: <path>` with a copy-paste `git -C <worktree> add -A -- …`
372
+ + `git commit` recipe carrying the `Agent: <agent>` trailer. It exits **non-zero while any exist** (usable as the
373
+ merge gate), prints nothing when clean, and **never commits for you** — who committed a record must stay true.
374
+ Ignored files (`state/`, build output) and dirty paths outside `<docs>/` are not part of the check; if no worktree
375
+ can be located it refuses (rc 2) rather than reporting clean — "not checked" must not look like "nothing wrong".
376
+
377
+ **After the merge, check whether the branch moved again.** A squash merge freezes the branch as it was *at that
378
+ moment*: commits the author lands afterwards are not in the protected branch (2026-09-22: P82 added two record-only
379
+ commits after the merge and `main` kept the older records). Any late delivery gets one command, before taking
380
+ anything:
381
+
382
+ ```bash
383
+ team review <ID> --post-merge
384
+ ```
385
+
386
+ It compares `main..task/<branch>` **per path** and reports only what the branch added *after* the merge: a path the
387
+ branch never changed since the fork, a path whose `main` version came later from elsewhere, and a path whose branch
388
+ version `main` already had at some point all belong to other work, not to this task. Without that filter a stale
389
+ branch would list every later task's files — and even advise "taking" records that would delete them. `<docs>/**`
390
+ paths → *records updated: take them* plus a copy-paste `git -C <root> checkout <branch> -- <paths>` (a record the
391
+ branch deleted comes as `git rm -f`), exit 0. Paths under `skills/**` (or anything else outside `<docs>/**`) → exit
392
+ non-zero with "code has unmerged changes — do not just take the records, re-merge and re-run the gates". Versions
393
+ that fit neither side (conflict resolution, a never-merged branch, a late change colliding with someone else's) are
394
+ named too rather than dropped. No branch → rc 2: "not checked" never looks like "nothing wrong".
395
+
396
+ 1. verify the branch exists (a mistyped `--branch` is not misreported as a "conflict");
397
+ 2. `merge --squash` → `commit` → **`push` (when `--push`/`--pr`)** all succeed;
398
+ 3. only then `board set <ID> done`.
399
+
400
+ If any step fails (conflict / failed commit / failed push): **the BOARD keeps its pre-merge state** (usually
401
+ `review`), and `done` is not set — code that never reached the protected branch is not finished.
402
+
403
+ ### The tool checks step 3 instead of trusting it
404
+
405
+ Since v1.20.0 `team board set <ID> done` (and `team close <ID>`, whose default status is `done`) **refuses** unless
406
+ it can point at something checkable at that moment:
407
+
408
+ - `<docs>/reviews/<ID>.md` exists and its verdict is not `FAIL`/`TIMEOUT` (`PASS`; `UNKNOWN`/`SKIPPED` are accepted
409
+ as an explicit manual review and named as such in the output), **or**
410
+ - the task branch tip is already contained in the protected branch (`git merge-base --is-ancestor`, i.e. a real
411
+ merge / fast-forward). A **squash** merge does not satisfy this — the branch commits are not ancestors — so in the
412
+ usual squash workflow the review record is what unlocks `done`.
413
+
414
+ Every accepted transition appends what it checked to `<docs>/reviews/<ID>-done.md` (append-only; the forced case is
415
+ marked `FORCED`), so "what did it verify at that moment" survives the terminal:
416
+
417
+ ```
418
+ - <timestamp> · `team board set M5.2 done` · OK:the evidence line for that moment
419
+ (e.g. "review record <docs>/reviews/M5.2.md, verdict PASS")
420
+ ```
421
+
422
+ If neither condition holds and the PM is sure anyway, the override has to carry a reason:
423
+
424
+ ```bash
425
+ TEAM_BOARD_DONE_FORCE=1 TEAM_BOARD_DONE_REASON="hotfix pushed by hand; PR #12 is the record" \
426
+ team board set <ID> done # or: team close <ID> --status done --force --reason "…"
427
+ ```
428
+
429
+ A missing reason is refused, and the transition is recorded as `FORCED` together with the failed checks — an
430
+ override is allowed, a silent one is not. Nothing is written when the gate refuses.
431
+
432
+ ### What the tool cannot check (the PM's own checklist)
433
+
434
+ The "pushed" half is the PM's:
435
+
436
+ - `git -C <root> merge-base --is-ancestor <branch> <protected>` exits 0, and `git -C <root> status -sb` shows the
437
+ protected branch is not ahead of its upstream;
438
+ - `team review <ID> --dir <independent checkout>` recorded `PASS` on the revision you are about to merge
439
+ (`--strong` for a milestone);
440
+ - only then `team board set <ID> done` and `team close <ID>`.
441
+
442
+ Conflict handling (the PM runs all of this itself):
443
+
444
+ ```bash
445
+ git -C <root> merge --abort # want to give up and start over
446
+ git -C <root> status --porcelain | grep '^U' # list the conflicted files (UU/AA/…)
447
+ # lockfile-style conflicts (pnpm-lock.yaml and friends): take the branch side, then reinstall
448
+ git -C <root> checkout --theirs -- pnpm-lock.yaml && (cd <root> && pnpm install --lockfile-only)
449
+ git -C <root> add -A && git -C <root> commit -m "<ID>: <title>"
450
+ ```
451
+
452
+ **Conflict markers do not ride along**: `smoke.sh` §0d greps every tracked file for a line starting with
453
+ `<<<<<<<` / `=======` / `>>>>>>>` and fails with `file:line`, so a `git add -A && git commit` on top of an
454
+ unresolved `merge --squash` is caught by the next gate instead of reaching `main` (it did once).
455
+
456
+ A trap: an add/add conflict is often git's rename detection pairing two different paths (e.g. `reviews/<ID>.md` and
457
+ `reports/<ID>-<agent>.md`). Retry with `git -c merge.renames=false merge --squash <branch>` and it goes away.
458
+
459
+ ## 8f. Template rendering and dispatch traps (measured on erp)
460
+
461
+ - **Rendering must not go through sed**: `&` inside the replacement string means "the matched text", so
462
+ `TEAM_GATES="pnpm test && pnpm lint"` was written out as `pnpm test {{GATES}}{{GATES}} pnpm lint`. `team_render` now
463
+ uses bash parameter expansion and explicitly disables bash 5.2+'s `patsub_replacement` (which likewise treats `&`
464
+ in the replacement as the matched text).
465
+ `init` also escapes gate values containing `$ \` \ "` before writing them into the config, so sourcing it back
466
+ yields the same value as the input (and is never executed).
467
+ - **Dispatch writes absolute paths**: the window shell's PATH/rc may not be ready yet, so exec'ing `pi` directly ends
468
+ in `command not found` (reproduced twice on erp). Dispatch now resolves pi's absolute path first, writes it into the
469
+ window command, and checks that it exists before dispatching (a missing binary fails immediately instead of being
470
+ discovered inside the window).
471
+ - **GitLab API headers and bodies must match**: if `--data-urlencode` is the form body, then
472
+ `Content-Type: application/x-www-form-urlencoded` must go with it; setting `application/json` gets rejected by
473
+ GitLab (`{"error":"Invalid JSON format"}`, and the PR/MR never opens). A JSON body (`--data/--data-binary`) still
474
+ uses `application/json`.
475
+
476
+ ## 8g. Across projects: you may talk, you may not command
477
+
478
+ - **Normal conversation between projects is allowed**: how an interface connects, advice with its basis, problem
479
+ reports with reproductions, scheduling a joint test window.
480
+ **Not allowed**: telling another PM/agent what to do, deciding on the other side's behalf, impersonating a human to
481
+ issue instructions, changing the other side's repository or state.
482
+ - The mechanism makes "wanting to command but being unable to" real: the `intent` whitelist of `team meeting` has
483
+ **no command/order**; `--as-user` only works from a human terminal (+ `TEAM_MEETING_ALLOW_USER_ID=1`), so an agent
484
+ process writing it is refused; consensus requires **both sides to agree separately**; the meeting only writes the
485
+ shared area and has zero write permission in the peer's repository.
486
+ - Division of labour: **workers do not attend** (cross-project communication goes through the PM); a worker that needs
487
+ outside cooperation writes `BLOCKED:` in its report.
488
+ - The shared area lives outside both projects (`~/.pi/team/meetings/<slug>/`) and the transcript is the only truth;
489
+ knocking (nudging the peer PM's window) is off by default and only happens with `--knock` + `TEAM_MEETING_KNOCK=1`
490
+ + a registered peer session.
491
+ - Boundary guard: cross-session typing is refused **by default without exception**; the single exception is knocking
492
+ for a registered meeting — which is what stops "casually reaching into another project".
493
+
494
+ ## 8h. git and forges belong to the PM: the skill neither performs nor wraps them
495
+
496
+ - The skill **does not perform** git writes (creating/switching branches, squash, push) or forge writes (open/merge a
497
+ PR, comment, close a PR); **and it does not print "recipes"** either — that would be over-packaging tools that
498
+ already exist. The PM uses the **real tools** directly: `git`, plus whatever forge access it has (`curl` against an
499
+ API, `gh`/`glab`, the web UI).
500
+ - On git the skill does exactly three things (all read-only or bookkeeping):
501
+ 1. **Checks**: before `dispatch` it confirms the worktree is clean and not on the protected branch (otherwise it
502
+ refuses and explains why);
503
+ 2. **Read-only observation**: `roster` / `digest` show the branch, dirty file count, commits ahead and a
504
+ "waiting to be wrapped up" list;
505
+ 3. **Verification evidence**: `review <ID> --dir <the checkout the PM prepared>` runs the gates and writes
506
+ `reviews/<ID>.md` (git is prepared by the PM).
507
+ - The conventions (written in SKILL.md and the project's PROTOCOL, for the PM to follow): one long-lived worktree per
508
+ agent; task branches cut off the protected branch; verification on a detached independent checkout; merging =
509
+ squashing into the protected branch (with a PR, merge the PR first and then `fetch + merge --ff-only`);
510
+ **the BOARD is only marked done after the code has really reached the protected branch**.
511
+ - Forge-agnostic: GitHub/GitLab are not assumed; a token is read from the project's configured token file and injected
512
+ only for the duration of a command, never echoed.
513
+
514
+ ## 8i. The roster is a contract value with one authorized entry
515
+
516
+ The roster (`TEAM_AGENTS`) is part of the project contract, and like every other key it has exactly one writer:
517
+ the contract's hardened writer, reached through `team add-agent <a> --register` (grow) or `team teardown --agent
518
+ <a> --register` (shrink). Both do a read-modify-write with the roster's value rule (each seat name matches
519
+ `[A-Za-z0-9][A-Za-z0-9._-]*`, appears once, is never `pm`), the sha256 fingerprint CAS and exactly one
520
+ `result=ok actor=cli` line in `<state>/config.log`; the flag is not optional, and a bare `team add-agent <a>` for
521
+ a seat the roster does not carry exits 5 while naming both routes that work (hand-edit `.pi/team/config.sh`, or
522
+ add `--register`). `TEAM_AGENTS` stays class `refuse`: the console may not write it — a human at the panel could
523
+ otherwise widen the project's authority — and the schema note it renders names the register entries. The same
524
+ value rule is what `team config list --json` reports as the key's `warning` when a hand-edited file already
525
+ carries an illegal token, so the read side and the write side can never disagree about what a seat name is.
526
+
527
+ ## 9. Capacity: the floor is that neither RAM nor disk swap bottoms out (zram does not count)
528
+
529
+ - There is only one condition for refusing a dispatch: free swap below `TEAM_MIN_FREE_SWAP_MB` (1024MB by default) or
530
+ RAM+swap below `TEAM_MIN_TOTAL_MB`.
531
+ - Tight RAM (below `TEAM_WARN_AVAIL_MB`) only warns: slowness is acceptable, because slow is not broken; an OOM is the
532
+ real accident.
533
+ - `team ps` / `team doctor` report from the same data source and add an estimate of "how many more agents fit"
534
+ (`TEAM_AGENT_MEM_MB`).
535
+
536
+ ## 9b. Tests and gates must have a timeout (non-negotiable)
537
+
538
+ - The fact: a deliberately broken implementation made a PG integration test wait for a connection forever (no pool
539
+ timeout + a missing `--test-timeout` + bash `timeout` set to 1800000s) → the script hung for **85 minutes** with zero
540
+ output.
541
+ - Therefore: `team review` **always wraps the gates in a hard timeout** (`TEAM_REVIEW_TIMEOUT`, 1800s by default; a
542
+ timeout is recorded as `TIMEOUT`, treated as FAIL and written into the verification record). The verdict is taken from
543
+ the `timeout` **wrapper's exit code together with the elapsed time** (124 = TERM fired, 137 = the child ignored TERM
544
+ and was KILLed), never from a substring of the gate's own log — otherwise a hung gate reads as a plain failure and a
545
+ gate that merely *prints* “using timeout 5” reads as a timeout. Requiring **both** signals is what stops the opposite
546
+ error: a gate that exits 124 by itself (or a suite whose inner test propagates 124) used to be recorded as "killed at
547
+ the deadline"; it is now `FAIL` (a signal-terminated gate is recorded as `FAIL` with the signal named). Gate commands
548
+ should carry their own `timeout` too (e.g. `timeout 900 pnpm test:unit`).
549
+ - Acceptance commands in a brief should carry their own timeout as well; destructive experiment scripts must restore
550
+ the scene with `trap 'git checkout -- …' EXIT`.
551
+
552
+ ### 9b-2. The gate is the machine's one shared resource (queue, and the measurement premise)
553
+
554
+ The full gate — `openspec validate … && bash skills/teamsmith/tests/smoke.sh` — spends the machine's tmux servers,
555
+ node/bun processes and login shells, so it is serialised on **one gate lock**
556
+ (`${TEAM_SMOKE_LOCK:-${TMPDIR:-/tmp}/teamsmith-smoke.lock}`, holder recorded in `<lock>.holder`, wait capped by
557
+ `TEAM_SMOKE_LOCK_WAIT`, default 1800 s). Use `TEAM_SMOKE_FAST=1` for in-batch self-tests (pure-logic sections
558
+ only; measured in the low minutes on a loaded 32-core box, not the seconds it once was - P100's F6) and the
559
+ **full** suite for delivery and review.
560
+
561
+ **A lock that cannot be taken is a visible degradation, not a hard failure.** If the lock file cannot be
562
+ created (or `flock` is absent) the suite prints `注意:锁文件 … 建不了 → 不做排队` and runs anyway; only a
563
+ *queue overrun* is loud (a one-line `排队超限` naming the holder in `<lock>.holder`, exit 2), and a genuine
564
+ red is exit 1 with no queue wording (P66/P100's F1).
565
+
566
+ **The gate fingerprints the tree it judges (P158).** Once the run's own root exists it records `HEAD` and the
567
+ sha256 of `git status --porcelain --untracked-files=all` (untracked files included) into the run's scene file
568
+ (`<run tmp>/run-fingerprint.txt`, next to `sections.tsv`), and compares that fingerprint again after the last
569
+ section. If the tree moved while the run was in flight — a merge into the same checkout, an edit to any path,
570
+ even one no section read — the run prints one conspicuous line
571
+ `本次运行无效:树在跑动中被改动(HEAD A→B / 脏文件 N→M)` right next to the result line, leaves every ✓/✗ it
572
+ already printed standing (the reds are not swallowed) and exits **4**: the verdict is *invalid*, not a judgement
573
+ on the code, because the tree that ran is not the tree the result line names. 1 stays “there are failures”, 2
574
+ “the gate stopped itself” (precondition or queue), 3 “no temp root”, so the four codes do not overlap; rerun
575
+ once the tree is stable. The criterion is deliberately the whole worktree rather than “the files the suite
576
+ read”: cheaper and unambiguous, and a record under `docs/team/**` that no section consumed still counts as the
577
+ tree having moved (conservative). A tree that is not a git checkout prints one visible note and does not judge
578
+ what it cannot judge (P148's rule); an unchanged tree adds no stdout at all. The red side and its teeth are
579
+ `tests/flip-p158.sh` (four cases plus two `--break=` shadows), and suite section `0i` runs it.
580
+
581
+ **How often the full suite runs (2026-09-23, user directive).** The full suite takes 13-20 minutes and the
582
+ machine runs one at a time, so it is a *milestone* gate, not a per-change habit: a task runs it **once at
583
+ delivery** (not per batch), a review runs it **once**, and the PM runs it on the protected branch **only at
584
+ archive/release milestones** - per merge it reads the delivered run plus CI. A change whose diff touches no
585
+ product path (for example records under `docs/**` only) needs **no** suite run: say so in the report and let
586
+ the guarded FAST set (or nothing) stand as the evidence. When in doubt prefer FAST plus the affected
587
+ sections and name what you did not run; **never** claim a full run you did not do. Which sections a changed path affects is
588
+ mechanical: `bash skills/teamsmith/tests/section-select.sh --paths <path…>` answers `RUN`, `NONE` (records under `docs/**`) or `FULL`
589
+ (a path no row claims — run the suite), `bash skills/teamsmith/tests/smoke.sh --paths <path…>` runs that answer, and a selected run
590
+ lists the sections it did not run instead of claiming the full suite. **A selected run's green covers only the sections it
591
+ ran, not the suite: a report citing one names the sections it did not run.** `team review` takes that same lock **before** starting its
592
+ hard timeout: the queue is its own bounded phase, the record accounts it separately (`limit=Ns queued=Ns ran=Ns`),
593
+ a queue that exceeds the cap is `FAIL` with the holder named (never `TIMEOUT`), a run that really overruns is still
594
+ `TIMEOUT` with `ran=Ns`, and `SMOKE_LOCK_WRAPPED=1` tells a nested run that an ancestor already holds the lock (so
595
+ it does not queue again and cannot deadlock against its own suite). Without `flock` the degradation is printed.
596
+ The gate judges **correctness only**: it contains no wall-clock or CPU-share red line, and a pure-logic guard in the
597
+ gate's own sources (`tests/gate-guard.sh`) fails when a frame-budget/CPU-share marker reappears in it or when the
598
+ performance suite loses its markers. The three panel numbers — the interactive first frame, the uncached frame
599
+ assembly and the steady-state pane CPU — belong to the **performance suite**
600
+ (`bash skills/teamsmith/tests/perf.sh`, front door `team perf`): the thresholds (`2000 ms` / `2000 ms` / `< 1 %` of
601
+ one core), the premise factors (`0.75` for the five-sample assembly median, `0.25` for the cold-start first frame
602
+ and the sampled pane CPU, `TEAM_PANEL_CPU_PREMISE_FACTOR`) and the median-of-three/five rules are unchanged, every
603
+ sample is printed, and above the premise the judgement **skips visibly** (exit `4` for a skip, `2` for a red, `0`
604
+ only when every judgement ran green) rather than reporting a red the machine owes. The suite takes its **own** lock
605
+ (`TEAM_PERF_LOCK`, `TEAM_PERF_LOCK_WAIT`, holder in `<lock>.holder`) and **never** takes `TEAM_SMOKE_LOCK`: it does
606
+ one read-only non-blocking probe of the gate lock and prints the holder when the correctness gate is running, but
607
+ it never queues behind it. The gate's lock accounting (`limit=Ns queued=Ns ran=Ns`), the fixture-knob rule (those
608
+ `TEAM_*` knobs only work under `TEAM_SMOKE_FIXTURE=1`, and in the real path they are ignored and printed) and the
609
+ gate's time-independent half of that check (`tests/panel-knobs.sh`) are unchanged; a red performance run changes no
610
+ review verdict. The contracts live in the specs (`verification#The correctness gate judges correctness only`,
611
+ `verification#The performance suite is separate, self-describing and non-blocking`,
612
+ `verification#The hard timeout covers the gate run, not the queue`,
613
+ `panel#Frame assembly is asynchronous, cached and never blocks input`); this section is the operational rule.
614
+
615
+ The gate also reports **its own temp-root usage**: one line at the start and one with the result summary (also on
616
+ failure) name the run's root, its size and its file count, and the run asserts that every root it created is gone
617
+ unless it declared one kept. Fixtures get their root from `${TMPDIR:-/tmp}/teamsmith-<kind>.XXXXXX` through the
618
+ single owner helper `tests/lib/tmp-root.sh` (owner marker inside, run ledger outside, reclaim on `EXIT`/`INT`/`TERM`,
619
+ `TEAM_TMP_KEEP=1` to keep); residual roots are reclaimed by an **operator** action,
620
+ `bash skills/teamsmith/tests/tmp-hygiene.sh --status` then `--sweep` (it proves a root is unoccupied before
621
+ deleting, and refuses with nothing deleted when it cannot). The gate never sweeps: a fixture another agent started
622
+ by hand is not in the gate lock, so pattern-deleting in the shared temp filesystem is the D37 family. `team doctor`
623
+ prints the temp root's headroom (free/total bytes and inodes, warning only) so a full tmpfs is visible before it
624
+ turns into a red a fixture cannot explain.
625
+
626
+ ### 9b-3. The ledger is public, so the ban is a gate check (D94)
627
+
628
+ Since 2026-10-04 the readable ledger — board, decisions, roadmap, ownership, briefs, the text of reports and
629
+ verification records, threads — is committed to the repository (D94). A brief or a report is therefore public the
630
+ moment it is written, and the one mechanical redaction pass that produced the first batch has no net behind it.
631
+ So the ban is a check in the gate: suite section `60` runs `tests/ledger-ban.sh`, which scans `docs/team/**/*.md`
632
+ and fails, naming file and line, on
633
+
634
+ - a home directory (`/home/<name>…` or `/Users/<name>…`; the ellipsis placeholders `/home/.../` and `/home/…/` pass);
635
+ - a private IPv4 address (`192.168.<x>`, `10.<x>.<x>`, `172.16–31.<x>` — three octets minimum, and the bare
636
+ `192.168.` prefix, the way this very rule writes it, never matches);
637
+ - the local username, resolved at run time (`id -un` → `$USER`/`$LOGNAME` → the tail of `$HOME`) and never written
638
+ into the repository; a name that cannot be resolved is a visible skip, not a silent pass;
639
+ - a name from the other-project list `.pi/team/forbidden-names.txt` — one name per line, `#` comments and blank
640
+ lines ignored, matched as a whole word, case-insensitive. The list is gitignored, and it has to be: the names it
641
+ spells out are exactly what the ban protects. A missing or empty list is a **visible skip**
642
+ (`SKIP names —— 禁令名单未配置… 这一项不是通过`), never a pass.
643
+
644
+ The `<home>` / `<user>` / `<peer>` / `<internal>` placeholders are stripped before matching, so the redacted ledger
645
+ passes; text outside `docs/team/**` is not in scope (the skill's own docs talk about *the user's* projects), and the
646
+ gitignored evidence packages (`docs/team/reports/<ID>-<agent>/…`) are not scanned — they never enter the public
647
+ surface. A hit line is masked: it names the file and line and replaces the offending token with a placeholder, so a
648
+ gate log can be pasted anywhere without leaking the thing it reported. Since P216 that promise covers **every shape on
649
+ the line and every occurrence of it**, not just the first shape the scanner recognized: the hit spans are collected
650
+ first and the line is assembled once from the original text, so a replacement is never scanned again (what a hit
651
+ looks like in the log is `<home>` / `<internal>` / `<names#N>` / `<user>`, with the first shape found naming the
652
+ line), and a line longer than `BAN_LINE_MAX` (4096 bytes) is masked first and truncated after, with an explicit
653
+ `…(截断)` marker. Exit codes: `0` every shape was checked and
654
+ clean, `3` clean but a sub-check was skipped (missing/empty list, unresolved username), `1` a hit, `4` the scanner
655
+ itself failed. Falsifiability lives in the fixture self-test (`bash tests/ledger-ban.sh --self-test`): a planted home
656
+ path and a planted forbidden name must come back red with file:line, a missing list must show the visible skip, a
657
+ shadow scanner whose hit counter is broken must make the two red cases fail, and a second shadow whose masking is
658
+ turned off must make the “no raw text in the output” cases fail — a mixed line, twenty-five occurrences on one line,
659
+ a placeholder standing before the hit (the offset must survive the blanking), and an over-long line.
660
+
661
+ ## 9c. Strong verification (adversarial package + finding flips, for milestones)
662
+
663
+ `team review <ID> --strong` checks two extra things and writes the conclusion into the verification record. The check is
664
+ **structural**, not a keyword grep (a report that merely *mentions* “flip evidence” or “independent package” does not
665
+ pass; an English-first report with real evidence does), the wording is the one this repo's own
666
+ `templates/report.md.tmpl` / protocol use, and the record shows what was looked for, what was found (file + line) and
667
+ which half is missing:
668
+
669
+ 1. **Flip evidence**: a section whose heading names the flip (`flip`, `flip evidence`, `red before … green after`,
670
+ “break the implementation”, `翻转`, `破坏`) **and** which contains both a failing (red) and a passing (green) result —
671
+ “red before the fix → green after”, or “break the implementation → the guard test must fail”. A command line is
672
+ recorded as an extra hint;
673
+ 2. **Independent verification package**: a **path** in the report that points at the package/script — `…/pkg/run.sh`,
674
+ `docs/team/reports/<ID>-<agent>/pkg/…`, a script (`.sh`/`.mjs`/`.js`/`.ts`/`.py`) or any *really existing* directory
675
+ in the checkout. Bare words (“an independent package exists”) do not count. A statement of independence is recorded
676
+ as a hint, and the record also says whether that path is actually present in the reviewed checkout.
677
+
678
+ The report is looked up in the reviewed checkout first and then in the PM's/agent's worktrees (a report that is not
679
+ committed in the verified revision is still read, and the record states that it was taken from outside the checkout).
680
+
681
+ A missing half is recorded as `不满足(不阻塞合并,但里程碑收口前应补齐)` and warns; it does not block the merge. The
682
+ sharper kind of flip — **deliberately break the implementation → the guard test must fail** — is exactly what a heading
683
+ like `## Flip evidence` with both outcomes is expected to contain.
684
+
685
+ It costs more, so it fits milestones and closure rounds; everyday tasks run the ordinary gates.
686
+
687
+ ## 10. Decision log and research rules
688
+
689
+ - For a stack/technology choice (language, framework, library, storage, protocol) a **research agent gathers evidence
690
+ first** (① measured on this machine > ② official documentation > ③ secondary sources; anything unmeasured must be
691
+ marked as such), and the PM only writes a "decision" after verifying that evidence chain.
692
+ - Every decision must record its **reason** and its **impact**: a decision log with conclusions only is worth nothing
693
+ six months later.
694
+ - An agent may overturn the PM's provisional judgement with its own evidence — that is by design, not overreach.
695
+
696
+ ## 11. Talking to the user: a code never stands alone
697
+
698
+ The ledger is keyed by codes (`M12`, `P14`, `V15`, `T1.1`): the BOARD, the roadmap, briefs and review records all
699
+ use them, and after a few days the team reads them fluently. The user has no such index in their head — a report
700
+ that says "P14 needs a decision" sends them to the files to find out what P14 *is*, and the message that should
701
+ have informed them turns into homework.
702
+
703
+ So: **in user-facing output, a code never stands alone.** Every occurrence that names a task carries its short
704
+ human-readable name in the same place — `M12 (fix the smoke flake)` — and milestones and change ids work the same
705
+ way. A list is read row by row, so a code repeated on another line is named again there ("each row is a reading
706
+ unit"). The one exception is a copy-pasteable command (`team close M12`): there the code is a key, and rewriting
707
+ it would break the tool it calls.
708
+
709
+ The mechanism backs this up wherever the ledger already knows the name: `team digest` (pending review, the
710
+ board-skipped line, wrap-up, suggestions), `team status` and `team roster` print the name next to the code, resolving
711
+ it from the BOARD's task column first, then the task brief's H1, then the task's report H1. When no name is known the
712
+ code is printed alone — never a made-up name, and never a hidden code: the code is the key to the ledger.