teamsmith 0.3.0 → 0.3.2

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.
Files changed (101) hide show
  1. package/README.md +4 -4
  2. package/package.json +6 -2
  3. package/skills/teamsmith/CHANGELOG.md +56 -0
  4. package/skills/teamsmith/SKILL.md +7 -7
  5. package/skills/teamsmith/extension/team-inbox-watch.ts +5 -3
  6. package/skills/teamsmith/references/protocol.md +33 -19
  7. package/skills/teamsmith/references/troubleshooting.md +6 -3
  8. package/skills/teamsmith/scripts/lib/cmd-review.sh +15 -10
  9. package/skills/teamsmith/scripts/lib/cmd-status.sh +8 -4
  10. package/skills/teamsmith/scripts/lib/common.sh +301 -267
  11. package/skills/teamsmith/scripts/lib/gate-lock.sh +66 -28
  12. package/skills/teamsmith/scripts/panel/panel.js +64 -64
  13. package/skills/teamsmith/scripts/panel/src/clipboard.ts +2 -1
  14. package/skills/teamsmith/scripts/panel/src/data.ts +40 -2
  15. package/skills/teamsmith/scripts/panel/src/main.tsx +5 -1
  16. package/skills/teamsmith/scripts/shim/killall +10 -0
  17. package/skills/teamsmith/scripts/shim/pgrep +10 -0
  18. package/skills/teamsmith/scripts/shim/pidof +10 -0
  19. package/skills/teamsmith/scripts/shim/pkill +10 -0
  20. package/skills/teamsmith/scripts/shim/signal-gate +108 -31
  21. package/skills/teamsmith/tests/README.md +31 -0
  22. package/skills/teamsmith/tests/checkout-shape-probe.sh +80 -53
  23. package/skills/teamsmith/tests/config-cli.sh +28 -22
  24. package/skills/teamsmith/tests/flip-p310-lock.sh +3 -9
  25. package/skills/teamsmith/tests/gate-guard.sh +52 -79
  26. package/skills/teamsmith/tests/help-surface.sh +2 -2
  27. package/skills/teamsmith/tests/install-shape.sh +127 -8
  28. package/skills/teamsmith/tests/key-replies-ui.sh +2 -1
  29. package/skills/teamsmith/tests/key-replies.sh +41 -27
  30. package/skills/teamsmith/tests/lib/pty-wait.sh +21 -111
  31. package/skills/teamsmith/tests/lib/section-guard.sh +104 -197
  32. package/skills/teamsmith/tests/loop-inventory.tsv +83 -89
  33. package/skills/teamsmith/tests/panel-b2.sh +351 -376
  34. package/skills/teamsmith/tests/panel-b3.sh +139 -43
  35. package/skills/teamsmith/tests/panel-cpu.sh +41 -129
  36. package/skills/teamsmith/tests/panel-p21.sh +96 -193
  37. package/skills/teamsmith/tests/perf.sh +83 -383
  38. package/skills/teamsmith/tests/routes.sh +115 -26
  39. package/skills/teamsmith/tests/seat-interrupt.sh +20 -10
  40. package/skills/teamsmith/tests/seat-visibility.sh +1 -1
  41. package/skills/teamsmith/tests/section-guard.sh +7 -101
  42. package/skills/teamsmith/tests/section-paths.tsv +15 -7
  43. package/skills/teamsmith/tests/section-select.sh +363 -18
  44. package/skills/teamsmith/tests/signal-gate.sh +249 -27
  45. package/skills/teamsmith/tests/signal-lint-legacy.txt +4 -1
  46. package/skills/teamsmith/tests/slash-team-e2e.sh +4 -4
  47. package/skills/teamsmith/tests/slice-coverage.sh +206 -0
  48. package/skills/teamsmith/tests/smoke.sh +856 -581
  49. package/skills/teamsmith/tests/task-model-routing.sh +25 -7
  50. package/skills/teamsmith/tests/team-bg-stop.sh +18 -10
  51. package/skills/teamsmith/tests/workflow-entry.sh +207 -0
  52. package/skills/teamsmith-init/SKILL.md +1 -1
  53. package/skills/teamsmith/tests/flip-glue.sh +0 -162
  54. package/skills/teamsmith/tests/flip-m12-26c.sh +0 -129
  55. package/skills/teamsmith/tests/flip-m12.sh +0 -185
  56. package/skills/teamsmith/tests/flip-m16.sh +0 -166
  57. package/skills/teamsmith/tests/flip-m17.sh +0 -204
  58. package/skills/teamsmith/tests/flip-m34.sh +0 -96
  59. package/skills/teamsmith/tests/flip-m37.sh +0 -188
  60. package/skills/teamsmith/tests/flip-m4.3.sh +0 -378
  61. package/skills/teamsmith/tests/flip-m43.sh +0 -128
  62. package/skills/teamsmith/tests/flip-m45.sh +0 -244
  63. package/skills/teamsmith/tests/flip-m46.sh +0 -238
  64. package/skills/teamsmith/tests/flip-m48.sh +0 -304
  65. package/skills/teamsmith/tests/flip-m6.2.sh +0 -205
  66. package/skills/teamsmith/tests/flip-m6.3.sh +0 -286
  67. package/skills/teamsmith/tests/flip-m6.4.sh +0 -267
  68. package/skills/teamsmith/tests/flip-m6.5.sh +0 -116
  69. package/skills/teamsmith/tests/flip-m7.1.sh +0 -135
  70. package/skills/teamsmith/tests/flip-m7.2.sh +0 -324
  71. package/skills/teamsmith/tests/flip-p144.sh +0 -112
  72. package/skills/teamsmith/tests/flip-p156.sh +0 -133
  73. package/skills/teamsmith/tests/flip-p160.sh +0 -182
  74. package/skills/teamsmith/tests/flip-p171.sh +0 -249
  75. package/skills/teamsmith/tests/flip-p18.1.sh +0 -95
  76. package/skills/teamsmith/tests/flip-p20.sh +0 -286
  77. package/skills/teamsmith/tests/flip-p201.sh +0 -249
  78. package/skills/teamsmith/tests/flip-p210.sh +0 -242
  79. package/skills/teamsmith/tests/flip-p211.sh +0 -152
  80. package/skills/teamsmith/tests/flip-p217.sh +0 -291
  81. package/skills/teamsmith/tests/flip-p22.sh +0 -123
  82. package/skills/teamsmith/tests/flip-p23.sh +0 -239
  83. package/skills/teamsmith/tests/flip-p25.sh +0 -165
  84. package/skills/teamsmith/tests/flip-p287-lock.sh +0 -342
  85. package/skills/teamsmith/tests/flip-p287-name.sh +0 -279
  86. package/skills/teamsmith/tests/flip-p304-read-side.sh +0 -98
  87. package/skills/teamsmith/tests/flip-p309-p162-deep.sh +0 -122
  88. package/skills/teamsmith/tests/flip-p71.sh +0 -184
  89. package/skills/teamsmith/tests/flip-p72.sh +0 -202
  90. package/skills/teamsmith/tests/load-experiment.sh +0 -290
  91. package/skills/teamsmith/tests/panel-cpu-premise.sh +0 -173
  92. package/skills/teamsmith/tests/panel-flip-m54.sh +0 -207
  93. package/skills/teamsmith/tests/panel-flip-p123.sh +0 -278
  94. package/skills/teamsmith/tests/panel-flip-p125.sh +0 -318
  95. package/skills/teamsmith/tests/panel-flip-p128.sh +0 -259
  96. package/skills/teamsmith/tests/panel-keyprobe-stub.sh +0 -41
  97. package/skills/teamsmith/tests/panel-keyprobe.sh +0 -82
  98. package/skills/teamsmith/tests/panel-knobs.sh +0 -89
  99. package/skills/teamsmith/tests/section-budgets.tsv +0 -164
  100. package/skills/teamsmith/tests/team-bg-flip.sh +0 -239
  101. package/skills/teamsmith/tests/team-inbox-watch-flip.sh +0 -191
@@ -105,6 +105,15 @@ inbox_hash() { # <仓库>:真实仓库收件箱指纹(M7.2 的反向守卫
105
105
  | while IFS= read -r f; do sha256sum "$f"; done | sha256sum | awk '{print $1}'
106
106
  )
107
107
  }
108
+ # P360 实测(2026-10-22):指纹比对在**活着的项目**上必然红 —— 收件箱由投递机制与巡检持续写入,
109
+ # 跟夹具一点关系都没有(那条红在我自己跑的三次里出现两次,另一次恰好在投递间隙)。判据的本意是
110
+ # 「夹具不许往真账本喂幻影待办」,所以判它自己留下的痕迹:本轮私有临时根路径出现在真实收件箱里。
111
+ inbox_fixture_leaks() { # <仓库> <本轮私有根>:真实收件箱里出现本轮夹具路径的行数
112
+ ( cd "$1" 2>/dev/null || return 0
113
+ find docs/team/inbox -type f 2>/dev/null | sort \
114
+ | while IFS= read -r f; do grep -hF -- "${2:-/nonexistent}" "$f" 2>/dev/null; done | wc -l | tr -d ' '
115
+ )
116
+ }
108
117
 
109
118
  # ── 版本锚点(P218):唯一来源 = 那棵树自己的 common.sh(TEAM_VERSION),本文件里不出现版本字面量 ──
110
119
  # 现场(P214):这四处改坏副本的 sed 原来写死成当时的版本号(`1.42.0`);版本改成 0.1.0 后 sed 空转 → 副本没被改坏 →
@@ -432,22 +441,30 @@ chk_init_docs_fact() { # <tree>
432
441
  return 0
433
442
  }
434
443
 
435
- chk_pack_manifest() { # <tree>:声明面 —— 恰好一个 bin 键,files 带着 bin/
444
+ chk_pack_manifest() { # <tree>:声明面 —— team + 四个信号入口,files 带着 bin/
436
445
  python3 - "$1/package.json" <<'PYMANI'
437
446
  import json, sys
438
447
  p = json.load(open(sys.argv[1]))
439
448
  binmap = p.get("bin") or {}
440
449
  files = p.get("files") or []
441
450
  problems = []
442
- if list(binmap.keys()) != ["team"]:
443
- problems.append("bin 键不是恰好一个 team:%r" % (list(binmap.keys()),))
451
+ # P360:0.3.1 的 bin 只有 team,`npm i -g` 因此不给 pkill/killall/pgrep/pidof 建链接,
452
+ # 用户敲这些名字落到 /usr/bin——闸门在 npm 路线上等于不存在。声明面必须含这四个名字。
453
+ want = ["team", "pkill", "killall", "pgrep", "pidof"]
454
+ if list(binmap.keys()) != want:
455
+ problems.append("bin 键不是 team + 四个信号入口:%r" % (list(binmap.keys()),))
444
456
  elif binmap["team"].lstrip("./") != "bin/team.mjs":
445
457
  problems.append("bin.team 指向 %r(要 bin/team.mjs)" % binmap["team"])
458
+ else:
459
+ for name in ("pkill", "killall", "pgrep", "pidof"):
460
+ want_t = "skills/teamsmith/scripts/shim/" + name
461
+ if binmap.get(name, "").lstrip("./") != want_t:
462
+ problems.append("bin.%s 指向 %r(要 %s)" % (name, binmap.get(name), want_t))
446
463
  if "bin/" not in files:
447
464
  problems.append("files 白名单里没有 bin/:%r" % (files,))
448
465
  if problems:
449
466
  print(";".join(problems)); sys.exit(1)
450
- print("bin 一项 + files 带 bin/(%r)" % (binmap["team"],))
467
+ print("bin 五项(team + 四个信号入口,均指向包内文件)+ files 带 bin/")
451
468
  PYMANI
452
469
  }
453
470
 
@@ -484,7 +501,99 @@ chk_prefix_install() { # <tree>:npm 私有 prefix 安装后与 bash 入口一
484
501
  if ! diff <("$prefix/bin/team" help 2>&1) <(bash "$t/skills/teamsmith/scripts/team" help 2>&1) >/dev/null; then
485
502
  printf 'prefix 的 help 与 bash 入口不一致\n'; return 1
486
503
  fi
487
- printf '私有 prefix 安装后 version/help 与 bash 入口一致(%s/bin/team)\n' "$prefix"
504
+ # P321:安装物还得带上信号闸门的四个入口。npm 的 tarball **不携带 120000 软链** —— 0.3.0 的包里
505
+ # pkill/killall/pgrep/pidof 四个名字全部缺失,装完全部落到 /usr/bin(docs/team/reviews/release-0.3.0.md)。
506
+ # 判据不看名字在不在:在**安装物**的 gated PATH 里用同名 argv 记录桩验拒绝/放行(不发任何信号)。
507
+ chk_prefix_signal_entries "$prefix" || return 1
508
+ printf '私有 prefix 安装后 version/help 与 bash 入口一致,四个信号入口在且判定生效(%s/bin/team)\n' "$prefix"
509
+ return 0
510
+ }
511
+
512
+ chk_prefix_signal_entries() { # <prefix>:安装物的 pkill/killall/pgrep/pidof 在、解析到安装目录、判定生效
513
+ local prefix="$1" shim backends stub wlog log t form out rc line fargs missing="" link want resolved
514
+ shim="$prefix/lib/node_modules/teamsmith/skills/teamsmith/scripts/shim"
515
+ backends="$tmp/prefix-signal-backends"; rm -rf "$backends"; mkdir -p "$backends"
516
+ stub="$backends/.witness"
517
+ cat > "$stub" <<'WITNESS'
518
+ #!/usr/bin/env bash
519
+ printf 'WITNESS tool=%s argc=%s argv=%s\n' "$(basename "$0")" "$#" "$*" >> "${WITNESS_LOG:?}"
520
+ [ -n "${WITNESS_OUT:-}" ] && printf '%s\n' "$WITNESS_OUT"
521
+ [ -n "${WITNESS_ERR:-}" ] && printf '%s\n' "$WITNESS_ERR" >&2
522
+ exit "${WITNESS_EXIT:-0}"
523
+ WITNESS
524
+ chmod +x "$stub"
525
+ for t in pkill killall pgrep pidof; do ln -sf .witness "$backends/$t"; done
526
+ for t in pkill killall pgrep pidof; do
527
+ [ -f "$shim/$t" ] && [ -x "$shim/$t" ] || missing="${missing:+$missing }$t"
528
+ done
529
+ if [ -n "$missing" ]; then
530
+ printf '安装包没有携带信号闸门入口(npm 丢 120000 软链的历史形状):%s\n' "$missing"; return 1
531
+ fi
532
+ # P360(0.3.1 实测漏网):**包里带着**不等于**装上能用** —— `npm i -g` 只在 package.json 的 `bin`
533
+ # 里列了谁才在 prefix/bin 里建链接。0.3.1 的 bin 只有 team,于是用户 `pkill` 落到 /usr/bin,
534
+ # 闸门在 npm 路线上等于不存在;而上面两条断言只查了「包内文件在不在」,两次复验都没抓住。
535
+ # 这里补的正是那个缺失的证伪者:装完必须在 prefix/bin 里解析到**这个包的**那个 shim。
536
+ # 两类形状分开判、一起点名(P360 红侧实测:`readlink -f` 对不存在的最后一级会原样吐出路径而不是空,
537
+ # 所以「在不在」必须先自己判,否则「bin 字段没列它们」那条永远打不出来;判据是解析到**这个包的**那个 shim,
538
+ # 所以指向包外、指向包内别的文件、悬空软链都落进 foreign)。
539
+ local miss_bin="" foreign=""
540
+ for t in pkill killall pgrep pidof; do
541
+ link="$prefix/bin/$t"
542
+ want="$(readlink -f "$shim/$t" 2>/dev/null || true)"
543
+ if [ ! -e "$link" ] && [ ! -L "$link" ]; then miss_bin="${miss_bin:+$miss_bin }$t"; continue; fi
544
+ resolved="$(readlink -f "$link" 2>/dev/null || true)"
545
+ [ "$resolved" = "$want" ] && continue
546
+ foreign="${foreign:+$foreign }$t→[${resolved:-<解析不出>}](要 $want)"
547
+ done
548
+ if [ -n "$miss_bin" ]; then
549
+ printf '安装后 prefix/bin 里没有 %s —— npm 没为这些名字建链接(bin 字段没列它们,或列的目标不是包内文件);用户敲这些名字会落到 /usr/bin\n' "$miss_bin"; return 1
550
+ fi
551
+ if [ -n "$foreign" ]; then
552
+ printf '安装后 prefix/bin 的入口没有落在包内 shim:%s\n' "$foreign"; return 1
553
+ fi
554
+ for t in pkill killall pgrep pidof; do
555
+ line="$(PATH="$shim:$backends:/usr/bin:/bin" command -v "$t" 2>/dev/null)"
556
+ if [ "$line" != "$shim/$t" ]; then
557
+ printf 'gated PATH 里 %s 解析到 [%s],不是安装包的入口\n' "$t" "$line"; return 1
558
+ fi
559
+ done
560
+ log="$tmp/prefix-signal-calls.log"; rm -f "$log" "$log.forensics"
561
+ wlog="$tmp/prefix-signal-witness.log"; rm -f "$wlog"
562
+ # 拒绝:exit 64、stdout 留空、同名后端一次也没被执行
563
+ for form in "pkill -f marker" "killall sleep" "pgrep -f marker" "pgrep sleep" "pidof sleep"; do
564
+ read -r -a fargs <<< "$form"
565
+ out="$(env -u TEAM_SIGNAL_REAL PATH="$shim:$backends:/usr/bin:/bin" TEAM_SIGNAL_CALLS_LOG="$log" \
566
+ WITNESS_LOG="$wlog" "$shim/${fargs[0]}" "${fargs[@]:1}" 2>/dev/null)"; rc=$?
567
+ if [ "$rc" != "64" ] || [ -n "$out" ]; then
568
+ printf '安装包入口 [%s] 应拒绝(64 + 空 stdout),实际 rc=%s stdout=[%s]\n' "$form" "$rc" "$out"; return 1
569
+ fi
570
+ unset fargs
571
+ done
572
+ if [ -s "$wlog" ]; then
573
+ printf '拒绝路径执行了同名后端:%s\n' "$(head -2 "$wlog" | tr '\n' ' ')"; return 1
574
+ fi
575
+ # 放行:--help 与显式 -P 的原样 argv / stdout / stderr / 非零状态都来自同名后端
576
+ out="$(env -u TEAM_SIGNAL_REAL PATH="$shim:$backends:/usr/bin:/bin" TEAM_SIGNAL_CALLS_LOG="$log" \
577
+ WITNESS_LOG="$wlog" WITNESS_EXIT=3 WITNESS_OUT=sel-out WITNESS_ERR=sel-err \
578
+ "$shim/pgrep" --help 2>"$tmp/prefix-signal.err")"; rc=$?
579
+ if [ "$rc" != "3" ] || [ "$out" != "sel-out" ] || [ "$(cat "$tmp/prefix-signal.err")" != "sel-err" ]; then
580
+ printf 'pgrep --help 没有原样透传:rc=%s stdout=[%s] stderr=[%s]\n' "$rc" "$out" "$(cat "$tmp/prefix-signal.err")"
581
+ return 1
582
+ fi
583
+ grep -qF 'WITNESS tool=pgrep argc=1 argv=--help' "$wlog" \
584
+ || { printf 'pgrep --help 的 argv 没落到同名后端:[%s]\n' "$(cat "$wlog")"; return 1; }
585
+ out="$(env -u TEAM_SIGNAL_REAL PATH="$shim:$backends:/usr/bin:/bin" TEAM_SIGNAL_CALLS_LOG="$log" \
586
+ WITNESS_LOG="$wlog" WITNESS_EXIT=0 WITNESS_OUT=42 \
587
+ "$shim/pgrep" -P 12 2>/dev/null)"; rc=$?
588
+ if [ "$rc" != "0" ] || [ "$out" != "42" ]; then
589
+ printf 'pgrep -P 12 没有原样透传:rc=%s stdout=[%s]\n' "$rc" "$out"; return 1
590
+ fi
591
+ grep -qF 'WITNESS tool=pgrep argc=2 argv=-P 12' "$wlog" \
592
+ || { printf 'pgrep -P 12 的 argv 没落到 pgrep 后端:[%s]\n' "$(cat "$wlog")"; return 1; }
593
+ grep -qF 'act=pass · tool=pgrep' "$log" \
594
+ || { printf '安装包入口的日志没有 act=pass · tool=pgrep:[%s]\n' "$(cat "$log")"; return 1; }
595
+ grep -qF 'act=refused · tool=pidof' "$log" \
596
+ || { printf '安装包入口的拒绝日志没有 tool=pidof:[%s]\n' "$(cat "$log")"; return 1; }
488
597
  return 0
489
598
  }
490
599
 
@@ -692,9 +801,9 @@ if want pack; then
692
801
  if ! command -v npm >/dev/null 2>&1; then
693
802
  skip "本机没有 npm:打包清单与 prefix 安装都跳过(可见 SKIP,不是静默通过)"
694
803
  else
695
- check_holds "声明面:一个 bin 键(team → bin/team.mjs)+ files 带 bin/" chk_pack_manifest "$tree"
804
+ check_holds "声明面:team + 四个信号入口都指向包内 shim + files 带 bin/" chk_pack_manifest "$tree"
696
805
  check_holds "打包清单:bin/team.mjs + 两个 SKILL.md + install.sh,不含账本" chk_pack_walk "$tree"
697
- check_holds "私有 prefix 安装:version/help 与 bash 入口一致" chk_prefix_install "$tree"
806
+ check_holds "私有 prefix 安装:version/help 与四个信号入口都来自安装物" chk_prefix_install "$tree"
698
807
  fi
699
808
  fi
700
809
 
@@ -883,6 +992,14 @@ PYPACKF
883
992
  ft="$tmp/f-pack2"; scratch_tree "$ft"; rm -f "$ft/bin/team.mjs"
884
993
  check_holds "⑤b 对照:真实树打包清单齐全" chk_pack_walk "$tree"
885
994
  check_breaks "⑤b 翻转:bin 目标文件不在(package 不完整)" chk_pack_walk "$ft"
995
+ # ⑥ P321:把四个信号入口改回 0.3.0 的软链形状 —— npm 的 tarball 丢掉它们,安装判据必须红
996
+ ft="$tmp/f-pack-symlink"; scratch_tree "$ft"
997
+ for _fs in pkill killall pgrep pidof; do
998
+ rm -f "$ft/skills/teamsmith/scripts/shim/$_fs"
999
+ ln -s signal-gate "$ft/skills/teamsmith/scripts/shim/$_fs"
1000
+ done
1001
+ check_holds "⑥ 对照:真实树的私有 prefix 安装带四个可执行信号入口" chk_prefix_install "$tree"
1002
+ check_breaks "⑥ 翻转:入口退回 0.3.0 的软链形状(npm 的 tarball 不携带软链)" chk_prefix_install "$ft"
886
1003
  fi
887
1004
  # ⑦ P59:安装步的信任提示行 —— 去掉它 → 判据红;让它在 --no-skills 下出现 → 判据红
888
1005
  ft="$tmp/f-trustline"; scratch_tree "$ft"
@@ -986,7 +1103,9 @@ PYEXT
986
1103
  fi
987
1104
 
988
1105
  # ---------------------------------------------------------------- 结果
989
- assert_eq "反向守卫(M7.2):整轮夹具没往真实仓库收件箱写一个字节" "$(inbox_hash "$tree")" "$inbox_before"
1106
+ # 判「夹具自己的痕迹」而不是「文件有没有被任何进程写过」:活着的项目里收件箱一直在长。
1107
+ assert_eq "反向守卫(M7.2):真实仓库收件箱里没有本轮夹具路径的痕迹" \
1108
+ "$(inbox_fixture_leaks "$tree" "$tmp")" "0"
990
1109
  printf '\n\033[1m== 结果 ==\033[0m ✓ %d ✗ %d SKIP %d\n' "$PASS" "$FAIL" "$SKIP"
991
1110
  [ "$FAIL" -eq 0 ] && exit 0
992
1111
  exit 1
@@ -80,7 +80,8 @@ kr_group_blocks() {
80
80
  t0="$(date +%s)"
81
81
  kr_panel_snapshot 5 --width 120 --height 28 --lang zh >"$tmp/bl-slow.txt"
82
82
  t1="$(date +%s)"
83
- if [ $((t1 - t0)) -le 20 ]; then ok "blocks:慢 list 在超时界内返回($((t1 - t0))s ≤ 20s)"; else bad "blocks:慢 list 拖过了超时界($((t1 - t0))s)"; fi
83
+ # P316:不判耗时;超时杀块的行为由下一行「慢 list 只降级本块」守。
84
+ printf ' \033[2m· 参考 blocks:慢 list 快照用时 %ss(不判快慢)\033[0m\n' "$((t1 - t0))"
84
85
  assert_has "$tmp/bl-slow.txt" "更早" "blocks:慢 list 只降级本块(页面的导航/其它内容仍在)"
85
86
  kr_shim_set_slow -
86
87
  # ⑥ 输出泛滥:块 stdout 超过上限 → 该块判失败而不是把巨量内容塞进帧
@@ -213,8 +213,8 @@ kr_group_input() {
213
213
  # 相同的合法输入再发一次 → 两条不同编号
214
214
  kr_post "$p" dev2 '完整结论与取舍' "$B" >/dev/null; rc=$?
215
215
  local lst; lst="$(kr_cli "$p" reply list --json)"
216
- eq "input:重复提交不合并(两条)" "$(jget "$lst" 'len(d["entries"])')" "2"
217
- eq "input:编号严格递增" "$(jget "$lst" 'd["entries"][0]["no"]')" "2"
216
+ # P348 合并(两条 → 一条):"两条记录"与"编号递增到 2"是同一份快照的两个面,合成一个谓词不会少判什么。
217
+ jok "$lst" 'len(d["entries"])==2 and d["entries"][0]["no"]==2' && ok "input:重复提交不合并(两条)、编号严格递增(最新 = 2)" || bad "input:重复提交/编号不对($lst)"
218
218
  # label 边界
219
219
  printf 'x\n' >"$B"
220
220
  kr_post "$p" '' 'T' "$B" >/dev/null 2>&1; eq "input:缺 --from → rc2" "$?" "2"
@@ -267,11 +267,9 @@ kr_group_paths() {
267
267
  rm -f "$KR/index.v1"; mv "$KR/index.real" "$KR/index.v1"
268
268
  # 2) writer.lock 是 FIFO → post 拒绝且不阻塞
269
269
  rm -f "$KR/writer.lock"; mkfifo "$KR/writer.lock"
270
- local t0 t1; t0=$(date +%s)
271
270
  kr_post "$p" dev2 'T-fifo' "$B" >/dev/null 2>&1; rc=$?
272
- t1=$(date +%s)
273
271
  eq "paths:writer.lock 是 FIFO → rc4" "$rc" "4"
274
- if [ $((t1 - t0)) -le 5 ]; then ok "paths:FIFO 不阻塞(${t1}s-${t0}s ≤ 5s)"; else bad "paths:FIFO 阻塞了 $((t1 - t0))s"; fi
272
+ # P316:不判耗时;rc4 证明它没有阻塞到超时,下面清掉 FIFO 继续。
275
273
  rm -f "$KR/writer.lock"
276
274
  # 3) bodies/<id>.md 被换成目录 / 软链 → show 拒绝,目标不动
277
275
  local bid; bid="$(kr_cli "$p" reply list --json | jget /dev/stdin 'd["entries"][0]["sha256"]' >/dev/null; ls "$KR/bodies" | head -1)"
@@ -380,8 +378,8 @@ kr_group_original() {
380
378
  kr_cli "$p" reply show 1 --raw >"$TMP/orig-out.md" 2>"$TMP/orig-raw.err"; rc=$?
381
379
  eq "original:raw 导出 rc=0" "$rc" "0"
382
380
  if cmp -s "$B" "$TMP/orig-out.md"; then ok "original:raw 与输入逐字节相同(CRLF/尾换行)"; else bad "original:raw 与输入不同"; fi
383
- local h1 h2; h1="$(sha256sum "$B" | cut -d' ' -f1)"; h2="$(sha256sum "$TMP/orig-out.md" | cut -d' ' -f1)"
384
- eq "original:两份 sha256 一致" "$h2" "$h1"
381
+ # P348 删:原来这里还有一条「两份 sha256 一致」——`cmp -s` 已经比过每一个字节,sha 只是同一事实的另一种数法;
382
+ # 字节相同 ⇒ sha 相同,没有一种破坏能让 sha 红而 cmp 绿。
385
383
  local js; js="$(kr_cli "$p" reply show 1 --json)"
386
384
  jok "$js" 'd["text_kind"]=="safe-display" and d["bytes"]>0 and len(d["sha256"])==64' && ok "original:JSON 标明显示表示并带原文长度/哈希" || bad "original:JSON 结构不对($js)"
387
385
  not_has "original:JSON 的显示文本不含 OSC" "$(jget "$js" 'd["display_text"]')" "$(printf '\033]0;t\007')"
@@ -448,8 +446,9 @@ kr_group_concurrency() {
448
446
  wait "$w1" 2>/dev/null; wait "$w2" 2>/dev/null
449
447
  eq "concurrency:两个真进程都 rc=0" "$(cat "$TMP/c1.rc")/$(cat "$TMP/c2.rc")" "0/0"
450
448
  local lst; lst="$(kr_cli "$p" reply list --json)"
451
- eq "concurrency:两条记录" "$(jget "$lst" 'len(d["entries"])')" "2"
452
- eq "concurrency:编号互不相同且连续" "$(jget "$lst" 'sorted(e["no"] for e in d["entries"])')" "[1, 2]"
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)"
453
452
  eq "concurrency:并发读快照数 >0" "$([ "$reads" -gt 0 ] && echo yes || echo no)" "yes"
454
453
  eq "concurrency:并发读没看到未提交的半条" "$partial" "0"
455
454
  # 两份原文都能取回
@@ -507,18 +506,29 @@ kr_group_receipts() {
507
506
  else
508
507
  bad "receipts:以 root 跑,不可写目录这条没法测(不许静默跳过)"
509
508
  fi
510
- # 锁竞争:另一个活 publisher 持锁 >2s → rc5,且没有新发布;list/show 照常
509
+ # 锁竞争:另一个活 publisher 持锁 → rc5,且没有新发布;list/show 照常
511
510
  kr_hold_lock "$KR" || bad "receipts:夹具没能持住写锁"
512
- local t0 t1; t0="$(date +%s%N)"
513
511
  kr_post "$p" dev2 'R3' "$B" >"$TMP/r-busy.out" 2>&1; rc=$?
514
- t1="$(date +%s%N)"
515
512
  eq "receipts:锁竞争 → rc5" "$rc" "5"
516
- local waited=$(( (t1 - t0) / 1000000 ))
517
- if [ "$waited" -ge 1500 ] && [ "$waited" -le 6000 ]; then ok "receipts:等锁区间 ${waited}ms(≤2000ms 等待 + 启动)"; else bad "receipts:等锁区间异常 ${waited}ms"; fi
518
513
  eq "receipts:竞争失败没有发布" "$(kr_cli "$p" reply list --json | jget /dev/stdin 'd["total_slots"]')" "1"
519
- kr_cli "$p" reply show 1 >/dev/null 2>&1; eq "receipts:锁被占时 show 照常" "$?" "0"
520
- kr_cli "$p" reply list >/dev/null 2>&1; eq "receipts:锁被占时 list 照常" "$?" "0"
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"
521
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"
522
532
  # unconfirmed(最终 fsync 失败):rc6 + candidate_no,不自动重发
523
533
  kr_post "$p" dev2 'R4' "$B" TEAM_REPLY_FAULT=fail:index-fsync >"$TMP/r-unc.out" 2>&1; rc=$?
524
534
  eq "receipts:最终 fsync 失败 → rc6" "$rc" "6"
@@ -576,7 +586,7 @@ kr_group_interrupt() {
576
586
  kr_post "$p" dev2 'K4' "$B" >/dev/null 2>&1; rc=$?
577
587
  eq "interrupt:完整坏槽时 post 拒绝(rc4)而不是截断" "$rc" "4"
578
588
  eq "interrupt:坏槽字节未被改写(sha 不变)" "$(sha256sum "$KR/index.v1" | cut -d' ' -f1)" "$bad_hash"
579
- eq "interrupt:坏槽尺寸未变" "$(stat -c %s "$KR/index.v1")" "$before_size"
589
+ # P348 删:原来还断言「坏槽尺寸未变」—— 整文件 sha 未变已经蕴含尺寸未变(截断一定改 sha)。
580
590
  kr_ev_note "interrupt baseline_hash=$before_hash corrupt_hash=$bad_hash"
581
591
  }
582
592
 
@@ -609,12 +619,13 @@ kr_group_paging() {
609
619
  [ "$cursor" = "None" ] && break
610
620
  if [ "$pages" -gt 10 ]; then bad "paging:cursor 链没在 10 页内结束"; break; fi
611
621
  done
612
- 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/ $//')"
613
624
  eq "paging:3 页覆盖 123→1" "$pages" "3"
614
- eq "paging:每个编号恰出现一次且降序" "$(printf '%s' "$norm" | tr -s ' ' '\n' | grep -c .)" "123"
615
- eq "paging:链的起点是 123" "$(printf '%s' "$norm" | awk '{print $1}')" "123"
616
- eq "paging:链的终点是 1" "$(printf '%s' "$norm" | awk '{print $NF}')" "1"
617
- eq "paging:无重复编号(去重后仍是 123)" "$(printf '%s' "$norm" | tr ' ' '\n' | grep . | sort -u | wc -l | tr -d ' ')" "123"
625
+ # P348 合并(四条 → 一条):原来说「条数 123」「起点 123」「终点 1」「去重后仍 123」四条,
626
+ # 合起来才等于「恰好一遍」;直接与期望链 123 122 … 1 逐字比一次,四条的事实全在里面(而且更强:
627
+ # 顺带钉住降序与无跳号,四条里任何一条独有的破坏都会让这一条红)。
628
+ eq "paging:链恰好是 123 122 … 1(无重复、无缺失、降序)" "$norm" "$want_chain"
618
629
  # 坏页仍前进:把某一整页(编号 24..73 是第 2 页)打坏
619
630
  local KR="$p/.pi/team/state/key-replies" n
620
631
  for n in $(seq 74 123); do :; done
@@ -665,8 +676,9 @@ kr_group_bounded() {
665
676
  local KR="$p/.pi/team/state/key-replies"
666
677
  printf 'ZZZZ' | dd of="$KR/index.v1" bs=1 seek=$((100000 * 4096 - 100)) conv=notrunc status=none
667
678
  local sj; sj="$(kr_cli "$p" __panel-data --block reply_summary)"
668
- eq "bounded:坏最新槽 summary=unavailable" "$(jget "$sj" 'd["state"]')" "unavailable"
669
- eq "bounded:坏最新不退回旧标题" "$(jget "$sj" 'd.get("entry")')" "None"
679
+ # P348 合并(两条 → 一条):同一次机器出口的两个面(状态 + 没有退回旧标题)。
680
+ jok "$sj" 'd["state"]=="unavailable" and d.get("entry") is None' \
681
+ && ok "bounded:坏最新槽 summary=unavailable 且不退回旧标题" || bad "bounded:坏最新槽的处理不对($sj)"
670
682
  # 读取量的观测器:内核自述的 /proc/<pid>/io(rchar/syscr)+ /proc/<pid>/fd{,info}(进程真正打开过
671
683
  # 哪些路径、以什么 flags 打开)。无编译器依赖 —— 门禁镜像按 M47 故意 purge 掉 build-essential,
672
684
  # 所以旧版 LD_PRELOAD shim 在那里永远编不出来(V27 的 M3)。观测器不可用(hidepid 等)时**点名跳过**。
@@ -984,7 +996,7 @@ kr_group_flip() {
984
996
  kr_post "$p" dev2 'base' "$b" >/dev/null 2>&1 || return 1
985
997
  rm -f "$KR/index.v1"; mkfifo "$KR/index.v1"
986
998
  local rc
987
- timeout 4 bash -c "cd '$p' && exec \"\$@\"" _ "${KR_CLEAN[@]}" "$KR_TEAM" --root "$p" reply list --json >/dev/null 2>&1
999
+ timeout 300 bash -c "cd '$p' && exec \"\$@\"" _ "${KR_CLEAN[@]}" "$KR_TEAM" --root "$p" reply list --json >/dev/null 2>&1
988
1000
  rc=$?
989
1001
  rm -f "$KR/index.v1"
990
1002
  printf 'flip/fifo_block:list 对 FIFO 索引 rc=%s\n' "$rc" >>"$TMP/flip-fifo.log"
@@ -1019,7 +1031,9 @@ kr_group_skip_path() {
1019
1031
  fi
1020
1032
  # 子进程里跑 bounded + flip:必须点名跳过、没有 ✗、退出 0(可见跳过 ≠ 静默通过,也 ≠ 红)
1021
1033
  local out="$TMP/skip-path.out" rc
1022
- TEAM_REPLY_NO_PROC_IO=1 timeout 900 bash "$SELF_DIR/key-replies.sh" --select bounded,flip >"$out" 2>&1; rc=$?
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=$?
1023
1037
  # 实质判据有两条:子进程跑完了整轮(末行是结果行且 ✗0)且没有红行。失败时**重跑一次带 trace**
1024
1038
  # 只为取证(不是掩盖红:红照旧判红,只是把成因写进断言与证据包)。
1025
1039
  local last
@@ -1028,7 +1042,7 @@ kr_group_skip_path() {
1028
1042
  *"✗0"*) ok "skip-path:缺观测器时子进程跑完整轮且 ✗0(末行:${last})" ;;
1029
1043
  *)
1030
1044
  local trace="$TMP/skip-path-trace.out"
1031
- 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
1032
1046
  kr_ev_save "$trace" "skip-path-failure-trace.txt"
1033
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)]"
1034
1048
  ;;
@@ -39,41 +39,15 @@
39
39
  # PTY_TRACE=0 print every wait/cleanup decision to stderr (fixture diagnostics)
40
40
  # PTY_SELFTEST_BREAK="" self-test only (`--self-test`): sabotage one rule so the guard test
41
41
  # can go red (early / nosettle / noclockmask / unguarded / noscene /
42
- # noext / alwaysext / noskip / alwaysskip / pipeshadow)
42
+ # noext / alwaysext / pipeshadow)
43
43
  #
44
- # P48 `pty-fixture-load-premise` (panel#The project-settings pty fixture judges under a machine
45
- # premise; the gate rule is verification#The correctness gate judges correctness only): the horizon
46
- # above is a **failure detector, never a judgment**. Time is the machine's dimension, so a machine
47
- # that cannot deliver a frame must not turn into a red. Two in-run instruments, both bounded:
48
- #
49
- # PTY_STALL_ROUNDS=8 the progress window, in rounds. A wait is extended only while the masked
50
- # capture changed within the last this many rounds AND at least this many
51
- # rounds have been observed — a horizon below the window (the fixture's own
52
- # site overrides at 6/8 rounds) is never extended and a scene that stopped
53
- # painting gets no extension at all, so the extension can never hide a
54
- # static failure. Measured basis: a round costs ~0.6-0.85 s, so 8 rounds is
55
- # ~5-7 s of identical masked frames.
56
- # PTY_EXT_FACTOR=3 the extension ceiling: at most this many times the base horizon (bounded
57
- # cost: a red can never take more than 3 x ~26 s per wait, and the scenario
58
- # stops at the first unattributable exhaustion)
59
- #
60
- # At that ceiling the wait asks the caller's premise hook and decides:
61
- # still painting OR pty_premise_over returns 0 (the machine's own readings are over their
62
- # ceilings) -> a **visible SKIP**: one line naming the wait, its rounds, its elapsed time, the
63
- # M59 scene report and the reason (the readings). The wait returns 3, sets PTY_SKIPPED=1 and
64
- # runs the caller's pty_on_skip when it defines one (the fixtures stop that scenario there);
65
- # a static scene with the readings under their ceilings -> the ordinary failure (rc 1) with the
66
- # M59 scene, so a real regression always reds on a healthy machine. A skip is never reported as
67
- # a pass and never as a failure by this file.
68
- #
69
- # The caller may define (both optional; absent = "the machine is under its premise"):
70
- # pty_premise_over 0 when the machine is over its premise (attributed -> SKIP), 1 otherwise
71
- # pty_premise_reason prints the one-line reason the SKIP line carries (loadavg/cores/probe)
72
- # pty_on_skip called after a skip is printed (the pty fixtures exit their scenario with 4)
73
- # PTY_INJECT_NEEDLE="" fixture/self-test only: an extra needle that can never appear, appended to
74
- # every wait — the "the state never arrives" shape the exhaustion tests need.
75
- # Wait verdict: 0 green | 1 red (the M59 failure scene) | 3 visible SKIP (machine, not code) | 2
76
- # setup (pty_cap missing).
44
+ # P316(用户裁定第二条:性能只能是参考指标,不能阻塞):**没有负载前提、没有 SKIP**。
45
+ # 等待视界是**失败探测器**(防死等),不是性能判定:
46
+ # PTY_WAIT_ITERS=100 基础视界(每轮 ~0.6-0.85 s → ~60-85 s);到点以后仍**在绘制**的现场
47
+ # 继续延长(PTY_EXT_FACTOR=5 → 最多 ~300-425 s),静态现场到点就停。
48
+ # 耗尽一律**红**:一行「没等到「X」(轮数 n/N,耗时约 Xs;最后一次状态:…;缺:…)」+ M59 现场,
49
+ # rc=1。**没有 rc=3**:机器忙不再是「没结论」的出口。
50
+ # Wait verdict: 0 green | 1 red (the M59 failure scene) | 2 setup (pty_cap missing).
77
51
  #
78
52
  # Constants, bands and how to re-derive them (design.md §3/§4; the raw table is
79
53
  # docs/team/reports/P48-dev3.md):
@@ -88,18 +62,16 @@
88
62
  # {probe,storm,burn} (owned load, owned targets, private roots).
89
63
  set -uo pipefail
90
64
 
91
- PTY_WAIT_ITERS="${PTY_WAIT_ITERS:-40}"
65
+ PTY_WAIT_ITERS="${PTY_WAIT_ITERS:-100}"
92
66
  PTY_WAIT_PAUSE="${PTY_WAIT_PAUSE:-0.35}"
93
67
  PTY_SETTLE_PAUSE="${PTY_SETTLE_PAUSE:-0.25}"
94
68
  PTY_CLEANUP_ITERS="${PTY_CLEANUP_ITERS:-4}"
95
69
  PTY_SCENE_LINES="${PTY_SCENE_LINES:-12}"
96
70
  PTY_STALL_ROUNDS="${PTY_STALL_ROUNDS:-8}"
97
- PTY_EXT_FACTOR="${PTY_EXT_FACTOR:-3}"
71
+ PTY_EXT_FACTOR="${PTY_EXT_FACTOR:-5}"
98
72
  PTY_INJECT_NEEDLE="${PTY_INJECT_NEEDLE:-}"
99
73
  PTY_TRACE="${PTY_TRACE:-0}"
100
74
  PTY_KEYS_SENT="${PTY_KEYS_SENT:-0}"
101
- PTY_SKIPPED="${PTY_SKIPPED:-0}"
102
- PTY_WAIT_PAINTING="${PTY_WAIT_PAINTING:-}"
103
75
  PTY_WAIT_CEILING="${PTY_WAIT_CEILING:-}"
104
76
  PTY_FAIL_STREAK="${PTY_FAIL_STREAK:-0}"
105
77
  PTY_WAIT_FAILED="${PTY_WAIT_FAILED:-0}"
@@ -197,51 +169,24 @@ _pty_painting_recent() {
197
169
  [ "$(( $1 - $2 ))" -le "$stall" ]
198
170
  }
199
171
 
200
- # _pty_premise_over — the caller's hook, with the two self-test sabotages: `noskip` makes an
201
- # over-premise exhaustion fail anyway (the guard test must catch a skip that stopped happening) and
202
- # `alwaysskip` skips even under the premise (the guard test must catch a skip that swallows a red).
203
- _pty_premise_over() {
204
- [ "${PTY_SELFTEST_BREAK:-}" = "alwaysskip" ] && return 0
205
- [ "${PTY_SELFTEST_BREAK:-}" = "noskip" ] && return 1
206
- declare -F pty_premise_over >/dev/null 2>&1 || return 1
207
- pty_premise_over
208
- }
209
- _pty_premise_reason() {
210
- if declare -F pty_premise_reason >/dev/null 2>&1; then pty_premise_reason
211
- else printf '机器读数超前提'; fi
212
- }
213
-
214
- # pty_skip_line — the one visible line a skip prints. It names the wait, its rounds against the
215
- # ceiling, the elapsed time, whether the scene was still painting, what was missing (the M59
216
- # report) and the caller's reason (the readings). stdout, so the gate's log carries it.
217
- pty_skip_line() {
218
- local painting='场景已静止'
219
- [ "${PTY_WAIT_PAINTING:-no}" = "yes" ] && painting='场景仍在绘制'
220
- printf ' \033[33mSKIP\033[0m 等待耗尽但归因于机器(既不是通过也不是失败):%s · 轮数 %s/%s · 耗时约 %ss · %s · %s · 归因:%s\n' \
221
- "${PTY_WAIT_LABEL:-?}" "${PTY_WAIT_ROUNDS:-?}" "${PTY_WAIT_CEILING:-?}" "${PTY_WAIT_SECONDS:-?}" \
222
- "$painting" "${PTY_WAIT_REPORT:-}" "$(_pty_premise_reason)"
223
- }
224
-
225
172
  # pty_wait_frame <outfile|-> <label> <needle...> → 0 when a settled frame carries every needle
226
173
  # (absent ones prefixed with `!`). The latest capture is written to <outfile> every round so the
227
174
  # caller's assertion can show what was on screen. The horizon is a failure detector: it is extended
228
175
  # (bounded, PTY_EXT_FACTOR) while the scene is still painting, and at the ceiling the verdict is
229
- # attributed — the machine (visible SKIP, rc 3, PTY_SKIPPED=1) or the code (the M59 failure scene,
230
- # rc 1, which the caller's bad() classifies as isolated vs cascade).
176
+ # always a failure (the M59 scene, rc 1, "没等到 X") — P316 removed the machine-attributed SKIP.
231
177
  pty_wait_frame() {
232
178
  local out="$1" label="$2"; shift 2
233
179
  declare -F pty_cap >/dev/null 2>&1 || { printf 'pty-wait: pty_cap is not defined\n' >&2; return 2; }
234
- local base="${PTY_WAIT_ITERS:-40}" extf="${PTY_EXT_FACTOR:-3}"
235
- case "$base" in ''|*[!0-9]*) base=40 ;; esac
180
+ local base="${PTY_WAIT_ITERS:-100}" extf="${PTY_EXT_FACTOR:-5}"
181
+ case "$base" in ''|*[!0-9]*) base=100 ;; esac
236
182
  [ "$base" -ge 1 ] || base=1
237
- case "$extf" in ''|*[!0-9]*) extf=3 ;; esac
183
+ case "$extf" in ''|*[!0-9]*) extf=5 ;; esac
238
184
  [ "$extf" -ge 1 ] || extf=1
239
185
  [ "${PTY_SELFTEST_BREAK:-}" = "noext" ] && extf=1
240
186
  local ceiling=$(( base * extf ))
241
187
  local extra="${PTY_INJECT_NEEDLE:-}"
242
188
  local i=0 a last_masked='' masked last_change=0 t0="$SECONDS"
243
189
  PTY_WAIT_FAILED=0
244
- PTY_SKIPPED=0
245
190
  while [ "$i" -lt "$ceiling" ]; do
246
191
  i=$((i + 1))
247
192
  a="$(pty_cap)"
@@ -250,7 +195,7 @@ pty_wait_frame() {
250
195
  PTY_WAIT_ROUNDS="$i"; PTY_WAIT_CEILING="$ceiling"
251
196
  # The trace line keeps the pre-P48 shape (`rounds=$i`): panel-p21.sh's own M59 assertion
252
197
  # (`wait picker … rounds=[0-9]+ settled=1`) pins it, and the ceiling already appears in the
253
- # exhaustion report and the skip line. A diagnostics line is no place to break a pin.
198
+ # exhaustion report. A diagnostics line is no place to break a pin.
254
199
  [ "${PTY_TRACE:-0}" = "1" ] && pty_trace "wait $label rounds=$i settled=1"
255
200
  return 0
256
201
  fi
@@ -270,12 +215,9 @@ pty_wait_frame() {
270
215
  PTY_WAIT_PAINTING="no"
271
216
  _pty_painting_recent "$i" "$last_change" && PTY_WAIT_PAINTING="yes"
272
217
  PTY_WAIT_REPORT="$(_pty_report_missing "$a" "$@" ${extra:+"$extra"})"
273
- if [ "$PTY_WAIT_PAINTING" = "yes" ] || _pty_premise_over; then
274
- PTY_SKIPPED=1
275
- pty_skip_line
276
- if declare -F pty_on_skip >/dev/null 2>&1; then pty_on_skip; fi
277
- return 3
278
- fi
218
+ # P316:耗尽就是「没等到」——一行点名等待/轮数/耗时/最后一次状态,再给 M59 现场;没有机器维度。
219
+ printf ' \033[33m没等到\033[0m %s:%s/%s 轮(耗时约 %ss;最后一次状态:%s;缺:%s)\n' \
220
+ "$label" "$i" "$ceiling" "$((SECONDS - t0))" "${PTY_WAIT_PAINTING:-no}" "${PTY_WAIT_REPORT:-?}"
279
221
  pty_wait_scene "$label" "$i" "$((SECONDS - t0))" "$a" "$@" ${extra:+"$extra"}
280
222
  return 1
281
223
  }
@@ -424,10 +366,9 @@ pty_selftest() {
424
366
  . "$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)/tmp-root.sh"
425
367
  st_dir="$(tmp_root_create pty-wait-selftest)" || return 3
426
368
  trap 'tmp_root_reap_all' EXIT
427
- local _PASS=0 _FAIL=0 _SKIP=0
369
+ local _PASS=0 _FAIL=0
428
370
  _st_ok() { printf ' \033[32m✓\033[0m %s\n' "$1"; _PASS=$((_PASS + 1)); pty_fail_reset; }
429
371
  _st_bad() { printf ' \033[31m✗\033[0m %s\n' "$1"; _FAIL=$((_FAIL + 1)); }
430
- _st_skip() { printf ' \033[33mSKIP\033[0m %s\n' "$1"; _SKIP=$((_SKIP + 1)); pty_fail_reset; }
431
372
 
432
373
  # The fake pane: a settings view; a picker paints one line per capture (max 4); the title clock
433
374
  # ticks every capture so only the masked comparison can settle. Keys mutate the app state:
@@ -606,38 +547,7 @@ pty_selftest() {
606
547
  _st_bad "静态场景被延长或没红(rc=$stat_rc rounds=$stat_rounds;断点=${PTY_SELFTEST_BREAK:-无})"
607
548
  fi
608
549
 
609
- # ── 判据⑤:耗尽那一刻的归因 —— 超前提是可见 SKIP(不是失败),前提之下仍是红 ──
610
- # 注入的前提钩子(真实夹具里由 panel-p21.sh 提供;这里换成一个可切换的自检读数)。
611
- _pty_selftest_premise="under"
612
- pty_premise_over() { [ "${_pty_selftest_premise:-under}" = "over" ]; }
613
- pty_premise_reason() {
614
- printf '注入读数:探针 999ms > 顶 120ms(loadavg %s · %s 核)' \
615
- "$(cut -d' ' -f1 /proc/loadavg 2>/dev/null || echo '?')" "$(nproc 2>/dev/null || echo '?')"
616
- }
617
- local skip_rc red_rc
618
- _st_reset view
619
- _pty_selftest_premise="over"
620
- PTY_WAIT_ITERS=6 PTY_STALL_ROUNDS=2 PTY_WAIT_PAUSE=0.01 PTY_SETTLE_PAUSE=0.01 \
621
- pty_wait_frame "$st_dir/skip.txt" "超前提的等待" "这条目永远不来" > "$st_dir/skip.out" 2> "$st_dir/skip.err"
622
- skip_rc=$?
623
- if [ "$skip_rc" -eq 3 ] && [ "${PTY_SKIPPED:-0}" = "1" ] \
624
- && grep -q 'SKIP' "$st_dir/skip.out" && grep -q '超前提的等待' "$st_dir/skip.out" \
625
- && grep -q '999ms' "$st_dir/skip.out" && grep -q '这条目永远不来' "$st_dir/skip.out"; then
626
- _st_skip "超前提:rc=3 + PTY_SKIPPED=1 + 一行可见 SKIP(点名等待/轮数/耗时/现场/读数)→ 记为 skip,不是失败"
627
- else
628
- _st_bad "超前提没有给出可见 SKIP(rc=$skip_rc PTY_SKIPPED=${PTY_SKIPPED:-};断点=${PTY_SELFTEST_BREAK:-无})"
629
- fi
630
- _st_reset view
631
- _pty_selftest_premise="under"
632
- PTY_WAIT_ITERS=6 PTY_STALL_ROUNDS=2 PTY_WAIT_PAUSE=0.01 PTY_SETTLE_PAUSE=0.01 \
633
- pty_wait_frame "$st_dir/red.txt" "前提之内的等待" "这条目永远不来" 2> "$st_dir/red.err"
634
- red_rc=$?
635
- if [ "$red_rc" -eq 1 ] && [ "${PTY_SKIPPED:-0}" = "0" ] && grep -q '等待超时' "$st_dir/red.err"; then
636
- _st_ok "前提之内:同一个静态现场仍是红(rc=1 + M59 现场)—— SKIP 不是逃逸门"
637
- else
638
- _st_bad "前提之内的耗尽没有红(rc=$red_rc PTY_SKIPPED=${PTY_SKIPPED:-};断点=${PTY_SELFTEST_BREAK:-无})"
639
- fi
640
-
550
+ # ── 判据⑤(P316 退役):原「超前提 → 可见 SKIP」不再存在;耗尽一律红,见判据④的静态场景。
641
551
  # ── 判据⑥:长帧(>128 KiB)的两向 —— 命中不能被 SIGPIPE 吃掉,缺失必须照缺报(P127)──
642
552
  # P124 的最小复现:帧 120607 B > 管道缓冲(64 KiB),needle 在最前面;旧写法
643
553
  # `printf '%s\n' "$c" | grep -qF` 命中即退 → 写端 SIGPIPE → pipefail 下 rc=141 → 假「没出现」。
@@ -666,7 +576,7 @@ pty_selftest() {
666
576
  _st_bad "长帧缺失没有照缺报(rc=$long_miss_rc;断点=${PTY_SELFTEST_BREAK:-无})"
667
577
  fi
668
578
 
669
- printf '\n\033[1m== 结果 ==\033[0m ✓ %d ✗ %d SKIP %d\n' "$_PASS" "$_FAIL" "$_SKIP"
579
+ printf '\n\033[1m== 结果 ==\033[0m ✓ %d ✗ %d\n' "$_PASS" "$_FAIL"
670
580
  [ "$_FAIL" -eq 0 ] && exit 0
671
581
  exit 1
672
582
  }