@chrono-meta/fh-gate 3.39.1 → 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 (46) 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 +20 -18
  5. package/README.zh.md +20 -18
  6. package/knowledge/shared/harness-core/claude_md_full_reference.md +8 -1
  7. package/knowledge/shared/harness-core/dispatch_conditional_prohibition.md +9 -0
  8. package/knowledge/shared/harness-core/fh_module_contract.md +55 -1
  9. package/knowledge/shared/harness-core/lease_record_channel.md +26 -2
  10. package/knowledge/shared/harness-core/onboarding_acceleration_autopilot.md +7 -0
  11. package/knowledge/shared/learnings/subagent_invocations_log.yaml +36 -0
  12. package/knowledge/shared/rules/operations.md +1 -0
  13. package/package.json +10 -1
  14. package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
  15. package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
  16. package/plugins/fh-meta/CHANGELOG.md +35 -0
  17. package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
  18. package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
  19. package/scripts/agent_tools_pin.txt +16 -0
  20. package/scripts/catch_tally.py +215 -0
  21. package/scripts/claim_precision_report.py +138 -0
  22. package/scripts/fh_module_check.py +182 -1
  23. package/scripts/generated_harness_check.py +4 -0
  24. package/scripts/package_coverage_check.sh +5 -0
  25. package/scripts/post_squash_verify.sh +53 -1
  26. package/scripts/pr_merge_verified.sh +56 -0
  27. package/scripts/probe_live_eval.sh +61 -0
  28. package/scripts/probe_live_eval_lib.py +47 -4
  29. package/scripts/selfcheck.sh +5 -0
  30. package/scripts/selfdev_merge_tier.sh +153 -0
  31. package/scripts/session_checklist.py +38 -1
  32. package/scripts/session_close_check.sh +67 -1
  33. package/scripts/sim_isolated_run.sh +62 -1
  34. package/scripts/test_agent_tools_pin_lanes.sh +73 -0
  35. package/scripts/test_catch_tally_lanes.sh +10 -0
  36. package/scripts/test_claim_precision_report_lanes.sh +77 -0
  37. package/scripts/test_fh_module_check_lanes.sh +106 -1
  38. package/scripts/test_generated_harness_check_lanes.sh +8 -0
  39. package/scripts/test_post_squash_verify_lanes.sh +23 -2
  40. package/scripts/test_pr_merge_verified_lanes.sh +55 -3
  41. package/scripts/test_probe_live_eval_lanes.sh +160 -5
  42. package/scripts/test_selfdev_merge_tier_lanes.sh +128 -0
  43. package/scripts/test_session_checklist_lanes.sh +57 -0
  44. package/scripts/test_session_close_chain_lanes.sh +93 -0
  45. package/scripts/test_sim_isolated_run_lanes.sh +67 -0
  46. package/templates/harness_birth_core.md +57 -0
@@ -0,0 +1,16 @@
1
+ # Declared tools: restriction per agent definition — a lane pins each line (present + unchanged).
2
+ # Change a restriction here in the same commit as the agent file; widening it is then a visible diff.
3
+ plugins/fh-commons/agents/a11y-lens.md|Read, Grep, Glob
4
+ plugins/fh-commons/agents/be-dev-lens.md|Read, Grep, Glob
5
+ plugins/fh-commons/agents/designer-lens.md|Read, Grep, Glob
6
+ plugins/fh-commons/agents/fe-dev-lens.md|Read, Grep, Glob
7
+ plugins/fh-commons/agents/qa-lens.md|Read, Grep, Glob
8
+ plugins/fh-commons/agents/quench-challenger.md|Read, Grep, Glob
9
+ plugins/fh-commons/agents/ux-writer-lens.md|Read, Grep, Glob
10
+ plugins/fh-meta/agents/beginner.md|Read
11
+ plugins/fh-meta/agents/challenger.md|Read, Grep, Glob, WebSearch, WebFetch
12
+ plugins/fh-meta/agents/expert.md|Read, WebSearch, WebFetch
13
+ plugins/fh-meta/agents/fact-checker.md|Read, Grep, Glob
14
+ plugins/fh-meta/agents/hub-persona-auditor.md|Read, Grep, Glob
15
+ plugins/fh-meta/agents/main-player.md|Read, Grep, Glob
16
+ plugins/fh-meta/agents/persona-innovator.md|Read, Grep, Glob, WebSearch, WebFetch
@@ -0,0 +1,215 @@
1
+ #!/usr/bin/env python3
2
+ """catch_tally.py — 마감 때 적은 «잡은 것» 표를 날짜 범위로 센다.
3
+
4
+ 왜 (2026-11-08 운영자): «작은 시뮬레이션보다는 정말 어려운 무언가에 맞닥뜨렸을 때 방법론들로
5
+ 결함을 잡은 것들을 그때그때 마감 때 카운트해 보는 게 맞을 듯». 11-07 두 번의 재측정은 심은
6
+ 결함이 쉬워 일반 검토가 87~100% 를 잡았고(천장), 방법 차이를 잴 힘이 없었다. 방법의 값은
7
+ 실작업에서 «일반 검토·저자가 놓친 것을 무엇이 잡았나» 로 드러나므로 그 기록을 센다.
8
+
9
+ 기록 자리: Session Wrap-up ⑤(a) 가 `tracks/_meta/fh_completed_{date}.md` 에 쓰는 `## 잡은 것` 절.
10
+
11
+ ## 잡은 것
12
+ | 결함 | 잡은 방법 | 놓친 쪽 | 근거 |
13
+ |---|---|---|---|
14
+ | 빈 집합에서 판정이 통과로 기움 | cross-family | author | #1041 |
15
+
16
+ 또는 잡은 게 없으면 표 대신 한 줄: `0건 — <살펴본 범위>`
17
+
18
+ 기계가 보는 것은 기록의 성질뿐이다(present · typed · attributable). 그 결함이 정말 어려웠는지,
19
+ 그 방법이 정말 잡았는지는 판단이고 이 스크립트는 판정하지 않는다.
20
+ - 절이 없거나 범위 없는 0건뿐인 날 = NOT_RECORDED (0 이 아니다 — 안 적은 것과 잡은 게 없는 것은 다르다)
21
+ - `0건 —` 뒤에 범위가 없으면 INVALID (빈 0 은 미측정과 구분이 안 된다)
22
+ - 방법·놓친 쪽이 닫힌 목록 밖이거나 근거가 비면 그 행은 INVALID 로 따로 찍고 세지 않는다
23
+
24
+ 사용:
25
+ catch_tally.py [--dir tracks/_meta] [--days 7] [--until YYYY-MM-DD]
26
+ catch_tally.py --self-test
27
+ exit: 0 집계 · 1 self-test 실패 · 2 INVALID 행 있음(집계는 찍는다) · 10 입력 오류
28
+ """
29
+ import argparse, datetime as dt, os, re, sys, tempfile
30
+
31
+ METHODS = ["cross-family", "revert-probe", "control", "lens", "gate", "lane", "operator", "self"]
32
+ MISSED = ["author", "plain-review", "lane", "gate", "none"]
33
+ HEAD_RE = re.compile(r"^##\s+(잡은 것|Catches)\s*$")
34
+ ZERO_RE = re.compile(r"^\s*0건\s*(?:—|-{1,2})\s*(.*)$")
35
+ FILE_RE = re.compile(r"^fh_completed_(\d{4}-\d{2}-\d{2})\.md$")
36
+ PLACEHOLDER = {"", "-", "—", "tbd", "없음", "n/a", "na"}
37
+ # 근거 = PR(#123 · /pull/123) · 커밋 해시(7~40자) · 파일:줄. 그 밖의 낱말만 있으면 «귀속 가능» 이 아니다.
38
+ EVIDENCE_RE = re.compile(r"#\d+|/pull/\d+|\b[0-9a-f]{7,40}\b|[\w./-]+\.\w+:\d+")
39
+ SEP_RE = re.compile(r"^:?-+:?$")
40
+
41
+
42
+ def parse_section(text):
43
+ """Return (state, rows, invalid). state ∈ NOT_RECORDED | ZERO | ROWS."""
44
+ lines = text.splitlines()
45
+ starts = [i for i, l in enumerate(lines) if HEAD_RE.match(l)]
46
+ if not starts:
47
+ return "NOT_RECORDED", [], []
48
+ rows, invalid, zero = [], [], None
49
+ for s in starts: # 하루에 마감이 둘 이상이면 절도 둘 이상일 수 있다 — 전부 읽는다
50
+ for l in lines[s + 1:]:
51
+ if l.startswith("#"):
52
+ break
53
+ m = ZERO_RE.match(l)
54
+ if m:
55
+ scope = m.group(1).strip()
56
+ if scope.lower() in PLACEHOLDER:
57
+ invalid.append((l.strip(), "0건 뒤에 살펴본 범위가 없다"))
58
+ else:
59
+ zero = scope
60
+ continue
61
+ if not l.strip().startswith("|"):
62
+ continue
63
+ cells = [c.strip() for c in l.strip().strip("|").split("|")]
64
+ if all(SEP_RE.match(c) for c in cells) or cells[0] == "결함":
65
+ continue # 구분선 · 머리줄
66
+ if len(cells) != 4:
67
+ invalid.append((l.strip(), f"칸이 {len(cells)}개 — 4칸(결함·잡은 방법·놓친 쪽·근거)이어야 한다"))
68
+ continue
69
+ defect, method, missed, evidence = cells
70
+ why = []
71
+ if defect.lower() in PLACEHOLDER:
72
+ why.append("결함이 비었다")
73
+ if method not in METHODS:
74
+ why.append(f"잡은 방법 «{method}» 는 목록 밖")
75
+ if missed not in MISSED:
76
+ why.append(f"놓친 쪽 «{missed}» 는 목록 밖")
77
+ if evidence.lower() in PLACEHOLDER:
78
+ why.append("근거가 비었다")
79
+ elif not EVIDENCE_RE.search(evidence):
80
+ why.append(f"근거 «{evidence}» 에 PR · 커밋 · 파일:줄이 없다")
81
+ if why:
82
+ invalid.append((l.strip(), " · ".join(why)))
83
+ else:
84
+ rows.append((defect, method, missed, evidence))
85
+ if rows:
86
+ return "ROWS", rows, invalid
87
+ if zero is not None:
88
+ return "ZERO", [], invalid
89
+ return "NOT_RECORDED", [], invalid
90
+
91
+
92
+ def tally(d, days, until):
93
+ lo = until - dt.timedelta(days=days - 1)
94
+ found, badnames = {}, []
95
+ for name in sorted(os.listdir(d)):
96
+ m = FILE_RE.match(name)
97
+ if not m:
98
+ continue
99
+ try:
100
+ day = dt.date.fromisoformat(m.group(1))
101
+ except ValueError:
102
+ badnames.append(name) # 범위 판단을 못 하니 무조건 알린다 — 한 파일이 리포트 전체를 죽이지 않게
103
+ continue
104
+ if lo <= day <= until:
105
+ with open(os.path.join(d, name), encoding="utf-8") as f:
106
+ found[day] = parse_section(f.read())
107
+ return lo, found, badnames
108
+
109
+
110
+ def report(d, days, until, out=sys.stdout):
111
+ lo, found, badnames = tally(d, days, until)
112
+ by_m = {k: 0 for k in METHODS}
113
+ by_x = {k: 0 for k in MISSED}
114
+ states = {"ROWS": 0, "ZERO": 0, "NOT_RECORDED": 0}
115
+ bad = []
116
+ for day, (state, rows, invalid) in sorted(found.items()):
117
+ states[state] += 1
118
+ for _, mth, mis, _ in rows:
119
+ by_m[mth] += 1
120
+ by_x[mis] += 1
121
+ bad += [(day, r, w) for r, w in invalid]
122
+ bad += [("-", n, "파일 이름의 날짜가 달력에 없다") for n in badnames]
123
+ nofile = [str(lo + dt.timedelta(days=i)) for i in range(days)
124
+ if lo + dt.timedelta(days=i) not in found]
125
+ total = sum(by_m.values())
126
+ p = lambda *a: print(*a, file=out)
127
+ p(f"catch_tally {lo}..{until} · 마감 기록 파일 {len(found)}개 "
128
+ f"(잡은 것 있음 {states['ROWS']} · 0건(범위 적음) {states['ZERO']} · 🟥 미기록 {states['NOT_RECORDED']})")
129
+ if nofile:
130
+ p(f" ⬜ 마감 파일 자체가 없는 날 {len(nofile)}개(마감이 없었거나 안 적음 — 0 으로 세지 않는다): {', '.join(nofile)}")
131
+ if states["NOT_RECORDED"]:
132
+ miss = [str(k) for k, v in found.items() if v[0] == "NOT_RECORDED"]
133
+ p(f" 🟥 미기록(절 없음 또는 범위 없는 0건) = 0 이 아니다: {', '.join(miss)}")
134
+ p(f" 잡은 것 {total}건")
135
+ p(" 잡은 방법: " + " · ".join(f"{k} {v}" for k, v in by_m.items() if v) if total else " 잡은 방법: —")
136
+ p(" 놓친 쪽: " + " · ".join(f"{k} {v}" for k, v in by_x.items() if v) if total else " 놓친 쪽: —")
137
+ for day, r, w in bad:
138
+ p(f" ⚠️ INVALID {day}: {w} — {r}")
139
+ return 2 if bad else 0
140
+
141
+
142
+ def self_test():
143
+ ok = True
144
+ with tempfile.TemporaryDirectory() as t:
145
+ w = lambda n, s: open(os.path.join(t, n), "w", encoding="utf-8").write(s)
146
+ w("fh_completed_2026-01-05.md", "# x\n## 잡은 것\n| 결함 | 잡은 방법 | 놓친 쪽 | 근거 |\n|---|---|---|---|\n"
147
+ "| 빈 집합 통과 | cross-family | author | #1 |\n| 되돌려도 초록 | revert-probe | lane | commit:abc1234 |\n"
148
+ "| 오타 | codex | author | #2 |\n## 다음\n| 무시 | self | none | x |\n")
149
+ w("fh_completed_2026-01-06.md", "## 잡은 것\n0건 — FoD 릴리스 PR 두 개만 봄\n")
150
+ w("fh_completed_2026-01-07.md", "# 절 없음\n")
151
+ w("fh_completed_2026-01-08.md", "## Catches\n0건 —\n")
152
+ w("fh_completed_2025-12-01.md", "## 잡은 것\n| 범위 밖 | self | none | #9 |\n")
153
+ w("fh_completed_2026-01-03.md", "## 잡은 것\n| 칸 부족 | self | author |\n| | self | author | #1 |\n"
154
+ "| 칸 넘침 | self | author | #1 | x |\n| 근거 낱말 | self | author | banana |\n"
155
+ "| 파일 근거 | lens | plain-review | scripts/x.sh:12 |\n")
156
+ w("fh_completed_2026-02-30.md", "## 잡은 것\n0건 — x\n")
157
+ import io
158
+ buf = io.StringIO()
159
+ rc = report(t, 7, dt.date(2026, 1, 8), buf)
160
+ o = buf.getvalue()
161
+ checks = [
162
+ ("rc=2 (INVALID 있음)", rc == 2),
163
+ ("잡은 것 3건(목록 밖 행·다른 절·범위 밖 날 제외)", "잡은 것 3건" in o),
164
+ ("cross-family 1 · revert-probe 1", "cross-family 1" in o and "revert-probe 1" in o),
165
+ ("놓친 쪽 author 1 · lane 1", "author 1" in o and "lane 1" in o),
166
+ ("0건+범위 = ZERO 로 셈", "0건(범위 적음) 1" in o),
167
+ ("절 없는 날·빈 0건 = 미기록, 0 아님", "미기록 2" in o and "2026-01-07, 2026-01-08" in o),
168
+ ("범위 없는 0건 = INVALID", "살펴본 범위가 없다" in o),
169
+ ("목록 밖 방법 = INVALID", "«codex» 는 목록 밖" in o),
170
+ ("칸 부족 = INVALID", "칸이 3개" in o),
171
+ ("빈 결함 칸 = INVALID(구분선으로 오인 안 함)", "결함이 비었다" in o),
172
+ ("칸 넘침 = INVALID", "칸이 5개" in o),
173
+ ("근거에 PR·커밋·파일:줄 없음 = INVALID", "«banana» 에 PR" in o),
174
+ ("파일:줄 근거는 유효 — lens 1 셈", "lens 1" in o),
175
+ ("달력에 없는 날짜 파일 = INVALID, 리포트는 계속", "달력에 없다" in o and "2026-02-30" in o),
176
+ ("파일 없는 날 = 따로 표시(0 아님)", "파일 자체가 없는 날 2개" in o and "2026-01-02, 2026-01-04" in o),
177
+ ]
178
+ # 컨트롤: 같은 디렉터리에서 유효 행만 남기면 rc=0 이어야 한다(INVALID 판정이 늘 켜진 건 아님)
179
+ w("fh_completed_2026-01-05.md", "## 잡은 것\n| 빈 집합 통과 | cross-family | author | #1 |\n")
180
+ w("fh_completed_2026-01-08.md", "## 잡은 것\n0건 — 문서 PR 하나\n")
181
+ os.remove(os.path.join(t, "fh_completed_2026-01-03.md"))
182
+ os.remove(os.path.join(t, "fh_completed_2026-02-30.md"))
183
+ rc2 = report(t, 7, dt.date(2026, 1, 8), io.StringIO())
184
+ checks.append(("컨트롤: 유효 기록만이면 rc=0", rc2 == 0))
185
+ for name, good in checks:
186
+ print(("PASS " if good else "FAIL ") + name)
187
+ ok &= good
188
+ if not ok:
189
+ print("--- 출력 ---\n" + o)
190
+ return 0 if ok else 1
191
+
192
+
193
+ def main():
194
+ ap = argparse.ArgumentParser(description=__doc__.splitlines()[0])
195
+ ap.add_argument("--dir", default=os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "tracks", "_meta"))
196
+ ap.add_argument("--days", type=int, default=7)
197
+ ap.add_argument("--until", default=None)
198
+ ap.add_argument("--self-test", action="store_true")
199
+ a = ap.parse_args()
200
+ if a.self_test:
201
+ return self_test()
202
+ if a.days < 1 or not os.path.isdir(a.dir):
203
+ print(f"입력 오류: --dir {a.dir} / --days {a.days}", file=sys.stderr)
204
+ return 10
205
+ try:
206
+ until = dt.date.fromisoformat(a.until) if a.until else dt.date.today()
207
+ until - dt.timedelta(days=a.days - 1)
208
+ except (ValueError, OverflowError):
209
+ print(f"입력 오류: --until {a.until}", file=sys.stderr)
210
+ return 10
211
+ return report(a.dir, a.days, until)
212
+
213
+
214
+ if __name__ == "__main__":
215
+ sys.exit(main())
@@ -0,0 +1,138 @@
1
+ #!/usr/bin/env python3
2
+ """claim_precision_report.py — completion-claim record counter (read-only, no verdict).
3
+
4
+ Origin: frontier digest 2026-11-11, arXiv:2611.10063 («completion-claim precision»).
5
+
6
+ What it counts, over existing request-checklist result sheets
7
+ (`tracks/_meta/session_checklist_<date>_<session>.md`):
8
+
9
+ N rows whose 상태 reads DONE in some sheet of a session
10
+ M of those, rows that a LATER sheet of the same session shows with a
11
+ non-DONE 상태 the status enum can read (downgraded / reopened in the record). Sticky:
12
+ a still-later DONE does not erase the reopening.
13
+ B of those (not in M), rows the NEWEST sheet of the session did not
14
+ re-judge: 상태 empty there, a value outside the status enum (e.g. «—»),
15
+ or the row is absent from it. That is a channel gap, NOT a correction,
16
+ and it is printed apart so «not re-judged» never reads as «still DONE».
17
+
18
+ Unreadable sheets are listed and do not count toward «measured».
19
+ Channels: only sessions with 2+ readable sheets can show a later re-judgment. Sessions
20
+ with a single sheet are listed as NOT MEASURED (their M is unknown, not 0).
21
+ Corrections made only in conversation, PRs or later sessions with a different
22
+ session id are not in these sheets and are named as an unread channel.
23
+
24
+ It reports record properties only — no ratio threshold, no pass/fail.
25
+ Rows are keyed by (시각, first 40 chars of 발화); a key seen twice in one sheet
26
+ is counted once and reported as a collision.
27
+
28
+ rc: 0 report printed · 10 no sheets found · 2 usage error.
29
+ """
30
+ import argparse
31
+ import collections
32
+ import glob
33
+ import os
34
+ import re
35
+ import sys
36
+
37
+ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
38
+ import session_checklist as sc # single source for table parsing + status enum
39
+
40
+ NAME_RE = re.compile(r"session_checklist_(\d{4}-\d\d-\d\d)_(.+)\.md$")
41
+
42
+
43
+ def row_keys(path):
44
+ """Yield (key, status_keys_or_None) for every 상태-table row of one sheet."""
45
+ tables, rc = sc.load_tables(path)
46
+ if not tables:
47
+ return
48
+ for header, rows in tables:
49
+ idx = [sc.find_header_index(header, n) for n in ("상태", "시각", "발화")]
50
+ if any(i is None or i < 0 for i in idx):
51
+ continue
52
+ si, ti, ui = idx
53
+ for r in rows:
54
+ if len(r) <= max(idx):
55
+ continue
56
+ yield (r[ti].strip(), r[ui].strip()[:40]), sc.classify_status(r[si]), r[si].strip()
57
+
58
+
59
+ def classify_or_none(raw):
60
+ """True only for a cell the status enum can read and that is not DONE-only-absent."""
61
+ return sc.classify_status(raw)
62
+
63
+
64
+ def main(argv=None):
65
+ ap = argparse.ArgumentParser(description=__doc__.split("\n")[0])
66
+ ap.add_argument("--dir", required=True, help="folder holding session_checklist_*.md")
67
+ ap.add_argument("--show", type=int, default=10, help="list up to N reopened rows")
68
+ a = ap.parse_args(argv)
69
+
70
+ by = collections.defaultdict(list)
71
+ for f in sorted(glob.glob(os.path.join(a.dir, "session_checklist_*.md"))):
72
+ m = NAME_RE.search(os.path.basename(f))
73
+ if m:
74
+ by[m.group(2)].append((m.group(1), f))
75
+ if not by:
76
+ print("claim-precision: sheets=0 — NOT MEASURED (no session_checklist_*.md in %s)" % a.dir)
77
+ return 10
78
+
79
+ n = m_ = b = coll = 0
80
+ measured, single, unparsed = [], [], []
81
+ shown = []
82
+ for sid, sheets in sorted(by.items()):
83
+ parsed = []
84
+ for date, f in sheets:
85
+ tables, rc = sc.load_tables(f)
86
+ if not tables or rc is not None or next(row_keys(f), None) is None:
87
+ # no table, or a table without 상태/시각/발화 rows: nothing measurable in this sheet
88
+ unparsed.append(os.path.basename(f)) # a sheet we could not read is NOT a clean sheet
89
+ continue
90
+ parsed.append((date, f))
91
+ if len(parsed) < 2:
92
+ single.append(sid)
93
+ continue
94
+ measured.append(sid)
95
+ done_at = {} # key -> date first seen DONE
96
+ reopened = {} # key -> (date, raw) first later non-empty non-DONE — sticky, a later DONE never erases it
97
+ last_date = parsed[-1][0]
98
+ in_last = {} # key -> raw 상태 in the newest parsed sheet
99
+ for date, f in parsed:
100
+ seen_here = set()
101
+ for key, st, raw in row_keys(f):
102
+ if key in seen_here:
103
+ coll += 1
104
+ continue
105
+ seen_here.add(key)
106
+ is_done = bool(st) and "DONE" in st
107
+ if date == last_date:
108
+ in_last[key] = raw
109
+ if key in done_at and date != done_at[key] and not is_done and st: # st None = blank or a cell outside the enum («—»)
110
+ reopened.setdefault(key, (date, raw))
111
+ if is_done and key not in done_at:
112
+ done_at[key] = date
113
+ n += len(done_at)
114
+ for key, (date, raw) in reopened.items():
115
+ m_ += 1
116
+ if len(shown) < a.show:
117
+ shown.append((sid, key, done_at[key], date, raw))
118
+ # B: DONE rows the newest sheet did not re-judge — row blank there, or row absent from it.
119
+ for key, d0 in done_at.items():
120
+ if key in reopened or d0 == last_date:
121
+ continue
122
+ if not classify_or_none(in_last.get(key, "")):
123
+ b += 1
124
+
125
+ print("claim-precision: sessions=%d measured=%d not-measured(<2 readable sheets)=%d"
126
+ % (len(by), len(measured), len(single)))
127
+ print(" N done-rows=%d · M later reopened (non-DONE in the enum)=%d · B not re-judged in newest sheet (blank, absent or outside the enum)=%d · key collisions=%d"
128
+ % (n, m_, b, coll))
129
+ print(" channels read: session_checklist sheets of %s" % (", ".join(measured) or "—"))
130
+ print(" NOT MEASURED: sessions with <2 readable sheets %s · unreadable sheets %s · corrections outside "
131
+ "these sheets (conversation, PRs, other session ids)" % (", ".join(single) or "—", ", ".join(unparsed) or "—"))
132
+ for sid, key, d0, d1, raw in shown:
133
+ print(" ↩︎ %s %s «%s» DONE@%s → %s@%s" % (sid, key[0], key[1], d0, raw, d1))
134
+ return 0
135
+
136
+
137
+ if __name__ == "__main__":
138
+ sys.exit(main())
@@ -12,7 +12,7 @@ Exit codes: 0 OK . 1 BLOCK . 2 UNMEASURED (unreadable / tooling down / empty cor
12
12
  3 OK-but-UNCALIBRATED (valid, no verdict entry points, calibration declared UNCALIBRATED; never a clean pass).
13
13
  Fail closed: nothing unreadable, unknown or empty ever exits 0.
14
14
  """
15
- import argparse, glob, hashlib, json, os, re, shutil, subprocess, sys
15
+ import argparse, ast, glob, hashlib, json, os, re, shutil, subprocess, sys, sysconfig
16
16
 
17
17
  OK, BLOCK, UNMEASURED, UNCAL = 0, 1, 2, 3
18
18
 
@@ -384,6 +384,185 @@ def validate(m, vd, repo_core, repo):
384
384
  vd.block("files: %s resolves outside the repo" % f)
385
385
 
386
386
 
387
+ def _is_stdlib(name):
388
+ """True when `name` is a standard-library module of the interpreter running this check (3.9 has no
389
+ sys.stdlib_module_names: fall back to where the module lives)."""
390
+ names = getattr(sys, "stdlib_module_names", None)
391
+ if names is not None:
392
+ return name in names
393
+ if name in sys.builtin_module_names:
394
+ return True
395
+ import importlib.util
396
+ try:
397
+ spec = importlib.util.find_spec(name)
398
+ except (ImportError, ValueError):
399
+ return False
400
+ if spec is None or not spec.origin:
401
+ return False
402
+ if spec.origin in ("built-in", "frozen"):
403
+ return True
404
+ std = os.path.realpath(sysconfig.get_paths()["stdlib"])
405
+ org = os.path.realpath(spec.origin)
406
+ return org.startswith(std + os.sep) and "site-packages" not in org
407
+
408
+
409
+ _CATCH = ("ImportError", "ModuleNotFoundError", "Exception", "BaseException")
410
+
411
+
412
+ def _bound_names(tree):
413
+ """Every name the file binds anywhere (assignment, parameter, `except … as`, def/class, import alias), except a plain
414
+ `import builtins`. Over-approximate on purpose: a rebound name stops counting as a guard -> fail closed."""
415
+ out = set()
416
+ for n in ast.walk(tree):
417
+ if isinstance(n, ast.Name) and isinstance(n.ctx, (ast.Store, ast.Del)):
418
+ out.add(n.id)
419
+ elif isinstance(n, ast.arg):
420
+ out.add(n.arg)
421
+ elif isinstance(n, ast.ExceptHandler) and n.name:
422
+ out.add(n.name)
423
+ elif isinstance(n, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)):
424
+ out.add(n.name)
425
+ elif isinstance(n, (ast.Global, ast.Nonlocal)):
426
+ out.update(n.names)
427
+ elif isinstance(n, (ast.Import, ast.ImportFrom)):
428
+ for a in n.names:
429
+ if isinstance(n, ast.Import) and a.name == "builtins" and not a.asname:
430
+ continue
431
+ out.add((a.asname or a.name).split(".")[0])
432
+ return out
433
+
434
+
435
+ def _bare_import_module(tree):
436
+ """True when the file binds `import_module` from importlib (so a bare `import_module("x")` call is that one)."""
437
+ return any(isinstance(n, ast.ImportFrom) and n.module == "importlib" and n.level == 0
438
+ and any(a.name == "import_module" and not a.asname for a in n.names) for n in ast.walk(tree))
439
+
440
+
441
+ def _dynamic_import(n, bare_ok=False):
442
+ """`importlib.import_module("x")` / `__import__("x")` (and a bare `import_module("x")` when the file imported it
443
+ from importlib), name given positionally or as `name=`, literal -> "x", else None. A computed name is not read
444
+ (named residual, contract 2b)."""
445
+ if not isinstance(n, ast.Call):
446
+ return None
447
+ f = n.func
448
+ if not ((isinstance(f, ast.Name) and (f.id == "__import__" or (bare_ok and f.id == "import_module"))) or
449
+ (isinstance(f, ast.Attribute) and f.attr == "import_module" and isinstance(f.value, ast.Name)
450
+ and f.value.id == "importlib")):
451
+ return None
452
+ arg = n.args[0] if n.args else next((k.value for k in n.keywords if k.arg == "name"), None)
453
+ if isinstance(arg, ast.Constant) and isinstance(arg.value, str):
454
+ return arg.value
455
+ return None
456
+
457
+
458
+ def _guarded_lines(tree):
459
+ """Line numbers of imports that run inside a `try:` body whose handlers catch ImportError / ModuleNotFoundError /
460
+ Exception / BaseException (or everything), by a name the file does not rebind."""
461
+ bound = _bound_names(tree)
462
+ bare = _bare_import_module(tree)
463
+
464
+ def _catches(x):
465
+ if isinstance(x, ast.Name):
466
+ return x.id in _CATCH and x.id not in bound
467
+ return (isinstance(x, ast.Attribute) and isinstance(x.value, ast.Name) and x.value.id == "builtins"
468
+ and "builtins" not in bound and x.attr in _CATCH)
469
+
470
+ def _imports_run_now(st):
471
+ # A def / lambda body inside the try runs later, outside the try: its imports are not guarded by it.
472
+ # (Named residual: default arguments and decorators do run at definition time; skipping them errs toward BLOCK.)
473
+ stack = [st]
474
+ while stack:
475
+ n = stack.pop()
476
+ if isinstance(n, (ast.FunctionDef, ast.AsyncFunctionDef, ast.Lambda)):
477
+ continue
478
+ if isinstance(n, ast.GeneratorExp):
479
+ # A generator runs on next(), outside the try; only its first iterable is evaluated here.
480
+ stack.append(n.generators[0].iter)
481
+ continue
482
+ if isinstance(n, (ast.Import, ast.ImportFrom)) or _dynamic_import(n, bare):
483
+ yield n.lineno
484
+ stack.extend(ast.iter_child_nodes(n))
485
+
486
+ out = set()
487
+ for node in ast.walk(tree):
488
+ if not isinstance(node, ast.Try):
489
+ continue
490
+ catches = False
491
+ for h in node.handlers:
492
+ t = h.type
493
+ names = [t] if t is not None and not isinstance(t, ast.Tuple) else (t.elts if t is not None else [])
494
+ if t is None or any(_catches(x) for x in names):
495
+ catches = True
496
+ if catches:
497
+ for st in node.body:
498
+ out.update(_imports_run_now(st))
499
+ return out
500
+
501
+
502
+ def runtime_deps(m, repo, vd):
503
+ """Spec section 2b: a module's python is stdlib-only, or each non-stdlib import is guarded so its absence can be
504
+ reported as UNMEASURED (exit 2, naming it). Unguarded non-stdlib import -> BLOCK; guarded -> NOTE (the floor run
505
+ environment may not have it). Unparsable python -> UNMEASURED. Only .py files are read (named residual: shell
506
+ scripts calling jq / yq / node are not checked)."""
507
+ paths, _prob = module_paths(m, repo)
508
+ files = []
509
+ for rel in paths:
510
+ full = os.path.join(repo, rel)
511
+ if os.path.isdir(full):
512
+ for dp, dn, fns in os.walk(full):
513
+ dn[:] = sorted(d for d in dn if d not in (".git", "__pycache__"))
514
+ files += [os.path.join(dp, f) for f in sorted(fns) if f.endswith(".py")]
515
+ elif full.endswith(".py") and os.path.isfile(full):
516
+ files.append(full)
517
+ shipped = {os.path.realpath(f) for f in files}
518
+
519
+ def _is_local(mod, importer):
520
+ # Python puts the running script's folder first on sys.path; a module inside a shipped package resolves from an
521
+ # ancestor folder. So a name is local when <dir>/<mod>.py or <dir>/<mod>/__init__.py is shipped in the
522
+ # importer's folder or one of its ancestors -- not anywhere in the module.
523
+ d = os.path.dirname(os.path.realpath(importer))
524
+ while True:
525
+ if os.path.join(d, mod + ".py") in shipped or os.path.join(d, mod, "__init__.py") in shipped:
526
+ return True
527
+ up = os.path.dirname(d)
528
+ if up == d or not up.startswith(os.path.realpath(repo)):
529
+ return False
530
+ d = up
531
+
532
+ import tokenize
533
+ for f in sorted(set(files)):
534
+ rel = os.path.relpath(f, repo)
535
+ try:
536
+ with tokenize.open(f) as fh: # honours a PEP 263 coding cookie, as Python does
537
+ tree = ast.parse(fh.read(), filename=rel)
538
+ except (OSError, UnicodeDecodeError, SyntaxError, ValueError) as e:
539
+ vd.unm("runtime dependencies of %s cannot be read: %s" % (rel, e))
540
+ continue
541
+ guarded = _guarded_lines(tree)
542
+ bare = _bare_import_module(tree)
543
+ seen = set()
544
+ for node in ast.walk(tree):
545
+ if isinstance(node, ast.Import):
546
+ mods = [a.name.split(".")[0] for a in node.names]
547
+ elif isinstance(node, ast.ImportFrom) and node.level == 0 and node.module:
548
+ mods = [node.module.split(".")[0]]
549
+ elif _dynamic_import(node, bare):
550
+ mods = [_dynamic_import(node, bare).split(".")[0]]
551
+ else:
552
+ continue
553
+ for mod in mods:
554
+ if (mod, node.lineno) in seen or not mod or mod == "__future__" or _is_stdlib(mod) or _is_local(mod, f):
555
+ continue
556
+ seen.add((mod, node.lineno))
557
+ if node.lineno in guarded:
558
+ vd.notes.append("runtime dependency %s (%s:%d) is not stdlib; guarded — allowed only when a stdlib route is not feasible (contract 2b); its absence must exit 2 "
559
+ "(UNMEASURED) naming it, and the floor run environment may not have it" % (mod, rel, node.lineno))
560
+ else:
561
+ vd.block("runtime dependency %s (%s:%d) is not stdlib and not guarded — in an environment without it "
562
+ "the module crashes instead of answering UNMEASURED; make it stdlib-only, or guard the import "
563
+ "and exit 2 naming the missing module" % (mod, rel, node.lineno))
564
+
565
+
387
566
  def load_installed(d):
388
567
  mods, errs, dups = {}, [], []
389
568
  if not os.path.isdir(d):
@@ -416,6 +595,8 @@ def cmd_check(a):
416
595
  if cerr:
417
596
  vd.unm(cerr)
418
597
  validate(m, vd, core, repo)
598
+ if isinstance(m, dict):
599
+ runtime_deps(m, repo, vd)
419
600
  if a.installed:
420
601
  inst, errs, dups = load_installed(a.installed)
421
602
  for e in errs: vd.unm("installed registry unreadable: " + e)
@@ -18,6 +18,7 @@
18
18
  # «확인 없이/알아서» 류와 같은(또는 바로 다음) 문장에서 허용.
19
19
  # 경고(rc 무영향): W1 읽기 전용 주장 vs 쓰기·Bash 도구(tools 없음=전부 상속 포함) · W2 tools 줄 없음(전부 상속) · W7 스킬 파일명이 SKILL.md 아님 ·
20
20
  # W4 죽은 참조 · W6 스킬 description 비어 있음.
21
+ # 정보 W8: 스킬 description 에 질문 모양 예시(«…?») 없음 — 질문으로 오는 요청에서 스스로 불리지 않을 수 있다.
21
22
  # 정보: W3 Bash 범위 제한 서술 없음 · W5 Done When 없음(FH 기준, 생성기 결함 아님) ·
22
23
  # 아직 없는 입출력 경로(자리표시자·디렉터리·_workspace·런타임 산출 파일명).
23
24
  #
@@ -589,6 +590,9 @@ def check(target, exclude_skills=()):
589
590
  continue
590
591
  if not fm.get("description", "").strip():
591
592
  rep.add("warn", "W6", path, where.get("description", 1), "(description 비어 있음)", "")
593
+ elif not re.search(r"[??]", fm.get("description", "")):
594
+ rep.add("info", "W8", path, where.get("description", 1), "description 에 질문 모양 예시 없음",
595
+ "활동 이름만 적은 description 은 «머지해도 돼?» · «몇 파일?» 류 질문에서 스스로 불리지 않았다 (A/B C7–C12: 활동 요청 9/9 · 예/아니오 질문 0–1/9)")
592
596
  if not DONE_WHEN_RE.search(text):
593
597
  rep.add("info", "W5", path, 1, "Done When 절 없음", "FH 기준이다 — 생성기의 결함이 아니다")
594
598
 
@@ -61,6 +61,11 @@ ACCEPTED_ABSENT=(
61
61
  # has no such file and no such convention, so shipping it would ship a tool with nothing to act on.
62
62
  "scripts/lease_line_apply.sh"
63
63
  "scripts/test_lease_line_apply_lanes.sh"
64
+ # 2026-11-11 — shared session ledger (root/child sessions of this hub). Pilot for this hub's thin-root operation;
65
+ # whether consumers get it is an operator decision after the pilot, so not shipped yet.
66
+ "scripts/session_ledger_write.sh"
67
+ "scripts/session_ledger_read.py"
68
+ "scripts/test_session_ledger_lanes.sh"
64
69
  # 2026-11-07 — context-continuity read half (AQ-20261107-10/-12). Governor tools for this hub: the hook reads the
65
70
  # hub's lease-file convention (CLAUDE.local.md «utterance» lines) and its snippet is not shipped either, so
66
71
  # shipping the script alone would hand consumers a hook nothing calls. Ship both together, or neither.