teamsmith 0.3.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +8 -8
  2. package/package.json +2 -6
  3. package/skills/teamsmith/CHANGELOG.md +77 -0
  4. package/skills/teamsmith/SKILL.md +83 -163
  5. package/skills/teamsmith/extension/team-inbox-watch.ts +30 -1
  6. package/skills/teamsmith/extension/team-notify.ts +162 -21
  7. package/skills/teamsmith/extension/team-reply.ts +105 -0
  8. package/skills/teamsmith/references/agent-adapters.md +4 -2
  9. package/skills/teamsmith/references/config.md +21 -12
  10. package/skills/teamsmith/references/migration.md +47 -3
  11. package/skills/teamsmith/references/protocol.md +85 -31
  12. package/skills/teamsmith/references/reminders.md +131 -0
  13. package/skills/teamsmith/references/troubleshooting.md +26 -8
  14. package/skills/teamsmith/references/workflows.md +18 -16
  15. package/skills/teamsmith/scripts/lib/cmd-agents.sh +290 -68
  16. package/skills/teamsmith/scripts/lib/cmd-config.sh +1 -1
  17. package/skills/teamsmith/scripts/lib/cmd-project.sh +193 -21
  18. package/skills/teamsmith/scripts/lib/cmd-remind.sh +103 -0
  19. package/skills/teamsmith/scripts/lib/cmd-status.sh +177 -21
  20. package/skills/teamsmith/scripts/lib/cmd-update.sh +7 -4
  21. package/skills/teamsmith/scripts/lib/cmd-watch.sh +11 -1
  22. package/skills/teamsmith/scripts/lib/common.sh +50 -6
  23. package/skills/teamsmith/scripts/lib/outbox.sh +103 -21
  24. package/skills/teamsmith/scripts/panel/panel.js +1 -1
  25. package/skills/teamsmith/scripts/panel/src/strings/en.ts +1 -1
  26. package/skills/teamsmith/scripts/panel/src/strings/zh.ts +1 -1
  27. package/skills/teamsmith/scripts/remind-store.mjs +529 -0
  28. package/skills/teamsmith/scripts/replies.mjs +9 -3
  29. package/skills/teamsmith/scripts/reply-capture.mjs +596 -0
  30. package/skills/teamsmith/scripts/state-authority.mjs +500 -0
  31. package/skills/teamsmith/scripts/strings/commands.tsv +2 -1
  32. package/skills/teamsmith/scripts/strings/help.en.tsv +16 -2
  33. package/skills/teamsmith/scripts/strings/help.zh.tsv +16 -2
  34. package/skills/teamsmith/scripts/team +2 -0
  35. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +68 -123
  36. package/skills/teamsmith/templates/PROTOCOL.md.tmpl +48 -55
  37. package/skills/teamsmith/templates/config.sh.tmpl +2 -1
  38. package/skills/teamsmith/templates/pm-prompt.md.tmpl +126 -119
  39. package/skills/teamsmith/tests/bg-ledger-harness.mjs +17 -6
  40. package/skills/teamsmith/tests/bg-ledger.sh +16 -5
  41. package/skills/teamsmith/tests/checkout-shape-probe.sh +6 -5
  42. package/skills/teamsmith/tests/delivery-truth.sh +82 -47
  43. package/skills/teamsmith/tests/fixtures/delivery-truth-real/README.md +71 -23
  44. package/skills/teamsmith/tests/fixtures/delivery-truth-real/__pycache__/judge-second.cpython-313.pyc +0 -0
  45. package/skills/teamsmith/tests/fixtures/delivery-truth-real/judge-dirty-ab.py +143 -0
  46. package/skills/teamsmith/tests/fixtures/delivery-truth-real/judge-second.py +26 -9
  47. package/skills/teamsmith/tests/fixtures/delivery-truth-real/run-case.sh +92 -20
  48. package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +47 -3
  49. package/skills/teamsmith/tests/fixtures/reply-capture-provider.ts +76 -0
  50. package/skills/teamsmith/tests/flip-p410-order2.sh +205 -0
  51. package/skills/teamsmith/tests/frames/README.md +3 -1
  52. package/skills/teamsmith/tests/gate-guard.sh +20 -4
  53. package/skills/teamsmith/tests/help-surface.sh +61 -3
  54. package/skills/teamsmith/tests/install-shape.sh +400 -38
  55. package/skills/teamsmith/tests/key-replies-pty.sh +197 -21
  56. package/skills/teamsmith/tests/key-replies.sh +187 -68
  57. package/skills/teamsmith/tests/ledger-claim.sh +8 -6
  58. package/skills/teamsmith/tests/lib/box-judge.sh +2 -1
  59. package/skills/teamsmith/tests/lib/main-team-fingerprint.sh +104 -0
  60. package/skills/teamsmith/tests/lib/pm-window.sh +127 -0
  61. package/skills/teamsmith/tests/lib/reply-fixture.sh +7 -19
  62. package/skills/teamsmith/tests/lib/reply-guard.sh +188 -0
  63. package/skills/teamsmith/tests/lib/section-calls.pl +171 -0
  64. package/skills/teamsmith/tests/loop-inventory.tsv +7 -5
  65. package/skills/teamsmith/tests/meta-suite.sh +215 -0
  66. package/skills/teamsmith/tests/panel-b3-pty-mouse.py +154 -17
  67. package/skills/teamsmith/tests/panel-b3.sh +33 -4
  68. package/skills/teamsmith/tests/panel-choices.sh +11 -7
  69. package/skills/teamsmith/tests/remind-cli.sh +574 -0
  70. package/skills/teamsmith/tests/reply-capture-real.mjs +360 -0
  71. package/skills/teamsmith/tests/reply-capture-real.sh +5 -0
  72. package/skills/teamsmith/tests/reply-capture.mjs +622 -0
  73. package/skills/teamsmith/tests/section-paths.tsv +41 -10
  74. package/skills/teamsmith/tests/section-select.sh +180 -26
  75. package/skills/teamsmith/tests/smoke.sh +1829 -249
  76. package/skills/teamsmith/tests/state-authority-node.mjs +42 -0
  77. package/skills/teamsmith/tests/state-authority.sh +629 -0
  78. package/skills/teamsmith/tests/task-model-routing.sh +10 -1
  79. package/skills/teamsmith/tests/team-inbox-watch-harness.mjs +33 -0
  80. package/skills/teamsmith/tests/team-notify-knock-marker.mjs +91 -0
  81. package/skills/teamsmith/tests/workflow-entry.sh +123 -3
  82. package/skills/teamsmith-init/SKILL.md +1 -1
@@ -78,6 +78,27 @@ Guards and limitations:
78
78
  records in `state/notify.log`, bounded by `TEAM_NOTIFY_DETAIL_MAX` and rotated once). A different key, a manual
79
79
  notice in between, or a record write that failed starts a new line; a byte-identical briefing inside
80
80
  `TEAM_NOTIFY_DEDUP_SEC` is still suppressed outright.
81
+ - **A notice also lands where the PM reads it** (change `turn-notice-in-pm-inbox`): when the resolved sender is not
82
+ the PM, the same settle writes a second, **independent** line — a pointer — into `docs/team/inbox/pm.md`:
83
+ `<ISO> [<tag>] agent:<seat> · <ID> · knock=enqueued|skipped:<class> · see=docs/team/inbox/<seat>.md`, plus
84
+ `task=<ID> tip=<hex>` when the record carries the revision stamp and `awaiting=<ids>` for a suspension. It is
85
+ derived by the writing side from the record line (same merge key, same merger, no second "what is the same run"
86
+ implementation) and it does **not** append to the detail file, so a run's `×N` still equals its record count. It
87
+ carries no last-message summary, no `branch=`/`uncommitted=`/`unpushed=` and no `⚠ 未提交` prefix: it says where to
88
+ look, and the PM's line count is the PM's pending count. `knock=` is a **run-scoped** field like `×N` and
89
+ `first=`: extending a run keeps the value its first event wrote, because only that event could have woken the PM.
90
+ `enqueued` means "handed to the delivery guard", never "delivered" (`state/outbox/delivered.log` says that). A
91
+ failed pointer write is logged by the extension and changes nothing else: it does not delay, suppress or duplicate
92
+ the knock, and the record line is already on disk. The record line itself stays byte-identical — the pointer is a
93
+ second, independent write, not a rewrite.
94
+ - **One notice is counted once**: an auto-class line whose `agent:` names the inbox file's own seat is that seat's
95
+ record, not its unread traffic (`team_inbox_new` and `team_inbox_since` share the one predicate), so one delivery
96
+ adds exactly one to the PM's pending count — the pointer line — and a seat no longer sees its own `[auto]` lines as
97
+ new mail. Historical `[auto]` lines are not counted after the upgrade and are **not** backfilled with pointers: a
98
+ pointer records where a notice landed and what the knock did, and neither is observable for a notice written before
99
+ the pointer existed. `team inbox <seat> --all` still shows them. `--detail` reconciles a merged line's `×N`
100
+ against the records of **that line's own key** (its first component is the sender), so a `×N` pointer line in
101
+ `pm.md` is not reported as a gap.
81
102
  - **A notice names the revision it describes** (R2/P139; width and branch proof fixed by P160): the durable inbox
82
103
  line and the knock payload carry `task=<ID> tip=<12-hex>` — the **first twelve hex characters of the branch tip,
83
104
  truncated by the sender itself** (`git rev-parse HEAD | cut -c1-12`; the extension's `TIP_WIDTH`), never a Git
@@ -160,35 +181,52 @@ refused (its pane is alive; `reap` only judges orphans); each refusal names the
160
181
  entries only: `interrupt` leaves the window as a live shell, leaves the worktree, the session file and the
161
182
  assignment record untouched, and does not touch the seat's detached background jobs (§4's `team-bg` lane).
162
183
 
163
- ## 4b. Key replies: publish the body before you answer
184
+ ## 4b. Key replies: mark the answer and the extension publishes it
164
185
 
165
- 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
166
187
  memorable: it travels with the tool, so it holds in every project and on every machine. The wake-up loop carries a
167
188
  *pointer* (`inbox/<agent>.md` plus a knock) and the report carries the *process*; neither carries the **body**, and
168
189
  both are transient or post-hoc — the inbox is gitignored, and a report is written after the work. **The reader
169
190
  decides what is published**: whenever the reply is written for the user — a landed milestone, an answer to a
170
191
  question, a status or progress report, a conclusion or a ruling, a decision you ask the user for, a delivery or
171
- verification summary, however short — publish the **complete reply** — the substance the user needs to read, not a
172
- 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:
173
194
 
174
195
  ```
175
- team reply post --from <seat> --title "<short single line>" --stdin <<'EOF'
176
- … the exact body you are about to send …
177
- EOF
196
+ [[team-reply]]
178
197
  ```
179
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
+
180
206
  **The reader decides, so ask "who is this reply written for?"** A reply meant for the patrol or the watchdog, for
181
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
182
- 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.
183
209
  A reply is never held back because of its kind: a status or progress report, a delivery summary and a decision
184
- 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.
185
211
  When the reader cannot be settled, treat the reply as meant for the user rather than risk the user missing it.
186
212
 
187
- A batch of user-facing replies may be one reply. Then send the answer normally. Publication **never gates the
188
- answer**: the same body goes out whether the post
189
- reported `saved` (0), an input error (2), storage unavailable (4), a busy writer (5, the lock wait is bounded) or
190
- `unconfirmed` (6, the entry is visible but its durability could not be confirmed — never re-post it automatically).
191
- 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.
192
230
 
193
231
  What a receipt does and does not mean:
194
232
  - **A saved receipt is project-local durable publication only.** It is not user delivery, not approval, not read
@@ -203,10 +241,11 @@ What a receipt does and does not mean:
203
241
  (newest first), `team reply show <no>` prints safe display text, `team reply show <no> --raw` exports the original
204
242
  bytes to a non-TTY stdout, and the console's page 5 renders the latest reply plus the numbered history. Flags and
205
243
  exit codes are in `team reply --help`.
206
- - **The honest limit**: the gate holds only that this duty is shipped on the instruction surfaces (the injected PM
207
- prompt template, this section, the command table) and that the example command printed there is accepted by the real
208
- parser. No tool can verify that a live PM follows the duty — whether a given reply was meant for the user, which
209
- 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.
210
249
 
211
250
  ## 5. Task briefs: written for "a weak model without context"
212
251
 
@@ -307,7 +346,8 @@ one of which hit RAM and zram bottom at the same time):
307
346
 
308
347
  Why zram is looked at separately: the "free space" of `/dev/zram0` is really compressed pages in RAM, and once full it
309
348
  stays essentially full; counting it towards the concurrency budget systematically overestimates the headroom, and when
310
- 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.
311
351
 
312
352
  ## 7. Security red lines (non-negotiable)
313
353
 
@@ -388,10 +428,10 @@ an occupant (`unknown`).
388
428
  - Boundaries: it does not manage tmux layout by default (`TEAM_PULSE_REBUILD_TMUX=0`, a lost session/window is only
389
429
  reported; with the knob set to 1 it rebuilds the session and the PM window **when it notices they are gone** --
390
430
  which cannot help if the tmux *server* died, because the patrol itself lives in a pane of that server). It does
391
- **not** leave agents alone, though: a seat that has stopped while its task is unfinished is auto-dispatched back
392
- onto the same task (`cmd-watch.sh`'s resume path, one `resume agent=<a> task=<id>` line in `watchdog.log` per
393
- attempt). It does not manage model quota and never merges automatically. Runaway protection: the auto-start quota
394
- 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.
395
435
 
396
436
  Why the boundaries are drawn this narrow: an "everything-managing" daemon would manipulate tmux layout, agent
397
437
  lifecycles and model quota at the same time, and when something breaks nobody can tell who corrupted the state;
@@ -629,14 +669,28 @@ otherwise widen the project's authority — and the schema note it renders names
629
669
  value rule is what `team config list --json` reports as the key's `warning` when a hand-edited file already
630
670
  carries an illegal token, so the read side and the write side can never disagree about what a seat name is.
631
671
 
632
- ## 9. Capacity: the floor is that neither RAM nor disk swap bottoms out (zram does not count)
633
-
634
- - There is only one condition for refusing a dispatch: free swap below `TEAM_MIN_FREE_SWAP_MB` (1024MB by default) or
635
- RAM+swap below `TEAM_MIN_TOTAL_MB`.
636
- - Tight RAM (below `TEAM_WARN_AVAIL_MB`) only warns: slowness is acceptable, because slow is not broken; an OOM is the
637
- real accident.
638
- - `team ps` / `team doctor` report from the same data source and add an estimate of "how many more agents fit"
639
- (`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)").
640
694
 
641
695
  ## 9b. Tests and gates must have a timeout (non-negotiable)
642
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
@@ -299,9 +312,13 @@ Honest edges (documented, not hidden):
299
312
  captures a pane, advances a drain observation or retries a delivery.
300
313
 
301
314
  If a notification really did get glued (e.g. the whitespace-only case), the mitigations from before still apply:
302
- answer with a short sentence right after reading it, lower the volume with `TEAM_INBOX_MAX_CHARS`, or set
303
- `TEAM_NOTIFY_TMUX=0` and read `team digest` yourself — or run that session on a built-in Pi launch path, where
304
- the box is not part of the delivery channel at all.
315
+ answer with a short sentence right after reading it, set `TEAM_NOTIFY_TMUX=0` and read `team digest` yourself — or
316
+ run that session on a built-in Pi launch path, where the box is not part of the delivery channel at all.
317
+
318
+ `TEAM_INBOX_MAX_CHARS` is **not** one of them: it only shortens the preview a knock quotes. The record line in
319
+ `docs/team/inbox/<seat>.md` and the detail in `state/notify.log` keep the whole message, so lowering it removes no
320
+ text from the inbox and no text from the disk — read what is already there and `team inbox <seat> --ack` it away,
321
+ and the volume that matters (events per day) is bounded by `TEAM_NOTIFY_DETAIL_MAX`, not by this key.
305
322
 
306
323
  ## 4. `team dispatch` refuses to dispatch
307
324
 
@@ -921,7 +938,8 @@ skipped (`classify stale=<n> …`, and a *recovered* line that has since gone st
921
938
 
922
939
  ## 21. pi announces a new version → the input box reads as BUSY
923
940
 
924
- **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`**
925
943
  (the message lands in `state/outbox/` instead of the box), and the real-pi fixture says so:
926
944
 
927
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".