teamsmith 0.0.0-stage → 0.1.2
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.
- package/LICENSE +21 -0
- package/README.md +158 -2
- package/bin/team.mjs +59 -0
- package/install.sh +94 -0
- package/package.json +37 -4
- package/skills/teamsmith/CHANGELOG.md +763 -0
- package/skills/teamsmith/SKILL.md +312 -0
- package/skills/teamsmith/extension/team-bg.ts +435 -0
- package/skills/teamsmith/extension/team-inbox-watch.ts +1412 -0
- package/skills/teamsmith/extension/team-notify.ts +663 -0
- package/skills/teamsmith/references/agent-adapters.md +643 -0
- package/skills/teamsmith/references/config.md +477 -0
- package/skills/teamsmith/references/meeting.md +124 -0
- package/skills/teamsmith/references/memory.md +133 -0
- package/skills/teamsmith/references/migration.md +227 -0
- package/skills/teamsmith/references/openspec.md +222 -0
- package/skills/teamsmith/references/philosophy.md +95 -0
- package/skills/teamsmith/references/protocol.md +712 -0
- package/skills/teamsmith/references/troubleshooting.md +1384 -0
- package/skills/teamsmith/references/workflows.md +448 -0
- package/skills/teamsmith/scripts/lib/cmd-agents.sh +1709 -0
- package/skills/teamsmith/scripts/lib/cmd-bg.sh +284 -0
- package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +311 -0
- package/skills/teamsmith/scripts/lib/cmd-config.sh +1156 -0
- package/skills/teamsmith/scripts/lib/cmd-death.sh +562 -0
- package/skills/teamsmith/scripts/lib/cmd-docs.sh +149 -0
- package/skills/teamsmith/scripts/lib/cmd-draft.sh +124 -0
- package/skills/teamsmith/scripts/lib/cmd-init.sh +212 -0
- package/skills/teamsmith/scripts/lib/cmd-meeting.sh +904 -0
- package/skills/teamsmith/scripts/lib/cmd-outbox.sh +196 -0
- package/skills/teamsmith/scripts/lib/cmd-project.sh +642 -0
- package/skills/teamsmith/scripts/lib/cmd-review.sh +1393 -0
- package/skills/teamsmith/scripts/lib/cmd-status.sh +1399 -0
- package/skills/teamsmith/scripts/lib/cmd-update.sh +191 -0
- package/skills/teamsmith/scripts/lib/cmd-watch.sh +1681 -0
- package/skills/teamsmith/scripts/lib/common.sh +4964 -0
- package/skills/teamsmith/scripts/lib/draft-entry.sh +51 -0
- package/skills/teamsmith/scripts/lib/outbox.sh +2042 -0
- package/skills/teamsmith/scripts/lib/tmux-argv.sh +165 -0
- package/skills/teamsmith/scripts/monitor.mjs +616 -0
- package/skills/teamsmith/scripts/panel/README.md +192 -0
- package/skills/teamsmith/scripts/panel/build.sh +47 -0
- package/skills/teamsmith/scripts/panel/bun.lock +109 -0
- package/skills/teamsmith/scripts/panel/draft-send.sh +68 -0
- package/skills/teamsmith/scripts/panel/package.json +24 -0
- package/skills/teamsmith/scripts/panel/panel.js +388 -0
- package/skills/teamsmith/scripts/panel/src/App.tsx +2150 -0
- package/skills/teamsmith/scripts/panel/src/clipboard.ts +154 -0
- package/skills/teamsmith/scripts/panel/src/compose.ts +691 -0
- package/skills/teamsmith/scripts/panel/src/data.ts +555 -0
- package/skills/teamsmith/scripts/panel/src/format.ts +50 -0
- package/skills/teamsmith/scripts/panel/src/layout.ts +2562 -0
- package/skills/teamsmith/scripts/panel/src/main.tsx +894 -0
- package/skills/teamsmith/scripts/panel/src/markdown.ts +340 -0
- package/skills/teamsmith/scripts/panel/src/sanitize.ts +42 -0
- package/skills/teamsmith/scripts/panel/src/settings.ts +154 -0
- package/skills/teamsmith/scripts/panel/src/strings/en.ts +416 -0
- package/skills/teamsmith/scripts/panel/src/strings/index.ts +65 -0
- package/skills/teamsmith/scripts/panel/src/strings/types.ts +9 -0
- package/skills/teamsmith/scripts/panel/src/strings/zh.ts +414 -0
- package/skills/teamsmith/scripts/panel/src/theme.ts +116 -0
- package/skills/teamsmith/scripts/panel/src/types.ts +652 -0
- package/skills/teamsmith/scripts/panel/src/width.ts +105 -0
- package/skills/teamsmith/scripts/panel/tsconfig.json +16 -0
- package/skills/teamsmith/scripts/shim/signal-gate +156 -0
- package/skills/teamsmith/scripts/shim/tmux +403 -0
- package/skills/teamsmith/scripts/team +143 -0
- package/skills/teamsmith/templates/AGENTS.section.md.tmpl +147 -0
- package/skills/teamsmith/templates/BOARD.md.tmpl +18 -0
- package/skills/teamsmith/templates/DECISIONS.md.tmpl +22 -0
- package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +25 -0
- package/skills/teamsmith/templates/PROTOCOL.md.tmpl +84 -0
- package/skills/teamsmith/templates/ROADMAP.md.tmpl +29 -0
- package/skills/teamsmith/templates/config.sh.tmpl +106 -0
- package/skills/teamsmith/templates/memory-seed.md.tmpl +46 -0
- package/skills/teamsmith/templates/pm-prompt.md.tmpl +110 -0
- package/skills/teamsmith/templates/report.md.tmpl +36 -0
- package/skills/teamsmith/templates/task.md.tmpl +65 -0
- package/skills/teamsmith/templates/threads-README.md +17 -0
- package/skills/teamsmith/tests/bg-ledger-harness.mjs +682 -0
- package/skills/teamsmith/tests/bg-ledger.sh +307 -0
- package/skills/teamsmith/tests/checkout-shape-probe.sh +800 -0
- package/skills/teamsmith/tests/config-cli.sh +1562 -0
- package/skills/teamsmith/tests/container-tmux.sh +493 -0
- package/skills/teamsmith/tests/coverage-inventory.sh +173 -0
- package/skills/teamsmith/tests/death-cause.sh +564 -0
- package/skills/teamsmith/tests/delivery-truth.sh +1231 -0
- package/skills/teamsmith/tests/fake-tui.py +450 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/README.md +60 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/judge-second.py +139 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/mock-server.py +29 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/observe.ts +20 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/run-case.sh +79 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +175 -0
- package/skills/teamsmith/tests/fixtures/p55/flip-p49.sh +229 -0
- package/skills/teamsmith/tests/fixtures/p71-incident/README.md +22 -0
- package/skills/teamsmith/tests/fixtures/p71-incident/dev2.seen +8 -0
- package/skills/teamsmith/tests/fixtures/p71-incident/dev2.wake +9 -0
- package/skills/teamsmith/tests/fixtures/p71-incident/pm-nudges.wake +3 -0
- package/skills/teamsmith/tests/fixtures/signal-lint-cases.txt +40 -0
- package/skills/teamsmith/tests/flip-glue.sh +162 -0
- package/skills/teamsmith/tests/flip-m12-26c.sh +129 -0
- package/skills/teamsmith/tests/flip-m12.sh +185 -0
- package/skills/teamsmith/tests/flip-m16.sh +166 -0
- package/skills/teamsmith/tests/flip-m17.sh +204 -0
- package/skills/teamsmith/tests/flip-m33.sh +284 -0
- package/skills/teamsmith/tests/flip-m34.sh +96 -0
- package/skills/teamsmith/tests/flip-m37.sh +185 -0
- package/skills/teamsmith/tests/flip-m4.3.sh +375 -0
- package/skills/teamsmith/tests/flip-m43.sh +128 -0
- package/skills/teamsmith/tests/flip-m44.sh +262 -0
- package/skills/teamsmith/tests/flip-m45.sh +244 -0
- package/skills/teamsmith/tests/flip-m46.sh +238 -0
- package/skills/teamsmith/tests/flip-m48.sh +304 -0
- package/skills/teamsmith/tests/flip-m6.2.sh +205 -0
- package/skills/teamsmith/tests/flip-m6.3.sh +283 -0
- package/skills/teamsmith/tests/flip-m6.4.sh +267 -0
- package/skills/teamsmith/tests/flip-m6.5.sh +113 -0
- package/skills/teamsmith/tests/flip-m7.1.sh +135 -0
- package/skills/teamsmith/tests/flip-m7.2.sh +321 -0
- package/skills/teamsmith/tests/flip-p144.sh +112 -0
- package/skills/teamsmith/tests/flip-p156.sh +133 -0
- package/skills/teamsmith/tests/flip-p158.sh +301 -0
- package/skills/teamsmith/tests/flip-p160.sh +182 -0
- package/skills/teamsmith/tests/flip-p171.sh +249 -0
- package/skills/teamsmith/tests/flip-p18.1.sh +95 -0
- package/skills/teamsmith/tests/flip-p20.sh +286 -0
- package/skills/teamsmith/tests/flip-p201.sh +249 -0
- package/skills/teamsmith/tests/flip-p210.sh +239 -0
- package/skills/teamsmith/tests/flip-p211.sh +152 -0
- package/skills/teamsmith/tests/flip-p217.sh +288 -0
- package/skills/teamsmith/tests/flip-p22.sh +123 -0
- package/skills/teamsmith/tests/flip-p23.sh +239 -0
- package/skills/teamsmith/tests/flip-p25.sh +165 -0
- package/skills/teamsmith/tests/flip-p71.sh +184 -0
- package/skills/teamsmith/tests/flip-p72.sh +202 -0
- package/skills/teamsmith/tests/frames/README.md +176 -0
- package/skills/teamsmith/tests/frames/p78-conversation-rule-below-box.txt +6 -0
- package/skills/teamsmith/tests/frames/p78-cursor-mid-draft.txt +6 -0
- package/skills/teamsmith/tests/frames/p78-draft-rule-below-cursor-line.txt +6 -0
- package/skills/teamsmith/tests/frames/p78-draft-rule-below-cursor.txt +6 -0
- package/skills/teamsmith/tests/frames/p78-draft-rule-blank-region.txt +6 -0
- package/skills/teamsmith/tests/frames/p78-draft-rule-only.txt +5 -0
- package/skills/teamsmith/tests/frames/p78-spinner-row-below-cursor.txt +6 -0
- package/skills/teamsmith/tests/frames/p78-wider-rule-below-cursor.txt +6 -0
- package/skills/teamsmith/tests/frames/p86-f1-mixed-width-disjoint-box.txt +8 -0
- package/skills/teamsmith/tests/frames/p86-f1-narrower-width-disjoint-box.txt +8 -0
- package/skills/teamsmith/tests/frames/p86-f1-spinner-top-disjoint-box.txt +8 -0
- package/skills/teamsmith/tests/frames/pi-0.85.1-update-banner.txt +30 -0
- package/skills/teamsmith/tests/frames/pi-0.87.0-draft-half-sentence.txt +30 -0
- package/skills/teamsmith/tests/frames/pi-0.87.0-empty-box.txt +30 -0
- package/skills/teamsmith/tests/frames/pi-0.87.0-one-line-draft.txt +30 -0
- package/skills/teamsmith/tests/frames/pi-0.87.0-project-trust-prompt.txt +30 -0
- package/skills/teamsmith/tests/frames/pi-0.99.2-empty-editor.txt +32 -0
- package/skills/teamsmith/tests/frames/pi-0.99.2-human-draft.txt +32 -0
- package/skills/teamsmith/tests/frames/pi-1.0.0-git-error-in-box.txt +32 -0
- package/skills/teamsmith/tests/gate-guard.sh +112 -0
- package/skills/teamsmith/tests/guard-matrix.sh +233 -0
- package/skills/teamsmith/tests/install-shape.sh +731 -0
- package/skills/teamsmith/tests/ledger-ban.sh +612 -0
- package/skills/teamsmith/tests/lib/box-judge.sh +68 -0
- package/skills/teamsmith/tests/lib/checkout-shape.sh +129 -0
- package/skills/teamsmith/tests/lib/loop-scan.awk +114 -0
- package/skills/teamsmith/tests/lib/pty-wait.sh +676 -0
- package/skills/teamsmith/tests/lib/section-guard.sh +855 -0
- package/skills/teamsmith/tests/lib/shell-lex.pl +261 -0
- package/skills/teamsmith/tests/lib/tmp-root.sh +528 -0
- package/skills/teamsmith/tests/lib/tmux-cap.sh +35 -0
- package/skills/teamsmith/tests/lib/tmux-iso-call-probe.sh +81 -0
- package/skills/teamsmith/tests/lib/tmux-iso-probe.sh +46 -0
- package/skills/teamsmith/tests/lib/tmux-iso.sh +381 -0
- package/skills/teamsmith/tests/load-experiment.sh +290 -0
- package/skills/teamsmith/tests/loop-inventory.tsv +84 -0
- package/skills/teamsmith/tests/panel-b2-slow-stub.sh +19 -0
- package/skills/teamsmith/tests/panel-b2.sh +1183 -0
- package/skills/teamsmith/tests/panel-b3-pty-mouse.py +240 -0
- package/skills/teamsmith/tests/panel-b3-pty-tmux-mouse.py +138 -0
- package/skills/teamsmith/tests/panel-b3-stub.sh +279 -0
- package/skills/teamsmith/tests/panel-b3.sh +1301 -0
- package/skills/teamsmith/tests/panel-choices.sh +572 -0
- package/skills/teamsmith/tests/panel-clipboard-model.ts +187 -0
- package/skills/teamsmith/tests/panel-compose-model.ts +290 -0
- package/skills/teamsmith/tests/panel-contrast.mjs +81 -0
- package/skills/teamsmith/tests/panel-cpu-premise.sh +173 -0
- package/skills/teamsmith/tests/panel-cpu.sh +391 -0
- package/skills/teamsmith/tests/panel-flip-m54.sh +207 -0
- package/skills/teamsmith/tests/panel-flip-p123.sh +278 -0
- package/skills/teamsmith/tests/panel-flip-p125.sh +318 -0
- package/skills/teamsmith/tests/panel-flip-p128.sh +259 -0
- package/skills/teamsmith/tests/panel-keyprobe-pty.py +99 -0
- package/skills/teamsmith/tests/panel-keyprobe-stub.sh +41 -0
- package/skills/teamsmith/tests/panel-keyprobe.sh +82 -0
- package/skills/teamsmith/tests/panel-keyprobe.tsx +116 -0
- package/skills/teamsmith/tests/panel-knobs.sh +83 -0
- package/skills/teamsmith/tests/panel-p21.sh +2181 -0
- package/skills/teamsmith/tests/panel-snapshots.sh +802 -0
- package/skills/teamsmith/tests/panel-strings.mjs +195 -0
- package/skills/teamsmith/tests/perf.sh +740 -0
- package/skills/teamsmith/tests/pm-box-real.sh +350 -0
- package/skills/teamsmith/tests/pulse-nudge-key.sh +563 -0
- package/skills/teamsmith/tests/routes.sh +1652 -0
- package/skills/teamsmith/tests/section-budgets.tsv +150 -0
- package/skills/teamsmith/tests/section-guard.sh +231 -0
- package/skills/teamsmith/tests/section-needs-audit.sh +94 -0
- package/skills/teamsmith/tests/section-paths.tsv +142 -0
- package/skills/teamsmith/tests/section-select.sh +655 -0
- package/skills/teamsmith/tests/signal-gate.sh +366 -0
- package/skills/teamsmith/tests/signal-lint-legacy.txt +14 -0
- package/skills/teamsmith/tests/signal-lint.pl +416 -0
- package/skills/teamsmith/tests/skill-load.mjs +65 -0
- package/skills/teamsmith/tests/smoke.sh +19711 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-120-detail.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-120-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-120.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-160-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-160.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-59-detail.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-59-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-59.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-99-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-99.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-120-detail.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-120-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-120.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-160-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-160.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-59-detail.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-59-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-59.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-99-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-99.txt +32 -0
- package/skills/teamsmith/tests/spec-ledger-refs.tsv +78 -0
- package/skills/teamsmith/tests/spec-refs.sh +826 -0
- package/skills/teamsmith/tests/task-header-model.sh +267 -0
- package/skills/teamsmith/tests/team-bg-flip.sh +239 -0
- package/skills/teamsmith/tests/team-bg-harness.mjs +392 -0
- package/skills/teamsmith/tests/team-bg-stop.sh +434 -0
- package/skills/teamsmith/tests/team-inbox-watch-flip.sh +191 -0
- package/skills/teamsmith/tests/team-inbox-watch-harness.mjs +1559 -0
- package/skills/teamsmith/tests/tmp-hygiene.sh +1190 -0
- package/skills/teamsmith/tests/tmux-lint-legacy.txt +31 -0
- package/skills/teamsmith/tests/tmux-lint.pl +604 -0
- package/skills/teamsmith-init/SKILL.md +100 -0
- package/skills/teamsmith-init/references/bootstrap.md +74 -0
- package/skills/teamsmith-init/templates/bootstrap-prompt.md.tmpl +46 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# P28 · 翻转包:inbox-spool-resilience(字节真值的 offset / 证据化的缩容 / 收敛)的 red → green 证据
|
|
3
|
+
#
|
|
4
|
+
# bash skills/teamsmith/tests/flip-p25.sh
|
|
5
|
+
# TEAM_FLIP_BASE=<sha> bash skills/teamsmith/tests/flip-p25.sh # 覆盖「修复前」的 revision
|
|
6
|
+
#
|
|
7
|
+
# 事故(2026-09-20 06:42,主树 .pi/team/state/inbox-watch.log:179-205):生产者把预览裁在多字节字符中间
|
|
8
|
+
# (`LC_ALL=C cut -c1-700` 是按字节的)→ spool 行不是合法 UTF-8;读者的 `readNewLines` 用
|
|
9
|
+
# `Buffer.byteLength(解码结果)` 算 advance(一个非法字节 = U+FFFD = 3 字节)→ baseline = size + 1 →
|
|
10
|
+
# 之后每一拍都像外部缩容:`spool shrink` + `rescan lines=66 … deliver=20` 每 5 秒一轮,把 1–2 天前的
|
|
11
|
+
# 66 行叫了四遍(`total` 灌水),直到有人手清 spool。
|
|
12
|
+
#
|
|
13
|
+
# 本包用**同一个 harness**(tests/team-inbox-watch-harness.mjs;S18/S19 是 P28 加的用例)对五种树各跑
|
|
14
|
+
# 一遍(夹具不变,只换被测扩展):
|
|
15
|
+
# ① 红树(TEAM_FLIP_BASE / merge-base HEAD main 的 P28 之前扩展)→ S18 必须 FAIL(复现假缩容)
|
|
16
|
+
# ② 绿树(本 worktree)→ 全 PASS
|
|
17
|
+
# ③ 变异 A(绿树 + 旧 advance)→ S18 必须 FAIL(baseline = size + 1)
|
|
18
|
+
# ④ 变异 B(A + 去掉 clamp/repeat 守卫)→ S18 必须 FAIL,且空闲每拍都写 `spool shrink`(2026-09-20 的循环本身)
|
|
19
|
+
# ⑤ 变异 C(绿树 + 无条件 clamp)→ S19b 必须 FAIL(真重写再也读不到)
|
|
20
|
+
#
|
|
21
|
+
# 退出码:0 = 五个预期全部成立;1 = 有任何一个不成立;2 = 环境/前置不满足(不算绿也不算红)。
|
|
22
|
+
# 隔离:harness 自己就是隔离夹具(清 TEAM_*/TMUX 身份、临时仓库、真实仓库 state/ 前后快照反守卫),
|
|
23
|
+
# 本脚本只写 /tmp 临时目录,不调用 tmux。
|
|
24
|
+
set -uo pipefail
|
|
25
|
+
|
|
26
|
+
SELF_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
27
|
+
SKILL_DIR="$(cd -P "$SELF_DIR/.." && pwd)"
|
|
28
|
+
# P53:临时根的唯一创建者(${TMPDIR:-/tmp} + owned 家族 + 回收)
|
|
29
|
+
. "$SELF_DIR/lib/tmp-root.sh"
|
|
30
|
+
REPO_ROOT="$(git -C "$SKILL_DIR" rev-parse --show-toplevel 2>/dev/null || true)"
|
|
31
|
+
[ -n "$REPO_ROOT" ] || { printf 'flip-p25: 找不到 git 仓库(需要 git archive 取修复前的树)\n' >&2; exit 2; }
|
|
32
|
+
|
|
33
|
+
# 能直接跑 .ts 的运行时(与 smoke.sh / flip-m43.sh 同口径)
|
|
34
|
+
TS_RUNNER=""
|
|
35
|
+
if command -v node >/dev/null 2>&1 && node -e 'process.exit(process.features.typescript?0:1)' >/dev/null 2>&1; then
|
|
36
|
+
TS_RUNNER="node"
|
|
37
|
+
elif command -v bun >/dev/null 2>&1 && bun -e '1' >/dev/null 2>&1; then
|
|
38
|
+
TS_RUNNER="bun"
|
|
39
|
+
elif [ -x "$HOME/.bun/bin/bun" ] && "$HOME/.bun/bin/bun" -e '1' >/dev/null 2>&1; then
|
|
40
|
+
TS_RUNNER="$HOME/.bun/bin/bun"
|
|
41
|
+
fi
|
|
42
|
+
[ -n "$TS_RUNNER" ] || { printf 'flip-p25: 需要 node(类型剥离)或 bun 来跑 TS 扩展\n' >&2; exit 2; }
|
|
43
|
+
|
|
44
|
+
BASE="${TEAM_FLIP_BASE:-}"
|
|
45
|
+
if [ -z "$BASE" ]; then
|
|
46
|
+
BASE="$(git -C "$REPO_ROOT" merge-base HEAD main 2>/dev/null || true)"
|
|
47
|
+
fi
|
|
48
|
+
[ -n "$BASE" ] || BASE="$(git -C "$REPO_ROOT" rev-parse --verify -q HEAD^ 2>/dev/null || true)"
|
|
49
|
+
[ -n "$BASE" ] || { printf 'flip-p25: 解析不到修复前的 revision,用 TEAM_FLIP_BASE=<sha> 指定\n' >&2; exit 2; }
|
|
50
|
+
|
|
51
|
+
[ "${KEEP:-0}" = "1" ] && export TEAM_TMP_KEEP=1
|
|
52
|
+
TMP="$(tmp_root_create flip-p25)" || exit 3
|
|
53
|
+
cleanup() {
|
|
54
|
+
[ "${BASHPID:-$$}" = "$$" ] || return 0 # 管道/命令替换的子 shell 不要重复清场
|
|
55
|
+
tmp_root_reap_all
|
|
56
|
+
}
|
|
57
|
+
trap cleanup EXIT
|
|
58
|
+
|
|
59
|
+
fail() { printf '\033[31m✗\033[0m %s\n' "$*"; }
|
|
60
|
+
pass() { printf '\033[32m✓\033[0m %s\n' "$*"; }
|
|
61
|
+
|
|
62
|
+
GREEN_EXT="$SKILL_DIR/extension/team-inbox-watch.ts"
|
|
63
|
+
HARNESS="$SKILL_DIR/tests/team-inbox-watch-harness.mjs"
|
|
64
|
+
|
|
65
|
+
# ---- 红树 + 三种变异树 ---------------------------------------------------------------------
|
|
66
|
+
mkdir -p "$TMP/red-skill" "$TMP/mutA/extension" "$TMP/mutB/extension" "$TMP/mutC/extension"
|
|
67
|
+
git -C "$REPO_ROOT" archive "$BASE" skills/teamsmith | tar -x -C "$TMP/red-skill" || exit 2
|
|
68
|
+
RED_EXT="$TMP/red-skill/skills/teamsmith/extension/team-inbox-watch.ts"
|
|
69
|
+
|
|
70
|
+
# 前置守卫:红树必须真的还没修,绿树必须真的修了、且可变异的那一行还在
|
|
71
|
+
grep -q 'offset resync' "$RED_EXT" 2>/dev/null && {
|
|
72
|
+
printf 'flip-p25: $BASE 已经包含 P28 的修复(不是修复前的树)——用 TEAM_FLIP_BASE=<修复前的 sha> 指定\n' >&2; exit 2; }
|
|
73
|
+
grep -q 'offset resync' "$GREEN_EXT" || { printf 'flip-p25: 本树扩展里没有 offset resync(P28 的修复不在?)\n' >&2; exit 2; }
|
|
74
|
+
grep -q 'const advance = end + 1' "$GREEN_EXT" || { printf 'flip-p25: 找不到变异锚点 const advance = end + 1\n' >&2; exit 2; }
|
|
75
|
+
grep -q 'headUnchanged(cur) && (repeat || regress <= clampBytes())' "$GREEN_EXT" \
|
|
76
|
+
|| { printf 'flip-p25: 找不到变异锚点 headUnchanged(cur) ... clampBytes()\n' >&2; exit 2; }
|
|
77
|
+
|
|
78
|
+
OLD_ADVANCE='const advance = Buffer.byteLength(win.subarray(0, end + 1).toString("utf8"), "utf8")'
|
|
79
|
+
mutate_advance() { # <file>
|
|
80
|
+
sed -i "s@const advance = end + 1@$OLD_ADVANCE@" "$1"
|
|
81
|
+
grep -qF "$OLD_ADVANCE" "$1" || { printf 'flip-p25: 旧 advance 变异没打上\n' >&2; exit 2; }
|
|
82
|
+
}
|
|
83
|
+
mutate_clamp_guard() { # <file>:去掉 clamp/repeat 守卫(shrink 一律重扫)
|
|
84
|
+
sed -i 's@if (size >= 0 \&\& headUnchanged(cur) \&\& (repeat || regress <= clampBytes()))@if (false)@' "$1"
|
|
85
|
+
[ "$(grep -c 'if (false) {' "$1")" = "1" ] || { printf 'flip-p25: 守卫变异没打上\n' >&2; exit 2; }
|
|
86
|
+
}
|
|
87
|
+
mutate_always_clamp() { # <file>:任何 shrink 都 clamp(重扫永远发生不了)
|
|
88
|
+
sed -i 's@if (size >= 0 \&\& headUnchanged(cur) \&\& (repeat || regress <= clampBytes()))@if (size >= 0)@' "$1"
|
|
89
|
+
[ "$(grep -c 'if (size >= 0) {' "$1")" = "1" ] || { printf 'flip-p25: 无条件 clamp 变异没打上\n' >&2; exit 2; }
|
|
90
|
+
}
|
|
91
|
+
cp "$GREEN_EXT" "$TMP/mutA/extension/team-inbox-watch.ts"; mutate_advance "$TMP/mutA/extension/team-inbox-watch.ts"
|
|
92
|
+
cp "$GREEN_EXT" "$TMP/mutB/extension/team-inbox-watch.ts"; mutate_advance "$TMP/mutB/extension/team-inbox-watch.ts"; mutate_clamp_guard "$TMP/mutB/extension/team-inbox-watch.ts"
|
|
93
|
+
cp "$GREEN_EXT" "$TMP/mutC/extension/team-inbox-watch.ts"; mutate_always_clamp "$TMP/mutC/extension/team-inbox-watch.ts"
|
|
94
|
+
# 变异只针对扩展:脚本侧(S10 的真 CLI)用本树的 scripts
|
|
95
|
+
for m in mutA mutB mutC; do cp -a "$SKILL_DIR/scripts" "$TMP/$m/scripts"; done
|
|
96
|
+
|
|
97
|
+
run_harness() { # <extension 路径> → stdout=日志;全局 LAST_RC
|
|
98
|
+
"$TS_RUNNER" "$HARNESS" "$1" 2>&1
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
RC=0
|
|
102
|
+
has() { case "$2" in *"$1"*) return 0 ;; *) return 1 ;; esac; }
|
|
103
|
+
|
|
104
|
+
# ---- ① 红树:必须复现(S18 红:baseline = size + 1)----------------------------------------
|
|
105
|
+
RED_LOG="$(run_harness "$RED_EXT")"; RED_RC=$?
|
|
106
|
+
if [ "$RED_RC" -ne 0 ] \
|
|
107
|
+
&& has 'TEAM-IW-CASE FAIL S18 the baseline is the spool byte size' "$RED_LOG" \
|
|
108
|
+
&& has 'TEAM-IW-CASE FAIL S18 idle ticks after a byte-clipped line add no spool shrink' "$RED_LOG"; then
|
|
109
|
+
pass "红树($BASE)复现成功:S18 全红(baseline 被 U+FFFD 撑成 size+1,空闲每拍假缩容)"
|
|
110
|
+
else
|
|
111
|
+
fail "红树没有复现(rc=$RED_RC;预期 S18 的 baseline 与空闲两断言 FAIL)"
|
|
112
|
+
printf '%s\n' "$RED_LOG" | grep 'TEAM-IW-CASE FAIL S18' | sed 's/^/ /'
|
|
113
|
+
RC=1
|
|
114
|
+
fi
|
|
115
|
+
printf '%s\n' "$RED_LOG" | grep -E 'FAIL S18 (the baseline|idle ticks)' | sed 's/^/ red: /'
|
|
116
|
+
|
|
117
|
+
# ---- ② 绿树:必须全绿 ---------------------------------------------------------------------
|
|
118
|
+
GREEN_LOG="$(run_harness "$GREEN_EXT")"; GREEN_RC=$?
|
|
119
|
+
GREEN_N="$(printf '%s\n' "$GREEN_LOG" | grep -c 'TEAM-IW-CASE PASS')"
|
|
120
|
+
if [ "$GREEN_RC" -eq 0 ] && has 'TEAM-IW-HARNESS OK' "$GREEN_LOG"; then
|
|
121
|
+
pass "绿树(本 worktree):harness 全绿($GREEN_N 条用例,含 S18/S19/S20/S21)"
|
|
122
|
+
else
|
|
123
|
+
fail "绿树不是全绿(rc=$GREEN_RC)——修复把别的用例弄红了?"
|
|
124
|
+
printf '%s\n' "$GREEN_LOG" | grep 'TEAM-IW-CASE FAIL' | sed 's/^/ /'
|
|
125
|
+
RC=1
|
|
126
|
+
fi
|
|
127
|
+
|
|
128
|
+
# ---- ③ 变异 A:旧 advance → S18 必须红(假缩容回来了)--------------------------------------
|
|
129
|
+
MUTA_LOG="$(run_harness "$TMP/mutA/extension/team-inbox-watch.ts")"; MUTA_RC=$?
|
|
130
|
+
if [ "$MUTA_RC" -ne 0 ] && has 'TEAM-IW-CASE FAIL S18 the baseline is the spool byte size' "$MUTA_LOG"; then
|
|
131
|
+
pass "变异 A(旧 advance):S18 红 —— 翻转成立(S18 真的咬在字节推进上)"
|
|
132
|
+
printf '%s\n' "$MUTA_LOG" | grep 'FAIL S18 the baseline' | sed 's/^/ mutA: /'
|
|
133
|
+
else
|
|
134
|
+
fail "变异 A 没有红(rc=$MUTA_RC;预期 S18 的 baseline 断言 FAIL)"
|
|
135
|
+
printf '%s\n' "$MUTA_LOG" | grep 'TEAM-IW-CASE' | tail -8 | sed 's/^/ /'
|
|
136
|
+
RC=1
|
|
137
|
+
fi
|
|
138
|
+
|
|
139
|
+
# ---- ④ 变异 B:A + 去掉 clamp/repeat 守卫 → S18 必须红,且是**重复**的 spool shrink(循环)----
|
|
140
|
+
MUTB_LOG="$(run_harness "$TMP/mutB/extension/team-inbox-watch.ts")"; MUTB_RC=$?
|
|
141
|
+
MUTB_IDLE="$(printf '%s\n' "$MUTB_LOG" | grep -F 'TEAM-IW-CASE FAIL S18 idle ticks after a byte-clipped line add no spool shrink' | head -1)"
|
|
142
|
+
MUTB_DELTA="$(printf '%s' "$MUTB_IDLE" | grep -oE 'shrink lines [0-9]+ -> [0-9]+' | head -1)"
|
|
143
|
+
MUTB_GROWTH="$(printf '%s' "$MUTB_DELTA" | awk '{print $5 - $3}')"
|
|
144
|
+
if [ "$MUTB_RC" -ne 0 ] && [ -n "$MUTB_IDLE" ] \
|
|
145
|
+
&& [ -n "$MUTB_GROWTH" ] && [ "${MUTB_GROWTH:-0}" -ge 2 ]; then
|
|
146
|
+
pass "变异 B(旧 advance + 无守卫):S18 红,空闲期反复写 spool shrink($MUTB_DELTA)—— 2026-09-20 的循环复现"
|
|
147
|
+
else
|
|
148
|
+
fail "变异 B 没有复现循环(rc=$MUTB_RC;$MUTB_DELTA)——S18/守卫可能没真的钉在收敛上"
|
|
149
|
+
printf '%s\n' "$MUTB_LOG" | grep 'TEAM-IW-CASE FAIL S18' | sed 's/^/ /'
|
|
150
|
+
RC=1
|
|
151
|
+
fi
|
|
152
|
+
|
|
153
|
+
# ---- ⑤ 变异 C:无条件 clamp → S19b 必须红(真重写永远不再被读)-----------------------------
|
|
154
|
+
MUTC_LOG="$(run_harness "$TMP/mutC/extension/team-inbox-watch.ts")"; MUTC_RC=$?
|
|
155
|
+
if [ "$MUTC_RC" -ne 0 ] && has 'TEAM-IW-CASE FAIL S19b a rewrite with a changed head is rescanned exactly once' "$MUTC_LOG"; then
|
|
156
|
+
pass "变异 C(无条件 clamp):S19b 红 —— 证据门槛真的在区分「修复」与「重写」"
|
|
157
|
+
printf '%s\n' "$MUTC_LOG" | grep -E 'FAIL S19b' | sed 's/^/ mutC: /'
|
|
158
|
+
else
|
|
159
|
+
fail "变异 C 没有红(rc=$MUTC_RC;预期 S19b 的 rescan 断言 FAIL)"
|
|
160
|
+
printf '%s\n' "$MUTC_LOG" | grep 'TEAM-IW-CASE FAIL S19' | sed 's/^/ /'
|
|
161
|
+
RC=1
|
|
162
|
+
fi
|
|
163
|
+
|
|
164
|
+
printf 'exit=%s\n' "$RC"
|
|
165
|
+
exit "$RC"
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# P81 · 翻转包:wake-delivery-idempotence(写前日志 / 至多一次 / fail-closed / 源行点名)的
|
|
3
|
+
# red → green 证据。
|
|
4
|
+
#
|
|
5
|
+
# bash skills/teamsmith/tests/flip-p71.sh
|
|
6
|
+
# TEAM_FLIP_BASE=<sha> bash skills/teamsmith/tests/flip-p71.sh # 覆盖「修复前」的 revision
|
|
7
|
+
#
|
|
8
|
+
# 事故(2026-09-22):一条 nudge 让 PM 在一个多小时里被「同一条」叫醒三次;durable 文件回答不了
|
|
9
|
+
# 「到底投过没有」。根因是 `wake()` 把去重记忆与账本写在 `pi.sendMessage` **之前**、并把发送失败
|
|
10
|
+
# 吞掉,读者位置只在进程内存里 ——「投过但没记下」「记了但没发出」都是文件可到达的状态。
|
|
11
|
+
#
|
|
12
|
+
# 本包用**同一个 harness**(tests/team-inbox-watch-harness.mjs;S25a/b/d/e 是 P81 加的用例)对五种树
|
|
13
|
+
# 各跑一遍(夹具不变,只换被测扩展;用例用轮询,不依赖 watcher 前提):
|
|
14
|
+
# ① 红树(TEAM_FLIP_BASE / merge-base HEAD main 的 P81 之前扩展)→ S25a/b/d/e 必须 FAIL(复现)
|
|
15
|
+
# ② 绿树(本 worktree)→ 目标用例全 PASS
|
|
16
|
+
# ③ 变异 A(绿树 + 丢掉发送后的终态记录)→ S25a 必须 FAIL(重启后第二次恢复唤醒)
|
|
17
|
+
# ④ 变异 B(绿树 + 把 intent 读成「还没开始」)→ S25b 必须 FAIL(结果未知的行被重投)
|
|
18
|
+
# ⑤ 变异 C(绿树 + 唤醒文本里拿掉身份与源时间)→ S25d 必须 FAIL(两条相同文本不可区分)
|
|
19
|
+
# ⑥ 变异 D(绿树 + 去掉淘汰下限规则)→ S25e 必须 FAIL(被淘汰的身份被重新唤醒)
|
|
20
|
+
#
|
|
21
|
+
# 退出码:0 = 六个预期全部成立;1 = 有任何一个不成立;2 = 环境/前置不满足(不算绿也不算红)。
|
|
22
|
+
# 隔离:harness 自身就是隔离夹具(清 TEAM_*/TMUX 身份、临时仓库、真实仓库 state/ 前后快照反守卫),
|
|
23
|
+
# 本脚本只写 /tmp 临时目录,不调用 tmux。
|
|
24
|
+
set -uo pipefail
|
|
25
|
+
|
|
26
|
+
SELF_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
27
|
+
SKILL_DIR="$(cd -P "$SELF_DIR/.." && pwd)"
|
|
28
|
+
# P53:临时根的唯一创建者(${TMPDIR:-/tmp} + owned 家族 + 回收)
|
|
29
|
+
. "$SELF_DIR/lib/tmp-root.sh"
|
|
30
|
+
REPO_ROOT="$(git -C "$SKILL_DIR" rev-parse --show-toplevel 2>/dev/null || true)"
|
|
31
|
+
[ -n "$REPO_ROOT" ] || { printf 'flip-p71: 找不到 git 仓库(需要 git archive 取修复前的树)\n' >&2; exit 2; }
|
|
32
|
+
|
|
33
|
+
# 能直接跑 .ts 的运行时(与 smoke.sh / flip-m43.sh 同口径)
|
|
34
|
+
TS_RUNNER=""
|
|
35
|
+
if command -v node >/dev/null 2>&1 && node -e 'process.exit(process.features.typescript?0:1)' >/dev/null 2>&1; then
|
|
36
|
+
TS_RUNNER="node"
|
|
37
|
+
elif command -v bun >/dev/null 2>&1 && bun -e '1' >/dev/null 2>&1; then
|
|
38
|
+
TS_RUNNER="bun"
|
|
39
|
+
elif [ -x "$HOME/.bun/bin/bun" ] && "$HOME/.bun/bin/bun" -e '1' >/dev/null 2>&1; then
|
|
40
|
+
TS_RUNNER="$HOME/.bun/bin/bun"
|
|
41
|
+
fi
|
|
42
|
+
[ -n "$TS_RUNNER" ] || { printf 'flip-p71: 需要 node(类型剥离)或 bun 来跑 TS 扩展\n' >&2; exit 2; }
|
|
43
|
+
|
|
44
|
+
BASE="${TEAM_FLIP_BASE:-}"
|
|
45
|
+
if [ -z "$BASE" ]; then
|
|
46
|
+
BASE="$(git -C "$REPO_ROOT" merge-base HEAD main 2>/dev/null || true)"
|
|
47
|
+
fi
|
|
48
|
+
[ -n "$BASE" ] || BASE="$(git -C "$REPO_ROOT" rev-parse --verify -q HEAD^ 2>/dev/null || true)"
|
|
49
|
+
[ -n "$BASE" ] || { printf 'flip-p71: 解析不到修复前的 revision,用 TEAM_FLIP_BASE=<sha> 指定\n' >&2; exit 2; }
|
|
50
|
+
|
|
51
|
+
[ "${KEEP:-0}" = "1" ] && export TEAM_TMP_KEEP=1
|
|
52
|
+
TMP="$(tmp_root_create flip-p71)" || exit 3
|
|
53
|
+
cleanup() {
|
|
54
|
+
[ "${BASHPID:-$$}" = "$$" ] || return 0 # 管道/命令替换的子 shell 不要重复清场
|
|
55
|
+
tmp_root_reap_all
|
|
56
|
+
}
|
|
57
|
+
trap cleanup EXIT
|
|
58
|
+
|
|
59
|
+
# 子串判定:用 case(不起管道)——`printf ... | grep -q` 在 `set -o pipefail` 下会被 grep 的提前退出
|
|
60
|
+
# 变成 SIGPIPE(141)而假红。
|
|
61
|
+
has() { case "$2" in *"$1"*) return 0 ;; *) return 1 ;; esac; }
|
|
62
|
+
|
|
63
|
+
fail() { printf '\033[31m✗\033[0m %s\n' "$*"; }
|
|
64
|
+
pass() { printf '\033[32m✓\033[0m %s\n' "$*"; }
|
|
65
|
+
|
|
66
|
+
GREEN_EXT="$SKILL_DIR/extension/team-inbox-watch.ts"
|
|
67
|
+
HARNESS="$SKILL_DIR/tests/team-inbox-watch-harness.mjs"
|
|
68
|
+
ONLY="S25a,S25b,S25d,S25e"
|
|
69
|
+
|
|
70
|
+
# ---- 目标用例(每个变异点名的那一条 red)---------------------------------------------------
|
|
71
|
+
# 红树(P81 之前)里能可靠复现的四条:没有写前日志、没有恢复、没有身份、没有下限
|
|
72
|
+
RED_TREE_A='TEAM-IW-CASE FAIL S25a a later rewrite of the same bytes produces no second wake'
|
|
73
|
+
RED_TREE_B='TEAM-IW-CASE FAIL S25b the child left a complete read+intent and no sent/failed'
|
|
74
|
+
RED_TREE_D='TEAM-IW-CASE FAIL S25d the two rows differ by source time and identity'
|
|
75
|
+
RED_TREE_E='TEAM-IW-CASE FAIL S25e an identity below the eviction floor is unprovable, never woken'
|
|
76
|
+
# 变异树里每条定点破坏必须打中的那一条
|
|
77
|
+
S25A_RED='TEAM-IW-CASE FAIL S25a a later rewrite of the same bytes produces no second wake'
|
|
78
|
+
S25B_RED='TEAM-IW-CASE FAIL S25b the restart sends no wake at all'
|
|
79
|
+
S25D_RED='TEAM-IW-CASE FAIL S25d the two rows differ by source time and identity'
|
|
80
|
+
S25E_RED='TEAM-IW-CASE FAIL S25e an identity below the eviction floor is unprovable, never woken'
|
|
81
|
+
|
|
82
|
+
# ---- 红树(修复前)--------------------------------------------------------------------------
|
|
83
|
+
mkdir -p "$TMP/red-skill"
|
|
84
|
+
git -C "$REPO_ROOT" archive "$BASE" skills/teamsmith | tar -x -C "$TMP/red-skill" || exit 2
|
|
85
|
+
RED_EXT="$TMP/red-skill/skills/teamsmith/extension/team-inbox-watch.ts"
|
|
86
|
+
|
|
87
|
+
# 前置守卫:红树必须真的还没有投递日志,绿树必须真的带着(否则这个包报的是假翻转)
|
|
88
|
+
grep -q '\.deliver' "$RED_EXT" 2>/dev/null && {
|
|
89
|
+
printf 'flip-p71: $BASE 已经包含 P81 的投递日志(不是修复前的树)——用 TEAM_FLIP_BASE=<修复前的 sha> 指定\n' >&2; exit 2; }
|
|
90
|
+
grep -q 'deliver blocked' "$GREEN_EXT" || { printf 'flip-p71: 本树扩展里没有 deliver blocked(P81 的修复不在?)\n' >&2; exit 2; }
|
|
91
|
+
|
|
92
|
+
# ---- 变异树(绿树 + 一处定点破坏)------------------------------------------------------------
|
|
93
|
+
for m in mut-a mut-b mut-c mut-d; do mkdir -p "$TMP/$m/extension"; done
|
|
94
|
+
|
|
95
|
+
cat > "$TMP/mutate.mjs" <<'MUTEOF'
|
|
96
|
+
import { readFileSync, writeFileSync } from 'node:fs'
|
|
97
|
+
const [file, oldText, newText] = process.argv.slice(2)
|
|
98
|
+
const s = readFileSync(file, 'utf8')
|
|
99
|
+
if (!s.includes(oldText)) { console.error('anchor missing:', oldText); process.exit(3) }
|
|
100
|
+
writeFileSync(file, s.split(oldText).join(newText))
|
|
101
|
+
MUTEOF
|
|
102
|
+
mutate() { # <file> <old> <new>
|
|
103
|
+
"$TS_RUNNER" "$TMP/mutate.mjs" "$1" "$2" "$3" || { printf 'flip-p71: 变异打不上(锚点不在?)\n' >&2; exit 2; }
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
# 变异 A:**恢复唤醒跳过写前记录**(read/intent 都不写)—— 重启后同一行会被再恢复一次,
|
|
107
|
+
# 也就是「一条门铃响两次」。它是「写前顺序」的定点破坏(恢复是唯一允许补发的路径)。
|
|
108
|
+
cp "$GREEN_EXT" "$TMP/mut-a/extension/team-inbox-watch.ts"
|
|
109
|
+
mutate "$TMP/mut-a/extension/team-inbox-watch.ts" \
|
|
110
|
+
'for (const l of lines) if (!journalAppend(readRecord(l))) return blocked()' \
|
|
111
|
+
'for (const l of lines) if (!(meta.recovery === true) && !journalAppend(readRecord(l))) return blocked()'
|
|
112
|
+
mutate "$TMP/mut-a/extension/team-inbox-watch.ts" \
|
|
113
|
+
'if (!journalAppend(`intent seq=${seq}`)) return blocked()' \
|
|
114
|
+
'if (!(meta.recovery === true) && !journalAppend(`intent seq=${seq}`)) return blocked()'
|
|
115
|
+
|
|
116
|
+
# 变异 B:把 intent(结果未知)读成「还没开始」—— 会重投一条可能已经进过会话的行
|
|
117
|
+
cp "$GREEN_EXT" "$TMP/mut-b/extension/team-inbox-watch.ts"
|
|
118
|
+
mutate "$TMP/mut-b/extension/team-inbox-watch.ts" \
|
|
119
|
+
"if (entry.state === 'read') entry.state = 'intent'" "if (entry.state === 'read') entry.state = 'read'"
|
|
120
|
+
|
|
121
|
+
# 变异 C:唤醒文本里拿掉源时间与身份 —— 两条逐字相同的 payload 再也分不开
|
|
122
|
+
cp "$GREEN_EXT" "$TMP/mut-c/extension/team-inbox-watch.ts"
|
|
123
|
+
mutate "$TMP/mut-c/extension/team-inbox-watch.ts" \
|
|
124
|
+
'${preview} (src ${src} · id ${l.identity})' '${preview}'
|
|
125
|
+
|
|
126
|
+
# 变异 D:去掉淘汰下限规则 —— 被压缩淘汰的身份会被重新唤醒(fail-open)
|
|
127
|
+
cp "$GREEN_EXT" "$TMP/mut-d/extension/team-inbox-watch.ts"
|
|
128
|
+
mutate "$TMP/mut-d/extension/team-inbox-watch.ts" \
|
|
129
|
+
'if (l.src > 0 && floorTs !== null && l.src < floorTs) { out.unprovable++; continue }' \
|
|
130
|
+
'if (false) { out.unprovable++; continue } // MUT-D'
|
|
131
|
+
|
|
132
|
+
run_harness() { # <extension> → stdout
|
|
133
|
+
TEAM_IW_ONLY="$ONLY" "$TS_RUNNER" "$HARNESS" "$1" 2>&1
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
RC=0
|
|
137
|
+
|
|
138
|
+
# ---- ① 红树:S25a/b/d/e 必须逐条 FAIL(复现)-------------------------------------------------
|
|
139
|
+
RED_LOG="$(run_harness "$RED_EXT")"; RED_RC=$?
|
|
140
|
+
if [ "$RED_RC" -ne 0 ] && has "$RED_TREE_A" "$RED_LOG" && has "$RED_TREE_B" "$RED_LOG" \
|
|
141
|
+
&& has "$RED_TREE_D" "$RED_LOG" && has "$RED_TREE_E" "$RED_LOG"; then
|
|
142
|
+
pass "红树($BASE)复现成功:S25a/b/d/e 全红(没有投递日志/至多一次/源行点名)"
|
|
143
|
+
else
|
|
144
|
+
fail "红树没有复现(rc=$RED_RC;预期 S25a/b/d/e 的定点断言 FAIL)"
|
|
145
|
+
printf '%s\n' "$RED_LOG" | grep 'TEAM-IW-CASE FAIL S25' | sed 's/^/ /'
|
|
146
|
+
RC=1
|
|
147
|
+
fi
|
|
148
|
+
printf '%s\n' "$RED_LOG" | grep 'TEAM-IW-CASE FAIL S25' | sed 's/^/ red: /'
|
|
149
|
+
|
|
150
|
+
# ---- ② 绿树:目标用例全 PASS ---------------------------------------------------------------
|
|
151
|
+
GREEN_LOG="$(run_harness "$GREEN_EXT")"; GREEN_RC=$?
|
|
152
|
+
if [ "$GREEN_RC" -eq 0 ] && has 'TEAM-IW-HARNESS OK' "$GREEN_LOG" \
|
|
153
|
+
&& has 'TEAM-IW-CASE PASS S25a exactly one recovery wake is sent' "$GREEN_LOG" \
|
|
154
|
+
&& has 'TEAM-IW-CASE PASS S25b the ledger records exactly one inflight assumed n=1' "$GREEN_LOG" \
|
|
155
|
+
&& has 'TEAM-IW-CASE PASS S25d the wake names each line' "$GREEN_LOG" \
|
|
156
|
+
&& has 'TEAM-IW-CASE PASS S25e compaction keeps the journal under the bound' "$GREEN_LOG"; then
|
|
157
|
+
pass "绿树(本 worktree)目标用例全绿(S25a/b/d/e)"
|
|
158
|
+
else
|
|
159
|
+
fail "绿树目标用例没有全绿(rc=$GREEN_RC)"
|
|
160
|
+
printf '%s\n' "$GREEN_LOG" | grep -E 'TEAM-IW-CASE FAIL|TEAM-IW-HARNESS' | sed 's/^/ /'
|
|
161
|
+
RC=1
|
|
162
|
+
fi
|
|
163
|
+
|
|
164
|
+
# ---- ③–⑥ 四个变异:各自点名的 red 必须出现 --------------------------------------------------
|
|
165
|
+
check_mutation() { # <名字> <扩展> <预期 red 子串> <说明>
|
|
166
|
+
local name="$1" ext="$2" want="$3" what="$4" log rc
|
|
167
|
+
log="$(run_harness "$ext")"; rc=$?
|
|
168
|
+
if [ "$rc" -ne 0 ] && has "$want" "$log"; then
|
|
169
|
+
pass "变异 $name:$what —— 命名断言红,rc=$rc"
|
|
170
|
+
else
|
|
171
|
+
fail "变异 $name 没有红(rc=$rc;预期「$want」)"
|
|
172
|
+
printf '%s\n' "$log" | grep 'TEAM-IW-CASE FAIL S25' | sed 's/^/ /'
|
|
173
|
+
RC=1
|
|
174
|
+
fi
|
|
175
|
+
printf '%s\n' "$log" | grep 'TEAM-IW-CASE FAIL S25' | sed "s/^/ $name: /"
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
check_mutation A "$TMP/mut-a/extension/team-inbox-watch.ts" "$S25A_RED" "恢复唤醒跳过写前记录(read/intent)→ 重启后重复恢复唤醒"
|
|
179
|
+
check_mutation B "$TMP/mut-b/extension/team-inbox-watch.ts" "$S25B_RED" "把 intent 读成「还没开始」→ 结果未知的行被重投"
|
|
180
|
+
check_mutation C "$TMP/mut-c/extension/team-inbox-watch.ts" "$S25D_RED" "唤醒文本拿掉身份 → 两条相同文本不可区分"
|
|
181
|
+
check_mutation D "$TMP/mut-d/extension/team-inbox-watch.ts" "$S25E_RED" "去掉淘汰下限规则 → 被淘汰的身份 fail-open 重唤醒"
|
|
182
|
+
|
|
183
|
+
[ "$RC" -eq 0 ] && printf 'flip-p71: 全部预期成立(red / green / 四个变异)\n'
|
|
184
|
+
exit "$RC"
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# flip-p72.sh — P82(change: notify-sender-identity)的翻转包。
|
|
3
|
+
#
|
|
4
|
+
# bash skills/teamsmith/tests/flip-p72.sh
|
|
5
|
+
# bash skills/teamsmith/tests/flip-p72.sh --keep # 保留临时目录(排查)
|
|
6
|
+
#
|
|
7
|
+
# 每个变异打在 /tmp 下的**技能树副本**上(真实工作树一个字节都不动),然后跑**聚焦探针**:
|
|
8
|
+
# smoke 前导(身份清洗 / 夹具 / 判据)+ 47 段(P82 的夹具)+ 结果行。三对「断掉 → 变红 → 还原 → 变绿」:
|
|
9
|
+
# a 发送者退回**收件人**(旧实现:收件箱行 / knock 文本 / 条目 from: 三处都用 recipient)
|
|
10
|
+
# → 1.2 / 1.5 / 1.6 的「发送者 = dev2」类断言变红
|
|
11
|
+
# b 未解析的运行时目录**静默退回 pm**(缺陷本身) → 1.4 的拒绝/零写入断言变红
|
|
12
|
+
# c 让**继承的 TEAM_AGENT 压过**运行时目录 → 1.3 的两条断言变红
|
|
13
|
+
# d 扩展回到 `window || …`(窗口名重新决定发送者)→ 3.2 的「窗口撒谎」对断言变红(3.1 保持绿,
|
|
14
|
+
# 证明这一对点的就是窗口那一条)
|
|
15
|
+
#
|
|
16
|
+
# 退出码:0 = 三对全部成立;1 = 有反例;3 = 前置不满足。
|
|
17
|
+
set -uo pipefail
|
|
18
|
+
|
|
19
|
+
SELF_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
20
|
+
SKILL_DIR="$(cd -P "$SELF_DIR/.." && pwd)"
|
|
21
|
+
# P53:临时根的唯一创建者(${TMPDIR:-/tmp} + owned 家族 + 回收)
|
|
22
|
+
. "$SELF_DIR/lib/tmp-root.sh"
|
|
23
|
+
SMOKE="$SKILL_DIR/tests/smoke.sh"
|
|
24
|
+
REPO_ROOT="$(git -C "$SKILL_DIR" rev-parse --show-toplevel 2>/dev/null || true)"
|
|
25
|
+
|
|
26
|
+
KEEP=0
|
|
27
|
+
case "${1:-}" in
|
|
28
|
+
"") ;;
|
|
29
|
+
--keep) KEEP=1 ;;
|
|
30
|
+
-h|--help) sed -n '2,24p' "$0"; exit 0 ;;
|
|
31
|
+
*) printf 'flip-p72: 未知参数 %s\n' "$1" >&2; exit 2 ;;
|
|
32
|
+
esac
|
|
33
|
+
|
|
34
|
+
[ -s "$SMOKE" ] || { printf 'flip-p72: 缺 %s\n' "$SMOKE" >&2; exit 3; }
|
|
35
|
+
grep -q '^section "47 ' "$SMOKE" || { printf 'flip-p72: smoke.sh 里没有 47 段(P82 夹具)\n' >&2; exit 3; }
|
|
36
|
+
|
|
37
|
+
# 3.x 与变异 d 要跑扩展(与 smoke.sh 同口径的 TS 运行时探测)
|
|
38
|
+
TS_RUNNER=""
|
|
39
|
+
if command -v node >/dev/null 2>&1 && node -e 'process.exit(process.features.typescript?0:1)' >/dev/null 2>&1; then
|
|
40
|
+
TS_RUNNER="node"
|
|
41
|
+
elif command -v bun >/dev/null 2>&1 && bun -e '1' >/dev/null 2>&1; then
|
|
42
|
+
TS_RUNNER="bun"
|
|
43
|
+
elif [ -x "$HOME/.bun/bin/bun" ] && "$HOME/.bun/bin/bun" -e '1' >/dev/null 2>&1; then
|
|
44
|
+
TS_RUNNER="$HOME/.bun/bin/bun"
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
[ "${KEEP:-0}" = "1" ] && export TEAM_TMP_KEEP=1
|
|
48
|
+
TMP="$(tmp_root_create flip-p72)" || exit 3
|
|
49
|
+
cleanup() { [ "${BASHPID:-$$}" = "$$" ] || return 0; [ "$KEEP" = "1" ] || tmp_root_reap_all; return 0; }
|
|
50
|
+
trap cleanup EXIT
|
|
51
|
+
|
|
52
|
+
TREE="$TMP/tree"; mkdir -p "$TREE/skills"
|
|
53
|
+
cp -a "$SKILL_DIR" "$TREE/skills/teamsmith"
|
|
54
|
+
MUT_SKILL="$TREE/skills/teamsmith"
|
|
55
|
+
|
|
56
|
+
PASS=0
|
|
57
|
+
FAIL=0
|
|
58
|
+
ok() { printf ' \033[32m✓\033[0m %s\n' "$1"; PASS=$((PASS + 1)); }
|
|
59
|
+
bad() { printf ' \033[31m✗\033[0m %s\n' "$1"; FAIL=$((FAIL + 1)); }
|
|
60
|
+
|
|
61
|
+
restore_skill() { rm -rf "$MUT_SKILL"; cp -a "$SKILL_DIR" "$MUT_SKILL"; }
|
|
62
|
+
show_red() { sed 's/\x1b\[[0-9;]*m//g' "$1" | grep '✗' | head -5 | sed 's/^/ /'; }
|
|
63
|
+
|
|
64
|
+
# ── 聚焦探针:smoke 前导 + 46 段 + 结果行(SKILL_DIR 换成变异树)─────────────────────────────
|
|
65
|
+
PROBE="$TMP/probe-47.sh"
|
|
66
|
+
{
|
|
67
|
+
awk '/^# -+ 0\. 仓库/{exit} {print}' "$SMOKE"
|
|
68
|
+
awk '/^section "47 /{f=1} f{ if ($0 ~ /^section "/ && $0 !~ /^section "47 /) exit; print }' "$SMOKE"
|
|
69
|
+
cat <<'EOS'
|
|
70
|
+
printf '\n== 结果 == ✓ %d ✗ %d\n' "$PASS" "$FAIL"
|
|
71
|
+
printf 'PROBE-47-END\n'
|
|
72
|
+
[ "$FAIL" -eq 0 ] && exit 0
|
|
73
|
+
exit 1
|
|
74
|
+
EOS
|
|
75
|
+
} | sed "s|^SKILL_DIR=.*|SKILL_DIR=\"$MUT_SKILL\"|" > "$PROBE"
|
|
76
|
+
grep -q 'PROBE-47-END' "$PROBE" || { printf 'flip-p72: 探针形状不对(46 段没抽出来?)\n' >&2; exit 3; }
|
|
77
|
+
bash -n "$PROBE" || { printf 'flip-p72: 探针语法错\n' >&2; exit 3; }
|
|
78
|
+
|
|
79
|
+
run_probe() { # <日志>
|
|
80
|
+
TEAM_SMOKE_FAST=1 TEAM_SMOKE_NO_LOCK=1 bash "$PROBE" >"$1" 2>&1
|
|
81
|
+
return $?
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
# ── 变异(只动 $MUT_SKILL 里的文件)─────────────────────────────────────────────────────────
|
|
85
|
+
m_a() { python3 - "$MUT_SKILL" <<'PY'
|
|
86
|
+
import io, sys
|
|
87
|
+
p = sys.argv[1] + '/scripts/lib/cmd-agents.sh'
|
|
88
|
+
s = io.open(p, encoding='utf-8').read()
|
|
89
|
+
# 收件箱行的第 4 参(发送者)去掉 → team_inbox_append 回落到「owner 标签」= 收件人
|
|
90
|
+
old = ' team_inbox_append "$agent" manual "$msg" "$sender" \\\n'
|
|
91
|
+
assert s.count(old) == 1, ('a inbox anchor', s.count(old))
|
|
92
|
+
s = s.replace(old, ' team_inbox_append "$agent" manual "$msg" \\\n', 1)
|
|
93
|
+
old = '"[manual] agent:$sender · $msg" knock --from "$sender"'
|
|
94
|
+
assert s.count(old) == 2, ('a knock anchors', s.count(old))
|
|
95
|
+
s = s.replace(old, '"[manual] agent:$agent · $msg" knock --from "$agent" # MUTATION a')
|
|
96
|
+
io.open(p, 'w', encoding='utf-8').write(s)
|
|
97
|
+
PY
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
m_b() { python3 - "$MUT_SKILL" <<'PY'
|
|
101
|
+
import io, sys
|
|
102
|
+
p = sys.argv[1] + '/scripts/lib/common.sh'
|
|
103
|
+
s = io.open(p, encoding='utf-8').read()
|
|
104
|
+
old = ' if [ -z "$dir" ]; then\n team_err "notify:发送者无法解析'
|
|
105
|
+
assert s.count(old) == 1, ('b anchor', s.count(old))
|
|
106
|
+
s = s.replace(old,
|
|
107
|
+
' # MUTATION b: an unresolved runtime directory falls back to pm (the defect)\n'
|
|
108
|
+
' [ -n "$dir" ] || { printf \'pm\\n\'; return 0; }\n'
|
|
109
|
+
+ old, 1)
|
|
110
|
+
io.open(p, 'w', encoding='utf-8').write(s)
|
|
111
|
+
PY
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
m_c() { python3 - "$MUT_SKILL" <<'PY'
|
|
115
|
+
import io, sys
|
|
116
|
+
p = sys.argv[1] + '/scripts/lib/common.sh'
|
|
117
|
+
s = io.open(p, encoding='utf-8').read()
|
|
118
|
+
old = ' dir="$(team_sender_from_dir)"\n'
|
|
119
|
+
assert s.count(old) == 1, ('c anchor', s.count(old))
|
|
120
|
+
s = s.replace(old,
|
|
121
|
+
old + ' if [ -n "${TEAM_AGENT:-}" ]; then dir="$TEAM_AGENT"; fi # MUTATION c: the inherited value wins\n',
|
|
122
|
+
1)
|
|
123
|
+
io.open(p, 'w', encoding='utf-8').write(s)
|
|
124
|
+
PY
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
m_d() { python3 - "$MUT_SKILL" <<'PYMUTD'
|
|
128
|
+
import io, sys
|
|
129
|
+
p = sys.argv[1] + '/extension/team-notify.ts'
|
|
130
|
+
s = io.open(p, encoding='utf-8').read()
|
|
131
|
+
old = ' const agent = senderFromDir(resolve(cwd), wtPrefix, cfg.roster)\n'
|
|
132
|
+
assert s.count(old) == 1, ('d anchor', s.count(old))
|
|
133
|
+
s = s.replace(old,
|
|
134
|
+
' const agent = window || senderFromDir(resolve(cwd), wtPrefix, cfg.roster) // MUTATION d: the window decides again\n',
|
|
135
|
+
1)
|
|
136
|
+
io.open(p, 'w', encoding='utf-8').write(s)
|
|
137
|
+
PYMUTD
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
flip() { # <名字> <变异函数> <期望红断言正则...>
|
|
141
|
+
local name="$1" mutfn="$2"; shift 2
|
|
142
|
+
restore_skill
|
|
143
|
+
if ! "$mutfn" >"$TMP/$name-mut.log" 2>&1; then
|
|
144
|
+
bad "$name:变异脚本失败(锚点文本动过?见 $TMP/$name-mut.log)"
|
|
145
|
+
return
|
|
146
|
+
fi
|
|
147
|
+
local rc
|
|
148
|
+
# 变异必须是「行为断掉」而不是「脚本改坏」:语法错的树只会把 46 段整体打红,那不是翻转证据
|
|
149
|
+
if ! ( for f in "$MUT_SKILL"/scripts/team "$MUT_SKILL"/scripts/lib/*.sh; do bash -n "$f" || exit 1; done ) >"$TMP/$name-syntax.log" 2>&1; then
|
|
150
|
+
bad "$name:变异把脚本改出了语法错(不是行为变异)—— 见 $TMP/$name-syntax.log"
|
|
151
|
+
show_red "$TMP/$name-syntax.log"
|
|
152
|
+
return
|
|
153
|
+
fi
|
|
154
|
+
if [ -n "$TS_RUNNER" ]; then
|
|
155
|
+
printf 'await import(%s)\n' "'$MUT_SKILL/extension/team-notify.ts'" > "$TMP/$name-ts-check.mjs"
|
|
156
|
+
if ! "$TS_RUNNER" "$TMP/$name-ts-check.mjs" >"$TMP/$name-ts.log" 2>&1; then
|
|
157
|
+
bad "$name:变异把扩展改得加载不了(不是行为变异)—— 见 $TMP/$name-ts.log"
|
|
158
|
+
show_red "$TMP/$name-ts.log"
|
|
159
|
+
return
|
|
160
|
+
fi
|
|
161
|
+
fi
|
|
162
|
+
run_probe "$TMP/$name-red.log"; rc=$?
|
|
163
|
+
if [ "$rc" -ne 0 ] && grep -q '✗' "$TMP/$name-red.log"; then
|
|
164
|
+
ok "$name:断掉之后 46 段变红(rc=$rc)"
|
|
165
|
+
else
|
|
166
|
+
bad "$name:断掉之后 46 段居然还是绿的(翻转失效)"
|
|
167
|
+
show_red "$TMP/$name-red.log"
|
|
168
|
+
fi
|
|
169
|
+
local miss="" pat
|
|
170
|
+
for pat in "$@"; do
|
|
171
|
+
{ grep -E '✗' "$TMP/$name-red.log" || true; } | grep -qE -- "$pat" || miss="$miss [$pat]"
|
|
172
|
+
done
|
|
173
|
+
if [ -z "$miss" ]; then ok "$name:红侧点在预期的断言上"
|
|
174
|
+
else bad "$name:红侧没点到预期断言$miss"; show_red "$TMP/$name-red.log"; fi
|
|
175
|
+
restore_skill
|
|
176
|
+
run_probe "$TMP/$name-green.log"; rc=$?
|
|
177
|
+
if [ "$rc" -eq 0 ]; then ok "$name:还原之后 46 段全绿($(grep -ac '^ .*✓' "$TMP/$name-green.log" 2>/dev/null || echo 0) 条)"
|
|
178
|
+
else bad "$name:还原之后 46 段仍然红"; show_red "$TMP/$name-green.log"; fi
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
printf '\033[1m== flip-p72 · notify-sender-identity(46 段:CLI 侧三处 + 扩展的窗口一处)==\033[0m\n'
|
|
182
|
+
restore_skill
|
|
183
|
+
run_probe "$TMP/baseline.log" || { printf '\033[31mflip-p72: 基线(未变异)就不是绿的,先修 46 段\033[0m\n'; show_red "$TMP/baseline.log"; exit 3; }
|
|
184
|
+
ok "基线:未变异的树上 46 段全绿"
|
|
185
|
+
|
|
186
|
+
flip a m_a 'P82 1\.2 发送者 = 工作树目录名' 'P82 1\.5 knock 文本与 from: / 收件箱行同名' 'P82 1\.6 dev 的收件箱里发送者仍是 worker'
|
|
187
|
+
flip b m_b 'P82 1\.4 项目外的工作树里 notify 应当拒绝' 'P82 1\.4 拒绝时零写入' 'P82 1\.4 拒绝输出点名 --from'
|
|
188
|
+
flip c m_c 'P82 1\.3 发送者仍是运行时目录的 dev2' 'P82 1\.3 stderr 点名被忽略的 TEAM_AGENT 值'
|
|
189
|
+
if [ -n "$TS_RUNNER" ]; then
|
|
190
|
+
flip d m_d 'P82 3\.2 窗口撒谎(报 dev)时 \[auto\] 这一路仍是 dev2' 'P82 3\.2 两条路在对抗性窗口下仍然同名' 'P82 3\.2 窗口名没有变成发送者'
|
|
191
|
+
else
|
|
192
|
+
printf ' \033[33mSKIP\033[0m d:本机没有 node(类型剥离)/ bun,跑不了扩展夹具\n'
|
|
193
|
+
fi
|
|
194
|
+
|
|
195
|
+
printf '\n\033[1m== 结果 ==\033[0m ✓ %d ✗ %d\n' "$PASS" "$FAIL"
|
|
196
|
+
if [ "$FAIL" -eq 0 ]; then
|
|
197
|
+
printf '\033[32mflip-p72 翻转成立\033[0m\n'
|
|
198
|
+
[ "$KEEP" = "1" ] && printf '日志保留:%s\n' "$TMP"
|
|
199
|
+
exit 0
|
|
200
|
+
fi
|
|
201
|
+
printf '\033[31mflip-p72 翻转不成立\033[0m —— 两侧日志在 %s\n' "$TMP"
|
|
202
|
+
exit 1
|