@chrono-meta/fh-gate 3.28.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 (40) hide show
  1. package/.claude-plugin/marketplace.json +4 -4
  2. package/CHEATSHEET.md +2 -2
  3. package/CLAUDE.md +5 -2
  4. package/docs/REFERENCE.md +4 -1
  5. package/knowledge/shared/harness-core/claude_md_full_reference.md +2 -0
  6. package/knowledge/shared/harness-core/claude_md_gate_details.md +7 -0
  7. package/knowledge/shared/harness-core/dispatch_conditional_prohibition.md +12 -0
  8. package/knowledge/shared/harness-core/fh_three_layer_canon.md +12 -0
  9. package/knowledge/shared/harness-core/measurement-integrity-checklist.md +16 -0
  10. package/knowledge/shared/learnings/subagent_invocations_log.yaml +56 -0
  11. package/package.json +3 -1
  12. package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
  13. package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
  14. package/plugins/fh-meta/CHANGELOG.md +22 -0
  15. package/plugins/fh-meta/skills/auto-decorrelation/SKILL.md +17 -0
  16. package/plugins/fh-meta/skills/sim-conductor/SKILL.md +2 -2
  17. package/plugins/fh-meta/skills/sim-conductor/SKILL_detail.md +3 -3
  18. package/plugins/fh-meta/skills/steel-quench/SKILL.md +25 -1
  19. package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
  20. package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
  21. package/scripts/degrade_direction_scan.sh +43 -0
  22. package/scripts/dispatch_receipt.py +185 -0
  23. package/scripts/doc_claim_triad_scan.py +43 -4
  24. package/scripts/fh-gate.sh +71 -11
  25. package/scripts/finding_fleet.sh +15 -3
  26. package/scripts/package_coverage_check.sh +5 -0
  27. package/scripts/selfcheck.sh +41 -20
  28. package/scripts/session_checklist.py +155 -12
  29. package/scripts/test_degrade_scan_shell_probes.sh +81 -0
  30. package/scripts/test_dispatch_receipt_lanes.sh +95 -0
  31. package/scripts/test_doc_claim_triad_lanes.sh +30 -0
  32. package/scripts/test_fh_audit_check_lanes.sh +10 -5
  33. package/scripts/test_fh_gate_regressions.sh +71 -1
  34. package/scripts/test_finding_pipeline_lanes.sh +83 -0
  35. package/scripts/test_locale_invariance_lanes.sh +19 -0
  36. package/scripts/test_mutation_probe_lanes.sh +22 -6
  37. package/scripts/test_selfcheck_state_lanes.sh +32 -0
  38. package/scripts/test_session_checklist_lanes.sh +138 -0
  39. package/templates/PRE-PUBLISH-CHECKLIST.md +10 -0
  40. package/templates/degrade_direction_scan.sh +43 -0
@@ -2006,6 +2006,89 @@ else
2006
2006
  no "L124 빈 1차 fail-open" "empty_rc=$R124 (3 기대) '$(printf '%s' "$O124" | /usr/bin/grep -o 'status=[A-Z_0-9]*' | head -1)' ctrl_rc=$R124c (0 기대)"
2007
2007
  fi
2008
2008
 
2009
+ # ── L125/L126 🟥 2차 철회 대조가 «부분 문자열» 이라 남의 발견을 삼키던 구멍 (2026-10-22, 호출지점 재고 조사) ──
2010
+ # 기전: `if _id in _body` — `DROPPED: codex-logic-10` 이 `codex-logic-1` 도 «철회됨» 으로 세서, 2차에서 조용히
2011
+ # 빠진 1번이 «설명됨» 이 되고 폴백도 안 돌았다(무음 삭제). 제목도 같은 부류(`Q1` ⊂ `Q10`).
2012
+ # 픽스처는 뚫리는 표기 그대로: 1차 10건 → 2차가 2~9 를 KEEP · 10 을 DROPPED · 1 은 말없이 뺀다.
2013
+ cat > "$D/x_ten.sh" <<'EOS'
2014
+ #!/bin/sh
2015
+ IN=$(cat); [ -n "$IN" ] || IN="$*"
2016
+ row(){ printf '{"id":"codex-logic-%s","title":"%s","file":"x_t.py","line":%s,"severity":"B","category":"s","detail":"x","defeater":"y","confidence":0.6}\n' "$1" "$2" "$1"; }
2017
+ case "$IN" in
2018
+ *"YOUR OWN ROUND-1 FINDINGS"*)
2019
+ for i in 2 3 4 5 6 7 8 9; do row $i "kept-$i"; done
2020
+ if [ -n "$TEN_DROP_BOTH" ]; then echo 'DROPPED: codex-logic-1 — re-read; not a defect'; fi
2021
+ echo 'DROPPED: codex-logic-10 — re-read; not a defect' ;;
2022
+ *) for i in 1 2 3 4 5 6 7 8 9 10; do printf '{"title":"r1-%s","file":"x_t.py","line":%s,"severity":"B","category":"s","detail":"x","defeater":"y","confidence":0.6}\n' "$i" "$i"; done ;;
2023
+ esac
2024
+ EOS
2025
+ cat > "$D/x_qtitle.sh" <<'EOS'
2026
+ #!/bin/sh
2027
+ IN=$(cat); [ -n "$IN" ] || IN="$*"
2028
+ case "$IN" in
2029
+ *"YOUR OWN ROUND-1 FINDINGS"*) echo 'DROPPED: Q10 — re-read; not a defect' ;;
2030
+ *) echo '{"title":"Q1","file":"x_t.py","line":1,"severity":"A","category":"d","detail":"x","defeater":"y","confidence":0.7}'
2031
+ echo '{"title":"Q10","file":"x_t.py","line":2,"severity":"B","category":"d","detail":"x","defeater":"y","confidence":0.7}' ;;
2032
+ esac
2033
+ EOS
2034
+ chmod +x "$D/x_ten.sh" "$D/x_qtitle.sh"
2035
+ printf 'codex|logic|sh %s\n' "$D/x_ten.sh" > "$D/f125.tbl"
2036
+ O125=$(bash "$FL" "$D/x_t.py" --out "$D/f125" --fleet "$D/f125.tbl" --round2 2>&1)
2037
+ # 컨트롤: 1 과 10 을 둘 다 «명시적으로» 내리면 폴백 없이 철회된다 — 경계 비교가 정당한 철회까지 막지 않는다
2038
+ O125c=$(TEN_DROP_BOTH=1 bash "$FL" "$D/x_t.py" --out "$D/f125c" --fleet "$D/f125.tbl" --round2 2>&1)
2039
+ if printf '%s\n' "$O125" | /usr/bin/grep -q 'unaccounted_r1=codex-logic-1 ' \
2040
+ && /usr/bin/grep -q '"r1-1"' "$D/f125/findings.jsonl" 2>/dev/null \
2041
+ && ! printf '%s\n' "$O125c" | /usr/bin/grep -q 'unaccounted_r1=' \
2042
+ && ! /usr/bin/grep -q '"r1-1"' "$D/f125c/findings.jsonl" 2>/dev/null \
2043
+ && /usr/bin/grep -q '"kept-2"' "$D/f125c/findings.jsonl" 2>/dev/null; then
2044
+ ok "L125 🟥 «DROPPED: codex-logic-10» 은 codex-logic-1 을 철회하지 않는다(말없이 빠진 1 → 폴백) · 컨트롤: 둘 다 명시 철회 → 폴백 없음"
2045
+ else
2046
+ no "L125 id 부분일치 철회" "$(printf '%s\n' "$O125" | /usr/bin/grep -E 'unaccounted|MEMBER2' | head -2) | ctrl: $(printf '%s\n' "$O125c" | /usr/bin/grep -E 'unaccounted|MEMBER2' | head -2)"
2047
+ fi
2048
+ printf 'codex|logic|sh %s\n' "$D/x_qtitle.sh" > "$D/f126.tbl"
2049
+ O126=$(bash "$FL" "$D/x_t.py" --out "$D/f126" --fleet "$D/f126.tbl" --round2 2>&1)
2050
+ if printf '%s\n' "$O126" | /usr/bin/grep -q 'unaccounted_r1=' \
2051
+ && /usr/bin/grep -q '"Q1"' "$D/f126/findings.jsonl" 2>/dev/null; then
2052
+ ok "L126 🟥 제목 «Q10» 철회가 제목 «Q1» 을 삼키지 않는다(Q1 은 설명 안 됨 → 폴백, 1차 그대로)"
2053
+ else
2054
+ no "L126 제목 부분일치 철회" "$(printf '%s\n' "$O126" | /usr/bin/grep -E 'unaccounted|MEMBER2' | head -2)"
2055
+ fi
2056
+
2057
+ # ── L127 🟥 codex R1 (같은 날) — 줄 «어디서든» 찾으면 이름만 «언급된» 발견도 철회로 셌다 ──
2058
+ # 처방 = DROPPED 줄은 «맨 앞에 오는» 한 발견만 철회한다(가장 긴 일치). 네 형태, 앞 셋은 말없이 빠진 A 가 살아 폴백해야,
2059
+ # 넷째(한국어 조사)는 정당한 철회로 인정돼야 한다 — 과차단 컨트롤.
2060
+ cat > "$D/x_two.sh" <<'EOS'
2061
+ #!/bin/sh
2062
+ IN=$(cat); [ -n "$IN" ] || IN="$*"
2063
+ case "$IN" in
2064
+ *"YOUR OWN ROUND-1 FINDINGS"*) printf '%s\n' "$TWO_DROP" ;;
2065
+ *) printf '{"title":"%s","file":"x_t.py","line":1,"severity":"A","category":"d","detail":"x","defeater":"y","confidence":0.7}\n' "$TWO_A"
2066
+ printf '{"title":"%s","file":"x_t.py","line":2,"severity":"B","category":"d","detail":"x","defeater":"y","confidence":0.7}\n' "$TWO_B" ;;
2067
+ esac
2068
+ EOS
2069
+ chmod +x "$D/x_two.sh"
2070
+ printf 'codex|logic|sh %s\n' "$D/x_two.sh" > "$D/f127.tbl"
2071
+ r127=""
2072
+ t127(){ # $1=label $2=A title $3=B title $4=DROPPED line $5=expect (fallback|withdrawn)
2073
+ _o=$(TWO_A="$2" TWO_B="$3" TWO_DROP="$4" bash "$FL" "$D/x_t.py" --out "$D/f127_$1" --fleet "$D/f127.tbl" --round2 2>&1)
2074
+ if [ "$5" = fallback ]; then
2075
+ printf '%s\n' "$_o" | /usr/bin/grep -q 'unaccounted_r1=' && /usr/bin/grep -qF "\"title\": \"$2\"" "$D/f127_$1/findings.jsonl" 2>/dev/null \
2076
+ || /usr/bin/grep -qF "\"title\":\"$2\"" "$D/f127_$1/findings.jsonl" 2>/dev/null || r127="$r127 $1"
2077
+ else
2078
+ printf '%s\n' "$_o" | /usr/bin/grep -q 'status=ZERO_SELFDROPPED' || r127="$r127 $1"
2079
+ fi
2080
+ }
2081
+ t127 punct 'Race' 'Race-condition' 'DROPPED: Race-condition — invalid' fallback
2082
+ t127 inid 'logic' 'Other' 'DROPPED: codex-logic-2 — invalid' fallback
2083
+ t127 reason 'Race condition' 'Other' 'DROPPED: codex-logic-2 — duplicate; Race condition remains valid' fallback
2084
+ # 컨트롤: 두 줄이 각자 «맨 앞» 에 한 발견씩 — 한국어 조사가 붙어도 정당한 철회로 셈 → 전원 철회
2085
+ t127 korean '경쟁 조건' 'Other' "$(printf 'DROPPED: 경쟁 조건은 오탐\nDROPPED: codex-logic-2은 오탐')" withdrawn
2086
+ if [ -z "$r127" ]; then
2087
+ ok "L127 🟥 DROPPED 는 맨 앞 한 발견만 철회(구두점 붙은 긴 제목 · id 속 제목 · 사유 속 언급 → 폴백) · 컨트롤: 한국어 조사 붙은 정당 철회는 인정"
2088
+ else
2089
+ no "L127 맨 앞 한 발견 철회" "failed:$r127"
2090
+ fi
2091
+
2009
2092
  /bin/rm -rf "$D"
2010
2093
  echo "PASS=$PASS FAIL=$FAIL"
2011
2094
  [ "$FAIL" -eq 0 ] && { echo "FAILED=0"; exit 0; } || { echo "FAILED=1"; exit 1; }
@@ -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
@@ -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"
@@ -767,6 +767,144 @@ else
767
767
  fail "L40 rc=$L40A_RC/$RC plain=$L40_PLAIN (see $L40)"
768
768
  fi
769
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
+
770
908
  echo "── $PASS_COUNT passed, $FAIL_COUNT failed ──"
771
909
 
772
910
  if [ "$FAIL_COUNT" -gt 0 ]; then
@@ -19,6 +19,10 @@
19
19
 
20
20
  ## When it applies
21
21
 
22
+ The leak gates (Steps 0–3) apply to any first-time public action below. The last item of
23
+ **§Read it as a reader** (Area B) applies to every minor/major release and every public announcement
24
+ of the harness itself, not only the first one.
25
+
22
26
  Any first-time public action:
23
27
  - `gh repo create --public` / `gh repo create ... --public`
24
28
  - `gh repo edit --visibility public` (private → public flip)
@@ -128,6 +132,12 @@ opens and look at what they see:
128
132
 
129
133
  A lens already exists — `/sim-conductor` A-1 (`beginner` cold-read) — or just render it and read it.
130
134
 
135
+ - [ ] **Minor/major release or public announcement of the harness itself**: run `/sim-conductor` Area B
136
+ (whole-set internal audit: outside-reader briefing · naming/structure gaps · challenger) unless one
137
+ already ran since the previous minor release. This replaced a 30-day terminal reminder on
138
+ 2026-10-19 (operator decision): Area B's distinct value is an outsider's view of the whole set,
139
+ and that view pays at publication, not on a clock.
140
+
131
141
  🟥 **Why this is a human step and not a scan**: a static check catches what is ABSENT, never what is
132
142
  UNREADABLE. Two independent measurements arrived here the same day (2026-08-17): one harness axis
133
143
  found 12 readability defects with **0** caught by static scanners; a third-harness review
@@ -588,6 +588,49 @@ for f in "${FILES[@]}"; do
588
588
  | grep -vE '^[0-9]+:[[:space:]]*#' \
589
589
  | grep -vE '#[[:space:]]*noqa[:[:space:]]*degrade')
590
590
  fi
591
+
592
+ # S7 — `set -e` under a declared exit contract that has its OWN error code, with no ERR trap.
593
+ # Under `set -e` a command that fails where nobody expected it ends the script with THAT
594
+ # command's status — usually 1. If the contract reserves a separate code for "the tool itself
595
+ # broke" (10 HARNESS_ERROR and the like), the low codes are verdicts, so a crash leaks out as
596
+ # one of them. Measured 2026-10-20 on fh-gate.sh: a failing `mktemp` exited 1 = PENDING
597
+ # ("proceed with awareness"); reported from outside, fixed in #927. The cure is an ERR trap
598
+ # that exits the error code, plus an exit-time check that 0..N only leave through the verdict
599
+ # sites (`set -u` and a failing EXIT-trap function end with 1 WITHOUT firing ERR).
600
+ # SCOPE, so this stays quiet: all three must hold — `set -…e…` · a comment header naming exit
601
+ # codes · a contract line naming an error code (harness/internal/tool error). A contract of
602
+ # just "0 = pass, 1 = fail" is excluded: there an unexpected 1 already points the safe way.
603
+ # Census 2026-10-20 over this repo's tracked shell: 1 file matched the shape (fh-gate.sh).
604
+ # FILE-level probe: it reports the `set -e` line once.
605
+ # Round-1 cross-family review (codex) widened three things: `set -o errexit` and `cmd; set -e`
606
+ # activate it; an `EXIT_*ERROR=10`-style constant counts as a contract; and a trap only counts
607
+ # when it EXITS — `trap cleanup ERR` (no exit) and a commented-out trap do not protect anything.
608
+ # A grep that ERRORS (rc>1) is reported as S7-UNMEASURED, never read as "no hit" — the same
609
+ # default-toward-clean shape this probe exists to find.
610
+ _s7_rc() { grep "$@" "$f" >/dev/null 2>&1; echo $?; }
611
+ _s7_lines=$(grep -nE '(^|[;{&|])[[:space:]]*set[[:space:]]+(-[A-Za-z]*e[A-Za-z]*|-o[[:space:]]+errexit)([[:space:];]|$)' "$f" 2>/dev/null); _s7_r1=$?
612
+ _s7_set=$(printf '%s\n' "$_s7_lines" | grep -vE '^[0-9]+:[[:space:]]*#' | grep -vE '#[[:space:]]*noqa[:[:space:]]*degrade' | sed -n 1p)
613
+ _s7_r2=$(_s7_rc -qE '^[[:space:]]*#.*\b[Ee]xit([[:space:]]+codes?|[[:space:]]+status(es)?)?[[:space:]]*:')
614
+ _s7_r3=$(_s7_rc -qiE '^[[:space:]]*#.*\b[0-9]+([[:space:]]*(—|–|-|=|:|\))[[:space:]]*.{0,40}|[[:space:]]+)(harness|internal|tool)[ _-]?error')
615
+ # ^ a CONTRACT ENTRY (`10 — Harness error`, `10 harness error`), not prose that happens to hold a
616
+ # number and the word (an old test file's comment «the count is 0 … HARNESS_ERROR» was flagged).
617
+ _s7_r4=$(_s7_rc -qE '^[[:space:]]*[A-Z_]*(HARNESS|INTERNAL|TOOL)_?ERR(OR)?[A-Z_]*=[0-9]+')
618
+ # protecting trap: an ACTIVE (non-comment) `trap … ERR` line that exits, or that names a handler
619
+ # function whose body (next 12 lines) exits.
620
+ _s7_traps=$(grep -nE "^[^#]*\btrap[[:space:]].*[[:space:]'\"]ERR(['\"]|[[:space:];]|$)" "$f" 2>/dev/null); _s7_r5=$?
621
+ _s7_guard=""
622
+ if [ -n "$_s7_traps" ]; then
623
+ if printf '%s\n' "$_s7_traps" | grep -qE '\bexit\b'; then _s7_guard=1
624
+ else
625
+ _s7_h=$(printf '%s\n' "$_s7_traps" | sed -nE "s/.*trap[[:space:]]+['\"]?([A-Za-z_][A-Za-z0-9_]*)['\"]?[[:space:]].*/\\1/p" | sed -n 1p)
626
+ [ -n "$_s7_h" ] && grep -A12 -E "^[[:space:]]*(function[[:space:]]+)?${_s7_h}[[:space:]]*\(\)" "$f" 2>/dev/null | grep -qE '\bexit\b' && _s7_guard=1
627
+ fi
628
+ fi
629
+ if [ "$_s7_r1" -gt 1 ] || [ "$_s7_r2" -gt 1 ] || [ "$_s7_r3" -gt 1 ] || [ "$_s7_r4" -gt 1 ] || [ "$_s7_r5" -gt 1 ]; then
630
+ emit "$f" 1 "S7-UNMEASURED(sh)" "could not read this file for the set -e / exit-contract check (grep error) — NOT checked, not clean"
631
+ elif [ -n "$_s7_set" ] && { { [ "$_s7_r2" -eq 0 ] && [ "$_s7_r3" -eq 0 ]; } || [ "$_s7_r4" -eq 0 ]; } && [ -z "$_s7_guard" ]; then
632
+ emit "$f" "${_s7_set%%:*}" "S7:set-e-leaks-verdict(sh)" "\`set -e\` under an exit contract that has its own error code, but no ERR trap that exits — an unexpected failure exits with the failing command's status (usually 1), which the contract reads as a verdict; add \`trap '…; exit <error-code>' ERR\` and an EXIT check that 0..N only leave through the verdict sites (set -u and EXIT-trap failures do not fire ERR). Do NOT add set -E without checking \`\$( ) || rc=\$?\` captures"
633
+ fi
591
634
  fi
592
635
 
593
636
  # Probe A — except/else/finally block returning a permissive value within 2 lines.