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.
- package/README.md +13 -7
- package/package.json +1 -1
- package/skills/teamsmith/CHANGELOG.md +67 -0
- package/skills/teamsmith/SKILL.md +26 -8
- package/skills/teamsmith/extension/team-notify.ts +37 -6
- package/skills/teamsmith/extension/team.ts +438 -0
- package/skills/teamsmith/references/agent-adapters.md +7 -7
- package/skills/teamsmith/references/config.md +65 -18
- package/skills/teamsmith/references/migration.md +220 -34
- package/skills/teamsmith/references/protocol.md +250 -25
- package/skills/teamsmith/references/troubleshooting.md +124 -7
- package/skills/teamsmith/references/workflows.md +66 -20
- package/skills/teamsmith/scripts/lib/cmd-agents.sh +525 -90
- package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +71 -10
- package/skills/teamsmith/scripts/lib/cmd-config.sh +562 -128
- package/skills/teamsmith/scripts/lib/cmd-death.sh +2 -15
- package/skills/teamsmith/scripts/lib/cmd-docs.sh +6 -3
- package/skills/teamsmith/scripts/lib/cmd-draft.sh +4 -4
- package/skills/teamsmith/scripts/lib/cmd-help.sh +677 -0
- package/skills/teamsmith/scripts/lib/cmd-init.sh +157 -5
- package/skills/teamsmith/scripts/lib/cmd-interrupt.sh +461 -0
- package/skills/teamsmith/scripts/lib/cmd-meeting.sh +2 -25
- package/skills/teamsmith/scripts/lib/cmd-project.sh +149 -105
- package/skills/teamsmith/scripts/lib/cmd-reap.sh +277 -0
- package/skills/teamsmith/scripts/lib/cmd-reply.sh +96 -0
- package/skills/teamsmith/scripts/lib/cmd-review.sh +188 -40
- package/skills/teamsmith/scripts/lib/cmd-status.sh +268 -30
- package/skills/teamsmith/scripts/lib/cmd-update.sh +36 -7
- package/skills/teamsmith/scripts/lib/cmd-watch.sh +634 -54
- package/skills/teamsmith/scripts/lib/common.sh +1560 -109
- package/skills/teamsmith/scripts/lib/gate-lock.sh +544 -0
- package/skills/teamsmith/scripts/monitor.mjs +34 -3
- package/skills/teamsmith/scripts/panel/README.md +22 -11
- package/skills/teamsmith/scripts/panel/draft-send.sh +11 -1
- package/skills/teamsmith/scripts/panel/panel.js +226 -224
- package/skills/teamsmith/scripts/panel/src/App.tsx +478 -184
- package/skills/teamsmith/scripts/panel/src/clipboard.ts +11 -5
- package/skills/teamsmith/scripts/panel/src/compose.ts +6 -3
- package/skills/teamsmith/scripts/panel/src/data.ts +95 -7
- package/skills/teamsmith/scripts/panel/src/layout.ts +703 -152
- package/skills/teamsmith/scripts/panel/src/main.tsx +129 -19
- package/skills/teamsmith/scripts/panel/src/settings.ts +1 -1
- package/skills/teamsmith/scripts/panel/src/strings/en.ts +76 -31
- package/skills/teamsmith/scripts/panel/src/strings/zh.ts +78 -33
- package/skills/teamsmith/scripts/panel/src/types.ts +204 -17
- package/skills/teamsmith/scripts/replies.mjs +896 -0
- package/skills/teamsmith/scripts/shim/tmux +18 -0
- package/skills/teamsmith/scripts/strings/commands.tsv +86 -0
- package/skills/teamsmith/scripts/strings/help.en.tsv +503 -0
- package/skills/teamsmith/scripts/strings/help.zh.tsv +489 -0
- package/skills/teamsmith/scripts/team +20 -6
- package/skills/teamsmith/templates/AGENTS.section.md.tmpl +23 -3
- package/skills/teamsmith/templates/BOARD.md.tmpl +2 -2
- package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +7 -3
- package/skills/teamsmith/templates/PROTOCOL.md.tmpl +17 -0
- package/skills/teamsmith/templates/config.sh.tmpl +29 -5
- package/skills/teamsmith/templates/memory-seed.md.tmpl +3 -0
- package/skills/teamsmith/templates/pm-prompt.md.tmpl +41 -1
- package/skills/teamsmith/templates/report.md.tmpl +12 -0
- package/skills/teamsmith/templates/task.md.tmpl +4 -0
- package/skills/teamsmith/tests/bg-ledger-harness.mjs +464 -40
- package/skills/teamsmith/tests/bg-ledger.sh +168 -10
- package/skills/teamsmith/tests/checkout-shape-probe.sh +3 -1
- package/skills/teamsmith/tests/config-cli.sh +320 -300
- package/skills/teamsmith/tests/death-cause.sh +5 -2
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +7 -1
- package/skills/teamsmith/tests/fixtures/p287/lint-good.sh.in +3 -0
- package/skills/teamsmith/tests/fixtures/p287/lint-hardcoded.sh.in +3 -0
- package/skills/teamsmith/tests/fixtures/p287/lint-no-ns.sh.in +3 -0
- package/skills/teamsmith/tests/fixtures/p55/flip-p49.sh +18 -6
- package/skills/teamsmith/tests/flip-m33.sh +5 -3
- package/skills/teamsmith/tests/flip-m37.sh +4 -1
- package/skills/teamsmith/tests/flip-m4.3.sh +4 -1
- package/skills/teamsmith/tests/flip-m6.3.sh +4 -1
- package/skills/teamsmith/tests/flip-m6.5.sh +4 -1
- package/skills/teamsmith/tests/flip-m7.2.sh +4 -1
- package/skills/teamsmith/tests/flip-p158.sh +2 -1
- package/skills/teamsmith/tests/flip-p210.sh +4 -1
- package/skills/teamsmith/tests/flip-p217.sh +4 -1
- package/skills/teamsmith/tests/flip-p287-lock.sh +342 -0
- package/skills/teamsmith/tests/flip-p287-name.sh +279 -0
- package/skills/teamsmith/tests/flip-p304-read-side.sh +98 -0
- package/skills/teamsmith/tests/flip-p308-skip-not-pass.sh +151 -0
- package/skills/teamsmith/tests/flip-p309-p162-deep.sh +122 -0
- package/skills/teamsmith/tests/flip-p310-lock.sh +216 -0
- package/skills/teamsmith/tests/flip-p310-socket.sh +125 -0
- package/skills/teamsmith/tests/help-surface.sh +1664 -0
- package/skills/teamsmith/tests/install-shape.sh +283 -22
- package/skills/teamsmith/tests/key-replies-pty.sh +374 -0
- package/skills/teamsmith/tests/key-replies-ui.sh +325 -0
- package/skills/teamsmith/tests/key-replies.sh +1314 -0
- package/skills/teamsmith/tests/ledger-ban.sh +9 -8
- package/skills/teamsmith/tests/ledger-claim.sh +248 -0
- package/skills/teamsmith/tests/lib/bounded-spin.sh +90 -0
- package/skills/teamsmith/tests/lib/model-policy.sh +30 -0
- package/skills/teamsmith/tests/lib/model-routing-boundary.sh +420 -0
- package/skills/teamsmith/tests/lib/model-routing-expansion.sh +155 -0
- package/skills/teamsmith/tests/lib/model-routing-flips.py +187 -0
- package/skills/teamsmith/tests/lib/model-routing-roles.sh +250 -0
- package/skills/teamsmith/tests/lib/proc-io.sh +103 -0
- package/skills/teamsmith/tests/lib/reply-fixture.sh +367 -0
- package/skills/teamsmith/tests/lib/section-guard.sh +258 -13
- package/skills/teamsmith/tests/lib/tmp-root.sh +139 -27
- package/skills/teamsmith/tests/lib/tmux-cap.sh +10 -1
- package/skills/teamsmith/tests/lib/tmux-iso.sh +39 -13
- package/skills/teamsmith/tests/loop-inventory.tsv +59 -47
- package/skills/teamsmith/tests/panel-b2.sh +107 -4
- package/skills/teamsmith/tests/panel-b3-stub.sh +139 -4
- package/skills/teamsmith/tests/panel-b3.sh +189 -29
- package/skills/teamsmith/tests/panel-choices.sh +81 -63
- package/skills/teamsmith/tests/panel-cpu.sh +3 -2
- package/skills/teamsmith/tests/panel-knobs.sh +7 -1
- package/skills/teamsmith/tests/panel-p21.sh +445 -241
- package/skills/teamsmith/tests/panel-snapshots.sh +41 -225
- package/skills/teamsmith/tests/panel-strings.mjs +33 -18
- package/skills/teamsmith/tests/perf.sh +122 -31
- package/skills/teamsmith/tests/pm-box-real.sh +1 -1
- package/skills/teamsmith/tests/pulse-nudge-key.sh +1 -1
- package/skills/teamsmith/tests/routes.sh +364 -109
- package/skills/teamsmith/tests/seat-interrupt.sh +1002 -0
- package/skills/teamsmith/tests/seat-visibility.sh +675 -0
- package/skills/teamsmith/tests/section-budgets.tsv +26 -12
- package/skills/teamsmith/tests/section-guard.sh +6 -1
- package/skills/teamsmith/tests/section-needs-audit.sh +24 -7
- package/skills/teamsmith/tests/section-paths.tsv +42 -26
- package/skills/teamsmith/tests/section-select.sh +90 -7
- package/skills/teamsmith/tests/slash-team-e2e.sh +323 -0
- package/skills/teamsmith/tests/slash-team.sh +617 -0
- package/skills/teamsmith/tests/smoke.sh +3762 -628
- package/skills/teamsmith/tests/snapshots/zh-dark-120-detail.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-dark-120-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-dark-120.txt +9 -9
- package/skills/teamsmith/tests/snapshots/zh-dark-160-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-dark-160.txt +9 -9
- package/skills/teamsmith/tests/snapshots/zh-dark-59-detail.txt +1 -1
- package/skills/teamsmith/tests/snapshots/zh-dark-59-p4.txt +1 -1
- package/skills/teamsmith/tests/snapshots/zh-dark-59.txt +5 -5
- package/skills/teamsmith/tests/snapshots/zh-dark-99-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-dark-99.txt +5 -5
- package/skills/teamsmith/tests/snapshots/zh-light-120-detail.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-light-120-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-light-120.txt +9 -9
- package/skills/teamsmith/tests/snapshots/zh-light-160-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-light-160.txt +9 -9
- package/skills/teamsmith/tests/snapshots/zh-light-59-detail.txt +1 -1
- package/skills/teamsmith/tests/snapshots/zh-light-59-p4.txt +1 -1
- package/skills/teamsmith/tests/snapshots/zh-light-59.txt +5 -5
- package/skills/teamsmith/tests/snapshots/zh-light-99-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-light-99.txt +5 -5
- package/skills/teamsmith/tests/task-header-model.sh +2 -1
- package/skills/teamsmith/tests/task-model-routing.sh +1511 -0
- package/skills/teamsmith/tests/tmp-hygiene.sh +782 -45
- package/skills/teamsmith/tests/tmux-identity-leak.sh +773 -0
- package/skills/teamsmith/tests/tmux-lint-legacy.txt +12 -18
- package/skills/teamsmith/tests/upgrade-recipe.sh +537 -0
- package/skills/teamsmith-init/SKILL.md +43 -43
- package/skills/teamsmith-init/references/bootstrap.md +8 -6
- package/skills/teamsmith-init/templates/bootstrap-prompt.md.tmpl +9 -5
|
@@ -0,0 +1,1511 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# P228: isolated policy/identity front door. Recording agents prove argv/state, not providers.
|
|
3
|
+
set -uo pipefail
|
|
4
|
+
here="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
5
|
+
source "$here/lib/tmp-root.sh"
|
|
6
|
+
source "$here/lib/model-policy.sh"
|
|
7
|
+
source "$here/lib/model-routing-boundary.sh"
|
|
8
|
+
source "$here/lib/model-routing-expansion.sh"
|
|
9
|
+
source "$here/lib/model-routing-roles.sh"
|
|
10
|
+
source "$here/lib/tmux-iso.sh"
|
|
11
|
+
TREE="${TEAM_ROUTING_TREE:-$(cd "$here/../../.." && pwd)}"
|
|
12
|
+
EVIDENCE="${TEAM_ROUTING_EVIDENCE:-}"
|
|
13
|
+
SELECT='policy,machine,init,config,upgrade,dispatch,resume,transaction,limits,preview,sid-readers,pm,heal,adopt,updatecheck,boundary'
|
|
14
|
+
while [ $# -gt 0 ]; do
|
|
15
|
+
case "$1" in --select) SELECT="${2:?}"; shift 2 ;; --flip) SELECT=flip; shift ;; *) printf 'unknown option: %s\n' "$1"; exit 2 ;; esac
|
|
16
|
+
done
|
|
17
|
+
for group in ${SELECT//,/ }; do
|
|
18
|
+
case "$group" in policy|machine|config|upgrade|dispatch|resume|transaction|limits|preview|sid-readers|pm|boundary|init|heal|adopt|updatecheck|flip) ;; *) printf 'unknown group: %s\n' "$group"; exit 2 ;; esac
|
|
19
|
+
done
|
|
20
|
+
while IFS='=' read -r k _; do case "$k" in TEAM_*) unset "$k" 2>/dev/null || true ;; esac; done < <(env)
|
|
21
|
+
TMP="$(tmp_root_create task-model-routing)" || exit 3
|
|
22
|
+
# Never inherit the shared runtime shim; a private wrapper must exec a real binary, not itself.
|
|
23
|
+
IFS=: read -r -a path_parts <<< "$PATH"; clean_path=''
|
|
24
|
+
for part in "${path_parts[@]}"; do case "$part" in */scripts/shim) ;; *) clean_path="${clean_path:+$clean_path:}$part" ;; esac; done
|
|
25
|
+
export PATH="$clean_path"
|
|
26
|
+
unset TMUX TMUX_PANE
|
|
27
|
+
export HOME="$TMP/home"; mkdir -p "$HOME"
|
|
28
|
+
PASS=0 FAIL=0; LIVE_SOCKET=''
|
|
29
|
+
cleanup() {
|
|
30
|
+
[ "${BASHPID:-$$}" = "$$" ] || return 0
|
|
31
|
+
if [ -n "$LIVE_SOCKET" ] && tmux_iso_guard_soft routing cleanup --tmpdir "$TMUX_TMPDIR" --sock-name "$LIVE_SOCKET" --own-root "$TMP" --own-root "$TMUX_TMPDIR"; then
|
|
32
|
+
tmux -L "$LIVE_SOCKET" kill-server 2>/dev/null || true
|
|
33
|
+
fi
|
|
34
|
+
if [ -n "$EVIDENCE" ]; then
|
|
35
|
+
mkdir -p "$EVIDENCE"
|
|
36
|
+
cp -a "$TMP" "$EVIDENCE/$(basename "$TMP")" || printf 'evidence export failed: %s\n' "$EVIDENCE" >&2
|
|
37
|
+
printf 'evidence: %s/%s\n' "$EVIDENCE" "$(basename "$TMP")"
|
|
38
|
+
fi
|
|
39
|
+
tmp_root_reap_all
|
|
40
|
+
}
|
|
41
|
+
trap cleanup EXIT
|
|
42
|
+
has() { case ",$SELECT," in *",$1,"*) return 0 ;; esac; return 1; }
|
|
43
|
+
check() { local name="$1"; shift; if "$@"; then PASS=$((PASS+1)); printf 'PASS %s\n' "$name"; else FAIL=$((FAIL+1)); printf 'FAIL %s\n' "$name"; fi; }
|
|
44
|
+
eq() { [ "$1" = "$2" ]; }
|
|
45
|
+
contains() { [[ "$1" == *"$2"* ]]; }
|
|
46
|
+
sha() { if [ -f "$1" ]; then sha256sum "$1" | cut -d' ' -f1; else printf absent; fi; }
|
|
47
|
+
CLI="$TREE/skills/teamsmith/scripts/team"
|
|
48
|
+
SKILL="$TREE/skills/teamsmith"
|
|
49
|
+
REPO="$TMP/repo"; mkdir -p "$REPO/.pi/team" "$REPO/docs/team/tasks" "$REPO/docs/team/threads"
|
|
50
|
+
git -C "$REPO" init -q -b main
|
|
51
|
+
git -C "$REPO" config user.name fixture; git -C "$REPO" config user.email fixture@example.invalid
|
|
52
|
+
printf '# fixture\n' > "$REPO/README.md"; git -C "$REPO" add README.md; git -C "$REPO" commit -qm fixture
|
|
53
|
+
cat > "$REPO/.pi/team/config.sh" <<EOF
|
|
54
|
+
TEAM_PROJECT='routing-fixture'
|
|
55
|
+
TEAM_SESSION='routing-fixture'
|
|
56
|
+
TEAM_PM_WINDOW='pm'
|
|
57
|
+
TEAM_DOCS_DIR='docs/team'
|
|
58
|
+
TEAM_AGENTS='dev verify'
|
|
59
|
+
TEAM_TASK_MODELS='routine=vendor/routine analysis=vendor/analysis verify=vendor/verify custom=vendor/custom'
|
|
60
|
+
TEAM_PM_MODEL='vendor/pm:high'
|
|
61
|
+
TEAM_WORKTREES_DIR='.worktrees'
|
|
62
|
+
TEAM_VCS='local'
|
|
63
|
+
TEAM_GATES='true'
|
|
64
|
+
TEAM_MIN_FREE_SWAP_MB=0
|
|
65
|
+
TEAM_MIN_TOTAL_MB=0
|
|
66
|
+
TEAM_MIN_AVAIL_MB=0
|
|
67
|
+
TEAM_TMP_MIN_FREE_MB=0
|
|
68
|
+
TEAM_TMP_MIN_FREE_INODES=0
|
|
69
|
+
TEAM_MODEL_LIMITS=''
|
|
70
|
+
TEAM_PI_BIN='$TMP/recording-pi'
|
|
71
|
+
EOF
|
|
72
|
+
cat > "$TMP/recording-pi" <<EOF
|
|
73
|
+
#!/usr/bin/env bash
|
|
74
|
+
printf '%s\\n' "\$@" >> '$TMP/argv.log'
|
|
75
|
+
python3 -c 'import json,sys; open(sys.argv[1],"a").write(json.dumps(sys.argv[2:])+chr(10))' '$TMP/argv-jsonl' "\$@"
|
|
76
|
+
[ ! -f '$TMP/fail-launch' ] || exit 9
|
|
77
|
+
sleep 180
|
|
78
|
+
EOF
|
|
79
|
+
chmod +x "$TMP/recording-pi"
|
|
80
|
+
effect_snapshot() {
|
|
81
|
+
[ -n "$EVIDENCE" ] || return 0
|
|
82
|
+
{ printf '\n%s\n' "$1"; sha256sum "$REPO/.pi/team/config.sh" "$REPO/docs/team/BOARD.md" 2>/dev/null || true
|
|
83
|
+
[ ! -d "$REPO/.pi/team/state" ] || find "$REPO/.pi/team/state" -maxdepth 1 -type f -print0 | sort -z | xargs -0 -r sha256sum
|
|
84
|
+
} >> "$TMP/effect-hashes.log"
|
|
85
|
+
}
|
|
86
|
+
run() { local rc=0; effect_snapshot "before $*"; OUT="$(cd "$REPO" && timeout 35 bash "$CLI" "$@" 2>&1)" || rc=$?; RC="$rc"; printf 'command=%q ' "$@"; printf '\nrc=%s\n%s\n' "$RC" "$OUT"; effect_snapshot "after rc=$RC $*"; }
|
|
87
|
+
STATE="$REPO/.pi/team/state"; CONFIG="$REPO/.pi/team/config.sh"
|
|
88
|
+
# ── 每组自足:自己准备自己的前置(P238 坑 1)────────────────────────────────────────────
|
|
89
|
+
# 以前夹具的 state 目录只在 sid-readers / boundary 组的正文里被建出来,于是单独 `--select pm`
|
|
90
|
+
# 时发布记录($STATE/pm-launch.env)写不进去、29 条断言连锁红(最早一条是 pm-partial-publication-record,
|
|
91
|
+
# 诊断 .pm-launch-test-nonce: No such file or directory)。跨组共享的前置一律在这里按**选中的组**
|
|
92
|
+
# 逐组准备,不靠兄弟组先跑过;准备失败时点名,而不是让下游断言各红一遍(缺前置不是静默跳过)。
|
|
93
|
+
# 现只有一处:state 目录是发布记录 / 审计 / 快照的落点,每个组都可能写它。
|
|
94
|
+
routing_group_setup() { # <组> → 0 = 就绪;1 = 前置准备失败(已点名)
|
|
95
|
+
local g="$1"
|
|
96
|
+
mkdir -p "$STATE" 2>/dev/null && return 0
|
|
97
|
+
printf 'FAIL group-setup:%s 前置准备失败:建不出夹具 state 目录 %s\n' "$g" "$STATE"
|
|
98
|
+
return 1
|
|
99
|
+
}
|
|
100
|
+
for _setup_group in ${SELECT//,/ }; do routing_group_setup "$_setup_group" || true; done
|
|
101
|
+
# Direct library fixtures are still isolated; never load real project state/config.
|
|
102
|
+
export TEAM_ROOT="$REPO" TEAM_MAIN_ROOT="$REPO" TEAM_STATE_DIR="$STATE" TEAM_CONFIG="$CONFIG" TEAM_CLI=team TEAM_SKILL_DIR="$SKILL" TEAM_DOCS_ABS="$REPO/docs/team" TEAM_DOCS_DIR=docs/team TEAM_SESSION=routing-fixture TEAM_PM_WINDOW=pm TEAM_AGENTS='dev verify' TEAM_WORKTREES_DIR=.worktrees TEAM_PI_AGENT_DIR="$HOME/.pi/agent"
|
|
103
|
+
source "$SKILL/scripts/lib/common.sh"
|
|
104
|
+
for lib in "$SKILL"/scripts/lib/cmd-*.sh; do source "$lib"; done
|
|
105
|
+
team_load_config
|
|
106
|
+
check isolation-root eq "$TEAM_MAIN_ROOT" "$REPO"
|
|
107
|
+
check isolation-home contains "$HOME" "$TMP"
|
|
108
|
+
if has policy; then
|
|
109
|
+
for map in '' 'routine=x/y analysis=x/z verify=x/v routine=a/b' 'routine=x/y analysis=x/z verify=' 'Routine=x/y analysis=x/z verify=x/v' 'routine=a//b analysis=x/z verify=x/v'; do
|
|
110
|
+
rc=0; team_task_map_violation "$map" || rc=$?; check "policy-invalid:$map" eq "$rc" 1
|
|
111
|
+
done
|
|
112
|
+
check policy-minimum-analysis-verify team_task_map_violation 'analysis=provider/deep/id:high verify=provider/verify'
|
|
113
|
+
check policy-custom-category team_task_map_violation 'custom=provider/name routine=p/r analysis=p/a verify=p/v'
|
|
114
|
+
# F6(真缺陷):analysis/verify 不是引擎必备类别 —— 合同写「Initial routine/analysis/verify are examples, not
|
|
115
|
+
# mandatory engine categories」(memory-and-deps)与「Initial examples … do not close the engine vocabulary」
|
|
116
|
+
# (dispatch delta)。旧实现无条件要求这两个名字,于是项目自定义词汇的整映射被拒。唯一非法的映射是空映射。
|
|
117
|
+
check policy-custom-vocabulary-only team_task_map_violation 'maintenance=vendor/light'
|
|
118
|
+
check policy-custom-vocabulary-partial team_task_map_violation 'routine=x/y analysis=x/z'
|
|
119
|
+
check policy-drop-analysis-verify team_task_map_violation 'routine=vendor/routine maintenance=vendor/light'
|
|
120
|
+
check policy-drop-routine-analysis team_task_map_violation 'verify=vendor/verify maintenance=vendor/light'
|
|
121
|
+
check policy-custom-vocabulary-multi team_task_map_violation 'ops=vendor/light audit=vendor/audit:high release=vendor/release'
|
|
122
|
+
before="$(sha "$CONFIG")"; run config set TEAM_DEFAULT_MODEL p/old --yes; check retired-key eq "$RC" 5
|
|
123
|
+
run config set-agent-model dev p/old; check retired-command eq "$RC" 5
|
|
124
|
+
run add-agent dev --model p/old; check retired-register-option eq "$RC" 2
|
|
125
|
+
check retired-no-write eq "$(sha "$CONFIG")" "$before"
|
|
126
|
+
run config set-task-model custom vendor/custom:high
|
|
127
|
+
printf '| ID | 任务 | Agent | 分支 | 依赖 | 状态 |\n|---|---|---|---|---|---|\n' > "$REPO/docs/team/BOARD.md"
|
|
128
|
+
run task G1 --title generated --slug generated --category custom --agent dev
|
|
129
|
+
printf 'generator rc=%s\n%s\n' "$RC" "$OUT" > "$TMP/generator-result.log"
|
|
130
|
+
check generated-mapped-category eq "$RC" 0
|
|
131
|
+
check generated-category-header eq "$(grep -cx 'category: custom' "$REPO/docs/team/tasks/G1-generated.md" || true)" 1
|
|
132
|
+
for fault in missing malformed unmapped; do
|
|
133
|
+
case "$fault" in
|
|
134
|
+
missing) run task G2 --title refused --slug refused ;;
|
|
135
|
+
malformed) run task G2 --title refused --slug refused --category Bad/token ;;
|
|
136
|
+
unmapped) run task G2 --title refused --slug refused --category unmapped ;;
|
|
137
|
+
esac
|
|
138
|
+
check "generation-refused:$fault" bash -c '[ "$1" != 0 ]' _ "$RC"
|
|
139
|
+
check "generation-no-file:$fault" bash -c '! test -e "$1"' _ "$REPO/docs/team/tasks/G2-refused.md"
|
|
140
|
+
done
|
|
141
|
+
fi
|
|
142
|
+
if has machine; then
|
|
143
|
+
run config list --json
|
|
144
|
+
check machine-json python3 -c 'import json,sys; d=json.loads(sys.argv[1]); assert "seats" not in d["models"] and "default" not in d["models"]; assert d["models"]["policy"]["pm"]=="vendor/pm:high"; assert all(x["diagnostic"] for x in d["models"]["assignments"]); assert all(not x["model"] for x in d["models"]["assignments"]); assert [k for k in d["keys"] if k["name"]=="TEAM_TASK_MODELS"][0]["group"]=="task-model"' "$OUT"
|
|
145
|
+
fi
|
|
146
|
+
if has config; then
|
|
147
|
+
before="$(sha "$CONFIG")"; run config set-task-model custom openrouter/amazon/nova-lite:high --dry-run; check map-preview eq "$RC" 0; check map-preview-pure eq "$(sha "$CONFIG")" "$before"
|
|
148
|
+
run config set-task-model custom openrouter/amazon/nova-lite:high; check map-upsert eq "$RC" 0
|
|
149
|
+
run config set-task-model broken a//b; check map-invalid eq "$RC" 4
|
|
150
|
+
fp="$(sha "$CONFIG")"; run config set-task-model custom p/one --fingerprint "$fp"; check map-cas-first eq "$RC" 0
|
|
151
|
+
run config set-task-model custom p/two --fingerprint "$fp"; check map-cas-loser eq "$RC" 3
|
|
152
|
+
fp="$(sha "$CONFIG")"
|
|
153
|
+
(cd "$REPO" && bash "$CLI" config set-task-model race-a p/a --fingerprint "$fp" > "$TMP/race-a.log" 2>&1; printf '%s' "$?" > "$TMP/race-a.rc") & p1=$!
|
|
154
|
+
(cd "$REPO" && bash "$CLI" config set-task-model race-b p/b --fingerprint "$fp" > "$TMP/race-b.log" 2>&1; printf '%s' "$?" > "$TMP/race-b.rc") & p2=$!
|
|
155
|
+
wait "$p1" "$p2"
|
|
156
|
+
check simultaneous-map-cas python3 -c 'import pathlib,sys; assert sorted(pathlib.Path(x).read_text() for x in sys.argv[1:])==["0","3"]' "$TMP/race-a.rc" "$TMP/race-b.rc"
|
|
157
|
+
# F6:写侧整映射(不含 analysis/verify)+ 读侧同一份映射;空映射仍是一个真拒绝。
|
|
158
|
+
map_fixture="$(team_config_file_value "$CONFIG" TEAM_TASK_MODELS)"
|
|
159
|
+
run config set TEAM_TASK_MODELS 'maintenance=vendor/light ops=vendor/ops:high' --yes
|
|
160
|
+
check map-custom-vocabulary-write eq "$RC" 0
|
|
161
|
+
check map-custom-vocabulary-line eq "$(grep -c "^TEAM_TASK_MODELS='maintenance=vendor/light ops=vendor/ops:high'\$" "$CONFIG" || true)" 1
|
|
162
|
+
run config list --json
|
|
163
|
+
check map-custom-vocabulary-read python3 -c 'import json,sys; d=json.loads(sys.argv[1]); assert [c["category"] for c in d["models"]["policy"]["categories"]]==["maintenance","ops"], d["models"]["policy"]' "$OUT"
|
|
164
|
+
run config set-task-model release vendor/release --yes
|
|
165
|
+
check map-custom-vocabulary-upsert eq "$RC" 0
|
|
166
|
+
check map-custom-vocabulary-upsert-line eq "$(grep -c "^TEAM_TASK_MODELS='maintenance=vendor/light ops=vendor/ops:high release=vendor/release'\$" "$CONFIG" || true)" 1
|
|
167
|
+
run config set TEAM_TASK_MODELS '' --yes
|
|
168
|
+
check map-empty-refused eq "$RC" 4
|
|
169
|
+
run config set TEAM_TASK_MODELS "$map_fixture" --yes
|
|
170
|
+
check map-fixture-restored eq "$RC" 0
|
|
171
|
+
payload="literal\$(touch '$TMP/PWNED')"
|
|
172
|
+
run config set TEAM_GATES "$payload" --yes
|
|
173
|
+
check writer-literal-payload-accepted eq "$RC" 0
|
|
174
|
+
run config list --json
|
|
175
|
+
check writer-payload-does-not-expand bash -c '[ ! -e "$1" ]' _ "$TMP/PWNED"
|
|
176
|
+
check writer-literal-roundtrip eq "$(bash --noprofile --norc -c 'source "$1"; printf "%s" "$TEAM_GATES"' _ "$CONFIG")" "$payload"
|
|
177
|
+
run config set TEAM_GATES true --yes
|
|
178
|
+
fi
|
|
179
|
+
if has upgrade; then
|
|
180
|
+
cp -p "$CONFIG" "$TMP/new-policy"
|
|
181
|
+
printf "TEAM_DEFAULT_MODEL='' # retired note\nTEAM_AGENT_MODELS='dev=p/old'\n" >> "$CONFIG"
|
|
182
|
+
before="$(sha "$CONFIG")"; audit="$(sha "$STATE/config.log")"
|
|
183
|
+
run config upgrade-models --task-models 'routine=p/r analysis=p/a verify=p/v' --pm-model p/pm
|
|
184
|
+
check upgrade-preview eq "$RC" 0; check upgrade-preview-config eq "$(sha "$CONFIG")" "$before"; check upgrade-preview-audit eq "$(sha "$STATE/config.log")" "$audit"
|
|
185
|
+
run config upgrade-models --task-models 'analysis=p/a verify=p/v' --pm-model p/pm --yes
|
|
186
|
+
check upgrade-commit eq "$RC" 0
|
|
187
|
+
check upgrade-retired-removed bash -c '! grep -Eq "^TEAM_(DEFAULT_MODEL|AGENT_MODELS)=" "$1" && grep -q "retired note" "$1"' _ "$CONFIG"
|
|
188
|
+
for shape in 'export TEAM_DEFAULT_MODEL="x/y"' 'TEAM_DEFAULT_MODEL=$(printf x/y)' 'TEAM_DEFAULT_MODEL="x/y"; echo nope' 'if true; then TEAM_DEFAULT_MODEL="x/y"; fi' 'TEAM_DEFAULT_MODEL="x/y"\nTEAM_DEFAULT_MODEL="x/z"' 'TEAM_DEFAULT_MODEL="x/y\nx/z"'; do
|
|
189
|
+
cp -p "$TMP/new-policy" "$CONFIG"; printf '%b\n' "$shape" >> "$CONFIG"; before="$(sha "$CONFIG")"
|
|
190
|
+
run config upgrade-models --task-models 'analysis=p/a verify=p/v' --pm-model p/pm --yes
|
|
191
|
+
check "upgrade-refuse:$shape" eq "$RC" 5; check "upgrade-no-write:$shape" eq "$(sha "$CONFIG")" "$before"
|
|
192
|
+
done
|
|
193
|
+
cp -p "$TMP/new-policy" "$CONFIG"
|
|
194
|
+
upgrade_fault() (
|
|
195
|
+
kind="$1"
|
|
196
|
+
printf "TEAM_DEFAULT_MODEL='p/old'\nTEAM_AGENT_MODELS='dev=p/old'\n" >> "$CONFIG"
|
|
197
|
+
old="$(sha "$CONFIG")"; expected=6; result=write-error
|
|
198
|
+
# Alias the trusted loaded function, not config data, so early field writes remain real.
|
|
199
|
+
definition="$(declare -f team_config_set_in_file)"
|
|
200
|
+
eval "${definition/team_config_set_in_file /p228_original_set_in_file }"
|
|
201
|
+
case "$kind" in
|
|
202
|
+
alloc) mktemp() { return 1; } ;;
|
|
203
|
+
copy) cp() { return 1; } ;;
|
|
204
|
+
render) team_config_set_in_file() { [ "$2" != TEAM_PM_MODEL ] || return 1; p228_original_set_in_file "$@"; } ;;
|
|
205
|
+
syntax) bash() { [ "${1:-}" != -n ] || return 1; command bash "$@"; } ;;
|
|
206
|
+
rename) mv() { return 1; } ;;
|
|
207
|
+
late-cas)
|
|
208
|
+
expected=3; result=conflict
|
|
209
|
+
team_config_set_in_file() {
|
|
210
|
+
p228_original_set_in_file "$@" || return
|
|
211
|
+
[ "$2" != TEAM_PM_MODEL ] || printf '# retained concurrent writer\n' >> "$CONFIG"
|
|
212
|
+
} ;;
|
|
213
|
+
stale-cas) expected=3; result=conflict; printf '# retained concurrent writer\n' >> "$CONFIG" ;;
|
|
214
|
+
esac
|
|
215
|
+
rc=0
|
|
216
|
+
team_config_upgrade_transaction "$CONFIG" 'analysis=p/a verify=p/v' p/pm 0 "$old" "p228-$kind" || rc=$?
|
|
217
|
+
printf 'upgrade-fault=%s rc=%s expected=%s\n' "$kind" "$rc" "$expected"
|
|
218
|
+
[ "$rc" = "$expected" ] || return 1
|
|
219
|
+
case "$kind" in
|
|
220
|
+
*cas) grep -q '^# retained concurrent writer$' "$CONFIG" && grep -q '^TEAM_DEFAULT_MODEL=' "$CONFIG" || return 1 ;;
|
|
221
|
+
*) [ "$(sha "$CONFIG")" = "$old" ] || return 1 ;;
|
|
222
|
+
esac
|
|
223
|
+
[ "$(grep -c "result=$result actor=p228-$kind " "$STATE/config.log" || true)" = 1 ] || return 1
|
|
224
|
+
[ "$(find "$(dirname "$CONFIG")" -maxdepth 1 -name '.model-upgrade.*' | wc -l)" = 0 ]
|
|
225
|
+
)
|
|
226
|
+
for fault in alloc copy render syntax rename stale-cas late-cas; do
|
|
227
|
+
cp -p "$TMP/new-policy" "$CONFIG"
|
|
228
|
+
check "upgrade-whole-file-fault:$fault" upgrade_fault "$fault"
|
|
229
|
+
done
|
|
230
|
+
cp -p "$TMP/new-policy" "$CONFIG"
|
|
231
|
+
for fault in missing-map missing-pm invalid-pm invalid-map; do
|
|
232
|
+
before="$(sha "$CONFIG")"
|
|
233
|
+
case "$fault" in
|
|
234
|
+
missing-map) run config upgrade-models --pm-model p/pm --yes ;;
|
|
235
|
+
missing-pm) run config upgrade-models --task-models 'analysis=p/a' --yes ;;
|
|
236
|
+
invalid-pm) run config upgrade-models --task-models 'analysis=p/a' --pm-model p//pm --yes ;;
|
|
237
|
+
invalid-map) run config upgrade-models --task-models 'analysis=p/a analysis=p/b' --pm-model p/pm --yes ;;
|
|
238
|
+
esac
|
|
239
|
+
check "upgrade-input-refused:$fault" bash -c '[ "$1" != 0 ]' _ "$RC"
|
|
240
|
+
check "upgrade-input-pure:$fault" eq "$(sha "$CONFIG")" "$before"
|
|
241
|
+
done
|
|
242
|
+
printf "TEAM_DEFAULT_MODEL='p/old'\nTEAM_AGENT_MODELS='dev=p/old'\nS1_UNRELATED_FINAL='keep # no newline'" >> "$CONFIG"
|
|
243
|
+
run config upgrade-models --task-models 'analysis=p/a verify=p/v' --pm-model p/pm --yes
|
|
244
|
+
check upgrade-no-final-newline-commit eq "$RC" 0
|
|
245
|
+
check upgrade-no-final-newline-preserved python3 -c 'import pathlib,sys; b=pathlib.Path(sys.argv[1]).read_bytes(); assert b.endswith(b"S1_UNRELATED_FINAL=\x27keep # no newline\x27") and not b.endswith(b"\n")' "$CONFIG"
|
|
246
|
+
cp -p "$TMP/new-policy" "$CONFIG"
|
|
247
|
+
upgrade_audit_unwritable() (
|
|
248
|
+
TEAM_STATE_DIR="$TMP/audit-unwritable"; mkdir -p "$TEAM_STATE_DIR/config.log"
|
|
249
|
+
rc=0
|
|
250
|
+
team_config_upgrade_transaction "$CONFIG" 'analysis=p/a verify=p/v' p/pm 0 '' p228-audit-unwritable > "$TMP/upgrade-audit-unwritable.log" 2>&1 || rc=$?
|
|
251
|
+
[ "$rc" = 0 ] && bash -n "$CONFIG" &&
|
|
252
|
+
grep -q 'TEAM_PM_MODEL=.*p/pm' "$CONFIG" && grep -Eqi 'audit|审计' "$TMP/upgrade-audit-unwritable.log"
|
|
253
|
+
)
|
|
254
|
+
check upgrade-audit-unwritable-honest-committed-result upgrade_audit_unwritable
|
|
255
|
+
cp -p "$TMP/new-policy" "$CONFIG"
|
|
256
|
+
upgrade_concurrent_readers() (
|
|
257
|
+
printf "TEAM_DEFAULT_MODEL='p/old'\nTEAM_AGENT_MODELS='dev=p/old'\n" >> "$CONFIG"
|
|
258
|
+
old="$(sha "$CONFIG")"; failed=0
|
|
259
|
+
old_map="$(bash --noprofile --norc -c 'source "$1"; printf "%s" "$TEAM_TASK_MODELS"' _ "$CONFIG")"
|
|
260
|
+
old_pm="$(bash --noprofile --norc -c 'source "$1"; printf "%s" "$TEAM_PM_MODEL"' _ "$CONFIG")"
|
|
261
|
+
definition="$(declare -f team_config_set_in_file)"
|
|
262
|
+
eval "${definition/team_config_set_in_file /p228_original_set_in_file }"
|
|
263
|
+
team_config_set_in_file() {
|
|
264
|
+
p228_original_set_in_file "$@" || return
|
|
265
|
+
if [ "$2" = TEAM_TASK_MODELS ]; then
|
|
266
|
+
touch "$TMP/upgrade-reader-ready"
|
|
267
|
+
for ((j=0; j<400; j++)); do
|
|
268
|
+
[ ! -f "$TMP/upgrade-reader-release" ] || return 0
|
|
269
|
+
sleep .05
|
|
270
|
+
done
|
|
271
|
+
return 1
|
|
272
|
+
fi
|
|
273
|
+
}
|
|
274
|
+
(team_with_lock "config:$CONFIG" team_config_upgrade_transaction "$CONFIG" 'analysis=p/a verify=p/v' p/pm 0 '' p228-readers > "$TMP/upgrade-readers-writer.log" 2>&1) & writer=$!
|
|
275
|
+
for ((j=0; j<200; j++)); do [ ! -f "$TMP/upgrade-reader-ready" ] || break; sleep .05; done
|
|
276
|
+
[ -f "$TMP/upgrade-reader-ready" ] || failed=1
|
|
277
|
+
for ((j=0; j<10; j++)); do
|
|
278
|
+
[ "$(sha "$CONFIG")" = "$old" ] && bash -n "$CONFIG" || failed=1
|
|
279
|
+
bash --noprofile --norc -c 'source "$1"; [ "$TEAM_DEFAULT_MODEL" = p/old ] && [ "$TEAM_PM_MODEL" = "$3" ] && [ "$TEAM_TASK_MODELS" = "$2" ]' _ "$CONFIG" "$old_map" "$old_pm" || failed=1
|
|
280
|
+
done
|
|
281
|
+
touch "$TMP/upgrade-reader-release"
|
|
282
|
+
wait "$writer" || failed=1
|
|
283
|
+
bash --noprofile --norc -c 'source "$1"; [ "${TEAM_DEFAULT_MODEL+x}" != x ] && [ "${TEAM_AGENT_MODELS+x}" != x ] && [ "$TEAM_PM_MODEL" = p/pm ] && [ "$TEAM_TASK_MODELS" = "analysis=p/a verify=p/v" ]' _ "$CONFIG" || failed=1
|
|
284
|
+
[ "$failed" = 0 ]
|
|
285
|
+
)
|
|
286
|
+
check upgrade-readers-wholly-old-before-rename-new-after upgrade_concurrent_readers
|
|
287
|
+
cp -p "$TMP/new-policy" "$CONFIG"
|
|
288
|
+
# F6:升级(现有的迁移/种子入口)也接受自定义词汇整映射,并把未交付的类别报给读侧
|
|
289
|
+
printf "TEAM_DEFAULT_MODEL='p/old'\nTEAM_AGENT_MODELS='dev=p/old'\n" >> "$CONFIG"
|
|
290
|
+
run config upgrade-models --task-models 'ops=vendor/ops audit=vendor/audit:high' --pm-model p/pm --yes
|
|
291
|
+
check upgrade-custom-vocabulary eq "$RC" 0
|
|
292
|
+
check upgrade-custom-vocabulary-line eq "$(grep -c "^TEAM_TASK_MODELS='ops=vendor/ops audit=vendor/audit:high'\$" "$CONFIG" || true)" 1
|
|
293
|
+
run config list --json
|
|
294
|
+
check upgrade-custom-vocabulary-read python3 -c 'import json,sys; d=json.loads(sys.argv[1]); assert [c["category"] for c in d["models"]["policy"]["categories"]]==["ops","audit"], d["models"]["policy"]' "$OUT"
|
|
295
|
+
cp -p "$TMP/new-policy" "$CONFIG"
|
|
296
|
+
fi
|
|
297
|
+
brief() { cat > "$REPO/docs/team/tasks/$1-fixture.md" <<EOF
|
|
298
|
+
# $1 · fixture
|
|
299
|
+
agent: $2
|
|
300
|
+
phase: apply
|
|
301
|
+
category: ${3:-routine}
|
|
302
|
+
change: -
|
|
303
|
+
anchor: none (infra) — isolated recording fixture
|
|
304
|
+
branch: task/$1-fixture
|
|
305
|
+
## Scope
|
|
306
|
+
No real provider or project state.
|
|
307
|
+
EOF
|
|
308
|
+
}
|
|
309
|
+
brief T1 dev routine; brief T2 verify routine
|
|
310
|
+
mkdir -p "$REPO/.worktrees"
|
|
311
|
+
git -C "$REPO" worktree add -qb task/T1-fixture "$REPO/.worktrees/dev"
|
|
312
|
+
git -C "$REPO" worktree add -qb task/T2-fixture "$REPO/.worktrees/verify"
|
|
313
|
+
printf '| ID | 任务 | Agent | 分支 | 依赖 | 状态 |\n|---|---|---|---|---|---|\n| T1 | fixture | dev | task/T1-fixture | - | todo |\n| T2 | fixture | verify | task/T2-fixture | - | todo |\n' > "$REPO/docs/team/BOARD.md"
|
|
314
|
+
if has preview || has dispatch || has resume || has transaction || has limits || has boundary; then
|
|
315
|
+
# Private socket bound shim; cleanup never reaches the shared server.
|
|
316
|
+
LIVE_SOCKET="routing-${BASHPID}-${RANDOM}"
|
|
317
|
+
# P309:socket 目录**不能**挂在本轮的临时根下 —— 临时根名带项目 ns(`/var/tmp/teamsmith-<ns>`)之后,
|
|
318
|
+
# `<TMP>/tmux/tmux-<uid>/routing-…` 已经 129 字节 > AF_UNIX 的 107,隔离前置直接硬停(routing 组整组判不了)。
|
|
319
|
+
# 基址要短:tmp_root_socket_dir 先试解析出的临时根、放不下就退 OS 默认临时目录。
|
|
320
|
+
TMUX_TMPDIR="$(tmp_root_socket_dir routing "tmux-$(id -u)/routing-999999-99999")" \
|
|
321
|
+
|| TMUX_TMPDIR="$TMP/tmux"
|
|
322
|
+
export TMUX_TMPDIR; mkdir -p "$TMUX_TMPDIR" "$TMP/bin"
|
|
323
|
+
REAL_TMUX="$(type -P tmux)"
|
|
324
|
+
printf '#!/usr/bin/env bash\nexec %q -L %q "$@"\n' "$REAL_TMUX" "$LIVE_SOCKET" > "$TMP/bin/tmux"; chmod +x "$TMP/bin/tmux"
|
|
325
|
+
export PATH="$TMP/bin:$PATH"
|
|
326
|
+
tmux_iso_require routing launch --tmpdir "$TMUX_TMPDIR" --sock-name "$LIVE_SOCKET" --own-root "$TMP" --own-root "$TMUX_TMPDIR"
|
|
327
|
+
before="$(sha "$STATE/dev.env")"; board="$(sha "$REPO/docs/team/BOARD.md")"
|
|
328
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --print
|
|
329
|
+
check preview-success eq "$RC" 0; check preview-no-assignment eq "$(sha "$STATE/dev.env")" "$before"; check preview-no-board eq "$(sha "$REPO/docs/team/BOARD.md")" "$board"
|
|
330
|
+
check preview-no-prompt bash -c '! test -f "$1/prompt-dev-T1.txt" && ! test -f "$1/dev.pending"' _ "$STATE"
|
|
331
|
+
check preview-no-session bash -c '! tmux -L "$1" has-session 2>/dev/null' _ "$LIVE_SOCKET"
|
|
332
|
+
cp -p "$REPO/docs/team/tasks/T1-fixture.md" "$TMP/legal-brief"
|
|
333
|
+
for fault in missing blank duplicate malformed explore propose verify; do
|
|
334
|
+
cp -p "$TMP/legal-brief" "$REPO/docs/team/tasks/T1-fixture.md"
|
|
335
|
+
case "$fault" in
|
|
336
|
+
missing) sed -i '/^category:/d' "$REPO/docs/team/tasks/T1-fixture.md" ;;
|
|
337
|
+
blank) sed -i 's/^category:.*/category: /' "$REPO/docs/team/tasks/T1-fixture.md" ;;
|
|
338
|
+
duplicate) printf 'category: analysis\n' >> "$REPO/docs/team/tasks/T1-fixture.md" ;;
|
|
339
|
+
malformed) sed -i 's/^category:.*/category: Bad\/token/' "$REPO/docs/team/tasks/T1-fixture.md" ;;
|
|
340
|
+
*) sed -i "s/^phase:.*/phase: $fault/" "$REPO/docs/team/tasks/T1-fixture.md" ;;
|
|
341
|
+
esac
|
|
342
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --model vendor/strong:high --force --print
|
|
343
|
+
case "$fault" in explore|propose|verify) expected=0 ;; *) expected=1 ;; esac
|
|
344
|
+
check "category-explicit-phase-independent:$fault" eq "$RC" "$expected"
|
|
345
|
+
if [ "$expected" = 0 ]; then check "phase-does-not-infer-category:$fault" contains "$OUT" 'category=routine'; fi
|
|
346
|
+
check "category-fault-record-pure:$fault" eq "$(sha "$STATE/dev.env")" "$before"
|
|
347
|
+
check "category-fault-board-pure:$fault" eq "$(sha "$REPO/docs/team/BOARD.md")" "$board"
|
|
348
|
+
done
|
|
349
|
+
cp -p "$TMP/legal-brief" "$REPO/docs/team/tasks/T1-fixture.md"
|
|
350
|
+
brief T2 verify unmapped
|
|
351
|
+
run dispatch verify T2 docs/team/tasks/T2-fixture.md --model vendor/strong:high --force --print
|
|
352
|
+
check new-unmapped-category-override-refused eq "$RC" 1
|
|
353
|
+
check unmapped-override-no-board eq "$(sha "$REPO/docs/team/BOARD.md")" "$board"
|
|
354
|
+
check unmapped-override-no-assignment bash -c '! test -f "$1/verify.env" && ! test -f "$1/prompt-verify-T2.md"' _ "$STATE"
|
|
355
|
+
# F6:同一套守卫在**自定义词汇**下也成立 —— 新选择只要求「类别在当前映射里」,映射里没写的仍拒绝。
|
|
356
|
+
# 任务/分支/工作树仍用本组的 T1 夹具(不碰工作树身份),只换类别。
|
|
357
|
+
map_fixture="$(team_config_file_value "$CONFIG" TEAM_TASK_MODELS)"
|
|
358
|
+
run config set TEAM_TASK_MODELS 'maintenance=vendor/light' --yes
|
|
359
|
+
check new-selection-custom-map-ready eq "$RC" 0
|
|
360
|
+
sed -i 's/^category:.*/category: maintenance/' "$REPO/docs/team/tasks/T1-fixture.md"
|
|
361
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --print
|
|
362
|
+
check new-selection-custom-vocabulary eq "$RC" 0
|
|
363
|
+
check new-selection-custom-vocabulary-model contains "$OUT" 'model=vendor/light'
|
|
364
|
+
sed -i 's/^category:.*/category: ops/' "$REPO/docs/team/tasks/T1-fixture.md"
|
|
365
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --print
|
|
366
|
+
check new-selection-custom-vocabulary-unmapped-refused eq "$RC" 1
|
|
367
|
+
check new-selection-custom-vocabulary-unmapped-reason contains "$OUT" 'category 未映射:ops'
|
|
368
|
+
check new-selection-custom-vocabulary-no-assignment bash -c '! test -f "$1/dev.pending" && ! test -f "$1/dev.env"' _ "$STATE"
|
|
369
|
+
cp -p "$TMP/legal-brief" "$REPO/docs/team/tasks/T1-fixture.md"
|
|
370
|
+
run config set TEAM_TASK_MODELS "$map_fixture" --yes
|
|
371
|
+
check new-selection-custom-map-restored eq "$RC" 0
|
|
372
|
+
brief T2 verify routine
|
|
373
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --model vendor/strong:high --fresh
|
|
374
|
+
check first-recorded-launch eq "$RC" 0
|
|
375
|
+
check first-complete-record team_assignment_load dev
|
|
376
|
+
SID_A="${TEAM_ASSIGN[sid]:-missing}"
|
|
377
|
+
check argv-full-suffix grep -Fxq strong:high "$TMP/argv.log"
|
|
378
|
+
if has resume; then
|
|
379
|
+
tmux kill-window -t routing-fixture:dev
|
|
380
|
+
cp -p "$STATE/dev.env" "$TMP/trusted-assignment"
|
|
381
|
+
argv_before="$(sha "$TMP/argv.log")"
|
|
382
|
+
for fault in missing malformed task_file category worktree branch; do
|
|
383
|
+
cp -p "$TMP/trusted-assignment" "$STATE/dev.env"
|
|
384
|
+
case "$fault" in
|
|
385
|
+
missing) rm "$STATE/dev.env" ;;
|
|
386
|
+
malformed) sed -i 's/^assignment_version=.*/assignment_version=broken/' "$STATE/dev.env" ;;
|
|
387
|
+
task_file) sed -i "s|^taskfile=.*|taskfile=$REPO/docs/team/tasks/T2-fixture.md|" "$STATE/dev.env" ;;
|
|
388
|
+
category) sed -i 's/^category=.*/category=analysis/' "$STATE/dev.env" ;;
|
|
389
|
+
worktree) sed -i "s|^worktree=.*|worktree=$REPO/.worktrees/verify|" "$STATE/dev.env" ;;
|
|
390
|
+
branch) sed -i 's|^branch=.*|branch=task/T2-fixture|' "$STATE/dev.env" ;;
|
|
391
|
+
esac
|
|
392
|
+
damaged="$(sha "$STATE/dev.env")"
|
|
393
|
+
run resume --agent dev --dry-run
|
|
394
|
+
check "untrusted-recovery-refused:$fault" eq "$RC" 1
|
|
395
|
+
check "untrusted-recovery-record-pure:$fault" eq "$(sha "$STATE/dev.env")" "$damaged"
|
|
396
|
+
check "untrusted-recovery-no-launch:$fault" eq "$(sha "$TMP/argv.log")" "$argv_before"
|
|
397
|
+
done
|
|
398
|
+
cp -p "$TMP/trusted-assignment" "$STATE/dev.env"
|
|
399
|
+
run config set TEAM_TASK_MODELS 'analysis=vendor/new verify=vendor/verify' --yes
|
|
400
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --print
|
|
401
|
+
check deleted-routine-recovery eq "$RC" 0; check recovery-model contains "$OUT" 'vendor/strong:high'; check recovery-sid contains "$OUT" "$SID_A"
|
|
402
|
+
run dispatch verify T2 docs/team/tasks/T2-fixture.md --model vendor/strong:high --print
|
|
403
|
+
check new-unmapped-override-refused eq "$RC" 1
|
|
404
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --model vendor/strong:low --print
|
|
405
|
+
check suffix-change-requires-fresh eq "$RC" 1
|
|
406
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --fresh --print
|
|
407
|
+
check fresh-keeps-stored-model eq "$RC" 0; check fresh-model contains "$OUT" 'vendor/strong:high'
|
|
408
|
+
tmux_iso_require routing stop-fixture --tmpdir "$TMUX_TMPDIR" --sock-name "$LIVE_SOCKET" --own-root "$TMP" --own-root "$TMUX_TMPDIR"
|
|
409
|
+
(cd "$REPO" && tmux kill-window -t routing-fixture:dev)
|
|
410
|
+
run resume --agent dev --dry-run
|
|
411
|
+
check resume-stored-identity eq "$RC" 0; check resume-sid contains "$OUT" "$SID_A"
|
|
412
|
+
run resume --agent dev
|
|
413
|
+
check actual-resume-after-policy-removal eq "$RC" 0
|
|
414
|
+
check actual-resume-argv-exact python3 -c 'import json,sys; a=json.loads(open(sys.argv[1]).readlines()[-1]); assert a[a.index("--provider")+1]=="vendor" and a[a.index("--model")+1]=="strong:high" and a[a.index("--session-id")+1]==sys.argv[2]' "$TMP/argv-jsonl" "$SID_A"
|
|
415
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --fresh
|
|
416
|
+
check actual-same-model-fresh-after-policy-removal eq "$RC" 0
|
|
417
|
+
check actual-fresh-record team_assignment_load dev
|
|
418
|
+
SID_FRESH="${TEAM_ASSIGN[sid]:-missing}"
|
|
419
|
+
check actual-fresh-SID-different bash -c '[ "$1" != "$2" ]' _ "$SID_A" "$SID_FRESH"
|
|
420
|
+
(cd "$REPO" && tmux kill-window -t routing-fixture:dev)
|
|
421
|
+
run resume --agent dev
|
|
422
|
+
check actual-resume-retains-fresh-identity eq "$RC" 0
|
|
423
|
+
check actual-resume-fresh-argv-exact python3 -c 'import json,sys; a=json.loads(open(sys.argv[1]).readlines()[-1]); assert a[a.index("--provider")+1]=="vendor" and a[a.index("--model")+1]=="strong:high" and a[a.index("--session-id")+1]==sys.argv[2]' "$TMP/argv-jsonl" "$SID_FRESH"
|
|
424
|
+
(cd "$REPO" && tmux kill-window -t routing-fixture:dev)
|
|
425
|
+
fi
|
|
426
|
+
if has dispatch; then routing_publication_probes; fi
|
|
427
|
+
fi
|
|
428
|
+
# Hook only the owned fixture shell; shipped files are never modified by these faults.
|
|
429
|
+
hooked() {
|
|
430
|
+
(cd "$REPO" && timeout 45 bash --noprofile --norc -c '
|
|
431
|
+
CMD=dispatch; ARGS=()
|
|
432
|
+
source "$1/scripts/lib/common.sh"
|
|
433
|
+
for lib in "$1"/scripts/lib/cmd-*.sh; do source "$lib"; done
|
|
434
|
+
team_load_config || exit
|
|
435
|
+
source "$2"
|
|
436
|
+
shift 2; team_cmd_dispatch "$@"
|
|
437
|
+
' _ "$SKILL" "$TMP/hook.sh" "$@")
|
|
438
|
+
}
|
|
439
|
+
run_hook() { RC=0; effect_snapshot "before hook $*"; OUT="$(hooked "$@" 2>&1)" || RC=$?; printf 'hook rc=%s\n%s\n' "$RC" "$OUT"; effect_snapshot "after hook rc=$RC $*"; }
|
|
440
|
+
stop_fixture_seat() { (cd "$REPO" && tmux kill-window -t "routing-fixture:$1") 2>/dev/null || true; }
|
|
441
|
+
assignment_snapshot() { printf '%s:%s:%s' "$(sha "$STATE/dev.env")" "$(sha "$STATE/dev.pending")" "$(sha "$REPO/docs/team/BOARD.md")"; }
|
|
442
|
+
if has boundary; then
|
|
443
|
+
routing_template_probes
|
|
444
|
+
routing_pm_template_probes
|
|
445
|
+
routing_expansion_probes worker
|
|
446
|
+
routing_expansion_probes pm
|
|
447
|
+
routing_role_probes worker
|
|
448
|
+
routing_role_probes pm
|
|
449
|
+
routing_resume_role_probes
|
|
450
|
+
fi
|
|
451
|
+
if has limits || has transaction; then
|
|
452
|
+
run config set TEAM_TASK_MODELS 'routine=vendor/routine analysis=vendor/analysis verify=vendor/verify' --yes
|
|
453
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --model vendor/strong:high --fresh
|
|
454
|
+
check advanced-setup-recorded-launch eq "$RC" 0
|
|
455
|
+
fi
|
|
456
|
+
if has limits; then
|
|
457
|
+
run config set TEAM_MODEL_LIMITS 'vendor/*=1' --yes
|
|
458
|
+
snap="$(assignment_snapshot)"; argv_before="$(sha "$TMP/argv.log")"
|
|
459
|
+
run dispatch verify T2 docs/team/tasks/T2-fixture.md --model vendor/strong:high --print
|
|
460
|
+
check positive-full-model-cap eq "$RC" 1
|
|
461
|
+
run dispatch verify T2 docs/team/tasks/T2-fixture.md --model vendor/different --print
|
|
462
|
+
check wildcard-bucket-counts-actual-peer eq "$RC" 1
|
|
463
|
+
check cap-refusal-keeps-assignment eq "$(assignment_snapshot)" "$snap"
|
|
464
|
+
check cap-refusal-no-launch eq "$(sha "$TMP/argv.log")" "$argv_before"
|
|
465
|
+
run config set TEAM_MODEL_LIMITS 'vendor/*=1 vendor/strong:low=1' --yes
|
|
466
|
+
run dispatch verify T2 docs/team/tasks/T2-fixture.md --model vendor/strong:low --print
|
|
467
|
+
check exact-suffix-bucket-independent eq "$RC" 0
|
|
468
|
+
run config set TEAM_MODEL_LIMITS 'vendor/*=1 *=0' --yes
|
|
469
|
+
run dispatch verify T2 docs/team/tasks/T2-fixture.md --model vendor/different --print
|
|
470
|
+
check zero-wildcard-does-not-erase-positive-cap eq "$RC" 1
|
|
471
|
+
cp "$STATE/dev.env" "$TMP/known-dev.env"
|
|
472
|
+
python3 - "$STATE/dev.env" <<'PY'
|
|
473
|
+
import pathlib,sys
|
|
474
|
+
p=pathlib.Path(sys.argv[1]); p.write_text(''.join(x for x in p.read_text().splitlines(True) if not x.startswith('model=')))
|
|
475
|
+
PY
|
|
476
|
+
run dispatch verify T2 docs/team/tasks/T2-fixture.md --model vendor/strong:high --force --print
|
|
477
|
+
check unknown-live-peer-fail-closed-even-force eq "$RC" 1
|
|
478
|
+
check unknown-live-peer-named contains "$OUT" 'unknown=dev'
|
|
479
|
+
check unknown-live-peer-clear-route contains "$OUT" 'teardown --agent dev'
|
|
480
|
+
snap="$(assignment_snapshot)"; argv_before="$(sha "$TMP/argv.log")"
|
|
481
|
+
run dispatch verify T2 docs/team/tasks/T2-fixture.md --model vendor/strong:high --force
|
|
482
|
+
check unknown-live-peer-real-launch-refused eq "$RC" 1
|
|
483
|
+
check unknown-live-peer-real-record-preserved eq "$(assignment_snapshot)" "$snap"
|
|
484
|
+
check unknown-live-peer-real-no-launch eq "$(sha "$TMP/argv.log")" "$argv_before"
|
|
485
|
+
run config set TEAM_MODEL_LIMITS 'vendor/*=0' --yes
|
|
486
|
+
run dispatch verify T2 docs/team/tasks/T2-fixture.md --model vendor/strong:high --print
|
|
487
|
+
check unlimited-does-not-demand-peer-model eq "$RC" 0
|
|
488
|
+
cp "$TMP/known-dev.env" "$STATE/dev.env"
|
|
489
|
+
# P228/R6(OBS1):模板没交付模型的活跃同伴(identity_via 里没有 model)同样是「完整已提交模型身份不存在」
|
|
490
|
+
# —— 不得按记录里的选择计数,正/通配限额下都 fail-closed(同一车道,新的一格)。
|
|
491
|
+
run config set TEAM_MODEL_LIMITS 'vendor/*=1' --yes
|
|
492
|
+
sed -i 's/^identity_via=.*/identity_via=provider,session_id/' "$STATE/dev.env"
|
|
493
|
+
run dispatch verify T2 docs/team/tasks/T2-fixture.md --model vendor/strong:high --force --print
|
|
494
|
+
check undelivered-model-peer-fail-closed eq "$RC" 1
|
|
495
|
+
check undelivered-model-peer-named contains "$OUT" 'unknown=dev'
|
|
496
|
+
cp "$TMP/known-dev.env" "$STATE/dev.env"
|
|
497
|
+
run config set TEAM_MODEL_LIMITS 'vendor/*=0' --yes
|
|
498
|
+
check pm-does-not-consume-worker-bucket bash -c '
|
|
499
|
+
source "$1/scripts/lib/common.sh"; for lib in "$1"/scripts/lib/cmd-*.sh; do source "$lib"; done; team_load_config
|
|
500
|
+
TEAM_AGENTS="dev pm verify"; TEAM_MODEL_LIMITS="vendor/*=1"
|
|
501
|
+
team_agent_live() { return 0; }
|
|
502
|
+
team_model_peers vendor/strong:high verify
|
|
503
|
+
[ "$TEAM_MODEL_KNOWN_COUNT" = 1 ] && [ -z "$TEAM_MODEL_UNKNOWN" ]
|
|
504
|
+
' _ "$SKILL"
|
|
505
|
+
stop_fixture_seat dev; stop_fixture_seat verify
|
|
506
|
+
run config set TEAM_MODEL_LIMITS 'vendor/*=1' --yes
|
|
507
|
+
for a in dev verify; do
|
|
508
|
+
id=T1; [ "$a" != verify ] || id=T2
|
|
509
|
+
(cd "$REPO" && bash "$CLI" dispatch "$a" "$id" "docs/team/tasks/$id-fixture.md" --model vendor/strong:high --fresh > "$TMP/cap-$a.log" 2>&1; printf '%s' "$?" > "$TMP/cap-$a.rc") &
|
|
510
|
+
done
|
|
511
|
+
wait
|
|
512
|
+
check cross-seat-serialized-admission python3 -c 'import pathlib,sys; assert sorted(pathlib.Path(x).read_text() for x in sys.argv[1:])==["0","1"]' "$TMP/cap-dev.rc" "$TMP/cap-verify.rc"
|
|
513
|
+
windows="$(cd "$REPO" && tmux list-windows -t routing-fixture -F '#{window_name}')"
|
|
514
|
+
check cross-seat-only-one-worker-window eq "$(printf '%s\n' "$windows" | grep -cE '^(dev|verify)$')" 1
|
|
515
|
+
stop_fixture_seat dev; stop_fixture_seat verify
|
|
516
|
+
run config set TEAM_MODEL_LIMITS '' --yes
|
|
517
|
+
fi
|
|
518
|
+
if has transaction; then
|
|
519
|
+
stop_fixture_seat dev
|
|
520
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --model vendor/strong:high --fresh
|
|
521
|
+
check transaction-initial-complete eq "$RC" 0
|
|
522
|
+
# Both processes must finish preflight on the same old generation before either admits.
|
|
523
|
+
cat > "$TMP/hook.sh" <<'HOOK'
|
|
524
|
+
team_dispatch_judge_seat_hint() {
|
|
525
|
+
if [ "${_TEAM_DISPATCH_PREFLIGHT_ONLY:-0}" = 1 ]; then
|
|
526
|
+
printf ready > "$TEAM_MAIN_ROOT/barrier-$FIXTURE_ATTEMPT"
|
|
527
|
+
local i; for ((i=0;i<200;i++)); do
|
|
528
|
+
[ ! -f "$TEAM_MAIN_ROOT/barrier-a" ] || [ ! -f "$TEAM_MAIN_ROOT/barrier-b" ] || return 0
|
|
529
|
+
sleep 0.02
|
|
530
|
+
done
|
|
531
|
+
return 1
|
|
532
|
+
fi
|
|
533
|
+
}
|
|
534
|
+
HOOK
|
|
535
|
+
calls_before="$(grep -c -- '^--provider$' "$TMP/argv.log")"
|
|
536
|
+
(FIXTURE_ATTEMPT=a hooked dev T1 docs/team/tasks/T1-fixture.md --fresh > "$TMP/same-a.log" 2>&1; printf '%s' "$?" > "$TMP/same-a.rc") & p1=$!
|
|
537
|
+
(FIXTURE_ATTEMPT=b hooked dev T1 docs/team/tasks/T1-fixture.md --fresh > "$TMP/same-b.log" 2>&1; printf '%s' "$?" > "$TMP/same-b.rc") & p2=$!
|
|
538
|
+
wait "$p1" "$p2"
|
|
539
|
+
check same-seat-generation-race python3 -c 'import pathlib,sys; assert sorted(pathlib.Path(x).read_text() for x in sys.argv[1:])==["0","1"]' "$TMP/same-a.rc" "$TMP/same-b.rc"
|
|
540
|
+
check same-seat-loser-no-second-launch eq "$(( $(grep -c -- '^--provider$' "$TMP/argv.log") - calls_before ))" 1
|
|
541
|
+
rm -f "$REPO/barrier-a" "$REPO/barrier-b"
|
|
542
|
+
# External edit bypasses the CLI config lock: final snapshot must still reject it.
|
|
543
|
+
cp "$CONFIG" "$TMP/config-before-race"
|
|
544
|
+
cat > "$TMP/hook.sh" <<'HOOK'
|
|
545
|
+
eval "$(declare -f team_dispatch_final_snapshot | sed '1s/team_dispatch_final_snapshot/fixture_original_snapshot/')"
|
|
546
|
+
team_dispatch_final_snapshot() { printf '\n# external edit\n' >> "$TEAM_CONFIG"; fixture_original_snapshot "$@"; }
|
|
547
|
+
HOOK
|
|
548
|
+
snap="$(assignment_snapshot)"; argv_before="$(sha "$TMP/argv.log")"
|
|
549
|
+
run_hook dev T1 docs/team/tasks/T1-fixture.md --fresh
|
|
550
|
+
check final-config-snapshot-refused eq "$RC" 1
|
|
551
|
+
check final-config-snapshot-record-preserved eq "$(assignment_snapshot)" "$snap"
|
|
552
|
+
check final-config-snapshot-no-launch eq "$(sha "$TMP/argv.log")" "$argv_before"
|
|
553
|
+
cp "$TMP/config-before-race" "$CONFIG"
|
|
554
|
+
cp "$REPO/docs/team/tasks/T1-fixture.md" "$TMP/brief-before-race"
|
|
555
|
+
cat > "$TMP/hook.sh" <<'HOOK'
|
|
556
|
+
eval "$(declare -f team_dispatch_final_snapshot | sed '1s/team_dispatch_final_snapshot/fixture_original_snapshot/')"
|
|
557
|
+
team_dispatch_final_snapshot() { printf '\nexternal brief edit\n' >> "$TEAM_MAIN_ROOT/docs/team/tasks/T1-fixture.md"; fixture_original_snapshot "$@"; }
|
|
558
|
+
HOOK
|
|
559
|
+
run_hook dev T1 docs/team/tasks/T1-fixture.md --fresh
|
|
560
|
+
check final-brief-snapshot-refused eq "$RC" 1
|
|
561
|
+
check final-brief-snapshot-record-preserved eq "$(assignment_snapshot)" "$snap"
|
|
562
|
+
cp "$TMP/brief-before-race" "$REPO/docs/team/tasks/T1-fixture.md"
|
|
563
|
+
# Actual startup failure: owned recording executable exits 9, never a real provider.
|
|
564
|
+
run config set TEAM_AGENT_CMD "$TMP/recording-pi --provider {provider} --model {model} --session-id {session_id}" --yes
|
|
565
|
+
touch "$TMP/fail-launch"; old="$(sha "$STATE/dev.env")"
|
|
566
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --fresh
|
|
567
|
+
check failed-launch-refused eq "$RC" 1
|
|
568
|
+
check failed-launch-old-record-bytes eq "$(sha "$STATE/dev.env")" "$old"
|
|
569
|
+
check failed-launch-nonce-diagnostic bash -c 'test -n "$(find "$1" -name "dispatch-dev.failed-*" -print -quit)"' _ "$STATE"
|
|
570
|
+
rm -f "$TMP/fail-launch"
|
|
571
|
+
run config set TEAM_AGENT_CMD '' --yes
|
|
572
|
+
cat > "$TMP/hook.sh" <<'HOOK'
|
|
573
|
+
eval "$(declare -f team_wait_launch_proof | sed '1s/team_wait_launch_proof/fixture_original_wait/')"
|
|
574
|
+
team_wait_launch_proof() { fixture_original_wait "$1" "$2" 2 >/dev/null || return; printf 'stale-nonce %s\n' "$BASHPID" > "$(team_dispatch_spawn_file "$1")"; fixture_original_wait "$1" "$2" 0; }
|
|
575
|
+
HOOK
|
|
576
|
+
run_hook dev T1 docs/team/tasks/T1-fixture.md --fresh
|
|
577
|
+
check stale-launch-proof-refused eq "$RC" 1
|
|
578
|
+
check stale-launch-proof-old-record eq "$(sha "$STATE/dev.env")" "$old"
|
|
579
|
+
check stale-launch-proof-diagnostic grep -q 'failed=no nonce proof' "$STATE/dispatch-dev.attempts.log"
|
|
580
|
+
cat > "$TMP/hook.sh" <<'HOOK'
|
|
581
|
+
mv() { local last="${!#}"; [ "$last" != "$TEAM_STATE_DIR/dev.env" ] || return 1; command mv "$@"; }
|
|
582
|
+
HOOK
|
|
583
|
+
run_hook dev T1 docs/team/tasks/T1-fixture.md --fresh
|
|
584
|
+
check failed-publication-refused eq "$RC" 1
|
|
585
|
+
check failed-publication-old-record-bytes eq "$(sha "$STATE/dev.env")" "$old"
|
|
586
|
+
check failed-publication-no-worker-window bash -c '! tmux list-windows -t routing-fixture -F "#{window_name}" 2>/dev/null | grep -Fxq dev'
|
|
587
|
+
cat > "$TMP/hook.sh" <<'HOOK'
|
|
588
|
+
team_board_set() { return 1; }
|
|
589
|
+
HOOK
|
|
590
|
+
run_hook dev T1 docs/team/tasks/T1-fixture.md --fresh
|
|
591
|
+
check board-failure-after-commit-not-rollback eq "$RC" 0
|
|
592
|
+
check board-failure-complete-record team_assignment_load dev
|
|
593
|
+
check board-failure-new-generation bash -c '[ "$1" != "$2" ]' _ "$(sha "$STATE/dev.env")" "$old"
|
|
594
|
+
check board-failure-pending-matches eq "$(awk -F= '$1=="launch_nonce"{print $2}' "$STATE/dev.pending")" "${TEAM_ASSIGN[launch_nonce]:-missing}"
|
|
595
|
+
stop_fixture_seat dev
|
|
596
|
+
cat > "$TMP/hook.sh" <<'HOOK'
|
|
597
|
+
eval "$(declare -f team_dispatch_prepare_record | sed '1s/team_dispatch_prepare_record/fixture_original_prepare/')"
|
|
598
|
+
team_dispatch_prepare_record() { fixture_original_prepare "$@" || return; kill -TERM "$BASHPID"; }
|
|
599
|
+
HOOK
|
|
600
|
+
old="$(sha "$STATE/dev.env")"; run_hook dev T1 docs/team/tasks/T1-fixture.md --fresh
|
|
601
|
+
check interrupted-before-commit eq "$RC" 143
|
|
602
|
+
check interrupted-before-commit-old-record eq "$(sha "$STATE/dev.env")" "$old"
|
|
603
|
+
pending_nonce="$(awk -F= '$1=="launch_nonce"{print $2}' "$STATE/dev.pending")"
|
|
604
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --print
|
|
605
|
+
check interrupted-pending-requires-explicit-fresh eq "$RC" 1
|
|
606
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --fresh
|
|
607
|
+
check interrupted-pending-fresh-takeover eq "$RC" 0
|
|
608
|
+
check interrupted-pending-preserved test -f "$STATE/dispatch-dev.interrupted-$pending_nonce"
|
|
609
|
+
# Crash AFTER low-model proof but BEFORE rename: a past complete high-model record cannot identify that live peer.
|
|
610
|
+
cat > "$TMP/hook.sh" <<'HOOK'
|
|
611
|
+
mv() { local last="${!#}"; if [ "$last" = "$TEAM_STATE_DIR/dev.env" ]; then kill -TERM "$BASHPID"; else command mv "$@"; fi; }
|
|
612
|
+
HOOK
|
|
613
|
+
old="$(sha "$STATE/dev.env")"
|
|
614
|
+
run_hook dev T1 docs/team/tasks/T1-fixture.md --fresh --model vendor/strong:low
|
|
615
|
+
check interrupted-proven-unpublished-launch eq "$RC" 143
|
|
616
|
+
check interrupted-proven-old-record-bytes eq "$(sha "$STATE/dev.env")" "$old"
|
|
617
|
+
run config set TEAM_MODEL_LIMITS 'vendor/strong:low=1' --yes
|
|
618
|
+
run dispatch verify T2 docs/team/tasks/T2-fixture.md --model vendor/strong:low --fresh --force --print
|
|
619
|
+
check interrupted-peer-positive-cap-unjudgeable eq "$RC" 1
|
|
620
|
+
check interrupted-peer-current-nonce-mismatch contains "$OUT" 'unknown=dev (interrupted pending launch/assignment nonce mismatch)'
|
|
621
|
+
run config set TEAM_MODEL_LIMITS '' --yes
|
|
622
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --fresh
|
|
623
|
+
check interrupted-proven-fresh-takeover eq "$RC" 0
|
|
624
|
+
cat > "$TMP/hook.sh" <<'HOOK'
|
|
625
|
+
team_board_set() { kill -TERM "$BASHPID"; }
|
|
626
|
+
HOOK
|
|
627
|
+
run_hook dev T1 docs/team/tasks/T1-fixture.md --fresh
|
|
628
|
+
check interrupted-after-commit eq "$RC" 143
|
|
629
|
+
check interrupted-after-commit-complete team_assignment_load dev
|
|
630
|
+
committed_sid="${TEAM_ASSIGN[sid]:-missing}"
|
|
631
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --print
|
|
632
|
+
check interrupted-after-commit-recoverable eq "$RC" 0
|
|
633
|
+
check interrupted-after-commit-sid contains "$OUT" "$committed_sid"
|
|
634
|
+
# Close/teardown queued AFTER proof cannot kill/clear a provisional worker through the held seat lock.
|
|
635
|
+
for clear_command in teardown close; do
|
|
636
|
+
rm -f "$REPO/proof-ready" "$REPO/proof-release"
|
|
637
|
+
cat > "$TMP/hook.sh" <<'HOOK'
|
|
638
|
+
eval "$(declare -f team_wait_launch_proof | sed '1s/team_wait_launch_proof/fixture_original_wait/')"
|
|
639
|
+
team_wait_launch_proof() {
|
|
640
|
+
local got i; got="$(fixture_original_wait "$@")" || return
|
|
641
|
+
printf ready > "$TEAM_MAIN_ROOT/proof-ready"
|
|
642
|
+
for ((i=0;i<300;i++)); do [ ! -f "$TEAM_MAIN_ROOT/proof-release" ] || { printf '%s\n' "$got"; return 0; }; sleep 0.02; done
|
|
643
|
+
return 1
|
|
644
|
+
}
|
|
645
|
+
HOOK
|
|
646
|
+
old="$(sha "$STATE/dev.env")"
|
|
647
|
+
(hooked dev T1 docs/team/tasks/T1-fixture.md --fresh > "$TMP/proof-$clear_command-dispatch.log" 2>&1; printf '%s' "$?" > "$TMP/proof-$clear_command-dispatch.rc") & pending_pid=$!
|
|
648
|
+
for ((i=0;i<300;i++)); do [ ! -f "$REPO/proof-ready" ] || break; sleep 0.02; done
|
|
649
|
+
check "$clear_command-current-proof-held" test -f "$REPO/proof-ready"
|
|
650
|
+
if [ "$clear_command" = teardown ]; then args=(teardown --agent dev); else args=(close T1 --status dropped); fi
|
|
651
|
+
(cd "$REPO" && bash "$CLI" "${args[@]}" > "$TMP/proof-$clear_command-clear.log" 2>&1; printf '%s' "$?" > "$TMP/proof-$clear_command-clear.rc") & clear_pid=$!
|
|
652
|
+
sleep 0.3
|
|
653
|
+
check "$clear_command-waits-for-publication-lock" bash -c '[ ! -f "$1" ] && [ "$2" = "$3" ]' _ "$TMP/proof-$clear_command-clear.rc" "$(sha "$STATE/dev.env")" "$old"
|
|
654
|
+
touch "$REPO/proof-release"; wait "$pending_pid" "$clear_pid"
|
|
655
|
+
check "$clear_command-proof-dispatch-success" eq "$(<"$TMP/proof-$clear_command-dispatch.rc")" 0
|
|
656
|
+
check "$clear_command-queued-clear-success" eq "$(<"$TMP/proof-$clear_command-clear.rc")" 0
|
|
657
|
+
check "$clear_command-no-identity-resurrection" bash -c '[ ! -e "$1" ]' _ "$STATE/dev.env"
|
|
658
|
+
git -C "$REPO/.worktrees/dev" switch task/T1-fixture >/dev/null 2>&1
|
|
659
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --model vendor/strong:high --fresh
|
|
660
|
+
check "$clear_command-proof-fixture-restored" eq "$RC" 0
|
|
661
|
+
done
|
|
662
|
+
# Explicit teardown/close serialized against a dispatch paused BEFORE seat admission.
|
|
663
|
+
for clear_command in teardown close; do
|
|
664
|
+
rm -f "$REPO/clear-ready" "$REPO/clear-release"
|
|
665
|
+
cat > "$TMP/hook.sh" <<'HOOK'
|
|
666
|
+
team_dispatch_judge_seat_hint() {
|
|
667
|
+
if [ "${_TEAM_DISPATCH_PREFLIGHT_ONLY:-0}" = 1 ]; then
|
|
668
|
+
printf ready > "$TEAM_MAIN_ROOT/clear-ready"
|
|
669
|
+
local i; for ((i=0;i<250;i++)); do [ ! -f "$TEAM_MAIN_ROOT/clear-release" ] || return 0; sleep 0.02; done
|
|
670
|
+
return 1
|
|
671
|
+
fi
|
|
672
|
+
}
|
|
673
|
+
HOOK
|
|
674
|
+
(hooked dev T1 docs/team/tasks/T1-fixture.md --fresh > "$TMP/clear-$clear_command.log" 2>&1; printf '%s' "$?" > "$TMP/clear-$clear_command.rc") & p1=$!
|
|
675
|
+
for ((i=0;i<250;i++)); do [ ! -f "$REPO/clear-ready" ] || break; sleep 0.02; done
|
|
676
|
+
check "$clear_command-race-preflight-ready" test -f "$REPO/clear-ready"
|
|
677
|
+
if [ "$clear_command" = teardown ]; then run teardown --agent dev; else run close T1 --status dropped; fi
|
|
678
|
+
check "$clear_command-explicit-clear" eq "$RC" 0
|
|
679
|
+
touch "$REPO/clear-release"; wait "$p1"
|
|
680
|
+
check "$clear_command-race-no-resurrection" eq "$(<"$TMP/clear-$clear_command.rc")" 1
|
|
681
|
+
check "$clear_command-assignment-cleared" bash -c '! test -e "$1/dev.env"' _ "$STATE"
|
|
682
|
+
git -C "$REPO/.worktrees/dev" switch task/T1-fixture >/dev/null 2>&1
|
|
683
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --fresh --model vendor/strong:high
|
|
684
|
+
check "$clear_command-fixture-restored" eq "$RC" 0
|
|
685
|
+
done
|
|
686
|
+
# Deterministic generator forces both a recorded and an on-disk SID collision.
|
|
687
|
+
check collision-source-complete team_assignment_load dev
|
|
688
|
+
COLLISION_A="${TEAM_ASSIGN[sid]}"; dir="$(team_pi_session_dir "$REPO/.worktrees/dev")"; mkdir -p "$dir"
|
|
689
|
+
printf '{}' > "$dir/000_fixed-clock-history.jsonl"; printf 0 > "$TMP/candidate-count"
|
|
690
|
+
printf 'sid=fixed-clock-staged\n' > "$STATE/.assignment-collision-staged"
|
|
691
|
+
eval "$(declare -f team_sid_candidate | sed '1s/team_sid_candidate/fixture_original_candidate/')"
|
|
692
|
+
team_sid_candidate() {
|
|
693
|
+
local n; n="$(<"$TMP/candidate-count")"; n=$((n+1)); printf '%s' "$n" > "$TMP/candidate-count"
|
|
694
|
+
case "$n" in 1) printf '%s' "$COLLISION_A" ;; 2) printf fixed-clock-history ;; 3) printf fixed-clock-staged ;; *) printf fixed-clock-unique ;; esac
|
|
695
|
+
}
|
|
696
|
+
collision_sid="$(team_unique_sid dev "$REPO/.worktrees/dev")"
|
|
697
|
+
check forced-sid-collision-regenerated eq "$collision_sid" fixed-clock-unique
|
|
698
|
+
check forced-sid-collision-four-candidates eq "$(<"$TMP/candidate-count")" 4
|
|
699
|
+
eval "$(declare -f fixture_original_candidate | sed '1s/fixture_original_candidate/team_sid_candidate/')"
|
|
700
|
+
# Alive owners are not stolen; stale PID ownership is reclaimed with evidence.
|
|
701
|
+
check lock-owner-liveness-and-reclaim bash -c '
|
|
702
|
+
export TMPDIR="$2"; mkdir -p "$TMPDIR"; source "$1/scripts/lib/common.sh"
|
|
703
|
+
lock="$(team_lock_path seat:dev)"; mkdir -m 700 "$lock"
|
|
704
|
+
mine="$BASHPID"; printf "%s %s live\n" "$mine" "$(team_proc_start_identity "$mine")" > "$lock/owner"
|
|
705
|
+
TEAM_LOCK_WAIT_TICKS=1 team_with_lock seat:dev true && exit 1
|
|
706
|
+
printf "999999999 123 stale\n" > "$lock/owner"
|
|
707
|
+
team_with_lock seat:dev true || exit
|
|
708
|
+
test -n "$(find "$TMPDIR" -name "*.stale.*" -print -quit)"
|
|
709
|
+
' _ "$SKILL" "$TMP/lock-tests"
|
|
710
|
+
fi
|
|
711
|
+
if has sid-readers; then
|
|
712
|
+
mkdir -p "$STATE"; routing_fixture_record "$STATE" dev T1 "$REPO/.worktrees/dev" "$REPO/docs/team/tasks/T1-fixture.md" vendor/strong:high recorded-A explicit
|
|
713
|
+
dir="$(team_pi_session_dir "$REPO/.worktrees/dev")"; mkdir -p "$dir"
|
|
714
|
+
printf '{"type":"session","cwd":"%s"}\n{"type":"message","message":{"role":"assistant","stopReason":"error","errorMessage":"429 rate_limit_error","content":[]}}\n' "$REPO/.worktrees/dev" > "$dir/000_recorded-A.jsonl"
|
|
715
|
+
printf '{"type":"session"}\n{"type":"message","message":{"role":"assistant","stopReason":"error","errorMessage":"403 invalid_api_key","content":[]}}\n' > "$dir/999_newer-B.jsonl"
|
|
716
|
+
check reader-session-A contains "$(team_agent_session_cols dev)" recorded-A.jsonl
|
|
717
|
+
check reader-cause-A contains "$(team_agent_session_latest dev)" recorded-A.jsonl
|
|
718
|
+
OUT="$(node "$SKILL/scripts/monitor.mjs" --root "$REPO" --only dev --json)"
|
|
719
|
+
check reader-monitor-A contains "$OUT" recorded-A.jsonl
|
|
720
|
+
routing_reader_matrix
|
|
721
|
+
rm "$dir/000_recorded-A.jsonl"
|
|
722
|
+
check reader-missing-A-no-B bash -c '! [[ "$1" == *newer-B* ]]' _ "$(team_agent_session_cols dev)"
|
|
723
|
+
cp "$STATE/dev.env" "$TMP/reader-record"; rm "$STATE/dev.env"
|
|
724
|
+
check reader-no-record-no-newest-fallback bash -c '! [[ "$1" == *newer-B* ]]' _ "$(team_agent_session_cols dev)"
|
|
725
|
+
OUT="$(node "$SKILL/scripts/monitor.mjs" --root "$REPO" --only dev --json)"
|
|
726
|
+
check reader-no-record-monitor-unavailable bash -c '! [[ "$1" == *newer-B.jsonl* ]]' _ "$OUT"
|
|
727
|
+
cp "$TMP/reader-record" "$STATE/dev.env"
|
|
728
|
+
: > "$dir/000_recorded-A.jsonl"
|
|
729
|
+
check reader-fresh-zero-bytes eq "$(team_session_bytes recorded-A "$REPO/.worktrees/dev")" 0
|
|
730
|
+
printf '{"type":"message","message":{"role":"assistant","content":[{"type":"text","text":"later recorded A growth"}]}}\n' >> "$dir/000_recorded-A.jsonl"
|
|
731
|
+
check reader-later-A-growth bash -c '[ "$1" -gt 0 ]' _ "$(team_session_bytes recorded-A "$REPO/.worktrees/dev")"
|
|
732
|
+
check reader-growth-still-A contains "$(team_agent_session_cols dev)" recorded-A.jsonl
|
|
733
|
+
rm "$dir/000_recorded-A.jsonl"
|
|
734
|
+
OUT="$(node "$SKILL/scripts/monitor.mjs" --root "$REPO" --only dev --json)"
|
|
735
|
+
check monitor-missing-A-unavailable contains "$OUT" 'committed SID unavailable'
|
|
736
|
+
fi
|
|
737
|
+
if has init; then
|
|
738
|
+
# P235 · S3 的前门:新鲜 init/bootstrap 必须拿显式类别映射 + 独立 PM 模型;旧配置在任何写入之前拒绝。
|
|
739
|
+
# 所有命令走真 CLI(不是 source 库),每条都记命令/rc/输出到 init-cmds.log。
|
|
740
|
+
iclean=(env -u TEAM_ROOT -u TEAM_MAIN_ROOT -u TEAM_ROOT_SOURCE -u TEAM_ROOT_WAS -u TEAM_PROJECT \
|
|
741
|
+
-u TEAM_SESSION -u TEAM_SESSION_FROM -u TEAM_PM_WINDOW -u TEAM_AGENTS -u TEAM_DOCS_DIR \
|
|
742
|
+
-u TEAM_WORKTREES_DIR -u TEAM_GATES -u TEAM_VCS -u TEAM_CONFIG -u TEAM_CONFIG_FILE \
|
|
743
|
+
-u TEAM_STATE_DIR -u TEAM_SKILL_DIR -u TEAM_PULSE_WINDOW -u TEAM_MODEL_RETIRED_ENV)
|
|
744
|
+
i_new_repo() { # <dir>
|
|
745
|
+
rm -rf "$1"; mkdir -p "$1"
|
|
746
|
+
( cd "$1" && git init -q -b main && git config user.name fixture && git config user.email fixture@example.invalid \
|
|
747
|
+
&& printf '# init fixture\n' > README.md && git add -A && git commit -qm fixture ) >/dev/null 2>&1
|
|
748
|
+
}
|
|
749
|
+
i_run() { # <dir> <team args...>
|
|
750
|
+
local d="$1"; shift
|
|
751
|
+
RC=0; OUT="$( cd "$d" && "${iclean[@]}" bash "$CLI" "$@" 2>&1 )" || RC=$?
|
|
752
|
+
{ printf 'command='; printf '%q ' "$@"; printf '\nrc=%s\n%s\n' "$RC" "$OUT"; } >> "$TMP/init-cmds.log"
|
|
753
|
+
return 0
|
|
754
|
+
}
|
|
755
|
+
i_hash_tree() { find "$1" -type f -print0 2>/dev/null | sort -z | xargs -0 -r sha256sum | sha256sum | cut -d' ' -f1; }
|
|
756
|
+
|
|
757
|
+
# ① 显式输入逐字渲染,绝不猜:配置里只有新策略键 + 用户给的值
|
|
758
|
+
i_fresh="$TMP/init-fresh"; i_new_repo "$i_fresh"
|
|
759
|
+
i_run "$i_fresh" init --no-skills --session init-fresh --agents 'dev verify' --vcs local --gates true \
|
|
760
|
+
--task-models 'maintenance=vendor/light audit=vendor/audit:high' --pm-model 'vendor/pm:max'
|
|
761
|
+
check init-fresh-rc eq "$RC" 0
|
|
762
|
+
check init-fresh-map eq "$(grep -c "^TEAM_TASK_MODELS='maintenance=vendor/light audit=vendor/audit:high'\$" "$i_fresh/.pi/team/config.sh" || true)" 1
|
|
763
|
+
check init-fresh-pm eq "$(grep -c "^TEAM_PM_MODEL='vendor/pm:max'\$" "$i_fresh/.pi/team/config.sh" || true)" 1
|
|
764
|
+
check init-fresh-no-retired-key bash -c '! grep -qE "^(export )?TEAM_(DEFAULT_MODEL|AGENT_MODELS)=" "$1"' _ "$i_fresh/.pi/team/config.sh"
|
|
765
|
+
check init-fresh-ledger test -f "$i_fresh/docs/team/BOARD.md"
|
|
766
|
+
check init-fresh-protocol grep -qF '<!-- teamsmith:begin -->' "$i_fresh/AGENTS.md"
|
|
767
|
+
i_run "$i_fresh" config list --json
|
|
768
|
+
check init-fresh-machine python3 -c 'import json,sys; d=json.loads(sys.argv[1]); assert d["models"]["policy"]["categories"]==[{"category":"maintenance","model":"vendor/light"},{"category":"audit","model":"vendor/audit:high"}], d["models"]["policy"]["categories"]; assert d["models"]["policy"]["pm"]=="vendor/pm:max"' "$OUT"
|
|
769
|
+
|
|
770
|
+
# ② 缺输入在配置/账本/安装/工作树/state 任何写入之前拒绝;退休旗标给修正路线
|
|
771
|
+
i_missing="$TMP/init-missing"; i_new_repo "$i_missing"
|
|
772
|
+
i_run "$i_missing" init --no-skills --session init-missing --agents dev --vcs local --gates true
|
|
773
|
+
check init-missing-refused bash -c '[ "$1" != 0 ]' _ "$RC"
|
|
774
|
+
check init-missing-route contains "$OUT" '--task-models'
|
|
775
|
+
check init-missing-no-side-effect bash -c '! test -e "$1/.pi/team/config.sh" && ! test -e "$1/.pi/team/state" && ! test -e "$1/.pi/skills" && ! test -e "$1/docs/team" && ! test -e "$1/AGENTS.md"' _ "$i_missing"
|
|
776
|
+
i_run "$i_missing" bootstrap --no-pulse --agents dev
|
|
777
|
+
check init-bootstrap-missing-refused bash -c '[ "$1" != 0 ]' _ "$RC"
|
|
778
|
+
check init-bootstrap-missing-no-side-effect bash -c '! test -e "$1/.pi/team/config.sh" && ! test -e "$1/.pi/team/state" && ! test -e "$1/.pi/skills" && ! test -e "$1/docs/team" && ! test -e "$1/.worktrees"' _ "$i_missing"
|
|
779
|
+
i_run "$i_missing" init --no-skills --session init-missing --agents dev --model p/old
|
|
780
|
+
check init-retired-flag eq "$RC" 2
|
|
781
|
+
check init-retired-route contains "$OUT" 'upgrade-models'
|
|
782
|
+
|
|
783
|
+
# ③ 非法输入拒绝且不落盘
|
|
784
|
+
i_bad="$TMP/init-bad"; i_new_repo "$i_bad"
|
|
785
|
+
i_run "$i_bad" init --no-skills --session init-bad --agents dev --task-models 'notamap' --pm-model 'vendor/pm'
|
|
786
|
+
check init-bad-map eq "$RC" 4
|
|
787
|
+
i_run "$i_bad" init --no-skills --session init-bad --agents dev --task-models 'routine=vendor/light' --pm-model 'badshape'
|
|
788
|
+
check init-bad-pm eq "$RC" 4
|
|
789
|
+
check init-bad-no-config bash -c '! test -e "$1/.pi/team/config.sh"' _ "$i_bad"
|
|
790
|
+
|
|
791
|
+
# ④ 合法新策略项目可无输入重入(策略逐字节保留);显式输入与现有策略不同时必须拒绝而不是静默忽略
|
|
792
|
+
i_before="$(sha "$i_fresh/.pi/team/config.sh")"
|
|
793
|
+
i_run "$i_fresh" init --no-skills --session init-fresh --agents dev --vcs local
|
|
794
|
+
check init-reentry-rc eq "$RC" 0
|
|
795
|
+
check init-reentry-keeps-policy eq "$(sha "$i_fresh/.pi/team/config.sh")" "$i_before"
|
|
796
|
+
i_run "$i_fresh" init --no-skills --session init-fresh --agents dev --vcs local --task-models 'routine=other/x' --pm-model 'vendor/pm:max'
|
|
797
|
+
check init-reentry-different-refused eq "$RC" 4
|
|
798
|
+
check init-reentry-different-no-write eq "$(sha "$i_fresh/.pi/team/config.sh")" "$i_before"
|
|
799
|
+
|
|
800
|
+
# ⑤ 旧配置:init / init --force / bootstrap / bootstrap --print 全在写入之前拒绝;身份与账本哈希不变
|
|
801
|
+
i_legacy="$TMP/init-legacy"; i_new_repo "$i_legacy"
|
|
802
|
+
mkdir -p "$i_legacy/.pi/team" "$i_legacy/docs/team"
|
|
803
|
+
cat > "$i_legacy/.pi/team/config.sh" <<'EOF'
|
|
804
|
+
TEAM_PROJECT='init-legacy'
|
|
805
|
+
TEAM_SESSION='init-legacy'
|
|
806
|
+
TEAM_DOCS_DIR='docs/team'
|
|
807
|
+
TEAM_AGENTS='dev verify'
|
|
808
|
+
TEAM_AGENT_MODELS='dev=p/old'
|
|
809
|
+
TEAM_DEFAULT_MODEL='p/old'
|
|
810
|
+
TEAM_GATES='true'
|
|
811
|
+
TEAM_VCS='local'
|
|
812
|
+
EOF
|
|
813
|
+
printf '# BOARD legacy\n' > "$i_legacy/docs/team/BOARD.md"
|
|
814
|
+
i_cfg0="$(sha "$i_legacy/.pi/team/config.sh")"; i_led0="$(i_hash_tree "$i_legacy/docs")"
|
|
815
|
+
i_run "$i_legacy" init --no-skills --session init-legacy --agents dev
|
|
816
|
+
check init-legacy-plain-refused bash -c '[ "$1" != 0 ]' _ "$RC"
|
|
817
|
+
check init-legacy-plain-route contains "$OUT" 'upgrade-models'
|
|
818
|
+
# P261 返修(V35 F1/F2):拒绝建议是**从项目自身配置推导**出来的一条可粘贴命令,不是占位符;
|
|
819
|
+
# 两条路线都在(手工事务 + 启动事务)。逐字节断言推导映射(含兜底对)。
|
|
820
|
+
i_derived_cmd='config upgrade-models --task-models '\''dev=p/old default=p/old'\'' --pm-model '\''p/old'\'' --dry-run'
|
|
821
|
+
check init-legacy-plain-derived contains "$OUT" "$i_derived_cmd"
|
|
822
|
+
check init-legacy-plain-startup-route contains "$OUT" '路线 ② 启动事务'
|
|
823
|
+
check init-legacy-plain-no-placeholder bash -c '! [[ "$1" == *"<category=provider/model"* ]]' _ "$OUT"
|
|
824
|
+
i_run "$i_legacy" init --force --no-skills --session init-legacy --agents dev --task-models 'routine=p/new' --pm-model 'p/pm'
|
|
825
|
+
check init-legacy-force-refused bash -c '[ "$1" != 0 ]' _ "$RC"
|
|
826
|
+
check init-legacy-force-route contains "$OUT" 'upgrade-models'
|
|
827
|
+
check init-legacy-force-derived contains "$OUT" "$i_derived_cmd"
|
|
828
|
+
i_run "$i_legacy" bootstrap --no-pulse --agents dev
|
|
829
|
+
check init-legacy-bootstrap-refused bash -c '[ "$1" != 0 ]' _ "$RC"
|
|
830
|
+
# F1:bootstrap 曾只点名手工事务 —— 它必须与 init 同构(两条路线 + 推导命令)。
|
|
831
|
+
check init-legacy-bootstrap-derived contains "$OUT" "$i_derived_cmd"
|
|
832
|
+
check init-legacy-bootstrap-startup-route contains "$OUT" '路线 ② 启动事务'
|
|
833
|
+
i_run "$i_legacy" bootstrap --no-pulse --agents dev --print
|
|
834
|
+
check init-legacy-print-refused bash -c '[ "$1" != 0 ]' _ "$RC"
|
|
835
|
+
check init-legacy-print-readonly contains "$OUT" 'upgrade-models'
|
|
836
|
+
check init-legacy-print-derived contains "$OUT" "$i_derived_cmd"
|
|
837
|
+
# O1:config 写路径在退休配置上也拒绝(写下去就是半迁移状态),同样给推导命令、同样零字节。
|
|
838
|
+
i_run "$i_legacy" config set TEAM_NOTIFY_TMUX 1 --yes
|
|
839
|
+
check init-legacy-config-set-refused eq "$RC" 5
|
|
840
|
+
check init-legacy-config-set-derived contains "$OUT" "$i_derived_cmd"
|
|
841
|
+
check init-legacy-config-set-startup-route contains "$OUT" '路线 ② 启动事务'
|
|
842
|
+
check init-legacy-config-unchanged eq "$(sha "$i_legacy/.pi/team/config.sh")" "$i_cfg0"
|
|
843
|
+
check init-legacy-ledger-unchanged eq "$(i_hash_tree "$i_legacy/docs")" "$i_led0"
|
|
844
|
+
check init-legacy-no-side-effect bash -c '! test -e "$1/.pi/skills" && ! test -e "$1/.pi/team/state" && ! test -e "$1/.worktrees" && ! test -e "$1/AGENTS.md"' _ "$i_legacy"
|
|
845
|
+
# 端到端现场(返修要求):把拒绝打印的那条命令**原样**粘回去 —— --dry-run 零写入 → --yes 落地
|
|
846
|
+
# → config list rc=0。用独立副本,上面那些「契约字节没变」的断言才继续成立。
|
|
847
|
+
i_paste="$TMP/init-legacy-paste"; i_new_repo "$i_paste"; mkdir -p "$i_paste/.pi/team"
|
|
848
|
+
cp -p "$i_legacy/.pi/team/config.sh" "$i_paste/.pi/team/config.sh"
|
|
849
|
+
i_run "$i_paste" init --no-skills --session init-legacy --agents dev
|
|
850
|
+
check init-paste-refused bash -c '[ "$1" != 0 ]' _ "$RC"
|
|
851
|
+
i_pasted="$(printf '%s\n' "$OUT" | grep -o "config upgrade-models --task-models '[^']*' --pm-model '[^']*' --dry-run" | head -1)"
|
|
852
|
+
check init-paste-derived-exact eq "$i_pasted" "$i_derived_cmd"
|
|
853
|
+
p0="$(sha "$i_paste/.pi/team/config.sh")"
|
|
854
|
+
prc=0; ( cd "$i_paste" && "${iclean[@]}" bash -c "bash $(printf %q "$CLI") $i_pasted" ) >"$TMP/init-paste-dry.log" 2>&1 || prc=$?
|
|
855
|
+
check init-paste-dry-run-rc eq "$prc" 0
|
|
856
|
+
check init-paste-dry-run-pure eq "$(sha "$i_paste/.pi/team/config.sh")" "$p0"
|
|
857
|
+
prc=0; ( cd "$i_paste" && "${iclean[@]}" bash -c "bash $(printf %q "$CLI") ${i_pasted% --dry-run} --yes" ) >"$TMP/init-paste-yes.log" 2>&1 || prc=$?
|
|
858
|
+
check init-paste-yes-rc eq "$prc" 0
|
|
859
|
+
check init-paste-yes-map eq "$(grep -c "^TEAM_TASK_MODELS='dev=p/old default=p/old'\$" "$i_paste/.pi/team/config.sh" || true)" 1
|
|
860
|
+
check init-paste-yes-pm eq "$(grep -c "^TEAM_PM_MODEL='p/old'\$" "$i_paste/.pi/team/config.sh" || true)" 1
|
|
861
|
+
check init-paste-yes-retired-gone bash -c '! grep -qE "^TEAM_(AGENT_MODELS|DEFAULT_MODEL)=" "$1"' _ "$i_paste/.pi/team/config.sh"
|
|
862
|
+
i_run "$i_paste" config list
|
|
863
|
+
check init-paste-config-list eq "$RC" 0
|
|
864
|
+
# 推导不出来时:退回占位符 + 点名障碍(不许打印可能错的命令)—— 同一个拒绝面,同一个渲染器。
|
|
865
|
+
i_under="$TMP/init-legacy-underivable"; i_new_repo "$i_under"; mkdir -p "$i_under/.pi/team"
|
|
866
|
+
cp -p "$i_legacy/.pi/team/config.sh" "$i_under/.pi/team/config.sh"
|
|
867
|
+
sed -i "s/^TEAM_AGENT_MODELS=.*/TEAM_AGENT_MODELS='dev=notamodel'/" "$i_under/.pi/team/config.sh"
|
|
868
|
+
i_run "$i_under" init --no-skills --session init-legacy --agents dev
|
|
869
|
+
check init-underivable-refused bash -c '[ "$1" != 0 ]' _ "$RC"
|
|
870
|
+
check init-underivable-placeholder contains "$OUT" "--task-models '<category=provider/model"
|
|
871
|
+
check init-underivable-obstacle contains "$OUT" '推导不出建议映射'
|
|
872
|
+
check init-underivable-startup-route contains "$OUT" '路线 ② 启动事务'
|
|
873
|
+
check init-underivable-no-derived-map bash -c '! printf %s "$1" | grep -q "upgrade-models --task-models .dev="' _ "$OUT"
|
|
874
|
+
|
|
875
|
+
# ⑥ 新鲜 bootstrap:给输入才写;--print 只读
|
|
876
|
+
i_boot="$TMP/init-boot"; i_new_repo "$i_boot"
|
|
877
|
+
i_run "$i_boot" bootstrap --no-pulse --agents dev --task-models 'routine=vendor/light' --pm-model 'vendor/pm:high'
|
|
878
|
+
check init-bootstrap-fresh-rc eq "$RC" 0
|
|
879
|
+
check init-bootstrap-fresh-map eq "$(grep -c "^TEAM_TASK_MODELS='routine=vendor/light'\$" "$i_boot/.pi/team/config.sh" || true)" 1
|
|
880
|
+
check init-bootstrap-fresh-pm eq "$(grep -c "^TEAM_PM_MODEL='vendor/pm:high'\$" "$i_boot/.pi/team/config.sh" || true)" 1
|
|
881
|
+
i_print="$TMP/init-print"; i_new_repo "$i_print"
|
|
882
|
+
i_run "$i_print" bootstrap --no-pulse --print
|
|
883
|
+
check init-print-rc eq "$RC" 0
|
|
884
|
+
check init-print-no-writes bash -c '! test -e "$1/.pi/team" && ! test -e "$1/docs/team"' _ "$i_print"
|
|
885
|
+
|
|
886
|
+
# ⑦ 共享来源 vs 未链接的私有集成树:私有树里的 init/升级不碰保留源与链接;指南点名共享读取与四个门
|
|
887
|
+
i_shared="$TMP/shared-source"; rm -rf "$i_shared"; mkdir -p "$i_shared"
|
|
888
|
+
cp -a "$SKILL" "$i_shared/teamsmith"
|
|
889
|
+
i_shared0="$(i_hash_tree "$i_shared/teamsmith")"
|
|
890
|
+
ln -sfn "$i_shared/teamsmith" "$TMP/shared-link"
|
|
891
|
+
i_link0="$(readlink -f "$TMP/shared-link")"
|
|
892
|
+
i_private="$TMP/private-integration"; rm -rf "$i_private"; mkdir -p "$i_private/skills"
|
|
893
|
+
cp -a "$SKILL" "$i_private/skills/teamsmith"
|
|
894
|
+
i_repo="$TMP/init-private"; i_new_repo "$i_repo"
|
|
895
|
+
( cd "$i_repo" && "${iclean[@]}" bash "$i_private/skills/teamsmith/scripts/team" init --no-skills --session init-private \
|
|
896
|
+
--agents dev --vcs local --gates true --task-models 'routine=vendor/light' --pm-model 'vendor/pm' ) >/dev/null 2>&1
|
|
897
|
+
check init-private-rc eq "$?" 0
|
|
898
|
+
check init-private-shared-source-unchanged eq "$(i_hash_tree "$i_shared/teamsmith")" "$i_shared0"
|
|
899
|
+
check init-private-link-intact eq "$(readlink -f "$TMP/shared-link")" "$i_link0"
|
|
900
|
+
check init-guidance-shared-effect bash -c 'for f in "$1/references/migration.md" "$1/templates/pm-prompt.md.tmpl"; do grep -q "installer" "$f" && grep -qi "shared" "$f" || exit 1; done' _ "$SKILL"
|
|
901
|
+
check init-guidance-separate-gates bash -c 'grep -q '\''separate recorded gates'\'' "$1/references/migration.md" && grep -q '\''separate recorded gates'\'' "$1/templates/pm-prompt.md.tmpl"' _ "$SKILL"
|
|
902
|
+
check init-guidance-ownership-not-model bash -c 'grep -q "not a model" "$1/templates/OWNERSHIP.md.tmpl" && ! grep -qE "^\| Agent \| Model" "$1/templates/OWNERSHIP.md.tmpl"' _ "$SKILL"
|
|
903
|
+
fi
|
|
904
|
+
if has pm || has boundary; then
|
|
905
|
+
TEAM_TASK_MODELS='analysis=p/a verify=p/v'; TEAM_PM_MODEL='pm-provider/deep/model:high'; TEAM_PM_FRESH_LAUNCH=1
|
|
906
|
+
check pm-independent-model contains "$(team_pm_pi_args)" '--provider pm-provider --model deep/model:high'
|
|
907
|
+
for extra in '--model x/y' '--model=x/y' '--provider=other' '-m other' '--session=/tmp/f.jsonl' '-c' '-r' "$TMP/file.jsonl"; do
|
|
908
|
+
TEAM_PM_EXTRA_PI_ARGS="$extra"; rc=0; team_pm_identity_guard || rc=$?; check "boundary-reject:$extra" eq "$rc" 1
|
|
909
|
+
done
|
|
910
|
+
TEAM_PM_EXTRA_PI_ARGS='--no-tools'; check boundary-harmless team_pm_identity_guard
|
|
911
|
+
TEAM_PM_EXTRA_PI_ARGS=''; TEAM_PM_FRESH_LAUNCH=0
|
|
912
|
+
# P261(design §7):**缺记录 ≠ 记录不一致** —— 工具对过去没有主张,所以放行并记下「本次要登记」;
|
|
913
|
+
# 登记本身发生在成功启动之后(守卫不预写)。仍会拒绝的是**不可读**的记录(下一条)与值变了的记录
|
|
914
|
+
# (pm-suffix-change-needs-fresh / pm-changed-resume-selector-needs-fresh)。
|
|
915
|
+
rm -f "$STATE/pm-launch.env"; rc=0; TEAM_PM_IDENTITY_REGISTER=0; team_pm_identity_guard || rc=$?
|
|
916
|
+
check pm-missing-record-registers eq "$rc" 0
|
|
917
|
+
check pm-missing-record-flags-registration eq "${TEAM_PM_IDENTITY_REGISTER:-}" 1
|
|
918
|
+
check pm-missing-record-not-precreated bash -c '[ ! -e "$1" ]' _ "$STATE/pm-launch.env"
|
|
919
|
+
printf 'not a launch record\n' > "$STATE/pm-launch.env"; rc=0; team_pm_identity_guard || rc=$?
|
|
920
|
+
check pm-unreadable-record-needs-fresh eq "$rc" 1
|
|
921
|
+
rm -f "$STATE/pm-launch.env"
|
|
922
|
+
TEAM_PM_FRESH_LAUNCH=1; team_pm_metadata_publish test-nonce
|
|
923
|
+
# P228/R6(OBS1):PM 记录也发布实际交付的身份字段(与 worker 同一份判据);成功行只声明已交付的
|
|
924
|
+
TEAM_PM_CMD="$TMP/recording-pi --model {model} {prompt}"; TEAM_PM_FRESH_LAUNCH=1
|
|
925
|
+
team_pm_metadata_publish fixture-partial-pm
|
|
926
|
+
check pm-partial-publication-record eq "$(grep '^identity_via=' "$STATE/pm-launch.env" | cut -d= -f2-)" 'model'
|
|
927
|
+
check pm-partial-publication-claim contains "$(TEAM_PM_MODEL='pm-provider/deep/model:high'; team_pm_identity_claim)" 'model=pm-provider/deep/model:high'
|
|
928
|
+
TEAM_PM_CMD="$TMP/recording-pi --ask {prompt}"; TEAM_PM_FRESH_LAUNCH=1
|
|
929
|
+
team_pm_metadata_publish fixture-opaque-pm
|
|
930
|
+
check pm-opaque-publication-record eq "$(grep '^identity_via=' "$STATE/pm-launch.env" | cut -d= -f2-)" ''
|
|
931
|
+
check pm-opaque-publication-claim contains "$(TEAM_PM_MODEL='pm-provider/deep/model:high'; team_pm_identity_claim)" 'model 未由模板交付'
|
|
932
|
+
TEAM_PM_CMD=''; TEAM_PM_FRESH_LAUNCH=1; team_pm_metadata_publish test-nonce
|
|
933
|
+
TEAM_PM_FRESH_LAUNCH=0; check pm-known-continues team_pm_identity_guard
|
|
934
|
+
routing_pm_metadata_matrix
|
|
935
|
+
TEAM_PM_MODEL='pm-provider/deep/model:low'; rc=0; team_pm_identity_guard || rc=$?; check pm-suffix-change-needs-fresh eq "$rc" 1
|
|
936
|
+
TEAM_PM_FRESH_LAUNCH=1; check pm-suffix-explicit-fresh team_pm_identity_guard
|
|
937
|
+
TEAM_PM_MODEL='pm-provider/deep/model:high'; TEAM_PM_FRESH_LAUNCH=0
|
|
938
|
+
TEAM_PM_SESSION_ID=unrecorded-sid; rc=0; team_pm_identity_guard || rc=$?; check pm-changed-resume-selector-needs-fresh eq "$rc" 1
|
|
939
|
+
TEAM_PM_SESSION_ID=''; TEAM_PM_FRESH_LAUNCH=1
|
|
940
|
+
TEAM_PM_RESUME_ARGS='--model wrong/model'; rc=0; team_pm_identity_guard || rc=$?; check pm-resume-args-cannot-shadow-model eq "$rc" 1
|
|
941
|
+
TEAM_PM_RESUME_ARGS=''
|
|
942
|
+
pm_no_respawn_guard() (
|
|
943
|
+
team_pm_window_exists() { return 0; }
|
|
944
|
+
team_pm_starting() { [ "$1" = ignored ]; } # replaced per arm below
|
|
945
|
+
team_tmux_respawn_pane() { touch "$TMP/pm-unexpected-respawn"; return 1; }
|
|
946
|
+
if [ "$1" = starting ]; then
|
|
947
|
+
team_pm_starting() { return 0; }
|
|
948
|
+
team_pm_starting_age() { printf '1\n'; }
|
|
949
|
+
team_pm_evidence() { printf 'owned test starting marker\n'; }
|
|
950
|
+
else
|
|
951
|
+
team_pm_starting() { return 1; }
|
|
952
|
+
team_pm_state() { printf 'running:owned-test-process\n'; }
|
|
953
|
+
fi
|
|
954
|
+
team_pm_start && [ ! -e "$TMP/pm-unexpected-respawn" ]
|
|
955
|
+
)
|
|
956
|
+
check pm-running-not-respawned pm_no_respawn_guard running
|
|
957
|
+
check pm-starting-not-respawned pm_no_respawn_guard starting
|
|
958
|
+
pm_publication_failure() (
|
|
959
|
+
old="$(sha "$STATE/pm-launch.env")"
|
|
960
|
+
team_pm_window_exists() { return 0; }
|
|
961
|
+
team_pm_starting() { return 1; }
|
|
962
|
+
team_pm_state() { printf 'idle:test\n'; }
|
|
963
|
+
team_pm_check_launch() { return 0; }
|
|
964
|
+
team_pm_check_bin() { return 0; }
|
|
965
|
+
team_pm_write_prompt() { printf '%s\n' "$TMP/pm-fixture-prompt"; }
|
|
966
|
+
team_pm_launch_cmd() { printf 'sleep 300\n'; }
|
|
967
|
+
team_pm_pane_agent_pid() { tmux display-message -p -t routing-fixture:pm '#{pane_pid}'; }
|
|
968
|
+
team_pm_launch_diag() { printf 'publication failure before stop\n' > "$TMP/pm-publication-diagnostic"; }
|
|
969
|
+
mv() { return 1; }
|
|
970
|
+
# The recording launcher owns an idle pm window already; do not create an ambiguous duplicate name.
|
|
971
|
+
if ! tmux list-windows -t routing-fixture -F '#{window_name}' | grep -Fxq pm; then
|
|
972
|
+
tmux new-window -d -t routing-fixture -n pm 'sleep 300' || return 1
|
|
973
|
+
fi
|
|
974
|
+
tmux list-windows -t routing-fixture -F '#{window_name} #{pane_id}' > "$TMP/pm-windows-before.log"
|
|
975
|
+
rc=0; team_pm_start || rc=$?
|
|
976
|
+
printf 'pm start rc=%s\n' "$rc" > "$TMP/pm-rollback-result.log"
|
|
977
|
+
[ "$rc" = 1 ] && [ "$(sha "$STATE/pm-launch.env")" = "$old" ] &&
|
|
978
|
+
[ -s "$TMP/pm-publication-diagnostic" ] && [ ! -e "$STATE/pm.pid" ] &&
|
|
979
|
+
[ ! -e "$STATE/pm.pid.proof" ] && ! tmux list-windows -t routing-fixture -F '#{window_name}' 2>/dev/null | grep -Fxq pm
|
|
980
|
+
)
|
|
981
|
+
if [ -n "${LIVE_SOCKET:-}" ]; then check pm-publication-failure-stops-uncommitted pm_publication_failure; fi
|
|
982
|
+
fi
|
|
983
|
+
# ---------------------------------------------------------------- heal / adopt / updatecheck(P261 · startup-self-heal)
|
|
984
|
+
# 三个前门共用一份「干净环境 + 私有 tmux 通道」的现场:真实 `team up` 会把 PM 拉起来(夹具自己的
|
|
985
|
+
# recording-pi),所以私有 socket 与私有 $TMP/bin/tmux 是前提(与 preview/boundary 组同一形状)。
|
|
986
|
+
# 真 tmux 的解析要跳过**包装层**:PATH 里可能已经有 teamsmith shim(本套件在启动时会清掉
|
|
987
|
+
# */scripts/shim,但调用方环境未必)或本套件自己刚装的私有 socket 包装($TMP/bin/tmux)。
|
|
988
|
+
# type -P 会欣然把包装当「真 tmux」返回,于是包装再包一层包装 —— 每次递归都追加一个 -L,最后
|
|
989
|
+
# 参数表撑爆(P261 实测:--select 里同时给 dispatch 与 heal 时就撞上)。
|
|
990
|
+
routing_real_tmux() {
|
|
991
|
+
local c
|
|
992
|
+
while IFS= read -r c; do
|
|
993
|
+
case "$c" in "$TMP"/*|*/scripts/shim/*) continue ;; esac
|
|
994
|
+
printf '%s\n' "$c"; return 0
|
|
995
|
+
done < <(type -a -p tmux 2>/dev/null)
|
|
996
|
+
return 1
|
|
997
|
+
}
|
|
998
|
+
if has heal || has adopt || has updatecheck; then
|
|
999
|
+
# preview/boundary 那一块(前面)可能已经装好了**同一条私有通道** —— 复用它,绝不在包装上再包一层。
|
|
1000
|
+
if [ -n "${LIVE_SOCKET:-}" ] && [ -x "$TMP/bin/tmux" ]; then
|
|
1001
|
+
STARTUP_TMUX_OWN=0
|
|
1002
|
+
else
|
|
1003
|
+
STARTUP_TMUX_OWN=1; STARTUP_PATH0="$PATH"
|
|
1004
|
+
LIVE_SOCKET="routing-${BASHPID}-${RANDOM}"
|
|
1005
|
+
TMUX_TMPDIR="$(tmp_root_socket_dir routing "tmux-$(id -u)/routing-999999-99999")" \
|
|
1006
|
+
|| TMUX_TMPDIR="$TMP/tmux"
|
|
1007
|
+
export TMUX_TMPDIR; mkdir -p "$TMUX_TMPDIR" "$TMP/bin"
|
|
1008
|
+
REAL_TMUX="$(routing_real_tmux)" || { printf 'routing: 找不到真 tmux\n' >&2; exit 3; }
|
|
1009
|
+
printf '#!/usr/bin/env bash\nexec %q -L %q "$@"\n' "$REAL_TMUX" "$LIVE_SOCKET" > "$TMP/bin/tmux"; chmod +x "$TMP/bin/tmux"
|
|
1010
|
+
export PATH="$TMP/bin:$PATH"
|
|
1011
|
+
fi
|
|
1012
|
+
tmux_iso_require routing launch --tmpdir "$TMUX_TMPDIR" --sock-name "$LIVE_SOCKET" --own-root "$TMP" --own-root "$TMUX_TMPDIR"
|
|
1013
|
+
fi
|
|
1014
|
+
startup_clean=(env -u TEAM_ROOT -u TEAM_MAIN_ROOT -u TEAM_ROOT_SOURCE -u TEAM_ROOT_WAS -u TEAM_PROJECT \
|
|
1015
|
+
-u TEAM_SESSION -u TEAM_SESSION_FROM -u TEAM_PM_WINDOW -u TEAM_AGENTS -u TEAM_DOCS_DIR \
|
|
1016
|
+
-u TEAM_WORKTREES_DIR -u TEAM_GATES -u TEAM_VCS -u TEAM_CONFIG -u TEAM_CONFIG_FILE \
|
|
1017
|
+
-u TEAM_STATE_DIR -u TEAM_SKILL_DIR -u TEAM_PULSE_WINDOW -u TEAM_MODEL_RETIRED_ENV -u TEAM_UPDATE_CHECK)
|
|
1018
|
+
s_run() { # <dir> [VAR=VAL…] -- <team args…>:真 CLI、干净环境、私有 PATH
|
|
1019
|
+
local d="$1"; shift
|
|
1020
|
+
local -a extra=()
|
|
1021
|
+
while [ $# -gt 0 ] && [ "$1" != '--' ]; do extra+=("$1"); shift; done
|
|
1022
|
+
[ "${1:-}" = '--' ] && shift
|
|
1023
|
+
RC=0; OUT="$( cd "$d" && "${startup_clean[@]}" "${extra[@]}" timeout 60 bash "$CLI" "$@" 2>&1 )" || RC=$?
|
|
1024
|
+
printf 'command=%q ' "$@"; printf '\nrc=%s\n%s\n' "$RC" "$OUT"
|
|
1025
|
+
}
|
|
1026
|
+
s_new_repo() { # <dir>
|
|
1027
|
+
rm -rf "$1"; mkdir -p "$1/.pi/team" "$1/docs/team/tasks" "$1/docs/team/reports" "$1/docs/team/threads" "$1/docs/team/inbox" "$1/docs/team/reviews"
|
|
1028
|
+
( cd "$1" && git init -q -b main && git config user.name fixture && git config user.email fixture@example.invalid \
|
|
1029
|
+
&& printf '# startup fixture\n' > README.md && git add -A && git commit -qm fixture ) >/dev/null 2>&1
|
|
1030
|
+
}
|
|
1031
|
+
s_backups() { find "$1/.pi/team/state/config-backups" -maxdepth 1 -type f -name 'config.sh.pre-*' 2>/dev/null | wc -l | tr -d ' '; }
|
|
1032
|
+
s_audit() { if [ -f "$1/.pi/team/state/config.log" ]; then sha "$1/.pi/team/state/config.log"; else printf absent; fi; }
|
|
1033
|
+
s_stop_pm() { # <dir> <session>:停掉夹具自己的 PM(私有 socket 与私有 session),等到 up --print 不再放行
|
|
1034
|
+
tmux -L "$LIVE_SOCKET" kill-session -t "$2" 2>/dev/null || true
|
|
1035
|
+
local i
|
|
1036
|
+
for i in 1 2 3 4 5 6 7 8 9 10; do
|
|
1037
|
+
s_run "$1" -- up --print
|
|
1038
|
+
[ "$RC" != 0 ] && break
|
|
1039
|
+
sleep 0.5
|
|
1040
|
+
done
|
|
1041
|
+
}
|
|
1042
|
+
s_brief() { # <dir> <id> <category>
|
|
1043
|
+
cat > "$1/docs/team/tasks/$2-fixture.md" <<EOF
|
|
1044
|
+
# $2 · fixture
|
|
1045
|
+
agent: dev
|
|
1046
|
+
phase: apply
|
|
1047
|
+
category: $3
|
|
1048
|
+
change: -
|
|
1049
|
+
anchor: none (infra) — isolated startup fixture
|
|
1050
|
+
branch: task/$2-fixture
|
|
1051
|
+
## Scope
|
|
1052
|
+
No real provider. The brief only exists so dispatch can resolve its category.
|
|
1053
|
+
EOF
|
|
1054
|
+
mkdir -p "$1/.worktrees"
|
|
1055
|
+
( cd "$1" && git worktree add -qb "task/$2-fixture" ".worktrees/dev" ) >/dev/null 2>&1 || true
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
if has heal; then
|
|
1059
|
+
H="$TMP/heal"; s_new_repo "$H"
|
|
1060
|
+
cat > "$H/.pi/team/config.sh" <<EOF
|
|
1061
|
+
TEAM_PROJECT='heal-fixture'
|
|
1062
|
+
TEAM_SESSION='routing-heal'
|
|
1063
|
+
TEAM_PM_WINDOW='pm'
|
|
1064
|
+
TEAM_DOCS_DIR='docs/team'
|
|
1065
|
+
TEAM_AGENTS='dev verify'
|
|
1066
|
+
TEAM_AGENT_MODELS='dev=vendor/light verify=vendor/strong:high'
|
|
1067
|
+
TEAM_DEFAULT_MODEL='vendor/base'
|
|
1068
|
+
TEAM_PM_MODEL='vendor/pm:high'
|
|
1069
|
+
TEAM_WORKTREES_DIR='.worktrees'
|
|
1070
|
+
TEAM_VCS='local'
|
|
1071
|
+
TEAM_GATES='true'
|
|
1072
|
+
TEAM_MIN_FREE_SWAP_MB=0
|
|
1073
|
+
TEAM_MIN_TOTAL_MB=0
|
|
1074
|
+
TEAM_MIN_AVAIL_MB=0
|
|
1075
|
+
TEAM_TMP_MIN_FREE_MB=0
|
|
1076
|
+
TEAM_TMP_MIN_FREE_INODES=0
|
|
1077
|
+
TEAM_MODEL_LIMITS=''
|
|
1078
|
+
TEAM_UPDATE_CHECK=0
|
|
1079
|
+
TEAM_PI_BIN='$TMP/recording-pi'
|
|
1080
|
+
EOF
|
|
1081
|
+
s_brief "$H" H1 default
|
|
1082
|
+
cp -p "$H/.pi/team/config.sh" "$TMP/heal-original"
|
|
1083
|
+
# ① --print:同一份预告、一个字节都不写(配置 hash / 备份目录 / 审计 / 身份记录四不变)
|
|
1084
|
+
h0="$(sha "$H/.pi/team/config.sh")"; hb0="$(s_backups "$H")"; ha0="$(s_audit "$H")"
|
|
1085
|
+
s_run "$H" -- up --print
|
|
1086
|
+
check heal-print-rc eq "$RC" 0
|
|
1087
|
+
check heal-print-pairs bash -c '[[ "$1" == *"TEAM_AGENT_MODELS dev=vendor/light → TEAM_TASK_MODELS dev=vendor/light"* && "$1" == *"TEAM_DEFAULT_MODEL vendor/base → TEAM_TASK_MODELS default=vendor/base"* && "$1" == *"TEAM_PM_MODEL vendor/pm:high → TEAM_PM_MODEL vendor/pm:high"* ]]' _ "$OUT"
|
|
1088
|
+
check heal-print-backup contains "$OUT" 'config-backups/config.sh.pre-0.2.0-'
|
|
1089
|
+
check heal-print-restore contains "$OUT" '还原:cp '
|
|
1090
|
+
check heal-print-identity-preview contains "$OUT" '身份预告:此前没有启动记录'
|
|
1091
|
+
check heal-print-skip-npm contains "$OUT" '--print 下不联网、不写缓存'
|
|
1092
|
+
check heal-print-pure bash -c '[ "$1" = "$2" ] && [ "$3" = "$4" ] && [ "$5" = "$6" ] && [ ! -e "$7" ]' _ \
|
|
1093
|
+
"$(sha "$H/.pi/team/config.sh")" "$h0" "$(s_backups "$H")" "$hb0" "$(s_audit "$H")" "$ha0" "$H/.pi/team/state/pm-launch.env"
|
|
1094
|
+
# ② --no-migrate:不写、拒绝、给出可粘贴命令;粘回去 --dry-run 必须绿(P253 的吸收要求)
|
|
1095
|
+
s_run "$H" -- up --no-migrate
|
|
1096
|
+
check heal-nomigrate-refused bash -c '[ "$1" != 0 ]' _ "$RC"
|
|
1097
|
+
check heal-nomigrate-command contains "$OUT" "--task-models 'dev=vendor/light verify=vendor/strong:high default=vendor/base'"
|
|
1098
|
+
check heal-nomigrate-manual-route contains "$OUT" 'config upgrade-models'
|
|
1099
|
+
check heal-nomigrate-pure bash -c '[ "$1" = "$2" ] && [ "$3" = "$4" ]' _ \
|
|
1100
|
+
"$(sha "$H/.pi/team/config.sh")" "$h0" "$(s_backups "$H")" "$hb0"
|
|
1101
|
+
heal_derived="$(printf '%s\n' "$OUT" | awk -F"'" '/^ *--task-models /{print $2}' | head -1)"
|
|
1102
|
+
heal_derived_pm="$(printf '%s\n' "$OUT" | awk -F"'" '/^ *--pm-model /{print $2}' | head -1)"
|
|
1103
|
+
check heal-nomigrate-derived-nonempty bash -c '[ -n "$1" ] && [ -n "$2" ]' _ "$heal_derived" "$heal_derived_pm"
|
|
1104
|
+
s_run "$H" -- config upgrade-models --task-models "$heal_derived" --pm-model "$heal_derived_pm" --dry-run
|
|
1105
|
+
check heal-nomigrate-command-pasted eq "$RC" 0
|
|
1106
|
+
check heal-nomigrate-paste-pure eq "$(sha "$H/.pi/team/config.sh")" "$h0"
|
|
1107
|
+
# ③ 真跑:迁移 + 身份登记 + 启动(rc=0),逐键表、备份、审计、形状号、登记行、派单按类别选模型
|
|
1108
|
+
s_run "$H" -- up
|
|
1109
|
+
check heal-migrate-rc eq "$RC" 0
|
|
1110
|
+
check heal-migrate-pairs bash -c '[[ "$1" == *"TEAM_AGENT_MODELS verify=vendor/strong:high → TEAM_TASK_MODELS verify=vendor/strong:high"* ]]' _ "$OUT"
|
|
1111
|
+
check heal-migrate-values eq "$(grep -c "^TEAM_TASK_MODELS='dev=vendor/light verify=vendor/strong:high default=vendor/base'\$" "$H/.pi/team/config.sh" || true)" 1
|
|
1112
|
+
check heal-migrate-pm-eq eq "$(grep -c "^TEAM_PM_MODEL='vendor/pm:high'\$" "$H/.pi/team/config.sh" || true)" 1
|
|
1113
|
+
check heal-migrate-retired-gone bash -c '! grep -qE "^TEAM_(AGENT_MODELS|DEFAULT_MODEL)=" "$1"' _ "$H/.pi/team/config.sh"
|
|
1114
|
+
check heal-migrate-shape-number eq "$(grep -c "^TEAM_CONFIG_VERSION='2'\$" "$H/.pi/team/config.sh" || true)" 1
|
|
1115
|
+
check heal-migrate-restore-printed contains "$OUT" '还原:cp '
|
|
1116
|
+
check heal-backup-exists eq "$(s_backups "$H")" 1
|
|
1117
|
+
check heal-backup-name bash -c 'ls "$1"/.pi/team/state/config-backups/ | grep -q "^config.sh.pre-0.2.0-[0-9]*T[0-9]*Z\$"' _ "$H"
|
|
1118
|
+
check heal-backup-bytes bash -c 'cmp -s "$(ls "$1"/.pi/team/state/config-backups/config.sh.pre-* | head -1)" "$2"' _ "$H" "$TMP/heal-original"
|
|
1119
|
+
# 备份只保留最新 5 份(备份是恢复手段,不是档案)—— 直接调写入器再写 7 份,数一次。
|
|
1120
|
+
( TEAM_STATE_DIR="$H/.pi/team/state" TEAM_MIGRATION_FROM=1
|
|
1121
|
+
for i in 1 2 3 4 5 6 7; do team_config_backup_write "$TMP/heal-original" "2026010${i}T000000Z" >/dev/null || exit 1; done )
|
|
1122
|
+
check heal-backup-keeps-five eq "$(s_backups "$H")" 5
|
|
1123
|
+
check heal-backup-keeps-newest bash -c 'ls "$1"/.pi/team/state/config-backups/ | sort | head -1 | grep -q "20260104T000000Z"' _ "$H"
|
|
1124
|
+
check heal-audit-actor contains "$(tail -1 "$H/.pi/team/state/config.log")" 'actor=up-migration'
|
|
1125
|
+
check heal-audit-shape contains "$(tail -1 "$H/.pi/team/state/config.log")" 'TEAM_CONFIG_VERSION'
|
|
1126
|
+
check heal-registration-line contains "$OUT" '已登记本次启动身份:model=vendor/pm:high resume_key=default'
|
|
1127
|
+
check heal-registration-record bash -c 'grep -qx "model=vendor/pm:high" "$1" && grep -qx "mode=continued" "$1"' _ "$H/.pi/team/state/pm-launch.env"
|
|
1128
|
+
s_run "$H" -- config list
|
|
1129
|
+
check heal-config-list eq "$RC" 0
|
|
1130
|
+
s_run "$H" -- dispatch dev H1 docs/team/tasks/H1-fixture.md --print
|
|
1131
|
+
check heal-dispatch-category eq "$RC" 0
|
|
1132
|
+
check heal-dispatch-model contains "$OUT" 'category=default model=vendor/base'
|
|
1133
|
+
cp -p "$H/.pi/team/config.sh" "$TMP/heal-migrated"
|
|
1134
|
+
# ④ 迁移后 --print 给出完整启动预览(不再是迁移预告)
|
|
1135
|
+
s_run "$H" -- up --print
|
|
1136
|
+
check heal-print-complete contains "$OUT" '完整命令:'
|
|
1137
|
+
check heal-print-complete-identity contains "$OUT" '身份预告:记录与当前解析一致'
|
|
1138
|
+
check heal-print-complete-no-migration bash -c '! [[ "$1" == *"检测到旧形状配置"* ]]' _ "$OUT"
|
|
1139
|
+
# ⑤ 失败关闭:rc 非 0、配置 hash 不变、备份不增、审计不变、点名障碍(design §4)
|
|
1140
|
+
# 行前缀 "-" = 先删掉那个键的行(替换而不是制造重复键)。
|
|
1141
|
+
heal_refusal() { # <name> <期望命中的障碍文本> <config 变更行…>
|
|
1142
|
+
local name="$1" want="$2"; shift 2
|
|
1143
|
+
cp -p "$TMP/heal-original" "$H/.pi/team/config.sh"
|
|
1144
|
+
local line
|
|
1145
|
+
for line in "$@"; do
|
|
1146
|
+
case "$line" in
|
|
1147
|
+
-*) sed -i "/^${line#-}=/d" "$H/.pi/team/config.sh" ;;
|
|
1148
|
+
*) printf '%s\n' "$line" >> "$H/.pi/team/config.sh" ;;
|
|
1149
|
+
esac
|
|
1150
|
+
done
|
|
1151
|
+
local c0 b0 a0
|
|
1152
|
+
c0="$(sha "$H/.pi/team/config.sh")"; b0="$(s_backups "$H")"; a0="$(s_audit "$H")"
|
|
1153
|
+
s_run "$H" -- up
|
|
1154
|
+
check "heal-refuse-$name" bash -c '[ "$1" != 0 ]' _ "$RC"
|
|
1155
|
+
check "heal-refuse-$name-named" contains "$OUT" "$want"
|
|
1156
|
+
check "heal-refuse-$name-pure" bash -c '[ "$1" = "$2" ] && [ "$3" = "$4" ] && [ "$5" = "$6" ]' _ \
|
|
1157
|
+
"$(sha "$H/.pi/team/config.sh")" "$c0" "$(s_backups "$H")" "$b0" "$(s_audit "$H")" "$a0"
|
|
1158
|
+
}
|
|
1159
|
+
heal_refusal not-locatable-duplicate 'duplicate TEAM_DEFAULT_MODEL' 'TEAM_DEFAULT_MODEL="vendor/other"'
|
|
1160
|
+
heal_refusal not-locatable-dynamic 'dynamic/indirect value' '-TEAM_DEFAULT_MODEL' 'TEAM_DEFAULT_MODEL=$(printf vendor/x)'
|
|
1161
|
+
heal_refusal invalid-model '不合法' '-TEAM_AGENT_MODELS' 'TEAM_AGENT_MODELS="dev=notamodel"'
|
|
1162
|
+
heal_refusal invalid-model-advice '其余已推导出的对可以先手工提交' '-TEAM_AGENT_MODELS' 'TEAM_AGENT_MODELS="dev=notamodel verify=vendor/strong:high"'
|
|
1163
|
+
heal_refusal unnormalizable '不是合法类别名' '-TEAM_AGENT_MODELS' 'TEAM_AGENT_MODELS="@=vendor/x"'
|
|
1164
|
+
heal_refusal seat-collision '两个席位规范化后都叫类别 dev-1' '-TEAM_AGENT_MODELS' 'TEAM_AGENT_MODELS="Dev-1=vendor/x dev_1=vendor/y"'
|
|
1165
|
+
heal_refusal fallback-collision '兜底名与它撞名' '-TEAM_AGENT_MODELS' 'TEAM_AGENT_MODELS="Default=vendor/x"'
|
|
1166
|
+
heal_refusal contradictory '非空的新键 TEAM_TASK_MODELS' "TEAM_TASK_MODELS='routine=vendor/x'"
|
|
1167
|
+
heal_refusal unknown-shape '形状号是 3' "TEAM_CONFIG_VERSION='3'"
|
|
1168
|
+
heal_refusal contradictory-shape '却还有退休键' "TEAM_CONFIG_VERSION='2'"
|
|
1169
|
+
# 环境里的退休键:形状已是最新、文件里没有退休键,但环境里有 → 拒绝并给 unset(文件一个字节都不写)
|
|
1170
|
+
cp -p "$TMP/heal-migrated" "$H/.pi/team/config.sh"
|
|
1171
|
+
c0="$(sha "$H/.pi/team/config.sh")"
|
|
1172
|
+
s_run "$H" TEAM_AGENT_MODELS='dev=vendor/x' -- up
|
|
1173
|
+
check heal-refuse-env-retired bash -c '[ "$1" != 0 ]' _ "$RC"
|
|
1174
|
+
check heal-refuse-env-named contains "$OUT" 'unset TEAM_AGENT_MODELS'
|
|
1175
|
+
check heal-refuse-env-pure eq "$(sha "$H/.pi/team/config.sh")" "$c0"
|
|
1176
|
+
# ⑥ 新项目必须写形状号(init 与 bootstrap 各一条;翻转里删渲染参数 → 这两条必红)
|
|
1177
|
+
s_new_repo "$TMP/heal-init"
|
|
1178
|
+
s_run "$TMP/heal-init" -- init --no-skills --session heal-init --agents dev --vcs local --gates true \
|
|
1179
|
+
--task-models 'routine=vendor/light' --pm-model 'vendor/pm:high'
|
|
1180
|
+
check heal-init-shape-number eq "$(team_config_file_value "$TMP/heal-init/.pi/team/config.sh" TEAM_CONFIG_VERSION)" 2
|
|
1181
|
+
s_new_repo "$TMP/heal-boot"
|
|
1182
|
+
s_run "$TMP/heal-boot" -- bootstrap --no-pulse --agents dev --task-models 'routine=vendor/light' --pm-model 'vendor/pm:high'
|
|
1183
|
+
check heal-bootstrap-shape-number eq "$(team_config_file_value "$TMP/heal-boot/.pi/team/config.sh" TEAM_CONFIG_VERSION)" 2
|
|
1184
|
+
fi
|
|
1185
|
+
|
|
1186
|
+
if has adopt; then
|
|
1187
|
+
A="$TMP/adopt"; s_new_repo "$A"
|
|
1188
|
+
cat > "$A/.pi/team/config.sh" <<EOF
|
|
1189
|
+
TEAM_PROJECT='adopt-fixture'
|
|
1190
|
+
TEAM_SESSION='routing-adopt'
|
|
1191
|
+
TEAM_PM_WINDOW='pm'
|
|
1192
|
+
TEAM_DOCS_DIR='docs/team'
|
|
1193
|
+
TEAM_AGENTS='dev verify'
|
|
1194
|
+
TEAM_TASK_MODELS='routine=vendor/light default=vendor/base'
|
|
1195
|
+
TEAM_PM_MODEL='vendor/pm:high'
|
|
1196
|
+
TEAM_CONFIG_VERSION='2'
|
|
1197
|
+
TEAM_WORKTREES_DIR='.worktrees'
|
|
1198
|
+
TEAM_VCS='local'
|
|
1199
|
+
TEAM_GATES='true'
|
|
1200
|
+
TEAM_MIN_FREE_SWAP_MB=0
|
|
1201
|
+
TEAM_MIN_TOTAL_MB=0
|
|
1202
|
+
TEAM_MIN_AVAIL_MB=0
|
|
1203
|
+
TEAM_TMP_MIN_FREE_MB=0
|
|
1204
|
+
TEAM_TMP_MIN_FREE_INODES=0
|
|
1205
|
+
TEAM_MODEL_LIMITS=''
|
|
1206
|
+
TEAM_UPDATE_CHECK=0
|
|
1207
|
+
TEAM_PI_BIN='$TMP/recording-pi'
|
|
1208
|
+
EOF
|
|
1209
|
+
s_brief "$A" A1 default
|
|
1210
|
+
# ① 缺记录:--print 打印将要登记的那一行,且不建文件(design §7)
|
|
1211
|
+
s_run "$A" -- up --print
|
|
1212
|
+
check adopt-print-rc eq "$RC" 0
|
|
1213
|
+
check adopt-print-preview contains "$OUT" '身份预告:此前没有启动记录;这次启动会登记 model=vendor/pm:high'
|
|
1214
|
+
check adopt-print-fresh-note contains "$OUT" '--fresh-pm'
|
|
1215
|
+
check adopt-print-no-file bash -c '[ ! -e "$1" ]' _ "$A/.pi/team/state/pm-launch.env"
|
|
1216
|
+
# ② 真跑:缺记录 → 登记 + 启动,登记行说明 model/resume_key/mode
|
|
1217
|
+
s_run "$A" -- up
|
|
1218
|
+
check adopt-register-rc eq "$RC" 0
|
|
1219
|
+
check adopt-register-line contains "$OUT" '已登记本次启动身份:model=vendor/pm:high resume_key=default mode=continued'
|
|
1220
|
+
check adopt-register-record bash -c 'grep -qx "model=vendor/pm:high" "$1" && grep -qx "resume_key=default" "$1" && grep -qx "mode=continued" "$1"' _ "$A/.pi/team/state/pm-launch.env"
|
|
1221
|
+
# ③ 记录存在但不一致:仍拒绝,打印两边(suffix 显式)与哪一处变了,给两条出路;记录字节不变
|
|
1222
|
+
rec0="$(sha "$A/.pi/team/state/pm-launch.env")"
|
|
1223
|
+
sed -i "s|^TEAM_PM_MODEL=.*|TEAM_PM_MODEL='vendor/pm:low'|" "$A/.pi/team/config.sh"
|
|
1224
|
+
s_run "$A" -- up --print
|
|
1225
|
+
check adopt-changed-refused bash -c '[ "$1" != 0 ]' _ "$RC"
|
|
1226
|
+
check adopt-changed-both-sides bash -c '[[ "$1" == *"记录 model=vendor/pm:high"* && "$1" == *"现在 model=vendor/pm:low"* ]]' _ "$OUT"
|
|
1227
|
+
check adopt-changed-names-change contains "$OUT" 'model(记录 vendor/pm:high → 现在 vendor/pm:low)'
|
|
1228
|
+
check adopt-changed-fresh-route contains "$OUT" '--fresh-pm'
|
|
1229
|
+
check adopt-changed-adopt-route contains "$OUT" '--adopt-pm-identity --yes'
|
|
1230
|
+
check adopt-changed-record-pure eq "$(sha "$A/.pi/team/state/pm-launch.env")" "$rec0"
|
|
1231
|
+
# ③b PM 正在运行时 adopt 不写记录:运行中的身份就是记录里那一个(政策改动不重启它),这时改记录
|
|
1232
|
+
# 等于给「下一次续跑」安排一份跟在跑的会话对不上的身份 —— 拒绝并给两条路,记录逐字节不变。
|
|
1233
|
+
s_run "$A" -- up
|
|
1234
|
+
check adopt-running-still-runs eq "$RC" 0
|
|
1235
|
+
check adopt-running-no-change contains "$OUT" 'PM 在运行'
|
|
1236
|
+
rec_run="$(sha "$A/.pi/team/state/pm-launch.env")"
|
|
1237
|
+
s_run "$A" -- up --adopt-pm-identity --yes
|
|
1238
|
+
check adopt-running-refused bash -c '[ "$1" != 0 ]' _ "$RC"
|
|
1239
|
+
check adopt-running-named contains "$OUT" '--adopt-pm-identity:PM 正在运行'
|
|
1240
|
+
check adopt-running-record-pure eq "$(sha "$A/.pi/team/state/pm-launch.env")" "$rec_run"
|
|
1241
|
+
# 让 PM 停下来(夹具自己的私有 socket 与私有 session),后续 adopt 臂都在「停了」的形态下跑
|
|
1242
|
+
s_stop_pm "$A" routing-adopt
|
|
1243
|
+
check adopt-running-stopped bash -c '[ "$1" != 0 ]' _ "$RC"
|
|
1244
|
+
# ④ adopt 不带 --yes:拒绝并点名旗标,一个字节都不写
|
|
1245
|
+
s_run "$A" -- up --adopt-pm-identity
|
|
1246
|
+
check adopt-no-yes-refused bash -c '[ "$1" != 0 ]' _ "$RC"
|
|
1247
|
+
check adopt-no-yes-names-flag contains "$OUT" '--adopt-pm-identity 需要 --yes'
|
|
1248
|
+
check adopt-no-yes-record-pure eq "$(sha "$A/.pi/team/state/pm-launch.env")" "$rec0"
|
|
1249
|
+
# ⑤ --print 下 adopt 不写盘(预览承诺)
|
|
1250
|
+
s_run "$A" -- up --adopt-pm-identity --yes --print
|
|
1251
|
+
check adopt-print-refused bash -c '[ "$1" != 0 ]' _ "$RC"
|
|
1252
|
+
check adopt-print-no-write-note contains "$OUT" '--print 不写盘'
|
|
1253
|
+
check adopt-print-record-pure eq "$(sha "$A/.pi/team/state/pm-launch.env")" "$rec0"
|
|
1254
|
+
# ⑥ adopt --yes 真跑:写记录 + config.log 一行审计 + 声明行;之后同一身份能续
|
|
1255
|
+
s_run "$A" -- up --adopt-pm-identity --yes
|
|
1256
|
+
check adopt-yes-rc eq "$RC" 0
|
|
1257
|
+
check adopt-yes-declaration contains "$OUT" '我声明这次续跑的身份是 model=vendor/pm:low'
|
|
1258
|
+
check adopt-yes-record eq "$(grep '^model=' "$A/.pi/team/state/pm-launch.env")" 'model=vendor/pm:low'
|
|
1259
|
+
check adopt-yes-audit contains "$(tail -1 "$A/.pi/team/state/config.log")" 'key=pm-launch-identity'
|
|
1260
|
+
check adopt-yes-audit-old contains "$(tail -1 "$A/.pi/team/state/config.log")" 'model=vendor/pm:high'
|
|
1261
|
+
s_run "$A" -- up --print
|
|
1262
|
+
check adopt-follow-continues eq "$RC" 0
|
|
1263
|
+
check adopt-follow-identity contains "$OUT" '身份预告:记录与当前解析一致'
|
|
1264
|
+
check adopt-follow-command contains "$OUT" '完整命令:'
|
|
1265
|
+
# ⑦ 不可读记录:即使给了 --yes 仍拒绝(这个旗标声明值,不认领别人的/坏掉的记录)
|
|
1266
|
+
s_stop_pm "$A" routing-adopt # ⑥ 刚把 PM 起起来;运行中的拒绝是另一条判据(③b 证过)
|
|
1267
|
+
printf 'garbage\n' > "$A/.pi/team/state/pm-launch.env"
|
|
1268
|
+
bad0="$(sha "$A/.pi/team/state/pm-launch.env")"
|
|
1269
|
+
s_run "$A" -- up --adopt-pm-identity --yes
|
|
1270
|
+
check adopt-unreadable-refused bash -c '[ "$1" != 0 ]' _ "$RC"
|
|
1271
|
+
check adopt-unreadable-named contains "$OUT" '不可读'
|
|
1272
|
+
check adopt-unreadable-pure eq "$(sha "$A/.pi/team/state/pm-launch.env")" "$bad0"
|
|
1273
|
+
# ⑧ --fresh-pm 语义不变:坏记录也拦不住显式的新会话(回归)
|
|
1274
|
+
s_run "$A" -- up --print --fresh-pm
|
|
1275
|
+
check adopt-fresh-pm-preview eq "$RC" 0
|
|
1276
|
+
check adopt-fresh-pm-judgement contains "$OUT" '会话判定:fresh:--fresh-pm'
|
|
1277
|
+
fi
|
|
1278
|
+
|
|
1279
|
+
if has updatecheck; then
|
|
1280
|
+
U="$TMP/updatecheck"; s_new_repo "$U"
|
|
1281
|
+
# 本地版本从**被测树**取(产品的 local_v 与缓存里的 LOCAL= 都取 scripts/lib/common.sh 的
|
|
1282
|
+
# TEAM_VERSION);写死字面量会在发布落点时变成「与另一个版本比较」(P319 §4:0.2.0 → 0.3.0)。
|
|
1283
|
+
U_LOCAL="$(sed -n 's/^TEAM_VERSION=//p' "$SKILL/scripts/lib/common.sh" | head -1 | tr -d "\"'")"
|
|
1284
|
+
[ -n "$U_LOCAL" ] || U_LOCAL="$(sed -n 's/^[[:space:]]*"version":[[:space:]]*"\([^"]*\)".*/\1/p' "$TREE/package.json" | head -1)"
|
|
1285
|
+
# 更旧的那个必须**严格小于**本地版本:同主版本、次版本减一(0.3.0 → 0.2.0);次版本为 0 时退主版本。
|
|
1286
|
+
U_OLDER="$(printf '%s\n' "$U_LOCAL" | awk -F. '{ if ($2+0 > 0) printf "%d.%d.0\n", $1, $2-1; else printf "%d.0.0\n", ($1+0 > 0 ? $1-1 : 0) }')"
|
|
1287
|
+
cat > "$U/.pi/team/config.sh" <<EOF
|
|
1288
|
+
TEAM_PROJECT='updatecheck-fixture'
|
|
1289
|
+
TEAM_SESSION='routing-update'
|
|
1290
|
+
TEAM_PM_WINDOW='pm'
|
|
1291
|
+
TEAM_DOCS_DIR='docs/team'
|
|
1292
|
+
TEAM_AGENTS='dev verify'
|
|
1293
|
+
TEAM_TASK_MODELS='routine=vendor/light default=vendor/base'
|
|
1294
|
+
TEAM_PM_MODEL='vendor/pm:high'
|
|
1295
|
+
TEAM_CONFIG_VERSION='2'
|
|
1296
|
+
TEAM_WORKTREES_DIR='.worktrees'
|
|
1297
|
+
TEAM_VCS='local'
|
|
1298
|
+
TEAM_GATES='true'
|
|
1299
|
+
TEAM_MIN_FREE_SWAP_MB=0
|
|
1300
|
+
TEAM_MIN_TOTAL_MB=0
|
|
1301
|
+
TEAM_MIN_AVAIL_MB=0
|
|
1302
|
+
TEAM_TMP_MIN_FREE_MB=0
|
|
1303
|
+
TEAM_TMP_MIN_FREE_INODES=0
|
|
1304
|
+
TEAM_MODEL_LIMITS=''
|
|
1305
|
+
TEAM_UPDATE_CHECK=1
|
|
1306
|
+
TEAM_PI_BIN='$TMP/recording-pi'
|
|
1307
|
+
EOF
|
|
1308
|
+
s_brief "$U" U1 default
|
|
1309
|
+
# 桩 npm(与既有 fake-bin 同族):计数 + 按答案文件回答;TEAM_UPDATE_CHECK=0 的零调用是可断言的。
|
|
1310
|
+
npm_stub() { # <答案|FAIL>
|
|
1311
|
+
if [ "$1" = FAIL ]; then
|
|
1312
|
+
printf '#!/usr/bin/env bash\nprintf "call\\n" >> "%s"\nexit 1\n' "$TMP/npm-calls" > "$TMP/bin/npm"
|
|
1313
|
+
else
|
|
1314
|
+
printf '#!/usr/bin/env bash\nprintf "call\\n" >> "%s"\nprintf "%%s\\n" "%s"\n' "$TMP/npm-calls" "$1" > "$TMP/bin/npm"
|
|
1315
|
+
fi
|
|
1316
|
+
chmod +x "$TMP/bin/npm"
|
|
1317
|
+
}
|
|
1318
|
+
npm_calls() { [ -f "$TMP/npm-calls" ] && wc -l < "$TMP/npm-calls" | tr -d ' ' || printf '0'; }
|
|
1319
|
+
npm_stub 9.9.9; : > "$TMP/npm-calls"
|
|
1320
|
+
s_run "$U" -- up
|
|
1321
|
+
check updatecheck-start-rc eq "$RC" 0
|
|
1322
|
+
check updatecheck-start-decision contains "$OUT" 'PM 已启动'
|
|
1323
|
+
check updatecheck-newer-line contains "$OUT" "本地 teamsmith $U_LOCAL,npm 上已有 9.9.9"
|
|
1324
|
+
check updatecheck-upgrade-command contains "$OUT" "npm i -g teamsmith@9.9.9 --registry https://registry.npmjs.org"
|
|
1325
|
+
check updatecheck-never-installs contains "$OUT" '工具从不自己安装'
|
|
1326
|
+
check updatecheck-first-call eq "$(npm_calls)" 1
|
|
1327
|
+
check updatecheck-cache-written bash -c 'grep -q "^LATEST=9.9.9\$" "$1" && grep -q "^LOCAL=$2\$" "$1" && grep -q "^CHECKED_AT=[0-9]*\$" "$1"' _ "$U/.pi/team/state/update-check.env" "$U_LOCAL"
|
|
1328
|
+
# 新鲜缓存:再跑两次,零调用(TTL 24h 内不重复联网),但仍打同一行(缓存里的结论)
|
|
1329
|
+
fresh0="$(npm_calls)"
|
|
1330
|
+
s_run "$U" -- up; check updatecheck-fresh-rc eq "$RC" 0
|
|
1331
|
+
check updatecheck-fresh-decision contains "$OUT" 'PM 在运行'
|
|
1332
|
+
s_run "$U" -- up; check updatecheck-fresh-rc2 eq "$RC" 0
|
|
1333
|
+
check updatecheck-fresh-zero-calls eq "$(npm_calls)" "$fresh0"
|
|
1334
|
+
check updatecheck-cached-line contains "$OUT" 'npm 上已有 9.9.9'
|
|
1335
|
+
# 其余四种回答:过期缓存 → 各查一次、一声不响(相同/更旧/报错/解析不出)
|
|
1336
|
+
u_arm() { # <答案|FAIL> <名称> [env…]
|
|
1337
|
+
local answer="$1" name="$2"; shift 2
|
|
1338
|
+
printf 'CHECKED_AT=1\nLATEST=9.9.9\nLOCAL=%s\n' "$U_LOCAL" > "$U/.pi/team/state/update-check.env"
|
|
1339
|
+
npm_stub "$answer"
|
|
1340
|
+
local n0; n0="$(npm_calls)"
|
|
1341
|
+
s_run "$U" "$@" -- up
|
|
1342
|
+
UCALLS=$(( $(npm_calls) - n0 )); UOUT="$OUT"; URC="$RC"
|
|
1343
|
+
check "updatecheck-$name-rc" eq "$URC" 0
|
|
1344
|
+
check "updatecheck-$name-decision" contains "$UOUT" 'PM 在运行'
|
|
1345
|
+
check "updatecheck-$name-silent" bash -c '! [[ "$1" == *"npm 上已有"* ]]' _ "$UOUT"
|
|
1346
|
+
}
|
|
1347
|
+
u_arm "$U_LOCAL" same; check updatecheck-same-one-call eq "$UCALLS" 1
|
|
1348
|
+
u_arm "$U_OLDER" older; check updatecheck-older-one-call eq "$UCALLS" 1
|
|
1349
|
+
u_arm FAIL failing; check updatecheck-failing-one-call eq "$UCALLS" 1
|
|
1350
|
+
check updatecheck-failing-cache bash -c 'grep -q "^LATEST=-\$" "$1"' _ "$U/.pi/team/state/update-check.env"
|
|
1351
|
+
u_arm not-a-version unparsable; check updatecheck-unparsable-one-call eq "$UCALLS" 1
|
|
1352
|
+
# TEAM_UPDATE_CHECK=0:连查询都不发生,缓存一个字节都不动
|
|
1353
|
+
printf 'CHECKED_AT=1\nLATEST=9.9.9\nLOCAL=%s\n' "$U_LOCAL" > "$U/.pi/team/state/update-check.env"
|
|
1354
|
+
cache0="$(sha "$U/.pi/team/state/update-check.env")"; dis0="$(npm_calls)"
|
|
1355
|
+
npm_stub 9.9.9
|
|
1356
|
+
s_run "$U" TEAM_UPDATE_CHECK=0 -- up
|
|
1357
|
+
check updatecheck-disabled-rc eq "$RC" 0
|
|
1358
|
+
check updatecheck-disabled-decision contains "$OUT" 'PM 在运行'
|
|
1359
|
+
check updatecheck-disabled-zero-calls eq "$(npm_calls)" "$dis0"
|
|
1360
|
+
check updatecheck-disabled-cache-pure eq "$(sha "$U/.pi/team/state/update-check.env")" "$cache0"
|
|
1361
|
+
check updatecheck-disabled-silent bash -c '! [[ "$1" == *"npm 上已有"* ]]' _ "$OUT"
|
|
1362
|
+
# 有界:桩 npm 挂住 30s → 查询必须在 2s 上限内被放弃(静默、rc 与启动决策不变)
|
|
1363
|
+
printf '#!/usr/bin/env bash\nprintf "call\\n" >> "%s"\nsleep 30\n' "$TMP/npm-calls" > "$TMP/bin/npm"; chmod +x "$TMP/bin/npm"
|
|
1364
|
+
printf 'CHECKED_AT=1\nLATEST=9.9.9\nLOCAL=%s\n' "$U_LOCAL" > "$U/.pi/team/state/update-check.env"
|
|
1365
|
+
uc0="$(npm_calls)"; ut0="$(date +%s)"
|
|
1366
|
+
s_run "$U" -- up
|
|
1367
|
+
ut1="$(date +%s)"
|
|
1368
|
+
check updatecheck-bounded-rc eq "$RC" 0
|
|
1369
|
+
check updatecheck-bounded-decision contains "$OUT" 'PM 在运行'
|
|
1370
|
+
check updatecheck-bounded-silent bash -c '! [[ "$1" == *"npm 上已有"* ]]' _ "$OUT"
|
|
1371
|
+
check updatecheck-bounded-called eq "$(( $(npm_calls) - uc0 ))" 1
|
|
1372
|
+
check updatecheck-bounded-seconds bash -c '[ "$1" -le 4 ]' _ "$((ut1 - ut0))"
|
|
1373
|
+
# --print:不联网、不写缓存,并说明跳过了检查
|
|
1374
|
+
printf 'CHECKED_AT=1\nLATEST=9.9.9\nLOCAL=%s\n' "$U_LOCAL" > "$U/.pi/team/state/update-check.env"
|
|
1375
|
+
cache0="$(sha "$U/.pi/team/state/update-check.env")"; pr0="$(npm_calls)"
|
|
1376
|
+
npm_stub 9.9.9
|
|
1377
|
+
s_run "$U" -- up --print
|
|
1378
|
+
check updatecheck-print-rc eq "$RC" 0
|
|
1379
|
+
check updatecheck-print-skip contains "$OUT" '--print 下不联网、不写缓存'
|
|
1380
|
+
check updatecheck-print-zero-calls eq "$(npm_calls)" "$pr0"
|
|
1381
|
+
check updatecheck-print-cache-unchanged eq "$(sha "$U/.pi/team/state/update-check.env")" "$cache0"
|
|
1382
|
+
rm -f "$TMP/bin/npm"
|
|
1383
|
+
fi
|
|
1384
|
+
|
|
1385
|
+
# 收尾:私有通道如果是**本段**装的,就还原 PATH 并撤掉包装 —— 别把它留给后续(flip 套件会以子进程
|
|
1386
|
+
# 重跑本套件,继承的 PATH 里留着指向上一轮 socket 的包装,同样会递归)。
|
|
1387
|
+
if [ "${STARTUP_TMUX_OWN:-0}" = 1 ]; then
|
|
1388
|
+
export PATH="$STARTUP_PATH0"
|
|
1389
|
+
rm -f "$TMP/bin/tmux"
|
|
1390
|
+
fi
|
|
1391
|
+
|
|
1392
|
+
if has flip; then
|
|
1393
|
+
CORE='policy,machine,init,config,upgrade,dispatch,resume,transaction,limits,preview,sid-readers,pm,heal,adopt,updatecheck,boundary'
|
|
1394
|
+
# One green baseline and one green restoration of the whole slice; each red arm has its own copy.
|
|
1395
|
+
flip_run() {
|
|
1396
|
+
local tag="$1" tree="$2" groups="$3" rc=0
|
|
1397
|
+
TEAM_ROUTING_TREE="$tree" TEAM_ROUTING_EVIDENCE="$TMP/flip-evidence/$tag" timeout 900 bash "$here/task-model-routing.sh" --select "$groups" > "$TMP/flip-$tag.log" 2>&1 || rc=$?
|
|
1398
|
+
printf 'CONTROL %s rc=%s log=%s\n' "$tag" "$rc" "$TMP/flip-$tag.log"
|
|
1399
|
+
tail -4 "$TMP/flip-$tag.log"
|
|
1400
|
+
FLIP_RC="$rc"
|
|
1401
|
+
}
|
|
1402
|
+
flip_run baseline "$TREE" "$CORE"
|
|
1403
|
+
check flip-baseline-green eq "$FLIP_RC" 0
|
|
1404
|
+
if [ "$FLIP_RC" = 0 ]; then
|
|
1405
|
+
for mutation in unmapped-override required-categories fingerprint expanding-quote recovery-drift partial-publication unknown-as-zero latest-shell latest-monitor pm-fallback pm-publication extra-shadow template-shadow template-unbound template-roles monitor-record-drift literal-shell-expansion pm-literal-resplit worker-literal-resplit identity-overclaim init-legacy-proceeds template-retired-key migration-row-removed no-backup no-shape-number missing-record-refused adopt-ignores-yes updatecheck-equal-prints updatecheck-ignores-off updatecheck-print-writes-cache legacy-route-placeholder; do
|
|
1406
|
+
case "$mutation" in
|
|
1407
|
+
unmapped-override) groups=dispatch ;;
|
|
1408
|
+
required-categories) groups=policy,config,upgrade,dispatch ;;
|
|
1409
|
+
identity-overclaim) groups=dispatch,limits ;;
|
|
1410
|
+
fingerprint|expanding-quote) groups=config ;;
|
|
1411
|
+
recovery-drift) groups=resume ;;
|
|
1412
|
+
partial-publication) groups=transaction ;;
|
|
1413
|
+
unknown-as-zero) groups=limits ;;
|
|
1414
|
+
latest-shell|latest-monitor) groups=sid-readers ;;
|
|
1415
|
+
pm-fallback) groups=pm ;;
|
|
1416
|
+
pm-publication) groups=dispatch,pm ;;
|
|
1417
|
+
extra-shadow|template-shadow|template-unbound|template-roles|literal-shell-expansion|pm-literal-resplit|worker-literal-resplit) groups=boundary ;;
|
|
1418
|
+
monitor-record-drift) groups=sid-readers ;;
|
|
1419
|
+
init-legacy-proceeds|template-retired-key) groups=init ;;
|
|
1420
|
+
migration-row-removed|no-backup|no-shape-number) groups=heal ;;
|
|
1421
|
+
missing-record-refused|adopt-ignores-yes) groups=adopt ;;
|
|
1422
|
+
updatecheck-equal-prints|updatecheck-ignores-off|updatecheck-print-writes-cache) groups=updatecheck ;;
|
|
1423
|
+
legacy-route-placeholder) groups=init ;;
|
|
1424
|
+
esac
|
|
1425
|
+
scratch="$TMP/mutants/$mutation"; mkdir -p "$scratch/skills/teamsmith"; touch "$scratch/.routing-mutant"
|
|
1426
|
+
# P320/V62:拷贝源目录叫 extension(单数),产品 init 从 $TEAM_SKILL_DIR/extension/team.ts 装扩展;
|
|
1427
|
+
# 之前写成 extensions,既有 `[ ! -d ]` 判据就把它们跳过,变异体缺扩展、bootstrap 先报“找不到可安装的扩展源”,
|
|
1428
|
+
# 抢在目标拒绝之前失败。只纠正目录名,不加兜底。
|
|
1429
|
+
for source_dir in scripts references templates extension; do
|
|
1430
|
+
[ ! -d "$SKILL/$source_dir" ] || cp -a "$SKILL/$source_dir" "$scratch/skills/teamsmith/"
|
|
1431
|
+
done
|
|
1432
|
+
before="$(find "$scratch/skills/teamsmith/scripts" -type f -print0 | sort -z | xargs -0 sha256sum | sha256sum | cut -d' ' -f1)"
|
|
1433
|
+
python3 "$here/lib/model-routing-flips.py" "$scratch" "$mutation" > "$TMP/mutation-$mutation.json"
|
|
1434
|
+
check "flip-$mutation-target-matched" eq "$?" 0
|
|
1435
|
+
check "flip-$mutation-shape-valid" bash -c 'for file in "$1"/scripts/lib/*.sh; do bash -n "$file" || exit; done; node --check "$1/scripts/monitor.mjs"' _ "$scratch/skills/teamsmith"
|
|
1436
|
+
flip_run "$mutation" "$scratch" "$groups"
|
|
1437
|
+
check "flip-$mutation-red" eq "$FLIP_RC" 1
|
|
1438
|
+
check "flip-$mutation-named-assertion" grep -q '^FAIL ' "$TMP/flip-$mutation.log"
|
|
1439
|
+
case "$mutation" in
|
|
1440
|
+
required-categories)
|
|
1441
|
+
check flip-required-categories-policy grep -q '^FAIL policy-custom-vocabulary-only$' "$TMP/flip-$mutation.log"
|
|
1442
|
+
check flip-required-categories-writer grep -q '^FAIL map-custom-vocabulary-write$' "$TMP/flip-$mutation.log"
|
|
1443
|
+
check flip-required-categories-upgrade grep -q '^FAIL upgrade-custom-vocabulary$' "$TMP/flip-$mutation.log"
|
|
1444
|
+
check flip-required-categories-selection grep -q '^FAIL new-selection-custom-vocabulary$' "$TMP/flip-$mutation.log" ;;
|
|
1445
|
+
identity-overclaim)
|
|
1446
|
+
check flip-identity-overclaim-record grep -q '^FAIL publication-record:model-only$' "$TMP/flip-$mutation.log"
|
|
1447
|
+
check flip-identity-overclaim-argv grep -q '^FAIL publication-record-equals-argv:model-only$' "$TMP/flip-$mutation.log"
|
|
1448
|
+
check flip-identity-overclaim-opaque grep -q '^FAIL publication-record:opaque$' "$TMP/flip-$mutation.log"
|
|
1449
|
+
check flip-identity-overclaim-claim grep -q '^FAIL publication-claim-gap:model-only$' "$TMP/flip-$mutation.log" ;;
|
|
1450
|
+
template-shadow) check flip-template-shadow-specific-worker grep -q '^FAIL template-refused:all-hardcoded:preview$' "$TMP/flip-$mutation.log"
|
|
1451
|
+
check flip-template-shadow-specific-pm grep -q '^FAIL pm-template-refused:provider:launch$' "$TMP/flip-$mutation.log" ;;
|
|
1452
|
+
template-unbound)
|
|
1453
|
+
check flip-unbound-worker-positional grep -q '^FAIL template-refused:positional-model:launch$' "$TMP/flip-$mutation.log"
|
|
1454
|
+
check flip-unbound-worker-data grep -q '^FAIL template-refused:data-sid:preview$' "$TMP/flip-$mutation.log"
|
|
1455
|
+
check flip-unbound-pm-positional grep -q '^FAIL pm-custom-missing-refused:positional-model:launch$' "$TMP/flip-$mutation.log"
|
|
1456
|
+
check flip-unbound-pm-data grep -q '^FAIL pm-template-refused:data-provider:preview$' "$TMP/flip-$mutation.log" ;;
|
|
1457
|
+
template-roles)
|
|
1458
|
+
check flip-role-worker-selector-as-data grep -q '^FAIL worker-role-refused:model:--skill:launch$' "$TMP/flip-$mutation.log"
|
|
1459
|
+
check flip-role-pm-selector-as-data grep -q '^FAIL pm-role-refused:provider:--skill:launch$' "$TMP/flip-$mutation.log"
|
|
1460
|
+
check flip-role-pm-resume-data grep -q '^FAIL pm-role-resume-refused:builtin:--skill --continue:launch$' "$TMP/flip-$mutation.log" ;;
|
|
1461
|
+
monitor-record-drift) check flip-monitor-record-drift-specific-nonce grep -q '^FAIL reader-monitor-unavailable:nonce$' "$TMP/flip-$mutation.log" ;;
|
|
1462
|
+
literal-shell-expansion)
|
|
1463
|
+
check flip-literal-shell-specific-worker-template grep -q '^FAIL worker-expansion-refused:template:model-glob:launch$' "$TMP/flip-$mutation.log"
|
|
1464
|
+
check flip-literal-shell-specific-worker-extra grep -q '^FAIL worker-expansion-refused:extra:model-glob:launch$' "$TMP/flip-$mutation.log"
|
|
1465
|
+
check flip-literal-shell-specific-pm-template grep -q '^FAIL pm-expansion-refused:template:model-glob:launch$' "$TMP/flip-$mutation.log"
|
|
1466
|
+
check flip-literal-shell-specific-pm-extra grep -q '^FAIL pm-expansion-refused:extra:model-glob:launch$' "$TMP/flip-$mutation.log" ;;
|
|
1467
|
+
pm-literal-resplit)
|
|
1468
|
+
check flip-pm-resplit-specific-extra grep -q '^FAIL pm-expansion-literal-argv:extra$' "$TMP/flip-$mutation.log"
|
|
1469
|
+
check flip-pm-resplit-specific-resume grep -q '^FAIL pm-resume-literal-argv:builtin$' "$TMP/flip-$mutation.log" ;;
|
|
1470
|
+
worker-literal-resplit)
|
|
1471
|
+
check flip-worker-resplit-specific-extra grep -q '^FAIL worker-expansion-literal-argv:extra$' "$TMP/flip-$mutation.log" ;;
|
|
1472
|
+
init-legacy-proceeds)
|
|
1473
|
+
check flip-init-legacy-proceeds-plain grep -q '^FAIL init-legacy-plain-refused$' "$TMP/flip-$mutation.log"
|
|
1474
|
+
check flip-init-legacy-proceeds-force grep -q '^FAIL init-legacy-force-refused$' "$TMP/flip-$mutation.log"
|
|
1475
|
+
check flip-init-legacy-proceeds-bootstrap grep -q '^FAIL init-legacy-bootstrap-refused$' "$TMP/flip-$mutation.log" ;;
|
|
1476
|
+
template-retired-key)
|
|
1477
|
+
check flip-template-retired-key-specific grep -q '^FAIL init-fresh-no-retired-key$' "$TMP/flip-$mutation.log" ;;
|
|
1478
|
+
migration-row-removed)
|
|
1479
|
+
check flip-migration-row-removed-specific grep -q '^FAIL heal-print-rc$' "$TMP/flip-$mutation.log" ;;
|
|
1480
|
+
no-backup)
|
|
1481
|
+
check flip-no-backup-specific grep -q '^FAIL heal-backup-exists$' "$TMP/flip-$mutation.log" ;;
|
|
1482
|
+
no-shape-number)
|
|
1483
|
+
check flip-no-shape-number-init grep -q '^FAIL heal-init-shape-number$' "$TMP/flip-$mutation.log"
|
|
1484
|
+
check flip-no-shape-number-bootstrap grep -q '^FAIL heal-bootstrap-shape-number$' "$TMP/flip-$mutation.log" ;;
|
|
1485
|
+
missing-record-refused)
|
|
1486
|
+
check flip-missing-record-refused-specific grep -q '^FAIL adopt-print-rc$' "$TMP/flip-$mutation.log" ;;
|
|
1487
|
+
adopt-ignores-yes)
|
|
1488
|
+
check flip-adopt-ignores-yes-specific grep -q '^FAIL adopt-no-yes-refused$' "$TMP/flip-$mutation.log" ;;
|
|
1489
|
+
updatecheck-equal-prints)
|
|
1490
|
+
check flip-updatecheck-equal-specific grep -q '^FAIL updatecheck-same-silent$' "$TMP/flip-$mutation.log" ;;
|
|
1491
|
+
updatecheck-ignores-off)
|
|
1492
|
+
check flip-updatecheck-off-specific grep -q '^FAIL updatecheck-disabled-zero-calls$' "$TMP/flip-$mutation.log" ;;
|
|
1493
|
+
updatecheck-print-writes-cache)
|
|
1494
|
+
check flip-updatecheck-print-specific grep -q '^FAIL updatecheck-print-cache-unchanged$' "$TMP/flip-$mutation.log" ;;
|
|
1495
|
+
legacy-route-placeholder)
|
|
1496
|
+
check flip-legacy-route-init grep -q '^FAIL init-legacy-plain-derived$' "$TMP/flip-$mutation.log"
|
|
1497
|
+
check flip-legacy-route-bootstrap grep -q '^FAIL init-legacy-bootstrap-derived$' "$TMP/flip-$mutation.log"
|
|
1498
|
+
check flip-legacy-route-write-path grep -q '^FAIL init-legacy-config-set-derived$' "$TMP/flip-$mutation.log"
|
|
1499
|
+
check flip-legacy-route-paste grep -q '^FAIL init-paste-derived-exact$' "$TMP/flip-$mutation.log" ;;
|
|
1500
|
+
esac
|
|
1501
|
+
cp -a "$SKILL/scripts/." "$scratch/skills/teamsmith/scripts/"
|
|
1502
|
+
restored="$(find "$scratch/skills/teamsmith/scripts" -type f -print0 | sort -z | xargs -0 sha256sum | sha256sum | cut -d' ' -f1)"
|
|
1503
|
+
check "flip-$mutation-source-restored" eq "$restored" "$before"
|
|
1504
|
+
printf 'CONTROL %s source_before=%s source_restored=%s\n' "$mutation" "$before" "$restored"
|
|
1505
|
+
done
|
|
1506
|
+
flip_run restored "$TREE" "$CORE"
|
|
1507
|
+
check flip-restored-all-green eq "$FLIP_RC" 0
|
|
1508
|
+
fi
|
|
1509
|
+
fi
|
|
1510
|
+
printf '\nRESULT pass=%s fail=%s selected=%s\n' "$PASS" "$FAIL" "$SELECT"
|
|
1511
|
+
[ "$FAIL" = 0 ]
|