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
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
# spawn、pid 记录在案,收尾**只按记录的 pid** 发信号;真实仓库 state/ 的反向守卫做成**白名单** ——
|
|
22
22
|
# 只看「夹具的产品代码可能写到」的那族路径(当前就是闸门自己的日志族 `signal-calls.log*`,逐条从
|
|
23
23
|
# 代码列在下面 FIXTURE_WRITE_WATCH 的注释里);活着的 PM 运行时每拍都在写别的车道(巡检的
|
|
24
|
-
# capacity.log 等),那不是夹具的事,**不进判据**(P171
|
|
25
|
-
# tests/flip-p171.sh
|
|
24
|
+
# capacity.log 等),那不是夹具的事,**不进判据**(P171 的现场同源)。跑动中写入的各面红侧曾由
|
|
25
|
+
# tests/flip-p171.sh 固定(P354 已删该夹具;证据见 docs/team/reports/P171-dev.md)。
|
|
26
26
|
set -uo pipefail
|
|
27
27
|
|
|
28
28
|
SELF_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
@@ -82,7 +82,8 @@ assert_gone() { kill -0 "$2" 2>/dev/null && bad "$1(pid $2 还活着)" || ok
|
|
|
82
82
|
# tmp_root_create 的私有根里,每个调用点都显式钉 TEAM_SIGNAL_CALLS_LOG/TEAM_SIGNAL_REAL。
|
|
83
83
|
# 判据取**内容哈希**(不是大小/时间戳):同长度的改写也看得见;目录不在 → 记 absent(连「凭空建出
|
|
84
84
|
# state/」也算变化)。覆盖与不覆盖的边界,报告里逐条写;受看面的形状由段尾 watch-shape 探针在合成
|
|
85
|
-
# 树上钉住(不许扩成「整个 state
|
|
85
|
+
# 树上钉住(不许扩成「整个 state/」,也不许缩成空转);跑动中写入的各面曾由 tests/flip-p171.sh
|
|
86
|
+
# 固定(P354 已删该夹具;证据见 docs/team/reports/P171-dev.md)。
|
|
86
87
|
FIXTURE_WRITE_WATCH='signal-calls.log*'
|
|
87
88
|
REAL_STATE="$REPO_ROOT/.pi/team/state"
|
|
88
89
|
# 两个函数都先**跟随软链**把根解成真路径:`find "<软链>"` 默认不走命令行上的软链(只报软链自己,
|
|
@@ -121,13 +122,20 @@ assert_has "夹具前提:诱饵 B 的 argv[0] 里带模式串" "$(tr '\0' ' '
|
|
|
121
122
|
STUB="$TMP/stub"
|
|
122
123
|
cat > "$STUB" <<'STUB_EOF'
|
|
123
124
|
#!/usr/bin/env bash
|
|
124
|
-
printf 'STUB argc=%s argv=%s\n' "$#" "$*" >> "${STUB_LOG:?}"
|
|
125
|
+
printf 'STUB argc=%s argv=%s tool=%s\n' "$#" "$*" "$(basename "$0")" >> "${STUB_LOG:?}"
|
|
126
|
+
[ -n "${STUB_OUT:-}" ] && printf '%s\n' "$STUB_OUT"
|
|
127
|
+
[ -n "${STUB_ERR:-}" ] && printf '%s\n' "$STUB_ERR" >&2
|
|
125
128
|
if [ -n "${STUB_KILL_PIDS:-}" ]; then
|
|
126
129
|
for _sp in $STUB_KILL_PIDS; do kill -TERM "$_sp" 2>/dev/null || true; done
|
|
127
130
|
fi
|
|
128
131
|
exit "${STUB_EXIT:-0}"
|
|
129
132
|
STUB_EOF
|
|
130
133
|
chmod +x "$STUB"
|
|
134
|
+
# 选择器的同名后端(真身的替身):P167/P321 的 pgrep/pidof 只按**自己的名字**在闸门目录之外解析,
|
|
135
|
+
# 所以它们必须在闸门目录**之后**紧跟一份同名的 argv 记录桩(真身永远是桩,夹具里不跑真选择器)。
|
|
136
|
+
# ps/fuser 的同名替身赔在同一目录:证明只读工具仍在闸门之外(不拦、不记行)。
|
|
137
|
+
SEL_SHIM="$TMP/selector-shim"; mkdir -p "$SEL_SHIM"
|
|
138
|
+
for _t in pgrep pidof ps fuser; do cp "$STUB" "$SEL_SHIM/$_t"; chmod +x "$SEL_SHIM/$_t"; done
|
|
131
139
|
# 「真身不可解析」那条腿的 PATH 兜底:$REAL_SHIM/pkill → 桩。
|
|
132
140
|
# **为什么必须有它**(2026-10-02 见证跑实测):那一条腿故意给 TEAM_SIGNAL_REAL 一个不存在的路径,
|
|
133
141
|
# 闸门于是回落到 PATH 扫描找「第一个不是自己的同名文件」—— 绿侧拒绝在前(不解析),但红侧
|
|
@@ -143,8 +151,8 @@ if [ "$BREAK" = "pass" ]; then
|
|
|
143
151
|
GATE_DIR="$TMP/shim-break"
|
|
144
152
|
mkdir -p "$GATE_DIR"
|
|
145
153
|
cp -a "$SKILL_DIR/scripts/shim/signal-gate" "$GATE_DIR/signal-gate"
|
|
146
|
-
|
|
147
|
-
|
|
154
|
+
# 真实入口从 P321 起是普通文件 wrapper(npm 带不了软链)—— 红侧副本也照真实形状拷四个入口
|
|
155
|
+
for _t in pkill killall pgrep pidof; do cp -a "$SKILL_DIR/scripts/shim/$_t" "$GATE_DIR/$_t"; done
|
|
148
156
|
sed -i 's/^_act="refused"$/_act="pass"/' "$GATE_DIR/signal-gate"
|
|
149
157
|
if grep -qx '_act="pass"' "$GATE_DIR/signal-gate"; then
|
|
150
158
|
printf '红侧:闸门副本的判定行已改成放行(%s)\n' "$GATE_DIR/signal-gate"
|
|
@@ -152,7 +160,9 @@ if [ "$BREAK" = "pass" ]; then
|
|
|
152
160
|
printf '✗ 红侧不成立:sed 没改到判定行(%s)\n' "$GATE_DIR/signal-gate" >&2; exit 2
|
|
153
161
|
fi
|
|
154
162
|
fi
|
|
155
|
-
|
|
163
|
+
for _t in pkill killall pgrep pidof; do
|
|
164
|
+
[ -x "$GATE_DIR/$_t" ] || { printf '✗ 闸门入口不可执行:%s/%s\n' "$GATE_DIR" "$_t" >&2; exit 2; }
|
|
165
|
+
done
|
|
156
166
|
|
|
157
167
|
LOGD="$TMP/logs"; mkdir -p "$LOGD"
|
|
158
168
|
# 红侧:桩按夹具记录过的诱饵 pid 收掉它们(于是 decoys-alive 也红);真身永远是桩。
|
|
@@ -165,6 +175,27 @@ p159_gate() { # <tool> <args...> → 闸门的 stdout/stderr/rc 由调用方接
|
|
|
165
175
|
"$GATE_DIR/$_tool" "$@"
|
|
166
176
|
}
|
|
167
177
|
gate_lines() { wc -l < "$1" 2>/dev/null | tr -dc '0-9'; }
|
|
178
|
+
# 选择器调用:与 p159_gate 同形的显式钉子,但 PATH 里紧跟闸门目录的是**同名**选择器桩。
|
|
179
|
+
# stdout/stderr 分开收(拒绝要把 stdout 留空),三样都从环境显式钉,不用调用者的值。
|
|
180
|
+
sel_run() { # <tool> <args…> → SEL_RC / SEL_OUT / SEL_ERR
|
|
181
|
+
local _tool="$1"; shift
|
|
182
|
+
SEL_OUT="$(env PATH="$GATE_DIR:$SEL_SHIM:$PATH" TEAM_SIGNAL_CALLS_LOG="${GATE_LOG:-$LOGD/gate.log}" \
|
|
183
|
+
STUB_LOG="${STUB_LOG:-$LOGD/stub.log}" STUB_EXIT="${STUB_EXIT:-0}" STUB_OUT="${STUB_OUT:-}" \
|
|
184
|
+
STUB_ERR="${STUB_ERR:-}" STUB_KILL_PIDS="${STUB_KILL_PIDS:-}" \
|
|
185
|
+
"$GATE_DIR/$_tool" "$@" 2>"$TMP/sel.err")"
|
|
186
|
+
SEL_RC=$?
|
|
187
|
+
SEL_ERR="$(cat "$TMP/sel.err" 2>/dev/null)"
|
|
188
|
+
}
|
|
189
|
+
# 拒绝形态的**分类**判据:退出码与空 stdout(每个不同输入各测一次)。诊断插值的文案与记录行的模板
|
|
190
|
+
# 对所有形态走的是同一份代码路径(P321 的 V65 复核意见:每形态再验一遍不增加独立行为),因此那两列
|
|
191
|
+
# 只在下面轮转段的两次**代表调用**(pgrep / pidof)上各验一次 —— 不另开开关、不增加调用。
|
|
192
|
+
# P318:rc 与空 stdout 是**一条契约的两半**(拒绝 = 64 且不交出 pid),一条精确比较同时判两半
|
|
193
|
+
# (`<rc>|<stdout>`,任一半走样都红),不是把两半放宽成一半。
|
|
194
|
+
refuse_sel() { # <说明> <tool> <args…> → SEL_RC / SEL_OUT / SEL_ERR(供代表调用就验)
|
|
195
|
+
local _label="$1" _tool="$2"; shift 2
|
|
196
|
+
sel_run "$_tool" "$@"
|
|
197
|
+
assert_eq "$_label 退出 64 且 stdout 留空" "$SEL_RC|$SEL_OUT" "64|"
|
|
198
|
+
}
|
|
168
199
|
|
|
169
200
|
# ══════════════════════════════════════════════════════════════════════════════════════════════
|
|
170
201
|
hdr "RA1 · 模式选择一律拒,且两个诱饵都活着"
|
|
@@ -174,25 +205,37 @@ assert_eq "pkill -f <marker> 退出 64" "$RC" "64"
|
|
|
174
205
|
assert_has "拒绝文案点名 pkill 与完整 argv" "$OUT" "pkill -f $MARKER"
|
|
175
206
|
assert_has "拒绝文案说清「模式不是身份」" "$OUT" "不是身份"
|
|
176
207
|
assert_has "拒绝文案给出安全路线 team bg stop <id>" "$OUT" "team bg stop <id>"
|
|
177
|
-
|
|
178
|
-
|
|
208
|
+
# P318:安全路线是**一份**固定文案(scripts/shim/signal-gate 191–194 的三行 printf,四个工具共用),
|
|
209
|
+
# 另外两条是同一块里的固定句子 —— 一条断言数出两条(缺一条就数成 1)。删掉的是重复视图,不是行为;
|
|
210
|
+
# scenario 的 THEN 点名的 `team bg stop` 仍单独验(上一条)。
|
|
211
|
+
assert_eq "拒绝文案给出其余两条安全路线(team bg list / kill <记录过的 pid>)" \
|
|
212
|
+
"$(printf '%s\n' "$OUT" | grep -cF -e 'team bg list' -e 'kill <记录过的 pid>' || true)" "2"
|
|
179
213
|
assert_eq "桩一个调用都没收到(拒绝不执行真身)" "$(cat "$STUB_LOG" 2>/dev/null | wc -l | tr -d ' ')" "0"
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
214
|
+
# P318:两个诱饵是同一事实(模式没被执行)—— 合成一条;红的时候两个 pid 都打出来,定位不受影响。
|
|
215
|
+
if kill -0 "$DECOY1" 2>/dev/null && kill -0 "$DECOY2" 2>/dev/null; then
|
|
216
|
+
ok "两个诱饵都还活着(模式没有被执行:pid $DECOY1 / $DECOY2)"
|
|
217
|
+
else
|
|
218
|
+
bad "有诱饵不见了(pid $DECOY1 / $DECOY2)—— 模式选择被执行了"
|
|
219
|
+
fi
|
|
220
|
+
# P318:调用日志是**一行**;动作/tool、argv、pid/ppid/cwd 是同一行的三个切面 → 一条形状断言。
|
|
221
|
+
assert_eq "调用日志一行带 act=refused · tool=pkill · argv=-f <marker> · pid=/ppid=/cwd=" \
|
|
222
|
+
"$(printf '%s\n' "$(cat "$GATE_LOG")" | grep -cE 'act=refused · tool=pkill · argv=-f [a-z0-9-]+ · pid=[0-9]+ ppid=[0-9]+ cwd=[^ ]' || true)" "1"
|
|
185
223
|
if cmp -s "$GATE_LOG.forensics" "$GATE_LOG"; then ok "拒绝行逐字节进了 .forensics(cmp)"; else bad "拒绝行与 .forensics 不是逐字节相同"; fi
|
|
186
224
|
|
|
187
225
|
hdr "RA1 · 每一种选择形态都被拒"
|
|
226
|
+
# P318(D-4):pkill 与 killall 走**同一个**分类分支(scripts/shim/signal-gate 的
|
|
227
|
+
# `case "$_tool" in pkill|killall)` 只对 argc=1 的只读词放行,其余一律落到 `_act="refused"` 的默认),
|
|
228
|
+
# 拒绝文案也只有一份(同文件 181–194:`已拒绝 %s` / `调用参数:%s` / `为什么:…` / 安全路线三行),
|
|
229
|
+
# `_tool` 与 `_argv` 都在那三行里插值。所以四种 pkill 形态的「理由点名工具」只留**代表**(上面
|
|
230
|
+
# `-f <marker>` 那条),killall 留一条 —— 它是**另一个插值值**(工具名),把工具名写死成 pkill
|
|
231
|
+
# 的回归只有它能抓到。形态本身(exit 64)仍然逐个验。
|
|
188
232
|
for form in "-x sleep" "-P $DECOY1" "-u $(id -u)"; do
|
|
189
233
|
OUT="$(p159_gate pkill $form 2>&1)"; RC=$?
|
|
190
234
|
assert_eq "pkill $form 退出 64" "$RC" "64"
|
|
191
|
-
assert_has "pkill $form 的理由点名工具" "$OUT" "pkill"
|
|
192
235
|
done
|
|
193
236
|
OUT="$(p159_gate killall sleep 2>&1)"; RC=$?
|
|
194
237
|
assert_eq "killall sleep 退出 64" "$RC" "64"
|
|
195
|
-
assert_has "killall 的理由点名 killall" "$OUT" "killall"
|
|
238
|
+
assert_has "killall 的理由点名 killall(工具名插值,与 pkill 同一份文案)" "$OUT" "killall"
|
|
196
239
|
assert_eq "四种形态都没有落到桩上" "$(cat "$STUB_LOG" 2>/dev/null | wc -l | tr -d ' ')" "0"
|
|
197
240
|
assert_eq "调用日志:5 次调用 5 行 refused" "$(grep -c 'act=refused' "$GATE_LOG")" "5"
|
|
198
241
|
|
|
@@ -203,7 +246,9 @@ assert_eq "TEAM_ALLOW_PATTERN_KILL=1 时仍退出 64" "$RC" "64"
|
|
|
203
246
|
OUT2="$(env PATH="$GATE_DIR:$PATH" TEAM_SIGNAL_REAL="$STUB" TEAM_SIGNAL_CALLS_LOG="$LOGD/env.log" \
|
|
204
247
|
STUB_LOG="$STUB_LOG" TEAM_ALLOW_PATTERN_KILL=1 bash -c '"$0/pkill" -f "$1"' "$GATE_DIR" "$MARKER" 2>&1)"; RC2=$?
|
|
205
248
|
assert_eq "子 shell 里同样退出 64" "$RC2" "64"
|
|
206
|
-
|
|
249
|
+
# P318 删除:「继承环境下桩仍是 0 次」数的是 RA1 首条已经断言过的**同一份** STUB_LOG(累计 0 次),
|
|
250
|
+
# 而两次拒绝各自已经证明不执行真身。三条必要性判据一条也不满足(不是新契约面、不是新的事故形状、
|
|
251
|
+
# 守不住别的行为的哑失效)。接管者:RA1 首条的「桩一个调用都没收到」。
|
|
207
252
|
assert_eq "env.log 里没有 pass/refused 之外的动作" "$(grep -cv 'act=\(pass\|refused\)' "$LOGD/env.log" || true)" "0"
|
|
208
253
|
|
|
209
254
|
hdr "RA1 · 只读四词原样透传(记 act=pass)"
|
|
@@ -242,9 +287,9 @@ hdr "RA2 · 一次拒绝 + 一次只读 = 两行日志,拒绝逐字节进 .for
|
|
|
242
287
|
L="$LOGD/two.log"; rm -f "$L" "$L.forensics"; GATE_LOG="$L"; STUB_LOG="$LOGD/stub-two.log"; rm -f "$STUB_LOG"
|
|
243
288
|
p159_gate pkill -f x >/dev/null 2>&1
|
|
244
289
|
p159_gate pkill --help >/dev/null 2>&1
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
290
|
+
# P318:行数与两行的动作是同一段输出(`sed -n '1,2p'`)的三个切面 → 一条断言(缺行/顺序反了都红)。
|
|
291
|
+
assert_eq "日志恰好两行:第一行 act=refused、第二行 act=pass" \
|
|
292
|
+
"$(sed -n '1,2p' "$L" | awk '{n++; if (n==1 && /act=refused/) r=1; if (n==2 && /act=pass/) p=1} END {printf "%d/%d/%d", n+0, r+0, p+0}')" "2/1/1"
|
|
248
293
|
assert_eq "长保留文件与拒绝行逐字节相同" "$(cat "$L.forensics")" "$(sed -n 1p "$L")"
|
|
249
294
|
|
|
250
295
|
hdr "RA2 · 拒绝熬得过主日志轮转"
|
|
@@ -252,29 +297,205 @@ L="$LOGD/rot.log"; rm -f "$L" "$L.forensics"
|
|
|
252
297
|
printf '2026-01-01T00:00:00+00:00 · act=refused · tool=pkill · argv=-f seeded · pid=1 ppid=1 cwd=/tmp\n' > "$L.forensics"
|
|
253
298
|
awk 'BEGIN { for (i = 0; i < 2100; i++) printf "2026-01-01T00:00:00+00:00 · act=pass · tool=pkill · argv=--help · pid=1 ppid=1 cwd=/tmp\n" }' > "$L"
|
|
254
299
|
GATE_LOG="$L" p159_gate pkill -f x >/dev/null 2>&1
|
|
255
|
-
assert_has "轮转后首行是 rotation
|
|
256
|
-
assert_has "轮转标记的 dropped 记下被裁掉的 1101 行" "$(sed -n 1p "$L")" "dropped=1101"
|
|
300
|
+
assert_has "轮转后首行是 rotation 标记,dropped 记下被裁掉的 1101 行" "$(sed -n 1p "$L")" " · rotation · dropped=1101"
|
|
257
301
|
assert_eq "标记 + 1000 条调用行" "$(gate_lines "$L")" "1001"
|
|
258
302
|
assert_has "长保留里那条被拒绝的行还在(逐字节)" "$(cat "$L.forensics")" "argv=-f seeded"
|
|
259
303
|
|
|
260
304
|
hdr "RA2 · 保留写失败:可见、不改判定、不挂住"
|
|
261
305
|
L="$LOGD/fail.log"; rm -f "$L"; rm -rf "$L.forensics"; mkdir -p "$L.forensics"
|
|
262
|
-
OUT="$(GATE_LOG="$L" timeout
|
|
306
|
+
OUT="$(GATE_LOG="$L" timeout 300 env PATH="$GATE_DIR:$PATH" TEAM_SIGNAL_REAL="$STUB" \
|
|
263
307
|
TEAM_SIGNAL_CALLS_LOG="$L" STUB_LOG="$STUB_LOG" "$GATE_DIR/pkill" -f x 2>&1)"; RC=$?
|
|
264
308
|
assert_eq "保留路径是目录时仍退出 64(且有界,没被挂住)" "$RC" "64"
|
|
265
|
-
|
|
266
|
-
assert_has "诊断点名 .forensics
|
|
309
|
+
# P318:同一个诊断行,只留可操作的那一半(路径);装饰性的 ✗ 不是行为。
|
|
310
|
+
assert_has "诊断点名 .forensics 保留路径(保留写失败可见)" "$OUT" "$L.forensics"
|
|
267
311
|
assert_has "本行带 retention=failed" "$(cat "$L")" "retention=failed"
|
|
268
312
|
assert_has "本行仍带 act=refused" "$(cat "$L")" "act=refused"
|
|
269
313
|
rm -rf "$L.forensics"
|
|
270
314
|
|
|
271
315
|
hdr "RA2 · FIFO 目标不挂住"
|
|
272
316
|
L="$LOGD/fifo.log"; rm -f "$L"; mkfifo "$L"
|
|
273
|
-
RC=0; GATE_LOG="$L" timeout
|
|
317
|
+
RC=0; GATE_LOG="$L" timeout 300 env PATH="$GATE_DIR:$PATH" TEAM_SIGNAL_REAL="$STUB" TEAM_SIGNAL_CALLS_LOG="$L" \
|
|
274
318
|
STUB_LOG="$STUB_LOG" "$GATE_DIR/pkill" -f x >/dev/null 2>&1 || RC=$?
|
|
275
319
|
assert_eq "FIFO 日志目标:拒绝照常退出 64,没有被写端挂住" "$RC" "64"
|
|
276
320
|
rm -f "$L"
|
|
277
321
|
|
|
322
|
+
# ══════════════════════════════════════════════════════════════════════════════════════════════════════
|
|
323
|
+
# P167/P321 · 选择器入口(pgrep / pidof):已归档的 boundary 契约 —— 只有整 argv 的极窄形态放行,
|
|
324
|
+
# 其余一律 exit 64、stdout 留空、同名真身零调用;放行形式的 argv/stdout/stderr/状态都来自真身。
|
|
325
|
+
# 红侧仍由 --break=pass 提供:判定被改成放行后,这里的 exit-64/空 stdout/零调用断言逐条变红
|
|
326
|
+
# (「被拒的替换不交出 pid」那一腿把半成品也证伪:桩一放行就会交出 424242)。
|
|
327
|
+
hdr "P167/P321 · PID 产出的选择形态全部拒(空 stdout、后端零调用、日志 tool= 正确)"
|
|
328
|
+
SEL_GROUP="4242"; SEL_PARENT="5353"
|
|
329
|
+
SEL_LOG="$LOGD/sel-refuse.log"; GATE_LOG="$SEL_LOG"; STUB_LOG="$LOGD/stub-sel-refuse.log"
|
|
330
|
+
rm -f "$SEL_LOG" "$SEL_LOG.forensics" "$STUB_LOG"
|
|
331
|
+
for _form in "pgrep -f $MARKER" "pgrep --full $MARKER" "pgrep -f$MARKER" "pgrep -x sleep" "pgrep sleep" \
|
|
332
|
+
"pgrep -u 1000" "pgrep -U 1000" "pgrep -G 1000" "pidof sleep" "pidof -s sleep"; do
|
|
333
|
+
read -r -a _fargs <<< "$_form"
|
|
334
|
+
refuse_sel "$_form" "${_fargs[@]}"
|
|
335
|
+
unset _fargs
|
|
336
|
+
done
|
|
337
|
+
assert_eq "十种选择形态都没有落到同名后端上" "$(cat "$STUB_LOG" 2>/dev/null | wc -l | tr -d ' ')" "0"
|
|
338
|
+
assert_eq "调用日志:十次调用十行 refused" "$(grep -c 'act=refused' "$SEL_LOG")" "10"
|
|
339
|
+
|
|
340
|
+
hdr "P167/P321 · 显式 group/parent 与三种整命令计数:语义原样保留"
|
|
341
|
+
GATE_LOG="$LOGD/sel-pass.log"; STUB_LOG="$LOGD/stub-sel-pass.log"; rm -f "$GATE_LOG" "$STUB_LOG"
|
|
342
|
+
STUB_OUT="77 78"; STUB_ERR="sel-err-note"; STUB_EXIT=3
|
|
343
|
+
sel_run pgrep -g "$SEL_GROUP"
|
|
344
|
+
assert_eq "pgrep -g <GROUP> 的退出码来自同名后端(3)" "$SEL_RC" "3"
|
|
345
|
+
assert_eq "pgrep -g <GROUP> 的 stdout 逐字节来自后端" "$SEL_OUT" "77 78"
|
|
346
|
+
assert_eq "pgrep -g <GROUP> 的 stderr 逐字节来自后端" "$SEL_ERR" "sel-err-note"
|
|
347
|
+
assert_has "pgrep -g <GROUP> 的原样 argv 落到同名后端" "$(cat "$STUB_LOG")" "STUB argc=2 argv=-g $SEL_GROUP tool=pgrep"
|
|
348
|
+
|
|
349
|
+
STUB_OUT=""; STUB_ERR=""; STUB_EXIT=0
|
|
350
|
+
sel_run pgrep -P "$SEL_PARENT"
|
|
351
|
+
assert_eq "pgrep -P <PARENT> 的退出码来自同名后端(0)" "$SEL_RC" "0"
|
|
352
|
+
assert_has "pgrep -P <PARENT> 的原样 argv 落到同名后端" "$(tail -n 1 "$STUB_LOG")" "STUB argc=2 argv=-P $SEL_PARENT tool=pgrep"
|
|
353
|
+
: > "$STUB_LOG"
|
|
354
|
+
for _resp in "0 1" "2 0"; do
|
|
355
|
+
read -r _out _rc <<< "$_resp"
|
|
356
|
+
for _spell in "-fc /tmp/p164-fixture/pi-sleep" "-f -c /tmp/p164-fixture/pi-sleep" "-c -f /tmp/p164-fixture/pi-sleep"; do
|
|
357
|
+
read -r -a _cargs <<< "$_spell"
|
|
358
|
+
STUB_OUT="$_out"; STUB_ERR=""; STUB_EXIT="$_rc"
|
|
359
|
+
sel_run pgrep "${_cargs[@]}"
|
|
360
|
+
# P318:rc 与 stdout 是同一次放行调用的两半(都要求「原样保留」)→ 一条精确比较。
|
|
361
|
+
assert_eq "pgrep $_spell · 响应 $_out/$_rc:退出码与 stdout 都原样保留" "$SEL_RC|$SEL_OUT" "$_rc|$_out"
|
|
362
|
+
assert_has "pgrep $_spell · 响应 $_out/$_rc:argv 逐字节到后端" "$(tail -n 1 "$STUB_LOG")" "STUB argc=${#_cargs[@]} argv=$_spell tool=pgrep"
|
|
363
|
+
unset _cargs
|
|
364
|
+
done
|
|
365
|
+
done
|
|
366
|
+
# P318:per-call 的「日志行 act=pass」是同一份记录模板(P321 对拒绝形态用的是同一条口径)——
|
|
367
|
+
# 8 次放行调用(-g、-P、三种拼写 × 两种响应)各留一行,数一次总数即可,少一行/多一行都红。
|
|
368
|
+
assert_eq "本节 8 次放行调用各留一行 act=pass · tool=pgrep" "$(grep -c 'act=pass · tool=pgrep' "$GATE_LOG")" "8"
|
|
369
|
+
assert_eq "放行调用不建长保留文件(pass 不保留)" "$([ -e "$GATE_LOG.forensics" ] && echo present || echo absent)" "absent"
|
|
370
|
+
STUB_OUT=""; STUB_ERR=""; STUB_EXIT=0
|
|
371
|
+
|
|
372
|
+
hdr "P167/P321 · 隐式/部分匹配与额外谓词都不能放宽(判据是整个 argv)"
|
|
373
|
+
GATE_LOG="$LOGD/sel-narrow.log"; STUB_LOG="$LOGD/stub-sel-narrow.log"; rm -f "$GATE_LOG" "$STUB_LOG"
|
|
374
|
+
refuse_sel "pgrep -g 0(隐式组)" pgrep -g 0
|
|
375
|
+
refuse_sel "pgrep -P 0(隐式父)" pgrep -P 0
|
|
376
|
+
refuse_sel "pgrep -g 1,2(列表)" pgrep -g 1,2
|
|
377
|
+
refuse_sel "pgrep -P -1(负数)" pgrep -P -1
|
|
378
|
+
refuse_sel "pgrep -g(缺值)" pgrep -g
|
|
379
|
+
refuse_sel "pgrep -P ''(空值)" pgrep -P ""
|
|
380
|
+
refuse_sel "pgrep -P 12 -v(额外谓词)" pgrep -P 12 -v
|
|
381
|
+
refuse_sel "pgrep -v -g 12(反转)" pgrep -v -g 12
|
|
382
|
+
refuse_sel "pgrep -g 12 sleep(名字 + ID)" pgrep -g 12 sleep
|
|
383
|
+
refuse_sel "pgrep -P 12 -u 1000(再选用户)" pgrep -P 12 -u 1000
|
|
384
|
+
refuse_sel "pgrep --parent=12(未支持的拼写)" pgrep --parent=12
|
|
385
|
+
refuse_sel "pgrep -fc(缺模式)" pgrep -fc
|
|
386
|
+
refuse_sel "pgrep -fc ''(空模式)" pgrep -fc ""
|
|
387
|
+
refuse_sel "pgrep -fc -sleep(模式像旗标)" pgrep -fc -sleep
|
|
388
|
+
refuse_sel "pgrep -fc sleep -l(计数 + 列表)" pgrep -fc sleep -l
|
|
389
|
+
refuse_sel "pgrep -fcl sleep(粘连旗标)" pgrep -fcl sleep
|
|
390
|
+
refuse_sel "pgrep --teamsmith-allow-pattern sleep(带内 token)" pgrep --teamsmith-allow-pattern sleep
|
|
391
|
+
refuse_sel "pidof --help sleep(多参数)" pidof --help sleep
|
|
392
|
+
assert_eq "十八种窄化形态都没有落到同名后端上" "$(cat "$STUB_LOG" 2>/dev/null | wc -l | tr -d ' ')" "0"
|
|
393
|
+
|
|
394
|
+
hdr "P167/P321 · 只读信息词走各自的同名真身,旧 pkill pin 不接线"
|
|
395
|
+
PK_WITNESS="$TMP/pkill-witness"; cp "$STUB" "$PK_WITNESS"; chmod +x "$PK_WITNESS"
|
|
396
|
+
PK_LOG="$LOGD/pkill-witness.log"; rm -f "$PK_LOG"
|
|
397
|
+
GATE_LOG="$LOGD/sel-info.log"; STUB_LOG="$LOGD/stub-sel-info.log"; rm -f "$GATE_LOG" "$STUB_LOG"
|
|
398
|
+
STUB_EXIT=5
|
|
399
|
+
for _t in pgrep pidof; do
|
|
400
|
+
for _tok in --help -h -V --version; do
|
|
401
|
+
SEL_OUT="$(env PATH="$GATE_DIR:$SEL_SHIM:$PATH" TEAM_SIGNAL_REAL="$PK_WITNESS" TEAM_SIGNAL_CALLS_LOG="$GATE_LOG" \
|
|
402
|
+
STUB_LOG="$STUB_LOG" STUB_EXIT=5 "$GATE_DIR/$_t" "$_tok" 2>"$TMP/sel.err")"; SEL_RC=$?
|
|
403
|
+
# P318:退出码与「原样 argv 到同名真身」是同一次放行的两半 → 一条精确比较(整行相等,比前缀匹配更严)。
|
|
404
|
+
assert_eq "$_t $_tok:退出码来自同名真身(5)且 argv 逐字节到达" \
|
|
405
|
+
"$SEL_RC|$(tail -n 1 "$STUB_LOG")" "5|STUB argc=1 argv=$_tok tool=$_t"
|
|
406
|
+
done
|
|
407
|
+
done
|
|
408
|
+
# P318:per-token 的日志行模板并成一次总数(2 工具 × 4 词 = 8 行 act=pass)。
|
|
409
|
+
assert_eq "本节 8 次信息词调用各留一行 act=pass" "$(grep -c 'act=pass · tool=' "$GATE_LOG")" "8"
|
|
410
|
+
assert_eq "旧 pkill pin 一次都没被调用(不把诊断路由成信号工具)" "$(cat "$PK_LOG" 2>/dev/null | wc -l | tr -d ' ')" "0"
|
|
411
|
+
sel_run pgrep -P "$SEL_PARENT"
|
|
412
|
+
# P318:rc 与 argv 同一次调用;「pin 下 pkill 桩仍是零调用」与上面同一条 PK_LOG 的累计零调用重复。
|
|
413
|
+
assert_eq "同一 pin 下 pgrep -P <PARENT> 仍走自己的同名真身(rc=5 且 argv 到 pgrep 桩)" \
|
|
414
|
+
"$SEL_RC|$(tail -n 1 "$STUB_LOG")" "5|STUB argc=2 argv=-P $SEL_PARENT tool=pgrep"
|
|
415
|
+
|
|
416
|
+
hdr "P167/P321 · 拒绝不看 pin,也不看继承的环境"
|
|
417
|
+
GATE_LOG="$LOGD/sel-grant.log"; STUB_LOG="$LOGD/stub-sel-grant.log"; rm -f "$GATE_LOG" "$STUB_LOG"
|
|
418
|
+
for _leg in direct child; do
|
|
419
|
+
for _form in "pgrep -f $MARKER" "pidof sleep"; do
|
|
420
|
+
read -r -a _fargs <<< "$_form"
|
|
421
|
+
if [ "$_leg" = "direct" ]; then
|
|
422
|
+
SEL_OUT="$(env PATH="$GATE_DIR:$SEL_SHIM:$PATH" TEAM_SIGNAL_REAL="$TMP/no-such-real" TEAM_ALLOW_PATTERN_KILL=1 \
|
|
423
|
+
TEAM_SIGNAL_CALLS_LOG="$GATE_LOG" STUB_LOG="$STUB_LOG" "$GATE_DIR/${_fargs[0]}" "${_fargs[@]:1}" 2>/dev/null)"; SEL_RC=$?
|
|
424
|
+
else
|
|
425
|
+
SEL_OUT="$(env PATH="$GATE_DIR:$SEL_SHIM:$PATH" TEAM_SIGNAL_REAL="$TMP/no-such-real" TEAM_ALLOW_PATTERN_KILL=1 \
|
|
426
|
+
TEAM_SIGNAL_CALLS_LOG="$GATE_LOG" STUB_LOG="$STUB_LOG" \
|
|
427
|
+
bash -c '"$@"' _ "$GATE_DIR/${_fargs[0]}" "${_fargs[@]:1}" 2>/dev/null)"; SEL_RC=$?
|
|
428
|
+
fi
|
|
429
|
+
assert_eq "$_leg 腿的 $_form 拒绝仍退出 64 且 stdout 留空" "$SEL_RC|$SEL_OUT" "64|"
|
|
430
|
+
unset _fargs
|
|
431
|
+
done
|
|
432
|
+
done
|
|
433
|
+
assert_eq "不可用 pin + 继承授权下同名后端零调用" "$(cat "$STUB_LOG" 2>/dev/null | wc -l | tr -d ' ')" "0"
|
|
434
|
+
# P318 删除:这条与「继承环境不授权」段里的同一句断言逐字相同(同一份模板、另一种输入)。
|
|
435
|
+
# 接管者:那一条(env.log 上的同一个判据)。
|
|
436
|
+
|
|
437
|
+
hdr "P167/P321 · 被拒的替换不交出 pid"
|
|
438
|
+
GATE_LOG="$LOGD/sel-subst.log"; STUB_LOG="$LOGD/stub-sel-subst.log"; rm -f "$GATE_LOG" "$STUB_LOG"
|
|
439
|
+
KILL_LOG="$LOGD/subst-kill.log"; rm -f "$KILL_LOG"
|
|
440
|
+
# P318:消费函数改名 `record`(不是 `kill`)—— 断言的东西一模一样(替换结果零个词 → 消费函数收到
|
|
441
|
+
# 0 个参数 → `kill $(…)` 什么都不发),但 tests/ 里不许出现 `kill $(pgrep …)` 这种静态可见的
|
|
442
|
+
# 「谓词选进程」形态(signal-lint 规则 C,tests/ 拒绝豁免)。原来那两行是 lint 的一条真红:判据
|
|
443
|
+
# 没变,改的是让 lint 不再为**证明闸门有效**的那段替身代码报红。
|
|
444
|
+
env PATH="$GATE_DIR:$SEL_SHIM:/usr/bin:/bin" TEAM_SIGNAL_CALLS_LOG="$GATE_LOG" STUB_LOG="$STUB_LOG" \
|
|
445
|
+
STUB_OUT=424242 KILL_LOG="$KILL_LOG" \
|
|
446
|
+
bash -c 'record() { printf "%s\n" "$#" >> "$KILL_LOG"; }
|
|
447
|
+
record $(pgrep -f "$1")
|
|
448
|
+
record $(pidof sleep)' _ "$MARKER" >/dev/null 2>&1
|
|
449
|
+
assert_eq "\$(pgrep -f …) 与 \$(pidof sleep) 的替换结果都是零个词(消费函数收到 0 个参数 → kill 什么都不发)" \
|
|
450
|
+
"$(paste -sd, "$KILL_LOG" 2>/dev/null)" "0,0"
|
|
451
|
+
assert_eq "替换里的两个选择器都没有落到同名后端上" "$(cat "$STUB_LOG" 2>/dev/null | wc -l | tr -d ' ')" "0"
|
|
452
|
+
assert_eq "两次被拒的替换各自留一行 refused" "$(grep -c 'act=refused' "$GATE_LOG")" "2"
|
|
453
|
+
STUB_OUT=""
|
|
454
|
+
|
|
455
|
+
hdr "P167/P321 · 选择器的拒绝走同一份记录,也熬得过主日志轮转"
|
|
456
|
+
L="$LOGD/sel-rot.log"; rm -f "$L" "$L.forensics"
|
|
457
|
+
GATE_LOG="$L"; STUB_LOG="$LOGD/stub-sel-rot.log"; rm -f "$STUB_LOG"
|
|
458
|
+
refuse_sel "轮转前的 pgrep 拒绝" pgrep -f "$MARKER"
|
|
459
|
+
# 代表调用①(pgrep):诊断插值的文案与记录行模板 —— 28 个不同输入共用这两列,只在这里验
|
|
460
|
+
assert_has "代表调用(pgrep)的理由点名工具与完整 argv" "$SEL_ERR" "pgrep -f $MARKER"
|
|
461
|
+
assert_has "代表调用(pgrep)的日志行记 act=refused · tool=pgrep" "$(tail -n 1 "$L")" "act=refused · tool=pgrep"
|
|
462
|
+
refuse_sel "轮转前的 pidof 拒绝" pidof sleep
|
|
463
|
+
# 代表调用②(pidof):同一模板的第二种 tool= 插值
|
|
464
|
+
assert_has "代表调用(pidof)的理由点名工具与完整 argv" "$SEL_ERR" "pidof sleep"
|
|
465
|
+
assert_has "代表调用(pidof)的日志行记 act=refused · tool=pidof" "$(tail -n 1 "$L")" "act=refused · tool=pidof"
|
|
466
|
+
assert_eq "两条拒绝行逐字节进了 .forensics" "$(cmp -s "$L.forensics" <(sed -n '1,2p' "$L") && echo same || echo differ)" "same"
|
|
467
|
+
awk 'BEGIN { for (i = 0; i < 2099; i++) printf "2026-01-01T00:00:00+00:00 · act=pass · tool=pgrep · argv=--help · pid=1 ppid=1 cwd=/tmp\n" }' >> "$L"
|
|
468
|
+
STUB_EXIT=0; sel_run pgrep --help
|
|
469
|
+
assert_has "轮转后主日志首行是累积的 rotation 标记" "$(sed -n 1p "$L")" " · rotation · dropped=1102"
|
|
470
|
+
assert_eq "标记 + 1000 条调用行" "$(gate_lines "$L")" "1001"
|
|
471
|
+
# P318:两行(两种 tool= 插值)都在同一份 .forensics 里 —— 一条数出两条,缺一条就红。
|
|
472
|
+
assert_eq "两条拒绝行都还在 .forensics 里(逐字节,两种 tool= 插值)" \
|
|
473
|
+
"$(grep -cE 'act=refused · tool=(pgrep|pidof) · argv=(-f '"$MARKER"'|sleep)' "$L.forensics" || true)" "2"
|
|
474
|
+
|
|
475
|
+
hdr "P167/P321 · 选择器的拒绝:保留写失败可见、不改判定、不挂住"
|
|
476
|
+
L="$LOGD/sel-fail.log"; rm -f "$L"; rm -rf "$L.forensics"; mkdir -p "$L.forensics"
|
|
477
|
+
GATE_LOG="$L"; sel_run pgrep -f "$MARKER"
|
|
478
|
+
assert_eq "保留路径是目录时选择器拒绝仍退出 64" "$SEL_RC" "64"
|
|
479
|
+
assert_has "诊断点名 .forensics 保留路径(保留写失败可见)" "$SEL_ERR" "$L.forensics"
|
|
480
|
+
assert_has "本行带 retention=failed" "$(cat "$L")" "retention=failed"
|
|
481
|
+
assert_has "本行仍带 act=refused · tool=pgrep" "$(cat "$L")" "act=refused · tool=pgrep"
|
|
482
|
+
rm -rf "$L.forensics"
|
|
483
|
+
|
|
484
|
+
hdr "P167/P321 · 闸门之外的只读工具照旧直通,不记行"
|
|
485
|
+
GATE_LOG="$LOGD/sel-other.log"; STUB_LOG="$LOGD/stub-sel-other.log"; rm -f "$GATE_LOG" "$STUB_LOG"
|
|
486
|
+
STUB_OUT="ps-out"; STUB_EXIT=1
|
|
487
|
+
OUT="$(env PATH="$SEL_SHIM:/usr/bin:/bin" TEAM_SIGNAL_CALLS_LOG="$GATE_LOG" STUB_LOG="$STUB_LOG" \
|
|
488
|
+
STUB_OUT="ps-out" STUB_EXIT=1 ps -p 12 2>/dev/null)"; RC=$?
|
|
489
|
+
# P318:rc / stdout / argv 是同一次「闸门没拦」的调用的三个切面 → 一条精确比较。
|
|
490
|
+
assert_eq "ps -p 12:退出码 1、stdout 原样、argv 原样到同名替身(闸门不拦)" \
|
|
491
|
+
"$RC|$OUT|$(cat "$STUB_LOG")" "1|ps-out|STUB argc=2 argv=-p 12 tool=ps"
|
|
492
|
+
OUT="$(env PATH="$SEL_SHIM:/usr/bin:/bin" TEAM_SIGNAL_CALLS_LOG="$GATE_LOG" STUB_LOG="$STUB_LOG" \
|
|
493
|
+
STUB_OUT="ps-out" STUB_EXIT=0 fuser /tmp/p321-file 2>/dev/null)"; RC=$?
|
|
494
|
+
assert_eq "fuser 的退出码来自同名替身(0)" "$RC" "0"
|
|
495
|
+
assert_eq "两次只读工具调用没有给信号闸门记行" "$(gate_lines "$GATE_LOG" 2>/dev/null || echo 0)" "0"
|
|
496
|
+
|
|
497
|
+
STUB_OUT=""; STUB_EXIT=0
|
|
498
|
+
|
|
278
499
|
# ══════════════════════════════════════════════════════════════════════════════════════════════
|
|
279
500
|
if [ "$BREAK" = "pass" ]; then
|
|
280
501
|
# 红侧:判定被改成放行后,「exit 64 / 桩没被调用 / 诱饵活着」这些断言必须红。
|
|
@@ -299,7 +520,8 @@ assert_eq "真实仓库 state/ 受看面(产品日志 signal-calls.log*)前
|
|
|
299
520
|
# 形状探针(P171 的正向对照):在合成树上钉住白名单的**形状** —— 受看那一族进快照;活运行时的车道
|
|
300
521
|
# (capacity.log/panel.log/dev.env/bg/bg.log/inbox-watch/sub 里的文件)一律不进。任何「放宽成整个
|
|
301
522
|
# state/」或「受看面写成不存在的名字(空转)」的改动在这里当场变红,不必等一次真跑;跑动中写入的
|
|
302
|
-
# 各面(受看面红 / 活车道绿 / 整份快照变异红 / 签名红 / runner
|
|
523
|
+
# 各面(受看面红 / 活车道绿 / 整份快照变异红 / 签名红 / runner 车道绿)曾由 tests/flip-p171.sh
|
|
524
|
+
# 固定(P354 已删该夹具;证据见 docs/team/reports/P171-dev.md)。
|
|
303
525
|
WATCH_PROBE="$TMP/watch-shape"; rm -rf "$WATCH_PROBE"
|
|
304
526
|
mkdir -p "$WATCH_PROBE/bg" "$WATCH_PROBE/sub" "$WATCH_PROBE/inbox-watch"
|
|
305
527
|
: > "$WATCH_PROBE/signal-calls.log"; : > "$WATCH_PROBE/signal-calls.log.forensics"
|
|
@@ -10,5 +10,8 @@
|
|
|
10
10
|
# (与 tmux-lint.pl 同源)跳过 logs/ 目录,它们根本不在判定面内,因此不需要(也不该)冻结在这里
|
|
11
11
|
# —— 写进来会因「记 2 条、实际 0 条」判 baseline 过期。
|
|
12
12
|
#
|
|
13
|
+
#
|
|
14
|
+
# P326(PM 明授):这里曾经有 1 条记录 —— docs/team/reports/M35-dev2/pkg/lib.sh(按 sha256 冻结的
|
|
15
|
+
# M35-dev2 证据包)。那份证据文件在 main 上已不存在,记录的对象没了,于是只删这条记录、让清单回到空
|
|
16
|
+
# (lint 的规则、条数核对、每轮打印、--no-legacy 全红都不变)。清单为空时 lint 照旧逐文件判整个扫描面。
|
|
13
17
|
# 格式:<sha256> <命中条数> <仓库相对路径> # 理由
|
|
14
|
-
60ed8d86d57df08a655cea11aeb7ee9d2da0aa4e7768cb9b7fba39a3749b0637 2 docs/team/reports/M35-dev2/pkg/lib.sh # M35-dev2 证据包(P159 之前:M25 对照组的 pkill -f 清理)
|