@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
@@ -368,6 +368,53 @@ def score_probe(primary_text, control_text, polarity, expect_re):
368
368
  return (PASS if not primary_hit else FAIL), primary_hit, control_hit
369
369
 
370
370
 
371
+ def _read_meta_tsv(path):
372
+ """key->value from a <arm>_r<n>.meta.tsv, or None when the file is absent."""
373
+ text = _read_text(path)
374
+ if text is None:
375
+ return None
376
+ out = {}
377
+ for line in text.splitlines():
378
+ if '\t' in line:
379
+ k, v = line.split('\t', 1)
380
+ out[k.strip()] = v.strip()
381
+ return out
382
+
383
+
384
+ def budget_line(base, arms_reps):
385
+ """BUDGET LINE (2026-10-17): the cap each verdict row ran under and whether any episode ENDED
386
+ AT it. Read from the runner's per-episode meta.tsv (written from the real invocation) — never
387
+ from constants in this file. `ended_at_cap` is three-valued: yes when ANY episode was cut at
388
+ its cap; otherwise UNKNOWN when any episode's value is UNKNOWN or its meta/field is missing
389
+ (an older run, or a stub that wrote none — not measured is not `no`); otherwise no.
390
+ Returns (ended_at_cap, text, n_yes, n_eps)."""
391
+ ends, caps = [], set()
392
+ for arm, i in arms_reps:
393
+ m = _read_meta_tsv(os.path.join(base, '%s_r%d.meta.tsv' % (arm, i)))
394
+ if m is None:
395
+ # No meta AND no transcript = the rep never ran: nothing to classify. A transcript
396
+ # without meta is an episode that ran unmeasured — UNKNOWN, never skipped (a skip
397
+ # let 2 `no` + 1 missing read as `no`).
398
+ if os.path.exists(os.path.join(base, '%s_r%d.txt' % (arm, i))):
399
+ ends.append('UNKNOWN')
400
+ continue
401
+ ends.append(m.get('ended_at_cap', 'UNKNOWN') or 'UNKNOWN')
402
+ caps.add('timeout=%ss max_turns=%s tokens=%s' % (
403
+ m.get('timeout_s', '?'), m.get('max_turns', '?'), m.get('token_cap', '?')))
404
+ if not caps:
405
+ return 'UNKNOWN', 'no episode meta (cap not recorded)', 0, len(ends)
406
+ n_yes = sum(1 for e in ends if e == 'yes')
407
+ if n_yes:
408
+ end = 'yes'
409
+ elif any(e != 'no' for e in ends):
410
+ end = 'UNKNOWN'
411
+ else:
412
+ end = 'no'
413
+ text = '%s ended_at_cap=%s%s' % ('; '.join(sorted(caps)), end,
414
+ ' (%d/%d episodes)' % (n_yes, len(ends)) if n_yes else '')
415
+ return end, text, n_yes, len(ends)
416
+
417
+
371
418
  def score_run(live_rows, run_root, ids_in_order, threshold, model, reps=1):
372
419
  """Read <run_root>/<id>/{primary,control}_r{1..reps}.txt for every id, score EACH rep, take the
373
420
  majority, and return a report dict. Does not touch the network or spawn `claude` — pure
@@ -396,7 +443,8 @@ def score_run(live_rows, run_root, ids_in_order, threshold, model, reps=1):
396
443
  for pid in ids_in_order:
397
444
  spec = by_id.get(pid)
398
445
  if spec is None:
399
- rows.append({'id': pid, 'verdict': 'UNKNOWN-ID', 'primary_hit': None, 'control_hit': None})
446
+ rows.append({'id': pid, 'verdict': 'UNKNOWN-ID', 'primary_hit': None, 'control_hit': None,
447
+ 'ended_at_cap': 'UNKNOWN', 'budget': 'n/a (unknown id)'})
400
448
  continue
401
449
  base = os.path.join(run_root, pid)
402
450
  has_ctrl_b = bool(spec.get('control_input_b'))
@@ -480,6 +528,10 @@ def score_run(live_rows, run_root, ids_in_order, threshold, model, reps=1):
480
528
  elif control_text is None or control_text == '':
481
529
  reasons.append('control: %s' % _failure_reason(base, 'control'))
482
530
  row['reason'] = '; '.join(reasons)
531
+ arms = ['primary', 'control'] + (['control_b'] if has_ctrl_b else [])
532
+ b_end, b_text, b_yes, b_n = budget_line(base, [(a, i) for a in arms for i in range(1, reps + 1)])
533
+ row['ended_at_cap'] = b_end
534
+ row['budget'] = b_text
483
535
  rows.append(row)
484
536
 
485
537
  # ── RUN-BLACKOUT / BLACKOUT-SUSPECT (2026-09-14) ──────────────────────────────────────────
@@ -568,6 +620,106 @@ def score_run(live_rows, run_root, ids_in_order, threshold, model, reps=1):
568
620
  }
569
621
 
570
622
 
623
+ def parse_prev_report(path):
624
+ """Rows of a previous live_eval_<date>.md run table -> {id: verdict}. None when unreadable or
625
+ no run table is found (the caller then says `before: not supplied`, never invents one)."""
626
+ text = _read_text(path)
627
+ if not text:
628
+ return None
629
+ out = {}
630
+ for line in text.splitlines():
631
+ cells = [c.strip() for c in line.strip().strip('|').split('|')]
632
+ if (line.startswith('|') and len(cells) >= 3
633
+ and cells[1] in (PASS, FAIL, UNCALIBRATED, FAILED_TO_RUN, 'UNKNOWN-ID')):
634
+ out[cells[0]] = cells[1]
635
+ return out or None
636
+
637
+
638
+ def _group_summary(verdicts, ended=None):
639
+ """verdicts: list of verdict strings -> counts. pass_rate is over PASS+FAIL only, the same
640
+ denominator score_run uses; None when nothing ran."""
641
+ ran = [v for v in verdicts if v in (PASS, FAIL)]
642
+ passed = [v for v in ran if v == PASS]
643
+ d = {'n': len(verdicts), 'ran': len(ran), 'passed': len(passed),
644
+ 'failed_to_run': sum(1 for v in verdicts if v == FAILED_TO_RUN),
645
+ 'uncalibrated': sum(1 for v in verdicts if v == UNCALIBRATED),
646
+ 'pass_rate': (len(passed) / float(len(ran))) if ran else None}
647
+ if ended is not None:
648
+ d['ended_at_cap_yes'] = sum(1 for e in ended if e == 'yes')
649
+ d['ended_at_cap_unknown'] = sum(1 for e in ended if e == 'UNKNOWN')
650
+ return d
651
+
652
+
653
+ def split_by_target(rows, target, before=None):
654
+ """--target <probe-id>: the targeted probe reported SEPARATELY from the rest, now and (when a
655
+ prior report is supplied) before. 'Fixed the target' and 'moved everything' are different
656
+ facts that one pooled pass_rate cannot tell apart. Record only: no verdict is changed and the
657
+ exit code never reads this. Returns None when target is not among the scored rows."""
658
+ tr = [r for r in rows if r['id'] == target]
659
+ if not tr:
660
+ return None
661
+ others = [r for r in rows if r['id'] != target]
662
+ res = {'target': target,
663
+ 'after_target': tr[0]['verdict'], 'after_target_cap': tr[0].get('ended_at_cap', 'UNKNOWN'),
664
+ 'after_others': _group_summary([r['verdict'] for r in others],
665
+ [r.get('ended_at_cap', 'UNKNOWN') for r in others]),
666
+ 'before': None, 'moved': []}
667
+ if before is not None:
668
+ oth_ids = [r['id'] for r in others]
669
+ b_oth = [before[i] for i in oth_ids if i in before]
670
+ res['before'] = {'target': before.get(target, 'ABSENT-IN-BEFORE'),
671
+ 'others': _group_summary(b_oth),
672
+ 'others_missing': [i for i in oth_ids if i not in before]}
673
+ res['moved'] = ['%s %s->%s' % (r['id'], before[r['id']], r['verdict'])
674
+ for r in others if r['id'] in before and before[r['id']] != r['verdict']]
675
+ return res
676
+
677
+
678
+ def _fmt_pr(g):
679
+ return ('%d/%d pass_rate=%s failed_to_run=%d uncalibrated=%d' % (
680
+ g['passed'], g['ran'], ('%.2f' % g['pass_rate']) if g['pass_rate'] is not None else 'n/a',
681
+ g['failed_to_run'], g['uncalibrated']))
682
+
683
+
684
+ def render_target_lines(t):
685
+ L = []
686
+ L.append('target=%s' % t['target'])
687
+ if t['before'] is not None:
688
+ L.append(' target before=%s after=%s (ended_at_cap=%s)' % (
689
+ t['before']['target'], t['after_target'], t['after_target_cap']))
690
+ L.append(' others before: %s' % _fmt_pr(t['before']['others']))
691
+ if t['before']['others_missing']:
692
+ L.append(' (not in before report, excluded from its count: %s)'
693
+ % ','.join(t['before']['others_missing']))
694
+ else:
695
+ L.append(' target before=not supplied (pass --before <prior live_eval .md>) after=%s '
696
+ '(ended_at_cap=%s)' % (t['after_target'], t['after_target_cap']))
697
+ L.append(' others after: %s ended_at_cap yes=%d unknown=%d' % (
698
+ _fmt_pr(t['after_others']), t['after_others']['ended_at_cap_yes'],
699
+ t['after_others']['ended_at_cap_unknown']))
700
+ if t['before'] is not None:
701
+ miss = t['before']['others_missing']
702
+ if t['moved']:
703
+ moved = ', '.join(t['moved'])
704
+ elif miss:
705
+ # «none» over a before-report that lacks those probes would read as «no movement».
706
+ moved = 'not comparable (%d others absent from before)' % len(miss)
707
+ else:
708
+ moved = 'none'
709
+ L.append(' others moved: %s' % moved)
710
+ return L
711
+
712
+
713
+ def render_target_md(t):
714
+ out = ['## Target split — %s' % t['target'], '',
715
+ 'Record only: the targeted probe is reported apart from the other probes so that '
716
+ '"fixed the target" is distinct from "moved everything". No verdict above depends on this.',
717
+ '']
718
+ out.extend('- ' + l.strip() if i else '- ' + l for i, l in enumerate(render_target_lines(t)))
719
+ out.append('')
720
+ return out
721
+
722
+
571
723
  def render_report_md(select_result, score_result, run_date):
572
724
  lines = []
573
725
  lines.append("# live_eval — %s" % run_date)
@@ -585,13 +737,13 @@ def render_report_md(select_result, score_result, run_date):
585
737
  if score_result is not None:
586
738
  lines.append("## Run — model=%s threshold=%.2f" % (score_result['model'], score_result['threshold']))
587
739
  lines.append("")
588
- lines.append("| Probe | Verdict | reps(pass/ran) | primary_hit | control_hit | polarity | Reason |")
589
- lines.append("|---|---|---|---|---|---|---|")
740
+ lines.append("| Probe | Verdict | reps(pass/ran) | primary_hit | control_hit | polarity | Reason | Budget |")
741
+ lines.append("|---|---|---|---|---|---|---|---|")
590
742
  for r in score_result['rows']:
591
- lines.append("| %s | %s | %s | %s | %s | %s | %s |" % (
743
+ lines.append("| %s | %s | %s | %s | %s | %s | %s | %s |" % (
592
744
  r['id'], r['verdict'], r.get('reps', '-'),
593
745
  r.get('primary_hit'), r.get('control_hit'), r.get('polarity', ''),
594
- _md_escape(r.get('reason', ''))))
746
+ _md_escape(r.get('reason', '')), _md_escape(r.get('budget', ''))))
595
747
  lines.append("")
596
748
  pr = score_result['pass_rate']
597
749
  pr_s = ("%.2f" % pr) if pr is not None else "n/a"
@@ -618,6 +770,8 @@ def render_report_md(select_result, score_result, run_date):
618
770
  "instrument failure produce this shape, and this file cannot tell them "
619
771
  "apart; the preserved response bodies can.")
620
772
  lines.append("")
773
+ if score_result is not None and score_result.get('target'):
774
+ lines.extend(render_target_md(score_result['target']))
621
775
  lines.append("## Excluded (from probes.md, 32-row snapshot)")
622
776
  lines.append("")
623
777
  lines.append("| Probe | Reason |")
@@ -705,8 +859,21 @@ def _cmd_score(args):
705
859
  reason = r.get('reason', '')
706
860
  if reason:
707
861
  line += " reason=%s" % reason
862
+ line += " | %s" % r.get('budget', '')
708
863
  print(line)
709
864
  print("")
865
+ if getattr(args, 'target', None):
866
+ before = parse_prev_report(args.before) if getattr(args, 'before', None) else None
867
+ if getattr(args, 'before', None) and before is None:
868
+ print("⚠️ --before %s unreadable or has no run table — before side NOT supplied" % args.before)
869
+ t = split_by_target(score_result['rows'], args.target, before)
870
+ if t is None:
871
+ print("❌ --target %s is not among the scored probes" % args.target, file=sys.stderr)
872
+ return 2
873
+ score_result['target'] = t
874
+ for l in render_target_lines(t):
875
+ print(l)
876
+ print("")
710
877
  pr = score_result['pass_rate']
711
878
  pr_s = ("%.2f" % pr) if pr is not None else "n/a"
712
879
  print("total=%d ran=%d failed_to_run=%d uncalibrated=%d passed=%d pass_rate=%s threshold=%.2f"
@@ -758,6 +925,8 @@ def main():
758
925
  sc.add_argument('--report-out')
759
926
  sc.add_argument('--run-date')
760
927
  sc.add_argument('--reps', type=int, default=1)
928
+ sc.add_argument('--target')
929
+ sc.add_argument('--before')
761
930
 
762
931
  args = ap.parse_args()
763
932
  if args.cmd == 'select':
@@ -25,7 +25,7 @@
25
25
  #
26
26
  # 범위 밖(이름으로 남긴다): 시스템 프롬프트 · 이 레포 밖 플러그인의 스킬 목록 · MCP 도구 설명 · 토큰 수.
27
27
  # 그래서 «합계» 는 «FH 가 좌우하는 상주분» 이지 세션 전체 비용이 아니다.
28
- # CLAUDE.md 크기 «가드» 는 scripts/test_claude_md_size_lanes.sh 가 따로 한다(한계 145,000). 이건 계기지 게이트가 아니다.
28
+ # CLAUDE.md 크기 «가드» 는 scripts/test_claude_md_size_lanes.sh 가 따로 한다(한계 18,000 — 2026-10-17 래칫). 이건 계기지 게이트가 아니다.
29
29
  #
30
30
  # 사용: python3 scripts/resident_cost.py [--json] [--repo DIR] [--user-claude FILE] [--memory-dir DIR]
31
31
  # [--memory-cap-chars N] [--no-user]
@@ -519,7 +519,7 @@ else
519
519
  fi
520
520
 
521
521
  # CLAUDE.md size guard — Claude Code warns «CLAUDE.md is over the 150.0k-char limit» on every session
522
- # start of a clone (measured 2026-09-26: 154,149 chars since ~v3.16.0). Guard at 145k (headroom ~1k/week).
522
+ # start of a clone (measured 2026-09-26: 154,149 chars since ~v3.16.0). Guard ratcheted 145k → 18k on 2026-10-17 (see the lane header; forks: FH_CLAUDE_MD_LIMIT).
523
523
  if [ ! -f CLAUDE.md ]; then
524
524
  _absent_subject_verdict "claude-md size lanes" "CLAUDE.md" || fail=1
525
525
  elif [ -f scripts/test_claude_md_size_lanes.sh ]; then
@@ -964,6 +964,42 @@ fi
964
964
  # script ships — both, and this anchor, are declared in package_coverage_check.sh ACCEPTED_ABSENT.
965
965
  # On a consumer install the SUBJECT arm fires first and `_ships_per_files` returns 1, so the row
966
966
  # resolves to "SKIP (subject not in files[], and absent)" — the anchor arm is never reached.
967
+ # Verdict for one subject|anchor suite's exit code. A function (2026-10-19) so the lane
968
+ # test_selfcheck_state_lanes.sh can call THIS code rather than a re-spelled copy. rc 0 = pass.
969
+ # 124 got its own arm because `timeout` kills silently: on 2026-10-18 a full local run ended
970
+ # `SELFCHECK: FAIL` with no FAIL line in 6,236 lines — the killed suite fell into a bare `*)`
971
+ # that set fail and printed nothing (fh_signal_2026-10-18_selfcheck-timeout-unlabelled). The
972
+ # catch-all now names the suite and its rc, so no exit code can fail without a line.
973
+ _pair_rc_verdict() { # $1=label $2=subject $3=rc · return 1 = counts as a failure
974
+ local _lbl="$1" _subj="$2" _rc="$3"
975
+ case "$_rc" in
976
+ 0) ;;
977
+ # The suite could not MEASURE. Distinguished from "the lane failed" because the two send a
978
+ # reader to different places, and a bare fail=1 sends them to the wrong one. 10 = the suite's
979
+ # own setup failed (mktemp, used by several of these); 2 = its subject was missing when it
980
+ # looked (test_knowledge_seam_lanes.sh:7 FATALs this way); 126/127 = the anchor is not
981
+ # executable or not found at all, i.e. a broken install that reached this arm anyway.
982
+ # Every one of them still sets fail — a harness that could not measure did not pass — but it
983
+ # is LABELLED, so the next reader debugs the instrument instead of the lane.
984
+ # The first draft of this loop routed only 10 and let everything else fall into an unlabelled
985
+ # fail=1. That is the same "assumed impossible rather than routed" shape that the sibling
986
+ # commit in lane_runner_check.sh had just written a paragraph against; adversarial review
987
+ # caught the inconsistency between the two files.
988
+ 10|2|126|127)
989
+ echo "HARNESS ERROR $_lbl: the suite exited $_rc — it could not measure, so its verdicts"
990
+ echo " prove nothing about $_subj. Not a lane failure, and not a pass either."
991
+ return 1 ;;
992
+ 124)
993
+ echo "TIMEOUT $_lbl: exited 124, the code \`timeout\` uses when it kills a suite (limit 300 s) —"
994
+ echo " not measured, not a pass. A suite that itself exits 124 lands here too."
995
+ echo " Re-run that suite alone to see whether it hangs or is only slow under load."
996
+ return 1 ;;
997
+ *)
998
+ echo "FAIL $_lbl (rc=$_rc) — see that suite's output above; subject: $_subj"
999
+ return 1 ;;
1000
+ esac
1001
+ return 0
1002
+ }
967
1003
  _LANE_TO=""; command -v timeout >/dev/null 2>&1 && _LANE_TO="timeout 300"
968
1004
  for _pair in \
969
1005
  `# 사용 원장 (2026-09-13 신설). SUBJECT 를 원장 모듈로 잡는다 — 배선이 끊기는 자리는 preprep.py 의 __main__ 한 줄이 아니라 모듈이 사라지는 쪽이고, import 가 try/except 라 모듈이 없으면 조용히 무동작으로 돌아간다. 그 무음이 이 레인이 잡을 것이다.` \
@@ -986,6 +1022,9 @@ for _pair in \
986
1022
  "scripts/session_close_check.sh|scripts/test_peer_worktree_detect_lanes.sh" \
987
1023
  "scripts/env_purity_scan.sh|scripts/test_env_purity_lanes.sh" \
988
1024
  "scripts/frontier_digest_daily.sh|scripts/test_frontier_digest_retry.sh" \
1025
+ "plugins/fh-meta/skills/frontier-digest/SKILL.md|scripts/test_frontier_digest_recall.sh" \
1026
+ "scripts/test_frontier_digest_recall.sh|scripts/test_frontier_digest_recall_negctl.sh" \
1027
+ "scripts/fh_module_check.py|scripts/test_fh_module_check_lanes.sh" \
989
1028
  "scripts/knowledge_seam_check.sh|scripts/test_knowledge_seam_lanes.sh" \
990
1029
  "templates/.git-hooks/pre-commit|scripts/test_marker_crossfamily_lanes.sh" \
991
1030
  "templates/.git-hooks/pre-commit|scripts/test_marker_floor_lanes.sh" \
@@ -1012,6 +1051,7 @@ for _pair in \
1012
1051
  "scripts/sim_isolated_run.sh|scripts/test_sim_path_isolation_lanes.sh" \
1013
1052
  `# ── mutation_probe (2026-10-07) — revert_probe 의 «저자가 고른 변이 1개» 를 연산자 생성 변이로 넓힌 것. 앵커가 고정하는 것은 생성기 보정(리다이렉트 비변이)과 «못 잰 것은 2» 다 ──` \
1014
1053
  "scripts/mutation_probe.py|scripts/test_mutation_probe_lanes.sh" \
1054
+ "scripts/cartridge_admit.py|scripts/test_cartridge_admit_lanes.sh" \
1015
1055
  `# ── live-eval — the live twin of the static /prompt-regression probe check (2026-09-04) ──` \
1016
1056
  "scripts/probe_live_eval.sh|scripts/test_probe_live_eval_lanes.sh" \
1017
1057
  "scripts/probe_live_eval_lib.py|scripts/test_probe_live_eval_lanes.sh" \
@@ -1085,12 +1125,17 @@ for _pair in \
1085
1125
  "scripts/transcript_utterances.py|scripts/test_utterance_intake_lanes.sh" \
1086
1126
  "scripts/compaction_probe.sh|scripts/test_utterance_intake_lanes.sh" \
1087
1127
  "scripts/session_close_check.sh|scripts/test_utterance_intake_lanes.sh" \
1128
+ `# ── 발화 체크리스트 훅(2026-10-18): 말한 순간 받아 적기 · 중간 점검 · 한글 턴. files[] 로 배포(selfcheck 가 이름을 대므로 package-coverage 가 요구) ──` \
1129
+ "scripts/utterance_checklist_hook.sh|scripts/test_utterance_checklist_hook_lanes.sh" \
1130
+ "scripts/utterance_checklist_hook.py|scripts/test_utterance_checklist_hook_lanes.sh" \
1088
1131
  `# ── 워크트리 회수(2026-09-05, N=2 재발 → 스크립트). 사람이 부르는 도구지만 레인은 자동 ──` \
1089
1132
  "scripts/worktree_reclaim.sh|scripts/test_worktree_reclaim_lanes.sh" \
1090
1133
  `# ── 가벼운 게이트 P1·P2(2026-10-12): 비주제 레인의 gh·①-g 스텁 + 켠/끈 비교기 ──` \
1091
1134
  "scripts/lane_stub_env.sh|scripts/test_lane_stub_env_lanes.sh" \
1092
1135
  "scripts/lane_stub_env.allow|scripts/test_lane_stub_env_lanes.sh" \
1093
- "scripts/lane_onoff_compare.py|scripts/test_lane_stub_env_lanes.sh"
1136
+ "scripts/lane_onoff_compare.py|scripts/test_lane_stub_env_lanes.sh" \
1137
+ `# ── 위임 마감 영수증(2026-10-20): 에이전트가 «고쳤다» 고 한 것을 거버너가 저장소에서 잰다(보고 ≠ 변경) ──` \
1138
+ "scripts/dispatch_receipt.py|scripts/test_dispatch_receipt_lanes.sh"
1094
1139
  do
1095
1140
  _subj="${_pair%%|*}"; _anc="${_pair##*|}"; _lbl="${_anc##*/}"
1096
1141
  if [ ! -f "$_subj" ]; then
@@ -1107,25 +1152,7 @@ do
1107
1152
  # a substitute; without it `< /dev/null` is the whole defence and a suite that reads stdin ends
1108
1153
  # immediately instead of waiting forever.
1109
1154
  $_LANE_TO bash "$_anc" < /dev/null; _rc=$?
1110
- case "$_rc" in
1111
- 0) ;;
1112
- # The suite could not MEASURE. Distinguished from "the lane failed" because the two send a
1113
- # reader to different places, and a bare fail=1 sends them to the wrong one. 10 = the suite's
1114
- # own setup failed (mktemp, used by several of these); 2 = its subject was missing when it
1115
- # looked (test_knowledge_seam_lanes.sh:7 FATALs this way); 126/127 = the anchor is not
1116
- # executable or not found at all, i.e. a broken install that reached this arm anyway.
1117
- # Every one of them still sets fail — a harness that could not measure did not pass — but it
1118
- # is LABELLED, so the next reader debugs the instrument instead of the lane.
1119
- # The first draft of this loop routed only 10 and let everything else fall into an unlabelled
1120
- # fail=1. That is the same "assumed impossible rather than routed" shape that the sibling
1121
- # commit in lane_runner_check.sh had just written a paragraph against; adversarial review
1122
- # caught the inconsistency between the two files.
1123
- 10|2|126|127)
1124
- echo "HARNESS ERROR $_lbl: the suite exited $_rc — it could not measure, so its verdicts"
1125
- echo " prove nothing about $_subj. Not a lane failure, and not a pass either."
1126
- fail=1 ;;
1127
- *) fail=1 ;;
1128
- esac
1155
+ _pair_rc_verdict "$_lbl" "$_subj" "$_rc" || fail=1
1129
1156
  elif _pkg_accepted_absent "$_anc"; then
1130
1157
  # DECLARED legitimately unshipped — the single source for that answer, not a guess from the
1131
1158
  # environment. The first draft printed "this package predates it", which is a WRONG DIAGNOSIS
@@ -3,13 +3,22 @@
3
3
 
4
4
  Two subcommands:
5
5
 
6
- extract --transcript <jsonl> [--out <md>]
6
+ extract --transcript <jsonl> [--out <md>] [--utterances <jsonl>]
7
7
  Reads a Claude Code transcript JSONL and emits a checklist SKELETON in
8
8
  Markdown: one row per operator utterance, 상태 column EMPTY. Opens TWO
9
9
  channels — raw entries and compaction-summary "All user messages"
10
10
  sections — and prints how many of each it found (0 found still counts
11
11
  as OPENED, never as "not opened"). See fh_signal_2026-09-18 for the
12
- doctrine this mechanizes.
12
+ doctrine this mechanizes. A THIRD channel, the UserPromptSubmit hook record
13
+ (tracks/_meta/utterances/<session_id>.jsonl, written by utterance_checklist_hook.py),
14
+ is merged in: it also holds messages sent while a tool was running, which the
15
+ transcript misses. Merge rule: a hook row is the same utterance as a transcript row
16
+ when the normalized text is equal (a hook row flagged `truncated` matches by prefix)
17
+ AND the timestamps are within HOOK_MATCH_WINDOW_S; each transcript row pairs with at
18
+ most one hook row (nearest in time). Unpaired hook rows are added as `H<n>` rows;
19
+ transcript rows keep `<n>`, summary rows `S<n>`. The header always states the hook
20
+ channel's state: not read (file absent) is NOT zero rows; a malformed line or an
21
+ unreadable file is a channel error (rc=2) and the transcript rows still print.
13
22
 
14
23
  check --file <md>
15
24
  Validates a FILLED checklist. FORM ONLY — this command never judges
@@ -57,6 +66,7 @@ closing/companion mark) apply only to entries that carry no metadata at all;
57
66
  there a byte-identical pasted envelope is indistinguishable by design.
58
67
  """
59
68
  import argparse
69
+ import datetime
60
70
  import json
61
71
  import os
62
72
  import re
@@ -343,7 +353,112 @@ def md_escape(text):
343
353
  return (text or "").replace("|", "\\|")
344
354
 
345
355
 
346
- def do_extract(transcript_path, out_path):
356
+ HOOK_MATCH_WINDOW_S = 1800 # a queued message can reach the transcript long after the hook saw it; further apart = a repeat, not the same message
357
+
358
+
359
+ def parse_ts(ts):
360
+ """transcript timestamps are UTC («…Z»); hook timestamps are local naive («YYYY-MM-DDTHH:MM:SS»). -> aware UTC datetime or None."""
361
+ c = parse_ts_candidates(ts)
362
+ return c[0] if c else None
363
+
364
+
365
+ TS_SHAPE_RE = re.compile(r"^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?Z?$")
366
+
367
+
368
+ def parse_ts_candidates(ts):
369
+ """-> [aware UTC datetimes]. A local naive time inside a DST fall-back hour names TWO instants (fold 0 and 1);
370
+ both are returned so the matcher can use the nearer one (codex 2026-10-19: picking one created a duplicate row)."""
371
+ if not isinstance(ts, str) or not TS_SHAPE_RE.match(ts):
372
+ return [] # exact shape only — `ts[:19]` alone accepted trailing garbage as a valid time (codex R2)
373
+ try:
374
+ dt = datetime.datetime.strptime(ts[:19], "%Y-%m-%dT%H:%M:%S")
375
+ except ValueError:
376
+ return []
377
+ if ts.endswith("Z"):
378
+ return [dt.replace(tzinfo=datetime.timezone.utc)]
379
+ out = []
380
+ for fold in (0, 1):
381
+ u = dt.replace(fold=fold).astimezone(datetime.timezone.utc)
382
+ if u not in out:
383
+ out.append(u)
384
+ return out
385
+
386
+
387
+ def default_hook_path(transcript_path):
388
+ sid = os.path.splitext(os.path.basename(transcript_path))[0]
389
+ hub = os.environ.get("FH_HUB") or os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
390
+ return os.path.join(hub, "tracks", "_meta", "utterances", sid + ".jsonl")
391
+
392
+
393
+ def read_hook_channel(path):
394
+ """-> (state, rows, bad_lines, detail). state: «read» · «absent» · «error». rows: [{ts, text, truncated}]."""
395
+ if not os.path.lexists(path):
396
+ return "absent", [], 0, ""
397
+ if not os.path.isfile(path):
398
+ return "error", [], 0, "not a regular file"
399
+ rows, bad = [], 0
400
+ try:
401
+ with open(path, "rb") as f:
402
+ for raw in f:
403
+ try:
404
+ line = raw.decode("utf-8").strip() # strict: a replaced byte would make a different text and a spurious H row
405
+ if not line:
406
+ continue
407
+ d = json.loads(line)
408
+ except Exception:
409
+ bad += 1
410
+ continue
411
+ if not isinstance(d, dict) or not isinstance(d.get("text"), str) or not d["text"].strip():
412
+ bad += 1
413
+ continue
414
+ if not parse_ts_candidates(d.get("ts")):
415
+ bad += 1 # the hook always writes ts; without it the time window cannot apply, so the row is not trusted
416
+ continue
417
+ rows.append({"ts": d.get("ts"), "text": d["text"], "truncated": d.get("truncated") is True})
418
+ except OSError as e:
419
+ return "error", [], 0, e.strerror or "unreadable"
420
+ return "read", rows, bad, ""
421
+
422
+
423
+ def merge_hook_rows(raw_rows, hook_rows):
424
+ """-> (hook_only, matched_count). Both channels record the same conversation in the same order, so pairing is
425
+ ORDER-PRESERVING, not nearest-first: hook rows in time order each take the EARLIEST unpaired transcript row of equal
426
+ normalized text inside HOOK_MATCH_WINDOW_S. Exact-text pairs (any row) are made first and truncated-prefix pairs
427
+ second, so a truncated hook row cannot take the row another hook row matches exactly. Still greedy, not an optimal
428
+ assignment — a named residual. (codex 2026-10-19: nearest-first greedy turned two
429
+ repeated «yes» pairs into three rows.) A transcript row with no usable time pairs on text alone."""
430
+ raw_norms = [normalize_utterance(r["text"]) for r in raw_rows]
431
+ raw_dts = [parse_ts(r["ts"]) for r in raw_rows]
432
+ order = sorted(range(len(hook_rows)), key=lambda k: (min(parse_ts_candidates(hook_rows[k]["ts"]) or [datetime.datetime.max.replace(tzinfo=datetime.timezone.utc)]), k))
433
+ used, paired = set(), set()
434
+
435
+ def within(hdts, i):
436
+ if raw_dts[i] is None or not hdts:
437
+ return True
438
+ return min(abs((h - raw_dts[i]).total_seconds()) for h in hdts) <= HOOK_MATCH_WINDOW_S
439
+
440
+ for prefix_pass in (False, True):
441
+ for k in order:
442
+ h = hook_rows[k]
443
+ if k in paired or (prefix_pass and not h["truncated"]):
444
+ continue # pass 1 = exact text for every row (a truncated row whose text is exact counts); pass 2 = prefixes
445
+ hn = normalize_utterance(h["text"])
446
+ hdts = parse_ts_candidates(h["ts"])
447
+ cands = [i for i, rn in enumerate(raw_norms)
448
+ if i not in used and (rn == hn or (prefix_pass and hn and rn.startswith(hn))) and within(hdts, i)]
449
+ if cands:
450
+ best = min(cands, key=lambda i: (raw_dts[i] is None, raw_dts[i] or 0, i))
451
+ used.add(best); paired.add(k)
452
+ hook_only = []
453
+ for k in order:
454
+ if k in paired:
455
+ continue
456
+ hdts = parse_ts_candidates(hook_rows[k]["ts"])
457
+ hook_only.append({"ts": hdts[0].strftime("%Y-%m-%dT%H:%M:%SZ") if hdts else None, "text": hook_rows[k]["text"]})
458
+ return hook_only, len(paired)
459
+
460
+
461
+ def do_extract(transcript_path, out_path, utterances_path=None):
347
462
  if not os.path.isfile(transcript_path):
348
463
  sys.stderr.write("error: transcript not found: %s\n" % transcript_path)
349
464
  return 10
@@ -389,6 +504,13 @@ def do_extract(transcript_path, out_path):
389
504
  continue
390
505
  raw_rows.append({"ts": entry.get("timestamp"), "text": text})
391
506
 
507
+ hook_path = utterances_path or default_hook_path(transcript_path)
508
+ hook_state, hook_rows, hook_bad, hook_detail = read_hook_channel(hook_path)
509
+ hook_only, hook_matched = merge_hook_rows(raw_rows, hook_rows)
510
+
511
+ # summary quotes are compared against the transcript rows only, as before: matching them against hook-only rows
512
+ # too dropped a distinct request that happened to repeat a short quote (codex 2026-10-19). A duplicate row is the
513
+ # safe direction; a missing one is not.
392
514
  raw_norms = [normalize_utterance(r["text"]) for r in raw_rows]
393
515
 
394
516
  summary_found_total = 0
@@ -406,7 +528,7 @@ def do_extract(transcript_path, out_path):
406
528
  n_raw = len(raw_rows)
407
529
  n_summary_found = summary_found_total
408
530
  n_summary_added = len(summary_rows)
409
- rc = 2 if parse_errors else 0 # v5: an unparsable line may have been an utterance — loud, never rc=0
531
+ rc = 2 if (parse_errors or hook_bad or hook_state == "error") else 0 # v5: an unparsable line may have been an utterance — loud, never rc=0
410
532
 
411
533
  lines_out = []
412
534
  title = "# 세션 요청 체크리스트 (스켈레톤) — %s" % os.path.basename(transcript_path)
@@ -419,6 +541,15 @@ def do_extract(transcript_path, out_path):
419
541
  lines_out.append(chr(0x1F4CE) + " " + "원장 = %s (%d lines)" % (transcript_path, line_count))
420
542
  if parse_errors:
421
543
  lines_out.append("🟥 JSONL 파싱 실패 %d줄 — 그 줄의 발화는 이 표에 없다 (rc=2)" % parse_errors)
544
+ if hook_state == "read":
545
+ lines_out.append("🪝 훅 기록 채널 읽음 — %d건 · 전사와 일치 %d건 · 훅 전용 %d건 (행 번호 H = 훅 전용, S = 요약, 숫자 = 전사)"
546
+ % (len(hook_rows), hook_matched, len(hook_only)))
547
+ elif hook_state == "absent":
548
+ lines_out.append("🟨 훅 기록 채널 안 읽음 — 파일 없음: %s (0건이 아니라 미열람; 훅이 안 걸렸거나 다른 허브일 수 있다)" % hook_path)
549
+ else:
550
+ lines_out.append("🟥 훅 기록 채널 오류 — %s: %s (rc=2; 전사 행은 그대로 아래에 있다)" % (hook_path, hook_detail))
551
+ if hook_bad:
552
+ lines_out.append("🟥 훅 기록 %d줄 해석 실패 — 그 줄의 발화는 이 표에 없을 수 있다 (rc=2)" % hook_bad)
422
553
  lines_out.append("")
423
554
  lines_out.append(
424
555
  "| # | \uc2dc\uac01 | \ubc1c\ud654(\uc694\uc9c0) | \uc0c1\ud0dc | \uc99d\uac70 | \uc0ac\uc720 / \ub0a8\uc740 \uac83 | \uc81c\uc548(\uc774\ubc88 \uc138\uc158 vs \uc774\uc6d4) |"
@@ -435,6 +566,16 @@ def do_extract(transcript_path, out_path):
435
566
  "| %d | %s | %s | | | | |" % (n, format_ts(r["ts"]), md_escape(blurb))
436
567
  )
437
568
 
569
+ h = 0
570
+ for r in hook_only:
571
+ h += 1
572
+ blurb = collapse(r["text"])
573
+ if len(blurb) > 160:
574
+ blurb = blurb[:160] + "\u2026"
575
+ lines_out.append(
576
+ "| H%d | %s | %s | | | | |" % (h, format_ts(r["ts"]), md_escape(blurb))
577
+ )
578
+
438
579
  s = 0
439
580
  for r in summary_rows:
440
581
  s += 1
@@ -445,6 +586,13 @@ def do_extract(transcript_path, out_path):
445
586
  "| S%d | (요약) | %s | | | | |" % (s, md_escape(blurb))
446
587
  )
447
588
 
589
+ # Re-running extract on a sheet that is already filled must not wipe it (2026-10-18: the mid-session nudge
590
+ # tells the session to re-extract into the SAME file; a plain overwrite erased 259 filled rows' 상태/증거).
591
+ # Carry the four judgement cells forward by (시각, 발화) — both are generated deterministically — and keep
592
+ # any filled row that no longer matches in a section at the end: dropped judgements are named, never lost.
593
+ if out_path and os.path.exists(out_path):
594
+ lines_out = carry_forward(lines_out, out_path)
595
+
448
596
  content = "\n".join(lines_out) + "\n"
449
597
  sys.stdout.write(content)
450
598
 
@@ -455,6 +603,65 @@ def do_extract(transcript_path, out_path):
455
603
  return rc
456
604
 
457
605
 
606
+ def _cells(line):
607
+ """split a markdown table row on unescaped «|» (md_escape writes «\\|»); None if not a 7-cell data row."""
608
+ if not line.startswith("| "):
609
+ return None
610
+ parts, cur, i = [], "", 0
611
+ while i < len(line):
612
+ ch = line[i]
613
+ if ch == "\\" and i + 1 < len(line) and line[i + 1] == "|":
614
+ cur += "\\|"; i += 2; continue
615
+ if ch == "|":
616
+ parts.append(cur); cur = ""
617
+ else:
618
+ cur += ch
619
+ i += 1
620
+ parts.append(cur)
621
+ cells = [c.strip() for c in parts[1:-1]]
622
+ return cells if len(cells) == 7 else None
623
+
624
+
625
+ CARRY_HEADING = "## 이전 결과서에서 이어받지 못한 판정"
626
+
627
+
628
+ def carry_forward(lines_out, out_path):
629
+ try:
630
+ with open(out_path, "r", encoding="utf-8", errors="replace") as f:
631
+ old = f.read().split("\n")
632
+ except OSError:
633
+ return lines_out
634
+ prev, orphans_prev = {}, []
635
+ in_orphans = False
636
+ for l in old:
637
+ if l.startswith(CARRY_HEADING):
638
+ in_orphans = True; continue
639
+ c = _cells(l)
640
+ if not c or c[0] in ("#", "---") or set(c[0]) <= set("-"):
641
+ continue
642
+ if not any(c[3:]):
643
+ continue # an empty row has nothing to carry
644
+ if in_orphans:
645
+ orphans_prev.append(l); continue # earlier orphans stay orphans unless they match below
646
+ prev.setdefault((c[1], c[2]), []).append(c[3:]) # a LIST per key: repeated rows (same minute, same words) keep each judgment, in order
647
+ used, out = 0, []
648
+ for l in lines_out:
649
+ c = _cells(l)
650
+ key = (c[1], c[2]) if c else None
651
+ if c and prev.get(key) and not any(c[3:]):
652
+ out.append("| %s | %s | %s | %s | %s | %s | %s |" % tuple(c[:3] + prev[key].pop(0)))
653
+ used += 1; continue
654
+ out.append(l)
655
+ orphans = ["| %s | %s | %s | %s | %s | %s | %s |" % ((("-",) + k + tuple(v))) for k, vs in prev.items() for v in vs]
656
+ orphans += orphans_prev
657
+ if used or orphans:
658
+ out.insert(4, "↩️ 이전 결과서에서 판정 %d줄 이어받음 · 못 맞춘 판정 %d줄은 맨 아래 «이전 결과서에서 이어받지 못한 판정»에 보존" % (used, len(orphans)))
659
+ if orphans:
660
+ out += ["", CARRY_HEADING, "", "| # | 시각 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안(이번 세션 vs 이월) |",
661
+ "|---|---|---|---|---|---|---|"] + orphans
662
+ return out
663
+
664
+
458
665
  # ---------------------------------------------------------------------------
459
666
  # check
460
667
  # ---------------------------------------------------------------------------
@@ -685,6 +892,8 @@ def build_parser():
685
892
  p_extract = sub.add_parser("extract", help="extract a checklist skeleton from a transcript JSONL")
686
893
  p_extract.add_argument("--transcript", required=True)
687
894
  p_extract.add_argument("--out", default=None)
895
+ p_extract.add_argument("--utterances", default=None,
896
+ help="hook record jsonl (default: <hub>/tracks/_meta/utterances/<session id>.jsonl)")
688
897
 
689
898
  p_unblocked = sub.add_parser(
690
899
  "unblocked",
@@ -799,7 +1008,7 @@ def main(argv=None):
799
1008
  args = parser.parse_args(argv)
800
1009
 
801
1010
  if args.cmd == "extract":
802
- return do_extract(args.transcript, args.out)
1011
+ return do_extract(args.transcript, args.out, args.utterances)
803
1012
  if args.cmd == "check":
804
1013
  return do_check(args.file)
805
1014
  if args.cmd == "unblocked":