@chrono-meta/fh-gate 3.28.0 → 3.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/.claude-plugin/marketplace.json +4 -4
  2. package/AGENTS.md +7 -2
  3. package/CHEATSHEET.md +2 -2
  4. package/CLAUDE.md +5 -2
  5. package/docs/REFERENCE.md +4 -1
  6. package/knowledge/shared/harness-core/claude_md_full_reference.md +2 -0
  7. package/knowledge/shared/harness-core/claude_md_gate_details.md +8 -1
  8. package/knowledge/shared/harness-core/dispatch_conditional_prohibition.md +12 -0
  9. package/knowledge/shared/harness-core/fh_three_layer_canon.md +12 -0
  10. package/knowledge/shared/harness-core/measurement-integrity-checklist.md +16 -0
  11. package/knowledge/shared/learnings/subagent_invocations_log.yaml +161 -0
  12. package/package.json +4 -1
  13. package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
  14. package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
  15. package/plugins/fh-meta/CHANGELOG.md +41 -0
  16. package/plugins/fh-meta/skills/auto-decorrelation/SKILL.md +17 -0
  17. package/plugins/fh-meta/skills/phantom-quench/SKILL.md +1 -1
  18. package/plugins/fh-meta/skills/sim-conductor/SKILL.md +2 -2
  19. package/plugins/fh-meta/skills/sim-conductor/SKILL_detail.md +3 -3
  20. package/plugins/fh-meta/skills/steel-quench/SKILL.md +25 -1
  21. package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
  22. package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
  23. package/scripts/degrade_direction_scan.sh +43 -0
  24. package/scripts/dispatch_receipt.py +185 -0
  25. package/scripts/doc_claim_triad_scan.py +43 -4
  26. package/scripts/fh-gate.sh +71 -11
  27. package/scripts/finding_fleet.sh +15 -3
  28. package/scripts/mapped_tracks.sh +20 -13
  29. package/scripts/memory_gc_report.py +55 -5
  30. package/scripts/package_coverage_check.sh +5 -0
  31. package/scripts/pr_merge_verified.sh +56 -8
  32. package/scripts/selfcheck.sh +43 -20
  33. package/scripts/session_checklist.py +158 -14
  34. package/scripts/session_close_check.sh +1 -1
  35. package/scripts/sim_isolated_run.sh +62 -0
  36. package/scripts/stale_ref_scan.py +47 -3
  37. package/scripts/test_degrade_scan_shell_probes.sh +81 -0
  38. package/scripts/test_dispatch_receipt_lanes.sh +95 -0
  39. package/scripts/test_doc_claim_triad_lanes.sh +30 -0
  40. package/scripts/test_fh_audit_check_lanes.sh +10 -5
  41. package/scripts/test_fh_gate_regressions.sh +71 -1
  42. package/scripts/test_finding_pipeline_lanes.sh +83 -0
  43. package/scripts/test_hook_source_gate_lanes.sh +16 -2
  44. package/scripts/test_locale_invariance_lanes.sh +19 -0
  45. package/scripts/test_mapped_tracks_lanes.sh +55 -1
  46. package/scripts/test_memory_gc_report_lanes.sh +91 -1
  47. package/scripts/test_mutation_probe_lanes.sh +40 -8
  48. package/scripts/test_pr_merge_verified_lanes.sh +48 -1
  49. package/scripts/test_prepush_real_fire_lanes.sh +215 -0
  50. package/scripts/test_selfcheck_state_lanes.sh +32 -0
  51. package/scripts/test_session_checklist_lanes.sh +172 -0
  52. package/scripts/test_sim_isolated_run_lanes.sh +88 -0
  53. package/scripts/test_stale_ref_scan_lanes.sh +11 -1
  54. package/templates/.git-hooks/pre-push +82 -1
  55. package/templates/PRE-PUBLISH-CHECKLIST.md +10 -0
  56. package/templates/degrade_direction_scan.sh +43 -0
@@ -14,6 +14,11 @@ WHAT: reads every topic file's frontmatter and the index, and reports
14
14
  · every entry — status, type, age (from `metadata.hits`), distinct days, last hit, index line
15
15
  · cold — non-user, age 1, last hit ≥ --cold-days ago → drop from the INDEX only
16
16
  · promote — age ≥ --promote-age across ≥ 2 distinct days → propose a rule/hook (human approves)
17
+ — only when the body cites at least one evidence anchor; otherwise «promote held»
18
+ · unanchored — feedback/project entries whose body cites no evidence anchor (commit sha · #PR/issue ·
19
+ file path · arXiv id · URL). harness2 (google-research, 2026-10) stores a lesson only with
20
+ a cited run contrast; this is the record-property half of that: present or not, never
21
+ whether the cited thing proves the lesson (judgment stays judgment).
17
22
  · order — user entries in index order, then valid measured entries by age (ties: index
18
23
  order), then the rest in index order; cold entries leave the order. Entries with an
19
24
  error status never drive cold / promote / measured ranking until repaired
@@ -36,6 +41,35 @@ exit: 0 report printed · 2 memory dir or index unreadable (instrument error, ne
36
41
  """
37
42
  import argparse, datetime as dt, json, os, re, sys, urllib.parse
38
43
 
44
+ # Evidence anchors a lesson can cite. A date alone is not an anchor (it says when, not what was measured).
45
+ # Presence is what is reported, never how many (one anchor is enough; double matches do not matter).
46
+ # NOT anchors, by design: [[wiki-links]] to other memories (a relation, not an artifact), bare dates.
47
+ # Round-1/2 review (codex · Gemini Flash, 2026-10-23) set these edges. Stopped at the round cap: a static string
48
+ # matcher does not converge (each round finds new edges) — residuals are listed in the lanes file, not chased.
49
+ _EXT = (r'md|sh|py|js|mjs|cjs|ts|tsx|jsx|json|ya?ml|toml|txt|plist|html|css|rs|go|rb|java|kt|swift|c|h|cpp|hpp|'
50
+ r'sql|lock|cfg|ini|env|xml|csv|ipynb')
51
+ ANCHOR_RES = [
52
+ # commit sha: hex mixing letters and digits, any case, not part of a #colour, UUID or longer word
53
+ re.compile(r'(?<![#\w-])(?=[0-9a-fA-F]*[0-9])(?=[0-9a-fA-F]*[a-fA-F])[0-9a-fA-F]{7,40}(?![\w-])'),
54
+ # commit sha named as such: then all-digit / all-letter hex counts too («commit 1234567», «커밋 deadbeef»)
55
+ re.compile(r'(?:commit|sha|커밋)\s*[:#]?\s*`?[0-9a-fA-F]{7,40}(?![\w-])', re.I),
56
+ # PR / issue: #N (not &#39; entities, not #section-slugs, not «#123456;» CSS) and owner/repo#N
57
+ re.compile(r'(?<![\w&#(])#\d+(?![\w;-])'), # not «(#2)» — a link to a section of the same document
58
+ re.compile(r'[\w.-]+/[\w.-]+#\d+\b'),
59
+ # file path (case-insensitive extension) and the usual extensionless build files
60
+ re.compile(r'[\w./~-]+\.(?:' + _EXT + r')\b', re.I),
61
+ re.compile(r'\b(?:Dockerfile|Makefile|Gemfile|Procfile)\b'),
62
+ re.compile(r'arXiv[: ]?(?:\d{4}\.\d{4,5}|[a-z-]+(?:\.[A-Z]{2})?/\d{7})', re.I), # arXiv id (new and legacy)
63
+ re.compile(r'https?://\S+')] # URL
64
+
65
+
66
+ _WIKI = re.compile(r'\[\[[^\]]*\]\]')
67
+
68
+
69
+ def count_anchors(text):
70
+ text = _WIKI.sub(' ', text) # [[x]] / [[x.md]] is a relation to another memory, never an anchor
71
+ return sum(len(r.findall(text)) for r in ANCHOR_RES) # URL
72
+
39
73
  def link_dests(line):
40
74
  """Markdown inline-link destinations with their start offset: <...> form, balanced parens, title dropped."""
41
75
  out, i = [], 0
@@ -76,7 +110,7 @@ def indent(line):
76
110
 
77
111
  def parse_entry(path, today):
78
112
  """-> dict(status, type, hits[(date,str)], bad[str])"""
79
- out = {'status': 'OK', 'type': None, 'hits': [], 'bad': []}
113
+ out = {'status': 'OK', 'type': None, 'hits': [], 'bad': [], 'anchors': 0}
80
114
  try:
81
115
  text = open(path, encoding='utf-8').read()
82
116
  except (OSError, UnicodeDecodeError) as e:
@@ -88,11 +122,13 @@ def parse_entry(path, today):
88
122
  out['status'] = 'NO_FRONTMATTER'
89
123
  return out
90
124
  try:
91
- end = next(i for i in range(1, len(lines)) if lines[i].strip() == '---')
125
+ end = next(i for i in range(1, len(lines)) if lines[i].rstrip() == '---')
92
126
  except StopIteration:
93
127
  out['status'] = 'UNTERMINATED_FRONTMATTER'
94
128
  return out
95
129
  fm = lines[1:end]
130
+ body = "\n".join(lines[end + 1:])
131
+ out['anchors'] = count_anchors(body)
96
132
  meta_i = next((i for i, l in enumerate(fm) if indent(l) == 0 and re.match(r'^metadata:\s*$', l)), None)
97
133
  if meta_i is None:
98
134
  return out
@@ -143,6 +179,7 @@ def parse_entry(path, today):
143
179
  out['hits'].append((d.isoformat(), m.group(2)))
144
180
  if out['bad'] and out['status'] == 'OK':
145
181
  out['status'] = 'HITS_MALFORMED'
182
+ out['anchors'] += count_anchors("\n".join(t for _, t in out['hits'])) # a hit line may cite the evidence
146
183
  return out
147
184
 
148
185
 
@@ -199,7 +236,7 @@ def main():
199
236
  entries = []
200
237
  for n in names:
201
238
  p = parse_entry(os.path.join(a.memory_dir, n), today)
202
- e = {'file': n, 'status': p['status'], 'type': p['type'], 'bad': p['bad'],
239
+ e = {'file': n, 'status': p['status'], 'type': p['type'], 'bad': p['bad'], 'anchors': p['anchors'],
203
240
  'index_line': pos.get(n, {}).get('line'), 'index_ord': pos.get(n, {}).get('ord'),
204
241
  'past_cap': pos.get(n, {}).get('past_cap', False)}
205
242
  if p['hits']:
@@ -215,8 +252,11 @@ def main():
215
252
  ok = lambda e: e['status'] == 'OK'
216
253
  cold = [e for e in entries if ok(e) and e['type'] != 'user' and e['age'] == 1
217
254
  and days_since(e['last_hit']) >= a.cold_days]
218
- promote = [e for e in entries if ok(e) and e['age'] is not None and e['age'] >= a.promote_age
219
- and e['distinct_days'] >= 2]
255
+ due = [e for e in entries if ok(e) and e['age'] is not None and e['age'] >= a.promote_age
256
+ and e['distinct_days'] >= 2]
257
+ promote = [e for e in due if e['anchors'] > 0]
258
+ promote_held = [e for e in due if e['anchors'] == 0] # recurring, but cites nothing to promote on
259
+ unanchored = [e for e in entries if ok(e) and e['type'] in ('feedback', 'project') and e['anchors'] == 0]
220
260
  cold_set = {e['file'] for e in cold}
221
261
  listed = sorted((e for e in entries if e['index_line'] is not None), key=lambda e: e['index_ord'])
222
262
  users = [e for e in listed if e['type'] == 'user']
@@ -234,6 +274,8 @@ def main():
234
274
  'errors': [[e['file'], e['status'], e['bad']] for e in entries if e['status'] != 'OK'],
235
275
  'cold': [e['file'] for e in cold],
236
276
  'promote': [[e['file'], e['age'], e['distinct_days']] for e in promote],
277
+ 'promote_held': [[e['file'], e['age'], e['distinct_days']] for e in promote_held],
278
+ 'unanchored': [e['file'] for e in unanchored],
237
279
  'order': order, 'entries': entries}
238
280
  if a.json:
239
281
  print(json.dumps(rep, ensure_ascii=False, indent=1))
@@ -259,6 +301,14 @@ def main():
259
301
  print(f" promote candidates (age ≥ {a.promote_age} over ≥ 2 days → propose rule/hook, human approves): {len(promote)}")
260
302
  for e in promote:
261
303
  print(f" promote {e['file']} age {e['age']} · days {e['distinct_days']} · last {e['last_hit']}")
304
+ print(f" promote held (recurs, but the body cites no evidence anchor — add one before proposing): {len(promote_held)}")
305
+ for e in promote_held:
306
+ print(f" held {e['file']} age {e['age']} · days {e['distinct_days']} · last {e['last_hit']}")
307
+ print(f" unanchored feedback/project (no commit · #PR · file · arXiv · URL in the body): {len(unanchored)}")
308
+ for e in unanchored[:20]:
309
+ print(f" unanchored {e['file']}")
310
+ if len(unanchored) > 20:
311
+ print(f" … {len(unanchored) - 20} more (--json lists all)")
262
312
  print(f" proposed order ({len(order)}):")
263
313
  for n, f in enumerate(order, 1):
264
314
  print(f" {n:>3}. {f}")
@@ -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)이고, 그것까지 실어 보내면 아무도 안 쓰는 실험 아카이브가 패키지
@@ -16,7 +16,14 @@
16
16
  # 🟥 This script does not decide whether to merge. Approval is still yours — it only makes the
17
17
  # verification impossible to forget once you do.
18
18
  #
19
- # USAGE bash scripts/pr_merge_verified.sh <pr-number> --rerun '<command>' [--repo <path>]
19
+ # USAGE bash scripts/pr_merge_verified.sh <pr-number> --rerun '<command>' [--repo <path>] [--lease '<label>']
20
+ # RECEIPT once GitHub has accepted the merge request (every outcome from there: verified · verify failed · queued/not completed ·
21
+ # merged from another head · not fetchable — never for a refusal or a merge GitHub did not take) one JSON line goes to
22
+ # ${PMV_RECEIPTS:-<git common dir>/fh-merge-receipts.jsonl} — local, never pushed: pr · head · merge · outcome ·
23
+ # actor (agent-session:claude-code when CLAUDECODE is set, else human-or-unknown — a human cannot be proven) ·
24
+ # lease (the --lease label of the standing approval the caller merges under, else NONE — recorded, not enforced) · rerun.
25
+ # Why: arXiv:2610.28683 — 27% of merges that passed a «non-author review» gate rested on an agent approving under a
26
+ # human account; who decided must be on the record, not inferred later (frontier digest 2026-10-23).
20
27
  # EXIT 0 merged + verified · 1 merged but verify FAILED (the merge stands — act on it)
21
28
  # 2 usage (nothing merged) · 3 trivial --rerun refused (nothing merged)
22
29
  # 4 harness error (see message: before or after the merge)
@@ -26,13 +33,14 @@
26
33
  # (gh non-zero but GitHub says MERGED → continue to verify; state unreadable → 4, outcome UNKNOWN)
27
34
 
28
35
  set -uo pipefail
29
- PR=""; RERUN=""; RERUN_SET=0; REPO="."
36
+ PR=""; RERUN=""; RERUN_SET=0; REPO="."; LEASE="NONE"
30
37
  _need() { [ $# -ge 2 ] || { echo "🟥 $1 needs a value" >&2; exit 2; }; }
31
38
  while [ $# -gt 0 ]; do
32
39
  case "$1" in
33
40
  --rerun) _need "$@"; RERUN="${2-}"; RERUN_SET=1; shift 2 ;;
34
41
  --repo) _need "$@"; REPO="${2:-}"; shift 2 ;;
35
- -h|--help) sed -n '2,24p' "$0"; exit 0 ;;
42
+ --lease) _need "$@"; LEASE="${2-}"; [ -n "$LEASE" ] || { echo "🟥 --lease needs a non-empty label" >&2; exit 2; }; shift 2 ;;
43
+ -h|--help) sed -n '2,30p' "$0"; exit 0 ;;
36
44
  -*) echo "unknown arg: $1" >&2; exit 2 ;;
37
45
  *) [ -z "$PR" ] || { echo "🟥 one PR number only" >&2; exit 2; }; PR="$1"; shift ;;
38
46
  esac
@@ -48,6 +56,23 @@ bash "$PSV" --precheck --rerun "$RERUN" >/dev/null; _pc=$?
48
56
 
49
57
  cd "$REPO" || { echo "🟥 HARNESS-ERROR (before merge): cannot cd $REPO" >&2; exit 4; }
50
58
 
59
+ # receipt (after GitHub accepted the merge request — a queued merge counts: the request was made under this actor/lease). Best-effort: a receipt that cannot be written is said, never silently skipped,
60
+ # and never changes the exit code — the merge already happened.
61
+ _receipt() { # outcome merge_oid
62
+ local f="${PMV_RECEIPTS:-}"
63
+ if [ -z "$f" ]; then local gd; gd=$(git rev-parse --git-common-dir 2>/dev/null) || gd=""; [ -n "$gd" ] && f="$gd/fh-merge-receipts.jsonl"; fi
64
+ local actor="human-or-unknown"; [ -n "${CLAUDECODE:-}" ] && actor="agent-session:claude-code"
65
+ if [ -z "$f" ] || ! PMV_R_PR="$PR" PMV_R_HEAD="$HEAD_OID" PMV_R_MERGE="${2:-}" PMV_R_OUT="$1" PMV_R_ACTOR="$actor" PMV_R_LEASE="$LEASE" \
66
+ PMV_R_RERUN="$RERUN" python3 -c 'import json,os,time
67
+ e=os.environ
68
+ print(json.dumps({"at":time.strftime("%Y-%m-%dT%H:%M:%S%z"),"pr":int(e["PMV_R_PR"]),"head":e["PMV_R_HEAD"],"merge":e["PMV_R_MERGE"] or None,
69
+ "outcome":e["PMV_R_OUT"],"actor":e["PMV_R_ACTOR"],"lease":e["PMV_R_LEASE"],"rerun":e["PMV_R_RERUN"]},ensure_ascii=False))' >> "$f" 2>/dev/null; then
70
+ echo "⚠️ merge receipt NOT written (${f:-no git dir}) — record by hand: PR #$PR $1 actor=$actor lease=$LEASE" >&2
71
+ else
72
+ echo "── receipt: $f (actor=$actor · lease=$LEASE · $1)"
73
+ fi
74
+ }
75
+
51
76
  # 1. head before merge
52
77
  HEAD_OID=$(gh pr view "$PR" --json headRefOid -q .headRefOid < /dev/null) || HEAD_OID=""
53
78
  [ -n "$HEAD_OID" ] || { echo "🟥 HARNESS-ERROR (before merge): could not read PR #$PR head" >&2; exit 4; }
@@ -56,6 +81,28 @@ git cat-file -e "$HEAD_OID^{commit}" 2>/dev/null \
56
81
  || { echo "🟥 HARNESS-ERROR (before merge): PR head $HEAD_OID not fetchable — not merging" >&2; exit 4; }
57
82
  echo "── PR #$PR head recorded: $HEAD_OID"
58
83
 
84
+ # 1b. coverage advisory — WARNING ONLY (never changes rc, never merges or refuses). post_squash_verify's precheck rejects a
85
+ # command that is trivially empty; it cannot see a command that is real but never touches this PR's files. Static, pre-merge,
86
+ # no execution: does any word of --rerun (or a tracked script it names) mention a path/basename this PR changes?
87
+ _changed=$(git -c core.quotepath=off diff --name-only "$(git merge-base origin/main "$HEAD_OID" 2>/dev/null || echo "$HEAD_OID^")" "$HEAD_OID" < /dev/null 2>/dev/null) || _changed=""
88
+ if [ -n "$_changed" ]; then
89
+ _hay="$RERUN"
90
+ set -f # split --rerun into words WITHOUT globbing it against the checkout (cross-family R1: `echo *` listed dirs)
91
+ for _w in $RERUN; do # unquoted on purpose: split into words; a word naming a tracked FILE adds that file's text (a runner script)
92
+ _w="${_w//[\"\';|&()]/}"
93
+ [ -n "$_w" ] && [ "$(git cat-file -t "$HEAD_OID:$_w" < /dev/null 2>/dev/null)" = blob ] \
94
+ && _wc=$(git show "$HEAD_OID:$_w" < /dev/null 2>/dev/null) && _hay="$_hay $_wc"
95
+ done
96
+ set +f
97
+ _hay=" $(printf '%s' "$_hay" | tr -s '[:space:]"'"'"';|&()' ' ') "
98
+ _hit=0
99
+ while IFS= read -r _f; do
100
+ [ -n "$_f" ] || continue
101
+ case "$_hay" in *" $_f "*|*" $(basename "$_f") "*) _hit=1; break ;; esac
102
+ done <<< "$_changed"
103
+ [ "$_hit" -eq 1 ] || echo "⚠️ --rerun mentions none of this PR's $(printf '%s\n' "$_changed" | wc -l | tr -d ' ') changed file(s) (nor any script it names) — it may not exercise the change. Advisory only; merging continues." >&2
104
+ fi
105
+
59
106
  # 2. merge
60
107
  # 🟥 cross-family W1: pin the merge to the head we RECORDED. Without it, a push landing between the
61
108
  # record and the merge gets squashed in unverified, and «merged and verified» describes a commit
@@ -76,7 +123,7 @@ if ! gh pr merge "$PR" --squash --delete-branch --admin --match-head-commit "$HE
76
123
  MERGED)
77
124
  # MERGED alone does not say WHICH head merged — someone may have pushed and merged after we
78
125
  # recorded (codex A2). Only the recorded head may continue to verification.
79
- [ "$HO" = "$HEAD_OID" ] || { echo "🟥 HARNESS-ERROR: gh pr merge failed, and PR #$PR is MERGED from head ${HO:-?}, not the recorded $HEAD_OID — NOT verified" >&2; exit 4; }
126
+ [ "$HO" = "$HEAD_OID" ] || { _receipt "merged-other-head-not-verified" ""; echo "🟥 HARNESS-ERROR: gh pr merge failed, and PR #$PR is MERGED from head ${HO:-?}, not the recorded $HEAD_OID — NOT verified" >&2; exit 4; }
80
127
  echo "⚠️ gh pr merge exited non-zero; GitHub reports MERGED from the recorded head — continuing to verify" >&2
81
128
  echo " the head branch may still exist on origin — delete it by hand if so" >&2 ;;
82
129
  # 🟥 a persistent OPEN cannot prove nothing merged (state may still be stale) — say what was seen
@@ -94,19 +141,20 @@ MC=$(gh pr view "$PR" --json mergeCommit -q .mergeCommit.oid < /dev/null) || MC=
94
141
  if [ "$ST" != "MERGED" ] || [ -z "$MC" ] || [ "$MC" = "null" ]; then
95
142
  echo "🟥 merge ACCEPTED but not completed (state=${ST:-?} mergeCommit=${MC:-none}) — queued or lagging." >&2
96
143
  echo " NOT verified. When it lands: bash $PSV --tip $HEAD_OID --merge <merge commit> --rerun '<cmd>'" >&2
144
+ _receipt "accepted-not-completed" ""
97
145
  exit 6
98
146
  fi
99
147
  git fetch -q origin < /dev/null 2>/dev/null || true
100
148
  # W2 (B): a narrow/single-branch refspec may not bring the merge commit — ask for it by oid too
101
149
  git cat-file -e "$MC^{commit}" 2>/dev/null || git fetch -q origin "$MC" < /dev/null 2>/dev/null || true
102
150
  git cat-file -e "$MC^{commit}" 2>/dev/null \
103
- || { echo "🟥 HARNESS-ERROR (AFTER merge): merge commit $MC not fetchable — run post_squash_verify by hand with --tip $HEAD_OID --merge $MC" >&2; exit 4; }
151
+ || { _receipt "merged-not-fetchable" "$MC"; echo "🟥 HARNESS-ERROR (AFTER merge): merge commit $MC not fetchable — run post_squash_verify by hand with --tip $HEAD_OID --merge $MC" >&2; exit 4; }
104
152
  echo "── merged as $MC"
105
153
 
106
154
  # 4. verify
107
155
  bash "$PSV" --repo . --tip "$HEAD_OID" --merge "$MC" --rerun "$RERUN"; rc=$?
108
156
  case "$rc" in
109
- 0) echo "✅ PR #$PR merged and verified"; exit 0 ;;
110
- 1) echo "🟥 PR #$PR IS MERGED but verification FAILED — the merge stands; fix forward or revert" >&2; exit 1 ;;
111
- *) echo "🟥 HARNESS-ERROR (AFTER merge): post_squash_verify rc=$rc — PR #$PR is merged, verification did not complete" >&2; exit 4 ;;
157
+ 0) _receipt "verified" "$MC"; echo "✅ PR #$PR merged and verified"; exit 0 ;;
158
+ 1) _receipt "verify-failed" "$MC"; echo "🟥 PR #$PR IS MERGED but verification FAILED — the merge stands; fix forward or revert" >&2; exit 1 ;;
159
+ *) _receipt "verify-incomplete" "$MC"; echo "🟥 HARNESS-ERROR (AFTER merge): post_squash_verify rc=$rc — PR #$PR is merged, verification did not complete" >&2; exit 4 ;;
112
160
  esac
@@ -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 라 모듈이 없으면 조용히 무동작으로 돌아간다. 그 무음이 이 레인이 잡을 것이다.` \
@@ -978,6 +1014,8 @@ for _pair in \
978
1014
  "scripts/destructive_pre_gate.sh|scripts/test_destructive_pre_gate_lanes.sh" \
979
1015
  "templates/.git-hooks/pre-push|scripts/test_prepush_destructive_lanes.sh" \
980
1016
  "templates/.git-hooks/pre-push|scripts/test_prepush_destructive_liveness.sh" \
1017
+ `# 실제 git push 발화 레인 (2026-10-24, 형제 하네스 회신). 합성 stdin 레인은 «판정» 만 잰다 — 이 레인은 git 이 그 동작에서 훅을 «부르는가 · 그 줄을 넘기는가» 를 잰다. --mirror 는 삭제 줄을 안 넘긴다(실측).` \
1018
+ "templates/.git-hooks/pre-push|scripts/test_prepush_real_fire_lanes.sh" \
981
1019
  `# ── 증거 vs 판정 토큰 충돌(2026-09-19). SUBJECT 는 훅이 아니라 «되돌림 프로브 자신»이다 — 이 레인이 재는 것은 게이트의 동작이 아니라 그 프로브의 «출력 계약»(자기가 authored 한 줄에만 ❌ 를 쓴다)이고, 이 집계기가 ❌ 로 실패를 판정하므로 둘이 같은 채널을 공유한다. 실측: run 35426860480 의 로그를 사람이 두 번 연속 오귀속했다 ──` \
982
1020
  "scripts/test_prepush_destructive_liveness.sh|scripts/test_liveness_echo_token_lanes.sh" \
983
1021
  "templates/.git-hooks/pre-push|scripts/test_push_zone_lanes.sh" \
@@ -1015,6 +1053,7 @@ for _pair in \
1015
1053
  "scripts/sim_isolated_run.sh|scripts/test_sim_path_isolation_lanes.sh" \
1016
1054
  `# ── mutation_probe (2026-10-07) — revert_probe 의 «저자가 고른 변이 1개» 를 연산자 생성 변이로 넓힌 것. 앵커가 고정하는 것은 생성기 보정(리다이렉트 비변이)과 «못 잰 것은 2» 다 ──` \
1017
1055
  "scripts/mutation_probe.py|scripts/test_mutation_probe_lanes.sh" \
1056
+ "scripts/cartridge_admit.py|scripts/test_cartridge_admit_lanes.sh" \
1018
1057
  `# ── live-eval — the live twin of the static /prompt-regression probe check (2026-09-04) ──` \
1019
1058
  "scripts/probe_live_eval.sh|scripts/test_probe_live_eval_lanes.sh" \
1020
1059
  "scripts/probe_live_eval_lib.py|scripts/test_probe_live_eval_lanes.sh" \
@@ -1096,7 +1135,9 @@ for _pair in \
1096
1135
  `# ── 가벼운 게이트 P1·P2(2026-10-12): 비주제 레인의 gh·①-g 스텁 + 켠/끈 비교기 ──` \
1097
1136
  "scripts/lane_stub_env.sh|scripts/test_lane_stub_env_lanes.sh" \
1098
1137
  "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"
1138
+ "scripts/lane_onoff_compare.py|scripts/test_lane_stub_env_lanes.sh" \
1139
+ `# ── 위임 마감 영수증(2026-10-20): 에이전트가 «고쳤다» 고 한 것을 거버너가 저장소에서 잰다(보고 ≠ 변경) ──` \
1140
+ "scripts/dispatch_receipt.py|scripts/test_dispatch_receipt_lanes.sh"
1100
1141
  do
1101
1142
  _subj="${_pair%%|*}"; _anc="${_pair##*|}"; _lbl="${_anc##*/}"
1102
1143
  if [ ! -f "$_subj" ]; then
@@ -1113,25 +1154,7 @@ do
1113
1154
  # a substitute; without it `< /dev/null` is the whole defence and a suite that reads stdin ends
1114
1155
  # immediately instead of waiting forever.
1115
1156
  $_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
1157
+ _pair_rc_verdict "$_lbl" "$_subj" "$_rc" || fail=1
1135
1158
  elif _pkg_accepted_absent "$_anc"; then
1136
1159
  # DECLARED legitimately unshipped — the single source for that answer, not a guess from the
1137
1160
  # environment. The first draft printed "this package predates it", which is a WRONG DIAGNOSIS
@@ -3,13 +3,22 @@
3
3
 
4
4
  Two subcommands:
5
5
 
6
- extract --transcript <jsonl> [--out <md>]
6
+ extract --transcript <jsonl> [--out <md>] [--utterances <jsonl>]
7
7
  Reads a Claude Code transcript JSONL and emits a checklist SKELETON in
8
8
  Markdown: one row per operator utterance, 상태 column EMPTY. Opens TWO
9
9
  channels — raw entries and compaction-summary "All user messages"
10
10
  sections — and prints how many of each it found (0 found still counts
11
11
  as OPENED, never as "not opened"). See fh_signal_2026-09-18 for the
12
- doctrine this mechanizes.
12
+ doctrine this mechanizes. A THIRD channel, the UserPromptSubmit hook record
13
+ (tracks/_meta/utterances/<session_id>.jsonl, written by utterance_checklist_hook.py),
14
+ is merged in: it also holds messages sent while a tool was running, which the
15
+ transcript misses. Merge rule: a hook row is the same utterance as a transcript row
16
+ when the normalized text is equal (a hook row flagged `truncated` matches by prefix)
17
+ AND the timestamps are within HOOK_MATCH_WINDOW_S; each transcript row pairs with at
18
+ most one hook row (nearest in time). Unpaired hook rows are added as `H<n>` rows;
19
+ transcript rows keep `<n>`, summary rows `S<n>`. The header always states the hook
20
+ channel's state: not read (file absent) is NOT zero rows; a malformed line or an
21
+ unreadable file is a channel error (rc=2) and the transcript rows still print.
13
22
 
14
23
  check --file <md>
15
24
  Validates a FILLED checklist. FORM ONLY — this command never judges
@@ -57,6 +66,7 @@ closing/companion mark) apply only to entries that carry no metadata at all;
57
66
  there a byte-identical pasted envelope is indistinguishable by design.
58
67
  """
59
68
  import argparse
69
+ import datetime
60
70
  import json
61
71
  import os
62
72
  import re
@@ -343,7 +353,112 @@ def md_escape(text):
343
353
  return (text or "").replace("|", "\\|")
344
354
 
345
355
 
346
- def do_extract(transcript_path, out_path):
356
+ HOOK_MATCH_WINDOW_S = 1800 # a queued message can reach the transcript long after the hook saw it; further apart = a repeat, not the same message
357
+
358
+
359
+ def parse_ts(ts):
360
+ """transcript timestamps are UTC («…Z»); hook timestamps are local naive («YYYY-MM-DDTHH:MM:SS»). -> aware UTC datetime or None."""
361
+ c = parse_ts_candidates(ts)
362
+ return c[0] if c else None
363
+
364
+
365
+ TS_SHAPE_RE = re.compile(r"^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?Z?$")
366
+
367
+
368
+ def parse_ts_candidates(ts):
369
+ """-> [aware UTC datetimes]. A local naive time inside a DST fall-back hour names TWO instants (fold 0 and 1);
370
+ both are returned so the matcher can use the nearer one (codex 2026-10-19: picking one created a duplicate row)."""
371
+ if not isinstance(ts, str) or not TS_SHAPE_RE.match(ts):
372
+ return [] # exact shape only — `ts[:19]` alone accepted trailing garbage as a valid time (codex R2)
373
+ try:
374
+ dt = datetime.datetime.strptime(ts[:19], "%Y-%m-%dT%H:%M:%S")
375
+ except ValueError:
376
+ return []
377
+ if ts.endswith("Z"):
378
+ return [dt.replace(tzinfo=datetime.timezone.utc)]
379
+ out = []
380
+ for fold in (0, 1):
381
+ u = dt.replace(fold=fold).astimezone(datetime.timezone.utc)
382
+ if u not in out:
383
+ out.append(u)
384
+ return out
385
+
386
+
387
+ def default_hook_path(transcript_path):
388
+ sid = os.path.splitext(os.path.basename(transcript_path))[0]
389
+ hub = os.environ.get("FH_HUB") or os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
390
+ return os.path.join(hub, "tracks", "_meta", "utterances", sid + ".jsonl")
391
+
392
+
393
+ def read_hook_channel(path):
394
+ """-> (state, rows, bad_lines, detail). state: «read» · «absent» · «error». rows: [{ts, text, truncated}]."""
395
+ if not os.path.lexists(path):
396
+ return "absent", [], 0, ""
397
+ if not os.path.isfile(path):
398
+ return "error", [], 0, "not a regular file"
399
+ rows, bad = [], 0
400
+ try:
401
+ with open(path, "rb") as f:
402
+ for raw in f:
403
+ try:
404
+ line = raw.decode("utf-8").strip() # strict: a replaced byte would make a different text and a spurious H row
405
+ if not line:
406
+ continue
407
+ d = json.loads(line)
408
+ except Exception:
409
+ bad += 1
410
+ continue
411
+ if not isinstance(d, dict) or not isinstance(d.get("text"), str) or not d["text"].strip():
412
+ bad += 1
413
+ continue
414
+ if not parse_ts_candidates(d.get("ts")):
415
+ bad += 1 # the hook always writes ts; without it the time window cannot apply, so the row is not trusted
416
+ continue
417
+ rows.append({"ts": d.get("ts"), "text": d["text"], "truncated": d.get("truncated") is True})
418
+ except OSError as e:
419
+ return "error", [], 0, e.strerror or "unreadable"
420
+ return "read", rows, bad, ""
421
+
422
+
423
+ def merge_hook_rows(raw_rows, hook_rows):
424
+ """-> (hook_only, matched_count). Both channels record the same conversation in the same order, so pairing is
425
+ ORDER-PRESERVING, not nearest-first: hook rows in time order each take the EARLIEST unpaired transcript row of equal
426
+ normalized text inside HOOK_MATCH_WINDOW_S. Exact-text pairs (any row) are made first and truncated-prefix pairs
427
+ second, so a truncated hook row cannot take the row another hook row matches exactly. Still greedy, not an optimal
428
+ assignment — a named residual. (codex 2026-10-19: nearest-first greedy turned two
429
+ repeated «yes» pairs into three rows.) A transcript row with no usable time pairs on text alone."""
430
+ raw_norms = [normalize_utterance(r["text"]) for r in raw_rows]
431
+ raw_dts = [parse_ts(r["ts"]) for r in raw_rows]
432
+ order = sorted(range(len(hook_rows)), key=lambda k: (min(parse_ts_candidates(hook_rows[k]["ts"]) or [datetime.datetime.max.replace(tzinfo=datetime.timezone.utc)]), k))
433
+ used, paired = set(), set()
434
+
435
+ def within(hdts, i):
436
+ if raw_dts[i] is None or not hdts:
437
+ return True
438
+ return min(abs((h - raw_dts[i]).total_seconds()) for h in hdts) <= HOOK_MATCH_WINDOW_S
439
+
440
+ for prefix_pass in (False, True):
441
+ for k in order:
442
+ h = hook_rows[k]
443
+ if k in paired or (prefix_pass and not h["truncated"]):
444
+ continue # pass 1 = exact text for every row (a truncated row whose text is exact counts); pass 2 = prefixes
445
+ hn = normalize_utterance(h["text"])
446
+ hdts = parse_ts_candidates(h["ts"])
447
+ cands = [i for i, rn in enumerate(raw_norms)
448
+ if i not in used and (rn == hn or (prefix_pass and hn and rn.startswith(hn))) and within(hdts, i)]
449
+ if cands:
450
+ best = min(cands, key=lambda i: (raw_dts[i] is None, raw_dts[i] or 0, i))
451
+ used.add(best); paired.add(k)
452
+ hook_only = []
453
+ for k in order:
454
+ if k in paired:
455
+ continue
456
+ hdts = parse_ts_candidates(hook_rows[k]["ts"])
457
+ hook_only.append({"ts": hdts[0].strftime("%Y-%m-%dT%H:%M:%SZ") if hdts else None, "text": hook_rows[k]["text"]})
458
+ return hook_only, len(paired)
459
+
460
+
461
+ def do_extract(transcript_path, out_path, utterances_path=None):
347
462
  if not os.path.isfile(transcript_path):
348
463
  sys.stderr.write("error: transcript not found: %s\n" % transcript_path)
349
464
  return 10
@@ -389,6 +504,13 @@ def do_extract(transcript_path, out_path):
389
504
  continue
390
505
  raw_rows.append({"ts": entry.get("timestamp"), "text": text})
391
506
 
507
+ hook_path = utterances_path or default_hook_path(transcript_path)
508
+ hook_state, hook_rows, hook_bad, hook_detail = read_hook_channel(hook_path)
509
+ hook_only, hook_matched = merge_hook_rows(raw_rows, hook_rows)
510
+
511
+ # summary quotes are compared against the transcript rows only, as before: matching them against hook-only rows
512
+ # too dropped a distinct request that happened to repeat a short quote (codex 2026-10-19). A duplicate row is the
513
+ # safe direction; a missing one is not.
392
514
  raw_norms = [normalize_utterance(r["text"]) for r in raw_rows]
393
515
 
394
516
  summary_found_total = 0
@@ -406,7 +528,7 @@ def do_extract(transcript_path, out_path):
406
528
  n_raw = len(raw_rows)
407
529
  n_summary_found = summary_found_total
408
530
  n_summary_added = len(summary_rows)
409
- rc = 2 if parse_errors else 0 # v5: an unparsable line may have been an utterance — loud, never rc=0
531
+ rc = 2 if (parse_errors or hook_bad or hook_state == "error") else 0 # v5: an unparsable line may have been an utterance — loud, never rc=0
410
532
 
411
533
  lines_out = []
412
534
  title = "# 세션 요청 체크리스트 (스켈레톤) — %s" % os.path.basename(transcript_path)
@@ -419,6 +541,15 @@ def do_extract(transcript_path, out_path):
419
541
  lines_out.append(chr(0x1F4CE) + " " + "원장 = %s (%d lines)" % (transcript_path, line_count))
420
542
  if parse_errors:
421
543
  lines_out.append("🟥 JSONL 파싱 실패 %d줄 — 그 줄의 발화는 이 표에 없다 (rc=2)" % parse_errors)
544
+ if hook_state == "read":
545
+ lines_out.append("🪝 훅 기록 채널 읽음 — %d건 · 전사와 일치 %d건 · 훅 전용 %d건 (행 번호 H = 훅 전용, S = 요약, 숫자 = 전사)"
546
+ % (len(hook_rows), hook_matched, len(hook_only)))
547
+ elif hook_state == "absent":
548
+ lines_out.append("🟨 훅 기록 채널 안 읽음 — 파일 없음: %s (0건이 아니라 미열람; 훅이 안 걸렸거나 다른 허브일 수 있다)" % hook_path)
549
+ else:
550
+ lines_out.append("🟥 훅 기록 채널 오류 — %s: %s (rc=2; 전사 행은 그대로 아래에 있다)" % (hook_path, hook_detail))
551
+ if hook_bad:
552
+ lines_out.append("🟥 훅 기록 %d줄 해석 실패 — 그 줄의 발화는 이 표에 없을 수 있다 (rc=2)" % hook_bad)
422
553
  lines_out.append("")
423
554
  lines_out.append(
424
555
  "| # | \uc2dc\uac01 | \ubc1c\ud654(\uc694\uc9c0) | \uc0c1\ud0dc | \uc99d\uac70 | \uc0ac\uc720 / \ub0a8\uc740 \uac83 | \uc81c\uc548(\uc774\ubc88 \uc138\uc158 vs \uc774\uc6d4) |"
@@ -435,6 +566,16 @@ def do_extract(transcript_path, out_path):
435
566
  "| %d | %s | %s | | | | |" % (n, format_ts(r["ts"]), md_escape(blurb))
436
567
  )
437
568
 
569
+ h = 0
570
+ for r in hook_only:
571
+ h += 1
572
+ blurb = collapse(r["text"])
573
+ if len(blurb) > 160:
574
+ blurb = blurb[:160] + "\u2026"
575
+ lines_out.append(
576
+ "| H%d | %s | %s | | | | |" % (h, format_ts(r["ts"]), md_escape(blurb))
577
+ )
578
+
438
579
  s = 0
439
580
  for r in summary_rows:
440
581
  s += 1
@@ -502,19 +643,19 @@ def carry_forward(lines_out, out_path):
502
643
  continue # an empty row has nothing to carry
503
644
  if in_orphans:
504
645
  orphans_prev.append(l); continue # earlier orphans stay orphans unless they match below
505
- prev.setdefault((c[1], c[2]), c[3:])
506
- used, out = set(), []
646
+ prev.setdefault((c[1], c[2]), []).append(c[3:]) # a LIST per key: repeated rows (same minute, same words) keep each judgment, in order
647
+ used, out = 0, []
507
648
  for l in lines_out:
508
649
  c = _cells(l)
509
650
  key = (c[1], c[2]) if c else None
510
- if c and key in prev and not any(c[3:]):
511
- out.append("| %s | %s | %s | %s | %s | %s | %s |" % tuple(c[:3] + prev[key]))
512
- used.add(key); continue
651
+ if c and prev.get(key) and not any(c[3:]):
652
+ out.append("| %s | %s | %s | %s | %s | %s | %s |" % tuple(c[:3] + prev[key].pop(0)))
653
+ used += 1; continue
513
654
  out.append(l)
514
- orphans = ["| %s | %s | %s | %s | %s | %s | %s |" % ((("-",) + k + tuple(v))) for k, v in prev.items() if k not in used]
655
+ orphans = ["| %s | %s | %s | %s | %s | %s | %s |" % ((("-",) + k + tuple(v))) for k, vs in prev.items() for v in vs]
515
656
  orphans += orphans_prev
516
657
  if used or orphans:
517
- out.insert(4, "↩️ 이전 결과서에서 판정 %d줄 이어받음 · 못 맞춘 판정 %d줄은 맨 아래 «이전 결과서에서 이어받지 못한 판정»에 보존" % (len(used), len(orphans)))
658
+ out.insert(4, "↩️ 이전 결과서에서 판정 %d줄 이어받음 · 못 맞춘 판정 %d줄은 맨 아래 «이전 결과서에서 이어받지 못한 판정»에 보존" % (used, len(orphans)))
518
659
  if orphans:
519
660
  out += ["", CARRY_HEADING, "", "| # | 시각 | 발화(요지) | 상태 | 증거 | 사유 / 남은 것 | 제안(이번 세션 vs 이월) |",
520
661
  "|---|---|---|---|---|---|---|"] + orphans
@@ -751,6 +892,8 @@ def build_parser():
751
892
  p_extract = sub.add_parser("extract", help="extract a checklist skeleton from a transcript JSONL")
752
893
  p_extract.add_argument("--transcript", required=True)
753
894
  p_extract.add_argument("--out", default=None)
895
+ p_extract.add_argument("--utterances", default=None,
896
+ help="hook record jsonl (default: <hub>/tracks/_meta/utterances/<session id>.jsonl)")
754
897
 
755
898
  p_unblocked = sub.add_parser(
756
899
  "unblocked",
@@ -819,7 +962,8 @@ def do_unblocked(file_path):
819
962
  rid = re.sub(r"[^A-Za-z0-9]", "", cells[idx_num]).upper()
820
963
  if not rid:
821
964
  continue
822
- keys = classify_status(cells[idx_status] if idx_status < len(cells) else "")
965
+ # an empty/invalid status cell classifies to None — that row is open (idle), never a crash
966
+ keys = classify_status(cells[idx_status] if idx_status < len(cells) else "") or set()
823
967
  status_by_id[rid] = keys
824
968
  rows_flat.append((rid, keys, cells))
825
969
 
@@ -830,7 +974,7 @@ def do_unblocked(file_path):
830
974
  # open rows collapsed two different nothings into the same rc=4: "every dependency was
831
975
  # resolved and closed" and "nobody ever wrote a dependency". The first is a clean run; the
832
976
  # second is an unread channel. («not found» is not «0» — the named family in this repo.)
833
- idle = not ("DONE" in keys or "n/a" in keys)
977
+ idle = not ("DONE" in keys or "N/A" in keys) # classify_status returns the key "N/A", never "n/a"
834
978
  joined = " | ".join(cells)
835
979
  for m in DEP_RE.finditer(joined):
836
980
  dep = m.group(1).upper()
@@ -865,7 +1009,7 @@ def main(argv=None):
865
1009
  args = parser.parse_args(argv)
866
1010
 
867
1011
  if args.cmd == "extract":
868
- return do_extract(args.transcript, args.out)
1012
+ return do_extract(args.transcript, args.out, args.utterances)
869
1013
  if args.cmd == "check":
870
1014
  return do_check(args.file)
871
1015
  if args.cmd == "unblocked":
@@ -967,7 +967,7 @@ else
967
967
  _sr_uns=$(printf '%s' "$_sr_v" | sed -n 's/.*UNSCANNABLE=\([0-9]*\).*/\1/p')
968
968
  if [ "${_sr_sup:-0}" -gt 0 ] 2>/dev/null; then
969
969
  echo "⚠️ ①-g stale-ref: ${_sr_sup} 개 id 가 폐기된 버전을 가리킨다 — advisory, 막지 않는다."
970
- echo " 🟥 의도한 pin 일 수 있다 — 눈으로 확인하고 고쳐라(고정이면 파일에 'stale-ref: pinned')."
970
+ echo " 🟥 의도한 pin 일 수 있다 — 눈으로 확인하고 고쳐라(발행 스냅샷이면 파일 첫머리에 '<!-- stale-ref: pinned -->', 옛 판을 일부러 가리키는 한 줄이면 그 줄에 '<!-- stale-ref: pinned-line=<id> -->'). 일부러 빨갛게 둔 것(예: replace 전 arXiv 판)은 그대로 둔다."
971
971
  printf '%s\n' "$_sr_out" | grep -E '^ +🟥 SUPERSEDED' | sed 's/^/ /'
972
972
  fi
973
973
  if [ "${_sr_unr:-0}" -gt 0 ] 2>/dev/null || [ "${_sr_uns:-0}" -gt 0 ] 2>/dev/null; then