@chrono-meta/fh-gate 3.27.0 → 3.29.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 (71) hide show
  1. package/.claude-plugin/marketplace.json +4 -4
  2. package/CHEATSHEET.md +2 -2
  3. package/CLAUDE.md +6 -3
  4. package/README.ja.md +2 -4
  5. package/README.ko.md +2 -4
  6. package/README.md +19 -19
  7. package/README.zh.md +2 -4
  8. package/docs/REFERENCE.md +4 -1
  9. package/knowledge/shared/harness-core/claude_md_full_reference.md +2 -0
  10. package/knowledge/shared/harness-core/claude_md_gate_details.md +7 -0
  11. package/knowledge/shared/harness-core/dispatch_conditional_prohibition.md +12 -0
  12. package/knowledge/shared/harness-core/fh_module_contract.md +97 -0
  13. package/knowledge/shared/harness-core/fh_three_layer_canon.md +12 -0
  14. package/knowledge/shared/harness-core/measurement-integrity-checklist.md +16 -0
  15. package/knowledge/shared/learnings/subagent_invocations_log.yaml +137 -0
  16. package/package.json +12 -1
  17. package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
  18. package/plugins/fh-commons/skills/ko-tech-writer/SKILL.md +84 -4
  19. package/plugins/fh-commons/skills/ko-tech-writer/fh-module.yaml +19 -0
  20. package/plugins/fh-commons/skills/ko-tech-writer/fixtures/known_negative.md +73 -1
  21. package/plugins/fh-commons/skills/ko-tech-writer/fixtures/known_positive.md +39 -1
  22. package/plugins/fh-commons/skills/ko-tech-writer/fixtures/known_unclosed.md +6 -0
  23. package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
  24. package/plugins/fh-meta/CHANGELOG.md +32 -0
  25. package/plugins/fh-meta/skills/auto-decorrelation/SKILL.md +17 -0
  26. package/plugins/fh-meta/skills/frontier-digest/SKILL.md +14 -10
  27. package/plugins/fh-meta/skills/frontier-digest/SKILL_detail.md +17 -1
  28. package/plugins/fh-meta/skills/sim-conductor/SKILL.md +2 -2
  29. package/plugins/fh-meta/skills/sim-conductor/SKILL_detail.md +3 -3
  30. package/plugins/fh-meta/skills/steel-quench/SKILL.md +25 -1
  31. package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
  32. package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
  33. package/scripts/degrade_direction_scan.sh +43 -0
  34. package/scripts/dispatch_receipt.py +185 -0
  35. package/scripts/doc_claim_triad_scan.py +43 -4
  36. package/scripts/fh-gate.sh +71 -11
  37. package/scripts/fh_module_check.py +686 -0
  38. package/scripts/finding_fleet.sh +15 -3
  39. package/scripts/fixtures/frontier_digest_recall.tsv +5 -0
  40. package/scripts/ko_tech_writer_calibrate.py +288 -15
  41. package/scripts/package_coverage_check.sh +5 -0
  42. package/scripts/probe_live_eval.sh +19 -1
  43. package/scripts/probe_live_eval_lib.py +174 -5
  44. package/scripts/resident_cost.py +1 -1
  45. package/scripts/selfcheck.sh +48 -21
  46. package/scripts/session_checklist.py +214 -5
  47. package/scripts/session_close_check.sh +44 -0
  48. package/scripts/sim_isolated_run.sh +31 -0
  49. package/scripts/test_claude_md_size_lanes.sh +22 -7
  50. package/scripts/test_degrade_scan_shell_probes.sh +81 -0
  51. package/scripts/test_dispatch_receipt_lanes.sh +95 -0
  52. package/scripts/test_doc_claim_triad_lanes.sh +30 -0
  53. package/scripts/test_fh_audit_check_lanes.sh +10 -5
  54. package/scripts/test_fh_gate_regressions.sh +71 -1
  55. package/scripts/test_fh_module_check_lanes.sh +581 -0
  56. package/scripts/test_finding_pipeline_lanes.sh +83 -0
  57. package/scripts/test_frontier_digest_recall.sh +26 -0
  58. package/scripts/test_frontier_digest_recall_negctl.sh +15 -0
  59. package/scripts/test_ko_tech_writer_lanes.sh +1 -1
  60. package/scripts/test_locale_invariance_lanes.sh +19 -0
  61. package/scripts/test_mutation_probe_lanes.sh +22 -6
  62. package/scripts/test_probe_live_eval_lanes.sh +116 -0
  63. package/scripts/test_resident_cost_lanes.sh +1 -1
  64. package/scripts/test_selfcheck_state_lanes.sh +32 -0
  65. package/scripts/test_session_checklist_lanes.sh +167 -0
  66. package/scripts/test_sim_isolated_run_lanes.sh +51 -0
  67. package/scripts/test_utterance_checklist_hook_lanes.sh +175 -0
  68. package/scripts/utterance_checklist_hook.py +193 -0
  69. package/scripts/utterance_checklist_hook.sh +31 -0
  70. package/templates/PRE-PUBLISH-CHECKLIST.md +10 -0
  71. package/templates/degrade_direction_scan.sh +43 -0
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env bash
2
+ # test_frontier_digest_recall.sh — structural recall regression for the frontier digest source list.
3
+ # Known-positive items (fixtures/frontier_digest_recall.tsv) must each have >=1 announcing channel
4
+ # present in SKILL.md Step 1. No live fetch, no LLM. Exit 0 = all covered, 1 = a gap.
5
+ # Env: FD_SKILL_FILE overrides the SKILL.md path (used by the negative control).
6
+ set -uo pipefail
7
+ D="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ SKILL="${FD_SKILL_FILE:-$D/../plugins/fh-meta/skills/frontier-digest/SKILL.md}"
9
+ FIX="${FD_RECALL_FIXTURE:-$D/fixtures/frontier_digest_recall.tsv}"
10
+ [ -f "$SKILL" ] && [ -f "$FIX" ] || { echo "HARNESS-ERROR: missing skill or fixture"; exit 10; }
11
+ # ids = backticked ids in Step-1 table rows (lines starting with '| ' and containing a backticked id in col 1)
12
+ IDS=$(awk -F'|' '/^## Step 1\./{on=1;next} /^## /{on=0} on&&/^\| /{print $2}' "$SKILL" | grep -oE '`[a-z0-9-]+`' | tr -d '`' | sort -u)
13
+ [ -n "$IDS" ] || { echo "HARNESS-ERROR: no channel ids parsed (instrument mismatch)"; exit 10; }
14
+ echo "channels: $(echo $IDS | tr '\n' ' ')"
15
+ FAIL=0; N=0
16
+ while IFS=$'\t' read -r item kind chans || [ -n "$item" ]; do
17
+ case "$item" in ''|'#'*) continue;; esac
18
+ N=$((N+1))
19
+ hit=""
20
+ for c in $(echo "$chans" | tr ',' ' '); do echo "$IDS" | grep -qx "$c" && hit="$hit $c"; done
21
+ if [ -n "$hit" ]; then echo "PASS $item ($kind) covered by:$hit"; else echo "FAIL $item ($kind) — none of [$chans] in Step 1"; FAIL=1; fi
22
+ done < "$FIX"
23
+ # an empty or truncated fixture must not pass vacuously
24
+ echo "checked $N items"
25
+ [ "$N" -ge 3 ] || { echo "HARNESS-ERROR: only $N fixture rows (floor 3)"; exit 10; }
26
+ exit $FAIL
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env bash
2
+ # Negative control for test_frontier_digest_recall.sh: remove channels from a COPY of SKILL.md and
3
+ # require the lane to go red; also require the unmodified file to be green (known pair).
4
+ set -uo pipefail
5
+ D="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
+ SK="$D/../plugins/fh-meta/skills/frontier-digest/SKILL.md"
7
+ T=$(mktemp -d); trap 'rm -rf "$T"' EXIT
8
+ bash "$D/test_frontier_digest_recall.sh" >/dev/null; [ $? -eq 0 ] || { echo "FAIL control: real file not green"; exit 1; }
9
+ # Aside needs launch-yc or product-hunt: drop both -> red. (apply check: rows really removed)
10
+ grep -v -E '^\| (Launch YC|Product Hunt) ' "$SK" > "$T/s.md"
11
+ [ "$(wc -l < "$T/s.md")" -lt "$(wc -l < "$SK")" ] || { echo "HARNESS-ERROR: mutation not applied"; exit 10; }
12
+ O1=$(FD_SKILL_FILE="$T/s.md" bash "$D/test_frontier_digest_recall.sh"); echo "$O1" | grep -q '^FAIL Aside' && echo "PASS negctl: removing Launch YC+Product Hunt turns Aside red" || { echo "FAIL negctl: lane stayed green"; exit 1; }
13
+ # Single removal must NOT turn Aside red (redundancy) but removing all of show-hn/PH/geeknews reds Orca.
14
+ grep -v -E '^\| (Show HN|Product Hunt|GeekNews) ' "$SK" > "$T/s2.md"
15
+ O2=$(FD_SKILL_FILE="$T/s2.md" bash "$D/test_frontier_digest_recall.sh"); echo "$O2" | grep -q '^FAIL Orca' && echo "PASS negctl: removing Show HN+PH+GeekNews turns Orca red" || { echo "FAIL negctl 2"; exit 1; }
@@ -27,7 +27,7 @@
27
27
  # 세 허용 엔진 중 어디에나 있는 유일한 것이다.
28
28
  #
29
29
  # ─────────────────────────────────────────────────────────────────────────────
30
- # 무엇이 재어지는가 — Step 2 다섯 클래스 + Step 4-b 두 패턴
30
+ # 무엇이 재어지는가 — Step 2 클래스(C1-C5, C7-C12) + Step 4-b 두 패턴
31
31
  # ─────────────────────────────────────────────────────────────────────────────
32
32
  # Step 2 C1 줄표 이어붙임 · C2 용어-머리 · C3 콜론 나열투 · C4 조각문 · C5 소유 직역
33
33
  # Step 4-b C6 전칭 어휘 · C6b 부정형 전칭
@@ -59,6 +59,25 @@ KO='성공 정의는 이것이고 절대 안 하는 것은 저것이다'
59
59
 
60
60
  # ── 계기 교정 ②: 이 기계에서 위험이 «실재하나» — wc -w 가 실제로 갈리는지 먼저 보인다.
61
61
  # 안 갈리면(예: POSIX 구현이 멀티바이트를 알아서 처리) 아래 레인들은 아무것도 못 가른다.
62
+ # 🟥 2026-10-20: ubuntu 26.04 의 `wc` 는 uutils(Rust) 0.10 이라 POSIX 에서도 한글을 8 낱말로
63
+ # 센다(8/8) — 그래서 이 스위트가 L0 에서 rc=2 로 끝났고, wc 와 무관한 레인(L9 브래킷 fail-OPEN ·
64
+ # L11–L14)까지 같이 안 돌았다(main 이 빨개진 원인, #928). 그 이미지에도 GNU 판이 `gnuwc` 로
65
+ # 들어 있고 그건 갈린다(11/8). 되돌림 프로브가 재는 것은 «옛 훅이 쓰던 `wc -w` 가 로케일로
66
+ # 갈리는 기계»이므로, 시스템 wc 가 안 갈릴 때만 **실제로 갈리는** 후보를 찾아 PATH 앞에 둔다.
67
+ # 고르는 기준은 이름이 아니라 실측(같은 KO 를 두 로케일로 세어 달라야 채택). 하나도 없으면
68
+ # 종전대로 rc=2 — 대조군 없는 초록은 측정이 아니다.
69
+ _wc_splits(){ [ "$(LC_ALL=POSIX bash -c 'printf "%s" "$1" | "$0" -w | tr -d " "' "$1" "$KO")" \
70
+ != "$(LC_ALL="$UTF8" bash -c 'printf "%s" "$1" | "$0" -w | tr -d " "' "$1" "$KO")" ]; }
71
+ if ! _wc_splits wc; then
72
+ for _wc in gnuwc gwc; do
73
+ _wcp=$(command -v "$_wc" 2>/dev/null) || continue
74
+ if _wc_splits "$_wcp"; then
75
+ mkdir -p "$T/wcbin" && ln -s "$_wcp" "$T/wcbin/wc" && export PATH="$T/wcbin:$PATH"
76
+ echo " wc 계기: $_wcp (시스템 wc 는 로케일로 안 갈린다 — 갈리는 구현으로 대조군을 세운다)"
77
+ break
78
+ fi
79
+ done
80
+ fi
62
81
  w_posix=$(LC_ALL=POSIX bash -c 'printf "%s" "$1" | wc -w | tr -d " "' _ "$KO")
63
82
  w_utf8=$(LC_ALL="$UTF8" bash -c 'printf "%s" "$1" | wc -w | tr -d " "' _ "$KO")
64
83
  _t "L0 계기 교정 — 이 기계에서 \`wc -w\` 가 로케일로 갈린다"
@@ -650,15 +650,31 @@ grep -qE 'invalid=0' <<<"$out" && grep -qE 'mutants=2 killed=1 survived=1 ' <<<"
650
650
 
651
651
  echo "── R7: blind review of v7 (2026-10-08) — each lane red on fbfe773"
652
652
  # R7-1 — a probe that READ the subject while another probe's mutant was live, and locked it only after that
653
- # probe had restored it, must not adopt the mutant. Deterministic: the subject is large enough that
654
- # reading + enumerating it outlasts the 0.4 s after which «the other probe» puts the original back.
653
+ # probe had restored it, must not adopt the mutant. The restore must land after the probe READ the
654
+ # subject (first thing it does) and before it LOCKED it (after enumerating every mutant).
655
+ # 🟥 2026-10-20: this used a fixed 0.4 s over a 6000-line subject and called it deterministic. It was
656
+ # not: time-to-lock measured 468 ms on macOS, 523 ms on ubuntu 24.04 and 288 ms on 26.04 (Python 3.14)
657
+ # — so on 26.04 the restore landed AFTER the lock, the probe refused for a different reason (the
658
+ # lane wrote the subject during the control run) and this lane went red on a correct probe. Now the
659
+ # delay is measured on this machine: one undisturbed run times its «subject:» header (printed after
660
+ # the lock), and the restore fires at half of that. Twice the lines makes that window seconds wide.
655
661
  printf '#!/usr/bin/env bash\n[ "$a" -ne 1 ] && echo x1\n' > r71.orig
656
- for k in $(seq 2 6000); do printf '[ "$a" -eq %d ] && echo x%d\n' "$k" "$k"; done >> r71.orig
657
- sed '2s/-ne 1/-eq 1/' r71.orig > r71.sh # the other probe's mutant is live
662
+ for k in $(seq 2 12000); do printf '[ "$a" -eq %d ] && echo x%d\n' "$k" "$k"; done >> r71.orig
658
663
  printf 'grep -q "exit 113" r71.sh && exit 1\nexit 0\n' > lane_r71.sh
659
- s71=$(date +%s%N)
664
+ cp r71.orig r71.sh
665
+ _ms(){ python3 -c 'import time; print(int(time.time() * 1000))'; } # BSD date has no %N
666
+ c71=$(_ms); h71=""
667
+ while IFS= read -r l; do
668
+ case "$l" in subject:*) [ -n "$h71" ] || h71=$(( $(_ms) - c71 )) ;; esac
669
+ done < <(python3 "$PROBE" r71.sh lane_r71.sh --max 1 --timeout 30 2>&1)
670
+ cmp -s r71.sh r71.orig || cp r71.orig r71.sh
671
+ # no header = the calibration run never reached the lock: the delay is unknown, so the lane fails below
672
+ # (d71 stays 0 → the restore lands before the read → no refusal) rather than guessing a number.
673
+ [ -n "$h71" ] || echo " ⚠️ R7-1 calibration: no «subject:» header — time-to-lock unknown on this machine"
674
+ d71=$(awk -v ms="${h71:-0}" 'BEGIN { printf "%.3f", ms / 2000 }')
675
+ sed '2s/-ne 1/-eq 1/' r71.orig > r71.sh # the other probe's mutant is live
660
676
  python3 "$PROBE" r71.sh lane_r71.sh --max 1 --timeout 30 > r71.out 2>&1 & pb=$!
661
- sleep 0.4; cat r71.orig > r71.sh; t71=$(date +%s%N) # … and now it restores (same inode)
677
+ sleep "$d71"; cat r71.orig > r71.sh # … and now it restores (same inode)
662
678
  wait "$pb"; rc=$?
663
679
  grep -q 'changed between reading it and locking it' r71.out && [ "$rc" -eq 2 ] && cmp -s r71.sh r71.orig && [ ! -e "$(bkpath r71.sh)" ] ; chk $? "R7-1 a subject that changed between read and lock → 2, the original stays (fbfe773: the stale mutant was backed up as «original» and written back)"
664
680
  cp r71.orig r71.sh
@@ -723,6 +723,122 @@ _lane EV8 evidence "control — the LIVE evidence dir was not written by these l
723
723
  "$LIVE_EV_BEFORE" "$([ -d "$LIVE_EV" ] && find "$LIVE_EV" -mindepth 1 -maxdepth 1 | wc -l | tr -d ' ' || echo ABSENT)"
724
724
 
725
725
  fi
726
+ echo ""
727
+ echo "── budget line + --target split (2026-10-17) ─────────────────────"
728
+ # WHY. A FAIL that ended at a harness cap (timeout) reads identically to a real FAIL, and one pooled
729
+ # pass_rate cannot say whether a repair fixed its target or moved everything. These lanes pin that
730
+ # every row carries the cap and ended_at_cap (three-valued: a missing record is UNKNOWN, never no),
731
+ # and that --target splits the summary while the default output is untouched.
732
+ _budget() { # $1=ended value for primary_r1 meta, or MISSING -> "ended_at_cap|budget"
733
+ python3 - "$REPO_ROOT" "$1" <<'PY'
734
+ import sys, os, tempfile
735
+ sys.path.insert(0, os.path.join(sys.argv[1], 'scripts'))
736
+ from probe_live_eval_lib import score_run
737
+ root = tempfile.mkdtemp(); base = os.path.join(root, 'G-X'); os.makedirs(base)
738
+ open(os.path.join(base, 'primary_r1.txt'), 'w').write('nothing')
739
+ open(os.path.join(base, 'control_r1.txt'), 'w').write('weather')
740
+ for arm in ('primary', 'control'):
741
+ if sys.argv[2] == 'MISSING':
742
+ continue
743
+ if sys.argv[2] == 'PARTIAL' and arm == 'primary':
744
+ continue # transcript present, meta absent: ran but unmeasured
745
+ end = sys.argv[2] if arm == 'primary' else 'no'
746
+ open(os.path.join(base, arm + '_r1.meta.tsv'), 'w').write(
747
+ 'rc\t0\ntimeout_s\t900\nmax_turns\tunset\ntoken_cap\tunset\nended_at_cap\t%s\n' % end)
748
+ r = score_run([{'id': 'G-X', 'polarity': 'present', 'expect_re': 'ZZZ'}], root, ['G-X'], 0.8, 'sonnet')['rows'][0]
749
+ print('%s|%s|%s' % (r['verdict'], r['ended_at_cap'], r['budget']))
750
+ PY
751
+ }
752
+ r="$(_budget yes)"
753
+ _lane BU1 budget "KNOWN-POSITIVE — a FAIL whose primary episode ended at the cap says so" \
754
+ "FAIL|yes|timeout=900s max_turns=unset tokens=unset ended_at_cap=yes (1/2 episodes)" "$r"
755
+ r="$(_budget no)"
756
+ _lane BU2 budget "KNOWN-NEGATIVE — a FAIL that ended on its own says ended_at_cap=no" \
757
+ "FAIL|no|timeout=900s max_turns=unset tokens=unset ended_at_cap=no" "$r"
758
+ r="$(_budget MISSING)"
759
+ _lane BU3 budget "no meta recorded -> UNKNOWN (not measured is not no)" \
760
+ "FAIL|UNKNOWN|no episode meta (cap not recorded)" "$r"
761
+ # BU5 (review B1): one episode's meta missing while its transcript exists must not let the other
762
+ # episode's `no` stand for the row — before the fix this printed `...|no|...`.
763
+ r="$(_budget PARTIAL)"
764
+ _lane BU5 budget "partial meta (transcript without meta) -> UNKNOWN, not the other episode's no" \
765
+ "FAIL|UNKNOWN|timeout=900s max_turns=unset tokens=unset ended_at_cap=UNKNOWN" "$r"
766
+
767
+ # BU4/TG*: end to end through the runner with a stub sim that writes the meta the real runner writes.
768
+ if [ "$NOPROBES" -eq 1 ]; then _skipblock "budget/target runner lanes BU4 TG3-TG5 (need probes.md)"; else
769
+ BSTUB="$T/bud_stub"; mkdir -p "$BSTUB"
770
+ cat > "$BSTUB/fake_sim_budget.sh" <<'FAKEBUD'
771
+ #!/usr/bin/env bash
772
+ arm=""; out=""
773
+ while [ $# -gt 0 ]; do case "$1" in --arm) arm="$2"; shift 2 ;; --out) out="$2"; shift 2 ;; *) shift ;; esac; done
774
+ mkdir -p "$out"
775
+ printf 'stub body %s\n' "$arm" > "$out/${arm}_r1.txt"
776
+ if [ "${FH_BUD_STUB_CAP:-no}" = yes ]; then rc=124; end=yes; else rc=0; end=no; fi
777
+ printf 'rc\t%s\ntimeout_s\t900\nmax_turns\tunset\ntoken_cap\tunset\nended_at_cap\t%s\n' "$rc" "$end" > "$out/${arm}_r1.meta.tsv"
778
+ echo "RESULT: CLEAN"; exit 0
779
+ FAKEBUD
780
+ chmod +x "$BSTUB/fake_sim_budget.sh"
781
+ ( cd "$REPO_ROOT" && FH_SIM_RUNNER_BIN="$BSTUB/fake_sim_budget.sh" FH_BUD_STUB_CAP=yes \
782
+ bash "$RUNNER" --ids "G-GREET-01" --no-evidence --report-out "$T/bud_report.md" ) >"$T/bud.log" 2>&1
783
+ _lane BU4 budget "runner -> report row carries 'ended_at_cap=yes' when the stub hit its cap" \
784
+ "yes" "$(grep -E '^\| G-GREET-01 ' "$T/bud_report.md" | grep -q 'ended_at_cap=yes' && echo yes || echo no)"
785
+
786
+ # TG3 default output unchanged: no --target -> no split section anywhere.
787
+ _lane TG3 target "default (no --target): report has no 'Target split' section" \
788
+ "no" "$(grep -q 'Target split' "$T/bud_report.md" && echo yes || echo no)"
789
+
790
+ # TG4 a --target that is not in the run is refused BEFORE any live call (stub counter stays empty).
791
+ TGCOUNT="$T/tg_counter"; : > "$TGCOUNT"
792
+ ( cd "$REPO_ROOT" && FH_SIM_RUNNER_BIN="$STUBROOT/fake_sim_ok.sh" FH_FAKESIM_COUNTER="$TGCOUNT" \
793
+ bash "$RUNNER" --ids "G-GREET-01" --target NOT-A-PROBE --no-evidence --report-out "$T/tg4.md" ) >/dev/null 2>&1
794
+ tg4_rc=$?
795
+ _lane TG4 target "unknown --target -> rc=2 and zero runner calls" "2/0" "$tg4_rc/$(wc -l < "$TGCOUNT" | tr -d ' ')"
796
+
797
+ # TG5 --target + --before through the runner: section present, before side filled in.
798
+ cat > "$T/prev.md" <<'PREV'
799
+ ## Run — model=sonnet threshold=0.80
800
+
801
+ | Probe | Verdict | reps(pass/ran) | primary_hit | control_hit | polarity | Reason |
802
+ |---|---|---|---|---|---|---|
803
+ | G-GREET-01 | FAIL | 0/1 | False | False | present | |
804
+ PREV
805
+ ( cd "$REPO_ROOT" && FH_SIM_RUNNER_BIN="$BSTUB/fake_sim_budget.sh" \
806
+ bash "$RUNNER" --ids "G-GREET-01,G-TRIG-07" --target G-GREET-01 --before "$T/prev.md" \
807
+ --no-evidence --report-out "$T/tg5.md" ) >"$T/tg5.log" 2>&1
808
+ _lane TG5 target "--target + --before: report has the split, target before=FAIL shown" \
809
+ "yes" "$(grep -q '^## Target split — G-GREET-01' "$T/tg5.md" && grep -q 'before=FAIL' "$T/tg5.md" && echo yes || echo no)"
810
+ fi
811
+
812
+ _target() { # $1=before verdicts "A:V,B:V,.." $2=after verdicts ; target=A -> prints summary tokens
813
+ python3 - "$REPO_ROOT" "$1" "$2" <<'PY'
814
+ import sys, os
815
+ sys.path.insert(0, os.path.join(sys.argv[1], 'scripts'))
816
+ from probe_live_eval_lib import split_by_target
817
+ parse = lambda s: dict(x.split(':') for x in s.split(','))
818
+ before, after = parse(sys.argv[2]), parse(sys.argv[3])
819
+ t = split_by_target([{'id': k, 'verdict': v, 'ended_at_cap': 'no'} for k, v in after.items()], 'A', before)
820
+ print('%s>%s | others %s>%s | moved=%s' % (t['before']['target'], t['after_target'],
821
+ t['before']['others']['passed'], t['after_others']['passed'], len(t['moved'])))
822
+ PY
823
+ }
824
+ r="$(_target 'A:FAIL,B:PASS,C:PASS' 'A:PASS,B:PASS,C:PASS')"
825
+ _lane TG1 target "target fixed, others untouched -> moved=0 (fixed the target, moved nothing else)" \
826
+ "FAIL>PASS | others 2>2 | moved=0" "$r"
827
+ r="$(_target 'A:FAIL,B:PASS,C:PASS' 'A:PASS,B:FAIL,C:PASS')"
828
+ _lane TG2 target "KNOWN-NEGATIVE pair — target fixed but a neighbour regressed -> moved=1, others 2>1" \
829
+ "FAIL>PASS | others 2>1 | moved=1" "$r"
830
+ # TG6 (review B4): a before-report that lacks the other probes must not render «others moved: none».
831
+ r="$(python3 - "$REPO_ROOT" <<'PY'
832
+ import sys, os
833
+ sys.path.insert(0, os.path.join(sys.argv[1], 'scripts'))
834
+ from probe_live_eval_lib import split_by_target, render_target_lines
835
+ t = split_by_target([{'id': k, 'verdict': 'PASS', 'ended_at_cap': 'no'} for k in 'ABC'], 'A', {'A': 'FAIL'})
836
+ print([l for l in render_target_lines(t) if 'others moved' in l][0].strip())
837
+ PY
838
+ )"
839
+ _lane TG6 target "narrower --before -> 'not comparable', never 'none'" \
840
+ "others moved: not comparable (2 others absent from before)" "$r"
841
+
726
842
  echo ""
727
843
  echo "── summary ──────────────────────────────────────────────────────"
728
844
  echo "lanes: $N failed: $([ "$FAIL" -eq 0 ] && echo 0 || echo '>=1')"
@@ -12,7 +12,7 @@
12
12
  # R8 합계 = 측정된 칸의 합(MEMORY 는 적재분)
13
13
  # R9 되돌림: nchars 를 바이트로 바꾼 변이체 → R1 이 빨개져야 한다(적용 확인 → 실행 → 판정)
14
14
  # R10 실물: 이 레포 CLAUDE.md 줄이 독립 계산(len)과 같은 값
15
- # CLAUDE.md 크기 «가드»(145,000 한계)는 scripts/test_claude_md_size_lanes.sh 가 맡는다 — 여기서 다시 안 잰다.
15
+ # CLAUDE.md 크기 «가드»(18,000 한계)는 scripts/test_claude_md_size_lanes.sh 가 맡는다 — 여기서 다시 안 잰다.
16
16
  set -uo pipefail
17
17
  HERE="$(cd "$(dirname "$0")" && pwd)"; ROOT="$(cd "$HERE/.." && pwd)"
18
18
  METER="${RESIDENT_COST_METER:-$HERE/resident_cost.py}" # R9 가 변이체를 넣을 때만 바뀐다
@@ -445,6 +445,38 @@ chk $? "CONTROL: the pre-repair substring form accepts both — the fixtures dis
445
445
  # through _show_failure, whose empty branch prints "(no output captured)" at runtime, so the failure
446
446
  # is loud rather than silent. Regression is anchored; evasion is a named residual, not a solved one.
447
447
 
448
+ # ── Pair-suite exit-code verdict (2026-10-19) ──────────────────────────────────
449
+ # fh_signal_2026-10-18_selfcheck-timeout-unlabelled: a suite killed by the 300 s lane timeout
450
+ # (rc=124) fell into a bare `*) fail=1` and the whole run said FAIL with no line naming anything.
451
+ # Lift the REAL function out of selfcheck.sh and call it — a re-spelled copy would stay green
452
+ # while the subject regressed. Every non-zero rc must print a line containing the suite label;
453
+ # rc 0 must print nothing and return 0 (the negative control that keeps "prints a line" from
454
+ # passing a function that prints on every call).
455
+ echo ""
456
+ echo "── pair-suite rc verdict (_pair_rc_verdict) ──"
457
+ _FN=$(sed -n '/^_pair_rc_verdict() {/,/^}/p' "$SELFCHECK")
458
+ if [ -z "$_FN" ]; then
459
+ chk 1 "_pair_rc_verdict found in selfcheck.sh (lane would test nothing)"
460
+ else
461
+ eval "$_FN"
462
+ _o=$(_pair_rc_verdict lane_x.sh subj_x 0); _r=$?
463
+ [ "$_r" -eq 0 ] && [ -z "$_o" ]; chk $? "rc=0 → pass, silent (control)"
464
+ for _c in 124 1 3 137; do
465
+ _o=$(_pair_rc_verdict lane_x.sh subj_x "$_c"); _r=$?
466
+ [ "$_r" -ne 0 ] && printf '%s' "$_o" | grep -q 'lane_x.sh'; chk $? "rc=$_c → failure AND a line naming the suite"
467
+ done
468
+ _o=$(_pair_rc_verdict lane_x.sh subj_x 124)
469
+ printf '%s' "$_o" | grep -q '^TIMEOUT '; chk $? "rc=124 → labelled TIMEOUT (not a generic FAIL)"
470
+ for _c in 10 2 126 127; do
471
+ _o=$(_pair_rc_verdict lane_x.sh subj_x "$_c"); _r=$?
472
+ [ "$_r" -ne 0 ] && printf '%s' "$_o" | grep -q '^HARNESS ERROR '; chk $? "rc=$_c → failure AND HARNESS ERROR"
473
+ done
474
+ # The loop must route through the function — a lifted function with no caller is decoration.
475
+ # Uncommented line only (codex review 2026-10-19: a commented-out call passed the first form).
476
+ # Still a text check — it cannot prove the line is reached; that residual is named, not closed.
477
+ grep -qE '^[[:space:]]+_pair_rc_verdict "\$_lbl" "\$_subj" "\$_rc" \|\| fail=1' "$SELFCHECK"; chk $? "pair loop calls _pair_rc_verdict (uncommented) and sets fail on it"
478
+ fi
479
+
448
480
  echo ""
449
481
  if [ "$FAILED" -ne 0 ]; then
450
482
  echo "SELFCHECK STATE LANES: FAIL — a discriminator would mis-route"
@@ -738,6 +738,173 @@ else
738
738
  fail "L39 rc=$RC (see $TMPDIR_ROOT/l39.out)"
739
739
  fi
740
740
 
741
+ # L40 — re-extracting into a filled sheet carries the judgements forward (2026-10-18: the mid-session nudge
742
+ # re-extracts into the SAME file; a plain overwrite erased 259 filled rows). Known pair: a filled row is carried,
743
+ # an empty row stays empty; a filled row whose utterance is gone is kept under the orphan heading; no file → plain write.
744
+ build_jsonl "$TMPDIR_ROOT/l40.jsonl" "[{'type':'user','timestamp':'2026-10-18T01:00:00.000Z','message':{'role':'user','content':'Please move the session bar a little higher than it is now.'}},{'type':'user','timestamp':'2026-10-18T01:05:00.000Z','message':{'role':'user','content':'Please also fix the badge that sits too far to the right.'}}]"
745
+ L40="$TMPDIR_ROOT/l40.md"
746
+ run "$TMPDIR_ROOT/l40a.out" extract --transcript "$TMPDIR_ROOT/l40.jsonl" --out "$L40"
747
+ L40A_RC=$RC
748
+ L40_PLAIN=$(grep -c '↩️' "$L40") # control: no prior file → no carry line
749
+ python3 - "$L40" <<'PYEOF'
750
+ import sys
751
+ p = sys.argv[1]; L = open(p, encoding="utf-8").read().split("\n")
752
+ for i, l in enumerate(L):
753
+ if l.startswith("| 1 |"):
754
+ L[i] = l.replace("| | | | |", "| ✅DONE | abc1234 (#99) | - | - |")
755
+ L.append("| 7 | 10-17 09:00 | an utterance no longer in the transcript | 🟡PARTIAL | - | half done | 이월: finish |")
756
+ open(p, "w", encoding="utf-8").write("\n".join(L))
757
+ PYEOF
758
+ run "$TMPDIR_ROOT/l40b.out" extract --transcript "$TMPDIR_ROOT/l40.jsonl" --out "$L40"
759
+ if [ "$L40A_RC" -eq 0 ] && [ "$RC" -eq 0 ] && [ "$L40_PLAIN" = 0 ] \
760
+ && grep -q '^| 1 | .*session bar.* | ✅DONE | abc1234 (#99) | - | - |$' "$L40" \
761
+ && grep -qE '^\| 2 \| .*badge.* \| \| \| \| \|$' "$L40" \
762
+ && grep -q '^## 이전 결과서에서 이어받지 못한 판정' "$L40" \
763
+ && grep -q 'an utterance no longer in the transcript | 🟡PARTIAL' "$L40" \
764
+ && grep -q '판정 1줄 이어받음 · 못 맞춘 판정 1줄' "$L40"; then
765
+ pass "L40 extract into a filled sheet: judgement carried (row 1), empty row stays empty (row 2), unmatched judgement kept under the orphan heading, no-file run writes plainly"
766
+ else
767
+ fail "L40 rc=$L40A_RC/$RC plain=$L40_PLAIN (see $L40)"
768
+ fi
769
+
770
+ # ---------------------------------------------------------------------------
771
+ # L41-L45 — the hook record as a second channel (merge with the transcript, tag source, never a silent zero)
772
+ # transcript: alpha 09:00Z · beta 09:10Z · gamma 09:20Z; hook: alpha · delta (09:05Z, hook only) · beta (+20s); hook ts is local-naive
773
+ # ---------------------------------------------------------------------------
774
+ python3 - "$TMPDIR_ROOT" <<'PYEOF'
775
+ import json, sys, datetime
776
+ d = sys.argv[1]
777
+ def loc(z): # UTC «…Z» -> local naive, as the hook writes it
778
+ t = datetime.datetime.strptime(z, "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=datetime.timezone.utc).astimezone()
779
+ return t.strftime("%Y-%m-%dT%H:%M:%S")
780
+ tr = [("2026-10-01T09:00:00Z", "alpha request about the status bar"),
781
+ ("2026-10-01T09:10:00Z", "beta request about the export button"),
782
+ ("2026-10-01T09:20:00Z", "gamma request only the transcript saw")]
783
+ with open(d + "/l41_tr.jsonl", "w", encoding="utf-8") as f:
784
+ for z, t in tr:
785
+ f.write(json.dumps({"type": "user", "timestamp": z, "message": {"role": "user", "content": t}}) + "\n")
786
+ hk = [("2026-10-01T09:00:00Z", "alpha request about the status bar"),
787
+ ("2026-10-01T09:05:00Z", "delta request sent while a tool was running"),
788
+ ("2026-10-01T09:10:20Z", "beta request about the export button")]
789
+ with open(d + "/l41_hook.jsonl", "w", encoding="utf-8") as f:
790
+ for n, (z, t) in enumerate(hk, 1):
791
+ f.write(json.dumps({"ts": loc(z), "n": n, "text": t}) + "\n")
792
+ with open(d + "/l44_hook.jsonl", "w", encoding="utf-8") as f: # one good row, one torn line, one row without text
793
+ f.write(json.dumps({"ts": loc("2026-10-01T09:05:00Z"), "n": 1, "text": "delta request sent while a tool was running"}) + "\n")
794
+ f.write('{"ts": "2026-10-01T09:06:00", "n": 2, "text": "torn li\n')
795
+ f.write(json.dumps({"ts": loc("2026-10-01T09:07:00Z"), "n": 3}) + "\n")
796
+ with open(d + "/l42_tr.jsonl", "w", encoding="utf-8") as f:
797
+ f.write(json.dumps({"type": "user", "timestamp": "2026-10-01T09:00:00Z", "message": {"role": "user", "content": "please continue with the next step"}}) + "\n")
798
+ with open(d + "/l42_hook.jsonl", "w", encoding="utf-8") as f:
799
+ for z in ("2026-10-01T09:00:00Z", "2026-10-01T13:00:00Z"):
800
+ f.write(json.dumps({"ts": loc(z), "n": 1, "text": "please continue with the next step"}) + "\n")
801
+ PYEOF
802
+ run "$TMPDIR_ROOT/l41.out" extract --transcript "$TMPDIR_ROOT/l41_tr.jsonl" --utterances "$TMPDIR_ROOT/l41_hook.jsonl"
803
+ L41_RC=$RC
804
+ L41_ROWS=$(grep -cE '^\| [0-9HS]+ \|' "$TMPDIR_ROOT/l41.out")
805
+ if [ "$L41_RC" -eq 0 ] && [ "$L41_ROWS" -eq 4 ] \
806
+ && [ "$(grep -c 'alpha request' "$TMPDIR_ROOT/l41.out")" -eq 1 ] \
807
+ && [ "$(grep -c 'beta request' "$TMPDIR_ROOT/l41.out")" -eq 1 ] \
808
+ && grep -q '^| 3 | .*gamma request' "$TMPDIR_ROOT/l41.out" \
809
+ && grep -q '^| H1 | 10-01 09:05 | delta request' "$TMPDIR_ROOT/l41.out" \
810
+ && grep -q '훅 기록 채널 읽음 — 3건 · 전사와 일치 2건 · 훅 전용 1건' "$TMPDIR_ROOT/l41.out"; then
811
+ pass "L41 hook+transcript: a message in both is ONE row (no dup), hook-only is an H row with its time, transcript-only keeps its number, header counts 3/2/1"
812
+ else
813
+ fail "L41 rc=$L41_RC rows=$L41_ROWS (see $TMPDIR_ROOT/l41.out)"
814
+ fi
815
+
816
+ # L42 — the same words far apart in time are a distinct message, not folded into the first
817
+ run "$TMPDIR_ROOT/l42.out" extract --transcript "$TMPDIR_ROOT/l42_tr.jsonl" --utterances "$TMPDIR_ROOT/l42_hook.jsonl"
818
+ if [ "$RC" -eq 0 ] && [ "$(grep -c 'please continue' "$TMPDIR_ROOT/l42.out")" -eq 2 ] && grep -q '^| H1 | 10-01 13:00 |' "$TMPDIR_ROOT/l42.out"; then
819
+ pass "L42 the same words 4h later are a second message (H row); the pair inside the window is one"
820
+ else
821
+ fail "L42 rc=$RC (see $TMPDIR_ROOT/l42.out)"
822
+ fi
823
+
824
+ # L43 — hook file absent: the header says NOT READ (never zero), rc stays 0, transcript rows print
825
+ run "$TMPDIR_ROOT/l43.out" extract --transcript "$TMPDIR_ROOT/l41_tr.jsonl" --utterances "$TMPDIR_ROOT/no_such_hook.jsonl"
826
+ if [ "$RC" -eq 0 ] && grep -q '훅 기록 채널 안 읽음 — 파일 없음' "$TMPDIR_ROOT/l43.out" \
827
+ && grep -q '0건이 아니라 미열람' "$TMPDIR_ROOT/l43.out" \
828
+ && [ "$(grep -cE '^\| [0-9]+ \|' "$TMPDIR_ROOT/l43.out")" -eq 3 ]; then
829
+ pass "L43 hook record absent: header says not read (not zero), the transcript's 3 rows intact, rc=0"
830
+ else
831
+ fail "L43 rc=$RC (see $TMPDIR_ROOT/l43.out)"
832
+ fi
833
+
834
+ # L44 — malformed hook lines: loud in the header, rc=2, transcript rows and the readable hook row survive
835
+ run "$TMPDIR_ROOT/l44.out" extract --transcript "$TMPDIR_ROOT/l41_tr.jsonl" --utterances "$TMPDIR_ROOT/l44_hook.jsonl"
836
+ if [ "$RC" -eq 2 ] && grep -q '훅 기록 2줄 해석 실패' "$TMPDIR_ROOT/l44.out" \
837
+ && [ "$(grep -cE '^\| [0-9]+ \|' "$TMPDIR_ROOT/l44.out")" -eq 3 ] \
838
+ && grep -q '^| H1 | .*delta request' "$TMPDIR_ROOT/l44.out"; then
839
+ pass "L44 malformed hook lines: header names 2 bad lines, rc=2, transcript rows and the readable hook row kept"
840
+ else
841
+ fail "L44 rc=$RC (see $TMPDIR_ROOT/l44.out)"
842
+ fi
843
+
844
+ # L45 — hook path unreadable as a record (a directory): channel error in the header, rc=2, no crash, transcript rows kept
845
+ mkdir -p "$TMPDIR_ROOT/l45_dir"
846
+ run "$TMPDIR_ROOT/l45.out" extract --transcript "$TMPDIR_ROOT/l41_tr.jsonl" --utterances "$TMPDIR_ROOT/l45_dir"
847
+ if [ "$RC" -eq 2 ] && grep -q '훅 기록 채널 오류' "$TMPDIR_ROOT/l45.out" \
848
+ && [ "$(grep -cE '^\| [0-9]+ \|' "$TMPDIR_ROOT/l45.out")" -eq 3 ]; then
849
+ pass "L45 hook path unreadable: channel error in the header, rc=2, transcript rows kept"
850
+ else
851
+ fail "L45 rc=$RC (see $TMPDIR_ROOT/l45.out)"
852
+ fi
853
+
854
+ # ---------------------------------------------------------------------------
855
+ # L46-L51 — merge edge cases a cross-family read reproduced (codex 2026-10-19). Each calls the REAL functions.
856
+ # L46 repeated short text: two «yes» pairs stay two rows (nearest-first greedy made three)
857
+ # L47 truncated hook row cannot steal the row a full hook row needs
858
+ # L48 hook row without a usable ts is a parse failure, not a text-only match
859
+ # L49 invalid UTF-8 in a hook line is a parse failure, not a replaced-character H row
860
+ # L50 DST fall-back hour: the nearer of the two instants is used (America/New_York)
861
+ # L51 carry_forward keeps BOTH judgments of two rows with the same minute and words
862
+ # ---------------------------------------------------------------------------
863
+ L46_OUT=$(python3 - "$SUBJ" "$TMPDIR_ROOT" <<'PYEOF'
864
+ import importlib.util, json, os, sys, datetime, time
865
+ spec = importlib.util.spec_from_file_location("sck", sys.argv[1]); m = importlib.util.module_from_spec(spec); spec.loader.exec_module(m)
866
+ d = sys.argv[2]
867
+ def loc(z):
868
+ t = datetime.datetime.strptime(z, "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=datetime.timezone.utc).astimezone()
869
+ return t.strftime("%Y-%m-%dT%H:%M:%S")
870
+ res = {}
871
+ raw = [{"ts": "2026-10-01T09:00:00Z", "text": "yes"}, {"ts": "2026-10-01T09:20:00Z", "text": "yes"}]
872
+ hk = [{"ts": loc("2026-10-01T09:11:00Z"), "text": "yes", "truncated": False}, {"ts": loc("2026-10-01T09:40:00Z"), "text": "yes", "truncated": False}]
873
+ only, n = m.merge_hook_rows(raw, hk); res["L46"] = (len(only), n) == (0, 2)
874
+ raw = [{"ts": "2026-10-01T09:00:00Z", "text": "prefix B"}, {"ts": "2026-10-01T09:01:00Z", "text": "prefix A"}]
875
+ hk = [{"ts": loc("2026-10-01T09:00:00Z"), "text": "prefix", "truncated": True}, {"ts": loc("2026-10-01T09:00:01Z"), "text": "prefix B", "truncated": False}]
876
+ only, n = m.merge_hook_rows(raw, hk); res["L47"] = (len(only), n) == (0, 2)
877
+ with open(d + "/l48.jsonl", "w") as f:
878
+ f.write(json.dumps({"n": 1, "text": "yes"}) + "\n"); f.write(json.dumps({"ts": "bad", "n": 2, "text": "yes"}) + "\n")
879
+ st, rows, bad, _ = m.read_hook_channel(d + "/l48.jsonl"); res["L48"] = (st, len(rows), bad) == ("read", 0, 2)
880
+ with open(d + "/l49.jsonl", "wb") as f:
881
+ f.write(b'{"ts": "2026-10-01T09:00:00", "n": 1, "text": "y\xffs"}\n')
882
+ st, rows, bad, _ = m.read_hook_channel(d + "/l49.jsonl"); res["L49"] = (len(rows), bad) == (0, 1)
883
+ raw = [{"ts": "2026-10-01T09:00:00Z", "text": "prefix A"}, {"ts": "2026-10-01T09:01:00Z", "text": "prefix B"}]
884
+ hk = [{"ts": loc("2026-10-01T09:00:00Z"), "text": "prefix", "truncated": True}, {"ts": loc("2026-10-01T09:01:00Z"), "text": "prefix A", "truncated": True}]
885
+ only, n = m.merge_hook_rows(raw, hk); res["L47b"] = (len(only), n) == (0, 2)
886
+ res["L48b"] = m.parse_ts_candidates("2026-10-01T09:00:00garbage") == [] and m.parse_ts_candidates("2026-10-01T09:00:00.123Z") != []
887
+ os.environ["TZ"] = "America/New_York"; time.tzset()
888
+ raw = [{"ts": "2026-11-01T06:30:00Z", "text": "second half hour"}]
889
+ hk = [{"ts": "2026-11-01T01:30:00", "text": "second half hour", "truncated": False}]
890
+ only, n = m.merge_hook_rows(raw, hk); res["L50"] = (len(only), n) == (0, 1)
891
+ out = d + "/l51.md"
892
+ row = "| %s | 10-01 09:00 | yes | %s | | | |"
893
+ with open(out, "w") as f:
894
+ f.write("\n".join(["# t", "", "x", "", "| # | 시각 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안(이번 세션 vs 이월) |", "|---|---|---|---|---|---|---|", row % ("H1", "✅"), row % ("H2", "❌")]) + "\n")
895
+ new = ["# t", "", "x", "", "| # | 시각 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안(이번 세션 vs 이월) |", "|---|---|---|---|---|---|---|", row % ("H1", ""), row % ("H2", "")]
896
+ got = m.carry_forward(new, out)
897
+ res["L51"] = any(l.startswith("| H1 |") and "✅" in l for l in got) and any(l.startswith("| H2 |") and "❌" in l for l in got)
898
+ print(" ".join("%s=%s" % (k, int(v)) for k, v in sorted(res.items())))
899
+ PYEOF
900
+ )
901
+ for L in L46 L47 L47b L48 L48b L49 L50 L51; do
902
+ case " $L46_OUT " in
903
+ *" $L=1 "*) pass "$L merge edge case (codex 2026-10-19 repro) holds" ;;
904
+ *) fail "$L merge edge case — got: ${L46_OUT:-<no output: the python block crashed>}" ;;
905
+ esac
906
+ done
907
+
741
908
  echo "── $PASS_COUNT passed, $FAIL_COUNT failed ──"
742
909
 
743
910
  if [ "$FAIL_COUNT" -gt 0 ]; then
@@ -79,6 +79,12 @@ case "${FH_STUB_MODE:-say}" in
79
79
  if [ "$_n" -eq 2 ]; then exit 7; fi
80
80
  printf '{"session_id":"SID-fixed","result":"turn %s ok"}\n' "$_n" ;;
81
81
  hang) sleep 30 ;;
82
+ # L29e — turn 1 crashes (rc 7), every later turn hangs. The rep returns its FIRST failing rc (7),
83
+ # so the budget line must read the per-turn table to see the timeout.
84
+ turns_die1_hang) _c=$(cat "${FH_STUB_SID_COUNTER:-/dev/null}" 2>/dev/null); [ -n "$_c" ] || _c=0
85
+ _n=$((_c+1)); echo "$_n" > "${FH_STUB_SID_COUNTER:-/dev/null}" 2>/dev/null || true
86
+ if [ "$_n" -eq 1 ]; then exit 7; fi
87
+ sleep 30 ;;
82
88
  esac
83
89
  exit 0
84
90
  STUB
@@ -523,5 +529,50 @@ grep -q "RESULT: CLEAN" "$WORKROOT/o_b28n.log" \
523
529
  && ok "L28n CONTROL — healthy multi-turn run is CLEAN (k/l/m are not firing on everything)" \
524
530
  || no "L28n CONTROL was not CLEAN — L28k/l/m prove nothing"
525
531
 
532
+ # ── L29 budget line (2026-10-17) — meta.tsv carries the cap the episode ran under and whether it
533
+ # ENDED AT it. Known-positive: a hanging stub under --timeout 1 (rc=124) -> yes. Known-negative:
534
+ # a normal answer -> no. And the two non-answers stay UNKNOWN, never `no`.
535
+ bud_meta() { # $1=tag $2=stub mode $3..= extra runner args ; env passes through. prints meta path
536
+ local tag="$1" mode="$2"; shift 2
537
+ ( cd "$SRC" && PATH="$STUBBIN:$PATH" HOME="$FAKEHOME" FH_STUB_MODE="$mode" \
538
+ bash "$SUT" --arm a --reps 1 --prompt p --out "$WORKROOT/o_$tag" "$@" ) >"$WORKROOT/o_$tag.log" 2>&1
539
+ printf '%s' "$WORKROOT/o_$tag/a_r1.meta.tsv"
540
+ }
541
+ meta_get() { awk -F'\t' -v k="$2" '$1==k{print $2}' "$1" 2>/dev/null; }
542
+ M="$(bud_meta b29a hang --timeout 1)"
543
+ { [ "$(meta_get "$M" ended_at_cap)" = yes ] && [ "$(meta_get "$M" rc)" = 124 ] && [ "$(meta_get "$M" timeout_s)" = 1 ]; } \
544
+ && ok "L29a KNOWN-POSITIVE — hang under --timeout 1: rc=124, timeout_s=1, ended_at_cap=yes" \
545
+ || no "L29a timeout not recorded as ended_at_cap=yes ($(meta_get "$M" rc)/$(meta_get "$M" ended_at_cap))"
546
+ M="$(bud_meta b29b say --timeout 60)"
547
+ { [ "$(meta_get "$M" ended_at_cap)" = no ] && [ "$(meta_get "$M" max_turns)" = unset ] && [ "$(meta_get "$M" timeout_s)" = 60 ]; } \
548
+ && ok "L29b KNOWN-NEGATIVE — normal answer: ended_at_cap=no, max_turns=unset, timeout_s=60" \
549
+ || no "L29b normal answer mis-recorded ($(meta_get "$M" ended_at_cap))"
550
+ M="$(bud_meta b29c die --timeout 60)"
551
+ [ "$(meta_get "$M" ended_at_cap)" = UNKNOWN ] \
552
+ && ok "L29c a crash (rc=7) is UNKNOWN, not no and not yes" \
553
+ || no "L29c crash classified as '$(meta_get "$M" ended_at_cap)'"
554
+ M="$(CLAUDE_CODE_MAX_OUTPUT_TOKENS=100 bud_meta b29d say --timeout 60)"
555
+ { [ "$(meta_get "$M" token_cap)" = 100 ] && [ "$(meta_get "$M" ended_at_cap)" = UNKNOWN ]; } \
556
+ && ok "L29d token cap read from the inherited env (100); rc=0 under a cap is UNKNOWN (stop reason not read)" \
557
+ || no "L29d token_cap/ended_at_cap: $(meta_get "$M" token_cap)/$(meta_get "$M" ended_at_cap)"
558
+ # L29e (review B2) — multi-turn: turn 1 rc=7, turn 2 times out. rep rc stays 7 (first failure), and
559
+ # before the fix ended_at_cap was UNKNOWN — the timeout was hidden.
560
+ : > "$WORKROOT/sid_b29e"
561
+ ( cd "$SRC" && PATH="$STUBBIN:$PATH" HOME="$FAKEHOME" FH_STUB_MODE=turns_die1_hang \
562
+ FH_STUB_SID_COUNTER="$WORKROOT/sid_b29e" \
563
+ bash "$SUT" --arm mt --reps 1 --turns "$WORKROOT/t3.txt" --timeout 1 --out "$WORKROOT/o_b29e" ) >"$WORKROOT/o_b29e.log" 2>&1
564
+ M="$WORKROOT/o_b29e/mt_r1.meta.tsv"
565
+ { [ "$(meta_get "$M" rc)" = 7 ] && [ "$(meta_get "$M" ended_at_cap)" = yes ]; } \
566
+ && ok "L29e multi-turn: turn-2 timeout behind a turn-1 crash still reads ended_at_cap=yes (rc stays 7)" \
567
+ || no "L29e multi-turn timeout hidden: rc=$(meta_get "$M" rc) ended_at_cap=$(meta_get "$M" ended_at_cap)"
568
+ # L29f (review C2) — a reused --out whose rep fails before writing meta must not keep the old meta.
569
+ mkdir -p "$WORKROOT/o_b29f"
570
+ printf 'rc\t0\nended_at_cap\tno\n' > "$WORKROOT/o_b29f/a_r1.meta.tsv"
571
+ ( cd "$SRC" && PATH="$STUBBIN:$PATH" HOME="$FAKEHOME" FH_STUB_MODE=say \
572
+ bash "$SUT" --arm a --reps 1 --prompt p --base-ref no-such-ref --base-sha 0000000 --out "$WORKROOT/o_b29f" ) >"$WORKROOT/o_b29f.log" 2>&1
573
+ { grep -q "BASE CLONE FAILED" "$WORKROOT/o_b29f.log" && [ ! -e "$WORKROOT/o_b29f/a_r1.meta.tsv" ]; } \
574
+ && ok "L29f clone failure on a reused --out leaves no stale ended_at_cap=no behind" \
575
+ || no "L29f stale meta survived (clone-fail seen: $(grep -c 'BASE CLONE FAILED' "$WORKROOT/o_b29f.log"))"
576
+
526
577
  echo "sim_isolated_run lanes: $pass passed, $fail failed"
527
578
  [ "$fail" -eq 0 ] || exit 1