@chrono-meta/fh-gate 3.37.0 → 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 (57) hide show
  1. package/.claude-plugin/marketplace.json +4 -4
  2. package/knowledge/shared/harness-core/self_evolution_routine.md +22 -0
  3. package/knowledge/shared/learnings/subagent_invocations_log.yaml +30 -0
  4. package/package.json +2 -1
  5. package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
  6. package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
  7. package/plugins/fh-meta/CHANGELOG.md +13 -1
  8. package/plugins/fh-meta/skills/frontier-digest/SKILL_detail.md +7 -3
  9. package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
  10. package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
  11. package/scripts/adapters/gstack_content_safety.sh +1 -1
  12. package/scripts/capability_effect_probe.sh +2 -2
  13. package/scripts/chamber_run.sh +2 -2
  14. package/scripts/compaction_probe.sh +14 -14
  15. package/scripts/fh_session_load.sh +2 -2
  16. package/scripts/frontier_digest_autopilot.sh +10 -0
  17. package/scripts/gate_shape_scan.sh +1 -1
  18. package/scripts/governor_board.sh +2 -2
  19. package/scripts/outbound_pr_gate.sh +1 -1
  20. package/scripts/package_coverage_check.sh +10 -0
  21. package/scripts/pr_merge_verified.sh +8 -1
  22. package/scripts/probe_live_eval_lib.py +49 -2
  23. package/scripts/residency_admission_check.sh +1 -1
  24. package/scripts/selfcheck.sh +5 -0
  25. package/scripts/session_close_check.sh +2 -2
  26. package/scripts/sim_isolated_run.sh +2 -2
  27. package/scripts/test_count_check_decl_lanes.sh +1 -1
  28. package/scripts/test_degrade_scan_shell_probes.sh +1 -1
  29. package/scripts/test_dispatch_log_lanes.sh +3 -3
  30. package/scripts/test_fh_qp_lanes.sh +1 -1
  31. package/scripts/test_fh_run_resolver_lanes.sh +4 -4
  32. package/scripts/test_finding_pipeline_lanes.sh +7 -7
  33. package/scripts/test_gate_two_verdicts_lanes.sh +1 -1
  34. package/scripts/test_lane_runner_lanes.sh +1 -1
  35. package/scripts/test_lane_stub_env_lanes.sh +2 -2
  36. package/scripts/test_map_postprocess_lanes.sh +1 -1
  37. package/scripts/test_marker_address_lanes.sh +1 -1
  38. package/scripts/test_marker_defense_lanes.sh +1 -1
  39. package/scripts/test_marker_oracle_lanes.sh +1 -1
  40. package/scripts/test_outbound_pr_gate_lanes.sh +1 -1
  41. package/scripts/test_peer_worktree_detect_lanes.sh +1 -1
  42. package/scripts/test_pr_merge_verified_lanes.sh +8 -0
  43. package/scripts/test_precommit_staged_drift_lanes.sh +1 -1
  44. package/scripts/test_preprep_adjacent_dup_lanes.sh +1 -1
  45. package/scripts/test_prepush_destructive_lanes.sh +1 -1
  46. package/scripts/test_probe_live_eval_lanes.sh +68 -1
  47. package/scripts/test_regression_guard_ci_lanes.sh +8 -8
  48. package/scripts/test_regression_guard_codecomment_lanes.sh +140 -0
  49. package/scripts/test_revert_probe_lanes.sh +1 -1
  50. package/scripts/test_selfcheck_state_lanes.sh +1 -1
  51. package/scripts/test_stale_ref_close_lanes.sh +1 -1
  52. package/scripts/test_temper_check_lanes.sh +1 -1
  53. package/scripts/test_utterance_intake_lanes.sh +9 -9
  54. package/scripts/test_verdict_watermark_lanes.sh +3 -3
  55. package/scripts/test_worktree_reclaim_lanes.sh +1 -1
  56. package/templates/.git-hooks/pre-commit +2 -2
  57. package/templates/regression_guard.sh +32 -2
@@ -1177,6 +1177,10 @@ for _pair in \
1177
1177
  "scripts/destructive_pre_gate.sh|scripts/test_destructive_pre_gate_lanes.sh" \
1178
1178
  "scripts/probe_live_eval_lib.py|scripts/test_live_eval_transitions_lanes.sh" \
1179
1179
  "scripts/correction_moments.py|scripts/test_correction_moments_lanes.sh" \
1180
+ `# 무인 자체개발 루프(2026-11-04, 운영자 상시 요청). 자동 머지 등급은 모델이 아니라 경로 허용 목록이 정한다 — 빈 목록은 AUTO 가 아니라 HARNESS-ERROR(실측: 가드를 지우면 빈 목록이 AUTO 로 통과).` \
1181
+ "scripts/selfdev_merge_tier.sh|scripts/test_selfdev_merge_tier_lanes.sh" \
1182
+ "scripts/selfdev_queue.py|scripts/test_selfdev_queue_lanes.sh" \
1183
+ "scripts/selfdev_loop.sh|scripts/test_selfdev_loop_lanes.sh" \
1180
1184
  "scripts/card_status_tags.sh|scripts/test_card_status_tags_lanes.sh" \
1181
1185
  "templates/.git-hooks/pre-push|scripts/test_prepush_destructive_lanes.sh" \
1182
1186
  "templates/.git-hooks/pre-push|scripts/test_prepush_destructive_liveness.sh" \
@@ -1198,6 +1202,7 @@ for _pair in \
1198
1202
  "templates/.git-hooks/pre-commit|scripts/test_marker_floor_lanes.sh" \
1199
1203
  ".github/workflows/regression-guard.yml|scripts/test_regression_guard_ci_lanes.sh" \
1200
1204
  "templates/regression_guard.sh|scripts/test_regression_guard_sibling_lanes.sh" \
1205
+ "templates/regression_guard.sh|scripts/test_regression_guard_codecomment_lanes.sh" \
1201
1206
  ".github/workflows/validate.yml|scripts/test_leak_scan_control_lanes.sh" \
1202
1207
  "templates/.git-hooks/pre-commit|scripts/test_marker_standpoint_lanes.sh" \
1203
1208
  "templates/.git-hooks/pre-commit|scripts/test_marker_thirdparty_lanes.sh" \
@@ -187,7 +187,7 @@ done
187
187
  _peer_cwd() { # $1=pid → cwd on stdout, empty if unresolvable
188
188
  if [ -r "/proc/$1/cwd" ]; then readlink "/proc/$1/cwd" 2>/dev/null; return; fi
189
189
  command -v lsof >/dev/null 2>&1 || return 0
190
- lsof -a -p "$1" -d cwd -Fn 2>/dev/null | sed -n 's/^n//p' | head -1
190
+ lsof -a -p "$1" -d cwd -Fn 2>/dev/null | sed -n 's/^n//p' | sed -n 1p
191
191
  }
192
192
  # Repo identity, NOT directory prefix. Measured 2026-08-22 (probe_2026-08-22_A2_replication.md):
193
193
  # `--show-toplevel` yields the WORKTREE's own path, and a worktree by definition lives outside the
@@ -321,7 +321,7 @@ if [ -f "$_UI_SUT" ]; then
321
321
  _UI_SID=""
322
322
  if [ -f "$FH/scripts/branch_claim.sh" ]; then
323
323
  _UI_SID=$(LC_ALL=C bash "$FH/scripts/branch_claim.sh" show 2>/dev/null \
324
- | LC_ALL=C sed -n 's/^세션ID[[:space:]][[:space:]]*//p' | head -1)
324
+ | LC_ALL=C sed -n 's/^세션ID[[:space:]][[:space:]]*//p' | sed -n 1p)
325
325
  fi
326
326
  case "$_UI_SID" in pid-*|'') _UI_SID="" ;; esac
327
327
  # 전사본 slug = 프로젝트 절대경로에서 `/` `.` `_` 를 `-` 로 (실측 2026-09-05, ~/.claude/projects 대조)
@@ -563,7 +563,7 @@ fh_sim_instr_hits() { # $1=absolute dir → prints instruction sources in $1 and
563
563
  case "$n" in .claude/*) [ "$skipclaude" = 1 ] && continue ;; esac
564
564
  [ -e "$d/$n" ] && hits="$hits $d/$n"
565
565
  done
566
- if [ "$skipclaude" = 0 ] && [ -d "$d/.claude/rules" ] && [ -n "$(find -L "$d/.claude/rules" -name '*.md' -print 2>/dev/null | head -1)" ]; then # -L: symlinked rules dirs load too (codex R2)
566
+ if [ "$skipclaude" = 0 ] && [ -d "$d/.claude/rules" ] && [ -n "$(find -L "$d/.claude/rules" -name '*.md' -print 2>/dev/null | sed -n 1p)" ]; then # -L: symlinked rules dirs load too (codex R2)
567
567
  hits="$hits $d/.claude/rules/"
568
568
  fi
569
569
  [ "$d" = "/" ] && break
@@ -590,7 +590,7 @@ fh_sim_refuse_inherit "$OUTDIR" "--out"
590
590
  # but printed so a reader of the run knows they were there (codex R1).
591
591
  _user_instr=""
592
592
  [ -e "$_user_cfg/CLAUDE.md" ] && _user_instr="$_user_instr $_user_cfg/CLAUDE.md"
593
- [ -d "$_user_cfg/rules" ] && [ -n "$(find -L "$_user_cfg/rules" -name '*.md' -print 2>/dev/null | head -1)" ] && _user_instr="$_user_instr $_user_cfg/rules/"
593
+ [ -d "$_user_cfg/rules" ] && [ -n "$(find -L "$_user_cfg/rules" -name '*.md' -print 2>/dev/null | sed -n 1p)" ] && _user_instr="$_user_instr $_user_cfg/rules/"
594
594
  [ -n "$_user_instr" ] && echo "ℹ️ user-level instructions load in every arm (same for all, not refused):$_user_instr" >&2
595
595
 
596
596
  # ── machine-surface snapshot ──────────────────────────────────────────────────────────────────
@@ -73,7 +73,7 @@ json.dump(d,open(sys.argv[1],"w",encoding="utf-8"),ensure_ascii=False,indent=2)
73
73
  PY
74
74
  }
75
75
  # verdict — echoes the single fh-qp skills sweep line from a real count_check run
76
- verdict() { ( cd "$FX" && bash scripts/count_check.sh 2>&1 ) | grep -E "sweep: fh-qp skills" | head -1; }
76
+ verdict() { ( cd "$FX" && bash scripts/count_check.sh 2>&1 ) | grep -E "sweep: fh-qp skills" | sed -n 1p; }
77
77
 
78
78
  DECL_OK="QP (Quality Platform) — 4 skills (qp · qp-plan · qp-run · qp-regress)."
79
79
  DECL_STALE="QP (Quality Platform) — 3 skills (qp · qp-plan · qp-run · qp-regress)."
@@ -688,7 +688,7 @@ fi
688
688
  # flips to a hit — proves the exclusion is load-bearing for this specific fixture, not just
689
689
  # present somewhere in the file.
690
690
  _scan_reverted="$TMP/scan_reverted.sh"
691
- _excl_line=$(grep -n "grep -vE 'in \[A-Z_\]" "$SCAN" | head -1 | cut -d: -f1) # portability-noqa: this file has no `set -e` (top line 22 is `set -uo pipefail` only) and the next line already guards empty via -z
691
+ _excl_line=$(grep -n "grep -vE 'in \[A-Z_\]" "$SCAN" | sed -n 1p | cut -d: -f1) # portability-noqa: this file has no `set -e` (top line 22 is `set -uo pipefail` only) and the next line already guards empty via -z
692
692
  if [ -z "$_excl_line" ]; then
693
693
  bad "C2-REVERT could not locate the exclusion line by its known text — fixture cannot run"
694
694
  else
@@ -153,7 +153,7 @@ new_form=$(bash -c 'set -uo pipefail; _int() { case "${1:-}" in (""|*[!0-9]*) ec
153
153
  # "needle matching unrelated text"). Extract the subject's OWN assignment lines and evaluate them.
154
154
  _eval_subject_assign() { # $1 = variable name; echoes what the SUBJECT computes for a zero match
155
155
  local var="$1" line
156
- line=$(grep -E "^${var}=" "$CHECK" | head -1)
156
+ line=$(grep -E "^${var}=" "$CHECK" | sed -n 1p)
157
157
  [ -n "$line" ] || { echo "NOLINE"; return; }
158
158
  bash -c "set -uo pipefail
159
159
  _int() { case \"\${1:-}\" in (''|*[!0-9]*) echo 0 ;; (*) echo \"\$1\" ;; esac; }
@@ -173,7 +173,7 @@ done
173
173
  echo ""
174
174
  echo "── 전환 설계 레인: 레거시 단일 파일 ∪ 세션별 디렉터리 ──"
175
175
  # 주어의 _cat_logs + LOGGED 를 그대로 들어와 4가지 상태에서 센다.
176
- LOGGED_LINE=$(grep -E "^LOGGED=" "$CHECK" | head -1)
176
+ LOGGED_LINE=$(grep -E "^LOGGED=" "$CHECK" | sed -n 1p)
177
177
  _count_in() { # $1=LOG 경로(없으면 빈문자) $2=LOGDIR 경로(없으면 빈문자)
178
178
  bash -c "set -uo pipefail
179
179
  _int() { case \"\${1:-}\" in (''|*[!0-9]*) echo 0 ;; (*) echo \"\$1\" ;; esac; }
@@ -198,7 +198,7 @@ echo ""
198
198
  echo "── read-error ≠ zero 레인 (2026-08-26, cross-family/codex) ──"
199
199
  # 주어가 «0건» 과 «못 읽었다» 를 가르는가. 가르기 전에는 읽기 실패가 0 으로 접혀
200
200
  # "✅ ④-e no sub-agent dispatches tallied today" 라는 **안 잰 초록**이 나갔다.
201
- DISP_LINE=$(grep -E "^DISPATCHED=" "$CHECK" | head -1)
201
+ DISP_LINE=$(grep -E "^DISPATCHED=" "$CHECK" | sed -n 1p)
202
202
  _disp_with() { # $1 = TALLY 로 쓸 경로
203
203
  bash -c "set -uo pipefail
204
204
  _int() { case \"\${1:-}\" in (''|*[!0-9]*) echo 0 ;; (*) echo \"\$1\" ;; esac; }
@@ -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"
@@ -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