@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
@@ -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
 
@@ -14,6 +14,9 @@
14
14
  # answers "run it".
15
15
  # S7 every shard owns at least one suite for N in 2..4 (an empty shard is a wasted runner and a
16
16
  # sign the plan collapsed).
17
+ # S8 shard 1 ACTUALLY runs the inline checks (the ~39 non-suite decisions it alone owns).
18
+ # S1..S7 are dry runs and `_shard_inline` answers "skip" in dry mode, so none of them can
19
+ # see this axis; breaking it leaves every leg green with those 39 checks run nowhere.
17
20
  # The runs are DRY (`--shard-dry`): nothing is executed, the decision is appended to $FH_SHARD_TRACE.
18
21
  # So this suite costs seconds, and it cannot recurse into itself (a dry run never runs a suite).
19
22
  set -u
@@ -121,6 +124,47 @@ else
121
124
  printf '%s' "$res" | grep -qx 'inlineskip=1'; chk $? "S6 without --shard no inline check is skipped"
122
125
  fi
123
126
 
127
+ # ── S8 shard 1 ACTUALLY runs the inline checks ───────────────────────────────────────────────
128
+ # WHY THIS LANE EXISTS (measured 2026-11-02, weekly clean-room audit). S1..S7 all run with
129
+ # `--shard-dry`, and in dry mode `_shard_inline` returns 1 BY CONSTRUCTION β€” so every lane above
130
+ # holds the SUITE assignment and none of them can say anything about the inline checks that
131
+ # shard 1 alone owns: the syntax scans, the nine named checkers routed through the `bash` shim
132
+ # (count_check Β· prepush_guard_check Β· gate_anchor_check Β· multibyte_bracket_lint Β·
133
+ # package_coverage_check Β· files_manifest_shipping_check Β· lane_runner_check Β· gate_pathspec_check
134
+ # Β· sync_guard_check) and every `--self-test` entry point β€” 39 decisions in the dry trace.
135
+ # The hole is silent in the direction this repo calls hollow green: 8 of the 11 `_shard_inline_skip`
136
+ # call sites are `then :`, so a skipped inline check never sets `fail=1`. Measured with the mutant
137
+ # below: with `_shard_inline` answering "skip" always, EVERY leg SHARD-SKIPs all 39, no leg runs
138
+ # them, selfcheck exits 0, and this suite reported 31 passed / 0 failed. Nothing was red anywhere.
139
+ # S6 does not cover it either: S6 asks the no-`--shard` case, which is `npm test`, not a CI leg.
140
+ if [ ! -f "$T/block.sh" ]; then
141
+ chk 1 "S8 the lifted shard block is available (S6 did not produce it β€” lane would test nothing)"
142
+ else
143
+ # one answer pair from the lifted block, run with the given arguments: "<_shard_inline rc> <_shard_inline_skip rc>"
144
+ inline_answer() { # $1 = block file, $2.. = arguments as selfcheck would receive them
145
+ local _bf="$1"; shift
146
+ ( cd "$ROOT" && env -u FH_SELFCHECK_SHARD bash -c '
147
+ f="$1"; shift
148
+ . "$f"
149
+ _shard_inline; a=$?
150
+ _shard_inline_skip LBL >/dev/null 2>&1; b=$?
151
+ echo "$a $b"' _ "$_bf" "$@" 2>/dev/null | tail -1 )
152
+ }
153
+ a_leg1=$(inline_answer "$T/block.sh" --shard 1/4)
154
+ a_leg2=$(inline_answer "$T/block.sh" --shard 2/4)
155
+ a_dry1=$(inline_answer "$T/block.sh" --shard 1/4 --shard-dry)
156
+ [ "$a_leg1" = "0 1" ]; chk $? "S8 --shard 1/4 (not dry): the inline checks RUN here (got '$a_leg1', want '0 1')"
157
+ [ "$a_leg2" = "1 0" ]; chk $? "S8 known-negative: --shard 2/4 skips them, so S8 is not a lane that always passes (got '$a_leg2', want '1 0')"
158
+ [ "$a_dry1" = "1 0" ]; chk $? "S8 control: the DRY form every lane above uses answers 'skip' even for shard 1 (got '$a_dry1') β€” that is why S1..S7 cannot hold this axis"
159
+
160
+ # KNOWN-NEGATIVE on the detector itself: break inline dispatch with one line. If S8 cannot go
161
+ # red on this, it proves nothing about the subject (same construction as S5).
162
+ sed 's|^ \[ "\$_SHARD_I" = 1 \]$| false|' "$T/block.sh" > "$T/block_mut.sh"
163
+ cmp -s "$T/block.sh" "$T/block_mut.sh"; chk $((1 - $?)) "S8 control: the mutation APPLIED β€” if this is red the \$_SHARD_I line moved, so S8's known-negative below is VOID, not the subject's fault"
164
+ a_mut=$(inline_answer "$T/block_mut.sh" --shard 1/4)
165
+ [ "$a_mut" != "0 1" ]; chk $? "S8 known-negative: with inline dispatch broken, shard 1 no longer runs them (got '$a_mut') β€” the detector can fail"
166
+ fi
167
+
124
168
  # ── notes (printed, never a verdict) ────────────────────────────────────────────────────────
125
169
  if [ -f "$ROOT/scripts/selfcheck_shard_weights.txt" ]; then
126
170
  awk 'NF >= 2 && $1 ~ /^[0-9.]+$/ && $2 != "@inline" { print $2 }' "$ROOT/scripts/selfcheck_shard_weights.txt" | LC_ALL=C sort -u > "$T/w.names"
@@ -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 κ²½κ³ , 컀밋 ν—ˆμš©"으둜 λ Œλ”λ˜λ˜ ꡬ멍.
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/env zsh
2
+ # forge-harness β€” periodic audit reminder (zshrc hook template)
3
+ #
4
+ # Checks elapsed days for each audit item every time a terminal opens,
5
+ # and prints a warning if the threshold is exceeded.
6
+ #
7
+ # ── Installation ──────────────────────────────────────────
8
+ #
9
+ # 1. Set environment variables in .zshrc:
10
+ #
11
+ # export FH_DIR="$HOME/path/to/forge-harness" # required
12
+ # export CC_HUB_DIR="$HOME/path/to/your-cc-hub" # if you have a CC hub
13
+ # export CC_SENTINELS_DIR="$HOME/.cc_sentinels" # project sentinels (optional)
14
+ #
15
+ # 2. Load the function using one of:
16
+ #
17
+ # a) source "$FH_DIR/templates/fh_audit_check.zsh" # source file directly
18
+ # b) Paste the contents of this file into .zshrc # standalone
19
+ #
20
+ # ── Auto-run (opt-in) ─────────────────────────────────────
21
+ #
22
+ # Default is manual run (call _fh_audit_check directly).
23
+ # To auto-run on terminal start, add to .zshrc:
24
+ #
25
+ # export FH_AUDIT_AUTO=1
26
+ #
27
+ # ── Sentinel-based project audits ─────────────────────────
28
+ #
29
+ # Quarterly/monthly project audits are tracked via sentinel files.
30
+ # After completing an audit, touch the sentinel to reset the warning.
31
+ #
32
+ # mkdir -p ~/.cc_sentinels
33
+ # touch ~/.cc_sentinels/my_project_pfd # record audit completion
34
+ # export CC_SENTINEL_MY_PROJECT_PFD_DAYS=90 # set 90-day threshold
35
+ #
36
+ # ──────────────────────────────────────────────────────────
37
+
38
+ # mtime lookup (macOS / Linux compatible) β€” **GNU-first, and the order is load-bearing**.
39
+ # This was BSD-first (`stat -f %m || stat -c %Y`) and that is silently wrong on GNU/Linux: `-f`
40
+ # there means `--file-system`, so on a regular file it exits 0 and prints a filesystem report
41
+ # instead of an epoch β€” the `||` fallback never runs and the caller gets a multi-line blob that
42
+ # compares as garbage. Fixed 2026-08-15 after the identical bug was measured in
43
+ # scripts/digest_landing_check.sh (macOS 10/10 PASS Β· ubuntu 1/10 FAIL). Every other _mtime helper
44
+ # in this repo is already GNU-first (scripts/sync-from-be.sh:116 Β· scripts/fh_session_load.sh:105
45
+ # carry the same warning); this template copy was the straggler, and it ships to field harnesses.
46
+ _fh_mtime() { stat -c %Y "$1" 2>/dev/null || stat -f %m "$1" 2>/dev/null || echo 0; }
47
+
48
+ _fh_audit_check() {
49
+ # The caller's zshrc must not leak options in: under KSH_ARRAYS `${arr[1]}` is the SECOND newest
50
+ # file, so a current audit would read as overdue (cross-family codex, 2026-09-27). Local reset.
51
+ emulate -L zsh
52
+ local -a warns=()
53
+ local now
54
+ now=$(date +%s)
55
+
56
+ # β‘  weekly_audit β€” 7-day threshold (when CC_HUB_DIR is set)
57
+ # πŸŸ₯ This used to glob `tracks/_meta/harvest_*.md`, a filename NOTHING writes (harvest-loop's
58
+ # SKILL*.md writes skill_usage.md Β· edit_manifest.yaml Β· fh_signal_*, never harvest_*). So the
59
+ # Β«No harvest historyΒ» line was unsatisfiable: it fired on every terminal open for every user,
60
+ # forever (measured 2026-09-26 on a hub whose latest weekly audit was 2 days old). The artifact
61
+ # the canonical cadence table names (CLAUDE.md Β§Cadence Rules Β· install-wizard Β§Step1-Checks
62
+ # `weekly_audit latest`) is `tracks/_audit/weekly_audit_*.md` β€” check THAT.
63
+ # Guard stays on the dir existing (`tracks/_audit/.gitkeep` ships in every clone), so a
64
+ # missing history still warns: not-found is not zero.
65
+ if [[ -n "${CC_HUB_DIR}" && -d "${CC_HUB_DIR}/tracks/_audit" ]]; then
66
+ local aud
67
+ # zsh: an unmatched glob is a SHELL error raised before `ls` runs β€” the `2>/dev/null` belongs to
68
+ # ls, so `_fh_audit_check:N: no matches found: …` printed on every terminal open of a hub with no
69
+ # harvest files (measured 2026-09-04). πŸŸ₯ The obvious fix β€” appending `(N)` to the ls argument β€”
70
+ # is WRONG and was measured wrong the same day: the null glob drops the word entirely, `ls -t`
71
+ # then lists the CURRENT DIRECTORY, `head -1` returns an unrelated file, and the Β«No harvest
72
+ # historyΒ» warning silently disappears (not-found rendered as found). Collect into an array with
73
+ # `(N.om)` (null-glob Β· plain files Β· newest-first) and read element 1 β€” empty array β‡’ empty aud.
74
+ local -a _fh_audits
75
+ _fh_audits=( "${CC_HUB_DIR}/tracks/_audit"/weekly_audit_*.md(N.om) )
76
+ aud="${_fh_audits[1]:-}"
77
+ if [[ -n "$aud" ]]; then
78
+ local d=$(( (now - $(_fh_mtime "$aud")) / 86400 ))
79
+ (( d >= 7 )) && warns+=("weekly_audit ${d}d elapsed β†’ run the weekly audit (/harvest-loop lightweight) in your CC hub cwd")
80
+ else
81
+ warns+=("No weekly audit history (tracks/_audit/weekly_audit_*.md) β†’ run the weekly audit (/harvest-loop lightweight) in your CC hub cwd")
82
+ fi
83
+ fi
84
+
85
+ # β‘‘ frontier_digest β€” 7-day threshold (when CC_HUB_DIR is set)
86
+ # πŸŸ₯ Same defect class as β‘ : this globbed `knowledge/shared/harness-core/harness_frontier_
87
+ # diagnosis_*.md` at 90d and told you to Β«run /frontier-digestΒ» β€” but /frontier-digest writes
88
+ # `tracks/_meta/frontier_digest_*.md` (frontier-digest SKILL.md --save), never the diagnosis
89
+ # file. Running the advised command could not reset the clock, and the diagnosis file's mtime
90
+ # moves on unrelated edits. Aligned to CLAUDE.md Β§Cadence Rules (7d on frontier_digest_*.md).
91
+ # Absent history stays silent, as before (not every install runs digests).
92
+ if [[ -n "${CC_HUB_DIR}" && -d "${CC_HUB_DIR}/tracks/_meta" ]]; then
93
+ local -a _fh_digests
94
+ _fh_digests=( "${CC_HUB_DIR}/tracks/_meta"/frontier_digest_*.md(N.om) )
95
+ local fd="${_fh_digests[1]:-}"
96
+ if [[ -n "$fd" ]]; then
97
+ local d=$(( (now - $(_fh_mtime "$fd")) / 86400 ))
98
+ (( d >= 7 )) && warns+=("frontier_digest ${d}d elapsed β†’ run /frontier-digest --save in your CC hub cwd")
99
+ fi
100
+ fi
101
+
102
+ # β‘’ FH sim Area B β€” REMOVED 2026-10-19 (operator decision Β«μ‚¬κ±΄κΈ°μ€€μœΌλ‘œ λ°”κΏ”μ€˜Β»).
103
+ # Area B used to nag here on a 30-day clock. It is now event-bound: run it before a minor/major
104
+ # release or a public announcement (templates/PRE-PUBLISH-CHECKLIST.md Β§Read it as a reader;
105
+ # sim-conductor SKILL.md Β§Frequency limits). A terminal opening is not that event, so this
106
+ # banner no longer has an Area B line. The 7-day minimum-interval guard stays in the skill.
107
+ # Lanes: scripts/test_fh_audit_check_lanes.sh β‘’ asserts the line is gone even at 116d.
108
+
109
+ # β‘£ Custom sentinels β€” per-file threshold in CC_SENTINELS_DIR (optional)
110
+ # Uppercase filename = env var key: CC_SENTINEL_{NAME}_DAYS (default 90)
111
+ # πŸŸ₯ The same directory also holds STATE markers written by install-wizard and
112
+ # scripts/fh_env_delta_scan.sh β€” `*_wizard_done` Β· `*_mapping_skipped` Β· `*_wizard_declined` Β·
113
+ # `*_wizard_reminder_muted`. They record that something happened, not when an audit is due; aging
114
+ # them as 90-day clocks produced false lines (and Β«touch … to resetΒ» would falsify a state
115
+ # record). They are skipped by suffix. Any other file is still a custom audit sentinel.
116
+ if [[ -n "${CC_SENTINELS_DIR}" && -d "${CC_SENTINELS_DIR}" ]]; then
117
+ for f in "${CC_SENTINELS_DIR}"/*(N); do
118
+ [[ -f "$f" ]] || continue
119
+ case "${f:t}" in
120
+ *_wizard_done|*_mapping_skipped|*_wizard_declined|*_wizard_reminder_muted) continue ;;
121
+ esac
122
+ local name="${${f:t}:u}"
123
+ local key="CC_SENTINEL_${name}_DAYS"
124
+ local threshold="${(P)key:-90}"
125
+ local d=$(( (now - $(_fh_mtime "$f")) / 86400 ))
126
+ (( d >= threshold )) && warns+=("${f:t} sentinel ${d}d elapsed β†’ touch ${f} to reset")
127
+ done
128
+ fi
129
+
130
+ # Output
131
+ (( ${#warns[@]} == 0 )) && return
132
+ print ""
133
+ print "\033[33m── forge-harness Audit Reminders ────────────────────────\033[0m"
134
+ for w in "${warns[@]}"; do
135
+ print "\033[33m ⚠ ${w}\033[0m"
136
+ done
137
+ print "\033[33m────────────────────────────────────────────────────────\033[0m"
138
+ print ""
139
+ }
140
+ [[ "${FH_AUDIT_AUTO:-0}" == "1" ]] && _fh_audit_check
@@ -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")
@@ -38,7 +38,8 @@
38
38
  "counterweight is mechanical. Net-new coverage is the LOCAL destructive ops no git hook sees;",
39
39
  "the pre-push hook remains the hard floor for the push-time surface (role deconfliction in the",
40
40
  "script header). Advisory by design, same contract as pipe_verdict_guard (additionalContext +",
41
- "systemMessage, no permissionDecision); escalate with FH_DESTRUCTIVE_BLOCK=1. Opt out with",
41
+ "systemMessage, no permissionDecision); escalate with FH_DESTRUCTIVE_BLOCK=1. Under",
42
+ "permission_mode=bypassPermissions it blocks by default (FH_DESTRUCTIVE_BLOCK=0 keeps advisory). Opt out with",
42
43
  "`# noqa: destructive-op` β€” the opt-out exempts the ENTIRE Bash payload (whole-command match),",
43
44
  "not a single line: a multi-statement payload with a destructive line 1 and a noqa on line 2 is",
44
45
  "fully exempt (accepted advisory-surface residual β€” see the script header's PRECISION OVER RECALL list).",