@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
@@ -6,7 +6,9 @@
6
6
  # Revert probe: FH_MODULE_PROBE=<name> neuters one check in a TEMP COPY of the checker (never the real
7
7
  # one) and the matching lane must go red:
8
8
  # hook-action | enum | route | strictest | dependants | unreadable | gating | corepat | irrverb |
9
- # case | shape | filescan | events | uncalmerge | uncal | dupkey | mergefloor | mergevalid | emptyinst
9
+ # case | shape | filescan | events | uncalmerge | uncal | dupkey | mergefloor | mergevalid | emptyinst |
10
+ # rtguard | rtscan | rtpkg | rtdyn | rtnear | rtdef | rtshadow | rtattr | rtenc | rtwalk |
11
+ # rtkw | rtbuiltins | rtarg | rtmeth | rtgen
10
12
  set -u
11
13
  HERE="$(cd "$(dirname "$0")" && pwd)"
12
14
  REPO="$(dirname "$HERE")"
@@ -31,6 +33,21 @@ if [ -n "${FH_MODULE_PROBE:-}" ]; then
31
33
  mergefloor) needle='merged = {ax: AXES[ax].index(v) for ax, v in CORE_FLOOR.items()}'; repl='merged = {}' ;;
32
34
  mergevalid) needle=' for x in sub.blocks: vd.block("%s: %s" % (p, x))'; repl=' pass' ;;
33
35
  emptyinst) needle=' if not files:'; repl=' if False:' ;;
36
+ rtguard) needle=' if node.lineno in guarded:'; repl=' if True:' ;;
37
+ rtscan) needle=' runtime_deps(m, repo, vd)'; repl=' pass' ;;
38
+ rtpkg) needle='or os.path.join(d, mod, "__init__.py") in shipped:'; repl=':' ;;
39
+ rtdyn) needle=' elif _dynamic_import(node, bare):'; repl=' elif False:' ;;
40
+ rtnear) needle='or _is_stdlib(mod) or _is_local(mod, f):'; repl='or _is_stdlib(mod) or mod in {os.path.splitext(os.path.basename(x))[0] for x in shipped}:' ;;
41
+ rtdef) needle=' if isinstance(n, (ast.FunctionDef, ast.AsyncFunctionDef, ast.Lambda)):'; repl=' if False:' ;;
42
+ rtshadow) needle=' return x.id in _CATCH and x.id not in bound'; repl=' return x.id in _CATCH' ;;
43
+ rtattr) needle=' return (isinstance(x, ast.Attribute)'; repl=' return False and (isinstance(x, ast.Attribute)' ;;
44
+ rtkw) needle='next((k.value for k in n.keywords if k.arg == "name"), None)'; repl='None' ;;
45
+ rtbuiltins) needle='and "builtins" not in bound and x.attr in _CATCH'; repl='and x.attr in _CATCH' ;;
46
+ rtarg) needle=' out.add(n.arg)'; repl=' pass' ;;
47
+ rtmeth) needle=' and f.value.id == "importlib")):'; repl=' or True)):' ;;
48
+ rtgen) needle=' if isinstance(n, ast.GeneratorExp):'; repl=' if False:' ;;
49
+ rtwalk) needle=' files += [os.path.join(dp, f) for f in sorted(fns) if f.endswith(".py")]'; repl=' pass' ;;
50
+ rtenc) needle=' with tokenize.open(f) as fh:'; repl=' with open(f, encoding="utf-8") as fh:' ;;
34
51
  hook-action) needle='elif act not in HOOK_ACTIONS:'; repl='elif False:' ;;
35
52
  enum) needle='if h.get("event") not in HOOK_EVENTS:'; repl='if False:' ;;
36
53
  route) needle='if route not in gates:'; repl='if False:' ;;
@@ -577,5 +594,93 @@ run "EX12 calibration rc 2 is UNMEASURED, not BLOCK (2)" 2 c expo
577
594
  if [ ! -e "$W/out8" ] && [ ! -e "$W/out12" ] && [ ! -e "$R/inside" ] && ! ls -d "$W"/.fh-export-* >/dev/null 2>&1; then PASS=$((PASS+1)); echo "PASS EX13 refused or failed exports leave no folder and no staging"
578
595
  else FAIL=$((FAIL+1)); echo "FAIL EX13 leftovers after a refused export"; fi
579
596
 
597
+ # RD — runtime dependencies (spec 2b; A/B C10 2026-11-08: a guarded PyYAML import lost 9/9 runs in an env without it)
598
+ printf 'import yaml\nprint(yaml)\n' > "$R/mod/dep_bad.py"
599
+ printf 'import json\ntry:\n import yaml\nexcept ImportError:\n yaml = None\n' > "$R/mod/dep_guard.py"
600
+ printf 'import json, os, re\nfrom collections import OrderedDict\n' > "$R/mod/dep_std.py"
601
+ printf 'def f():\n import requests\n return requests\n' > "$R/mod/dep_lazy.py"
602
+ printf 'import dep_std\n' > "$R/mod/dep_local.py"
603
+ printf 'def broken(:\n' > "$R/mod/dep_syntax.py"
604
+ for n in bad guard std lazy local syntax; do
605
+ extra=""; [ "$n" = local ] && extra=", mod/dep_std.py"
606
+ mk "rd_$n" <<YAML
607
+ id: rd-$n
608
+ version: 1.0.0
609
+ touches_irreversible: none
610
+ files: [mod/dep_$n.py$extra]
611
+ $TAIL
612
+ YAML
613
+ done
614
+ run "RD1 unguarded non-stdlib import blocks (1)" 1 c check "$W/rd_bad/fh-module.yaml"
615
+ run "RD2 guarded non-stdlib import passes with a NOTE (0)" 0 c check "$W/rd_guard/fh-module.yaml"
616
+ out="$(c check "$W/rd_guard/fh-module.yaml" 2>&1)"
617
+ if printf '%s\n' "$out" | grep -q '^NOTE: runtime dependency yaml (mod/dep_guard.py:3)'; then PASS=$((PASS+1)); echo "PASS RD2b the NOTE names the module and the line"
618
+ else FAIL=$((FAIL+1)); echo "FAIL RD2b no NOTE naming yaml"; echo "$out" | sed 's/^/ /'; fi
619
+ run "RD3 stdlib-only passes (0)" 0 c check "$W/rd_std/fh-module.yaml"
620
+ run "RD4 unguarded lazy import inside a function blocks (1)" 1 c check "$W/rd_lazy/fh-module.yaml"
621
+ run "RD5 a sibling module the module ships is not a dependency (0)" 0 c check "$W/rd_local/fh-module.yaml"
622
+ run "RD6 unparsable python is UNMEASURED, not OK (2)" 2 c check "$W/rd_syntax/fh-module.yaml"
623
+ mkdir -p "$R/mod/dep_pkg/helpers"; : > "$R/mod/dep_pkg/helpers/__init__.py"; printf 'import helpers\n' > "$R/mod/dep_pkg/main.py"
624
+ mk rd_pkg <<YAML
625
+ id: rd-pkg
626
+ version: 1.0.0
627
+ touches_irreversible: none
628
+ files: [mod/dep_pkg]
629
+ $TAIL
630
+ YAML
631
+ run "RD7 a package folder the module ships is not a dependency (0)" 0 c check "$W/rd_pkg/fh-module.yaml"
632
+ # RD8–RD13 — codex R1 on the first draft (2026-11-09), one lane per verified finding
633
+ mkdir -p "$R/mod/dep_far/elsewhere"
634
+ printf 'import importlib\nimportlib.import_module("fh_missing_dep")\n' > "$R/mod/dep_dyn.py"
635
+ printf 'import fh_missing_dep\n' > "$R/mod/dep_far/main.py"; : > "$R/mod/dep_far/elsewhere/fh_missing_dep.py"
636
+ printf 'try:\n def f():\n import fh_missing_dep\nexcept ImportError:\n pass\nf()\n' > "$R/mod/dep_def.py"
637
+ printf 'ImportError = ValueError\ntry:\n import fh_missing_dep\nexcept ImportError:\n pass\n' > "$R/mod/dep_shadow.py"
638
+ printf 'import builtins\ntry:\n import fh_missing_dep\nexcept builtins.ImportError:\n fh_missing_dep = None\n' > "$R/mod/dep_attr.py"
639
+ printf '# coding: latin-1\nlabel = "caf\351"\nimport json\n' > "$R/mod/dep_enc.py"
640
+ for n in dyn far def shadow attr enc; do
641
+ tgt="mod/dep_$n.py"; [ "$n" = far ] && tgt="mod/dep_far"
642
+ mk "rd_$n" <<YAML
643
+ id: rd-$n
644
+ version: 1.0.0
645
+ touches_irreversible: none
646
+ files: [$tgt]
647
+ $TAIL
648
+ YAML
649
+ done
650
+ run "RD8 a literal importlib/__import__ of a non-stdlib module blocks (1)" 1 c check "$W/rd_dyn/fh-module.yaml"
651
+ run "RD9 a same-named file in an unrelated folder does not satisfy it (1)" 1 c check "$W/rd_far/fh-module.yaml"
652
+ run "RD10 a try around a def does not guard the import inside it (1)" 1 c check "$W/rd_def/fh-module.yaml"
653
+ run "RD11 a rebound ImportError does not count as a guard (1)" 1 c check "$W/rd_shadow/fh-module.yaml"
654
+ run "RD12 except builtins.ImportError is a guard (0, NOTE)" 0 c check "$W/rd_attr/fh-module.yaml"
655
+ run "RD13 a latin-1 coding cookie is read, not UNMEASURED (0)" 0 c check "$W/rd_enc/fh-module.yaml"
656
+ # RD14–RD17 — codex R2 (2026-11-09): new gaps in the R1 fixes
657
+ printf 'import importlib\nimportlib.import_module(name="fh_missing_dep")\n' > "$R/mod/dep_kw.py"
658
+ printf 'import types\nbuiltins = types.SimpleNamespace(ImportError=ValueError)\ntry:\n import fh_missing_dep\nexcept builtins.ImportError:\n pass\n' > "$R/mod/dep_builtins.py"
659
+ printf 'def f(ImportError=ValueError):\n try:\n import fh_missing_dep\n except ImportError:\n pass\nf()\n' > "$R/mod/dep_arg.py"
660
+ printf 'class Loader:\n def import_module(self, name):\n return name\nLoader().import_module("label")\n' > "$R/mod/dep_meth.py"
661
+ for n in kw builtins arg meth; do
662
+ mk "rd_$n" <<YAML
663
+ id: rd-$n
664
+ version: 1.0.0
665
+ touches_irreversible: none
666
+ files: [mod/dep_$n.py]
667
+ $TAIL
668
+ YAML
669
+ done
670
+ run "RD14 import_module(name=\"…\") with a literal blocks (1)" 1 c check "$W/rd_kw/fh-module.yaml"
671
+ run "RD15 a rebound builtins receiver does not count as a guard (1)" 1 c check "$W/rd_builtins/fh-module.yaml"
672
+ run "RD16 a parameter named ImportError does not count as a guard (1)" 1 c check "$W/rd_arg/fh-module.yaml"
673
+ run "RD17 a method named import_module is not a dependency (0)" 0 c check "$W/rd_meth/fh-module.yaml"
674
+ # RD18 — codex R3: a generator inside the try runs on next(), outside it
675
+ printf 'import importlib\nrows = [[1]]\ntry:\n arrays = (importlib.import_module("fh_missing_dep").array(r) for r in rows)\nexcept ImportError:\n arrays = iter(rows)\nnext(arrays)\n' > "$R/mod/dep_gen.py"
676
+ mk rd_gen <<YAML
677
+ id: rd-gen
678
+ version: 1.0.0
679
+ touches_irreversible: none
680
+ files: [mod/dep_gen.py]
681
+ $TAIL
682
+ YAML
683
+ run "RD18 an import inside a generator in a try is not guarded by it (1)" 1 c check "$W/rd_gen/fh-module.yaml"
684
+
580
685
  echo "lanes: pass=$PASS fail=$FAIL"
581
686
  [ "$FAIL" = 0 ]
@@ -321,5 +321,13 @@ OUT=$("$PY" "$CHK" "$D/lnk" --json 2>&1); RC=$?
321
321
  N=$(printf '%s' "$OUT" | "$PY" -c 'import json,sys; print(sum(1 for x in json.load(sys.stdin)["human_review"] if x["id"]=="H2"))' 2>/dev/null)
322
322
  [ "$RC" -eq 1 ] && [ "$N" = "1" ] && ok "L14 링크된 .claude/CLAUDE.md 는 두 번 세지 않는다 (H2=1, rc=1)" || no "L14 링크 중복" "rc=$RC H2=$N"
323
323
 
324
+ # L15 — W8 (정보): description 에 질문 모양이 없으면 표시, 있으면 표시 없음. rc 는 둘 다 0 (정보는 판정에 영향 없음)
325
+ mkdir -p "$D/w8a/.claude/skills/a" "$D/w8b/.claude/skills/b"
326
+ printf -- '---\nname: a\ndescription: Use when reviewing a SQL migration\n---\n## Done When\n- x\n' > "$D/w8a/.claude/skills/a/SKILL.md"
327
+ printf -- '---\nname: b\ndescription: Use when reviewing a SQL migration, or asked «will this migration wipe data?»\n---\n## Done When\n- x\n' > "$D/w8b/.claude/skills/b/SKILL.md"
328
+ OUTA=$("$PY" "$CHK" "$D/w8a" 2>&1); RCA=$?; OUTB=$("$PY" "$CHK" "$D/w8b" 2>&1); RCB=$?
329
+ [ "$RCA" -eq 0 ] && [ "$RCB" -eq 0 ] && printf '%s' "$OUTA" | /usr/bin/grep -qE '^ W8 ' && ! printf '%s' "$OUTB" | /usr/bin/grep -qE '^ W8 ' \
330
+ && ok "L15 W8: 질문 모양 없는 description 표시 · 있는 쪽 표시 없음 · rc 0/0" || no "L15 W8" "rcA=$RCA rcB=$RCB $OUTA"
331
+
324
332
  /bin/rm -rf "$D"
325
333
  echo "PASS=$PASS FAIL=$FAIL"; [ "$FAIL" -eq 0 ] && { echo "FAILED=0"; exit 0; } || { echo "FAILED=1"; exit 1; }
@@ -71,11 +71,12 @@ done
71
71
  [ "$_tf" -eq 0 ] && ok "trivial ② (: · true · ' true ; ' · exit 0 · '' · /usr/bin/true) → rc=3 each"
72
72
 
73
73
  # failing ② on a byte-correct merge → rc=1
74
- run "$T/ok" "$TIP_OK" --rerun 'grep -q NOPE a'
74
+ run "$T/ok" "$TIP_OK" --rerun 'grep -q NOPE a && echo found'
75
75
  [ "$RC" -eq 1 ] && ok "failing ② on a byte-correct squash → rc=1" || { bad "failing ② rc=$RC"; printf '%s\n' "$OUT" | tail -4; }
76
76
 
77
77
  # silent ② (rc=0, no output) → rc=4, never a pass
78
- run "$T/ok" "$TIP_OK" --rerun 'grep -q a2 a'
78
+ # (wrapped in bash -c: a bare `grep -q` is now refused before running — X12; the guard must still catch what X12 cannot see)
79
+ run "$T/ok" "$TIP_OK" --rerun 'bash -c "grep -q a2 a"'
79
80
  [ "$RC" -eq 4 ] && ok "silent ② (rc=0, empty output) → rc=4" || { bad "silent ② rc=$RC"; printf '%s\n' "$OUT" | tail -4; }
80
81
 
81
82
  # COMBINED: main also changed a (different line region) after the branch was cut → not DIFFERS
@@ -179,5 +180,25 @@ _p2=$(bash "$SC" --precheck --rerun 'grep -q x y; echo z' >/dev/null 2>&1; echo
179
180
  _p3=$(bash "$SC" --precheck >/dev/null 2>&1; echo $?)
180
181
  [ "$_p1$_p2$_p3" = "302" ] && ok "X11 --precheck: trivial=3 · real=0 · missing=2" || bad "X11 --precheck got $_p1/$_p2/$_p3 (want 3/0/2)"
181
182
 
183
+ # X12 a ② that is statically silent on success is refused BEFORE merging (rc=3). Origin: the 7 merges in the
184
+ # receipts that ended verify-incomplete (2026-11-09) — content intact, ② a quiet check, the rc=4 silence
185
+ # guard fired only after the merge. Shapes below are those real --rerun strings, reduced. Pass side: a
186
+ # quiet check that also says what passed, and commands that print, must stay accepted.
187
+ _x12=0
188
+ for q in 'grep -q x y' 'bash a.sh --help >/dev/null 2>&1; grep -q "A pass" b.md' 'git show HEAD:f | grep -qx L' \
189
+ 'grep -qF "curl -sL \"u\"" s.md' 'python3 -c "import yaml;yaml.safe_load(open(\"l.yaml\"))"' \
190
+ 'git check-ignore -q f' 'test -f a && [ -s a ]' 'cmp -s a b'; do
191
+ _r=$(bash "$SC" --precheck --rerun "$q" >/dev/null 2>&1; echo $?)
192
+ [ "$_r" = 3 ] || { bad "X12 quiet ② '$q' → rc=$_r (want 3)"; _x12=1; }
193
+ done
194
+ for p in 'grep -q x y && echo ok' 'pytest -q t' 'bash scripts/x.sh' 'python3 -c "import yaml;print(1)"' \
195
+ 'git grep -e x' 'grep -c x y' 'make t >/dev/null 2>&1; echo done' 'cat a 2>/dev/null' 'bash -c true' \
196
+ 'cat a 3>/dev/null' 'cat a >/dev/null 1>&2' "printf '%s\\n' -q | grep -- -q" "python3 -c 'import os; os.write(1,b\"ok\")'" \
197
+ "grep -q '\"' a; echo \"ok\"" "grep -q x a & echo done" 'cat a >&2 | test -d /tmp'; do # last 7 = cross-family R1 over-refusals
198
+ _r=$(bash "$SC" --precheck --rerun "$p" >/dev/null 2>&1; echo $?)
199
+ [ "$_r" = 0 ] || { bad "X12 printing ② '$p' → rc=$_r (want 0)"; _x12=1; }
200
+ done
201
+ [ "$_x12" -eq 0 ] && ok "X12 quiet ② refused before merge (8 shapes → 3) · printing ② accepted (16 shapes → 0)"
202
+
182
203
  printf 'PASS %d · FAIL %d\n' "$PASS" "$FAIL"
183
204
  [ "$FAIL" -eq 0 ]
@@ -24,7 +24,19 @@ setup() {
24
24
  # SETUP_EXTRA=1: a tracked dir whose listing names `a`, and a runner whose text names `a` — the shapes a glob/dir word can drag in
25
25
  [ -n "${SETUP_EXTRA:-}" ] && { mkdir -p "$d/seed/d"; printf 'x\n' > "$d/seed/d/a"; printf 'grep -q a2 a\n' > "$d/seed/r.sh"; }
26
26
  git -C "$d/seed" add -A; git -C "$d/seed" commit -qm init --no-verify; git -C "$d/seed" push -q origin HEAD:main
27
- git -C "$d/seed" switch -qc feat; printf 'a2\n' > "$d/seed/a"; printf 'b2\n' > "$d/seed/b"
27
+ # SETUP_DOCS=1: the PR changes only docs/x.md (a change the merge tier allows); main carries it at x1
28
+ # SETUP_SKILL=1: the PR rewords one skill line (no verdict words) — the tier must READ its diff to say AUTO
29
+ if [ -n "${SETUP_SKILL:-}" ]; then
30
+ mkdir -p "$d/seed/plugins/p/skills/s"; printf 'Plain text one.\n' > "$d/seed/plugins/p/skills/s/SKILL.md"; git -C "$d/seed" add plugins
31
+ git -C "$d/seed" commit -qm skill --no-verify; git -C "$d/seed" push -q origin HEAD:main
32
+ git -C "$d/seed" switch -qc feat; printf 'Plain text two.\n' > "$d/seed/plugins/p/skills/s/SKILL.md"
33
+ elif [ -n "${SETUP_DOCS:-}" ]; then
34
+ mkdir -p "$d/seed/docs"; printf 'x1\n' > "$d/seed/docs/x.md"; git -C "$d/seed" add docs/x.md
35
+ git -C "$d/seed" commit -qm docs --no-verify; git -C "$d/seed" push -q origin HEAD:main
36
+ git -C "$d/seed" switch -qc feat; printf 'x2\n' > "$d/seed/docs/x.md"
37
+ else
38
+ git -C "$d/seed" switch -qc feat; printf 'a2\n' > "$d/seed/a"; printf 'b2\n' > "$d/seed/b"
39
+ fi
28
40
  git -C "$d/seed" commit -qam feat --no-verify; git -C "$d/seed" push -q origin feat
29
41
  git clone -q "$d/origin.git" "$d/work" 2>/dev/null; git -C "$d/work" fetch -q origin feat
30
42
  printf '%s' "$(git -C "$d/seed" rev-parse feat)" > "$d/head.oid"
@@ -38,6 +50,7 @@ D="$D"
38
50
  case "\$1 \$2" in
39
51
  "pr view")
40
52
  [ -f "\$D/view_fail" ] && exit 1
53
+ case "\$*" in *--json\ files*) cat "\$D/files.tsv"; exit 0 ;; esac
41
54
  [ -f "\$D/view_fail_after_merge" ] && [ -s "\$D/merge.log" ] && exit 1
42
55
  case "\$*" in
43
56
  *state,headRefOid*)
@@ -81,6 +94,7 @@ GOOD='grep -q a2 a && grep -q b2 b && echo instrument-ok'
81
94
  printf '── pr_merge_verified ──\n'
82
95
 
83
96
  setup ok; mkgh "$T/ok"; run "$T/ok" 7 --rerun "$GOOD"
97
+ OK_OUT="$OUT"
84
98
  { [ "$RC" -eq 0 ] && printf '%s' "$OUT" | grep -q 'merged and verified'; } \
85
99
  && ok "L1 merge + verify → rc=0" || { bad "L1 happy path rc=$RC"; printf '%s\n' "$OUT" | tail -6; }
86
100
 
@@ -156,13 +170,51 @@ setup st; mkgh "$T/st"; : > "$T/st/local_fail"; : > "$T/st/stuck"; run "$T/st" 7
156
170
 
157
171
  # ── merge receipt: actor + lease (frontier digest 2026-10-23, arXiv:2610.28683) ──
158
172
  # L17 an agent session merging under a named lease → one receipt line naming both, with the merge commit and outcome
159
- setup rl; mkgh "$T/rl"; OUT=$(cd "$T/rl/work" && CLAUDECODE=1 PATH="$T/rl/bin:$PATH" PMV_RETRY_SLEEP=0 PMV_RECEIPTS="$T/rl/receipts.jsonl" bash "$SC" 7 --rerun "$GOOD" --lease "night-2026-10-22" 2>&1); RC=$?
160
- { [ "$RC" -eq 0 ] && [ "$(rcpt "$T/rl" actor)" = "agent-session:claude-code" ] && [ "$(rcpt "$T/rl" lease)" = "night-2026-10-22" ] \
173
+ setup rl; mkgh "$T/rl"; OUT=$(cd "$T/rl/work" && CLAUDECODE=1 PATH="$T/rl/bin:$PATH" PMV_RETRY_SLEEP=0 PMV_RECEIPTS="$T/rl/receipts.jsonl" bash "$SC" 7 --rerun "$GOOD" --lease "operator «night-2026-10-22»" 2>&1); RC=$?
174
+ RL_OUT="$OUT"
175
+ { [ "$RC" -eq 0 ] && [ "$(rcpt "$T/rl" actor)" = "agent-session:claude-code" ] && [ "$(rcpt "$T/rl" lease)" = "operator «night-2026-10-22»" ] \
161
176
  && [ "$(rcpt "$T/rl" outcome)" = "verified" ] && [ "$(rcpt "$T/rl" merge)" = "$(cat "$T/rl/merge.oid")" ] && [ "$(wc -l < "$T/rl/receipts.jsonl")" -eq 1 ]; } \
162
177
  && ok "L17 agent merge under a lease → receipt: actor agent-session · lease · verified · merge oid" || { bad "L17 rc=$RC receipt=$(cat "$T/rl/receipts.jsonl" 2>/dev/null)"; printf '%s\n' "$OUT" | tail -3; }
163
178
  # L18 control: no lease, no agent marker → actor human-or-unknown, lease NONE (recorded, not refused)
164
179
  { [ "$(rcpt "$T/ok" actor)" = "human-or-unknown" ] && [ "$(rcpt "$T/ok" lease)" = "NONE" ]; } \
165
180
  && ok "L18 no lease, no agent marker → human-or-unknown · NONE (merge still allowed)" || bad "L18 receipt=$(cat "$T/ok/receipts.jsonl" 2>/dev/null)"
181
+ # L18b/L18c (AQ-20261109-5) lease=NONE is said before the merge; a named lease is not warned about
182
+ { [ "$(rcpt "$T/ok" lease)" = "NONE" ] && printf '%s' "$OK_OUT" | grep -qF 'no --lease: the receipt will record lease=NONE'; } \
183
+ && ok "L18b no lease → warning line before the merge (the merge still runs)" || bad "L18b warning missing: $(printf '%s' "$OK_OUT" | head -5)"
184
+ printf '%s' "$RL_OUT" | grep -qF 'no --lease' && bad "L18c named lease still warned" || ok "L18c --lease given → no NONE warning"
185
+ # ── a lease is checked by the merge tier unless it is the operator's answer for this PR (AQ-20261109-4: #1063 was
186
+ # TIER=HOLD and merged «under the lease»). The tier reads the recorded head through local git, not the live PR.
187
+ GOODX='grep -q x2 docs/x.md && echo instrument-ok'
188
+ # S1 a standing lease + a docs-only PR (tier AUTO) → merged, and it says it asked
189
+ SETUP_DOCS=1 setup sa; mkgh "$T/sa"; run "$T/sa" 7 --rerun "$GOODX" --lease 'selfdev standing 2026-11-04'
190
+ { [ "$RC" -eq 0 ] && merged "$T/sa" && printf '%s' "$OUT" | grep -qF 'says TIER=AUTO'; } && ok "S1 standing lease + tier AUTO → merged" || { bad "S1 rc=$RC"; printf '%s\n' "$OUT" | tail -4; }
191
+ # S2 a standing lease + a PR the tier holds (root files a, b) → rc 7 before the merge
192
+ setup sh; mkgh "$T/sh"; run "$T/sh" 7 --rerun "$GOOD" --lease 'selfdev standing 2026-11-04'
193
+ { [ "$RC" -eq 7 ] && ! merged "$T/sh" && printf '%s' "$OUT" | grep -qF 'TIER=HOLD'; } && ok "S2 standing lease + tier HOLD → rc 7, nothing merged" || { bad "S2 rc=$RC merged=$(merged "$T/sh" && echo yes || echo no)"; printf '%s\n' "$OUT" | tail -4; }
194
+ # S3 spellings a substring list missed (codex R1): upper case · self-dev · session lease → all checked, all refused
195
+ for _l in 'STANDING' 'self-dev lease' 'session lease 2026-11-09'; do
196
+ setup sv; mkgh "$T/sv"; run "$T/sv" 7 --rerun "$GOOD" --lease "$_l"
197
+ { [ "$RC" -eq 7 ] && ! merged "$T/sv"; } && ok "S3 lease «$_l» → tier checked, rc 7" || bad "S3 lease «$_l» rc=$RC"
198
+ rm -rf "$T/sv"
199
+ done
200
+ # S4 control: the operator's answer for this PR is not checked — even when it mentions selfdev (codex R1 #4)
201
+ setup so; mkgh "$T/so"; run "$T/so" 7 --rerun "$GOOD" --lease 'Operator: «merge this selfdev fix» 2026-11-09'
202
+ { [ "$RC" -eq 0 ] && merged "$T/so" && ! printf '%s' "$OUT" | grep -qF 'TIER='; } && ok "S4 operator lease → tier not consulted, merged" || { bad "S4 rc=$RC"; printf '%s\n' "$OUT" | tail -4; }
203
+ # S6 codex R2: «--lease none» typed by hand is a label, not the default → checked, refused on a HOLD change
204
+ setup sn; mkgh "$T/sn"; run "$T/sn" 7 --rerun "$GOOD" --lease 'none'
205
+ { [ "$RC" -eq 7 ] && ! merged "$T/sn"; } && ok "S6 «--lease none» → tier checked, rc 7" || bad "S6 rc=$RC"
206
+ # S7 codex R2: the caller's git config cannot change what the tier sees (noprefix · color · relative · ignoreSubmodules)
207
+ for _d in s7a s7h; do
208
+ if [ "$_d" = s7a ]; then SETUP_SKILL=1 setup "$_d"; else setup "$_d"; fi; mkgh "$T/$_d"
209
+ for _c in 'diff.noprefix true' 'color.diff always' 'color.ui always' 'diff.relative true' 'diff.ignoreSubmodules all'; do git -C "$T/$_d/work" config $_c; done
210
+ done
211
+ run "$T/s7a" 7 --rerun 'grep -q "text two" plugins/p/skills/s/SKILL.md && echo instrument-ok' --lease 'selfdev standing 2026-11-04'
212
+ { [ "$RC" -eq 0 ] && merged "$T/s7a"; } && ok "S7a hostile git config + plain skill edit (diff is read) → tier still AUTO, merged" || { bad "S7a rc=$RC"; printf '%s\n' "$OUT" | tail -4; }
213
+ run "$T/s7h" 7 --rerun "$GOOD" --lease 'selfdev standing 2026-11-04'
214
+ { [ "$RC" -eq 7 ] && ! merged "$T/s7h"; } && ok "S7h hostile git config + held PR → still rc 7" || bad "S7h rc=$RC"
215
+ # S5 the tier judges the RECORDED head: a live PR whose file list says docs-only cannot launder a head that changes a, b
216
+ setup sl; mkgh "$T/sl"; printf 'MODIFIED\tdocs/x.md\t1\t1\n' > "$T/sl/files.tsv"; run "$T/sl" 7 --rerun "$GOOD" --lease 'selfdev standing 2026-11-04'
217
+ { [ "$RC" -eq 7 ] && ! merged "$T/sl"; } && ok "S5 tier reads the recorded head, not the live file list → rc 7" || bad "S5 rc=$RC"
166
218
  # L19 negative control — a refusal BEFORE the merge, or a merge GitHub did not take, leaves no receipt. It cannot detect the feature
167
219
  # being removed on its own (codex R1); L17 · L18 · L21 are its positive pair.
168
220
  { [ ! -s "$T/nore/receipts.jsonl" ] && [ ! -s "$T/triv/receipts.jsonl" ] && [ ! -s "$T/mf/receipts.jsonl" ]; } \
@@ -740,21 +740,30 @@ open(os.path.join(base, 'control_r1.txt'), 'w').write('weather')
740
740
  for arm in ('primary', 'control'):
741
741
  if sys.argv[2] == 'MISSING':
742
742
  continue
743
- if sys.argv[2] == 'PARTIAL' and arm == 'primary':
743
+ if sys.argv[2] in ('PARTIAL', 'WALLNOMETA') and arm == 'primary':
744
744
  continue # transcript present, meta absent: ran but unmeasured
745
745
  end = sys.argv[2] if arm == 'primary' else 'no'
746
+ wall = ''
747
+ if sys.argv[2] == 'WALL':
748
+ end, wall = 'no', 'wall_s\t%d\n' % (3 if arm == 'primary' else 7)
749
+ if sys.argv[2] == 'WALLNOMETA':
750
+ end, wall = 'no', 'wall_s\t4\n'
751
+ if sys.argv[2] == 'WALLBAD':
752
+ end, wall = 'no', ('wall_s\t\u00b2\n' if arm == 'primary' else 'wall_s\t6\n')
753
+ if sys.argv[2] == 'WALLHALF':
754
+ end, wall = 'no', ('wall_s\t5\n' if arm == 'primary' else 'wall_s\t\n')
746
755
  open(os.path.join(base, arm + '_r1.meta.tsv'), 'w').write(
747
- 'rc\t0\ntimeout_s\t900\nmax_turns\tunset\ntoken_cap\tunset\nended_at_cap\t%s\n' % end)
756
+ 'rc\t0\ntimeout_s\t900\nmax_turns\tunset\ntoken_cap\tunset\nended_at_cap\t%s\n%s' % (end, wall))
748
757
  r = score_run([{'id': 'G-X', 'polarity': 'present', 'expect_re': 'ZZZ'}], root, ['G-X'], 0.8, 'sonnet')['rows'][0]
749
758
  print('%s|%s|%s' % (r['verdict'], r['ended_at_cap'], r['budget']))
750
759
  PY
751
760
  }
752
761
  r="$(_budget yes)"
753
762
  _lane BU1 budget "KNOWN-POSITIVE — a FAIL whose primary episode ended at the cap says so" \
754
- "FAIL|yes|timeout=900s max_turns=unset tokens=unset ended_at_cap=yes (1/2 episodes)" "$r"
763
+ "FAIL|yes|timeout=900s max_turns=unset tokens=unset ended_at_cap=yes (1/2 episodes) wall_s=UNMEASURED tokens_used=UNMEASURED" "$r"
755
764
  r="$(_budget no)"
756
765
  _lane BU2 budget "KNOWN-NEGATIVE — a FAIL that ended on its own says ended_at_cap=no" \
757
- "FAIL|no|timeout=900s max_turns=unset tokens=unset ended_at_cap=no" "$r"
766
+ "FAIL|no|timeout=900s max_turns=unset tokens=unset ended_at_cap=no wall_s=UNMEASURED tokens_used=UNMEASURED" "$r"
758
767
  r="$(_budget MISSING)"
759
768
  _lane BU3 budget "no meta recorded -> UNKNOWN (not measured is not no)" \
760
769
  "FAIL|UNKNOWN|no episode meta (cap not recorded)" "$r"
@@ -762,7 +771,21 @@ _lane BU3 budget "no meta recorded -> UNKNOWN (not measured is not no)" \
762
771
  # episode's `no` stand for the row — before the fix this printed `...|no|...`.
763
772
  r="$(_budget PARTIAL)"
764
773
  _lane BU5 budget "partial meta (transcript without meta) -> UNKNOWN, not the other episode's no" \
765
- "FAIL|UNKNOWN|timeout=900s max_turns=unset tokens=unset ended_at_cap=UNKNOWN" "$r"
774
+ "FAIL|UNKNOWN|timeout=900s max_turns=unset tokens=unset ended_at_cap=UNKNOWN wall_s=UNMEASURED tokens_used=UNMEASURED" "$r"
775
+
776
+ # BU6/BU7 cost axis (2026-11-12): wall seconds sit next to the verdict, never in it; tokens stay UNMEASURED.
777
+ r="$(_budget WALL)"
778
+ _lane BU6 budget "KNOWN-POSITIVE — wall_s recorded in both episodes -> range, verdict unchanged" \
779
+ "FAIL|no|timeout=900s max_turns=unset tokens=unset ended_at_cap=no wall_s=3..7 tokens_used=UNMEASURED" "$r"
780
+ r="$(_budget WALLHALF)"
781
+ _lane BU7 budget "one episode's wall_s empty -> counted as unmeasured, not as 0" \
782
+ "FAIL|no|timeout=900s max_turns=unset tokens=unset ended_at_cap=no wall_s=5..5 (1/2 episodes unmeasured) tokens_used=UNMEASURED" "$r"
783
+ r="$(_budget WALLNOMETA)"
784
+ _lane BU8 budget "transcript without meta next to a measured episode -> range flagged partial (codex R1 A)" \
785
+ "FAIL|UNKNOWN|timeout=900s max_turns=unset tokens=unset ended_at_cap=UNKNOWN wall_s=4..4 (1/2 episodes unmeasured) tokens_used=UNMEASURED" "$r"
786
+ r="$(_budget WALLBAD)"
787
+ _lane BU9 budget "non-ASCII digit wall_s does not crash scoring; counted unmeasured (codex R1 A)" \
788
+ "FAIL|no|timeout=900s max_turns=unset tokens=unset ended_at_cap=no wall_s=6..6 (1/2 episodes unmeasured) tokens_used=UNMEASURED" "$r"
766
789
 
767
790
  # BU4/TG*: end to end through the runner with a stub sim that writes the meta the real runner writes.
768
791
  if [ "$NOPROBES" -eq 1 ]; then _skipblock "budget/target runner lanes BU4 TG3-TG5 (need probes.md)"; else
@@ -783,6 +806,77 @@ chmod +x "$BSTUB/fake_sim_budget.sh"
783
806
  _lane BU4 budget "runner -> report row carries 'ended_at_cap=yes' when the stub hit its cap" \
784
807
  "yes" "$(grep -E '^\| G-GREET-01 ' "$T/bud_report.md" | grep -q 'ended_at_cap=yes' && echo yes || echo no)"
785
808
 
809
+ # SF1-SF3 state fingerprint (2026-11-11): one line per rep, appended after the verdict, never scored.
810
+ # SF1 the budget stub writes no treediff → the line says MISSING (not measured ≠ 0).
811
+ _lane SF1 state-fp "stub without treediff: report carries 'treediff=MISSING' for both arms" "2" \
812
+ "$(grep -cE '^state-fingerprint: G-GREET-01 (primary|control) r1 treediff=MISSING$' "$T/bud_report.md")"
813
+ # SF2 a stub that writes a treediff + the changed file → changed=1 with a hash; a second run with
814
+ # different file bytes but the SAME porcelain line gets a different hash (state, not output).
815
+ cat > "$BSTUB/fake_sim_state.sh" <<'FAKESTATE'
816
+ #!/usr/bin/env bash
817
+ arm=""; out=""
818
+ while [ $# -gt 0 ]; do case "$1" in --arm) arm="$2"; shift 2 ;; --out) out="$2"; shift 2 ;; *) shift ;; esac; done
819
+ mkdir -p "$out/w_${arm}_r1/repo"
820
+ printf 'stub body %s\n' "$arm" > "$out/${arm}_r1.txt"
821
+ printf 'rc\t0\ntimeout_s\t900\nmax_turns\tunset\ntoken_cap\tunset\nended_at_cap\tno\n' > "$out/${arm}_r1.meta.tsv"
822
+ case "${FH_STATE_STUB_KIND:-file}" in
823
+ file) printf '?? note.txt\n' > "$out/${arm}_r1.treediff.txt"
824
+ printf '%s\n' "${FH_STATE_STUB_BYTES:-a}" > "$out/w_${arm}_r1/repo/note.txt" ;;
825
+ dir) printf '?? newdir/\n' > "$out/${arm}_r1.treediff.txt"; mkdir -p "$out/w_${arm}_r1/repo/newdir"
826
+ printf '%s\n' "${FH_STATE_STUB_BYTES:-a}" > "$out/w_${arm}_r1/repo/newdir/f.txt" ;;
827
+ quoted) printf '?? "a b.txt"\n' > "$out/${arm}_r1.treediff.txt"
828
+ printf '%s\n' "${FH_STATE_STUB_BYTES:-a}" > "$out/w_${arm}_r1/repo/a b.txt" ;;
829
+ unread) printf '?? note.txt\n' > "$out/${arm}_r1.treediff.txt"; chmod 000 "$out/${arm}_r1.treediff.txt" ;;
830
+ rename) printf 'R old.txt -> new.txt\n' > "$out/${arm}_r1.treediff.txt"
831
+ printf '%s\n' "${FH_STATE_STUB_BYTES:-a}" > "$out/w_${arm}_r1/repo/new.txt" ;;
832
+ lockedfile) printf ' M secret.txt\n' > "$out/${arm}_r1.treediff.txt"
833
+ printf 'x\n' > "$out/w_${arm}_r1/repo/secret.txt"; chmod 000 "$out/w_${arm}_r1/repo/secret.txt" ;;
834
+ esac
835
+ echo "RESULT: CLEAN"; exit 0
836
+ FAKESTATE
837
+ chmod +x "$BSTUB/fake_sim_state.sh"
838
+ for v in a b; do
839
+ ( cd "$REPO_ROOT" && FH_SIM_RUNNER_BIN="$BSTUB/fake_sim_state.sh" FH_STATE_STUB_BYTES="$v" \
840
+ bash "$RUNNER" --ids "G-GREET-01" --no-evidence --report-out "$T/sf_$v.md" ) >"$T/sf_$v.log" 2>&1
841
+ done
842
+ sf_a="$(grep -E '^state-fingerprint: G-GREET-01 primary r1 changed=1 unhashed=0 sha256=[0-9a-f]{16}$' "$T/sf_a.md")"
843
+ sf_b="$(grep -E '^state-fingerprint: G-GREET-01 primary r1 changed=1 unhashed=0 sha256=[0-9a-f]{16}$' "$T/sf_b.md")"
844
+ _lane SF2 state-fp "treediff present: changed=1 + hash; same porcelain, different bytes → different hash" "yes" \
845
+ "$([ -n "$sf_a" ] && [ -n "$sf_b" ] && [ "$sf_a" != "$sf_b" ] && echo yes || echo no)"
846
+ # Codex R1 (2026-11-11): SF4 a changed DIRECTORY is hashed over its files (different bytes → different hash)
847
+ for v in a b; do
848
+ ( cd "$REPO_ROOT" && FH_SIM_RUNNER_BIN="$BSTUB/fake_sim_state.sh" FH_STATE_STUB_KIND=dir FH_STATE_STUB_BYTES="$v" \
849
+ bash "$RUNNER" --ids "G-GREET-01" --no-evidence --report-out "$T/sfd_$v.md" ) >"$T/sfd_$v.log" 2>&1
850
+ done
851
+ _lane SF4 state-fp "untracked directory: content change moves the hash" "yes" \
852
+ "$(a=$(grep '^state-fingerprint: G-GREET-01 primary r1 changed=1 ' "$T/sfd_a.md"); b=$(grep '^state-fingerprint: G-GREET-01 primary r1 changed=1 ' "$T/sfd_b.md"); [ -n "$a" ] && [ "$a" != "$b" ] && echo yes || echo no)"
853
+ # SF5 a git-quoted path is named as unhashed, never silently folded into «same hash»
854
+ ( cd "$REPO_ROOT" && FH_SIM_RUNNER_BIN="$BSTUB/fake_sim_state.sh" FH_STATE_STUB_KIND=quoted \
855
+ bash "$RUNNER" --ids "G-GREET-01" --no-evidence --report-out "$T/sfq.md" ) >"$T/sfq.log" 2>&1
856
+ _lane SF5 state-fp "quoted porcelain path → unhashed=1 on the line" "1" \
857
+ "$(grep -cE '^state-fingerprint: G-GREET-01 primary r1 changed=1 unhashed=1 ' "$T/sfq.md")"
858
+ # SF6 an unreadable treediff says UNREADABLE, not changed=0 (skipped as root: root reads mode 000)
859
+ if [ "$(id -u)" = 0 ]; then _skipblock "SF6 (root reads mode-000 files)"; else
860
+ ( cd "$REPO_ROOT" && FH_SIM_RUNNER_BIN="$BSTUB/fake_sim_state.sh" FH_STATE_STUB_KIND=unread \
861
+ bash "$RUNNER" --ids "G-GREET-01" --no-evidence --report-out "$T/sfu.md" ) >"$T/sfu.log" 2>&1
862
+ _lane SF6 state-fp "unreadable treediff → treediff=UNREADABLE" "1" \
863
+ "$(grep -cE '^state-fingerprint: G-GREET-01 primary r1 treediff=UNREADABLE$' "$T/sfu.md")"
864
+ chmod -R u+rwx "$T" 2>/dev/null
865
+ fi
866
+ # Codex R2: SF7 rename record and SF8 unreadable listed file → counted as unhashed
867
+ ( cd "$REPO_ROOT" && FH_SIM_RUNNER_BIN="$BSTUB/fake_sim_state.sh" FH_STATE_STUB_KIND=rename \
868
+ bash "$RUNNER" --ids "G-GREET-01" --no-evidence --report-out "$T/sfr.md" ) >"$T/sfr.log" 2>&1
869
+ _lane SF7 state-fp "rename record → unhashed=1" "1" "$(grep -cE '^state-fingerprint: G-GREET-01 primary r1 changed=1 unhashed=1 ' "$T/sfr.md")"
870
+ if [ "$(id -u)" != 0 ]; then
871
+ ( cd "$REPO_ROOT" && FH_SIM_RUNNER_BIN="$BSTUB/fake_sim_state.sh" FH_STATE_STUB_KIND=lockedfile \
872
+ bash "$RUNNER" --ids "G-GREET-01" --no-evidence --report-out "$T/sfl.md" ) >"$T/sfl.log" 2>&1
873
+ _lane SF8 state-fp "unreadable listed file → unhashed=1" "1" "$(grep -cE '^state-fingerprint: G-GREET-01 primary r1 changed=1 unhashed=1 ' "$T/sfl.md")"
874
+ chmod -R u+rwx "$T" 2>/dev/null
875
+ fi
876
+ # SF3 the fingerprint never moves a verdict: the G-GREET-01 report row is byte-identical across a/b.
877
+ _lane SF3 state-fp "verdict row identical across runs whose end states differ" "yes" \
878
+ "$([ -n "$(grep -E '^\| G-GREET-01 ' "$T/sf_a.md")" ] && [ "$(grep -E '^\| G-GREET-01 ' "$T/sf_a.md")" = "$(grep -E '^\| G-GREET-01 ' "$T/sf_b.md")" ] && echo yes || echo no)"
879
+
786
880
  # TG3 default output unchanged: no --target -> no split section anywhere.
787
881
  _lane TG3 target "default (no --target): report has no 'Target split' section" \
788
882
  "no" "$(grep -q 'Target split' "$T/bud_report.md" && echo yes || echo no)"
@@ -906,6 +1000,67 @@ PY
906
1000
  )"
907
1001
  _lane IF4 instrument "KNOWN-NEGATIVE — stub sim runner is fingerprinted as sim_runner(override)" "override" "$r"
908
1002
 
1003
+ # ── run-rc: a rep the runner says did not finish (meta rc != 0) is FAILED-TO-RUN (2026-11-11) ──────
1004
+ # Real defect: a usage-limit reply is NON-EMPTY text, so the empty-text check let it through and it
1005
+ # was scored FAIL. Measured: 2026-11-10 model-arms run, Opus G-MAP-01 r1-r3 = 6 limit replies scored
1006
+ # FAIL 0/3; nightly 2026-10-27 had 75 such files. In every one of those 156 files the runner's
1007
+ # meta.tsv said rc=1, and in all 2,142 normal replies it said rc=0 — so the discriminator is the
1008
+ # runner's own exit code, never the reply text. Fixture texts below are byte-copied from those runs.
1009
+ # 🟥 RC4/RC5 are the opposite-direction controls: an rc=0 reply that merely CONTAINS limit wording is
1010
+ # still scored normally (a real FAIL stays FAIL), and a run with no meta.tsv is not re-guessed.
1011
+ _rc_run() { # $1=reps, then per rep "<kind>:<primary rc>:<control rc>"; kind P pass | F fail | L limit | M mixed | Q pass+limit words; rc '-' = no meta
1012
+ local reps="$1"; shift
1013
+ python3 - "$REPO_ROOT" "$reps" "$@" <<'PY'
1014
+ import sys, os, tempfile
1015
+ sys.path.insert(0, os.path.join(sys.argv[1], 'scripts'))
1016
+ from probe_live_eval_lib import score_run
1017
+ LIMIT = "You've hit your 5-hour limit · resets 11:30pm (Asia/Seoul)\n"
1018
+ LIMIT_S = "You've hit your session limit · resets 3:20am (Asia/Seoul)\n"
1019
+ reps = int(sys.argv[2]); specs = sys.argv[3:]
1020
+ root = tempfile.mkdtemp(); base = os.path.join(root, 'G-X'); os.makedirs(base)
1021
+ for i, spec in enumerate(specs, start=1):
1022
+ kind, prc, crc = spec.split(':')
1023
+ prim = {'P': '\U0001f43f️ hi', 'F': 'nothing here', 'L': LIMIT, 'S': LIMIT_S,
1024
+ 'M': 'Not mapped. ' + LIMIT, 'Q': '\U0001f43f️ hi. ' + LIMIT}[kind]
1025
+ ctrl = {'L': LIMIT, 'S': LIMIT_S}.get(kind, 'weather')
1026
+ for arm, text, rc in (('primary', prim, prc), ('control', ctrl, crc)):
1027
+ open(os.path.join(base, '%s_r%d.txt' % (arm, i)), 'w', encoding='utf-8').write(text)
1028
+ if rc != '-':
1029
+ open(os.path.join(base, '%s_r%d.meta.tsv' % (arm, i)), 'w').write('sim_model\tx\nrc\t%s\n' % rc)
1030
+ row = score_run([{'id': 'G-X', 'polarity': 'present', 'expect_re': '\U0001f43f️'}],
1031
+ root, ['G-X'], 0.8, 'sonnet', reps=reps)['rows'][0]
1032
+ print('%s %s|%s' % (row['verdict'], row.get('reps'), row.get('reason', '')))
1033
+ PY
1034
+ }
1035
+ r="$(_rc_run 3 L:1:1 L:1:1 L:1:1)"
1036
+ _lane RC1 run-rc "3 limit replies (rc=1, real text) -> FAILED-TO-RUN, not FAIL 0/3" "FAILED-TO-RUN 0/0" "${r%%|*}"
1037
+ case "${r#*|}" in *"rc=1"*"limit"*) rr=named ;; *) rr="unnamed:${r#*|}" ;; esac
1038
+ _lane RC1b run-rc "reason names the runner rc and the reply's first line" "named" "$rr"
1039
+ r="$(python3 - "$REPO_ROOT" <<'PY'
1040
+ import sys, os, tempfile
1041
+ sys.path.insert(0, os.path.join(sys.argv[1], 'scripts'))
1042
+ from probe_live_eval_lib import _failure_reason
1043
+ b = tempfile.mkdtemp()
1044
+ open(os.path.join(b, 'primary_r1.txt'), 'w').write('')
1045
+ open(os.path.join(b, 'primary_r1.meta.tsv'), 'w').write('rc\t127\n')
1046
+ open(os.path.join(b, 'primary_r1.stderr.txt'), 'w').write('claude: command not found\n')
1047
+ print(_failure_reason(b, 'primary'))
1048
+ PY
1049
+ )"
1050
+ _lane RC1c run-rc "rc!=0 with EMPTY reply keeps the stderr diagnostic (codex R1)" "claude: command not found" "$r"
1051
+ r="$(_rc_run 3 P:0:0 P:0:0 L:1:1)"
1052
+ _lane RC2 run-rc "a limit rep leaves the denominator: 2 pass + 1 limit -> PASS 2/2" "PASS 2/2" "${r%%|*}"
1053
+ r="$(_rc_run 3 P:0:1 P:0:0 P:0:0)"
1054
+ _lane RC3 run-rc "control arm alone rc!=0 -> that rep did not run (PASS 2/2)" "PASS 2/2" "${r%%|*}"
1055
+ r="$(_rc_run 3 M:0:0 M:0:0 M:0:0)"
1056
+ _lane RC4 run-rc "KNOWN-NEGATIVE — rc=0 reply with limit wording and no rule hit stays FAIL" "FAIL 0/3" "${r%%|*}"
1057
+ r="$(_rc_run 3 Q:0:0 Q:0:0 Q:0:0)"
1058
+ _lane RC4b run-rc "KNOWN-NEGATIVE — rc=0 reply with limit wording and a rule hit stays PASS" "PASS 3/3" "${r%%|*}"
1059
+ r="$(_rc_run 3 L:-:- L:-:- L:-:-)"
1060
+ _lane RC5 run-rc "no meta.tsv (older run) -> text is not re-guessed; scored as before (FAIL)" "FAIL 0/3" "${r%%|*}"
1061
+ r="$(_rc_run 3 S:1:1 S:1:1 S:1:1)"
1062
+ _lane RC6 run-rc "nightly 'session limit' variant (rc=1) -> FAILED-TO-RUN" "FAILED-TO-RUN 0/0" "${r%%|*}"
1063
+
909
1064
  echo ""
910
1065
  echo "── summary ──────────────────────────────────────────────────────"
911
1066
  echo "lanes: $N failed: $([ "$FAIL" -eq 0 ] && echo 0 || echo '>=1')"