teamsmith 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/README.md +4 -4
  2. package/package.json +1 -1
  3. package/skills/teamsmith/CHANGELOG.md +69 -0
  4. package/skills/teamsmith/SKILL.md +20 -13
  5. package/skills/teamsmith/extension/team-inbox-watch.ts +5 -3
  6. package/skills/teamsmith/extension/team-notify.ts +37 -6
  7. package/skills/teamsmith/extension/team.ts +438 -0
  8. package/skills/teamsmith/references/config.md +39 -6
  9. package/skills/teamsmith/references/migration.md +197 -47
  10. package/skills/teamsmith/references/protocol.md +201 -30
  11. package/skills/teamsmith/references/troubleshooting.md +130 -10
  12. package/skills/teamsmith/references/workflows.md +36 -2
  13. package/skills/teamsmith/scripts/lib/cmd-agents.sh +318 -23
  14. package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +2 -2
  15. package/skills/teamsmith/scripts/lib/cmd-config.sh +349 -67
  16. package/skills/teamsmith/scripts/lib/cmd-draft.sh +4 -4
  17. package/skills/teamsmith/scripts/lib/cmd-help.sh +677 -0
  18. package/skills/teamsmith/scripts/lib/cmd-init.sh +157 -5
  19. package/skills/teamsmith/scripts/lib/cmd-interrupt.sh +461 -0
  20. package/skills/teamsmith/scripts/lib/cmd-meeting.sh +2 -25
  21. package/skills/teamsmith/scripts/lib/cmd-project.sh +30 -103
  22. package/skills/teamsmith/scripts/lib/cmd-reap.sh +277 -0
  23. package/skills/teamsmith/scripts/lib/cmd-reply.sh +3 -3
  24. package/skills/teamsmith/scripts/lib/cmd-review.sh +182 -32
  25. package/skills/teamsmith/scripts/lib/cmd-status.sh +234 -21
  26. package/skills/teamsmith/scripts/lib/cmd-update.sh +36 -7
  27. package/skills/teamsmith/scripts/lib/cmd-watch.sh +564 -46
  28. package/skills/teamsmith/scripts/lib/common.sh +1004 -245
  29. package/skills/teamsmith/scripts/lib/gate-lock.sh +582 -0
  30. package/skills/teamsmith/scripts/panel/draft-send.sh +11 -1
  31. package/skills/teamsmith/scripts/panel/panel.js +211 -211
  32. package/skills/teamsmith/scripts/panel/src/App.tsx +58 -21
  33. package/skills/teamsmith/scripts/panel/src/clipboard.ts +12 -5
  34. package/skills/teamsmith/scripts/panel/src/compose.ts +6 -3
  35. package/skills/teamsmith/scripts/panel/src/data.ts +51 -5
  36. package/skills/teamsmith/scripts/panel/src/layout.ts +209 -69
  37. package/skills/teamsmith/scripts/panel/src/main.tsx +37 -8
  38. package/skills/teamsmith/scripts/panel/src/strings/en.ts +39 -29
  39. package/skills/teamsmith/scripts/panel/src/strings/zh.ts +41 -31
  40. package/skills/teamsmith/scripts/panel/src/types.ts +28 -3
  41. package/skills/teamsmith/scripts/replies.mjs +4 -1
  42. package/skills/teamsmith/scripts/shim/killall +10 -0
  43. package/skills/teamsmith/scripts/shim/pgrep +10 -0
  44. package/skills/teamsmith/scripts/shim/pidof +10 -0
  45. package/skills/teamsmith/scripts/shim/pkill +10 -0
  46. package/skills/teamsmith/scripts/shim/signal-gate +108 -31
  47. package/skills/teamsmith/scripts/shim/tmux +18 -0
  48. package/skills/teamsmith/scripts/strings/commands.tsv +86 -0
  49. package/skills/teamsmith/scripts/strings/help.en.tsv +503 -0
  50. package/skills/teamsmith/scripts/strings/help.zh.tsv +489 -0
  51. package/skills/teamsmith/scripts/team +19 -6
  52. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +8 -1
  53. package/skills/teamsmith/templates/config.sh.tmpl +20 -1
  54. package/skills/teamsmith/templates/pm-prompt.md.tmpl +21 -0
  55. package/skills/teamsmith/tests/README.md +31 -0
  56. package/skills/teamsmith/tests/bg-ledger-harness.mjs +464 -40
  57. package/skills/teamsmith/tests/bg-ledger.sh +168 -10
  58. package/skills/teamsmith/tests/checkout-shape-probe.sh +83 -54
  59. package/skills/teamsmith/tests/config-cli.sh +184 -32
  60. package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +7 -1
  61. package/skills/teamsmith/tests/fixtures/p287/lint-good.sh.in +3 -0
  62. package/skills/teamsmith/tests/fixtures/p287/lint-hardcoded.sh.in +3 -0
  63. package/skills/teamsmith/tests/fixtures/p287/lint-no-ns.sh.in +3 -0
  64. package/skills/teamsmith/tests/fixtures/p55/flip-p49.sh +18 -6
  65. package/skills/teamsmith/tests/flip-m33.sh +5 -3
  66. package/skills/teamsmith/tests/flip-p158.sh +2 -1
  67. package/skills/teamsmith/tests/flip-p308-skip-not-pass.sh +151 -0
  68. package/skills/teamsmith/tests/flip-p310-lock.sh +210 -0
  69. package/skills/teamsmith/tests/flip-p310-socket.sh +125 -0
  70. package/skills/teamsmith/tests/gate-guard.sh +52 -79
  71. package/skills/teamsmith/tests/help-surface.sh +1664 -0
  72. package/skills/teamsmith/tests/install-shape.sh +359 -22
  73. package/skills/teamsmith/tests/key-replies-pty.sh +9 -10
  74. package/skills/teamsmith/tests/key-replies-ui.sh +2 -8
  75. package/skills/teamsmith/tests/key-replies.sh +281 -28
  76. package/skills/teamsmith/tests/ledger-ban.sh +5 -4
  77. package/skills/teamsmith/tests/ledger-claim.sh +2 -1
  78. package/skills/teamsmith/tests/lib/bounded-spin.sh +90 -0
  79. package/skills/teamsmith/tests/lib/model-policy.sh +4 -0
  80. package/skills/teamsmith/tests/lib/model-routing-flips.py +51 -0
  81. package/skills/teamsmith/tests/lib/pty-wait.sh +21 -111
  82. package/skills/teamsmith/tests/lib/reply-fixture.sh +4 -9
  83. package/skills/teamsmith/tests/lib/section-guard.sh +316 -164
  84. package/skills/teamsmith/tests/lib/tmp-root.sh +139 -27
  85. package/skills/teamsmith/tests/lib/tmux-cap.sh +10 -1
  86. package/skills/teamsmith/tests/lib/tmux-iso.sh +31 -13
  87. package/skills/teamsmith/tests/loop-inventory.tsv +83 -77
  88. package/skills/teamsmith/tests/panel-b2.sh +430 -352
  89. package/skills/teamsmith/tests/panel-b3-stub.sh +112 -4
  90. package/skills/teamsmith/tests/panel-b3.sh +314 -62
  91. package/skills/teamsmith/tests/panel-choices.sh +11 -6
  92. package/skills/teamsmith/tests/panel-cpu.sh +43 -130
  93. package/skills/teamsmith/tests/panel-p21.sh +251 -265
  94. package/skills/teamsmith/tests/panel-snapshots.sh +41 -225
  95. package/skills/teamsmith/tests/panel-strings.mjs +33 -18
  96. package/skills/teamsmith/tests/perf.sh +187 -396
  97. package/skills/teamsmith/tests/routes.sh +440 -117
  98. package/skills/teamsmith/tests/seat-interrupt.sh +1012 -0
  99. package/skills/teamsmith/tests/seat-visibility.sh +675 -0
  100. package/skills/teamsmith/tests/section-guard.sh +13 -102
  101. package/skills/teamsmith/tests/section-needs-audit.sh +24 -7
  102. package/skills/teamsmith/tests/section-paths.tsv +32 -18
  103. package/skills/teamsmith/tests/section-select.sh +371 -19
  104. package/skills/teamsmith/tests/signal-gate.sh +249 -27
  105. package/skills/teamsmith/tests/signal-lint-legacy.txt +4 -1
  106. package/skills/teamsmith/tests/slash-team-e2e.sh +323 -0
  107. package/skills/teamsmith/tests/slash-team.sh +617 -0
  108. package/skills/teamsmith/tests/slice-coverage.sh +206 -0
  109. package/skills/teamsmith/tests/smoke.sh +3595 -788
  110. package/skills/teamsmith/tests/task-model-routing.sh +530 -15
  111. package/skills/teamsmith/tests/team-bg-stop.sh +18 -10
  112. package/skills/teamsmith/tests/tmp-hygiene.sh +782 -45
  113. package/skills/teamsmith/tests/tmux-identity-leak.sh +773 -0
  114. package/skills/teamsmith/tests/tmux-lint-legacy.txt +12 -18
  115. package/skills/teamsmith/tests/upgrade-recipe.sh +537 -0
  116. package/skills/teamsmith/tests/workflow-entry.sh +207 -0
  117. package/skills/teamsmith-init/SKILL.md +12 -12
  118. package/skills/teamsmith-init/references/bootstrap.md +3 -3
  119. package/skills/teamsmith/tests/flip-glue.sh +0 -162
  120. package/skills/teamsmith/tests/flip-m12-26c.sh +0 -129
  121. package/skills/teamsmith/tests/flip-m12.sh +0 -185
  122. package/skills/teamsmith/tests/flip-m16.sh +0 -166
  123. package/skills/teamsmith/tests/flip-m17.sh +0 -204
  124. package/skills/teamsmith/tests/flip-m34.sh +0 -96
  125. package/skills/teamsmith/tests/flip-m37.sh +0 -185
  126. package/skills/teamsmith/tests/flip-m4.3.sh +0 -375
  127. package/skills/teamsmith/tests/flip-m43.sh +0 -128
  128. package/skills/teamsmith/tests/flip-m45.sh +0 -244
  129. package/skills/teamsmith/tests/flip-m46.sh +0 -238
  130. package/skills/teamsmith/tests/flip-m48.sh +0 -304
  131. package/skills/teamsmith/tests/flip-m6.2.sh +0 -205
  132. package/skills/teamsmith/tests/flip-m6.3.sh +0 -283
  133. package/skills/teamsmith/tests/flip-m6.4.sh +0 -267
  134. package/skills/teamsmith/tests/flip-m6.5.sh +0 -113
  135. package/skills/teamsmith/tests/flip-m7.1.sh +0 -135
  136. package/skills/teamsmith/tests/flip-m7.2.sh +0 -321
  137. package/skills/teamsmith/tests/flip-p144.sh +0 -112
  138. package/skills/teamsmith/tests/flip-p156.sh +0 -133
  139. package/skills/teamsmith/tests/flip-p160.sh +0 -182
  140. package/skills/teamsmith/tests/flip-p171.sh +0 -249
  141. package/skills/teamsmith/tests/flip-p18.1.sh +0 -95
  142. package/skills/teamsmith/tests/flip-p20.sh +0 -286
  143. package/skills/teamsmith/tests/flip-p201.sh +0 -249
  144. package/skills/teamsmith/tests/flip-p210.sh +0 -239
  145. package/skills/teamsmith/tests/flip-p211.sh +0 -152
  146. package/skills/teamsmith/tests/flip-p217.sh +0 -288
  147. package/skills/teamsmith/tests/flip-p22.sh +0 -123
  148. package/skills/teamsmith/tests/flip-p23.sh +0 -239
  149. package/skills/teamsmith/tests/flip-p25.sh +0 -165
  150. package/skills/teamsmith/tests/flip-p71.sh +0 -184
  151. package/skills/teamsmith/tests/flip-p72.sh +0 -202
  152. package/skills/teamsmith/tests/load-experiment.sh +0 -290
  153. package/skills/teamsmith/tests/panel-cpu-premise.sh +0 -173
  154. package/skills/teamsmith/tests/panel-flip-m54.sh +0 -207
  155. package/skills/teamsmith/tests/panel-flip-p123.sh +0 -278
  156. package/skills/teamsmith/tests/panel-flip-p125.sh +0 -318
  157. package/skills/teamsmith/tests/panel-flip-p128.sh +0 -259
  158. package/skills/teamsmith/tests/panel-keyprobe-stub.sh +0 -41
  159. package/skills/teamsmith/tests/panel-keyprobe.sh +0 -82
  160. package/skills/teamsmith/tests/panel-knobs.sh +0 -83
  161. package/skills/teamsmith/tests/section-budgets.tsv +0 -154
  162. package/skills/teamsmith/tests/team-bg-flip.sh +0 -239
  163. package/skills/teamsmith/tests/team-inbox-watch-flip.sh +0 -191
@@ -10,12 +10,12 @@ source "$here/lib/model-routing-roles.sh"
10
10
  source "$here/lib/tmux-iso.sh"
11
11
  TREE="${TEAM_ROUTING_TREE:-$(cd "$here/../../.." && pwd)}"
12
12
  EVIDENCE="${TEAM_ROUTING_EVIDENCE:-}"
13
- SELECT='policy,machine,init,config,upgrade,dispatch,resume,transaction,limits,preview,sid-readers,pm,boundary'
13
+ SELECT='policy,machine,init,config,upgrade,dispatch,resume,transaction,limits,preview,sid-readers,pm,heal,adopt,updatecheck,boundary'
14
14
  while [ $# -gt 0 ]; do
15
15
  case "$1" in --select) SELECT="${2:?}"; shift 2 ;; --flip) SELECT=flip; shift ;; *) printf 'unknown option: %s\n' "$1"; exit 2 ;; esac
16
16
  done
17
17
  for group in ${SELECT//,/ }; do
18
- case "$group" in policy|machine|config|upgrade|dispatch|resume|transaction|limits|preview|sid-readers|pm|boundary|init|flip) ;; *) printf 'unknown group: %s\n' "$group"; exit 2 ;; esac
18
+ case "$group" in policy|machine|config|upgrade|dispatch|resume|transaction|limits|preview|sid-readers|pm|boundary|init|heal|adopt|updatecheck|flip) ;; *) printf 'unknown group: %s\n' "$group"; exit 2 ;; esac
19
19
  done
20
20
  while IFS='=' read -r k _; do case "$k" in TEAM_*) unset "$k" 2>/dev/null || true ;; esac; done < <(env)
21
21
  TMP="$(tmp_root_create task-model-routing)" || exit 3
@@ -28,7 +28,7 @@ export HOME="$TMP/home"; mkdir -p "$HOME"
28
28
  PASS=0 FAIL=0; LIVE_SOCKET=''
29
29
  cleanup() {
30
30
  [ "${BASHPID:-$$}" = "$$" ] || return 0
31
- if [ -n "$LIVE_SOCKET" ] && tmux_iso_guard_soft routing cleanup --tmpdir "$TMUX_TMPDIR" --sock-name "$LIVE_SOCKET" --own-root "$TMP"; then
31
+ if [ -n "$LIVE_SOCKET" ] && tmux_iso_guard_soft routing cleanup --tmpdir "$TMUX_TMPDIR" --sock-name "$LIVE_SOCKET" --own-root "$TMP" --own-root "$TMUX_TMPDIR"; then
32
32
  tmux -L "$LIVE_SOCKET" kill-server 2>/dev/null || true
33
33
  fi
34
34
  if [ -n "$EVIDENCE" ]; then
@@ -83,7 +83,7 @@ effect_snapshot() {
83
83
  [ ! -d "$REPO/.pi/team/state" ] || find "$REPO/.pi/team/state" -maxdepth 1 -type f -print0 | sort -z | xargs -0 -r sha256sum
84
84
  } >> "$TMP/effect-hashes.log"
85
85
  }
86
- run() { local rc=0; effect_snapshot "before $*"; OUT="$(cd "$REPO" && timeout 35 bash "$CLI" "$@" 2>&1)" || rc=$?; RC="$rc"; printf 'command=%q ' "$@"; printf '\nrc=%s\n%s\n' "$RC" "$OUT"; effect_snapshot "after rc=$RC $*"; }
86
+ run() { local rc=0; effect_snapshot "before $*"; OUT="$(cd "$REPO" && timeout 300 bash "$CLI" "$@" 2>&1)" || rc=$?; RC="$rc"; printf 'command=%q ' "$@"; printf '\nrc=%s\n%s\n' "$RC" "$OUT"; effect_snapshot "after rc=$RC $*"; }
87
87
  STATE="$REPO/.pi/team/state"; CONFIG="$REPO/.pi/team/config.sh"
88
88
  # ── 每组自足:自己准备自己的前置(P238 坑 1)────────────────────────────────────────────
89
89
  # 以前夹具的 state 目录只在 sid-readers / boundary 组的正文里被建出来,于是单独 `--select pm`
@@ -314,11 +314,16 @@ printf '| ID | 任务 | Agent | 分支 | 依赖 | 状态 |\n|---|---|---|---|---
314
314
  if has preview || has dispatch || has resume || has transaction || has limits || has boundary; then
315
315
  # Private socket bound shim; cleanup never reaches the shared server.
316
316
  LIVE_SOCKET="routing-${BASHPID}-${RANDOM}"
317
- export TMUX_TMPDIR="$TMP/tmux"; mkdir -p "$TMUX_TMPDIR" "$TMP/bin"
317
+ # P309:socket 目录**不能**挂在本轮的临时根下 —— 临时根名带项目 ns(`/var/tmp/teamsmith-<ns>`)之后,
318
+ # `<TMP>/tmux/tmux-<uid>/routing-…` 已经 129 字节 > AF_UNIX 的 107,隔离前置直接硬停(routing 组整组判不了)。
319
+ # 基址要短:tmp_root_socket_dir 先试解析出的临时根、放不下就退 OS 默认临时目录。
320
+ TMUX_TMPDIR="$(tmp_root_socket_dir routing "tmux-$(id -u)/routing-999999-99999")" \
321
+ || TMUX_TMPDIR="$TMP/tmux"
322
+ export TMUX_TMPDIR; mkdir -p "$TMUX_TMPDIR" "$TMP/bin"
318
323
  REAL_TMUX="$(type -P tmux)"
319
324
  printf '#!/usr/bin/env bash\nexec %q -L %q "$@"\n' "$REAL_TMUX" "$LIVE_SOCKET" > "$TMP/bin/tmux"; chmod +x "$TMP/bin/tmux"
320
325
  export PATH="$TMP/bin:$PATH"
321
- tmux_iso_require routing launch --tmpdir "$TMUX_TMPDIR" --sock-name "$LIVE_SOCKET" --own-root "$TMP"
326
+ tmux_iso_require routing launch --tmpdir "$TMUX_TMPDIR" --sock-name "$LIVE_SOCKET" --own-root "$TMP" --own-root "$TMUX_TMPDIR"
322
327
  before="$(sha "$STATE/dev.env")"; board="$(sha "$REPO/docs/team/BOARD.md")"
323
328
  run dispatch dev T1 docs/team/tasks/T1-fixture.md --print
324
329
  check preview-success eq "$RC" 0; check preview-no-assignment eq "$(sha "$STATE/dev.env")" "$before"; check preview-no-board eq "$(sha "$REPO/docs/team/BOARD.md")" "$board"
@@ -400,7 +405,7 @@ if has preview || has dispatch || has resume || has transaction || has limits ||
400
405
  check suffix-change-requires-fresh eq "$RC" 1
401
406
  run dispatch dev T1 docs/team/tasks/T1-fixture.md --fresh --print
402
407
  check fresh-keeps-stored-model eq "$RC" 0; check fresh-model contains "$OUT" 'vendor/strong:high'
403
- tmux_iso_require routing stop-fixture --tmpdir "$TMUX_TMPDIR" --sock-name "$LIVE_SOCKET" --own-root "$TMP"
408
+ tmux_iso_require routing stop-fixture --tmpdir "$TMUX_TMPDIR" --sock-name "$LIVE_SOCKET" --own-root "$TMP" --own-root "$TMUX_TMPDIR"
404
409
  (cd "$REPO" && tmux kill-window -t routing-fixture:dev)
405
410
  run resume --agent dev --dry-run
406
411
  check resume-stored-identity eq "$RC" 0; check resume-sid contains "$OUT" "$SID_A"
@@ -422,7 +427,7 @@ if has preview || has dispatch || has resume || has transaction || has limits ||
422
427
  fi
423
428
  # Hook only the owned fixture shell; shipped files are never modified by these faults.
424
429
  hooked() {
425
- (cd "$REPO" && timeout 45 bash --noprofile --norc -c '
430
+ (cd "$REPO" && timeout 300 bash --noprofile --norc -c '
426
431
  CMD=dispatch; ARGS=()
427
432
  source "$1/scripts/lib/common.sh"
428
433
  for lib in "$1"/scripts/lib/cmd-*.sh; do source "$lib"; done
@@ -810,17 +815,62 @@ EOF
810
815
  i_run "$i_legacy" init --no-skills --session init-legacy --agents dev
811
816
  check init-legacy-plain-refused bash -c '[ "$1" != 0 ]' _ "$RC"
812
817
  check init-legacy-plain-route contains "$OUT" 'upgrade-models'
818
+ # P261 返修(V35 F1/F2):拒绝建议是**从项目自身配置推导**出来的一条可粘贴命令,不是占位符;
819
+ # 两条路线都在(手工事务 + 启动事务)。逐字节断言推导映射(含兜底对)。
820
+ i_derived_cmd='config upgrade-models --task-models '\''dev=p/old default=p/old'\'' --pm-model '\''p/old'\'' --dry-run'
821
+ check init-legacy-plain-derived contains "$OUT" "$i_derived_cmd"
822
+ check init-legacy-plain-startup-route contains "$OUT" '路线 ② 启动事务'
823
+ check init-legacy-plain-no-placeholder bash -c '! [[ "$1" == *"<category=provider/model"* ]]' _ "$OUT"
813
824
  i_run "$i_legacy" init --force --no-skills --session init-legacy --agents dev --task-models 'routine=p/new' --pm-model 'p/pm'
814
825
  check init-legacy-force-refused bash -c '[ "$1" != 0 ]' _ "$RC"
815
826
  check init-legacy-force-route contains "$OUT" 'upgrade-models'
827
+ check init-legacy-force-derived contains "$OUT" "$i_derived_cmd"
816
828
  i_run "$i_legacy" bootstrap --no-pulse --agents dev
817
829
  check init-legacy-bootstrap-refused bash -c '[ "$1" != 0 ]' _ "$RC"
830
+ # F1:bootstrap 曾只点名手工事务 —— 它必须与 init 同构(两条路线 + 推导命令)。
831
+ check init-legacy-bootstrap-derived contains "$OUT" "$i_derived_cmd"
832
+ check init-legacy-bootstrap-startup-route contains "$OUT" '路线 ② 启动事务'
818
833
  i_run "$i_legacy" bootstrap --no-pulse --agents dev --print
819
834
  check init-legacy-print-refused bash -c '[ "$1" != 0 ]' _ "$RC"
820
835
  check init-legacy-print-readonly contains "$OUT" 'upgrade-models'
836
+ check init-legacy-print-derived contains "$OUT" "$i_derived_cmd"
837
+ # O1:config 写路径在退休配置上也拒绝(写下去就是半迁移状态),同样给推导命令、同样零字节。
838
+ i_run "$i_legacy" config set TEAM_NOTIFY_TMUX 1 --yes
839
+ check init-legacy-config-set-refused eq "$RC" 5
840
+ check init-legacy-config-set-derived contains "$OUT" "$i_derived_cmd"
841
+ check init-legacy-config-set-startup-route contains "$OUT" '路线 ② 启动事务'
821
842
  check init-legacy-config-unchanged eq "$(sha "$i_legacy/.pi/team/config.sh")" "$i_cfg0"
822
843
  check init-legacy-ledger-unchanged eq "$(i_hash_tree "$i_legacy/docs")" "$i_led0"
823
844
  check init-legacy-no-side-effect bash -c '! test -e "$1/.pi/skills" && ! test -e "$1/.pi/team/state" && ! test -e "$1/.worktrees" && ! test -e "$1/AGENTS.md"' _ "$i_legacy"
845
+ # 端到端现场(返修要求):把拒绝打印的那条命令**原样**粘回去 —— --dry-run 零写入 → --yes 落地
846
+ # → config list rc=0。用独立副本,上面那些「契约字节没变」的断言才继续成立。
847
+ i_paste="$TMP/init-legacy-paste"; i_new_repo "$i_paste"; mkdir -p "$i_paste/.pi/team"
848
+ cp -p "$i_legacy/.pi/team/config.sh" "$i_paste/.pi/team/config.sh"
849
+ i_run "$i_paste" init --no-skills --session init-legacy --agents dev
850
+ check init-paste-refused bash -c '[ "$1" != 0 ]' _ "$RC"
851
+ i_pasted="$(printf '%s\n' "$OUT" | grep -o "config upgrade-models --task-models '[^']*' --pm-model '[^']*' --dry-run" | head -1)"
852
+ check init-paste-derived-exact eq "$i_pasted" "$i_derived_cmd"
853
+ p0="$(sha "$i_paste/.pi/team/config.sh")"
854
+ prc=0; ( cd "$i_paste" && "${iclean[@]}" bash -c "bash $(printf %q "$CLI") $i_pasted" ) >"$TMP/init-paste-dry.log" 2>&1 || prc=$?
855
+ check init-paste-dry-run-rc eq "$prc" 0
856
+ check init-paste-dry-run-pure eq "$(sha "$i_paste/.pi/team/config.sh")" "$p0"
857
+ prc=0; ( cd "$i_paste" && "${iclean[@]}" bash -c "bash $(printf %q "$CLI") ${i_pasted% --dry-run} --yes" ) >"$TMP/init-paste-yes.log" 2>&1 || prc=$?
858
+ check init-paste-yes-rc eq "$prc" 0
859
+ check init-paste-yes-map eq "$(grep -c "^TEAM_TASK_MODELS='dev=p/old default=p/old'\$" "$i_paste/.pi/team/config.sh" || true)" 1
860
+ check init-paste-yes-pm eq "$(grep -c "^TEAM_PM_MODEL='p/old'\$" "$i_paste/.pi/team/config.sh" || true)" 1
861
+ check init-paste-yes-retired-gone bash -c '! grep -qE "^TEAM_(AGENT_MODELS|DEFAULT_MODEL)=" "$1"' _ "$i_paste/.pi/team/config.sh"
862
+ i_run "$i_paste" config list
863
+ check init-paste-config-list eq "$RC" 0
864
+ # 推导不出来时:退回占位符 + 点名障碍(不许打印可能错的命令)—— 同一个拒绝面,同一个渲染器。
865
+ i_under="$TMP/init-legacy-underivable"; i_new_repo "$i_under"; mkdir -p "$i_under/.pi/team"
866
+ cp -p "$i_legacy/.pi/team/config.sh" "$i_under/.pi/team/config.sh"
867
+ sed -i "s/^TEAM_AGENT_MODELS=.*/TEAM_AGENT_MODELS='dev=notamodel'/" "$i_under/.pi/team/config.sh"
868
+ i_run "$i_under" init --no-skills --session init-legacy --agents dev
869
+ check init-underivable-refused bash -c '[ "$1" != 0 ]' _ "$RC"
870
+ check init-underivable-placeholder contains "$OUT" "--task-models '<category=provider/model"
871
+ check init-underivable-obstacle contains "$OUT" '推导不出建议映射'
872
+ check init-underivable-startup-route contains "$OUT" '路线 ② 启动事务'
873
+ check init-underivable-no-derived-map bash -c '! printf %s "$1" | grep -q "upgrade-models --task-models .dev="' _ "$OUT"
824
874
 
825
875
  # ⑥ 新鲜 bootstrap:给输入才写;--print 只读
826
876
  i_boot="$TMP/init-boot"; i_new_repo "$i_boot"
@@ -859,7 +909,16 @@ if has pm || has boundary; then
859
909
  done
860
910
  TEAM_PM_EXTRA_PI_ARGS='--no-tools'; check boundary-harmless team_pm_identity_guard
861
911
  TEAM_PM_EXTRA_PI_ARGS=''; TEAM_PM_FRESH_LAUNCH=0
862
- rm -f "$STATE/pm-launch.env"; rc=0; team_pm_identity_guard || rc=$?; check pm-unknown-needs-fresh eq "$rc" 1
912
+ # P261(design §7):**缺记录 ≠ 记录不一致** —— 工具对过去没有主张,所以放行并记下「本次要登记」;
913
+ # 登记本身发生在成功启动之后(守卫不预写)。仍会拒绝的是**不可读**的记录(下一条)与值变了的记录
914
+ # (pm-suffix-change-needs-fresh / pm-changed-resume-selector-needs-fresh)。
915
+ rm -f "$STATE/pm-launch.env"; rc=0; TEAM_PM_IDENTITY_REGISTER=0; team_pm_identity_guard || rc=$?
916
+ check pm-missing-record-registers eq "$rc" 0
917
+ check pm-missing-record-flags-registration eq "${TEAM_PM_IDENTITY_REGISTER:-}" 1
918
+ check pm-missing-record-not-precreated bash -c '[ ! -e "$1" ]' _ "$STATE/pm-launch.env"
919
+ printf 'not a launch record\n' > "$STATE/pm-launch.env"; rc=0; team_pm_identity_guard || rc=$?
920
+ check pm-unreadable-record-needs-fresh eq "$rc" 1
921
+ rm -f "$STATE/pm-launch.env"
863
922
  TEAM_PM_FRESH_LAUNCH=1; team_pm_metadata_publish test-nonce
864
923
  # P228/R6(OBS1):PM 记录也发布实际交付的身份字段(与 worker 同一份判据);成功行只声明已交付的
865
924
  TEAM_PM_CMD="$TMP/recording-pi --model {model} {prompt}"; TEAM_PM_FRESH_LAUNCH=1
@@ -921,20 +980,447 @@ if has pm || has boundary; then
921
980
  )
922
981
  if [ -n "${LIVE_SOCKET:-}" ]; then check pm-publication-failure-stops-uncommitted pm_publication_failure; fi
923
982
  fi
983
+ # ---------------------------------------------------------------- heal / adopt / updatecheck(P261 · startup-self-heal)
984
+ # 三个前门共用一份「干净环境 + 私有 tmux 通道」的现场:真实 `team up` 会把 PM 拉起来(夹具自己的
985
+ # recording-pi),所以私有 socket 与私有 $TMP/bin/tmux 是前提(与 preview/boundary 组同一形状)。
986
+ # 真 tmux 的解析要跳过**包装层**:PATH 里可能已经有 teamsmith shim(本套件在启动时会清掉
987
+ # */scripts/shim,但调用方环境未必)或本套件自己刚装的私有 socket 包装($TMP/bin/tmux)。
988
+ # type -P 会欣然把包装当「真 tmux」返回,于是包装再包一层包装 —— 每次递归都追加一个 -L,最后
989
+ # 参数表撑爆(P261 实测:--select 里同时给 dispatch 与 heal 时就撞上)。
990
+ routing_real_tmux() {
991
+ local c
992
+ while IFS= read -r c; do
993
+ case "$c" in "$TMP"/*|*/scripts/shim/*) continue ;; esac
994
+ printf '%s\n' "$c"; return 0
995
+ done < <(type -a -p tmux 2>/dev/null)
996
+ return 1
997
+ }
998
+ if has heal || has adopt || has updatecheck; then
999
+ # preview/boundary 那一块(前面)可能已经装好了**同一条私有通道** —— 复用它,绝不在包装上再包一层。
1000
+ if [ -n "${LIVE_SOCKET:-}" ] && [ -x "$TMP/bin/tmux" ]; then
1001
+ STARTUP_TMUX_OWN=0
1002
+ else
1003
+ STARTUP_TMUX_OWN=1; STARTUP_PATH0="$PATH"
1004
+ LIVE_SOCKET="routing-${BASHPID}-${RANDOM}"
1005
+ TMUX_TMPDIR="$(tmp_root_socket_dir routing "tmux-$(id -u)/routing-999999-99999")" \
1006
+ || TMUX_TMPDIR="$TMP/tmux"
1007
+ export TMUX_TMPDIR; mkdir -p "$TMUX_TMPDIR" "$TMP/bin"
1008
+ REAL_TMUX="$(routing_real_tmux)" || { printf 'routing: 找不到真 tmux\n' >&2; exit 3; }
1009
+ printf '#!/usr/bin/env bash\nexec %q -L %q "$@"\n' "$REAL_TMUX" "$LIVE_SOCKET" > "$TMP/bin/tmux"; chmod +x "$TMP/bin/tmux"
1010
+ export PATH="$TMP/bin:$PATH"
1011
+ fi
1012
+ tmux_iso_require routing launch --tmpdir "$TMUX_TMPDIR" --sock-name "$LIVE_SOCKET" --own-root "$TMP" --own-root "$TMUX_TMPDIR"
1013
+ fi
1014
+ startup_clean=(env -u TEAM_ROOT -u TEAM_MAIN_ROOT -u TEAM_ROOT_SOURCE -u TEAM_ROOT_WAS -u TEAM_PROJECT \
1015
+ -u TEAM_SESSION -u TEAM_SESSION_FROM -u TEAM_PM_WINDOW -u TEAM_AGENTS -u TEAM_DOCS_DIR \
1016
+ -u TEAM_WORKTREES_DIR -u TEAM_GATES -u TEAM_VCS -u TEAM_CONFIG -u TEAM_CONFIG_FILE \
1017
+ -u TEAM_STATE_DIR -u TEAM_SKILL_DIR -u TEAM_PULSE_WINDOW -u TEAM_MODEL_RETIRED_ENV -u TEAM_UPDATE_CHECK)
1018
+ s_run() { # <dir> [VAR=VAL…] -- <team args…>:真 CLI、干净环境、私有 PATH
1019
+ local d="$1"; shift
1020
+ local -a extra=()
1021
+ while [ $# -gt 0 ] && [ "$1" != '--' ]; do extra+=("$1"); shift; done
1022
+ [ "${1:-}" = '--' ] && shift
1023
+ RC=0; OUT="$( cd "$d" && "${startup_clean[@]}" "${extra[@]}" timeout 300 bash "$CLI" "$@" 2>&1 )" || RC=$?
1024
+ printf 'command=%q ' "$@"; printf '\nrc=%s\n%s\n' "$RC" "$OUT"
1025
+ }
1026
+ s_new_repo() { # <dir>
1027
+ rm -rf "$1"; mkdir -p "$1/.pi/team" "$1/docs/team/tasks" "$1/docs/team/reports" "$1/docs/team/threads" "$1/docs/team/inbox" "$1/docs/team/reviews"
1028
+ ( cd "$1" && git init -q -b main && git config user.name fixture && git config user.email fixture@example.invalid \
1029
+ && printf '# startup fixture\n' > README.md && git add -A && git commit -qm fixture ) >/dev/null 2>&1
1030
+ }
1031
+ s_backups() { find "$1/.pi/team/state/config-backups" -maxdepth 1 -type f -name 'config.sh.pre-*' 2>/dev/null | wc -l | tr -d ' '; }
1032
+ s_audit() { if [ -f "$1/.pi/team/state/config.log" ]; then sha "$1/.pi/team/state/config.log"; else printf absent; fi; }
1033
+ s_stop_pm() { # <dir> <session>:停掉夹具自己的 PM(私有 socket 与私有 session),等到 up --print 不再放行
1034
+ tmux -L "$LIVE_SOCKET" kill-session -t "$2" 2>/dev/null || true
1035
+ local i
1036
+ for i in 1 2 3 4 5 6 7 8 9 10; do
1037
+ s_run "$1" -- up --print
1038
+ [ "$RC" != 0 ] && break
1039
+ sleep 0.5
1040
+ done
1041
+ }
1042
+ s_brief() { # <dir> <id> <category>
1043
+ cat > "$1/docs/team/tasks/$2-fixture.md" <<EOF
1044
+ # $2 · fixture
1045
+ agent: dev
1046
+ phase: apply
1047
+ category: $3
1048
+ change: -
1049
+ anchor: none (infra) — isolated startup fixture
1050
+ branch: task/$2-fixture
1051
+ ## Scope
1052
+ No real provider. The brief only exists so dispatch can resolve its category.
1053
+ EOF
1054
+ mkdir -p "$1/.worktrees"
1055
+ ( cd "$1" && git worktree add -qb "task/$2-fixture" ".worktrees/dev" ) >/dev/null 2>&1 || true
1056
+ }
1057
+
1058
+ if has heal; then
1059
+ H="$TMP/heal"; s_new_repo "$H"
1060
+ cat > "$H/.pi/team/config.sh" <<EOF
1061
+ TEAM_PROJECT='heal-fixture'
1062
+ TEAM_SESSION='routing-heal'
1063
+ TEAM_PM_WINDOW='pm'
1064
+ TEAM_DOCS_DIR='docs/team'
1065
+ TEAM_AGENTS='dev verify'
1066
+ TEAM_AGENT_MODELS='dev=vendor/light verify=vendor/strong:high'
1067
+ TEAM_DEFAULT_MODEL='vendor/base'
1068
+ TEAM_PM_MODEL='vendor/pm:high'
1069
+ TEAM_WORKTREES_DIR='.worktrees'
1070
+ TEAM_VCS='local'
1071
+ TEAM_GATES='true'
1072
+ TEAM_MIN_FREE_SWAP_MB=0
1073
+ TEAM_MIN_TOTAL_MB=0
1074
+ TEAM_MIN_AVAIL_MB=0
1075
+ TEAM_TMP_MIN_FREE_MB=0
1076
+ TEAM_TMP_MIN_FREE_INODES=0
1077
+ TEAM_MODEL_LIMITS=''
1078
+ TEAM_UPDATE_CHECK=0
1079
+ TEAM_PI_BIN='$TMP/recording-pi'
1080
+ EOF
1081
+ s_brief "$H" H1 default
1082
+ cp -p "$H/.pi/team/config.sh" "$TMP/heal-original"
1083
+ # ① --print:同一份预告、一个字节都不写(配置 hash / 备份目录 / 审计 / 身份记录四不变)
1084
+ h0="$(sha "$H/.pi/team/config.sh")"; hb0="$(s_backups "$H")"; ha0="$(s_audit "$H")"
1085
+ s_run "$H" -- up --print
1086
+ check heal-print-rc eq "$RC" 0
1087
+ check heal-print-pairs bash -c '[[ "$1" == *"TEAM_AGENT_MODELS dev=vendor/light → TEAM_TASK_MODELS dev=vendor/light"* && "$1" == *"TEAM_DEFAULT_MODEL vendor/base → TEAM_TASK_MODELS default=vendor/base"* && "$1" == *"TEAM_PM_MODEL vendor/pm:high → TEAM_PM_MODEL vendor/pm:high"* ]]' _ "$OUT"
1088
+ check heal-print-backup contains "$OUT" 'config-backups/config.sh.pre-0.2.0-'
1089
+ check heal-print-restore contains "$OUT" '还原:cp '
1090
+ check heal-print-identity-preview contains "$OUT" '身份预告:此前没有启动记录'
1091
+ check heal-print-skip-npm contains "$OUT" '--print 下不联网、不写缓存'
1092
+ check heal-print-pure bash -c '[ "$1" = "$2" ] && [ "$3" = "$4" ] && [ "$5" = "$6" ] && [ ! -e "$7" ]' _ \
1093
+ "$(sha "$H/.pi/team/config.sh")" "$h0" "$(s_backups "$H")" "$hb0" "$(s_audit "$H")" "$ha0" "$H/.pi/team/state/pm-launch.env"
1094
+ # ② --no-migrate:不写、拒绝、给出可粘贴命令;粘回去 --dry-run 必须绿(P253 的吸收要求)
1095
+ s_run "$H" -- up --no-migrate
1096
+ check heal-nomigrate-refused bash -c '[ "$1" != 0 ]' _ "$RC"
1097
+ check heal-nomigrate-command contains "$OUT" "--task-models 'dev=vendor/light verify=vendor/strong:high default=vendor/base'"
1098
+ check heal-nomigrate-manual-route contains "$OUT" 'config upgrade-models'
1099
+ check heal-nomigrate-pure bash -c '[ "$1" = "$2" ] && [ "$3" = "$4" ]' _ \
1100
+ "$(sha "$H/.pi/team/config.sh")" "$h0" "$(s_backups "$H")" "$hb0"
1101
+ heal_derived="$(printf '%s\n' "$OUT" | awk -F"'" '/^ *--task-models /{print $2}' | head -1)"
1102
+ heal_derived_pm="$(printf '%s\n' "$OUT" | awk -F"'" '/^ *--pm-model /{print $2}' | head -1)"
1103
+ check heal-nomigrate-derived-nonempty bash -c '[ -n "$1" ] && [ -n "$2" ]' _ "$heal_derived" "$heal_derived_pm"
1104
+ s_run "$H" -- config upgrade-models --task-models "$heal_derived" --pm-model "$heal_derived_pm" --dry-run
1105
+ check heal-nomigrate-command-pasted eq "$RC" 0
1106
+ check heal-nomigrate-paste-pure eq "$(sha "$H/.pi/team/config.sh")" "$h0"
1107
+ # ③ 真跑:迁移 + 身份登记 + 启动(rc=0),逐键表、备份、审计、形状号、登记行、派单按类别选模型
1108
+ s_run "$H" -- up
1109
+ check heal-migrate-rc eq "$RC" 0
1110
+ check heal-migrate-pairs bash -c '[[ "$1" == *"TEAM_AGENT_MODELS verify=vendor/strong:high → TEAM_TASK_MODELS verify=vendor/strong:high"* ]]' _ "$OUT"
1111
+ check heal-migrate-values eq "$(grep -c "^TEAM_TASK_MODELS='dev=vendor/light verify=vendor/strong:high default=vendor/base'\$" "$H/.pi/team/config.sh" || true)" 1
1112
+ check heal-migrate-pm-eq eq "$(grep -c "^TEAM_PM_MODEL='vendor/pm:high'\$" "$H/.pi/team/config.sh" || true)" 1
1113
+ check heal-migrate-retired-gone bash -c '! grep -qE "^TEAM_(AGENT_MODELS|DEFAULT_MODEL)=" "$1"' _ "$H/.pi/team/config.sh"
1114
+ check heal-migrate-shape-number eq "$(grep -c "^TEAM_CONFIG_VERSION='2'\$" "$H/.pi/team/config.sh" || true)" 1
1115
+ check heal-migrate-restore-printed contains "$OUT" '还原:cp '
1116
+ check heal-backup-exists eq "$(s_backups "$H")" 1
1117
+ check heal-backup-name bash -c 'ls "$1"/.pi/team/state/config-backups/ | grep -q "^config.sh.pre-0.2.0-[0-9]*T[0-9]*Z\$"' _ "$H"
1118
+ check heal-backup-bytes bash -c 'cmp -s "$(ls "$1"/.pi/team/state/config-backups/config.sh.pre-* | head -1)" "$2"' _ "$H" "$TMP/heal-original"
1119
+ # 备份只保留最新 5 份(备份是恢复手段,不是档案)—— 直接调写入器再写 7 份,数一次。
1120
+ ( TEAM_STATE_DIR="$H/.pi/team/state" TEAM_MIGRATION_FROM=1
1121
+ for i in 1 2 3 4 5 6 7; do team_config_backup_write "$TMP/heal-original" "2026010${i}T000000Z" >/dev/null || exit 1; done )
1122
+ check heal-backup-keeps-five eq "$(s_backups "$H")" 5
1123
+ check heal-backup-keeps-newest bash -c 'ls "$1"/.pi/team/state/config-backups/ | sort | head -1 | grep -q "20260104T000000Z"' _ "$H"
1124
+ check heal-audit-actor contains "$(tail -1 "$H/.pi/team/state/config.log")" 'actor=up-migration'
1125
+ check heal-audit-shape contains "$(tail -1 "$H/.pi/team/state/config.log")" 'TEAM_CONFIG_VERSION'
1126
+ check heal-registration-line contains "$OUT" '已登记本次启动身份:model=vendor/pm:high resume_key=default'
1127
+ check heal-registration-record bash -c 'grep -qx "model=vendor/pm:high" "$1" && grep -qx "mode=continued" "$1"' _ "$H/.pi/team/state/pm-launch.env"
1128
+ s_run "$H" -- config list
1129
+ check heal-config-list eq "$RC" 0
1130
+ s_run "$H" -- dispatch dev H1 docs/team/tasks/H1-fixture.md --print
1131
+ check heal-dispatch-category eq "$RC" 0
1132
+ check heal-dispatch-model contains "$OUT" 'category=default model=vendor/base'
1133
+ cp -p "$H/.pi/team/config.sh" "$TMP/heal-migrated"
1134
+ # ④ 迁移后 --print 给出完整启动预览(不再是迁移预告)
1135
+ s_run "$H" -- up --print
1136
+ check heal-print-complete contains "$OUT" '完整命令:'
1137
+ check heal-print-complete-identity contains "$OUT" '身份预告:记录与当前解析一致'
1138
+ check heal-print-complete-no-migration bash -c '! [[ "$1" == *"检测到旧形状配置"* ]]' _ "$OUT"
1139
+ # ⑤ 失败关闭:rc 非 0、配置 hash 不变、备份不增、审计不变、点名障碍(design §4)
1140
+ # 行前缀 "-" = 先删掉那个键的行(替换而不是制造重复键)。
1141
+ heal_refusal() { # <name> <期望命中的障碍文本> <config 变更行…>
1142
+ local name="$1" want="$2"; shift 2
1143
+ cp -p "$TMP/heal-original" "$H/.pi/team/config.sh"
1144
+ local line
1145
+ for line in "$@"; do
1146
+ case "$line" in
1147
+ -*) sed -i "/^${line#-}=/d" "$H/.pi/team/config.sh" ;;
1148
+ *) printf '%s\n' "$line" >> "$H/.pi/team/config.sh" ;;
1149
+ esac
1150
+ done
1151
+ local c0 b0 a0
1152
+ c0="$(sha "$H/.pi/team/config.sh")"; b0="$(s_backups "$H")"; a0="$(s_audit "$H")"
1153
+ s_run "$H" -- up
1154
+ check "heal-refuse-$name" bash -c '[ "$1" != 0 ]' _ "$RC"
1155
+ check "heal-refuse-$name-named" contains "$OUT" "$want"
1156
+ check "heal-refuse-$name-pure" bash -c '[ "$1" = "$2" ] && [ "$3" = "$4" ] && [ "$5" = "$6" ]' _ \
1157
+ "$(sha "$H/.pi/team/config.sh")" "$c0" "$(s_backups "$H")" "$b0" "$(s_audit "$H")" "$a0"
1158
+ }
1159
+ heal_refusal not-locatable-duplicate 'duplicate TEAM_DEFAULT_MODEL' 'TEAM_DEFAULT_MODEL="vendor/other"'
1160
+ heal_refusal not-locatable-dynamic 'dynamic/indirect value' '-TEAM_DEFAULT_MODEL' 'TEAM_DEFAULT_MODEL=$(printf vendor/x)'
1161
+ heal_refusal invalid-model '不合法' '-TEAM_AGENT_MODELS' 'TEAM_AGENT_MODELS="dev=notamodel"'
1162
+ heal_refusal invalid-model-advice '其余已推导出的对可以先手工提交' '-TEAM_AGENT_MODELS' 'TEAM_AGENT_MODELS="dev=notamodel verify=vendor/strong:high"'
1163
+ heal_refusal unnormalizable '不是合法类别名' '-TEAM_AGENT_MODELS' 'TEAM_AGENT_MODELS="@=vendor/x"'
1164
+ heal_refusal seat-collision '两个席位规范化后都叫类别 dev-1' '-TEAM_AGENT_MODELS' 'TEAM_AGENT_MODELS="Dev-1=vendor/x dev_1=vendor/y"'
1165
+ heal_refusal fallback-collision '兜底名与它撞名' '-TEAM_AGENT_MODELS' 'TEAM_AGENT_MODELS="Default=vendor/x"'
1166
+ heal_refusal contradictory '非空的新键 TEAM_TASK_MODELS' "TEAM_TASK_MODELS='routine=vendor/x'"
1167
+ heal_refusal unknown-shape '形状号是 3' "TEAM_CONFIG_VERSION='3'"
1168
+ heal_refusal contradictory-shape '却还有退休键' "TEAM_CONFIG_VERSION='2'"
1169
+ # 环境里的退休键:形状已是最新、文件里没有退休键,但环境里有 → 拒绝并给 unset(文件一个字节都不写)
1170
+ cp -p "$TMP/heal-migrated" "$H/.pi/team/config.sh"
1171
+ c0="$(sha "$H/.pi/team/config.sh")"
1172
+ s_run "$H" TEAM_AGENT_MODELS='dev=vendor/x' -- up
1173
+ check heal-refuse-env-retired bash -c '[ "$1" != 0 ]' _ "$RC"
1174
+ check heal-refuse-env-named contains "$OUT" 'unset TEAM_AGENT_MODELS'
1175
+ check heal-refuse-env-pure eq "$(sha "$H/.pi/team/config.sh")" "$c0"
1176
+ # ⑥ 新项目必须写形状号(init 与 bootstrap 各一条;翻转里删渲染参数 → 这两条必红)
1177
+ s_new_repo "$TMP/heal-init"
1178
+ s_run "$TMP/heal-init" -- init --no-skills --session heal-init --agents dev --vcs local --gates true \
1179
+ --task-models 'routine=vendor/light' --pm-model 'vendor/pm:high'
1180
+ check heal-init-shape-number eq "$(team_config_file_value "$TMP/heal-init/.pi/team/config.sh" TEAM_CONFIG_VERSION)" 2
1181
+ s_new_repo "$TMP/heal-boot"
1182
+ s_run "$TMP/heal-boot" -- bootstrap --no-pulse --agents dev --task-models 'routine=vendor/light' --pm-model 'vendor/pm:high'
1183
+ check heal-bootstrap-shape-number eq "$(team_config_file_value "$TMP/heal-boot/.pi/team/config.sh" TEAM_CONFIG_VERSION)" 2
1184
+ fi
1185
+
1186
+ if has adopt; then
1187
+ A="$TMP/adopt"; s_new_repo "$A"
1188
+ cat > "$A/.pi/team/config.sh" <<EOF
1189
+ TEAM_PROJECT='adopt-fixture'
1190
+ TEAM_SESSION='routing-adopt'
1191
+ TEAM_PM_WINDOW='pm'
1192
+ TEAM_DOCS_DIR='docs/team'
1193
+ TEAM_AGENTS='dev verify'
1194
+ TEAM_TASK_MODELS='routine=vendor/light default=vendor/base'
1195
+ TEAM_PM_MODEL='vendor/pm:high'
1196
+ TEAM_CONFIG_VERSION='2'
1197
+ TEAM_WORKTREES_DIR='.worktrees'
1198
+ TEAM_VCS='local'
1199
+ TEAM_GATES='true'
1200
+ TEAM_MIN_FREE_SWAP_MB=0
1201
+ TEAM_MIN_TOTAL_MB=0
1202
+ TEAM_MIN_AVAIL_MB=0
1203
+ TEAM_TMP_MIN_FREE_MB=0
1204
+ TEAM_TMP_MIN_FREE_INODES=0
1205
+ TEAM_MODEL_LIMITS=''
1206
+ TEAM_UPDATE_CHECK=0
1207
+ TEAM_PI_BIN='$TMP/recording-pi'
1208
+ EOF
1209
+ s_brief "$A" A1 default
1210
+ # ① 缺记录:--print 打印将要登记的那一行,且不建文件(design §7)
1211
+ s_run "$A" -- up --print
1212
+ check adopt-print-rc eq "$RC" 0
1213
+ check adopt-print-preview contains "$OUT" '身份预告:此前没有启动记录;这次启动会登记 model=vendor/pm:high'
1214
+ check adopt-print-fresh-note contains "$OUT" '--fresh-pm'
1215
+ check adopt-print-no-file bash -c '[ ! -e "$1" ]' _ "$A/.pi/team/state/pm-launch.env"
1216
+ # ② 真跑:缺记录 → 登记 + 启动,登记行说明 model/resume_key/mode
1217
+ s_run "$A" -- up
1218
+ check adopt-register-rc eq "$RC" 0
1219
+ check adopt-register-line contains "$OUT" '已登记本次启动身份:model=vendor/pm:high resume_key=default mode=continued'
1220
+ check adopt-register-record bash -c 'grep -qx "model=vendor/pm:high" "$1" && grep -qx "resume_key=default" "$1" && grep -qx "mode=continued" "$1"' _ "$A/.pi/team/state/pm-launch.env"
1221
+ # ③ 记录存在但不一致:仍拒绝,打印两边(suffix 显式)与哪一处变了,给两条出路;记录字节不变
1222
+ rec0="$(sha "$A/.pi/team/state/pm-launch.env")"
1223
+ sed -i "s|^TEAM_PM_MODEL=.*|TEAM_PM_MODEL='vendor/pm:low'|" "$A/.pi/team/config.sh"
1224
+ s_run "$A" -- up --print
1225
+ check adopt-changed-refused bash -c '[ "$1" != 0 ]' _ "$RC"
1226
+ check adopt-changed-both-sides bash -c '[[ "$1" == *"记录 model=vendor/pm:high"* && "$1" == *"现在 model=vendor/pm:low"* ]]' _ "$OUT"
1227
+ check adopt-changed-names-change contains "$OUT" 'model(记录 vendor/pm:high → 现在 vendor/pm:low)'
1228
+ check adopt-changed-fresh-route contains "$OUT" '--fresh-pm'
1229
+ check adopt-changed-adopt-route contains "$OUT" '--adopt-pm-identity --yes'
1230
+ check adopt-changed-record-pure eq "$(sha "$A/.pi/team/state/pm-launch.env")" "$rec0"
1231
+ # ③b PM 正在运行时 adopt 不写记录:运行中的身份就是记录里那一个(政策改动不重启它),这时改记录
1232
+ # 等于给「下一次续跑」安排一份跟在跑的会话对不上的身份 —— 拒绝并给两条路,记录逐字节不变。
1233
+ s_run "$A" -- up
1234
+ check adopt-running-still-runs eq "$RC" 0
1235
+ check adopt-running-no-change contains "$OUT" 'PM 在运行'
1236
+ rec_run="$(sha "$A/.pi/team/state/pm-launch.env")"
1237
+ s_run "$A" -- up --adopt-pm-identity --yes
1238
+ check adopt-running-refused bash -c '[ "$1" != 0 ]' _ "$RC"
1239
+ check adopt-running-named contains "$OUT" '--adopt-pm-identity:PM 正在运行'
1240
+ check adopt-running-record-pure eq "$(sha "$A/.pi/team/state/pm-launch.env")" "$rec_run"
1241
+ # 让 PM 停下来(夹具自己的私有 socket 与私有 session),后续 adopt 臂都在「停了」的形态下跑
1242
+ s_stop_pm "$A" routing-adopt
1243
+ check adopt-running-stopped bash -c '[ "$1" != 0 ]' _ "$RC"
1244
+ # ④ adopt 不带 --yes:拒绝并点名旗标,一个字节都不写
1245
+ s_run "$A" -- up --adopt-pm-identity
1246
+ check adopt-no-yes-refused bash -c '[ "$1" != 0 ]' _ "$RC"
1247
+ check adopt-no-yes-names-flag contains "$OUT" '--adopt-pm-identity 需要 --yes'
1248
+ check adopt-no-yes-record-pure eq "$(sha "$A/.pi/team/state/pm-launch.env")" "$rec0"
1249
+ # ⑤ --print 下 adopt 不写盘(预览承诺)
1250
+ s_run "$A" -- up --adopt-pm-identity --yes --print
1251
+ check adopt-print-refused bash -c '[ "$1" != 0 ]' _ "$RC"
1252
+ check adopt-print-no-write-note contains "$OUT" '--print 不写盘'
1253
+ check adopt-print-record-pure eq "$(sha "$A/.pi/team/state/pm-launch.env")" "$rec0"
1254
+ # ⑥ adopt --yes 真跑:写记录 + config.log 一行审计 + 声明行;之后同一身份能续
1255
+ s_run "$A" -- up --adopt-pm-identity --yes
1256
+ check adopt-yes-rc eq "$RC" 0
1257
+ check adopt-yes-declaration contains "$OUT" '我声明这次续跑的身份是 model=vendor/pm:low'
1258
+ check adopt-yes-record eq "$(grep '^model=' "$A/.pi/team/state/pm-launch.env")" 'model=vendor/pm:low'
1259
+ check adopt-yes-audit contains "$(tail -1 "$A/.pi/team/state/config.log")" 'key=pm-launch-identity'
1260
+ check adopt-yes-audit-old contains "$(tail -1 "$A/.pi/team/state/config.log")" 'model=vendor/pm:high'
1261
+ s_run "$A" -- up --print
1262
+ check adopt-follow-continues eq "$RC" 0
1263
+ check adopt-follow-identity contains "$OUT" '身份预告:记录与当前解析一致'
1264
+ check adopt-follow-command contains "$OUT" '完整命令:'
1265
+ # ⑦ 不可读记录:即使给了 --yes 仍拒绝(这个旗标声明值,不认领别人的/坏掉的记录)
1266
+ s_stop_pm "$A" routing-adopt # ⑥ 刚把 PM 起起来;运行中的拒绝是另一条判据(③b 证过)
1267
+ printf 'garbage\n' > "$A/.pi/team/state/pm-launch.env"
1268
+ bad0="$(sha "$A/.pi/team/state/pm-launch.env")"
1269
+ s_run "$A" -- up --adopt-pm-identity --yes
1270
+ check adopt-unreadable-refused bash -c '[ "$1" != 0 ]' _ "$RC"
1271
+ check adopt-unreadable-named contains "$OUT" '不可读'
1272
+ check adopt-unreadable-pure eq "$(sha "$A/.pi/team/state/pm-launch.env")" "$bad0"
1273
+ # ⑧ --fresh-pm 语义不变:坏记录也拦不住显式的新会话(回归)
1274
+ s_run "$A" -- up --print --fresh-pm
1275
+ check adopt-fresh-pm-preview eq "$RC" 0
1276
+ check adopt-fresh-pm-judgement contains "$OUT" '会话判定:fresh:--fresh-pm'
1277
+ fi
1278
+
1279
+ if has updatecheck; then
1280
+ U="$TMP/updatecheck"; s_new_repo "$U"
1281
+ # 本地版本从**被测树**取(产品的 local_v 与缓存里的 LOCAL= 都取 scripts/lib/common.sh 的
1282
+ # TEAM_VERSION);写死字面量会在发布落点时变成「与另一个版本比较」(P319 §4:0.2.0 → 0.3.0)。
1283
+ U_LOCAL="$(sed -n 's/^TEAM_VERSION=//p' "$SKILL/scripts/lib/common.sh" | head -1 | tr -d "\"'")"
1284
+ [ -n "$U_LOCAL" ] || U_LOCAL="$(sed -n 's/^[[:space:]]*"version":[[:space:]]*"\([^"]*\)".*/\1/p' "$TREE/package.json" | head -1)"
1285
+ # 更旧的那个必须**严格小于**本地版本:同主版本、次版本减一(0.3.0 → 0.2.0);次版本为 0 时退主版本。
1286
+ U_OLDER="$(printf '%s\n' "$U_LOCAL" | awk -F. '{ if ($2+0 > 0) printf "%d.%d.0\n", $1, $2-1; else printf "%d.0.0\n", ($1+0 > 0 ? $1-1 : 0) }')"
1287
+ cat > "$U/.pi/team/config.sh" <<EOF
1288
+ TEAM_PROJECT='updatecheck-fixture'
1289
+ TEAM_SESSION='routing-update'
1290
+ TEAM_PM_WINDOW='pm'
1291
+ TEAM_DOCS_DIR='docs/team'
1292
+ TEAM_AGENTS='dev verify'
1293
+ TEAM_TASK_MODELS='routine=vendor/light default=vendor/base'
1294
+ TEAM_PM_MODEL='vendor/pm:high'
1295
+ TEAM_CONFIG_VERSION='2'
1296
+ TEAM_WORKTREES_DIR='.worktrees'
1297
+ TEAM_VCS='local'
1298
+ TEAM_GATES='true'
1299
+ TEAM_MIN_FREE_SWAP_MB=0
1300
+ TEAM_MIN_TOTAL_MB=0
1301
+ TEAM_MIN_AVAIL_MB=0
1302
+ TEAM_TMP_MIN_FREE_MB=0
1303
+ TEAM_TMP_MIN_FREE_INODES=0
1304
+ TEAM_MODEL_LIMITS=''
1305
+ TEAM_UPDATE_CHECK=1
1306
+ TEAM_PI_BIN='$TMP/recording-pi'
1307
+ EOF
1308
+ s_brief "$U" U1 default
1309
+ # 桩 npm(与既有 fake-bin 同族):计数 + 按答案文件回答;TEAM_UPDATE_CHECK=0 的零调用是可断言的。
1310
+ npm_stub() { # <答案|FAIL>
1311
+ if [ "$1" = FAIL ]; then
1312
+ printf '#!/usr/bin/env bash\nprintf "call\\n" >> "%s"\nexit 1\n' "$TMP/npm-calls" > "$TMP/bin/npm"
1313
+ else
1314
+ printf '#!/usr/bin/env bash\nprintf "call\\n" >> "%s"\nprintf "%%s\\n" "%s"\n' "$TMP/npm-calls" "$1" > "$TMP/bin/npm"
1315
+ fi
1316
+ chmod +x "$TMP/bin/npm"
1317
+ }
1318
+ npm_calls() { [ -f "$TMP/npm-calls" ] && wc -l < "$TMP/npm-calls" | tr -d ' ' || printf '0'; }
1319
+ npm_stub 9.9.9; : > "$TMP/npm-calls"
1320
+ s_run "$U" -- up
1321
+ check updatecheck-start-rc eq "$RC" 0
1322
+ check updatecheck-start-decision contains "$OUT" 'PM 已启动'
1323
+ check updatecheck-newer-line contains "$OUT" "本地 teamsmith $U_LOCAL,npm 上已有 9.9.9"
1324
+ check updatecheck-upgrade-command contains "$OUT" "npm i -g teamsmith@9.9.9 --registry https://registry.npmjs.org"
1325
+ check updatecheck-never-installs contains "$OUT" '工具从不自己安装'
1326
+ check updatecheck-first-call eq "$(npm_calls)" 1
1327
+ check updatecheck-cache-written bash -c 'grep -q "^LATEST=9.9.9\$" "$1" && grep -q "^LOCAL=$2\$" "$1" && grep -q "^CHECKED_AT=[0-9]*\$" "$1"' _ "$U/.pi/team/state/update-check.env" "$U_LOCAL"
1328
+ # 新鲜缓存:再跑两次,零调用(TTL 24h 内不重复联网),但仍打同一行(缓存里的结论)
1329
+ fresh0="$(npm_calls)"
1330
+ s_run "$U" -- up; check updatecheck-fresh-rc eq "$RC" 0
1331
+ check updatecheck-fresh-decision contains "$OUT" 'PM 在运行'
1332
+ s_run "$U" -- up; check updatecheck-fresh-rc2 eq "$RC" 0
1333
+ check updatecheck-fresh-zero-calls eq "$(npm_calls)" "$fresh0"
1334
+ check updatecheck-cached-line contains "$OUT" 'npm 上已有 9.9.9'
1335
+ # 其余四种回答:过期缓存 → 各查一次、一声不响(相同/更旧/报错/解析不出)
1336
+ u_arm() { # <答案|FAIL> <名称> [env…]
1337
+ local answer="$1" name="$2"; shift 2
1338
+ printf 'CHECKED_AT=1\nLATEST=9.9.9\nLOCAL=%s\n' "$U_LOCAL" > "$U/.pi/team/state/update-check.env"
1339
+ npm_stub "$answer"
1340
+ local n0; n0="$(npm_calls)"
1341
+ s_run "$U" "$@" -- up
1342
+ UCALLS=$(( $(npm_calls) - n0 )); UOUT="$OUT"; URC="$RC"
1343
+ check "updatecheck-$name-rc" eq "$URC" 0
1344
+ check "updatecheck-$name-decision" contains "$UOUT" 'PM 在运行'
1345
+ check "updatecheck-$name-silent" bash -c '! [[ "$1" == *"npm 上已有"* ]]' _ "$UOUT"
1346
+ }
1347
+ u_arm "$U_LOCAL" same; check updatecheck-same-one-call eq "$UCALLS" 1
1348
+ u_arm "$U_OLDER" older; check updatecheck-older-one-call eq "$UCALLS" 1
1349
+ u_arm FAIL failing; check updatecheck-failing-one-call eq "$UCALLS" 1
1350
+ check updatecheck-failing-cache bash -c 'grep -q "^LATEST=-\$" "$1"' _ "$U/.pi/team/state/update-check.env"
1351
+ u_arm not-a-version unparsable; check updatecheck-unparsable-one-call eq "$UCALLS" 1
1352
+ # TEAM_UPDATE_CHECK=0:连查询都不发生,缓存一个字节都不动
1353
+ printf 'CHECKED_AT=1\nLATEST=9.9.9\nLOCAL=%s\n' "$U_LOCAL" > "$U/.pi/team/state/update-check.env"
1354
+ cache0="$(sha "$U/.pi/team/state/update-check.env")"; dis0="$(npm_calls)"
1355
+ npm_stub 9.9.9
1356
+ s_run "$U" TEAM_UPDATE_CHECK=0 -- up
1357
+ check updatecheck-disabled-rc eq "$RC" 0
1358
+ check updatecheck-disabled-decision contains "$OUT" 'PM 在运行'
1359
+ check updatecheck-disabled-zero-calls eq "$(npm_calls)" "$dis0"
1360
+ check updatecheck-disabled-cache-pure eq "$(sha "$U/.pi/team/state/update-check.env")" "$cache0"
1361
+ check updatecheck-disabled-silent bash -c '! [[ "$1" == *"npm 上已有"* ]]' _ "$OUT"
1362
+ # 有界:桩 npm 挂住 30s → 查询必须在 2s 上限内被放弃(静默、rc 与启动决策不变)
1363
+ printf '#!/usr/bin/env bash\nprintf "call\\n" >> "%s"\nsleep 30\n' "$TMP/npm-calls" > "$TMP/bin/npm"; chmod +x "$TMP/bin/npm"
1364
+ printf 'CHECKED_AT=1\nLATEST=9.9.9\nLOCAL=%s\n' "$U_LOCAL" > "$U/.pi/team/state/update-check.env"
1365
+ uc0="$(npm_calls)"; ut0="$(date +%s)"
1366
+ s_run "$U" -- up
1367
+ ut1="$(date +%s)"
1368
+ check updatecheck-bounded-rc eq "$RC" 0
1369
+ check updatecheck-bounded-decision contains "$OUT" 'PM 在运行'
1370
+ check updatecheck-bounded-silent bash -c '! [[ "$1" == *"npm 上已有"* ]]' _ "$OUT"
1371
+ check updatecheck-bounded-called eq "$(( $(npm_calls) - uc0 ))" 1
1372
+ # P316:不判秒数;桩挂 30s 而命令返回,本身就证明它没被拖住(rc/决策/缓存三条已断言)。
1373
+ printf ' \033[2m· 参考 updatecheck-bounded:用时 %ss(不判快慢)\033[0m\n' "$((ut1 - ut0))"
1374
+ # --print:不联网、不写缓存,并说明跳过了检查
1375
+ printf 'CHECKED_AT=1\nLATEST=9.9.9\nLOCAL=%s\n' "$U_LOCAL" > "$U/.pi/team/state/update-check.env"
1376
+ cache0="$(sha "$U/.pi/team/state/update-check.env")"; pr0="$(npm_calls)"
1377
+ npm_stub 9.9.9
1378
+ s_run "$U" -- up --print
1379
+ check updatecheck-print-rc eq "$RC" 0
1380
+ check updatecheck-print-skip contains "$OUT" '--print 下不联网、不写缓存'
1381
+ check updatecheck-print-zero-calls eq "$(npm_calls)" "$pr0"
1382
+ check updatecheck-print-cache-unchanged eq "$(sha "$U/.pi/team/state/update-check.env")" "$cache0"
1383
+ rm -f "$TMP/bin/npm"
1384
+ fi
1385
+
1386
+ # 收尾:私有通道如果是**本段**装的,就还原 PATH 并撤掉包装 —— 别把它留给后续(flip 套件会以子进程
1387
+ # 重跑本套件,继承的 PATH 里留着指向上一轮 socket 的包装,同样会递归)。
1388
+ if [ "${STARTUP_TMUX_OWN:-0}" = 1 ]; then
1389
+ export PATH="$STARTUP_PATH0"
1390
+ rm -f "$TMP/bin/tmux"
1391
+ fi
1392
+
924
1393
  if has flip; then
925
- CORE='policy,machine,init,config,upgrade,dispatch,resume,transaction,limits,preview,sid-readers,pm,boundary'
1394
+ CORE='policy,machine,init,config,upgrade,dispatch,resume,transaction,limits,preview,sid-readers,pm,heal,adopt,updatecheck,boundary'
1395
+ # P358:臂预算。`flip_run` 只能给**所有臂一个值**(每条臂跑哪些组由变异体决定,耗时差一个量级),
1396
+ # 所以这个值是**最慢那条臂**的上限,不是典型值:`template-shadow` 把 identity guard 整个拆掉之后,
1397
+ # boundary 组 29 类故障模板 × 4 种模式全部走到真派单 —— 变异树实测 842s(2026-10-21,P358;同一条
1398
+ # 命令的绿基线 411s)。原来的 900s 只剩 6% 余量,机器一忙就必然撞上(发布那轮 fail=2 → fail=1 的
1399
+ # 漂移就是这里来的)。取实测 × 2 = 1800s,与整段 7200s 同一个口径:**它只回答「它没动」,不回答
1400
+ # 「它慢」**。整段的上限归 §61b 那条段(smoke.sh 的 7200s),不因这里而变。
1401
+ FLIP_ARM_BUDGET=1800
1402
+ # 撞上限只是 rc=124(1 是「它自己判红」)。超时必须是一条**点名**的红:只留 rc=124 就把「哪条臂、
1403
+ # 用满多少秒」留给下一个人去猜,那正是同一类问题的下一次复发(P358)。
1404
+ flip_arm_budget_red() { # <tag> <elapsed-seconds>
1405
+ FAIL=$((FAIL+1))
1406
+ printf 'FAIL flip-%s-arm-budget 臂 %s 用满臂预算 %ss(实跑 %ss)仍未出结果 —— 这是「它没跑完」,不是「它红了」\n' \
1407
+ "$1" "$1" "$FLIP_ARM_BUDGET" "$2"
1408
+ }
926
1409
  # One green baseline and one green restoration of the whole slice; each red arm has its own copy.
927
1410
  flip_run() {
928
- local tag="$1" tree="$2" groups="$3" rc=0
929
- TEAM_ROUTING_TREE="$tree" TEAM_ROUTING_EVIDENCE="$TMP/flip-evidence/$tag" timeout 900 bash "$here/task-model-routing.sh" --select "$groups" > "$TMP/flip-$tag.log" 2>&1 || rc=$?
930
- printf 'CONTROL %s rc=%s log=%s\n' "$tag" "$rc" "$TMP/flip-$tag.log"
1411
+ local tag="$1" tree="$2" groups="$3" rc=0 started ended
1412
+ started="$(date +%s)"
1413
+ TEAM_ROUTING_TREE="$tree" TEAM_ROUTING_EVIDENCE="$TMP/flip-evidence/$tag" timeout "$FLIP_ARM_BUDGET" bash "$here/task-model-routing.sh" --select "$groups" > "$TMP/flip-$tag.log" 2>&1 || rc=$?
1414
+ ended="$(date +%s)"
1415
+ printf 'CONTROL %s rc=%s elapsed=%ss budget=%ss log=%s\n' "$tag" "$rc" "$((ended - started))" "$FLIP_ARM_BUDGET" "$TMP/flip-$tag.log"
931
1416
  tail -4 "$TMP/flip-$tag.log"
1417
+ [ "$rc" != 124 ] || flip_arm_budget_red "$tag" "$((ended - started))"
932
1418
  FLIP_RC="$rc"
933
1419
  }
934
1420
  flip_run baseline "$TREE" "$CORE"
935
1421
  check flip-baseline-green eq "$FLIP_RC" 0
936
1422
  if [ "$FLIP_RC" = 0 ]; then
937
- for mutation in unmapped-override required-categories fingerprint expanding-quote recovery-drift partial-publication unknown-as-zero latest-shell latest-monitor pm-fallback pm-publication extra-shadow template-shadow template-unbound template-roles monitor-record-drift literal-shell-expansion pm-literal-resplit worker-literal-resplit identity-overclaim init-legacy-proceeds template-retired-key; do
1423
+ for mutation in unmapped-override required-categories fingerprint expanding-quote recovery-drift partial-publication unknown-as-zero latest-shell latest-monitor pm-fallback pm-publication extra-shadow template-shadow template-unbound template-roles monitor-record-drift literal-shell-expansion pm-literal-resplit worker-literal-resplit identity-overclaim init-legacy-proceeds template-retired-key migration-row-removed no-backup no-shape-number missing-record-refused adopt-ignores-yes updatecheck-equal-prints updatecheck-ignores-off updatecheck-print-writes-cache legacy-route-placeholder; do
938
1424
  case "$mutation" in
939
1425
  unmapped-override) groups=dispatch ;;
940
1426
  required-categories) groups=policy,config,upgrade,dispatch ;;
@@ -949,9 +1435,16 @@ if has flip; then
949
1435
  extra-shadow|template-shadow|template-unbound|template-roles|literal-shell-expansion|pm-literal-resplit|worker-literal-resplit) groups=boundary ;;
950
1436
  monitor-record-drift) groups=sid-readers ;;
951
1437
  init-legacy-proceeds|template-retired-key) groups=init ;;
1438
+ migration-row-removed|no-backup|no-shape-number) groups=heal ;;
1439
+ missing-record-refused|adopt-ignores-yes) groups=adopt ;;
1440
+ updatecheck-equal-prints|updatecheck-ignores-off|updatecheck-print-writes-cache) groups=updatecheck ;;
1441
+ legacy-route-placeholder) groups=init ;;
952
1442
  esac
953
1443
  scratch="$TMP/mutants/$mutation"; mkdir -p "$scratch/skills/teamsmith"; touch "$scratch/.routing-mutant"
954
- for source_dir in scripts references templates extensions; do
1444
+ # P320/V62:拷贝源目录叫 extension(单数),产品 init 从 $TEAM_SKILL_DIR/extension/team.ts 装扩展;
1445
+ # 之前写成 extensions,既有 `[ ! -d ]` 判据就把它们跳过,变异体缺扩展、bootstrap 先报“找不到可安装的扩展源”,
1446
+ # 抢在目标拒绝之前失败。只纠正目录名,不加兜底。
1447
+ for source_dir in scripts references templates extension; do
955
1448
  [ ! -d "$SKILL/$source_dir" ] || cp -a "$SKILL/$source_dir" "$scratch/skills/teamsmith/"
956
1449
  done
957
1450
  before="$(find "$scratch/skills/teamsmith/scripts" -type f -print0 | sort -z | xargs -0 sha256sum | sha256sum | cut -d' ' -f1)"
@@ -1000,6 +1493,28 @@ if has flip; then
1000
1493
  check flip-init-legacy-proceeds-bootstrap grep -q '^FAIL init-legacy-bootstrap-refused$' "$TMP/flip-$mutation.log" ;;
1001
1494
  template-retired-key)
1002
1495
  check flip-template-retired-key-specific grep -q '^FAIL init-fresh-no-retired-key$' "$TMP/flip-$mutation.log" ;;
1496
+ migration-row-removed)
1497
+ check flip-migration-row-removed-specific grep -q '^FAIL heal-print-rc$' "$TMP/flip-$mutation.log" ;;
1498
+ no-backup)
1499
+ check flip-no-backup-specific grep -q '^FAIL heal-backup-exists$' "$TMP/flip-$mutation.log" ;;
1500
+ no-shape-number)
1501
+ check flip-no-shape-number-init grep -q '^FAIL heal-init-shape-number$' "$TMP/flip-$mutation.log"
1502
+ check flip-no-shape-number-bootstrap grep -q '^FAIL heal-bootstrap-shape-number$' "$TMP/flip-$mutation.log" ;;
1503
+ missing-record-refused)
1504
+ check flip-missing-record-refused-specific grep -q '^FAIL adopt-print-rc$' "$TMP/flip-$mutation.log" ;;
1505
+ adopt-ignores-yes)
1506
+ check flip-adopt-ignores-yes-specific grep -q '^FAIL adopt-no-yes-refused$' "$TMP/flip-$mutation.log" ;;
1507
+ updatecheck-equal-prints)
1508
+ check flip-updatecheck-equal-specific grep -q '^FAIL updatecheck-same-silent$' "$TMP/flip-$mutation.log" ;;
1509
+ updatecheck-ignores-off)
1510
+ check flip-updatecheck-off-specific grep -q '^FAIL updatecheck-disabled-zero-calls$' "$TMP/flip-$mutation.log" ;;
1511
+ updatecheck-print-writes-cache)
1512
+ check flip-updatecheck-print-specific grep -q '^FAIL updatecheck-print-cache-unchanged$' "$TMP/flip-$mutation.log" ;;
1513
+ legacy-route-placeholder)
1514
+ check flip-legacy-route-init grep -q '^FAIL init-legacy-plain-derived$' "$TMP/flip-$mutation.log"
1515
+ check flip-legacy-route-bootstrap grep -q '^FAIL init-legacy-bootstrap-derived$' "$TMP/flip-$mutation.log"
1516
+ check flip-legacy-route-write-path grep -q '^FAIL init-legacy-config-set-derived$' "$TMP/flip-$mutation.log"
1517
+ check flip-legacy-route-paste grep -q '^FAIL init-paste-derived-exact$' "$TMP/flip-$mutation.log" ;;
1003
1518
  esac
1004
1519
  cp -a "$SKILL/scripts/." "$scratch/skills/teamsmith/scripts/"
1005
1520
  restored="$(find "$scratch/skills/teamsmith/scripts" -type f -print0 | sort -z | xargs -0 sha256sum | sha256sum | cut -d' ' -f1)"