teamsmith 0.4.6 → 0.4.8

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 (91) hide show
  1. package/README.md +6 -6
  2. package/package.json +1 -1
  3. package/skills/teamsmith/CHANGELOG.md +35 -0
  4. package/skills/teamsmith/SKILL.md +43 -30
  5. package/skills/teamsmith/extension/team-bg.ts +5 -3
  6. package/skills/teamsmith/extension/team-inbox-watch.ts +14 -3
  7. package/skills/teamsmith/extension/team-notify.ts +20 -13
  8. package/skills/teamsmith/extension/team-remind.ts +189 -0
  9. package/skills/teamsmith/extension/team-reply.ts +4 -7
  10. package/skills/teamsmith/references/config.md +11 -12
  11. package/skills/teamsmith/references/migration.md +101 -0
  12. package/skills/teamsmith/references/openspec.md +43 -27
  13. package/skills/teamsmith/references/protocol.md +26 -15
  14. package/skills/teamsmith/references/reminders.md +153 -161
  15. package/skills/teamsmith/references/troubleshooting.md +12 -7
  16. package/skills/teamsmith/references/workflows.md +84 -31
  17. package/skills/teamsmith/scripts/lib/cmd-agents.sh +10 -4
  18. package/skills/teamsmith/scripts/lib/cmd-project.sh +88 -6
  19. package/skills/teamsmith/scripts/lib/cmd-remind.sh +88 -2
  20. package/skills/teamsmith/scripts/lib/cmd-review.sh +61 -35
  21. package/skills/teamsmith/scripts/lib/cmd-watch.sh +48 -11
  22. package/skills/teamsmith/scripts/lib/common.sh +83 -13
  23. package/skills/teamsmith/scripts/panel/README.md +35 -33
  24. package/skills/teamsmith/scripts/panel/panel.js +217 -199
  25. package/skills/teamsmith/scripts/panel/src/App.tsx +221 -66
  26. package/skills/teamsmith/scripts/panel/src/data.ts +71 -15
  27. package/skills/teamsmith/scripts/panel/src/layout.ts +159 -310
  28. package/skills/teamsmith/scripts/panel/src/main.tsx +83 -21
  29. package/skills/teamsmith/scripts/panel/src/project-settings.ts +46 -0
  30. package/skills/teamsmith/scripts/panel/src/strings/en.ts +71 -205
  31. package/skills/teamsmith/scripts/panel/src/strings/index.ts +3 -5
  32. package/skills/teamsmith/scripts/panel/src/strings/zh.ts +72 -204
  33. package/skills/teamsmith/scripts/panel/src/types.ts +23 -4
  34. package/skills/teamsmith/scripts/remind-capability.mjs +261 -0
  35. package/skills/teamsmith/scripts/remind-store.mjs +55 -24
  36. package/skills/teamsmith/scripts/remind-tick.mjs +5 -2
  37. package/skills/teamsmith/scripts/reply-capture.mjs +8 -9
  38. package/skills/teamsmith/scripts/state-authority.mjs +72 -6
  39. package/skills/teamsmith/scripts/strings/commands.tsv +1 -1
  40. package/skills/teamsmith/scripts/team +1 -0
  41. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +18 -8
  42. package/skills/teamsmith/templates/DECISIONS.md.tmpl +2 -2
  43. package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +3 -3
  44. package/skills/teamsmith/templates/PROTOCOL.md.tmpl +19 -14
  45. package/skills/teamsmith/templates/memory-seed.md.tmpl +2 -2
  46. package/skills/teamsmith/templates/pm-prompt.md.tmpl +41 -25
  47. package/skills/teamsmith/templates/report.md.tmpl +33 -0
  48. package/skills/teamsmith/tests/bg-ledger-harness.mjs +217 -33
  49. package/skills/teamsmith/tests/bg-ledger.sh +24 -10
  50. package/skills/teamsmith/tests/checkout-shape-probe.sh +7 -6
  51. package/skills/teamsmith/tests/fixtures/remind-adversarial-delay.ts +27 -0
  52. package/skills/teamsmith/tests/fixtures/remind-tool-provider.ts +65 -0
  53. package/skills/teamsmith/tests/help-surface.sh +78 -12
  54. package/skills/teamsmith/tests/install-shape.sh +7 -7
  55. package/skills/teamsmith/tests/isolation-ledger.sh +6 -2
  56. package/skills/teamsmith/tests/key-replies-ui.sh +64 -5
  57. package/skills/teamsmith/tests/key-replies.sh +307 -106
  58. package/skills/teamsmith/tests/lib/main-team-fingerprint.sh +2 -0
  59. package/skills/teamsmith/tests/lib/model-routing-boundary.sh +255 -90
  60. package/skills/teamsmith/tests/lib/model-routing-expansion.sh +181 -61
  61. package/skills/teamsmith/tests/lib/model-routing-roles.sh +125 -67
  62. package/skills/teamsmith/tests/lib/reply-fixture.sh +14 -9
  63. package/skills/teamsmith/tests/lib/routes-pages.sh +243 -0
  64. package/skills/teamsmith/tests/lib/tmp-root.sh +1 -1
  65. package/skills/teamsmith/tests/loop-inventory.tsv +3 -0
  66. package/skills/teamsmith/tests/panel-b2.sh +91 -31
  67. package/skills/teamsmith/tests/panel-b3-stub.sh +9 -2
  68. package/skills/teamsmith/tests/panel-p21.sh +607 -1162
  69. package/skills/teamsmith/tests/panel-strings.mjs +21 -113
  70. package/skills/teamsmith/tests/remind-adversarial-faults.mjs +190 -0
  71. package/skills/teamsmith/tests/remind-adversarial-faults.sh +78 -0
  72. package/skills/teamsmith/tests/remind-adversarial-real.sh +28 -0
  73. package/skills/teamsmith/tests/remind-cli.sh +108 -3
  74. package/skills/teamsmith/tests/remind-delivery-node.mjs +13 -0
  75. package/skills/teamsmith/tests/remind-delivery.sh +123 -35
  76. package/skills/teamsmith/tests/remind-lifecycle.sh +197 -0
  77. package/skills/teamsmith/tests/remind-pulse.sh +199 -0
  78. package/skills/teamsmith/tests/remind-recovery-real.sh +5 -0
  79. package/skills/teamsmith/tests/remind-recovery-unit.sh +118 -0
  80. package/skills/teamsmith/tests/remind-tool-node.mjs +159 -0
  81. package/skills/teamsmith/tests/remind-tool-real.mjs +801 -0
  82. package/skills/teamsmith/tests/remind-tool-real.sh +180 -0
  83. package/skills/teamsmith/tests/reply-capture-real.mjs +93 -2
  84. package/skills/teamsmith/tests/routes.sh +213 -293
  85. package/skills/teamsmith/tests/section-paths.tsv +19 -17
  86. package/skills/teamsmith/tests/smoke.sh +583 -133
  87. package/skills/teamsmith/tests/state-authority.sh +152 -8
  88. package/skills/teamsmith/tests/task-model-routing.sh +57 -26
  89. package/skills/teamsmith/tests/tmp-hygiene.sh +1 -1
  90. package/skills/teamsmith-init/SKILL.md +5 -5
  91. package/skills/teamsmith/tests/fixtures/delivery-truth-real/__pycache__/judge-second.cpython-313.pyc +0 -0
@@ -1,174 +1,166 @@
1
1
  # Reminders
2
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: recording, reading, cancelling, and what happens when a reminder
8
- comes due.
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 into a batch.
15
- - Queues a reminder when it comes due (the pulse's own ten-second due check) and delivers it — as one
16
- complete message, one batch at a time — into the verified PM session through the inbox watcher. The
17
- message is a Pi custom message: nothing is typed into the editor and a draft is never touched.
18
- - Leaves Standby once, and only after the wake is actually observed. Being due, queued, frozen or
19
- refused does **not** leave Standby, and a newer Standby generation is never cleared by an older
20
- batch.
21
- - Does **not** resend a batch whose delivery cannot be proven: it becomes `unknown` and waits for an
22
- operator (`team remind resolve <batch> --ack-unknown`).
23
- - Does **not** accept a project, an owner or a recipient from the caller: those come from the
24
- checkout the command runs in and from the authority itself.
25
- - Does **not** start a stopped PM for a reminder, and does not expose a PM model tool: the CLI is the
26
- way this build creates reminders, and a queued reminder waits for the session that comes back.
27
-
28
- ## Where the state lives
3
+ A Reminder is a durable one-shot note the project PM leaves for itself. The project state, not a model
4
+ session or a timer process, decides when it is due, whether it was sent and what remains uncertain.
29
5
 
30
- ```
31
- <main checkout>/.pi/team/reminder-locator.json the pinned state root and the project identity
32
- <main checkout>/.pi/team/reminder-locator.lock serialises establishing that locator
33
- <state root>/reminders/state.json the versioned snapshot: reminders, batches, audit
34
- <state root>/reminders/authority.lock serialises every state transaction
35
- ```
36
-
37
- The state root is the project's own `<main checkout>/.pi/team/state` unless the project pins
38
- `TEAM_STATE_DIR`; the first use pins it in the locator and every later process must agree with it.
39
- Two processes with different `TMPDIR` values still meet on that one path. A different state root is
40
- refused instead of silently creating a second authority.
6
+ This page covers the CLI, the PM-only tool, delivery, stopped-PM recovery and operator recovery.
41
7
 
42
- Every read and write is one `flock` transaction: read and validate the snapshot, mutate it, write a
43
- temporary file, `fsync` it, rename it into place, `fsync` the directory. A missing `flock`, a timeout,
44
- an unreadable snapshot or an identity mismatch is a visible error; there is no unlocked fallback and
45
- an unreadable snapshot is never replaced by an empty store.
46
-
47
- ## Commands
8
+ ## Create and inspect
48
9
 
49
10
  ```bash
50
11
  team remind add --after 20m --message "check the build"
51
- team remind add --at 2026-10-28T09:00:00+08:00 --message-file note.md --key morning-review --task P409
12
+ team remind add --at 2026-10-28T09:00:00+08:00 --message-file note.md --key morning-review --task P443
52
13
  team remind list
53
14
  team remind list --all
54
- team remind list --json
55
15
  team remind show rem-<project id>-3
56
16
  team remind cancel rem-<project id>-3
57
17
  ```
58
18
 
59
- `list` prints a count line per view, then one block per active reminder: its stable id, its view, the
60
- due instant with a relative distance, then the text exactly as stored. Ended reminders are kept but
61
- printed only with `--all`; they are counted either way. `--json` on any of the four subcommands returns
62
- the same snapshot the text is rendered from, for scripts.
63
-
64
- `show` prints one record in full. A message is never shortened: `list` and `show` print the bytes that
65
- were stored, and `--message-file` stores the file byte for byte (a trailing newline is part of the
66
- text — the shell does not get to trim it).
67
-
68
- ## Time
69
-
70
- Exactly one of the two forms:
71
-
72
- - `--at` is an RFC 3339 date-time with an explicit offset (`2026-10-28T09:00:00+08:00`) or `Z`. A
73
- time without an offset, an impossible date such as `2026-02-30`, a leap second, a second that does
74
- not exist or an instant in the past is refused with the reason, and nothing is written.
75
- - `--after` is a positive whole number followed by `s`, `m` or `h` (`90s`, `20m`, `2h`). Zero,
76
- negative, non-numeric and overflowing values are refused.
77
-
78
- The relative form is resolved **once, inside the locked transaction**, and the resulting instant is
79
- what the snapshot stores. Printing it is the record's due time, not a recomputation.
80
-
81
- ## Keys
82
-
83
- `--key <name>` names one logical reminder. While a live record holds the key:
84
-
85
- - the identical request (same time form and value, same text, same task) returns that record and its
86
- original due instant, and allocates nothing;
87
- - a different request under the same key is refused, naming the record that holds it.
88
-
89
- A key is held by `scheduled`, `queued`, `intent` and `unknown` records. Any terminal phase
90
- (`observed`, `cancelled`, `resolved`) releases it, and the next request is a new reminder with a new
91
- id — reuse after release is deliberately not an exactly-once guarantee.
92
-
93
- ## Views
94
-
95
- The snapshot stores phases, never views. Every read derives the view from the phase, the due instant
96
- and the clock:
97
-
98
- | View | Meaning |
99
- |---|---|
100
- | `scheduled` | recorded, due in the future, not admitted for delivery |
101
- | `derived-due` | recorded, due now or in the past, still not admitted — the clock alone says "due" |
102
- | `queued` | delivery admitted with a queue identity and enqueue time |
103
- | `intent` | frozen into a delivery batch, before the Pi call |
104
- | `observed` | the correlated Pi message was seen; delivery is proven, nothing more |
105
- | `unknown` | a batch was frozen and no correlated observation exists; never resent blindly |
106
- | `cancelled` | withdrawn before delivery was frozen |
107
- | `resolved` | an operator acknowledged an unknown batch |
108
-
109
- `due` is not `queued`: a reminder can be overdue for a long time and still never have been sent.
110
- All of these phases are produced by this build; the reader derives the view from the snapshot rather
111
- than from a second copy, so a record written by any process shows up the same way in every reader.
112
-
113
- ## Delivery
114
-
115
- The delivery path has four separate facts, and each one is durable before the next step:
116
-
117
- 1. **Due admission.** Both pulse shapes (the console and the headless tick loop) run a lightweight
118
- check about every ten seconds, apart from the full patrol. A due reminder is committed as `queued`
119
- with a queue order and its enqueue time; a repeated scan never creates a second queue entry. An
120
- item is marked `overdue` when its due instant predates the pulse instance that admitted it (a
121
- catch-up after a restart) or when admission lagged due by more than 30 seconds — an ordinary
122
- polling delay is not labelled overdue. A reminder still arriving 5 seconds late is normal; one
123
- that arrives 5 minutes late says so.
124
- 2. **One frozen batch.** The PM session's inbox watcher freezes at most eight queued reminders into
125
- one batch, records the intent — every member, the full text, the correlation nonce and the current
126
- Standby generation — and only then calls Pi. One batch is outstanding at a time; at most one
127
- submission per five seconds. Nothing is written into the editor and the input draft is untouched.
128
- 3. **Observation.** Pi's own `message_start` for that custom message, carrying the batch id and the
129
- nonce, is the only thing that counts as a wake. A return value, a thrown error, a deferred action
130
- or an unrelated run is not. The observation, the consumed right and the Standby exit commit in one
131
- atomic snapshot with an audit line naming the batch and every reminder id and source.
132
- 4. **Standby.** A reminder may wake a PM that is on standby (this is the one wake that Standby does
133
- not suppress). If the generation bound at intent is still the current one, the same observation
134
- transaction switches standby off — once per batch, never twice. If a newer generation exists, it
135
- is preserved and the outcome is reported as `generation-ambiguous`. If standby was already
136
- manually off, the audit says `already-off` rather than inventing an automatic exit.
137
-
138
- If the session API refuses the message, the batch becomes `unknown` (visible in `team remind list`),
139
- its members stop being independently sendable and nothing resends automatically: a call returning or
140
- throwing is not a receipt. `team remind resolve <batch-id> --ack-unknown` is the operator's explicit
141
- acknowledgment — it closes every member of that batch, burns its remaining right and reports the ids
142
- without claiming delivery.
143
-
144
- After a restart, `queued` reminders are still queued and are delivered by the next watcher; an intent
145
- that never saw an observation past its 60-second deadline becomes `unknown` instead of being resent;
146
- `observed` and `resolved` reminders are never queued again.
147
-
148
- ## Retention and the issued high-water
149
-
150
- Ended reminders are history: the newest 1000 terminal outcomes within 30 days are kept, older ones are
151
- compacted inside the same transaction that mutates. Active and unknown records are never evicted, and
152
- the count of pruned outcomes is cumulative.
153
-
154
- Ids are never reused. The snapshot carries the next sequence number, so a compaction, a restart or a
155
- lost reply cannot hand out an id twice. Asking for an id that was issued and has since been compacted
156
- answers `history-pruned`; an id above the issued high-water answers as never issued. Neither can be
157
- revived or sent.
158
-
159
- ## When it refuses
160
-
161
- - No `flock` on the machine, lock timeout, an unreadable or unsupported snapshot, or a snapshot whose
162
- identity contradicts the locator: the command fails with the reason and writes nothing. Repair the
163
- host or the snapshot; there is no unlocked mode to fall back to.
164
- - `already-observed`, `in-flight` or `unknown` on `cancel`: the reminder is past the point where
165
- withdrawal can be guaranteed, and the command says so instead of pretending it was cancelled.
166
- - A message that is empty, blank, contains a NUL byte or is not valid UTF-8: refused before anything
167
- is stored.
168
-
169
- ## Not in this build
170
-
171
- The PM-only model tool, starting a stopped PM for a reminder (the prompt-free handoff), and the
172
- configurable limits (active count, message bytes, create rate) are later tasks of the same change.
173
- Until they land, the CLI is how a reminder is created and a queued reminder waits for a PM session
174
- that is running.
19
+ The verified PM also has the `team_remind` model tool with `add/list/show/cancel`. It uses the same
20
+ state authority and records `source=pm-tool`; CLI-created records record `source=cli`. The tool is not
21
+ injected into workers or `/team`. A switch, fork, reload or stale identity hides it immediately, and
22
+ `team doctor` no longer reports the previous registration as ready. Missing evidence is `unknown`, not
23
+ proof that the extension failed to load.
24
+
25
+ There are no Reminder rate, active-count, message-size, batch-size or spacing quotas and no Reminder
26
+ configuration keys. Input is still checked: exactly one future time, nonempty valid UTF-8 text without
27
+ NUL, and a valid optional key/task. Text is never truncated. `--message-file` preserves trailing
28
+ newlines. With `--json`, stdin decoding and NUL refusals are JSON objects with
29
+ `{ok:false, refusal:"bad-message", reason:"…"}` and a nonzero exit status.
30
+
31
+ `--at` requires RFC 3339 with `Z` or an explicit offset. `--after` is a positive integer plus `s`, `m`
32
+ or `h`; one second is valid. A relative deadline is computed once inside the locked create transaction.
33
+
34
+ ## Keys and repeated one-shots
35
+
36
+ `--key <name>` deduplicates only the active request. An identical retry returns the original ID and its
37
+ first persisted due time. A different request under that key is refused. `scheduled`, `queued`,
38
+ `intent` and `unknown` hold the key; `observed`, `cancelled` and `resolved` release it.
39
+
40
+ Periodic work is a sequence of one-shot Reminders, not a recurring scheduler: after one wake is
41
+ observed, create the next one-shot with the same key. It receives a new monotone ID. Do not infer a
42
+ period from the old record or retry a terminal creation expecting global idempotency.
43
+
44
+ ## Due is not queued, and queued is not a wake
45
+
46
+ The views are `scheduled`, `derived-due`, `queued`, `intent`, `observed`, `unknown`, `cancelled` and
47
+ `resolved`. `derived-due` means the clock reached the due instant; it does not prove that Pulse was
48
+ running or admitted the item. `queued` has a durable queue order and enqueue time. `intent` means one
49
+ whole batch was frozen before a Pi call. Only a correlated Pi `message_start` is an observed wake; a
50
+ process start, API return, queue entry, deferred action or model completion is not.
51
+
52
+ Both Pulse shapes run the lightweight due check about every ten seconds without increasing the full
53
+ patrol frequency. A long patrol does not stop admission. There is at most one full patrol and one
54
+ Reminder recovery decision; due items arriving during either are coalesced into one recovery recheck
55
+ after it ends. Pulse reaps its patrol/recovery children on shutdown.
56
+
57
+ In normal conditions (Pulse alive, healthy clock/storage/lock and responsive OS scheduling), durable
58
+ admission targets 30 seconds after due. An item due before this Pulse instance started, or admitted
59
+ more than 30 seconds late, is marked `overdue`. This target says nothing about Pi start time, model
60
+ latency or work completion. Pulse stopped or a failed lock is visible failure, not a passing timing
61
+ measurement.
62
+
63
+ ## Delivery and Standby
64
+
65
+ The PM inbox watcher freezes all currently queued Reminders into one full-text batch. There is no
66
+ member cap and no post-outcome spacing timer. One batch remains outstanding until observation or an
67
+ explicit unknown acknowledgment. The watcher sends one Pi custom follow-up message; it does not type
68
+ into the editor or disturb a draft.
69
+
70
+ The batch intent binds the current Standby generation before the Pi call. Observation, the consumed
71
+ batch right, the Standby result and the audit commit atomically:
72
+
73
+ - the same bound generation still current: switch it off once as `auto-off`;
74
+ - already manually off: record `already-off`;
75
+ - a newer generation whose ordering cannot be proven: preserve it as `generation-ambiguous`.
76
+
77
+ An ordinary pending nudge is a different mechanism and does not count as a Reminder wake. Ordinary
78
+ Outbox drain and an explicitly directed `--now` keep their independent authorization.
79
+
80
+ ## A stopped PM: Reminder-only recovery
81
+
82
+ An eligible queued Reminder can recover the stopped built-in Pi PM while Standby is on. Recovery uses
83
+ the existing PM identity, continuity, `starting`, window ownership, capacity evidence and restart
84
+ quota. It starts or resumes Pi with the usual resume arguments and PM extensions, but **without**
85
+ `@pm-prompt` or any replacement initial user/model prompt. The watcher starts with the process and
86
+ delivers the queued Reminder through the normal direct path.
87
+
88
+ Before the correlated observation and a permitted Standby result, ordinary startup work and ordinary
89
+ inbox recovery remain suppressed. Starting, queueing or a failed/lost send does not switch Standby
90
+ off. A newer ambiguous Standby generation remains on. After a valid observation, ordinary work
91
+ resumes under the existing rules; startup-age backlog still follows the watcher's baseline rules.
92
+
93
+ Recovery has explicit outcomes instead of a success message for every path:
94
+
95
+ - running/busy PM: no second process and no ordinary nudge; a busy PM receives only the later
96
+ correlated follow-up;
97
+ - `starting`: wait, do not respawn or consume another restart slot;
98
+ - missing window/session: report it; do not rebuild tmux unless the existing rebuild policy allows it;
99
+ - restart quota, identity/continuity or foreign-window refusal: no launch;
100
+ - missing required extension: no launch;
101
+ - custom PM adapter: `unsupported-adapter`; the prompt-free Pi watcher contract is not claimed;
102
+ - launch failure, send failure or lost outcome: no success claim, no blind resend and no Standby off.
103
+
104
+ `result=started` means launch proof was obtained, not that the Reminder was observed. Only the later
105
+ correlated event changes the batch to `observed`.
106
+
107
+ ## Unknown outcomes and operator resolution
108
+
109
+ A synchronous send failure, process death after intent, or 60 seconds without a correlated observation
110
+ makes the batch `unknown`. It is never automatically resent, and it blocks the next batch until a late
111
+ valid observation or an explicit operator acknowledgment. Creating new Reminders is still allowed.
112
+
113
+ Inspect the whole batch, then run:
114
+
115
+ ```bash
116
+ team remind resolve <batch-id> --ack-unknown
117
+ ```
118
+
119
+ This closes every member as `resolved`, burns the batch's remaining automatic-off right and returns
120
+ the member IDs. It does not claim that delivery happened or did not happen and does not resend. A late
121
+ event cannot reopen the batch or clear a newer Standby generation. To arrange another reminder, create
122
+ a new ID.
123
+
124
+ ## State, locking and retention
125
+
126
+ ```text
127
+ <main checkout>/.pi/team/reminder-locator.json pinned state root and project identity
128
+ <main checkout>/.pi/team/reminder-locator.lock serializes locator establishment
129
+ <state root>/reminders/state.json reminders, batches, Standby and audit
130
+ <state root>/reminders/authority.lock one cross-process transaction lock
131
+ ```
132
+
133
+ Every mutation uses `flock`: read and validate the snapshot, mutate briefly, write a same-directory
134
+ temporary file, `fsync` it, rename and `fsync` the directory. Pi/model calls and patrols never run under
135
+ this lock. Different `TMPDIR` values still use the canonical project lock. Missing `flock`, lock
136
+ timeout, corrupt/unsupported state or a state-root mismatch is a visible error with no unlocked
137
+ fallback and no partial snapshot replacement.
138
+
139
+ Terminal reminders and batches retain at most the newest 1000 outcomes or 30 days. Active/unknown
140
+ records and every unspent batch right are never evicted. A retained batch keeps all its members. IDs
141
+ and the issued high-water are never reused; an absent issued ID reports `history-pruned`. A late event
142
+ for retained unknown history can still be observed once. A late event for a pruned ID is reported and
143
+ ignored: it cannot synthesize a Reminder, recreate a batch, spend another right or authorize a resend.
144
+
145
+ ## Upgrade and rollback
146
+
147
+ 1. Quiesce the old PM, Pulse and other writers. Old code that writes the legacy Standby marker must not
148
+ run beside the new authority.
149
+ 2. Back up the runtime state, verify `flock` and the JS runtime, and confirm the intended canonical
150
+ state root before starting the new writers. The legacy Standby marker migrates once under the lock
151
+ with its reason and generation preserved. `flock` is required for Standby even when the project has
152
+ no Reminders; `team paths` exposes the exact `flock_runner` used by transactions.
153
+ 3. A missing executable reports `flock unavailable: no executable flock on PATH`; an unusable one names
154
+ its path. An OS locking failure reports `exclusive flock failed at <lock>` and the filesystem repair.
155
+ `team doctor` fails in all three cases and gives the corresponding repair. There is no unlocked
156
+ mutation or requirement switch that bypasses the dependency.
157
+ 4. Before rollback, quiesce the new writers, inspect and resolve outstanding intents and export
158
+ `reminders/state.json`. Restore the legacy Standby marker from the authoritative generation/reason
159
+ and keep the Reminder snapshot outside the old code's path. The exact `cp` / `node -e` export,
160
+ recovery check, migration-failure states and restart order are in [migration.md §9](migration.md#9-reminder-state-and-prompt-free-recovery);
161
+ there is no separate export or automatic rollback command.
162
+ 5. Old binaries cannot interpret or deliver outstanding Reminders. Rollback suspends them; it does not
163
+ auto-replay them. Verify the backup, marker and stopped processes before resuming old code.
164
+
165
+ `team doctor` checks the lock dependency and PM-tool evidence. There is no scheduler daemon, separate
166
+ Reminder outbox, TUI scheduler or model-autonomy guarantee in this design.
@@ -655,7 +655,7 @@ seat's last screen and tmux's exit evidence survive the death. Reading such a se
655
655
  ## 12. General Pi traps
656
656
 
657
657
  - **A test conclusion must come from a real run of this round**: put the command and the tail of its output into the
658
- report, and the PM re-runs it.
658
+ report, and the assigned non-implementer verifier re-runs it; the PM reviews that evidence.
659
659
  - Type-only imports (`import type`) are mandatory in projects with `verbatimModuleSyntax` and the like — such project
660
660
  rules belong in `AGENTS.md`, otherwise weaker models trip over them again and again.
661
661
  - Screen scraping is unreliable (TUI refreshes/line wraps), so never treat tmux scrollback as evidence; reports and
@@ -1396,16 +1396,21 @@ offending line, so the fix stays local to the brief.
1396
1396
 
1397
1397
  ### 27c. `team review` refuses without `--dir`: the one-command independent review
1398
1398
 
1399
- `team review` runs the gates against a checkout **the PM prepared** and writes the verdict record itself; it does
1400
- not create the checkout and does not run git. One command line covers both steps:
1399
+ The PM prepares the checkout; the assigned non-implementer verifier runs `team review` from its own worktree, and
1400
+ the tool writes the verdict record/log. The command does not create the checkout and does not run git. Preparation
1401
+ and verifier execution are separate steps:
1401
1402
 
1402
1403
  ```bash
1403
- git -C <root> worktree add --detach /tmp/review-<ID> <task-branch> && \
1404
- bash <skill>/scripts/team review <ID> --dir /tmp/review-<ID> # add --strong for the structural checks
1404
+ git -C <root> worktree add --detach /tmp/review-<ID> <task-branch> # PM
1405
+ # Assigned verifier, from its own worktree:
1406
+ bash <skill>/scripts/team review <ID> --dir /tmp/review-<ID> # add --strong for structural checks
1405
1407
  ```
1406
1408
 
1407
- Both forms write `docs/team/reviews/<ID>.md` (HEAD, diffstat, commit list, gate tail, verdict checklist) — the
1408
- record that `team board set <ID> done` and the merge step read. The details that bite:
1409
+ The verify brief explicitly authorizes only the tool-written main-checkout `docs/team/reviews/<ID>.md` and
1410
+ `<ID>-verify.log` exception. The record carries the actual executor, HEAD, diffstat, commit list, gate tail and
1411
+ verdict checklist; the verifier's own report stays on its task branch. This grants no other manual main-checkout
1412
+ writes. After merging, the same verifier checks the merged revision and the PM accepts that passing evidence before
1413
+ `team board set <ID> done`. The details that bite:
1409
1414
 
1410
1415
  - `--dir` is the **root** of the checkout; a subdirectory is refused with the path it resolved.
1411
1416
  - The checkout must be clean and sit at the branch under review; a dirty or mismatched one is refused, and the
@@ -16,8 +16,8 @@ each** — the reasoning, owners and gates are in [openspec.md](openspec.md):
16
16
  | 1 | `opsx-explore` | an explorer worker (never the eventual implementer) | the PM accepts the approach, records it in `DECISIONS.md`, writes the propose brief |
17
17
  | 2 | `opsx-propose` | the explorer, same agent (planning only — no code) | the PM's **proposal review is ACCEPTED** in `reviews/<change>-proposal.md`: `openspec validate --all --strict` green + the ten-point checklist |
18
18
  | 3 | `opsx-apply` | a dev worker | independent verification is dispatched to a different agent |
19
- | 4 | `opsx-verify` | an **independent** verify agent | the PM re-runs the gate on the merged tree and sets `done` |
20
- | 5 | `opsx-archive` | the PM | the user confirms (the PM may act as the user's proxy only when it says so and records why) |
19
+ | 4 | `opsx-verify` | an **independent** verify agent | after the PM merges, the same verifier resumes on the pinned merged SHA and runs the applicable gates + OpenSpec assessment; the PM accepts passing evidence before `done` |
20
+ | 5 | `opsx-archive` | a non-implementer worker (possibly that verifier) | the PM dispatches archive only after accepted merged-revision evidence, zero unresolved CRITICAL findings, reconciled sibling/checklist evidence, and the user's confirmation; the PM may act as proxy only for a small, reversible change already covered by the approved approach and records the confirmer and reason |
21
21
 
22
22
  ```bash
23
23
  openspec list --specs # capabilities and their requirement counts
@@ -142,23 +142,43 @@ renders (board `done`/`closed` skipped, drafts listed but *not* counted), and a
142
142
  re-executes itself as soon as `scripts/lib/**` changes on disk, so the reason it wakes the PM is never older than
143
143
  the digest the PM then reads.
144
144
 
145
- When a "turn ended" notification arrives, look at `git -C .worktrees/<a> log --oneline -5` and `status` first, then
146
- decide: dispatch the next task, send it back, or verify. After a long absence (end of day, machine reboot): **run
147
- `team up` first**.
145
+ Notifications are the first prompt, but files decide the state. **Before repeating an unchanged waiting report**,
146
+ reconcile `team digest`, BOARD, the task-branch report and the task worktree's `git log`/`status`. Read the report
147
+ from the branch without switching: `git show <task-branch>:docs/team/reports/<ID>-<agent>.md`; an uncommitted
148
+ report is a draft, not delivery. An old tip, no new notice or a merged inbox line does not by itself prove that
149
+ work is unfinished.
148
150
 
149
- ## E. Verification (the PM's independent check, never skipped)
151
+ A committed final report enters the existing acceptance route: prepare the independent checkout and hand it to the
152
+ assigned non-implementer verifier; the PM reviews evidence and does not rerun that verifier's acceptance tests. A
153
+ live job without a committed final report stays on the existing wait/harvest route and is not declared delivered.
154
+ Do not poll seat screens. This reconciliation happens on the ordinary notification/patrol loop; it adds no timer,
155
+ notification channel or PM verification lane. After a long absence (end of day, machine reboot): **run `team up`
156
+ first**.
157
+
158
+ ## E. Delegated verification (the verifier executes; the PM accepts)
150
159
 
151
160
  ```bash
152
161
  git -C <root> worktree add --detach /tmp/review-T1.1 task/T1.1-* # the PM prepares an independent checkout
153
- bash <skill>/scripts/team review T1.1 --dir /tmp/review-T1.1 # runs gates only + writes the verification record
154
- bash <skill>/scripts/team review T1.1 --dir /tmp/review-T1.1 --no-gates # manual review only
162
+ # From the assigned verifier's own worktree, not the PM window:
163
+ bash <skill>/scripts/team review T1.1 --dir /tmp/review-T1.1 # verifier runs gates; tool writes the named record/log
164
+ bash <skill>/scripts/team review T1.1 --dir /tmp/review-T1.1 --no-gates # manual review only; not gate evidence
155
165
  ```
156
166
 
157
- Artefact `docs/team/reviews/T1.1.md`: HEAD, diffstat, commit list, file list, tail of the gate output, verdict
158
- checklist. When the gates fail the command returns non-zero — do not ignore it.
167
+ The verify brief names the implementation task ID, target revision and exactly `docs/team/reviews/<ID>.md` plus
168
+ `<ID>-verify.log` as the tool-written main-checkout exception. The generated record identifies the actual verifier,
169
+ checkout and reviewed SHA; it does not attribute execution to the PM or the implementer. The verifier's report stays on
170
+ its own task branch. The exception excludes manual main edits, other records, code/spec writes, merges and pushes.
171
+ When the verify assignment ID differs from the implementation ID, the PM writes `docs/team/reviews/<verify-task>.md`
172
+ as a separate **PM acceptance** record linking that implementation-ID execution record, the verifier report and the
173
+ verified merged SHA; it is not execution evidence.
174
+
175
+ Artefact `docs/team/reviews/T1.1.md`: actual executor, HEAD, diffstat, commit list, file list, tail of the gate output
176
+ and verdict checklist. When the gates fail the command returns non-zero — do not ignore it. A shell PASS is not a
177
+ completed OpenSpec assessment: the verifier's report uses CRITICAL/WARNING/SUGGESTION/Final assessment and records
178
+ unverified checks and reasons.
159
179
 
160
- **The PM also has to read the diff**: gates only prove "the existing tests did not fail", not "the implementation
161
- matches the brief".
180
+ **The PM also has to read the evidence and diff**: gates only prove "the existing tests did not fail", not "the
181
+ implementation matches the brief". This acceptance review does not make the PM the gate executor.
162
182
 
163
183
  **A gate that takes tens of minutes must not sit inside a turn.** teamsmith's own background lane is the default
164
184
  on Pi (§E2); `team doctor` reports the harness and the plugins this project carries (`harness` /
@@ -171,12 +191,12 @@ fact, counterexample, reasoning gap or unobserved boundary is a finding to delet
171
191
  and a longer or more defensive report is not stronger evidence. This is a reading rule, not a gate: no section
172
192
  checks the wording (see [references/protocol.md](protocol.md) §11b).
173
193
 
174
- ### E2. The PM's background gate (the team's own lane, no extra window)
194
+ ### E2. The verifier's background gate (the team's own lane, no extra window)
175
195
 
176
196
  On the built-in Pi paths (both the PM and the workers) the session already has two tools for this:
177
197
 
178
198
  ```text
179
- team_bg_run command="bash <skill>/scripts/team review T1.1 --dir /tmp/review-T1.1" name="review-T1.1"
199
+ team_bg_run command="bash <skill>/scripts/team review T1.1 --dir /tmp/review-T1.1" name="review-T1.1" # verifier-owned job
180
200
  → job review-T1.1 started (pid 12345); log: <root>/.pi/team/state/bg/review-T1.1.log
181
201
  cmd: bash <skill>/scripts/team review T1.1 --dir /tmp/review-T1.1 (single-lined; shortened with … past 100 code points)
182
202
  (the tool returns at once — the turn is free again)
@@ -208,8 +228,9 @@ The four rules that make it safe (they are the extension's code, not a conventio
208
228
  4. **A restart does not kill a job** (the process is detached), but the job table is per session: after a
209
229
  restart read `state/bg.log` and the log file instead of waiting for a wake-up.
210
230
 
211
- A worker uses the same tools (its prompt says so) — that is how a worker can run a long build without burning its
212
- turn. A CLI without the Pi extension API does not have them: fall back to a background tmux window
231
+ The assigned verifier uses these tools for review gates; a PM-owned background review does not satisfy delegation.
232
+ Another worker uses the same tools for a long build without burning its turn. A CLI without the Pi extension API does
233
+ not have them: fall back to a background tmux window
213
234
  ([troubleshooting.md](troubleshooting.md) §17).
214
235
 
215
236
  ### E3. Performance is a separate run (and a release step)
@@ -238,7 +259,9 @@ release checklist says (`docs/team/PUBLISH.md`).
238
259
  git -C <root> status # the main worktree must be clean and on the protected branch
239
260
  git -C <root> merge --squash <branch> # conflict handling: see protocol.md §8e
240
261
  git -C <root> commit -m "T1.1: <title>"
241
- bash <skill>/scripts/team board set T1.1 done # only mark done once it is really in the protected branch
262
+ git -C <root> worktree add --detach /tmp/review-T1.1-merged <merged-SHA> # PM prepares the merged checkout
263
+ # The same verifier resumes and runs: team review T1.1 --dir /tmp/review-T1.1-merged --branch <merged-SHA>
264
+ bash <skill>/scripts/team board set T1.1 done # only after the PM accepts that passing merged-revision evidence
242
265
  bash <skill>/scripts/team close T1.1 # close the window, clear the task
243
266
  ```
244
267
 
@@ -258,7 +281,8 @@ bash <skill>/scripts/team close T1.1 # close the window, clear the ta
258
281
  gh pr merge --squash --delete-branch <PR> # GitLab: glab mr merge <iid> --squash
259
282
  # 若 forge 合并 403(缺 Contents: write):本地 squash + push + 评论 + 关 PR
260
283
  git -C <root> fetch origin <protected-branch> && git -C <root> merge --ff-only FETCH_HEAD
261
- bash <skill>/scripts/team board set <ID> done
284
+ # PM prepares a detached checkout of the merged SHA; the same verifier resumes with --branch <merged-SHA>.
285
+ bash <skill>/scripts/team board set <ID> done # only after the PM accepts passing merged-revision evidence
262
286
  ```
263
287
 
264
288
  > The order matters: **pushing locally first makes the PR unmergeable right away** (equivalent content, different
@@ -273,15 +297,39 @@ bash <skill>/scripts/team board set <ID> done
273
297
  > **close the PR/MR instead of merging it** (the content is already in; merging afterwards would create a second,
274
298
  > empty change). The `board set <ID> done` step below is unchanged.
275
299
 
276
- When the whole change (not just this task) is done, close the spec side too — **after** the verification record
277
- exists, the code landed, the user confirmed, and **the change's own ledger is reconciled** (every box in its
278
- `tasks.md` ticked against evidence, or ticked with the reason it could not be run):
300
+ When the whole change (not just this task) is ready to close, the PM dispatches a separate archive brief to a
301
+ non-implementer worker. The brief declares the literal header `phase: archive` (`opsx-archive` is the command name,
302
+ and neither it nor `-` is the header value) and grants only the selected change/archive destination, enumerated
303
+ capability specs and the worker's report in its own worktree/task branch. It names the accepted merged baseline and
304
+ the implementation-ID execution record plus completed OpenSpec assessment; a PM acceptance stub is not a substitute.
305
+
306
+ The worker requires zero unresolved CRITICAL findings and discloses WARNING/SUGGESTION findings and every unverified
307
+ check/reason before confirmation. Confirmation is the user's, or an explicitly recorded PM proxy only for a small,
308
+ reversible change already covered by the approved approach; PM evidence acceptance alone is not confirmation.
309
+
310
+ The worker reads blockers rather than demanding pre-archive exit zero. `team change status <change>` may exit nonzero
311
+ because this archive task is active. The tool excludes only the row whose task ID equals this brief's ID. The brief's
312
+ literal `phase: archive` makes that row read as `archive`; the tool does not use the phase text to decide which row is
313
+ self. Any other task/archive row, checklist problem or unreadable output still blocks. After the accepted archive
314
+ merge, the PM closes the archive task.
279
315
 
280
316
  ```bash
281
- bash <skill>/scripts/team change status <change> # must exit 0: every task finished + no unchecked item
282
- openspec archive -y <change> # merges the deltas into openspec/specs/ and archives the change (see §0)
317
+ bash <skill>/scripts/team change status <change> # read blockers; only the exact self archive row may remain
318
+ trial_root="$(mktemp -d -p /var/tmp teamsmith-archive.XXXXXX)" # use the project's declared disk-backed root
319
+ mkdir "$trial_root/project"
320
+ cp -a openspec "$trial_root/project/openspec"
321
+ (cd "$trial_root/project" && openspec archive -y <change>)
322
+ # Inspect the complete output and resulting specs; remove only this exact private directory.
323
+ rm -rf -- "$trial_root"
324
+ openspec archive -y <change> # on the assigned worker's own branch, after every prerequisite passes
283
325
  ```
284
326
 
327
+ Native synchronization preserves each capability's existing Purpose. The stale verification Purpose is changed only
328
+ in a later, separately authorized Purpose-only documentation commit with its before/after diff, not in the native
329
+ archive commit. For dependent `alpha → beta`, the PM accepts and merges alpha's archive before preparing beta from
330
+ that new baseline. Beta's worker reconciles every complete MODIFIED block/scenario against post-alpha accepted
331
+ behavior; a missing predecessor or stale block returns for authorized correction and independent re-verification.
332
+
285
333
  ## G. Scaling up / down
286
334
 
287
335
  ```bash
@@ -293,9 +341,10 @@ bash <skill>/scripts/team teardown --all --purge --force # delete the worktree
293
341
  ```
294
342
 
295
343
  Sizing rule of thumb: **parallel agents ≈ min((RAM+free swap)/one-agent footprint, strong-model concurrency limit,
296
- the verification bandwidth you actually have)**.
297
- Memory no longer limits you so tightly (the floor is "do not fill swap"), but the PM's verification bandwidth is
298
- usually the real bottleneck — dispatching too fast just builds a queue of reports waiting to be verified.
344
+ the verifier execution capacity and PM evidence-review bandwidth you actually have)**.
345
+ Memory no longer limits you so tightly (the floor is "do not fill swap"), but verifier capacity and the PM's
346
+ evidence-review bandwidth are usually the real bottleneck — dispatching too fast just builds a queue awaiting delegated
347
+ verification and acceptance.
299
348
  Tune the estimate with `TEAM_AGENT_MEM_MB` (default 6144); `team ps` tells you directly "how many more fit".
300
349
 
301
350
  ## H. Blockers, conflicts, boundary crossings
@@ -316,7 +365,8 @@ git -C .worktrees/dev branch --show-current # task/T1.2-api-health
316
365
  git -C <root> worktree add --detach /tmp/review-T1.2 task/T1.2-api # the PM prepares an independent checkout
317
366
  bash <skill>/scripts/team review T1.2 --dir /tmp/review-T1.2 --strong # gates with a hard timeout + structural strong-verification checks
318
367
  gh pr merge --squash --delete-branch 17 && git -C <root> fetch origin main && git -C <root> merge --ff-only FETCH_HEAD
319
- bash <skill>/scripts/team board set T1.2 done # only mark done once it is confirmed in main
368
+ # PM prepares the merged-SHA checkout; the same verifier resumes with --branch <merged-SHA>.
369
+ bash <skill>/scripts/team board set T1.2 done # only after the PM accepts passing merged-revision evidence
320
370
  ```
321
371
 
322
372
  `review` **fails closed** on evidence that does not describe what it stamps: an unresolvable `--branch` (the old code
@@ -440,14 +490,17 @@ bash <skill>/scripts/team standby off # done, resume wa
440
490
 
441
491
  When it applies: there really is nothing to push forward, or a human has to step in (authorization/choice of stack/
442
492
  outside information). Going on standby loses nothing: the backlog still lands in `state/watchdog.log` and
443
- `team digest` still shows it.
493
+ `team digest` still shows it. A due PM self-Reminder is the narrow exception: it may start the built-in Pi PM
494
+ without the generic startup prompt, but ordinary backlog stays suppressed until the correlated wake. A newer
495
+ Standby generation whose ordering is ambiguous stays on. See `skills/teamsmith/references/reminders.md`.
444
496
 
445
497
  ### Why it can pick up again after a restart
446
498
 
447
499
  All progress is on disk: `state/` (model/window/worktree/task/taskfile), `docs/team/` (briefs/reports/reviews/board/
448
- threads), git branches and worktrees. When the PM is brought back it continues its original session with `pi -c` (no
449
- history lost) and receives a kick-off prompt: run `team digest` → `team inbox --ack` → `team resume --dry-run`, and
450
- then carry on.
500
+ threads), git branches and worktrees. An ordinary `team up` continues the original session with `pi -c` and receives
501
+ a kick-off prompt: run `team digest` → `team inbox --ack` → `team resume --dry-run`, and then carry on. A
502
+ Reminder-only recovery uses the same resume arguments but no kick-off prompt or ordinary backlog nudge; only its
503
+ correlated Reminder starts the work.
451
504
 
452
505
  ### Maintenance downtime / shutting it down on purpose
453
506