teamsmith 0.1.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/README.md +13 -7
  2. package/package.json +1 -1
  3. package/skills/teamsmith/CHANGELOG.md +67 -0
  4. package/skills/teamsmith/SKILL.md +26 -8
  5. package/skills/teamsmith/extension/team-notify.ts +37 -6
  6. package/skills/teamsmith/extension/team.ts +438 -0
  7. package/skills/teamsmith/references/agent-adapters.md +7 -7
  8. package/skills/teamsmith/references/config.md +65 -18
  9. package/skills/teamsmith/references/migration.md +220 -34
  10. package/skills/teamsmith/references/protocol.md +250 -25
  11. package/skills/teamsmith/references/troubleshooting.md +124 -7
  12. package/skills/teamsmith/references/workflows.md +66 -20
  13. package/skills/teamsmith/scripts/lib/cmd-agents.sh +525 -90
  14. package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +71 -10
  15. package/skills/teamsmith/scripts/lib/cmd-config.sh +562 -128
  16. package/skills/teamsmith/scripts/lib/cmd-death.sh +2 -15
  17. package/skills/teamsmith/scripts/lib/cmd-docs.sh +6 -3
  18. package/skills/teamsmith/scripts/lib/cmd-draft.sh +4 -4
  19. package/skills/teamsmith/scripts/lib/cmd-help.sh +677 -0
  20. package/skills/teamsmith/scripts/lib/cmd-init.sh +157 -5
  21. package/skills/teamsmith/scripts/lib/cmd-interrupt.sh +461 -0
  22. package/skills/teamsmith/scripts/lib/cmd-meeting.sh +2 -25
  23. package/skills/teamsmith/scripts/lib/cmd-project.sh +149 -105
  24. package/skills/teamsmith/scripts/lib/cmd-reap.sh +277 -0
  25. package/skills/teamsmith/scripts/lib/cmd-reply.sh +96 -0
  26. package/skills/teamsmith/scripts/lib/cmd-review.sh +188 -40
  27. package/skills/teamsmith/scripts/lib/cmd-status.sh +268 -30
  28. package/skills/teamsmith/scripts/lib/cmd-update.sh +36 -7
  29. package/skills/teamsmith/scripts/lib/cmd-watch.sh +634 -54
  30. package/skills/teamsmith/scripts/lib/common.sh +1560 -109
  31. package/skills/teamsmith/scripts/lib/gate-lock.sh +544 -0
  32. package/skills/teamsmith/scripts/monitor.mjs +34 -3
  33. package/skills/teamsmith/scripts/panel/README.md +22 -11
  34. package/skills/teamsmith/scripts/panel/draft-send.sh +11 -1
  35. package/skills/teamsmith/scripts/panel/panel.js +226 -224
  36. package/skills/teamsmith/scripts/panel/src/App.tsx +478 -184
  37. package/skills/teamsmith/scripts/panel/src/clipboard.ts +11 -5
  38. package/skills/teamsmith/scripts/panel/src/compose.ts +6 -3
  39. package/skills/teamsmith/scripts/panel/src/data.ts +95 -7
  40. package/skills/teamsmith/scripts/panel/src/layout.ts +703 -152
  41. package/skills/teamsmith/scripts/panel/src/main.tsx +129 -19
  42. package/skills/teamsmith/scripts/panel/src/settings.ts +1 -1
  43. package/skills/teamsmith/scripts/panel/src/strings/en.ts +76 -31
  44. package/skills/teamsmith/scripts/panel/src/strings/zh.ts +78 -33
  45. package/skills/teamsmith/scripts/panel/src/types.ts +204 -17
  46. package/skills/teamsmith/scripts/replies.mjs +896 -0
  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 +20 -6
  52. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +23 -3
  53. package/skills/teamsmith/templates/BOARD.md.tmpl +2 -2
  54. package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +7 -3
  55. package/skills/teamsmith/templates/PROTOCOL.md.tmpl +17 -0
  56. package/skills/teamsmith/templates/config.sh.tmpl +29 -5
  57. package/skills/teamsmith/templates/memory-seed.md.tmpl +3 -0
  58. package/skills/teamsmith/templates/pm-prompt.md.tmpl +41 -1
  59. package/skills/teamsmith/templates/report.md.tmpl +12 -0
  60. package/skills/teamsmith/templates/task.md.tmpl +4 -0
  61. package/skills/teamsmith/tests/bg-ledger-harness.mjs +464 -40
  62. package/skills/teamsmith/tests/bg-ledger.sh +168 -10
  63. package/skills/teamsmith/tests/checkout-shape-probe.sh +3 -1
  64. package/skills/teamsmith/tests/config-cli.sh +320 -300
  65. package/skills/teamsmith/tests/death-cause.sh +5 -2
  66. package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +7 -1
  67. package/skills/teamsmith/tests/fixtures/p287/lint-good.sh.in +3 -0
  68. package/skills/teamsmith/tests/fixtures/p287/lint-hardcoded.sh.in +3 -0
  69. package/skills/teamsmith/tests/fixtures/p287/lint-no-ns.sh.in +3 -0
  70. package/skills/teamsmith/tests/fixtures/p55/flip-p49.sh +18 -6
  71. package/skills/teamsmith/tests/flip-m33.sh +5 -3
  72. package/skills/teamsmith/tests/flip-m37.sh +4 -1
  73. package/skills/teamsmith/tests/flip-m4.3.sh +4 -1
  74. package/skills/teamsmith/tests/flip-m6.3.sh +4 -1
  75. package/skills/teamsmith/tests/flip-m6.5.sh +4 -1
  76. package/skills/teamsmith/tests/flip-m7.2.sh +4 -1
  77. package/skills/teamsmith/tests/flip-p158.sh +2 -1
  78. package/skills/teamsmith/tests/flip-p210.sh +4 -1
  79. package/skills/teamsmith/tests/flip-p217.sh +4 -1
  80. package/skills/teamsmith/tests/flip-p287-lock.sh +342 -0
  81. package/skills/teamsmith/tests/flip-p287-name.sh +279 -0
  82. package/skills/teamsmith/tests/flip-p304-read-side.sh +98 -0
  83. package/skills/teamsmith/tests/flip-p308-skip-not-pass.sh +151 -0
  84. package/skills/teamsmith/tests/flip-p309-p162-deep.sh +122 -0
  85. package/skills/teamsmith/tests/flip-p310-lock.sh +216 -0
  86. package/skills/teamsmith/tests/flip-p310-socket.sh +125 -0
  87. package/skills/teamsmith/tests/help-surface.sh +1664 -0
  88. package/skills/teamsmith/tests/install-shape.sh +283 -22
  89. package/skills/teamsmith/tests/key-replies-pty.sh +374 -0
  90. package/skills/teamsmith/tests/key-replies-ui.sh +325 -0
  91. package/skills/teamsmith/tests/key-replies.sh +1314 -0
  92. package/skills/teamsmith/tests/ledger-ban.sh +9 -8
  93. package/skills/teamsmith/tests/ledger-claim.sh +248 -0
  94. package/skills/teamsmith/tests/lib/bounded-spin.sh +90 -0
  95. package/skills/teamsmith/tests/lib/model-policy.sh +30 -0
  96. package/skills/teamsmith/tests/lib/model-routing-boundary.sh +420 -0
  97. package/skills/teamsmith/tests/lib/model-routing-expansion.sh +155 -0
  98. package/skills/teamsmith/tests/lib/model-routing-flips.py +187 -0
  99. package/skills/teamsmith/tests/lib/model-routing-roles.sh +250 -0
  100. package/skills/teamsmith/tests/lib/proc-io.sh +103 -0
  101. package/skills/teamsmith/tests/lib/reply-fixture.sh +367 -0
  102. package/skills/teamsmith/tests/lib/section-guard.sh +258 -13
  103. package/skills/teamsmith/tests/lib/tmp-root.sh +139 -27
  104. package/skills/teamsmith/tests/lib/tmux-cap.sh +10 -1
  105. package/skills/teamsmith/tests/lib/tmux-iso.sh +39 -13
  106. package/skills/teamsmith/tests/loop-inventory.tsv +59 -47
  107. package/skills/teamsmith/tests/panel-b2.sh +107 -4
  108. package/skills/teamsmith/tests/panel-b3-stub.sh +139 -4
  109. package/skills/teamsmith/tests/panel-b3.sh +189 -29
  110. package/skills/teamsmith/tests/panel-choices.sh +81 -63
  111. package/skills/teamsmith/tests/panel-cpu.sh +3 -2
  112. package/skills/teamsmith/tests/panel-knobs.sh +7 -1
  113. package/skills/teamsmith/tests/panel-p21.sh +445 -241
  114. package/skills/teamsmith/tests/panel-snapshots.sh +41 -225
  115. package/skills/teamsmith/tests/panel-strings.mjs +33 -18
  116. package/skills/teamsmith/tests/perf.sh +122 -31
  117. package/skills/teamsmith/tests/pm-box-real.sh +1 -1
  118. package/skills/teamsmith/tests/pulse-nudge-key.sh +1 -1
  119. package/skills/teamsmith/tests/routes.sh +364 -109
  120. package/skills/teamsmith/tests/seat-interrupt.sh +1002 -0
  121. package/skills/teamsmith/tests/seat-visibility.sh +675 -0
  122. package/skills/teamsmith/tests/section-budgets.tsv +26 -12
  123. package/skills/teamsmith/tests/section-guard.sh +6 -1
  124. package/skills/teamsmith/tests/section-needs-audit.sh +24 -7
  125. package/skills/teamsmith/tests/section-paths.tsv +42 -26
  126. package/skills/teamsmith/tests/section-select.sh +90 -7
  127. package/skills/teamsmith/tests/slash-team-e2e.sh +323 -0
  128. package/skills/teamsmith/tests/slash-team.sh +617 -0
  129. package/skills/teamsmith/tests/smoke.sh +3762 -628
  130. package/skills/teamsmith/tests/snapshots/zh-dark-120-detail.txt +2 -2
  131. package/skills/teamsmith/tests/snapshots/zh-dark-120-p4.txt +2 -2
  132. package/skills/teamsmith/tests/snapshots/zh-dark-120.txt +9 -9
  133. package/skills/teamsmith/tests/snapshots/zh-dark-160-p4.txt +2 -2
  134. package/skills/teamsmith/tests/snapshots/zh-dark-160.txt +9 -9
  135. package/skills/teamsmith/tests/snapshots/zh-dark-59-detail.txt +1 -1
  136. package/skills/teamsmith/tests/snapshots/zh-dark-59-p4.txt +1 -1
  137. package/skills/teamsmith/tests/snapshots/zh-dark-59.txt +5 -5
  138. package/skills/teamsmith/tests/snapshots/zh-dark-99-p4.txt +2 -2
  139. package/skills/teamsmith/tests/snapshots/zh-dark-99.txt +5 -5
  140. package/skills/teamsmith/tests/snapshots/zh-light-120-detail.txt +2 -2
  141. package/skills/teamsmith/tests/snapshots/zh-light-120-p4.txt +2 -2
  142. package/skills/teamsmith/tests/snapshots/zh-light-120.txt +9 -9
  143. package/skills/teamsmith/tests/snapshots/zh-light-160-p4.txt +2 -2
  144. package/skills/teamsmith/tests/snapshots/zh-light-160.txt +9 -9
  145. package/skills/teamsmith/tests/snapshots/zh-light-59-detail.txt +1 -1
  146. package/skills/teamsmith/tests/snapshots/zh-light-59-p4.txt +1 -1
  147. package/skills/teamsmith/tests/snapshots/zh-light-59.txt +5 -5
  148. package/skills/teamsmith/tests/snapshots/zh-light-99-p4.txt +2 -2
  149. package/skills/teamsmith/tests/snapshots/zh-light-99.txt +5 -5
  150. package/skills/teamsmith/tests/task-header-model.sh +2 -1
  151. package/skills/teamsmith/tests/task-model-routing.sh +1511 -0
  152. package/skills/teamsmith/tests/tmp-hygiene.sh +782 -45
  153. package/skills/teamsmith/tests/tmux-identity-leak.sh +773 -0
  154. package/skills/teamsmith/tests/tmux-lint-legacy.txt +12 -18
  155. package/skills/teamsmith/tests/upgrade-recipe.sh +537 -0
  156. package/skills/teamsmith-init/SKILL.md +43 -43
  157. package/skills/teamsmith-init/references/bootstrap.md +8 -6
  158. package/skills/teamsmith-init/templates/bootstrap-prompt.md.tmpl +9 -5
@@ -79,7 +79,9 @@ export SMOKE_TMP_RUN_ID="${SMOKE_TMP_RUN_ID:-routes-$$-$(date +%s 2>/dev/null ||
79
79
 
80
80
  # shellcheck source=tests/lib/tmp-root.sh
81
81
  . "$here/lib/tmp-root.sh"
82
+ . "$here/lib/model-policy.sh"
82
83
  tmp="$(tmp_root_create routes)" || { printf 'routes: 临时根建不起来\n' >&2; exit 3; }
84
+ export HOME="$tmp/home"; mkdir -p "$HOME"
83
85
  PASS=0
84
86
  FIND=0
85
87
  SKIP=0
@@ -111,8 +113,10 @@ want() { local s; for s in "${SECTIONS[@]}"; do [ "$s" = "$1" ] && return 0; don
111
113
 
112
114
  # ── containment: the recording tmux shim (never calls the real tmux) ────────────────────────────────
113
115
  # P140 扩展:除了记账,它还替窗口 harness 签证 —— 窗口注册表(new-window/kill-window/list-windows)
114
- # 让“窗口存在”这件事自洽;TEAM_ROUTES_FAKE_LAUNCH=1 时,respawn-pane 把 harness 命令里的
116
+ # 让“窗口存在”这件事自洽;SMOKE_ROUTES_FAKE_LAUNCH=1 时,respawn-pane 把 harness 命令里的
115
117
  # (nonce, marker) 解析出来写下启动/退出证据(假窗口但真证据,不碰真 server)。
118
+ # 载体(TMUX_LOG/WINDOWS/FAKE_LAUNCH)故意用非 TEAM_ 的 SMOKE_ROUTES_* 前缀(P320):产品的
119
+ # team_tmux 对可能起 server 的动词会剥掉整个 TEAM_* 命名空间(M67/P274),载体落在里面就收不到。
116
120
  SHIM="$tmp/shim"
117
121
  TMUX_LOG="$tmp/tmux-calls.log"
118
122
  WINREG="$tmp/windows.reg"
@@ -122,8 +126,8 @@ cat > "$SHIM/tmux" <<'SHIM'
122
126
  # Recording tmux: session queries answer "absent", windows live in a registry file, everything is
123
127
  # recorded and exits 0. It never invokes the real tmux, so no call this process makes can reach a
124
128
  # live server.
125
- printf '%s\n' "$*" >> "${TEAM_ROUTES_TMUX_LOG:-/dev/null}" 2>/dev/null || true
126
- win="${TEAM_ROUTES_WINDOWS:-/dev/null}"
129
+ printf '%s\n' "$*" >> "${SMOKE_ROUTES_TMUX_LOG:-/dev/null}" 2>/dev/null || true
130
+ win="${SMOKE_ROUTES_WINDOWS:-/dev/null}"
127
131
  sub="" t="" name=""
128
132
  while [ $# -gt 0 ]; do
129
133
  case "$1" in
@@ -152,9 +156,9 @@ case "$sub" in
152
156
  new-window) reg "${t:-?}:$name"; exit 0 ;;
153
157
  kill-window) unreg "${t:-?}"; exit 0 ;;
154
158
  respawn-pane)
155
- # P140:TEAM_ROUTES_FAKE_LAUNCH=1 时替窗口 harness 写下本轮 (nonce, pid) 启动证据与 (nonce, 0)
159
+ # P140:SMOKE_ROUTES_FAKE_LAUNCH=1 时替窗口 harness 写下本轮 (nonce, pid) 启动证据与 (nonce, 0)
156
160
  # 退出证据 —— 内容从 harness 命令行里解析,不是猜的;默认关着(只有最终拒绝路线真拉起时用)。
157
- if [ "${TEAM_ROUTES_FAKE_LAUNCH:-0}" = "1" ]; then
161
+ if [ "${SMOKE_ROUTES_FAKE_LAUNCH:-0}" = "1" ]; then
158
162
  inner="" prev=""
159
163
  for a in "${rest[@]}"; do [ "$prev" = "-lc" ] && inner="$a"; prev="$a"; done
160
164
  if [ -n "$inner" ]; then
@@ -191,7 +195,8 @@ new_fixture() {
191
195
  ( cd "$d" && git init -q -b main && git config user.email routes@teamsmith && git config user.name routes \
192
196
  && printf '{"name":"%s","scripts":{"verify":"true"}}\n' "$name" > package.json \
193
197
  && git add -A && git commit -qm init ) >/dev/null 2>&1
194
- if ! ( cd "$d" && env PATH="$SHIM:$PATH" TEAM_PI_BIN=/bin/true TEAM_ROUTES_TMUX_LOG="$TMUX_LOG" \
198
+ routing_fixture_config "$d/.pi/team/config.sh" "$skill/templates/config.sh.tmpl" "routes-$name" 'dev verify' || return 1
199
+ if ! ( cd "$d" && env PATH="$SHIM:$PATH" TEAM_PI_BIN=/bin/true SMOKE_ROUTES_TMUX_LOG="$TMUX_LOG" \
195
200
  TEAM_MEETINGS_DIR="$d/.meetings" TEAM_PI_AGENT_DIR="$d/.pi-agent" \
196
201
  bash "$team" init --no-skills --session "routes-$name" --agents "dev verify" --vcs local \
197
202
  --gates true --docs docs/team ) >"$tmp/$name-init.log" 2>&1; then
@@ -207,7 +212,7 @@ mr_run() {
207
212
  local d="$1"; shift
208
213
  local out rc
209
214
  out="$( cd "$d" && env -u TMUX -u TMUX_PANE \
210
- PATH="$SHIM:$PATH" TEAM_PI_BIN=/bin/true TEAM_ROUTES_TMUX_LOG="$TMUX_LOG" \
215
+ PATH="$SHIM:$PATH" TEAM_PI_BIN=/bin/true SMOKE_ROUTES_TMUX_LOG="$TMUX_LOG" \
211
216
  TEAM_MEETINGS_DIR="$d/.meetings" TEAM_PI_AGENT_DIR="$d/.pi-agent" \
212
217
  ${TIMEOUT_BIN:+"$TIMEOUT_BIN" "$timeout_sec"} bash "$team" "$@" </dev/null 2>&1 )"
213
218
  rc=$?
@@ -228,7 +233,7 @@ mr_known_tables() {
228
233
  inb && /^esac/ { inb=0 }
229
234
  inb && /^[[:space:]]+[A-Za-z0-9_'"'"'|.-]+\)/ {
230
235
  line=$0; sub(/^[[:space:]]+/,"",line); sub(/\).*/,"",line)
231
- n=split(line,a,"|"); for (i=1;i<=n;i++){ gsub(/[^a-z0-9-]/,"",a[i]); if(a[i]!="") printf "%s ", a[i] }
236
+ n=split(line,a,"|"); for (i=1;i<=n;i++){ if (a[i] ~ /^__/) continue; gsub(/[^a-z0-9-]/,"",a[i]); if(a[i]!="") printf "%s ", a[i] }
232
237
  }' "$src")"
233
238
  MRI_SUBS=""
234
239
  for f in "$skill"/scripts/lib/cmd-*.sh; do
@@ -442,81 +447,205 @@ mr_probe_claim() {
442
447
  return 0
443
448
  }
444
449
 
450
+ # ── Walk A: the manifest's usage lines, rendered on every level and probed ─────────────────────────
451
+ # The working set comes from the command manifest (the same file the renderer reads), never from
452
+ # whatever text a page happens to yield: for every command the manifest carries, every usage line it
453
+ # declares must be printed on that command's page and probed, and a command the CLI accepts while the
454
+ # manifest omits it is a finding naming that command. Coverage is "every command × every usage line".
455
+ mr_manifest() { printf '%s\n' "$skill/scripts/strings/commands.tsv"; }
456
+ mr_cmds() { awk -F'\t' '$1=="cmd"{print $2}' "$(mr_manifest)"; }
457
+ mr_groups() { awk -F'\t' '$1=="group"{print $2}' "$(mr_manifest)"; }
458
+ mr_field() { awk -F'\t' -v n="$1" -v f="$2" '$1=="cmd" && $2==n {print $f}' "$(mr_manifest)"; }
459
+ mr_begin() { awk -F'\t' '$1=="begin"{for(i=2;i<=NF;i++) printf "%s ", $i}' "$(mr_manifest)"; }
460
+ mr_is_alias() { awk -F'\t' -v a="$1" '$1=="cmd"{n=split($7,x," "); for(i=1;i<=n;i++) if(x[i]==a) f=1} END{exit !f}' "$(mr_manifest)"; }
461
+ mr_is_cmd() { awk -F'\t' -v a="$1" '$1=="cmd" && $2==a {f=1} END{exit !f}' "$(mr_manifest)"; }
462
+
463
+ # mr_fragments → every declared usage fragment, one per line (with the command it belongs to)
464
+ mr_fragments() {
465
+ awk -F'\t' '$1=="cmd"{n=split($4,f," ;; "); for(i=1;i<=n;i++) print $2 "\t" f[i]}' "$(mr_manifest)"
466
+ }
467
+
468
+ # mr_pages → render the menu, every group page and every command page; prints "<kind>\t<label>"
469
+ mr_pages() {
470
+ local pages="$tmp/pages" spec kind label
471
+ mkdir -p "$pages"
472
+ local -a jobs=()
473
+ local g n
474
+ jobs+=("menu:")
475
+ for g in $(mr_groups); do jobs+=("group:$g"); done
476
+ for n in $(mr_cmds); do jobs+=("command:$n"); done
477
+ local running=0
478
+ for spec in "${jobs[@]}"; do
479
+ kind="${spec%%:*}"; label="${spec#*:}"
480
+ ( cd "$tmp" && env -u TMUX -u TMUX_PANE bash "$team" help $label > "$pages/$kind--$label.txt" 2>/dev/null ) &
481
+ running=$((running + 1))
482
+ if [ "$running" -ge 6 ]; then wait -n 2>/dev/null || true; running=$((running - 1)); fi
483
+ done
484
+ wait 2>/dev/null || true
485
+ printf '%s\n' "${jobs[@]}"
486
+ }
487
+
488
+ # mr_page_usage <page-file> → the usage entries of a page, one per line (continuations joined)
489
+ mr_page_usage() {
490
+ awk '
491
+ function indent(l) { m=match(l, /[^ ]/); return m-1 }
492
+ { l=$0
493
+ if (l ~ /^[ \t]*$/) next
494
+ ind=indent(l)
495
+ if (l ~ /^──/) { inblock=1; lastindent=-1; cur=""; next }
496
+ if (!inblock) next
497
+ if (ind == 0) { if (cur!="") { print cur; cur="" }; inblock=0; next }
498
+ if (lastindent >= 0 && ind > lastindent && ind < 6) { if (cur != "") cur = cur " " substr(l, ind+1); next }
499
+ if (lastindent >= 0 && ind > lastindent) { next } # the description block: not part of the usage line
500
+ if (cur != "") print cur
501
+ cur=substr(l, ind+1); lastindent=ind
502
+ }
503
+ END { if (cur != "") print cur }
504
+ ' "$1"
505
+ }
506
+
507
+ # mr_manifest_claims → $tmp/walk-a.tsv: the manifest's usage lines, judged by the same parser.
508
+ # The walk and its non-vacuity control both take their working set from here, so neither can drift
509
+ # from the command manifest the renderer reads.
510
+ mr_manifest_claims() {
511
+ mr_known_tables
512
+ mr_write_parser
513
+ { printf '── manifest ──\n'
514
+ while IFS=$'\t' read -r c frag; do printf ' %s\n' "$frag"; done < <(mr_fragments)
515
+ } > "$tmp/manifest-page.txt"
516
+ awk -v tops="$MRI_TOPS" -v subs="$MRI_SUBS" -f "$tmp/walk-a.awk" "$tmp/manifest-page.txt" \
517
+ > "$tmp/walk-a.tsv" 2>"$tmp/manifest-claims.err"
518
+ [ -s "$tmp/manifest-claims.err" ] && return 1
519
+ return 0
520
+ }
521
+
445
522
  mr_walk_a() {
446
- section "walk · team help 的每条用法行 ↔ 解析器(打印的每个 --flag 都要被自己的解析器接受)"
447
- local help_out
448
- help_out="$( cd "$tmp" && env PATH="$SHIM:$PATH" bash "$team" help 2>&1 )"
449
- if ! printf '%s\n' "$help_out" | grep -q '用法:'; then
450
- finding "team help 没有打印用法头部(不可解析)"
523
+ section "walk · 帮助面每一级(菜单 / 组页 / 命令页)↔ 命令清单 ↔ 真解析器"
524
+ local manifest; manifest="$(mr_manifest)"
525
+ if [ ! -f "$manifest" ]; then
526
+ finding "walk: 没有命令清单($manifest)—— 帮助面没有单一真源"
451
527
  return 1
452
528
  fi
453
529
  mr_known_tables
454
530
  mr_write_parser
455
- printf '%s\n' "$help_out" > "$tmp/help.txt"
456
- # 全角 |/ → \x1f(bash 的字面替换按字节序列匹配,安全;awk 的字符类不行)。
457
- local prepped="" hline
458
- while IFS= read -r hline; do
459
- hline="${hline//|/$'\x1f'}"
460
- prepped="$prepped${hline////$'\x1f'}"$'\n'
461
- done <<< "$help_out"
462
- printf '%s' "$prepped" | awk -v tops="$MRI_TOPS" -v subs="$MRI_SUBS" -f "$tmp/walk-a.awk" > "$tmp/walk-a.tsv" 2>"$tmp/walk-a.err"
463
- if [ -s "$tmp/walk-a.err" ]; then
464
- finding "Walk A 解析器报错:$(head -2 "$tmp/walk-a.err" | tr '\n' ' ')"
465
- return 1
466
- fi
531
+ local failed=0
467
532
 
468
- local n_entry n_claim
469
- n_entry="$(grep -ac '^ENTRY' "$tmp/walk-a.tsv" || true)"
470
- n_claim="$(grep -ac '^CLAIM' "$tmp/walk-a.tsv" || true)"
471
- if [ "${n_entry:-0}" -lt 5 ] || [ "${n_claim:-0}" -lt 10 ]; then
472
- finding "Walk A 解析出的条目/断言太少(entry=$n_entry claim=$n_claim)—— 解析器或 help 形状变了"
473
- grep -a '^FAIL' "$tmp/walk-a.tsv" | head -5 | sed 's/^/ /'
533
+ # ① 覆盖度:dispatcher 接受的每个名字都要有记录或别名声明;清单里每个命令都要真的被接受
534
+ local n missing=0
535
+ for n in $MRI_TOPS; do
536
+ [ "$n" = "panel-data" ] && continue
537
+ mr_is_cmd "$n" && continue
538
+ mr_is_alias "$n" || { finding "walk: dispatcher 接受的 $n 在命令清单里没有记录(也没有别名声明)"; missing=1; }
539
+ done
540
+ [ "$missing" = "0" ] && ok "清单盖住 dispatcher 接受的每个名字($(printf '%s\n' $MRI_TOPS | grep -c . || true) 个标签,内部标签 __* 不算命令名)"
541
+ local orphan=0
542
+ for n in $(mr_cmds); do
543
+ printf '%s\n' $MRI_TOPS | grep -qx "$n" || { finding "walk: 清单里的 $n 不是 dispatcher 接受的命令"; orphan=1; }
544
+ done
545
+ [ "$orphan" = "0" ] && ok "清单里每个命令都被 dispatcher 接受($(mr_cmds | grep -c . || true) 个命令)"
546
+
547
+ # ② 工作集来自清单:把清单的每个用法片段喂同一个解析器
548
+ if ! mr_manifest_claims; then
549
+ finding "walk: 清单解析器报错:$(head -2 "$tmp/manifest-claims.err" | tr '\n' ' ')"
474
550
  return 1
475
551
  fi
476
- local ln line
477
- while IFS=$'\t' read -r _ ln; do
478
- line="$(sed -n "${ln}p" "$tmp/help.txt" | sed 's/^[[:space:]]*//' | cut -c1-60)"
479
- ok "用法行 L$ln:$line"
480
- done < <(grep -a '^ENTRY' "$tmp/walk-a.tsv")
481
- local failed=0
482
552
  while IFS=$'\t' read -r _ ln rest; do
483
- finding "L$ln 无法归属(解析器拒绝静默跳过):$rest"
553
+ finding "walk: 清单里有无法归属的用法行(解析器拒绝静默跳过):$rest"
484
554
  failed=1
485
555
  done < <(grep -a '^FAIL' "$tmp/walk-a.tsv")
486
- [ "$failed" = "1" ] && return 1
556
+ local n_manifest_claims n_manifest_entries
557
+ n_manifest_claims="$(grep -ac '^CLAIM' "$tmp/walk-a.tsv" || true)"
558
+ n_manifest_entries="$(grep -ac '^ENTRY' "$tmp/walk-a.tsv" || true)"
559
+ if [ "${n_manifest_entries:-0}" -lt 5 ] || [ "${n_manifest_claims:-0}" -lt 10 ]; then
560
+ finding "walk: 清单解析出的条目/断言太少(entry=$n_manifest_entries claim=$n_manifest_claims)"
561
+ return 1
562
+ fi
487
563
 
564
+ # ③ 逐级渲染:每一页都必须真的打印清单声明的那几行,且每一页都要能被同一个解析器读
565
+ local list; list="$(mr_pages)"
566
+ local spec kind label page n_pages=0 n_entries=0 n_claims=0 level_fail=0
567
+ local -A LEVEL_OK=()
568
+ while IFS=':' read -r kind label; do
569
+ page="$tmp/pages/$kind--$label.txt"
570
+ [ -s "$page" ] || { finding "walk: 帮助面缺一页($kind $label)"; level_fail=1; continue; }
571
+ n_pages=$((n_pages + 1))
572
+ if [ "$kind" = "command" ]; then
573
+ # the page's own usage header must be there (a deleted header is a defect, never a skip)
574
+ grep -qE '^── (Usage|用法)' "$page" || { finding "walk: $label 的页没有用法头部(Usage:/用法:)"; level_fail=1; }
575
+ local declared printed
576
+ declared="$(awk -F'\t' -v c="$label" '$1==c {print $2}' < <(mr_fragments) | sort)"
577
+ printed="$(mr_page_usage "$page" | sort)"
578
+ if [ "$declared" != "$printed" ]; then
579
+ local extra; extra="$(comm -13 <(printf '%s\n' "$declared") <(printf '%s\n' "$printed") | head -3 | paste -sd ' ' -)"
580
+ local gone; gone="$(comm -23 <(printf '%s\n' "$declared") <(printf '%s\n' "$printed") | head -3 | paste -sd ' ' -)"
581
+ finding "walk: $label 的页与清单不一致(页上多出:${extra:-无};页上缺少:${gone:-无})"
582
+ level_fail=1
583
+ fi
584
+ if printf '%s\n' "$printed" | grep -q -- '--ghost-probe\|--frobnicate-probe'; then
585
+ finding "walk: $label 的页打印了清单没有的旗标($(printf '%s\n' "$printed" | grep -- '--ghost-probe\|--frobnicate-probe' | head -1))"
586
+ level_fail=1
587
+ fi
588
+ LEVEL_OK[command]=1
589
+ elif [ "$kind" = "group" ]; then
590
+ local want got
591
+ want="$(awk -F'\t' -v g="$label" '$1=="cmd" && $3==g {n=split($4,f," ;; "); print f[1]}' "$manifest" | sort)"
592
+ got="$(mr_page_usage "$page" | sort)"
593
+ if [ "$want" != "$got" ]; then
594
+ finding "walk: 组页 $label 与清单不一致($(diff <(printf '%s\n' "$want") <(printf '%s\n' "$got") | grep '^[<>]' | head -2 | tr '\n' ' '))"
595
+ level_fail=1
596
+ fi
597
+ LEVEL_OK[group]=1
598
+ else
599
+ local want got
600
+ want="$(mr_begin | tr ' ' '\n' | grep -v '^$' | sort)"
601
+ got="$(mr_page_usage "$page" | awk '{print $1}' | sort)"
602
+ if [ "$want" != "$got" ]; then
603
+ finding "walk: 菜单的上手命令与清单的 begin 行不一致($(diff <(printf '%s\n' "$want") <(printf '%s\n' "$got") | grep '^[<>]' | head -2 | tr '\n' ' '))"
604
+ level_fail=1
605
+ fi
606
+ LEVEL_OK[menu]=1
607
+ fi
608
+ # the same parser reads every level (block rules unchanged)
609
+ awk -v tops="$MRI_TOPS" -v subs="$MRI_SUBS" -f "$tmp/walk-a.awk" "$page" > "$tmp/page-claims.tsv" 2>/dev/null
610
+ local ln rest
611
+ while IFS=$'\t' read -r _ ln rest; do
612
+ finding "walk: $kind $label 的第 $ln 行无法归属(解析器拒绝静默跳过):$rest"
613
+ level_fail=1
614
+ done < <(grep -a '^FAIL' "$tmp/page-claims.tsv")
615
+ n_entries=$((n_entries + $(grep -ac '^ENTRY' "$tmp/page-claims.tsv" || true)))
616
+ n_claims=$((n_claims + $(grep -ac '^CLAIM' "$tmp/page-claims.tsv" || true)))
617
+ ok "walk: $kind $label 判过($(grep -ac '^ENTRY' "$tmp/page-claims.tsv" || true) 条用法行,$(grep -ac '^CLAIM' "$tmp/page-claims.tsv" || true) 条断言)"
618
+ done <<< "$list"
619
+ [ "$level_fail" = "1" ] && failed=1
620
+ local lv
621
+ for lv in menu group command; do
622
+ [ -n "${LEVEL_OK[$lv]:-}" ] || { finding "walk: $lv 这一级一条都没被判到(静默漏读)"; failed=1; }
623
+ done
624
+
625
+ # ④ 每条 (命令, 旗标) 断言喂真解析器;探针结果按 (命令,旗标) 去重
488
626
  local fixture
489
627
  fixture="$(new_fixture walk-a)" || return 1
490
- local path flag note
628
+ local path flag note n_probed=0
491
629
  while IFS=$'\t' read -r _ ln path flag; do
492
630
  if mr_probe_claim "$fixture" "$path" "$flag"; then
493
631
  note="$(first_line "$MR_OUT")"
494
- ok "断言 L$ln:$path $flag → rc=$MR_RC ${note:+| $note}"
632
+ ok "断言:$path $flag → rc=$MR_RC ${note:+| $note}"
633
+ n_probed=$((n_probed + 1))
495
634
  else
496
- finding "断言 L$ln:$path $flag 被自己的解析器拒绝(原文:$(first_line "$MR_OUT"))"
635
+ finding "断言:$path $flag 被自己的解析器拒绝(原文:$(first_line "$MR_OUT"))"
497
636
  failed=1
498
637
  fi
499
638
  done < <(grep -a '^CLAIM' "$tmp/walk-a.tsv")
500
639
  [ "$failed" = "1" ] && return 1
640
+ printf ' \033[2m·\033[0m walk 覆盖面:%d 个页面(1 菜单 + %d 组页 + %d 命令页)、%d 条用法行、%d 条 (命令,旗标) 断言,逐条喂过真解析器\n' \
641
+ "$n_pages" "$(mr_groups | grep -c . || true)" "$(mr_cmds | grep -c . || true)" "$n_manifest_entries" "$n_probed"
501
642
  return 0
502
643
  }
503
644
 
504
645
  # ── control: an unknown flag must be refused by every flag-printing path ────────────────────────────
505
646
  mr_control() {
506
647
  section "control · 非空洞臂:打印旗标的每条路径都必须拒绝未知参数(--frobnicate-probe)"
507
- [ -f "$tmp/walk-a.tsv" ] || {
508
- local help_out prepped hline
509
- help_out="$( cd "$tmp" && env PATH="$SHIM:$PATH" bash "$team" help 2>&1 )"
510
- mr_known_tables
511
- mr_write_parser
512
- printf '%s\n' "$help_out" > "$tmp/help.txt"
513
- prepped=""
514
- while IFS= read -r hline; do
515
- hline="${hline//|/$'\x1f'}"
516
- prepped="$prepped${hline////$'\x1f'}"$'\n'
517
- done <<< "$help_out"
518
- printf '%s' "$prepped" | awk -v tops="$MRI_TOPS" -v subs="$MRI_SUBS" -f "$tmp/walk-a.awk" > "$tmp/walk-a.tsv" 2>/dev/null
519
- }
648
+ [ -f "$tmp/walk-a.tsv" ] || mr_manifest_claims
520
649
  local fixture; fixture="$(new_fixture control)" || return 1
521
650
  local p n=0 bad=0
522
651
  while IFS= read -r p; do
@@ -548,11 +677,11 @@ mr_probe_for() { # <KEY> → probe id(空 = 没有声明)
548
677
  case "$1" in
549
678
  TEAM_PROJECT|TEAM_SESSION|TEAM_PM_WINDOW) printf 'identity\n' ;;
550
679
  TEAM_AGENTS) printf 'roster\n' ;;
551
- TEAM_AGENT_MODELS) printf 'seat-model\n' ;;
680
+ TEAM_TASK_MODELS) printf 'task-model\n' ;;
552
681
  TEAM_PM_MODEL) printf 'pm-model\n' ;;
553
682
  TEAM_PULSE_WINDOW) printf 'pulse-window\n' ;;
554
- TEAM_DEFAULT_MODEL) printf 'default-model\n' ;;
555
683
  TEAM_BG_STOP_GRACE) printf 'bg-stop-grace\n' ;;
684
+ TEAM_ORPHAN_SCAN) printf 'orphan-scan\n' ;;
556
685
  *) printf '\n' ;;
557
686
  esac
558
687
  }
@@ -600,11 +729,11 @@ mr_walk_b() {
600
729
  case "$probe" in
601
730
  identity) mr_promise_identity "$key" || bad=1 ;;
602
731
  roster) mr_promise_roster "$key" || bad=1 ;;
603
- seat-model) mr_promise_seat_model "$key" || bad=1 ;;
732
+ task-model) mr_promise_task_model "$key" || bad=1 ;;
604
733
  pm-model) mr_promise_pm_model "$key" || bad=1 ;;
605
734
  pulse-window) mr_promise_pulse_window "$key" || bad=1 ;;
606
- default-model) mr_promise_default_model "$key" || bad=1 ;;
607
735
  bg-stop-grace) mr_promise_bg_stop_grace "$key" || bad=1 ;;
736
+ orphan-scan) mr_promise_orphan_scan "$key" || bad=1 ;;
608
737
  *) finding "promise:$key 的探针 id「$probe」没有实现(覆盖表与实现脱节)"; bad=1 ;;
609
738
  esac
610
739
  done < "$rows"
@@ -757,9 +886,9 @@ mr_promise_seat_model() { # <KEY>
757
886
  mr_promise_pm_model() { # <KEY>
758
887
  local key="$1" d
759
888
  d="$(new_fixture promise-pm-model)" || return 1
760
- mr_run "$d" config set-agent-model pm vendor/pm9
761
- [ "$MR_RC" = "0" ] || { finding "promise($key):set-agent-model pm 失败($(first_line "$MR_OUT"))"; return 1; }
762
- mr_run "$d" up --print
889
+ mr_run "$d" config set TEAM_PM_MODEL vendor/pm9 --yes
890
+ [ "$MR_RC" = "0" ] || { finding "promise($key):独立 PM writer 失败($(first_line "$MR_OUT"))"; return 1; }
891
+ mr_run "$d" up --fresh-pm --print
763
892
  if printf '%s' "$MR_OUT" | grep -q -- '--provider vendor --model pm9'; then
764
893
  ok "promise($key):team up --print 渲染出的命令带着 --provider vendor --model pm9"
765
894
  else
@@ -785,7 +914,47 @@ mr_promise_pulse_window() { # <KEY>
785
914
  return 0
786
915
  }
787
916
 
788
- mr_promise_default_model() { # <KEY>
917
+ # P276:孤儿普查开关的探针。schema 注释点名了 `team reap`(「0 = 完全不扫 /proc(读数只剩一行点名的跳过;
918
+ # team reap --orphans 也随之不可用)」),所以那条句子要在真夹具里真的发生。判的是**效果**:
919
+ # ① 开关开着时 `team reap --orphans` 正常给出计划/空计划(不是拒绝)—— 非空洞对照;
920
+ # ② 关掉后同一个命令**拒绝**并点名那个键;③ 读数只剩一行点名的跳过(没有 pid、没有清理命令)。
921
+ mr_promise_orphan_scan() { # <KEY>
922
+ local key="$1" d line n_pid
923
+ d="$(new_fixture promise-orphan-scan)" || return 1
924
+ # ① 对照:开关开着 → 同一命令不拒绝(否则下面的「拒绝」什么也证明不了)
925
+ mr_run "$d" reap --orphans
926
+ case "$MR_OUT" in
927
+ *TEAM_ORPHAN_SCAN*) finding "promise($key):开关开着时 reap --orphans 就已经拿开关当理由拒绝了($(first_line "$MR_OUT"))"; return 1 ;;
928
+ *没有本项目孤儿*) : ;;
929
+ *) finding "promise($key):开关开着时 reap --orphans 没有给出计划($(first_line "$MR_OUT"))"; return 1 ;;
930
+ esac
931
+ ok "promise($key):开关开着 → reap --orphans 给出计划(rc=$MR_RC,不看退出码)"
932
+ # ② 用真路由关掉它(顺便验证这个键在 config 路由上真的可写)
933
+ mr_run "$d" config set TEAM_ORPHAN_SCAN 0 --yes
934
+ [ "$MR_RC" = "0" ] || { finding "promise($key):config set TEAM_ORPHAN_SCAN 0 失败($(first_line "$MR_OUT"))"; return 1; }
935
+ mr_run "$d" reap --orphans
936
+ case "$MR_OUT" in
937
+ *TEAM_ORPHAN_SCAN*) ok "promise($key):关掉之后 reap --orphans 拒绝并点名该键(rc=$MR_RC)" ;;
938
+ *) finding "promise($key):关掉之后 reap --orphans 照样列孤儿($(first_line "$MR_OUT"))"; return 1 ;;
939
+ esac
940
+ # ③ 读数只剩一行点名的跳过,且不含 pid / 清理命令
941
+ mr_run "$d" ps
942
+ line="$(printf '%s\n' "$MR_OUT" | grep '^孤儿席位进程' | tail -1)"
943
+ case "$line" in
944
+ *TEAM_ORPHAN_SCAN*) : ;;
945
+ *) finding "promise($key):关掉之后 ps 的读数不是一行点名的跳过($line)"; return 1 ;;
946
+ esac
947
+ if [ "$(printf '%s\n' "$MR_OUT" | grep -c '^孤儿席位进程')" != "1" ]; then
948
+ finding "promise($key):关掉之后 ps 的读数不止一行"; return 1
949
+ fi
950
+ case "$line" in
951
+ *reap*) finding "promise($key):跳过行里还带着清理命令($line)"; return 1 ;;
952
+ esac
953
+ ok "promise($key):关掉之后 ps 的读数恰好一行、点名该键、无 pid 无清理命令"
954
+ return 0
955
+ }
956
+
957
+ mr_promise_task_model() { # <KEY>
789
958
  local key="$1" d br
790
959
  d="$(new_fixture promise-default-model)" || return 1
791
960
  mkdir -p "$d/docs/team/tasks" "$d/openspec/specs/routes"
@@ -795,6 +964,7 @@ mr_promise_default_model() { # <KEY>
795
964
  ```
796
965
  task: T1
797
966
  agent: dev
967
+ category: routine
798
968
  change: -
799
969
  specs: routes#The fixture requirement
800
970
  phase: apply
@@ -816,8 +986,11 @@ BRIEF
816
986
  finding "promise($key):夹具建不出 worktree"; return 1
817
987
  fi
818
988
  rm -f "$d/.pi/team/state/dev.env"
819
- mr_run "$d" config set TEAM_DEFAULT_MODEL vendor/dm9 --yes
820
- [ "$MR_RC" = "0" ] || { finding "promise($key):设置 TEAM_DEFAULT_MODEL 失败"; return 1; }
989
+ mr_run "$d" config set-task-model routine vendor/dm9 --yes
990
+ [ "$MR_RC" = "0" ] || { finding "promise($key):类别 upsert 失败"; return 1; }
991
+ grep -q 'result=ok .*key=TEAM_TASK_MODELS' "$d/.pi/team/state/config.log" || { finding "promise($key):类别编辑无审计"; return 1; }
992
+ mr_run "$d" config list --json
993
+ printf '%s' "$MR_OUT" | python3 -c 'import json,sys; d=json.load(sys.stdin); assert next(x for x in d["models"]["policy"]["categories"] if x["category"]=="routine")["model"]=="vendor/dm9"; assert "seats" not in d["models"]' || { finding "promise($key):JSON 未来策略不一致/伪造实际模型"; return 1; }
821
994
  mr_run "$d" dispatch dev T1 docs/team/tasks/T1-anchor.md --print
822
995
  if printf '%s' "$MR_OUT" | grep -q -- '--provider vendor --model dm9'; then
823
996
  ok "promise($key):dispatch --print 渲染出的启动命令带着 --provider vendor --model dm9"
@@ -856,6 +1029,7 @@ RC_CLAIMS=(
856
1029
  'session-fresh|修法:$TEAM_CLI dispatch $agent $id $taskfile --fresh'
857
1030
  'session-overflow|修法:$TEAM_CLI dispatch $agent $id $taskfile --allow-overflow'
858
1031
  'capacity-override|修法:$(team_dispatch_mem_fix_cmd'
1032
+ 'tmp-root-mkdir|修法:mkdir -p '
859
1033
  )
860
1034
  RC_EXTRA=()
861
1035
  RC_PI_BIN=""
@@ -865,10 +1039,10 @@ RC_FAKE_LAUNCH=0
865
1039
  # rc_team <dir> <team 参数…> → 组合输出;rc = 被测 CLI 的 rc
866
1040
  rc_team() {
867
1041
  local d="$1"; shift
868
- local -a e=(env -u TMUX -u TMUX_PANE "PATH=$SHIM:$PATH" "TEAM_ROUTES_WINDOWS=$WINREG"
869
- "TEAM_ROUTES_TMUX_LOG=$TMUX_LOG" "TEAM_MEETINGS_DIR=$d/.meetings" "TEAM_PI_AGENT_DIR=$d/.pi-agent")
1042
+ local -a e=(env -u TMUX -u TMUX_PANE "PATH=$SHIM:$PATH" "SMOKE_ROUTES_WINDOWS=$WINREG"
1043
+ "SMOKE_ROUTES_TMUX_LOG=$TMUX_LOG" "TEAM_MEETINGS_DIR=$d/.meetings" "TEAM_PI_AGENT_DIR=$d/.pi-agent")
870
1044
  [ "$RC_OMIT_PI_BIN" = "1" ] || e+=("TEAM_PI_BIN=${RC_PI_BIN:-/bin/true}")
871
- [ "$RC_FAKE_LAUNCH" = "1" ] && e+=("TEAM_ROUTES_FAKE_LAUNCH=1" "TEAM_DISPATCH_VERIFY_SEC=2" "TEAM_DISPATCH_ALIVE_SEC=0")
1045
+ [ "$RC_FAKE_LAUNCH" = "1" ] && e+=("SMOKE_ROUTES_FAKE_LAUNCH=1" "TEAM_DISPATCH_VERIFY_SEC=2" "TEAM_DISPATCH_ALIVE_SEC=0")
872
1046
  [ "${#RC_EXTRA[@]}" -gt 0 ] && e+=("${RC_EXTRA[@]}")
873
1047
  ( cd "$d" && ${TIMEOUT_BIN:+"$TIMEOUT_BIN" "$timeout_sec"} "${e[@]}" bash "$team" "$@" </dev/null 2>&1 )
874
1048
  }
@@ -876,9 +1050,9 @@ rc_team() {
876
1050
  # rc_sh <dir> <命令字符串> → 把打印出来的路线原样当命令跑(fake launch 开着)
877
1051
  rc_sh() {
878
1052
  local d="$1" cmd="$2"
879
- local -a e=(env -u TMUX -u TMUX_PANE "PATH=$SHIM:$PATH" "TEAM_ROUTES_WINDOWS=$WINREG"
880
- "TEAM_ROUTES_TMUX_LOG=$TMUX_LOG" "TEAM_MEETINGS_DIR=$d/.meetings" "TEAM_PI_AGENT_DIR=$d/.pi-agent"
881
- "TEAM_ROUTES_FAKE_LAUNCH=1" "TEAM_DISPATCH_VERIFY_SEC=2" "TEAM_DISPATCH_ALIVE_SEC=0")
1053
+ local -a e=(env -u TMUX -u TMUX_PANE "PATH=$SHIM:$PATH" "SMOKE_ROUTES_WINDOWS=$WINREG"
1054
+ "SMOKE_ROUTES_TMUX_LOG=$TMUX_LOG" "TEAM_MEETINGS_DIR=$d/.meetings" "TEAM_PI_AGENT_DIR=$d/.pi-agent"
1055
+ "SMOKE_ROUTES_FAKE_LAUNCH=1" "TEAM_DISPATCH_VERIFY_SEC=2" "TEAM_DISPATCH_ALIVE_SEC=0")
882
1056
  [ "$RC_OMIT_PI_BIN" = "1" ] || e+=("TEAM_PI_BIN=${RC_PI_BIN:-/bin/true}")
883
1057
  [ "${#RC_EXTRA[@]}" -gt 0 ] && e+=("${RC_EXTRA[@]}")
884
1058
  ( cd "$d" && ${TIMEOUT_BIN:+"$TIMEOUT_BIN" "$timeout_sec"} "${e[@]}" bash -c "$cmd" </dev/null 2>&1 )
@@ -902,7 +1076,8 @@ rc_brief() {
902
1076
  mkdir -p "$d/docs/team/tasks"
903
1077
  {
904
1078
  printf '# %s · fixture\n\n```\n' "$id"
905
- printf 'task: %s\nagent: %s\nissue: -\n' "$id" "$agent"
1079
+ local category=routine; case "$phase" in *explore*|*propose*) category=analysis ;; *verify*) category=verify ;; esac
1080
+ printf 'task: %s\nagent: %s\ncategory: %s\nissue: -\n' "$id" "$agent" "$category"
906
1081
  [ -n "$br" ] && printf 'branch: %s\n' "$br"
907
1082
  printf 'change: %s\nspecs: -\nanchor: %s\nphase: %s\n' "$change" "$anchor" "$phase"
908
1083
  printf 'deltas: %s\ndeps: -\nstatus: todo\nbudget: -\n```\n\nbody\n' "$deltas"
@@ -1049,7 +1224,7 @@ mr_refusals() {
1049
1224
  br="$(rc_canon "$d" P1)"; rc_wt "$d" dev "$br"
1050
1225
  printf 'wip from OLD\n' > "$d/.worktrees/dev/wip.txt"
1051
1226
  mkdir -p "$d/.pi/team/state"
1052
- printf 'task=OLD\nworktree=%s\ntaskfile=%s\nbranch=%s\n' "$d/.worktrees/dev" "$d/docs/team/tasks/OLD-fixture.md" "$br" > "$d/.pi/team/state/dev.env"
1227
+ routing_fixture_record "$d/.pi/team/state" dev OLD "$d/.worktrees/dev" "$d/docs/team/tasks/OLD-fixture.md" deepseek/deepseek-flash "routes-OLD" policy '' routine "$br"
1053
1228
  rc_brief "$d" OLD - "none (infra) — fixture" - >/dev/null
1054
1229
  RC_CMD=(dispatch dev P1 "$b" --print)
1055
1230
  rc_case dirty-stash '有 1 个未提交改动.*属于上一个任务 OLD' '修法:git -C' 'apply:cmd' same clear
@@ -1156,7 +1331,7 @@ mr_refusals() {
1156
1331
  b="$(rc_brief "$d" P1 - "none (infra) — fixture" -)"; RC_BRIEF="$b"
1157
1332
  br="$(rc_canon "$d" P1)"; rc_wt "$d" dev "$br"
1158
1333
  mkdir -p "$d/.pi/team/state"
1159
- printf 'task=OLD\nworktree=%s\ntaskfile=%s\nbranch=%s\n' "$d/.worktrees/dev" "$d/docs/team/tasks/OLD-fixture.md" "$br" > "$d/.pi/team/state/dev.env"
1334
+ routing_fixture_record "$d/.pi/team/state" dev OLD "$d/.worktrees/dev" "$d/docs/team/tasks/OLD-fixture.md" deepseek/deepseek-flash "routes-OLD" policy '' routine "$br"
1160
1335
  RC_CMD=(dispatch dev P1 "$b" --print)
1161
1336
  rc_case stack-force '还有一个没结束的任务' '修法:team dispatch' 'apply:cmd' route force
1162
1337
 
@@ -1169,7 +1344,7 @@ mr_refusals() {
1169
1344
  b="$(rc_brief "$d" P1 - "none (infra) — fixture" -)"; RC_BRIEF="$b"
1170
1345
  br_old="$(rc_canon "$d" OLD)"; rc_wt "$d" dev "$br_old"
1171
1346
  mkdir -p "$d/.pi/team/state"
1172
- printf 'task=OLD\nworktree=%s\ntaskfile=%s\nbranch=%s\n' "$d/.worktrees/dev" "$d/docs/team/tasks/OLD-fixture.md" "$br_old" > "$d/.pi/team/state/dev.env"
1347
+ routing_fixture_record "$d/.pi/team/state" dev OLD "$d/.worktrees/dev" "$d/docs/team/tasks/OLD-fixture.md" deepseek/deepseek-flash "routes-OLD" policy '' routine "$br_old"
1173
1348
  RC_CMD=(dispatch dev P1 "$b" --print)
1174
1349
  out="$(rc_team "$d" "${RC_CMD[@]}")" || true
1175
1350
  route="$(rc_route "$out" '修法:team resume') || true"
@@ -1244,8 +1419,11 @@ mr_refusals() {
1244
1419
  enc="$(printf '%s' "$d/.worktrees/dev" | sed -e 's|^/||' -e 's|[/\\:]|-|g')"
1245
1420
  mkdir -p "$d/.pi-agent/sessions/--$enc--"
1246
1421
  printf '%s\n' "$(head -c 400 /dev/zero | tr '\0' 'x')" > "$d/.pi-agent/sessions/--$enc--/x_routes-refuse-session-dev.jsonl"
1422
+ routing_fixture_record "$d/.pi/team/state" dev P1 "$d/.worktrees/dev" "$b" deepseek/deepseek-flash routes-refuse-session-dev policy '' routine "$br"
1247
1423
  RC_CMD=(dispatch dev P1 "$b" --print)
1248
1424
  rc_case session-fresh '拒绝复用这个会话' '修法:team dispatch' 'apply:cmd' route proceed
1425
+ # Fresh now commits a different SID; restore overflow's own complete identity for the independent override probe.
1426
+ routing_fixture_record "$d/.pi/team/state" dev P1 "$d/.worktrees/dev" "$b" deepseek/deepseek-flash routes-refuse-session-dev policy '' routine "$br"
1249
1427
  out="$(rc_team "$d" "${RC_CMD[@]}")" || true
1250
1428
  route="$(printf '%s\n' "$out" | grep -aF '修法:team dispatch' | grep -aF -- '--allow-overflow' | head -1 | sed 's/.*修法://; s/(.*//' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' || true)"
1251
1429
  if [ -z "$route" ]; then
@@ -1270,17 +1448,29 @@ mr_refusals() {
1270
1448
  RC_CMD=(dispatch dev P1 "$b" --print)
1271
1449
  rc_case capacity-override 'MemAvailable 只剩' '修法:TEAM_MIN_AVAIL_MB=0' 'apply:cmd' route proceed "dispatched P1"
1272
1450
  RC_EXTRA=()
1451
+
1452
+ # ⑲ P309:显式选定的临时根不存在 → 修法:mkdir -p <根>(兑现:建完就放行;不许换用别的根)
1453
+ d="$(new_fixture refuse-tmp-root)"; RC_DIR="$d"
1454
+ rc_board "$d" P1 "P1 fixture"
1455
+ b="$(rc_brief "$d" P1 - "none (infra) — fixture" -)"; RC_BRIEF="$b"
1456
+ br="$(rc_canon "$d" P1)"; rc_wt "$d" dev "$br"
1457
+ RC_EXTRA=("TEAM_TMP_ROOT=$d/explicit-root")
1458
+ RC_CMD=(dispatch dev P1 "$b" --print)
1459
+ rc_case tmp-root-mkdir '临时根不可用' '修法:mkdir -p ' 'apply:cmd' same clear
1460
+ RC_EXTRA=()
1273
1461
  }
1274
1462
 
1275
1463
  # ── flips: scratch trees that MUST redden the walk ──────────────────────────────────────────────────
1276
- mr_scratch_tree() { # <name> → 打印 scratch 树(skills/teamsmith + skills/teamsmith-init 的最小副本)
1464
+ mr_scratch_tree() { # <name> → 打印 scratch 树(skills/teamsmith 的完整副本 + 同级 teamsmith-init)
1277
1465
  local name="$1"
1278
1466
  local s="$tmp/$name"
1279
- rm -rf "$s"; mkdir -p "$s/skills/teamsmith"
1280
- cp -a "$skill/scripts" "$skill/references" "$skill/templates" "$s/skills/teamsmith/" 2>/dev/null || true
1281
- # perf.sh 是 source 模式的声明文件(walk 要读它),scratch 树也得有。
1282
- mkdir -p "$s/skills/teamsmith/tests"
1283
- cp -a "$skill/tests/perf.sh" "$s/skills/teamsmith/tests/perf.sh" 2>/dev/null || true
1467
+ rm -rf "$s"; mkdir -p "$s/skills"
1468
+ # 整棵副本(不再挑目录):控制臂扫的是清单声明的**每条路径**,其中包括会走到 tests/ 的命令
1469
+ # (`smoke`)——最小副本会让它们在嵌套 run 里以「环境缺件」的形状红,而那与「吞掉未知旗标」
1470
+ # 无关(P260 实测:同一段嵌套 walk control 在整棵副本上 ✓179/✗0,在最小副本上红一条)。
1471
+ cp -a "$skill" "$s/skills/teamsmith" 2>/dev/null || true
1472
+ local init="$skill/../teamsmith-init"
1473
+ [ -d "$init" ] && cp -a "$init" "$s/skills/teamsmith-init" 2>/dev/null || true
1284
1474
  printf '%s\n' "$s"
1285
1475
  }
1286
1476
 
@@ -1363,11 +1553,12 @@ mr_flip_require() {
1363
1553
  # 根都在册,与 mtime 无关);find 是次要来源(原始形状,保留不放松)。
1364
1554
  # <base> 可换:翻转⑧在私有 TMPDIR 里造「不回收」形状,不让刻意的残留落进共享临时目录。
1365
1555
  mr_nested_leftovers() { # [<base>]
1366
- local base="${1:-${TMPDIR:-/tmp}}"
1556
+ local base="${1:-$(team_tmp_root)}"
1367
1557
  {
1368
1558
  tmp_root_ledger_survivors 2>/dev/null | awk -F'\t' -v me="$$" -v base="$base" \
1369
1559
  '$2 != me && $3 == "routes" && index($1, base "/") == 1 { print $1 }'
1370
- find "$base" -maxdepth 1 -name 'teamsmith-routes.*' -newer "$tmp" 2>/dev/null | grep -v "^$tmp\$" || true
1560
+ # P287:根名带 ns(`teamsmith-routes-<ns>.<rand>`)—— 两种形状都认([.-] 覆盖平铺与带 ns)
1561
+ find "$base" -maxdepth 1 -name 'teamsmith-routes[.-]*' -newer "$tmp" 2>/dev/null | grep -v "^$tmp\$" || true
1371
1562
  } | sed '/^$/d' | sort -u
1372
1563
  }
1373
1564
 
@@ -1386,33 +1577,45 @@ mr_flips() {
1386
1577
  else
1387
1578
  finding "判据卫生:证据里混进了正文的用法行标记($ev)"
1388
1579
  fi
1389
- # ① 场地缺陷:help 打印 add-agent --model,解析器拒绝它
1580
+ # ① 场地缺陷:重新印出已退休的 add-agent --model,并让解析器明确拒绝它。
1390
1581
  s="$(mr_scratch_tree flip-model)"
1391
- python3 - "$s/skills/teamsmith/scripts/lib/cmd-agents.sh" <<'PY'
1582
+ python3 - "$s/skills/teamsmith/scripts/strings/commands.tsv" <<'MUT'
1392
1583
  import sys
1393
1584
  p = sys.argv[1]
1394
1585
  s = open(p, encoding='utf-8').read()
1395
- s = s.replace('--model) model="${2:?--model 需要 <provider/model> 或 -}"; has_model=1; shift 2 ;;',
1396
- '--model) team_usage_die "add-agent: 未知参数 --model" ;;', 1)
1397
- s = s.replace('--model=*) model="${1#*=}"; has_model=1; shift ;;', '', 1)
1586
+ old = 'add-agent <a> [--register] [--create]'
1587
+ new = 'add-agent <a> [--register] [--model <m>] [--create]'
1588
+ assert s.count(old) == 1, 'add-agent usage route must match exactly once'
1589
+ open(p, 'w', encoding='utf-8').write(s.replace(old, new, 1))
1590
+ MUT
1591
+ python3 - "$s/skills/teamsmith/scripts/lib/cmd-agents.sh" <<'MUT'
1592
+ import sys
1593
+ p = sys.argv[1]
1594
+ s = open(p, encoding='utf-8').read()
1595
+ old = "--model|--model=*) team_err 'add-agent --model retired;使用 task category 和 config set-task-model'; return 2 ;;"
1596
+ new = '--model|--model=*) team_usage_die "add-agent: 未知参数 --model" ;;'
1597
+ assert s.count(old) == 1, 'retired model branch must match exactly once'
1598
+ s = s.replace(old, new, 1)
1398
1599
  open(p, 'w', encoding='utf-8').write(s)
1399
- PY
1400
- # 落地证明(P202):①改了两处,两处都要真的落到副本里
1600
+ MUT
1601
+ # 落地证明(P202):两种 --model 拼法如今在同一退休分支,仍检查原分支消失、新分支出现与字节变化。
1401
1602
  if mr_flip_require "翻转①" "$s" scripts/lib/cmd-agents.sh \
1402
- '--model) model="${2:?--model 需要 <provider/model> 或 -}"; has_model=1; shift 2 ;;' \
1403
- '--model) team_usage_die "add-agent: 未知参数 --model" ;;' \
1404
- && mr_flip_require "翻转①" "$s" scripts/lib/cmd-agents.sh '--model=*) model="${1#*=}"; has_model=1; shift ;;' -; then
1603
+ "--model|--model=*) team_err 'add-agent --model retired;使用 task category 和 config set-task-model'; return 2 ;;" \
1604
+ '--model|--model=*) team_usage_die "add-agent: 未知参数 --model" ;;' &&
1605
+ mr_flip_require "翻转① help" "$s" scripts/strings/commands.tsv \
1606
+ 'add-agent <a> [--register] [--create]' \
1607
+ 'add-agent <a> [--register] [--model <m>] [--create]'; then
1405
1608
  mr_flip_run "$s" walk
1406
1609
  if [ "$MR_FLIP_RC" != "0" ] && mr_flip_log_has 'add-agent --model'; then
1407
- ok "翻转①:help 打印 --model 而解析器拒绝 → walk 红并点名 add-agent --model"
1610
+ ok "翻转①:清单打印 --model 而解析器拒绝 → walk 红并点名 add-agent --model"
1408
1611
  else
1409
1612
  finding "翻转①没有兑现(rc=$MR_FLIP_RC):$(mr_flip_evidence)"
1410
1613
  fi
1411
1614
  fi
1412
1615
  # ② 兄弟旗标:--fresh 是 dispatch 的,add-agent 不接受
1413
1616
  s="$(mr_scratch_tree flip-sibling)"
1414
- sed -i 's/add-agent <a> \[--register\]/add-agent <a> [--fresh]/' "$s/skills/teamsmith/scripts/lib/cmd-project.sh"
1415
- if mr_flip_require "翻转②" "$s" scripts/lib/cmd-project.sh 'add-agent <a> [--register]' 'add-agent <a> [--fresh]'; then
1617
+ sed -i 's/^cmd\tadd-agent\tseats\tadd-agent <a> \[--register\]/cmd\tadd-agent\tseats\tadd-agent <a> [--fresh]/' "$s/skills/teamsmith/scripts/strings/commands.tsv"
1618
+ if mr_flip_require "翻转②" "$s" scripts/strings/commands.tsv 'add-agent <a> [--register]' 'add-agent <a> [--fresh]'; then
1416
1619
  mr_flip_run "$s" walk
1417
1620
  if [ "$MR_FLIP_RC" != "0" ] && mr_flip_log_has 'add-agent --fresh'; then
1418
1621
  ok "翻转②:add-agent 行印上兄弟命令的 --fresh → walk 红并点名 add-agent --fresh"
@@ -1424,15 +1627,15 @@ PY
1424
1627
  # a) 陈旧模式:sed 的搜索端在文件里根本不存在 → 谁都没改 → 必须报「变异没落地」;
1425
1628
  # b) 只插不删:新文本出现了、旧文本还在 → 判据的另一侧必须红(证明 gone 一侧承重)。
1426
1629
  s="$(mr_scratch_tree flip-stale-pattern)"
1427
- sed -i 's/add-agent <a> \[--frosh\]/add-agent <a> [--fresh]/' "$s/skills/teamsmith/scripts/lib/cmd-project.sh"
1428
- if mr_flip_landed "落地判据红侧 a" "$s" scripts/lib/cmd-project.sh 'add-agent <a> [--register]' 'add-agent <a> [--fresh]'; then
1630
+ sed -i 's/add-agent <a> \[--frosh\]/add-agent <a> [--fresh]/' "$s/skills/teamsmith/scripts/strings/commands.tsv"
1631
+ if mr_flip_landed "落地判据红侧 a" "$s" scripts/strings/commands.tsv 'add-agent <a> [--register]' 'add-agent <a> [--fresh]'; then
1429
1632
  finding "落地判据红侧 a:陈旧 sed 什么也没改,判据却放行了(判据是橡皮章)"
1430
1633
  else
1431
1634
  ok "落地判据红侧 a:陈旧 sed(搜索端不存在)→ 判据报「变异没落地」:$MR_FLIP_WHY"
1432
1635
  fi
1433
1636
  s="$(mr_scratch_tree flip-half-landed)"
1434
- sed -i 's/^ add-agent <a> \[--register\]/ add-agent <a> [--register] [--fresh]/' "$s/skills/teamsmith/scripts/lib/cmd-project.sh"
1435
- if mr_flip_landed "落地判据红侧 b" "$s" scripts/lib/cmd-project.sh 'add-agent <a> [--register]' 'add-agent <a> [--fresh]'; then
1637
+ sed -i 's/add-agent <a> \[--register\]/add-agent <a> [--register] [--fresh]/' "$s/skills/teamsmith/scripts/strings/commands.tsv"
1638
+ if mr_flip_landed "落地判据红侧 b" "$s" scripts/strings/commands.tsv 'add-agent <a> [--register]' 'add-agent <a> [--fresh]'; then
1436
1639
  finding "落地判据红侧 b:旧文本还在(只插不删),判据却放行了"
1437
1640
  else
1438
1641
  ok "落地判据红侧 b:只插不删 → 判据报「变异没落地」:$MR_FLIP_WHY"
@@ -1452,9 +1655,17 @@ open(p, 'w', encoding='utf-8').write(s)
1452
1655
  PY
1453
1656
  # ps 在 help 里不打印旗标 —— 控制臂按设计只覆盖「打印旗标的路径」;这里把 ps 的用法行改印一个旗标,
1454
1657
  # 让这段翻转的能量落在「吞旗标必须红」上(形状与今天实测的 version/meeting list 同类)。
1455
- sed -i 's/^ ps 容量:/ ps [--frobnicate-probe] 容量:/' "$s/skills/teamsmith/scripts/lib/cmd-project.sh"
1658
+ python3 - "$s/skills/teamsmith/scripts/strings/commands.tsv" <<'MUT'
1659
+ import sys
1660
+ p = sys.argv[1]
1661
+ s = open(p, encoding='utf-8').read()
1662
+ old = 'cmd\tps\tobserve\tps\t-'
1663
+ new = 'cmd\tps\tobserve\tps [--frobnicate-probe]\t--frobnicate-probe'
1664
+ assert s.count(old) == 1, 'the ps row must match exactly once'
1665
+ open(p, 'w', encoding='utf-8').write(s.replace(old, new, 1))
1666
+ MUT
1456
1667
  if mr_flip_require "翻转③" "$s" scripts/lib/cmd-status.sh - '-*) shift ;;' \
1457
- && mr_flip_require "翻转③" "$s" scripts/lib/cmd-project.sh ' ps 容量:' ' ps [--frobnicate-probe] 容量:'; then
1668
+ && mr_flip_require "翻转③" "$s" scripts/strings/commands.tsv "$(printf 'cmd\tps\tobserve\tps\t-')" "$(printf 'cmd\tps\tobserve\tps [--frobnicate-probe]')"; then
1458
1669
  mr_flip_run "$s" walk control
1459
1670
  if [ "$MR_FLIP_RC" != "0" ] && mr_flip_log_has '控制:ps'; then
1460
1671
  ok "翻转③:ps 吞掉未知旗标 → 控制臂红并点名 ps"
@@ -1462,12 +1673,18 @@ PY
1462
1673
  finding "翻转③没有兑现(rc=$MR_FLIP_RC):$(mr_flip_evidence)"
1463
1674
  fi
1464
1675
  fi
1465
- # ④ 无法归属的行:命令块里列 0 的行(修复前的 board 形状)
1676
+ # ④ 无法归属的行:命令块里列 0 的行(把一条用法行渲染到列 0)
1466
1677
  s="$(mr_scratch_tree flip-unattributable)"
1467
- sed -i 's/^ board add|assign|set|row|ls/board add|assign|set|row|ls/' "$s/skills/teamsmith/scripts/lib/cmd-project.sh"
1468
- # 落地证明只查 gone 一侧:这步只动行首两个空格,去空格后的行**仍包含**原来那段文本,所以「0→1」
1469
- # 用子串表达不出来;而「带两个空格的形式由 1 变 0」+ cmp 的字节差就是确证(只有 sed 能改出这个形状)。
1470
- if mr_flip_require "翻转④" "$s" scripts/lib/cmd-project.sh ' board add|assign|set|row|ls' -; then
1678
+ python3 - "$s/skills/teamsmith/scripts/lib/cmd-help.sh" <<'MUT'
1679
+ import sys
1680
+ p = sys.argv[1]
1681
+ s = open(p, encoding='utf-8').read()
1682
+ old = ' local plain="${_TH_USAGE[$i]// ;; /;;;}"'
1683
+ new = old + '\n [ "$name" != "board" ] || team_help_flow 0 4 "board add <ID> [--allow-dup]"'
1684
+ assert s.count(old) == 1, 'the usage renderer must match exactly once'
1685
+ open(p, 'w', encoding='utf-8').write(s.replace(old, new, 1))
1686
+ MUT
1687
+ if mr_flip_require "翻转④" "$s" scripts/lib/cmd-help.sh - 'team_help_flow 0 4 "board add <ID> [--allow-dup]"'; then
1471
1688
  mr_flip_run "$s" walk
1472
1689
  if [ "$MR_FLIP_RC" != "0" ] && mr_flip_log_has '列 0 的行'; then
1473
1690
  ok "翻转④:命令块里的列 0 行 → walk 红并点名该行(修复前的 board 形状)"
@@ -1533,7 +1750,7 @@ PY
1533
1750
  local lkdir="$tmp/flip-tail-leak-tmp"
1534
1751
  mkdir -p "$lkdir"
1535
1752
  # 变异(这个旋钮)的落地证明:helper 里**有**这个分支(在真树里数得着),且这次 run 真的没回收 ——
1536
- # 私有 TMPDIR 里直接看得见一个 teamsmith-routes.* 根。它与收尾扫描互为对照(后者走台账+find):
1753
+ # 私有 TMPDIR 里直接看得见一个 teamsmith-routes* 根。它与收尾扫描互为对照(后者走台账+find):
1537
1754
  # 根在、扫描看不见 = 扫描瞎了;根不在 = 旋钮没生效。
1538
1755
  s="$(mr_scratch_tree flip-tail-leak)"
1539
1756
  local lkdir="$tmp/flip-tail-leak-tmp"
@@ -1543,7 +1760,7 @@ PY
1543
1760
  env -u TMUX -u TMUX_PANE TEAM_ROUTES_NESTED=1 TEAM_ROUTES_TREE="$s" TMPDIR="$lkdir" TMP_ROOT_BREAK=noreap \
1544
1761
  bash "$here/routes.sh" walk >"$tmp/flip-tail-leak.log" 2>&1 || true
1545
1762
  grep -a '^保留临时根:' "$tmp/flip-tail-leak.log" 2>/dev/null >>"$tmp/kept-roots.log" || true
1546
- left_fs="$(find "$lkdir" -maxdepth 1 -name 'teamsmith-routes.*' -type d 2>/dev/null | head -1)"
1763
+ left_fs="$(find "$lkdir" -maxdepth 1 -name 'teamsmith-routes[.-]*' -type d 2>/dev/null | head -1)"
1547
1764
  if [ "${knob:-0}" -lt 1 ] || [ -z "$left_fs" ]; then
1548
1765
  finding "翻转⑧:变异没落地(夹具缺陷)—— helper 里的 noreap 分支 ${knob:-0} 处;私有 TMPDIR 里没留下根(旋钮没生效)"
1549
1766
  elif [ -n "$(mr_nested_leftovers "$lkdir")" ]; then
@@ -1600,6 +1817,44 @@ PY
1600
1817
  finding "翻转⑩对照:修坏的树上 Walk A/控制臂不该变红(rc=$MR_FLIP_RC)"
1601
1818
  fi
1602
1819
  fi
1820
+ # ⑪ 第 2 级页面打印一条清单没有声明的用法行(旧走查看不到这里)
1821
+ s="$(mr_scratch_tree flip-page-ghost)"
1822
+ python3 - "$s/skills/teamsmith/scripts/lib/cmd-help.sh" <<'MUT'
1823
+ import sys
1824
+ p = sys.argv[1]
1825
+ s = open(p, encoding='utf-8').read()
1826
+ old = ' local plain="${_TH_USAGE[$i]// ;; /;;;}"'
1827
+ new = old + '\n [ "$name" != "dispatch" ] || team_help_flow 2 4 "dispatch --ghost-probe"'
1828
+ assert s.count(old) == 1, 'the usage renderer must match exactly once'
1829
+ open(p, 'w', encoding='utf-8').write(s.replace(old, new, 1))
1830
+ MUT
1831
+ if mr_flip_require "翻转⑪" "$s" scripts/lib/cmd-help.sh - 'team_help_flow 2 4 "dispatch --ghost-probe"'; then
1832
+ mr_flip_run "$s" walk
1833
+ if [ "$MR_FLIP_RC" != "0" ] && mr_flip_log_has 'dispatch' && mr_flip_log_has 'ghost-probe'; then
1834
+ ok "翻转⑪:第 2 级页面多出一条清单没有的用法行 → walk 红并点名该页与旗标"
1835
+ else
1836
+ finding "翻转⑪没有兑现(rc=$MR_FLIP_RC):$(mr_flip_evidence)"
1837
+ fi
1838
+ fi
1839
+ # ⑫ 清单漏掉一个 CLI 仍然接受的命令 —— 与帮助面夹具的 coverage 红侧同形(那条更便宜),
1840
+ # 这里不重复跑一遍 Walk A。
1841
+ # ⑬ 一级没有被判到(组表空了 → 一个组页都渲染不出来)
1842
+ s="$(mr_scratch_tree flip-level-unread)"
1843
+ python3 - "$s/skills/teamsmith/scripts/strings/commands.tsv" <<'MUT'
1844
+ import sys
1845
+ p = sys.argv[1]
1846
+ s = open(p, encoding='utf-8').read()
1847
+ s = "\n".join(l for l in s.split("\n") if not l.startswith("group\t"))
1848
+ open(p, 'w', encoding='utf-8').write(s)
1849
+ MUT
1850
+ if mr_flip_require "翻转⑬" "$s" scripts/strings/commands.tsv "$(printf 'group\tstart')" -; then
1851
+ mr_flip_run "$s" walk
1852
+ if [ "$MR_FLIP_RC" != "0" ] && mr_flip_log_has '这一级一条都没被判到'; then
1853
+ ok "翻转⑬:一级一条都没被判到 → walk 红并点名该级"
1854
+ else
1855
+ finding "翻转⑬没有兑现(rc=$MR_FLIP_RC):$(mr_flip_evidence)"
1856
+ fi
1857
+ fi
1603
1858
  # 收尾:flips 自己的 scratch 树与嵌套 run 的根都不留下。
1604
1859
  # TEAM_TMP_KEEP=1(门禁的 --keep 让子进程都继承它)是**刻意的保留**,不是泄漏 —— 与 smoke §40
1605
1860
  # 同口径:打一条可见说明,并把嵌套 run 打印的保留路径逐个列出(静默保留仍是缺陷)。