teamsmith 0.3.4 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +8 -8
  2. package/package.json +1 -1
  3. package/skills/teamsmith/CHANGELOG.md +40 -0
  4. package/skills/teamsmith/SKILL.md +83 -163
  5. package/skills/teamsmith/extension/team-notify.ts +1 -1
  6. package/skills/teamsmith/extension/team-reply.ts +105 -0
  7. package/skills/teamsmith/references/agent-adapters.md +1 -1
  8. package/skills/teamsmith/references/config.md +20 -11
  9. package/skills/teamsmith/references/migration.md +47 -3
  10. package/skills/teamsmith/references/protocol.md +64 -31
  11. package/skills/teamsmith/references/reminders.md +131 -0
  12. package/skills/teamsmith/references/troubleshooting.md +19 -5
  13. package/skills/teamsmith/references/workflows.md +18 -16
  14. package/skills/teamsmith/scripts/lib/cmd-agents.sh +77 -49
  15. package/skills/teamsmith/scripts/lib/cmd-project.sh +193 -21
  16. package/skills/teamsmith/scripts/lib/cmd-remind.sh +103 -0
  17. package/skills/teamsmith/scripts/lib/cmd-update.sh +7 -4
  18. package/skills/teamsmith/scripts/lib/common.sh +44 -4
  19. package/skills/teamsmith/scripts/lib/outbox.sh +72 -18
  20. package/skills/teamsmith/scripts/remind-store.mjs +529 -0
  21. package/skills/teamsmith/scripts/replies.mjs +9 -3
  22. package/skills/teamsmith/scripts/reply-capture.mjs +612 -0
  23. package/skills/teamsmith/scripts/state-authority.mjs +500 -0
  24. package/skills/teamsmith/scripts/strings/commands.tsv +2 -1
  25. package/skills/teamsmith/scripts/strings/help.en.tsv +16 -2
  26. package/skills/teamsmith/scripts/strings/help.zh.tsv +16 -2
  27. package/skills/teamsmith/scripts/team +1 -0
  28. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +68 -123
  29. package/skills/teamsmith/templates/PROTOCOL.md.tmpl +48 -55
  30. package/skills/teamsmith/templates/pm-prompt.md.tmpl +126 -119
  31. package/skills/teamsmith/tests/checkout-shape-probe.sh +6 -5
  32. package/skills/teamsmith/tests/delivery-truth.sh +82 -47
  33. package/skills/teamsmith/tests/fixtures/delivery-truth-real/README.md +71 -23
  34. package/skills/teamsmith/tests/fixtures/delivery-truth-real/__pycache__/judge-second.cpython-313.pyc +0 -0
  35. package/skills/teamsmith/tests/fixtures/delivery-truth-real/judge-dirty-ab.py +143 -0
  36. package/skills/teamsmith/tests/fixtures/delivery-truth-real/judge-second.py +26 -9
  37. package/skills/teamsmith/tests/fixtures/delivery-truth-real/run-case.sh +92 -20
  38. package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +47 -3
  39. package/skills/teamsmith/tests/fixtures/reply-capture-provider.ts +76 -0
  40. package/skills/teamsmith/tests/flip-p410-order2.sh +205 -0
  41. package/skills/teamsmith/tests/frames/README.md +3 -1
  42. package/skills/teamsmith/tests/gate-guard.sh +20 -4
  43. package/skills/teamsmith/tests/help-surface.sh +60 -2
  44. package/skills/teamsmith/tests/install-shape.sh +312 -0
  45. package/skills/teamsmith/tests/key-replies-pty.sh +197 -21
  46. package/skills/teamsmith/tests/key-replies.sh +187 -68
  47. package/skills/teamsmith/tests/ledger-claim.sh +8 -6
  48. package/skills/teamsmith/tests/lib/box-judge.sh +2 -1
  49. package/skills/teamsmith/tests/lib/main-team-fingerprint.sh +104 -0
  50. package/skills/teamsmith/tests/lib/pm-window.sh +143 -0
  51. package/skills/teamsmith/tests/lib/reply-fixture.sh +7 -19
  52. package/skills/teamsmith/tests/lib/reply-guard.sh +188 -0
  53. package/skills/teamsmith/tests/lib/section-calls.pl +171 -0
  54. package/skills/teamsmith/tests/loop-inventory.tsv +7 -5
  55. package/skills/teamsmith/tests/meta-suite.sh +215 -0
  56. package/skills/teamsmith/tests/panel-b3-pty-mouse.py +154 -17
  57. package/skills/teamsmith/tests/panel-b3.sh +33 -4
  58. package/skills/teamsmith/tests/remind-cli.sh +574 -0
  59. package/skills/teamsmith/tests/reply-capture-real.mjs +360 -0
  60. package/skills/teamsmith/tests/reply-capture-real.sh +5 -0
  61. package/skills/teamsmith/tests/reply-capture.mjs +756 -0
  62. package/skills/teamsmith/tests/section-paths.tsv +40 -9
  63. package/skills/teamsmith/tests/section-select.sh +180 -26
  64. package/skills/teamsmith/tests/smoke.sh +1235 -238
  65. package/skills/teamsmith/tests/state-authority-node.mjs +42 -0
  66. package/skills/teamsmith/tests/state-authority.sh +629 -0
  67. package/skills/teamsmith/tests/workflow-entry.sh +123 -3
  68. package/skills/teamsmith-init/SKILL.md +1 -1
@@ -190,17 +190,26 @@ project's seat, still without a live pane, and the same process start time the p
190
190
 
191
191
  ### Deferred delivery (`delivery-guard`)
192
192
 
193
- Automatic senders never type into an input box that already holds a draft: the message is queued in
194
- `state/outbox/` (one immutable file per message) and delivered when the box is free. A message deferred behind a
195
- **trusted** non-empty box is reported as `queued` (exit 0). Two outcomes are instead `held` with a machine reason
196
- and a non-zero exit: `geometry-untrusted` (the supported Pi layout cannot be established — no key is sent and no
197
- draft is asserted) and `queue-stalled` (three consecutive eligible drains read a trusted empty box but made no
198
- progress; observations are recorded per entry in `state/outbox/diagnostics/`). Both keep the immutable entry and
199
- its durable inbox copy; `team outbox list` names the reason and the recovery command, and the obstacles are also
200
- counted on the `team status` / `team digest` outbox line and in the panel. The escape hatches are explicit:
201
- `team say <agent> "…" --now` and `team outbox flush --now` type immediately **even into a non-empty box** and append
202
- one audit line to `state/outbox/forced.log`; `team outbox drop <n|all>` discards entries; `team draft pm`
203
- (`state/draft-pm.md`) is the human entry point. See `references/troubleshooting.md` §3 for the detector's known edges.
193
+ Protected automated senders — a `team notify` knock, the watchdog wake line, the notify extension's knock, the
194
+ meeting knock, ordinary `team draft send` and ordinary queued pane delivery — never type into an input box that
195
+ already holds a draft: the message is queued in `state/outbox/` (one immutable file per message) and delivered when
196
+ the box is free. A message deferred behind a **trusted** non-empty box is reported as `queued` (exit 0). Two
197
+ outcomes are instead `held` with a machine reason and a non-zero exit: `geometry-untrusted` (the supported Pi
198
+ layout cannot be established — no key is sent and no draft is asserted) and `queue-stalled` (three consecutive
199
+ eligible drains read a trusted empty box but made no progress; observations are recorded per entry in
200
+ `state/outbox/diagnostics/`). Both keep the immutable entry and its durable inbox copy; `team outbox list` names
201
+ the reason and the recovery command, and the obstacles are also counted on the `team status` / `team digest` outbox
202
+ line and in the panel.
203
+
204
+ `team say` is the exception the user chose. It prefers a valid live inbox watcher (durable inbox line plus wake
205
+ spool, zero tmux keys, the draft untouched). With no usable watcher it attempts the old direct send immediately,
206
+ even into a draft, after its recipient/`--any`, window, dead-pane and empty-shell checks, and appends one line to
207
+ `state/outbox/forced.log`. That is an **attempt**: it never claims confirmed model receipt and does not promise an
208
+ automatic queueing of a failed transport. The public `say --now` flag is retired (an unknown flag, exit 2).
209
+ The remaining explicit human overrides are `team draft send --now` and `team outbox flush --now`, which type even
210
+ into a non-empty box and record the skip in `state/outbox/forced.log`; `team outbox drop <n|all>` discards
211
+ entries; `team draft pm` (`state/draft-pm.md`) is the human entry point. See `references/troubleshooting.md` §3 for
212
+ the detector's known edges.
204
213
 
205
214
  ### Branch model (D1)
206
215
 
@@ -18,7 +18,7 @@ session) and for anyone deciding whether upgrading is safe.
18
18
  | `TEAM_*` environment variables | override the config file (env beats config) and are read that way in every version |
19
19
  | the `docs/team/**` layout | `tasks/ reports/ reviews/ threads/ inbox/` plus `BOARD.md ROADMAP.md OWNERSHIP.md DECISIONS.md PROTOCOL.md` |
20
20
  | `docs/team/BOARD.md` columns | `ID · task · agent · branch · deps · status`, with the status vocabulary `todo/wip/review/done/blocked/dropped` |
21
- | the `AGENTS.md` protocol section | injected between markers and **refreshed in place** by `team init`, never appended twice; only the marker text changed once (§2) |
21
+ | the `AGENTS.md` protocol section | injected between markers and **refreshed in place** by an explicit `team init` (never by `bootstrap`/`team up`), never appended twice; only the marker text changed once (§2). Outside the pair every byte is preserved — §1b |
22
22
  | `.pi/team/state/` | flat `key=value` files (agent records, `pm-loaded.env`, logs); version-agnostic and never migrated |
23
23
  | version bookkeeping | `team mark-loaded` + `team version --check` compare a version string and a content hash; deleting `state/pm-loaded.env` only makes the tool say "unknown", nothing breaks |
24
24
 
@@ -26,6 +26,47 @@ The **text** of `SKILL.md`, `references/**` and the templates is the part that g
26
26
  Commands always re-read `scripts/**` from disk, but text already read into a running session does not change under
27
27
  you — that is what `/reload` is for (§6), and §7 covers going back.
28
28
 
29
+ ## 1b. The AGENTS managed block: what an explicit refresh does, and what it does not
30
+
31
+ `team init` (without `--force`) is the only refresh path for the generated AGENTS block. `team bootstrap` on an
32
+ existing valid config installs the project-local skills and stops there — it does **not** run init's AGENTS writer —
33
+ and `team up` never touches AGENTS. `--force` re-renders config and ledger as well, so it is not the refresh switch.
34
+
35
+ **The boundary.** A delimiter is an exact standalone `<!-- teamsmith:begin -->` / `<!-- teamsmith:end -->` line
36
+ outside a fenced code block. Exactly one such pair is replaced between its two delimiter lines; a file with no such
37
+ line gains one block; any other shape is refused with the file left byte-identical and the reason named — two or more
38
+ pairs, a begin without its end (or the reverse), current and legacy delimiter lines mixed, or no pair in a file that
39
+ ends inside an unclosed fence. A marker quoted in prose, indented, sharing a line with text or sitting inside a closed
40
+ fenced example is ordinary content: never a pair, never an error.
41
+
42
+ **What survives.** Both delimiter lines and every byte outside them — preceding and following sections, ordinary
43
+ headings, project rules, those examples, line order, line endings (LF, CRLF, mixed) and a final line without a
44
+ newline. The inserted body uses the begin line's own terminator; nothing is normalized and no trailing newline is
45
+ added. **What does not survive**: everything *inside* the pair is managed text and is replaced, including any project
46
+ customization there. Project rules belong outside the markers — the managed block is not a customization surface.
47
+
48
+ **Before a refresh.** The PM inventories the rules currently inside the block and preserves them outside under the
49
+ project's own authorization, previews the exact command in a private copy with the project's actual inputs, and diffs
50
+ the result. init classifies nothing and moves no text for you.
51
+
52
+ **Render parameters.** Without the matching flag, a valid existing contract's present session, roster, docs path, PM
53
+ window and gates are used; the ordinary defaults (main-root basename session, `dev verify` roster, `docs/team`, `pm`
54
+ PM window, detected gates) apply only to a fresh project or an absent key, and an explicitly supplied flag still wins.
55
+ The AGENTS render currently passes the protected branch `main` — a non-main protected branch is a known limitation,
56
+ not something this recipe overrides.
57
+
58
+ **Write target.** Run it from the main checkout: a linked worktree resolves to the main root, so the main-root AGENTS
59
+ is the one refreshed and no private worktree AGENTS is created.
60
+
61
+ **The rest of init's writes are not skipped.** init also writes or skips config (and chmods it), creates the docs
62
+ skeleton, renders missing ledger files, overwrites the inbox/reviews `.gitignore` files, updates the root `.gitignore`,
63
+ and — unless `--no-skills` — installs the project-local skills and the `/team` extension. `--no-skills` skips
64
+ installation only, not the AGENTS refresh. The sequence is **not transactional**: a late install conflict can return
65
+ non-zero after AGENTS, docs and ignore writes already happened. Without `--force`, an existing valid config and
66
+ existing ledger documents keep their bytes; `--force` may replace config and ledger. A retired-model configuration is
67
+ refused before any write, with or without `--force`. An existing generated `PROTOCOL.md` is skipped by a non-force
68
+ init and keeps its old text.
69
+
29
70
  ## 2. The rename: `pi-team` → `teamsmith` (v1.13.0)
30
71
 
31
72
  The name change touched three things and only one of them needs a command from you.
@@ -34,7 +75,7 @@ The name change touched three things and only one of them needs a command from y
34
75
  |---|---|---|
35
76
  | `skills/pi-team` (repository path **and** installed skill directory) | `skills/teamsmith` | **change the path** (since the release that carries M22): the compatibility symlink was **removed**, so an absolute path or a `settings.json` entry that still says `skills/pi-team` must be updated to `skills/teamsmith` (or to the installed `~/.agents/skills/teamsmith`). The installed copy is unaffected — it is a link to *this repository*, not to the old name. See §2b below |
36
77
  | the Pi command `/pi-team-reload` | `/teamsmith-reload` | **nothing**: the old spelling stays registered as an alias |
37
- | the `AGENTS.md` marker `<!-- pi-team:begin -->` … `<!-- pi-team:end -->` | `<!-- teamsmith:begin -->` … `<!-- teamsmith:end -->` | run `team init` (or `team bootstrap`) once: the marker is rewritten **in place** and idempotently, with no duplicate section. `team doctor` prints a pointer to this file while the old marker is still there |
78
+ | the `AGENTS.md` marker `<!-- pi-team:begin -->` … `<!-- pi-team:end -->` | `<!-- teamsmith:begin -->` … `<!-- teamsmith:end -->` | run an explicit `team init` once: the legacy pair is converted **in place** and idempotently, with no duplicate section (§1b). An existing valid config's `team bootstrap` does not run this writer, and `team up` never does. `team doctor` prints a pointer to this file while the old marker is still there |
38
79
  | the repository name `pi-team` | `teamsmith` | only if your own notes or scripts hard-code it; the skill's contracts (command, config, `TEAM_*`, `docs/team/**`) were never renamed |
39
80
  | prose in your own docs, briefs or scripts | — | by hand: the skill cannot rewrite your files (the former name is also what a "stale session" error message used to say) |
40
81
 
@@ -73,7 +114,7 @@ period was ended early by the user's call. What this means for an existing proje
73
114
  | your `settings.json` `skills` array, or a config/`TEAM_*` value with an **absolute** path | replace the removed alias `skills/pi-team` with `skills/teamsmith` (a project that uses the CLI through `PATH` or a `~/.agents/skills/teamsmith` link needs nothing) |
74
115
  | your own notes, briefs or scripts | by hand — the skill cannot rewrite your files |
75
116
  | the installed directory `~/.agents/skills/pi-team` | re-run `./install.sh` (it installs the canonical directories only); `./install.sh --uninstall` also removes a legacy `pi-team` entry left by an older install |
76
- | an `AGENTS.md` marker `<!-- pi-team:begin -->` | **still automatic**: the next `team init`/`team bootstrap` rewrites the marker in place (§2) |
117
+ | an `AGENTS.md` marker `<!-- pi-team:begin -->` | **still automatic, by an explicit `team init`**: it converts the legacy pair in place (§1b); `team bootstrap` on an existing valid config does not, and `team up` never does |
77
118
  | the Pi command `/pi-team-reload` | **still works**: it stays registered as an alias of `/teamsmith-reload` — a *command name*, not a path |
78
119
 
79
120
  A *copy* install (`./install.sh --copy`) made while the symlink existed simply carries a copy of the old alias;
@@ -290,6 +331,9 @@ and inference are **not** migration routes (§5b). Confirm the new shape before
290
331
  team config list # exit code 0, and no `migration_required` line at the end
291
332
  ```
292
333
 
334
+ The AGENTS managed block is not part of this migration: `team up` and `bootstrap` do not refresh it. An explicit
335
+ `team init` does, under the boundary and preservation rules in §1b.
336
+
293
337
  ### Step 3 — the PM launch identity (`state/pm-launch.env`)
294
338
 
295
339
  `.pi/team/state/pm-launch.env` is a flat record of the identity the PM was last started with: the project and
@@ -181,35 +181,52 @@ refused (its pane is alive; `reap` only judges orphans); each refusal names the
181
181
  entries only: `interrupt` leaves the window as a live shell, leaves the worktree, the session file and the
182
182
  assignment record untouched, and does not touch the seat's detached background jobs (§4's `team-bg` lane).
183
183
 
184
- ## 4b. Key replies: publish the body before you answer
184
+ ## 4b. Key replies: mark the answer and the extension publishes it
185
185
 
186
- Publishing the body of a key conclusion is a **standing duty of the PM**, not a licence for answers that merely look
186
+ Marking a reply written for the user is a **standing duty of the PM**, not a licence for answers that merely look
187
187
  memorable: it travels with the tool, so it holds in every project and on every machine. The wake-up loop carries a
188
188
  *pointer* (`inbox/<agent>.md` plus a knock) and the report carries the *process*; neither carries the **body**, and
189
189
  both are transient or post-hoc — the inbox is gitignored, and a report is written after the work. **The reader
190
190
  decides what is published**: whenever the reply is written for the user — a landed milestone, an answer to a
191
191
  question, a status or progress report, a conclusion or a ruling, a decision you ask the user for, a delivery or
192
- verification summary, however short — publish the **complete reply** — the substance the user needs to read, not a
193
- play-by-play of the work — with:
192
+ verification summary, however short — write the **complete reply** — the substance the user needs to read, not a
193
+ play-by-play of the work — as the normal answer, and end it with the capture marker as its own final line:
194
194
 
195
195
  ```
196
- team reply post --from <seat> --title "<short single line>" --stdin <<'EOF'
197
- … the exact body you are about to send …
198
- EOF
196
+ [[team-reply]]
199
197
  ```
200
198
 
199
+ `[[team-reply:<short single-line title>]]` keeps the title you wrote; the bare form derives it from the first
200
+ nonblank line of the body. An empty explicit title is invalid, not omitted. The marker is a control line:
201
+ case-sensitive, alone at column zero, no trailing spaces, and the last nonblank line of the message — everything
202
+ after it may only be blank lines. It is recognized only outside code: one inside a fenced block or a paired inline
203
+ span is a literal example, a second complete marker line is ambiguous, and a marker that is not final is misplaced;
204
+ none of those publishes.
205
+
201
206
  **The reader decides, so ask "who is this reply written for?"** A reply meant for the patrol or the watchdog, for
202
207
  another seat, or for another project's PM stays in its own channel, and a receipt a tool generated is not a reply at
203
- all. Length never decides: a one-line answer or a short progress report meant for the user is published in full.
208
+ all. Length never decides: a one-line answer or a short progress report meant for the user is marked in full.
204
209
  A reply is never held back because of its kind: a status or progress report, a delivery summary and a decision
205
- request are published exactly as a conclusion is, and reading like process never makes a reply unpublishable.
210
+ request are marked exactly as a conclusion is, and reading like process never makes a reply unpublishable.
206
211
  When the reader cannot be settled, treat the reply as meant for the user rather than risk the user missing it.
207
212
 
208
- A batch of user-facing replies may be one reply. Then send the answer normally. Publication **never gates the
209
- answer**: the same body goes out whether the post
210
- reported `saved` (0), an input error (2), storage unavailable (4), a busy writer (5, the lock wait is bounded) or
211
- `unconfirmed` (6, the entry is visible but its durability could not be confirmed — never re-post it automatically).
212
- Failures are diagnostics on stderr; they must not be concatenated into the answer, and they must not stop it.
213
+ A batch of user-facing replies may be one reply. The directed PM extension captures a marked message once it settles
214
+ as the latest successful answer of the current activity, and passes the **complete sanitized body** — your answer
215
+ with only the recognized control line removed — through the existing writer into the same reply store. An unmarked
216
+ answer is never published by inference: no session scan, no body-hash or page matching, and no automatic fallback that
217
+ posts with the CLI. Each marked activity earns at most one automatic attempt — a busy, failed or unconfirmed capture
218
+ is never retried automatically.
219
+
220
+ Publication **never gates the answer**: the same answer goes out whether capture reported `saved`,
221
+ an input rejection, storage unavailable, a busy writer or `unconfirmed`. Any diagnostic is separate from the answer
222
+ and must not stop it. The marker control line is removed from the answer you send, from the finalized transcript and
223
+ from later model history; bytes already streamed to the terminal are not retroactively erased, so the marker may be
224
+ visible for a moment while the answer streams. That is a known boundary, not a delivery guarantee at a fixed latency.
225
+
226
+ `team reply post --from <seat> --title "<short single line>" --stdin` remains the **manual** publication, backfill and
227
+ recovery entry — for a reply written before capture existed, a session without the extension, or a deliberate
228
+ backfill. It is not the daily default, and the old habit of posting first and then repeating the same body in the
229
+ conversation is not the workflow this tool ships.
213
230
 
214
231
  What a receipt does and does not mean:
215
232
  - **A saved receipt is project-local durable publication only.** It is not user delivery, not approval, not read
@@ -224,10 +241,11 @@ What a receipt does and does not mean:
224
241
  (newest first), `team reply show <no>` prints safe display text, `team reply show <no> --raw` exports the original
225
242
  bytes to a non-TTY stdout, and the console's page 5 renders the latest reply plus the numbered history. Flags and
226
243
  exit codes are in `team reply --help`.
227
- - **The honest limit**: the gate holds only that this duty is shipped on the instruction surfaces (the injected PM
228
- prompt template, this section, the command table) and that the example command printed there is accepted by the real
229
- parser. No tool can verify that a live PM follows the duty — whether a given reply was meant for the user, which
230
- conclusions a PM published, and whether the body matched the answer, stay unprovable from here.
244
+ - **The honest limit**: the correctness gate holds only that this duty is shipped on the instruction surfaces (the
245
+ injected PM prompt template, this section, the command table) and that the shipped marker example is parsed and
246
+ published by the real parser and writer. No tool can verify that a live PM follows the duty — whether a given reply
247
+ was meant for the user, which conclusions a PM marked, and whether the body matched the answer, stay unprovable
248
+ from here.
231
249
 
232
250
  ## 5. Task briefs: written for "a weak model without context"
233
251
 
@@ -328,7 +346,8 @@ one of which hit RAM and zram bottom at the same time):
328
346
 
329
347
  Why zram is looked at separately: the "free space" of `/dev/zram0` is really compressed pages in RAM, and once full it
330
348
  stays essentially full; counting it towards the concurrency budget systematically overestimates the headroom, and when
331
- an OOM happens RAM and zram bottom out together.
349
+ an OOM happens RAM and zram bottom out together. These are the memory and swap legs only: the temp-root usability rule
350
+ and the temp/worktree byte and inode floors that dispatch also judges are in §9.
332
351
 
333
352
  ## 7. Security red lines (non-negotiable)
334
353
 
@@ -409,10 +428,10 @@ an occupant (`unknown`).
409
428
  - Boundaries: it does not manage tmux layout by default (`TEAM_PULSE_REBUILD_TMUX=0`, a lost session/window is only
410
429
  reported; with the knob set to 1 it rebuilds the session and the PM window **when it notices they are gone** --
411
430
  which cannot help if the tmux *server* died, because the patrol itself lives in a pane of that server). It does
412
- **not** leave agents alone, though: a seat that has stopped while its task is unfinished is auto-dispatched back
413
- onto the same task (`cmd-watch.sh`'s resume path, one `resume agent=<a> task=<id>` line in `watchdog.log` per
414
- attempt). It does not manage model quota and never merges automatically. Runaway protection: the auto-start quota
415
- of 5 per hour plus the pulse's own pid lock.
431
+ **not** resume stopped agents either: a seat that stopped with an unfinished task is reported as pending work and
432
+ stays untouched until the PM runs `team resume` (the one exception is a human's `team up --agents` rescue, above).
433
+ It does not manage model quota and never merges automatically. Runaway protection: the auto-start quota of 5 per
434
+ hour plus the pulse's own pid lock.
416
435
 
417
436
  Why the boundaries are drawn this narrow: an "everything-managing" daemon would manipulate tmux layout, agent
418
437
  lifecycles and model quota at the same time, and when something breaks nobody can tell who corrupted the state;
@@ -650,14 +669,28 @@ otherwise widen the project's authority — and the schema note it renders names
650
669
  value rule is what `team config list --json` reports as the key's `warning` when a hand-edited file already
651
670
  carries an illegal token, so the read side and the write side can never disagree about what a seat name is.
652
671
 
653
- ## 9. Capacity: the floor is that neither RAM nor disk swap bottoms out (zram does not count)
654
-
655
- - There is only one condition for refusing a dispatch: free swap below `TEAM_MIN_FREE_SWAP_MB` (1024MB by default) or
656
- RAM+swap below `TEAM_MIN_TOTAL_MB`.
657
- - Tight RAM (below `TEAM_WARN_AVAIL_MB`) only warns: slowness is acceptable, because slow is not broken; an OOM is the
658
- real accident.
659
- - `team ps` / `team doctor` report from the same data source and add an estimate of "how many more agents fit"
660
- (`TEAM_AGENT_MEM_MB`).
672
+ ## 9. Capacity: the floor protects the host, and the refusal names the leg it judged
673
+
674
+ `team dispatch` refuses to start a worker when any leg is below its floor — before a window opens and for `--print` as
675
+ well:
676
+
677
+ - **RAM**: RAM+swap below `TEAM_MIN_TOTAL_MB` (512MB) or `MemAvailable` below `TEAM_MIN_AVAIL_MB` (1024MB).
678
+ - **Swap**: free **disk** swap below `TEAM_MIN_FREE_SWAP_MB` (1024MB). zram does not count (its pages live in RAM),
679
+ and zram occupancy above `TEAM_ZRAM_WARN_PCT` is a warning only.
680
+ - **Disk and inodes**: the filesystems the worker will write to — the **resolved** temp root (the path the one
681
+ resolver returns, named with its `source=tmpdir|config|default`) and the worktree filesystem — need free bytes
682
+ above `TEAM_TMP_MIN_FREE_MB` (1024MB) and, only where the filesystem reports an inode table, free inodes above
683
+ `TEAM_TMP_MIN_FREE_INODES` (100000). A temp root that cannot be used (an explicit `TEAM_TMP_ROOT`/`TMPDIR` that is
684
+ missing, not a directory or not writable) refuses before the numbers are judged and is never silently replaced by
685
+ another root.
686
+
687
+ Tight RAM (below `TEAM_WARN_AVAIL_MB`) only warns: slowness is acceptable, because slow is not broken; an OOM is the
688
+ real accident. A figure that cannot be read is not judged and no number is invented for it. Each refusal names
689
+ the path, the resolution source, the measured figures, the threshold crossed and a `修法:` line, and `0` disables one
690
+ leg without disabling the others. Model concurrency is a separate limit (`TEAM_MODEL_LIMITS`, §6). `team ps` / `team
691
+ doctor` report from the same data source, and `team ps` adds the "how many more agents fit" estimate
692
+ (`TEAM_AGENT_MEM_MB`). Thresholds, defaults and the override/fixture seams: [config.md](config.md) §2 ("Guards
693
+ (capacity)").
661
694
 
662
695
  ## 9b. Tests and gates must have a timeout (non-negotiable)
663
696
 
@@ -0,0 +1,131 @@
1
+ # Reminders
2
+
3
+ A reminder is a durable one-shot note the project PM leaves for itself: "come back to this at that
4
+ time". It is stored in the same versioned project state as the rest of teamsmith, so it survives a
5
+ restart, a lost session and a new checkout, and it is the only copy of that decision.
6
+
7
+ This page is the operator's manual for the part that exists today: recording, reading and cancelling
8
+ a reminder. It does not describe delivery, because this build does not deliver.
9
+
10
+ ## What this build does and does not do
11
+
12
+ - Records a reminder with its full text, its due instant, its source and an optional key and task.
13
+ - Lists what is waiting, when it is due, and whether it is due *now*; shows one record in full;
14
+ cancels a reminder that has not been frozen for delivery.
15
+ - Does **not** wake the PM, does not queue anything for delivery, and does not touch Standby. A due
16
+ reminder is shown as `derived-due` and stays there until the delivery part of the change reads it.
17
+ - Does **not** accept a project, an owner or a recipient from the caller: those come from the
18
+ checkout the command runs in and from the authority itself.
19
+
20
+ ## Where the state lives
21
+
22
+ ```
23
+ <main checkout>/.pi/team/reminder-locator.json the pinned state root and the project identity
24
+ <main checkout>/.pi/team/reminder-locator.lock serialises establishing that locator
25
+ <state root>/reminders/state.json the versioned snapshot: reminders, batches, audit
26
+ <state root>/reminders/authority.lock serialises every state transaction
27
+ ```
28
+
29
+ The state root is the project's own `<main checkout>/.pi/team/state` unless the project pins
30
+ `TEAM_STATE_DIR`; the first use pins it in the locator and every later process must agree with it.
31
+ Two processes with different `TMPDIR` values still meet on that one path. A different state root is
32
+ refused instead of silently creating a second authority.
33
+
34
+ Every read and write is one `flock` transaction: read and validate the snapshot, mutate it, write a
35
+ temporary file, `fsync` it, rename it into place, `fsync` the directory. A missing `flock`, a timeout,
36
+ an unreadable snapshot or an identity mismatch is a visible error; there is no unlocked fallback and
37
+ an unreadable snapshot is never replaced by an empty store.
38
+
39
+ ## Commands
40
+
41
+ ```bash
42
+ team remind add --after 20m --message "check the build"
43
+ team remind add --at 2026-10-28T09:00:00+08:00 --message-file note.md --key morning-review --task P409
44
+ team remind list
45
+ team remind list --all
46
+ team remind list --json
47
+ team remind show rem-<project id>-3
48
+ team remind cancel rem-<project id>-3
49
+ ```
50
+
51
+ `list` prints a count line per view, then one block per active reminder: its stable id, its view, the
52
+ due instant with a relative distance, then the text exactly as stored. Ended reminders are kept but
53
+ printed only with `--all`; they are counted either way. `--json` on any of the four subcommands returns
54
+ the same snapshot the text is rendered from, for scripts.
55
+
56
+ `show` prints one record in full. A message is never shortened: `list` and `show` print the bytes that
57
+ were stored, and `--message-file` stores the file byte for byte (a trailing newline is part of the
58
+ text — the shell does not get to trim it).
59
+
60
+ ## Time
61
+
62
+ Exactly one of the two forms:
63
+
64
+ - `--at` is an RFC 3339 date-time with an explicit offset (`2026-10-28T09:00:00+08:00`) or `Z`. A
65
+ time without an offset, an impossible date such as `2026-02-30`, a leap second, a second that does
66
+ not exist or an instant in the past is refused with the reason, and nothing is written.
67
+ - `--after` is a positive whole number followed by `s`, `m` or `h` (`90s`, `20m`, `2h`). Zero,
68
+ negative, non-numeric and overflowing values are refused.
69
+
70
+ The relative form is resolved **once, inside the locked transaction**, and the resulting instant is
71
+ what the snapshot stores. Printing it is the record's due time, not a recomputation.
72
+
73
+ ## Keys
74
+
75
+ `--key <name>` names one logical reminder. While a live record holds the key:
76
+
77
+ - the identical request (same time form and value, same text, same task) returns that record and its
78
+ original due instant, and allocates nothing;
79
+ - a different request under the same key is refused, naming the record that holds it.
80
+
81
+ A key is held by `scheduled`, `queued`, `intent` and `unknown` records. Any terminal phase
82
+ (`observed`, `cancelled`, `resolved`) releases it, and the next request is a new reminder with a new
83
+ id — reuse after release is deliberately not an exactly-once guarantee.
84
+
85
+ ## Views
86
+
87
+ The snapshot stores phases, never views. Every read derives the view from the phase, the due instant
88
+ and the clock:
89
+
90
+ | View | Meaning |
91
+ |---|---|
92
+ | `scheduled` | recorded, due in the future, not admitted for delivery |
93
+ | `derived-due` | recorded, due now or in the past, still not admitted — the clock alone says "due" |
94
+ | `queued` | delivery admitted with a queue identity and enqueue time |
95
+ | `intent` | frozen into a delivery batch, before the Pi call |
96
+ | `observed` | the correlated Pi message was seen; delivery is proven, nothing more |
97
+ | `unknown` | a batch was frozen and no correlated observation exists; never resent blindly |
98
+ | `cancelled` | withdrawn before delivery was frozen |
99
+ | `resolved` | an operator acknowledged an unknown batch |
100
+
101
+ `due` is not `queued`: a reminder can be overdue for a long time and still never have been sent. This
102
+ build produces only `scheduled`, `cancelled` and, from the clock, `derived-due`; the other phases are
103
+ written by the delivery and Pulse tasks of the same change, and this reader already shows them
104
+ because it derives from the snapshot rather than from a second copy.
105
+
106
+ ## Retention and the issued high-water
107
+
108
+ Ended reminders are history: the newest 1000 terminal outcomes within 30 days are kept, older ones are
109
+ compacted inside the same transaction that mutates. Active and unknown records are never evicted, and
110
+ the count of pruned outcomes is cumulative.
111
+
112
+ Ids are never reused. The snapshot carries the next sequence number, so a compaction, a restart or a
113
+ lost reply cannot hand out an id twice. Asking for an id that was issued and has since been compacted
114
+ answers `history-pruned`; an id above the issued high-water answers as never issued. Neither can be
115
+ revived or sent.
116
+
117
+ ## When it refuses
118
+
119
+ - No `flock` on the machine, lock timeout, an unreadable or unsupported snapshot, or a snapshot whose
120
+ identity contradicts the locator: the command fails with the reason and writes nothing. Repair the
121
+ host or the snapshot; there is no unlocked mode to fall back to.
122
+ - `already-observed`, `in-flight` or `unknown` on `cancel`: the reminder is past the point where
123
+ withdrawal can be guaranteed, and the command says so instead of pretending it was cancelled.
124
+ - A message that is empty, blank, contains a NUL byte or is not valid UTF-8: refused before anything
125
+ is stored.
126
+
127
+ ## Not in this build
128
+
129
+ Pulse admission, the PM wake-up and its message, Standby interaction, the configurable limits (active
130
+ count, message bytes, create rate) and the PM-only tool are later tasks of the same change. Until
131
+ they land, a reminder is a durable note that a person reads — it does not summon anyone.
@@ -54,6 +54,14 @@ conversation like a queued follow-up. The input box is never read and never type
54
54
  a custom adapter, a Pi session started without the extension, a registration whose pid is dead or whose cwd
55
55
  is another project — takes the **delivery guard** below, which is the only code allowed to type into a pane.
56
56
 
57
+ **Two senders are direct-attempt exceptions, and they are named, not hidden.** `team say` prefers a valid live
58
+ watcher (durable inbox line plus wake spool, zero keys, draft untouched). With **no usable watcher** it attempts the
59
+ old direct send immediately — after its existing recipient/`--any`, window, dead-pane and empty-shell checks — even
60
+ when the box holds a draft, and appends exactly one line to `state/outbox/forced.log`. That line, a zero exit and a
61
+ pane snapshot are an **attempt**, never proof that the model received the message; the retired `say --now` is
62
+ rejected as an unknown flag before any side effect. The other exception is the human's explicit override
63
+ `team draft send --now` / `team outbox flush --now`.
64
+
57
65
  The Pi channel exists because five draft-race incidents (2026-09, all on real Pi 0.85.1) showed that the box
58
66
  heuristic cannot be made reliable enough: D20 is where the guard came from (an automated message glued onto a
59
67
  human's draft); in M17 a payload was judged to have raced a draft while the PM had in fact just finished a long
@@ -89,7 +97,9 @@ Honest edges of the Pi channel (visible, never silent):
89
97
 
90
98
  **The delivery guard** (the paste path) locates the target pane's input box before typing and reads **every content row
91
99
  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
100
+ sits below the cursor row. If the box already holds text, a **protected sender** (a `team notify` knock, the
101
+ watchdog wake line, the notify extension's knock, the meeting knock, an ordinary `team draft send`, or ordinary
102
+ queued pane delivery) writes **no key at all**: the message goes
93
103
  into `state/outbox/` as one immutable entry and is delivered when the box is free (`team outbox list` shows what is
94
104
  waiting, `team outbox flush` drains it, and every watchdog tick drives one drain as well). A message deferred behind a
95
105
  **trusted** non-empty box is reported as **`queued`** (exit 0), never as delivered. The two impediment outcomes below —
@@ -103,8 +113,9 @@ What this means for you:
103
113
  - Keep typing. Your draft stays in the box; the notice waits outside it.
104
114
  - If the queue bothers you: `team outbox drop <n|all>` discards entries, and `team status` / `team digest` print one
105
115
  `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
116
+ - `team say <agent> "…"` with no usable watcher types into a non-empty box on purpose — that is the default direct
117
+ attempt now, and it appends one line to `state/outbox/forced.log`. `team outbox flush --now` and
118
+ `team draft send --now` stay the human's explicit overrides for queued messages. Use them only when you really
108
119
  want the text glued.
109
120
  - The human entry point is `team draft pm`: an editor window on `state/draft-pm.md` (nothing automated ever types
110
121
  into it); saving and quitting enqueues the file through the same guarded path and prints the acknowledgement in
@@ -266,7 +277,9 @@ Honest edges (documented, not hidden):
266
277
  missing/short bottom rule, or a content row wider than the pane (a clipping or scrolled TUI, a draft whose own
267
278
  rule row makes the rectangle ambiguous) are **`geometry-untrusted`**: no key is sent, the payload is moved to
268
279
  `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
280
+ entry and the recovery command, and the protected sender asserts no draft and promises no automatic delivery.
281
+ (A default `team say` with no watcher never takes this path: it attempts the direct send instead, which reads no
282
+ geometry at all.) Recovery
270
283
  is `team outbox flush` once the layout is supported again (the entry is never-typed, so it may be retried; a
271
284
  terminal `draft-raced*`/`unconfirmed` entry never is). Real captures and the red side (`admission shadowed
272
285
  off` → the same bytes read `[21 30]`/BUSY) are pinned in `tests/frames/` and
@@ -925,7 +938,8 @@ skipped (`classify stale=<n> …`, and a *recovered* line that has since gone st
925
938
 
926
939
  ## 21. pi announces a new version → the input box reads as BUSY
927
940
 
928
- **Symptom**: a PM/worker Pi pane is idle with an empty box, yet `team say` / `team notify` report **`queued`**
941
+ **Symptom**: a PM/worker Pi pane is idle with an empty box, yet `team notify` (or a drained `team draft send` /
942
+ ordinary queued message) reports **`queued`**
929
943
  (the message lands in `state/outbox/` instead of the box), and the real-pi fixture says so:
930
944
 
931
945
  ```
@@ -116,7 +116,7 @@ bash <skill>/scripts/team digest # pending work: new notifications + re
116
116
  bash <skill>/scripts/team inbox --ack # read and mark as read
117
117
  bash <skill>/scripts/team roster # who is running, branch, dirty files, ahead of the protected branch, unpushed commits
118
118
  bash <skill>/scripts/team ps # capacity (RAM/swap/how many more fit) + model concurrency + PM/pulse liveness
119
- bash <skill>/scripts/team up # one-shot repair: session/PM/agents that stopped without delivering
119
+ bash <skill>/scripts/team up # manual rescue: build the tmux stage + start the PM (agents untouched)
120
120
  ```
121
121
 
122
122
  `digest` §[4] measures the push state **against `@{upstream}`** (`git rev-list --count @{upstream}..HEAD`), never
@@ -217,35 +217,38 @@ turn. A CLI without the Pi extension API does not have them: fall back to a back
217
217
  ### E3. Performance is a separate run (and a release step)
218
218
 
219
219
  The gate above judges **correctness only** — `openspec validate --all --strict && bash
220
- skills/teamsmith/tests/smoke.sh </dev/null` (front door `team smoke`). The wall-clock/CPU red lines (interactive
221
- first frame, frame assembly, steady-state pane CPU) live in a separate suite, are never part of a review, and are
222
- run **once before a release** in the reference image:
220
+ skills/teamsmith/tests/smoke.sh </dev/null` (front door `team smoke`). The performance readings (interactive first
221
+ frame, frame assembly, steady-state pane CPU) live in a separate suite, are never part of a review, and are run
222
+ **once before a release** in the reference image:
223
223
 
224
224
  ```bash
225
225
  bash <skill>/scripts/team perf --container # reference environment: the pinned ci/Containerfile image (default)
226
226
  bash <skill>/scripts/team perf --host # this machine, explicitly labelled NOT the reference
227
227
  ```
228
228
 
229
- Exit `0` = all three judgements ran green; `2` = a red with its measured numbers; `4` = no conclusion (a visible
230
- SKIP: the load premise does not hold, the machine lacks a tool, or the reference engine/image is missing — the
231
- reason, the measured values and the exact build/run command are printed); `3` = setup failure. The suite takes its
232
- own lock (`TEAM_PERF_LOCK`, `TEAM_PERF_LOCK_WAIT`) and never queues behind the gate lock. Record the numbers where
233
- the release checklist says (`docs/team/PUBLISH.md`); a red performance run never delays a merge and never changes a
234
- review verdict.
229
+ The suite only measures and prints reference readings, and names the environment it measured in: exit `0` = a reading
230
+ was taken, `3` = it could not measure (setup failed, or the performance lock was unavailable). There is no threshold
231
+ and no verdict to give, so a reading never delays a merge and never changes a review verdict. The suite takes its own
232
+ lock (`TEAM_PERF_LOCK`, `TEAM_PERF_LOCK_WAIT`) and never queues behind the gate lock. Record the numbers where the
233
+ release checklist says (`docs/team/PUBLISH.md`).
235
234
 
236
235
  ## F. Merging and wrapping up
237
236
 
238
- **Without a PR (local mode)**:
237
+ **Local mode (`TEAM_VCS=local`, no remote — no push)**:
239
238
 
240
239
  ```bash
241
240
  git -C <root> status # the main worktree must be clean and on the protected branch
242
241
  git -C <root> merge --squash <branch> # conflict handling: see protocol.md §8e
243
242
  git -C <root> commit -m "T1.1: <title>"
244
- git -C <root> push origin <protected-branch>
245
243
  bash <skill>/scripts/team board set T1.1 done # only mark done once it is really in the protected branch
246
244
  bash <skill>/scripts/team close T1.1 # close the window, clear the task
247
245
  ```
248
246
 
247
+ > A local deliverable is the committed report plus the settled task branch; there is no remote to push to. A
248
+ > `TEAM_VCS=remote` project that merges without a PR still pushes the protected branch
249
+ > (`git -C <root> push origin <protected-branch>`) — that push is a shared-state change and needs the user's
250
+ > authorization like any other.
251
+
249
252
  > After a squash merge the branch still holds its own commits, so it stays "ahead of main" (and, with a forge,
250
253
  > may even look "unpushed"). `roster`/`digest` recognise the usual case (same content) and say "already merged
251
254
  > (squash)" — see section D for the heuristic and its limits. `board set <ID> done` + `close <ID>` is what actually
@@ -420,10 +423,9 @@ logged).
420
423
  for "the window was closed while the server still lives". It **cannot** help when the tmux *server* dies: the
421
424
  patrol runs in a pane of that server, so it dies with it, and nothing in the project restarts it (a human runs
422
425
  `team up`, which also rebuilds the session).
423
- - **It does manage stopped agents, in one narrow way**: a seat with an unfinished task whose process has stopped is
424
- auto-dispatched back onto **the same task** (the resume path in `cmd-watch.sh`; each attempt writes
425
- `resume agent=<a> task=<id>` to `state/watchdog.log`). This is not a substitute for the PM's own `team resume`
426
- decision — it exists so a seat that died mid-task comes back without waiting for a human.
426
+ - **It does not resume stopped agents**: a seat with an unfinished task whose process has stopped is reported as
427
+ pending work and left alone; starting it is the PM's call (`team resume --agent <a>`), or a human's
428
+ `team up --agents` rescue.
427
429
  - **It does not manage model quota and never merges**: those are the PM's job.
428
430
  - **The PM is not required to run continuously**: between pending batches the PM may sit quietly (or not be running at
429
431
  all); the pulse will not wake it just to "keep it alive".