teamsmith 0.3.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.
Files changed (101) hide show
  1. package/README.md +4 -4
  2. package/package.json +1 -1
  3. package/skills/teamsmith/CHANGELOG.md +41 -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 +80 -2
  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
@@ -85,7 +85,6 @@ assert_eq() { [ "$2" = "$3" ] && ok "$1" || bad "$1(期望 [$3],实际 [$2]
85
85
  assert_has() { grep -qF -- "$2" "$1" 2>/dev/null && ok "$3" || bad "$3($1 里找不到 [$2])"; }
86
86
  assert_not() { grep -qF -- "$2" "$1" 2>/dev/null && bad "$3(不该出现 [$2])" || ok "$3"; }
87
87
  assert_match() { grep -qE -- "$2" "$1" 2>/dev/null && ok "$3" || bad "$3($1 里没有匹配 [$2])"; }
88
- cond_skip() { printf ' \033[33mSKIP(条件不满足)\033[0m %s\n' "$1${2:+ —— $2}"; }
89
88
 
90
89
  # ---------------------------------------------------------------- P68 数据态等待
91
90
  # fixture-waits-for-landed-reads:控制台自己的状态(首帧标题、工具写的日志、capacity.log 的行数)在断言
@@ -98,21 +97,18 @@ pty_cap() { tmux -L "$sock" capture-pane -p -t "$sess:${b3_cap_pane:-panel}" -S
98
97
  pty_keys() { keys "$@"; }
99
98
  pty_pane_state() { tmux -L "$sock" list-panes -t "$sess:${b3_cap_pane:-panel}" -F '#{pane_dead}:#{pane_dead_status}' 2>/dev/null | head -1; }
100
99
 
101
- # 等控制台自己的标题(`teamsmith pulse`)在稳定帧上。上界 75 轮基础视界(轮询 0.4s + 稳定确认 0.25s;
102
- # 实测每轮 ~0.43s → 约 32s,静态场景不延长)。带宽与推导:安静机上首帧 <1s;旧形状的固定窗口是 5s,
103
- # P52 F2 在负载主机上 6 次红 4 次(首帧落在 5s 之后);确定性的注入(JS runner 晚 8s)实测标题在第
104
- # 43-44 轮(~19s)落地(runner 在路径上付了两次:monitor 的 spawn + activity 读的 monitor.mjs),75 轮
105
- # ≈ 1.7× 实测慢端。rc:0 绿 / 1 红(M59 现场)/ 3 可见 SKIP(场景仍在绘制,机器维度)。
106
- # 夹具旋钮:B3_CONSOLE_ITERS 覆盖上界(只在测带宽时用;默认 75)。
100
+ # 等控制台自己的标题(`teamsmith pulse`)在稳定帧上。视界用 tests/lib/pty-wait.sh 的默认
101
+ # (基础 100 轮 + 仍在绘制时最多 5 倍 ≈ 300s),只防死等;耗尽一律红并报「没等到」(P316:
102
+ # 没有机器前提,没有 SKIP 出口)。耗时只是参考读数。
107
103
  wait_console() { # <outfile> <label>
108
- B3_FRAME_ITERS="${B3_CONSOLE_ITERS:-75}" wait_frame "$1" "$2" 'teamsmith pulse'
104
+ wait_frame "$1" "$2" 'teamsmith pulse'
109
105
  }
110
106
 
111
- # 把 pty-wait 的 rc 翻成夹具的断言:0 → ✓;3 → 可见 SKIP(机器,不算通过也不算失败,D33);其它 → ✗。
107
+ # 把 pty-wait 的 rc 翻成夹具的断言:0 → ✓;其它(含「没等到」)→ ✗。
112
108
  b3_wait_verdict() { # <rc> <ok text> <bad text>
113
109
  case "$1" in
114
110
  0) ok "$2" ;;
115
- 3) cond_skip "$2" "机器读数超前提(等待耗尽但场景仍在绘制,D33 的可见 SKIP)" ;;
111
+ 3) bad "$3" ;; # P316:没有机器前提/ SKIP 出口;耗尽就是「没等到」
116
112
  *) bad "$3" ;;
117
113
  esac
118
114
  }
@@ -120,7 +116,7 @@ b3_wait_verdict() { # <rc> <ok text> <bad text>
120
116
  # 等面板帧满足 needle... 后把捕获写到 <outfile>(needle 以 `!` 开头表示必须缺席)。
121
117
  wait_frame() { # <outfile> <label> <needle...>
122
118
  local _out="$1" _label="$2"; shift 2
123
- local PTY_WAIT_ITERS="${B3_FRAME_ITERS:-30}" PTY_WAIT_PAUSE=0.4 PTY_SETTLE_PAUSE=0.25
119
+ local PTY_WAIT_PAUSE=0.4 PTY_SETTLE_PAUSE=0.25 # 视界用 pty-wait 的默认(只防死等)
124
120
  pty_wait_frame "$_out" "$_label" "$@"
125
121
  }
126
122
 
@@ -145,13 +141,13 @@ wait_cap_not() { # <file name> <needle> <message>
145
141
  # 等一个由工具自己写的文件里出现 <needle>(例如 `pulse up` 的日志点名窗口):20 轮 × 0.5s = 10s。
146
142
  wait_file_has() { # <file> <needle> <label>
147
143
  local file="$1" needle="$2" label="$3" i=1
148
- while [ "$i" -le "${B3_FILE_ITERS:-20}" ]; do
144
+ while [ "$i" -le "${B3_FILE_ITERS:-600}" ]; do
149
145
  grep -qF -- "$needle" "$file" 2>/dev/null && return 0
150
146
  sleep 0.5
151
147
  i=$((i + 1))
152
148
  done
153
149
  printf ' \033[33m·\033[0m 等待超时:%s(%s 轮/%s;%s 里缺 [%s],最后两行:%s)\n' \
154
- "$label" "$((i - 1))" "${B3_FILE_ITERS:-20}" "$file" "$needle" \
150
+ "$label" "$((i - 1))" "${B3_FILE_ITERS:-600}" "$file" "$needle" \
155
151
  "$(tail -2 "$file" 2>/dev/null | tr '\n' ';')" >&2
156
152
  return 1
157
153
  }
@@ -159,7 +155,7 @@ wait_file_has() { # <file> <needle> <label>
159
155
  # 等窗格里的进程参数命中 <needle>(q 收起后窗口里应换成 --headless 巡检循环):30 轮 × 0.5s = 15s。
160
156
  wait_pane_args() { # <pane> <needle> <label>
161
157
  local pane="$1" needle="$2" label="$3" i=1 pid args
162
- while [ "$i" -le "${B3_ARGS_ITERS:-30}" ]; do
158
+ while [ "$i" -le "${B3_ARGS_ITERS:-600}" ]; do
163
159
  pid="$(tmux -L "$sock" list-panes -t "$sess:$pane" -F '#{pane_pid}' 2>/dev/null | head -1)"
164
160
  args="$(ps -o args= -p "${pid:-0}" 2>/dev/null || true)"
165
161
  if [ -n "$args" ] && printf '%s' "$args" | grep -qF -- "$needle"; then return 0; fi
@@ -167,21 +163,21 @@ wait_pane_args() { # <pane> <needle> <label>
167
163
  i=$((i + 1))
168
164
  done
169
165
  printf ' \033[33m·\033[0m 等待超时:%s(%s 轮/%s;窗格进程参数里缺 [%s],最后读到 [%s])\n' \
170
- "$label" "$((i - 1))" "${B3_ARGS_ITERS:-30}" "$needle" "${args:-(无)}" >&2
166
+ "$label" "$((i - 1))" "${B3_ARGS_ITERS:-600}" "$needle" "${args:-(无)}" >&2
171
167
  return 1
172
168
  }
173
169
 
174
170
  # 等 capacity.log 的行数真的长过 <floor>(巡检还在跑的正证据):30 轮 × 0.5s = 15s;成功时打印行数。
175
171
  wait_capacity_growth() { # <file> <floor> <label>
176
172
  local file="$1" floor="$2" label="$3" i=1 c=0
177
- while [ "$i" -le "${B3_CAP_ITERS:-30}" ]; do
173
+ while [ "$i" -le "${B3_CAP_ITERS:-600}" ]; do
178
174
  c="$(grep -c . "$file" 2>/dev/null || echo 0)"
179
175
  if [ "${c:-0}" -gt "$floor" ]; then printf '%s\n' "$c"; return 0; fi
180
176
  sleep 0.5
181
177
  i=$((i + 1))
182
178
  done
183
179
  printf ' \033[33m·\033[0m 等待超时:%s(%s 轮/%s;%s 的行数停在 %s,没长过 %s)\n' \
184
- "$label" "$((i - 1))" "${B3_CAP_ITERS:-30}" "$file" "${c:-?}" "$floor" >&2
180
+ "$label" "$((i - 1))" "${B3_CAP_ITERS:-600}" "$file" "${c:-?}" "$floor" >&2
185
181
  return 1
186
182
  }
187
183
 
@@ -334,6 +330,98 @@ print(",".join(ids))
334
330
  PYL
335
331
  }
336
332
 
333
+ # ---------------------------------------------------------------- 看板页在场(判行为,不判列宽)
334
+ # 120 列的并排档里,空车道按规格折成三列小框(openspec/specs/panel/spec.md「three-column frame」),
335
+ # 框里放不下 `已放弃` 这样的标签,所以「某个车道标签在帧上」不能当「看板页在场」的判据(P125 换形态后
336
+ # 它就恒假,P351 归因)。改判产品自己的两条行为:
337
+ # ① 展开车道的头(`▾ 待办`)只在看板页画 —— 这一帧是不是看板页;
338
+ # ② 目标表按图例顺序给出六条车道 —— 六条车道在不在(车道顺序由规格写死)。
339
+ # 车道清单来自产品自己的 `--snapshot --targets`(点击目标就是「这条车道在这里」的承诺),跑在同一个
340
+ # 夹具状态上,所以它判的是这一版的布局行为,不是某一档的列宽。前提:夹具的看板里至少还有一条展开的
341
+ # 车道(默认就是这样——空车道才折,而 `todo` 有卡片),车道头的字才在帧上。
342
+ board_anchor="▾ 待办"
343
+ board_lane_order="todo,wip,review,done,blocked,dropped"
344
+
345
+ board_lane_list() { # <outfile> → 按图例顺序去重的 lane-fold 车道名
346
+ "$js" "$panel" --snapshot --targets --root "$ROOT" --state-dir "$state" --team-cli "$stub" \
347
+ --lang zh --theme dark --width 120 --height 32 --page 4 >"$1" 2>/dev/null
348
+ python3 - "$1" <<'PYL'
349
+ import json, sys
350
+
351
+ try:
352
+ data = json.load(open(sys.argv[1]))
353
+ except Exception as e: # 读不出的 dump 必须让断言红,不能当成「六条车道都在」
354
+ print(f"<unreadable: {e}>")
355
+ raise SystemExit
356
+ seen = []
357
+ for t in data:
358
+ a = t.get("action") or {}
359
+ if a.get("kind") == "lane-fold" and a.get("lane") not in seen:
360
+ seen.append(a.get("lane"))
361
+ print(",".join(seen))
362
+ PYL
363
+ }
364
+
365
+ board_anchor_hits() { # <capture file> → 帧上展开车道头的处数(读不到按 0,断言随之红)
366
+ local n
367
+ n="$(grep -cF -- "$board_anchor" "$1" 2>/dev/null)"
368
+ printf '%s\n' "${n:-0}"
369
+ }
370
+
371
+ assert_board_page() { # <capture file> <label>
372
+ local lanes hits
373
+ lanes="$(board_lane_list "$tmp/$current/board-lanes.json")"
374
+ hits="$(board_anchor_hits "$1")"
375
+ if [ "$hits" -ge 1 ] && [ "$lanes" = "$board_lane_order" ]; then
376
+ ok "$2(帧上是看板页:车道头 ${hits} 处;六条车道按图例顺序:${lanes})"
377
+ else
378
+ bad "$2(帧上车道头 ${hits} 处、期望 ≥1;车道目标 [${lanes}]、期望 [${board_lane_order}])"
379
+ fi
380
+ }
381
+
382
+ assert_not_board_page() { # <capture file> <label>
383
+ local hits
384
+ hits="$(board_anchor_hits "$1")"
385
+ if [ "$hits" -eq 0 ]; then
386
+ ok "$2(帧上没有看板页的车道头)"
387
+ else
388
+ bad "$2(帧上出现看板页的车道头 ${hits} 处)"
389
+ fi
390
+ }
391
+
392
+ # 6.1 的点击坐标从帧里取:行 = 画着那张卡的那一行,列 = 那张卡的 id 所在的显示列。P125 把未折叠
393
+ # 车道 19→22 列之后,写死的 25 落到卡片内边距那一列,点击就不再落在卡片上;从帧里取坐标的断言判的
394
+ # 是「画出来的这张卡片点得中」,换一版宽度分配也成立。取不到就打印空,由下面的断言红(不回落常数)。
395
+ card_point() { # <capture file> <card id> → "col row"(显示列/行,1-based)
396
+ python3 - "$1" "$2" <<'PYX'
397
+ import re, sys
398
+
399
+ WIDE = [(0x1100,0x115f),(0x2e80,0x303e),(0x3041,0x33ff),(0x3400,0x4dbf),(0x4e00,0x9fff),(0xa000,0xa4cf),(0xac00,0xd7a3),(0xf900,0xfaff),(0xfe10,0xfe19),(0xfe30,0xfe6f),(0xff00,0xff60),(0xffe0,0xffe6)]
400
+
401
+ def cells(text):
402
+ out = []
403
+ for ch in text:
404
+ out.append(ch)
405
+ if any(a <= ord(ch) <= b for a, b in WIDE):
406
+ out.append("")
407
+ return out
408
+
409
+ rows = [re.sub(r"\x1b\[[0-9;]*m", "", l.rstrip("\n")) for l in open(sys.argv[1], encoding="utf-8")]
410
+ needle = sys.argv[2]
411
+ for row, r in enumerate(rows, 1):
412
+ c = cells(r) # 每个显示列一个元素(宽字符的第二列是空串),下标 + 1 就是显示列
413
+ for i in range(len(c) - len(needle) + 1):
414
+ if "".join(c[i:i + len(needle)]) != needle:
415
+ continue
416
+ before = c[i - 1] if i else ""
417
+ after = c[i + len(needle)] if i + len(needle) < len(c) else ""
418
+ if (before and before.isalnum()) or (after and after.isdigit()): # 不是 P140 这类更长的 id
419
+ continue
420
+ print(i + 1, row)
421
+ raise SystemExit
422
+ PYX
423
+ }
424
+
337
425
  # ---------------------------------------------------------------- scenarios
338
426
 
339
427
  scn_pages() {
@@ -358,7 +446,7 @@ scn_pages() {
358
446
  if wait_frame "$tmp/$current/p3-inbox.txt" "消息页计数行(往来,无线程)" '收件箱' '往来' '!线程'; then
359
447
  assert_not "$tmp/$current/p3-inbox.txt" "线程" "捕获里没有 [线程]"
360
448
  else
361
- b3_wait_verdict $? "捕获里没有 [线程]" "消息页计数行没有在预算内落定"
449
+ b3_wait_verdict $? "捕获里没有 [线程]" "消息页计数行没等到(超过等待上限)"
362
450
  fi
363
451
  assert_eq "按 3 后 panel-page=3" "$(page_of)" "3"
364
452
  keys m
@@ -384,18 +472,18 @@ scn_settings() {
384
472
  # The selected row is language: Enter switches zh -> en and it applies on the next frame.
385
473
  keys Enter
386
474
  wait_cap_has lang-en.txt "language" "捕获里有 [language]"
387
- wait_file_has "$(conf)" "lang=en" "语言切换写进 panel.conf" || bad "语言偏好没有在预算内落盘"
475
+ wait_file_has "$(conf)" "lang=en" "语言切换写进 panel.conf" || bad "语言偏好没等到落盘(超过等待上限)"
388
476
  assert_has "$(conf)" "lang=en" "切换语言写进 panel.conf"
389
477
  # Down three rows to the mouse preference and toggle it off.
390
478
  keys Down Down Down
391
479
  sleep 0.3
392
480
  keys Enter
393
- wait_file_has "$(conf)" "mouse=0" "鼠标开关写进 panel.conf" || bad "鼠标偏好没有在预算内落盘"
481
+ wait_file_has "$(conf)" "mouse=0" "鼠标开关写进 panel.conf" || bad "鼠标偏好没等到落盘(超过等待上限)"
394
482
  assert_has "$(conf)" "mouse=0" "鼠标开关写进 panel.conf"
395
483
  keys Down
396
484
  sleep 0.2
397
485
  keys Enter
398
- wait_file_has "$(conf)" "density=compact" "密度开关写进 panel.conf" || bad "密度偏好没有在预算内落盘"
486
+ wait_file_has "$(conf)" "density=compact" "密度开关写进 panel.conf" || bad "密度偏好没等到落盘(超过等待上限)"
399
487
  assert_has "$(conf)" "density=compact" "密度开关写进 panel.conf"
400
488
  keys ,
401
489
  wait_cap_not overlay-closed.txt "设置" "捕获里没有 [设置]"
@@ -412,7 +500,7 @@ scn_settings() {
412
500
  local cyc
413
501
  for cyc in 2 3 4 5 1; do
414
502
  keys Enter
415
- wait_file_has "$(conf)" "page=$cyc" "defaultPage 循环到 $cyc" || bad "defaultPage 没有在预算内循环到 $cyc"
503
+ wait_file_has "$(conf)" "page=$cyc" "defaultPage 循环到 $cyc" || bad "defaultPage 没等到(超过等待上限)循环到 $cyc"
416
504
  assert_eq "defaultPage 循环到 $cyc(五页 + 回绕)" "$(sed -n 's/^page=//p' "$(conf)" | tr -d '\n')" "$cyc"
417
505
  done
418
506
  keys Escape
@@ -512,14 +600,14 @@ scn_workdetail() {
512
600
  # 工作页刚把它走到 V14,所以看板页打开的也是 V14 —— 验证的是「返回原页」,不是 id。
513
601
  keys 4; sleep 1
514
602
  wcap board
515
- assert_has "$(wfile board)" "已放弃" "B5 切到看板页"
603
+ assert_board_page "$(wfile board)" "B5 切到看板页"
516
604
  assert_eq "B5 焦点状态两页共用(看板页也在 V14)" "$(focused_id "$(wfile board)")" "V14"
517
605
  keys Enter; sleep 1.4
518
606
  wcap board-detail
519
607
  assert_has "$(wfile board-detail)" "详情 V14" "B5 看板页 enter 打开焦点卡详情"
520
608
  keys Escape; sleep 0.8
521
609
  wcap board-back
522
- assert_has "$(wfile board-back)" "已放弃" "B5 esc 回到看板页"
610
+ assert_board_page "$(wfile board-back)" "B5 esc 回到看板页"
523
611
  assert_eq "B5 看板页返回后 panel-page=4" "$(page_of)" "4"
524
612
  assert_eq "B5 看板页返回后焦点仍是 V14" "$(focused_id "$(wfile board-back)")" "V14"
525
613
 
@@ -834,13 +922,13 @@ scn_collapse() {
834
922
  "bash '$skill/scripts/team' pulse up > '$tmp/$current/up.log' 2>&1; sleep 1"
835
923
  # P68:等日志自己点名窗口(原来是 sleep 5 + 单次采样)。
836
924
  wait_file_has "$tmp/$current/up.log" "巡检已在" "pulse up 的日志点名窗口" \
837
- || bad "pulse up 的日志没有在预算内点名窗口"
925
+ || bad "pulse up 的日志没等到点名窗口"
838
926
  assert_has "$tmp/$current/up.log" "巡检已在" "pulse up 起了窗口"
839
927
  # P68:等控制台自己的标题在稳定帧上(原来是 sleep 5 + 单次 capture-pane)。
840
928
  if wait_console "$tmp/$current/console.txt" "pulse 窗口里的控制台首帧"; then
841
929
  assert_has "$tmp/$current/console.txt" "teamsmith pulse" "pulse 窗口里是控制台"
842
930
  else
843
- b3_wait_verdict $? "pulse 窗口里是控制台" "pulse 窗口里没有在预算内出现控制台"
931
+ b3_wait_verdict $? "pulse 窗口里是控制台" "pulse 窗口里没等到(超过等待上限)控制台"
844
932
  fi
845
933
  # 计数放在控制台起来之后:`cmd` 辅助窗口的命令末尾有 `sleep 1`,它自己退掉后剩下的才是后端窗口。
846
934
  local wins_before; wins_before="$(tmux -L "$sock" list-windows -t "$sess" | wc -l | tr -d ' ')"
@@ -871,15 +959,15 @@ scn_collapse() {
871
959
  bash '$skill/scripts/team' pulse up > '$tmp/$current/up2.log' 2>&1"
872
960
  # P68:两份由命令自己写的日志分别等(原来是 sleep 6 + 两次单次采样)。
873
961
  wait_file_has "$tmp/$current/status-headless.log" "无界面 tick" "pulse status 报无界面形态" \
874
- || bad "pulse status 没有在预算内报无界面形态"
962
+ || bad "pulse status 没等到无界面形态"
875
963
  assert_has "$tmp/$current/status-headless.log" "无界面 tick" "pulse status 报无界面形态"
876
964
  wait_file_has "$tmp/$current/up2.log" "恢复成控制台" "pulse up 原地恢复控制台" \
877
- || bad "pulse up 没有在预算内恢复控制台"
965
+ || bad "pulse up 没等到恢复控制台"
878
966
  assert_has "$tmp/$current/up2.log" "恢复成控制台" "pulse up 原地恢复控制台"
879
967
  if wait_console "$tmp/$current/restored.txt" "恢复后的控制台首帧"; then
880
968
  assert_has "$tmp/$current/restored.txt" "teamsmith pulse" "恢复后同一窗口里又是控制台"
881
969
  else
882
- b3_wait_verdict $? "恢复后同一窗口里又是控制台" "恢复后同一窗口里没有在预算内出现控制台"
970
+ b3_wait_verdict $? "恢复后同一窗口里又是控制台" "恢复后同一窗口里没等到(超过等待上限)控制台"
883
971
  fi
884
972
  }
885
973
 
@@ -895,18 +983,18 @@ scn_board() {
895
983
  keys 4
896
984
  sleep 1
897
985
  bcap p4
898
- assert_has "$(bfile p4)" "已放弃" "按 4 切到看板页(六车道在场)"
986
+ assert_board_page "$(bfile p4)" "按 4 切到看板页(六车道在场)"
899
987
  assert_eq "按 4 后 panel-page=4" "$(page_of)" "4"
900
988
  start_panel
901
989
  bcap relaunch
902
- assert_has "$(bfile relaunch)" "已放弃" "重启后仍在看板页(panel-page 记忆)"
990
+ assert_board_page "$(bfile relaunch)" "重启后仍在看板页(panel-page 记忆)"
903
991
  assert_eq "重启后 panel-page 仍是 4" "$(page_of)" "4"
904
992
  # 4.2: an out-of-range file falls back to the default page, never an error.
905
993
  printf '9\n' > "$(page_file)"
906
994
  start_panel
907
995
  bcap oob
908
996
  assert_has "$(bfile oob)" "项目进度" "panel-page=9 时回落到默认页(总览)"
909
- assert_not "$(bfile oob)" "已放弃" "panel-page=9 时没有渲染看板页"
997
+ assert_not_board_page "$(bfile oob)" "panel-page=9 时没有渲染看板页"
910
998
  # 5.3: the focus is keyed by entry id — a reorder keeps it, a removal falls back inside the lane.
911
999
  board_a="$tmp/$current/board-a.json"
912
1000
  board_b="$tmp/$current/board-b.json"
@@ -1047,9 +1135,14 @@ PYC
1047
1135
 
1048
1136
  # 6.1: a click on a card focuses it — in the injected instance's own bytes, the focus cursor has
1049
1137
  # to move onto the clicked card (the start of the frame puts it on the first card of `todo`).
1138
+ # P352: 坐标从帧里取(行 = 画着 P14 的那一行,列 = 它的 id 所在的显示列)—— P125 把未折叠车道
1139
+ # 19→22 列之后,写死的 25 落到卡片内边距那一列,点击就不再是「点卡片」。
1140
+ read -r click_col click_row < <(card_point "$(bfile lane-first)" P14)
1141
+ printf ' \033[36m· 夹具\033[0m 6.1 的点击点取自 lane-first 帧:row=%s col=%s(P14 的 id 列)\n' \
1142
+ "${click_row:-(取不到)}" "${click_col:-(取不到)}"
1050
1143
  B3_STUB_DONE=20 python3 "$pty_direct" --js "$js" --panel "$panel" --root "$ROOT" --state-dir "$state" \
1051
1144
  --team-cli "$stub" --out "$tmp/$current/click-card.bin" --expect-enable yes \
1052
- --click-col 25 --click-row 4 --cols 120 --rows 32 >"$tmp/$current/click-card.log" 2>&1
1145
+ --click-col "${click_col:-0}" --click-row "${click_row:-0}" --cols 120 --rows 32 >"$tmp/$current/click-card.log" 2>&1
1053
1146
  assert_eq "直驱 pty:卡片点击注入成功(6.1)" "$?" "0"
1054
1147
  click_moved="$(python3 - "$tmp/$current/click-card.bin" <<'PYM'
1055
1148
  import re, sys
@@ -1088,21 +1181,24 @@ scn_detail() {
1088
1181
  other_before="$(cd "$ROOT" && find .pi/team/state -type f ! -name draft.md ! -name panel.conf ! -name panel-page | sort | xargs -r md5sum | md5sum)"
1089
1182
  start_panel
1090
1183
  dcap board
1091
- assert_has "$(dfile board)" "已放弃" "夹具:控制台停在看板页(六车道在场)"
1184
+ assert_board_page "$(dfile board)" "夹具:控制台停在看板页(六车道在场)"
1092
1185
 
1093
1186
  # 9.1 + 9.4: Enter opens the focused card's detail; the first detail frame is timed from the key,
1094
1187
  # then the view is waited for (the first frame is the loading state — the block is one child away).
1095
- local t0 t1 opened=1 i
1188
+ local t0 t1 opened=1 i last_state=""
1096
1189
  t0="$(date +%s.%N)"
1097
1190
  keys Enter
1098
- for i in $(seq 1 40); do
1099
- if { cap || true; } | grep -qF '详情'; then opened=0; break; fi
1191
+ # P316:上限 300s(防死等);耗尽报「没等到详情视图」并带最后一次状态;耗时只作参考打印。
1192
+ for i in $(seq 1 10000); do
1193
+ last_state="$(cap || true)"
1194
+ if printf '%s' "$last_state" | grep -qF '详情'; then opened=0; break; fi
1100
1195
  sleep 0.03
1101
1196
  done
1102
1197
  t1="$(date +%s.%N)"
1103
- assert_eq "Enter 后 1.2s 内出现详情视图" "$opened" "0"
1104
- printf ' \033[36m·\033[0m 首帧耗时(Enter→详情标题上屏):%ss\n' "$(awk -v a="$t0" -v b="$t1" 'BEGIN { printf "%.3f", b - a }')"
1105
- for i in $(seq 1 40); do
1198
+ assert_eq "详情视图出现(上限 300s;没等到时下面打最后状态)" "$opened" "0"
1199
+ [ "$opened" = "0" ] || printf ' \033[33m没等到\033[0m 详情视图:最后一次状态=%s\n' "$(printf '%s' "$last_state" | tail -3 | tr '\n' '|')"
1200
+ printf ' \033[36m· 参考\033[0m 首帧耗时(Enter→详情标题上屏):%ss\n' "$(awk -v a="$t0" -v b="$t1" 'BEGIN { printf "%.3f", b - a }')"
1201
+ for i in $(seq 1 6000); do
1106
1202
  if { cap || true; } | grep -qF '[brief]'; then break; fi
1107
1203
  sleep 0.05
1108
1204
  done
@@ -1111,7 +1207,7 @@ scn_detail() {
1111
1207
  assert_has "$(dfile open)" "[brief]" "第一个文件 tab 默认打开"
1112
1208
  assert_has "$(dfile open)" "fixture brief" "详情视图渲染了 brief 的正文"
1113
1209
  assert_has "$(dfile open)" "verbatim fence body" "围栏代码块正文原样上屏"
1114
- assert_not "$(dfile open)" "已放弃" "详情视图替换了看板块(替换块不留内容)"
1210
+ assert_not_board_page "$(dfile open)" "详情视图替换了看板块(替换块不留内容)"
1115
1211
 
1116
1212
  # 9.2: ←/→ switch files, ↑/↓ scroll the document.
1117
1213
  keys Right
@@ -1133,7 +1229,7 @@ scn_detail() {
1133
1229
  keys q
1134
1230
  sleep 0.8
1135
1231
  dcap back-q
1136
- assert_has "$(dfile back-q)" "已放弃" "q 返回看板页"
1232
+ assert_board_page "$(dfile back-q)" "q 返回看板页"
1137
1233
  assert_not "$(dfile back-q)" "详情 V14" "q 之后详情视图关闭"
1138
1234
  local pane_pid args
1139
1235
  pane_pid="$(tmux -L "$sock" list-panes -t "$sess:panel" -F '#{pane_pid}' | head -1)"
@@ -1148,7 +1244,7 @@ scn_detail() {
1148
1244
  keys Escape
1149
1245
  sleep 0.8
1150
1246
  dcap back-esc
1151
- assert_has "$(dfile back-esc)" "已放弃" "Esc 返回看板页"
1247
+ assert_board_page "$(dfile back-esc)" "Esc 返回看板页"
1152
1248
  assert_not "$(dfile back-esc)" "详情 V14" "Esc 之后详情视图关闭"
1153
1249
 
1154
1250
  # P249: a preview's artifacts switch with ←/→, ↑/↓ scrolls the document and q returns to the work
@@ -1,44 +1,22 @@
1
1
  #!/usr/bin/env bash
2
- # CPU red-line fixture (pulse-console B1, tasks.md 1.5).
2
+ # CPU / first-frame **reference readings** (pulse-console B1, tasks.md 1.5; P316).
3
3
  #
4
4
  # bash skills/teamsmith/tests/panel-cpu.sh [tree] [seconds]
5
5
  # TEAM_PANEL_CPU_PAGE=4 bash skills/teamsmith/tests/panel-cpu.sh # park it on the board page
6
- # TEAM_PANEL_CPU_DETAIL=1 bash skills/teamsmith/tests/panel-cpu.sh # open the markdown detail view
7
- # TEAM_PANEL_CPU_COMPOSE=1 bash skills/teamsmith/tests/panel-cpu.sh # hold the compose line open
8
- # TEAM_PANEL_CPU_VIEW=1 bash skills/teamsmith/tests/panel-cpu.sh # keep the project-settings view open
6
+ # TEAM_PANEL_CPU_DETAIL=1 bash ... # open the markdown detail view
7
+ # TEAM_PANEL_CPU_COMPOSE=1 bash ... # hold the compose line open
8
+ # TEAM_PANEL_CPU_VIEW=1 bash ... # keep the project-settings view open
9
9
  # TEAM_PANEL_CPU_VIEW=1 TEAM_PANEL_CPU_EDIT=1 bash ... # …and an editor holding a typed draft
10
10
  #
11
- # P26/G3(panel#Frame assembly is asynchronous… MODIFIED):2000ms 与 1% 是**面板**的判定,不是机器的
12
- # 判定 —— 它们只在**测量前提**成立时判:`loadavg_1m ≤ factor × 逻辑核数`(核数取 `nproc`,否则
13
- # `getconf _NPROCESSORS_ONLN`)。前提不成立就打印实测的三个数(首帧 ms、窗格 CPU%、load)并退出 **4**。
11
+ # 用户裁定(2026-10-19,第二条):**性能只能是参考指标,不能作为阻塞**。本夹具照旧测量首帧(三次独立
12
+ # spawn 的中位)与窗格 CPU(采样窗三等分的中位),样本与树 CPU 图都打印出来,行首是「· 参考」——
13
+ # **没有阈值判定、没有负载前提、没有 SKIP**:机器多忙都照测,数字是给人看的。
14
14
  #
15
- # **本文件用 factor = 0.25**(`TEAM_PANEL_CPU_PREMISE_FACTOR` 可覆盖)—— 与 smoke 27-d 的 0.75 不同,
16
- # 因为两者量的东西不同:27-d 是 5 次采样的**中位**(实测到 0.62 × 核仍 1.2–1.7s,M49 的红在
17
- # 0.81–1.0 × 核),而这里的交互首帧是**单进程冷启动**量出来的,实测(32 核机器,median-of-3):
18
- # 0.22 × 核(load 6.9)首帧中位 1542ms ✓ | 0.40 × 核(load 13.0)2005ms ✗ | 0.71 × 核(load 22.8)3919ms ✗
19
- # 也就是绿→红的交叉在 0.22–0.40 × 核之间;取 0.25 × 核(本机 load 8)落在交叉之下、实测绿之上。
20
- # 代价说明:机器忙时这条断言会可见地 SKIP(退出 4),而不是给出一个机器欠的假红。
21
- # 红线本身**没有动**:前提成立时判法与阈值与以前逐字一致(超 2000ms 或 CPU ≥ 1% → 退出 2)。
15
+ # Exit: 0 测到了(读数照打,不管数值多大)
16
+ # 3 搭建失败(没有 tmux / node / 面板 bundle / 窗格没起来)
22
17
  #
23
- # **中位 of 3**(PM 口径决定,2026-09-20 第二批返工):首帧与窗格 CPU% 都取三次测量的中位,三个样本
24
- # 都打印出来 —— 单次采样把机器自己的启动抖动算进了面板的账(实测:安静时 ~1.5s,load 4.5 时单次
25
- # 2141ms,load 13 时 2279ms;同一台机器同一天里 1.697% 与 0.399% 都出现过)。首帧是三次**独立 spawn**
26
- # (每次都是「窗口创建 → 第一帧可见」);CPU% 是把同一个采样窗口**三等分**后的三个子窗均值(不额外
27
- # 加长采样时间)。阈值不缩放:中位 ≥ 2000ms 或中位 ≥ 1% 仍是红。
28
- #
29
- # 环境姿态(M51):树 CPU 图用 `/usr/bin/time -o/-f` 读,缺这个工具时**可见跳过**(exit 4,打印原因)——
30
- # 它是附带读数,不是判定依据(判定只看首帧与窗格 CPU);把它当搭建失败(exit 3)会在缺工具的环境里
31
- # 造出假红(CI 的 M51 红就是这个形状)。门禁镜像里有它(ci/Containerfile 的构建期断言)。
32
- #
33
- # Exit: 0 窗格进程 < 1% 单核且首帧在预算内
34
- # 2 红线破了(首帧 ≥ 2000ms 或窗格进程 ≥ 1%)
35
- # 3 搭建失败(没有 tmux / node / bundle)
36
- # 4 **跳过**(既不是通过也不是红;包装器不能把 4 当成 0):负载前提不成立,或环境缺 GNU time
37
- #
38
- # 夹具旋钮(**只在 `TEAM_SMOKE_FIXTURE=1` 时生效**,裸设一律忽略并打印):
39
- # TEAM_PANEL_CPU_LOADAVG=<数> 替掉 /proc/loadavg 的读数
40
- # TEAM_PANEL_CPU_CORES=<整数> 替掉核数
41
- # TEAM_PANEL_CPU_FRAME_DELAY_MS=<ms> 在面板进程启动前睡一觉(造一个真越线的首帧)
18
+ # 环境姿态(M51 保留):树 CPU 图用 `/usr/bin/time -o/-f` 读;缺这个工具时只打印一行「读不到」,
19
+ # 不影响首帧/窗格 CPU 的读数,也不改变退出码(它是附带读数,本来就不是判定依据)。
42
20
  set -uo pipefail
43
21
 
44
22
  here="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
@@ -49,60 +27,19 @@ here="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
49
27
  tree="${1:-$(cd -P "$here/../../.." && pwd)}"
50
28
  secs="${2:-${TEAM_PANEL_CPU_SECS:-60}}"
51
29
 
52
- # ── 测量前提(P26/G3)───────────────────────────────────────────────────────────────────────
53
- # 夹具旋钮只有在 TEAM_SMOKE_FIXTURE=1 时被采信 —— 否则“负载前提”会退化成“想跳就跳”的后门
54
- # (PM 审查要点②:真路径下的 TEAM_PANEL_CPU_* 注入不得改变判定)。
55
- PREMISE_FACTOR="${TEAM_PANEL_CPU_PREMISE_FACTOR:-0.25}"
56
- case "$PREMISE_FACTOR" in ''|*[!0-9.]*) PREMISE_FACTOR=0.25 ;; esac
57
- pc_fixture_on() { [ "${TEAM_SMOKE_FIXTURE:-0}" = "1" ]; }
58
- pc_notice() { printf ' 忽略 %s=%s(只有 TEAM_SMOKE_FIXTURE=1 时夹具旋钮才生效;真实路径读真值)\n' "$1" "$2" >&2; }
59
- pc_load() {
60
- if [ -n "${TEAM_PANEL_CPU_LOADAVG:-}" ]; then
61
- if pc_fixture_on; then printf '%s\n' "$TEAM_PANEL_CPU_LOADAVG"; return 0; fi
62
- pc_notice TEAM_PANEL_CPU_LOADAVG "$TEAM_PANEL_CPU_LOADAVG"
63
- fi
64
- cut -d' ' -f1 /proc/loadavg 2>/dev/null || printf '?'
65
- }
66
- pc_cores() {
67
- if [ -n "${TEAM_PANEL_CPU_CORES:-}" ]; then
68
- if pc_fixture_on; then printf '%s\n' "$TEAM_PANEL_CPU_CORES"; return 0; fi
69
- pc_notice TEAM_PANEL_CPU_CORES "$TEAM_PANEL_CPU_CORES"
70
- fi
71
- nproc 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null || printf '0'
72
- }
73
- # → 0 前提成立(照判)/ 1 不成立(跳过)。同时把前提一行打给人看。
74
- pc_premise() {
75
- local load cores thr
76
- load="$(pc_load)"; cores="$(pc_cores)"
77
- case "$cores" in ''|*[!0-9]*) cores=0 ;; esac
78
- thr="$(awk -v c="$cores" -v f="$PREMISE_FACTOR" 'BEGIN { printf "%.2f", f * c }')"
79
- if [ "$cores" -gt 0 ] && awk -v l="$load" -v t="$thr" 'BEGIN { exit !(l <= t) }'; then
80
- printf '== load premise: loadavg %s <= %s (%s x %s cores) -> hold (judging)\n' "$load" "$thr" "$PREMISE_FACTOR" "$cores"
81
- return 0
82
- fi
83
- printf '== load premise: loadavg %s > %s (%s x %s cores) -> NOT held (skip)\n' "$load" "$thr" "$PREMISE_FACTOR" "$cores"
84
- return 1
30
+ # ── 机器读数(P316:只打印,不判绿红,不设前提)──────────────────────────────────────────
31
+ pc_load() { cut -d' ' -f1 /proc/loadavg 2>/dev/null || printf '?'; }
32
+ pc_cores() { nproc 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null || printf '0'; }
33
+ pc_reference_machine() {
34
+ printf '· 参考 机器:loadavg %s · %s 核 · 采样窗 %ss(本夹具不判绿红)\n' \
35
+ "$(pc_load)" "$(pc_cores)" "$secs"
85
36
  }
86
- # ── 前提自述模式(M58/B1 1.7):只打印前提行与每个注入旋钮的忽略行,**不测量、不起任何进程**。
87
- # 这是 d-realpath 承诺的时间无关形态(正确性门禁每轮都跑它,经 tests/panel-knobs.sh):夹具开关关着时,
88
- # 注入的 TEAM_PANEL_CPU_* 必须被忽略并打印,前提行必须反映真读数。它不判任何时长,退出 0。
89
- if [ "${TEAM_PANEL_CPU_PREMISE_ONLY:-0}" = "1" ]; then
90
- # pc_premise 自己会把注入的 LOADAVG / CORES 走 pc_load/pc_cores 读一遍(真路径即打印忽略行)。
91
- if [ -n "${TEAM_PANEL_CPU_FRAME_DELAY_MS:-}" ]; then
92
- if pc_fixture_on; then :; else pc_notice TEAM_PANEL_CPU_FRAME_DELAY_MS "$TEAM_PANEL_CPU_FRAME_DELAY_MS"; fi
93
- fi
94
- pc_premise || true # 前提一行(真读数;不成立也照打)
95
- printf 'panel-cpu: premise-only 模式(裸读数 + 旋钮忽略声明;没有起进程、没有测量、没有判定)\n'
96
- exit 0
97
- fi
98
-
99
37
  refresh="${TEAM_PANEL_CPU_REFRESH:-3}"
100
38
  interval=5
101
39
  sock="p12cpu-$$"
102
40
  sess="p12cpu-$$"
103
41
  js="${TEAM_JS_BIN:-$(command -v node || true)}"
104
42
  [ -n "$js" ] || js="$(command -v bun || true)"
105
- rc=3
106
43
 
107
44
  cleanup() {
108
45
  # P162:收尾先证明私有 socket 生效(不成立就拒绝;cleanup 里不许 exit)
@@ -128,8 +65,8 @@ for cand in /usr/bin/time "$(command -v time || true)"; do
128
65
  [ -x "$cand" ] && { time_bin="$cand"; break; }
129
66
  done
130
67
  if [ -z "$time_bin" ]; then
131
- printf 'panel-cpu: SKIP — the tree CPU figure needs GNU time (/usr/bin/time) and it is not installed here; the 2000ms / 1%% red line was not judged (exit 4; the gate image pins the tool)\n' >&2
132
- exit 4
68
+ printf '· 参考 面板读数:没测到(缺 GNU time = /usr/bin/time;树 CPU 图是附带读数,本环境没有它)\n' >&2
69
+ exit 0
133
70
  fi
134
71
 
135
72
  panel="$tree/skills/teamsmith/scripts/panel/panel.js"
@@ -192,21 +129,10 @@ if [ -n "$compose_flag" ]; then
192
129
  compose_env="PATH=$fakebin:\$PATH "
193
130
  fi
194
131
  pane_cmd="cd '$neut_root' && ${compose_env}exec '$time_bin' -o '$time_out' -f 'P12CPU user=%U sys=%S elapsed=%e' -- '$js' '$panel' --root '$neut_root' --team-cli '$tree/skills/teamsmith/scripts/team' --no-pulse --refresh $refresh${page_flag}${state_flag}"
195
- # 夹具注入(P26/G3):在面板进程启动前睡一觉 → 造一个**真越线**的首帧(只在夹具模式下)
196
- if [ -n "${TEAM_PANEL_CPU_FRAME_DELAY_MS:-}" ]; then
197
- if pc_fixture_on; then
198
- case "$TEAM_PANEL_CPU_FRAME_DELAY_MS" in
199
- ''|*[!0-9]*) : ;;
200
- *) pane_cmd="$(awk -v ms="$TEAM_PANEL_CPU_FRAME_DELAY_MS" 'BEGIN { printf "sleep %.2f\n", ms / 1000 }')"$'\n'"$pane_cmd" ;;
201
- esac
202
- else
203
- pc_notice TEAM_PANEL_CPU_FRAME_DELAY_MS "$TEAM_PANEL_CPU_FRAME_DELAY_MS"
204
- fi
205
- fi
206
132
  tmux -L "$sock" new-session -d -s "$sess" -x 140 -y 34 -c "$neut_root" "sleep 600"
207
- pc_premise || true # 前提一行先打(不成立也照测,因为退出 4 时要把实测三个数一起打出来)
133
+ pc_reference_machine # 参考机器读数(不判绿红)
208
134
  # 首帧:三次独立 spawn 各量一次「窗口创建 → 第一帧可见」,取中位(中位 of 3)。
209
- # `never` = 轮询预算内没出现(> 2000ms 的一种形态),记成 9999 参与中位,但打印时保留 `never`。
135
+ # `never` = 300s 轮询视界内没出现(读数的一种形态),记成 9999 参与中位,但打印时保留 `never`。
210
136
  first_frames=()
211
137
  ff_never=0
212
138
  measure_first_frame() { # → 毫秒数(没出现 → 9999)
@@ -216,14 +142,15 @@ measure_first_frame() { # → 毫秒数(没出现 → 9999)
216
142
  t0="$(date +%s%3N)"
217
143
  tmux -L "$sock" new-window -d -t "$sess" -n console -c "$neut_root" "$pane_cmd" 2>/dev/null || true
218
144
  # F8: the interactive first frame is measured, not promised — poll the pane for the title band.
219
- for _ in $(seq 1 20); do
145
+ # P316:上限 300s(只防死等);首帧多久都照打,不判快慢。
146
+ for _ in $(seq 1 3000); do
220
147
  sleep 0.1
221
148
  if tmux -L "$sock" capture-pane -p -t "$sess:console" 2>/dev/null | grep -q 'teamsmith pulse'; then
222
149
  ms=$(( $(date +%s%3N) - t0 )); break
223
150
  fi
224
151
  done
225
152
  if [ -z "$ms" ]; then
226
- sleep 1 # one last look before judging it `never`
153
+ sleep 1 # 最后一次确认(没等到才记 never)
227
154
  tmux -L "$sock" capture-pane -p -t "$sess:console" 2>/dev/null | grep -q 'teamsmith pulse' \
228
155
  && ms=$(( $(date +%s%3N) - t0 ))
229
156
  fi
@@ -236,9 +163,9 @@ done
236
163
  first_frame_ms="$(printf '%s\n' "${first_frames[@]}" | sort -n | awk '{a[NR] = $1} END {print a[int((NR + 1) / 2)]}')"
237
164
  for f in "${first_frames[@]}"; do [ "$f" = "9999" ] && ff_never=$((ff_never + 1)); done
238
165
  ff_txt="$(printf '%s ' "${first_frames[@]}" | sed 's/9999/never/g; s/ $//')"
239
- printf '== first frame: %s -> median %s (budget 2000ms)%s ==\n' \
166
+ printf '· 参考 首帧:%s -> 中位 %s%s\n' \
240
167
  "$ff_txt" "$([ "$first_frame_ms" = "9999" ] && echo never || echo "$first_frame_ms")" \
241
- "$([ "$ff_never" -gt 0 ] && printf ' [%s 次 never = 超过轮询预算]' "$ff_never")"
168
+ "$([ "$ff_never" -gt 0 ] && printf ' [%s 次 never = 超过等待视界]' "$ff_never")"
242
169
  sleep 8 # warm-up: Ink startup, the first assembly, the first TTL cycle
243
170
 
244
171
  if [ -n "$detail_flag" ]; then
@@ -286,8 +213,13 @@ if [ -n "$compose_flag" ]; then
286
213
  "$(tmux -L "$sock" capture-pane -p -t "$sess:console" 2>/dev/null | grep -c 'Enter 发送' | tr -d ' ')"
287
214
  fi
288
215
 
289
- time_pid="$(tmux -L "$sock" list-panes -t "$sess:console" -F '#{pane_pid}' 2>/dev/null | head -1)"
290
- pane_pid="$(pgrep -P "${time_pid:-0}" 2>/dev/null | head -1)"
216
+ # 窗格进程树就绪(上限 300s:只防死等,不判启动快慢;P316)
217
+ for _i in $(seq 1 3000); do
218
+ time_pid="$(tmux -L "$sock" list-panes -t "$sess:console" -F '#{pane_pid}' 2>/dev/null | head -1)"
219
+ pane_pid="$(ps -o pid= --ppid "${time_pid:-0}" 2>/dev/null | head -1 | tr -d ' ')" # ps 而不是 pgrep:pgrep 是团队 shim(身份护栏),夹具里读不到子进程
220
+ [ -n "$time_pid" ] && [ -n "$pane_pid" ] && break
221
+ sleep 0.1
222
+ done
291
223
  if [ -z "$time_pid" ] || [ -z "$pane_pid" ]; then
292
224
  printf 'panel-cpu: the console pane did not start (time=%s node=%s)\n' "$time_pid" "$pane_pid" >&2
293
225
  exit 3
@@ -359,34 +291,14 @@ if [ -n "$summary" ]; then
359
291
  tree_avg="$(awk -v u="$user" -v s="$sys" -v e="$elapsed" 'BEGIN{printf "%.3f", (u+s)/e*100}')"
360
292
  fi
361
293
  fi
362
- printf '== pane CPU thirds: %s -> median %s%% (overall %s%% over %ss) of one core · reader tree %s%% ==\n' \
294
+ printf '· 参考 窗格 CPU 三等分:%s -> 中位 %s%%(整窗 %s%%,%ss)· 读进程树 %s%%\n' \
363
295
  "$(printf '%s ' "${sub_pcts[@]}" | sed 's/ $//')" "$pane_avg" "$pane_overall" "$((span_ms / 1000))" "$tree_avg"
364
296
 
365
- # ── P26/G3:前提先于判定。不成立就打印实测三数并退出 4(既不是通过也不是红)。
366
- # 注意:前提一行在**采样前**就打过一次;这里再打一次结果行,让日志尾部自带结论。
367
- # P68:每条结论都带上量测目标与被测 bundle 两个名字(读者不必翻源码就知道数字描述什么)。
297
+ # ── P316:参考读数,不是判定 ────────────────────────────────────────────────────────────
368
298
  pc_target="measured root $neut_root · bundle $panel"
369
- if ! pc_premise >/dev/null 2>&1; then
370
- printf '== load premise: loadavg %s > %s x %s cores -> SKIP (exit 4; the red line was not judged)\n' \
371
- "$(pc_load)" "$PREMISE_FACTOR" "$(pc_cores)" >&2
372
- ff_txt="never appeared" # 顶层语句:不能用 local(只在函数里合法)
373
- [ -n "$first_frame_ms" ] && ff_txt="${first_frame_ms}ms"
374
- printf 'panel-cpu: SKIP — first frame %s, pane CPU %s%%, loadavg %s over the premise (%s x %s cores); the 2000ms / 1%% thresholds are unchanged (%s)\n' \
375
- "$ff_txt" "$pane_avg" "$(pc_load)" "$PREMISE_FACTOR" "$(pc_cores)" "$pc_target" >&2
376
- exit 4
377
- fi
378
-
379
- if [ -z "$first_frame_ms" ]; then
380
- printf 'panel-cpu: RED — the first frame never appeared within 2.1s of the window spawn (%s)\n' "$pc_target" >&2
381
- rc=2
382
- elif [ "$first_frame_ms" -ge 2000 ]; then
383
- printf 'panel-cpu: RED — the interactive first frame took %sms (budget 2000ms, the 2s assembly line) (%s)\n' "$first_frame_ms" "$pc_target" >&2
384
- rc=2
385
- elif awk -v v="$pane_avg" 'BEGIN{exit !(v < 1)}'; then
386
- printf 'panel-cpu: OK — the pane process is under 1%% of one core and the first frame is in budget (%s)\n' "$pc_target"
387
- rc=0
388
- else
389
- printf 'panel-cpu: RED — the pane process is %s%% of one core (red line: <1%%) (%s)\n' "$pane_avg" "$pc_target" >&2
390
- rc=2
391
- fi
392
- exit "$rc"
299
+ ff_txt="never appeared"
300
+ [ -n "$first_frame_ms" ] && ff_txt="${first_frame_ms}ms"
301
+ printf '· 参考 首帧:%s(3 次独立 spawn 的中位)| 窗格 CPU:%s%%(三等分中位)| 树 CPU:%s%%(%s)\n' \
302
+ "$ff_txt" "$pane_avg" "$tree_avg" "$pc_target"
303
+ printf '· 参考 机器:loadavg %s · %s 核 · 采样窗 %ss\n' "$(pc_load)" "$(pc_cores)" "$secs"
304
+ exit 0