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
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
# workflow 指引:fixture Agent 在五种结果后仍发同一正文、回执 body-free、账本不变(4.1)
|
|
17
17
|
# flip 坏源码→红→还原→绿:九条具名 guard 的独立 scratch 源码 + 哈希(2.4)
|
|
18
18
|
# skip-path 缺观测器(/proc/<pid>/io)时可见跳过并点名,而不是判红(V27 M3)
|
|
19
|
+
# guide 指引面:PM 提示词/协议/命令表三处纪律在场 + 示例命令对拍真解析器 + 四变异红侧(change: pm-reply-discipline · P267)
|
|
19
20
|
#
|
|
20
21
|
# 隔离(M7.2 的纪律):夹具只在临时根里的私有仓库跑真 CLI;进入任何写盘命令前先断言
|
|
21
22
|
# `team paths` 的 main_root 等于夹具仓库(不是真实仓库);跑完断言真实仓库的 docs/team/inbox
|
|
@@ -44,7 +45,7 @@ while [ $# -gt 0 ]; do
|
|
|
44
45
|
*) printf 'key-replies.sh:未知参数 %s(-h 看用法)\n' "$1" >&2; exit 2 ;;
|
|
45
46
|
esac
|
|
46
47
|
done
|
|
47
|
-
KR_ALL_GROUPS=(input paths original concurrency receipts interrupt paging bounded readonly workflow flip skip-path)
|
|
48
|
+
KR_ALL_GROUPS=(input paths original concurrency receipts interrupt paging bounded readonly workflow flip skip-path guide)
|
|
48
49
|
if [ "$ALL" = "1" ] && [ "${#KR_GROUPS[@]}" -gt 0 ]; then
|
|
49
50
|
printf 'key-replies.sh:--all 与 --select 不同用\n' >&2; exit 2
|
|
50
51
|
fi
|
|
@@ -212,8 +213,8 @@ kr_group_input() {
|
|
|
212
213
|
# 相同的合法输入再发一次 → 两条不同编号
|
|
213
214
|
kr_post "$p" dev2 '完整结论与取舍' "$B" >/dev/null; rc=$?
|
|
214
215
|
local lst; lst="$(kr_cli "$p" reply list --json)"
|
|
215
|
-
|
|
216
|
-
|
|
216
|
+
# P348 合并(两条 → 一条):"两条记录"与"编号递增到 2"是同一份快照的两个面,合成一个谓词不会少判什么。
|
|
217
|
+
jok "$lst" 'len(d["entries"])==2 and d["entries"][0]["no"]==2' && ok "input:重复提交不合并(两条)、编号严格递增(最新 = 2)" || bad "input:重复提交/编号不对($lst)"
|
|
217
218
|
# label 边界
|
|
218
219
|
printf 'x\n' >"$B"
|
|
219
220
|
kr_post "$p" '' 'T' "$B" >/dev/null 2>&1; eq "input:缺 --from → rc2" "$?" "2"
|
|
@@ -266,11 +267,9 @@ kr_group_paths() {
|
|
|
266
267
|
rm -f "$KR/index.v1"; mv "$KR/index.real" "$KR/index.v1"
|
|
267
268
|
# 2) writer.lock 是 FIFO → post 拒绝且不阻塞
|
|
268
269
|
rm -f "$KR/writer.lock"; mkfifo "$KR/writer.lock"
|
|
269
|
-
local t0 t1; t0=$(date +%s)
|
|
270
270
|
kr_post "$p" dev2 'T-fifo' "$B" >/dev/null 2>&1; rc=$?
|
|
271
|
-
t1=$(date +%s)
|
|
272
271
|
eq "paths:writer.lock 是 FIFO → rc4" "$rc" "4"
|
|
273
|
-
|
|
272
|
+
# P316:不判耗时;rc4 证明它没有阻塞到超时,下面清掉 FIFO 继续。
|
|
274
273
|
rm -f "$KR/writer.lock"
|
|
275
274
|
# 3) bodies/<id>.md 被换成目录 / 软链 → show 拒绝,目标不动
|
|
276
275
|
local bid; bid="$(kr_cli "$p" reply list --json | jget /dev/stdin 'd["entries"][0]["sha256"]' >/dev/null; ls "$KR/bodies" | head -1)"
|
|
@@ -379,8 +378,8 @@ kr_group_original() {
|
|
|
379
378
|
kr_cli "$p" reply show 1 --raw >"$TMP/orig-out.md" 2>"$TMP/orig-raw.err"; rc=$?
|
|
380
379
|
eq "original:raw 导出 rc=0" "$rc" "0"
|
|
381
380
|
if cmp -s "$B" "$TMP/orig-out.md"; then ok "original:raw 与输入逐字节相同(CRLF/尾换行)"; else bad "original:raw 与输入不同"; fi
|
|
382
|
-
|
|
383
|
-
|
|
381
|
+
# P348 删:原来这里还有一条「两份 sha256 一致」——`cmp -s` 已经比过每一个字节,sha 只是同一事实的另一种数法;
|
|
382
|
+
# 字节相同 ⇒ sha 相同,没有一种破坏能让 sha 红而 cmp 绿。
|
|
384
383
|
local js; js="$(kr_cli "$p" reply show 1 --json)"
|
|
385
384
|
jok "$js" 'd["text_kind"]=="safe-display" and d["bytes"]>0 and len(d["sha256"])==64' && ok "original:JSON 标明显示表示并带原文长度/哈希" || bad "original:JSON 结构不对($js)"
|
|
386
385
|
not_has "original:JSON 的显示文本不含 OSC" "$(jget "$js" 'd["display_text"]')" "$(printf '\033]0;t\007')"
|
|
@@ -447,8 +446,9 @@ kr_group_concurrency() {
|
|
|
447
446
|
wait "$w1" 2>/dev/null; wait "$w2" 2>/dev/null
|
|
448
447
|
eq "concurrency:两个真进程都 rc=0" "$(cat "$TMP/c1.rc")/$(cat "$TMP/c2.rc")" "0/0"
|
|
449
448
|
local lst; lst="$(kr_cli "$p" reply list --json)"
|
|
450
|
-
|
|
451
|
-
|
|
449
|
+
# P348 合并(两条 → 一条):同一次快照的条数与编号集合。
|
|
450
|
+
jok "$lst" 'len(d["entries"])==2 and sorted(e["no"] for e in d["entries"])==[1, 2]' \
|
|
451
|
+
&& ok "concurrency:两条记录、编号互不相同且连续([1, 2])" || bad "concurrency:条数/编号不对($lst)"
|
|
452
452
|
eq "concurrency:并发读快照数 >0" "$([ "$reads" -gt 0 ] && echo yes || echo no)" "yes"
|
|
453
453
|
eq "concurrency:并发读没看到未提交的半条" "$partial" "0"
|
|
454
454
|
# 两份原文都能取回
|
|
@@ -506,18 +506,29 @@ kr_group_receipts() {
|
|
|
506
506
|
else
|
|
507
507
|
bad "receipts:以 root 跑,不可写目录这条没法测(不许静默跳过)"
|
|
508
508
|
fi
|
|
509
|
-
# 锁竞争:另一个活 publisher 持锁
|
|
509
|
+
# 锁竞争:另一个活 publisher 持锁 → rc5,且没有新发布;list/show 照常
|
|
510
510
|
kr_hold_lock "$KR" || bad "receipts:夹具没能持住写锁"
|
|
511
|
-
local t0 t1; t0="$(date +%s%N)"
|
|
512
511
|
kr_post "$p" dev2 'R3' "$B" >"$TMP/r-busy.out" 2>&1; rc=$?
|
|
513
|
-
t1="$(date +%s%N)"
|
|
514
512
|
eq "receipts:锁竞争 → rc5" "$rc" "5"
|
|
515
|
-
local waited=$(( (t1 - t0) / 1000000 ))
|
|
516
|
-
if [ "$waited" -ge 1500 ] && [ "$waited" -le 6000 ]; then ok "receipts:等锁区间 ${waited}ms(≤2000ms 等待 + 启动)"; else bad "receipts:等锁区间异常 ${waited}ms"; fi
|
|
517
513
|
eq "receipts:竞争失败没有发布" "$(kr_cli "$p" reply list --json | jget /dev/stdin 'd["total_slots"]')" "1"
|
|
518
|
-
kr_cli "$p" reply show 1 >/dev/null 2>&1;
|
|
519
|
-
kr_cli "$p" reply list >/dev/null 2>&1;
|
|
514
|
+
kr_cli "$p" reply show 1 >/dev/null 2>&1; local busy_show=$?
|
|
515
|
+
kr_cli "$p" reply list >/dev/null 2>&1; local busy_list=$?
|
|
516
|
+
# P348 合并(两条 → 一条):两个命令两个退出码一起比,任一半走样都红。
|
|
517
|
+
eq "receipts:锁被占时 show/list 照常(都 rc=0)" "$busy_show/$busy_list" "0/0"
|
|
520
518
|
kr_release_lock
|
|
519
|
+
# P316 · V61 F3:spec 承诺「writer-lock contention 最多等 2000 ms 后返回 5」(scripts/replies.mjs 的
|
|
520
|
+
# LOCK_WAIT_SEC=2)。这条**不改回秒表**:把 `flock` 换成"记下 argv 就以忙退出"的桩,断言工具交给
|
|
521
|
+
# 限时 flock 的**就是它自己的那个界**(`-w 2`)——把 LOCK_WAIT_SEC 改成 30,这里立刻红。
|
|
522
|
+
# 只守「-w 2」这一段:后面的 fd 是实现细节,不是锁契约(V63)。
|
|
523
|
+
local krstub="$TMP/kr-flock-stub" krlog="$TMP/kr-flock-argv"
|
|
524
|
+
mkdir -p "$krstub"; : > "$krlog"
|
|
525
|
+
printf '#!/usr/bin/env bash\nprintf "%%s\\n" "$*" >> "%s"\nexit 1\n' "$krlog" > "$krstub/flock"
|
|
526
|
+
chmod +x "$krstub/flock"
|
|
527
|
+
kr_post "$p" dev2 'R5' "$B" PATH="$krstub:$PATH" >"$TMP/r-lockbound.out" 2>&1; rc=$?
|
|
528
|
+
eq "receipts:限时 flock 报到界了(忙) → rc5" "$rc" "5"
|
|
529
|
+
has "receipts:传给 flock 的是产品自己的界(-w 2)" "$(cat "$krlog")" "-w 2 "
|
|
530
|
+
has "receipts:忙时的诊断报出同一个界(2000ms)" "$(cat "$TMP/r-lockbound.out")" "2000ms"
|
|
531
|
+
eq "receipts:限时 flock 放弃时同样没有发布" "$(kr_cli "$p" reply list --json | jget /dev/stdin 'd["total_slots"]')" "1"
|
|
521
532
|
# unconfirmed(最终 fsync 失败):rc6 + candidate_no,不自动重发
|
|
522
533
|
kr_post "$p" dev2 'R4' "$B" TEAM_REPLY_FAULT=fail:index-fsync >"$TMP/r-unc.out" 2>&1; rc=$?
|
|
523
534
|
eq "receipts:最终 fsync 失败 → rc6" "$rc" "6"
|
|
@@ -575,7 +586,7 @@ kr_group_interrupt() {
|
|
|
575
586
|
kr_post "$p" dev2 'K4' "$B" >/dev/null 2>&1; rc=$?
|
|
576
587
|
eq "interrupt:完整坏槽时 post 拒绝(rc4)而不是截断" "$rc" "4"
|
|
577
588
|
eq "interrupt:坏槽字节未被改写(sha 不变)" "$(sha256sum "$KR/index.v1" | cut -d' ' -f1)" "$bad_hash"
|
|
578
|
-
|
|
589
|
+
# P348 删:原来还断言「坏槽尺寸未变」—— 整文件 sha 未变已经蕴含尺寸未变(截断一定改 sha)。
|
|
579
590
|
kr_ev_note "interrupt baseline_hash=$before_hash corrupt_hash=$bad_hash"
|
|
580
591
|
}
|
|
581
592
|
|
|
@@ -608,12 +619,13 @@ kr_group_paging() {
|
|
|
608
619
|
[ "$cursor" = "None" ] && break
|
|
609
620
|
if [ "$pages" -gt 10 ]; then bad "paging:cursor 链没在 10 页内结束"; break; fi
|
|
610
621
|
done
|
|
611
|
-
local norm; norm="$(printf '%s' "$seen" | tr ' ' '\n' | grep -E '^[0-9]+$' | tr '\n' ' ')"
|
|
622
|
+
local norm; norm="$(printf '%s' "$seen" | tr ' ' '\n' | grep -E '^[0-9]+$' | tr '\n' ' ' | sed -e 's/ */ /g' -e 's/^ //' -e 's/ $//')"
|
|
623
|
+
local want_chain; want_chain="$(seq 123 -1 1 | tr '\n' ' ' | sed 's/ $//')"
|
|
612
624
|
eq "paging:3 页覆盖 123→1" "$pages" "3"
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
eq "paging
|
|
625
|
+
# P348 合并(四条 → 一条):原来说「条数 123」「起点 123」「终点 1」「去重后仍 123」四条,
|
|
626
|
+
# 合起来才等于「恰好一遍」;直接与期望链 123 122 … 1 逐字比一次,四条的事实全在里面(而且更强:
|
|
627
|
+
# 顺带钉住降序与无跳号,四条里任何一条独有的破坏都会让这一条红)。
|
|
628
|
+
eq "paging:链恰好是 123 122 … 1(无重复、无缺失、降序)" "$norm" "$want_chain"
|
|
617
629
|
# 坏页仍前进:把某一整页(编号 24..73 是第 2 页)打坏
|
|
618
630
|
local KR="$p/.pi/team/state/key-replies" n
|
|
619
631
|
for n in $(seq 74 123); do :; done
|
|
@@ -664,8 +676,9 @@ kr_group_bounded() {
|
|
|
664
676
|
local KR="$p/.pi/team/state/key-replies"
|
|
665
677
|
printf 'ZZZZ' | dd of="$KR/index.v1" bs=1 seek=$((100000 * 4096 - 100)) conv=notrunc status=none
|
|
666
678
|
local sj; sj="$(kr_cli "$p" __panel-data --block reply_summary)"
|
|
667
|
-
|
|
668
|
-
|
|
679
|
+
# P348 合并(两条 → 一条):同一次机器出口的两个面(状态 + 没有退回旧标题)。
|
|
680
|
+
jok "$sj" 'd["state"]=="unavailable" and d.get("entry") is None' \
|
|
681
|
+
&& ok "bounded:坏最新槽 summary=unavailable 且不退回旧标题" || bad "bounded:坏最新槽的处理不对($sj)"
|
|
669
682
|
# 读取量的观测器:内核自述的 /proc/<pid>/io(rchar/syscr)+ /proc/<pid>/fd{,info}(进程真正打开过
|
|
670
683
|
# 哪些路径、以什么 flags 打开)。无编译器依赖 —— 门禁镜像按 M47 故意 purge 掉 build-essential,
|
|
671
684
|
# 所以旧版 LD_PRELOAD shim 在那里永远编不出来(V27 的 M3)。观测器不可用(hidepid 等)时**点名跳过**。
|
|
@@ -983,7 +996,7 @@ kr_group_flip() {
|
|
|
983
996
|
kr_post "$p" dev2 'base' "$b" >/dev/null 2>&1 || return 1
|
|
984
997
|
rm -f "$KR/index.v1"; mkfifo "$KR/index.v1"
|
|
985
998
|
local rc
|
|
986
|
-
timeout
|
|
999
|
+
timeout 300 bash -c "cd '$p' && exec \"\$@\"" _ "${KR_CLEAN[@]}" "$KR_TEAM" --root "$p" reply list --json >/dev/null 2>&1
|
|
987
1000
|
rc=$?
|
|
988
1001
|
rm -f "$KR/index.v1"
|
|
989
1002
|
printf 'flip/fifo_block:list 对 FIFO 索引 rc=%s\n' "$rc" >>"$TMP/flip-fifo.log"
|
|
@@ -1018,7 +1031,9 @@ kr_group_skip_path() {
|
|
|
1018
1031
|
fi
|
|
1019
1032
|
# 子进程里跑 bounded + flip:必须点名跳过、没有 ✗、退出 0(可见跳过 ≠ 静默通过,也 ≠ 红)
|
|
1020
1033
|
local out="$TMP/skip-path.out" rc
|
|
1021
|
-
|
|
1034
|
+
# P357/P324:嵌套子进程跑的是**用完就扔**的隔离基,门禁的 `--keep` 说的是它自己那个根。继承了保留
|
|
1035
|
+
# 开关时子进程末行会变成「保留临时根:…」而不是结果行 —— 那条断言测的「跑完整轮」就永远不成立。
|
|
1036
|
+
TEAM_REPLY_NO_PROC_IO=1 env -u TEAM_TMP_KEEP timeout 900 bash "$SELF_DIR/key-replies.sh" --select bounded,flip >"$out" 2>&1; rc=$?
|
|
1022
1037
|
# 实质判据有两条:子进程跑完了整轮(末行是结果行且 ✗0)且没有红行。失败时**重跑一次带 trace**
|
|
1023
1038
|
# 只为取证(不是掩盖红:红照旧判红,只是把成因写进断言与证据包)。
|
|
1024
1039
|
local last
|
|
@@ -1027,7 +1042,7 @@ kr_group_skip_path() {
|
|
|
1027
1042
|
*"✗0"*) ok "skip-path:缺观测器时子进程跑完整轮且 ✗0(末行:${last})" ;;
|
|
1028
1043
|
*)
|
|
1029
1044
|
local trace="$TMP/skip-path-trace.out"
|
|
1030
|
-
TEAM_REPLY_NO_PROC_IO=1 timeout 600 bash -x "$SELF_DIR/key-replies.sh" --select bounded,flip >"$trace" 2>&1
|
|
1045
|
+
TEAM_REPLY_NO_PROC_IO=1 env -u TEAM_TMP_KEEP timeout 600 bash -x "$SELF_DIR/key-replies.sh" --select bounded,flip >"$trace" 2>&1
|
|
1031
1046
|
kr_ev_save "$trace" "skip-path-failure-trace.txt"
|
|
1032
1047
|
bad "skip-path:子进程没跑完整轮(末行=[${last:-<空>}],rc=$rc,子进程日志长度=$(stat -c %s "$out" 2>/dev/null || echo 0))—— 带 trace 的重跑见证据包 skip-path-failure-trace.txt;trace 尾部=[$(tail -3 "$trace" 2>/dev/null | tr '\n' ' ' | cut -c1-200)]"
|
|
1033
1048
|
;;
|
|
@@ -1046,6 +1061,244 @@ kr_group_skip_path() {
|
|
|
1046
1061
|
kr_ev_save "$out" "skip-path-bounded-flip.txt"
|
|
1047
1062
|
}
|
|
1048
1063
|
|
|
1064
|
+
# ---------------------------------------------------------------- 组:guide(change: pm-reply-discipline · P267;判据面 P301)
|
|
1065
|
+
# 纪律要随工具走:三处指令面(注入的 PM 提示词 / 协议的 §4b / SKILL 命令表)各自带着同一套**语义锚点**
|
|
1066
|
+
# (大小写不敏感;断言的是「义务在场」,不是逐字措辞),并且各自带着同一条**判据** `written for the user`
|
|
1067
|
+
# ——写给用户的回复(回答/汇报/结论/裁定/请示/交付摘要)必须发布,写给巡检/席位/别的项目 PM 的与工具回执不算。
|
|
1068
|
+
# 模板里印出来的示例命令必须被**真解析器**接受
|
|
1069
|
+
# ——「印出来就能用」是承诺兑现;控制臂(同一 argv 追加未知旗标)必须被拒,否则这个探针是空对空。
|
|
1070
|
+
# 五个 $TMP 变异副本必须红并点名被改的面(①②③⑤ 还要点名缺失的判据 token),重新从真树复制后绿。
|
|
1071
|
+
# 真树与真项目在这一组里只读。
|
|
1072
|
+
guide_spec() { # <面名> → 分号分隔的锚点;`row:` 前缀 = 必须落在 SKILL 的 `| Key replies |` 行内
|
|
1073
|
+
case "$1" in
|
|
1074
|
+
"prompt template") printf '%s' 'conclusion;milestone;ruling;ask the user;--stdin;team reply post;written for the user' ;;
|
|
1075
|
+
"protocol reference") printf '%s' 'conclusion;milestone;ruling;ask the user;--stdin;team reply post;No tool can verify;written for the user' ;;
|
|
1076
|
+
"command table") printf '%s' 'milestone;ruling;ask the user;row:conclusion;row:say;row:notify;row:--stdin;row:team reply post;row:written for the user' ;;
|
|
1077
|
+
esac
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
guide_surface_path() { # <面名> → 该面的真实路径
|
|
1081
|
+
case "$1" in
|
|
1082
|
+
"prompt template") printf '%s\n' "$SKILL_DIR/templates/pm-prompt.md.tmpl" ;;
|
|
1083
|
+
"protocol reference") printf '%s\n' "$SKILL_DIR/references/protocol.md" ;;
|
|
1084
|
+
"command table") printf '%s\n' "$SKILL_DIR/SKILL.md" ;;
|
|
1085
|
+
esac
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
guide_check_surface() { # <面名> <文件>:绿=0;红=1 并点名面 + 缺的锚点(真树与变异副本共用)
|
|
1089
|
+
local name="$1" f="$2" specs row="" miss="" a want
|
|
1090
|
+
local -a arr
|
|
1091
|
+
if [ ! -f "$f" ]; then
|
|
1092
|
+
bad "guide-surfaces:$name 文件缺失($f)—— 这个面不再承载「关键结论先发布」"
|
|
1093
|
+
return 1
|
|
1094
|
+
fi
|
|
1095
|
+
specs="$(guide_spec "$name")"
|
|
1096
|
+
case "$specs" in *row:*) row="$(grep -m1 '^| Key replies |' "$f" 2>/dev/null)" ;; esac
|
|
1097
|
+
IFS=';' read -r -a arr <<<"$specs"
|
|
1098
|
+
for a in "${arr[@]}"; do
|
|
1099
|
+
case "$a" in
|
|
1100
|
+
row:*)
|
|
1101
|
+
want="${a#row:}"
|
|
1102
|
+
if [ -z "$row" ] || ! printf '%s' "$row" | grep -qiF -- "$want"; then
|
|
1103
|
+
miss="$miss [$want](Key replies 行内)"
|
|
1104
|
+
fi ;;
|
|
1105
|
+
*)
|
|
1106
|
+
grep -qiF -- "$a" "$f" || miss="$miss [$a]" ;;
|
|
1107
|
+
esac
|
|
1108
|
+
done
|
|
1109
|
+
if [ -z "$miss" ]; then
|
|
1110
|
+
ok "guide-surfaces:$name 带着全部语义锚点(${specs//;/、},大小写不敏感)"
|
|
1111
|
+
else
|
|
1112
|
+
bad "guide-surfaces:$name 丢了纪律判据:$miss —— 这里判的是这个面缺了什么,不是要求某个措辞;这个面不再承载「关键结论先发布」"
|
|
1113
|
+
return 1
|
|
1114
|
+
fi
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
guide_example_cmd() { # <模板> → 唯一示例命令(去反引号);次数≠1/形状不全 → rc1 + stderr 说明
|
|
1118
|
+
local tmpl="$1" n cmd
|
|
1119
|
+
n="$(grep -c -- 'team reply post' "$tmpl" 2>/dev/null || true)"
|
|
1120
|
+
if [ "${n:-0}" != "1" ]; then
|
|
1121
|
+
printf '模板里 team reply post 出现 %s 次(示例命令必须是唯一一行)' "${n:-0}" >&2
|
|
1122
|
+
return 1
|
|
1123
|
+
fi
|
|
1124
|
+
cmd="$(grep -o 'team reply post[^`]*' "$tmpl" 2>/dev/null | head -1 | sed 's/[[:space:]]*$//')"
|
|
1125
|
+
if ! printf '%s' "$cmd" | grep -q -- '--stdin'; then
|
|
1126
|
+
printf '示例命令里没有 --stdin(取到 [%s])' "$cmd" >&2
|
|
1127
|
+
return 1
|
|
1128
|
+
fi
|
|
1129
|
+
case "$cmd" in
|
|
1130
|
+
*'< '*) ;;
|
|
1131
|
+
*) printf '示例命令没有用 < <file> 把正文从文件重定向进来(取到 [%s])' "$cmd" >&2; return 1 ;;
|
|
1132
|
+
esac
|
|
1133
|
+
printf '%s\n' "$cmd"
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
guide_run_example() { # <夹具项目> <旗标文本(印刷原样,去掉重定向)> <正文文件> —— 行首 team 解析为真 CLI
|
|
1137
|
+
local p="$1" flags="$2" f="$3"
|
|
1138
|
+
( cd "$p" && env "${KR_CLEAN[@]:1}" bash -c 'eval "bash \"$1\" --root \"$2\" $3 < \"$4\""' _ "$KR_TEAM" "$p" "$flags" "$f" )
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
guide_check_example() { # <模板> <夹具项目>:绿=0;红=1(文案里点名 example command)
|
|
1142
|
+
local tmpl="$1" p="$2" cmd rest flags body out rc2 rc before after after2 red=0
|
|
1143
|
+
cmd="$(guide_example_cmd "$tmpl" 2>"$TMP/guide-example.err")"
|
|
1144
|
+
if [ -z "$cmd" ]; then
|
|
1145
|
+
bad "guide-example:example command 在 $tmpl 里取不到可执行的样例($(head -c 160 "$TMP/guide-example.err" 2>/dev/null))"
|
|
1146
|
+
return 1
|
|
1147
|
+
fi
|
|
1148
|
+
rest="${cmd#team }"; flags="${rest%% < *}" # 在重定向前的 ` < ` 处截断(题目的 `<short title>` 里没有这个分隔)
|
|
1149
|
+
if [ "$flags" = "$rest" ] || ! printf '%s' "$flags" | grep -q -- '--stdin'; then
|
|
1150
|
+
bad "guide-example:example command 的旗标部分取不到(取到 [$(printf '%s' "$flags" | head -c 120)])"
|
|
1151
|
+
return 1
|
|
1152
|
+
fi
|
|
1153
|
+
flags="${flags%"${flags##*[![:space:]]}"}" # 去掉换行/尾随空格,保留印刷原样的词序列
|
|
1154
|
+
body="$TMP/guide-example-body.txt"
|
|
1155
|
+
printf '引导面探针正文:完整的一份答复(不是摘要)。\n' >"$body"
|
|
1156
|
+
before="$(kr_cli "$p" reply list --json 2>/dev/null | jget /dev/stdin 'd["total_slots"]')"
|
|
1157
|
+
out="$(guide_run_example "$p" "$flags" "$body" 2>&1)"; rc=$?
|
|
1158
|
+
after="$(kr_cli "$p" reply list --json 2>/dev/null | jget /dev/stdin 'd["total_slots"]')"
|
|
1159
|
+
if [ "$rc" = "0" ]; then
|
|
1160
|
+
ok "guide-example:示例命令被真解析器接受(rc=0,$cmd)"
|
|
1161
|
+
else
|
|
1162
|
+
bad "guide-example:example command 被真解析器拒绝(rc=$rc,输出 [$(printf '%s' "$out" | head -c 160)])"; red=1
|
|
1163
|
+
fi
|
|
1164
|
+
if jok "$out" 'd["outcome"]=="saved"'; then
|
|
1165
|
+
ok "guide-example:示例命令的回执 outcome=saved(no=$(jget "$out" 'd.get("no")'))"
|
|
1166
|
+
else
|
|
1167
|
+
bad "guide-example:example command 的回执不是 saved(rc=$rc,输出 [$(printf '%s' "$out" | head -c 160)])"; red=1
|
|
1168
|
+
fi
|
|
1169
|
+
if [ "${after:-x}" = "$(( ${before:-0} + 1 ))" ]; then
|
|
1170
|
+
ok "guide-example:示例命令真的发布了一条(槽位 ${before:-?} → ${after:-?})"
|
|
1171
|
+
else
|
|
1172
|
+
bad "guide-example:example command 发布后槽位不是 +1(${before:-?} → ${after:-?})"; red=1
|
|
1173
|
+
fi
|
|
1174
|
+
out="$(guide_run_example "$p" "$flags --frobnicate-probe" "$body" 2>&1)"; rc2=$?
|
|
1175
|
+
after2="$(kr_cli "$p" reply list --json 2>/dev/null | jget /dev/stdin 'd["total_slots"]')"
|
|
1176
|
+
if [ "$rc2" = "2" ]; then
|
|
1177
|
+
ok "guide-example:控制臂(同一 argv + 未知旗标)被真解析器拒绝(rc=2)"
|
|
1178
|
+
else
|
|
1179
|
+
bad "guide-example:example command 的控制臂没有拒绝未知旗标(rc=$rc2)—— 探针可能把旗标吞掉了"; red=1
|
|
1180
|
+
fi
|
|
1181
|
+
if printf '%s' "$out" | grep -qF -- '未知参数'; then
|
|
1182
|
+
ok "guide-example:控制臂诊断点名「未知参数」"
|
|
1183
|
+
else
|
|
1184
|
+
bad "guide-example:example command 的控制臂诊断没有点名「未知参数」([$(printf '%s' "$out" | head -c 160)])"; red=1
|
|
1185
|
+
fi
|
|
1186
|
+
if [ "${after2:-x}" = "${after:-y}" ]; then
|
|
1187
|
+
ok "guide-example:控制臂没有新槽位(拒绝发生在发布之前,槽位仍 ${after2:-?})"
|
|
1188
|
+
else
|
|
1189
|
+
bad "guide-example:example command 的控制臂留下了新槽位(${after:-?} → ${after2:-?})"; red=1
|
|
1190
|
+
fi
|
|
1191
|
+
return "$red"
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
kr_group_guide() {
|
|
1195
|
+
section "guide · 三处表面的纪律 + 按读者判据 + 示例命令对拍 + 五变异(change: pm-reply-discipline · P267 / P301)"
|
|
1196
|
+
local TMPL PROTO SKILLMD pex mut MUTD out rc
|
|
1197
|
+
TMPL="$(guide_surface_path "prompt template")"
|
|
1198
|
+
PROTO="$(guide_surface_path "protocol reference")"
|
|
1199
|
+
SKILLMD="$(guide_surface_path "command table")"
|
|
1200
|
+
|
|
1201
|
+
# ---- guide-surfaces:真树的三处表面各自带着自己的锚点(缺哪个点名哪个面)
|
|
1202
|
+
guide_check_surface "prompt template" "$TMPL"
|
|
1203
|
+
guide_check_surface "protocol reference" "$PROTO"
|
|
1204
|
+
guide_check_surface "command table" "$SKILLMD"
|
|
1205
|
+
|
|
1206
|
+
# ---- guide-example:印出来的示例命令必须被真解析器接受(真 CLI、私有夹具、重定向指向夹具正文)
|
|
1207
|
+
pex="$(kr_new_proj "guide-example")"
|
|
1208
|
+
guide_check_example "$TMPL" "$pex"
|
|
1209
|
+
|
|
1210
|
+
# ---- guide-flip:四个 $TMP 变异副本,每次必须红并点名被改的面;还原(重新从真树复制)后绿
|
|
1211
|
+
MUTD="$TMP/guide-mut"; rm -rf "$MUTD"; mkdir -p "$MUTD"
|
|
1212
|
+
|
|
1213
|
+
guide_flip_red() { # <标签> <期望点名的面> <rc> <断言文本>
|
|
1214
|
+
local label="$1" expect="$2" rc="$3" text="$4" first
|
|
1215
|
+
if [ -n "$KR_EV" ]; then
|
|
1216
|
+
printf '%s\n' "$text" >"$TMP/guide-flip.out"
|
|
1217
|
+
kr_ev_save "$TMP/guide-flip.out" "guide-flip-$(printf '%s' "$expect" | tr ' ' '-')-red.txt"
|
|
1218
|
+
fi
|
|
1219
|
+
if [ "$rc" != "0" ] && printf '%s' "$text" | grep -q '✗' && printf '%s' "$text" | grep -qF -- "$expect"; then
|
|
1220
|
+
first="$(printf '%s' "$text" | grep -m1 '✗' | sed 's/^[[:space:]]*//; s/ —— .*$//')"
|
|
1221
|
+
ok "guide-flip/$label:变异 → 红并点名 [$expect](${first:0:200})"
|
|
1222
|
+
else
|
|
1223
|
+
bad "guide-flip/$label:变异后没有红/没有点名 [$expect](rc=$rc,输出 [$(printf '%s' "$text" | tr '\n' '|' | cut -c1-220)])"
|
|
1224
|
+
fi
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
guide_flip_names_criterion() { # <标签> <断言文本>:红文案里必须出现被摘掉的那条判据(缺了什么,不是措辞要求)
|
|
1228
|
+
local label="$1" text="$2"
|
|
1229
|
+
if printf '%s' "$text" | grep -qF -- '[written for the user]'; then
|
|
1230
|
+
ok "guide-flip/$label:红文案点名缺失的判据 [written for the user]"
|
|
1231
|
+
else
|
|
1232
|
+
bad "guide-flip/$label:红文案没有点名缺失的判据 [written for the user]([$(printf '%s' "$text" | tr '\n' '|' | cut -c1-220)])"
|
|
1233
|
+
fi
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
guide_flip_ev() { # <名字> <断言文本(还原后的绿)>:TEAM_REPLY_EVIDENCE 时留证
|
|
1237
|
+
[ -n "$KR_EV" ] || return 0
|
|
1238
|
+
printf '%s\n' "$2" >"$TMP/guide-flip.out"
|
|
1239
|
+
kr_ev_save "$TMP/guide-flip.out" "$1"
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
# ① 模板:删掉持有 `Key conclusions` 锚点的整段 → 红并点名 prompt template
|
|
1243
|
+
mut="$MUTD/pm-prompt.md.tmpl"; cp -f "$TMPL" "$mut"
|
|
1244
|
+
awk 'BEGIN{RS="";ORS="\n\n"} !index($0,"Key conclusions") {print}' "$mut" >"$mut.tmp" && mv "$mut.tmp" "$mut"
|
|
1245
|
+
if grep -qF -- 'Key conclusions' "$mut"; then bad "guide-flip/①:变异没应用上(Key conclusions 段还在)"; fi
|
|
1246
|
+
out="$(guide_check_surface "prompt template" "$mut" 2>&1)"; rc=$?
|
|
1247
|
+
guide_flip_red "①" "prompt template" "$rc" "$out"
|
|
1248
|
+
guide_flip_names_criterion "①" "$out"
|
|
1249
|
+
cp -f "$TMPL" "$mut"
|
|
1250
|
+
out="$(guide_check_surface "prompt template" "$mut" 2>&1)"; rc=$?
|
|
1251
|
+
if [ "$rc" = "0" ]; then ok "guide-flip/①:还原(重新从真树复制)后绿"; else bad "guide-flip/①:还原后仍红([$(printf '%s' "$out" | tr '\n' '|' | cut -c1-200)])"; fi
|
|
1252
|
+
guide_flip_ev "guide-flip-1-restore-green.txt" "$out"
|
|
1253
|
+
|
|
1254
|
+
# ② 协议:删掉 §4b 的常设义务段 → 红并点名 protocol reference
|
|
1255
|
+
mut="$MUTD/protocol.md"; cp -f "$PROTO" "$mut"
|
|
1256
|
+
awk 'BEGIN{RS="";ORS="\n\n"} !index($0,"standing duty of the PM") {print}' "$mut" >"$mut.tmp" && mv "$mut.tmp" "$mut"
|
|
1257
|
+
if grep -qF -- 'standing duty of the PM' "$mut"; then bad "guide-flip/②:变异没应用上(常设义务段还在)"; fi
|
|
1258
|
+
out="$(guide_check_surface "protocol reference" "$mut" 2>&1)"; rc=$?
|
|
1259
|
+
guide_flip_red "②" "protocol reference" "$rc" "$out"
|
|
1260
|
+
guide_flip_names_criterion "②" "$out"
|
|
1261
|
+
cp -f "$PROTO" "$mut"
|
|
1262
|
+
out="$(guide_check_surface "protocol reference" "$mut" 2>&1)"; rc=$?
|
|
1263
|
+
if [ "$rc" = "0" ]; then ok "guide-flip/②:还原(重新从真树复制)后绿"; else bad "guide-flip/②:还原后仍红([$(printf '%s' "$out" | tr '\n' '|' | cut -c1-200)])"; fi
|
|
1264
|
+
guide_flip_ev "guide-flip-2-restore-green.txt" "$out"
|
|
1265
|
+
|
|
1266
|
+
# ③ SKILL:把 `| Key replies |` 行换成不含锚点的行 → 红并点名 command table
|
|
1267
|
+
mut="$MUTD/SKILL.md"; cp -f "$SKILLMD" "$mut"
|
|
1268
|
+
awk 'index($0, "| Key replies |") == 1 && !done { print "| Key replies | See `references/protocol.md` §4b. |"; done=1; next } { print }' "$mut" >"$mut.tmp" && mv "$mut.tmp" "$mut"
|
|
1269
|
+
if grep -qF -- 'The outlet for key conclusions' "$mut"; then bad "guide-flip/③:变异没应用上(旧行还在)"; fi
|
|
1270
|
+
out="$(guide_check_surface "command table" "$mut" 2>&1)"; rc=$?
|
|
1271
|
+
guide_flip_red "③" "command table" "$rc" "$out"
|
|
1272
|
+
guide_flip_names_criterion "③" "$out"
|
|
1273
|
+
cp -f "$SKILLMD" "$mut"
|
|
1274
|
+
out="$(guide_check_surface "command table" "$mut" 2>&1)"; rc=$?
|
|
1275
|
+
if [ "$rc" = "0" ]; then ok "guide-flip/③:还原(重新从真树复制)后绿"; else bad "guide-flip/③:还原后仍红([$(printf '%s' "$out" | tr '\n' '|' | cut -c1-200)])"; fi
|
|
1276
|
+
guide_flip_ev "guide-flip-3-restore-green.txt" "$out"
|
|
1277
|
+
|
|
1278
|
+
# ④ 模板:示例行的 `--stdin` 改成 `--stdinX` → 真解析器拒绝 → 红并点名 example command
|
|
1279
|
+
mut="$MUTD/pm-prompt.md.tmpl"; cp -f "$TMPL" "$mut"
|
|
1280
|
+
perl -pi -e 's/--stdin\b/--stdinX/ if /team reply post/' "$mut"
|
|
1281
|
+
if ! grep -qF -- '--stdinX' "$mut"; then bad "guide-flip/④:变异没应用上(示例行没有 --stdinX)"; fi
|
|
1282
|
+
out="$(guide_check_example "$mut" "$pex" 2>&1)"; rc=$?
|
|
1283
|
+
guide_flip_red "④" "example command" "$rc" "$out"
|
|
1284
|
+
cp -f "$TMPL" "$mut"
|
|
1285
|
+
out="$(guide_check_example "$mut" "$pex" 2>&1)"; rc=$?
|
|
1286
|
+
if [ "$rc" = "0" ]; then ok "guide-flip/④:还原(重新从真树复制)后绿"; else bad "guide-flip/④:还原后仍红([$(printf '%s' "$out" | tr '\n' '|' | cut -c1-200)])"; fi
|
|
1287
|
+
guide_flip_ev "guide-flip-4-restore-green.txt" "$out"
|
|
1288
|
+
|
|
1289
|
+
# ⑤ 模板:只把判据 token 换成另一种说法(句子仍通顺)→ 红并点名 prompt template 与缺失的判据
|
|
1290
|
+
mut="$MUTD/pm-prompt.md.tmpl"; cp -f "$TMPL" "$mut"
|
|
1291
|
+
perl -pi -e 's/written for the user/written for a person/g' "$mut"
|
|
1292
|
+
if grep -qiF -- 'written for the user' "$mut"; then bad "guide-flip/⑤:变异没应用上(判据 token 还在)"; fi
|
|
1293
|
+
out="$(guide_check_surface "prompt template" "$mut" 2>&1)"; rc=$?
|
|
1294
|
+
guide_flip_red "⑤" "prompt template" "$rc" "$out"
|
|
1295
|
+
guide_flip_names_criterion "⑤" "$out"
|
|
1296
|
+
cp -f "$TMPL" "$mut"
|
|
1297
|
+
out="$(guide_check_surface "prompt template" "$mut" 2>&1)"; rc=$?
|
|
1298
|
+
if [ "$rc" = "0" ]; then ok "guide-flip/⑤:还原(重新从真树复制)后绿"; else bad "guide-flip/⑤:还原后仍红([$(printf '%s' "$out" | tr '\n' '|' | cut -c1-200)])"; fi
|
|
1299
|
+
guide_flip_ev "guide-flip-5-restore-green.txt" "$out"
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1049
1302
|
# ---------------------------------------------------------------- 驱动
|
|
1050
1303
|
if [ -n "$KR_EV" ]; then mkdir -p "$KR_EV" 2>/dev/null || true; kr_ev_note "run start $(date -u +%Y-%m-%dT%H:%M:%SZ)"; fi
|
|
1051
1304
|
if ! kr_io_supported; then
|
|
@@ -40,6 +40,7 @@ set -uo pipefail
|
|
|
40
40
|
|
|
41
41
|
BAN_SELF="${BASH_SOURCE[0]}"
|
|
42
42
|
BAN_DIR="$(cd -P "$(dirname "$BAN_SELF")" && pwd)"
|
|
43
|
+
BAN_SKILL_DIR="$(cd -P "$BAN_DIR/.." && pwd)" # skill 根(影子副本要指回真库,见 tmp-root.sh 的 TEAM_TMP_SKILL_DIR)
|
|
43
44
|
BAN_REPO_ROOT="$(cd -P "$BAN_DIR/../../.." && pwd)" # tests/ → teamsmith/ → skills/ → 仓库根
|
|
44
45
|
BAN_DOCS_REL="docs/team"
|
|
45
46
|
BAN_NAMES_REL=".pi/team/forbidden-names.txt"
|
|
@@ -328,7 +329,7 @@ ban_run() { # <root> <published|all> <名单源文件|-> <用户名|->
|
|
|
328
329
|
|
|
329
330
|
# ── 自检:五形状 + 不误伤 + 混合/超量/截断 + 可证伪(含遮蔽影子)──────────────────────────
|
|
330
331
|
ban_selftest() {
|
|
331
|
-
local base="$
|
|
332
|
+
local base="$(team_tmp_root)/.teamsmith-ledger-ban-selftest.$$"
|
|
332
333
|
local okn=0 badn=0 case_rc=0 out="" rc=0
|
|
333
334
|
rm -rf "$base"
|
|
334
335
|
mkdir -p "$base" || { ban_note "自检:建不出 $base"; return 1; }
|
|
@@ -425,7 +426,7 @@ EOF
|
|
|
425
426
|
awk -v pat="$ban_ct" '{ if (index($0, pat) > 0) print ": # 影子:永远不记命中"; else print }' \
|
|
426
427
|
"$sh/ledger-ban.sh" >"$sh/ledger-ban.new" && mv "$sh/ledger-ban.new" "$sh/ledger-ban.sh"
|
|
427
428
|
if [ "$(grep -cF "$ban_ct" "$sh/ledger-ban.sh")" = "0" ]; then
|
|
428
|
-
out="$(LEDGER_BAN_SHADOW_CHILD=1 bash "$sh/ledger-ban.sh" --self-test 2>&1)"; rc=$?
|
|
429
|
+
out="$(LEDGER_BAN_SHADOW_CHILD=1 TEAM_TMP_SKILL_DIR="$BAN_SKILL_DIR" bash "$sh/ledger-ban.sh" --self-test 2>&1)"; rc=$?
|
|
429
430
|
if [ "$rc" = "1" ] && ban_case_has "✗ ①" && ban_case_has "✗ ②"; then
|
|
430
431
|
ban_case_ok "④" "影子:把扫描改成永远通过 → ①②红(自检有牙)"
|
|
431
432
|
else
|
|
@@ -556,7 +557,7 @@ EOF
|
|
|
556
557
|
awk -v pat="$ban_mk" '{ if (index($0, pat) > 0) sub(/i <= n_spans/, "i <= 0"); print }' \
|
|
557
558
|
"$sh2/ledger-ban.sh" >"$sh2/ledger-ban.new" && mv "$sh2/ledger-ban.new" "$sh2/ledger-ban.sh"
|
|
558
559
|
if [ "$(grep -cF "$ban_mk" "$sh2/ledger-ban.sh")" = "0" ]; then
|
|
559
|
-
out="$(LEDGER_BAN_SHADOW_CHILD=1 bash "$sh2/ledger-ban.sh" --self-test 2>&1)"; rc=$?
|
|
560
|
+
out="$(LEDGER_BAN_SHADOW_CHILD=1 TEAM_TMP_SKILL_DIR="$BAN_SKILL_DIR" bash "$sh2/ledger-ban.sh" --self-test 2>&1)"; rc=$?
|
|
560
561
|
if [ "$rc" = "1" ] && ban_case_has "✗ ⑦" && ban_case_has "✗ ⑧"; then
|
|
561
562
|
ban_case_ok "④b" "影子(遮蔽关掉):⑦⑧ 的「输出无原文」断言红(断言有牙)"
|
|
562
563
|
else
|
|
@@ -607,6 +608,6 @@ fi
|
|
|
607
608
|
if [ "$BAN_SCOPE" = "published" ] && [ ! -e "$BAN_ROOT/$BAN_DOCS_REL" ]; then
|
|
608
609
|
ban_note "注意:$BAN_DOCS_REL 不存在(产品面检出?)—— 没有账本文本可扫"
|
|
609
610
|
fi
|
|
610
|
-
BAN_TMP="$(tmp_root_create ledger-ban)" || ban_die "建不出临时根(TMPDIR=$
|
|
611
|
+
BAN_TMP="$(tmp_root_create ledger-ban)" || ban_die "建不出临时根(TMPDIR=$(team_tmp_root))"
|
|
611
612
|
ban_run "$BAN_ROOT" "$BAN_SCOPE" "$BAN_NAMES" "$BAN_USER"
|
|
612
613
|
exit $?
|
|
@@ -229,7 +229,8 @@ if [ "$(grep -cF -- "$OLD_PAT" "$OLDFACE/ledger-ban.sh")" = "1" ]; then
|
|
|
229
229
|
awk -v pat="$OLD_PAT" -v rep="$OLD_NEW" '{ i = index($0, pat); if (i > 0) $0 = substr($0, 1, i - 1) rep substr($0, i + length(pat)); print }' \
|
|
230
230
|
"$OLDFACE/ledger-ban.sh" >"$OLDFACE/new" && mv "$OLDFACE/new" "$OLDFACE/ledger-ban.sh"
|
|
231
231
|
if [ "$(grep -cF -- "$OLD_NEW" "$OLDFACE/ledger-ban.sh")" = "1" ]; then
|
|
232
|
-
|
|
232
|
+
# 旧面副本只拷了 ledger-ban.sh + lib/tmp-root.sh → 指回真库(P309:解析器不在,创建者会具名失败)
|
|
233
|
+
OUT="$(TEAM_TMP_SKILL_DIR="$SKILL_DIR" bash "$OLDFACE/ledger-ban.sh" --all --root "$FACE" --names-file "$FACE/.pi/team/forbidden-names.txt" 2>&1)"; RC=$?
|
|
233
234
|
if [ "$RC" = "0" ] && printf '%s\n' "$OUT" | grep -qF 'hits=0' \
|
|
234
235
|
&& ! printf '%s\n' "$OUT" | grep -qF 'planted.tsv'; then
|
|
235
236
|
case_ok "⑥ 假绿对照:账本面退回「只扫 *.md」→ 同一棵树、同一个植入 hits=0(假绿就是这么来的)"
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# bounded-spin.sh — 夹具的后台「看门 / 轮询」进程的**唯一实现**(infra · 实现:P313)
|
|
3
|
+
#
|
|
4
|
+
# 现场(2026-10-18,PM 实测):`/tmp` 显示 100% 满(64 M),`du` 只算出 9 G,`df` 说用了 15 G ——
|
|
5
|
+
# 差额是「**已删除但仍被持有**」的文件:78 个同一形状的进程合计持有 **11.98 GB**,运行 2 天以上:
|
|
6
|
+
#
|
|
7
|
+
# bash -c 'log="$1"; trap "" TERM; while :; do date +%s >> "$log"; sleep 0.2; done' _ <log>
|
|
8
|
+
#
|
|
9
|
+
# 它们的父进程(一次被打断的夹具运行)早已不在、写入的目标(夹具的临时根)早已被删,而循环
|
|
10
|
+
# **忽略 TERM**、**从不检查父进程**、**没有上限** → 任何一次被打断的夹具运行都会永久泄漏一个。
|
|
11
|
+
#
|
|
12
|
+
# 契约(三条,缺一条就是缺陷):
|
|
13
|
+
# ① 响应 TERM:`trap` 记录收到 TERM 然后**退出**;绝不 `trap "" TERM`
|
|
14
|
+
# (只有「忽略 TERM」本身是被测对象时才用 BOUNDED_SPIN_IGNORE_TERM=1,并写清理由);
|
|
15
|
+
# ② 每轮检查父进程:`while kill -0 "$parent"`,父没了就自己退(被打断的运行不留孤儿);
|
|
16
|
+
# ③ 硬上限:最大运行秒数 + 最大写入字节,到点退出并留**一行**说明(到点不是静默消失);
|
|
17
|
+
# 另外:写目标已经不在了(夹具的临时根被清理)也立即退出 ——「往已删除的文件里继续写」
|
|
18
|
+
# 正是上一次泄漏的形状(df 与 du 的差额就是这么来的)。
|
|
19
|
+
#
|
|
20
|
+
# 用法(夹具里):
|
|
21
|
+
# . "$SELF_DIR/lib/bounded-spin.sh"
|
|
22
|
+
# bounded_spin <interval_s> <cap_s> <cap_bytes|-> <log|-> [<parent_pid>] &
|
|
23
|
+
# log = `-` → 只自旋、不写日志(此时 cap_bytes 用 `-`)
|
|
24
|
+
# 父 pid 默认 `$PPID`;**经子 shell / setsid / tmux 间接拉起时**要显式给一个活到最后的
|
|
25
|
+
# supervisor pid(否则父一退它就跟着退,那就成了它自己的缺陷)。
|
|
26
|
+
# BOUNDED_SPIN_TERM="<snippet>" TERM 到达时先跑这段(记录证据),然后退出
|
|
27
|
+
# BOUNDED_SPIN_IGNORE_TERM=1 故意忽略 TERM(只给「忽略 TERM 的被测对象」,仍受 ②③ 约束)
|
|
28
|
+
#
|
|
29
|
+
# 退出行(写进日志尾部 + stderr 各一行):
|
|
30
|
+
# bounded-spin:退出(<原因>)· pid=<pid> · 父=<pid> · 轮=<n> · 用时=<s>s · 已写=<bytes>B
|
|
31
|
+
|
|
32
|
+
BS_LIB=1
|
|
33
|
+
|
|
34
|
+
# 父进程还活着吗?僵尸按「不在」算(它已经不在运行,只是还没被回收)。
|
|
35
|
+
# 没有 /proc 的平台退回 kill -0(拿不到僵尸判定,但边界仍在)。
|
|
36
|
+
_bs_parent_alive() { # <pid>
|
|
37
|
+
local pid="${1:-}" st
|
|
38
|
+
case "$pid" in ''|0|*[!0-9]*) return 1 ;; esac
|
|
39
|
+
if [ ! -d /proc/1 ]; then kill -0 "$pid" 2>/dev/null; return; fi
|
|
40
|
+
[ -r "/proc/$pid/stat" ] || return 1
|
|
41
|
+
st="$(awk '{ sub(/^.*\) /, ""); print $1 }' "/proc/$pid/stat" 2>/dev/null || true)"
|
|
42
|
+
[ "$st" = "Z" ] && return 1
|
|
43
|
+
return 0
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
# 收口:留一行说明再退。局部变量(parent / rounds / t0 / bytes / log)由 bounded_spin 定义,
|
|
47
|
+
# bash 的动态作用域让这里读得到 —— 改这个函数前先确认那几个变量名没被换掉。
|
|
48
|
+
_bs_exit() { # <原因>
|
|
49
|
+
local reason="$1" msg
|
|
50
|
+
msg="$(printf 'bounded-spin:退出(%s)· pid=%s · 父=%s · 轮=%s · 用时=%ss · 已写=%sB' \
|
|
51
|
+
"$reason" "$$" "${parent:-?}" "${rounds:-0}" "$(( SECONDS - ${t0:-$SECONDS} ))" "${bytes:-0}")"
|
|
52
|
+
if [ "${log:--}" != "-" ] && [ -n "${log:-}" ] && [ -e "$log" ]; then
|
|
53
|
+
printf '%s\n' "$msg" >> "$log" 2>/dev/null || true
|
|
54
|
+
fi
|
|
55
|
+
printf '%s\n' "$msg" >&2
|
|
56
|
+
exit 0
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
_bs_on_term() { # TERM = 收工:先跑调用方要的证据片段,再退出(绝不忽略)
|
|
60
|
+
eval "${BOUNDED_SPIN_TERM:-:}" >/dev/null 2>&1 || true
|
|
61
|
+
_bs_exit "收到 TERM"
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
bounded_spin() { # <interval_s> <cap_s> <cap_bytes|-> <log|-> [<parent_pid>]
|
|
65
|
+
local iv="${1:-0.2}" cap_s="${2:-1800}" cap_b="${3:--}" log="${4:--}" parent="${5:-$PPID}"
|
|
66
|
+
local t0="$SECONDS" rounds=0 bytes=0 line
|
|
67
|
+
case "$cap_s" in ''|*[!0-9]*) printf 'bounded-spin:cap_s 必须是正整数(收到 [%s])\n' "$cap_s" >&2; return 2 ;; esac
|
|
68
|
+
[ "$cap_s" -gt 0 ] || { printf 'bounded-spin:cap_s 必须是正整数(收到 [%s])\n' "$cap_s" >&2; return 2; }
|
|
69
|
+
if [ "${BOUNDED_SPIN_IGNORE_TERM:-0}" = "1" ]; then
|
|
70
|
+
trap '' TERM # 只有「忽略 TERM」本身是被测对象时才允许(调用方必须写清理由)
|
|
71
|
+
else
|
|
72
|
+
trap '_bs_on_term' TERM
|
|
73
|
+
fi
|
|
74
|
+
trap '_bs_exit "收到 INT"' INT
|
|
75
|
+
while _bs_parent_alive "$parent"; do
|
|
76
|
+
if [ "$(( SECONDS - t0 ))" -ge "$cap_s" ]; then _bs_exit "到点(最大运行 ${cap_s}s)"; fi
|
|
77
|
+
rounds=$((rounds + 1))
|
|
78
|
+
if [ "$log" != "-" ]; then
|
|
79
|
+
[ -e "$log" ] || _bs_exit "写目标已不在(${log})"
|
|
80
|
+
line="$(date +%s)"
|
|
81
|
+
if [ "$cap_b" != "-" ] && [ "$(( bytes + ${#line} + 1 ))" -gt "$cap_b" ]; then
|
|
82
|
+
_bs_exit "到点(最大写入 ${cap_b}B)"
|
|
83
|
+
fi
|
|
84
|
+
printf '%s\n' "$line" >> "$log" 2>/dev/null || _bs_exit "写不进去(${log})"
|
|
85
|
+
bytes=$(( bytes + ${#line} + 1 ))
|
|
86
|
+
fi
|
|
87
|
+
sleep "$iv"
|
|
88
|
+
done
|
|
89
|
+
_bs_exit "父进程 ${parent} 已不在"
|
|
90
|
+
}
|
|
@@ -17,6 +17,10 @@ for k,v in values.items(): s=s.replace('{{'+k+'}}',v)
|
|
|
17
17
|
# P235: the template carries empty model-policy keys; the fixture fills both.
|
|
18
18
|
s=re.sub(r'^TEAM_TASK_MODELS=.*$', 'TEAM_TASK_MODELS="routine=deepseek/deepseek-flash analysis=xai/grok-4.6 verify=kimi-coding/k3-256k"', s, flags=re.M)
|
|
19
19
|
s=re.sub(r'^TEAM_PM_MODEL=.*$', 'TEAM_PM_MODEL="deepseek/deepseek-flash"', s, flags=re.M)
|
|
20
|
+
# P261: the template's shape number is a render placeholder too; the fixture declares the shape it builds
|
|
21
|
+
# (same style as the two model keys above), otherwise the literal '{{CONFIG_VERSION}}' would read as a
|
|
22
|
+
# non-integer shape marker and the startup transaction would refuse the fixture.
|
|
23
|
+
s=re.sub(r'^TEAM_CONFIG_VERSION=.*$', 'TEAM_CONFIG_VERSION="2"', s, flags=re.M)
|
|
20
24
|
pathlib.Path(out).write_text(s)
|
|
21
25
|
PY
|
|
22
26
|
}
|