teamsmith 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/package.json +1 -1
- package/skills/teamsmith/CHANGELOG.md +69 -0
- package/skills/teamsmith/SKILL.md +20 -13
- package/skills/teamsmith/extension/team-inbox-watch.ts +5 -3
- package/skills/teamsmith/extension/team-notify.ts +37 -6
- package/skills/teamsmith/extension/team.ts +438 -0
- package/skills/teamsmith/references/config.md +39 -6
- package/skills/teamsmith/references/migration.md +197 -47
- package/skills/teamsmith/references/protocol.md +201 -30
- package/skills/teamsmith/references/troubleshooting.md +130 -10
- package/skills/teamsmith/references/workflows.md +36 -2
- package/skills/teamsmith/scripts/lib/cmd-agents.sh +318 -23
- package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +2 -2
- package/skills/teamsmith/scripts/lib/cmd-config.sh +349 -67
- 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 +30 -103
- package/skills/teamsmith/scripts/lib/cmd-reap.sh +277 -0
- package/skills/teamsmith/scripts/lib/cmd-reply.sh +3 -3
- package/skills/teamsmith/scripts/lib/cmd-review.sh +182 -32
- package/skills/teamsmith/scripts/lib/cmd-status.sh +234 -21
- package/skills/teamsmith/scripts/lib/cmd-update.sh +36 -7
- package/skills/teamsmith/scripts/lib/cmd-watch.sh +564 -46
- package/skills/teamsmith/scripts/lib/common.sh +1004 -245
- package/skills/teamsmith/scripts/lib/gate-lock.sh +582 -0
- package/skills/teamsmith/scripts/panel/draft-send.sh +11 -1
- package/skills/teamsmith/scripts/panel/panel.js +211 -211
- package/skills/teamsmith/scripts/panel/src/App.tsx +58 -21
- package/skills/teamsmith/scripts/panel/src/clipboard.ts +12 -5
- package/skills/teamsmith/scripts/panel/src/compose.ts +6 -3
- package/skills/teamsmith/scripts/panel/src/data.ts +51 -5
- package/skills/teamsmith/scripts/panel/src/layout.ts +209 -69
- package/skills/teamsmith/scripts/panel/src/main.tsx +37 -8
- package/skills/teamsmith/scripts/panel/src/strings/en.ts +39 -29
- package/skills/teamsmith/scripts/panel/src/strings/zh.ts +41 -31
- package/skills/teamsmith/scripts/panel/src/types.ts +28 -3
- package/skills/teamsmith/scripts/replies.mjs +4 -1
- package/skills/teamsmith/scripts/shim/killall +10 -0
- package/skills/teamsmith/scripts/shim/pgrep +10 -0
- package/skills/teamsmith/scripts/shim/pidof +10 -0
- package/skills/teamsmith/scripts/shim/pkill +10 -0
- package/skills/teamsmith/scripts/shim/signal-gate +108 -31
- 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 +19 -6
- package/skills/teamsmith/templates/AGENTS.section.md.tmpl +8 -1
- package/skills/teamsmith/templates/config.sh.tmpl +20 -1
- package/skills/teamsmith/templates/pm-prompt.md.tmpl +21 -0
- package/skills/teamsmith/tests/README.md +31 -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 +83 -54
- package/skills/teamsmith/tests/config-cli.sh +184 -32
- 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-p158.sh +2 -1
- package/skills/teamsmith/tests/flip-p308-skip-not-pass.sh +151 -0
- package/skills/teamsmith/tests/flip-p310-lock.sh +210 -0
- package/skills/teamsmith/tests/flip-p310-socket.sh +125 -0
- package/skills/teamsmith/tests/gate-guard.sh +52 -79
- package/skills/teamsmith/tests/help-surface.sh +1664 -0
- package/skills/teamsmith/tests/install-shape.sh +359 -22
- package/skills/teamsmith/tests/key-replies-pty.sh +9 -10
- package/skills/teamsmith/tests/key-replies-ui.sh +2 -8
- package/skills/teamsmith/tests/key-replies.sh +281 -28
- package/skills/teamsmith/tests/ledger-ban.sh +5 -4
- package/skills/teamsmith/tests/ledger-claim.sh +2 -1
- package/skills/teamsmith/tests/lib/bounded-spin.sh +90 -0
- package/skills/teamsmith/tests/lib/model-policy.sh +4 -0
- package/skills/teamsmith/tests/lib/model-routing-flips.py +51 -0
- package/skills/teamsmith/tests/lib/pty-wait.sh +21 -111
- package/skills/teamsmith/tests/lib/reply-fixture.sh +4 -9
- package/skills/teamsmith/tests/lib/section-guard.sh +316 -164
- 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 +31 -13
- package/skills/teamsmith/tests/loop-inventory.tsv +83 -77
- package/skills/teamsmith/tests/panel-b2.sh +430 -352
- package/skills/teamsmith/tests/panel-b3-stub.sh +112 -4
- package/skills/teamsmith/tests/panel-b3.sh +314 -62
- package/skills/teamsmith/tests/panel-choices.sh +11 -6
- package/skills/teamsmith/tests/panel-cpu.sh +43 -130
- package/skills/teamsmith/tests/panel-p21.sh +251 -265
- package/skills/teamsmith/tests/panel-snapshots.sh +41 -225
- package/skills/teamsmith/tests/panel-strings.mjs +33 -18
- package/skills/teamsmith/tests/perf.sh +187 -396
- package/skills/teamsmith/tests/routes.sh +440 -117
- package/skills/teamsmith/tests/seat-interrupt.sh +1012 -0
- package/skills/teamsmith/tests/seat-visibility.sh +675 -0
- package/skills/teamsmith/tests/section-guard.sh +13 -102
- package/skills/teamsmith/tests/section-needs-audit.sh +24 -7
- package/skills/teamsmith/tests/section-paths.tsv +32 -18
- package/skills/teamsmith/tests/section-select.sh +371 -19
- package/skills/teamsmith/tests/signal-gate.sh +249 -27
- package/skills/teamsmith/tests/signal-lint-legacy.txt +4 -1
- package/skills/teamsmith/tests/slash-team-e2e.sh +323 -0
- package/skills/teamsmith/tests/slash-team.sh +617 -0
- package/skills/teamsmith/tests/slice-coverage.sh +206 -0
- package/skills/teamsmith/tests/smoke.sh +3595 -788
- package/skills/teamsmith/tests/task-model-routing.sh +530 -15
- package/skills/teamsmith/tests/team-bg-stop.sh +18 -10
- 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/tests/workflow-entry.sh +207 -0
- package/skills/teamsmith-init/SKILL.md +12 -12
- package/skills/teamsmith-init/references/bootstrap.md +3 -3
- package/skills/teamsmith/tests/flip-glue.sh +0 -162
- package/skills/teamsmith/tests/flip-m12-26c.sh +0 -129
- package/skills/teamsmith/tests/flip-m12.sh +0 -185
- package/skills/teamsmith/tests/flip-m16.sh +0 -166
- package/skills/teamsmith/tests/flip-m17.sh +0 -204
- package/skills/teamsmith/tests/flip-m34.sh +0 -96
- package/skills/teamsmith/tests/flip-m37.sh +0 -185
- package/skills/teamsmith/tests/flip-m4.3.sh +0 -375
- package/skills/teamsmith/tests/flip-m43.sh +0 -128
- package/skills/teamsmith/tests/flip-m45.sh +0 -244
- package/skills/teamsmith/tests/flip-m46.sh +0 -238
- package/skills/teamsmith/tests/flip-m48.sh +0 -304
- package/skills/teamsmith/tests/flip-m6.2.sh +0 -205
- package/skills/teamsmith/tests/flip-m6.3.sh +0 -283
- package/skills/teamsmith/tests/flip-m6.4.sh +0 -267
- package/skills/teamsmith/tests/flip-m6.5.sh +0 -113
- package/skills/teamsmith/tests/flip-m7.1.sh +0 -135
- package/skills/teamsmith/tests/flip-m7.2.sh +0 -321
- package/skills/teamsmith/tests/flip-p144.sh +0 -112
- package/skills/teamsmith/tests/flip-p156.sh +0 -133
- package/skills/teamsmith/tests/flip-p160.sh +0 -182
- package/skills/teamsmith/tests/flip-p171.sh +0 -249
- package/skills/teamsmith/tests/flip-p18.1.sh +0 -95
- package/skills/teamsmith/tests/flip-p20.sh +0 -286
- package/skills/teamsmith/tests/flip-p201.sh +0 -249
- package/skills/teamsmith/tests/flip-p210.sh +0 -239
- package/skills/teamsmith/tests/flip-p211.sh +0 -152
- package/skills/teamsmith/tests/flip-p217.sh +0 -288
- package/skills/teamsmith/tests/flip-p22.sh +0 -123
- package/skills/teamsmith/tests/flip-p23.sh +0 -239
- package/skills/teamsmith/tests/flip-p25.sh +0 -165
- package/skills/teamsmith/tests/flip-p71.sh +0 -184
- package/skills/teamsmith/tests/flip-p72.sh +0 -202
- package/skills/teamsmith/tests/load-experiment.sh +0 -290
- package/skills/teamsmith/tests/panel-cpu-premise.sh +0 -173
- package/skills/teamsmith/tests/panel-flip-m54.sh +0 -207
- package/skills/teamsmith/tests/panel-flip-p123.sh +0 -278
- package/skills/teamsmith/tests/panel-flip-p125.sh +0 -318
- package/skills/teamsmith/tests/panel-flip-p128.sh +0 -259
- package/skills/teamsmith/tests/panel-keyprobe-stub.sh +0 -41
- package/skills/teamsmith/tests/panel-keyprobe.sh +0 -82
- package/skills/teamsmith/tests/panel-knobs.sh +0 -83
- package/skills/teamsmith/tests/section-budgets.tsv +0 -154
- package/skills/teamsmith/tests/team-bg-flip.sh +0 -239
- package/skills/teamsmith/tests/team-inbox-watch-flip.sh +0 -191
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# flip-p310-lock.sh — P310 ② 的翻转夹具:嵌套 review 靠**进程树 + starttime 的证明**认出祖辈持锁
|
|
3
|
+
#
|
|
4
|
+
# bash skills/teamsmith/tests/flip-p310-lock.sh [--keep]
|
|
5
|
+
#
|
|
6
|
+
# 事故形状(P288 / 6f1ed69d 之后):修 F4(写权不可继承)时套件拿到锁就 `unset SMOKE_LOCK_WRAPPED`,
|
|
7
|
+
# 而 `cmd-review.sh` 的「祖先持锁 → 不排队」仍看这个**可继承的环境标记** → 嵌套 review 认不出祖辈正
|
|
8
|
+
# 握着锁,反向排到自己祖先的后头(等满上限 / 段预算超时,§10 的 TIMEOUT)。
|
|
9
|
+
#
|
|
10
|
+
# 三条腿(都在**私有锁 + 私有临时根**上跑;不碰机器锁,不碰别的项目的目录;只对自己 spawn 的进程
|
|
11
|
+
# 发信号):
|
|
12
|
+
# leg green :真代码 + **真祖辈**持两把锁并写了记录 → 子 review 不排队(queued=0s)、rc=0,
|
|
13
|
+
# 记录写「已由祖先持有(进程树 + starttime 证明:祖辈 pid=N)」。
|
|
14
|
+
# leg red :同一现场、判据**回退成看环境标记**(镜像树里只改 cmd-review.sh 那一行,改动前的形状)
|
|
15
|
+
# → 必须排队撞上限:rc=1、记录写「排队等满上限」且**没有**「已由祖先持有」。
|
|
16
|
+
# leg control:持锁者是**非祖辈**(兄弟 flock + 旧形状持有者记录),review 仍是某个 shell 的子进程
|
|
17
|
+
# (所以「有祖先」这件事成立,但祖先没持锁)→ 必须照常排队。
|
|
18
|
+
# 判绿:三条都按预期。全绿 exit 0;有腿没按预期 → exit 1;夹具前提不成立(改不动镜像/建不出树)→ 2。
|
|
19
|
+
set -uo pipefail
|
|
20
|
+
|
|
21
|
+
SELF_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
22
|
+
SKILL_DIR="$(cd -P "$SELF_DIR/.." && pwd)"
|
|
23
|
+
. "$SELF_DIR/lib/tmp-root.sh"
|
|
24
|
+
. "$SKILL_DIR/scripts/lib/gate-lock.sh" # gate_lock_companion_path(伴生锁路径的唯一实现)
|
|
25
|
+
TEAM_CLI="$SKILL_DIR/scripts/team"
|
|
26
|
+
[ -f "$TEAM_CLI" ] || { printf 'flip-p310-lock: 找不到 %s\n' "$TEAM_CLI" >&2; exit 2; }
|
|
27
|
+
command -v flock >/dev/null 2>&1 || { printf 'flip-p310-lock: 没有 flock —— 这条腿判不了\n' >&2; exit 2; }
|
|
28
|
+
command -v git >/dev/null 2>&1 || { printf 'flip-p310-lock: 需要 git\n' >&2; exit 2; }
|
|
29
|
+
|
|
30
|
+
KEEP=0
|
|
31
|
+
while [ $# -gt 0 ]; do
|
|
32
|
+
case "$1" in
|
|
33
|
+
--keep) KEEP=1; shift ;;
|
|
34
|
+
-h|--help) sed -n '2,24p' "$0"; exit 0 ;;
|
|
35
|
+
*) printf 'flip-p310-lock: 未知参数 %s(--keep)\n' "$1" >&2; exit 2 ;;
|
|
36
|
+
esac
|
|
37
|
+
done
|
|
38
|
+
[ "$KEEP" = "1" ] && export TEAM_TMP_KEEP=1
|
|
39
|
+
|
|
40
|
+
TMP="$(tmp_root_create flip-p310lock)" || exit 3
|
|
41
|
+
cleanup() {
|
|
42
|
+
[ "${BASHPID:-$$}" = "$$" ] || return 0
|
|
43
|
+
p310l_release_holder
|
|
44
|
+
[ "$KEEP" = "0" ] && tmp_root_reap_all
|
|
45
|
+
}
|
|
46
|
+
trap cleanup EXIT
|
|
47
|
+
|
|
48
|
+
FAILED=0
|
|
49
|
+
case_ok() { printf ' \033[32m✓\033[0m %s\n' "$*"; }
|
|
50
|
+
case_bad() { printf ' \033[31m✗\033[0m %s\n' "$*"; FAILED=1; }
|
|
51
|
+
|
|
52
|
+
LOCK="$TMP/lock"; LOCK_COMP="$(gate_lock_companion_path "$LOCK")"
|
|
53
|
+
REPO="$TMP/repo"; mkdir -p "$REPO"
|
|
54
|
+
REC="$REPO/docs/team/reviews/T1.1.md"
|
|
55
|
+
|
|
56
|
+
# ── 现场:一个干净的夹具项目(init 出来的)─────────────────────────────────────────────
|
|
57
|
+
( cd "$REPO" && git init -q -b main && git config user.email flip@teamsmith && git config user.name flip \
|
|
58
|
+
&& echo "# p310" > README.md && git add -A && git commit -qm init ) >/dev/null 2>&1
|
|
59
|
+
p310l_env() { # <cmd…>:身份干净 + 私有锁 + 沙盒脏树/忽略产物覆盖(夹具仓的 docs/team 是 init 出来的)
|
|
60
|
+
( cd "$REPO" && env -u TEAM_ROOT -u TEAM_MAIN_ROOT -u TEAM_ROOT_SOURCE -u TEAM_ROOT_WAS -u TEAM_PROJECT \
|
|
61
|
+
-u TEAM_SESSION -u TEAM_SESSION_FROM -u TEAM_STATE_DIR -u TEAM_DOCS_DIR -u TEAM_CONFIG_FILE \
|
|
62
|
+
-u TEAM_GATES -u TEAM_VCS -u TEAM_WORKTREES_DIR -u TEAM_SKILL_DIR -u TEAM_ALLOW_FOREIGN_IDENTITY \
|
|
63
|
+
-u SMOKE_LOCK_WRAPPED -u SMOKE_LOCK_QUEUED \
|
|
64
|
+
TEAM_REVIEW_ALLOW_DIRTY=1 TEAM_REVIEW_ALLOW_IGNORED=1 "$@" )
|
|
65
|
+
}
|
|
66
|
+
p310l_env bash "$TEAM_CLI" init --session "flip-p310l-$$" --agents "dev verify" --vcs local --gates "true" \
|
|
67
|
+
--docs docs/team \
|
|
68
|
+
--task-models 'routine=deepseek/deepseek-flash analysis=xai/grok-4.6 verify=kimi-coding/k3-256k' \
|
|
69
|
+
--pm-model 'deepseek/deepseek-flash' >"$TMP/init.log" 2>&1 \
|
|
70
|
+
|| { printf 'flip-p310-lock: 夹具项目 init 失败(%s)\n' "$TMP/init.log" >&2; tail -3 "$TMP/init.log" >&2; exit 2; }
|
|
71
|
+
mkdir -p "$REPO/docs/team/reports" "$REPO/docs/team/reviews"
|
|
72
|
+
printf '# T1.1 · 夹具报告\n\nagent: dev\n' > "$REPO/docs/team/reports/T1.1-dev.md"
|
|
73
|
+
printf '\033[1m══ P310 ②:嵌套 review 认祖辈的持锁证明(不是可继承的环境标记)══\033[0m\n'
|
|
74
|
+
|
|
75
|
+
# ── 祖辈包装器:取**两把**锁 + 写自己的记录(kind=top),再把命令当子进程跑 ────────────────
|
|
76
|
+
ANC="$TMP/ancestor.sh"
|
|
77
|
+
cat > "$ANC" <<'ANC_EOF'
|
|
78
|
+
#!/usr/bin/env bash
|
|
79
|
+
# <skill-dir> <lock> <log> <cmd…>:真祖辈。取锁顺序/记录字段与产品同源(gate-lock.sh 的唯一实现)。
|
|
80
|
+
set -uo pipefail
|
|
81
|
+
skill="$1"; lock="$2"; log="$3"; shift 3
|
|
82
|
+
. "$skill/scripts/lib/gate-lock.sh"
|
|
83
|
+
gate_lock_acquire_pair "$lock" || { printf 'p310-ancestor: 取锁失败 %s\n' "$?" >&2; exit 9; }
|
|
84
|
+
comp="$(gate_lock_companion_path "$lock")"
|
|
85
|
+
IFS=$'\t' read -r ident ino < <(gate_lock_claim_identity "$comp")
|
|
86
|
+
gate_lock_write_holder "$comp" "$$" top "p310-ancestor" dev "$PWD" "$(date +%s)" 60 240 3 0 - - "$ident" "$ino"
|
|
87
|
+
"$@" >"$log" 2>&1
|
|
88
|
+
rc=$?
|
|
89
|
+
gate_lock_remove_holder "$comp"
|
|
90
|
+
exit "$rc"
|
|
91
|
+
ANC_EOF
|
|
92
|
+
chmod +x "$ANC"
|
|
93
|
+
|
|
94
|
+
# ── 非祖辈持锁者(leg control):兄弟 flock + 旧形状持有者记录(review 读得到它点名)────────
|
|
95
|
+
P310L_HOLDER=""
|
|
96
|
+
p310l_hold() { # <秒>
|
|
97
|
+
: >>"$LOCK"
|
|
98
|
+
flock -x "$LOCK" sleep "$1" &
|
|
99
|
+
P310L_HOLDER=$!
|
|
100
|
+
sleep 0.3
|
|
101
|
+
printf '%s pid=%s cmd=p310-holder\n' "$(date -Is)" "$P310L_HOLDER" >"$LOCK.holder"
|
|
102
|
+
}
|
|
103
|
+
p310l_release_holder() {
|
|
104
|
+
[ -n "${P310L_HOLDER:-}" ] && { kill "$P310L_HOLDER" 2>/dev/null; wait "$P310L_HOLDER" 2>/dev/null; }
|
|
105
|
+
P310L_HOLDER=""; rm -f "$LOCK.holder" 2>/dev/null || true
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
# ── 一条腿:跑一次 review,回 rc;log/记录路径固定 ────────────────────────────────────────
|
|
109
|
+
LEG_RC=""; LEG_LOG=""; LEG_T0=""; LEG_T1=""
|
|
110
|
+
p310l_review() { # <日志> <lock_wait> <CLI> [前置命令…]
|
|
111
|
+
local log="$1" cap="$2" cli="$3"; shift 3
|
|
112
|
+
rm -f "$REC"
|
|
113
|
+
LEG_LOG="$log"; LEG_T0="$(date +%s)"
|
|
114
|
+
LEG_RC=0
|
|
115
|
+
p310l_env TEAM_SMOKE_LOCK="$LOCK" TEAM_SMOKE_LOCK_WAIT="$cap" TEAM_GATES='true' TEAM_REVIEW_TIMEOUT=30 \
|
|
116
|
+
"$@" bash "$cli" review T1.1 --dir "$REPO" --branch main >"$log" 2>&1 || LEG_RC=$?
|
|
117
|
+
LEG_T1="$(date +%s)"
|
|
118
|
+
}
|
|
119
|
+
p310l_ancestor_review() { # <日志> <lock_wait> <skill 树(含被拷/换过的 lib)>
|
|
120
|
+
local log="$1" cap="$2" skill="$3"
|
|
121
|
+
p310l_review "$log" "$cap" "$skill/scripts/team" bash "$ANC" "$skill" "$LOCK" "$log.body"
|
|
122
|
+
}
|
|
123
|
+
rec_has() { grep -aqF -- "$1" "$REC" 2>/dev/null; }
|
|
124
|
+
|
|
125
|
+
# ── leg green:真祖辈持锁 → 不排队 ─────────────────────────────────────────────────────────
|
|
126
|
+
printf '\n\033[1m── leg green:真祖辈持两把锁(带记录)→ 子 review 不排队 ──\033[0m\n'
|
|
127
|
+
p310l_ancestor_review "$TMP/green.log" 30 "$SKILL_DIR"
|
|
128
|
+
ELAPSED=$(( LEG_T1 - LEG_T0 ))
|
|
129
|
+
if [ "$LEG_RC" != "0" ]; then
|
|
130
|
+
case_bad "leg green:review rc=$LEG_RC(期望 0)"
|
|
131
|
+
sed -n '1,6p' "$TMP/green.log.body" 2>/dev/null | sed 's/^/ /'
|
|
132
|
+
elif ! rec_has '进程树 + starttime 证明:祖辈 pid='; then
|
|
133
|
+
case_bad "leg green:记录里没有「已由祖先持有(进程树 + starttime 证明:祖辈 pid=…)」"
|
|
134
|
+
grep -a '门禁锁' "$REC" | head -2 | sed 's/^/ /'
|
|
135
|
+
elif rec_has '排队等满上限'; then
|
|
136
|
+
case_bad "leg green:祖辈持锁却仍在排队(记录写「排队等满上限」)"
|
|
137
|
+
else
|
|
138
|
+
case_ok "leg green:rc=0 · queued=0s · 记录点名被证明的祖辈 pid(· 参考 用时 ${ELAPSED}s)"
|
|
139
|
+
fi
|
|
140
|
+
|
|
141
|
+
# ── 镜像树:判据回退成「看环境标记」(改动前的形状)────────────────────────────────────────
|
|
142
|
+
MUT="$TMP/mut/skills/teamsmith"; mkdir -p "$MUT/scripts/lib"
|
|
143
|
+
cp -f "$TEAM_CLI" "$MUT/scripts/team"
|
|
144
|
+
for f in "$SKILL_DIR"/scripts/lib/*.sh; do ln -sf "$f" "$MUT/scripts/lib/$(basename "$f")"; done
|
|
145
|
+
for f in "$SKILL_DIR"/scripts/shim "$SKILL_DIR"/scripts/panel; do
|
|
146
|
+
[ -e "$f" ] && ln -sf "$f" "$MUT/scripts/$(basename "$f")"
|
|
147
|
+
done
|
|
148
|
+
for f in "$SKILL_DIR"/SKILL.md "$SKILL_DIR"/references "$SKILL_DIR"/templates "$SKILL_DIR"/tests \
|
|
149
|
+
"$SKILL_DIR"/scripts/replies.mjs "$SKILL_DIR"/scripts/monitor.mjs "$SKILL_DIR"/strings; do
|
|
150
|
+
[ -e "$f" ] && ln -sf "$f" "$MUT/$(basename "$f")"
|
|
151
|
+
done
|
|
152
|
+
rm -f "$MUT/scripts/lib/cmd-review.sh"
|
|
153
|
+
cp -f "$SKILL_DIR/scripts/lib/cmd-review.sh" "$MUT/scripts/lib/cmd-review.sh"
|
|
154
|
+
MUT_F="$MUT/scripts/lib/cmd-review.sh"
|
|
155
|
+
MUT_LN="$(grep -n 'lock_ancestor="$(gate_lock_prove_ancestor_pair' "$MUT_F" | head -1 | cut -d: -f1)"
|
|
156
|
+
if [ -n "$MUT_LN" ]; then
|
|
157
|
+
awk -v ln="$MUT_LN" 'NR==ln { print " lock_ancestor=\"\"; if [ \"${SMOKE_LOCK_WRAPPED:-0}\" = \"1\" ]; then lock_ancestor=marker; fi # P310 红侧:判据回退成环境标记"; next } { print }' \
|
|
158
|
+
"$MUT_F" > "$MUT_F.new" && mv "$MUT_F.new" "$MUT_F"
|
|
159
|
+
fi
|
|
160
|
+
if [ -z "$MUT_LN" ] || ! grep -q 'P310 红侧:判据回退成环境标记' "$MUT_F"; then
|
|
161
|
+
printf 'flip-p310-lock: 镜像树的判据回退没打上(%s 里找不到那行)—— 夹具前提不成立\n' "$MUT_F" >&2
|
|
162
|
+
exit 2
|
|
163
|
+
fi
|
|
164
|
+
bash -n "$MUT_F" || { printf 'flip-p310-lock: 镜像树的 cmd-review.sh 语法坏了\n' >&2; exit 2; }
|
|
165
|
+
|
|
166
|
+
# ── leg red:同一现场 + 判据回退 → 必须排队撞上限 ─────────────────────────────────────────
|
|
167
|
+
printf '\n\033[1m── leg red:判据回退成看环境标记(改动前)→ 同一个祖辈现场必须排队撞上限 ──\033[0m\n'
|
|
168
|
+
WAIT_CAP=2
|
|
169
|
+
p310l_ancestor_review "$TMP/red.log" "$WAIT_CAP" "$MUT"
|
|
170
|
+
ELAPSED=$(( LEG_T1 - LEG_T0 ))
|
|
171
|
+
if [ "$LEG_RC" != "1" ]; then
|
|
172
|
+
case_bad "leg red:review rc=$LEG_RC(期望 1 —— 排队撞上限)"
|
|
173
|
+
elif ! rec_has '排队等满上限'; then
|
|
174
|
+
case_bad "leg red:记录里没有「排队等满上限」(判据回退没有复现回归)"
|
|
175
|
+
elif rec_has '已由祖先持有'; then
|
|
176
|
+
case_bad "leg red:判据回退后仍认出了祖先(镜像树没生效)"
|
|
177
|
+
else
|
|
178
|
+
case_ok "leg red:rc=1 · 排队等满上限 · 记录「排队等满上限」且没有「已由祖先持有」(回归复现;· 参考 用时 ${ELAPSED}s)"
|
|
179
|
+
fi
|
|
180
|
+
|
|
181
|
+
# ── leg control:持锁者不是祖辈 → 照常排队(不许因为「有祖先」就跳过排队)──────────────────
|
|
182
|
+
printf '\n\033[1m── leg control:有祖先但祖先没持锁(持锁者是兄弟)→ 必须照常排队 ──\033[0m\n'
|
|
183
|
+
p310l_hold 20
|
|
184
|
+
p310l_review "$TMP/control.log" "$WAIT_CAP" "$TEAM_CLI"
|
|
185
|
+
p310l_release_holder
|
|
186
|
+
ELAPSED=$(( LEG_T1 - LEG_T0 ))
|
|
187
|
+
if [ "$LEG_RC" != "1" ]; then
|
|
188
|
+
case_bad "leg control:review rc=$LEG_RC(期望 1 —— 排队撞上限)"
|
|
189
|
+
elif rec_has '已由祖先持有'; then
|
|
190
|
+
case_bad "leg control:把**非祖辈**的持锁者当成了祖先(证明太松)"
|
|
191
|
+
elif ! grep -aq '门禁锁正被持有' "$TMP/control.log"; then
|
|
192
|
+
case_bad "leg control:日志里没有「门禁锁正被持有…排队」(它没有排队)"
|
|
193
|
+
elif ! rec_has '排队等满上限'; then
|
|
194
|
+
case_bad "leg control:记录里没有「排队等满上限」"
|
|
195
|
+
else
|
|
196
|
+
case_ok "leg control:rc=1 · 排队等满上限 · 点名持锁者(祖先没持锁时照常排队;· 参考 用时 ${ELAPSED}s)"
|
|
197
|
+
fi
|
|
198
|
+
|
|
199
|
+
# 收尾:锁记录只删自己那一条(祖先包装器已删;这里只收夹具的持锁者)
|
|
200
|
+
p310l_release_holder
|
|
201
|
+
|
|
202
|
+
printf '\n'
|
|
203
|
+
if [ "$FAILED" = "0" ]; then
|
|
204
|
+
printf '\033[32mflip-p310-lock:三条腿都对上了\033[0m\n'
|
|
205
|
+
[ "$KEEP" = "1" ] && printf '保留:%s\n' "$TMP"
|
|
206
|
+
exit 0
|
|
207
|
+
fi
|
|
208
|
+
printf '\033[31mflip-p310-lock:有腿没按预期\033[0m\n' >&2
|
|
209
|
+
[ "$KEEP" = "1" ] && printf '保留:%s\n' "$TMP"
|
|
210
|
+
exit 1
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# flip-p310-socket.sh — P310 ① 的翻转夹具:私有 tmux socket 的路径长度**不随临时根变长**
|
|
3
|
+
#
|
|
4
|
+
# bash skills/teamsmith/tests/flip-p310-socket.sh [--keep]
|
|
5
|
+
#
|
|
6
|
+
# 事故形状(P288 之后):临时根名带项目 ns(`teamsmith-<kind>-<ns>.XXXXXX`)且 socket 目录挂在临时根下
|
|
7
|
+
# (`$TMP/tmux`)→ 嵌套夹具再套一层 `TMPDIR=$TMP/case-*` 时 socket 到 126 字节 > AF_UNIX 的 107,
|
|
8
|
+
# §0c 的隔离前置硬停(exit 2),嵌套门禁一条结论都拿不到(§0i ✓2 ✗3)。
|
|
9
|
+
#
|
|
10
|
+
# 两条腿(都跑**真门禁**:嵌套的 smoke.sh --select 0b,私有 TMPDIR + FAST + 私有锁;不碰机器锁,
|
|
11
|
+
# 不碰调用者的默认 server;不对任何非自己 spawn 的进程发信号):
|
|
12
|
+
# leg green:TMPDIR 深到「旧形状会 >107 字节」→ 门禁必须 **rc=0**,日志里的 socket 行长度 ≤ 107
|
|
13
|
+
# (实测值打印出来,供复验核对)。
|
|
14
|
+
# leg red :同一个 TMPDIR + `TEAM_SMOKE_FIXTURE=1 TEAM_SMOKE_TMUX_UNDER_TMP=1`(把 socket 目录放回
|
|
15
|
+
# 临时根下 = 改动前的形状)→ §0c 的隔离前置必须**硬停**(exit 2)、点名
|
|
16
|
+
# `socket 路径 N 字节 > AF_UNIX 上限 107`,且 N 恰是本夹具按旧形状算出的那个长度(>107)。
|
|
17
|
+
# 判绿:两条都按预期。全绿 exit 0;任何一条没按预期 → exit 1(脚本级前提不成立 → exit 2)。
|
|
18
|
+
set -uo pipefail
|
|
19
|
+
|
|
20
|
+
SELF_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
21
|
+
SKILL_DIR="$(cd -P "$SELF_DIR/.." && pwd)"
|
|
22
|
+
. "$SELF_DIR/lib/tmp-root.sh"
|
|
23
|
+
SMOKE="$SKILL_DIR/tests/smoke.sh"
|
|
24
|
+
[ -f "$SMOKE" ] || { printf 'flip-p310-socket: 找不到 %s\n' "$SMOKE" >&2; exit 2; }
|
|
25
|
+
command -v tmux >/dev/null 2>&1 || { printf 'flip-p310-socket: 没有 tmux —— 这条腿判不了(需要私有 socket)\n' >&2; exit 2; }
|
|
26
|
+
|
|
27
|
+
KEEP=0
|
|
28
|
+
while [ $# -gt 0 ]; do
|
|
29
|
+
case "$1" in
|
|
30
|
+
--keep) KEEP=1; shift ;;
|
|
31
|
+
-h|--help) sed -n '2,20p' "$0"; exit 0 ;;
|
|
32
|
+
*) printf 'flip-p310-socket: 未知参数 %s(--keep)\n' "$1" >&2; exit 2 ;;
|
|
33
|
+
esac
|
|
34
|
+
done
|
|
35
|
+
[ "$KEEP" = "1" ] && export TEAM_TMP_KEEP=1
|
|
36
|
+
|
|
37
|
+
TMP="$(tmp_root_create flip-p310sock)" || exit 3
|
|
38
|
+
cleanup() { [ "${BASHPID:-$$}" = "$$" ] && [ "$KEEP" = "0" ] && tmp_root_reap_all; }
|
|
39
|
+
trap cleanup EXIT
|
|
40
|
+
|
|
41
|
+
FAILED=0
|
|
42
|
+
case_ok() { printf ' \033[32m✓\033[0m %s\n' "$*"; }
|
|
43
|
+
case_bad() { printf ' \033[31m✗\033[0m %s\n' "$*"; FAILED=1; }
|
|
44
|
+
ns="$(tmp_root_ns)"; uid="$(id -u)"
|
|
45
|
+
|
|
46
|
+
# ── 现场:一个**深到旧形状必然 >107 字节**的嵌套 TMPDIR ────────────────────────────────────
|
|
47
|
+
# 旧形状 = <TMPDIR>/teamsmith-smoke-<ns>.XXXXXX(临时根)+ /tmux(socket 目录)+ /tmux-<uid>/default
|
|
48
|
+
DEEP="$TMP/case-deep"; mkdir -p "$DEEP"
|
|
49
|
+
old_shape_len() { # <TMPDIR>
|
|
50
|
+
printf '%s' "$(( ${#1} + 1 + 16 + ${#ns} + 1 + 6 + 5 + 6 + ${#uid} + 8 ))"
|
|
51
|
+
}
|
|
52
|
+
# 每加一层 /ddddddad 加 7 字节;上限 8 层(病态长 ns 也不至于打转)
|
|
53
|
+
i=0
|
|
54
|
+
while [ "$(old_shape_len "$DEEP")" -le 110 ] && [ "$i" -lt 8 ]; do
|
|
55
|
+
DEEP="$DEEP/ddddddd"; mkdir -p "$DEEP"; i=$((i + 1))
|
|
56
|
+
done
|
|
57
|
+
OLD_LEN="$(old_shape_len "$DEEP")"
|
|
58
|
+
if [ "$OLD_LEN" -le 107 ]; then
|
|
59
|
+
printf 'flip-p310-socket: 造不出「旧形状 >107 字节」的现场(算出来 %s)—— 夹具前提不成立\n' "$OLD_LEN" >&2
|
|
60
|
+
exit 2
|
|
61
|
+
fi
|
|
62
|
+
printf '\033[1m══ P310 ①:私有 socket 的路径长度不随临时根变长 ══\033[0m\n'
|
|
63
|
+
printf ' 嵌套 TMPDIR(%s 字节):%s\n' "${#DEEP}" "$DEEP"
|
|
64
|
+
printf ' 旧形状(socket 挂在临时根下)在这里是:%s 字节 > 107 —— 正是 §0i 的 ✗3 现场\n' "$OLD_LEN"
|
|
65
|
+
|
|
66
|
+
# 嵌套门禁:清掉身份/锁/socket 继承位(它必须自己算自己的 socket),私有 TMPDIR + FAST(不排队)
|
|
67
|
+
p310s_nest() { # <日志> [extra env assignment…]
|
|
68
|
+
local log="$1"; shift
|
|
69
|
+
( cd "$TMP" && env -u TMUX -u TMUX_PANE -u TMUX_TMPDIR -u TEAM_ROOT -u TEAM_MAIN_ROOT -u TEAM_PROJECT \
|
|
70
|
+
-u TEAM_SESSION -u TEAM_TMUX_REAL -u SMOKE_LOCK_WRAPPED -u SMOKE_LOCK_QUEUED -u SMOKE_LOCK_MARKER \
|
|
71
|
+
-u TEAM_SMOKE_LOCK -u TEAM_SMOKE_LOCK_WAIT -u TEAM_SMOKE_NO_PRIVATE_TMUX -u TEAM_SMOKE_TMUX_UNDER_TMP \
|
|
72
|
+
-u TEAM_SMOKE_BREAK -u TEAM_SMOKE_FIXTURE \
|
|
73
|
+
TMPDIR="$DEEP" TEAM_SMOKE_FAST=1 "$@" \
|
|
74
|
+
bash "$SMOKE" --select 0b ) >"$log" 2>&1
|
|
75
|
+
printf '%s\n' "$?"
|
|
76
|
+
}
|
|
77
|
+
plain() { sed 's/\x1b\[[0-9;]*m//g' "$1" 2>/dev/null || true; }
|
|
78
|
+
sock_len_of() { # <日志> → 日志里那行私有 socket 路径的字节数(缺 → 空)
|
|
79
|
+
local p
|
|
80
|
+
p="$(plain "$1" | sed -n 's/^ · tmux 私有 socket:\(.*\)(夹具与产品调用都走它.*$/\1/p' | head -1)"
|
|
81
|
+
[ -n "$p" ] && printf '%s' "$p" | wc -c | tr -d ' ' || true
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
# ── leg green:新形状 —— 深 TMPDIR 下 socket 仍 ≤107,门禁跑完(0c 的隔离前置通过)──────────
|
|
85
|
+
printf '\n\033[1m── leg green:深嵌套 TMPDIR 下照常跑(socket 目录在临时根之外)──\033[0m\n'
|
|
86
|
+
G_RC="$(p310s_nest "$TMP/green.log")"
|
|
87
|
+
G_LEN="$(sock_len_of "$TMP/green.log")"
|
|
88
|
+
if [ "$G_RC" != "0" ]; then
|
|
89
|
+
case_bad "leg green:嵌套门禁退出码 [$G_RC](期望 0)"
|
|
90
|
+
plain "$TMP/green.log" | grep -a '隔离前置不成立\|socket 路径' | head -3 | sed 's/^/ /'
|
|
91
|
+
elif [ -z "$G_LEN" ]; then
|
|
92
|
+
case_bad "leg green:日志里没有「tmux 私有 socket:」那行(0c 没跑到?)"
|
|
93
|
+
elif [ "$G_LEN" -gt 107 ]; then
|
|
94
|
+
case_bad "leg green:socket 路径 ${G_LEN} 字节 > 107(改法没生效)"
|
|
95
|
+
else
|
|
96
|
+
case_ok "leg green:rc=0 · socket 路径 ${G_LEN} 字节 ≤ 107(临时根之外)"
|
|
97
|
+
fi
|
|
98
|
+
|
|
99
|
+
# ── leg red:把 socket 目录放回临时根下(改动前的形状)→ 0c 必须硬停并点名长度 ──────────────
|
|
100
|
+
printf '\n\033[1m── leg red:socket 目录放回临时根下(TEAM_SMOKE_TMUX_UNDER_TMP=1)→ 必须硬停 ──\033[0m\n'
|
|
101
|
+
R_RC="$(p310s_nest "$TMP/red.log" TEAM_SMOKE_FIXTURE=1 TEAM_SMOKE_TMUX_UNDER_TMP=1)"
|
|
102
|
+
R_PLAIN="$(plain "$TMP/red.log")"
|
|
103
|
+
R_N="$(printf '%s\n' "$R_PLAIN" | sed -n 's/.*socket 路径 \([0-9]\+\) 字节 > AF_UNIX 上限 107.*/\1/p' | head -1)"
|
|
104
|
+
if [ "$R_RC" != "2" ]; then
|
|
105
|
+
case_bad "leg red:嵌套门禁退出码 [$R_RC](期望 2 —— 隔离前置硬停)"
|
|
106
|
+
elif ! printf '%s\n' "$R_PLAIN" | grep -aq '隔离前置不成立'; then
|
|
107
|
+
case_bad "leg red:日志里没有「隔离前置不成立」"
|
|
108
|
+
elif [ -z "$R_N" ]; then
|
|
109
|
+
case_bad "leg red:硬停没有点名 socket 长度(找不到「socket 路径 N 字节 > AF_UNIX 上限 107」)"
|
|
110
|
+
elif [ "$R_N" != "$OLD_LEN" ]; then
|
|
111
|
+
case_bad "leg red:点名的长度 [$R_N] 不是旧形状算出来的 [$OLD_LEN](判据点到别处去了)"
|
|
112
|
+
elif printf '%s\n' "$R_PLAIN" | grep -aq '== 选段结果 =='; then
|
|
113
|
+
case_bad "leg red:硬停之后还出了结果行(门禁应当根本没跑起来)"
|
|
114
|
+
else
|
|
115
|
+
case_ok "leg red:rc=2 · 点名「socket 路径 ${R_N} 字节 > AF_UNIX 上限 107」= 旧形状的长度 · 没有结果行"
|
|
116
|
+
fi
|
|
117
|
+
|
|
118
|
+
printf '\n'
|
|
119
|
+
if [ "$FAILED" = "0" ]; then
|
|
120
|
+
printf '\033[32mflip-p310-socket:两条腿都对上了\033[0m\n'
|
|
121
|
+
exit 0
|
|
122
|
+
fi
|
|
123
|
+
printf '\033[31mflip-p310-socket:有腿没按预期\033[0m\n' >&2
|
|
124
|
+
[ "$KEEP" = "1" ] && printf '保留:%s\n' "$TMP"
|
|
125
|
+
exit 1
|
|
@@ -1,111 +1,84 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
2
|
+
# P316 · 正确性门禁 / 参考读数 的双向机械守卫(纯逻辑:只 grep 文件,不起任何进程、不判时长)
|
|
3
3
|
#
|
|
4
|
-
# bash skills/teamsmith/tests/gate-guard.sh
|
|
4
|
+
# bash skills/teamsmith/tests/gate-guard.sh
|
|
5
5
|
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
6
|
+
# 用户裁定(2026-10-19,第二条):**门禁的绿/红只由行为决定;时间只说给人听**。
|
|
7
|
+
# 三条机械边界(任一不成立 → 打印 `bad: …` 并退出 1):
|
|
8
|
+
# ① 门禁面(`smoke.sh` + `tests/lib/*.sh`)里没有**这一种**墙钟判据:`$elapsed/$duration/$took/$SECONDS`
|
|
9
|
+
# 与 `-gt/-ge/-lt/-le` 相邻的阈值比较。**它只证明这一种写法不在**,不证明「门禁里没有任何墙钟判据」
|
|
10
|
+
# —— 参数形态(例如等待函数第 N 个参数是秒数)它看不见,那要靠调用点的单点实验。
|
|
11
|
+
# ② 门禁不点名测量夹具(`perf.sh` / `panel-cpu.sh` / 已退役的 `load-experiment.sh`、`panel-cpu-premise.sh`)
|
|
12
|
+
# —— 性能读数留在门禁之外,这一条编码的是用户裁定的**结构**。
|
|
13
|
+
# ③ 两个参考打印器没有**判定型退出码**(`exit 2` / `exit 4`):读不到就走 3/0,不能因为「慢」或
|
|
14
|
+
# 「机器忙」而失败。这是行为性质,不是措辞。
|
|
10
15
|
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
16
|
+
# 已删除(P316 返修 · V61 裁定):原来的 ④「门禁真的调用本守卫」是自指检查,没有行为证据价值;
|
|
17
|
+
# 以及 ③ 里「必须带 `· 参考` 标记」那一半 —— 那是呈现契约,不是「不阻塞」的证据(「不阻塞」的证据是
|
|
18
|
+
# perf.sh 在 4065ms 首帧上 rc=0、CI 的 continue-on-error、panel-cpu 无工具时 exit 0)。
|
|
13
19
|
#
|
|
14
|
-
# 注意:本文件**不是**被 grep
|
|
15
|
-
# 守卫自己也不判时长、不读环境 —— 跑机核数/负载与它无关。
|
|
20
|
+
# 注意:本文件**不是**被 grep 的对象(守卫自己要写这些字面量),被检查的是上面两个面。
|
|
16
21
|
set -uo pipefail
|
|
17
22
|
|
|
18
23
|
here="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
19
24
|
smoke="$here/smoke.sh"
|
|
20
|
-
knobs="$here/panel-knobs.sh"
|
|
21
25
|
perf="$here/perf.sh"
|
|
26
|
+
pcpu="$here/panel-cpu.sh"
|
|
22
27
|
|
|
23
28
|
FAILED=0
|
|
24
29
|
ok() { printf 'ok: %s\n' "$1"; }
|
|
25
30
|
bad() { printf 'bad: %s\n' "$1"; FAILED=$((FAILED + 1)); }
|
|
26
31
|
|
|
27
|
-
#
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
# ① 时长阈值比较(与旧 D33 的形态一致:变量名 + 比较符相邻;打印时长不算)
|
|
33
|
+
DUR_CMP_RE='(\$elapsed|\$\{elapsed\}|\$duration|\$took|\$SECONDS)[^|;]*-(gt|ge|lt|le)([^0-9A-Za-z_]|$)'
|
|
34
|
+
DUR_HITS=""
|
|
35
|
+
DUR_MOD="$here/lib/section-guard.sh"
|
|
36
|
+
for f in "$smoke" "$here"/lib/*.sh; do
|
|
37
|
+
[ -f "$f" ] || continue
|
|
38
|
+
# 段落守卫是挂住上限的唯一实现:它把 now-armed 与常量 cap 比较(防死等),另有两处纯记账
|
|
39
|
+
# (秒数归零 / 取最大值)。它不是墙钟判据,单独下面一条钉住「cap 比较仍在」。
|
|
40
|
+
[ "$f" = "$DUR_MOD" ] && continue
|
|
41
|
+
# 注释行不算比较(本守卫自己的说明、「不要写成 X 与 -gt 相邻」这类提示都写在注释里)。
|
|
42
|
+
h="$(grep -nE -- "$DUR_CMP_RE" "$f" 2>/dev/null | grep -vE '^[0-9]+:[[:space:]]*#' | head -3 || true)"
|
|
43
|
+
[ -n "$h" ] && DUR_HITS="$DUR_HITS$(basename "$f"): $h; "
|
|
44
|
+
done
|
|
45
|
+
if [ -f "$DUR_MOD" ] && grep -qE -- '-(ge|gt)[[:space:]]+"\$cap"' "$DUR_MOD"; then
|
|
46
|
+
ok "lib/section-guard.sh 只把时长与常量挂住上限比较(防死等)"
|
|
47
|
+
elif [ -f "$DUR_MOD" ]; then
|
|
48
|
+
bad "lib/section-guard.sh 丢了挂住上限比较(-ge \"\$cap\")—— 防死等没了"
|
|
49
|
+
fi
|
|
50
|
+
if [ -z "$DUR_HITS" ]; then
|
|
51
|
+
ok "门禁面(smoke.sh + lib/*.sh)没有「\$elapsed 与 -gt/-ge/-lt/-le 相邻」的阈值比较"
|
|
52
|
+
else
|
|
53
|
+
bad "门禁面里出现了这一种墙钟阈值比较(时间成了判决):$DUR_HITS"
|
|
54
|
+
fi
|
|
35
55
|
|
|
36
|
-
#
|
|
56
|
+
# ② 门禁不点名测量夹具(它们只在参考读数路径里被调用)
|
|
57
|
+
FIX_RE='panel-cpu\.sh|panel-cpu-premise\.sh|perf\.sh|load-experiment\.sh'
|
|
37
58
|
if [ -f "$smoke" ]; then
|
|
38
|
-
hits="$(grep -nE -- "$MARK_RE" "$smoke" || true)"
|
|
39
|
-
cmps="$(grep -nE -- "$MARK_CMP_RE" "$smoke" || true)"
|
|
40
59
|
fixes="$(grep -nE -- "$FIX_RE" "$smoke" || true)"
|
|
41
|
-
if [ -z "$
|
|
42
|
-
ok "smoke.sh
|
|
60
|
+
if [ -z "$fixes" ]; then
|
|
61
|
+
ok "smoke.sh 不点名测量/参考夹具(性能读数不在正确性门禁里跑)"
|
|
43
62
|
else
|
|
44
|
-
bad "smoke.sh
|
|
63
|
+
bad "smoke.sh 点名了测量/参考夹具:$(printf '%s' "$fixes" | head -3 | tr '\n' ';')"
|
|
45
64
|
fi
|
|
46
|
-
# 门禁还得真的调用守卫与旋钮助手(否则守卫被摘掉也没人知道)
|
|
47
|
-
for need in 'gate-guard\.sh' 'panel-knobs\.sh'; do
|
|
48
|
-
grep -qE -- "$need" "$smoke" || bad "smoke.sh 没有调用 $need(守卫/旋钮完整性被摘掉了)"
|
|
49
|
-
done
|
|
50
65
|
else
|
|
51
66
|
bad "缺 $smoke"
|
|
52
67
|
fi
|
|
53
68
|
|
|
54
|
-
#
|
|
55
|
-
|
|
56
|
-
if
|
|
57
|
-
|
|
69
|
+
# ③ 参考打印器:在、没有判定型退出码
|
|
70
|
+
for f in "$perf" "$pcpu"; do
|
|
71
|
+
if [ ! -f "$f" ]; then bad "缺参考打印器 $(basename "$f")"; continue; fi
|
|
72
|
+
verdicts="$(grep -nE '(^|[^0-9A-Za-z_])exit[[:space:]]+(2|4)([^0-9]|$)' "$f" || true)"
|
|
73
|
+
if [ -z "$verdicts" ]; then
|
|
74
|
+
ok "$(basename "$f") 没有判定型退出码(exit 2/4):测不出来 ≠ 性能不合格"
|
|
58
75
|
else
|
|
59
|
-
bad "
|
|
76
|
+
bad "$(basename "$f") 还有判定型退出码:$(printf '%s' "$verdicts" | head -3 | tr '\n' ';')"
|
|
60
77
|
fi
|
|
61
|
-
grep -qE 'panel-cpu-premise\.sh' "$knobs" \
|
|
62
|
-
&& bad "panel-knobs.sh 反过来驱赶测量夹具 panel-cpu-premise.sh(门禁又被测量绑上了)" \
|
|
63
|
-
|| ok "panel-knobs.sh 不驱赶测量夹具"
|
|
64
|
-
else
|
|
65
|
-
bad "缺 $knobs(旋钮不得漏进真路径的检查没了)"
|
|
66
|
-
fi
|
|
67
|
-
|
|
68
|
-
# ③ 性能套件
|
|
69
|
-
if [ -f "$perf" ]; then
|
|
70
|
-
PERF_MARKERS_OK=1
|
|
71
|
-
for pair in 'PERF_FRAME_BUDGET_MS=2000' 'PERF_CPU_MAX_PCT=1' 'PERF_ASSEMBLY_PREMISE_FACTOR=0.75' \
|
|
72
|
-
'PERF_FIRST_FRAME_PREMISE_FACTOR=0.25' 'PERF_CPU_PREMISE_FACTOR=0.25'; do
|
|
73
|
-
grep -qF -- "$pair" "$perf" || { bad "perf.sh 没有带着标记 $pair(判定被删掉了?)"; PERF_MARKERS_OK=0; }
|
|
74
|
-
done
|
|
75
|
-
# ok 只在**全部**标记都在时打印 —— 缺任何一个都只说 bad(PM 复验 F1:bad 与「带着标记」的 ok
|
|
76
|
-
# 并排是最伤信任的自相矛盾;判定 rc 一直是对的,错的是自述)。
|
|
77
|
-
[ "$PERF_MARKERS_OK" = "1" ] && ok "perf.sh 带着帧预算 / CPU 份额 / 前提系数的命名单源标记"
|
|
78
|
-
else
|
|
79
|
-
bad "缺 $perf"
|
|
80
|
-
fi
|
|
81
|
-
|
|
82
|
-
# ④ 计时记录不是判决(P70 / D33 的边界):门禁里唯一可以把「测到的时长」和阈值比的模块是
|
|
83
|
-
# lib/section-guard.sh(每段硬预算 = 存活检测)。标记是**比较形态**($elapsed / $SECONDS… 与
|
|
84
|
-
# -gt/-ge/-lt/-le 相邻),不是变量名本身 —— 别的模块打印时长、把时长当数据搬运都不算判定。
|
|
85
|
-
DUR_MOD="$here/lib/section-guard.sh"
|
|
86
|
-
DUR_CMP_RE='(\$elapsed|\$\{elapsed\}|\$duration|\$took|\$SECONDS)[^|;]*-(gt|ge|lt|le)([^0-9A-Za-z_]|$)'
|
|
87
|
-
DUR_HITS=""
|
|
88
|
-
for f in "$smoke" "$here"/lib/*.sh; do
|
|
89
|
-
[ -f "$f" ] || continue
|
|
90
|
-
[ "$f" = "$DUR_MOD" ] && continue
|
|
91
|
-
h="$(grep -nE -- "$DUR_CMP_RE" "$f" 2>/dev/null | head -3 || true)"
|
|
92
|
-
[ -n "$h" ] && DUR_HITS="$DUR_HITS$f: $h; "
|
|
93
78
|
done
|
|
94
|
-
if [ -z "$DUR_HITS" ]; then
|
|
95
|
-
ok "门禁的时长只被记录、不被判定(lib/section-guard.sh 之外没有时长阈值比较)"
|
|
96
|
-
else
|
|
97
|
-
bad "门禁里出现了时长阈值比较(计时记录成了判决):$DUR_HITS"
|
|
98
|
-
fi
|
|
99
|
-
if [ -f "$DUR_MOD" ]; then
|
|
100
|
-
grep -qE -- '-(ge|gt)[[:space:]]+"\$budget"' "$DUR_MOD" \
|
|
101
|
-
&& ok "lib/section-guard.sh 是唯一做时长比较的模块(trip 比较在位)" \
|
|
102
|
-
|| bad "lib/section-guard.sh 丢了 trip 比较(-ge \"\$budget\")—— 单源边界没了"
|
|
103
|
-
else
|
|
104
|
-
bad "缺 $DUR_MOD(每段硬预算的看门狗模块)"
|
|
105
|
-
fi
|
|
106
79
|
|
|
107
80
|
if [ "$FAILED" -eq 0 ]; then
|
|
108
|
-
printf '\ngate-guard:
|
|
81
|
+
printf '\ngate-guard: 三向都过(这一种墙钟比较不在门禁面、门禁不点名测量夹具、参考打印器无 2/4 退出)\n'
|
|
109
82
|
exit 0
|
|
110
83
|
fi
|
|
111
84
|
printf '\ngate-guard: %d 条不成立\n' "$FAILED"
|