@chrono-meta/fh-gate 3.28.0 → 3.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/.claude-plugin/marketplace.json +4 -4
  2. package/CHEATSHEET.md +2 -2
  3. package/CLAUDE.md +5 -2
  4. package/docs/REFERENCE.md +4 -1
  5. package/knowledge/shared/harness-core/claude_md_full_reference.md +2 -0
  6. package/knowledge/shared/harness-core/claude_md_gate_details.md +7 -0
  7. package/knowledge/shared/harness-core/dispatch_conditional_prohibition.md +12 -0
  8. package/knowledge/shared/harness-core/fh_three_layer_canon.md +12 -0
  9. package/knowledge/shared/harness-core/measurement-integrity-checklist.md +16 -0
  10. package/knowledge/shared/learnings/subagent_invocations_log.yaml +56 -0
  11. package/package.json +3 -1
  12. package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
  13. package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
  14. package/plugins/fh-meta/CHANGELOG.md +22 -0
  15. package/plugins/fh-meta/skills/auto-decorrelation/SKILL.md +17 -0
  16. package/plugins/fh-meta/skills/sim-conductor/SKILL.md +2 -2
  17. package/plugins/fh-meta/skills/sim-conductor/SKILL_detail.md +3 -3
  18. package/plugins/fh-meta/skills/steel-quench/SKILL.md +25 -1
  19. package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
  20. package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
  21. package/scripts/degrade_direction_scan.sh +43 -0
  22. package/scripts/dispatch_receipt.py +185 -0
  23. package/scripts/doc_claim_triad_scan.py +43 -4
  24. package/scripts/fh-gate.sh +71 -11
  25. package/scripts/finding_fleet.sh +15 -3
  26. package/scripts/package_coverage_check.sh +5 -0
  27. package/scripts/selfcheck.sh +41 -20
  28. package/scripts/session_checklist.py +155 -12
  29. package/scripts/test_degrade_scan_shell_probes.sh +81 -0
  30. package/scripts/test_dispatch_receipt_lanes.sh +95 -0
  31. package/scripts/test_doc_claim_triad_lanes.sh +30 -0
  32. package/scripts/test_fh_audit_check_lanes.sh +10 -5
  33. package/scripts/test_fh_gate_regressions.sh +71 -1
  34. package/scripts/test_finding_pipeline_lanes.sh +83 -0
  35. package/scripts/test_locale_invariance_lanes.sh +19 -0
  36. package/scripts/test_mutation_probe_lanes.sh +22 -6
  37. package/scripts/test_selfcheck_state_lanes.sh +32 -0
  38. package/scripts/test_session_checklist_lanes.sh +138 -0
  39. package/templates/PRE-PUBLISH-CHECKLIST.md +10 -0
  40. package/templates/degrade_direction_scan.sh +43 -0
@@ -0,0 +1,185 @@
1
+ #!/usr/bin/env python3
2
+ """dispatch_receipt.py — the governor's own receipt for edit work a dispatched agent says it did.
3
+
4
+ Why (2026-10-20): an agent's hand-back («committed 7f2acd2, 11 files, tests green») is a claim. CLAUDE.md §Agent Dispatch
5
+ says a sidecar's findings stay evidence until the governor closes each against a mechanical anchor — for EDIT work there was
6
+ no anchor, so the close step read the agent's own summary. Outside anchors for the same gap: arXiv:2610.15459 and «report ≠
7
+ change» (frontier digest 2026-10-20). This prints what the repository says, measured by the governor, and with a claim
8
+ compares it with the files the agent named.
9
+
10
+ Usage: python3 scripts/dispatch_receipt.py <repo-or-worktree> <base-ref> [--claimed a,b,...] [--claimed-file F] [--head REF]
11
+ --claimed comma-separated paths. An empty entry, a duplicate or a path with leading/trailing space is REFUSED (rc 2):
12
+ a claim is never silently rewritten. Paths containing a comma need --claimed-file.
13
+ --claimed-file one path per line (or NUL-separated if the file contains NUL bytes), same refusal rules.
14
+ Prints head sha · branch · commits base..head · per-path line (sha256 prefix of the blob at head, «deleted», «submodule <sha>»,
15
+ «symlink <sha>») · uncommitted(tracked) / untracked counts.
16
+ Exit: 0 = receipt printed and the claim (if any) equals the changed set exactly · 1 = claim differs (named both ways), or tracked
17
+ changes are not committed · 2 = usage / malformed claim · 10 = harness error (any git call failed, base is not an ancestor of head).
18
+ 🟥 Rename detection is OFF: a move lists both the old and the new path — every affected path, independent of git config.
19
+ 🟥 «0 paths» is not a pass when a claim names files: rc 1.
20
+ 🟥 Named residual (codex R3, rounds capped there): the receipt overrides the git settings that changed its answer in review
21
+ (GIT_* env, replace refs, diff.relative, ignoreSubmodules, fileMode, quotePath) and measures from the top level. It still
22
+ trusts the rest of the repository's own config and hooks-free plumbing; it is a receipt for cooperative dispatch, not a
23
+ sandbox for a hostile repository.
24
+ """
25
+ import hashlib, os, subprocess, sys
26
+
27
+ # 🟥 codex R3: inherited GIT_DIR / GIT_WORK_TREE / GIT_INDEX_FILE … would make it measure another repository — drop every GIT_*
28
+ # variable, then set only what the receipt needs. Replacement refs off: the printed sha must be the measured history.
29
+ ENV = {k: v for k, v in os.environ.items() if not k.startswith("GIT_")}
30
+ ENV.update(GIT_OPTIONAL_LOCKS="0", GIT_TERMINAL_PROMPT="0", GIT_LITERAL_PATHSPECS="1", GIT_NO_REPLACE_OBJECTS="1", LC_ALL="C")
31
+
32
+
33
+ class HarnessError(Exception):
34
+ pass
35
+
36
+
37
+ def git(repo, *args):
38
+ r = subprocess.run(["git", "-C", repo, "-c", "core.fsmonitor=false", "-c", "core.quotePath=false",
39
+ "-c", "diff.ignoreSubmodules=none", "-c", "status.showUntrackedFiles=normal",
40
+ "-c", "diff.relative=false", "-c", "core.fileMode=true", *args],
41
+ capture_output=True, env=ENV)
42
+ if r.returncode != 0:
43
+ raise HarnessError("git %s failed (rc=%d): %s" % (" ".join(args[:2]), r.returncode,
44
+ r.stderr.decode("utf-8", "replace").strip()[:200]))
45
+ return r.stdout
46
+
47
+
48
+ def usage(msg):
49
+ print("usage: dispatch_receipt.py <repo-or-worktree> <base-ref> [--claimed a,b] [--claimed-file F] [--head REF]", file=sys.stderr)
50
+ if msg:
51
+ print(" " + msg, file=sys.stderr)
52
+ return 2
53
+
54
+
55
+ def parse_claim(entries, origin):
56
+ """→ (set of paths, error or None). Nothing is normalised: an ambiguous entry is an error, not a guess."""
57
+ seen = []
58
+ for e in entries:
59
+ if e == "":
60
+ return None, "empty entry in %s (a trailing or doubled separator?)" % origin
61
+ if e != e.strip():
62
+ return None, "entry with leading/trailing space in %s: %r — say exactly which path" % (origin, e)
63
+ if e in seen:
64
+ return None, "duplicate entry in %s: %r" % (origin, e)
65
+ seen.append(e)
66
+ return set(seen), None
67
+
68
+
69
+ def main(argv):
70
+ if len(argv) < 2:
71
+ return usage("")
72
+ repo, base, rest = argv[0], argv[1], argv[2:]
73
+ head_ref, claim, have_claim = "HEAD", set(), False
74
+ i = 0
75
+ while i < len(rest):
76
+ a = rest[i]
77
+ if a in ("--claimed", "--claimed-file", "--head") and i + 1 >= len(rest):
78
+ return usage("%s needs a value" % a)
79
+ if a == "--head":
80
+ head_ref = rest[i + 1]
81
+ elif a == "--claimed":
82
+ got, err = parse_claim(rest[i + 1].split(","), "--claimed")
83
+ if err:
84
+ return usage(err)
85
+ if claim & got:
86
+ return usage("duplicate entry across claim options: %r" % sorted(claim & got)[0])
87
+ claim |= got; have_claim = True
88
+ elif a == "--claimed-file":
89
+ try:
90
+ raw = open(rest[i + 1], "rb").read().decode("utf-8")
91
+ except (OSError, UnicodeDecodeError) as exc:
92
+ return usage("cannot read --claimed-file: %s" % exc)
93
+ parts = raw.split("\0") if "\0" in raw else raw.split("\n")
94
+ if parts and parts[-1] == "":
95
+ parts.pop() # ONE final terminator is normal; a second one is an empty entry
96
+ got, err = parse_claim(parts, "--claimed-file")
97
+ if err:
98
+ return usage(err)
99
+ if claim & got:
100
+ return usage("duplicate entry across claim options: %r" % sorted(claim & got)[0])
101
+ claim |= got; have_claim = True
102
+ else:
103
+ return usage("unknown argument %r" % a)
104
+ i += 2
105
+ if not os.path.isdir(repo):
106
+ print("HARNESS-ERROR: not a directory: %s" % repo, file=sys.stderr); return 10
107
+ try:
108
+ repo = git(repo, "rev-parse", "--show-toplevel").decode().strip() # codex R3: a subdirectory must not narrow the diff
109
+ head = git(repo, "rev-parse", "--verify", "--quiet", head_ref + "^{commit}").decode().strip()
110
+ base_sha = git(repo, "rev-parse", "--verify", "--quiet", base + "^{commit}").decode().strip()
111
+ r = subprocess.run(["git", "-C", repo, "merge-base", "--is-ancestor", base_sha, head], capture_output=True, env=ENV)
112
+ if r.returncode == 1:
113
+ raise HarnessError("base %s is not an ancestor of head %s — the receipt would mix unrelated history" % (base_sha[:12], head[:12]))
114
+ if r.returncode != 0:
115
+ raise HarnessError("merge-base failed (rc=%d)" % r.returncode)
116
+ b = subprocess.run(["git", "-C", repo, "symbolic-ref", "--quiet", "--short", "HEAD"], capture_output=True, env=ENV)
117
+ branch = b.stdout.decode().strip() if b.returncode == 0 else "(detached)"
118
+ commits = int(git(repo, "rev-list", "--count", "%s..%s" % (base_sha, head)).decode().strip())
119
+ paths = [p.decode("utf-8", "surrogateescape") for p in
120
+ git(repo, "diff", "--name-only", "-z", "--no-renames", "--ignore-submodules=none", base_sha, head).split(b"\0") if p]
121
+ lines = []
122
+ for p in paths:
123
+ t = git(repo, "ls-tree", "-z", head, "--", p).split(b"\0")[0]
124
+ if not t:
125
+ prev = git(repo, "ls-tree", "-z", base_sha, "--", p).split(b"\0")[0]
126
+ if not prev:
127
+ raise HarnessError("path %r is in the diff but in neither tree" % p)
128
+ lines.append(("deleted", p)); continue
129
+ meta, _, _name = t.partition(b"\t")
130
+ mode, typ, obj = meta.decode().split(" ")
131
+ if typ == "commit":
132
+ lines.append(("submodule " + obj[:12], p)); continue
133
+ if typ != "blob":
134
+ raise HarnessError("unexpected object type %s for %r" % (typ, p))
135
+ data = git(repo, "cat-file", "blob", obj)
136
+ tag = hashlib.sha256(data).hexdigest()[:16]
137
+ lines.append((("symlink " if mode == "120000" else "") + tag, p))
138
+ st = git(repo, "status", "--porcelain=v1", "-z", "--untracked-files=normal", "--ignore-submodules=none").split(b"\0")
139
+ # assume-unchanged (h) / skip-worktree (S) entries are invisible to status — count them, they make «committed» unprovable
140
+ hidden = sum(1 for e in git(repo, "ls-files", "-v", "-z").split(b"\0") if e[:1] in (b"h", b"S", b"s"))
141
+ dirty = untracked = 0
142
+ skip = False
143
+ for e in st:
144
+ if skip:
145
+ skip = False; continue
146
+ if not e:
147
+ continue
148
+ code = e[:2]
149
+ if code == b"??":
150
+ untracked += 1
151
+ else:
152
+ dirty += 1
153
+ if code[:1] in (b"R", b"C"):
154
+ skip = True # rename/copy entries carry the source path as the next field
155
+ except HarnessError as exc:
156
+ print("HARNESS-ERROR: %s" % exc, file=sys.stderr); return 10
157
+ print("receipt repo=%s" % repo)
158
+ print(" head=%s branch=%s base=%s" % (head, branch, base_sha))
159
+ print(" commits=%d paths=%d" % (commits, len(paths)))
160
+ print(" uncommitted(tracked)=%d untracked=%d hidden-from-status=%d" % (dirty, untracked, hidden))
161
+ for tag, p in lines:
162
+ print(" path %-18s %s" % (tag, p))
163
+ rc = 0
164
+ if dirty:
165
+ print("NOT-COMMITTED: %d tracked path(s) changed but not committed — the receipt covers commits only" % dirty); rc = 1
166
+ if hidden:
167
+ print("UNPROVABLE-CLEAN: %d path(s) marked assume-unchanged/skip-worktree — status cannot show their edits" % hidden); rc = 1
168
+ if have_claim:
169
+ actual = set(paths)
170
+ missing, extra = sorted(claim - actual), sorted(actual - claim)
171
+ if missing:
172
+ print("CLAIMED-NOT-CHANGED:"); [print(" " + p) for p in missing]; rc = 1
173
+ if extra:
174
+ print("CHANGED-NOT-CLAIMED:"); [print(" " + p) for p in extra]; rc = 1
175
+ if not missing and not extra:
176
+ print("CLAIMED-MATCHES: %d path(s)" % len(claim))
177
+ return rc
178
+
179
+
180
+ if __name__ == "__main__":
181
+ try:
182
+ sys.exit(main(sys.argv[1:]))
183
+ except Exception as exc: # an instrument crash is never a pass
184
+ print("HARNESS-ERROR: %s: %s" % (type(exc).__name__, exc), file=sys.stderr)
185
+ sys.exit(10)
@@ -17,7 +17,7 @@
17
17
  🟥 구조 술어만 쓴다 — FH 고유 어휘(마커·4축·영혼)를 넣지 않는다. 그래야 남의 레포에도 돈다.
18
18
  """
19
19
  from __future__ import annotations
20
- import os, re, sys, json, argparse
20
+ import os, re, sys, json, argparse, subprocess
21
21
  from typing import Dict, List, Tuple
22
22
 
23
23
  DOC_EXT = {".md"}
@@ -56,14 +56,53 @@ def _inside(root: str, path: str) -> bool:
56
56
  return c == r or c.startswith(r + os.sep)
57
57
 
58
58
 
59
+ _TRACKED_CACHE: dict = {}
60
+ _INVENTORY_FAILED = "INVENTORY-FAILED"
61
+
62
+
63
+ def _tracked(root: str):
64
+ """git 저장소면 추적된 파일의 실경로 집합(frozenset), git 밖이면 None, git 인데 목록을 못 얻으면 _INVENTORY_FAILED.
65
+ 🟥 2026-10-20: 이름 대체 찾기가 os.walk 로 트리 «전체» 를 훑어서, 저자 머신의 미추적 실험 폴더(tracks/_meta/claude200 안 복제본
66
+ 10개)가 known-pair 대상의 이름을 겹치게 만들었다 → 보정이 «대상이 실재하지 않는다» 로 거짓 실패(깨끗한 복제본은 통과).
67
+ 반대로 미추적 파일 하나가 사라진 대상을 «있다» 로 만들 수도 있다(되돌림 레인 L9 B 에서 실측).
68
+ 🟥 codex 1라운드: git 이 실패하면 «git 밖» 으로 떨어져 옛 동작이 돌아오면 안 된다 — «git 밖» 은 rev-parse 가 그렇다고 말할 때만,
69
+ 그 밖의 실패는 _INVENTORY_FAILED(resolve 가 아무것도 못 찾는 닫힌 쪽). 서브모듈 안 파일도 포함(--recurse-submodules),
70
+ 충돌 단계 중복은 한 번만(--deduplicate), 실경로 집합은 루트마다 한 번만 계산."""
71
+ if root in _TRACKED_CACHE:
72
+ return _TRACKED_CACHE[root]
73
+ env = {k: v for k, v in os.environ.items() if not k.startswith("GIT_")}
74
+ out = _INVENTORY_FAILED
75
+ try:
76
+ top = subprocess.run(["git", "-C", root, "rev-parse", "--show-toplevel"], capture_output=True, env=env, timeout=10)
77
+ if top.returncode != 0:
78
+ msg = top.stderr.decode("utf-8", "replace").lower()
79
+ out = None if "not a git repository" in msg else _INVENTORY_FAILED
80
+ else:
81
+ t = top.stdout.decode("utf-8", "surrogateescape").strip()
82
+ r = subprocess.run(["git", "-C", t, "-c", "core.fsmonitor=false", "ls-files", "-z", "--full-name",
83
+ "--recurse-submodules", "--deduplicate"], capture_output=True, env=env, timeout=30)
84
+ if r.returncode == 0:
85
+ out = frozenset(os.path.realpath(os.path.join(t, x.decode("utf-8", "surrogateescape")))
86
+ for x in r.stdout.split(b"\0") if x)
87
+ except (OSError, subprocess.SubprocessError):
88
+ out = _INVENTORY_FAILED
89
+ _TRACKED_CACHE[root] = out
90
+ return out
91
+
92
+
59
93
  def resolve(root: str, p: str) -> str | None:
60
94
  # `..` 를 담은 참조는 «해석하기 전에» 거절한다 — 해석 후 판정은 심링크 한 겹에 뚫린다.
61
95
  cand = os.path.join(root, p)
62
- if os.path.isfile(cand) and not os.path.islink(cand) and _inside(root, cand):
96
+ tracked = _tracked(root)
97
+ if tracked == _INVENTORY_FAILED:
98
+ return None # git 인데 목록을 못 얻었다 — 못 찾은 것으로(닫힌 쪽), 옛 전체 훑기로 안 떨어진다
99
+ if os.path.isfile(cand) and not os.path.islink(cand) and _inside(root, cand) \
100
+ and (tracked is None or os.path.realpath(cand) in tracked):
63
101
  return cand
64
102
  base = os.path.basename(p)
65
- hits = [f for f in walk(root)
66
- if os.path.basename(f) == base and not os.path.islink(f) and _inside(root, f)]
103
+ pool = sorted(tracked) if tracked is not None else walk(root) # git 이면 추적 파일만, 아니면 종전처럼 트리 전체
104
+ hits = [f for f in pool
105
+ if os.path.basename(f) == base and os.path.isfile(f) and not os.path.islink(f) and _inside(root, f)]
67
106
  return hits[0] if len(hits) == 1 else None
68
107
 
69
108
  # 실행 증거: 인터프리터 뒤 또는 명령 위치. 주석줄과 grep 패턴 안은 제외.
@@ -30,6 +30,37 @@
30
30
  # FH_RECORD_BASE=<p> directory for governance_log YAML (default: FH_ROOT/tracks/_meta)
31
31
 
32
32
  set -euo pipefail
33
+ # Unexpected failure → HARNESS_ERROR (10), never PENDING (1). Under `set -e` a command that fails where
34
+ # nobody expected it ends the script with that command's status — usually 1, which the contract reads as
35
+ # PENDING ("proceed with awareness"). MEASURED 2026-10-20: `TMPDIR=/nonexistent` made `mktemp` fail and
36
+ # the gate exited 1 (also through bin/fh-gate.js). Every intended outcome leaves through an explicit
37
+ # `exit N`, which does not fire ERR. A failing `X=$(cmd)` at top level still fires it.
38
+ # 🟥 NOT `set -E`: errtrace carries the trap INTO command substitutions, where it ignores the caller's
39
+ # `|| rc=$?`. Measured on the first draft: the cross-mode leg capture `_legout=$(…) || _legrc=$?` got
40
+ # 10 instead of the leg's 2, and one lane folded a BLOCKED leg into a PASS union. The regression suite
41
+ # (`cross: one leg BLOCKED → union BLOCKED`) is the anchor for this line.
42
+ # 10 is written as a literal because EXIT_HARNESS_ERROR is defined further down.
43
+ trap 'echo "ERROR: fh-gate: unexpected failure at line $LINENO (status $?) — failing closed as HARNESS_ERROR." >&2 || :; exit 10' ERR
44
+ # The ERR trap does not see every unexpected end: an unbound variable under `set -u` exits 1 without
45
+ # firing ERR, and so does a failure inside a function called from the EXIT trap (cross-family review,
46
+ # 2026-10-20 — `cleanup(){ false; }; trap cleanup EXIT; exit 2` returned 1). So the exit itself is the
47
+ # second check: a status of 0-3 is a verdict, and a verdict may only leave through a line that set
48
+ # _FH_VERDICT_EXIT=1 first (--version, --help, the cross union, the final verdict). Anything else that
49
+ # ends with 0-3 is reported as HARNESS_ERROR. Cleanup runs here too, and its own failure cannot change
50
+ # the status. Every message on these paths is `|| :` — with stderr closed a failing echo would otherwise
51
+ # end the handler before its `exit 10` (cross-family review round 2: `--invalid 2>&-` returned 1).
52
+ _FH_VERDICT_EXIT=0
53
+ _FH_CLEANUP=0
54
+ _fh_on_exit() {
55
+ local rc=$?
56
+ if [ "$_FH_CLEANUP" = 1 ]; then cleanup 2>/dev/null || true; fi
57
+ if [ "$rc" -le 3 ] && [ "$_FH_VERDICT_EXIT" != 1 ]; then
58
+ echo "ERROR: fh-gate: ended with status $rc without reaching a verdict — failing closed as HARNESS_ERROR." >&2 || :
59
+ exit 10
60
+ fi
61
+ exit "$rc"
62
+ }
63
+ trap _fh_on_exit EXIT
33
64
 
34
65
  FH_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
35
66
  # Single source of truth: read version from the package.json shipped alongside this script.
@@ -76,7 +107,7 @@ EXIT_DRY_RUN=12
76
107
  case "${1:-}" in
77
108
  --version|-V)
78
109
  printf '%s\n' "fh-gate $VERSION"
79
- exit 0
110
+ _FH_VERDICT_EXIT=1; exit 0
80
111
  ;;
81
112
  --help|-h)
82
113
  printf '%s\n' "fh-gate $VERSION — FH governance gate"
@@ -110,7 +141,7 @@ case "${1:-}" in
110
141
  printf '%s\n' " FH_VERBOSE=1 print full backend stderr"
111
142
  printf '%s\n' ""
112
143
  printf '%s\n' " https://github.com/chrono-meta/forge-harness"
113
- exit 0
144
+ _FH_VERDICT_EXIT=1; exit 0
114
145
  ;;
115
146
  -*)
116
147
  printf '%s\n' "ERROR: unrecognized option '${1}'." >&2
@@ -153,7 +184,8 @@ esac
153
184
  # `cross` is a REQUEST, not a guarantee — a machine may have only one family installed. When a leg is
154
185
  # unavailable or errors, this degrades to the surviving leg and SAYS SO, loudly, in both the human and
155
186
  # the machine-readable output. A single-leg result that reads as if it were cross-checked is the same
156
- # class of defect as a check that did not run reading as PASS.
187
+ # class of defect as a check that did not run reading as PASS. Since 2026-10-22 the EXIT CODE says so too:
188
+ # a single-leg PASS/PENDING leaves as ESCALATE (3) unless FH_GATE_CROSS_ALLOW_SINGLE=1 (see below).
157
189
  #
158
190
  # COST: cross is ~2x. It is deliberately NOT a default — [[feedback_decorrelation_not_fanout_cost_boundary]]
159
191
  # says match the parallelisation axis to the failure mode rather than multiply. Callers should request
@@ -171,6 +203,15 @@ if [[ "$FH_BACKEND" == "cross" ]]; then
171
203
  # without letting it abort. Verified against a BLOCKED leg, not assumed.
172
204
  _legrc=0
173
205
  _legout=$(FH_BACKEND="$_leg" "$0" "$@" 2>/dev/null) || _legrc=$?
206
+ # 11 (argument error) and 12 (dry-run) are not a leg failing — every leg gets the same arguments, so
207
+ # every leg would say the same. Pass them through instead of folding them into "harness error 10"
208
+ # (found 2026-10-20 by a local-model self-audit candidate, reproduced: cross + bad level → 10, not 11;
209
+ # cross + FH_DRY_RUN=1 → 10 and the prompt was lost). A dry-run leg's stdout IS the prompt — print it.
210
+ if [ "$_legrc" -eq "$EXIT_ARG_ERROR" ] || [ "$_legrc" -eq "$EXIT_DRY_RUN" ]; then
211
+ [ "$_legrc" -eq "$EXIT_DRY_RUN" ] && printf '%s\n' "$_legout"
212
+ echo "→ fh-gate: cross mode — leg $_leg exited $_legrc (same arguments for every leg); passing it through" >&2 || :
213
+ exit "$_legrc"
214
+ fi
174
215
  if [ "$_legrc" -ge 10 ]; then
175
216
  _CROSS_ERR="${_CROSS_ERR}${_CROSS_ERR:+, }$_leg (harness error $_legrc)"; continue
176
217
  fi
@@ -189,22 +230,40 @@ $(printf '%s' "$_legout" | sed -n '/^---$/,$p')"
189
230
  exit $EXIT_HARNESS_ERROR
190
231
  fi
191
232
 
233
+ # 🟥 A single-leg PASS/PENDING used to leave with 0/1 — the codes a two-family run gives — so a caller reading
234
+ # only the exit code could not tell «cross-checked» from «one family alone» (2026-10-22, LLM call-site inventory).
235
+ # Cross was requested and could not be provided: that goes to a person (ESCALATE), unless the caller says
236
+ # exactly FH_GATE_CROSS_ALLOW_SINGLE=1, which is echoed into the output. BLOCKED/ESCALATE already stop.
237
+ _CROSS_FINAL="$_CROSS_WORST"; _CROSS_OVERRIDE=""
238
+ if [ "$_CROSS_RAN" -lt 2 ] && [ "$(_sev_rank "$_CROSS_WORST")" -lt "$(_sev_rank ESCALATE)" ]; then
239
+ if [ "${FH_GATE_CROSS_ALLOW_SINGLE:-}" = "1" ]; then
240
+ _CROSS_OVERRIDE=1
241
+ else
242
+ _CROSS_FINAL="ESCALATE"
243
+ fi
244
+ fi
192
245
  printf 'FH_STATUS: SUCCESS\n'
193
- printf 'FH_GATE_VERDICT: %s\n' "$_CROSS_WORST"
246
+ printf 'FH_GATE_VERDICT: %s\n' "$_CROSS_FINAL"
194
247
  printf 'FH_GATE_MODE: cross\n'
195
248
  printf 'FH_GATE_LEGS: %s\n' "$_CROSS_LEGS"
196
249
  if [ "$_CROSS_RAN" -lt 2 ]; then
197
250
  # Degraded, and it must be impossible to mistake this for a two-family result.
198
251
  printf 'FH_GATE_DECORRELATED: no\n'
199
252
  printf 'FH_GATE_DEGRADED: %s\n' "$_CROSS_ERR"
253
+ if [ "$_CROSS_FINAL" != "$_CROSS_WORST" ]; then
254
+ printf 'FH_GATE_ESCALATE_REASON: cross-degraded (single leg %s said %s; set FH_GATE_CROSS_ALLOW_SINGLE=1 to accept one family)\n' "$_CROSS_LEGS" "$_CROSS_WORST"
255
+ elif [ -n "$_CROSS_OVERRIDE" ]; then
256
+ printf 'FH_GATE_CROSS_OVERRIDE: FH_GATE_CROSS_ALLOW_SINGLE=1 (single leg %s accepted as %s)\n' "$_CROSS_LEGS" "$_CROSS_WORST"
257
+ fi
200
258
  echo "WARN: FH_BACKEND=cross ran a SINGLE leg ($_CROSS_LEGS) — $_CROSS_ERR." >&2
201
259
  echo " This verdict is NOT decorrelated. Treat it as $_CROSS_LEGS alone." >&2
202
260
  else
203
261
  printf 'FH_GATE_DECORRELATED: yes\n'
204
262
  fi
205
263
  printf '%s\n' "$_CROSS_OUT"
206
- echo "→ fh-gate: cross mode — legs [$_CROSS_LEGS], union verdict $_CROSS_WORST" >&2
207
- case "$_CROSS_WORST" in
264
+ echo "→ fh-gate: cross mode — legs [$_CROSS_LEGS], union verdict $_CROSS_WORST, final $_CROSS_FINAL" >&2 || :
265
+ _FH_VERDICT_EXIT=1
266
+ case "$_CROSS_FINAL" in
208
267
  PASS) exit $EXIT_PASS ;;
209
268
  PENDING) exit $EXIT_PENDING ;;
210
269
  BLOCKED) exit $EXIT_BLOCKED ;;
@@ -436,7 +495,7 @@ else
436
495
  fi
437
496
 
438
497
  cleanup() { rm -f "$PROMPT_FILE" "$OUTPUT_FILE" "$ERR_FILE" "$PARSE_FILE" "$SCHEMA_FILE" "$CODEX_LAST"; }
439
- trap cleanup EXIT
498
+ _FH_CLEANUP=1 # _fh_on_exit (top of file) calls cleanup from here on
440
499
 
441
500
  # --- Build prompt ---
442
501
  cat > "$PROMPT_FILE" <<PROMPT
@@ -764,11 +823,12 @@ FINDINGS_N_LOG=$(grep -m 1 "^FH_FINDINGS_COUNT:" "$PARSE_FILE" 2>/dev/null | awk
764
823
  } >> "$RECORD_PATH" || echo "WARN: governance log write failed: $RECORD_PATH" >&2
765
824
 
766
825
  # Exit code
826
+ _FH_VERDICT_EXIT=1
767
827
  case "$VERDICT" in
768
- PASS) echo "→ verdict: PASS" >&2; exit $EXIT_PASS ;;
769
- PENDING) echo "→ verdict: PENDING" >&2; exit $EXIT_PENDING ;;
770
- BLOCKED) echo "→ verdict: BLOCKED" >&2; exit $EXIT_BLOCKED ;;
771
- ESCALATE) echo "→ verdict: ESCALATE" >&2; exit $EXIT_ESCALATE ;;
828
+ PASS) echo "→ verdict: PASS" >&2 || :; exit $EXIT_PASS ;;
829
+ PENDING) echo "→ verdict: PENDING" >&2 || :; exit $EXIT_PENDING ;;
830
+ BLOCKED) echo "→ verdict: BLOCKED" >&2 || :; exit $EXIT_BLOCKED ;;
831
+ ESCALATE) echo "→ verdict: ESCALATE" >&2 || :; exit $EXIT_ESCALATE ;;
772
832
  *)
773
833
  echo "ERROR: unrecognized verdict '${VERDICT:-EMPTY}' — harness error, failing safe (commit not allowed)" >&2
774
834
  exit $EXIT_HARNESS_ERROR
@@ -142,7 +142,7 @@ with open(sys.argv[2], "w", encoding="utf-8") as w:
142
142
  eval "$cmd" < "$pf" > "$raw" 2>"$out/err2_${fam}_${role}.txt"
143
143
  local rc=$?
144
144
  FAM="$fam" ROLE="$role" RC="$rc" /usr/bin/python3 - "$raw" "$out/part2_${fam}_${role}.jsonl" "$out/findings_r1.jsonl" <<'PYR2'
145
- import json, os, sys
145
+ import json, os, re, sys
146
146
  own_r1 = {} # own round-1 id -> its trusted member_id alias (or None)
147
147
  try:
148
148
  for _l in open(sys.argv[3], encoding="utf-8"):
@@ -186,9 +186,21 @@ with open(dst, "w", encoding="utf-8") as w:
186
186
  line = line.strip().lstrip("\ufeff")
187
187
  if line.startswith("DROPPED:"):
188
188
  _body = line[len("DROPPED:"):]
189
+ # 🟥 A DROPPED line withdraws ONE finding: the one its body STARTS with (id or title, the longest that
190
+ # fits, followed by a non-[A-Za-z0-9_-] char or the end). Searching the whole line used to withdraw
191
+ # every finding merely named in it — «codex-logic-10» took «codex-logic-1», title «Q10» took «Q1»,
192
+ # «… Race condition remains valid» took «Race condition» — and the silently omitted finding then
193
+ # counted as accounted for, so no fallback ran (L125–L127, 2026-10-22, codex R1). An unrecognised
194
+ # withdrawal falls back to round 1 (the safe side). ASCII boundary so «codex-logic-1은» still counts.
195
+ _head = _body.strip().lstrip("\"'`*#([ ").strip()
196
+ _best = None
189
197
  for _id, _t in own_r1_titles.items():
190
- if _id in _body or (_t and _t in _body):
191
- withdrawn_ids.add(_id)
198
+ for _ref in (_id, _t):
199
+ if _ref and _head.startswith(_ref) and not re.match(r"[A-Za-z0-9_-]", _head[len(_ref):len(_ref) + 1]):
200
+ if _best is None or len(_ref) > len(_best[1]):
201
+ _best = (_id, _ref)
202
+ if _best:
203
+ withdrawn_ids.add(_best[0])
192
204
  # 🟥 saw_bytes 를 여기서 «올리지 않는다». DROPPED 는 2차 계약이 요구한 출력이므로
193
205
  # 「계약 밖 응답」의 증거가 될 수 없다 (cross-family #5, codex 2026-09-10).
194
206
  # 🟥 "DROPPED: none" 은 삭제가 아니다. 세면 «숨은 수확 손실» 계측이 그 자리에서 거짓이 된다.
@@ -39,6 +39,11 @@ cd "$REPO_ROOT" || exit 1
39
39
  # scripts/sync_to_be_lanes.sh — forward-path lane suite for sync-to-be.sh, itself
40
40
  # ACCEPTED_ABSENT above; added 2026-08-14, pmh-dev#69.
41
41
  ACCEPTED_ABSENT=(
42
+ # 2026-10-19 — cartridge admission checker and its lanes. Not shipped yet on purpose: publishing cartridges
43
+ # (fh-cartridges) is an open operator decision, and shipping the checker would put it in the next npm
44
+ # release by default. selfcheck resolves its row as SKIP («not in files[], and absent») on a consumer tree.
45
+ "scripts/cartridge_admit.py"
46
+ "scripts/test_cartridge_admit_lanes.sh"
42
47
  # 🟥 2026-09-21 (야간) — 정책렌즈 채점기와 그 레인. **FH 자기 연구의 실험 기록**이지 소비자
43
48
  # 능력이 아니다: 판정 대상이 `scripts/fixtures/policy_lens_knownpair_2026-09-21/` 안의
44
49
  # 1차 런 48개 파일(236K)이고, 그것까지 실어 보내면 아무도 안 쓰는 실험 아카이브가 패키지
@@ -964,6 +964,42 @@ fi
964
964
  # script ships — both, and this anchor, are declared in package_coverage_check.sh ACCEPTED_ABSENT.
965
965
  # On a consumer install the SUBJECT arm fires first and `_ships_per_files` returns 1, so the row
966
966
  # resolves to "SKIP (subject not in files[], and absent)" — the anchor arm is never reached.
967
+ # Verdict for one subject|anchor suite's exit code. A function (2026-10-19) so the lane
968
+ # test_selfcheck_state_lanes.sh can call THIS code rather than a re-spelled copy. rc 0 = pass.
969
+ # 124 got its own arm because `timeout` kills silently: on 2026-10-18 a full local run ended
970
+ # `SELFCHECK: FAIL` with no FAIL line in 6,236 lines — the killed suite fell into a bare `*)`
971
+ # that set fail and printed nothing (fh_signal_2026-10-18_selfcheck-timeout-unlabelled). The
972
+ # catch-all now names the suite and its rc, so no exit code can fail without a line.
973
+ _pair_rc_verdict() { # $1=label $2=subject $3=rc · return 1 = counts as a failure
974
+ local _lbl="$1" _subj="$2" _rc="$3"
975
+ case "$_rc" in
976
+ 0) ;;
977
+ # The suite could not MEASURE. Distinguished from "the lane failed" because the two send a
978
+ # reader to different places, and a bare fail=1 sends them to the wrong one. 10 = the suite's
979
+ # own setup failed (mktemp, used by several of these); 2 = its subject was missing when it
980
+ # looked (test_knowledge_seam_lanes.sh:7 FATALs this way); 126/127 = the anchor is not
981
+ # executable or not found at all, i.e. a broken install that reached this arm anyway.
982
+ # Every one of them still sets fail — a harness that could not measure did not pass — but it
983
+ # is LABELLED, so the next reader debugs the instrument instead of the lane.
984
+ # The first draft of this loop routed only 10 and let everything else fall into an unlabelled
985
+ # fail=1. That is the same "assumed impossible rather than routed" shape that the sibling
986
+ # commit in lane_runner_check.sh had just written a paragraph against; adversarial review
987
+ # caught the inconsistency between the two files.
988
+ 10|2|126|127)
989
+ echo "HARNESS ERROR $_lbl: the suite exited $_rc — it could not measure, so its verdicts"
990
+ echo " prove nothing about $_subj. Not a lane failure, and not a pass either."
991
+ return 1 ;;
992
+ 124)
993
+ echo "TIMEOUT $_lbl: exited 124, the code \`timeout\` uses when it kills a suite (limit 300 s) —"
994
+ echo " not measured, not a pass. A suite that itself exits 124 lands here too."
995
+ echo " Re-run that suite alone to see whether it hangs or is only slow under load."
996
+ return 1 ;;
997
+ *)
998
+ echo "FAIL $_lbl (rc=$_rc) — see that suite's output above; subject: $_subj"
999
+ return 1 ;;
1000
+ esac
1001
+ return 0
1002
+ }
967
1003
  _LANE_TO=""; command -v timeout >/dev/null 2>&1 && _LANE_TO="timeout 300"
968
1004
  for _pair in \
969
1005
  `# 사용 원장 (2026-09-13 신설). SUBJECT 를 원장 모듈로 잡는다 — 배선이 끊기는 자리는 preprep.py 의 __main__ 한 줄이 아니라 모듈이 사라지는 쪽이고, import 가 try/except 라 모듈이 없으면 조용히 무동작으로 돌아간다. 그 무음이 이 레인이 잡을 것이다.` \
@@ -1015,6 +1051,7 @@ for _pair in \
1015
1051
  "scripts/sim_isolated_run.sh|scripts/test_sim_path_isolation_lanes.sh" \
1016
1052
  `# ── mutation_probe (2026-10-07) — revert_probe 의 «저자가 고른 변이 1개» 를 연산자 생성 변이로 넓힌 것. 앵커가 고정하는 것은 생성기 보정(리다이렉트 비변이)과 «못 잰 것은 2» 다 ──` \
1017
1053
  "scripts/mutation_probe.py|scripts/test_mutation_probe_lanes.sh" \
1054
+ "scripts/cartridge_admit.py|scripts/test_cartridge_admit_lanes.sh" \
1018
1055
  `# ── live-eval — the live twin of the static /prompt-regression probe check (2026-09-04) ──` \
1019
1056
  "scripts/probe_live_eval.sh|scripts/test_probe_live_eval_lanes.sh" \
1020
1057
  "scripts/probe_live_eval_lib.py|scripts/test_probe_live_eval_lanes.sh" \
@@ -1096,7 +1133,9 @@ for _pair in \
1096
1133
  `# ── 가벼운 게이트 P1·P2(2026-10-12): 비주제 레인의 gh·①-g 스텁 + 켠/끈 비교기 ──` \
1097
1134
  "scripts/lane_stub_env.sh|scripts/test_lane_stub_env_lanes.sh" \
1098
1135
  "scripts/lane_stub_env.allow|scripts/test_lane_stub_env_lanes.sh" \
1099
- "scripts/lane_onoff_compare.py|scripts/test_lane_stub_env_lanes.sh"
1136
+ "scripts/lane_onoff_compare.py|scripts/test_lane_stub_env_lanes.sh" \
1137
+ `# ── 위임 마감 영수증(2026-10-20): 에이전트가 «고쳤다» 고 한 것을 거버너가 저장소에서 잰다(보고 ≠ 변경) ──` \
1138
+ "scripts/dispatch_receipt.py|scripts/test_dispatch_receipt_lanes.sh"
1100
1139
  do
1101
1140
  _subj="${_pair%%|*}"; _anc="${_pair##*|}"; _lbl="${_anc##*/}"
1102
1141
  if [ ! -f "$_subj" ]; then
@@ -1113,25 +1152,7 @@ do
1113
1152
  # a substitute; without it `< /dev/null` is the whole defence and a suite that reads stdin ends
1114
1153
  # immediately instead of waiting forever.
1115
1154
  $_LANE_TO bash "$_anc" < /dev/null; _rc=$?
1116
- case "$_rc" in
1117
- 0) ;;
1118
- # The suite could not MEASURE. Distinguished from "the lane failed" because the two send a
1119
- # reader to different places, and a bare fail=1 sends them to the wrong one. 10 = the suite's
1120
- # own setup failed (mktemp, used by several of these); 2 = its subject was missing when it
1121
- # looked (test_knowledge_seam_lanes.sh:7 FATALs this way); 126/127 = the anchor is not
1122
- # executable or not found at all, i.e. a broken install that reached this arm anyway.
1123
- # Every one of them still sets fail — a harness that could not measure did not pass — but it
1124
- # is LABELLED, so the next reader debugs the instrument instead of the lane.
1125
- # The first draft of this loop routed only 10 and let everything else fall into an unlabelled
1126
- # fail=1. That is the same "assumed impossible rather than routed" shape that the sibling
1127
- # commit in lane_runner_check.sh had just written a paragraph against; adversarial review
1128
- # caught the inconsistency between the two files.
1129
- 10|2|126|127)
1130
- echo "HARNESS ERROR $_lbl: the suite exited $_rc — it could not measure, so its verdicts"
1131
- echo " prove nothing about $_subj. Not a lane failure, and not a pass either."
1132
- fail=1 ;;
1133
- *) fail=1 ;;
1134
- esac
1155
+ _pair_rc_verdict "$_lbl" "$_subj" "$_rc" || fail=1
1135
1156
  elif _pkg_accepted_absent "$_anc"; then
1136
1157
  # DECLARED legitimately unshipped — the single source for that answer, not a guess from the
1137
1158
  # environment. The first draft printed "this package predates it", which is a WRONG DIAGNOSIS