teamsmith 0.4.5 → 0.4.7

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 (81) hide show
  1. package/README.md +6 -6
  2. package/package.json +1 -1
  3. package/skills/teamsmith/CHANGELOG.md +37 -1
  4. package/skills/teamsmith/SKILL.md +32 -23
  5. package/skills/teamsmith/extension/team-bg.ts +12 -11
  6. package/skills/teamsmith/extension/team-inbox-watch.ts +149 -5
  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/migration.md +101 -0
  11. package/skills/teamsmith/references/openspec.md +43 -27
  12. package/skills/teamsmith/references/protocol.md +28 -18
  13. package/skills/teamsmith/references/reminders.md +133 -98
  14. package/skills/teamsmith/references/troubleshooting.md +12 -7
  15. package/skills/teamsmith/references/workflows.md +85 -34
  16. package/skills/teamsmith/scripts/lib/cmd-agents.sh +28 -5
  17. package/skills/teamsmith/scripts/lib/cmd-project.sh +100 -15
  18. package/skills/teamsmith/scripts/lib/cmd-remind.sh +135 -10
  19. package/skills/teamsmith/scripts/lib/cmd-review.sh +42 -4
  20. package/skills/teamsmith/scripts/lib/cmd-update.sh +90 -88
  21. package/skills/teamsmith/scripts/lib/cmd-watch.sh +322 -159
  22. package/skills/teamsmith/scripts/lib/common.sh +156 -26
  23. package/skills/teamsmith/scripts/panel/panel.js +182 -182
  24. package/skills/teamsmith/scripts/panel/src/data.ts +113 -6
  25. package/skills/teamsmith/scripts/panel/src/layout.ts +26 -4
  26. package/skills/teamsmith/scripts/panel/src/main.tsx +103 -14
  27. package/skills/teamsmith/scripts/remind-capability.mjs +261 -0
  28. package/skills/teamsmith/scripts/remind-store.mjs +404 -17
  29. package/skills/teamsmith/scripts/remind-tick.mjs +105 -0
  30. package/skills/teamsmith/scripts/reminder-delivery.mjs +76 -0
  31. package/skills/teamsmith/scripts/reply-capture.mjs +8 -9
  32. package/skills/teamsmith/scripts/state-authority.mjs +334 -20
  33. package/skills/teamsmith/scripts/strings/commands.tsv +3 -3
  34. package/skills/teamsmith/scripts/strings/help.en.tsv +12 -12
  35. package/skills/teamsmith/scripts/strings/help.zh.tsv +12 -12
  36. package/skills/teamsmith/scripts/team +4 -3
  37. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +13 -11
  38. package/skills/teamsmith/templates/DECISIONS.md.tmpl +2 -2
  39. package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +3 -3
  40. package/skills/teamsmith/templates/PROTOCOL.md.tmpl +19 -14
  41. package/skills/teamsmith/templates/memory-seed.md.tmpl +2 -2
  42. package/skills/teamsmith/templates/pm-prompt.md.tmpl +36 -18
  43. package/skills/teamsmith/templates/report.md.tmpl +33 -0
  44. package/skills/teamsmith/tests/bg-ledger-harness.mjs +217 -33
  45. package/skills/teamsmith/tests/bg-ledger.sh +24 -10
  46. package/skills/teamsmith/tests/checkout-shape-probe.sh +7 -6
  47. package/skills/teamsmith/tests/death-cause.sh +5 -0
  48. package/skills/teamsmith/tests/fixtures/remind-adversarial-delay.ts +27 -0
  49. package/skills/teamsmith/tests/fixtures/remind-tool-provider.ts +65 -0
  50. package/skills/teamsmith/tests/help-surface.sh +14 -151
  51. package/skills/teamsmith/tests/isolation-ledger.sh +89 -0
  52. package/skills/teamsmith/tests/key-replies-ui.sh +53 -0
  53. package/skills/teamsmith/tests/key-replies.sh +307 -106
  54. package/skills/teamsmith/tests/lib/main-team-fingerprint.sh +17 -1
  55. package/skills/teamsmith/tests/lib/routes-pages.sh +243 -0
  56. package/skills/teamsmith/tests/live-capture-probe.sh +12 -2
  57. package/skills/teamsmith/tests/loop-inventory.tsv +1 -0
  58. package/skills/teamsmith/tests/panel-b3-stub.sh +9 -2
  59. package/skills/teamsmith/tests/pulse-nudge-key.sh +5 -0
  60. package/skills/teamsmith/tests/remind-adversarial-faults.mjs +163 -0
  61. package/skills/teamsmith/tests/remind-adversarial-faults.sh +26 -0
  62. package/skills/teamsmith/tests/remind-adversarial-real.sh +27 -0
  63. package/skills/teamsmith/tests/remind-cli.sh +108 -3
  64. package/skills/teamsmith/tests/remind-delivery-node.mjs +189 -0
  65. package/skills/teamsmith/tests/remind-delivery.sh +699 -0
  66. package/skills/teamsmith/tests/remind-lifecycle.sh +197 -0
  67. package/skills/teamsmith/tests/remind-pulse.sh +199 -0
  68. package/skills/teamsmith/tests/remind-recovery-real.sh +5 -0
  69. package/skills/teamsmith/tests/remind-recovery-unit.sh +118 -0
  70. package/skills/teamsmith/tests/remind-tool-node.mjs +159 -0
  71. package/skills/teamsmith/tests/remind-tool-real.mjs +754 -0
  72. package/skills/teamsmith/tests/remind-tool-real.sh +5 -0
  73. package/skills/teamsmith/tests/reply-capture-real.mjs +93 -2
  74. package/skills/teamsmith/tests/routes.sh +213 -293
  75. package/skills/teamsmith/tests/section-paths.tsv +14 -12
  76. package/skills/teamsmith/tests/smoke.sh +876 -130
  77. package/skills/teamsmith/tests/state-authority.sh +392 -28
  78. package/skills/teamsmith/tests/team-inbox-watch-harness.mjs +58 -8
  79. package/skills/teamsmith/tests/tmux-identity-leak.sh +12 -16
  80. package/skills/teamsmith-init/SKILL.md +5 -5
  81. package/skills/teamsmith/tests/fixtures/delivery-truth-real/__pycache__/judge-second.cpython-313.pyc +0 -0
@@ -1,131 +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.
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.
6
5
 
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.
6
+ This page covers the CLI, the PM-only tool, delivery, stopped-PM recovery and operator recovery.
9
7
 
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
8
+ ## Create and inspect
40
9
 
41
10
  ```bash
42
11
  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
12
+ team remind add --at 2026-10-28T09:00:00+08:00 --message-file note.md --key morning-review --task P443
44
13
  team remind list
45
14
  team remind list --all
46
- team remind list --json
47
15
  team remind show rem-<project id>-3
48
16
  team remind cancel rem-<project id>-3
49
17
  ```
50
18
 
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.
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.
55
33
 
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).
34
+ ## Keys and repeated one-shots
59
35
 
60
- ## Time
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.
61
39
 
62
- Exactly one of the two forms:
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.
63
43
 
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.
44
+ ## Due is not queued, and queued is not a wake
69
45
 
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.
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.
72
51
 
73
- ## Keys
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.
74
56
 
75
- `--key <name>` names one logical reminder. While a live record holds the key:
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.
76
62
 
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.
63
+ ## Delivery and Standby
80
64
 
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.
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.
84
69
 
85
- ## Views
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:
86
72
 
87
- The snapshot stores phases, never views. Every read derives the view from the phase, the due instant
88
- and the clock:
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`.
89
76
 
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 |
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.
100
79
 
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.
80
+ ## A stopped PM: Reminder-only recovery
105
81
 
106
- ## Retention and the issued high-water
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.
107
87
 
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.
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.
111
92
 
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.
93
+ Recovery has explicit outcomes instead of a success message for every path:
116
94
 
117
- ## When it refuses
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.
118
103
 
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.
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`.
126
106
 
127
- ## Not in this build
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
+ ```
128
132
 
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.
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)
@@ -194,9 +214,7 @@ The four rules that make it safe (they are the extension's code, not a conventio
194
214
  1. **End the turn after starting; the completion wake-up is the normal harvest point.** The tool returns at once,
195
215
  so the turn is free: end it, and when the job finishes and you are idle you are woken once (several jobs
196
216
  finishing together arrive as one message) to run `team_bg_wait <id>`; a harvested job stays silent (its result
197
- came back inline). In-turn waiting is the bounded exception: use it only when all three hold -- the job is
198
- expected to finish within the inline-wait budget (about 2 minutes), its result blocks your immediate next step,
199
- and no other task work can advance meanwhile. A turn that ends with this session's jobs still running is
217
+ came back inline). Do not wait inside the turn: it blocks the user's input. A turn that ends with this session's jobs still running is
200
218
  **suspended on background jobs** -- a third legal ending beside **delivered** and **hard-blocked**, not a
201
219
  delivery and not a blockage, and its last line names every awaited job id.
202
220
  2. **The ledger is on disk**: `team_bg_run` appends `<ISO timestamp> start id=<id> pid=<pid>` before it returns the
@@ -210,8 +228,9 @@ The four rules that make it safe (they are the extension's code, not a conventio
210
228
  4. **A restart does not kill a job** (the process is detached), but the job table is per session: after a
211
229
  restart read `state/bg.log` and the log file instead of waiting for a wake-up.
212
230
 
213
- A worker uses the same tools (its prompt says so) — that is how a worker can run a long build without burning its
214
- 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
215
234
  ([troubleshooting.md](troubleshooting.md) §17).
216
235
 
217
236
  ### E3. Performance is a separate run (and a release step)
@@ -240,7 +259,9 @@ release checklist says (`docs/team/PUBLISH.md`).
240
259
  git -C <root> status # the main worktree must be clean and on the protected branch
241
260
  git -C <root> merge --squash <branch> # conflict handling: see protocol.md §8e
242
261
  git -C <root> commit -m "T1.1: <title>"
243
- 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
244
265
  bash <skill>/scripts/team close T1.1 # close the window, clear the task
245
266
  ```
246
267
 
@@ -260,7 +281,8 @@ bash <skill>/scripts/team close T1.1 # close the window, clear the ta
260
281
  gh pr merge --squash --delete-branch <PR> # GitLab: glab mr merge <iid> --squash
261
282
  # 若 forge 合并 403(缺 Contents: write):本地 squash + push + 评论 + 关 PR
262
283
  git -C <root> fetch origin <protected-branch> && git -C <root> merge --ff-only FETCH_HEAD
263
- 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
264
286
  ```
265
287
 
266
288
  > The order matters: **pushing locally first makes the PR unmergeable right away** (equivalent content, different
@@ -275,15 +297,39 @@ bash <skill>/scripts/team board set <ID> done
275
297
  > **close the PR/MR instead of merging it** (the content is already in; merging afterwards would create a second,
276
298
  > empty change). The `board set <ID> done` step below is unchanged.
277
299
 
278
- When the whole change (not just this task) is done, close the spec side too — **after** the verification record
279
- exists, the code landed, the user confirmed, and **the change's own ledger is reconciled** (every box in its
280
- `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.
281
315
 
282
316
  ```bash
283
- bash <skill>/scripts/team change status <change> # must exit 0: every task finished + no unchecked item
284
- 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
285
325
  ```
286
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
+
287
333
  ## G. Scaling up / down
288
334
 
289
335
  ```bash
@@ -295,9 +341,10 @@ bash <skill>/scripts/team teardown --all --purge --force # delete the worktree
295
341
  ```
296
342
 
297
343
  Sizing rule of thumb: **parallel agents ≈ min((RAM+free swap)/one-agent footprint, strong-model concurrency limit,
298
- the verification bandwidth you actually have)**.
299
- Memory no longer limits you so tightly (the floor is "do not fill swap"), but the PM's verification bandwidth is
300
- 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.
301
348
  Tune the estimate with `TEAM_AGENT_MEM_MB` (default 6144); `team ps` tells you directly "how many more fit".
302
349
 
303
350
  ## H. Blockers, conflicts, boundary crossings
@@ -318,7 +365,8 @@ git -C .worktrees/dev branch --show-current # task/T1.2-api-health
318
365
  git -C <root> worktree add --detach /tmp/review-T1.2 task/T1.2-api # the PM prepares an independent checkout
319
366
  bash <skill>/scripts/team review T1.2 --dir /tmp/review-T1.2 --strong # gates with a hard timeout + structural strong-verification checks
320
367
  gh pr merge --squash --delete-branch 17 && git -C <root> fetch origin main && git -C <root> merge --ff-only FETCH_HEAD
321
- 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
322
370
  ```
323
371
 
324
372
  `review` **fails closed** on evidence that does not describe what it stamps: an unresolvable `--branch` (the old code
@@ -442,14 +490,17 @@ bash <skill>/scripts/team standby off # done, resume wa
442
490
 
443
491
  When it applies: there really is nothing to push forward, or a human has to step in (authorization/choice of stack/
444
492
  outside information). Going on standby loses nothing: the backlog still lands in `state/watchdog.log` and
445
- `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`.
446
496
 
447
497
  ### Why it can pick up again after a restart
448
498
 
449
499
  All progress is on disk: `state/` (model/window/worktree/task/taskfile), `docs/team/` (briefs/reports/reviews/board/
450
- threads), git branches and worktrees. When the PM is brought back it continues its original session with `pi -c` (no
451
- history lost) and receives a kick-off prompt: run `team digest` → `team inbox --ack` → `team resume --dry-run`, and
452
- 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.
453
504
 
454
505
  ### Maintenance downtime / shutting it down on purpose
455
506
 
@@ -128,7 +128,7 @@ team_build_prompt() { # <agent> <ID> <taskfile-abs> <worktree> <model> [<session
128
128
  # 其它 adapter 不提:工具不存在,教了只会让 worker 白找。
129
129
  case "${TEAM_AGENT_CMD:-}" in
130
130
  ''|*'{bg_ext}'*)
131
- bg_block="$(printf '\n**Long jobs (a gate, a build)**: start them with `team_bg_run` (it returns a job id immediately and keeps\nworking while you go on), then **end your turn** -- the completion wake-up is the normal harvest point: when the\njob finishes you are woken once (several jobs finishing together arrive as one message) and harvest it with\n`team_bg_wait <id>` (the exit code and the log tail come back inline). **In-turn waiting is the bounded\nexception**: use it only when all three hold -- the job is expected to finish within the inline-wait budget (about 2 minutes),\nits result blocks your immediate next step, and no other task work can advance meanwhile.\n')" ;;
131
+ bg_block="$(printf '\n**Long jobs (a gate, a build)**: start them with `team_bg_run` (it returns a job id immediately and keeps\nworking while you go on), then **end your turn** -- the completion wake-up is the normal harvest point: when the\njob finishes you are woken once (several jobs finishing together arrive as one message) and harvest it with\n`team_bg_wait <id>` (the exit code and the log tail come back inline). Do not wait inside the turn (`sleep`, `team wait`, a blocking harvest).\n')" ;;
132
132
  esac
133
133
 
134
134
  cat <<PROMPT
@@ -675,11 +675,24 @@ team_df_raw_err() { _TEAM_DF_ERR="${_TEAM_DF_ERR}${1:-}"$'\n'; }
675
675
  team_df_lines_raw_err() { local t="${1:-}" line; [ -n "$t" ] || return 0; while IFS= read -r line; do team_df_raw_err "$line"; done <<< "$t"; }
676
676
  team_df_lines_err() { local t="${1:-}" line; [ -n "$t" ] || return 0; while IFS= read -r line; do team_df_err "$line"; done <<< "$t"; }
677
677
  team_df_lines_dim() { local t="${1:-}" line; [ -n "$t" ] || return 0; while IFS= read -r line; do team_df_dim "$line"; done <<< "$t"; }
678
+ team_df_has_block() { # <一段输出> → 0 = 里面已经有 ✗ 行(阻塞项有具体原因)
679
+ case "${1:-}" in *✗*) return 0 ;; esac
680
+ return 1
681
+ }
682
+ # P420 · 判不了就是阻塞,但不许无声:守卫 rc≠0 却一行 ✗ 都没写时,补一条点名它的阻塞行。
683
+ # 现场:某个守卫只 warn(`!`)后 return 1,report 只重放那条警告,末行却是「共 1 个阻塞项」——
684
+ # 人看得见计数、看不见是哪一项,于是只能猜。守卫名 = 传进来的第一个词(函数名)。
685
+ team_df_block_reason() { # <守卫名> <rc> → 一行 ✗(结尾有换行;由调用方写进自己的缓冲)
686
+ printf '%s✗%s %s:判不了(rc=%s),没有任何具体原因\n' "$C_RED" "$C_RESET" "${1:-?}" "${2:-?}"
687
+ }
678
688
  # 一个守卫跑一趟:_TEAM_DF_RUN_RC = 这次守卫的 rc(driver 据此判「前提缺失 → 判不了」,不冒充查过)。
679
689
  team_df_run() { # <守卫函数> [参数…]
680
690
  _TEAM_DF_ERR=""; _TEAM_DF_OUT=""
681
691
  local rc=0; "$@" || rc=$?
682
692
  _TEAM_DF_RUN_RC="$rc"
693
+ if [ "$rc" -ne 0 ] && ! team_df_has_block "$_TEAM_DF_ERR"; then
694
+ _TEAM_DF_ERR="${_TEAM_DF_ERR}$(team_df_block_reason "${1:-?}" "$rc")"$'\n'
695
+ fi
683
696
  if [ "$rc" -eq 0 ]; then _TEAM_DF_NOTES+=("$_TEAM_DF_ERR"$'\x1f'"$_TEAM_DF_OUT")
684
697
  else _TEAM_DF_BLOCKS+=("$_TEAM_DF_ERR"$'\x1f'"$_TEAM_DF_OUT"); _TEAM_DF_N=$((_TEAM_DF_N + 1)); fi
685
698
  return 0
@@ -691,6 +704,10 @@ team_df_run_lib() { # <函数> [参数…]
691
704
  local rc=0 out=""
692
705
  out="$("$@" 2>&1)" || rc=$?
693
706
  _TEAM_DF_RUN_RC="$rc"
707
+ # P420 · 同上:库守卫非 0 却没有 ✗ 行时补一条,report 里必须点得出是哪一项。
708
+ if [ "$rc" -ne 0 ] && ! team_df_has_block "$out"; then
709
+ out="${out}$(team_df_block_reason "${1:-?}" "$rc")"$'\n'
710
+ fi
694
711
  [ -n "$out" ] && out="$out"$'\n'
695
712
  if [ "$rc" -eq 0 ]; then _TEAM_DF_NOTES+=("$out"$'\x1f'"")
696
713
  else _TEAM_DF_BLOCKS+=("$out"$'\x1f'""); _TEAM_DF_N=$((_TEAM_DF_N + 1)); fi
@@ -1746,13 +1763,14 @@ team_inbox_append() { # <agent> <tag> <msg> [<sender>]
1746
1763
  # 明细记录数;明细写失败 → 本事件不合并、行带 `detail=unavailable`、日志点名,该行也不做锚;
1747
1764
  # ④ 只有 [auto*] 类行参与合并与明细;[manual]/[draft]/[nudge]/pulse 行原样追加。
1748
1765
 
1749
- # 行 → 合并键(seat|class|task|awaiting)。非 [auto*] 类 / 解析不成立 → rc 1(调用方按「不可合并」处理)。
1766
+ # 行 → 合并键(seat|class|task|awaiting|delivered-tip)。非 [auto*] 类 / 解析不成立 → rc 1。
1750
1767
  # awaiting 是**集合**(去重、排序;缺字段与空集是两个不同的值);task 取 task= 戳里的 ID,否则取
1751
- # agent 后的第一个 <ID> token;branch/tip/uncommitted 不进键(它们只更新显示值)。
1768
+ # agent 后的第一个 <ID> token。只有 delivered 用十二位 tip 分量区分修订;无戳发送者用统一的 NOREV,
1769
+ # suspended/interrupted 用空标记,所以它们的跨 tip 进度仍合并。branch/uncommitted 只更新显示值。
1752
1770
  team_notify_line_key() {
1753
1771
  local body="$1"
1754
1772
  case "$body" in '- '*) body="${body#- }" ;; esac
1755
- local iso rest tag class seat fields aw nrm t
1773
+ local iso rest tag class seat fields aw nrm t rev
1756
1774
  iso="${body%% *}"
1757
1775
  case "$iso" in ''|*[!0-9TZ:.-]*) return 1 ;; esac
1758
1776
  rest="${body#"$iso" }"
@@ -1794,7 +1812,12 @@ team_notify_line_key() {
1794
1812
  t="${t%% *}"
1795
1813
  fi
1796
1814
  [ -n "$t" ] || t='?'
1797
- printf '%s|%s|%s|%s\n' "$seat" "$class" "$t" "$nrm"
1815
+ rev='-'
1816
+ if [ "$class" = delivered ]; then
1817
+ rev='NOREV'
1818
+ if [[ "$fields" =~ tip=([0-9a-f]{12})([[:space:]]|$) ]]; then rev="T:${BASH_REMATCH[1]}"; fi
1819
+ fi
1820
+ printf '%s|%s|%s|%s|%s\n' "$seat" "$class" "$t" "$nrm" "$rev"
1798
1821
  }
1799
1822
 
1800
1823
  # 尾行能不能当锚:带 detail=unavailable 的行不是锚(否则下一次成功的事件会把它抹掉,缺口就不可见了)。