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
@@ -30,8 +30,9 @@ If the pulse restarted you: read the tail of `{{DOCS_DIR}}/../.pi/team/state/wat
30
30
 
31
31
  ## Your creed (on demand: `{{SKILL_DIR}}/references/philosophy.md`)
32
32
 
33
- A report is a claim and your own verification is the evidence; a false green is worse than nothing; disk beats memory
34
- (you will be restarted), so progress lands in the ledger, never only in the conversation.
33
+ A report is a claim and the assigned non-implementer verifier's execution is the evidence; your acceptance is a separate
34
+ review of that evidence and the diff. A false green is worse than nothing; disk beats memory (you will be restarted), so
35
+ progress lands in the ledger, never only in the conversation.
35
36
 
36
37
  ## What you write to the user
37
38
 
@@ -75,21 +76,33 @@ recovery entry only -- never the daily default. See `{{SKILL_DIR}}/references/pr
75
76
 
76
77
  ## Your loop
77
78
 
79
+ Follow **PM — proceed within authorization** under **Roles and reading order** in `AGENTS.md`.
80
+
78
81
  Specs live in OpenSpec: a brief names the change id and the scenarios it must satisfy; `openspec validate --all
79
- --strict` before dispatching, and `openspec archive -y <change>` only after the code landed and the review record
80
- exists (`{{SKILL_DIR}}/references/openspec.md`).
82
+ --strict` before dispatching. After the same verifier accepts the merged revision and valid confirmation is recorded,
83
+ dispatch a non-implementer worker to run `openspec archive -y <change>` on its own authorized task branch
84
+ (`{{SKILL_DIR}}/references/openspec.md`).
81
85
 
82
86
  1. **Model it**: `team status` / `team board ls`, and `{{DOCS_DIR}}/ROADMAP.md`.
83
87
  2. **Dispatch**: write a self-contained brief (context / deliverables / boundaries / copy-pasteable acceptance
84
88
  commands), then `team dispatch <agent> <ID> <taskfile>`; check `team ps` first when capacity is tight.
85
- 3. **Wait for notifications**: a worker's turn end appends to the inbox and knocks on this window. Do not poll their
86
- screens.
87
- 4. **Verify**: `team review <ID> --dir <independent checkout>` (gates + reading the diff). **The agent's report is a
88
- claim; your verification is the evidence.** Whether to resume a stopped agent (its `pi` exited) is your call:
89
- `team resume --dry-run`, then `team resume`.
89
+ 3. **Wait with notifications first and files as the authority**: a worker's turn end appends to the inbox and
90
+ knocks on this window. Before repeating an unchanged waiting report, reconcile `team digest`, BOARD, the
91
+ task-branch report and the task worktree's `git log`/`status`. Read a committed report without switching
92
+ branches: `git show <task-branch>:{{DOCS_DIR}}/reports/<ID>-<agent>.md`; an uncommitted report is a draft.
93
+ An old tip, no new notice or a merged line does not prove unfinished work. A committed final report enters the
94
+ existing acceptance route; a live job without one stays on the wait/harvest route. Do not poll agent screens
95
+ or rerun the assigned non-implementer verifier's acceptance tests yourself.
96
+ 4. **Delegate verification**: prepare a clean detached checkout, then dispatch a non-implementer verifier to run
97
+ `team review <ID> --dir <independent checkout>`. The tool writes only the brief-named central review record/log;
98
+ the verifier keeps its own report on its branch. **The agent's report is a claim; the verifier's execution is the
99
+ evidence; your evidence/diff review is acceptance, not another gate run.** Whether to resume a stopped agent (its
100
+ `pi` exited) is your call: `team resume --dry-run`, then `team resume`.
90
101
  5. **Merge / wrap up** (git and forge are yours): `git -C <root> merge --squash <branch>` + commit + push (with a
91
- PR/MR, merge it first and then `fetch && merge --ff-only`) -> `team board set <ID> done` -> `team close <ID>`.
92
- Mark `done` only when the work really landed on the protected branch: `blocked` beats a pretty status. On failure:
102
+ PR/MR, merge it first and then `fetch && merge --ff-only`) -> resume the same verifier on a clean checkout pinned
103
+ to the merged SHA -> accept its passing gates and OpenSpec assessment -> `team board set <ID> done` -> `team close <ID>`.
104
+ `team review --post-merge` is inspection only and never substitutes for that verifier run. Mark `done` only after
105
+ accepted merged-revision evidence: `blocked` beats a pretty status. On failure:
93
106
  `team thread <agent> "<failure evidence>"` + `team say <agent> "<one-line instruction>"`.
94
107
  6. **Report**: the code with its short name, the conclusion, where the evidence is, the risks and the next step;
95
108
  decisions with their rationale and impact in `{{DOCS_DIR}}/DECISIONS.md`. With magic-context, durable rules go to
@@ -97,13 +110,14 @@ exists (`{{SKILL_DIR}}/references/openspec.md`).
97
110
 
98
111
  **Background jobs and turn endings.** A turn ends in one of three states: **delivered**, **hard-blocked** (blocked on
99
112
  a human: record it and stand down), or **suspended on background jobs** with every awaited id named on its last line.
100
- Do not run long work in your own session — not a full gate, not a long test matrix, not a bulk refactor. A seat
101
- does that work, or `team_bg_run` does it in the background; your session does routing, judgement and acceptance.
102
- Guidance, not a limit: nothing stops you, but a busy PM cannot answer the user and cannot be steered.
113
+ Do not run long work in your own session — not a full gate, not a long test matrix, not a bulk refactor. Verification
114
+ and archive execution belong to their assigned non-implementer workers; moving either into a PM-owned `team_bg_run`
115
+ does not satisfy delegation. Your session does routing, judgement, evidence review and acceptance; `team_bg_run`
116
+ remains available for unrelated authorized work. A busy PM cannot answer the user and cannot be steered.
103
117
 
104
- Long commands run in the background -- the full gate, a container gate, a mutation matrix, a project build, a long
105
- test suite. Do not wait inline (`sleep`, `team wait`, a blocking harvest): end the turn and come back on the
106
- completion wake-up or a reminder.
118
+ A verifier runs its long gates in its own background lane; other long authorized commands also run in the background.
119
+ Do not wait inline (`sleep`, `team wait`, a blocking harvest): end the turn and come back on the completion wake-up or
120
+ a reminder.
107
121
 
108
122
  `team_bg_run` starts a long job (a gate, a build) and you **let the turn end**; the completion wake-up is the normal
109
123
  harvest point, and `team_bg_wait <id>` then brings back the exit code and the log tail. Harvest after the wake rather
@@ -137,10 +151,11 @@ does not fit; a model change for a running task is an explicit `--fresh` launch,
137
151
  own model changes only through `team up --fresh-pm`. Disk beats memory across a fresh takeover: brief, report, thread
138
152
  and `state/` carry the work, never a session.
139
153
 
140
- Four operations are **separate recorded gates**, each previewed and authorized per command: private source
141
- verification; landing validated source on a shared/protected tree; writing this project's configuration (and the first
142
- fresh launch that reads it); and adopting a changed shared skill/copy source -- a shared link reads its target's
143
- current bytes, so changing that target can affect other readers without any installer.
154
+ For a Teamsmith tool-source upgrade, keep four separate recorded gates: private source verification; landing
155
+ validated source on a shared/protected tree; writing this project's configuration and the first fresh PM launch that
156
+ reads it; and adopting a changed shared skill/copy source. Preview the exact command and obtain authorization for each
157
+ command, including both the configuration write and the first fresh launch. A shared link reads its target's current
158
+ bytes, so changing that target can affect other readers without any installer.
144
159
 
145
160
  ## Boundaries
146
161
 
@@ -148,10 +163,11 @@ current bytes, so changing that target can affect other readers without any inst
148
163
  not read other people's session files, do not message windows in other tmux sessions (the CLI rejects cross-session
149
164
  `say`/`notify`). Communication with other projects or PMs goes through the user or `team meeting`; register new or
150
165
  temporary windows with `team add-agent` instead of creating them by hand.
151
- - **Do not implement yourself** (except small fixes found during verification); your output is briefs, verification,
152
- merges and decisions. The protected branch `{{PROTECTED_BRANCH}}` is yours to advance; agents may only push their own
153
- task branches. Changing shared/remote state (push, merge, PR/MR, issue) needs explicit user authorization: pass
154
- `--yes`.
166
+ - **Do not implement yourself** (except small fixes found during evidence review); your output is briefs, evidence
167
+ acceptance, merges and decisions, not verification or archive execution. The protected branch `{{PROTECTED_BRANCH}}` is yours to advance; agents may only push their own
168
+ task branches. Changing shared/remote state (push, merge, PR/MR, issue) needs explicit user authorization. Where a
169
+ `team` command requires `--yes`, it expresses authorization already given; it does not grant authorization or apply
170
+ to direct git/forge writes.
155
171
  - The pulse is yours to run: `team pulse up` / `status` / `logs` / `down`; it checks for work every 15 minutes and only
156
172
  wakes you when there is some.
157
173
  - Keep the team alive: you yourself may be restarted by the pulse, so **all progress must land on disk** (reports,
@@ -9,6 +9,39 @@ branch: `{{BRANCH}}` PR/MR: <link or ->
9
9
  |---|---|
10
10
  | `<file>` | <what was done> |
11
11
 
12
+ ## OpenSpec assessment
13
+
14
+ For `opsx-verify`, follow the generated `.pi/skills/openspec-verify-change/SKILL.md` when present; otherwise perform
15
+ the documented equivalent review and disclose that limitation. A shell-gate PASS does not complete this assessment.
16
+ Use `N/A — <reason>` only for a genuinely non-OpenSpec task; empty placeholders are not evidence.
17
+
18
+ | Dimension | Score | Evidence |
19
+ |---|---|---|
20
+ | Completeness | <score> | <implemented tasks and requirement coverage> |
21
+ | Correctness | <score> | <requirement/scenario and red-green evidence> |
22
+ | Coherence | <score> | <design consistency and integration evidence> |
23
+
24
+ ## CRITICAL
25
+
26
+ - <Incomplete tasks, missing requirement implementations, removed requirements still implemented, or renamed behavior
27
+ no longer present; give a concrete recommendation. Write `None` only after checking.>
28
+
29
+ ## WARNING
30
+
31
+ - <Spec/design divergence or missing scenario coverage, with a recommendation; otherwise `None`.>
32
+
33
+ ## SUGGESTION
34
+
35
+ - <Pattern inconsistency or minor improvement; otherwise `None`.>
36
+
37
+ ## Final assessment
38
+
39
+ - Counts: CRITICAL <n> · WARNING <n> · SUGGESTION <n>.
40
+ - Readiness: <unresolved CRITICAL = fix before archive; otherwise state readiness only within the checks actually
41
+ completed, with noted improvements>.
42
+ - Unverified applicable checks and reasons: <every skipped/partial check and why; these prohibit an unqualified
43
+ readiness claim and must not be described as passed. Write `None` only when every applicable check ran.>
44
+
12
45
  ## Verification evidence (must have actually been run)
13
46
 
14
47
  ```
@@ -89,8 +89,8 @@ const newBgHost = mod => {
89
89
  }
90
90
  const makeRunner = (host, cwd) => {
91
91
  const ctx = { cwd }
92
- const run = async (command, name) => {
93
- const res = await host.tools.team_bg_run.execute('call-run', { command, name }, null, null, ctx)
92
+ const run = async (command, name, options = {}) => {
93
+ const res = await host.tools.team_bg_run.execute('call-run', { command, name, ...options }, null, null, ctx)
94
94
  const id = String(res?.details?.id ?? '')
95
95
  const pid = Number(res?.details?.pid ?? 0)
96
96
  trackPid(pid)
@@ -161,10 +161,12 @@ const procStartTime = pid => {
161
161
  }
162
162
 
163
163
  /** 写一条 `state/bg/<id>.job` 记录(与 team-bg 的记录同形状)。 */
164
- const writeRecord = (bgDir, id, { pid, pgid = pid, start, cwd = '', log = '', cmd = 'fixture' }) => {
164
+ const writeRecord = (bgDir, id, { pid, pgid = pid, start, sessionCwd, cwd = '', log = '', cmd = 'fixture' }) => {
165
165
  mkdirSync(bgDir, { recursive: true })
166
+ const initiator = sessionCwd === undefined ? [] : [`session_cwd=${sessionCwd}`]
166
167
  writeFileSync(join(bgDir, `${id}.job`),
167
- `id=${id}\npid=${pid}\npgid=${pgid}\nstart=${start}\ncwd=${cwd}\nlog=${log}\ncmd=${cmd}\n`)
168
+ [`id=${id}`, `pid=${pid}`, `pgid=${pgid}`, `start=${start}`, ...initiator,
169
+ `cwd=${cwd}`, `log=${log}`, `cmd=${cmd}`, ''].join('\n'))
168
170
  }
169
171
  const spawnSleep = (seconds) => {
170
172
  const child = spawn('sleep', [String(seconds)], { stdio: 'ignore' })
@@ -256,6 +258,10 @@ const groupLedger = async () => {
256
258
  !!startLine && new RegExp(` start id=${escapeRe(j1.id)} pid=${j1.pid}$`).test(startLine) &&
257
259
  existsSync(join(STATE, 'bg', `${j1.id}.job`)),
258
260
  startLine || '(no start line)')
261
+ const defaultRecord = readFileSync(join(STATE, 'bg', `${j1.id}.job`), 'utf8')
262
+ check('ledger: a default-cwd job records the same initiating and execution directory',
263
+ defaultRecord.includes(`session_cwd=${ROOT}\n`) && defaultRecord.includes(`cwd=${ROOT}\n`),
264
+ defaultRecord.replace(/\n/g, ' | '))
259
265
  await R.wait(j1.id, 5000)
260
266
 
261
267
  // ② 原地收割:wait 行量的是这次调用(≈ 作业运行时长)
@@ -527,11 +533,9 @@ const groupSuspendShape = async () => {
527
533
  await bgHost.emit('session_shutdown', { reason: 'fixture' }, { cwd: ROOT })
528
534
  }
529
535
 
530
- // ── owner-scope:挂起判定只认**本会话自己的**作业(P236)────────────────────────
531
- // 缺陷现场(2026-10-12 真实运行):两个席位共享同一个车道 state 目录,dev 的作业躺在里面,
532
- // dev2 结束回合时被打上 awaiting=<dev 的作业>。归属判据 = 记录里的 cwd(作业启动时的工作目录,
533
- // 也就是拥有它的那个席位的工作树)与本会话自己的工作树/cwd 解析到同一个真实路径;别人的记录、
534
- // 缺 cwd / 相对 cwd / 解析不出来的畸形记录一律不算(fail-closed)。
536
+ // ── owner-scope:挂起判定只认**本会话发起的**作业 ────────────────────────────────
537
+ // 新记录的 session_cwd 与执行 cwd 分开:独立 clone 不丢发起身份,显式外来身份也不回退到 cwd。
538
+ // 旧记录仅在 cwd 恰好等于席位工作树时兼容;别人的、子目录的、独立 clone 与无效路径都不收养。
535
539
  const groupOwnerScope = async () => {
536
540
  const bgMod = await loadModule(BG)
537
541
  const bgHost = newBgHost(bgMod)
@@ -577,9 +581,10 @@ const groupOwnerScope = async () => {
577
581
  }
578
582
  }
579
583
 
580
- // ③ 活 pid 的畸形记录:缺 cwd / 相对 cwd / 解析不出来的 cwd → 都不判挂起(fail-closed)
584
+ // ③ 活 pid 也不能补猜身份:legacy 坏 cwd,以及显式空/相对/失效/他人 session_cwd 都不挂起。
585
+ // 显式 session_cwd 的记录故意把执行 cwd 写成本席位,证明不会回退到执行目录。
581
586
  {
582
- const b = makeBase('owner-nocwd')
587
+ const b = makeBase('owner-nocwd', { seats: ['dev', 'dev2'] })
583
588
  const sleeper = spawnSleep(30)
584
589
  const start = procStartTime(sleeper.pid)
585
590
  const bgDir = join(b.state, 'bg')
@@ -588,8 +593,12 @@ const groupOwnerScope = async () => {
588
593
  `id=bg-ledger-nocwd\npid=${sleeper.pid}\npgid=${sleeper.pid}\nstart=${start}\nlog=\ncmd=fixture\n`)
589
594
  writeRecord(bgDir, 'bg-ledger-relcwd', { pid: sleeper.pid, pgid: sleeper.pid, start, cwd: '.worktrees/dev' })
590
595
  writeRecord(bgDir, 'bg-ledger-gonecwd', { pid: sleeper.pid, pgid: sleeper.pid, start, cwd: '/nonexistent/p236/worktree' })
596
+ for (const [id, sessionCwd] of [
597
+ ['bg-ledger-empty-initiator', ''], ['bg-ledger-relative-initiator', '.worktrees/dev'],
598
+ ['bg-ledger-gone-initiator', '/nonexistent/p449/initiator'], ['bg-ledger-foreign-initiator', b.wts.dev2],
599
+ ]) writeRecord(bgDir, id, { pid: sleeper.pid, pgid: sleeper.pid, start, sessionCwd, cwd: b.wt })
591
600
  resetNotify(b.base)
592
- await notify.settle(b.wt, 'stop', 'BG-LEDGER-NOCWD records without an owning cwd must not suspend')
601
+ await notify.settle(b.wt, 'stop', 'BG-LEDGER-NOCWD records without an owning initiator must not suspend')
593
602
  const line = inboxLine(b.base)
594
603
  check('owner-scope: a live record with a missing, relative or unresolvable cwd does not suspend (fail-closed)',
595
604
  line.includes('[auto] ') && !line.includes('awaiting=') && line.includes('⚠ 未提交'),
@@ -597,20 +606,29 @@ const groupOwnerScope = async () => {
597
606
  try { process.kill(sleeper.pid, 'SIGKILL') } catch { /* ignore */ }
598
607
  }
599
608
 
600
- // ④ 软链 + 尾斜杠:记录里的 cwd 文本不同、真实路径相同 → 仍然是本会话的作业(挂起)
609
+ // ④ legacy 只接受恰好等于席位工作树的 cwd(软链/尾斜杠归一);其余形状一律无归属。
601
610
  {
602
- const b = makeBase('owner-realpath')
611
+ const b = makeBase('owner-realpath', { seats: ['dev', 'dev2'] })
603
612
  const sleeper = spawnSleep(30)
613
+ const start = procStartTime(sleeper.pid)
604
614
  const link = join(b.base, 'link-to-dev')
615
+ const subdir = join(b.wt, 'nested')
616
+ const independent = join(SCRATCH, 'legacy-independent')
617
+ rmSync(independent, { recursive: true, force: true })
618
+ mkdirSync(subdir, { recursive: true })
605
619
  symlinkSync(b.wt, link)
606
- writeRecord(join(b.state, 'bg'), 'bg-ledger-symlink', {
607
- pid: sleeper.pid, pgid: sleeper.pid, start: procStartTime(sleeper.pid), cwd: `${link}/`,
608
- })
620
+ git(['clone', '-q', '--no-local', b.base, independent], SCRATCH)
621
+ const bgDir = join(b.state, 'bg')
622
+ writeRecord(bgDir, 'bg-ledger-symlink', { pid: sleeper.pid, pgid: sleeper.pid, start, cwd: `${link}/` })
623
+ writeRecord(bgDir, 'bg-legacy-subdir', { pid: sleeper.pid, pgid: sleeper.pid, start, cwd: subdir })
624
+ writeRecord(bgDir, 'bg-legacy-independent', { pid: sleeper.pid, pgid: sleeper.pid, start, cwd: independent })
625
+ writeRecord(bgDir, 'bg-legacy-other-seat', { pid: sleeper.pid, pgid: sleeper.pid, start, cwd: b.wts.dev2 })
609
626
  resetNotify(b.base)
610
- await notify.settle(b.wt, 'stop', 'BG-LEDGER-REALPATH symlink and trailing slash resolve to the seat worktree')
627
+ await notify.settle(b.wt, 'stop', 'BG-LEDGER-REALPATH only an exact legacy worktree match is owned')
611
628
  const line = inboxLine(b.base)
612
- check('owner-scope: a job cwd reaching the session worktree through a symlink still belongs to it',
613
- line.includes('[auto·suspended]') && line.includes('awaiting=bg-ledger-symlink'),
629
+ check('owner-scope: legacy ownership accepts only an exact seat-worktree match',
630
+ line.includes('[auto·suspended]') && line.includes('awaiting=bg-ledger-symlink') &&
631
+ !line.includes('bg-legacy-subdir') && !line.includes('bg-legacy-independent') && !line.includes('bg-legacy-other-seat'),
614
632
  line || '(no inbox line)')
615
633
  try { process.kill(sleeper.pid, 'SIGKILL') } catch { /* ignore */ }
616
634
  }
@@ -629,6 +647,52 @@ const groupOwnerScope = async () => {
629
647
  line || '(no inbox line)')
630
648
  }
631
649
 
650
+ // ⑥ 独立执行 clone:发起身份仍属于 dev;挂起不敲,最终报告的新 delivered tip 恰好敲一次。
651
+ {
652
+ const b = makeBase('owner-independent', { seats: ['dev', 'dev2'] })
653
+ taskProof(b.base, 'dev', 'P230')
654
+ const independent = join(SCRATCH, 'owner-independent-checkout')
655
+ rmSync(independent, { recursive: true, force: true })
656
+ git(['clone', '-q', '--no-local', b.base, independent], SCRATCH)
657
+ const R = makeRunner(bgHost, b.wt)
658
+ const job = await R.run('sleep 30', jobName('independent-final'), { cwd: independent })
659
+ const record = readFileSync(join(b.state, 'bg', `${job.id}.job`), 'utf8')
660
+ check('owner-scope: a job record separates its initiating session from its execution directory',
661
+ record.includes(`session_cwd=${b.wt}\n`) && record.includes(`cwd=${independent}\n`) &&
662
+ record.includes(`pid=${job.pid}\n`) && /start=\d+\n/.test(record) && record.includes(`log=${job.log}\n`),
663
+ record.replace(/\n/g, ' | '))
664
+ const prevPane = process.env.TMUX_PANE
665
+ process.env.TMUX_PANE = 'p449-independent-pane'
666
+ try {
667
+ resetNotify(b.base)
668
+ const k0 = knockEntries(b.base)
669
+ await notify.settle(b.wt, 'stop', 'P449 independent clone suspended progress')
670
+ const suspended = inboxLine(b.base)
671
+ const k1 = knockEntries(b.base)
672
+ await notify.settle(b.wts.dev2, 'stop', 'P449 another seat does not adopt the independent job')
673
+ const other = inboxLine(b.base, 'dev2')
674
+ const k2 = knockEntries(b.base)
675
+ await R.stop(job)
676
+ mkdirSync(join(b.wt, 'docs/team/reports'), { recursive: true })
677
+ writeFileSync(join(b.wt, 'docs/team/reports/P230-dev.md'), '# P230\n\nstatus: delivered\n')
678
+ git(['add', 'docs/team/reports/P230-dev.md'], b.wt)
679
+ git(['-c', 'user.email=fixture@teamsmith', '-c', 'user.name=fixture', 'commit', '-qm', 'final report'], b.wt)
680
+ await notify.settle(b.wt, 'stop', 'P449 independent clone final report delivered')
681
+ const lines = inboxAll(b.base)
682
+ const pointers = inboxAll(b.base, 'pm').filter(l => l.includes('agent:dev '))
683
+ const k3 = knockEntries(b.base)
684
+ check('owner-scope: an independent-checkout job becomes one final delivery wake',
685
+ suspended.includes('[auto·suspended]') && suspended.includes(`awaiting=${job.id}`) && k1 === k0 &&
686
+ other.includes('[auto] ') && !other.includes('awaiting=') && !other.includes(job.id) &&
687
+ lines.length === 2 && lines[0] === suspended && lines[1].includes('[auto] ') &&
688
+ tipOfLine(lines[0]) !== tipOfLine(lines[1]) && pointers.length === 2 && k3 === k2 + 1,
689
+ `knocks=${k0},${k1},${k2},${k3} lines=${lines.length} pointers=${pointers.length} :: ${lines.join(' || ')}`)
690
+ } finally {
691
+ if (prevPane === undefined) delete process.env.TMUX_PANE
692
+ else process.env.TMUX_PANE = prevPane
693
+ }
694
+ }
695
+
632
696
  // 收尾:只按登记过的作业停(kill + 收割),然后清掉扩展的会话资源
633
697
  for (const [R, job] of jobs) await R.stop(job)
634
698
  await bgHost.emit('session_shutdown', { reason: 'fixture' }, { cwd: ROOT })
@@ -728,27 +792,69 @@ const groupMerge = async () => {
728
792
  dl.join(' | ').slice(0, 200))
729
793
  }
730
794
 
731
- // ② 汇总行取**最后一条**的值(uncommitted/tip/last);取最大值、平均或第一条的值都在这里变红
795
+ // ② 非交付类不按 tip 拆行:suspended 三次跨 tip 仍 ×3,interrupted 两次跨 tip 仍 ×2;
796
+ // 汇总行始终取最后事件的 uncommitted/tip/last。
732
797
  {
733
798
  const b = makeBase('merge-last')
734
799
  taskProof(b.base, 'dev', 'P230')
735
800
  resetNotify(b.base)
801
+ const pid = liveRecord(b.base, 'JLAST', b.wt)
736
802
  for (const f of ['w2.txt', 'w3.txt', 'w4.txt']) writeFileSync(join(b.wt, f), 'x\n')
737
- await notify.settle(b.wt, 'stop', 'MERGE-LAST one')
803
+ await notify.settle(b.wt, 'stop', 'MERGE-LAST suspended one')
738
804
  const rec1 = detailRecs(b.base).at(-1) ?? ''
739
805
  git(['add', '-A'], b.wt)
740
806
  git(['-c', 'user.email=fixture@teamsmith', '-c', 'user.name=fixture', 'commit', '-qm', 'merge-last one'], b.wt)
741
807
  writeFileSync(join(b.wt, 'w5.txt'), 'x\n')
742
- await notify.settle(b.wt, 'stop', 'MERGE-LAST two')
808
+ await notify.settle(b.wt, 'stop', 'MERGE-LAST suspended two')
743
809
  rmSync(join(b.wt, 'w5.txt'), { force: true })
744
- await notify.settle(b.wt, 'stop', 'MERGE-LAST three')
810
+ await notify.settle(b.wt, 'stop', 'MERGE-LAST suspended three')
745
811
  const rec3 = detailRecs(b.base).at(-1) ?? ''
746
- const line = inboxAll(b.base)[0] ?? ''
747
- const tip1 = tipOfLine(rec1); const tip3 = tipOfLine(rec3)
812
+ await notify.settle(b.wt, 'aborted', 'MERGE-LAST interrupted one')
813
+ writeFileSync(join(b.wt, 'w6.txt'), 'x\n')
814
+ git(['add', '-A'], b.wt)
815
+ git(['-c', 'user.email=fixture@teamsmith', '-c', 'user.name=fixture', 'commit', '-qm', 'merge-last two'], b.wt)
816
+ await notify.settle(b.wt, 'aborted', 'MERGE-LAST interrupted two')
817
+ const rec5 = detailRecs(b.base).at(-1) ?? ''
818
+ const lines = inboxAll(b.base)
819
+ const line = lines[0] ?? ''
820
+ const interrupted = lines[1] ?? ''
821
+ const tip1 = tipOfLine(rec1); const tip3 = tipOfLine(rec3); const tip5 = tipOfLine(rec5)
748
822
  check('merge: the merged line carries the last event’s values',
749
- tip1 !== '' && tip3 !== '' && tip1 !== tip3 && /uncommitted=0( |·)/.test(line) && line.includes(`tip=${tip3}`) &&
750
- !line.includes(`tip=${tip1}`) && /last=(\S+)/.exec(line)?.[1] === isoOfLine(rec3) && line.includes('×3'),
751
- `tip1=${tip1} tip3=${tip3} :: ${line}`)
823
+ tip1 !== '' && tip3 !== '' && tip5 !== '' && tip1 !== tip3 && tip3 !== tip5 && lines.length === 2 &&
824
+ line.includes('[auto·suspended]') && /uncommitted=0( |·)/.test(line) && line.includes(`tip=${tip3}`) &&
825
+ !line.includes(`tip=${tip1}`) && /last=(\S+)/.exec(line)?.[1] === isoOfLine(rec3) && line.includes('×3') &&
826
+ interrupted.includes('[auto·interrupted]') && interrupted.includes('×2') && interrupted.includes(`tip=${tip5}`) &&
827
+ detailRecs(b.base).length === 5,
828
+ `tip1=${tip1} tip3=${tip3} tip5=${tip5} :: ${lines.join(' || ')}`)
829
+ killPid(pid); dropRecord(b.base, 'JLAST')
830
+ }
831
+
832
+ // ②b delivered 才按修订拆行:三个 tip 三行,同 tip 的后续事件只扩展自己的那一行。
833
+ {
834
+ const b = makeBase('merge-revisions')
835
+ taskProof(b.base, 'dev', 'P230')
836
+ resetNotify(b.base)
837
+ await notify.settle(b.wt, 'stop', 'MERGE-REVISIONS delivered one')
838
+ const tip1 = tipOfLine(detailRecs(b.base).at(-1) ?? '')
839
+ writeFileSync(join(b.wt, 'revision-2.txt'), 'two\n')
840
+ git(['add', '-A'], b.wt)
841
+ git(['-c', 'user.email=fixture@teamsmith', '-c', 'user.name=fixture', 'commit', '-qm', 'revision two'], b.wt)
842
+ await notify.settle(b.wt, 'stop', 'MERGE-REVISIONS delivered two')
843
+ await notify.settle(b.wt, 'stop', 'MERGE-REVISIONS same tip churn')
844
+ const tip2 = tipOfLine(detailRecs(b.base).at(-1) ?? '')
845
+ writeFileSync(join(b.wt, 'revision-3.txt'), 'three\n')
846
+ git(['add', '-A'], b.wt)
847
+ git(['-c', 'user.email=fixture@teamsmith', '-c', 'user.name=fixture', 'commit', '-qm', 'revision three'], b.wt)
848
+ await notify.settle(b.wt, 'stop', 'MERGE-REVISIONS delivered three')
849
+ const tip3 = tipOfLine(detailRecs(b.base).at(-1) ?? '')
850
+ const lines = inboxAll(b.base)
851
+ const pointers = inboxAll(b.base, 'pm')
852
+ check('merge: each delivered revision starts a new line and same-tip events merge',
853
+ lines.length === 3 && pointers.length === 3 && new Set([tip1, tip2, tip3]).size === 3 &&
854
+ !lines[0].includes('×') && lines[1].includes('×2') && !lines[2].includes('×') &&
855
+ lines[0].includes(`tip=${tip1}`) && lines[1].includes(`tip=${tip2}`) && lines[2].includes(`tip=${tip3}`) &&
856
+ detailRecs(b.base).length === 4,
857
+ `tips=${tip1},${tip2},${tip3} lines=${lines.length} pointers=${pointers.length} :: ${lines.join(' || ')}`)
752
858
  }
753
859
 
754
860
  // ③ 状态类变化必然新起一行(两个同 awaiting 的 suspended 不跨过 delivered 合并)
@@ -873,16 +979,17 @@ const groupMerge = async () => {
873
979
  `before=${before} after=${after} :: pm=${pmLine} || dev=${recLine}`)
874
980
  }
875
981
 
876
- // ⑩ 陈旧判据在合并行上读最后一条的 tip(更早的事件从明细里判)
982
+ // ⑩ 陈旧判据在 suspended 合并行上读最后一条的 tip(更早的事件从明细里判)。
877
983
  {
878
984
  const b = makeBase('merge-stale')
879
985
  taskProof(b.base, 'dev', 'P230')
880
986
  resetNotify(b.base)
881
- await notify.settle(b.wt, 'stop', 'MERGE-STALE one')
987
+ const pid = liveRecord(b.base, 'JSTALE', b.wt)
988
+ await notify.settle(b.wt, 'stop', 'MERGE-STALE suspended one')
882
989
  const tip1 = tipOfLine(detailRecs(b.base).at(-1) ?? '')
883
990
  git(['add', '-A'], b.wt)
884
991
  git(['-c', 'user.email=fixture@teamsmith', '-c', 'user.name=fixture', 'commit', '-qm', 'merge-stale one'], b.wt)
885
- await notify.settle(b.wt, 'stop', 'MERGE-STALE two')
992
+ await notify.settle(b.wt, 'stop', 'MERGE-STALE suspended two')
886
993
  const tip2 = tipOfLine(detailRecs(b.base).at(-1) ?? '')
887
994
  const line = inboxAll(b.base)[0] ?? ''
888
995
  mkdirSync(join(b.base, 'docs/team/reviews'), { recursive: true })
@@ -890,8 +997,10 @@ const groupMerge = async () => {
890
997
  const reviewed = new RegExp(tip1).test(readFileSync(join(b.base, 'docs/team/reviews/P230.md'), 'utf8'))
891
998
  const judged = t => tip1.startsWith(t) || t.startsWith(tip1)
892
999
  check('merge: a merged line is judged by its last event, not as current state',
893
- /×2/.test(line) && tip1 !== tip2 && line.includes(`tip=${tip2}`) && !judged(tip2) && judged(tip1) && reviewed,
1000
+ /×2/.test(line) && line.includes('[auto·suspended]') && tip1 !== tip2 && line.includes(`tip=${tip2}`) &&
1001
+ !judged(tip2) && judged(tip1) && reviewed,
894
1002
  `tip1=${tip1} tip2=${tip2} :: ${line}`)
1003
+ killPid(pid); dropRecord(b.base, 'JSTALE')
895
1004
  }
896
1005
  }
897
1006
 
@@ -1049,6 +1158,81 @@ const groupWake = async () => {
1049
1158
  killPid(pid2); dropRecord(b.base, 'W3')
1050
1159
  }
1051
1160
 
1161
+ // ③b delivered 每个新 tip 各敲一次;同 tip 的进度只合并、不再敲。
1162
+ {
1163
+ const b = makeBase('wake-revisions')
1164
+ configAdd(b.base, 'TEAM_NOTIFY_DEDUP_SEC=0')
1165
+ taskProof(b.base, 'dev', 'P230')
1166
+ resetNotify(b.base)
1167
+ await notify.settle(b.wt, 'stop', 'WAKE-REVISIONS delivered one')
1168
+ const k1 = knockEntries(b.base)
1169
+ writeFileSync(join(b.wt, 'revision-2.txt'), 'two\n')
1170
+ git(['add', '-A'], b.wt)
1171
+ git(['-c', 'user.email=fixture@teamsmith', '-c', 'user.name=fixture', 'commit', '-qm', 'wake revision two'], b.wt)
1172
+ await notify.settle(b.wt, 'stop', 'WAKE-REVISIONS delivered two')
1173
+ await notify.settle(b.wt, 'stop', 'WAKE-REVISIONS same tip churn')
1174
+ const k2 = knockEntries(b.base)
1175
+ writeFileSync(join(b.wt, 'revision-3.txt'), 'three\n')
1176
+ git(['add', '-A'], b.wt)
1177
+ git(['-c', 'user.email=fixture@teamsmith', '-c', 'user.name=fixture', 'commit', '-qm', 'wake revision three'], b.wt)
1178
+ await notify.settle(b.wt, 'stop', 'WAKE-REVISIONS delivered three')
1179
+ const k3 = knockEntries(b.base)
1180
+ const lines = inboxAll(b.base)
1181
+ const pointers = inboxAll(b.base, 'pm')
1182
+ check('wake: each delivered revision wakes once and same-tip churn stays merged',
1183
+ k1 === 1 && k2 === 2 && k3 === 3 && lines.length === 3 && pointers.length === 3 &&
1184
+ !lines[0].includes('×') && lines[1].includes('×2') && !lines[2].includes('×'),
1185
+ `knocks=${k1},${k2},${k3} lines=${lines.length} pointers=${pointers.length} :: ${lines.join(' || ')}`)
1186
+ }
1187
+
1188
+ // ③b-2 无法证明 tip 的 delivered 发送者保持 NOREV 合并边界:两次仍一行、只敲一次。
1189
+ // 不写 taskProof,分支名本身不能伪造 task/tip 戳;有 tip 的对照就是上面的 wake-revisions。
1190
+ {
1191
+ const b = makeBase('wake-no-revision')
1192
+ configAdd(b.base, 'TEAM_NOTIFY_DEDUP_SEC=0')
1193
+ resetNotify(b.base)
1194
+ await notify.settle(b.wt, 'stop', 'WAKE-NOREV delivered one')
1195
+ const k1 = knockEntries(b.base)
1196
+ await notify.settle(b.wt, 'stop', 'WAKE-NOREV delivered two')
1197
+ const k2 = knockEntries(b.base)
1198
+ const lines = inboxAll(b.base)
1199
+ const pointers = inboxAll(b.base, 'pm')
1200
+ check('wake: delivered events without a proven tip merge without a second wake',
1201
+ k1 === 1 && k2 === 1 && lines.length === 1 && pointers.length === 1 &&
1202
+ lines[0].includes('[auto] ') && lines[0].includes('×2') && pointers[0].includes('×2') &&
1203
+ !lines[0].includes('tip=') && !pointers[0].includes('tip=') && detailRecs(b.base).length === 2,
1204
+ `knocks=${k1},${k2} :: ${lines[0]} || ${pointers[0]}`)
1205
+ }
1206
+
1207
+ // ③c 非交付进度跨 tip 合并:suspended 始终安静,interrupted 只有首行的一次叫醒。
1208
+ {
1209
+ const b = makeBase('wake-progress-revisions')
1210
+ configAdd(b.base, 'TEAM_NOTIFY_DEDUP_SEC=0')
1211
+ taskProof(b.base, 'dev', 'P230')
1212
+ resetNotify(b.base)
1213
+ const pid = liveRecord(b.base, 'WPROGRESS', b.wt)
1214
+ await notify.settle(b.wt, 'stop', 'WAKE-PROGRESS suspended one')
1215
+ writeFileSync(join(b.wt, 'progress-2.txt'), 'two\n')
1216
+ git(['add', '-A'], b.wt)
1217
+ git(['-c', 'user.email=fixture@teamsmith', '-c', 'user.name=fixture', 'commit', '-qm', 'wake progress two'], b.wt)
1218
+ await notify.settle(b.wt, 'stop', 'WAKE-PROGRESS suspended two')
1219
+ const ks = knockEntries(b.base)
1220
+ await notify.settle(b.wt, 'aborted', 'WAKE-PROGRESS interrupted one')
1221
+ const ki1 = knockEntries(b.base)
1222
+ writeFileSync(join(b.wt, 'progress-3.txt'), 'three\n')
1223
+ git(['add', '-A'], b.wt)
1224
+ git(['-c', 'user.email=fixture@teamsmith', '-c', 'user.name=fixture', 'commit', '-qm', 'wake progress three'], b.wt)
1225
+ await notify.settle(b.wt, 'aborted', 'WAKE-PROGRESS interrupted two')
1226
+ const ki2 = knockEntries(b.base)
1227
+ const lines = inboxAll(b.base)
1228
+ check('wake: suspended and interrupted progress merge across tips without another wake',
1229
+ ks === 0 && ki1 === 1 && ki2 === 1 && lines.length === 2 &&
1230
+ lines[0].includes('[auto·suspended]') && lines[0].includes('×2') &&
1231
+ lines[1].includes('[auto·interrupted]') && lines[1].includes('×2'),
1232
+ `knocks=${ks},${ki1},${ki2} :: ${lines.join(' || ')}`)
1233
+ killPid(pid); dropRecord(b.base, 'WPROGRESS')
1234
+ }
1235
+
1052
1236
  // ④ 计数抖动不叫醒:先显式清掉上一条 knock(否则 outbox 自己的去重会替实现挡住这条断言)
1053
1237
  {
1054
1238
  const b = makeBase('wake-churn')
@@ -16,13 +16,12 @@
16
16
  # 死 pid / pid 复用 / 畸形记录 → 今天的形状;中断 + 活记录 → [auto·interrupted] + awaiting=;
17
17
  # 车道目录按**车道自己的规则**解析(worktree 自带 config / 显式 TEAM_STATE_DIR 都不许被
18
18
  # notify 自己的 root 顶替)。
19
- # owner-scope 挂起判定**按归属范围**(P236):同一车道目录里的记录可能属于别的席位 —— 记录里的
20
- # cwd 必须解析到本会话自己的工作树/cwd 才算「我的作业」;多席位各有作业时各自只认自己的
21
- # id;空席位(dev2 与 dev3 两个非拥有者)不被别人的作业打成挂起;缺 cwd / 相对 cwd /
22
- # 解析不出来的畸形记录不判挂起(fail-closed);软链与尾斜杠按真实路径归一。
23
- # merge turn-notice-merge 的写入面(P251):合并键四分量(席位/任务/状态类/awaiting 集合)、
19
+ # owner-scope 挂起判定**按发起身份**:新记录只看 session_cwd,执行 cwd 可以是独立 clone;显式外来身份
20
+ # 不回退到 cwd。旧记录只在 cwd 恰好解析到席位工作树时兼容;子目录、独立 clone、他人与
21
+ # 无效路径都不收养。独立 clone 的挂起不敲,最终 delivered 新行恰好敲一次。
22
+ # merge turn-notice-merge 的写入面:合并键五分量(席位/任务/状态类/awaiting 集合/delivered tip)、
24
23
  # 汇总行的形状(最后一条事件的行 + ×N first= last=)与最后一条的值、尾行锚、跨类/跨任务/
25
- # 跨 awaiting 不合并、去重窗口语义、行计数读者(未读 + --ack)与陈旧判据。
24
+ # 跨 awaiting 不合并;不同 delivered tip 新行,同 tip 合并,suspended/interrupted 跨 tip 合并。
26
25
  # detail 明细文件(state/notify.log):一行一事件、先明细后合并(×N 与记录数一致)、
27
26
  # TEAM_NOTIFY_DETAIL_MAX 上界与一代轮转(轮转头 + 扩展日志)、`team inbox --detail`
28
27
  # 的读面(缺文件/被轮转出去要点名 state/notify.log.1 并非零退出、只读不 ack)。
@@ -168,7 +167,7 @@ run_harness() { # <tag> <groups> [<bg> <notify>] → rc;stdout+stderr 落 $TMP
168
167
  # P251:带 wake 的组要「有 PM 窗口」的形状 —— 假 tmux 必须在 runner **启动前**进 PATH(bun 缓存在
169
168
  # 启动时读的 PATH,运行中改 process.env.PATH 对子进程查找无效;实测)。只加给带 wake 的组。
170
169
  local tag="$1" groups="$2" bg="${3:-$BG_EXT}" notify="${4:-$NOTIFY_EXT}" path_pre="$PATH"
171
- case ",$groups," in *,wake,*) path_pre="$KNOCK_SHIM:$PATH" ;; esac
170
+ case ",$groups," in *,wake,*|*,owner-scope,*) path_pre="$KNOCK_SHIM:$PATH" ;; esac
172
171
  env PATH="$path_pre" "$RUNNER" "$HARNESS" --bg "$bg" --notify "$notify" --root "$FIX" --groups "$groups" --marker "$MARKER" \
173
172
  >"$TMP/h-$tag.log" 2>&1
174
173
  }
@@ -285,7 +284,7 @@ if selects flip; then
285
284
  expect_red flip-own-root "suspend: a worktree carrying its own config uses its own lane records" "$TMP/h-flip-green.log"
286
285
 
287
286
  # ⑥ 删掉归属判据(退回「同一车道目录里有活作业即算」)→ 归属用例必须红
288
- M6="$(flip_mut owner-scope "$NOTIFY_EXT" "s#if (!isOwnedCwd(fields.cwd ?? '', owned)) continue#if (false) continue#")"
287
+ M6="$(flip_mut owner-scope "$NOTIFY_EXT" "s#if (!isOwnedJob(fields, owned, legacyWorktree)) continue#if (false) continue#")"
289
288
  flip_premise owner-scope "$M6" 'if (false) continue' has
290
289
  run_harness flip-owner-scope owner-scope "$BG_EXT" "$M6"
291
290
  expect_red flip-owner-scope "owner-scope: each seat suspends on its own job only" "$TMP/h-flip-green.log"
@@ -294,6 +293,13 @@ if selects flip; then
294
293
  expect_red flip-owner-scope "owner-scope: a live record with a missing, relative or unresolvable cwd does not suspend (fail-closed)" "$TMP/h-flip-green.log"
295
294
  expect_red flip-owner-scope "owner-scope: a job started from the main worktree does not suspend a seat" "$TMP/h-flip-green.log"
296
295
 
296
+ # ⑥b 丢掉发起身份、退回执行 cwd:独立 clone 不再挂起,显式他人身份还会被错误收养。
297
+ M6B="$(flip_mut initiator-fallback "$NOTIFY_EXT" "s#if (!isOwnedJob(fields, owned, legacyWorktree)) continue#if (!isOwnedCwd(fields.cwd ?? '', owned)) continue#")"
298
+ flip_premise initiator-fallback "$M6B" "if (!isOwnedCwd(fields.cwd ?? '', owned)) continue" has
299
+ run_harness flip-initiator-fallback owner-scope "$BG_EXT" "$M6B"
300
+ expect_red flip-initiator-fallback "owner-scope: an independent-checkout job becomes one final delivery wake" "$TMP/h-flip-green.log"
301
+ expect_red flip-initiator-fallback "owner-scope: a live record with a missing, relative or unresolvable cwd does not suspend (fail-closed)" "$TMP/h-flip-green.log"
302
+
297
303
  # ── P251 · turn-notice-merge 的写入面红侧(merge/detail/wake)────────────────────────────
298
304
  # 扩展的 skillDir() = 它自己目录的父目录 → CLI 侧的合并/明细代码与扩展侧的叫醒代码必须在**同一棵
299
305
  # scratch 树**里破坏($MUT/<tag>/{extension,scripts}),否则扩展找不到 scripts/team,knock 断言是假红。
@@ -387,8 +393,8 @@ if selects flip; then
387
393
 
388
394
  # ⑯ 用摘要文本当 knock 去重键 → 文本逐字相同的两条不同行互吞
389
395
  M16="$(flip_tree wake-summarykey)"
390
- F16="$(flip_tree_sed wake-summarykey extension/team-notify.ts 's#const lineIdentity = .*#const lineIdentity = `line|${agent}|${summary}`#')"
391
- flip_premise wake-summarykey "$F16" 'const lineIdentity = `line|${agent}|${summary}`' has
396
+ F16="$(flip_tree_sed wake-summarykey extension/team-notify.ts 's#identity = `line|${mergeKey}|${firstEvent}`#identity = `line|${agent}|${summary}`#')"
397
+ flip_premise wake-summarykey "$F16" 'identity = `line|${agent}|${summary}`' has
392
398
  run_harness flip-wake-summarykey wake "$BG_EXT" "$M16"
393
399
  expect_red flip-wake-summarykey "wake: two text-identical lines are not conflated" "$TMP/h-flip-green-notify.log"
394
400
 
@@ -417,6 +423,14 @@ if selects flip; then
417
423
  run_harness flip-merge-off merge "$BG_EXT" "$M19"
418
424
  expect_red flip-merge-off "merge: line-counting readers count a merged line once" "$TMP/h-flip-green-notify.log"
419
425
 
426
+ # ⑳ 删除 delivered 的 tip 分量:不同修订又静默合并,记录行与叫醒两组都必须按名变红。
427
+ M20="$(flip_tree merge-delivered-tip)"
428
+ F20="$(flip_tree_sed merge-delivered-tip scripts/lib/cmd-agents.sh 's#"$seat" "$class" "$t" "$nrm" "$rev"#"$seat" "$class" "$t" "$nrm" "-"#')"
429
+ flip_premise merge-delivered-tip "$F20" '"$seat" "$class" "$t" "$nrm" "-"' has
430
+ run_harness flip-merge-delivered-tip merge,wake "$BG_EXT" "$M20"
431
+ expect_red flip-merge-delivered-tip "merge: each delivered revision starts a new line and same-tip events merge" "$TMP/h-flip-green-notify.log"
432
+ expect_red flip-merge-delivered-tip "wake: each delivered revision wakes once and same-tip churn stays merged" "$TMP/h-flip-green-notify.log"
433
+
420
434
  # 还原后绿:pristine 树重跑一遍(上面所有破坏都只写 scratch 副本)
421
435
  section "flip · 还原后绿(pristine 树重跑)"
422
436
  run_harness flip-restored wording