teamsmith 0.1.1 → 0.2.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 +16 -8
- package/package.json +1 -1
- package/skills/teamsmith/CHANGELOG.md +55 -0
- package/skills/teamsmith/SKILL.md +18 -7
- package/skills/teamsmith/extension/team-bg.ts +47 -11
- package/skills/teamsmith/extension/team-notify.ts +143 -4
- package/skills/teamsmith/references/agent-adapters.md +7 -7
- package/skills/teamsmith/references/config.md +29 -15
- package/skills/teamsmith/references/migration.md +38 -2
- package/skills/teamsmith/references/openspec.md +23 -9
- package/skills/teamsmith/references/protocol.md +81 -13
- package/skills/teamsmith/references/workflows.md +31 -19
- package/skills/teamsmith/scripts/lib/cmd-agents.sh +210 -70
- package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +70 -9
- package/skills/teamsmith/scripts/lib/cmd-config.sh +222 -70
- 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-project.sh +134 -17
- package/skills/teamsmith/scripts/lib/cmd-reply.sh +96 -0
- package/skills/teamsmith/scripts/lib/cmd-review.sh +13 -10
- package/skills/teamsmith/scripts/lib/cmd-status.sh +42 -13
- package/skills/teamsmith/scripts/lib/cmd-watch.sh +75 -13
- package/skills/teamsmith/scripts/lib/common.sh +797 -71
- package/skills/teamsmith/scripts/monitor.mjs +34 -3
- package/skills/teamsmith/scripts/panel/README.md +22 -11
- package/skills/teamsmith/scripts/panel/panel.js +217 -215
- package/skills/teamsmith/scripts/panel/src/App.tsx +421 -164
- package/skills/teamsmith/scripts/panel/src/data.ts +84 -4
- package/skills/teamsmith/scripts/panel/src/layout.ts +502 -91
- package/skills/teamsmith/scripts/panel/src/main.tsx +97 -12
- package/skills/teamsmith/scripts/panel/src/settings.ts +1 -1
- package/skills/teamsmith/scripts/panel/src/strings/en.ts +56 -21
- package/skills/teamsmith/scripts/panel/src/strings/zh.ts +56 -21
- package/skills/teamsmith/scripts/panel/src/types.ts +178 -16
- package/skills/teamsmith/scripts/replies.mjs +893 -0
- package/skills/teamsmith/scripts/team +1 -0
- package/skills/teamsmith/templates/AGENTS.section.md.tmpl +15 -2
- 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 +10 -5
- package/skills/teamsmith/templates/memory-seed.md.tmpl +3 -0
- package/skills/teamsmith/templates/pm-prompt.md.tmpl +20 -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 +682 -0
- package/skills/teamsmith/tests/bg-ledger.sh +307 -0
- package/skills/teamsmith/tests/checkout-shape-probe.sh +287 -58
- package/skills/teamsmith/tests/config-cli.sh +162 -288
- package/skills/teamsmith/tests/death-cause.sh +5 -2
- package/skills/teamsmith/tests/install-shape.sh +4 -2
- package/skills/teamsmith/tests/key-replies-pty.sh +375 -0
- package/skills/teamsmith/tests/key-replies-ui.sh +332 -0
- package/skills/teamsmith/tests/key-replies.sh +1075 -0
- package/skills/teamsmith/tests/ledger-ban.sh +5 -5
- package/skills/teamsmith/tests/ledger-claim.sh +247 -0
- package/skills/teamsmith/tests/lib/checkout-shape.sh +66 -14
- package/skills/teamsmith/tests/lib/model-policy.sh +26 -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 +136 -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 +372 -0
- package/skills/teamsmith/tests/lib/tmux-iso.sh +8 -0
- package/skills/teamsmith/tests/panel-b2.sh +1 -1
- package/skills/teamsmith/tests/panel-b3-stub.sh +27 -0
- package/skills/teamsmith/tests/panel-b3.sh +14 -10
- package/skills/teamsmith/tests/panel-choices.sh +74 -61
- package/skills/teamsmith/tests/panel-cpu.sh +1 -1
- package/skills/teamsmith/tests/panel-p21.sh +311 -190
- package/skills/teamsmith/tests/perf.sh +1 -1
- 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 +43 -22
- package/skills/teamsmith/tests/section-budgets.tsv +9 -5
- package/skills/teamsmith/tests/section-paths.tsv +26 -16
- package/skills/teamsmith/tests/section-select.sh +99 -16
- package/skills/teamsmith/tests/smoke.sh +930 -216
- 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 +1014 -0
- package/skills/teamsmith-init/SKILL.md +38 -38
- package/skills/teamsmith-init/references/bootstrap.md +6 -4
- package/skills/teamsmith-init/templates/bootstrap-prompt.md.tmpl +9 -5
|
@@ -0,0 +1,1014 @@
|
|
|
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,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|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"; 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
|
+
export TMUX_TMPDIR="$TMP/tmux"; mkdir -p "$TMUX_TMPDIR" "$TMP/bin"
|
|
318
|
+
REAL_TMUX="$(type -P tmux)"
|
|
319
|
+
printf '#!/usr/bin/env bash\nexec %q -L %q "$@"\n' "$REAL_TMUX" "$LIVE_SOCKET" > "$TMP/bin/tmux"; chmod +x "$TMP/bin/tmux"
|
|
320
|
+
export PATH="$TMP/bin:$PATH"
|
|
321
|
+
tmux_iso_require routing launch --tmpdir "$TMUX_TMPDIR" --sock-name "$LIVE_SOCKET" --own-root "$TMP"
|
|
322
|
+
before="$(sha "$STATE/dev.env")"; board="$(sha "$REPO/docs/team/BOARD.md")"
|
|
323
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --print
|
|
324
|
+
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"
|
|
325
|
+
check preview-no-prompt bash -c '! test -f "$1/prompt-dev-T1.txt" && ! test -f "$1/dev.pending"' _ "$STATE"
|
|
326
|
+
check preview-no-session bash -c '! tmux -L "$1" has-session 2>/dev/null' _ "$LIVE_SOCKET"
|
|
327
|
+
cp -p "$REPO/docs/team/tasks/T1-fixture.md" "$TMP/legal-brief"
|
|
328
|
+
for fault in missing blank duplicate malformed explore propose verify; do
|
|
329
|
+
cp -p "$TMP/legal-brief" "$REPO/docs/team/tasks/T1-fixture.md"
|
|
330
|
+
case "$fault" in
|
|
331
|
+
missing) sed -i '/^category:/d' "$REPO/docs/team/tasks/T1-fixture.md" ;;
|
|
332
|
+
blank) sed -i 's/^category:.*/category: /' "$REPO/docs/team/tasks/T1-fixture.md" ;;
|
|
333
|
+
duplicate) printf 'category: analysis\n' >> "$REPO/docs/team/tasks/T1-fixture.md" ;;
|
|
334
|
+
malformed) sed -i 's/^category:.*/category: Bad\/token/' "$REPO/docs/team/tasks/T1-fixture.md" ;;
|
|
335
|
+
*) sed -i "s/^phase:.*/phase: $fault/" "$REPO/docs/team/tasks/T1-fixture.md" ;;
|
|
336
|
+
esac
|
|
337
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --model vendor/strong:high --force --print
|
|
338
|
+
case "$fault" in explore|propose|verify) expected=0 ;; *) expected=1 ;; esac
|
|
339
|
+
check "category-explicit-phase-independent:$fault" eq "$RC" "$expected"
|
|
340
|
+
if [ "$expected" = 0 ]; then check "phase-does-not-infer-category:$fault" contains "$OUT" 'category=routine'; fi
|
|
341
|
+
check "category-fault-record-pure:$fault" eq "$(sha "$STATE/dev.env")" "$before"
|
|
342
|
+
check "category-fault-board-pure:$fault" eq "$(sha "$REPO/docs/team/BOARD.md")" "$board"
|
|
343
|
+
done
|
|
344
|
+
cp -p "$TMP/legal-brief" "$REPO/docs/team/tasks/T1-fixture.md"
|
|
345
|
+
brief T2 verify unmapped
|
|
346
|
+
run dispatch verify T2 docs/team/tasks/T2-fixture.md --model vendor/strong:high --force --print
|
|
347
|
+
check new-unmapped-category-override-refused eq "$RC" 1
|
|
348
|
+
check unmapped-override-no-board eq "$(sha "$REPO/docs/team/BOARD.md")" "$board"
|
|
349
|
+
check unmapped-override-no-assignment bash -c '! test -f "$1/verify.env" && ! test -f "$1/prompt-verify-T2.md"' _ "$STATE"
|
|
350
|
+
# F6:同一套守卫在**自定义词汇**下也成立 —— 新选择只要求「类别在当前映射里」,映射里没写的仍拒绝。
|
|
351
|
+
# 任务/分支/工作树仍用本组的 T1 夹具(不碰工作树身份),只换类别。
|
|
352
|
+
map_fixture="$(team_config_file_value "$CONFIG" TEAM_TASK_MODELS)"
|
|
353
|
+
run config set TEAM_TASK_MODELS 'maintenance=vendor/light' --yes
|
|
354
|
+
check new-selection-custom-map-ready eq "$RC" 0
|
|
355
|
+
sed -i 's/^category:.*/category: maintenance/' "$REPO/docs/team/tasks/T1-fixture.md"
|
|
356
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --print
|
|
357
|
+
check new-selection-custom-vocabulary eq "$RC" 0
|
|
358
|
+
check new-selection-custom-vocabulary-model contains "$OUT" 'model=vendor/light'
|
|
359
|
+
sed -i 's/^category:.*/category: ops/' "$REPO/docs/team/tasks/T1-fixture.md"
|
|
360
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --print
|
|
361
|
+
check new-selection-custom-vocabulary-unmapped-refused eq "$RC" 1
|
|
362
|
+
check new-selection-custom-vocabulary-unmapped-reason contains "$OUT" 'category 未映射:ops'
|
|
363
|
+
check new-selection-custom-vocabulary-no-assignment bash -c '! test -f "$1/dev.pending" && ! test -f "$1/dev.env"' _ "$STATE"
|
|
364
|
+
cp -p "$TMP/legal-brief" "$REPO/docs/team/tasks/T1-fixture.md"
|
|
365
|
+
run config set TEAM_TASK_MODELS "$map_fixture" --yes
|
|
366
|
+
check new-selection-custom-map-restored eq "$RC" 0
|
|
367
|
+
brief T2 verify routine
|
|
368
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --model vendor/strong:high --fresh
|
|
369
|
+
check first-recorded-launch eq "$RC" 0
|
|
370
|
+
check first-complete-record team_assignment_load dev
|
|
371
|
+
SID_A="${TEAM_ASSIGN[sid]:-missing}"
|
|
372
|
+
check argv-full-suffix grep -Fxq strong:high "$TMP/argv.log"
|
|
373
|
+
if has resume; then
|
|
374
|
+
tmux kill-window -t routing-fixture:dev
|
|
375
|
+
cp -p "$STATE/dev.env" "$TMP/trusted-assignment"
|
|
376
|
+
argv_before="$(sha "$TMP/argv.log")"
|
|
377
|
+
for fault in missing malformed task_file category worktree branch; do
|
|
378
|
+
cp -p "$TMP/trusted-assignment" "$STATE/dev.env"
|
|
379
|
+
case "$fault" in
|
|
380
|
+
missing) rm "$STATE/dev.env" ;;
|
|
381
|
+
malformed) sed -i 's/^assignment_version=.*/assignment_version=broken/' "$STATE/dev.env" ;;
|
|
382
|
+
task_file) sed -i "s|^taskfile=.*|taskfile=$REPO/docs/team/tasks/T2-fixture.md|" "$STATE/dev.env" ;;
|
|
383
|
+
category) sed -i 's/^category=.*/category=analysis/' "$STATE/dev.env" ;;
|
|
384
|
+
worktree) sed -i "s|^worktree=.*|worktree=$REPO/.worktrees/verify|" "$STATE/dev.env" ;;
|
|
385
|
+
branch) sed -i 's|^branch=.*|branch=task/T2-fixture|' "$STATE/dev.env" ;;
|
|
386
|
+
esac
|
|
387
|
+
damaged="$(sha "$STATE/dev.env")"
|
|
388
|
+
run resume --agent dev --dry-run
|
|
389
|
+
check "untrusted-recovery-refused:$fault" eq "$RC" 1
|
|
390
|
+
check "untrusted-recovery-record-pure:$fault" eq "$(sha "$STATE/dev.env")" "$damaged"
|
|
391
|
+
check "untrusted-recovery-no-launch:$fault" eq "$(sha "$TMP/argv.log")" "$argv_before"
|
|
392
|
+
done
|
|
393
|
+
cp -p "$TMP/trusted-assignment" "$STATE/dev.env"
|
|
394
|
+
run config set TEAM_TASK_MODELS 'analysis=vendor/new verify=vendor/verify' --yes
|
|
395
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --print
|
|
396
|
+
check deleted-routine-recovery eq "$RC" 0; check recovery-model contains "$OUT" 'vendor/strong:high'; check recovery-sid contains "$OUT" "$SID_A"
|
|
397
|
+
run dispatch verify T2 docs/team/tasks/T2-fixture.md --model vendor/strong:high --print
|
|
398
|
+
check new-unmapped-override-refused eq "$RC" 1
|
|
399
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --model vendor/strong:low --print
|
|
400
|
+
check suffix-change-requires-fresh eq "$RC" 1
|
|
401
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --fresh --print
|
|
402
|
+
check fresh-keeps-stored-model eq "$RC" 0; check fresh-model contains "$OUT" 'vendor/strong:high'
|
|
403
|
+
tmux_iso_require routing stop-fixture --tmpdir "$TMUX_TMPDIR" --sock-name "$LIVE_SOCKET" --own-root "$TMP"
|
|
404
|
+
(cd "$REPO" && tmux kill-window -t routing-fixture:dev)
|
|
405
|
+
run resume --agent dev --dry-run
|
|
406
|
+
check resume-stored-identity eq "$RC" 0; check resume-sid contains "$OUT" "$SID_A"
|
|
407
|
+
run resume --agent dev
|
|
408
|
+
check actual-resume-after-policy-removal eq "$RC" 0
|
|
409
|
+
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"
|
|
410
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --fresh
|
|
411
|
+
check actual-same-model-fresh-after-policy-removal eq "$RC" 0
|
|
412
|
+
check actual-fresh-record team_assignment_load dev
|
|
413
|
+
SID_FRESH="${TEAM_ASSIGN[sid]:-missing}"
|
|
414
|
+
check actual-fresh-SID-different bash -c '[ "$1" != "$2" ]' _ "$SID_A" "$SID_FRESH"
|
|
415
|
+
(cd "$REPO" && tmux kill-window -t routing-fixture:dev)
|
|
416
|
+
run resume --agent dev
|
|
417
|
+
check actual-resume-retains-fresh-identity eq "$RC" 0
|
|
418
|
+
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"
|
|
419
|
+
(cd "$REPO" && tmux kill-window -t routing-fixture:dev)
|
|
420
|
+
fi
|
|
421
|
+
if has dispatch; then routing_publication_probes; fi
|
|
422
|
+
fi
|
|
423
|
+
# Hook only the owned fixture shell; shipped files are never modified by these faults.
|
|
424
|
+
hooked() {
|
|
425
|
+
(cd "$REPO" && timeout 45 bash --noprofile --norc -c '
|
|
426
|
+
CMD=dispatch; ARGS=()
|
|
427
|
+
source "$1/scripts/lib/common.sh"
|
|
428
|
+
for lib in "$1"/scripts/lib/cmd-*.sh; do source "$lib"; done
|
|
429
|
+
team_load_config || exit
|
|
430
|
+
source "$2"
|
|
431
|
+
shift 2; team_cmd_dispatch "$@"
|
|
432
|
+
' _ "$SKILL" "$TMP/hook.sh" "$@")
|
|
433
|
+
}
|
|
434
|
+
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 $*"; }
|
|
435
|
+
stop_fixture_seat() { (cd "$REPO" && tmux kill-window -t "routing-fixture:$1") 2>/dev/null || true; }
|
|
436
|
+
assignment_snapshot() { printf '%s:%s:%s' "$(sha "$STATE/dev.env")" "$(sha "$STATE/dev.pending")" "$(sha "$REPO/docs/team/BOARD.md")"; }
|
|
437
|
+
if has boundary; then
|
|
438
|
+
routing_template_probes
|
|
439
|
+
routing_pm_template_probes
|
|
440
|
+
routing_expansion_probes worker
|
|
441
|
+
routing_expansion_probes pm
|
|
442
|
+
routing_role_probes worker
|
|
443
|
+
routing_role_probes pm
|
|
444
|
+
routing_resume_role_probes
|
|
445
|
+
fi
|
|
446
|
+
if has limits || has transaction; then
|
|
447
|
+
run config set TEAM_TASK_MODELS 'routine=vendor/routine analysis=vendor/analysis verify=vendor/verify' --yes
|
|
448
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --model vendor/strong:high --fresh
|
|
449
|
+
check advanced-setup-recorded-launch eq "$RC" 0
|
|
450
|
+
fi
|
|
451
|
+
if has limits; then
|
|
452
|
+
run config set TEAM_MODEL_LIMITS 'vendor/*=1' --yes
|
|
453
|
+
snap="$(assignment_snapshot)"; argv_before="$(sha "$TMP/argv.log")"
|
|
454
|
+
run dispatch verify T2 docs/team/tasks/T2-fixture.md --model vendor/strong:high --print
|
|
455
|
+
check positive-full-model-cap eq "$RC" 1
|
|
456
|
+
run dispatch verify T2 docs/team/tasks/T2-fixture.md --model vendor/different --print
|
|
457
|
+
check wildcard-bucket-counts-actual-peer eq "$RC" 1
|
|
458
|
+
check cap-refusal-keeps-assignment eq "$(assignment_snapshot)" "$snap"
|
|
459
|
+
check cap-refusal-no-launch eq "$(sha "$TMP/argv.log")" "$argv_before"
|
|
460
|
+
run config set TEAM_MODEL_LIMITS 'vendor/*=1 vendor/strong:low=1' --yes
|
|
461
|
+
run dispatch verify T2 docs/team/tasks/T2-fixture.md --model vendor/strong:low --print
|
|
462
|
+
check exact-suffix-bucket-independent eq "$RC" 0
|
|
463
|
+
run config set TEAM_MODEL_LIMITS 'vendor/*=1 *=0' --yes
|
|
464
|
+
run dispatch verify T2 docs/team/tasks/T2-fixture.md --model vendor/different --print
|
|
465
|
+
check zero-wildcard-does-not-erase-positive-cap eq "$RC" 1
|
|
466
|
+
cp "$STATE/dev.env" "$TMP/known-dev.env"
|
|
467
|
+
python3 - "$STATE/dev.env" <<'PY'
|
|
468
|
+
import pathlib,sys
|
|
469
|
+
p=pathlib.Path(sys.argv[1]); p.write_text(''.join(x for x in p.read_text().splitlines(True) if not x.startswith('model=')))
|
|
470
|
+
PY
|
|
471
|
+
run dispatch verify T2 docs/team/tasks/T2-fixture.md --model vendor/strong:high --force --print
|
|
472
|
+
check unknown-live-peer-fail-closed-even-force eq "$RC" 1
|
|
473
|
+
check unknown-live-peer-named contains "$OUT" 'unknown=dev'
|
|
474
|
+
check unknown-live-peer-clear-route contains "$OUT" 'teardown --agent dev'
|
|
475
|
+
snap="$(assignment_snapshot)"; argv_before="$(sha "$TMP/argv.log")"
|
|
476
|
+
run dispatch verify T2 docs/team/tasks/T2-fixture.md --model vendor/strong:high --force
|
|
477
|
+
check unknown-live-peer-real-launch-refused eq "$RC" 1
|
|
478
|
+
check unknown-live-peer-real-record-preserved eq "$(assignment_snapshot)" "$snap"
|
|
479
|
+
check unknown-live-peer-real-no-launch eq "$(sha "$TMP/argv.log")" "$argv_before"
|
|
480
|
+
run config set TEAM_MODEL_LIMITS 'vendor/*=0' --yes
|
|
481
|
+
run dispatch verify T2 docs/team/tasks/T2-fixture.md --model vendor/strong:high --print
|
|
482
|
+
check unlimited-does-not-demand-peer-model eq "$RC" 0
|
|
483
|
+
cp "$TMP/known-dev.env" "$STATE/dev.env"
|
|
484
|
+
# P228/R6(OBS1):模板没交付模型的活跃同伴(identity_via 里没有 model)同样是「完整已提交模型身份不存在」
|
|
485
|
+
# —— 不得按记录里的选择计数,正/通配限额下都 fail-closed(同一车道,新的一格)。
|
|
486
|
+
run config set TEAM_MODEL_LIMITS 'vendor/*=1' --yes
|
|
487
|
+
sed -i 's/^identity_via=.*/identity_via=provider,session_id/' "$STATE/dev.env"
|
|
488
|
+
run dispatch verify T2 docs/team/tasks/T2-fixture.md --model vendor/strong:high --force --print
|
|
489
|
+
check undelivered-model-peer-fail-closed eq "$RC" 1
|
|
490
|
+
check undelivered-model-peer-named contains "$OUT" 'unknown=dev'
|
|
491
|
+
cp "$TMP/known-dev.env" "$STATE/dev.env"
|
|
492
|
+
run config set TEAM_MODEL_LIMITS 'vendor/*=0' --yes
|
|
493
|
+
check pm-does-not-consume-worker-bucket bash -c '
|
|
494
|
+
source "$1/scripts/lib/common.sh"; for lib in "$1"/scripts/lib/cmd-*.sh; do source "$lib"; done; team_load_config
|
|
495
|
+
TEAM_AGENTS="dev pm verify"; TEAM_MODEL_LIMITS="vendor/*=1"
|
|
496
|
+
team_agent_live() { return 0; }
|
|
497
|
+
team_model_peers vendor/strong:high verify
|
|
498
|
+
[ "$TEAM_MODEL_KNOWN_COUNT" = 1 ] && [ -z "$TEAM_MODEL_UNKNOWN" ]
|
|
499
|
+
' _ "$SKILL"
|
|
500
|
+
stop_fixture_seat dev; stop_fixture_seat verify
|
|
501
|
+
run config set TEAM_MODEL_LIMITS 'vendor/*=1' --yes
|
|
502
|
+
for a in dev verify; do
|
|
503
|
+
id=T1; [ "$a" != verify ] || id=T2
|
|
504
|
+
(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") &
|
|
505
|
+
done
|
|
506
|
+
wait
|
|
507
|
+
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"
|
|
508
|
+
windows="$(cd "$REPO" && tmux list-windows -t routing-fixture -F '#{window_name}')"
|
|
509
|
+
check cross-seat-only-one-worker-window eq "$(printf '%s\n' "$windows" | grep -cE '^(dev|verify)$')" 1
|
|
510
|
+
stop_fixture_seat dev; stop_fixture_seat verify
|
|
511
|
+
run config set TEAM_MODEL_LIMITS '' --yes
|
|
512
|
+
fi
|
|
513
|
+
if has transaction; then
|
|
514
|
+
stop_fixture_seat dev
|
|
515
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --model vendor/strong:high --fresh
|
|
516
|
+
check transaction-initial-complete eq "$RC" 0
|
|
517
|
+
# Both processes must finish preflight on the same old generation before either admits.
|
|
518
|
+
cat > "$TMP/hook.sh" <<'HOOK'
|
|
519
|
+
team_dispatch_judge_seat_hint() {
|
|
520
|
+
if [ "${_TEAM_DISPATCH_PREFLIGHT_ONLY:-0}" = 1 ]; then
|
|
521
|
+
printf ready > "$TEAM_MAIN_ROOT/barrier-$FIXTURE_ATTEMPT"
|
|
522
|
+
local i; for ((i=0;i<200;i++)); do
|
|
523
|
+
[ ! -f "$TEAM_MAIN_ROOT/barrier-a" ] || [ ! -f "$TEAM_MAIN_ROOT/barrier-b" ] || return 0
|
|
524
|
+
sleep 0.02
|
|
525
|
+
done
|
|
526
|
+
return 1
|
|
527
|
+
fi
|
|
528
|
+
}
|
|
529
|
+
HOOK
|
|
530
|
+
calls_before="$(grep -c -- '^--provider$' "$TMP/argv.log")"
|
|
531
|
+
(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=$!
|
|
532
|
+
(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=$!
|
|
533
|
+
wait "$p1" "$p2"
|
|
534
|
+
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"
|
|
535
|
+
check same-seat-loser-no-second-launch eq "$(( $(grep -c -- '^--provider$' "$TMP/argv.log") - calls_before ))" 1
|
|
536
|
+
rm -f "$REPO/barrier-a" "$REPO/barrier-b"
|
|
537
|
+
# External edit bypasses the CLI config lock: final snapshot must still reject it.
|
|
538
|
+
cp "$CONFIG" "$TMP/config-before-race"
|
|
539
|
+
cat > "$TMP/hook.sh" <<'HOOK'
|
|
540
|
+
eval "$(declare -f team_dispatch_final_snapshot | sed '1s/team_dispatch_final_snapshot/fixture_original_snapshot/')"
|
|
541
|
+
team_dispatch_final_snapshot() { printf '\n# external edit\n' >> "$TEAM_CONFIG"; fixture_original_snapshot "$@"; }
|
|
542
|
+
HOOK
|
|
543
|
+
snap="$(assignment_snapshot)"; argv_before="$(sha "$TMP/argv.log")"
|
|
544
|
+
run_hook dev T1 docs/team/tasks/T1-fixture.md --fresh
|
|
545
|
+
check final-config-snapshot-refused eq "$RC" 1
|
|
546
|
+
check final-config-snapshot-record-preserved eq "$(assignment_snapshot)" "$snap"
|
|
547
|
+
check final-config-snapshot-no-launch eq "$(sha "$TMP/argv.log")" "$argv_before"
|
|
548
|
+
cp "$TMP/config-before-race" "$CONFIG"
|
|
549
|
+
cp "$REPO/docs/team/tasks/T1-fixture.md" "$TMP/brief-before-race"
|
|
550
|
+
cat > "$TMP/hook.sh" <<'HOOK'
|
|
551
|
+
eval "$(declare -f team_dispatch_final_snapshot | sed '1s/team_dispatch_final_snapshot/fixture_original_snapshot/')"
|
|
552
|
+
team_dispatch_final_snapshot() { printf '\nexternal brief edit\n' >> "$TEAM_MAIN_ROOT/docs/team/tasks/T1-fixture.md"; fixture_original_snapshot "$@"; }
|
|
553
|
+
HOOK
|
|
554
|
+
run_hook dev T1 docs/team/tasks/T1-fixture.md --fresh
|
|
555
|
+
check final-brief-snapshot-refused eq "$RC" 1
|
|
556
|
+
check final-brief-snapshot-record-preserved eq "$(assignment_snapshot)" "$snap"
|
|
557
|
+
cp "$TMP/brief-before-race" "$REPO/docs/team/tasks/T1-fixture.md"
|
|
558
|
+
# Actual startup failure: owned recording executable exits 9, never a real provider.
|
|
559
|
+
run config set TEAM_AGENT_CMD "$TMP/recording-pi --provider {provider} --model {model} --session-id {session_id}" --yes
|
|
560
|
+
touch "$TMP/fail-launch"; old="$(sha "$STATE/dev.env")"
|
|
561
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --fresh
|
|
562
|
+
check failed-launch-refused eq "$RC" 1
|
|
563
|
+
check failed-launch-old-record-bytes eq "$(sha "$STATE/dev.env")" "$old"
|
|
564
|
+
check failed-launch-nonce-diagnostic bash -c 'test -n "$(find "$1" -name "dispatch-dev.failed-*" -print -quit)"' _ "$STATE"
|
|
565
|
+
rm -f "$TMP/fail-launch"
|
|
566
|
+
run config set TEAM_AGENT_CMD '' --yes
|
|
567
|
+
cat > "$TMP/hook.sh" <<'HOOK'
|
|
568
|
+
eval "$(declare -f team_wait_launch_proof | sed '1s/team_wait_launch_proof/fixture_original_wait/')"
|
|
569
|
+
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; }
|
|
570
|
+
HOOK
|
|
571
|
+
run_hook dev T1 docs/team/tasks/T1-fixture.md --fresh
|
|
572
|
+
check stale-launch-proof-refused eq "$RC" 1
|
|
573
|
+
check stale-launch-proof-old-record eq "$(sha "$STATE/dev.env")" "$old"
|
|
574
|
+
check stale-launch-proof-diagnostic grep -q 'failed=no nonce proof' "$STATE/dispatch-dev.attempts.log"
|
|
575
|
+
cat > "$TMP/hook.sh" <<'HOOK'
|
|
576
|
+
mv() { local last="${!#}"; [ "$last" != "$TEAM_STATE_DIR/dev.env" ] || return 1; command mv "$@"; }
|
|
577
|
+
HOOK
|
|
578
|
+
run_hook dev T1 docs/team/tasks/T1-fixture.md --fresh
|
|
579
|
+
check failed-publication-refused eq "$RC" 1
|
|
580
|
+
check failed-publication-old-record-bytes eq "$(sha "$STATE/dev.env")" "$old"
|
|
581
|
+
check failed-publication-no-worker-window bash -c '! tmux list-windows -t routing-fixture -F "#{window_name}" 2>/dev/null | grep -Fxq dev'
|
|
582
|
+
cat > "$TMP/hook.sh" <<'HOOK'
|
|
583
|
+
team_board_set() { return 1; }
|
|
584
|
+
HOOK
|
|
585
|
+
run_hook dev T1 docs/team/tasks/T1-fixture.md --fresh
|
|
586
|
+
check board-failure-after-commit-not-rollback eq "$RC" 0
|
|
587
|
+
check board-failure-complete-record team_assignment_load dev
|
|
588
|
+
check board-failure-new-generation bash -c '[ "$1" != "$2" ]' _ "$(sha "$STATE/dev.env")" "$old"
|
|
589
|
+
check board-failure-pending-matches eq "$(awk -F= '$1=="launch_nonce"{print $2}' "$STATE/dev.pending")" "${TEAM_ASSIGN[launch_nonce]:-missing}"
|
|
590
|
+
stop_fixture_seat dev
|
|
591
|
+
cat > "$TMP/hook.sh" <<'HOOK'
|
|
592
|
+
eval "$(declare -f team_dispatch_prepare_record | sed '1s/team_dispatch_prepare_record/fixture_original_prepare/')"
|
|
593
|
+
team_dispatch_prepare_record() { fixture_original_prepare "$@" || return; kill -TERM "$BASHPID"; }
|
|
594
|
+
HOOK
|
|
595
|
+
old="$(sha "$STATE/dev.env")"; run_hook dev T1 docs/team/tasks/T1-fixture.md --fresh
|
|
596
|
+
check interrupted-before-commit eq "$RC" 143
|
|
597
|
+
check interrupted-before-commit-old-record eq "$(sha "$STATE/dev.env")" "$old"
|
|
598
|
+
pending_nonce="$(awk -F= '$1=="launch_nonce"{print $2}' "$STATE/dev.pending")"
|
|
599
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --print
|
|
600
|
+
check interrupted-pending-requires-explicit-fresh eq "$RC" 1
|
|
601
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --fresh
|
|
602
|
+
check interrupted-pending-fresh-takeover eq "$RC" 0
|
|
603
|
+
check interrupted-pending-preserved test -f "$STATE/dispatch-dev.interrupted-$pending_nonce"
|
|
604
|
+
# Crash AFTER low-model proof but BEFORE rename: a past complete high-model record cannot identify that live peer.
|
|
605
|
+
cat > "$TMP/hook.sh" <<'HOOK'
|
|
606
|
+
mv() { local last="${!#}"; if [ "$last" = "$TEAM_STATE_DIR/dev.env" ]; then kill -TERM "$BASHPID"; else command mv "$@"; fi; }
|
|
607
|
+
HOOK
|
|
608
|
+
old="$(sha "$STATE/dev.env")"
|
|
609
|
+
run_hook dev T1 docs/team/tasks/T1-fixture.md --fresh --model vendor/strong:low
|
|
610
|
+
check interrupted-proven-unpublished-launch eq "$RC" 143
|
|
611
|
+
check interrupted-proven-old-record-bytes eq "$(sha "$STATE/dev.env")" "$old"
|
|
612
|
+
run config set TEAM_MODEL_LIMITS 'vendor/strong:low=1' --yes
|
|
613
|
+
run dispatch verify T2 docs/team/tasks/T2-fixture.md --model vendor/strong:low --fresh --force --print
|
|
614
|
+
check interrupted-peer-positive-cap-unjudgeable eq "$RC" 1
|
|
615
|
+
check interrupted-peer-current-nonce-mismatch contains "$OUT" 'unknown=dev (interrupted pending launch/assignment nonce mismatch)'
|
|
616
|
+
run config set TEAM_MODEL_LIMITS '' --yes
|
|
617
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --fresh
|
|
618
|
+
check interrupted-proven-fresh-takeover eq "$RC" 0
|
|
619
|
+
cat > "$TMP/hook.sh" <<'HOOK'
|
|
620
|
+
team_board_set() { kill -TERM "$BASHPID"; }
|
|
621
|
+
HOOK
|
|
622
|
+
run_hook dev T1 docs/team/tasks/T1-fixture.md --fresh
|
|
623
|
+
check interrupted-after-commit eq "$RC" 143
|
|
624
|
+
check interrupted-after-commit-complete team_assignment_load dev
|
|
625
|
+
committed_sid="${TEAM_ASSIGN[sid]:-missing}"
|
|
626
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --print
|
|
627
|
+
check interrupted-after-commit-recoverable eq "$RC" 0
|
|
628
|
+
check interrupted-after-commit-sid contains "$OUT" "$committed_sid"
|
|
629
|
+
# Close/teardown queued AFTER proof cannot kill/clear a provisional worker through the held seat lock.
|
|
630
|
+
for clear_command in teardown close; do
|
|
631
|
+
rm -f "$REPO/proof-ready" "$REPO/proof-release"
|
|
632
|
+
cat > "$TMP/hook.sh" <<'HOOK'
|
|
633
|
+
eval "$(declare -f team_wait_launch_proof | sed '1s/team_wait_launch_proof/fixture_original_wait/')"
|
|
634
|
+
team_wait_launch_proof() {
|
|
635
|
+
local got i; got="$(fixture_original_wait "$@")" || return
|
|
636
|
+
printf ready > "$TEAM_MAIN_ROOT/proof-ready"
|
|
637
|
+
for ((i=0;i<300;i++)); do [ ! -f "$TEAM_MAIN_ROOT/proof-release" ] || { printf '%s\n' "$got"; return 0; }; sleep 0.02; done
|
|
638
|
+
return 1
|
|
639
|
+
}
|
|
640
|
+
HOOK
|
|
641
|
+
old="$(sha "$STATE/dev.env")"
|
|
642
|
+
(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=$!
|
|
643
|
+
for ((i=0;i<300;i++)); do [ ! -f "$REPO/proof-ready" ] || break; sleep 0.02; done
|
|
644
|
+
check "$clear_command-current-proof-held" test -f "$REPO/proof-ready"
|
|
645
|
+
if [ "$clear_command" = teardown ]; then args=(teardown --agent dev); else args=(close T1 --status dropped); fi
|
|
646
|
+
(cd "$REPO" && bash "$CLI" "${args[@]}" > "$TMP/proof-$clear_command-clear.log" 2>&1; printf '%s' "$?" > "$TMP/proof-$clear_command-clear.rc") & clear_pid=$!
|
|
647
|
+
sleep 0.3
|
|
648
|
+
check "$clear_command-waits-for-publication-lock" bash -c '[ ! -f "$1" ] && [ "$2" = "$3" ]' _ "$TMP/proof-$clear_command-clear.rc" "$(sha "$STATE/dev.env")" "$old"
|
|
649
|
+
touch "$REPO/proof-release"; wait "$pending_pid" "$clear_pid"
|
|
650
|
+
check "$clear_command-proof-dispatch-success" eq "$(<"$TMP/proof-$clear_command-dispatch.rc")" 0
|
|
651
|
+
check "$clear_command-queued-clear-success" eq "$(<"$TMP/proof-$clear_command-clear.rc")" 0
|
|
652
|
+
check "$clear_command-no-identity-resurrection" bash -c '[ ! -e "$1" ]' _ "$STATE/dev.env"
|
|
653
|
+
git -C "$REPO/.worktrees/dev" switch task/T1-fixture >/dev/null 2>&1
|
|
654
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --model vendor/strong:high --fresh
|
|
655
|
+
check "$clear_command-proof-fixture-restored" eq "$RC" 0
|
|
656
|
+
done
|
|
657
|
+
# Explicit teardown/close serialized against a dispatch paused BEFORE seat admission.
|
|
658
|
+
for clear_command in teardown close; do
|
|
659
|
+
rm -f "$REPO/clear-ready" "$REPO/clear-release"
|
|
660
|
+
cat > "$TMP/hook.sh" <<'HOOK'
|
|
661
|
+
team_dispatch_judge_seat_hint() {
|
|
662
|
+
if [ "${_TEAM_DISPATCH_PREFLIGHT_ONLY:-0}" = 1 ]; then
|
|
663
|
+
printf ready > "$TEAM_MAIN_ROOT/clear-ready"
|
|
664
|
+
local i; for ((i=0;i<250;i++)); do [ ! -f "$TEAM_MAIN_ROOT/clear-release" ] || return 0; sleep 0.02; done
|
|
665
|
+
return 1
|
|
666
|
+
fi
|
|
667
|
+
}
|
|
668
|
+
HOOK
|
|
669
|
+
(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=$!
|
|
670
|
+
for ((i=0;i<250;i++)); do [ ! -f "$REPO/clear-ready" ] || break; sleep 0.02; done
|
|
671
|
+
check "$clear_command-race-preflight-ready" test -f "$REPO/clear-ready"
|
|
672
|
+
if [ "$clear_command" = teardown ]; then run teardown --agent dev; else run close T1 --status dropped; fi
|
|
673
|
+
check "$clear_command-explicit-clear" eq "$RC" 0
|
|
674
|
+
touch "$REPO/clear-release"; wait "$p1"
|
|
675
|
+
check "$clear_command-race-no-resurrection" eq "$(<"$TMP/clear-$clear_command.rc")" 1
|
|
676
|
+
check "$clear_command-assignment-cleared" bash -c '! test -e "$1/dev.env"' _ "$STATE"
|
|
677
|
+
git -C "$REPO/.worktrees/dev" switch task/T1-fixture >/dev/null 2>&1
|
|
678
|
+
run dispatch dev T1 docs/team/tasks/T1-fixture.md --fresh --model vendor/strong:high
|
|
679
|
+
check "$clear_command-fixture-restored" eq "$RC" 0
|
|
680
|
+
done
|
|
681
|
+
# Deterministic generator forces both a recorded and an on-disk SID collision.
|
|
682
|
+
check collision-source-complete team_assignment_load dev
|
|
683
|
+
COLLISION_A="${TEAM_ASSIGN[sid]}"; dir="$(team_pi_session_dir "$REPO/.worktrees/dev")"; mkdir -p "$dir"
|
|
684
|
+
printf '{}' > "$dir/000_fixed-clock-history.jsonl"; printf 0 > "$TMP/candidate-count"
|
|
685
|
+
printf 'sid=fixed-clock-staged\n' > "$STATE/.assignment-collision-staged"
|
|
686
|
+
eval "$(declare -f team_sid_candidate | sed '1s/team_sid_candidate/fixture_original_candidate/')"
|
|
687
|
+
team_sid_candidate() {
|
|
688
|
+
local n; n="$(<"$TMP/candidate-count")"; n=$((n+1)); printf '%s' "$n" > "$TMP/candidate-count"
|
|
689
|
+
case "$n" in 1) printf '%s' "$COLLISION_A" ;; 2) printf fixed-clock-history ;; 3) printf fixed-clock-staged ;; *) printf fixed-clock-unique ;; esac
|
|
690
|
+
}
|
|
691
|
+
collision_sid="$(team_unique_sid dev "$REPO/.worktrees/dev")"
|
|
692
|
+
check forced-sid-collision-regenerated eq "$collision_sid" fixed-clock-unique
|
|
693
|
+
check forced-sid-collision-four-candidates eq "$(<"$TMP/candidate-count")" 4
|
|
694
|
+
eval "$(declare -f fixture_original_candidate | sed '1s/fixture_original_candidate/team_sid_candidate/')"
|
|
695
|
+
# Alive owners are not stolen; stale PID ownership is reclaimed with evidence.
|
|
696
|
+
check lock-owner-liveness-and-reclaim bash -c '
|
|
697
|
+
export TMPDIR="$2"; mkdir -p "$TMPDIR"; source "$1/scripts/lib/common.sh"
|
|
698
|
+
lock="$(team_lock_path seat:dev)"; mkdir -m 700 "$lock"
|
|
699
|
+
mine="$BASHPID"; printf "%s %s live\n" "$mine" "$(team_proc_start_identity "$mine")" > "$lock/owner"
|
|
700
|
+
TEAM_LOCK_WAIT_TICKS=1 team_with_lock seat:dev true && exit 1
|
|
701
|
+
printf "999999999 123 stale\n" > "$lock/owner"
|
|
702
|
+
team_with_lock seat:dev true || exit
|
|
703
|
+
test -n "$(find "$TMPDIR" -name "*.stale.*" -print -quit)"
|
|
704
|
+
' _ "$SKILL" "$TMP/lock-tests"
|
|
705
|
+
fi
|
|
706
|
+
if has sid-readers; then
|
|
707
|
+
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
|
|
708
|
+
dir="$(team_pi_session_dir "$REPO/.worktrees/dev")"; mkdir -p "$dir"
|
|
709
|
+
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"
|
|
710
|
+
printf '{"type":"session"}\n{"type":"message","message":{"role":"assistant","stopReason":"error","errorMessage":"403 invalid_api_key","content":[]}}\n' > "$dir/999_newer-B.jsonl"
|
|
711
|
+
check reader-session-A contains "$(team_agent_session_cols dev)" recorded-A.jsonl
|
|
712
|
+
check reader-cause-A contains "$(team_agent_session_latest dev)" recorded-A.jsonl
|
|
713
|
+
OUT="$(node "$SKILL/scripts/monitor.mjs" --root "$REPO" --only dev --json)"
|
|
714
|
+
check reader-monitor-A contains "$OUT" recorded-A.jsonl
|
|
715
|
+
routing_reader_matrix
|
|
716
|
+
rm "$dir/000_recorded-A.jsonl"
|
|
717
|
+
check reader-missing-A-no-B bash -c '! [[ "$1" == *newer-B* ]]' _ "$(team_agent_session_cols dev)"
|
|
718
|
+
cp "$STATE/dev.env" "$TMP/reader-record"; rm "$STATE/dev.env"
|
|
719
|
+
check reader-no-record-no-newest-fallback bash -c '! [[ "$1" == *newer-B* ]]' _ "$(team_agent_session_cols dev)"
|
|
720
|
+
OUT="$(node "$SKILL/scripts/monitor.mjs" --root "$REPO" --only dev --json)"
|
|
721
|
+
check reader-no-record-monitor-unavailable bash -c '! [[ "$1" == *newer-B.jsonl* ]]' _ "$OUT"
|
|
722
|
+
cp "$TMP/reader-record" "$STATE/dev.env"
|
|
723
|
+
: > "$dir/000_recorded-A.jsonl"
|
|
724
|
+
check reader-fresh-zero-bytes eq "$(team_session_bytes recorded-A "$REPO/.worktrees/dev")" 0
|
|
725
|
+
printf '{"type":"message","message":{"role":"assistant","content":[{"type":"text","text":"later recorded A growth"}]}}\n' >> "$dir/000_recorded-A.jsonl"
|
|
726
|
+
check reader-later-A-growth bash -c '[ "$1" -gt 0 ]' _ "$(team_session_bytes recorded-A "$REPO/.worktrees/dev")"
|
|
727
|
+
check reader-growth-still-A contains "$(team_agent_session_cols dev)" recorded-A.jsonl
|
|
728
|
+
rm "$dir/000_recorded-A.jsonl"
|
|
729
|
+
OUT="$(node "$SKILL/scripts/monitor.mjs" --root "$REPO" --only dev --json)"
|
|
730
|
+
check monitor-missing-A-unavailable contains "$OUT" 'committed SID unavailable'
|
|
731
|
+
fi
|
|
732
|
+
if has init; then
|
|
733
|
+
# P235 · S3 的前门:新鲜 init/bootstrap 必须拿显式类别映射 + 独立 PM 模型;旧配置在任何写入之前拒绝。
|
|
734
|
+
# 所有命令走真 CLI(不是 source 库),每条都记命令/rc/输出到 init-cmds.log。
|
|
735
|
+
iclean=(env -u TEAM_ROOT -u TEAM_MAIN_ROOT -u TEAM_ROOT_SOURCE -u TEAM_ROOT_WAS -u TEAM_PROJECT \
|
|
736
|
+
-u TEAM_SESSION -u TEAM_SESSION_FROM -u TEAM_PM_WINDOW -u TEAM_AGENTS -u TEAM_DOCS_DIR \
|
|
737
|
+
-u TEAM_WORKTREES_DIR -u TEAM_GATES -u TEAM_VCS -u TEAM_CONFIG -u TEAM_CONFIG_FILE \
|
|
738
|
+
-u TEAM_STATE_DIR -u TEAM_SKILL_DIR -u TEAM_PULSE_WINDOW -u TEAM_MODEL_RETIRED_ENV)
|
|
739
|
+
i_new_repo() { # <dir>
|
|
740
|
+
rm -rf "$1"; mkdir -p "$1"
|
|
741
|
+
( cd "$1" && git init -q -b main && git config user.name fixture && git config user.email fixture@example.invalid \
|
|
742
|
+
&& printf '# init fixture\n' > README.md && git add -A && git commit -qm fixture ) >/dev/null 2>&1
|
|
743
|
+
}
|
|
744
|
+
i_run() { # <dir> <team args...>
|
|
745
|
+
local d="$1"; shift
|
|
746
|
+
RC=0; OUT="$( cd "$d" && "${iclean[@]}" bash "$CLI" "$@" 2>&1 )" || RC=$?
|
|
747
|
+
{ printf 'command='; printf '%q ' "$@"; printf '\nrc=%s\n%s\n' "$RC" "$OUT"; } >> "$TMP/init-cmds.log"
|
|
748
|
+
return 0
|
|
749
|
+
}
|
|
750
|
+
i_hash_tree() { find "$1" -type f -print0 2>/dev/null | sort -z | xargs -0 -r sha256sum | sha256sum | cut -d' ' -f1; }
|
|
751
|
+
|
|
752
|
+
# ① 显式输入逐字渲染,绝不猜:配置里只有新策略键 + 用户给的值
|
|
753
|
+
i_fresh="$TMP/init-fresh"; i_new_repo "$i_fresh"
|
|
754
|
+
i_run "$i_fresh" init --no-skills --session init-fresh --agents 'dev verify' --vcs local --gates true \
|
|
755
|
+
--task-models 'maintenance=vendor/light audit=vendor/audit:high' --pm-model 'vendor/pm:max'
|
|
756
|
+
check init-fresh-rc eq "$RC" 0
|
|
757
|
+
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
|
|
758
|
+
check init-fresh-pm eq "$(grep -c "^TEAM_PM_MODEL='vendor/pm:max'\$" "$i_fresh/.pi/team/config.sh" || true)" 1
|
|
759
|
+
check init-fresh-no-retired-key bash -c '! grep -qE "^(export )?TEAM_(DEFAULT_MODEL|AGENT_MODELS)=" "$1"' _ "$i_fresh/.pi/team/config.sh"
|
|
760
|
+
check init-fresh-ledger test -f "$i_fresh/docs/team/BOARD.md"
|
|
761
|
+
check init-fresh-protocol grep -qF '<!-- teamsmith:begin -->' "$i_fresh/AGENTS.md"
|
|
762
|
+
i_run "$i_fresh" config list --json
|
|
763
|
+
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"
|
|
764
|
+
|
|
765
|
+
# ② 缺输入在配置/账本/安装/工作树/state 任何写入之前拒绝;退休旗标给修正路线
|
|
766
|
+
i_missing="$TMP/init-missing"; i_new_repo "$i_missing"
|
|
767
|
+
i_run "$i_missing" init --no-skills --session init-missing --agents dev --vcs local --gates true
|
|
768
|
+
check init-missing-refused bash -c '[ "$1" != 0 ]' _ "$RC"
|
|
769
|
+
check init-missing-route contains "$OUT" '--task-models'
|
|
770
|
+
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"
|
|
771
|
+
i_run "$i_missing" bootstrap --no-pulse --agents dev
|
|
772
|
+
check init-bootstrap-missing-refused bash -c '[ "$1" != 0 ]' _ "$RC"
|
|
773
|
+
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"
|
|
774
|
+
i_run "$i_missing" init --no-skills --session init-missing --agents dev --model p/old
|
|
775
|
+
check init-retired-flag eq "$RC" 2
|
|
776
|
+
check init-retired-route contains "$OUT" 'upgrade-models'
|
|
777
|
+
|
|
778
|
+
# ③ 非法输入拒绝且不落盘
|
|
779
|
+
i_bad="$TMP/init-bad"; i_new_repo "$i_bad"
|
|
780
|
+
i_run "$i_bad" init --no-skills --session init-bad --agents dev --task-models 'notamap' --pm-model 'vendor/pm'
|
|
781
|
+
check init-bad-map eq "$RC" 4
|
|
782
|
+
i_run "$i_bad" init --no-skills --session init-bad --agents dev --task-models 'routine=vendor/light' --pm-model 'badshape'
|
|
783
|
+
check init-bad-pm eq "$RC" 4
|
|
784
|
+
check init-bad-no-config bash -c '! test -e "$1/.pi/team/config.sh"' _ "$i_bad"
|
|
785
|
+
|
|
786
|
+
# ④ 合法新策略项目可无输入重入(策略逐字节保留);显式输入与现有策略不同时必须拒绝而不是静默忽略
|
|
787
|
+
i_before="$(sha "$i_fresh/.pi/team/config.sh")"
|
|
788
|
+
i_run "$i_fresh" init --no-skills --session init-fresh --agents dev --vcs local
|
|
789
|
+
check init-reentry-rc eq "$RC" 0
|
|
790
|
+
check init-reentry-keeps-policy eq "$(sha "$i_fresh/.pi/team/config.sh")" "$i_before"
|
|
791
|
+
i_run "$i_fresh" init --no-skills --session init-fresh --agents dev --vcs local --task-models 'routine=other/x' --pm-model 'vendor/pm:max'
|
|
792
|
+
check init-reentry-different-refused eq "$RC" 4
|
|
793
|
+
check init-reentry-different-no-write eq "$(sha "$i_fresh/.pi/team/config.sh")" "$i_before"
|
|
794
|
+
|
|
795
|
+
# ⑤ 旧配置:init / init --force / bootstrap / bootstrap --print 全在写入之前拒绝;身份与账本哈希不变
|
|
796
|
+
i_legacy="$TMP/init-legacy"; i_new_repo "$i_legacy"
|
|
797
|
+
mkdir -p "$i_legacy/.pi/team" "$i_legacy/docs/team"
|
|
798
|
+
cat > "$i_legacy/.pi/team/config.sh" <<'EOF'
|
|
799
|
+
TEAM_PROJECT='init-legacy'
|
|
800
|
+
TEAM_SESSION='init-legacy'
|
|
801
|
+
TEAM_DOCS_DIR='docs/team'
|
|
802
|
+
TEAM_AGENTS='dev verify'
|
|
803
|
+
TEAM_AGENT_MODELS='dev=p/old'
|
|
804
|
+
TEAM_DEFAULT_MODEL='p/old'
|
|
805
|
+
TEAM_GATES='true'
|
|
806
|
+
TEAM_VCS='local'
|
|
807
|
+
EOF
|
|
808
|
+
printf '# BOARD legacy\n' > "$i_legacy/docs/team/BOARD.md"
|
|
809
|
+
i_cfg0="$(sha "$i_legacy/.pi/team/config.sh")"; i_led0="$(i_hash_tree "$i_legacy/docs")"
|
|
810
|
+
i_run "$i_legacy" init --no-skills --session init-legacy --agents dev
|
|
811
|
+
check init-legacy-plain-refused bash -c '[ "$1" != 0 ]' _ "$RC"
|
|
812
|
+
check init-legacy-plain-route contains "$OUT" 'upgrade-models'
|
|
813
|
+
i_run "$i_legacy" init --force --no-skills --session init-legacy --agents dev --task-models 'routine=p/new' --pm-model 'p/pm'
|
|
814
|
+
check init-legacy-force-refused bash -c '[ "$1" != 0 ]' _ "$RC"
|
|
815
|
+
check init-legacy-force-route contains "$OUT" 'upgrade-models'
|
|
816
|
+
i_run "$i_legacy" bootstrap --no-pulse --agents dev
|
|
817
|
+
check init-legacy-bootstrap-refused bash -c '[ "$1" != 0 ]' _ "$RC"
|
|
818
|
+
i_run "$i_legacy" bootstrap --no-pulse --agents dev --print
|
|
819
|
+
check init-legacy-print-refused bash -c '[ "$1" != 0 ]' _ "$RC"
|
|
820
|
+
check init-legacy-print-readonly contains "$OUT" 'upgrade-models'
|
|
821
|
+
check init-legacy-config-unchanged eq "$(sha "$i_legacy/.pi/team/config.sh")" "$i_cfg0"
|
|
822
|
+
check init-legacy-ledger-unchanged eq "$(i_hash_tree "$i_legacy/docs")" "$i_led0"
|
|
823
|
+
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"
|
|
824
|
+
|
|
825
|
+
# ⑥ 新鲜 bootstrap:给输入才写;--print 只读
|
|
826
|
+
i_boot="$TMP/init-boot"; i_new_repo "$i_boot"
|
|
827
|
+
i_run "$i_boot" bootstrap --no-pulse --agents dev --task-models 'routine=vendor/light' --pm-model 'vendor/pm:high'
|
|
828
|
+
check init-bootstrap-fresh-rc eq "$RC" 0
|
|
829
|
+
check init-bootstrap-fresh-map eq "$(grep -c "^TEAM_TASK_MODELS='routine=vendor/light'\$" "$i_boot/.pi/team/config.sh" || true)" 1
|
|
830
|
+
check init-bootstrap-fresh-pm eq "$(grep -c "^TEAM_PM_MODEL='vendor/pm:high'\$" "$i_boot/.pi/team/config.sh" || true)" 1
|
|
831
|
+
i_print="$TMP/init-print"; i_new_repo "$i_print"
|
|
832
|
+
i_run "$i_print" bootstrap --no-pulse --print
|
|
833
|
+
check init-print-rc eq "$RC" 0
|
|
834
|
+
check init-print-no-writes bash -c '! test -e "$1/.pi/team" && ! test -e "$1/docs/team"' _ "$i_print"
|
|
835
|
+
|
|
836
|
+
# ⑦ 共享来源 vs 未链接的私有集成树:私有树里的 init/升级不碰保留源与链接;指南点名共享读取与四个门
|
|
837
|
+
i_shared="$TMP/shared-source"; rm -rf "$i_shared"; mkdir -p "$i_shared"
|
|
838
|
+
cp -a "$SKILL" "$i_shared/teamsmith"
|
|
839
|
+
i_shared0="$(i_hash_tree "$i_shared/teamsmith")"
|
|
840
|
+
ln -sfn "$i_shared/teamsmith" "$TMP/shared-link"
|
|
841
|
+
i_link0="$(readlink -f "$TMP/shared-link")"
|
|
842
|
+
i_private="$TMP/private-integration"; rm -rf "$i_private"; mkdir -p "$i_private/skills"
|
|
843
|
+
cp -a "$SKILL" "$i_private/skills/teamsmith"
|
|
844
|
+
i_repo="$TMP/init-private"; i_new_repo "$i_repo"
|
|
845
|
+
( cd "$i_repo" && "${iclean[@]}" bash "$i_private/skills/teamsmith/scripts/team" init --no-skills --session init-private \
|
|
846
|
+
--agents dev --vcs local --gates true --task-models 'routine=vendor/light' --pm-model 'vendor/pm' ) >/dev/null 2>&1
|
|
847
|
+
check init-private-rc eq "$?" 0
|
|
848
|
+
check init-private-shared-source-unchanged eq "$(i_hash_tree "$i_shared/teamsmith")" "$i_shared0"
|
|
849
|
+
check init-private-link-intact eq "$(readlink -f "$TMP/shared-link")" "$i_link0"
|
|
850
|
+
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"
|
|
851
|
+
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"
|
|
852
|
+
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"
|
|
853
|
+
fi
|
|
854
|
+
if has pm || has boundary; then
|
|
855
|
+
TEAM_TASK_MODELS='analysis=p/a verify=p/v'; TEAM_PM_MODEL='pm-provider/deep/model:high'; TEAM_PM_FRESH_LAUNCH=1
|
|
856
|
+
check pm-independent-model contains "$(team_pm_pi_args)" '--provider pm-provider --model deep/model:high'
|
|
857
|
+
for extra in '--model x/y' '--model=x/y' '--provider=other' '-m other' '--session=/tmp/f.jsonl' '-c' '-r' "$TMP/file.jsonl"; do
|
|
858
|
+
TEAM_PM_EXTRA_PI_ARGS="$extra"; rc=0; team_pm_identity_guard || rc=$?; check "boundary-reject:$extra" eq "$rc" 1
|
|
859
|
+
done
|
|
860
|
+
TEAM_PM_EXTRA_PI_ARGS='--no-tools'; check boundary-harmless team_pm_identity_guard
|
|
861
|
+
TEAM_PM_EXTRA_PI_ARGS=''; TEAM_PM_FRESH_LAUNCH=0
|
|
862
|
+
rm -f "$STATE/pm-launch.env"; rc=0; team_pm_identity_guard || rc=$?; check pm-unknown-needs-fresh eq "$rc" 1
|
|
863
|
+
TEAM_PM_FRESH_LAUNCH=1; team_pm_metadata_publish test-nonce
|
|
864
|
+
# P228/R6(OBS1):PM 记录也发布实际交付的身份字段(与 worker 同一份判据);成功行只声明已交付的
|
|
865
|
+
TEAM_PM_CMD="$TMP/recording-pi --model {model} {prompt}"; TEAM_PM_FRESH_LAUNCH=1
|
|
866
|
+
team_pm_metadata_publish fixture-partial-pm
|
|
867
|
+
check pm-partial-publication-record eq "$(grep '^identity_via=' "$STATE/pm-launch.env" | cut -d= -f2-)" 'model'
|
|
868
|
+
check pm-partial-publication-claim contains "$(TEAM_PM_MODEL='pm-provider/deep/model:high'; team_pm_identity_claim)" 'model=pm-provider/deep/model:high'
|
|
869
|
+
TEAM_PM_CMD="$TMP/recording-pi --ask {prompt}"; TEAM_PM_FRESH_LAUNCH=1
|
|
870
|
+
team_pm_metadata_publish fixture-opaque-pm
|
|
871
|
+
check pm-opaque-publication-record eq "$(grep '^identity_via=' "$STATE/pm-launch.env" | cut -d= -f2-)" ''
|
|
872
|
+
check pm-opaque-publication-claim contains "$(TEAM_PM_MODEL='pm-provider/deep/model:high'; team_pm_identity_claim)" 'model 未由模板交付'
|
|
873
|
+
TEAM_PM_CMD=''; TEAM_PM_FRESH_LAUNCH=1; team_pm_metadata_publish test-nonce
|
|
874
|
+
TEAM_PM_FRESH_LAUNCH=0; check pm-known-continues team_pm_identity_guard
|
|
875
|
+
routing_pm_metadata_matrix
|
|
876
|
+
TEAM_PM_MODEL='pm-provider/deep/model:low'; rc=0; team_pm_identity_guard || rc=$?; check pm-suffix-change-needs-fresh eq "$rc" 1
|
|
877
|
+
TEAM_PM_FRESH_LAUNCH=1; check pm-suffix-explicit-fresh team_pm_identity_guard
|
|
878
|
+
TEAM_PM_MODEL='pm-provider/deep/model:high'; TEAM_PM_FRESH_LAUNCH=0
|
|
879
|
+
TEAM_PM_SESSION_ID=unrecorded-sid; rc=0; team_pm_identity_guard || rc=$?; check pm-changed-resume-selector-needs-fresh eq "$rc" 1
|
|
880
|
+
TEAM_PM_SESSION_ID=''; TEAM_PM_FRESH_LAUNCH=1
|
|
881
|
+
TEAM_PM_RESUME_ARGS='--model wrong/model'; rc=0; team_pm_identity_guard || rc=$?; check pm-resume-args-cannot-shadow-model eq "$rc" 1
|
|
882
|
+
TEAM_PM_RESUME_ARGS=''
|
|
883
|
+
pm_no_respawn_guard() (
|
|
884
|
+
team_pm_window_exists() { return 0; }
|
|
885
|
+
team_pm_starting() { [ "$1" = ignored ]; } # replaced per arm below
|
|
886
|
+
team_tmux_respawn_pane() { touch "$TMP/pm-unexpected-respawn"; return 1; }
|
|
887
|
+
if [ "$1" = starting ]; then
|
|
888
|
+
team_pm_starting() { return 0; }
|
|
889
|
+
team_pm_starting_age() { printf '1\n'; }
|
|
890
|
+
team_pm_evidence() { printf 'owned test starting marker\n'; }
|
|
891
|
+
else
|
|
892
|
+
team_pm_starting() { return 1; }
|
|
893
|
+
team_pm_state() { printf 'running:owned-test-process\n'; }
|
|
894
|
+
fi
|
|
895
|
+
team_pm_start && [ ! -e "$TMP/pm-unexpected-respawn" ]
|
|
896
|
+
)
|
|
897
|
+
check pm-running-not-respawned pm_no_respawn_guard running
|
|
898
|
+
check pm-starting-not-respawned pm_no_respawn_guard starting
|
|
899
|
+
pm_publication_failure() (
|
|
900
|
+
old="$(sha "$STATE/pm-launch.env")"
|
|
901
|
+
team_pm_window_exists() { return 0; }
|
|
902
|
+
team_pm_starting() { return 1; }
|
|
903
|
+
team_pm_state() { printf 'idle:test\n'; }
|
|
904
|
+
team_pm_check_launch() { return 0; }
|
|
905
|
+
team_pm_check_bin() { return 0; }
|
|
906
|
+
team_pm_write_prompt() { printf '%s\n' "$TMP/pm-fixture-prompt"; }
|
|
907
|
+
team_pm_launch_cmd() { printf 'sleep 300\n'; }
|
|
908
|
+
team_pm_pane_agent_pid() { tmux display-message -p -t routing-fixture:pm '#{pane_pid}'; }
|
|
909
|
+
team_pm_launch_diag() { printf 'publication failure before stop\n' > "$TMP/pm-publication-diagnostic"; }
|
|
910
|
+
mv() { return 1; }
|
|
911
|
+
# The recording launcher owns an idle pm window already; do not create an ambiguous duplicate name.
|
|
912
|
+
if ! tmux list-windows -t routing-fixture -F '#{window_name}' | grep -Fxq pm; then
|
|
913
|
+
tmux new-window -d -t routing-fixture -n pm 'sleep 300' || return 1
|
|
914
|
+
fi
|
|
915
|
+
tmux list-windows -t routing-fixture -F '#{window_name} #{pane_id}' > "$TMP/pm-windows-before.log"
|
|
916
|
+
rc=0; team_pm_start || rc=$?
|
|
917
|
+
printf 'pm start rc=%s\n' "$rc" > "$TMP/pm-rollback-result.log"
|
|
918
|
+
[ "$rc" = 1 ] && [ "$(sha "$STATE/pm-launch.env")" = "$old" ] &&
|
|
919
|
+
[ -s "$TMP/pm-publication-diagnostic" ] && [ ! -e "$STATE/pm.pid" ] &&
|
|
920
|
+
[ ! -e "$STATE/pm.pid.proof" ] && ! tmux list-windows -t routing-fixture -F '#{window_name}' 2>/dev/null | grep -Fxq pm
|
|
921
|
+
)
|
|
922
|
+
if [ -n "${LIVE_SOCKET:-}" ]; then check pm-publication-failure-stops-uncommitted pm_publication_failure; fi
|
|
923
|
+
fi
|
|
924
|
+
if has flip; then
|
|
925
|
+
CORE='policy,machine,init,config,upgrade,dispatch,resume,transaction,limits,preview,sid-readers,pm,boundary'
|
|
926
|
+
# One green baseline and one green restoration of the whole slice; each red arm has its own copy.
|
|
927
|
+
flip_run() {
|
|
928
|
+
local tag="$1" tree="$2" groups="$3" rc=0
|
|
929
|
+
TEAM_ROUTING_TREE="$tree" TEAM_ROUTING_EVIDENCE="$TMP/flip-evidence/$tag" timeout 900 bash "$here/task-model-routing.sh" --select "$groups" > "$TMP/flip-$tag.log" 2>&1 || rc=$?
|
|
930
|
+
printf 'CONTROL %s rc=%s log=%s\n' "$tag" "$rc" "$TMP/flip-$tag.log"
|
|
931
|
+
tail -4 "$TMP/flip-$tag.log"
|
|
932
|
+
FLIP_RC="$rc"
|
|
933
|
+
}
|
|
934
|
+
flip_run baseline "$TREE" "$CORE"
|
|
935
|
+
check flip-baseline-green eq "$FLIP_RC" 0
|
|
936
|
+
if [ "$FLIP_RC" = 0 ]; then
|
|
937
|
+
for mutation in unmapped-override required-categories fingerprint expanding-quote recovery-drift partial-publication unknown-as-zero latest-shell latest-monitor pm-fallback pm-publication extra-shadow template-shadow template-unbound template-roles monitor-record-drift literal-shell-expansion pm-literal-resplit worker-literal-resplit identity-overclaim init-legacy-proceeds template-retired-key; do
|
|
938
|
+
case "$mutation" in
|
|
939
|
+
unmapped-override) groups=dispatch ;;
|
|
940
|
+
required-categories) groups=policy,config,upgrade,dispatch ;;
|
|
941
|
+
identity-overclaim) groups=dispatch,limits ;;
|
|
942
|
+
fingerprint|expanding-quote) groups=config ;;
|
|
943
|
+
recovery-drift) groups=resume ;;
|
|
944
|
+
partial-publication) groups=transaction ;;
|
|
945
|
+
unknown-as-zero) groups=limits ;;
|
|
946
|
+
latest-shell|latest-monitor) groups=sid-readers ;;
|
|
947
|
+
pm-fallback) groups=pm ;;
|
|
948
|
+
pm-publication) groups=dispatch,pm ;;
|
|
949
|
+
extra-shadow|template-shadow|template-unbound|template-roles|literal-shell-expansion|pm-literal-resplit|worker-literal-resplit) groups=boundary ;;
|
|
950
|
+
monitor-record-drift) groups=sid-readers ;;
|
|
951
|
+
init-legacy-proceeds|template-retired-key) groups=init ;;
|
|
952
|
+
esac
|
|
953
|
+
scratch="$TMP/mutants/$mutation"; mkdir -p "$scratch/skills/teamsmith"; touch "$scratch/.routing-mutant"
|
|
954
|
+
for source_dir in scripts references templates extensions; do
|
|
955
|
+
[ ! -d "$SKILL/$source_dir" ] || cp -a "$SKILL/$source_dir" "$scratch/skills/teamsmith/"
|
|
956
|
+
done
|
|
957
|
+
before="$(find "$scratch/skills/teamsmith/scripts" -type f -print0 | sort -z | xargs -0 sha256sum | sha256sum | cut -d' ' -f1)"
|
|
958
|
+
python3 "$here/lib/model-routing-flips.py" "$scratch" "$mutation" > "$TMP/mutation-$mutation.json"
|
|
959
|
+
check "flip-$mutation-target-matched" eq "$?" 0
|
|
960
|
+
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"
|
|
961
|
+
flip_run "$mutation" "$scratch" "$groups"
|
|
962
|
+
check "flip-$mutation-red" eq "$FLIP_RC" 1
|
|
963
|
+
check "flip-$mutation-named-assertion" grep -q '^FAIL ' "$TMP/flip-$mutation.log"
|
|
964
|
+
case "$mutation" in
|
|
965
|
+
required-categories)
|
|
966
|
+
check flip-required-categories-policy grep -q '^FAIL policy-custom-vocabulary-only$' "$TMP/flip-$mutation.log"
|
|
967
|
+
check flip-required-categories-writer grep -q '^FAIL map-custom-vocabulary-write$' "$TMP/flip-$mutation.log"
|
|
968
|
+
check flip-required-categories-upgrade grep -q '^FAIL upgrade-custom-vocabulary$' "$TMP/flip-$mutation.log"
|
|
969
|
+
check flip-required-categories-selection grep -q '^FAIL new-selection-custom-vocabulary$' "$TMP/flip-$mutation.log" ;;
|
|
970
|
+
identity-overclaim)
|
|
971
|
+
check flip-identity-overclaim-record grep -q '^FAIL publication-record:model-only$' "$TMP/flip-$mutation.log"
|
|
972
|
+
check flip-identity-overclaim-argv grep -q '^FAIL publication-record-equals-argv:model-only$' "$TMP/flip-$mutation.log"
|
|
973
|
+
check flip-identity-overclaim-opaque grep -q '^FAIL publication-record:opaque$' "$TMP/flip-$mutation.log"
|
|
974
|
+
check flip-identity-overclaim-claim grep -q '^FAIL publication-claim-gap:model-only$' "$TMP/flip-$mutation.log" ;;
|
|
975
|
+
template-shadow) check flip-template-shadow-specific-worker grep -q '^FAIL template-refused:all-hardcoded:preview$' "$TMP/flip-$mutation.log"
|
|
976
|
+
check flip-template-shadow-specific-pm grep -q '^FAIL pm-template-refused:provider:launch$' "$TMP/flip-$mutation.log" ;;
|
|
977
|
+
template-unbound)
|
|
978
|
+
check flip-unbound-worker-positional grep -q '^FAIL template-refused:positional-model:launch$' "$TMP/flip-$mutation.log"
|
|
979
|
+
check flip-unbound-worker-data grep -q '^FAIL template-refused:data-sid:preview$' "$TMP/flip-$mutation.log"
|
|
980
|
+
check flip-unbound-pm-positional grep -q '^FAIL pm-custom-missing-refused:positional-model:launch$' "$TMP/flip-$mutation.log"
|
|
981
|
+
check flip-unbound-pm-data grep -q '^FAIL pm-template-refused:data-provider:preview$' "$TMP/flip-$mutation.log" ;;
|
|
982
|
+
template-roles)
|
|
983
|
+
check flip-role-worker-selector-as-data grep -q '^FAIL worker-role-refused:model:--skill:launch$' "$TMP/flip-$mutation.log"
|
|
984
|
+
check flip-role-pm-selector-as-data grep -q '^FAIL pm-role-refused:provider:--skill:launch$' "$TMP/flip-$mutation.log"
|
|
985
|
+
check flip-role-pm-resume-data grep -q '^FAIL pm-role-resume-refused:builtin:--skill --continue:launch$' "$TMP/flip-$mutation.log" ;;
|
|
986
|
+
monitor-record-drift) check flip-monitor-record-drift-specific-nonce grep -q '^FAIL reader-monitor-unavailable:nonce$' "$TMP/flip-$mutation.log" ;;
|
|
987
|
+
literal-shell-expansion)
|
|
988
|
+
check flip-literal-shell-specific-worker-template grep -q '^FAIL worker-expansion-refused:template:model-glob:launch$' "$TMP/flip-$mutation.log"
|
|
989
|
+
check flip-literal-shell-specific-worker-extra grep -q '^FAIL worker-expansion-refused:extra:model-glob:launch$' "$TMP/flip-$mutation.log"
|
|
990
|
+
check flip-literal-shell-specific-pm-template grep -q '^FAIL pm-expansion-refused:template:model-glob:launch$' "$TMP/flip-$mutation.log"
|
|
991
|
+
check flip-literal-shell-specific-pm-extra grep -q '^FAIL pm-expansion-refused:extra:model-glob:launch$' "$TMP/flip-$mutation.log" ;;
|
|
992
|
+
pm-literal-resplit)
|
|
993
|
+
check flip-pm-resplit-specific-extra grep -q '^FAIL pm-expansion-literal-argv:extra$' "$TMP/flip-$mutation.log"
|
|
994
|
+
check flip-pm-resplit-specific-resume grep -q '^FAIL pm-resume-literal-argv:builtin$' "$TMP/flip-$mutation.log" ;;
|
|
995
|
+
worker-literal-resplit)
|
|
996
|
+
check flip-worker-resplit-specific-extra grep -q '^FAIL worker-expansion-literal-argv:extra$' "$TMP/flip-$mutation.log" ;;
|
|
997
|
+
init-legacy-proceeds)
|
|
998
|
+
check flip-init-legacy-proceeds-plain grep -q '^FAIL init-legacy-plain-refused$' "$TMP/flip-$mutation.log"
|
|
999
|
+
check flip-init-legacy-proceeds-force grep -q '^FAIL init-legacy-force-refused$' "$TMP/flip-$mutation.log"
|
|
1000
|
+
check flip-init-legacy-proceeds-bootstrap grep -q '^FAIL init-legacy-bootstrap-refused$' "$TMP/flip-$mutation.log" ;;
|
|
1001
|
+
template-retired-key)
|
|
1002
|
+
check flip-template-retired-key-specific grep -q '^FAIL init-fresh-no-retired-key$' "$TMP/flip-$mutation.log" ;;
|
|
1003
|
+
esac
|
|
1004
|
+
cp -a "$SKILL/scripts/." "$scratch/skills/teamsmith/scripts/"
|
|
1005
|
+
restored="$(find "$scratch/skills/teamsmith/scripts" -type f -print0 | sort -z | xargs -0 sha256sum | sha256sum | cut -d' ' -f1)"
|
|
1006
|
+
check "flip-$mutation-source-restored" eq "$restored" "$before"
|
|
1007
|
+
printf 'CONTROL %s source_before=%s source_restored=%s\n' "$mutation" "$before" "$restored"
|
|
1008
|
+
done
|
|
1009
|
+
flip_run restored "$TREE" "$CORE"
|
|
1010
|
+
check flip-restored-all-green eq "$FLIP_RC" 0
|
|
1011
|
+
fi
|
|
1012
|
+
fi
|
|
1013
|
+
printf '\nRESULT pass=%s fail=%s selected=%s\n' "$PASS" "$FAIL" "$SELECT"
|
|
1014
|
+
[ "$FAIL" = 0 ]
|