teamsmith 0.3.4 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/package.json +1 -1
- package/skills/teamsmith/CHANGELOG.md +30 -0
- package/skills/teamsmith/SKILL.md +83 -163
- package/skills/teamsmith/extension/team-notify.ts +1 -1
- package/skills/teamsmith/extension/team-reply.ts +105 -0
- package/skills/teamsmith/references/agent-adapters.md +1 -1
- package/skills/teamsmith/references/config.md +20 -11
- package/skills/teamsmith/references/migration.md +47 -3
- package/skills/teamsmith/references/protocol.md +64 -31
- package/skills/teamsmith/references/reminders.md +131 -0
- package/skills/teamsmith/references/troubleshooting.md +19 -5
- package/skills/teamsmith/references/workflows.md +18 -16
- package/skills/teamsmith/scripts/lib/cmd-agents.sh +77 -49
- package/skills/teamsmith/scripts/lib/cmd-project.sh +193 -21
- package/skills/teamsmith/scripts/lib/cmd-remind.sh +103 -0
- package/skills/teamsmith/scripts/lib/cmd-update.sh +7 -4
- package/skills/teamsmith/scripts/lib/common.sh +44 -4
- package/skills/teamsmith/scripts/lib/outbox.sh +72 -18
- package/skills/teamsmith/scripts/remind-store.mjs +529 -0
- package/skills/teamsmith/scripts/replies.mjs +9 -3
- package/skills/teamsmith/scripts/reply-capture.mjs +596 -0
- package/skills/teamsmith/scripts/state-authority.mjs +500 -0
- package/skills/teamsmith/scripts/strings/commands.tsv +2 -1
- package/skills/teamsmith/scripts/strings/help.en.tsv +16 -2
- package/skills/teamsmith/scripts/strings/help.zh.tsv +16 -2
- package/skills/teamsmith/scripts/team +1 -0
- package/skills/teamsmith/templates/AGENTS.section.md.tmpl +68 -123
- package/skills/teamsmith/templates/PROTOCOL.md.tmpl +48 -55
- package/skills/teamsmith/templates/pm-prompt.md.tmpl +126 -119
- package/skills/teamsmith/tests/checkout-shape-probe.sh +6 -5
- package/skills/teamsmith/tests/delivery-truth.sh +82 -47
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/README.md +71 -23
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/__pycache__/judge-second.cpython-313.pyc +0 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/judge-dirty-ab.py +143 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/judge-second.py +26 -9
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/run-case.sh +92 -20
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +47 -3
- package/skills/teamsmith/tests/fixtures/reply-capture-provider.ts +76 -0
- package/skills/teamsmith/tests/flip-p410-order2.sh +205 -0
- package/skills/teamsmith/tests/frames/README.md +3 -1
- package/skills/teamsmith/tests/gate-guard.sh +20 -4
- package/skills/teamsmith/tests/help-surface.sh +60 -2
- package/skills/teamsmith/tests/install-shape.sh +312 -0
- package/skills/teamsmith/tests/key-replies-pty.sh +197 -21
- package/skills/teamsmith/tests/key-replies.sh +187 -68
- package/skills/teamsmith/tests/ledger-claim.sh +8 -6
- package/skills/teamsmith/tests/lib/box-judge.sh +2 -1
- package/skills/teamsmith/tests/lib/main-team-fingerprint.sh +104 -0
- package/skills/teamsmith/tests/lib/pm-window.sh +127 -0
- package/skills/teamsmith/tests/lib/reply-fixture.sh +7 -19
- package/skills/teamsmith/tests/lib/reply-guard.sh +188 -0
- package/skills/teamsmith/tests/lib/section-calls.pl +171 -0
- package/skills/teamsmith/tests/loop-inventory.tsv +7 -5
- package/skills/teamsmith/tests/meta-suite.sh +215 -0
- package/skills/teamsmith/tests/panel-b3-pty-mouse.py +154 -17
- package/skills/teamsmith/tests/panel-b3.sh +33 -4
- package/skills/teamsmith/tests/remind-cli.sh +574 -0
- package/skills/teamsmith/tests/reply-capture-real.mjs +360 -0
- package/skills/teamsmith/tests/reply-capture-real.sh +5 -0
- package/skills/teamsmith/tests/reply-capture.mjs +622 -0
- package/skills/teamsmith/tests/section-paths.tsv +40 -9
- package/skills/teamsmith/tests/section-select.sh +180 -26
- package/skills/teamsmith/tests/smoke.sh +1235 -238
- package/skills/teamsmith/tests/state-authority-node.mjs +42 -0
- package/skills/teamsmith/tests/state-authority.sh +629 -0
- package/skills/teamsmith/tests/workflow-entry.sh +123 -3
- package/skills/teamsmith-init/SKILL.md +1 -1
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
# panel panel.outbox.impeded / impediments 在 JSON / 纯文本 / TUI 上只读呈现,观察不改队列
|
|
19
19
|
# judge 判据本体(fixtures/delivery-truth-real/judge-second.py)的单次运行戳(P197):
|
|
20
20
|
# run_start 恰好一条 / 在第一行 / run 与 run.json 一致;run-start.txt 存在/非空/run= 一致。
|
|
21
|
+
# P380:不再钉版本,改为要具体版本号且与现场 pi-version.txt 实测值相等(另拒 observation)。
|
|
21
22
|
# 合成现场(不跑真 Pi、不进容器);--mutations 把「恰好一条」影子回旧的集合相等 → 同 ID 重复必须被吞
|
|
22
23
|
#
|
|
23
24
|
# 输出契约:每条断言一行 `✓` / `✗` / `· finding` / `· skip`;段末 `== <n> <段名> 结果 == ✓ x ✗ y`;
|
|
@@ -234,31 +235,43 @@ fix_frame_text() { # <光标 1-based> <cwd>;stdin = 帧文本
|
|
|
234
235
|
fix_keys() { wc -l < "$FIX/keys.log" | tr -d ' '; }
|
|
235
236
|
fix_clear_keys() { : > "$FIX/keys.log"; }
|
|
236
237
|
fix_q() { fix_team outbox "$@"; }
|
|
238
|
+
# P393:默认 say 不再因为「框里有草稿」排队(无 watcher 时它即时直投)。草稿守卫/几何/终态/回执用例
|
|
239
|
+
# 改用**真正受保护的发送方**:人的 draft send 走同一个守卫 + 同一个排水(durable 副本是草稿文件本身)。
|
|
240
|
+
fix_protected() { # <payload> → 受保护的投递到 p147:dev
|
|
241
|
+
printf '%s\n' "$1" > "$FIX/protected.txt"
|
|
242
|
+
fix_team draft send "$FIX/protected.txt" --target p147:dev
|
|
243
|
+
}
|
|
244
|
+
# 队列或 held/ 里是否有含全文的条目(不需要 durable 收件箱行)
|
|
245
|
+
fix_any_entry_has() { # <payload>
|
|
246
|
+
local q
|
|
247
|
+
for q in "$FIX/proj/.pi/team/state/outbox/"*.msg "$FIX/proj/.pi/team/state/outbox/held/"*.msg; do
|
|
248
|
+
[ -f "$q" ] || continue
|
|
249
|
+
grep -q -- "$1" "$q" && return 0
|
|
250
|
+
done
|
|
251
|
+
return 1
|
|
252
|
+
}
|
|
237
253
|
# 夹具 state 里的一个文件的 sha256(不存在 → 空)
|
|
238
254
|
fix_sha() { [ -f "$1" ] && sha256sum "$1" | cut -d' ' -f1 || printf 'missing'; }
|
|
239
255
|
|
|
240
256
|
# 变异副本(红侧专用):只拷 team CLI 真正需要的最小集(team + lib + shim,约 1 MB),
|
|
241
257
|
# 再把 cmd-agents.sh 的 queued 分支两行报告删掉 = 「见到框里有东西就静默排队、不报告」的形状。
|
|
242
258
|
# 生产文件绝不被改写:新内容写进 .new 再 mv 覆盖(避免任何原地写回)。
|
|
243
|
-
|
|
244
|
-
|
|
259
|
+
mut_skill_silent_protected() { # → stdout: 变异 SKILL_DIR;锚点漂了 → 非 0(绝不静默返回一个假副本)
|
|
260
|
+
# P393:受保护发送方的「可见报告」现在由 cmd-draft.sh 的 queued 分支负责(默认 say 已不排队)。
|
|
261
|
+
local mut="$TMP/mut-silent-protected" new
|
|
245
262
|
rm -rf "$mut"; mkdir -p "$mut/scripts"
|
|
246
263
|
cp -a "$SKILL_DIR/scripts/team" "$SKILL_DIR/scripts/lib" "$SKILL_DIR/scripts/shim" "$mut/scripts/" || return 1
|
|
247
|
-
new="$mut/scripts/lib/cmd-
|
|
248
|
-
python3 - "$SKILL_DIR/scripts/lib/cmd-
|
|
264
|
+
new="$mut/scripts/lib/cmd-draft.sh.new"
|
|
265
|
+
python3 - "$SKILL_DIR/scripts/lib/cmd-draft.sh" "$new" <<'PY' || return 1
|
|
249
266
|
import pathlib, sys
|
|
250
|
-
old = ''' queued)
|
|
251
|
-
# 契约:排队 ≠ 送达 —— 输出里只许有 queued,绝不能写「已确认送达」
|
|
252
|
-
team_ok "queued for $target: $msg(目标输入框里有草稿:没有写任何键;条目已入 state/outbox/,清空后自动投递)"
|
|
253
|
-
team_dim " 原因/条目:$TEAM_CLI outbox list | 投递未确认的兜底:消息已在 $TEAM_DOCS_DIR/inbox/$agent.md"
|
|
254
|
-
return 0 ;;'''
|
|
267
|
+
old = ''' queued) team_ok "queued for $target(输入框有草稿或目标没在跑;条目已入 state/outbox/,清空后自动投递)" ;;'''
|
|
255
268
|
src = pathlib.Path(sys.argv[1]).read_text()
|
|
256
269
|
if old not in src:
|
|
257
|
-
sys.stderr.write('mutation anchor missing in cmd-
|
|
270
|
+
sys.stderr.write('mutation anchor missing in cmd-draft.sh(受保护发送方的 queued 报告改了?)\n')
|
|
258
271
|
sys.exit(1)
|
|
259
|
-
pathlib.Path(sys.argv[2]).write_text(src.replace(old, ' queued)
|
|
272
|
+
pathlib.Path(sys.argv[2]).write_text(src.replace(old, ' queued) : ;;', 1))
|
|
260
273
|
PY
|
|
261
|
-
mv -f "$new" "$mut/scripts/lib/cmd-
|
|
274
|
+
mv -f "$new" "$mut/scripts/lib/cmd-draft.sh" || return 1
|
|
262
275
|
printf '%s\n' "$mut"
|
|
263
276
|
}
|
|
264
277
|
|
|
@@ -428,7 +441,7 @@ section_drafts() {
|
|
|
428
441
|
local label="$1" want="$2" file="$3" cy="$4"
|
|
429
442
|
fix_frame "$file" "$cy" "$cwd"
|
|
430
443
|
fix_clear_keys
|
|
431
|
-
out="$(
|
|
444
|
+
out="$(fix_protected "P147-$label" 2>&1)"; rc=$?
|
|
432
445
|
keys="$(fix_keys)"
|
|
433
446
|
case "$want" in
|
|
434
447
|
queued)
|
|
@@ -516,30 +529,29 @@ section_foreign() {
|
|
|
516
529
|
[ "$verdict" = "idle-read=NOT-EMPTY" ] && ok "1.0.0 真帧:判定 BUSY(异物绝不被当空框放行)" \
|
|
517
530
|
|| bad "1.0.0 真帧:判定 =[$verdict],期望 idle-read=NOT-EMPTY"
|
|
518
531
|
|
|
519
|
-
#
|
|
532
|
+
# 真进程:同一份帧跑受保护的 draft send(假 tmux pane = 真进程读同一份字节)
|
|
520
533
|
fix_setup x1
|
|
521
534
|
fix_frame "$f" "$cy" "$cwd"
|
|
522
535
|
fix_clear_keys
|
|
523
536
|
frame_sha_before="$(sha256sum "$FIX/frame" | cut -d' ' -f1)"
|
|
524
|
-
out="$(
|
|
537
|
+
out="$(fix_protected "P163-FOREIGN-1.0.0" 2>&1)"; rc=$?
|
|
525
538
|
frame_sha_after="$(sha256sum "$FIX/frame" | cut -d' ' -f1)"
|
|
526
|
-
# 「可见报告」= 状态 +
|
|
539
|
+
# 「可见报告」= 状态 + 条目落地(受保护发送方 = draft send:durable 副本是草稿文件本身,
|
|
540
|
+
# 所以这里的承重判据是 queued + 条目已入 state/outbox/)
|
|
527
541
|
fix_report_visible() { # <out> → 0 = 可见报告完整
|
|
528
542
|
local o="$1"
|
|
529
543
|
printf '%s' "$o" | grep -q 'queued' \
|
|
530
|
-
&& printf '%s' "$o" | grep -q '
|
|
531
|
-
&& printf '%s' "$o" | grep -q 'outbox list' \
|
|
532
|
-
&& printf '%s' "$o" | grep -q 'inbox/dev.md'
|
|
544
|
+
&& printf '%s' "$o" | grep -q 'state/outbox/'
|
|
533
545
|
}
|
|
534
546
|
if [ "$rc" -eq 0 ] && [ "$(fix_keys)" = "0" ]; then
|
|
535
|
-
ok "1.0.0
|
|
547
|
+
ok "1.0.0 真帧:受保护的发送方一个键都不发(异物绝不打字进去)"
|
|
536
548
|
else
|
|
537
549
|
bad "1.0.0 真帧:rc=$rc keys=$(fix_keys)(期望 rc=0 且零按键)"
|
|
538
550
|
fi
|
|
539
|
-
[ "$frame_sha_before" = "$frame_sha_after" ] && ok "1.0.0
|
|
540
|
-
|| bad "1.0.0
|
|
551
|
+
[ "$frame_sha_before" = "$frame_sha_after" ] && ok "1.0.0 真帧:受保护发送之后输入框字节不变" \
|
|
552
|
+
|| bad "1.0.0 真帧:受保护发送改动了输入框(sha 变了)"
|
|
541
553
|
if fix_report_visible "$out"; then
|
|
542
|
-
ok "1.0.0 真帧:可见报告 = queued +
|
|
554
|
+
ok "1.0.0 真帧:可见报告 = queued + 条目已入 state/outbox/"
|
|
543
555
|
else
|
|
544
556
|
bad "1.0.0 真帧:可见报告不完整:$(printf '%s' "$out" | tr '\n' ' ' | head -c 240)"
|
|
545
557
|
fi
|
|
@@ -557,10 +569,10 @@ section_foreign() {
|
|
|
557
569
|
done
|
|
558
570
|
return 1
|
|
559
571
|
}
|
|
560
|
-
if fix_queue_has 'P163-FOREIGN-1.0.0' && grep -q 'P163-FOREIGN-1.0.0' "$FIX/
|
|
561
|
-
ok "1.0.0 真帧:消息不丢(活动队列条目 +
|
|
572
|
+
if fix_queue_has 'P163-FOREIGN-1.0.0' && grep -q 'P163-FOREIGN-1.0.0' "$FIX/protected.txt" 2>/dev/null; then
|
|
573
|
+
ok "1.0.0 真帧:消息不丢(活动队列条目 + 草稿文件都有全文)"
|
|
562
574
|
else
|
|
563
|
-
bad "1.0.0
|
|
575
|
+
bad "1.0.0 真帧:消息不在队列/草稿文件里(可能被静默吞掉)"
|
|
564
576
|
fi
|
|
565
577
|
|
|
566
578
|
# 同一份帧、光标落在上边框(TMUX cursor_y 是 0-based —— off-by-one 误读的真实形状)→ 几何不可信:
|
|
@@ -568,29 +580,29 @@ section_foreign() {
|
|
|
568
580
|
fix_setup x2
|
|
569
581
|
fix_frame "$f" 28 "$cwd"
|
|
570
582
|
fix_clear_keys
|
|
571
|
-
out="$(
|
|
583
|
+
out="$(fix_protected "P163-FOREIGN-OFFBYONE" 2>&1)"; rc=$?
|
|
572
584
|
if [ "$rc" -ne 0 ] && printf '%s' "$out" | grep -q 'held' && printf '%s' "$out" | grep -q 'geometry-untrusted' \
|
|
573
|
-
&& printf '%s' "$out" | grep -q 'outbox flush'
|
|
585
|
+
&& printf '%s' "$out" | grep -q 'outbox flush' \
|
|
574
586
|
&& ! printf '%s' "$out" | grep -q '清空后自动投递'; then
|
|
575
587
|
ok "同帧 off-by-one(光标在上边框):held/geometry-untrusted + 原因/恢复命令,且不承诺自动投递"
|
|
576
588
|
else
|
|
577
589
|
bad "同帧 off-by-one:rc=$rc out=$(printf '%s' "$out" | tr '\n' ' ' | head -c 240)"
|
|
578
590
|
fi
|
|
579
591
|
[ "$(fix_keys)" = "0" ] && ok "同帧 off-by-one:零按键" || bad "同帧 off-by-one 发了 $(fix_keys) 个键"
|
|
580
|
-
|
|
581
|
-
&& ok "同帧 off-by-one:held 也不丢(
|
|
592
|
+
fix_any_entry_has 'P163-FOREIGN-OFFBYONE' \
|
|
593
|
+
&& ok "同帧 off-by-one:held 也不丢(held/ 条目里有全文)" || bad "同帧 off-by-one:消息没落账本"
|
|
582
594
|
|
|
583
595
|
# 红侧:变异副本只删 queued 分支的两行报告(静默排队)→「可见报告」必须红;安全断言保持绿
|
|
584
596
|
if [ "$MUTATIONS" = "1" ]; then
|
|
585
597
|
local mut sha_before sha_after
|
|
586
|
-
mut="$(
|
|
598
|
+
mut="$(mut_skill_silent_protected)" || { bad "红侧:变异副本没造出来(锚点漂了?)"; mut=""; }
|
|
587
599
|
if [ -n "$mut" ]; then
|
|
588
|
-
sha_before="$(fix_sha "$SKILL_DIR/scripts/lib/cmd-
|
|
600
|
+
sha_before="$(fix_sha "$SKILL_DIR/scripts/lib/cmd-draft.sh")"
|
|
589
601
|
fix_setup x3
|
|
590
602
|
fix_frame "$f" "$cy" "$cwd"
|
|
591
603
|
fix_clear_keys
|
|
592
|
-
FIX_SKILL="$mut"; out="$(
|
|
593
|
-
sha_after="$(fix_sha "$SKILL_DIR/scripts/lib/cmd-
|
|
604
|
+
FIX_SKILL="$mut"; out="$(fix_protected "P163-FOREIGN-MUT" 2>&1)"; rc=$?; FIX_SKILL=""
|
|
605
|
+
sha_after="$(fix_sha "$SKILL_DIR/scripts/lib/cmd-draft.sh")"
|
|
594
606
|
if fix_report_visible "$out"; then
|
|
595
607
|
bad "红侧(静默排队):变异后「可见报告」仍成立 —— 判据没咬住那个决策点"
|
|
596
608
|
else
|
|
@@ -602,8 +614,8 @@ section_foreign() {
|
|
|
602
614
|
fix_queue_has 'P163-FOREIGN-MUT' \
|
|
603
615
|
&& ok "红侧对照:静默变异下消息仍在队列(红的是报告,不是丢失)" \
|
|
604
616
|
|| bad "红侧对照:静默变异下消息没进队列"
|
|
605
|
-
[ "$sha_before" = "$sha_after" ] && ok "红侧:变异只动副本,生产 cmd-
|
|
606
|
-
|| bad "红侧:生产 cmd-
|
|
617
|
+
[ "$sha_before" = "$sha_after" ] && ok "红侧:变异只动副本,生产 cmd-draft.sh 的 sha 不变" \
|
|
618
|
+
|| bad "红侧:生产 cmd-draft.sh 被变异污染"
|
|
607
619
|
fi
|
|
608
620
|
else
|
|
609
621
|
skipnote "红侧 mutation(--mutations 才跑)"
|
|
@@ -770,9 +782,9 @@ section_queue() {
|
|
|
770
782
|
{ printf '%s\n' "$RULE120"; printf '\n\n'; printf '%s\n' "$RULE120"; printf '%s\n' "$RULE120"; printf '%s\n' "$RULE120"; printf '%s\n' "$FOOT1"; printf '%s\n' "$FOOT2"; } > "$FIX/frame-u"
|
|
771
783
|
fix_frame "$FIX/frame-u" 5 "$REAL_CWD_EMPTY"
|
|
772
784
|
printf '1\n' > "$FIX/sendkeys_rc"
|
|
773
|
-
out="$(
|
|
785
|
+
out="$(fix_protected "P147-Q9-UNTRUSTED" 2>&1)"; rc=$?
|
|
774
786
|
[ "$rc" -ne 0 ] && printf '%s' "$out" | grep -q 'held' && printf '%s' "$out" | grep -q 'geometry-untrusted' \
|
|
775
|
-
&& ok "恢复夹具:untrusted
|
|
787
|
+
&& ok "恢复夹具:untrusted 的受保护发送非零退出 + held/geometry-untrusted" || bad "恢复夹具:untrusted 受保护发送 rc=$rc"
|
|
776
788
|
# 再造一个 queue-stalled hold
|
|
777
789
|
fix_setup q9b
|
|
778
790
|
fix_frame "$FRAMES/pi-0.99.2-empty-editor.txt" 29 "$REAL_CWD_EMPTY"
|
|
@@ -817,24 +829,24 @@ section_receipts() {
|
|
|
817
829
|
{ printf '%s\n' "$RULE120"; printf '\n\n'; printf '%s\n' "$RULE120"; printf '%s\n' "$RULE120"; printf '%s\n' "$RULE120"; printf '%s\n' "$FOOT1"; printf '%s\n' "$FOOT2"; } > "$FIX/frame"
|
|
818
830
|
fix_frame "$FIX/frame" 5 "$REAL_CWD_EMPTY"
|
|
819
831
|
fix_clear_keys
|
|
820
|
-
out="$(
|
|
832
|
+
out="$(fix_protected "P147-R1-UNTRUSTED" 2>&1)"; rc=$?
|
|
821
833
|
if [ "$rc" -ne 0 ] && printf '%s' "$out" | grep -q 'held' && printf '%s' "$out" | grep -q 'geometry-untrusted' \
|
|
822
|
-
&& printf '%s' "$out" | grep -q 'outbox flush'
|
|
834
|
+
&& printf '%s' "$out" | grep -q 'outbox flush' \
|
|
823
835
|
&& ! printf '%s' "$out" | grep -q '清空后自动投递'; then
|
|
824
836
|
ok "untrusted:非零退出 + held/geometry-untrusted + 恢复命令 + 点名 durable 全文,且不承诺清空后自动投递"
|
|
825
837
|
else
|
|
826
838
|
bad "untrusted receipt:rc=$rc out=$(printf '%s' "$out" | tr '\n' ' ' | head -c 240)"
|
|
827
839
|
fi
|
|
828
840
|
[ "$(fix_keys)" = "0" ] && ok "untrusted:零按键" || bad "untrusted 发了键"
|
|
829
|
-
|
|
830
|
-
&& ok "untrusted:durable
|
|
841
|
+
fix_any_entry_has 'P147-R1-UNTRUSTED' \
|
|
842
|
+
&& ok "untrusted:held/ 条目里有全文(受保护发送的 durable 副本)" || bad "untrusted 没有 durable 条目"
|
|
831
843
|
|
|
832
844
|
# 1b) 真帧 + 失效的页脚前提(target cwd 与页脚不符)→ 同一份真帧必须走 untrusted,
|
|
833
845
|
# 而不是退回旧域的保守读(那会给出一条永不兑现的「清空后自动投递」承诺)
|
|
834
846
|
fix_setup r1b
|
|
835
847
|
fix_frame "$FRAMES/pi-0.99.2-empty-editor.txt" 29 "/tmp/not-the-target-cwd"
|
|
836
848
|
fix_clear_keys
|
|
837
|
-
out="$(
|
|
849
|
+
out="$(fix_protected "P147-R1B-REALFRAME" 2>&1)"; rc=$?
|
|
838
850
|
if [ "$rc" -ne 0 ] && printf '%s' "$out" | grep -q 'held' && printf '%s' "$out" | grep -q 'geometry-untrusted' \
|
|
839
851
|
&& ! printf '%s' "$out" | grep -q '清空后自动投递'; then
|
|
840
852
|
ok "真帧 + 页脚 cwd 不符:held/geometry-untrusted、非零退出、不承诺自动投递"
|
|
@@ -847,7 +859,7 @@ section_receipts() {
|
|
|
847
859
|
fix_setup r2
|
|
848
860
|
fix_frame "$FRAMES/pi-0.99.2-human-draft.txt" 29 "$REAL_CWD_DRAFT"
|
|
849
861
|
fix_clear_keys
|
|
850
|
-
out="$(
|
|
862
|
+
out="$(fix_protected "P147-R2-DRAFT" 2>&1)"; rc=$?
|
|
851
863
|
if [ "$rc" -eq 0 ] && printf '%s' "$out" | grep -q 'queued' && ! printf '%s' "$out" | grep -q '已确认送达'; then
|
|
852
864
|
ok "可信草稿:queued、exit 0、不出现「已确认送达」"
|
|
853
865
|
else
|
|
@@ -860,7 +872,7 @@ section_receipts() {
|
|
|
860
872
|
fix_frame "$FRAMES/pi-0.99.2-empty-editor.txt" 29 "$REAL_CWD_EMPTY"
|
|
861
873
|
printf '0\n' > "$FIX/sendkeys_rc"
|
|
862
874
|
fix_clear_keys
|
|
863
|
-
out="$(
|
|
875
|
+
out="$(fix_protected "P147-R3-CLEAN" 2>&1)"; rc=$?
|
|
864
876
|
if [ "$rc" -eq 0 ] && printf '%s' "$out" | grep -q '已确认送达'; then
|
|
865
877
|
ok "干净空框:报已确认送达、exit 0"
|
|
866
878
|
else
|
|
@@ -1085,6 +1097,10 @@ JSON
|
|
|
1085
1097
|
# 不进容器、不碰 tmux):run_start 标记必须恰好一条 / 在第一行 / run 与 run.json.run_id 一致;
|
|
1086
1098
|
# run-start.txt 必须存在、非空、run= 与本次 run id 一致。--mutations 把「恰好一条」影子回旧的
|
|
1087
1099
|
# 集合相等(sorted({…}))→ 同 ID 的重复标记必须被吞成一条(红),证明条数检查是承重的。
|
|
1100
|
+
#
|
|
1101
|
+
# P380(版本):判据不再钉死 0.99.2,改为「run.json.pi_version 必须是具体版本号、且等于现场
|
|
1102
|
+
# pi-version.txt 的实测值」。下面用 0.99.2 的合成现场作为**历史版本仍可判**的正向对照,另加
|
|
1103
|
+
# 四条红侧:版本写成 latest / 现场实测值与记录不符 / mode=observation / 请求版本与记录不符。
|
|
1088
1104
|
judge_scene() { # <evidence-dir> <case> <run-id>
|
|
1089
1105
|
mkdir -p "$1/logs/$2"
|
|
1090
1106
|
P197_CASE="$2" P197_RID="$3" python3 - "$1/logs/$2" <<'PY'
|
|
@@ -1096,7 +1112,7 @@ mark = {'event': 'run_start', 'run': rid, 'ts': now}
|
|
|
1096
1112
|
marker = 'P138-SECOND-' + case
|
|
1097
1113
|
(L / 'run.json').write_text(json.dumps({
|
|
1098
1114
|
'case': case, 'run_id': rid, 'rev': 'HEAD', 'rev_full': '0' * 40,
|
|
1099
|
-
'pi_version': '0.99.2', 'mode': 'verdict', 'started_at': now}, indent=1, sort_keys=True) + '\n')
|
|
1115
|
+
'pi_version': '0.99.2', 'runtime_requested': '0.99.2', 'mode': 'verdict', 'started_at': now}, indent=1, sort_keys=True) + '\n')
|
|
1100
1116
|
(L / 'pi-version.txt').write_text('0.99.2\n')
|
|
1101
1117
|
(L / 'run-start.txt').write_text(f'P163 case={case} run={rid} mode=verdict runtime=0.99.2\n')
|
|
1102
1118
|
(L / 'dev-events.jsonl').write_text('\n'.join(json.dumps(x) for x in [
|
|
@@ -1142,13 +1158,27 @@ elif kind == 'empty-stamp':
|
|
|
1142
1158
|
(L / 'run-start.txt').write_text('\n')
|
|
1143
1159
|
elif kind == 'wrong-stamp':
|
|
1144
1160
|
(L / 'run-start.txt').write_text('P163 case=x run=ffffffffffff mode=verdict runtime=0.99.2\n')
|
|
1161
|
+
elif kind == 'nonconcrete-version':
|
|
1162
|
+
run = json.loads((L / 'run.json').read_text())
|
|
1163
|
+
run['pi_version'] = 'latest'
|
|
1164
|
+
(L / 'run.json').write_text(json.dumps(run, indent=1, sort_keys=True) + '\n')
|
|
1165
|
+
elif kind == 'observed-mismatch':
|
|
1166
|
+
(L / 'pi-version.txt').write_text('9.9.9\n')
|
|
1167
|
+
elif kind == 'observation':
|
|
1168
|
+
run = json.loads((L / 'run.json').read_text())
|
|
1169
|
+
run['mode'] = 'observation'
|
|
1170
|
+
(L / 'run.json').write_text(json.dumps(run, indent=1, sort_keys=True) + '\n')
|
|
1171
|
+
elif kind == 'requested-mismatch':
|
|
1172
|
+
run = json.loads((L / 'run.json').read_text())
|
|
1173
|
+
run['runtime_requested'] = '0.99.1'
|
|
1174
|
+
(L / 'run.json').write_text(json.dumps(run, indent=1, sort_keys=True) + '\n')
|
|
1145
1175
|
else:
|
|
1146
1176
|
raise SystemExit(f'unknown mutation {kind}')
|
|
1147
1177
|
PY
|
|
1148
1178
|
}
|
|
1149
1179
|
|
|
1150
1180
|
section_judge() {
|
|
1151
|
-
begin "judge
|
|
1181
|
+
begin "judge(单次运行戳 + P380 版本记录/实测一致;红侧标记 5 + 戳 3 + 版本/观测 4 + 影子)"
|
|
1152
1182
|
local J="$SKILL_DIR/tests/fixtures/delivery-truth-real/judge-second.py"
|
|
1153
1183
|
local CASE="tmux-p163-p197-synth" RID="aabbccddeeff" E="$TMP/judge-evidence" M="$TMP/judge-mutations"
|
|
1154
1184
|
local rc rc2 out out2 before after miss want
|
|
@@ -1196,6 +1226,11 @@ section_judge() {
|
|
|
1196
1226
|
judge_red "缺 run-start.txt" no-stamp '缺 run-start.txt'
|
|
1197
1227
|
judge_red "run-start.txt 为空" empty-stamp '是空的'
|
|
1198
1228
|
judge_red "run-start.txt 的 run 不是本次" wrong-stamp '不是本次运行的戳' "'ffffffffffff'"
|
|
1229
|
+
# P380:判据不钉版本,但拒绝别名、观测模式、记录与实测不符、请求与记录不符。
|
|
1230
|
+
judge_red "版本写成 latest" nonconcrete-version '不是具体版本号'
|
|
1231
|
+
judge_red "现场实测版本与记录不符" observed-mismatch 'pi-version.txt' "'9.9.9'" "'0.99.2'"
|
|
1232
|
+
judge_red "observation 现场" observation '人工观察'
|
|
1233
|
+
judge_red "请求版本与记录不符" requested-mismatch 'runtime_requested=0.99.1' '!= pi_version=0.99.2'
|
|
1199
1234
|
|
|
1200
1235
|
# ③ 影子:把「恰好一条」改回集合相等 → 同 ID 重复被吞(PASS);真判据在同一现场拒绝
|
|
1201
1236
|
if [ "$MUTATIONS" = "1" ]; then
|
|
@@ -7,35 +7,34 @@
|
|
|
7
7
|
| 文件 | 来源(sha256 为提升时源文件) | 说明 |
|
|
8
8
|
|---|---|---|
|
|
9
9
|
| `scenario.sh` | `docs/team/reports/P157-verify/pkg/scenario.sh` `3fa9d3d6…` | 改:读 `run.json` 运行戳 + 在判据读的事件文件第一行写单次 `run_start` 标记 |
|
|
10
|
-
| `run-case.sh` | `docs/team/reports/P157-verify/pkg/run-case.sh` `167c474c…` | 改:case 名 `*-p163-*`、现场强制重置 + `run.json`、变量名 `P163_EVIDENCE
|
|
11
|
-
| `judge-
|
|
10
|
+
| `run-case.sh` | `docs/team/reports/P157-verify/pkg/run-case.sh` `167c474c…` | 改:case 名 `*-p163-*`、现场强制重置 + `run.json`、变量名 `P163_EVIDENCE`;P380 起运行时默认解析最新版(`latest`)并记录实际版本(见下) |
|
|
11
|
+
| `judge-dirty-ab.py` | 新增(P393):脏框 A/B 的严格单次运行判据;单次运行/版本/旧现场检查复用 `judge-second.py` 的实现 |
|
|
12
|
+
| `judge-second.py` | `docs/team/reports/P157-verify/pkg/judge-second.py` `e6735be5…` | 改:严格单次运行校验(缺戳 / 多 run 标记 / 有旧文件 / observation 一律拒绝);P197 起标记必须**恰好一条**(集合相等会吞掉同 ID 的重复)且在**第一行**,`run-start.txt` 必须存在/非空/`run=` 与 `run.json` 一致;P380 起不再硬编码版本号,改为要求记录值等于现场实测值 |
|
|
12
13
|
| `mock-server.py` | `docs/team/reports/P157-verify/pkg/mock-server.py` `629963db…` | 逐字相同(回环 mock 模型,`--network=none`) |
|
|
13
14
|
| `observe.ts` | `docs/team/reports/P157-verify/pkg/observe.ts` `3bab2cb4…` | 逐字相同(把 pane 帧/事件写成 jsonl 证据) |
|
|
14
15
|
|
|
15
|
-
##
|
|
16
|
+
## 运行时:默认最新版,记录实际版本(P380)
|
|
16
17
|
|
|
17
|
-
-
|
|
18
|
-
|
|
18
|
+
- **判据路线默认为 npm 上的最新版**。`run-case.sh` 的第 4 个参数不给(或给 `latest`)时,它在**每次证据运行开始时**
|
|
19
|
+
解析一次 `@earendil-works/pi-coding-agent` 的最新版本,装进 `$E/.runtime/<版本>/`(网络只在安装这一步用),
|
|
20
|
+
把这个目录挂只读进 `--network=none` 的 case 容器。`run.json.pi_version` 记**解析出的具体版本**,容器里
|
|
21
|
+
`pi --version` 的**实测值**写进 `pi-version.txt`。
|
|
22
|
+
- `judge-second.py` 不再钉死任何版本号:`pi_version` 必须是**具体版本号**(`latest` 会被拒绝),且必须等于
|
|
23
|
+
`pi-version.txt` 的实测值。两者不符就是可见的不兼容(判据 exit 2 点名两边),不会把旧钉版当通过。
|
|
24
|
+
- **复现历史运行**:第 4 个参数给具体版本(例如 `0.99.2`)走同一条安装/记录/核对路径;它只代表「这次跑的是它」,
|
|
25
|
+
不再是「判据版本」。`tests/frames/pi-0.99.2-*`、`pi-1.0.0-*` 是**回放帧**(录制下来的真帧),不是运行时钉版。
|
|
26
|
+
- **解析或安装失败 → 非 0 退出并点名**(没有记住的旧版本可回落);`$E/.runtime/<版本>` 里已装的是别的版本时直接拒绝。
|
|
19
27
|
- **单次运行的三重钉(P197)**:判据读的每个事件文件里 `run_start` 必须**恰好一条**、在**第一行**、
|
|
20
28
|
且 `run` 等于 `run.json.run_id`;`run-start.txt` 必须存在、非空、`run=` 与 `run.json.run_id` 一致。
|
|
21
29
|
数条数而不是比集合 —— 同 ID 的第二个标记正是「现场跨次累积」最坏的形状。红侧见
|
|
22
|
-
`delivery-truth.sh --section judge
|
|
23
|
-
-
|
|
24
|
-
`observation`,并在终端打印醒目提示;`judge-second.py` **拒绝**给这种现场出判据(exit 2
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
`delivery-truth.sh --section judge`(含把「恰好一条」影子回集合相等的变异,以及版本别名 / 实测不符 / 观测模式三条红侧)。
|
|
31
|
+
- **宿主机路线(`host`)仍仅供人工观察**:`run-case.sh … host` 用宿主当前的 pi,把 `run.json.mode` 写成
|
|
32
|
+
`observation`,并在终端打印醒目提示;`judge-second.py` **拒绝**给这种现场出判据(exit 2)。夹具绝不
|
|
33
|
+
`pi update` / `npm i -g` 改宿主。为什么宿主路线不出判据:版本变化会把夹具自造的框内行(例如宿主 Pi 把夹具那条 git
|
|
34
|
+
命令的报错画进输入框,`fatal: no upstream configured …`)暴露成产品行为差异 —— 产品把框内异物当内容扣住、不回字,
|
|
35
|
+
正是要钉住的行为(用例见 `skills/teamsmith/tests/frames/pi-1.0.0-git-error-in-box.txt` 与 `delivery-truth.sh --section foreign`)。
|
|
28
36
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
```sh
|
|
32
|
-
E="$PWD/docs/team/reports/P163-dev-bob"
|
|
33
|
-
mkdir -p "$E/.runtime"
|
|
34
|
-
distrobox-host-exec podman run --rm --userns=keep-id -e HOME=/tmp \
|
|
35
|
-
-v "$E/.runtime:/runtime:rw" \
|
|
36
|
-
localhost/teamsmith-gate:local npm install --prefix /runtime --no-audit --no-fund \
|
|
37
|
-
@earendil-works/pi-coding-agent@0.99.2
|
|
38
|
-
```
|
|
37
|
+
运行时目录由脚本自己建(第一次用某个版本需要网络),不需要再手工安装:
|
|
39
38
|
|
|
40
39
|
## 运行(每次先清空自己的 case 现场)
|
|
41
40
|
|
|
@@ -43,8 +42,8 @@ distrobox-host-exec podman run --rm --userns=keep-id -e HOME=/tmp \
|
|
|
43
42
|
E="$PWD/docs/team/reports/P163-dev-bob"
|
|
44
43
|
P138_SECOND=1 P143_DRAFT=1 \
|
|
45
44
|
P163_EVIDENCE="$E" \
|
|
46
|
-
bash skills/teamsmith/tests/fixtures/delivery-truth-real/run-case.sh tmux-p163-after-
|
|
47
|
-
P163_EVIDENCE="$E" python3 skills/teamsmith/tests/fixtures/delivery-truth-real/judge-second.py tmux-p163-after-
|
|
45
|
+
bash skills/teamsmith/tests/fixtures/delivery-truth-real/run-case.sh tmux-p163-after-latest-dirty HEAD 0 latest
|
|
46
|
+
P163_EVIDENCE="$E" python3 skills/teamsmith/tests/fixtures/delivery-truth-real/judge-second.py tmux-p163-after-latest-dirty
|
|
48
47
|
```
|
|
49
48
|
|
|
50
49
|
`run-case.sh` 每次 `rm -rf "$E/logs/$CASE"` 并写 `run.json`;`scenario.sh` 再把单次 `run_start` 标记写进
|
|
@@ -52,6 +51,55 @@ P163_EVIDENCE="$E" python3 skills/teamsmith/tests/fixtures/delivery-truth-real/j
|
|
|
52
51
|
(没有 `run.json`、或同一现场里出现第二个 run id、或有早于本次运行的文件)会被**明确拒绝**,
|
|
53
52
|
不会把跨次累积算成一条。
|
|
54
53
|
|
|
54
|
+
## 已知的失败形状:没有 upstream 的分支(P380 实测,2026-10-27)
|
|
55
|
+
|
|
56
|
+
worker 分支没有 upstream 时(`git worktree add -b task/…` 的默认形状),`team-notify` 的
|
|
57
|
+
`git rev-parse --symbolic-full-name @{upstream}` 探测会失败;`run()` 里的 `execFileSync` 没带 `stdio`,
|
|
58
|
+
git 的 `fatal: no upstream configured for branch …` 被写到 pane 上。Pi 1.4.0 下它留在编辑框矩形里,产品读到
|
|
59
|
+
的就是「框里有草稿」:不写键、报 queued,第二封 say 因此到不了模型(`second_received=0`、判据 FAIL)。同一份
|
|
60
|
+
产品代码、同一个 case 在 Pi 0.99.2 下 `box_text=[]`、判据 PASS —— 差别在运行时这一层(0.99.2 下那行没有留在
|
|
61
|
+
屏幕上;具体是重绘还是 stdio 接线的差别没有单独证到),所以**钉住 0.99.2 曾把这个产品侧的问题挡在门外**。
|
|
62
|
+
|
|
63
|
+
诊断开关:`P163_BRANCH_UPSTREAM=1` 给分支一个本地 upstream(`branch.task/P138.remote=.` → 本仓 `main`,
|
|
64
|
+
无远端、不联网),把「第二封 say 能不能送达」与「探测的 stderr 漏到 pane」分开;默认**关**,保持真实工作树
|
|
65
|
+
形状。根治在产品侧(`skills/teamsmith/extension/team-notify.ts` 的 `run()` 需要
|
|
66
|
+
`stdio: ['ignore', 'pipe', 'pipe']`;最小复现见 `docs/team/reports/P380-dev3.md`),修好后这个开关可以删掉。
|
|
67
|
+
|
|
68
|
+
## P393 · 脏框 A/B(默认 say 的 watch-first/直投)与当前 Pi 观察
|
|
69
|
+
|
|
70
|
+
三条独立运行、同一个真草稿、同一个 mock 后端、同一个 0.99.2 运行时。基线 = `ec78b6c622ad`:
|
|
71
|
+
|
|
72
|
+
```sh
|
|
73
|
+
E="$PWD/docs/team/reports/P393-dev"; mkdir -p "$E"
|
|
74
|
+
# ① 基线默认 say:无 watcher + 真草稿 → 旧行为排队,不产生模型请求
|
|
75
|
+
P163_DRAFT_AB=1 P163_EVIDENCE="$E" \
|
|
76
|
+
bash skills/teamsmith/tests/fixtures/delivery-truth-real/run-case.sh tmux-p163-base-default-dirty ec78b6c622ad 0 0.99.2
|
|
77
|
+
# ② 基线自带的显式 --now:同一个脏框 → 旧 forced 动作
|
|
78
|
+
P163_DRAFT_AB=1 P163_BASELINE_NOW=1 P163_EVIDENCE="$E" \
|
|
79
|
+
bash skills/teamsmith/tests/fixtures/delivery-truth-real/run-case.sh tmux-p163-base-now-dirty ec78b6c622ad 0 0.99.2
|
|
80
|
+
# ③ 候选默认 say:必须与 ② 等价(草稿+修正同一条真实请求、恰一条 forced 审计、零活动条目)
|
|
81
|
+
P163_DRAFT_AB=1 P163_EVIDENCE="$E" \
|
|
82
|
+
bash skills/teamsmith/tests/fixtures/delivery-truth-real/run-case.sh tmux-p163-candidate-default-dirty <candidate-sha> 0 0.99.2
|
|
83
|
+
P163_EVIDENCE="$E" python3 skills/teamsmith/tests/fixtures/delivery-truth-real/judge-dirty-ab.py \
|
|
84
|
+
tmux-p163-base-default-dirty tmux-p163-base-now-dirty tmux-p163-candidate-default-dirty
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`P163_BASELINE_NOW=1` 只对基线 revision 有意义:它让 scenario 调用**基线自带的** `say --now`,用来
|
|
88
|
+
证明候选的默认直投与旧的显式强制投递等价;候选不实现这个退休旗标。判据只信请求正文、`say.txt`、
|
|
89
|
+
`forced.log`、队列和草稿字节,不用 pane 回显或 `rc=0`。
|
|
90
|
+
|
|
91
|
+
第二封修正仍走原有的 0.99.2 单次判据:
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
P138_SECOND=1 P163_EVIDENCE="$E" \
|
|
95
|
+
bash skills/teamsmith/tests/fixtures/delivery-truth-real/run-case.sh tmux-p163-candidate-second-dirty <candidate-sha> 0 0.99.2
|
|
96
|
+
P163_EVIDENCE="$E" python3 skills/teamsmith/tests/fixtures/delivery-truth-real/judge-second.py tmux-p163-candidate-second-dirty
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**当前宿主 Pi(1.4.0)只作观察**:同一个 `P163_DRAFT_AB=1` 现场用 `host` 运行时跑一遍,记下真实的
|
|
100
|
+
`pi --version`、请求与帧;`judge-second.py` 与 `judge-dirty-ab.py` 都会**拒绝**给 observation 现场出
|
|
101
|
+
判据(exit 2)。不要把一个版本的观察当成另一个版本的判据,也不要把 P380 的旧证据拼进来。
|
|
102
|
+
|
|
55
103
|
## 纪律
|
|
56
104
|
|
|
57
105
|
- 只调 `distrobox-host-exec podman`;容器 `--network=none`、回环 mock 模型、无凭据挂载;
|
package/skills/teamsmith/tests/fixtures/delivery-truth-real/__pycache__/judge-second.cpython-313.pyc
ADDED
|
Binary file
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""P393 · delivery-truth 脏框 A/B 判据(**严格单次运行**,只判 P163_DRAFT_AB 现场)。
|
|
3
|
+
|
|
4
|
+
三条等价运行,同一个真草稿、同一个 mock 后端、同一个 0.99.2 运行时:
|
|
5
|
+
|
|
6
|
+
tmux-p163-base-default-dirty 基线 ec78b6c622ad 的默认 say → 无可用 watcher:旧行为排队
|
|
7
|
+
tmux-p163-base-now-dirty 基线自带的 say --now → 旧 forced 动作,直投那个脏框
|
|
8
|
+
tmux-p163-candidate-default-dirty 候选的默认 say → 必须与上一行等价
|
|
9
|
+
|
|
10
|
+
判据只信现场的证据文件(请求正文、say 输出、forced 审计、队列与草稿字节),不用 pane 回显、rc=0
|
|
11
|
+
或「我以为它会」代替。单次运行/版本/旧现场的严格检查复用 judge-second.py 的一处实现(同一个种子
|
|
12
|
+
问题不应有两个答案)。
|
|
13
|
+
|
|
14
|
+
用法:
|
|
15
|
+
P163_EVIDENCE=<证据目录> python3 judge-dirty-ab.py <case> [<case> …]
|
|
16
|
+
"""
|
|
17
|
+
import importlib.util
|
|
18
|
+
import json
|
|
19
|
+
import pathlib
|
|
20
|
+
import sys
|
|
21
|
+
|
|
22
|
+
HERE = pathlib.Path(__file__).resolve().parent
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _load_second():
|
|
26
|
+
"""把 judge-second.py 的单次运行/版本/旧现场检查装进来(文件名带连字符,用 importlib)。"""
|
|
27
|
+
spec = importlib.util.spec_from_file_location('judge_second', HERE / 'judge-second.py')
|
|
28
|
+
mod = importlib.util.module_from_spec(spec)
|
|
29
|
+
spec.loader.exec_module(mod)
|
|
30
|
+
return mod
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
JS = _load_second()
|
|
34
|
+
|
|
35
|
+
DIRECT_CASES = ('tmux-p163-base-now-dirty', 'tmux-p163-candidate-default-dirty')
|
|
36
|
+
QUEUED_CASES = ('tmux-p163-base-default-dirty',)
|
|
37
|
+
FORCED_RE = r'^[^ ]+ kind=say from=pm target=p138:dev entry=none$'
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def refuse(name, why):
|
|
41
|
+
JS.refuse(name, why)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def user_texts(request):
|
|
45
|
+
return [str(m.get('content', '')) for m in request.get('messages', []) if m.get('role') == 'user']
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def q_files(scene, sub=''):
|
|
49
|
+
d = scene / 'state-after-say' / 'outbox'
|
|
50
|
+
if sub:
|
|
51
|
+
d = d / sub
|
|
52
|
+
return sorted(d.glob('*.msg')) if d.is_dir() else []
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def forced_lines(scene):
|
|
56
|
+
f = scene / 'state-after-say' / 'outbox' / 'forced.log'
|
|
57
|
+
return [x for x in f.read_text().splitlines() if x.strip()] if f.is_file() else []
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def main(argv):
|
|
61
|
+
names = argv[1:]
|
|
62
|
+
if not names:
|
|
63
|
+
print('usage: judge-dirty-ab.py <case> [case…](P163_EVIDENCE=<证据目录>)', file=sys.stderr)
|
|
64
|
+
return 2
|
|
65
|
+
failed = 0
|
|
66
|
+
for name in names:
|
|
67
|
+
scene = JS.load_scene(name)
|
|
68
|
+
if name not in DIRECT_CASES and name not in QUEUED_CASES:
|
|
69
|
+
refuse(name, '不是 P393 的三条脏框 A/B case 名之一')
|
|
70
|
+
draft_file = scene / 'draft-typed.txt'
|
|
71
|
+
if not draft_file.is_file():
|
|
72
|
+
refuse(name, '缺 draft-typed.txt(现场没有跑 P163_DRAFT_AB=1 的真草稿模式)')
|
|
73
|
+
draft = draft_file.read_text()
|
|
74
|
+
msg = 'P138-SAY-' + name
|
|
75
|
+
say_txt = (scene / 'say.txt').read_text() if (scene / 'say.txt').is_file() else ''
|
|
76
|
+
requests = [json.loads(x) for x in (scene / 'requests.jsonl').read_text().splitlines()
|
|
77
|
+
if x.strip() and '"run_start"' not in x]
|
|
78
|
+
hits = [r for r in requests if any(draft in c and msg in c for c in user_texts(r))]
|
|
79
|
+
queued = q_files(scene)
|
|
80
|
+
held = q_files(scene, 'held')
|
|
81
|
+
forced = forced_lines(scene)
|
|
82
|
+
after = (scene / 'dev-after-say.frame').read_text() if (scene / 'dev-after-say.frame').is_file() else ''
|
|
83
|
+
# 发送**前**的帧必须已经含有那真草稿(draft-typed-before.frame 是键入之后、send 之前拍的)
|
|
84
|
+
before = (scene / 'draft-typed-before.frame').read_text() if (scene / 'draft-typed-before.frame').is_file() else ''
|
|
85
|
+
problems = []
|
|
86
|
+
if not before:
|
|
87
|
+
problems.append('缺 draft-typed-before.frame(现场没有真草稿的发送前帧)')
|
|
88
|
+
elif draft not in before:
|
|
89
|
+
problems.append('发送前的帧里没有那真草稿(夹具前提不成立)')
|
|
90
|
+
if queued and not any(msg in p.read_text() for p in queued):
|
|
91
|
+
problems.append('活动队列条目里没有这次 payload')
|
|
92
|
+
|
|
93
|
+
if name in QUEUED_CASES:
|
|
94
|
+
if 'queued' not in say_txt:
|
|
95
|
+
problems.append('基线的默认 say 没有报 queued(旧行为不再被保留)')
|
|
96
|
+
if '已确认送达' in say_txt:
|
|
97
|
+
problems.append('排队却报「已确认送达」')
|
|
98
|
+
if hits:
|
|
99
|
+
problems.append(f'基线默认 say 居然产生了含草稿+修正的模型请求({len(hits)} 条)')
|
|
100
|
+
if forced:
|
|
101
|
+
problems.append(f'基线默认 say 写了 {len(forced)} 条 forced 审计(排队不该直投)')
|
|
102
|
+
if len(queued) != 1:
|
|
103
|
+
problems.append(f'活动队列应恰好 1 条,实际 {len(queued)}')
|
|
104
|
+
if draft not in after:
|
|
105
|
+
problems.append('排队之后草稿不在框里了(被改动)')
|
|
106
|
+
verdict = 'queued (no model request)'
|
|
107
|
+
else:
|
|
108
|
+
if len(hits) != 1:
|
|
109
|
+
problems.append(f'含草稿+修正的模型请求应恰好 1 条,实际 {len(hits)}')
|
|
110
|
+
if name in ('tmux-p163-base-now-dirty',):
|
|
111
|
+
# 基线自带的显式旗标:它的措辞就是旧的「--now 跳过守卫直投」——只否认证回执
|
|
112
|
+
if '--now' not in say_txt:
|
|
113
|
+
problems.append('基线 --now 的输出没有点名 --now(等价性证据不完整)')
|
|
114
|
+
elif '已尝试立即发送' not in say_txt and 'attempted immediate send' not in say_txt:
|
|
115
|
+
problems.append('候选直投的输出没有说明这是一次立即尝试(不许暗示回执)')
|
|
116
|
+
if name != 'tmux-p163-base-now-dirty' and '--now' in say_txt:
|
|
117
|
+
problems.append('候选输出提到了已退休的 say --now')
|
|
118
|
+
if '已确认送达' in say_txt:
|
|
119
|
+
problems.append('直投冒充「已确认送达」')
|
|
120
|
+
if len(forced) != 1:
|
|
121
|
+
problems.append(f'forced 审计应恰好 1 条,实际 {len(forced)}')
|
|
122
|
+
elif not __import__('re').match(FORCED_RE, forced[0]):
|
|
123
|
+
problems.append(f'forced 审计格式不是既有格式:{forced[0]!r}')
|
|
124
|
+
if queued:
|
|
125
|
+
problems.append(f'直投之后还留下 {len(queued)} 条活动队列条目')
|
|
126
|
+
if held:
|
|
127
|
+
problems.append(f'直投之后出现了 {len(held)} 条 held/ 条目')
|
|
128
|
+
verdict = 'direct (draft+correction in one request)'
|
|
129
|
+
|
|
130
|
+
print(f'{name}: requests_matching_draft_and_correction={len(hits)} '
|
|
131
|
+
f'queued={len(queued)} held={len(held)} forced={len(forced)}')
|
|
132
|
+
if problems:
|
|
133
|
+
for why in problems:
|
|
134
|
+
print(f' ✗ {why}')
|
|
135
|
+
print(f'FAIL dirty A/B {name}')
|
|
136
|
+
failed += 1
|
|
137
|
+
else:
|
|
138
|
+
print(f'PASS dirty A/B {name}: {verdict}')
|
|
139
|
+
return 1 if failed else 0
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
if __name__ == '__main__':
|
|
143
|
+
sys.exit(main(sys.argv))
|