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
@@ -1,283 +0,0 @@
1
- #!/usr/bin/env bash
2
- # M6.3 · 独立验证包:dispatch / 通知 / 边界的七个 finding,red → green 复现
3
- #
4
- # bash skills/teamsmith/tests/flip-m6.3.sh # 红树 = 与 main 的分叉点,绿树 = 本 worktree
5
- # TEAM_FLIP_BASE=<sha> bash skills/teamsmith/tests/flip-m6.3.sh
6
- #
7
- # 覆盖(每个 finding 的「修复后该成立的性质」在两棵树上各断言一次):
8
- # F16 (high) dispatch 拒绝「工作树停在别的任务的分支上」,并点名两个分支 + 给出 git switch
9
- # F26 (high) worker 的 `notify pm`(PM 自己的收件箱)算待办 → watchdog 会叫醒/拉起 PM
10
- # F15 (low) 项目外的任务书被拒(不再把绝对路径叫 repo-relative)
11
- # F18 (low) 打错的收件人非零退出并点名名册(--any 可强制,留痕)
12
- # F17 (low) 去重键能区分「开头 60 字符相同、后半不同」的简报;字节相同仍去重
13
- # F27 (med) 空 tmux 目标在包装里被拒(探针不落地)
14
- # F30 (med) wrapper agent(脚本 exec 掉自己)被报为已启动,证据是 spawn(活 pid + cwd 在项目内)
15
- #
16
- # 安全:所有 tmux 流量走**私有 socket**(PATH shim 给每条命令加 `-L <socket>`),
17
- # 所以红树里那个危险的 `-t ""` 探针也只能打到本包的场地。只写 /tmp,不碰调用者的仓库/session。
18
- set -uo pipefail
19
-
20
- SELF_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
21
- SKILL_DIR="$(cd -P "$SELF_DIR/.." && pwd)"
22
- # P53:临时根的唯一创建者(${TMPDIR:-/tmp} + owned 家族 + 回收)
23
- . "$SELF_DIR/lib/tmp-root.sh"
24
- # P162:破坏性调用(kill-server/kill-session/kill-window)动手前先证明私有 socket 生效
25
- . "$SELF_DIR/lib/tmux-iso.sh"
26
- REPO_ROOT="$(git -C "$SKILL_DIR" rev-parse --show-toplevel 2>/dev/null || true)"
27
- [ -n "$REPO_ROOT" ] || { printf 'flip-m6.3: 找不到 git 仓库(本脚本用 git archive 取修复前的树)\n' >&2; exit 2; }
28
- command -v tmux >/dev/null 2>&1 || { printf 'flip-m6.3: 需要 tmux(本复现是 tmux 现场的)\n' >&2; exit 2; }
29
-
30
- BASE="${TEAM_FLIP_BASE:-}"
31
- [ -n "$BASE" ] || BASE="$(git -C "$REPO_ROOT" merge-base HEAD main 2>/dev/null || true)"
32
- [ -n "$BASE" ] || { printf 'flip-m6.3: 解析不到红树的 revision,用 TEAM_FLIP_BASE=<sha> 指定\n' >&2; exit 2; }
33
-
34
- [ "${KEEP:-0}" = "1" ] && export TEAM_TMP_KEEP=1
35
- TMP="$(tmp_root_create flip-m6.3)" || exit 3
36
- SOCK="m63flip-$$"
37
- mkdir -p "$TMP/red" "$TMP/shim"
38
-
39
- # M28:夹具自己的 tmux 调用要有隔离证据(裸 tmux 按 $TMUX 打到调用者 server —— M23 事故形状)。
40
- # 下面仍旧保留 PATH shim(工具的调用走 -L);这里补的是**本脚本自己**的顶层白名单:
41
- # unset TMUX + 私有 TMUX_TMPDIR,shim 洗掉也不会回落默认 socket。口径见 tests/tmux-lint.pl。
42
- unset TMUX TMUX_PANE 2>/dev/null || true
43
- TMUX_TMPDIR="$TMP/tmux"; mkdir -p "$TMUX_TMPDIR"; export TMUX_TMPDIR
44
- git -C "$REPO_ROOT" archive "$BASE" skills/teamsmith | tar -x -C "$TMP/red" || exit 2
45
- RED_SKILL="$TMP/red/skills/teamsmith"
46
- GREEN_SKILL="$SKILL_DIR"
47
- [ -f "$RED_SKILL/scripts/team" ] || { printf 'flip-m6.3: 红树里没取到 skills/teamsmith(base=%s)\n' "$BASE" >&2; exit 2; }
48
- # 守卫:base 必须真的还是「修复前」,否则这个包会报一个假的翻转
49
- if grep -q 'team_require_recipient' "$RED_SKILL/scripts/lib/cmd-agents.sh" 2>/dev/null; then
50
- printf 'flip-m6.3: TEAM_FLIP_BASE=%s 已经含修复(红树不是红的)——用更早的 revision\n' "$BASE" >&2; exit 2
51
- fi
52
-
53
- printf '#!/usr/bin/env bash\nexec /usr/bin/tmux -L %s "$@"\n' "$SOCK" > "$TMP/shim/tmux"
54
- chmod +x "$TMP/shim/tmux"
55
- PATH="$TMP/shim:$PATH"; export PATH
56
- export TMUX="$SOCK,0,0" TMUX_PANE=""
57
- cleanup() {
58
- # P162:收尾先证明私有 socket 生效(不成立就拒绝;cleanup 里不许 exit)
59
- if tmux_iso_guard_soft "flip-m6.3" "收尾:私有 server" --tmpdir "${TMUX_TMPDIR:-}" --sock-name "$SOCK" --own-root "$TMP"; then
60
- tmux kill-server >/dev/null 2>&1 || true
61
- fi
62
- tmp_root_reap_all
63
- }
64
- trap cleanup EXIT
65
-
66
- PASS=0; FAIL=0
67
- ok() { printf ' \033[32m✓\033[0m %s\n' "$1"; PASS=$((PASS+1)); }
68
- bad() { printf ' \033[31m✗\033[0m %s\n' "$1"; FAIL=$((FAIL+1)); }
69
- hdr() { printf '\n\033[1m══ %s\033[0m\n' "$1"; }
70
-
71
- # ---- 夹具 ----------------------------------------------------------------
72
- STUB="$TMP/stub-agent"
73
- cat > "$STUB" <<STUBEOF
74
- #!/usr/bin/env bash
75
- printf 'argv_count=%s\n' "\$#" >> "$TMP/stub-args.log"
76
- sleep 300
77
- STUBEOF
78
- chmod +x "$STUB"
79
-
80
- fixture() { # <skill> <name> [session] → repo 路径(已 init + 提交)
81
- local skill="$1" name="$2" sess="${3:-$2}"
82
- local r="$TMP/$name"
83
- mkdir -p "$r"
84
- git -C "$r" init -q -b main
85
- git -C "$r" config user.email flip@m63
86
- git -C "$r" config user.name flip
87
- printf '# %s\n' "$name" > "$r/README.md"
88
- git -C "$r" add -A && git -C "$r" commit -qm init
89
- ( cd "$r" && bash "$skill/scripts/team" init --session "$sess" --agents "dev verify" --gates "true" ) >/dev/null 2>&1
90
- git -C "$r" add -A && git -C "$r" commit -qm "teamsmith init"
91
- printf '%s\n' "$r"
92
- }
93
-
94
- runp() { # <repo> <skill> <args...>
95
- local r="$1" skill="$2"; shift 2
96
- ( cd "$r" && env -u TEAM_ROOT -u TEAM_MAIN_ROOT -u TEAM_SKILL_DIR bash "$skill/scripts/team" "$@" ) 2>&1
97
- }
98
-
99
- engine() { # <repo> <skill> <bash 片段>:source 全库后在夹具里跑片段(白盒探针)
100
- local r="$1" skill="$2" code="$3"
101
- ( cd "$r" && env -u TEAM_ROOT -u TEAM_MAIN_ROOT -u TEAM_SKILL_DIR TEAM_ROOT="$r" \
102
- bash -c 'd="$1"; . "$d/scripts/lib/common.sh"; for f in "$d"/scripts/lib/cmd-*.sh; do . "$f" 2>/dev/null || true; done; team_load_config 2>/dev/null; '"$code" _ "$skill" ) 2>/dev/null
103
- }
104
-
105
- brief() { # <repo> <ID>
106
- local r="$1" id="$2"
107
- local f="$r/docs/team/tasks/$id-flip.md"
108
- mkdir -p "$(dirname "$f")"
109
- printf '# %s · flip fixture\n\n```\ntask: %s\nagent: dev\n```\n\nDo X.\n' "$id" "$id" > "$f"
110
- printf '%s\n' "$f"
111
- }
112
-
113
- canon_branch() { engine "$1" "$2" "team_branch_for_agent dev '$3'"; }
114
-
115
- # 真派单需要一个「能解析到的 agent 可执行文件」:把假 adapter 写进夹具配置
116
- use_stub_adapter() { # <repo>
117
- printf 'TEAM_AGENT_CMD="%s {prompt}"\nTEAM_AGENT_BIN="%s"\n' "$STUB" "$STUB" >> "$1/.pi/team/config.sh"
118
- }
119
-
120
- # assert_fix <修复后性质是否成立(1/0)> <标签>:红树要求 0,绿树要求 1
121
- EXPECT_TREE=""
122
- assert_fix() {
123
- local got="$1" label="$2"
124
- if [ "$EXPECT_TREE" = "green" ]; then
125
- [ "$got" = "1" ] && ok "$label(green:成立)" || bad "$label(green:修复后仍不成立)"
126
- else
127
- [ "$got" = "0" ] && ok "$label(red:修复前不成立 ✓)" || bad "$label(red:修复前就成立 → 夹具/基点不对)"
128
- fi
129
- }
130
-
131
- TSRUN=""
132
- if command -v node >/dev/null 2>&1 && node -e 'process.exit(process.features.typescript?0:1)' >/dev/null 2>&1; then TSRUN="node"
133
- elif command -v bun >/dev/null 2>&1 && bun -e '1' >/dev/null 2>&1; then TSRUN="bun"
134
- elif [ -x "$HOME/.bun/bin/bun" ] && "$HOME/.bun/bin/bun" -e '1' >/dev/null 2>&1; then TSRUN="$HOME/.bun/bin/bun"
135
- elif command -v tsx >/dev/null 2>&1; then TSRUN="tsx"; fi
136
-
137
- # ---- F16:工作树停在别的任务的分支上 --------------------------------------
138
- case_f16() { # <skill> <tag>
139
- local skill="$1" tag="$2" r out rc br want sess fixed=0
140
- sess="m63-$tag-f16"; r="$(fixture "$skill" "$tag-f16" "$sess")"
141
- git -C "$r" worktree add -q --detach "$r/.worktrees/dev" main >/dev/null 2>&1
142
- git -C "$r/.worktrees/dev" switch -q -c task/P2-smoke main >/dev/null 2>&1
143
- use_stub_adapter "$r"
144
- local b; b="$(brief "$r" P1)"
145
- want="$(canon_branch "$r" "$skill" P1)"
146
- out="$(runp "$r" "$skill" dispatch dev P1 "$b")"; rc=$?
147
- br="$(engine "$r" "$skill" "team_state_get dev branch -")"
148
- [ "$rc" != "0" ] && grep -q 'task/P2-smoke' <<<"$out" && grep -qF "$want" <<<"$out" && grep -q 'switch' <<<"$out" && fixed=1
149
- assert_fix "$fixed" "F16 跨任务分支被拒 + 点名两分支 + 给出 switch(rc=$rc state分支=$br want=$want)"
150
- # P162:破坏性调用前先证明私有 socket 生效(不成立 → 硬停)
151
- tmux_iso_require "flip-m6.3" "收掉夹具 session" --tmpdir "${TMUX_TMPDIR:-}" --sock-name "$SOCK" --own-root "$TMP"
152
- tmux kill-session -t "$sess" >/dev/null 2>&1 || true
153
- }
154
-
155
- # ---- F26:PM 自己的收件箱算待办 --------------------------------------------
156
- case_f26() { # <skill> <tag>
157
- local skill="$1" tag="$2" r out fixed=0
158
- r="$(fixture "$skill" "$tag-f26" "m63-$tag-f26")"
159
- printf 'worker summary for the PM\n' > "$TMP/$tag-f26-summary.txt"
160
- runp "$r" "$skill" notify pm --from-file "$TMP/$tag-f26-summary.txt" >/dev/null 2>&1
161
- out="$(runp "$r" "$skill" watch --once | head -1)"
162
- grep -q '未读通知 1' <<<"$out" && fixed=1
163
- assert_fix "$fixed" "F26 watchdog 把 inbox/pm.md 算作待办(${out#*watchdog: })"
164
- }
165
-
166
- # ---- F15:项目外的任务书 ---------------------------------------------------
167
- case_f15() { # <skill> <tag>
168
- local skill="$1" tag="$2" r out rc fixed=0
169
- r="$(fixture "$skill" "$tag-f15" "m63-$tag-f15")"
170
- git -C "$r" worktree add -q --detach "$r/.worktrees/dev" main >/dev/null 2>&1
171
- git -C "$r/.worktrees/dev" switch -q -c "$(canon_branch "$r" "$skill" P1)" main >/dev/null 2>&1
172
- printf '# P9 · outside\n\n```\ntask: P9\nagent: dev\n```\n' > "$TMP/$tag-f15-outside.md"
173
- use_stub_adapter "$r"
174
- out="$(runp "$r" "$skill" dispatch dev P1 "$TMP/$tag-f15-outside.md" --print)"; rc=$?
175
- [ "$rc" != "0" ] && ! grep -q 'repo-relative' <<<"$out" && grep -qF "$r" <<<"$out" && fixed=1
176
- assert_fix "$fixed" "F15 项目外任务书被拒 + 不再叫 repo-relative(rc=$rc)"
177
- }
178
-
179
- # ---- F18:打错的收件人 -----------------------------------------------------
180
- case_f18() { # <skill> <tag>
181
- local skill="$1" tag="$2" r out rc fixed=0 anyrc=0
182
- r="$(fixture "$skill" "$tag-f18" "m63-$tag-f18")"
183
- out="$(runp "$r" "$skill" say devv 'hello?')"; rc=$?
184
- [ "$rc" != "0" ] && [ ! -f "$r/docs/team/inbox/devv.md" ] && grep -q 'dev' <<<"$out" && grep -q -- '--any' <<<"$out" && fixed=1
185
- if [ "$fixed" = "1" ]; then
186
- runp "$r" "$skill" say devv --any 'forced' >/dev/null 2>&1; anyrc=$?
187
- { [ "$anyrc" = "0" ] && grep -q 'forced' "$r/docs/team/inbox/devv.md" 2>/dev/null; } || fixed=0
188
- fi
189
- assert_fix "$fixed" "F18 未知收件人非零退出 + 点名名册 + --any 可强制(rc=$rc any=$anyrc)"
190
- }
191
-
192
- # ---- F17:去重键 -----------------------------------------------------------
193
- driver_f17() {
194
- cat > "$TMP/f17-drive.mjs" <<'DRV'
195
- import { readFileSync } from 'node:fs'
196
- const [extPath, root, cwd, textsFile] = process.argv.slice(2)
197
- delete process.env.TMUX_PANE
198
- const handlers = Object.create(null)
199
- const pi = { on: (e, h) => { handlers[e] = h }, registerCommand() {}, registerTool() {}, sendMessage() {} }
200
- const mod = await import(extPath)
201
- mod.default(pi)
202
- const settle = handlers.agent_settled
203
- for (const text of readFileSync(textsFile, 'utf8').split('\n').filter(Boolean)) {
204
- await settle({}, { cwd, sessionManager: { getEntries: () => [{ message: { role: 'assistant', content: [{ text }] } }] } })
205
- }
206
- DRV
207
- }
208
-
209
- case_f17() { # <skill> <tag>
210
- local skill="$1" tag="$2" r inbox n=""
211
- if [ -z "$TSRUN" ]; then printf ' (F17 跳过:没有 TS runner)\n'; return 0; fi
212
- r="$(fixture "$skill" "$tag-f17" "m63-$tag-f17")"
213
- git -C "$r" worktree add -q --detach "$r/.worktrees/dev" main >/dev/null 2>&1
214
- git -C "$r/.worktrees/dev" switch -q -c "$(canon_branch "$r" "$skill" P1)" main >/dev/null 2>&1
215
- inbox="$r/docs/team/inbox/dev.md"
216
- driver_f17
217
- local prefix='All gates are green. I delivered the parser fix; the remaining work on this branch is'
218
- { printf '%s the retry path.\n' "$prefix"; printf '%s the cache warm-up.\n' "$prefix"; printf '%s error mapping.\n' "$prefix"; } > "$TMP/$tag-f17.txt"
219
- ( cd "$r" && env TEAM_ROOT="$r" "$TSRUN" "$TMP/f17-drive.mjs" "$skill/extension/team-notify.ts" "$r" "$r/.worktrees/dev" "$TMP/$tag-f17.txt" ) >/dev/null 2>&1
220
- n="$(wc -l < "$inbox" 2>/dev/null | tr -d ' ' || echo 0)"
221
- local fixed=0
222
- if [ "$n" = "3" ]; then
223
- rm -f "$inbox" "$r/.pi/team/state/notify-dedup"
224
- printf 'Identical settle message, twice.\nIdentical settle message, twice.\n' > "$TMP/$tag-f17b.txt"
225
- ( cd "$r" && env TEAM_ROOT="$r" "$TSRUN" "$TMP/f17-drive.mjs" "$skill/extension/team-notify.ts" "$r" "$r/.worktrees/dev" "$TMP/$tag-f17b.txt" ) >/dev/null 2>&1
226
- local n2; n2="$(wc -l < "$inbox" 2>/dev/null | tr -d ' ' || echo 0)"
227
- [ "$n2" = "1" ] && fixed=1
228
- assert_fix "$fixed" "F17 三条前缀相同的简报都在($n 行)+ 重复同一条仍去重($n2 行)"
229
- else
230
- assert_fix 0 "F17 三条前缀相同的简报都在(实际 $n 行)"
231
- fi
232
- }
233
-
234
- # ---- F27:空 tmux 目标 -----------------------------------------------------
235
- case_f27() { # <skill> <tag>
236
- local skill="$1" tag="$2" r out rc fixed=0 sess panes
237
- sess="m63-$tag-f27"; r="$(fixture "$skill" "$tag-f27" "$sess")"
238
- tmux new-session -d -s "$sess" -n pm >/dev/null 2>&1 || true
239
- tmux send-keys -t "$sess:pm" 'clear' Enter >/dev/null 2>&1 || true
240
- out="$(engine "$r" "$skill" "TEAM_SESSION='$sess' team_tmux_send_text '' 'EMPTY-TARGET-PROBE'; echo rc=\$?")"
241
- rc="$(sed -n 's/^rc=//p' <<<"$out")"
242
- panes="$(tmux capture-pane -p -t "$sess:pm" 2>/dev/null)"
243
- [ "$rc" != "0" ] && ! grep -q 'EMPTY-TARGET-PROBE' <<<"$panes" && fixed=1
244
- assert_fix "$fixed" "F27 空目标被拒且探针不落地(rc=${rc:-?})"
245
- # P162:破坏性调用前先证明私有 socket 生效(不成立 → 硬停)
246
- tmux_iso_require "flip-m6.3" "收掉夹具 session" --tmpdir "${TMUX_TMPDIR:-}" --sock-name "$SOCK" --own-root "$TMP"
247
- tmux kill-session -t "$sess" >/dev/null 2>&1 || true
248
- }
249
-
250
- # ---- F30:wrapper agent 启动证据 -------------------------------------------
251
- case_f30() { # <skill> <tag>
252
- local skill="$1" tag="$2" r out fixed=0 wrap proof pid sess
253
- sess="m63-$tag-f30"; r="$(fixture "$skill" "$tag-f30" "$sess")"
254
- wrap="$TMP/$tag-f30-wrapper"
255
- printf '#!/bin/sh\nexec sleep 300\n' > "$wrap"; chmod +x "$wrap"
256
- printf 'TEAM_PI_BIN="%s"\n' "$wrap" >> "$r/.pi/team/config.sh"
257
- out="$(runp "$r" "$skill" up)"
258
- proof="$(cat "$r/.pi/team/state/pm.pid.proof" 2>/dev/null || true)"
259
- pid=""
260
- [ -f "$r/.pi/team/state/pm.pid" ] && pid="$(tr -dc '0-9' < "$r/.pi/team/state/pm.pid")"
261
- if grep -q 'PM 已启动' <<<"$out" && grep -q 'proof=spawn' <<<"$out" \
262
- && [ "$proof" = "spawn" ] && [ -n "$pid" ] && kill -0 "$pid" 2>/dev/null \
263
- && [ "$(readlink "/proc/$pid/cwd" 2>/dev/null)" = "$r" ]; then fixed=1; fi
264
- assert_fix "$fixed" "F30 wrapper agent 报已启动 + proof=spawn + 活 pid 在项目内(proof=${proof:-无})"
265
- # P162:破坏性调用前先证明私有 socket 生效(不成立 → 硬停)
266
- tmux_iso_require "flip-m6.3" "收掉夹具 session" --tmpdir "${TMUX_TMPDIR:-}" --sock-name "$SOCK" --own-root "$TMP"
267
- tmux kill-session -t "$sess" >/dev/null 2>&1 || true
268
- }
269
-
270
- run_tree() { # <red|green> <skill>
271
- EXPECT_TREE="$1"
272
- printf '\n\033[36m▸ %s tree:%s\033[0m\n' "$1" "$2"
273
- case_f16 "$2" "$1"; case_f26 "$2" "$1"; case_f15 "$2" "$1"; case_f18 "$2" "$1"
274
- case_f17 "$2" "$1"; case_f27 "$2" "$1"; case_f30 "$2" "$1"
275
- }
276
-
277
- hdr "M6.3 flip · red(base=$BASE) → green($GREEN_SKILL)"
278
- run_tree red "$RED_SKILL"
279
- run_tree green "$GREEN_SKILL"
280
- printf '\n\033[1m== flip-m6.3 结果 ==\033[0m ✓ %d ✗ %d\n' "$PASS" "$FAIL"
281
- [ "$FAIL" -eq 0 ] && { printf '\033[32mred 复现了全部 7 个 finding,green 全部修复\033[0m\n'; exit 0; }
282
- printf '\033[31m有断言不成立(红/绿说明见上)\033[0m\n'
283
- exit 1
@@ -1,267 +0,0 @@
1
- #!/usr/bin/env bash
2
- # M6.4 · 独立验证包:V4.0 F4/F6/F19/F21/F23 的 red → green 复现
3
- #
4
- # bash skills/teamsmith/tests/flip-m6.4.sh # 红树 = 与保护分支的分叉点,绿树 = 本 worktree
5
- # TEAM_FLIP_BASE=<sha> bash skills/teamsmith/tests/flip-m6.4.sh
6
- #
7
- # 为什么需要:M6.4 修的是「信号与承诺的诚实」——每一条都是「旧版真的会发错信号」。
8
- # 这个包**不复用 smoke 的夹具**:自己建仓库/自带 upstream 的 worktree/会议目录,对同一份现场
9
- # 分别跑「修复前」和「修复后」两棵 skill 树,断言旧版会红、新版会绿:
10
- #
11
- # F4 已 push(@{upstream}..HEAD=0)但领先 main 的分支:旧版 digest 喊「收尾:提交并 push」,新版不喊
12
- # F6 id 带 '-' 的任务(API-2):旧版把 reports/API-2-dev.md 当 id=API → 「忽略的非任务报告」,新版待复验
13
- # F19 会议 TTL:旧版 --ttl 0 接受、TTL_HOURS=abc 的历史会议永生,新版拒绝/按默认值判定过期
14
- # F21 落后会话的 version --check:旧版退出码 141(SIGPIPE),新版 0
15
- # F23 team reload:旧版承诺「watchdog 看到 marker 会重启 PM 会话」,新版删掉承诺、只说实的
16
- #
17
- # 只写 /tmp 下的临时目录,不碰调用者所在的任何仓库/session。
18
- set -uo pipefail
19
-
20
- SELF_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
21
- SKILL_DIR="$(cd -P "$SELF_DIR/.." && pwd)"
22
- # P53:临时根的唯一创建者(${TMPDIR:-/tmp} + owned 家族 + 回收)
23
- . "$SELF_DIR/lib/tmp-root.sh"
24
- REPO_ROOT="$(git -C "$SKILL_DIR" rev-parse --show-toplevel 2>/dev/null || true)"
25
- [ -n "$REPO_ROOT" ] || { printf 'flip-m6.4: 找不到 git 仓库(需要 git archive 取修复前的树)\n' >&2; exit 2; }
26
-
27
- BASE="${TEAM_FLIP_BASE:-}"
28
- if [ -z "$BASE" ]; then
29
- BASE="$(git -C "$REPO_ROOT" merge-base HEAD main 2>/dev/null || true)"
30
- fi
31
- [ -n "$BASE" ] || { printf 'flip-m6.4: 解析不到修复前的 revision,用 TEAM_FLIP_BASE=<sha> 指定\n' >&2; exit 2; }
32
-
33
- [ "${KEEP:-0}" = "1" ] && export TEAM_TMP_KEEP=1
34
- TMP="$(tmp_root_create flip-m6.4)" || exit 3
35
- cleanup() { tmp_root_reap_all; }
36
- trap cleanup EXIT
37
-
38
- # ---- 红树(修复前) / 绿树(修复后) -----------------------------------------
39
- mkdir -p "$TMP/red"
40
- git -C "$REPO_ROOT" archive "$BASE" skills/teamsmith | tar -x -C "$TMP/red" || exit 2
41
- RED_SKILL="$TMP/red/skills/teamsmith"
42
- GREEN_SKILL="$SKILL_DIR"
43
- # 守卫:传进来的 base 必须真的还是「修复前」,否则这个包会报出一个假的「翻转」
44
- for probe in 'team_git_upstream_ahead:scripts/lib/cmd-status.sh' \
45
- 'team_report_task_id:scripts/lib/common.sh' \
46
- 'team_meeting_ttl_hours:scripts/lib/cmd-meeting.sh' \
47
- '没有任何组件会因为 marker 重启会话:scripts/lib/cmd-update.sh'; do
48
- f="${probe#*:}"; needle="${probe%%:*}"
49
- if grep -qF "$needle" "$RED_SKILL/$f" 2>/dev/null; then
50
- printf 'flip-m6.4: $BASE 已经包含 M6.4 的修复(%s 里已有 %s)——用 TEAM_FLIP_BASE=<修复前的 sha> 指定\n' "$f" "$needle" >&2
51
- exit 2
52
- fi
53
- done
54
-
55
- # ---- 夹具仓库(同一个现场,两棵树各跑一遍) ----------------------------------
56
- REPO="$TMP/repo"; mkdir -p "$REPO"
57
- export TEAM_MEETINGS_DIR="$TMP/meetings"
58
- (
59
- cd "$REPO" || exit 1
60
- git init -q -b main .
61
- git config user.email flip@teamsmith
62
- git config user.name flip
63
- echo "# flip fixture" > README.md
64
- git add -A && git commit -qm "chore: init"
65
- bash "$GREEN_SKILL/scripts/team" init --session flip-m64 --agents dev --vcs local --gates true --docs docs/team >/dev/null 2>&1
66
- mkdir -p docs/team/reports
67
- ) || { printf 'flip-m6.4: 夹具仓库初始化失败\n' >&2; exit 2; }
68
-
69
- FAIL=0
70
- ok() { printf ' \033[32m✓\033[0m %s\n' "$1"; }
71
- bad() { printf ' \033[31m✗\033[0m %s\n' "$1"; FAIL=$((FAIL+1)); }
72
-
73
- team() { # <skill-dir> <log> <args...>(不覆盖名册)
74
- local sk="$1" log="$2"; shift 2
75
- ( cd "$REPO" && bash "$sk/scripts/team" "$@" ) >"$log" 2>&1
76
- TEAM_RC=$?
77
- }
78
- team_agents() { # <名册> <skill-dir> <log> <args...>(临时覆盖名册:环境变量优先于 config)
79
- local agents="$1" sk="$2" log="$3"; shift 3
80
- ( cd "$REPO" && TEAM_AGENTS="$agents" bash "$sk/scripts/team" "$@" ) >"$log" 2>&1
81
- TEAM_RC=$?
82
- }
83
- tailof() { grep -F -- "$2" "$1" | head -3; }
84
-
85
- printf '修复前 revision: %s(%s)\n修复后 skill: %s\n夹具仓库: %s\n' \
86
- "$BASE" "$(git -C "$REPO_ROOT" log -1 --format=%s "$BASE")" "$GREEN_SKILL" "$REPO"
87
-
88
- # ---------------------------------------------------------------- F4
89
- printf '\n=== F4 · push 状态必须相对 @{upstream} ===\n'
90
- F4WT="$REPO/.worktrees/f4"
91
- git -C "$REPO" init -q --bare "$TMP/origin.git"
92
- git -C "$REPO" worktree add -q -b task/F4 "$F4WT" main >/dev/null 2>&1 || true
93
- printf 'one\n' > "$F4WT/f4.txt"
94
- git -C "$F4WT" add -A >/dev/null 2>&1 && git -C "$F4WT" commit -qm "feat: demo" >/dev/null 2>&1
95
- git -C "$REPO" remote add origin "$TMP/origin.git" >/dev/null 2>&1 || true
96
- git -C "$F4WT" push -q -u origin task/F4 >/dev/null 2>&1
97
- printf '现场:@{upstream}..HEAD=%s(真的没东西可 push) main..HEAD=%s(旧版拿这个当下面的「未 push」)\n' \
98
- "$(git -C "$F4WT" rev-list --count '@{upstream}..HEAD')" "$(git -C "$F4WT" rev-list --count main..HEAD)"
99
-
100
- team_agents f4 "$RED_SKILL" "$TMP/f4-red.log" digest
101
- team_agents f4 "$GREEN_SKILL" "$TMP/f4-green.log" digest
102
- printf '[红] digest §[4] 相关行:\n'; tailof "$TMP/f4-red.log" "收尾:提交并 push" | sed 's/^/ /'
103
- printf '[绿] digest §[4] 相关行:\n'; tailof "$TMP/f4-green.log" "未 push" | sed 's/^/ /'
104
- if grep -qF '收尾:提交并 push' "$TMP/f4-red.log"; then
105
- ok "修复前:已 push 的分支被喊「收尾:提交并 push」(这就是 F4 的假信号)"
106
- else bad "修复前:夹具没造出假信号(旧版竟然没喊 push)"; fi
107
- if grep -qF '收尾:提交并 push' "$TMP/f4-green.log"; then
108
- bad "修复后:已 push 的分支仍然被喊 push"
109
- else ok "修复后:@{upstream}..HEAD=0 → 不再被当成未收尾"; fi
110
- if grep -qF '领先 1' "$TMP/f4-red.log" && ! grep -qF '领先 1' "$TMP/f4-green.log"; then
111
- ok "修复后:相对 main 的领先数不再冒充「未 push」(绿树 §[4] 里没有它)"
112
- else bad "修复后:关于「领先 main」的表达没有变(红有/绿无 这个差分不成立)"; fi
113
-
114
- # ---------------------------------------------------------------- F6
115
- printf '\n=== F6 · id 带 "-" 的任务报告(API-2) ===\n'
116
- team "$GREEN_SKILL" "$TMP/f6-task.log" task API-2 --title "api-2 endpoint" --agent dev
117
- printf '%s\n' '# API-2 · api-2 endpoint' '' 'agent: dev status: DONE' > "$REPO/docs/team/reports/API-2-dev.md"
118
- team "$RED_SKILL" "$TMP/f6-red.log" digest
119
- team "$GREEN_SKILL" "$TMP/f6-green.log" digest
120
- printf '[红] 忽略清单/待复验:\n'; { tailof "$TMP/f6-red.log" "忽略的非任务报告" | sed 's/^/ /'; tailof "$TMP/f6-red.log" "review API" | sed 's/^/ /'; }
121
- printf '[绿] 忽略清单/待复验:\n'; { tailof "$TMP/f6-green.log" "忽略的非任务报告" | sed 's/^/ /'; tailof "$TMP/f6-green.log" "review API" | sed 's/^/ /'; }
122
- if grep -qF '忽略的非任务报告:API-2-dev.md' "$TMP/f6-red.log" && ! grep -qF 'review API-2' "$TMP/f6-red.log"; then
123
- ok "修复前:正式任务 API-2 的报告落进「忽略的非任务报告」,也不在待复验里(F6)"
124
- else bad "修复前:夹具没造出误判(旧版没有把 API-2-dev.md 忽略)"; fi
125
- if grep -qF 'review API-2' "$TMP/f6-green.log" && ! grep -qF '忽略的非任务报告:API-2-dev.md' "$TMP/f6-green.log"; then
126
- ok "修复后:API-2 的报告进入待复验,且带完整 id"
127
- else bad "修复后:API-2 的报告仍然被判成非任务报告"; fi
128
-
129
- # ---------------------------------------------------------------- F19
130
- printf '\n=== F19 · 会议 TTL 不能是垃圾值/永生 ===\n'
131
- team "$RED_SKILL" "$TMP/f19-red.log" meeting open ttl-zero --with other --topic "ttl 0" --ttl 0 --yes
132
- RED_TTL_RC="$TEAM_RC"
133
- team "$GREEN_SKILL" "$TMP/f19-green.log" meeting open ttl-zero --with other --topic "ttl 0" --ttl 0 --yes
134
- GREEN_TTL_RC="$TEAM_RC"
135
- printf '[红] rc=%s 登记值:%s\n' "$RED_TTL_RC" "$(grep -s '^TTL_HOURS=' "$TMP/meetings/ttl-zero/state.env" 2>/dev/null || echo '(没有 state.env)')"
136
- printf '[绿] rc=%s %s\n' "$GREEN_TTL_RC" "$(grep -sF '正整数小时' "$TMP/f19-green.log" | head -1)"
137
- if [ "$RED_TTL_RC" = "0" ]; then ok "修复前:--ttl 0 被接受(会议成了永生)"
138
- else bad "修复前:夹具没造出「永生」格(--ttl 0 竟然被拒)"; fi
139
- if [ "$GREEN_TTL_RC" != "0" ]; then ok "修复后:--ttl 0 非 0 退出(被拒绝)"
140
- else bad "修复后:--ttl 0 仍然被接受"; fi
141
-
142
- # 历史遗留的非法登记值:旧版永生,新版按默认值判定过期
143
- team "$GREEN_SKILL" "$TMP/f19-legacy-open.log" meeting open ttl-legacy --with other --topic "legacy" --yes
144
- sed -i 's/^TTL_HOURS=.*/TTL_HOURS=abc/' "$TMP/meetings/ttl-legacy/state.env"
145
- sed -i 's/^OPENED_EPOCH=.*/OPENED_EPOCH=1000/' "$TMP/meetings/ttl-legacy/state.env"
146
- team "$RED_SKILL" "$TMP/f19-legacy-red.log" meeting read ttl-legacy --peek
147
- team "$GREEN_SKILL" "$TMP/f19-legacy-green.log" meeting read ttl-legacy --peek
148
- team "$RED_SKILL" "$TMP/f19-say-red.log" meeting say ttl-legacy --intent info "54 年后还能说吗"
149
- RED_SAY_RC="$TEAM_RC"
150
- team "$GREEN_SKILL" "$TMP/f19-say-green.log" meeting say ttl-legacy --intent info "54 年后还能说吗"
151
- GREEN_SAY_RC="$TEAM_RC"
152
- printf '[红] read:%s | say rc=%s\n' "$(grep -sF 'TTL' "$TMP/f19-legacy-red.log" | head -1 | sed 's/^[[:space:]]*//')" "$RED_SAY_RC"
153
- printf '[绿] read:%s | say rc=%s\n' "$(grep -sF 'TTL' "$TMP/f19-legacy-green.log" | head -1 | sed 's/^[[:space:]]*//')" "$GREEN_SAY_RC"
154
- if [ "$RED_SAY_RC" = "0" ]; then ok "修复前:TTL_HOURS=abc 的老会议 54 年后仍然能发言(F19 的永生)"
155
- else bad "修复前:夹具没造出永生(旧版竟然拒绝了 say)"; fi
156
- if [ "$GREEN_SAY_RC" != "0" ]; then ok "修复后:非法 TTL 按默认值判过期(say 被拒)"
157
- else bad "修复后:非法 TTL 的老会议仍然能发言"; fi
158
- if grep -qF 'TTL abch' "$TMP/f19-legacy-red.log"; then ok "修复前:read 把登记值原样印成 \"TTL abch\""
159
- else bad "修复前:read 没有印出 \"TTL abch\"(夹具或文案变了)"; fi
160
- if grep -qF 'TTL 72h' "$TMP/f19-legacy-green.log"; then ok "修复后:read 印有效 TTL(TTL 72h)"
161
- else bad "修复后:read 没有印有效 TTL"; fi
162
-
163
- # ---------------------------------------------------------------- F21
164
- printf '\n=== F21 · 落后会话的 version --check 退出码 ===\n'
165
- team "$RED_SKILL" "$TMP/f21-mark-red.log" mark-loaded --version 0.0.1
166
- team "$RED_SKILL" "$TMP/f21-red.log" version --check
167
- RED_V_RC="$TEAM_RC"
168
- team "$GREEN_SKILL" "$TMP/f21-mark-green.log" mark-loaded --version 0.0.1
169
- team "$GREEN_SKILL" "$TMP/f21-green.log" version --check
170
- GREEN_V_RC="$TEAM_RC"
171
- printf '[红] rc=%s %s\n' "$RED_V_RC" "$(grep -sF '本会话是旧的' "$TMP/f21-red.log" | head -1 | sed 's/^[[:space:]]*//')"
172
- printf '[绿] rc=%s %s\n' "$GREEN_V_RC" "$(grep -sF '本会话是旧的' "$TMP/f21-green.log" | head -1 | sed 's/^[[:space:]]*//')"
173
- if [ "$RED_V_RC" = "141" ]; then ok "修复前:退出码 141(SIGPIPE,head 提前退出 + pipefail)"
174
- else bad "修复前:退出码是 $RED_V_RC(没复现 141)"; fi
175
- if grep -qF '本会话是旧的' "$TMP/f21-red.log"; then ok "修复前:文案本身是对的(所以调用方会把 141 当崩溃)"
176
- else bad "修复前:连「本会话是旧的」都没打印(夹具不对)"; fi
177
- if [ "$GREEN_V_RC" = "0" ]; then ok "修复后:退出码 0(stale 不再是崩溃)"
178
- else bad "修复后:退出码是 $GREEN_V_RC"; fi
179
- if grep -qF '本会话是旧的' "$TMP/f21-green.log" && grep -qF '最新变更' "$TMP/f21-green.log"; then
180
- ok "修复后:既报「旧的」也仍然打印 CHANGELOG 摘要"
181
- else bad "修复后:CHANGELOG 摘要被吃掉了"; fi
182
- team "$GREEN_SKILL" "$TMP/f21-restore.log" mark-loaded >/dev/null 2>&1
183
-
184
- # ---------------------------------------------------------------- F23
185
- printf '\n=== F23 · team reload 的承诺 ===\n'
186
- team "$RED_SKILL" "$TMP/f23-red.log" reload
187
- team "$GREEN_SKILL" "$TMP/f23-green.log" reload
188
- printf '[红] %s\n' "$(grep -sF 'watchdog' "$TMP/f23-red.log" | head -1 | sed 's/^[[:space:]]*//')"
189
- printf '[绿] %s\n' "$(grep -sF 'marker' "$TMP/f23-green.log" | head -1 | sed 's/^[[:space:]]*//')"
190
- if grep -qF 'watchdog' "$TMP/f23-red.log" && grep -qF '重启 PM 会话' "$TMP/f23-red.log"; then
191
- ok "修复前:promises the watchdog will restart the PM session when it sees the marker"
192
- else bad "修复前:没有那句假承诺(文案变了?)"; fi
193
- if ! grep -qF '重启 PM 会话' "$TMP/f23-green.log" && grep -qF '没有任何组件会因为 marker 重启会话' "$TMP/f23-green.log"; then
194
- ok "修复后:删掉承诺,只说 marker 的真实作用(含「没有任何组件重启会话」)"
195
- else bad "修复后:承诺还在或没有说清实际行为"; fi
196
- GREEN_READERS="$(grep -rl 'reload-requested' "$GREEN_SKILL/scripts" 2>/dev/null | grep -v 'cmd-update.sh' || true)"
197
- if [ -z "$GREEN_READERS" ]; then ok "修复后:scripts/ 里除 cmd-update.sh 外确实没有组件读 marker"
198
- else bad "还有组件读 marker:$GREEN_READERS"; fi
199
- if grep -qF 'rmSync(marker, { force: true })' "$GREEN_SKILL/extension/team-notify.ts" 2>/dev/null; then
200
- ok "修复后:扩展侧只在 /reload 后清掉 marker(与文案一致)"
201
- else bad "扩展侧不再清理 marker(文案就又不准了)"; fi
202
- team "$GREEN_SKILL" "$TMP/f23-done.log" reload --done >/dev/null 2>&1
203
-
204
- # ---------------------------------------------------------------- 变异自检:把实现改坏 → 守卫必须红
205
- # 上面的红树是「整个修复前版本」;这里再单独把每一处修复改坏(其余都是修好的代码),
206
- # 确认守卫断言真的是针对这几行实现,而不是靠整个版本差异。
207
- printf '\n=== 变异自检(破坏实现 → 守卫断言必须变红) ===\n'
208
- MUT="$TMP/mutant"
209
- rm -rf "$MUT"; cp -r "$GREEN_SKILL" "$MUT"
210
- mutate() { # <文件> <原文字面量> <替换>(整行子串替换,避免 sed 的转义地狱)
211
- local f="$1" old="$2" new="$3"
212
- awk -v old="$old" -v new="$new" '{ p=index($0, old); if (p>0) { $0 = substr($0,1,p-1) new substr($0,p+length(old)) }; print }' "$f" > "$f.mut" && mv "$f.mut" "$f"
213
- }
214
- mutate "$MUT/scripts/lib/cmd-status.sh" '"$(team_git_upstream_ahead "$wt")"' '"$ahead"'
215
- mutate "$MUT/scripts/lib/common.sh" 'id="$(team_report_task_id "$glob")"' 'id="${base%%-*}"'
216
- mutate "$MUT/scripts/lib/cmd-status.sh" 'id="$(team_report_task_id "$glob")"' 'id="${base%%-*}"'
217
- mutate "$MUT/scripts/lib/cmd-meeting.sh" '[ "$ttl" -gt 0 ] 2>/dev/null || team_usage_die' '[ "$ttl" -gt 0 ] 2>/dev/null || team_warn'
218
- f21_old="$(grep -F 'BEGIN{n=0} /^## /' "$MUT/scripts/lib/cmd-update.sh" | head -1)"
219
- [ -n "$f21_old" ] && mutate "$MUT/scripts/lib/cmd-update.sh" "$f21_old" ' sed -n '\''/^## /,$p'\'' "$(team_skill_changelog)" | head -14 | sed '\''s/^/ /'\'''
220
- mutate "$MUT/scripts/lib/cmd-update.sh" 'marker(.pi/team/state/reload-requested)仅用于记账' '若你有 watchdog:它看到 marker 后会重启 PM 会话(pi -c 保留历史。marker 记账'
221
- MUTATIONS="$(diff -rq "$GREEN_SKILL/scripts" "$MUT/scripts" 2>/dev/null | wc -l | tr -d ' ')"
222
- printf '已注入变异:%s 个文件不同(期望 4:cmd-status/cmd-meeting/cmd-update/common)\n' "$MUTATIONS"
223
-
224
- # 边界:变异树必须只作用在夹具仓库上(第一次写这个包时就踩过:CLI 用调用者的 cwd,
225
- # 结果把真实项目当成了受测对象)。每条命令都在夹具仓库里跑,并且先证明 paths 认的是夹具。
226
- mut() { # <log> <env 名册或 -> <args...>:在夹具仓库里跑变异树
227
- local log="$1" agents="$2"; shift 2
228
- ( cd "$REPO" && [ "$agents" = "-" ] && bash "$MUT/scripts/team" "$@" || TEAM_AGENTS="$agents" bash "$MUT/scripts/team" "$@" ) >"$log" 2>&1
229
- MUT_RC=$?
230
- }
231
- MUT_ROOT="$( cd "$REPO" && bash "$MUT/scripts/team" paths 2>/dev/null | sed -n 's/.*"main_root": "\([^"]*\)".*/\1/p' )"
232
- if [ "$MUT_ROOT" = "$REPO" ]; then ok "变异自检在夹具仓库里跑(main_root=$REPO)"
233
- else bad "变异自检没有认到夹具仓库(main_root=$MUT_ROOT)——拒绝继续"; printf '\n'; exit 2; fi
234
-
235
- # 守卫 1(F4):改了 push 状态的口径 → digest 必须重新喊 push
236
- mut "$TMP/mut-f4.log" f4 digest
237
- if grep -qF '收尾:提交并 push' "$TMP/mut-f4.log"; then ok "变异 F4:把 upstream 量法改回保护分支 → 守卫(不许喊 push)变红"
238
- else bad "变异 F4:改回旧口径后 digest 竟然仍然不喊 push(守卫没在防这条实现)"; fi
239
- # 守卫 2(F6):两个调用点(common/report 扫描 + cmd-status 待复验覆盖)都得改回「第一个 '-'」
240
- mut "$TMP/mut-f6.log" - digest
241
- if grep -qF '忽略的非任务报告:API-2-dev.md' "$TMP/mut-f6.log" && ! grep -qF 'review API-2' "$TMP/mut-f6.log"; then
242
- ok "变异 F6:改回首个 '-' 切 id → 守卫(API-2 必须在待复验)变红"
243
- else bad "变异 F6:改回旧解析后 API-2 仍然在待复验(守卫没在防这条实现)"; fi
244
- # 守卫 3(F19):去掉「必须正数」这一半 → --ttl 0 必须又能被接受
245
- mut "$TMP/mut-f19.log" - meeting open mut-ttl --with other --topic "mutant" --ttl 0 --yes
246
- if [ "$MUT_RC" = "0" ]; then ok "变异 F19:去掉正数校验 → 守卫(--ttl 0 必须被拒)变红"
247
- else bad "变异 F19:去掉校验后 --ttl 0 仍然被拒(守卫没在防这条实现)"; fi
248
- # 守卫 4(F21):改回 sed|head 管道 → 退出码必须又变 141
249
- mut "$TMP/mut-f21-mark.log" - mark-loaded --version 0.0.1
250
- mut "$TMP/mut-f21.log" - version --check
251
- if [ "$MUT_RC" = "141" ]; then ok "变异 F21:改回 sed|head 管道 → 守卫(退出码必须 0)变红"
252
- else bad "变异 F21:改回管道后退出码是 $MUT_RC(守卫没在防这条实现)"; fi
253
- ( cd "$REPO" && bash "$GREEN_SKILL/scripts/team" mark-loaded ) >/dev/null 2>&1
254
- # 守卫 5(F23):把假承诺放回去 → 守卫(不许出现「重启 PM 会话」)必须变红
255
- mut "$TMP/mut-f23.log" - reload
256
- if grep -qF '重启 PM 会话' "$TMP/mut-f23.log"; then ok "变异 F23:把假承诺放回文案 → 守卫(不许承诺重启)变红"
257
- else bad "变异 F23:放回假承诺后守卫没抓到(守卫没在防这条文案)"; fi
258
- mut "$TMP/mut-f23-done.log" - reload --done
259
-
260
- # ---------------------------------------------------------------- 汇总
261
- printf '\n'
262
- if [ "$FAIL" -eq 0 ]; then
263
- printf '\033[32mflip-m6.4:五个 finding 的翻转全部复现(红 → 绿)\033[0m\n'
264
- exit 0
265
- fi
266
- printf '\033[31mflip-m6.4:有 %d 条翻转断言失败(见上)\033[0m\n' "$FAIL"
267
- exit 1