@chrono-meta/fh-gate 3.36.1 → 3.38.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.
Files changed (77) hide show
  1. package/.claude-plugin/marketplace.json +4 -4
  2. package/knowledge/shared/harness-core/builtin_capability_map.md +23 -2
  3. package/knowledge/shared/harness-core/claude_md_full_reference.md +7 -0
  4. package/knowledge/shared/harness-core/self_evolution_routine.md +22 -0
  5. package/knowledge/shared/learnings/subagent_invocations_log.yaml +84 -0
  6. package/package.json +9 -1
  7. package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
  8. package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
  9. package/plugins/fh-meta/CHANGELOG.md +30 -0
  10. package/plugins/fh-meta/skills/frontier-digest/SKILL.md +2 -0
  11. package/plugins/fh-meta/skills/frontier-digest/SKILL_detail.md +7 -3
  12. package/plugins/fh-meta/skills/harness-doctor/SKILL.md +1 -0
  13. package/plugins/fh-meta/skills/harvest-loop/SKILL.md +1 -0
  14. package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
  15. package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
  16. package/scripts/adapters/gstack_content_safety.sh +1 -1
  17. package/scripts/capability_effect_probe.sh +2 -2
  18. package/scripts/card_status_tags.sh +47 -0
  19. package/scripts/chamber_run.sh +2 -2
  20. package/scripts/compaction_probe.sh +14 -14
  21. package/scripts/correction_moments.py +116 -0
  22. package/scripts/destructive_pre_gate.sh +25 -2
  23. package/scripts/env_layer_fingerprint.sh +44 -3
  24. package/scripts/fh_session_load.sh +2 -2
  25. package/scripts/frontier_digest_autopilot.sh +10 -0
  26. package/scripts/gate_shape_scan.sh +1 -1
  27. package/scripts/governor_board.sh +2 -2
  28. package/scripts/outbound_pr_gate.sh +1 -1
  29. package/scripts/package_coverage_check.sh +10 -0
  30. package/scripts/pr_merge_verified.sh +8 -1
  31. package/scripts/probe_live_eval.sh +9 -0
  32. package/scripts/probe_live_eval_lib.py +89 -2
  33. package/scripts/residency_admission_check.sh +1 -1
  34. package/scripts/selfcheck.sh +8 -0
  35. package/scripts/selfcheck_shard_weights.txt +184 -0
  36. package/scripts/session_close_check.sh +13 -2
  37. package/scripts/sim_isolated_run.sh +2 -2
  38. package/scripts/test_card_status_tags_lanes.sh +58 -0
  39. package/scripts/test_correction_moments_lanes.sh +42 -0
  40. package/scripts/test_count_check_decl_lanes.sh +1 -1
  41. package/scripts/test_degrade_scan_shell_probes.sh +1 -1
  42. package/scripts/test_destructive_pre_gate_lanes.sh +36 -0
  43. package/scripts/test_dispatch_log_lanes.sh +3 -3
  44. package/scripts/test_env_layer_fingerprint_lanes.sh +6 -1
  45. package/scripts/test_fh_detach_lanes.sh +27 -4
  46. package/scripts/test_fh_qp_lanes.sh +1 -1
  47. package/scripts/test_fh_run_resolver_lanes.sh +4 -4
  48. package/scripts/test_finding_pipeline_lanes.sh +7 -7
  49. package/scripts/test_gate_two_verdicts_lanes.sh +1 -1
  50. package/scripts/test_lane_runner_lanes.sh +1 -1
  51. package/scripts/test_lane_stub_env_lanes.sh +2 -2
  52. package/scripts/test_live_eval_transitions_lanes.sh +32 -0
  53. package/scripts/test_map_postprocess_lanes.sh +1 -1
  54. package/scripts/test_marker_address_lanes.sh +1 -1
  55. package/scripts/test_marker_defense_lanes.sh +1 -1
  56. package/scripts/test_marker_oracle_lanes.sh +1 -1
  57. package/scripts/test_outbound_pr_gate_lanes.sh +1 -1
  58. package/scripts/test_peer_worktree_detect_lanes.sh +1 -1
  59. package/scripts/test_pr_merge_verified_lanes.sh +8 -0
  60. package/scripts/test_precommit_staged_drift_lanes.sh +1 -1
  61. package/scripts/test_preprep_adjacent_dup_lanes.sh +1 -1
  62. package/scripts/test_prepush_destructive_lanes.sh +1 -1
  63. package/scripts/test_probe_live_eval_lanes.sh +68 -1
  64. package/scripts/test_regression_guard_ci_lanes.sh +8 -8
  65. package/scripts/test_regression_guard_codecomment_lanes.sh +140 -0
  66. package/scripts/test_revert_probe_lanes.sh +1 -1
  67. package/scripts/test_selfcheck_shard_lanes.sh +44 -0
  68. package/scripts/test_selfcheck_state_lanes.sh +1 -1
  69. package/scripts/test_stale_ref_close_lanes.sh +1 -1
  70. package/scripts/test_temper_check_lanes.sh +1 -1
  71. package/scripts/test_utterance_intake_lanes.sh +9 -9
  72. package/scripts/test_verdict_watermark_lanes.sh +3 -3
  73. package/scripts/test_worktree_reclaim_lanes.sh +1 -1
  74. package/templates/.git-hooks/pre-commit +2 -2
  75. package/templates/fh_audit_check.zsh +140 -0
  76. package/templates/regression_guard.sh +32 -2
  77. package/templates/settings.PreToolUse.snippet.json +2 -1
@@ -15,7 +15,12 @@ DETACH="$HERE/fh_detach.py"
15
15
  DETAIL="$ROOT/plugins/fh-meta/skills/install-wizard/SKILL_detail.md"
16
16
  T="$(mktemp -d)"
17
17
  trap 'rm -rf "$T"' EXIT
18
- pass=0; fail=0
18
+ pass=0; fail=0; unmeas=0
19
+ # 🟥 미측정은 통과도 실패도 아니다. 전제를 못 만든 레인을 ❌ 로 찍으면 주체를 의심하게
20
+ # 만들고(실측: M5d, 아래), ✅ 로 찍으면 공허한 초록이 된다. 세 번째 칸을 둔다.
21
+ unmeasured() { # unmeasured <name> <why>
22
+ unmeas=$((unmeas+1)); printf ' ⬜ %-58s %s\n' "$1" "$2 — 미측정, 통과 아님"
23
+ }
19
24
  chk() { # chk <name> <got> <want>
20
25
  if [ "$2" = "$3" ]; then pass=$((pass+1)); printf ' ✅ %-58s %s\n' "$1" "$2"
21
26
  else fail=$((fail+1)); printf ' ❌ %-58s got=%s want=%s\n' "$1" "$2" "$3"; fi
@@ -274,7 +279,21 @@ chk "M5c … with --machine the same file is an error (rc 10)" "$(detach_p "$W"
274
279
  W="$T/w17"; mkworld "$W"; install "$W"
275
280
  mkdir -p "$W/proj/.claude" && git -C "$W/proj" init -q && cp "$W/hub/.claude/settings.json" "$W/proj/.claude/settings.json"
276
281
  chmod 000 "$W/hub/.claude/settings.json"
277
- chk "M5d an unreadable FH-clone settings file: project detach rc 0 · --machine rc 10" "$(detach_p "$W" "$W/proj" --apply)/$(detach_p "$W" "$W/proj" --machine)" "0/10"
282
+ # 🟥 `chmod 000` 은 root 를 묶지 않는다 — **이 파일 자신이 그것을 이미 적는다**(아래 M6 줄의
283
+ # «chmod 000 does not bind root — codex»). 그 지적이 이웃 레인에만 반영되고 이 레인에는
284
+ # 안 반영된 절반 수리였다. 전제가 안 걸리면 파일이 그냥 읽히고, 주체는 올바르게 rc 0 을
285
+ # 내는데 레인은 `got=0/0 want=0/10` 을 찍는다 — 읽는 사람을 `fh_detach.py` 로 보낸다.
286
+ # 실측 2026-11-02, 같은 트리·같은 스위트·uid 만 바꿈: root → 61 passed · 1 failed(M5d ❌)
287
+ # / `setpriv --reuid=65534` → **62 passed · 0 failed**(M5d ✅ `0/10`). 즉 주체는 성하다.
288
+ # 그러니 이 자리는 수리할 결함이 아니라 **못 쟀다고 말해야 하는 칸**이다. CI 는 비-root 라
289
+ # 거기서는 그대로 측정된다. ⚠️ 전제를 «얻는» 길(이 두 호출만 권한 내려 돌리기)은 택하지
290
+ # 않았다 — `$T` 는 mktemp 의 0700 이라 통과 자체가 안 되고, 통과시키면 주체 프로세스의 uid
291
+ # 가 바뀌어 레인이 재는 것이 달라진다. 이름으로 남기고 고치지 않는다.
292
+ if cat "$W/hub/.claude/settings.json" >/dev/null 2>&1; then
293
+ unmeasured "M5d an unreadable FH-clone settings file" "chmod 000 이 이 uid($(id -u)) 를 묶지 않았다"
294
+ else
295
+ chk "M5d an unreadable FH-clone settings file: project detach rc 0 · --machine rc 10" "$(detach_p "$W" "$W/proj" --apply)/$(detach_p "$W" "$W/proj" --machine)" "0/10"
296
+ fi
278
297
  chmod 644 "$W/hub/.claude/settings.json"
279
298
  W="$T/w18"; mkworld "$W"; install "$W"
280
299
  mkdir -p "$W/proj/.claude" && git -C "$W/proj" init -q && cp "$W/hub/CLAUDE.local.md" "$W/proj/CLAUDE.local.md"
@@ -298,5 +317,9 @@ chk "W3 install-wizard SKILL.md names --machine" "$(grep -c 'fh_detach.py" --pr
298
317
  chk "W2 install-wizard SKILL.md points at the detach command" "$(grep -q 'scripts/fh_detach.py" --project . --apply' "$ROOT/plugins/fh-meta/skills/install-wizard/SKILL.md" && echo yes)" yes
299
318
 
300
319
  echo
301
- echo "fh_detach lanes: $pass passed · $fail failed"
302
- [ "$fail" -eq 0 ]
320
+ echo "fh_detach lanes: $pass passed · $fail failed · $unmeas unmeasured"
321
+ if [ "$unmeas" -gt 0 ] && [ "$fail" -eq 0 ]; then
322
+ # 통과로 접지 않는다. 같은 판정을 test_mutation_probe_lanes.sh 가 쓰는 문구로 낸다.
323
+ echo "INCOMPLETE fh_detach: $unmeas 레인이 전제를 못 만들어 안 돌았다 — 통과 아님"
324
+ fi
325
+ [ "$fail" -eq 0 ] && [ "$unmeas" -eq 0 ]
@@ -81,7 +81,7 @@ if [ -f "$FH/scripts/residency_closure_scan.py" ]; then
81
81
  out="$(cd "$FH" && python3 scripts/residency_closure_scan.py --files $FILES 2>&1)"; rc=$?
82
82
  case "$rc" in
83
83
  0) PASS=$((PASS+1)); echo " ✅ RES-closure-scan CLEAN ($(printf '%s' "$FILES" | wc -l | tr -d ' ') files)" ;;
84
- 10) if printf '%s' "$out" | grep -q '운영자 패턴 파일이 없다'; then
84
+ 10) if printf '%s' "$out" | grep -c '운영자 패턴 파일이 없다' >/dev/null; then
85
85
  # CI and consumer clones structurally lack the operator override (gitignored). That is
86
86
  # UNMEASURED, not a failure of the shipped files — the generic RES-zero-constant-grep lane
87
87
  # below is the guarantee that travels; this lane measures only where the override exists.
@@ -51,7 +51,7 @@ ng(){ printf ' ❌ %s\n' "$1"; FAIL=$((FAIL+1)); }
51
51
  # 더 쓸모 있는 순서는 해석이 먼저지만, 그건 이 PR 의 범위가 아니라 별건이다.
52
52
  resolve(){
53
53
  FH_DRY_RUN=1 _ttl 60 bash "$HERE/scripts/fh-run.sh" --backend codex --skill "$1" 2>&1 \
54
- | /usr/bin/grep -oE 'plugins/[A-Za-z0-9_-]+/skills/[A-Za-z0-9_.-]+/SKILL\.md' | head -1
54
+ | /usr/bin/grep -oE 'plugins/[A-Za-z0-9_-]+/skills/[A-Za-z0-9_.-]+/SKILL\.md' | sed -n 1p
55
55
  }
56
56
 
57
57
  echo "== 이름만으로 어느 플러그인이든 닿나 =="
@@ -81,7 +81,7 @@ fi
81
81
  echo
82
82
  echo "== 우선순위가 안 뒤집혔나 (일반화의 대가) =="
83
83
  # fh-meta 에 실재하는 이름은 여전히 fh-meta 로 가야 한다.
84
- M=$(ls plugins/fh-meta/skills 2>/dev/null | head -1)
84
+ M=$(ls plugins/fh-meta/skills 2>/dev/null | sed -n 1p)
85
85
  if [ -n "$M" ]; then
86
86
  R=$(resolve "$M")
87
87
  case "$R" in
@@ -91,7 +91,7 @@ if [ -n "$M" ]; then
91
91
  else
92
92
  ng "F4 fh-meta 스킬을 못 찾았다 — 계기 오류(레포가 헐었거나 경로가 틀렸다)"
93
93
  fi
94
- C=$(ls plugins/fh-commons/skills 2>/dev/null | head -1)
94
+ C=$(ls plugins/fh-commons/skills 2>/dev/null | sed -n 1p)
95
95
  if [ -n "$C" ]; then
96
96
  R=$(resolve "$C")
97
97
  case "$R" in
@@ -119,7 +119,7 @@ echo "== 백엔드 바이너리가 없는 환경에서도 같은 답인가 (CI
119
119
  # 로컬에서도 빨갰고, 그게 사실은 «이 레인이 계기 고장을 잡았다»는 증거다.
120
120
  R7=$(_ttl 60 env PATH=/usr/bin:/bin FH_DRY_RUN=1 bash "$HERE/scripts/fh-run.sh" \
121
121
  --backend codex --skill preprep 2>&1 \
122
- | /usr/bin/grep -oE 'plugins/[A-Za-z0-9_-]+/skills/[A-Za-z0-9_.-]+/SKILL\.md' | head -1)
122
+ | /usr/bin/grep -oE 'plugins/[A-Za-z0-9_-]+/skills/[A-Za-z0-9_.-]+/SKILL\.md' | sed -n 1p)
123
123
  case "${R7}" in
124
124
  plugins/fh-preprep/skills/preprep/SKILL.md) ok "F7 백엔드 바이너리 0개인 환경에서도 해석된다 (CI 와 같은 답)" ;;
125
125
  "") ng "F7 백엔드 없는 환경에서 해석 실패 — 이 레인은 로컬 전용이다(= CI 에서 빨개진다)" ;;
@@ -419,7 +419,7 @@ bash "$PIPE" "$D/s4.py" --out "$D/o34" --fleet "$D/fleet.tbl" >/dev/null 2>&1; R
419
419
  # L35 (A7) — 프롬프트 파일은 소스 전문을 담는다. 다른 계정이 읽으면 안 된다
420
420
  printf 'x = 1\n' > "$D/s7.py"
421
421
  FH_CODEX_BIN=/bin/true bash "$HERE/finding_fleet.sh" "$D/s7.py" --out "$D/o35" --fleet "$D/fleetS1.tbl" >/dev/null 2>&1
422
- PF=$(ls "$D/o35"/prompt_*.txt 2>/dev/null | head -1)
422
+ PF=$(ls "$D/o35"/prompt_*.txt 2>/dev/null | sed -n 1p)
423
423
  if [ -n "$PF" ]; then
424
424
  MODE=$(/usr/bin/stat -f "%OLp" "$PF" 2>/dev/null || /usr/bin/stat -c "%a" "$PF" 2>/dev/null)
425
425
  case "$MODE" in *[04]|*[04][04]) OTHERS_R=1;; *) OTHERS_R=0;; esac
@@ -531,7 +531,7 @@ else
531
531
  # 🟥 «coverage= 가 없다» 만 보면 **크래시한 뮤턴트도 통과**한다 — 없는 이유가 «지웠기 때문» 인지
532
532
  # «안 돌았기 때문» 인지 안 갈린다(cross-family 지적 2026-09-09, 항목 5). 그래서 뮤턴트가
533
533
  # «정상 종료 + FINDINGS 줄을 냈다» 를 먼저 요구하고, 그 다음에 coverage 부재를 본다.
534
- if [ "$MRC" -ne 0 ] || ! printf '%s' "$MO" | /usr/bin/grep -q '^FINDINGS '; then
534
+ if [ "$MRC" -ne 0 ] || ! printf '%s' "$MO" | /usr/bin/grep -c '^FINDINGS ' >/dev/null; then
535
535
  no "L44 되돌림" "뮤턴트가 정상 실행되지 않았다(rc=$MRC) — coverage 부재를 «지웠기 때문» 으로 읽을 수 없다"
536
536
  elif printf '%s' "$MO" | /usr/bin/grep -q 'coverage='; then
537
537
  no "L44 되돌림" "coverage 를 지웠는데도 출력에 남아 있다 — 앵커가 다른 곳을 잰다"
@@ -899,7 +899,7 @@ else
899
899
  no "L60 종단간 씨앗" "rc=$R60 want=5 · $(grep -m1 '^PIPELINE ' "$D/pSEED") · $(tail -2 "$D/pSEED")"
900
900
  fi
901
901
  # L61 배선 검사(행동 아님, 그렇게 라벨한다) — COUNT_ERR 이 실제로 소비되나
902
- if /usr/bin/grep -q 'COUNT_ERR' "$PIPE" && /usr/bin/grep -A6 'if \[ "\$COUNT_ERR" -ne 0 \]' "$PIPE" | /usr/bin/grep -q 'note_rc'; then
902
+ if /usr/bin/grep -q 'COUNT_ERR' "$PIPE" && /usr/bin/grep -A6 'if \[ "\$COUNT_ERR" -ne 0 \]' "$PIPE" | /usr/bin/grep -c 'note_rc' >/dev/null; then
903
903
  ok "L61 배선: 계측 오류 플래그가 실제로 note_rc 로 소비된다 (🟡 배선 검사지 행동 검사가 아니다)"
904
904
  else
905
905
  no "L61 배선" "COUNT_ERR 이 설정만 되고 rc 에 반영되지 않는다 — 조용한 계측 실패다"
@@ -1237,7 +1237,7 @@ if /usr/bin/grep -q '_ROSTER_N=$(/usr/bin/grep -c . "$ROSTER"' "$PIPE" \
1237
1237
  && ! /usr/bin/grep -q '! -s "$ROSTER"' "$PIPE"; then
1238
1238
  ok "L75b 드라이버가 명부를 «계열 수» 로 판정한다 (-s 가 사라졌다 — 🟡 배선 검사)"
1239
1239
  else
1240
- no "L75b 명부 판정 배선" "$(/usr/bin/grep -n 'ROSTER_N\|-s \"\$ROSTER\"' "$PIPE" | head -3)"
1240
+ no "L75b 명부 판정 배선" "$(/usr/bin/grep -n 'ROSTER_N\|-s \"\$ROSTER\"' "$PIPE" | sed -n '1,3p')"
1241
1241
  fi
1242
1242
 
1243
1243
  # L76 🟥 «전부 스스로 내림» 은 계약 준수지 «차단» 이 아니다
@@ -1292,7 +1292,7 @@ _K79=$(for d in "$D"/pk/split_*; do /usr/bin/grep -lq 'tokens used' "$d"/err.txt
1292
1292
  if [ "$_N79" -ge 2 ] && [ "$_K79" = "$_N79" ]; then
1293
1293
  ok "L79 검증 패스 stderr 가 «split 마다» 남는다 ($_K79/$_N79 — 첫 디렉터리로 몰리지 않는다)"
1294
1294
  else
1295
- no "L79 검증 stderr 보존" "split=$_N79 keep=$_K79 · $(ls "$D"/pk/split_* 2>/dev/null | head -3)"
1295
+ no "L79 검증 stderr 보존" "split=$_N79 keep=$_K79 · $(ls "$D"/pk/split_* 2>/dev/null | sed -n '1,3p')"
1296
1296
  fi
1297
1297
 
1298
1298
  # ── L80~L84 cross-family R2 (codex, 2026-09-10 21:45) — 2차 병합·명부 파서의 남은 구멍 ─────────
@@ -1390,7 +1390,7 @@ A84=$(/usr/bin/grep -l 'tokens used AUDIT' "$D"/f84/split_*/keep_audit/err.txt
1390
1390
  if [ "$V84" -ge 1 ] && [ "$A84" -ge 1 ]; then
1391
1391
  ok "L84 🟥 검증 keep($V84) 과 감사 keep($A84) 이 갈라져 있다 — 드롭 런에서 검증 토큰 회계가 살아남는다"
1392
1392
  else
1393
- no "L84 keep 분리" "verify=$V84 audit=$A84 · $(ls -d "$D"/f84/split_*/keep_* 2>/dev/null | head -3)"
1393
+ no "L84 keep 분리" "verify=$V84 audit=$A84 · $(ls -d "$D"/f84/split_*/keep_* 2>/dev/null | sed -n '1,3p')"
1394
1394
  fi
1395
1395
 
1396
1396
  # ══ R3 (cross-family, codex 2026-09-11 03:00) — 9 findings, each with a known pair ══
@@ -1741,7 +1741,7 @@ printf 'codex|logic|sh %s\n' "$D/m_alias_only.sh" > "$D/f107.tbl"; bash "$FL" "$
1741
1741
  if [ -s "$D/f107/findings.jsonl" ] && ! /usr/bin/grep -q 'seed-never-emitted' "$D/f107/findings.jsonl"; then
1742
1742
  ok "L107 🟥 R6#4 응답의 member_id 는 버려진다(발견은 살아 있음)"
1743
1743
  else
1744
- no "L107 member_id 신뢰" "$(cat "$D/f107/findings.jsonl" 2>/dev/null | head -1 | cut -c1-120)"
1744
+ no "L107 member_id 신뢰" "$(cat "$D/f107/findings.jsonl" 2>/dev/null | sed -n 1p | cut -c1-120)"
1745
1745
  fi
1746
1746
  # L108 🟥 R6 #5: keep 루트 `link/.` · `link//.` 도 거부
1747
1747
  E108=$(bash "$VERIFIER" --family codex --target "$D/x_t.py" --keep "$D/keep_link/." 2>&1 </dev/null); R108=$?
@@ -87,7 +87,7 @@ lane L9b-tier-paren-kept "standpoint: tier2(qasp) — 명령과 출력" "standp
87
87
 
88
88
  # L8b 잘린 값이 «그대로» 새어나오지 않는지 직접 확인 (needle 부재를 단언)
89
89
  printf 'thirdparty: checked(확인한 것 = x)\n' > "$T/p.marker"
90
- if run "$T/p.marker" | grep -qF 'checked(확인한'; then
90
+ if run "$T/p.marker" | grep -cF 'checked(확인한' >/dev/null; then
91
91
  echo " ❌ L8b 잘린 괄호 문자열이 아직 출력에 있다"; FAIL=1
92
92
  else
93
93
  echo " ✅ L8b 잘린 괄호 문자열은 출력에 없다"
@@ -385,7 +385,7 @@ rm -f "$_ISN"
385
385
 
386
386
  # The note must fire on the FAIL path — a function nothing calls is the very defect this file names.
387
387
  if sed -n '/lane suite(s) with no runner and no declaration/,/Fix by ONE of/p' "$CHECK" \
388
- | grep -q 'index_source_note'; then
388
+ | grep -c 'index_source_note' >/dev/null; then
389
389
  ok "IDX6 the note is CALLED on the FAIL path (not just defined)"
390
390
  else
391
391
  bad "IDX6 index_source_note is defined but the FAIL path does not call it"
@@ -24,7 +24,7 @@ leaks() { # $1=검색 루트 → 허용 목록·예외 밖에서 lane_stub_env
24
24
  /usr/bin/grep -qxF "$rel" "$ALLOW" && continue
25
25
  if [ "$rel" = scripts/selfcheck.sh ] || [ "$b" = selfcheck.sh ]; then # 레인 등록부 줄만 허용
26
26
  # 줄 «전체» 가 등록부 문법이어야 한다 — 뒤에 `; . lane_stub_env.sh` 를 붙인 줄은 누출 (codex 구현 R2 A2)
27
- /usr/bin/grep 'lane_stub_env' "$f" | /usr/bin/grep -vqE '^[[:space:]]*"scripts/lane_(stub_env\.(sh|allow)|onoff_compare\.py)\|scripts/test_lane_stub_env_lanes\.sh"[[:space:]]*\\?$' || continue
27
+ [ "$(/usr/bin/grep 'lane_stub_env' "$f" | /usr/bin/grep -vcE '^[[:space:]]*"scripts/lane_(stub_env\.(sh|allow)|onoff_compare\.py)\|scripts/test_lane_stub_env_lanes\.sh"[[:space:]]*\\?$')" -ge 1 ] || continue # count, not -q: pipefail early-exit (class-lock)
28
28
  fi
29
29
  echo "$f"
30
30
  done
@@ -176,7 +176,7 @@ printf '✅ premise: card.md=2026-10-12 14:38:18 vs log.md=2000-01-01 00:00:00\n
176
176
  printf '✅ premise: card.md=2026-10-13 09:01:40 vs log.md=2000-01-01 00:00:00\n' > "$T/c_on"
177
177
  [ "$(cmpf)" = 1 ] && ok "C13 정규화 없음: 픽스처 파일 시각이 다르면 선언 없이는 DIFFERENT" || ng "C13 계기가 스스로 정규화한다"
178
178
  [ "$(cmpf --volatile '^✅ premise:')" = 0 ] && ok "C13b 휘발 선언(--volatile)한 줄만 빼고 SAME" || ng "C13b 휘발 선언이 안 듣는다"
179
- python3 "$CMP" files "$T/c_off" "$T/c_rcoff" "$T/c_on" "$T/c_rcon" --volatile '^✅ premise:' 2>&1 | /usr/bin/grep -q '^UNMEASURED 휘발 선언 줄 off×1 on×1' \
179
+ [ "$(python3 "$CMP" files "$T/c_off" "$T/c_rcoff" "$T/c_on" "$T/c_rcon" --volatile '^✅ premise:' 2>&1 | /usr/bin/grep -c '^UNMEASURED 휘발 선언 줄 off×1 on×1')" -ge 1 ] \
180
180
  && ok "C13c 휘발 선언 줄은 UNMEASURED 로 보고된다(조용히 같다고 하지 않는다)" || ng "C13c 휘발 줄이 보고되지 않는다"
181
181
  printf '✅ x\n✅ premise: a=2026-10-12 14:38:18\n' > "$T/c_off" # 휘발 줄 «수» 만 다르다 — 나머지 줄은 같게
182
182
  printf '✅ x\n✅ premise: a=2026-10-12 14:38:18\n✅ premise: b=2026-10-12 14:38:19\n' > "$T/c_on"
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env bash
2
+ # Lanes for probe_live_eval_lib.transitions / render_transitions_line («moved since previous», record only).
3
+ # Known pair: a probe that flipped must be listed; identical runs say «none». The two shapes that must NOT read as «none»:
4
+ # a previous report that lacks some current probes (not comparable) and no previous report at all (not supplied).
5
+ set -u
6
+ FH="$(cd "$(dirname "$0")/.." && pwd)"
7
+ out=$(python3 - "$FH/scripts" <<'PY'
8
+ import sys
9
+ sys.path.insert(0, sys.argv[1])
10
+ import probe_live_eval_lib as L
11
+ rows = [{'id': 'G-A', 'verdict': 'PASS'}, {'id': 'G-B', 'verdict': 'FAIL'}, {'id': 'G-C', 'verdict': 'PASS'}]
12
+ def show(name, tr, prev='live_eval_2026-11-02.md'):
13
+ print(name, tr['status'], '|', L.render_transitions_line(tr, prev))
14
+ show('T1', L.transitions(rows, {'G-A': 'PASS', 'G-B': 'PASS', 'G-C': 'PASS'}))
15
+ show('T2', L.transitions(rows, {'G-A': 'PASS', 'G-B': 'FAIL', 'G-C': 'PASS'}))
16
+ show('T3', L.transitions(rows, {'G-A': 'PASS', 'G-B': 'FAIL'}))
17
+ show('T4', L.transitions(rows, None), '')
18
+ show('T5', L.transitions(rows, {'G-A': 'FAIL', 'G-B': 'FAIL'}))
19
+ PY
20
+ )
21
+ rc=$?
22
+ pass=0; fail=0
23
+ lane() { if printf '%s\n' "$out" | grep -q -E "$2"; then echo "PASS $1"; pass=$((pass+1)); else echo "FAIL $1"; fail=$((fail+1)); fi; }
24
+ [ "$rc" = 0 ] || { echo "FAIL harness — python rc=$rc"; printf '%s\n' "$out"; exit 1; }
25
+ lane T1-flip-listed '^T1 moved \| moved since previous \(live_eval_2026-11-02.md\): G-B PASS->FAIL$'
26
+ lane T2-identical-none '^T2 none \| moved since previous \(live_eval_2026-11-02.md\): none$'
27
+ lane T3-narrower-not-none '^T3 not-comparable \| .*not comparable \(1 probes absent from previous\)$'
28
+ lane T4-no-prev '^T4 not-supplied \| moved since previous: not supplied \(no prior report found\)$'
29
+ lane T5-flip-plus-absent '^T5 moved \| .*G-A FAIL->PASS \(absent from previous: G-C\)$'
30
+ printf '%s\n' "$out" | sed 's/^/ /'
31
+ echo "live-eval transitions lanes: $pass pass · $fail fail"
32
+ [ "$fail" -eq 0 ]
@@ -147,7 +147,7 @@ for f in docs/map/*.html; do
147
147
  [ -f "$f" ] || continue
148
148
  case "$f" in *.visual-check.html) continue;; esac
149
149
  SHIPPED_N=$((SHIPPED_N+1))
150
- python3 "$S" --check "$f" 2>/dev/null | /usr/bin/grep -q '^PATCHED' || { SHIPPED_OK=0; echo " ✗ $f not patched"; }
150
+ python3 "$S" --check "$f" 2>/dev/null | /usr/bin/grep -c '^PATCHED' >/dev/null || { SHIPPED_OK=0; echo " ✗ $f not patched"; }
151
151
  done
152
152
  if [ "$SHIPPED_N" -eq 0 ]; then
153
153
  ng "L9 no docs/map/*.html found — nothing measured (NOT a pass)"
@@ -57,7 +57,7 @@ o=$(unread_markers "" "$ADDR")
57
57
 
58
58
  # L4 — THE ADVISORY MUST NOT BLOCK. Pinned in the source, because the whole design rests on it:
59
59
  # a blocking version would push authors to write FEWER records, inverting the intent.
60
- if sed -n '/_MK_UNREAD=/,/^ fi$/p' "$HOOK" | grep -qE 'FAILED=1|exit 1'; then
60
+ if sed -n '/_MK_UNREAD=/,/^ fi$/p' "$HOOK" | grep -cE 'FAILED=1|exit 1' >/dev/null; then
61
61
  no "L4 the unread-marker advisory sets FAILED/exit — it must stay advisory"
62
62
  else
63
63
  ok "L4 the unread-marker advisory never blocks"
@@ -118,7 +118,7 @@ else
118
118
  fi
119
119
  # and that the call is gated on the floor tiers the doc claims — not on load-bearing, which is
120
120
  # where it was first (wrongly) wired.
121
- if grep -B4 'validate_defense_leg "\$MARKER"' "$HOOK" | grep -qE 'floor-status:.*sonnet-floor\|below-floor'; then
121
+ if grep -B4 'validate_defense_leg "\$MARKER"' "$HOOK" | grep -cE 'floor-status:.*sonnet-floor\|below-floor' >/dev/null; then
122
122
  printf ' ✅ %-6s %s\n' "call" "call is gated on floor-status (sonnet-floor|below-floor)"; pass=$((pass+1))
123
123
  else
124
124
  printf ' ❌ %-6s %s\n' "call" "call is NOT gated on floor-status — scope drifted from the doc"; fail=$((fail+1))
@@ -124,7 +124,7 @@ echo
124
124
  echo "== 실물 코퍼스 대조 (있으면) =="
125
125
  # 실물 마커에 oracle: 가 아직 없는 것이 정상이다 — 이 필드는 오늘 신설이다. 부재 마커도 여전히
126
126
  # PASS 여야 한다는 것을 실물로도 한 번 더 확인한다(계기가 실물 코퍼스에서도 안 죽는가).
127
- _real=$(ls -t "$REPO_ROOT"/tracks/_meta/.axes_23_passed_*.marker 2>/dev/null | head -1)
127
+ _real=$(ls -t "$REPO_ROOT"/tracks/_meta/.axes_23_passed_*.marker 2>/dev/null | sed -n 1p)
128
128
  if [ -n "$_real" ] && [ -f "$_real" ]; then
129
129
  lane "R1-real-corpus-$(basename "$_real" | cut -c1-24)" PASS "$(cat "$_real")"
130
130
  else
@@ -213,7 +213,7 @@ ENUM2=$(awk '/^validate_standpoint_leg\(\)/{f=1} f&&/^}/{f=0} f' "$FAKEPC" 2>/de
213
213
  | grep -E '^[A-Za-z]' | sort -u)
214
214
  DECLARED2=$( { grep -m1 '^STRONG_RUNGS=' "$GATE"; grep -m1 '^WEAK_RUNGS=' "$GATE"; } \
215
215
  | sed -E 's/^[A-Z_]+="//; s/"$//' | tr ' ' '\n' | grep -E '^[A-Za-z]' | sort -u)
216
- if printf '%s\n' "$(comm -23 <(printf '%s\n' "$ENUM2") <(printf '%s\n' "$DECLARED2"))" | grep -qx 'tier4'; then
216
+ if printf '%s\n' "$(comm -23 <(printf '%s\n' "$ENUM2") <(printf '%s\n' "$DECLARED2"))" | grep -cx 'tier4' >/dev/null; then
217
217
  echo "PASS L8b class-closing arm goes RED when an enum member is added"
218
218
  else
219
219
  echo "FAIL L8b class-closing arm did NOT notice an added enum member — L8 green means nothing"
@@ -55,7 +55,7 @@ for p in $PIDS; do touch "$TMP/socks/$p.sock"; done
55
55
  _cwd_of() {
56
56
  if [ -r "/proc/$1/cwd" ]; then readlink "/proc/$1/cwd" 2>/dev/null; return; fi
57
57
  command -v lsof >/dev/null 2>&1 || return 0
58
- lsof -a -p "$1" -d cwd -Fn 2>/dev/null | sed -n 's/^n//p' | head -1
58
+ lsof -a -p "$1" -d cwd -Fn 2>/dev/null | sed -n 's/^n//p' | sed -n 1p
59
59
  }
60
60
  C_MAIN=$(_cwd_of "$P_MAIN"); C_WT=$(_cwd_of "$P_WT"); C_OTHER=$(_cwd_of "$N_OTHER")
61
61
  if [ -z "$C_MAIN" ] || [ -z "$C_WT" ] || [ -z "$C_OTHER" ]; then
@@ -227,5 +227,13 @@ if [ "$(id -u)" -eq 0 ]; then ok "L31 SKIP (root can write anywhere) — not a p
227
227
  else { [ "$RC" -eq 0 ] && printf '%s' "$OUT" | grep -q 'WARNING: completion record NOT written' && printf '%s' "$OUT" | grep -q 'merged and verified'; } \
228
228
  && ok "L31 unwritable tracks/_meta → warning, rc=0 unchanged" || { bad "L31 rc=$RC"; printf '%s\n' "$OUT" | tail -3; }; fi
229
229
 
230
+ # L32 --expect-head (selfdev_loop.sh, 2026-11-04): a head other than the one the caller checked → rc=2 BEFORE
231
+ # the merge; the matching head (control) merges as usual
232
+ setup eh; mkgh "$T/eh"; run "$T/eh" 7 --rerun "$GOOD" --expect-head 0000000000000000000000000000000000000000
233
+ { [ "$RC" -eq 2 ] && ! merged "$T/eh" && printf '%s' "$OUT" | grep -q 'not the checked'; } \
234
+ && ok "L32a --expect-head mismatch → rc=2, merge never called" || { bad "L32a rc=$RC merged=$(merged "$T/eh" && echo yes || echo no)"; printf '%s\n' "$OUT" | tail -3; }
235
+ setup eh2; mkgh "$T/eh2"; run "$T/eh2" 7 --rerun "$GOOD" --expect-head "$(cat "$T/eh2/head.oid")"
236
+ { [ "$RC" -eq 0 ] && merged "$T/eh2"; } && ok "L32b --expect-head matching → merged and verified" || { bad "L32b rc=$RC"; printf '%s\n' "$OUT" | tail -3; }
237
+
230
238
  printf 'PASS %d · FAIL %d\n' "$PASS" "$FAIL"
231
239
  [ "$FAIL" -eq 0 ]
@@ -64,7 +64,7 @@ o=$(staged_worktree_drift "" "a.sh")
64
64
 
65
65
  # L5 — THE GATE MUST NOT BLOCK. Pinned as a lane because the whole design rests on it: a blocking
66
66
  # version would fire on legitimate hunk staging and train `--no-verify`.
67
- if grep -A14 '^_DRIFT=' "$HOOK" | grep -qE 'FAILED=1|exit 1'; then
67
+ if grep -A14 '^_DRIFT=' "$HOOK" | grep -cE 'FAILED=1|exit 1' >/dev/null; then
68
68
  no "L5 the drift gate sets FAILED/exit — it must stay advisory"
69
69
  else
70
70
  ok "L5 the drift gate never blocks (advisory by construction)"
@@ -47,7 +47,7 @@ g(){ python3 -c "import json,sys;d=json.loads(sys.argv[1]);print(d[sys.argv[2]][
47
47
  # 🟥 J4 의 초판은 glob `*%*자*` 였는데 **되돌림 프로브가 그걸 뚫었다** — 숫자를 지워도 남은
48
48
  # 문자열에 «자» 와 «%» 가 우연히 들어 있어 통과했다. 장식 앵커였다.
49
49
  # 지금은 «숫자 + 단위» 를 정규식으로 요구한다: `NN자` 와 `NN%` 가 둘 다 있어야 한다.
50
- if printf '%s' "$(g pos msg)" | grep -qE '[0-9]+자' && printf '%s' "$(g pos msg)" | grep -qE '[0-9]+%'; then
50
+ if printf '%s' "$(g pos msg)" | grep -cE '[0-9]+자' >/dev/null && printf '%s' "$(g pos msg)" | grep -cE '[0-9]+%' >/dev/null; then
51
51
  ok "J4 처방: «NN자»·«NN%» 를 실제 숫자로 낸다"
52
52
  else
53
53
  ng "J4 실패 — 숫자 없는 지적은 처방이 아니다: $(g pos msg)"
@@ -86,7 +86,7 @@ WORK="$(fh_fixture_root "$(mktemp -d)")" || exit 1
86
86
  : "${WORK:?fixture root unset — refusing to run git in cwd}"
87
87
  trap 'rm -rf "$WORK"' EXIT
88
88
  _status=$(git -C "$REPO_ROOT" -c core.quotePath=false diff --cached --name-status --no-renames 2>/dev/null \
89
- | awk -F'\t' '$2 == "templates/.git-hooks/pre-push" { print $1; exit }')
89
+ | awk -F'\t' '$2 == "templates/.git-hooks/pre-push" && !d { print $1; d = 1 }') # reads to EOF (pipefail-safe)
90
90
  case "$_status" in
91
91
  D) echo "❌ FAIL — pre-push is being DELETED from the index — fail-closed."; exit 1 ;;
92
92
  '') cp "$HOOK_SRC" "$WORK/hook" ;;
@@ -677,7 +677,7 @@ EVROOT="$T/evidence_root"
677
677
  FH_LIVE_EVAL_EVIDENCE_ROOT="$EVROOT" \
678
678
  bash "$RUNNER" --ids "G-GREET-01,G-TRIG-07" --report-out "$T/ev_report.md" ) >"$T/ev.log" 2>&1
679
679
 
680
- ev_day="$(find "$EVROOT" -mindepth 1 -maxdepth 1 -type d 2>/dev/null | head -1)"
680
+ ev_day="$(find "$EVROOT" -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sed -n 1p)"
681
681
  _lane EV1 evidence "a run creates a dated evidence dir under the evidence root" \
682
682
  "yes" "$([ -n "$ev_day" ] && echo yes || echo no)"
683
683
 
@@ -839,6 +839,73 @@ PY
839
839
  _lane TG6 target "narrower --before -> 'not comparable', never 'none'" \
840
840
  "others moved: not comparable (2 others absent from before)" "$r"
841
841
 
842
+ # ── instrument lanes (2026-11-05, AQ-20261105-1) ─────────────────────────────────────────────
843
+ # The report's «Instrument» line carries git blob ids of runner · scorer · probes_live.yaml so two
844
+ # dated reports can be told apart mechanically: «did the target move, or did the instrument?».
845
+ # Record only — no verdict reads it. Known pair: IF1 (real files → equals `git hash-object`) vs
846
+ # IF2 (unreadable file → UNKNOWN, never dropped). IF3: the run-table reader still ignores it.
847
+ # IF4: an FH_SIM_RUNNER_BIN stub is fingerprinted as sim_runner(override), never as the live runner.
848
+ if [ -e "$REPO_ROOT/.git" ] && command -v git >/dev/null 2>&1; then
849
+ r="$(env -u FH_SIM_RUNNER_BIN python3 - "$REPO_ROOT" "$PROBES_LIVE" <<'PY'
850
+ import sys, os, subprocess
851
+ sys.path.insert(0, os.path.join(sys.argv[1], 'scripts'))
852
+ from probe_live_eval_lib import instrument_fingerprint
853
+ paths = {'runner': os.path.join(sys.argv[1], 'scripts', 'probe_live_eval.sh'),
854
+ 'scorer': os.path.join(sys.argv[1], 'scripts', 'probe_live_eval_lib.py'),
855
+ 'probes': sys.argv[2],
856
+ 'sim_runner': os.path.join(sys.argv[1], 'scripts', 'sim_isolated_run.sh')}
857
+ fp = instrument_fingerprint(sys.argv[2])
858
+ names = [n for n, _ in fp]
859
+ if names != ['runner', 'scorer', 'probes', 'sim_runner']: # an empty/partial list must not read as «match»
860
+ print('names:' + ','.join(names)); sys.exit(0)
861
+ bad = [n for n, s in fp
862
+ if s != subprocess.check_output(['git', 'hash-object', '--no-filters', paths[n]]).decode().strip()]
863
+ print('match' if not bad else 'mismatch:' + ','.join(bad))
864
+ PY
865
+ )"
866
+ _lane IF1 instrument "fingerprint == git hash-object for runner/scorer/probes/sim_runner" "match" "$r"
867
+ else
868
+ printf ' ⏭️ SKIP (PASS 아님 · no .git or no git binary — nothing to compare against) — IF1\n'
869
+ SKIPPED_BLOCKS="$SKIPPED_BLOCKS [IF1 no-git]"
870
+ fi
871
+ r="$(env -u FH_SIM_RUNNER_BIN python3 - "$REPO_ROOT" <<'PY'
872
+ import sys, os, re
873
+ sys.path.insert(0, os.path.join(sys.argv[1], 'scripts'))
874
+ from probe_live_eval_lib import instrument_fingerprint, render_instrument_line
875
+ l = render_instrument_line(instrument_fingerprint('/nonexistent/probes_live.yaml'))
876
+ # the readable neighbours must still carry a real 40-hex id — a blanket UNKNOWN must not pass
877
+ ok = ('probes=UNKNOWN(unreadable)' in l and re.search(r'runner=[0-9a-f]{40} ', l)
878
+ and re.search(r'scorer=[0-9a-f]{40} ', l) and re.search(r'sim_runner=[0-9a-f]{40} ', l))
879
+ print('unknown' if ok else 'dropped:' + l)
880
+ PY
881
+ )"
882
+ _lane IF2 instrument "KNOWN-NEGATIVE — unreadable probes file -> UNKNOWN(unreadable), not omitted" "unknown" "$r"
883
+ r="$(python3 - "$REPO_ROOT" "$T/if3.md" "$PROBES_LIVE" <<'PY'
884
+ import sys, os
885
+ sys.path.insert(0, os.path.join(sys.argv[1], 'scripts'))
886
+ from probe_live_eval_lib import render_report_md, parse_prev_report, instrument_fingerprint
887
+ sr = {'model': 'm', 'threshold': 0.5, 'rows': [{'id': 'G-X-01', 'verdict': 'PASS'}], 'pass_rate': 1.0,
888
+ 'overall': 'PASS', 'ran': 1, 'failed_to_run': 0, 'uncalibrated': 0, 'passed': 1}
889
+ md = render_report_md({'selected': [], 'excluded': [], 'warnings': []}, sr, 'd',
890
+ instrument=instrument_fingerprint(sys.argv[3]))
891
+ open(sys.argv[2], 'w').write(md)
892
+ print('%s|%s' % (md.splitlines()[4].startswith('- Instrument (git blob ids'), parse_prev_report(sys.argv[2])))
893
+ PY
894
+ )"
895
+ _lane IF3 instrument "line sits at the top; run-table reader unchanged by it" "True|{'G-X-01': 'PASS'}" "$r"
896
+ printf '#!/usr/bin/env bash\necho stub\n' > "$T/if4_stub.sh"
897
+ r="$(FH_SIM_RUNNER_BIN="$T/if4_stub.sh" python3 - "$REPO_ROOT" "$PROBES_LIVE" "$T/if4_stub.sh" <<'PY'
898
+ import sys, os
899
+ sys.path.insert(0, os.path.join(sys.argv[1], 'scripts'))
900
+ from probe_live_eval_lib import instrument_fingerprint, _git_blob_sha
901
+ fp = dict(instrument_fingerprint(sys.argv[2]))
902
+ live = _git_blob_sha(os.path.join(sys.argv[1], 'scripts', 'sim_isolated_run.sh'))
903
+ print('override' if fp.get('sim_runner(override)') == _git_blob_sha(sys.argv[3]) != live
904
+ and 'sim_runner' not in fp else 'leak:%r' % sorted(fp))
905
+ PY
906
+ )"
907
+ _lane IF4 instrument "KNOWN-NEGATIVE — stub sim runner is fingerprinted as sim_runner(override)" "override" "$r"
908
+
842
909
  echo ""
843
910
  echo "── summary ──────────────────────────────────────────────────────"
844
911
  echo "lanes: $N failed: $([ "$FAIL" -eq 0 ] && echo 0 || echo '>=1')"
@@ -66,12 +66,12 @@ fi
66
66
  verdict() { # $1=exit_code $2=scanned ; echoes rc + first line
67
67
  local out rc
68
68
  out=$(EXIT_IN="$1" SCANNED_IN="$2" bash "$T/eval.sh" 2>&1); rc=$?
69
- printf '%s|%s' "$rc" "$(printf '%s' "$out" | head -1)"
69
+ printf '%s|%s' "$rc" "$(printf '%s' "$out" | sed -n 1p)"
70
70
  }
71
71
  lane() { # $1=id $2=exit $3=scanned $4=expect(ok|fail) $5=substring
72
72
  local r; r=$(verdict "$2" "$3"); local rc="${r%%|*}" msg="${r#*|}"
73
73
  local got=ok; [ "$rc" -ne 0 ] && got=fail
74
- if [ "$got" = "$4" ] && printf '%s' "$msg" | grep -q "$5"; then
74
+ if [ "$got" = "$4" ] && printf '%s' "$msg" | grep -c "$5" >/dev/null; then
75
75
  printf ' ✅ %-30s rc=%s %s\n' "$1" "$rc" "$(printf '%s' "$msg" | cut -c1-58)"
76
76
  else
77
77
  printf ' ❌ %-30s expected %s+/%s/, got rc=%s %s\n' "$1" "$4" "$5" "$rc" "$msg"; FAIL=1
@@ -137,18 +137,18 @@ if git -C "$REPO_ROOT" clone -q --no-local "$REPO_ROOT" "$CL" 2>/dev/null; then
137
137
  # L8a — a bare NAME must be REFUSED. Name-guessing is what let a fork PR branch called `main`
138
138
  # resolve to this repo's main and compare it to itself.
139
139
  out=$(cd "$CL" && bash templates/regression_guard.sh --pr "$BR" "$BASE_SHA" 2>&1); rc=$?
140
- if [ "$rc" -eq 3 ] && printf '%s' "$out" | grep -q "head='$BR'->'<none>'"; then
140
+ if [ "$rc" -eq 3 ] && printf '%s' "$out" | grep -c "head='$BR'->'<none>'" >/dev/null; then
141
141
  printf ' ✅ %-30s fork-collision name '"'"'%s'"'"' refused, attributed to HEAD (local refs: %s)\n' "L8a-name-refused" "$BR" "$_left"
142
142
  else
143
- printf ' ❌ %-30s expected exit 3 naming head=%s, got rc=%s: %s\n' "L8a-name-refused" "$BR" "$rc" "$(printf '%s' "$out" | head -1)"; FAIL=1
143
+ printf ' ❌ %-30s expected exit 3 naming head=%s, got rc=%s: %s\n' "L8a-name-refused" "$BR" "$rc" "$(printf '%s' "$out" | sed -n 1p)"; FAIL=1
144
144
  fi
145
145
 
146
146
  # L8b — unambiguous SHAs on both sides must resolve and compute a merge-base.
147
147
  out=$(cd "$CL" && bash templates/regression_guard.sh --pr "$SHA" "$BASE_SHA" 2>&1); rc=$?
148
- if printf '%s' "$out" | grep -q 'PR MODE: merge-base='; then
148
+ if printf '%s' "$out" | grep -c 'PR MODE: merge-base=' >/dev/null; then
149
149
  printf ' ✅ %-30s %s\n' "L8b-sha-resolves" "$(printf '%s' "$out" | grep -o 'merge-base=[^ ]*')"
150
150
  else
151
- printf ' ❌ %-30s SHA did not resolve (rc=%s): %s\n' "L8b-sha-resolves" "$rc" "$(printf '%s' "$out" | head -1)"; FAIL=1
151
+ printf ' ❌ %-30s SHA did not resolve (rc=%s): %s\n' "L8b-sha-resolves" "$rc" "$(printf '%s' "$out" | sed -n 1p)"; FAIL=1
152
152
  fi
153
153
 
154
154
  else
@@ -211,13 +211,13 @@ EOF
211
211
  grun() { # $1=guard path ; echoes "rc|<matched verdict line>"
212
212
  local out rc
213
213
  out=$(cd "$G" && bash "$1" --staged 2>&1); rc=$?
214
- printf '%s|%s' "$rc" "$(printf '%s\n' "$out" | grep -E 'M-TIER|S-TIER' | head -1)"
214
+ printf '%s|%s' "$rc" "$(printf '%s\n' "$out" | grep -E 'M-TIER|S-TIER' | sed -n 1p)"
215
215
  }
216
216
  glane() { # $1=id $2=expected rc $3=substring('' = none) $4=guard path
217
217
  local r rc msg ok=1
218
218
  r=$(grun "$4"); rc="${r%%|*}"; msg="${r#*|}"
219
219
  [ "$rc" = "$2" ] || ok=0
220
- [ -z "$3" ] || printf '%s' "$msg" | grep -qF -- "$3" || ok=0
220
+ [ -z "$3" ] || printf '%s' "$msg" | grep -cF -- "$3" >/dev/null || ok=0
221
221
  if [ "$ok" -eq 1 ]; then
222
222
  printf ' ✅ %-28s rc=%s %s\n' "$1" "$rc" "$(printf '%s' "$msg" | cut -c1-56)"
223
223
  else