@chrono-meta/fh-gate 3.26.2 → 3.28.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 (56) hide show
  1. package/.claude-plugin/marketplace.json +4 -4
  2. package/AGENTS.md +2 -1
  3. package/CLAUDE.md +84 -1329
  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/knowledge/shared/dialogue/memory_intent_recall.md +35 -0
  9. package/knowledge/shared/harness-core/builtin_capability_map.md +70 -0
  10. package/knowledge/shared/harness-core/claude_md_full_reference.md +1277 -0
  11. package/knowledge/shared/harness-core/fh_module_contract.md +97 -0
  12. package/knowledge/shared/harness-core/multi_model_sidecar_strategy.md +64 -0
  13. package/knowledge/shared/learnings/subagent_invocations_log.yaml +145 -0
  14. package/package.json +14 -1
  15. package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
  16. package/plugins/fh-commons/skills/ko-tech-writer/SKILL.md +84 -4
  17. package/plugins/fh-commons/skills/ko-tech-writer/fh-module.yaml +19 -0
  18. package/plugins/fh-commons/skills/ko-tech-writer/fixtures/known_negative.md +73 -1
  19. package/plugins/fh-commons/skills/ko-tech-writer/fixtures/known_positive.md +39 -1
  20. package/plugins/fh-commons/skills/ko-tech-writer/fixtures/known_unclosed.md +6 -0
  21. package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
  22. package/plugins/fh-meta/CHANGELOG.md +23 -0
  23. package/plugins/fh-meta/skills/context-doctor/SKILL.md +1 -1
  24. package/plugins/fh-meta/skills/frontier-digest/SKILL.md +14 -10
  25. package/plugins/fh-meta/skills/frontier-digest/SKILL_detail.md +17 -1
  26. package/plugins/fh-meta/skills/install-doctor/SKILL.md +1 -1
  27. package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
  28. package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
  29. package/scripts/fh_env_delta_scan.sh +20 -4
  30. package/scripts/fh_module_check.py +686 -0
  31. package/scripts/fixtures/frontier_digest_recall.tsv +5 -0
  32. package/scripts/ko_tech_writer_calibrate.py +288 -15
  33. package/scripts/memory_gc_report.py +270 -0
  34. package/scripts/probe_live_eval.sh +19 -1
  35. package/scripts/probe_live_eval_lib.py +174 -5
  36. package/scripts/resident_cost.py +1 -1
  37. package/scripts/selfcheck.sh +34 -1
  38. package/scripts/session_checklist.py +66 -0
  39. package/scripts/session_close_check.sh +44 -0
  40. package/scripts/sim_isolated_run.sh +31 -0
  41. package/scripts/test_claude_md_size_lanes.sh +22 -7
  42. package/scripts/test_env_delta_worktree_lanes.sh +61 -0
  43. package/scripts/test_fh_module_check_lanes.sh +581 -0
  44. package/scripts/test_frontier_digest_recall.sh +26 -0
  45. package/scripts/test_frontier_digest_recall_negctl.sh +15 -0
  46. package/scripts/test_ko_tech_writer_lanes.sh +1 -1
  47. package/scripts/test_memory_gc_report_lanes.sh +210 -0
  48. package/scripts/test_probe_live_eval_lanes.sh +116 -0
  49. package/scripts/test_regression_guard_sibling_lanes.sh +193 -0
  50. package/scripts/test_resident_cost_lanes.sh +1 -1
  51. package/scripts/test_session_checklist_lanes.sh +29 -0
  52. package/scripts/test_sim_isolated_run_lanes.sh +51 -0
  53. package/scripts/test_utterance_checklist_hook_lanes.sh +175 -0
  54. package/scripts/utterance_checklist_hook.py +193 -0
  55. package/scripts/utterance_checklist_hook.sh +31 -0
  56. package/templates/regression_guard.sh +30 -12
@@ -69,6 +69,8 @@
69
69
  # bash scripts/probe_live_eval.sh --ids G-GREET-01,G-TRIG-02 --model sonnet
70
70
  # bash scripts/probe_live_eval.sh --subset 3
71
71
  # bash scripts/probe_live_eval.sh --subset 3 --report-out /tmp/spot.md # spot-check: keep the nightly record untouched
72
+ # bash scripts/probe_live_eval.sh --target G-TRIG-02 --before tracks/_meta/live_eval_2026-10-16.md
73
+ # # after a repair aimed at one probe: target reported apart from the other probes, before/after
72
74
  # bash scripts/probe_live_eval.sh # full selected set — nightly cron shape
73
75
  #
74
76
  # PORTABILITY: bash 3.2 (macOS) + bash 5.x (Linux CI). No associative arrays, no `${var,,}`,
@@ -140,6 +142,8 @@ SUBSET=""
140
142
  IDS=""
141
143
  OUTDIR=""
142
144
  REPORT_OUT="" # --report-out: where the markdown report lands (default: tracks/_meta/live_eval_<date>.md)
145
+ TARGET="" # --target <probe-id>: report that probe apart from the rest (record only; default output unchanged)
146
+ BEFORE="" # --before <prior live_eval .md>: the "before" side of the --target split
143
147
  NO_EVIDENCE=0 # --no-evidence: skip the preserved-artifact copy (lanes / throwaway spot-checks)
144
148
  while [ $# -gt 0 ]; do
145
149
  case "$1" in
@@ -151,6 +155,8 @@ while [ $# -gt 0 ]; do
151
155
  --out) OUTDIR="${2:-}"; shift 2 ;;
152
156
  --report-out) REPORT_OUT="${2:-}"; shift 2 ;; # lanes/spot-checks MUST pass this — never the live path
153
157
  --no-evidence) NO_EVIDENCE=1; shift ;;
158
+ --target) TARGET="${2:-}"; shift 2 ;;
159
+ --before) BEFORE="${2:-}"; shift 2 ;;
154
160
  *) echo "unknown flag: $1" >&2; exit 2 ;;
155
161
  esac
156
162
  done
@@ -198,6 +204,15 @@ if [ "$SELECTED_COUNT" -eq 0 ]; then
198
204
  exit 2
199
205
  fi
200
206
 
207
+ # --target must name a probe that is actually in this run: a typo would otherwise burn the whole
208
+ # live run and only fail at report time.
209
+ if [ -n "$TARGET" ] && ! grep -qxF -- "$TARGET" "$SPEC_DIR/selected_ids.txt"; then
210
+ echo "❌ --target '$TARGET' is not among the selected probes (see SELECTED above) — refusing before any live call." >&2
211
+ rm -rf "$WORKDIR"
212
+ exit 2
213
+ fi
214
+ [ -z "$BEFORE" ] || [ -n "$TARGET" ] || { echo "❌ --before only makes sense with --target" >&2; rm -rf "$WORKDIR"; exit 2; }
215
+
201
216
  # `claude` presence is the REAL runner's preflight, so it is checked only on that path. Under
202
217
  # FH_SIM_RUNNER_BIN the stub owns its own preflight — measured 2026-09-05 on CI (ubuntu, no
203
218
  # `claude` installed): this line fired BEFORE the stub was ever called, so FF2/FF3/FF4/FF6 went
@@ -336,7 +351,10 @@ echo ""
336
351
  # default overwrote a real night's distribution once (2026-09-05 10:18: test_probe_live_eval_lanes.sh FF4
337
352
  # ran the real script with a stub runner and replaced the 02:30 report). Lanes pass --report-out.
338
353
  REPORT_PATH="${REPORT_OUT:-$REPO_ROOT/tracks/_meta/live_eval_${RUN_DATE}.md}"
339
- python3 "$LIB" score \
354
+ SCORE_EXTRA=()
355
+ [ -n "$TARGET" ] && SCORE_EXTRA+=(--target "$TARGET")
356
+ [ -n "$BEFORE" ] && SCORE_EXTRA+=(--before "$BEFORE")
357
+ python3 "$LIB" score ${SCORE_EXTRA[@]+"${SCORE_EXTRA[@]}"} \
340
358
  --probes-live "$PROBES_LIVE" \
341
359
  --select-json "$SELECT_JSON" \
342
360
  --ids-file "$SPEC_DIR/selected_ids.txt" \
@@ -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
@@ -986,10 +986,14 @@ for _pair in \
986
986
  "scripts/session_close_check.sh|scripts/test_peer_worktree_detect_lanes.sh" \
987
987
  "scripts/env_purity_scan.sh|scripts/test_env_purity_lanes.sh" \
988
988
  "scripts/frontier_digest_daily.sh|scripts/test_frontier_digest_retry.sh" \
989
+ "plugins/fh-meta/skills/frontier-digest/SKILL.md|scripts/test_frontier_digest_recall.sh" \
990
+ "scripts/test_frontier_digest_recall.sh|scripts/test_frontier_digest_recall_negctl.sh" \
991
+ "scripts/fh_module_check.py|scripts/test_fh_module_check_lanes.sh" \
989
992
  "scripts/knowledge_seam_check.sh|scripts/test_knowledge_seam_lanes.sh" \
990
993
  "templates/.git-hooks/pre-commit|scripts/test_marker_crossfamily_lanes.sh" \
991
994
  "templates/.git-hooks/pre-commit|scripts/test_marker_floor_lanes.sh" \
992
995
  ".github/workflows/regression-guard.yml|scripts/test_regression_guard_ci_lanes.sh" \
996
+ "templates/regression_guard.sh|scripts/test_regression_guard_sibling_lanes.sh" \
993
997
  ".github/workflows/validate.yml|scripts/test_leak_scan_control_lanes.sh" \
994
998
  "templates/.git-hooks/pre-commit|scripts/test_marker_standpoint_lanes.sh" \
995
999
  "templates/.git-hooks/pre-commit|scripts/test_marker_thirdparty_lanes.sh" \
@@ -1084,6 +1088,9 @@ for _pair in \
1084
1088
  "scripts/transcript_utterances.py|scripts/test_utterance_intake_lanes.sh" \
1085
1089
  "scripts/compaction_probe.sh|scripts/test_utterance_intake_lanes.sh" \
1086
1090
  "scripts/session_close_check.sh|scripts/test_utterance_intake_lanes.sh" \
1091
+ `# ── 발화 체크리스트 훅(2026-10-18): 말한 순간 받아 적기 · 중간 점검 · 한글 턴. files[] 로 배포(selfcheck 가 이름을 대므로 package-coverage 가 요구) ──` \
1092
+ "scripts/utterance_checklist_hook.sh|scripts/test_utterance_checklist_hook_lanes.sh" \
1093
+ "scripts/utterance_checklist_hook.py|scripts/test_utterance_checklist_hook_lanes.sh" \
1087
1094
  `# ── 워크트리 회수(2026-09-05, N=2 재발 → 스크립트). 사람이 부르는 도구지만 레인은 자동 ──` \
1088
1095
  "scripts/worktree_reclaim.sh|scripts/test_worktree_reclaim_lanes.sh" \
1089
1096
  `# ── 가벼운 게이트 P1·P2(2026-10-12): 비주제 레인의 gh·①-g 스텁 + 켠/끈 비교기 ──` \
@@ -2101,6 +2108,32 @@ else
2101
2108
  fail=1
2102
2109
  fi
2103
2110
 
2111
+ # env-delta SessionStart hook — linked worktrees are not new sibling repos (2026-10-15: 30 of 33
2112
+ # «unmapped siblings» were worktrees). Same pairing rule as above.
2113
+ if [ ! -f scripts/fh_env_delta_scan.sh ]; then
2114
+ _absent_subject_verdict "test_env_delta_worktree_lanes.sh" "scripts/fh_env_delta_scan.sh" || fail=1
2115
+ elif [ -f scripts/test_env_delta_worktree_lanes.sh ]; then
2116
+ if ! bash scripts/test_env_delta_worktree_lanes.sh; then
2117
+ fail=1
2118
+ fi
2119
+ else
2120
+ echo "FAIL test_env_delta_worktree_lanes.sh: fh_env_delta_scan.sh present but its anchor is missing"
2121
+ fail=1
2122
+ fi
2123
+
2124
+ # memory_gc_report.py — read-only lifecycle report over a memory dir (age from `hits`, cold, promote,
2125
+ # index hygiene, loader cap). Same pairing rule as above.
2126
+ if [ ! -f scripts/memory_gc_report.py ]; then
2127
+ _absent_subject_verdict "test_memory_gc_report_lanes.sh" "scripts/memory_gc_report.py" || fail=1
2128
+ elif [ -f scripts/test_memory_gc_report_lanes.sh ]; then
2129
+ if ! bash scripts/test_memory_gc_report_lanes.sh; then
2130
+ fail=1
2131
+ fi
2132
+ else
2133
+ echo "FAIL test_memory_gc_report_lanes.sh: memory_gc_report.py present but its anchor is missing"
2134
+ fail=1
2135
+ fi
2136
+
2104
2137
  # SessionStart multi-hook + install-wizard snippet merge. Subject for both = the shipped settings
2105
2138
  # snippets; a clone without them is a legitimate SKIP, a clone with them and no anchor is not —
2106
2139
  # UNLESS the anchor itself is declared package-mode-optional. test_sessionstart_multihook_lanes.sh
@@ -445,6 +445,13 @@ def do_extract(transcript_path, out_path):
445
445
  "| S%d | (요약) | %s | | | | |" % (s, md_escape(blurb))
446
446
  )
447
447
 
448
+ # Re-running extract on a sheet that is already filled must not wipe it (2026-10-18: the mid-session nudge
449
+ # tells the session to re-extract into the SAME file; a plain overwrite erased 259 filled rows' 상태/증거).
450
+ # Carry the four judgement cells forward by (시각, 발화) — both are generated deterministically — and keep
451
+ # any filled row that no longer matches in a section at the end: dropped judgements are named, never lost.
452
+ if out_path and os.path.exists(out_path):
453
+ lines_out = carry_forward(lines_out, out_path)
454
+
448
455
  content = "\n".join(lines_out) + "\n"
449
456
  sys.stdout.write(content)
450
457
 
@@ -455,6 +462,65 @@ def do_extract(transcript_path, out_path):
455
462
  return rc
456
463
 
457
464
 
465
+ def _cells(line):
466
+ """split a markdown table row on unescaped «|» (md_escape writes «\\|»); None if not a 7-cell data row."""
467
+ if not line.startswith("| "):
468
+ return None
469
+ parts, cur, i = [], "", 0
470
+ while i < len(line):
471
+ ch = line[i]
472
+ if ch == "\\" and i + 1 < len(line) and line[i + 1] == "|":
473
+ cur += "\\|"; i += 2; continue
474
+ if ch == "|":
475
+ parts.append(cur); cur = ""
476
+ else:
477
+ cur += ch
478
+ i += 1
479
+ parts.append(cur)
480
+ cells = [c.strip() for c in parts[1:-1]]
481
+ return cells if len(cells) == 7 else None
482
+
483
+
484
+ CARRY_HEADING = "## 이전 결과서에서 이어받지 못한 판정"
485
+
486
+
487
+ def carry_forward(lines_out, out_path):
488
+ try:
489
+ with open(out_path, "r", encoding="utf-8", errors="replace") as f:
490
+ old = f.read().split("\n")
491
+ except OSError:
492
+ return lines_out
493
+ prev, orphans_prev = {}, []
494
+ in_orphans = False
495
+ for l in old:
496
+ if l.startswith(CARRY_HEADING):
497
+ in_orphans = True; continue
498
+ c = _cells(l)
499
+ if not c or c[0] in ("#", "---") or set(c[0]) <= set("-"):
500
+ continue
501
+ if not any(c[3:]):
502
+ continue # an empty row has nothing to carry
503
+ if in_orphans:
504
+ orphans_prev.append(l); continue # earlier orphans stay orphans unless they match below
505
+ prev.setdefault((c[1], c[2]), c[3:])
506
+ used, out = set(), []
507
+ for l in lines_out:
508
+ c = _cells(l)
509
+ key = (c[1], c[2]) if c else None
510
+ if c and key in prev and not any(c[3:]):
511
+ out.append("| %s | %s | %s | %s | %s | %s | %s |" % tuple(c[:3] + prev[key]))
512
+ used.add(key); continue
513
+ out.append(l)
514
+ orphans = ["| %s | %s | %s | %s | %s | %s | %s |" % ((("-",) + k + tuple(v))) for k, v in prev.items() if k not in used]
515
+ orphans += orphans_prev
516
+ if used or orphans:
517
+ out.insert(4, "↩️ 이전 결과서에서 판정 %d줄 이어받음 · 못 맞춘 판정 %d줄은 맨 아래 «이전 결과서에서 이어받지 못한 판정»에 보존" % (len(used), len(orphans)))
518
+ if orphans:
519
+ out += ["", CARRY_HEADING, "", "| # | 시각 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안(이번 세션 vs 이월) |",
520
+ "|---|---|---|---|---|---|---|"] + orphans
521
+ return out
522
+
523
+
458
524
  # ---------------------------------------------------------------------------
459
525
  # check
460
526
  # ---------------------------------------------------------------------------
@@ -364,6 +364,50 @@ else
364
364
  echo "⚠️ ①-f utterance_intake.sh 없음 — skipped, not passed (UNMEASURED)"
365
365
  fi
366
366
 
367
+ # ── ①-g REQUEST CHECKLIST RESULT SHEET (advisory) ─────────────────────────────
368
+ # WHY. ①-f asks «did the utterance reach a record»; the operator asked a different question twice:
369
+ # «체크리스트에 받아적고 마무리시점이나 중간에 한번씩 파악해보는거» (2026-10-18) and, on 2026-09-18, a close
370
+ # report «like TCs — done / partly / not done, with reasons and proposals» (fh_signal_2026-09-18_request-
371
+ # checklist-close-report.md). session_checklist.py was built for that and never called from here; ①-f's own
372
+ # history (a checker with zero call sites) repeated. utterance_checklist_hook.sh nudges it mid-session; this
373
+ # line asks for it at the close. Advisory: the table is a surface the operator reads and contests row by row,
374
+ # not a gate (form is checked, truth is not — session_checklist.py header).
375
+ _SC_PY="$FH/scripts/session_checklist.py"
376
+ if [ -f "$_SC_PY" ]; then
377
+ _SC_FILES=()
378
+ # this session's sheet (any date — a session can cross midnight); without a session id, today's sheets
379
+ # (codex R1 B11: a sheet from another session must not satisfy this one's close)
380
+ if [ -n "${_UI_SID:-}" ]; then
381
+ for _p in "$FH"/tracks/_meta/session_checklist_*_"${_UI_SID:0:8}".md; do [ -f "$_p" ] && _SC_FILES+=("$_p"); done
382
+ else
383
+ for _p in "$FH"/tracks/_meta/session_checklist_"$TODAY"_*.md; do [ -f "$_p" ] && _SC_FILES+=("$_p"); done
384
+ [ "${#_SC_FILES[@]}" -gt 0 ] && echo "ℹ️ ①-g 세션 id 미상 — 오늘자 결과서 ${#_SC_FILES[@]} 개를 본다(다른 세션 것일 수 있다: «이 세션 결과서가 있다» 의 증명이 아니다)"
385
+ fi
386
+ if [ "${#_SC_FILES[@]}" -eq 0 ]; then
387
+ echo "⚠️ ①-g 오늘자 요청 체크리스트 결과서가 없다 — advisory, 막지 않는다"
388
+ if [ -n "${_UI_TR:-}" ] && [ -f "${_UI_TR:-/nonexistent}" ]; then
389
+ printf ' 만들기: python3 scripts/session_checklist.py extract --transcript %q --out %q\n' "$_UI_TR" "tracks/_meta/session_checklist_${TODAY}_${_UI_SID:0:8}.md"
390
+ else
391
+ echo " 만들기: python3 scripts/session_checklist.py extract --transcript <이 세션 전사본> --out tracks/_meta/session_checklist_${TODAY}_<세션8>.md"
392
+ fi
393
+ echo " → 상태 칸을 증거·사유와 함께 채우고, 열린 줄을 운영자에게 표로 보여라(영혼 다지기)."
394
+ else
395
+ for _f in "${_SC_FILES[@]}"; do
396
+ _SC_OUT=$(python3 "$_SC_PY" check --file "$_f" 2>&1); _SC_RC=$?
397
+ case "$_SC_RC" in
398
+ 0) echo "✅ ①-g 결과서 형식 OK — ${_f#$FH/} (형식만 본다: 상태가 참인지는 운영자가 본다)" ;;
399
+ 1) echo "⚠️ ①-g 결과서에 빈 칸·사유 없는 미완 줄이 있다 — ${_f#$FH/}"
400
+ printf '%s\n' "$_SC_OUT" | tail -8 | sed 's/^/ /' ;;
401
+ 4) echo "⚠️ ①-g 결과서 표에 행이 0 개다(DEAD CONTROL) — ${_f#$FH/} · «잴 게 없었다» 가 아니라 «안 적었다» 다" ;;
402
+ *) echo "⚠️ ①-g 결과서 검사 UNMEASURED (rc=$_SC_RC) — ${_f#$FH/}"
403
+ printf '%s\n' "$_SC_OUT" | tail -4 | sed 's/^/ /' ;;
404
+ esac
405
+ done
406
+ fi
407
+ else
408
+ echo "⚠️ ①-g session_checklist.py 없음 — skipped, not passed (UNMEASURED)"
409
+ fi
410
+
367
411
  # ② FH assets changed today → harvest-loop owed
368
412
  # NOTE: no `grep -q` here — under `set -o pipefail`, -q's early exit SIGPIPEs git log (141),
369
413
  # masking a real match as pipeline failure so the warning NEVER fired on true positives
@@ -571,6 +571,10 @@ snapshot "$OUTDIR/_machine_before.txt"
571
571
 
572
572
  CONTAMINATED=0
573
573
  for r in $(seq 1 "$REPS"); do
574
+ # A reused --out must not carry the previous run's budget record into a rep that fails before
575
+ # writing its own (clone failure `continue`s first) — a stale `ended_at_cap=no` would be read as
576
+ # this run's. Same for the per-turn table the budget line reads.
577
+ rm -f "$OUTDIR/${ARM}_r${r}.meta.tsv" "$OUTDIR/${ARM}_r${r}.turns.tsv"
574
578
  # Each clone gets its OWN parent directory. Siblings under one parent are visible to `../`,
575
579
  # and that is not hypothetical: an arm measured 2026-08-29 scanned its parent for mappable
576
580
  # projects and reported finding "iso_A, door_CTRL" — the other arms' work dirs. Content stayed
@@ -758,6 +762,33 @@ for r in $(seq 1 "$REPS"); do
758
762
  fi
759
763
  bytes=$(wc -c < "$OUTDIR/${ARM}_r${r}.txt" | tr -d ' ')
760
764
 
765
+ # ── BUDGET LINE (2026-10-17) — which cap this episode ran under, and did it END at that cap. ──
766
+ # Caps are read off the ARGV actually handed to `claude -p` (TOOLS/MCPARGS arrays) and the env it
767
+ # inherited — never retyped. `timeout_s` is the very $TIMEOUT fed to fh_timeout above.
768
+ # ended_at_cap is three-valued, never defaulted to "no":
769
+ # yes rc=124 — fh_timeout's own convention for all three kinds (gnu / gtimeout / bash watchdog)
770
+ # no rc=0 AND no turn/token cap was set (nothing else could have stopped it early)
771
+ # UNKNOWN anything else: rc=0 with a turn/token cap set (a max-turns stop exits 0 and this
772
+ # runner reads no stop reason), or a non-124 failure (crash vs kill is not told apart)
773
+ _cap_arg() { local _f="$1"; shift; while [ $# -gt 0 ]; do [ "$1" = "$_f" ] && { printf '%s' "${2:-unset}"; return; }; shift; done; printf 'unset'; }
774
+ _cap_turns="$(_cap_arg --max-turns "${TOOLS[@]}" ${MCPARGS[@]+"${MCPARGS[@]}"})"
775
+ _cap_tokens="${CLAUDE_CODE_MAX_OUTPUT_TOKENS:-unset}"
776
+ # Multi-turn: the rep returns its FIRST failing rc, so turn 1 rc=7 + turn 2 rc=124 returns 7 and
777
+ # would hide the timeout. Any turn row with rc=124 makes the episode `yes`. timeout_s is per turn.
778
+ _turn_timeout=0
779
+ [ -f "$OUTDIR/${ARM}_r${r}.turns.tsv" ] && \
780
+ awk -F'\t' 'NR>1 && $2==124 {f=1} END {exit !f}' "$OUTDIR/${ARM}_r${r}.turns.tsv" && _turn_timeout=1
781
+ if [ "$rc" -eq 124 ] || [ "$_turn_timeout" -eq 1 ]; then _cap_end=yes
782
+ elif [ "$rc" -eq 0 ] && [ "$_cap_turns" = unset ] && [ "$_cap_tokens" = unset ]; then _cap_end=no
783
+ else _cap_end=UNKNOWN; fi
784
+ {
785
+ printf 'rc\t%s\n' "$rc"
786
+ printf 'timeout_s\t%s\n' "$TIMEOUT"
787
+ printf 'max_turns\t%s\n' "$_cap_turns"
788
+ printf 'token_cap\t%s\n' "$_cap_tokens"
789
+ printf 'ended_at_cap\t%s\n' "$_cap_end"
790
+ } >> "$OUTDIR/${ARM}_r${r}.meta.tsv"
791
+
761
792
  # 🟥 An empty output is NOT a "no" answer. The first version of tonight's runner used
762
793
  # `timeout 300`, which killed exactly the heavy arms — the ones where the behaviour under test
763
794
  # actually fired — and left 0-byte files that read as "the identity did not fire". A false RED
@@ -4,14 +4,18 @@
4
4
  # 왜: Claude Code 는 세션 시작 시 CLAUDE.md 가 150.0k **문자**를 넘으면
5
5
  # `⚠ CLAUDE.md is over the 150.0k-char limit` 경고를 띄운다. 허브 CLAUDE.md 는 tracked·출하 파일이라
6
6
  # README 주 경로(git clone)로 들어온 모든 사용자가 그 경고를 본다(v3.16.0~v3.21.0 실측: 150,733 → 154,149).
7
- # 파일은 주당 ~1k 씩 자라므로, 경고가 뜨기 **전에** 이 레인이 빨개지도록 한계를 145,000 으로 둔다.
7
+ # 파일은 주당 ~1k 씩 자라므로, 경고가 뜨기 **전에** 이 레인이 빨개지도록 한계를 145,000 으로 두었다(과거).
8
+ # 2026-10-17 래칫: v3.27.0 다이어트로 95줄 14,697자가 됐는데 한계가 145,000 이라 10배 재팽창까지 아무것도
9
+ # 안 막았다(운영자 «클로드md 자수는 앞으로도 잘 관리되겠지?»). 한계 = 18,000(지금 +22%). 넘으면 옮기거나,
10
+ # 정말 상주가 필요하면 **이 숫자를 올리는 커밋**으로 늘린다 — 그래야 늘어난 이유가 기록에 남는다.
11
+ # L7(advisory): 이 머신에 CLAUDE.local.md 가 있으면 합계를 같이 찍는다. CC 경고는 지침 파일 «합계» 150k 를 센다.
8
12
  # 무엇을 세나: Python `len()` 을 UTF-8 디코드한 텍스트에 건다 = **문자 수**(바이트 아님). CC 경고가 문자를
9
13
  # 세므로 같은 단위다. `wc -c` 는 바이트라 한글 한 글자를 3 으로 세어 과차단한다(L4 가 그 차이를 박는다).
10
14
  # 처방: 빨개지면 지우지 말고 **옮겨라** — 근거·실측·철회 경위를 detail 파일로 verbatim 이관하고 상주에는
11
15
  # 규칙 + 포인터만 남긴다(선례: tracks/_meta/claude_md_diet_2026-09-26/ 의 diet.py·verify.py).
12
16
  set -uo pipefail
13
17
  HERE="$(cd "$(dirname "$0")" && pwd)"; ROOT="$(cd "$HERE/.." && pwd)"
14
- LIMIT=145000
18
+ LIMIT="${FH_CLAUDE_MD_LIMIT:-18000}" # 포크는 자기 CLAUDE.md 에 맞춰 올려도 된다(이건 FH 허브 상주 래칫이다)
15
19
  PASS=0; FAIL=0
16
20
  ok(){ PASS=$((PASS+1)); printf ' ✅ %s\n' "$1"; }
17
21
  no(){ FAIL=$((FAIL+1)); printf ' ❌ %s — %s\n' "$1" "${2:-}"; }
@@ -45,11 +49,12 @@ printf '# small\n' > "$D/small.md"
45
49
  OUT=$(size_check "$D/small.md" "$LIMIT"); RC=$?
46
50
  [ "$RC" -eq 0 ] && ok "L3 known-negative: 작은 파일 → PASS" || no "L3 known-negative" "rc=$RC out=$OUT"
47
51
 
48
- # L4 unit = characters, not bytes: 100,000 Hangul chars = 300,000 bytes must PASS.
49
- python3 -c 'import sys; open(sys.argv[1],"w",encoding="utf-8").write("가"*100000)' "$D/ko.md"
52
+ # L4 unit = characters, not bytes: LIMIT/2 Hangul chars = 1.5×LIMIT bytes must PASS.
53
+ HALF=$((LIMIT/2))
54
+ python3 -c 'import sys; open(sys.argv[1],"w",encoding="utf-8").write("가"*int(sys.argv[2]))' "$D/ko.md" "$HALF"
50
55
  OUT=$(size_check "$D/ko.md" "$LIMIT"); RC=$?; BYTES=$(wc -c < "$D/ko.md" | tr -d ' ')
51
- [ "$RC" -eq 0 ] && [ "$OUT" = "100000" ] && [ "$BYTES" -gt "$LIMIT" ] \
52
- && ok "L4 단위 = 문자: 한글 100,000자(${BYTES} bytes) → PASS" || no "L4 단위" "rc=$RC chars=$OUT bytes=$BYTES — 바이트를 세고 있다"
56
+ [ "$RC" -eq 0 ] && [ "$OUT" = "$HALF" ] && [ "$BYTES" -gt "$LIMIT" ] \
57
+ && ok "L4 단위 = 문자: 한글 ${HALF}자(${BYTES} bytes) → PASS" || no "L4 단위" "rc=$RC chars=$OUT bytes=$BYTES — 바이트를 세고 있다"
53
58
 
54
59
  # L5 boundary: exactly LIMIT passes, LIMIT+1 fails.
55
60
  python3 -c 'import sys; open(sys.argv[1],"w",encoding="utf-8").write("a"*int(sys.argv[2]))' "$D/eq.md" "$LIMIT"
@@ -66,9 +71,19 @@ if [ ! -f "$ROOT/CLAUDE.md" ]; then
66
71
  no "L1 CLAUDE.md" "파일 부재 — 미측정(통과 아님)"
67
72
  else
68
73
  OUT=$(size_check "$ROOT/CLAUDE.md" "$LIMIT"); RC=$?
69
- if [ "$RC" -eq 0 ]; then ok "L1 CLAUDE.md = ${OUT}자 ≤ ${LIMIT} (CC 경고선 150,000 까지 $((150000-OUT)))"
74
+ if [ "$RC" -eq 0 ]; then ok "L1 CLAUDE.md = ${OUT}자 ≤ ${LIMIT} (한계까지 $((LIMIT-OUT)) · CC 경고선 150,000)"
70
75
  else no "L1 CLAUDE.md" "${OUT}자 > ${LIMIT} — 지우지 말고 detail 파일로 옮겨라(헤더 처방)"; fi
71
76
  fi
72
77
 
78
+ # L7 advisory (never fails): the CC warning counts ALL instruction files (150k total). CLAUDE.local.md is
79
+ # gitignored, so CI never sees it — on a machine that has one, print the pair's total so growth is visible.
80
+ if [ -f "$ROOT/CLAUDE.local.md" ] && [ -f "$ROOT/CLAUDE.md" ]; then
81
+ A=$(size_check "$ROOT/CLAUDE.md" 999999999); B=$(size_check "$ROOT/CLAUDE.local.md" 999999999)
82
+ case "$A$B" in *UNMEASURED*) echo " ℹ️ L7 합계 미측정 ($A / $B)" ;;
83
+ *) echo " ℹ️ L7 CLAUDE.md ${A} + CLAUDE.local.md ${B} = $((A+B))자 (CC 합계 경고 150,000 · 전역 ~/.claude/CLAUDE.md 는 scripts/resident_cost.py 로)" ;; esac
84
+ else
85
+ echo " ℹ️ L7 CLAUDE.local.md 없음 — 합계 미측정(0 아님)"
86
+ fi
87
+
73
88
  echo "PASS=$PASS FAIL=$FAIL"
74
89
  [ "$FAIL" -eq 0 ] || { echo "FAILED=1"; exit 1; }