@chrono-meta/fh-gate 3.39.0 → 3.40.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 (49) hide show
  1. package/.claude/regression/probes_live.yaml +9 -2
  2. package/.claude-plugin/marketplace.json +4 -4
  3. package/CLAUDE.md +2 -2
  4. package/README.ja.md +22 -20
  5. package/README.ko.md +2 -2
  6. package/README.md +2 -2
  7. package/README.zh.md +22 -20
  8. package/knowledge/shared/harness-core/claude_md_full_reference.md +8 -1
  9. package/knowledge/shared/harness-core/dispatch_conditional_prohibition.md +9 -0
  10. package/knowledge/shared/harness-core/fh_module_contract.md +68 -3
  11. package/knowledge/shared/harness-core/governor_landing_before_compact.md +4 -4
  12. package/knowledge/shared/harness-core/lease_record_channel.md +26 -2
  13. package/knowledge/shared/harness-core/onboarding_acceleration_autopilot.md +7 -0
  14. package/knowledge/shared/learnings/subagent_invocations_log.yaml +36 -0
  15. package/knowledge/shared/rules/operations.md +1 -0
  16. package/package.json +10 -1
  17. package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
  18. package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
  19. package/plugins/fh-meta/CHANGELOG.md +45 -0
  20. package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
  21. package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
  22. package/scripts/agent_tools_pin.txt +16 -0
  23. package/scripts/catch_tally.py +215 -0
  24. package/scripts/claim_precision_report.py +138 -0
  25. package/scripts/fh_module_check.py +182 -1
  26. package/scripts/generated_harness_check.py +4 -0
  27. package/scripts/package_coverage_check.sh +5 -0
  28. package/scripts/post_squash_verify.sh +53 -1
  29. package/scripts/pr_merge_verified.sh +56 -0
  30. package/scripts/probe_live_eval.sh +61 -0
  31. package/scripts/probe_live_eval_lib.py +47 -4
  32. package/scripts/selfcheck.sh +5 -0
  33. package/scripts/selfdev_merge_tier.sh +153 -0
  34. package/scripts/session_checklist.py +38 -1
  35. package/scripts/session_close_check.sh +67 -1
  36. package/scripts/sim_isolated_run.sh +62 -1
  37. package/scripts/test_agent_tools_pin_lanes.sh +73 -0
  38. package/scripts/test_catch_tally_lanes.sh +10 -0
  39. package/scripts/test_claim_precision_report_lanes.sh +77 -0
  40. package/scripts/test_fh_module_check_lanes.sh +106 -1
  41. package/scripts/test_generated_harness_check_lanes.sh +8 -0
  42. package/scripts/test_post_squash_verify_lanes.sh +23 -2
  43. package/scripts/test_pr_merge_verified_lanes.sh +55 -3
  44. package/scripts/test_probe_live_eval_lanes.sh +160 -5
  45. package/scripts/test_selfdev_merge_tier_lanes.sh +128 -0
  46. package/scripts/test_session_checklist_lanes.sh +57 -0
  47. package/scripts/test_session_close_chain_lanes.sh +93 -0
  48. package/scripts/test_sim_isolated_run_lanes.sh +67 -0
  49. package/templates/harness_birth_core.md +57 -0
@@ -12,7 +12,7 @@ Exit codes: 0 OK . 1 BLOCK . 2 UNMEASURED (unreadable / tooling down / empty cor
12
12
  3 OK-but-UNCALIBRATED (valid, no verdict entry points, calibration declared UNCALIBRATED; never a clean pass).
13
13
  Fail closed: nothing unreadable, unknown or empty ever exits 0.
14
14
  """
15
- import argparse, glob, hashlib, json, os, re, shutil, subprocess, sys
15
+ import argparse, ast, glob, hashlib, json, os, re, shutil, subprocess, sys, sysconfig
16
16
 
17
17
  OK, BLOCK, UNMEASURED, UNCAL = 0, 1, 2, 3
18
18
 
@@ -384,6 +384,185 @@ def validate(m, vd, repo_core, repo):
384
384
  vd.block("files: %s resolves outside the repo" % f)
385
385
 
386
386
 
387
+ def _is_stdlib(name):
388
+ """True when `name` is a standard-library module of the interpreter running this check (3.9 has no
389
+ sys.stdlib_module_names: fall back to where the module lives)."""
390
+ names = getattr(sys, "stdlib_module_names", None)
391
+ if names is not None:
392
+ return name in names
393
+ if name in sys.builtin_module_names:
394
+ return True
395
+ import importlib.util
396
+ try:
397
+ spec = importlib.util.find_spec(name)
398
+ except (ImportError, ValueError):
399
+ return False
400
+ if spec is None or not spec.origin:
401
+ return False
402
+ if spec.origin in ("built-in", "frozen"):
403
+ return True
404
+ std = os.path.realpath(sysconfig.get_paths()["stdlib"])
405
+ org = os.path.realpath(spec.origin)
406
+ return org.startswith(std + os.sep) and "site-packages" not in org
407
+
408
+
409
+ _CATCH = ("ImportError", "ModuleNotFoundError", "Exception", "BaseException")
410
+
411
+
412
+ def _bound_names(tree):
413
+ """Every name the file binds anywhere (assignment, parameter, `except … as`, def/class, import alias), except a plain
414
+ `import builtins`. Over-approximate on purpose: a rebound name stops counting as a guard -> fail closed."""
415
+ out = set()
416
+ for n in ast.walk(tree):
417
+ if isinstance(n, ast.Name) and isinstance(n.ctx, (ast.Store, ast.Del)):
418
+ out.add(n.id)
419
+ elif isinstance(n, ast.arg):
420
+ out.add(n.arg)
421
+ elif isinstance(n, ast.ExceptHandler) and n.name:
422
+ out.add(n.name)
423
+ elif isinstance(n, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)):
424
+ out.add(n.name)
425
+ elif isinstance(n, (ast.Global, ast.Nonlocal)):
426
+ out.update(n.names)
427
+ elif isinstance(n, (ast.Import, ast.ImportFrom)):
428
+ for a in n.names:
429
+ if isinstance(n, ast.Import) and a.name == "builtins" and not a.asname:
430
+ continue
431
+ out.add((a.asname or a.name).split(".")[0])
432
+ return out
433
+
434
+
435
+ def _bare_import_module(tree):
436
+ """True when the file binds `import_module` from importlib (so a bare `import_module("x")` call is that one)."""
437
+ return any(isinstance(n, ast.ImportFrom) and n.module == "importlib" and n.level == 0
438
+ and any(a.name == "import_module" and not a.asname for a in n.names) for n in ast.walk(tree))
439
+
440
+
441
+ def _dynamic_import(n, bare_ok=False):
442
+ """`importlib.import_module("x")` / `__import__("x")` (and a bare `import_module("x")` when the file imported it
443
+ from importlib), name given positionally or as `name=`, literal -> "x", else None. A computed name is not read
444
+ (named residual, contract 2b)."""
445
+ if not isinstance(n, ast.Call):
446
+ return None
447
+ f = n.func
448
+ if not ((isinstance(f, ast.Name) and (f.id == "__import__" or (bare_ok and f.id == "import_module"))) or
449
+ (isinstance(f, ast.Attribute) and f.attr == "import_module" and isinstance(f.value, ast.Name)
450
+ and f.value.id == "importlib")):
451
+ return None
452
+ arg = n.args[0] if n.args else next((k.value for k in n.keywords if k.arg == "name"), None)
453
+ if isinstance(arg, ast.Constant) and isinstance(arg.value, str):
454
+ return arg.value
455
+ return None
456
+
457
+
458
+ def _guarded_lines(tree):
459
+ """Line numbers of imports that run inside a `try:` body whose handlers catch ImportError / ModuleNotFoundError /
460
+ Exception / BaseException (or everything), by a name the file does not rebind."""
461
+ bound = _bound_names(tree)
462
+ bare = _bare_import_module(tree)
463
+
464
+ def _catches(x):
465
+ if isinstance(x, ast.Name):
466
+ return x.id in _CATCH and x.id not in bound
467
+ return (isinstance(x, ast.Attribute) and isinstance(x.value, ast.Name) and x.value.id == "builtins"
468
+ and "builtins" not in bound and x.attr in _CATCH)
469
+
470
+ def _imports_run_now(st):
471
+ # A def / lambda body inside the try runs later, outside the try: its imports are not guarded by it.
472
+ # (Named residual: default arguments and decorators do run at definition time; skipping them errs toward BLOCK.)
473
+ stack = [st]
474
+ while stack:
475
+ n = stack.pop()
476
+ if isinstance(n, (ast.FunctionDef, ast.AsyncFunctionDef, ast.Lambda)):
477
+ continue
478
+ if isinstance(n, ast.GeneratorExp):
479
+ # A generator runs on next(), outside the try; only its first iterable is evaluated here.
480
+ stack.append(n.generators[0].iter)
481
+ continue
482
+ if isinstance(n, (ast.Import, ast.ImportFrom)) or _dynamic_import(n, bare):
483
+ yield n.lineno
484
+ stack.extend(ast.iter_child_nodes(n))
485
+
486
+ out = set()
487
+ for node in ast.walk(tree):
488
+ if not isinstance(node, ast.Try):
489
+ continue
490
+ catches = False
491
+ for h in node.handlers:
492
+ t = h.type
493
+ names = [t] if t is not None and not isinstance(t, ast.Tuple) else (t.elts if t is not None else [])
494
+ if t is None or any(_catches(x) for x in names):
495
+ catches = True
496
+ if catches:
497
+ for st in node.body:
498
+ out.update(_imports_run_now(st))
499
+ return out
500
+
501
+
502
+ def runtime_deps(m, repo, vd):
503
+ """Spec section 2b: a module's python is stdlib-only, or each non-stdlib import is guarded so its absence can be
504
+ reported as UNMEASURED (exit 2, naming it). Unguarded non-stdlib import -> BLOCK; guarded -> NOTE (the floor run
505
+ environment may not have it). Unparsable python -> UNMEASURED. Only .py files are read (named residual: shell
506
+ scripts calling jq / yq / node are not checked)."""
507
+ paths, _prob = module_paths(m, repo)
508
+ files = []
509
+ for rel in paths:
510
+ full = os.path.join(repo, rel)
511
+ if os.path.isdir(full):
512
+ for dp, dn, fns in os.walk(full):
513
+ dn[:] = sorted(d for d in dn if d not in (".git", "__pycache__"))
514
+ files += [os.path.join(dp, f) for f in sorted(fns) if f.endswith(".py")]
515
+ elif full.endswith(".py") and os.path.isfile(full):
516
+ files.append(full)
517
+ shipped = {os.path.realpath(f) for f in files}
518
+
519
+ def _is_local(mod, importer):
520
+ # Python puts the running script's folder first on sys.path; a module inside a shipped package resolves from an
521
+ # ancestor folder. So a name is local when <dir>/<mod>.py or <dir>/<mod>/__init__.py is shipped in the
522
+ # importer's folder or one of its ancestors -- not anywhere in the module.
523
+ d = os.path.dirname(os.path.realpath(importer))
524
+ while True:
525
+ if os.path.join(d, mod + ".py") in shipped or os.path.join(d, mod, "__init__.py") in shipped:
526
+ return True
527
+ up = os.path.dirname(d)
528
+ if up == d or not up.startswith(os.path.realpath(repo)):
529
+ return False
530
+ d = up
531
+
532
+ import tokenize
533
+ for f in sorted(set(files)):
534
+ rel = os.path.relpath(f, repo)
535
+ try:
536
+ with tokenize.open(f) as fh: # honours a PEP 263 coding cookie, as Python does
537
+ tree = ast.parse(fh.read(), filename=rel)
538
+ except (OSError, UnicodeDecodeError, SyntaxError, ValueError) as e:
539
+ vd.unm("runtime dependencies of %s cannot be read: %s" % (rel, e))
540
+ continue
541
+ guarded = _guarded_lines(tree)
542
+ bare = _bare_import_module(tree)
543
+ seen = set()
544
+ for node in ast.walk(tree):
545
+ if isinstance(node, ast.Import):
546
+ mods = [a.name.split(".")[0] for a in node.names]
547
+ elif isinstance(node, ast.ImportFrom) and node.level == 0 and node.module:
548
+ mods = [node.module.split(".")[0]]
549
+ elif _dynamic_import(node, bare):
550
+ mods = [_dynamic_import(node, bare).split(".")[0]]
551
+ else:
552
+ continue
553
+ for mod in mods:
554
+ if (mod, node.lineno) in seen or not mod or mod == "__future__" or _is_stdlib(mod) or _is_local(mod, f):
555
+ continue
556
+ seen.add((mod, node.lineno))
557
+ if node.lineno in guarded:
558
+ vd.notes.append("runtime dependency %s (%s:%d) is not stdlib; guarded — allowed only when a stdlib route is not feasible (contract 2b); its absence must exit 2 "
559
+ "(UNMEASURED) naming it, and the floor run environment may not have it" % (mod, rel, node.lineno))
560
+ else:
561
+ vd.block("runtime dependency %s (%s:%d) is not stdlib and not guarded — in an environment without it "
562
+ "the module crashes instead of answering UNMEASURED; make it stdlib-only, or guard the import "
563
+ "and exit 2 naming the missing module" % (mod, rel, node.lineno))
564
+
565
+
387
566
  def load_installed(d):
388
567
  mods, errs, dups = {}, [], []
389
568
  if not os.path.isdir(d):
@@ -416,6 +595,8 @@ def cmd_check(a):
416
595
  if cerr:
417
596
  vd.unm(cerr)
418
597
  validate(m, vd, core, repo)
598
+ if isinstance(m, dict):
599
+ runtime_deps(m, repo, vd)
419
600
  if a.installed:
420
601
  inst, errs, dups = load_installed(a.installed)
421
602
  for e in errs: vd.unm("installed registry unreadable: " + e)
@@ -18,6 +18,7 @@
18
18
  # «확인 없이/알아서» 류와 같은(또는 바로 다음) 문장에서 허용.
19
19
  # 경고(rc 무영향): W1 읽기 전용 주장 vs 쓰기·Bash 도구(tools 없음=전부 상속 포함) · W2 tools 줄 없음(전부 상속) · W7 스킬 파일명이 SKILL.md 아님 ·
20
20
  # W4 죽은 참조 · W6 스킬 description 비어 있음.
21
+ # 정보 W8: 스킬 description 에 질문 모양 예시(«…?») 없음 — 질문으로 오는 요청에서 스스로 불리지 않을 수 있다.
21
22
  # 정보: W3 Bash 범위 제한 서술 없음 · W5 Done When 없음(FH 기준, 생성기 결함 아님) ·
22
23
  # 아직 없는 입출력 경로(자리표시자·디렉터리·_workspace·런타임 산출 파일명).
23
24
  #
@@ -589,6 +590,9 @@ def check(target, exclude_skills=()):
589
590
  continue
590
591
  if not fm.get("description", "").strip():
591
592
  rep.add("warn", "W6", path, where.get("description", 1), "(description 비어 있음)", "")
593
+ elif not re.search(r"[??]", fm.get("description", "")):
594
+ rep.add("info", "W8", path, where.get("description", 1), "description 에 질문 모양 예시 없음",
595
+ "활동 이름만 적은 description 은 «머지해도 돼?» · «몇 파일?» 류 질문에서 스스로 불리지 않았다 (A/B C7–C12: 활동 요청 9/9 · 예/아니오 질문 0–1/9)")
592
596
  if not DONE_WHEN_RE.search(text):
593
597
  rep.add("info", "W5", path, 1, "Done When 절 없음", "FH 기준이다 — 생성기의 결함이 아니다")
594
598
 
@@ -61,6 +61,11 @@ ACCEPTED_ABSENT=(
61
61
  # has no such file and no such convention, so shipping it would ship a tool with nothing to act on.
62
62
  "scripts/lease_line_apply.sh"
63
63
  "scripts/test_lease_line_apply_lanes.sh"
64
+ # 2026-11-11 — shared session ledger (root/child sessions of this hub). Pilot for this hub's thin-root operation;
65
+ # whether consumers get it is an operator decision after the pilot, so not shipped yet.
66
+ "scripts/session_ledger_write.sh"
67
+ "scripts/session_ledger_read.py"
68
+ "scripts/test_session_ledger_lanes.sh"
64
69
  # 2026-11-07 — context-continuity read half (AQ-20261107-10/-12). Governor tools for this hub: the hook reads the
65
70
  # hub's lease-file convention (CLAUDE.local.md «utterance» lines) and its snippet is not shipped either, so
66
71
  # shipping the script alone would hand consumers a hook nothing calls. Ship both together, or neither.
@@ -26,7 +26,8 @@
26
26
  # --rerun run with `bash -c` inside a throwaway detached worktree at --merge. Cwd = that worktree.
27
27
  #
28
28
  # EXIT 0 both halves pass · 1 content mismatch or ② failed · 2 usage (incl. missing --rerun)
29
- # 3 trivial ② refused · 4 instrument/harness error (② silent, worktree not creatable, bad sha)
29
+ # 3 trivial or statically quiet ② refused (`grep -q …` alone — add `&& echo …`) · 4 instrument/harness
30
+ # error (② silent at run time, worktree not creatable, bad sha)
30
31
  #
31
32
  # Labels for ①, per path the branch changed (merge-base(tip, merge^) .. tip, machine-listed):
32
33
  # SAME blob on --merge == blob on --tip (incl. both absent = deletion carried)
@@ -83,6 +84,57 @@ if [ "$_noop" -eq 1 ]; then
83
84
  echo "🟥 --rerun '$RERUN' only echoes / no-ops — refused. Printing is not exercising the change." >&2
84
85
  exit 3
85
86
  fi
87
+ # 🟥 2026-11-09 (verify-incomplete root cause, tracks/_meta/verify_incomplete_root_cause_2026-11-09.md):
88
+ # 7 of 7 non-verified merges in the receipts carried a QUIET ② (`grep -q`, `>/dev/null`, a python -c
89
+ # with no print). Content was intact every time; the silence guard below (rc=0 + no output → rc=4)
90
+ # fired AFTER the merge, so each ended verify-incomplete. Refuse before merging instead, when every
91
+ # segment is statically a silent check. The silence guard stays as it is for what this cannot see.
92
+ # Quoted text is blanked before splitting so a `;` inside `python3 -c "…"` does not split it.
93
+ # 🟥 cross-family R1 (codex, 11 findings): over-refusal is the costly direction (a printing command
94
+ # refused before merging). Fixed: quote blanking is one left-to-right pass (a `"` inside '…' no longer
95
+ # pairs with a later quote) · a lone `&` separates · `>&2` anywhere in a segment means output reaches
96
+ # ② (captured 2>&1) · only fd-less/1/& redirects to /dev/null count · grep options stop at `--` ·
97
+ # python -c is quiet only with no print/stdout/write anywhere. Named residual (fail-open → rc=4 after
98
+ # the merge, guard unchanged): a quoted option (`grep '-q'`), a comment containing «print», a quiet
99
+ # check piped into a printer of nothing (`… | cat`), and any wrapper (`bash -c '…'`).
100
+ _quiet_seg() { # $1 = one segment; rc 0 = prints nothing on success
101
+ local s="$1" w1 w
102
+ case "$s" in *'>&2'*) return 1 ;; esac # stdout sent to stderr — ② captures both
103
+ s="${s##*|}" # judge the last element of a pipeline
104
+ printf '%s' "$s" | grep -Eq '(^|[[:space:]])(1|&)?>[[:space:]]*/dev/null' && return 0
105
+ set -f; set -- $s; set +f; w1="${1:-}"
106
+ case "$w1" in
107
+ :|true|/bin/true|/usr/bin/true|exit|return|test|'['|'[[') return 0 ;;
108
+ grep|egrep|fgrep|rg)
109
+ for w in "$@"; do case "$w" in --) break ;; --quiet|--silent) return 0 ;; --*) : ;; -*q*) return 0 ;; esac; done ;;
110
+ git) for w in "$@"; do case "$w" in --) break ;; -q|--quiet|--is-ancestor) return 0 ;; esac; done
111
+ case " $s " in *" cat-file "*" -e "*) return 0 ;; esac ;; # bare -e only for cat-file (git grep -e prints)
112
+ cmp) for w in "$@"; do [ "$w" = -s ] && return 0; done ;;
113
+ python|python3) for w in "$@"; do [ "$w" = -c ] && { case "$RERUN" in *print*|*stdout*|*write*) return 1 ;; esac; return 0; }; done ;;
114
+ esac
115
+ return 1
116
+ }
117
+ _bl=""; _q=""; _esc=0; _i=0
118
+ while [ "$_i" -lt "${#RERUN}" ]; do
119
+ _c="${RERUN:$_i:1}"; _i=$((_i+1))
120
+ if [ "$_q" = "'" ]; then [ "$_c" = "'" ] && { _q=""; _bl="$_bl'"; }; continue; fi
121
+ if [ "$_q" = '"' ]; then
122
+ if [ "$_esc" -eq 1 ]; then _esc=0; elif [ "$_c" = '\' ]; then _esc=1; elif [ "$_c" = '"' ]; then _q=""; _bl="$_bl\""; fi
123
+ continue; fi
124
+ if [ "$_esc" -eq 1 ]; then _esc=0; _bl="$_bl$_c"; continue; fi
125
+ case "$_c" in '\') _esc=1; _bl="$_bl$_c" ;; "'"|'"') _q="$_c"; _bl="$_bl$_c" ;; *) _bl="$_bl$_c" ;; esac
126
+ done
127
+ _quiet=1; _nseg=0
128
+ while IFS= read -r _seg; do
129
+ _t=$(printf '%s' "$_seg" | tr -d '[:space:]'); [ -z "$_t" ] && continue
130
+ _nseg=$((_nseg+1)); _quiet_seg "$_seg" || { _quiet=0; break; }
131
+ done <<< "$(printf '%s' "$_bl" | sed -E -e 's/&&/;/g' -e 's/[|][|]/;/g' -e 's/([^>&<0-9])&([^>&]|$)/\1;\2/g' | tr ';' '\n')"
132
+ if [ "$_quiet" -eq 1 ] && [ "$_nseg" -gt 0 ]; then
133
+ echo "🟥 --rerun '$RERUN' prints nothing when it passes (every segment is a quiet check) — refused before merging." >&2
134
+ echo " A silent ② reads as an instrument failure (rc=4), so the merge would end verify-incomplete." >&2
135
+ echo " Make it say what passed, e.g. <your check> && echo '<what passed>'" >&2
136
+ exit 3
137
+ fi
86
138
 
87
139
  [ "$PRECHECK" -eq 0 ] || { echo "✅ --rerun accepted (precheck)"; exit 0; }
88
140
 
@@ -28,6 +28,8 @@
28
28
  # 2 usage (nothing merged) · 3 trivial --rerun refused (nothing merged)
29
29
  # 4 harness error (see message: before or after the merge)
30
30
  # 6 merge accepted but not completed (queue/lag) — NOT verified, nothing claimed
31
+ # 7 lease merge refused: a --lease other than «operator…» and selfdev_merge_tier.sh did not say AUTO, or the tier
32
+ # could not be read (nothing merged)
31
33
  # 5 merge NOT observed (gh failed and GitHub still reports OPEN/CLOSED after bounded re-reads —
32
34
  # an observation, not proof: stale state can outlast the re-reads)
33
35
  # (gh non-zero but GitHub says MERGED → continue to verify; state unreadable → 4, outcome UNKNOWN)
@@ -104,6 +106,60 @@ if [ -n "$EXPECT_HEAD" ] && [ "$HEAD_OID" != "$EXPECT_HEAD" ]; then
104
106
  echo "🟥 PR #$PR head is $HEAD_OID, not the checked $EXPECT_HEAD — not merging" >&2; exit 2
105
107
  fi
106
108
  echo "── PR #$PR head recorded: $HEAD_OID"
109
+ # 1a. no --lease → say so, before the merge (AQ-20261109-5). The receipt still records NONE and the merge still runs:
110
+ # most merges rest on the operator's per-PR answer, which is fine to leave unnamed. What must not stay silent is a merge
111
+ # that rested on a STANDING approval and recorded none — #1063 was merged on the self-dev lease with lease=NONE and the
112
+ # receipt said nothing. Advisory only; never changes rc.
113
+ if [ "$LEASE" = "NONE" ]; then
114
+ echo "⚠️ no --lease: the receipt will record lease=NONE. If this merge rests on a standing approval (the self-dev" >&2
115
+ echo " lease, a session lease), stop and rerun with --lease '<its label>'; if it rests on the operator's answer for" >&2
116
+ echo " THIS PR, NONE is right. Advisory only; merging continues." >&2
117
+ fi
118
+
119
+ # 1c. a lease only covers what the merge tier allows (AQ-20261109-4). The self-dev lease (CLAUDE.local.md 2026-11-04) is
120
+ # grade (가): reversible changes merge on their own, anything gate-shaped waits for the operator. selfdev_loop.sh asks
121
+ # selfdev_merge_tier.sh before calling here; an interactive session merging «under the lease» did not (#1063: TIER=HOLD,
122
+ # merged as (가)). So every --lease is checked against the tier here, before the merge, EXCEPT a label that starts with
123
+ # «operator» — the operator's answer for THIS PR, which is what a HOLD asks for. Default-on, not a list of standing-lease
124
+ # spellings (codex R1: «STANDING», «self-dev», «session lease» each slipped a substring list).
125
+ # The tier reads the RECORDED head through local git (merge-base with origin/main .. $HEAD_OID), not the live PR, so what
126
+ # it judged is what --match-head-commit merges (codex R1: a head swapped during the check). Unreadable → refuse (rc 7).
127
+ # only the literal default skips («--lease none» is a label someone typed — codex R2); «operator…» in any case
128
+ _lease_lc=$(printf '%s' "$LEASE" | tr '[:upper:]' '[:lower:]')
129
+ [ "$LEASE" = "NONE" ] && _lease_lc="__default_none__"
130
+ case "$_lease_lc" in
131
+ __default_none__|operator*) ;;
132
+ *)
133
+ _tier="$(dirname "$PSV")/selfdev_merge_tier.sh"
134
+ _tw=$(mktemp -d "${TMPDIR:-/tmp}/pmv-tier-XXXXXX") || _tw=""
135
+ _tok=0
136
+ # the diff must not depend on the caller's git config (codex R2: diff.ignoreSubmodules · diff.relative hid changes;
137
+ # noprefix / color would break the tier's parser), and the base is the live main, fetched now
138
+ _gd() { git -c core.quotepath=off -c diff.noprefix=false -c diff.mnemonicPrefix=false -c diff.relative=false \
139
+ -c diff.ignoreSubmodules=none diff --no-color --no-ext-diff --no-textconv --no-renames --ignore-submodules=none "$@"; }
140
+ if [ -f "$_tier" ] && [ -n "$_tw" ] && git fetch -q origin main < /dev/null 2>/dev/null \
141
+ && _mb=$(git merge-base origin/main "$HEAD_OID" < /dev/null 2>/dev/null) && [ -n "$_mb" ] \
142
+ && _gd --name-status "$_mb" "$HEAD_OID" < /dev/null > "$_tw/ns" 2>/dev/null \
143
+ && _gd --numstat "$_mb" "$HEAD_OID" < /dev/null > "$_tw/num" 2>/dev/null \
144
+ && _gd "$_mb" "$HEAD_OID" < /dev/null > "$_tw/diff" 2>/dev/null \
145
+ && awk -F'\t' 'NR==FNR { st[$2]=$1; next } { print st[$3] "\t" $3 "\t" $1 "\t" $2 }' "$_tw/ns" "$_tw/num" > "$_tw/files" 2>/dev/null; then
146
+ _tok=1
147
+ fi
148
+ if [ "$_tok" -ne 1 ]; then
149
+ [ -n "$_tw" ] && rm -rf "$_tw"
150
+ echo "🟥 lease «$LEASE»: the merge tier could not be read for head $HEAD_OID (tier script, merge-base or diff) — not merging" >&2
151
+ exit 7
152
+ fi
153
+ _tout=$(bash "$_tier" --files "$_tw/files" --diff "$_tw/diff" < /dev/null 2>&1); _trc=$?
154
+ rm -rf "$_tw"
155
+ if [ "$_trc" -ne 0 ] || [ "$(printf '%s\n' "$_tout" | tail -1)" != "TIER=AUTO" ]; then
156
+ printf '%s\n' "$_tout" | sed 's/^/ /' >&2
157
+ echo "🟥 lease «$LEASE» is not the operator's answer for this PR, and selfdev_merge_tier.sh did not say AUTO (rc=$_trc) — not merging." >&2
158
+ echo " Ask the operator for THIS PR, then merge with --lease 'operator: «<their words>» <date>'." >&2
159
+ exit 7
160
+ fi
161
+ echo "── lease «$LEASE»: selfdev_merge_tier.sh says TIER=AUTO for head $HEAD_OID" ;;
162
+ esac
107
163
 
108
164
  # 1b. coverage advisory — WARNING ONLY (never changes rc, never merges or refuses). post_squash_verify's precheck rejects a
109
165
  # command that is trivially empty; it cannot see a command that is real but never touches this PR's files. Static, pre-merge,
@@ -375,6 +375,67 @@ python3 "$LIB" score ${SCORE_EXTRA[@]+"${SCORE_EXTRA[@]}"} \
375
375
  --reps "$REPS"
376
376
  score_rc=$?
377
377
 
378
+ # State fingerprint (2026-11-11, arXiv:2611.11216 — record only, never read by the scorer above).
379
+ # Two arms can print the same output while leaving their isolated clones in different states. The
380
+ # runner already writes `<arm>_r<n>.treediff.txt` (porcelain lines the arm added); this appends, in
381
+ # the same execution as the verdict, one line per rep: changed-path count + a hash over the treediff
382
+ # and the current bytes of every path it lists. A rep with no treediff file says MISSING — not 0.
383
+ # Appended AFTER score so no verdict row can move; score_rc is untouched.
384
+ {
385
+ echo ""
386
+ echo "## State fingerprint (record only — not scored)"
387
+ echo ""
388
+ while IFS= read -r id; do
389
+ [ -z "$id" ] && continue
390
+ for arm in primary control control_b; do
391
+ [ "$arm" = control_b ] && [ ! -f "$SPEC_DIR/$id.control_b.txt" ] && continue
392
+ r=1
393
+ while [ "$r" -le "$REPS" ]; do
394
+ td="$OUTDIR/$id/${arm}_r${r}.treediff.txt"
395
+ if [ ! -f "$td" ]; then
396
+ echo "state-fingerprint: $id $arm r$r treediff=MISSING"
397
+ elif [ ! -r "$td" ]; then
398
+ echo "state-fingerprint: $id $arm r$r treediff=UNREADABLE"
399
+ else
400
+ n=$(grep -c . "$td" 2>/dev/null); n=${n:-0}
401
+ # A listed path we cannot read as bytes is counted as unhashed and the line says how many,
402
+ # so «same hash» never silently covers it: git-quoted paths (spaces, non-ASCII — not decoded
403
+ # here), rename records («a -> b»), unreadable files, directories holding unreadable files.
404
+ # Directories (?? dir/) are otherwise hashed over their files in sorted order.
405
+ uh=0; body="$(mktemp "${TMPDIR:-/tmp}/fh-sfp.XXXXXX")"; cat "$td" > "$body"
406
+ while IFS= read -r p; do
407
+ f="$OUTDIR/$id/w_${arm}_r${r}/repo/$p"
408
+ case "$p" in
409
+ (\"*|*" -> "*) uh=$((uh + 1)); echo "<unhashed:$p>" >> "$body" ;;
410
+ (*)
411
+ if [ -d "$f" ]; then
412
+ # find output and rc captured apart: a failing find counts the path as unhashed,
413
+ # never as «no unreadable files» (pipefail class-lock lane L12c).
414
+ _bad="$(find "$f" -type f ! -perm -u=r 2>/dev/null)"; _brc=$?
415
+ _all="$(find "$f" -type f 2>/dev/null)"; _arc=$?
416
+ if [ "$_brc" -ne 0 ] || [ "$_arc" -ne 0 ] || [ -n "$_bad" ]; then uh=$((uh + 1)); echo "<unhashed:$p>" >> "$body"
417
+ else
418
+ _sorted="$(printf '%s\n' "$_all" | LC_ALL=C sort)"
419
+ while IFS= read -r g; do
420
+ [ -n "$g" ] || continue
421
+ echo "<f:${g#"$f"}>" >> "$body"
422
+ cat "$g" >> "$body" || { uh=$((uh + 1)); echo "<unhashed:$g>" >> "$body"; }
423
+ done <<< "$_sorted"
424
+ fi
425
+ elif [ -e "$f" ] && [ ! -r "$f" ]; then uh=$((uh + 1)); echo "<unhashed:$p>" >> "$body"
426
+ elif [ -f "$f" ]; then cat "$f" >> "$body"
427
+ else echo "<absent:$p>" >> "$body"; fi ;;
428
+ esac
429
+ done < <(cut -c4- "$td")
430
+ h=$(shasum -a 256 < "$body" | cut -c1-16); rm -f "$body"
431
+ echo "state-fingerprint: $id $arm r$r changed=$n unhashed=$uh sha256=$h"
432
+ fi
433
+ r=$((r + 1))
434
+ done
435
+ done
436
+ done < "$SPEC_DIR/selected_ids.txt"
437
+ } >> "$REPORT_PATH"
438
+
378
439
  if [ -n "$EVIDENCE_DIR" ]; then
379
440
  # The report is part of the evidence: a preserved body set with no verdict beside it forces the
380
441
  # next reader to re-derive what the run concluded.
@@ -344,6 +344,13 @@ def _failure_reason(base, arm):
344
344
  (sim_isolated_run.sh prints "(rc=<n>, ...)" there) and bytes from the actual output file's
345
345
  size (0 for a file that was never written). Purely a diagnostic label for the report/console —
346
346
  never used by score_probe, which stays unchanged."""
347
+ rc = _runner_rc(base, arm, 1)
348
+ said = _read_first_line(os.path.join(base, '%s_r1.txt' % arm)) if rc is not None else None
349
+ if said:
350
+ # The arm wrote text but the runner says it did not finish (a usage-limit reply) — show
351
+ # the rc AND what it said, since the text is exactly what the old scorer mistook for an answer.
352
+ # Empty text falls through to stderr, which then holds the real error.
353
+ return 'rc=%s (runner): %s' % (rc, said)
347
354
  stderr_line = _read_first_line(os.path.join(base, '%s_r1.stderr.txt' % arm))
348
355
  if stderr_line:
349
356
  return stderr_line
@@ -402,6 +409,25 @@ def _read_meta_tsv(path):
402
409
  return out
403
410
 
404
411
 
412
+ def _runner_rc(base, arm, i):
413
+ """The runner's recorded exit code for <arm>_r<i> when it is NONZERO, else None. A nonzero rc
414
+ means the rep did not finish (measured 2026-11-10/11: every usage-limit reply — 156 files across
415
+ a model-arms run and nightly 2026-10-27 — carried rc=1, every normal reply rc=0). The reply text
416
+ is never inspected: a normal answer that quotes limit wording must still be scored. No meta.tsv
417
+ (older runs) or no rc key -> None, i.e. scored exactly as before."""
418
+ m = _read_meta_tsv(os.path.join(base, '%s_r%d.meta.tsv' % (arm, i)))
419
+ rc = (m or {}).get('rc', '')
420
+ return rc if rc not in ('', '0') else None
421
+
422
+
423
+ def _rep_text(base, arm, i):
424
+ """Text of <arm>_r<i>, or None when the runner recorded a nonzero rc for it — so score_probe
425
+ returns FAILED-TO-RUN for a reply that exists but came from a run that did not finish."""
426
+ if _runner_rc(base, arm, i) is not None:
427
+ return None
428
+ return _read_text(os.path.join(base, '%s_r%d.txt' % (arm, i)))
429
+
430
+
405
431
  def budget_line(base, arms_reps):
406
432
  """BUDGET LINE (2026-10-17): the cap each verdict row ran under and whether any episode ENDED
407
433
  AT it. Read from the runner's per-episode meta.tsv (written from the real invocation) — never
@@ -409,7 +435,7 @@ def budget_line(base, arms_reps):
409
435
  its cap; otherwise UNKNOWN when any episode's value is UNKNOWN or its meta/field is missing
410
436
  (an older run, or a stub that wrote none — not measured is not `no`); otherwise no.
411
437
  Returns (ended_at_cap, text, n_yes, n_eps)."""
412
- ends, caps = [], set()
438
+ ends, caps, walls, wall_missing = [], set(), [], 0
413
439
  for arm, i in arms_reps:
414
440
  m = _read_meta_tsv(os.path.join(base, '%s_r%d.meta.tsv' % (arm, i)))
415
441
  if m is None:
@@ -418,8 +444,14 @@ def budget_line(base, arms_reps):
418
444
  # let 2 `no` + 1 missing read as `no`).
419
445
  if os.path.exists(os.path.join(base, '%s_r%d.txt' % (arm, i))):
420
446
  ends.append('UNKNOWN')
447
+ wall_missing += 1
421
448
  continue
422
449
  ends.append(m.get('ended_at_cap', 'UNKNOWN') or 'UNKNOWN')
450
+ w = m.get('wall_s', '') or ''
451
+ if re.fullmatch(r'[0-9]{1,9}', w): # ASCII digits only — '²'.isdigit() is True (codex R1)
452
+ walls.append(int(w))
453
+ else:
454
+ wall_missing += 1
423
455
  caps.add('timeout=%ss max_turns=%s tokens=%s' % (
424
456
  m.get('timeout_s', '?'), m.get('max_turns', '?'), m.get('token_cap', '?')))
425
457
  if not caps:
@@ -433,6 +465,17 @@ def budget_line(base, arms_reps):
433
465
  end = 'no'
434
466
  text = '%s ended_at_cap=%s%s' % ('; '.join(sorted(caps)), end,
435
467
  ' (%d/%d episodes)' % (n_yes, len(ends)) if n_yes else '')
468
+ # COST AXIS (2026-11-12, arXiv:2611.13541 / 2611.12122): a separate record next to the 1-bit
469
+ # verdict, never folded into it. Wall seconds only; tokens are not captured by the single-shot
470
+ # runner (plain-text output) and are printed as UNMEASURED, not 0.
471
+ if walls:
472
+ text += ' wall_s=%d..%d' % (min(walls), max(walls))
473
+ if wall_missing:
474
+ text += ' (%d/%d episodes unmeasured)' % (wall_missing, len(walls) + wall_missing)
475
+ else:
476
+ text += ' wall_s=UNMEASURED'
477
+ text += ' tokens_used=UNMEASURED'
478
+
436
479
  return end, text, n_yes, len(ends)
437
480
 
438
481
 
@@ -475,15 +518,15 @@ def score_run(live_rows, run_root, ids_in_order, threshold, model, reps=1):
475
518
  ctrl_b_absent = False # rep-1 only, diagnostic: which arm actually produced nothing
476
519
  per_rep = [] # [(verdict, phit, chit, primary_text, control_text)]
477
520
  for i in range(1, reps + 1):
478
- pt = _read_text(os.path.join(base, 'primary_r%d.txt' % i))
479
- ct = _read_text(os.path.join(base, 'control_r%d.txt' % i))
521
+ pt = _rep_text(base, 'primary', i)
522
+ ct = _rep_text(base, 'control', i)
480
523
  ct_first_arm_ran = bool(ct)
481
524
  if has_ctrl_b:
482
525
  # A declared second control that produced nothing did NOT run — and a probe whose
483
526
  # calibration arm did not run has not been calibrated. Collapsing that into "the
484
527
  # control stayed silent, so the pattern discriminates" is the not-found-is-not-zero
485
528
  # defect pointed at the calibration channel instead of the measurement channel.
486
- ctb = _read_text(os.path.join(base, 'control_b_r%d.txt' % i))
529
+ ctb = _rep_text(base, 'control_b', i)
487
530
  if not ctb:
488
531
  ct = None
489
532
  if i == 1 and ct_first_arm_ran:
@@ -1184,6 +1184,8 @@ for _pair in \
1184
1184
  "scripts/ablation_nominate.py|scripts/test_ablation_nominate_lanes.sh" \
1185
1185
  `# 리스 기록 채널(2026-11-07). 세션은 초안, 기록은 운영자 — 에이전트 셸 거부 · 코드 불일치 무기록 · 원자적 교체.` \
1186
1186
  "scripts/lease_line_apply.sh|scripts/test_lease_line_apply_lanes.sh" \
1187
+ `# 공유 세션 장부(2026-11-11 시범). 실무 세션이 쓰고 루트가 읽는다 — 안 적은 세션은 NOT-WRITTEN, 깨진 줄은 MALFORMED.` \
1188
+ "scripts/session_ledger_read.py|scripts/test_session_ledger_lanes.sh" \
1187
1189
  `# 맥락 유지 읽는 절반(2026-11-07). 상태 주장 뒤 리스 줄 한 줄 · 착지 판정 — 못 읽음은 OK 가 아니다.` \
1188
1190
  "scripts/state_claim_recheck_hook.sh|scripts/test_state_claim_recheck_lanes.sh" \
1189
1191
  "scripts/governor_landing_check.py|scripts/test_governor_landing_check_lanes.sh" \
@@ -1236,6 +1238,7 @@ for _pair in \
1236
1238
  `# ── mutation_probe (2026-10-07) — revert_probe 의 «저자가 고른 변이 1개» 를 연산자 생성 변이로 넓힌 것. 앵커가 고정하는 것은 생성기 보정(리다이렉트 비변이)과 «못 잰 것은 2» 다 ──` \
1237
1239
  "scripts/mutation_probe.py|scripts/test_mutation_probe_lanes.sh" \
1238
1240
  "scripts/cartridge_admit.py|scripts/test_cartridge_admit_lanes.sh" \
1241
+ "scripts/agent_tools_pin.txt|scripts/test_agent_tools_pin_lanes.sh" \
1239
1242
  `# ── live-eval — the live twin of the static /prompt-regression probe check (2026-09-04) ──` \
1240
1243
  "scripts/probe_live_eval.sh|scripts/test_probe_live_eval_lanes.sh" \
1241
1244
  "scripts/probe_live_eval_lib.py|scripts/test_probe_live_eval_lanes.sh" \
@@ -1251,6 +1254,7 @@ for _pair in \
1251
1254
  # 운영자 지적: «내 발화가 도중에 열화되었다 … 테스트 한 차례 끝날 때마다 들여다봐야 할 것 같다».
1252
1255
  # SUBJECT 를 session_checklist.py 로 잡는다 — 이 레인이 재는 것은 그 도구의 판정이다.` \
1253
1256
  "scripts/session_checklist.py|scripts/test_checklist_unblocked_lanes.sh" \
1257
+ "scripts/claim_precision_report.py|scripts/test_claim_precision_report_lanes.sh" \
1254
1258
  "templates/.git-hooks/pre-commit|scripts/test_hook_leg_wiring_lanes.sh" \
1255
1259
  ".claude/soul_tenets.txt|scripts/test_marker_soul_tenet_lanes.sh" \
1256
1260
  "docs/map/fh_assets.architecture.json|scripts/test_fh_map_paths_lanes.sh" \
@@ -1282,6 +1286,7 @@ for _pair in \
1282
1286
  "scripts/proposal_hook.sh|scripts/test_proposal_hook_lanes.sh" \
1283
1287
  "plugins/fh-commons/skills/ko-tech-writer/SKILL.md|scripts/test_ko_tech_writer_lanes.sh" \
1284
1288
  "scripts/absorption_queue.py|scripts/test_absorption_queue_lanes.sh" \
1289
+ "scripts/catch_tally.py|scripts/test_catch_tally_lanes.sh" \
1285
1290
  "scripts/digest_slow_leg.py|scripts/test_digest_slow_leg_lanes.sh" \
1286
1291
  "scripts/script_caller_ratchet.sh|scripts/test_script_caller_ratchet_lanes.sh" \
1287
1292
  "scripts/script_caller_ratchet.sh|scripts/test_runner_surface_index_lanes.sh" \