@chrono-meta/fh-gate 3.37.0 → 3.38.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 (58) hide show
  1. package/.claude-plugin/marketplace.json +4 -4
  2. package/knowledge/shared/harness-core/governance_engineering_definition.md +26 -0
  3. package/knowledge/shared/harness-core/self_evolution_routine.md +22 -0
  4. package/knowledge/shared/learnings/subagent_invocations_log.yaml +54 -0
  5. package/package.json +2 -1
  6. package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
  7. package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
  8. package/plugins/fh-meta/CHANGELOG.md +21 -1
  9. package/plugins/fh-meta/skills/frontier-digest/SKILL_detail.md +7 -3
  10. package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
  11. package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
  12. package/scripts/adapters/gstack_content_safety.sh +1 -1
  13. package/scripts/capability_effect_probe.sh +2 -2
  14. package/scripts/chamber_run.sh +2 -2
  15. package/scripts/compaction_probe.sh +14 -14
  16. package/scripts/fh_session_load.sh +2 -2
  17. package/scripts/frontier_digest_autopilot.sh +10 -0
  18. package/scripts/gate_shape_scan.sh +1 -1
  19. package/scripts/governor_board.sh +2 -2
  20. package/scripts/outbound_pr_gate.sh +1 -1
  21. package/scripts/package_coverage_check.sh +10 -0
  22. package/scripts/pr_merge_verified.sh +8 -1
  23. package/scripts/probe_live_eval_lib.py +49 -2
  24. package/scripts/residency_admission_check.sh +1 -1
  25. package/scripts/selfcheck.sh +5 -0
  26. package/scripts/session_close_check.sh +2 -2
  27. package/scripts/sim_isolated_run.sh +2 -2
  28. package/scripts/test_count_check_decl_lanes.sh +1 -1
  29. package/scripts/test_degrade_scan_shell_probes.sh +1 -1
  30. package/scripts/test_dispatch_log_lanes.sh +3 -3
  31. package/scripts/test_fh_qp_lanes.sh +1 -1
  32. package/scripts/test_fh_run_resolver_lanes.sh +4 -4
  33. package/scripts/test_finding_pipeline_lanes.sh +7 -7
  34. package/scripts/test_gate_two_verdicts_lanes.sh +1 -1
  35. package/scripts/test_lane_runner_lanes.sh +1 -1
  36. package/scripts/test_lane_stub_env_lanes.sh +2 -2
  37. package/scripts/test_map_postprocess_lanes.sh +1 -1
  38. package/scripts/test_marker_address_lanes.sh +1 -1
  39. package/scripts/test_marker_defense_lanes.sh +1 -1
  40. package/scripts/test_marker_oracle_lanes.sh +1 -1
  41. package/scripts/test_outbound_pr_gate_lanes.sh +1 -1
  42. package/scripts/test_peer_worktree_detect_lanes.sh +1 -1
  43. package/scripts/test_pr_merge_verified_lanes.sh +8 -0
  44. package/scripts/test_precommit_staged_drift_lanes.sh +1 -1
  45. package/scripts/test_preprep_adjacent_dup_lanes.sh +1 -1
  46. package/scripts/test_prepush_destructive_lanes.sh +1 -1
  47. package/scripts/test_probe_live_eval_lanes.sh +68 -1
  48. package/scripts/test_regression_guard_ci_lanes.sh +8 -8
  49. package/scripts/test_regression_guard_codecomment_lanes.sh +140 -0
  50. package/scripts/test_revert_probe_lanes.sh +1 -1
  51. package/scripts/test_selfcheck_state_lanes.sh +1 -1
  52. package/scripts/test_stale_ref_close_lanes.sh +1 -1
  53. package/scripts/test_temper_check_lanes.sh +1 -1
  54. package/scripts/test_utterance_intake_lanes.sh +9 -9
  55. package/scripts/test_verdict_watermark_lanes.sh +3 -3
  56. package/scripts/test_worktree_reclaim_lanes.sh +1 -1
  57. package/templates/.git-hooks/pre-commit +2 -2
  58. package/templates/regression_guard.sh +32 -2
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/env bash
2
+ # test_regression_guard_codecomment_lanes.sh — Axis 1 F4 must not count `#` comment lines in code.
3
+ #
4
+ # WHY (2026-11-04): F4 counts operational tokens (PASS, BLOCK, M-tier, ...) and blocks at >=50%
5
+ # loss. In a .py file a `PASS` that sits only in a comment is prose, yet it was counted: a
6
+ # downstream harness's utterance_checklist_hook.py reworded one comment, `PASS` went 1 -> 0, and
7
+ # the guard hard-blocked an otherwise clean port. F4 now drops real Python comments (found by
8
+ # Python's tokenizer) before counting. Shell is not filtered. These lanes pin both directions:
9
+ # C1 .py, token only in a comment, comment reworded -> no M-tier (the fix)
10
+ # C2 .py, token in a string literal, dropped -> M-tier (still guards code)
11
+ # C3 .sh, `# BLOCK` inside a heredoc, changed -> M-tier (shell not filtered)
12
+ # C4 .md, `# PASS ...` heading dropped -> M-tier (md is not code)
13
+ # C5 .py, `# BLOCK` line inside a triple-quoted string -> M-tier (string data, not a comment)
14
+ # C6 .py that does not parse, comment-only token dropped -> M-tier (tokenizer fails -> stricter)
15
+ # C7 .py with a form feed before a string holding PASS -> M-tier (rows must not shift)
16
+ # C8 .py, comment then a lone CR then a string holding PASS -> M-tier (only the comment text goes)
17
+ # C3, C5 (round 1) and C7 (round 2), C8 (round 3) are the cross-family findings against a first draft that matched `^#` lines.
18
+ # REVERT PROBE: the .py case is disabled in a copy of the guard and C1 must turn red.
19
+ #
20
+ # Usage: bash scripts/test_regression_guard_codecomment_lanes.sh Exit: 0 = all behave; 1 = regression.
21
+
22
+ set -uo pipefail
23
+ . "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # fixtures never write the real repo
24
+ REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
25
+ GUARD="$REPO_ROOT/templates/regression_guard.sh"
26
+ T="$(fh_fixture_root "$(mktemp -d)")"
27
+ : "${T:?fixture root unset — refusing to run git in cwd}"
28
+ trap 'rm -rf "$T"' EXIT
29
+ FAIL=0
30
+
31
+ PY_BEFORE='import sys
32
+
33
+ def main():
34
+ # retry on a busy lock (5x PASS under contention)
35
+ return 0
36
+ '
37
+ PY_AFTER='import sys
38
+
39
+ def main():
40
+ # retry on a busy lock, measured under contention
41
+ return 0
42
+ '
43
+ PYS_BEFORE='def verdict(ok):
44
+ return "PASS" if ok else "FAIL"
45
+ '
46
+ PYS_AFTER='def verdict(ok):
47
+ return "ok" if ok else "FAIL"
48
+ '
49
+ SH_BEFORE='#!/usr/bin/env bash
50
+ cat <<EOF
51
+ # BLOCK
52
+ EOF
53
+ '
54
+ SH_AFTER='#!/usr/bin/env bash
55
+ cat <<EOF
56
+ # allow
57
+ EOF
58
+ '
59
+ PYQ_BEFORE='MSG = """
60
+ # BLOCK
61
+ """
62
+ print(MSG)
63
+ '
64
+ PYQ_AFTER='MSG = """
65
+ # allow
66
+ """
67
+ print(MSG)
68
+ '
69
+ PYBAD_BEFORE='def broken(:
70
+ # PASS here
71
+ return 0
72
+ '
73
+ PYBAD_AFTER='def broken(:
74
+ # fine here
75
+ return 0
76
+ '
77
+ PYFF_BEFORE=$(printf 'x=0\f\ns="PASS"\n# note\n')
78
+ PYFF_AFTER=$(printf 'x=0\f\ns="okay"\n# note\n')
79
+ PYCR_BEFORE=$(printf '# note\rs="PASS"\n')
80
+ PYCR_AFTER=$(printf '# note\rs="okay"\n')
81
+ MD_BEFORE='# s
82
+ # PASS criteria
83
+ the run is green.
84
+ '
85
+ MD_AFTER='# s
86
+ the run is green.
87
+ '
88
+
89
+ # $1=dir $2=path $3=before $4=after — base commit with $3, then stage $4
90
+ mkcase() {
91
+ local d=$1 p=$2
92
+ mkdir -p "$d/$(dirname "$p")"
93
+ git -C "$d" init -q && git -C "$d" config user.email t@t && git -C "$d" config user.name t
94
+ printf '%s' "$3" > "$d/$p"
95
+ git -C "$d" add -A && git -C "$d" commit -q -m base
96
+ printf '%s' "$4" > "$d/$p"
97
+ git -C "$d" add -A
98
+ }
99
+
100
+ # $1=id $2=dir $3=guard $4=expect(block|pass)
101
+ run_lane() {
102
+ local id=$1 d=$2 g=$3 want=$4 rc out
103
+ out=$(cd "$d" && bash "$g" --staged 2>&1); rc=$?; [ -n "${SHOW:-}" ] && printf "%s\n" "$out" | grep -E "M-TIER" | sed "s/^/ [$id] /"
104
+ if [ -z "$out" ]; then echo " ❌ $id — guard printed nothing (instrument silence, not a pass)"; FAIL=1; return; fi
105
+ if [ "$rc" -ne 0 ] && [ "$rc" -ne 1 ] && [ "$rc" -ne 2 ]; then
106
+ echo " ❌ $id — guard rc=$rc (could not run)"; printf '%s\n' "$out" | tail -3 | sed 's/^/ /'; FAIL=1; return
107
+ fi
108
+ if ! grep -c "Files changed: 1" <<<"$out" >/dev/null; then
109
+ echo " ❌ $id — the fixture file was not selected (inert pathspec reads as a clean 0)"; FAIL=1; return
110
+ fi
111
+ if [ "$want" = block ] && [ "$rc" -eq 2 ]; then echo " ✅ $id — M-tier block (rc=2)"
112
+ elif [ "$want" = pass ] && [ "$rc" -ne 2 ]; then echo " ✅ $id — no M-tier (rc=$rc)"
113
+ else echo " ❌ $id — want $want, got rc=$rc"; printf '%s\n' "$out" | grep -E 'M-TIER|token' | head -3 | sed 's/^/ /'; FAIL=1
114
+ fi
115
+ }
116
+
117
+ echo "regression_guard F4 — code comments are not operational tokens"
118
+ mkcase "$T/c1" scripts/hook.py "$PY_BEFORE" "$PY_AFTER"; run_lane C1 "$T/c1" "$GUARD" pass
119
+ mkcase "$T/c2" scripts/verdict.py "$PYS_BEFORE" "$PYS_AFTER"; run_lane C2 "$T/c2" "$GUARD" block
120
+ mkcase "$T/c3" scripts/gate.sh "$SH_BEFORE" "$SH_AFTER"; run_lane C3 "$T/c3" "$GUARD" block
121
+ mkcase "$T/c4" README.md "$MD_BEFORE" "$MD_AFTER"; run_lane C4 "$T/c4" "$GUARD" block
122
+ mkcase "$T/c5" scripts/msg.py "$PYQ_BEFORE" "$PYQ_AFTER"; run_lane C5 "$T/c5" "$GUARD" block
123
+ mkcase "$T/c6" scripts/bad.py "$PYBAD_BEFORE" "$PYBAD_AFTER"; run_lane C6 "$T/c6" "$GUARD" block
124
+ mkcase "$T/c7" scripts/ff.py "$PYFF_BEFORE" "$PYFF_AFTER"; run_lane C7 "$T/c7" "$GUARD" block
125
+ mkcase "$T/c8" scripts/cr.py "$PYCR_BEFORE" "$PYCR_AFTER"; run_lane C8 "$T/c8" "$GUARD" block
126
+
127
+ echo "revert probe — disable the .py case; C1 must turn red"
128
+ G2="$T/guard_reverted.sh"
129
+ sed 's/^ \*\.py)$/ __never_matches__)/' "$GUARD" > "$G2"
130
+ if cmp -s "$GUARD" "$G2"; then
131
+ echo " ❌ R1 — revert did not apply (pattern not found in guard; probe is dead)"; FAIL=1
132
+ else
133
+ out=$(cd "$T/c1" && bash "$G2" --staged 2>&1); rc=$?
134
+ if [ "$rc" -eq 2 ]; then echo " ✅ R1 — reverted guard blocks C1 (rc=2): the case is load-bearing"
135
+ else echo " ❌ R1 — reverted guard still passes C1 (rc=$rc): lane C1 is decoration"; FAIL=1
136
+ fi
137
+ fi
138
+
139
+ [ "$FAIL" -eq 0 ] && echo "PASS — 8 lanes + revert probe" || echo "FAIL"
140
+ exit "$FAIL"
@@ -138,7 +138,7 @@ OUT5e=$(bash "$SUT" "$TARGET" "$REAL_SUITE" --baseline totally-bogus-ref 2>&1);
138
138
  ( cd "$SRC" && git diff --cached --quiet ) \
139
139
  && ok "L6 no staged changes left in the index after any probe run" \
140
140
  || no "L6 the index has staged changes — a checkout-based restore would do this"
141
- ( cd "$SRC" && git status --porcelain ) | grep -q . \
141
+ ( cd "$SRC" && git status --porcelain ) | grep -c . >/dev/null \
142
142
  && no "L6b working tree not clean after probes (git status is non-empty)" \
143
143
  || ok "L6b working tree clean after all probes (file content == committed HEAD)"
144
144
 
@@ -405,7 +405,7 @@ if [ "$(printf '%s\n' "$DD_ARM" | wc -l)" -gt 15 ]; then
405
405
  fi
406
406
  dd_arm_says() { # $1 = the subject's stdout; echoes PASS or FAIL
407
407
  ( _out="$1"; fail=0; _show_failure() { :; }
408
- eval "$DD_ARM" ) | grep -oE '^(PASS|FAIL)' | head -1
408
+ eval "$DD_ARM" ) | grep -oE '^(PASS|FAIL)' | sed -n 1p
409
409
  }
410
410
 
411
411
  [ "$(dd_arm_says '✅ calibration passed (28 pairs)')" = PASS ]
@@ -32,7 +32,7 @@ if [ ! -f "$SUBJECT" ]; then
32
32
  fi
33
33
 
34
34
  BLOCK=$(awk '/^# ── ①-g STALE REF \(advisory\)/,/^echo "── close check:/' "$SUBJECT" | sed '$d')
35
- if [ -z "$BLOCK" ] || ! printf '%s' "$BLOCK" | grep -q '_SR_SCAN'; then
35
+ if [ -z "$BLOCK" ] || ! printf '%s' "$BLOCK" | grep -c '_SR_SCAN' >/dev/null; then
36
36
  bad "①-g 블록을 subject 에서 못 찾았다 — 못 찾는 것을 검증할 수는 없다"
37
37
  echo "----"; echo "stale-ref close lanes: $pass passed, $fail failed"; exit 1
38
38
  fi
@@ -261,7 +261,7 @@ else
261
261
  CHANGED="$(git -C "$REPO_ROOT" diff --name-only "$BASEREF" HEAD -- '*.md')"
262
262
  # L1 — 그 구간에 «안 변한» 실물 md → 6지표 전부 +0
263
263
  UNCH=""
264
- for f in $(git -C "$REPO_ROOT" ls-tree -r --name-only HEAD | grep '\.md$' | head -60); do
264
+ for f in $(git -C "$REPO_ROOT" ls-tree -r --name-only HEAD | grep '\.md$' | sed -n '1,60p'); do
265
265
  printf '%s\n' "$CHANGED" | grep -Fxq "$f" && continue
266
266
  git -C "$REPO_ROOT" cat-file -e "$BASEREF:$f" 2>/dev/null || continue
267
267
  UNCH="$f"; break
@@ -186,7 +186,7 @@ grep -qE $'^1\t2026-09-05T01:00:00' <<<"${_L9C_OUT%%$'\n'*}" \
186
186
 
187
187
  # ── L10 seal 출력 골든 — 공용화가 기존 원장을 바꾸지 않았다 ─────────────────
188
188
  bash "$PROBE" seal --transcript "$T/tr.jsonl" --dir "$T/seal" >/dev/null 2>&1
189
- SF="$(ls "$T/seal"/seal_*.md 2>/dev/null | head -1)"
189
+ SF="$(ls "$T/seal"/seal_*.md 2>/dev/null | sed -n 1p)"
190
190
  if [ -n "$SF" ]; then
191
191
  sed -n '/^## 운영자 발화/,/^## 이 세션이 건드린/p' "$SF" | sed '$d' > "$T/seal_block.txt"
192
192
  cat > "$T/seal_expect.txt" <<'GOLD'
@@ -203,7 +203,7 @@ GOLD
203
203
  if diff -u "$T/seal_expect.txt" "$T/seal_block.txt" >"$T/seal_diff.txt" 2>&1; then
204
204
  ok "L10 seal 발화 블록이 골든과 바이트 동일"
205
205
  else
206
- ng "L10 seal 발화 블록이 골든과 다르다"; sed 's/^/ /' "$T/seal_diff.txt" | head -20
206
+ ng "L10 seal 발화 블록이 골든과 다르다"; sed 's/^/ /' "$T/seal_diff.txt" | sed -n '1,20p'
207
207
  fi
208
208
  else
209
209
  ng "L10 seal 파일이 안 생겼다"
@@ -218,7 +218,7 @@ if bash "$PROBE" --self-test >/dev/null 2>&1; then ok "L11 compaction_probe --se
218
218
  mkdir -p "$T/mirror/scripts"
219
219
  cp "$PROBE" "$T/mirror/scripts/compaction_probe.sh"
220
220
  bash "$T/mirror/scripts/compaction_probe.sh" seal --transcript "$T/tr.jsonl" --dir "$T/seal_rv" >/dev/null 2>&1
221
- SFR="$(ls "$T/seal_rv"/seal_*.md 2>/dev/null | head -1)"
221
+ SFR="$(ls "$T/seal_rv"/seal_*.md 2>/dev/null | sed -n 1p)"
222
222
  if [ -n "$SFR" ] && grep -q "앞으로 무인 잡은 plist" "$SFR"; then
223
223
  ng "L12 추출기가 없는데도 발화가 실렸다 — seal 이 그 파일을 통해 돌지 않는다(배선 장식)"
224
224
  else
@@ -227,7 +227,7 @@ fi
227
227
  # known-positive 짝: 같은 미러에 추출기를 넣으면 살아난다
228
228
  cp "$EXTRACT" "$T/mirror/scripts/transcript_utterances.py"
229
229
  bash "$T/mirror/scripts/compaction_probe.sh" seal --transcript "$T/tr.jsonl" --dir "$T/seal_rv2" >/dev/null 2>&1
230
- SFR2="$(ls "$T/seal_rv2"/seal_*.md 2>/dev/null | head -1)"
230
+ SFR2="$(ls "$T/seal_rv2"/seal_*.md 2>/dev/null | sed -n 1p)"
231
231
  if [ -n "$SFR2" ] && grep -q "앞으로 무인 잡은 plist" "$SFR2"; then
232
232
  ok "L12b 추출기 복원 → 발화가 다시 실린다 (복원 확인 — L12 가 미러 자체의 사망이 아님)"
233
233
  else
@@ -314,9 +314,9 @@ NS_ON=$(python3 "$EXTRACT" "$T/tr_slash.jsonl" --min-chars 20 --strip-system-mar
314
314
  [ "$NS_OFF" -eq 0 ] && ok "L16 플래그 없으면 셋 다 커맨드로 제외 (옛 규칙 = seal 경로, 컨트롤)" \
315
315
  || ng "L16 플래그 없이 $NS_OFF 건 남았다 (기대 0) — seal 행동이 바뀌었다"
316
316
  [ "$NS_ON" -eq 1 ] && ok "L16b 플래그를 주면 경로형 실발화 1 건만 살아난다" || ng "L16b 플래그 켜고 $NS_ON 건 (기대 1)"
317
- python3 "$EXTRACT" "$T/tr_slash.jsonl" --min-chars 20 --strip-system-markers 2>/dev/null | grep -q "발표자 오티" \
317
+ python3 "$EXTRACT" "$T/tr_slash.jsonl" --min-chars 20 --strip-system-markers 2>/dev/null | grep -c "발표자 오티" >/dev/null \
318
318
  && ok "L16c 살아난 것이 **경로형 실발화** 다 (known-positive)" || ng "L16c 엉뚱한 것이 살아났다"
319
- python3 "$EXTRACT" "$T/tr_slash.jsonl" --min-chars 20 --strip-system-markers 2>/dev/null | grep -q "install-wizard" \
319
+ python3 "$EXTRACT" "$T/tr_slash.jsonl" --min-chars 20 --strip-system-markers 2>/dev/null | grep -c "install-wizard" >/dev/null \
320
320
  && ng "L16d 진짜 슬래시 커맨드가 살아남았다" || ok "L16d 진짜 슬래시 커맨드는 여전히 제외 (known-negative)"
321
321
 
322
322
  # ── L17 압축 이어붙임 프리앰블 (첫 실사용이 잡은 다섯째) ────────────────────
@@ -329,7 +329,7 @@ NC_ON=$(python3 "$EXTRACT" "$T/tr_cont.jsonl" --min-chars 20 --strip-system-mark
329
329
  NC_OFF=$(python3 "$EXTRACT" "$T/tr_cont.jsonl" --min-chars 20 2>/dev/null | grep -c .); case "$NC_OFF" in ''|*[!0-9]*) NC_OFF=0 ;; esac
330
330
  [ "$NC_ON" -eq 1 ] && ok "L17 압축 프리앰블 제외 · 실발화 1 건만 남는다" || ng "L17 플래그 켜고 $NC_ON 건 (기대 1)"
331
331
  [ "$NC_OFF" -eq 2 ] && ok "L17b 플래그 없으면 둘 다 통과 (컨트롤 — seal 행동 불변)" || ng "L17b 플래그 없이 $NC_OFF 건 (기대 2)"
332
- python3 "$EXTRACT" "$T/tr_cont.jsonl" --min-chars 20 --strip-system-markers 2>/dev/null | grep -q "등급 기댓값" \
332
+ python3 "$EXTRACT" "$T/tr_cont.jsonl" --min-chars 20 --strip-system-markers 2>/dev/null | grep -c "등급 기댓값" >/dev/null \
333
333
  && ok "L17c 남은 것이 실발화다 (known-positive)" || ng "L17c 실발화까지 버렸다"
334
334
 
335
335
  # ── L18 ①-f **행복 경로** — 전사본과 기록이 다 있을 때 실제로 판정까지 간다 ────
@@ -421,8 +421,8 @@ cat > "$T/tr23.jsonl" <<'JSONL'
421
421
  JSONL
422
422
  N23=$(python3 "$EXTRACT" "$T/tr23.jsonl" --min-chars 20 2>/dev/null | grep -c .); case "$N23" in ''|*[!0-9]*) N23=0 ;; esac
423
423
  [ "$N23" -eq 1 ] && ok "L23 isMeta·isSidechain 레코드 제외 · 표시 없는 1 건만 남는다" || ng "L23 $N23 건 (기대 1)"
424
- python3 "$EXTRACT" "$T/tr23.jsonl" --min-chars 20 2>/dev/null | grep -q "표시가 없는" && ok "L23b known-positive: 남은 것이 표시 없는 발화다" || ng "L23b 표시 없는 발화까지 버렸다"
425
- python3 "$EXTRACT" "$T/tr23.jsonl" --min-chars 20 2>/dev/null | grep -q "메타표시레코드\|사이드체인" && ng "L23c 표시된 레코드가 살아남았다" || ok "L23c 표시된 레코드는 없다 (known-negative)"
424
+ python3 "$EXTRACT" "$T/tr23.jsonl" --min-chars 20 2>/dev/null | grep -c "표시가 없는" >/dev/null && ok "L23b known-positive: 남은 것이 표시 없는 발화다" || ng "L23b 표시 없는 발화까지 버렸다"
425
+ python3 "$EXTRACT" "$T/tr23.jsonl" --min-chars 20 2>/dev/null | grep -c "메타표시레코드\|사이드체인" >/dev/null && ng "L23c 표시된 레코드가 살아남았다" || ok "L23c 표시된 레코드는 없다 (known-negative)"
426
426
 
427
427
  # ── L24 키 선택: 별칭 + 길이 대역 (2026-09-16) ──────────────────────────────
428
428
  # WHY. 「가장 긴 토큰 3 개」 휴리스틱이 **붙여쓴 절**을 키로 고른다 — 절은 정의상 가장 길고
@@ -379,7 +379,7 @@ rm -rf "$_L25"
379
379
  if grep -q 'TYPED_N=' "$S"; then
380
380
  # 🟥 초판 정규식은 `$TYPED_N / $TOTAL_N` 이라는 **표시용 구분자**를 나눗셈으로 오탐했다.
381
381
  # (오늘 그 축: 계기가 «형태»만 보고 «문맥»을 안 봤다.) ⇒ 산술 문맥 `$((…))` 안만 본다.
382
- if grep -oE '\$\(\([^)]*\)\)' "$S" 2>/dev/null | grep -E '(TYPED_N|FALLBACK_N)' | grep -qE '[*/]'; then
382
+ if grep -oE '\$\(\([^)]*\)\)' "$S" 2>/dev/null | grep -E '(TYPED_N|FALLBACK_N)' | grep -cE '[*/]' >/dev/null; then
383
383
  no "L26a 두 숫자를 결합하는 식이 있다 — 곱하면 어느 쪽이 나빠졌는지 못 본다"
384
384
  else ok "L26a 두 숫자 결합식 없음 (곱한 값이 소스에 없다)"; fi
385
385
  grep -q '② 규약 준수' "$S" && grep -q '① 폴백 도달' "$S" \
@@ -388,7 +388,7 @@ if grep -q 'TYPED_N=' "$S"; then
388
388
  cp "$S" "$S.l26bak"
389
389
  printf '\nBAD_RATIO=$((TYPED_N * 100))\n' >> "$S"
390
390
  if grep -q 'TYPED_N \* 100' "$S"; then
391
- if grep -oE '\$\(\([^)]*\)\)' "$S" 2>/dev/null | grep -E 'TYPED_N' | grep -qE '[*/]'; then ok "L26c [되돌림] 결합식을 넣으면 검사가 문다"
391
+ if grep -oE '\$\(\([^)]*\)\)' "$S" 2>/dev/null | grep -E 'TYPED_N' | grep -cE '[*/]' >/dev/null; then ok "L26c [되돌림] 결합식을 넣으면 검사가 문다"
392
392
  else no "L26c 결합식을 넣었는데 검사가 안 문다 — L26a 는 장식이다"; fi
393
393
  else no "L26c 되돌림 적용 실패"; fi
394
394
  mv -f "$S.l26bak" "$S"
@@ -408,7 +408,7 @@ else no "L27 프로브 없음 — 검사 못 함(스킵 아님)"; fi
408
408
  # 「deliver 가 규약 준수를 죽인다」는 «발견» 으로 낼 뻔했다.
409
409
  # 🟥 known-pair 를 «한 인자씩» 만 돌리면 조합이 여는 경로를 구조적으로 못 본다.
410
410
  if grep -q 'DELIVER" = 1 \] && \[ "$arm" = ARM' "$S"; then
411
- _dl=$(grep -n 'DELIVER" = 1 \] && \[ "$arm" = ARM' "$S" | head -1 | cut -d: -f1)
411
+ _dl=$(grep -n 'DELIVER" = 1 \] && \[ "$arm" = ARM' "$S" | sed -n 1p | cut -d: -f1)
412
412
  _blk=$(sed -n "${_dl},$((_dl+4))p" "$S")
413
413
  if printf '%s' "$_blk" | grep -q '^\$question"$'; then
414
414
  no "L28 deliver 분기가 \$question 을 다시 읽는다 — 규약이 버려진다"
@@ -166,7 +166,7 @@ mk_pair "$T/m"; M="$T/m/main"; W="$T/m/wt"; mkdir -p "$W/tracks/_meta" "$W/node_
166
166
  printf 'tracks/\nnode_modules/\n' > "$W/.gitignore" # 🟥 ignored 여야 SKIP (B-7: untracked 는 막는다)
167
167
  echo j > "$W/node_modules/x/p.js"
168
168
  OUT="$(bash "$SUT" "$W" 2>&1)"; RC=$?
169
- L="$(ls -t "$M"/tracks/_meta/dispatch/reclaim_wt_*.txt 2>/dev/null | head -1)"
169
+ L="$(ls -t "$M"/tracks/_meta/dispatch/reclaim_wt_*.txt 2>/dev/null | sed -n 1p)"
170
170
  if [ "$RC" -eq 0 ] && printf '%s' "$OUT" | grep -q "non-blocking: skipped 1" \
171
171
  && [ -n "$L" ] && grep -q "^SKIP node_modules/x/p.js" "$L"; then
172
172
  ok "W7e 제외분은 «버리는» 게 아니라 «세고 목록에 남긴다» — 과소차단 방향이 더는 무음이 아니다"
@@ -128,7 +128,7 @@ readme_first_screen_touched() { # $1 = staged README path
128
128
  # 🟥 No hunks is NOT "nothing changed above the fold". `git diff -U0` prints no @@ for a
129
129
  # binary blob or a pure rename, so returning false here renders UNMEASURED as none — the
130
130
  # exact family this repo keeps closing. Measure whether the file is staged at all first.
131
- git diff --cached --name-only -- "$file" 2>/dev/null | grep -q . || return 1 # genuinely unstaged
131
+ git diff --cached --name-only -- "$file" 2>/dev/null | grep -c . >/dev/null || return 1 # genuinely unstaged
132
132
  return 0 # staged but unreadable → fail closed
133
133
  fi
134
134
  while IFS= read -r h; do
@@ -641,7 +641,7 @@ else
641
641
  GUARD_RESULT_FILE=$(mktemp "${TMPDIR:-/tmp}/fh_guard_result.XXXXXX")
642
642
  GUARD_OUT="$(REGRESSION_GUARD_RESULT_FILE="$GUARD_RESULT_FILE" bash "$GUARD" --staged 2>&1)" || GUARD_EXIT=$?
643
643
  printf '%s\n' "$GUARD_OUT"
644
- GUARD_VERDICT=$(sed -n 's/^result=//p' "$GUARD_RESULT_FILE" 2>/dev/null | head -1)
644
+ GUARD_VERDICT=$(sed -n 's/^result=//p' "$GUARD_RESULT_FILE" 2>/dev/null | sed -n 1p)
645
645
  rm -f "$GUARD_RESULT_FILE"
646
646
  # 일관성 검사 (challenger C-1): exit 코드와 typed verdict 가 어긋나면 게이트 계기 오류다 —
647
647
  # 특히 중도 crash(exit 1, 파일 미작성)가 "S-tier 경고, 커밋 허용"으로 렌더되던 구멍.
@@ -600,10 +600,40 @@ print('OK')
600
600
  # NOTE: combined-count is a PRESENCE heuristic, not semantic equivalence — an
601
601
  # unrelated detail-file line can absorb the count. True equivalence is owned by
602
602
  # F2 (critical sections) + the Axis 2/3 review, not this counter.
603
+ # Python files: real comments are prose, not verdict surface. A `PASS` that lived only in a
604
+ # comment was counted as an operational token, so rewording one comment read as 100% loss and
605
+ # hard-blocked an otherwise clean port (measured 2026-11-04: a downstream harness's
606
+ # utterance_checklist_hook.py, `PASS` 1 -> 0, the only hit a comment). Comments are found by
607
+ # Python's own tokenizer, not by a `^#` line match: a `#` line inside a string or heredoc is
608
+ # data and keeps counting (cross-family review showed the line match erased it). If the
609
+ # tokenizer cannot run or parse either side, both sides are counted unfiltered — the stricter
610
+ # direction. Only the comment token's own text is removed, and only after checking that exactly
611
+ # that text sits at the tokenizer's reported position; any mismatch exits non-zero, which falls
612
+ # back to unfiltered counting. (Rebuilding lines from row numbers was tried first and was wrong
613
+ # twice under cross-family review: form feeds and lone CRs shift rows.) Shell files are deliberately NOT filtered: heredocs and multi-line strings make
614
+ # a `#` line ambiguous there, and no shell false positive has been observed.
615
+ f4_before=$before_content; f4_after=$after_content
616
+ case "$f" in
617
+ *.py)
618
+ _f4_strip='import sys,io,tokenize
619
+ lines=io.StringIO(sys.stdin.read()).readlines(); it=iter(lines); out=list(lines)
620
+ for t in tokenize.generate_tokens(lambda: next(it, "")):
621
+ if t.type!=tokenize.COMMENT: continue
622
+ r,c=t.start
623
+ if r>len(out) or out[r-1][c:c+len(t.string)]!=t.string: sys.exit(3)
624
+ out[r-1]=out[r-1][:c]+out[r-1][c+len(t.string):]
625
+ sys.stdout.write("".join(out))'
626
+ if _f4b=$(printf '%s\n' "$before_content" | python3 -c "$_f4_strip" 2>/dev/null) \
627
+ && _f4a=$(printf '%s\n' "$after_content" | python3 -c "$_f4_strip" 2>/dev/null); then
628
+ f4_before=$_f4b; f4_after=$_f4a
629
+ else
630
+ verbose "F4: python tokenizer unavailable or failed on $f — counting comments too (stricter)"
631
+ fi ;;
632
+ esac
603
633
  if [ "$is_deprecated" -eq 0 ]; then
604
634
  for token in "M-tier" "S-tier" "R-tier" "PASS" "BLOCK" "Wave 0" "Wave 1" "Wave 4" "Step 0" "Step 1" "Step 2" "Step 3" "Step 4" "fan-in" "Done When"; do
605
- before=$(count_in "$before_content" "$token")
606
- after=$(count_in "$after_content" "$token")
635
+ before=$(count_in "$f4_before" "$token")
636
+ after=$(count_in "$f4_after" "$token")
607
637
  if [ "$before" -gt 0 ] && [ "$after" -lt "$before" ]; then
608
638
  if [ -n "$detail_content" ]; then
609
639
  in_detail=$(_gain count_in "$token")