@chrono-meta/fh-gate 3.32.0 → 3.33.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 (28) hide show
  1. package/.claude-plugin/marketplace.json +4 -4
  2. package/AGENTS.md +23 -0
  3. package/CATALOG.md +44 -0
  4. package/CLAUDE.md +2 -2
  5. package/knowledge/shared/harness-core/claude_md_full_reference.md +19 -0
  6. package/knowledge/shared/harness-core/dispatch_conditional_prohibition.md +9 -0
  7. package/knowledge/shared/learnings/subagent_invocations_log.yaml +56 -0
  8. package/knowledge/shared/rules/operations.md +11 -0
  9. package/knowledge/shared/rules/sister_asset_protocol.md +21 -2
  10. package/package.json +3 -1
  11. package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
  12. package/plugins/fh-commons/skills/ko-tech-writer/SKILL.md +28 -0
  13. package/plugins/fh-commons/skills/ko-tech-writer/fixtures/known_negative.md +32 -0
  14. package/plugins/fh-commons/skills/ko-tech-writer/fixtures/known_positive.md +22 -0
  15. package/plugins/fh-commons/skills/ko-tech-writer/fixtures/rewrite_clean.md +4 -0
  16. package/plugins/fh-commons/skills/ko-tech-writer/fixtures/rewrite_drops_metaphor.md +4 -0
  17. package/plugins/fh-commons/skills/ko-tech-writer/fixtures/rewrite_invents_number.md +4 -0
  18. package/plugins/fh-commons/skills/ko-tech-writer/fixtures/rewrite_keep.txt +2 -0
  19. package/plugins/fh-commons/skills/ko-tech-writer/fixtures/rewrite_original.md +4 -0
  20. package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
  21. package/plugins/fh-meta/CHANGELOG.md +19 -0
  22. package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
  23. package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
  24. package/scripts/absorption_queue.py +417 -0
  25. package/scripts/fh_session_load.sh +12 -0
  26. package/scripts/ko_tech_writer_calibrate.py +284 -7
  27. package/scripts/selfcheck.sh +1 -0
  28. package/scripts/test_absorption_queue_lanes.sh +10 -0
@@ -0,0 +1,417 @@
1
+ #!/usr/bin/env python3
2
+ """absorption_queue.py — 바깥에서 들어온 «가져올 것» 이 사람 기억 말고 기록에 남게 한다.
3
+
4
+ 왜 (2026-10-28 실측): 외부 자산 감사(techwriting-min-check, 10-27)가 «가져올 것 5» 를 냈는데
5
+ 하루 동안 아무도 안 집었다. 운영자가 다음 날 발표 요약을 직접 붙여 넣고서야 ko-tech-writer 가
6
+ 고쳐졌다. 흡수 고리에서 끊긴 곳은 둘이다:
7
+ ② 바깥 신호 → 우리 자산 짝짓기가 «누가 기시감을 느끼느냐» 에 달렸다
8
+ ④ 비교표 · 후보 목록에 읽는 쪽(소비처)이 없다
9
+ digest 쪽에는 착지 증언(digest_landing_check.sh)이 있지만 결과는 로그 파일에만 가고, 그 판별
10
+ 토큰은 `arXiv:2610.x` 가 콜론에서 잘려 `arXiv` 한 낱말이 되는 경우가 있어 «착지» 가 어휘 우연으로
11
+ 나올 수 있다(10-28 실측: 10-26 digest 후보 셋 다 토큰이 `arXiv` 하나뿐이었고 그날 판정은 ALL-LANDED).
12
+ 그래서 이 대기열은 낱말 추론으로 닫지 않는다.
13
+
14
+ 기계가 하는 일은 기록의 성질만이다(present · typed · attributable). 무엇을 가져올지, 그게 정말
15
+ 착지했는지는 판단이고 닫는 사람이 근거를 적는다:
16
+ landed — 근거에 PR 번호(#123 · /pull/123) 나 commit:<해시> · <레포>@<해시> 가 있어야 한다
17
+ declined · deferred — 사유 낱말이 있어야 한다(빈 칸 · «-» 금지)
18
+
19
+ 사용:
20
+ absorption_queue.py add --source <URL|경로|digest:파일> --item "<한 줄>" [--asset <경로> ...]
21
+ absorption_queue.py import-digest <frontier_digest_*.md> # digest_landing_check.sh --extract 의 후보를 넣는다
22
+ absorption_queue.py close <ID> --status landed|declined|deferred --evidence "<PR#·커밋·사유>"
23
+ absorption_queue.py list [--open]
24
+ absorption_queue.py summary # 세션 시작용 한 줄 — 열린 항목이 없거나 파일이 없으면 아무것도 안 찍는다
25
+ absorption_queue.py match "<텍스트>" # 우리 자산 후보(어휘 선별기 — 열어서 판단)
26
+ absorption_queue.py --self-test
27
+
28
+ 대기열 파일: $FH_ABSORPTION_QUEUE, 없으면 <레포>/tracks/_meta/absorption_queue.tsv (gitignored 자리).
29
+ exit: 0 성공 · 1 self-test 실패 · 2 기록 규칙 위반(아무것도 안 씀) · 10 입력 오류 · 추출기 실패
30
+ """
31
+ import datetime
32
+ import fcntl
33
+ import os
34
+ import re
35
+ import subprocess
36
+ import sys
37
+ import tempfile
38
+
39
+ HERE = os.path.dirname(os.path.abspath(__file__))
40
+ ROOT = os.environ.get("CLAUDE_PROJECT_DIR") or os.path.dirname(HERE)
41
+ COLS = ["id", "added", "source", "item", "assets", "status", "closed", "evidence"]
42
+ STATUSES = ("open", "landed", "declined", "deferred")
43
+ # PR 번호(#975 · …/pull/975) 또는 **명시 표기한** 커밋(commit:5cac232 · <레포>@5cac232).
44
+ # 맨 16진수는 받지 않는다 — 모양으로 «커밋인가» 를 짐작하면 낱말 «defaced» 가 통과하고(codex R1),
45
+ # 그걸 막으려 숫자를 요구하면 진짜 해시 «deadbee» 가 거부된다(codex R2). 두 라운드가 서로를
46
+ # 낳았으므로 짐작을 그만두고 표기를 요구한다. 해시가 실재하는지는 안 본다(다른 레포 커밋일 수 있다).
47
+ PR_REF = re.compile(r"(?:^|[^\w])#\d+\b|/pull/\d+\b")
48
+ HASH_REF = re.compile(r"(?:\bcommit:\s*|[\w.-]@)[0-9a-f]{7,40}\b")
49
+ REASON = re.compile(r"[^\W\d_]{2,}") # 글자 두 개 이상 — «123» · «__» 는 사유가 아니다
50
+
51
+
52
+ def attributable(ev):
53
+ return bool(PR_REF.search(ev) or HASH_REF.search(ev))
54
+
55
+
56
+ def qpath():
57
+ return os.environ.get("FH_ABSORPTION_QUEUE") or os.path.join(ROOT, "tracks", "_meta", "absorption_queue.tsv")
58
+
59
+
60
+ def today():
61
+ return os.environ.get("AQ_TODAY") or datetime.date.today().isoformat()
62
+
63
+
64
+ def clean(s):
65
+ return re.sub(r"[\t\r\n]+", " ", s or "").strip()
66
+
67
+
68
+ def load(path):
69
+ rows = []
70
+ if not os.path.exists(path):
71
+ return rows
72
+ with open(path, encoding="utf-8") as f:
73
+ for n, line in enumerate(f):
74
+ line = line.rstrip("\n")
75
+ if not line or line.startswith("#"):
76
+ continue
77
+ parts = line.split("\t")
78
+ if parts[0] == "id":
79
+ continue
80
+ if len(parts) != len(COLS):
81
+ raise ValueError("%s:%d 칸 수 %d (기대 %d)" % (path, n + 1, len(parts), len(COLS)))
82
+ r = dict(zip(COLS, parts))
83
+ # 읽을 때 검증한다 — 오타 status(«opne») 나 근거 없는 landed 가 «열린 것 0» 으로 읽히면
84
+ # 세션 시작 줄이 조용히 사라진다(codex R1).
85
+ bad = ("status %r" % r["status"]) if r["status"] not in STATUSES else \
86
+ "source/item 비어 있음" if not r["source"] or not r["item"] else \
87
+ ("added 날짜 %r" % r["added"]) if days_between(r["added"], r["added"]) is None else \
88
+ "열린 행에 closed 날짜" if r["status"] == "open" and r["closed"] else \
89
+ ("closed 날짜 %r" % r["closed"]) if r["status"] != "open" and days_between(r["closed"], r["closed"]) is None else \
90
+ "id 비어 있음" if not r["id"] else \
91
+ ("id 중복 %s" % r["id"]) if any(x["id"] == r["id"] for x in rows) else \
92
+ "landed 인데 근거가 PR/커밋이 아님" if r["status"] == "landed" and not attributable(r["evidence"]) else \
93
+ "닫혔는데 사유 없음" if r["status"] in ("declined", "deferred") and not REASON.search(r["evidence"]) else ""
94
+ if bad:
95
+ raise ValueError("%s:%d %s" % (path, n + 1, bad))
96
+ rows.append(r)
97
+ return rows
98
+
99
+
100
+ def save(path, rows):
101
+ os.makedirs(os.path.dirname(path) or ".", exist_ok=True)
102
+ fd, tmp = tempfile.mkstemp(dir=os.path.dirname(path) or ".", prefix=".aq_")
103
+ with os.fdopen(fd, "w", encoding="utf-8") as f:
104
+ f.write("\t".join(COLS) + "\n")
105
+ for r in rows:
106
+ f.write("\t".join(clean(r.get(c, "")) for c in COLS) + "\n")
107
+ os.replace(tmp, path)
108
+
109
+
110
+ def next_id(rows):
111
+ stem = "AQ-" + today().replace("-", "")
112
+ n = sum(1 for r in rows if r["id"].startswith(stem + "-"))
113
+ return "%s-%d" % (stem, n + 1)
114
+
115
+
116
+ def add_row(rows, source, item, assets=()):
117
+ source, item = clean(source), clean(item)
118
+ if not source or not item:
119
+ return None, "source 와 item 은 비울 수 없다"
120
+ for r in rows:
121
+ if r["source"] == source and r["item"] == item:
122
+ return r, "dup"
123
+ r = {"id": next_id(rows), "added": today(), "source": source, "item": item,
124
+ "assets": " ".join(clean(a) for a in assets if clean(a)), "status": "open", "closed": "", "evidence": ""}
125
+ rows.append(r)
126
+ return r, "added"
127
+
128
+
129
+ def close_row(rows, rid, status, evidence):
130
+ evidence = clean(evidence)
131
+ hit = [r for r in rows if r["id"] == rid]
132
+ if not hit:
133
+ return "없는 ID: %s" % rid
134
+ if status not in STATUSES[1:]:
135
+ return "status 는 landed · declined · deferred 중 하나"
136
+ if status == "landed" and not attributable(evidence):
137
+ return "landed 는 근거에 PR 번호(#123 · /pull/123)나 commit:<해시> · <레포>@<해시> 가 있어야 한다 — 받은 값: %r" % evidence
138
+ if status != "landed" and not REASON.search(evidence):
139
+ return "%s 는 사유를 적어야 한다 — 받은 값: %r" % (status, evidence)
140
+ hit[0].update(status=status, closed=today(), evidence=evidence)
141
+ return None
142
+
143
+
144
+ def days_between(a, b):
145
+ try:
146
+ return (datetime.date.fromisoformat(b) - datetime.date.fromisoformat(a)).days
147
+ except ValueError:
148
+ return None
149
+
150
+
151
+ def summary_line(rows, path):
152
+ op = [r for r in rows if r["status"] == "open"]
153
+ if not op:
154
+ return ""
155
+ ages = [d for d in (days_between(r["added"], today()) for r in op) if d is not None]
156
+ oldest = max(ages) if ages else None
157
+ no_asset = sum(1 for r in op if not r["assets"])
158
+ rel = os.path.relpath(path, ROOT) if path.startswith(ROOT) else path
159
+ return ("📥 [흡수 대기열] 열림 %d · 가장 오래된 것 %s일 · 우리 자산 미지정 %d — %s"
160
+ " (닫기: scripts/absorption_queue.py close <ID> --status landed|declined|deferred --evidence ...)"
161
+ % (len(op), "?" if oldest is None else oldest, no_asset, rel))
162
+
163
+
164
+ def extract_digest(digest):
165
+ """digest_landing_check.sh --extract 를 그대로 쓴다 — 후보 판정 규칙을 여기 다시 쓰지 않는다."""
166
+ checker = os.path.join(HERE, "digest_landing_check.sh")
167
+ if not os.path.isfile(checker):
168
+ return None, "digest_landing_check.sh 없음"
169
+ p = subprocess.run(["bash", checker, "--extract", digest], capture_output=True, text=True)
170
+ if p.returncode != 0:
171
+ return None, "추출기 rc=%d: %s" % (p.returncode, (p.stderr or p.stdout).strip()[:200])
172
+ items = []
173
+ for line in p.stdout.splitlines():
174
+ parts = line.split("\t")
175
+ if parts[0] == "TARGET" and len(parts) >= 3:
176
+ items.append(re.sub(r"^후보\s*", "", parts[2]))
177
+ elif parts[0] == "# UNCHECKABLE" and len(parts) >= 2:
178
+ items.append(parts[1])
179
+ if not items:
180
+ return None, "후보 0개 — 절을 못 찾았거나 비었다(0 이 아니라 미측정)"
181
+ return items, None
182
+
183
+
184
+ def skill_index():
185
+ """FH 플러그인 + 매핑된 필드 하네스의 SKILL.md 이름 · 설명."""
186
+ roots = [os.path.join(ROOT, "plugins")]
187
+ proj_root = os.environ.get("FH_PROJECTS_ROOT") or os.path.dirname(ROOT)
188
+ tracks = os.path.join(ROOT, "tracks")
189
+ if os.path.isdir(tracks):
190
+ for t in sorted(os.listdir(tracks)):
191
+ if not t.startswith("_") and os.path.isdir(os.path.join(proj_root, t)):
192
+ roots.append(os.path.join(proj_root, t))
193
+ out = []
194
+ for r in roots:
195
+ for d, dirs, files in os.walk(r):
196
+ dirs[:] = [x for x in dirs if x not in (".git", "node_modules", "worktrees", ".claude-worktrees")]
197
+ # 스킬만 보면 검토 에이전트(agents/*.md)가 빠진다 — 10-28 첫 실사용에서 «검토 페르소나 출력»
198
+ # 항목의 짝(persona lens 에이전트)이 후보에 안 나왔다.
199
+ cand = (["SKILL.md"] if "SKILL.md" in files else []) + \
200
+ ([f for f in files if f.endswith(".md")] if os.path.basename(d) == "agents" else [])
201
+ for fn in cand:
202
+ p = os.path.join(d, fn)
203
+ try:
204
+ head = open(p, encoding="utf-8", errors="replace").read(4000)
205
+ except OSError:
206
+ continue
207
+ name = re.search(r"^name:\s*(.+)$", head, re.M)
208
+ desc = re.search(r"^description:\s*(.+)$", head, re.M)
209
+ out.append((p, (name.group(1) if name else (os.path.basename(d) if fn == "SKILL.md" else fn[:-3])).strip(), (desc.group(1) if desc else "").strip()))
210
+ return out
211
+
212
+
213
+ def tokens(s):
214
+ return {w.lower() for w in re.findall(r"[A-Za-z][A-Za-z0-9_-]{2,}|[가-힣]{2,}", s)}
215
+
216
+
217
+ def match(text, top=5):
218
+ want = tokens(text)
219
+ scored = []
220
+ for p, name, desc in skill_index():
221
+ have = tokens(name + " " + desc + " " + name.replace("-", " "))
222
+ hit = want & have
223
+ if hit:
224
+ scored.append((len(hit), p, name, sorted(hit)[:6]))
225
+ scored.sort(key=lambda x: (-x[0], x[1]))
226
+ return scored[:top]
227
+
228
+
229
+ def main(argv):
230
+ if not argv or argv[0] in ("-h", "--help"):
231
+ print(__doc__)
232
+ return 0 if argv else 10
233
+ if argv[0] == "--self-test":
234
+ return self_test()
235
+ cmd, rest = argv[0], argv[1:]
236
+ path = qpath()
237
+ lock = None
238
+ if cmd in ("add", "import-digest", "close"):
239
+ # 매일 09:00 잡과 대화 세션이 같은 파일을 읽고-고치고-바꾼다. 잠금 없이는 늦게 쓴 쪽이
240
+ # 먼저 쓴 쪽의 변경을 지운다(codex R1). 잠금은 읽기 전에 잡고 바꾼 뒤에 놓는다.
241
+ try:
242
+ os.makedirs(os.path.dirname(path) or ".", exist_ok=True)
243
+ lock = open(path + ".lock", "w")
244
+ fcntl.flock(lock, fcntl.LOCK_EX)
245
+ except OSError as e:
246
+ print("🟥 잠금 실패: %s" % e, file=sys.stderr)
247
+ return 10
248
+ try:
249
+ rows = load(path)
250
+ except (ValueError, OSError) as e:
251
+ print("🟥 대기열을 못 읽었다: %s" % e, file=sys.stderr)
252
+ return 10
253
+
254
+ def opt(name, many=False):
255
+ vals, i = [], 0
256
+ while i < len(rest):
257
+ if rest[i] == name and i + 1 < len(rest):
258
+ vals.append(rest[i + 1])
259
+ i += 2
260
+ else:
261
+ i += 1
262
+ return vals if many else (vals[-1] if vals else "")
263
+
264
+ if cmd == "add":
265
+ r, how = add_row(rows, opt("--source"), opt("--item"), opt("--asset", many=True))
266
+ if r is None:
267
+ print("🟥 %s" % how, file=sys.stderr)
268
+ return 2
269
+ if how == "added":
270
+ save(path, rows)
271
+ print("%s %s" % ("추가" if how == "added" else "이미 있음", r["id"]))
272
+ return 0
273
+ if cmd == "import-digest":
274
+ if not rest or not os.path.isfile(rest[0]):
275
+ print("🟥 digest 파일이 필요하다", file=sys.stderr)
276
+ return 10
277
+ items, err = extract_digest(rest[0])
278
+ if err:
279
+ print("🟥 %s" % err, file=sys.stderr)
280
+ return 10
281
+ src = "digest:" + os.path.basename(rest[0])
282
+ n_add = 0
283
+ for it in items:
284
+ r, how = add_row(rows, src, it)
285
+ n_add += how == "added"
286
+ if n_add:
287
+ save(path, rows)
288
+ print("digest 후보 %d개 중 새로 %d개 넣음 (%s)" % (len(items), n_add, src))
289
+ return 0
290
+ if cmd == "close":
291
+ if not rest:
292
+ print("🟥 ID 가 필요하다", file=sys.stderr)
293
+ return 10
294
+ err = close_row(rows, rest[0], opt("--status"), opt("--evidence"))
295
+ if err:
296
+ print("🟥 %s — 아무것도 안 썼다" % err, file=sys.stderr)
297
+ return 2
298
+ save(path, rows)
299
+ print("닫음 %s" % rest[0])
300
+ return 0
301
+ if cmd == "list":
302
+ only_open = "--open" in rest
303
+ for r in rows:
304
+ if only_open and r["status"] != "open":
305
+ continue
306
+ print("%s\t%s\t%s\t%s\t%s%s" % (r["id"], r["status"], r["added"], r["item"][:90], r["source"],
307
+ ("\t→ " + r["evidence"]) if r["evidence"] else ""))
308
+ return 0
309
+ if cmd == "summary":
310
+ line = summary_line(rows, path)
311
+ if line:
312
+ print(line)
313
+ return 0
314
+ if cmd == "match":
315
+ res = match(" ".join(rest))
316
+ print("# 어휘 선별기 — 겹치는 낱말 수로만 줄 세웠다. 열어서 판단하라(0건 ≠ 짝 없음).")
317
+ for n, p, name, hit in res:
318
+ print("%d\t%s\t%s\t%s" % (n, name, os.path.relpath(p, ROOT), ",".join(hit)))
319
+ return 0
320
+ print("🟥 모르는 명령: %s" % cmd, file=sys.stderr)
321
+ return 10
322
+
323
+
324
+ def self_test():
325
+ res = []
326
+ with tempfile.TemporaryDirectory() as td:
327
+ q = os.path.join(td, "q.tsv")
328
+ env = dict(os.environ, FH_ABSORPTION_QUEUE=q, AQ_TODAY="2026-10-28")
329
+
330
+ def run(*a, **kw):
331
+ e = dict(env, **kw.get("env", {}))
332
+ p = subprocess.run([sys.executable, os.path.abspath(__file__)] + list(a), capture_output=True, text=True, env=e)
333
+ return p.returncode, p.stdout + p.stderr
334
+
335
+ rc, out = run("summary")
336
+ res.append(("S1 no queue file → summary prints nothing, rc 0", rc == 0 and out.strip() == ""))
337
+ rc, out = run("add", "--source", "https://example.org/x", "--item", "가져올 것 하나")
338
+ res.append(("A1 add writes an open row", rc == 0 and "AQ-20261028-1" in out))
339
+ rc, out = run("add", "--source", "https://example.org/x", "--item", "가져올 것 하나")
340
+ res.append(("A2 same source+item is not added twice", rc == 0 and "이미 있음" in out and len(load(q)) == 1))
341
+ rc, out = run("add", "--source", "", "--item", "x")
342
+ res.append(("A3 empty source refused (rc 2)", rc == 2))
343
+ rc, out = run("summary", env={"AQ_TODAY": "2026-10-31"})
344
+ res.append(("S2 control: one open row → summary names count 1 and age 3", rc == 0 and "열림 1" in out and "3일" in out))
345
+ rc, out = run("close", "AQ-20261028-1", "--status", "landed", "--evidence", "done")
346
+ res.append(("C1 landed without PR#/commit refused, nothing written", rc == 2 and load(q)[0]["status"] == "open"))
347
+ rc, out = run("close", "AQ-20261028-1", "--status", "declined", "--evidence", "-")
348
+ res.append(("C2 declined without a reason refused", rc == 2 and load(q)[0]["status"] == "open"))
349
+ rc, out = run("close", "AQ-20261028-1", "--status", "landed", "--evidence", "PR #975")
350
+ res.append(("C3 control: landed with PR# closes", rc == 0 and load(q)[0]["status"] == "landed"))
351
+ rc, out = run("close", "AQ-20261028-1", "--status", "landed", "--evidence", "abc")
352
+ res.append(("C4 a 3-char hex is not a commit", rc == 2))
353
+ rc, out = run("summary")
354
+ res.append(("S3 all closed → summary prints nothing", rc == 0 and out.strip() == ""))
355
+ # codex R1 — 근거 규칙의 양쪽
356
+ run("add", "--source", "s2", "--item", "둘")
357
+ rcs = tuple(run("close", "AQ-20261028-2", "--status", st, "--evidence", ev)[0]
358
+ for st, ev in (("landed", "defaced"), ("landed", "1234567"), ("landed", "deadbee"),
359
+ ("declined", "__"), ("declined", "123")))
360
+ res.append(("R1 bare hex/digits are not evidence; «__» · «123» are not reasons", rcs == (2, 2, 2, 2, 2)))
361
+ rc, _ = run("close", "AQ-20261028-2", "--status", "landed", "--evidence", "https://github.com/o/r/pull/975")
362
+ res.append(("R2 control: a PR URL is evidence", rc == 0))
363
+ run("add", "--source", "s3", "--item", "셋")
364
+ rc, _ = run("close", "AQ-20261028-3", "--status", "landed", "--evidence", "commit:deadbee (hash without digits)")
365
+ run("add", "--source", "s4", "--item", "넷")
366
+ rc2, _ = run("close", "AQ-20261028-4", "--status", "landed", "--evidence", "friends-on-desk@f1a96e4")
367
+ res.append(("R3 control: commit:<hex> and <repo>@<hex> are evidence (digits not required)", (rc, rc2) == (0, 0)))
368
+ rc, out = run("close", "AQ-nope", "--status", "declined", "--evidence", "중복")
369
+ res.append(("C5 unknown ID refused", rc == 2))
370
+ # digest — 같은 절 규칙(digest_landing_check --extract)을 쓰는지, 두 번 넣어도 한 번인지
371
+ d = os.path.join(td, "frontier_digest_2026_10_28.md")
372
+ with open(d, "w", encoding="utf-8") as f:
373
+ f.write("# d\n\n## FH Immediate Application Candidates\n\n"
374
+ "- **후보 하나 (`builtin_capability_map`).** 본문.\n"
375
+ "- **후보 둘 — 토큰 없음.** 본문.\n\n## Warning Signals\n\n- 무관\n")
376
+ n0 = len(load(q))
377
+ rc, out = run("import-digest", d, env={"CLAUDE_PROJECT_DIR": ROOT})
378
+ n1 = len(load(q))
379
+ rc2, out2 = run("import-digest", d, env={"CLAUDE_PROJECT_DIR": ROOT})
380
+ res.append(("D1 digest candidates enter the queue (incl. UNCHECKABLE), second import adds 0",
381
+ rc == 0 and n1 == n0 + 2 and rc2 == 0 and len(load(q)) == n1 and "새로 0개" in out2))
382
+ e = os.path.join(td, "frontier_digest_empty.md")
383
+ with open(e, "w", encoding="utf-8") as f:
384
+ f.write("# d\n\n## Warning Signals\n\n- 무관\n")
385
+ rc, out = run("import-digest", e, env={"CLAUDE_PROJECT_DIR": ROOT})
386
+ res.append(("D2 digest without the section is an error (rc 10), not 0 candidates", rc == 10 and len(load(q)) == n1))
387
+ # 동시 쓰기 — 잠금이 없으면 늦게 쓴 쪽이 앞의 행을 지운다
388
+ procs = [subprocess.Popen([sys.executable, os.path.abspath(__file__), "add", "--source", "par", "--item", "p%d" % i],
389
+ env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) for i in range(12)]
390
+ for pr in procs:
391
+ pr.wait()
392
+ par = [r for r in load(q) if r["source"] == "par"]
393
+ res.append(("W1 12 concurrent adds keep 12 rows with 12 distinct ids", len(par) == 12 and len({r["id"] for r in par}) == 12))
394
+ good = open(q, encoding="utf-8").read()
395
+ for label, row in (("L2 a typo status («opne») is an error, not «nothing open»", "AQ-x\t2026-10-28\ts\ti\t\topne\t\t\n"),
396
+ ("L3 a landed row without PR/commit evidence is an error", "AQ-y\t2026-10-28\ts\ti\t\tlanded\t2026-10-28\tdone\n"),
397
+ ("L4 a row with an empty item is an error", "AQ-z\t2026-10-28\ts\t\t\topen\t\t\n"),
398
+ ("L5 a row with a bad added date is an error", "AQ-w\t28/10/2026\ts\ti\t\topen\t\t\n"),
399
+ ("L1 a malformed row is an error (rc 10), not silently skipped", "broken\trow\n")):
400
+ with open(q, "w", encoding="utf-8") as f:
401
+ f.write(good + row)
402
+ rc, out = run("summary")
403
+ res.append((label, rc == 10))
404
+ m = match("ko-tech-writer 번역투 기술블로그 개고")
405
+ res.append(("M1 match finds ko-tech-writer for its own vocabulary", any(name == "ko-tech-writer" for _, _, name, _ in m)))
406
+ m2 = match("QA 엔지니어 테스트 케이스 재현 화면")
407
+ res.append(("M2 match also indexes agent definitions (qa-lens)", any(p.endswith("agents/qa-lens.md") for _, p, _, _ in m2)))
408
+ ok = 0
409
+ for name, passed in res:
410
+ print("%s %s" % ("OK " if passed else "FAIL", name))
411
+ ok += passed
412
+ print("── PASS=%d FAIL=%d ──" % (ok, len(res) - ok))
413
+ return 0 if ok == len(res) else 1
414
+
415
+
416
+ if __name__ == "__main__":
417
+ sys.exit(main(sys.argv[1:]))
@@ -227,6 +227,18 @@ if [ -d "$_AUDIT_DIR" ] && fh_cadence_due "$_FH_HOOK_SRC"; then
227
227
  fi
228
228
  fi
229
229
 
230
+ # 1-b2) 흡수 대기열 (2026-10-28) — 바깥에서 온 «가져올 것» (digest 후보 · 외부 자산 감사의 가져올
231
+ # 목록 · 운영자가 건넨 링크) 이 열린 채 남아 있으면 한 줄. MEASURED: techwriting 감사의 «가져올 것 5»
232
+ # 가 하루 동안 아무도 안 집었고, 다음 날 운영자가 직접 발표 요약을 들고 와서야 ko-tech-writer 가
233
+ # 고쳐졌다 — 목록은 있었고 읽는 쪽이 없었다. 위 1-b 와 같은 성격: 알리기만 하고 막지 않는다.
234
+ # 파일이 없거나 열린 항목이 0 이면 아무것도 안 찍는다(새 클론을 조르지 않는다).
235
+ _AQ="$FH/scripts/absorption_queue.py"
236
+ if [ -f "$_AQ" ] && fh_cadence_due "$_FH_HOOK_SRC"; then
237
+ # 출력을 받아서 찍는다 — `| head` 는 pipefail 아래 조기종료 소비자 취약형이다(class-lock 레인).
238
+ _AQ_OUT="$(CLAUDE_PROJECT_DIR="$FH" python3 "$_AQ" summary 2>&1)"
239
+ if [ -n "$_AQ_OUT" ]; then printf '%s\n' "$_AQ_OUT"; fi
240
+ fi
241
+
230
242
  # 1-c) harness-doctor cadence — 위 1-b 와 같은 이유로, 같은 훅에서, 한 블록 더.
231
243
  # MEASURED 2026-08-16 (weekly_audit_2026-08-16.md 🟥-3): 직전 감사(07-31)가 «산문 캐던스 미이행»을
232
244
  # N=2 로 집계하면서 **주간감사(50일)와 harness-doctor(당시 ~49일) 둘을 함께** 지목했다. 그 뒤 16일