@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.
- package/.claude-plugin/marketplace.json +4 -4
- package/AGENTS.md +23 -0
- package/CATALOG.md +44 -0
- package/CLAUDE.md +2 -2
- package/knowledge/shared/harness-core/claude_md_full_reference.md +19 -0
- package/knowledge/shared/harness-core/dispatch_conditional_prohibition.md +9 -0
- package/knowledge/shared/learnings/subagent_invocations_log.yaml +56 -0
- package/knowledge/shared/rules/operations.md +11 -0
- package/knowledge/shared/rules/sister_asset_protocol.md +21 -2
- package/package.json +3 -1
- package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-commons/skills/ko-tech-writer/SKILL.md +28 -0
- package/plugins/fh-commons/skills/ko-tech-writer/fixtures/known_negative.md +32 -0
- package/plugins/fh-commons/skills/ko-tech-writer/fixtures/known_positive.md +22 -0
- package/plugins/fh-commons/skills/ko-tech-writer/fixtures/rewrite_clean.md +4 -0
- package/plugins/fh-commons/skills/ko-tech-writer/fixtures/rewrite_drops_metaphor.md +4 -0
- package/plugins/fh-commons/skills/ko-tech-writer/fixtures/rewrite_invents_number.md +4 -0
- package/plugins/fh-commons/skills/ko-tech-writer/fixtures/rewrite_keep.txt +2 -0
- package/plugins/fh-commons/skills/ko-tech-writer/fixtures/rewrite_original.md +4 -0
- package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-meta/CHANGELOG.md +19 -0
- package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
- package/scripts/absorption_queue.py +417 -0
- package/scripts/fh_session_load.sh +12 -0
- package/scripts/ko_tech_writer_calibrate.py +284 -7
- package/scripts/selfcheck.sh +1 -0
- package/scripts/test_absorption_queue_lanes.sh +10 -0
|
@@ -23,8 +23,10 @@ Python `re` 는 ⓐ 세 허용 엔진 중 **어디에나 있는 유일한 것**
|
|
|
23
23
|
|
|
24
24
|
사용: python3 ko_tech_writer_calibrate.py (보정)
|
|
25
25
|
python3 ko_tech_writer_calibrate.py --scan 문서.md (같은 레인·필터로 문서 스캔, 줄\t레인\t본문)
|
|
26
|
+
python3 ko_tech_writer_calibrate.py --check-rewrite --original 원문.md --rewrite 개고.md [--keep 목록.txt] [--listed C9,C15]
|
|
27
|
+
(개고 사후 점검: 남길 곳 · 확인할 곳 · 고칠 곳 세 칸. 발상 출처: 우아콘26 세션 «AI야, 네 글 너무 AI티 나» 의 사후 Eval 3분류. 구현은 이 레포 것)
|
|
26
28
|
|
|
27
|
-
exit: 0 전 레인 판별 · 1 판별 실패(픽스처 부재 포함 — known_unclosed.md 가 없으면 1) · 3 --scan 대상에 안 닫힌 블록 · 10 harness error(입력 오류)
|
|
29
|
+
exit: 0 전 레인 판별 · 1 판별 실패(--check-rewrite 에서는 어느 칸이든 FAIL 또는 UNSURE) · 2 --check-rewrite 에서 FAIL 은 없으나 남길 곳 목록이 없어 UNMEASURED(픽스처 부재 포함 — known_unclosed.md 가 없으면 1) · 3 --scan 대상에 안 닫힌 블록 · 10 harness error(입력 오류)
|
|
28
30
|
"""
|
|
29
31
|
import os
|
|
30
32
|
import re
|
|
@@ -79,6 +81,12 @@ LANES = [
|
|
|
79
81
|
# ── 경동사 «내다» 후보 (S23 변종). 🟥 UNCALIBRATED: 「판정을 내리다」는 관용구라 «내는» 도 정상 용례가 많다 → 과차단이 예상 결과.
|
|
80
82
|
# 판별력을 주장하지 않는다. 잡는 형태 둘: 따옴표 명사+를 냈다 / 판정을 내는.
|
|
81
83
|
("C15 경동사 내다(후보·UNCALIBRATED)", r"['’”」»』\"`]\s?(을|를) (냈|낸|내는|낼|냅)|판정을 (냈|낸|내는|낼|냅)", "candidate", "uncalibrated", "neg=1"),
|
|
84
|
+
# ── AI티 후보 클래스 C17~C21 (우아콘26 세션 «AI티 패턴» 목록에서 온 후보. 🟥 운영자 교정 쌍 없음 — 구성한 쌍으로만 판별을 잰다, 실문서 정밀도 UNMEASURED)
|
|
85
|
+
("C17 가운뎃점 밀도(한 줄 3개 이상·후보)", r"(?:·[^·\n]*){3}"),
|
|
86
|
+
("C18 대조형 «X가 아니라 Y입니다» 문말(후보)", r"[이가] 아니라 [^.\n]{1,50}(입니다|이다)[.\s]*(<!--.*)?$"),
|
|
87
|
+
("C19 분열문 «~할 점은 ~입니다»(후보)", r"(할|둘|볼) 점은 [^.\n]*(입니다|이다)"),
|
|
88
|
+
("C20 소제목 과밀(연속 3절 이상이 단락 2개 이하·후보)", None, "hdens"),
|
|
89
|
+
("C21 뻔한 추상 표현(닫힌 어휘·후보)", r"생각의 근육|배움의 리듬|켜켜이|장면을 포착|손에 쥐여? ?주"),
|
|
82
90
|
# ── S7 내부 조어 후보 추출기 (함수 lane — 줄 패턴이 아니라 문서 전체를 본다)
|
|
83
91
|
("C16 내부 조어 후보(S7·후보)", None, "s7"),
|
|
84
92
|
]
|
|
@@ -215,6 +223,41 @@ def s7_candidates(path, common=None, st=None):
|
|
|
215
223
|
return out
|
|
216
224
|
|
|
217
225
|
|
|
226
|
+
def heading_dense(path, common=None, st=None):
|
|
227
|
+
"""C20: 소제목이 단락 2개 이하마다 붙은 절이 3개 이상 연달아 나오는 구간. [(제목, 줄번호, 종류)] — 후보 전용.
|
|
228
|
+
단락 = 빈 줄로 갈린 비어 있지 않은 덩어리. 펜스·그림 블록·HTML 주석은 단락이 아니다."""
|
|
229
|
+
text = open(path, encoding="utf-8").read()
|
|
230
|
+
text = COMMENT.sub(lambda m: re.sub(r"[^\n]", " ", m.group(0)), text)
|
|
231
|
+
secs, cur, para = [], None, False
|
|
232
|
+
for i, line in iter_lines(text.split("\n"), True, st or Blocks()):
|
|
233
|
+
if HEADING.match(line):
|
|
234
|
+
if cur:
|
|
235
|
+
secs.append(cur)
|
|
236
|
+
cur, para = [i, line.strip(), 0], False
|
|
237
|
+
elif line.strip():
|
|
238
|
+
if cur and not para:
|
|
239
|
+
cur[2] += 1
|
|
240
|
+
para = True
|
|
241
|
+
else:
|
|
242
|
+
para = False
|
|
243
|
+
if cur:
|
|
244
|
+
secs.append(cur)
|
|
245
|
+
out, run = [], []
|
|
246
|
+
for sec in secs + [None]:
|
|
247
|
+
if sec is not None and sec[2] <= 2:
|
|
248
|
+
run.append(sec)
|
|
249
|
+
continue
|
|
250
|
+
if len(run) >= 3:
|
|
251
|
+
out.extend((r[1], r[0], "sparse-section run of %d" % len(run)) for r in run)
|
|
252
|
+
run = []
|
|
253
|
+
return out
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
# 함수형 레인 레지스트리: 플래그 -> f(path, common) -> [(키, 줄번호, 종류)]
|
|
257
|
+
FUNC_LANES = {"s7": lambda path, common=None: s7_candidates(path, common),
|
|
258
|
+
"hdens": lambda path, common=None: heading_dense(path)}
|
|
259
|
+
|
|
260
|
+
|
|
218
261
|
# 절대 잡히면 안 되는 토큰 — 「늘 잡는다」를 내는 죽은 계기 배제용
|
|
219
262
|
NEVER = r"ZZZ_absent_token_ZZZ"
|
|
220
263
|
|
|
@@ -231,8 +274,9 @@ def scan(path, common=None):
|
|
|
231
274
|
rows, st = [], Blocks()
|
|
232
275
|
for lane in LANES:
|
|
233
276
|
label, pat, flags = lane[0], lane[1], lane[2:]
|
|
234
|
-
if
|
|
235
|
-
|
|
277
|
+
fl = [f for f in flags if f in FUNC_LANES]
|
|
278
|
+
if fl:
|
|
279
|
+
for term, i, kind in FUNC_LANES[fl[0]](path, common):
|
|
236
280
|
rows.append((label, i, "%s [%s]" % (term, kind)))
|
|
237
281
|
continue
|
|
238
282
|
rx = re.compile(pat)
|
|
@@ -246,6 +290,203 @@ def scan(path, common=None):
|
|
|
246
290
|
return rows, st
|
|
247
291
|
|
|
248
292
|
|
|
293
|
+
# ── 개고 사후 점검 (--check-rewrite) — 세 칸: 남길 곳 · 확인할 곳 · 고칠 곳.
|
|
294
|
+
# 🟥 기계가 하는 것은 «기록의 속성» 뿐이다: 목록에 적힌 구절이 개고에 남았나 · 숫자 집합이 움직였나 · 발화한 클래스가 줄었나.
|
|
295
|
+
# 무엇을 남길지의 «선정» 은 판단이고 개고 전에 사람/모델이 --keep 목록으로 적는다. 목록이 없으면 그 칸은 UNMEASURED(0 아님).
|
|
296
|
+
# 한글 수사(세 배)·표로 된 수치는 못 잡는다 — Step 4 의 눈 판정 잔여로 간다.
|
|
297
|
+
VAGUE = ("대폭", "크게", "많이", "상당히", "대거", "급격히", "훨씬", "현저히")
|
|
298
|
+
# 수치 토큰 = 숫자 + (천·만·억·조) + 단위. 단위를 떼어 비교하면 «3배 → 3천 배», «12% → 12배» 가 통과한다.
|
|
299
|
+
# 원칙(R2 교차검토 후 뒤집음): 점검기는 영리하려 들지 않는다. 확신이 없으면 UNSURE 를 낸다 — 통과가 아니다(exit 1, «사람이 볼 곳»).
|
|
300
|
+
# 정규화는 NFKC + 연속 공백 한 칸뿐이다. 목록 기호 제거·단위 정규화·0 정리는 하지 않는다(각각이 새 구멍이었다).
|
|
301
|
+
# 수치 토큰 = [부호] 숫자([.,] 묶음) + 바로 뒤 최대 4자(단위·자릿수어)를 그대로. «1.0 vs 1.00», «30 ms vs 30ms» 처럼 표기만 달라도 NEW/LOST 로 뜬다 — 표기만 달라도 사람이 본다(닫힌 방향의 비용).
|
|
302
|
+
NUMRX = re.compile(r"[+\-\u2212]?\d+(?:[.,]\d+)*[\w%]{0,4}")
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
def _norm(text):
|
|
306
|
+
import unicodedata
|
|
307
|
+
return re.sub(r"\s+", " ", unicodedata.normalize("NFKC", text)).strip()
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
def _full(path):
|
|
311
|
+
"""NFKC + 공백 한 칸. 코드 펜스·인라인 코드·주석·목록 기호를 건드리지 않는다 — 수치·모호 표현·남길 곳은 전부 본다."""
|
|
312
|
+
return _norm(open(path, encoding="utf-8").read())
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
def _numtoks(text):
|
|
316
|
+
from collections import Counter
|
|
317
|
+
return Counter(re.sub(r"(?<=\d),(?=\d{3})", "", m.group(0)) for m in NUMRX.finditer(text))
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
def check_rewrite(orig_path, rw_path, keep_path=None, listed=()):
|
|
321
|
+
"""{칸: (상태, [항목…])}. 상태: PASS · FAIL · UNSURE(사람이 볼 곳) · UNMEASURED. 키 구절이 원문에 없거나 비어 있거나 입력 파일이 비면 ValueError."""
|
|
322
|
+
o, r = _full(orig_path), _full(rw_path)
|
|
323
|
+
if not o or not r:
|
|
324
|
+
raise ValueError("empty original or rewrite file")
|
|
325
|
+
nows = lambda t: re.sub(r"\s+", "", t)
|
|
326
|
+
# ① 남길 곳 — 정확 부분문자열 → OK · 공백을 지워야만 찾으면 UNSURE · 아니면 DROPPED
|
|
327
|
+
keep = []
|
|
328
|
+
if keep_path:
|
|
329
|
+
for raw in open(keep_path, encoding="utf-8").read().split("\n"):
|
|
330
|
+
if raw.strip() and not raw.lstrip().startswith("#"):
|
|
331
|
+
ph, _, why = raw.partition("\t")
|
|
332
|
+
if not _norm(ph):
|
|
333
|
+
raise ValueError("empty keep phrase in row %r" % raw)
|
|
334
|
+
keep.append((_norm(ph), why.strip()))
|
|
335
|
+
items, bad, unsure = [], False, False
|
|
336
|
+
for ph, why in keep:
|
|
337
|
+
if nows(ph) not in nows(o):
|
|
338
|
+
raise ValueError("keep phrase not in the original: %r" % ph)
|
|
339
|
+
if ph in r:
|
|
340
|
+
items.append("KEEP-OK %s" % ph)
|
|
341
|
+
elif nows(ph) in nows(r):
|
|
342
|
+
items.append("KEEP-UNSURE %s (found only with whitespace removed -- a person looks)" % ph)
|
|
343
|
+
unsure = True
|
|
344
|
+
elif why:
|
|
345
|
+
items.append("KEEP-LISTED %s -- %s" % (ph, why))
|
|
346
|
+
else:
|
|
347
|
+
items.append("KEEP-DROPPED %s" % ph)
|
|
348
|
+
bad = True
|
|
349
|
+
keep_state = "UNMEASURED" if not keep else ("FAIL" if bad else "UNSURE" if unsure else "PASS")
|
|
350
|
+
if not keep:
|
|
351
|
+
items.append("NO-KEEP-LIST (not measured; this is not a pass)")
|
|
352
|
+
# ② 확인할 곳 — 다중집합 비교, 코드 안 수치도 센다
|
|
353
|
+
to, tr = _numtoks(o), _numtoks(r)
|
|
354
|
+
items2, bad2 = [], False
|
|
355
|
+
for t in sorted((tr - to).elements()):
|
|
356
|
+
items2.append("NUMBER-NEW %s" % t)
|
|
357
|
+
bad2 = True
|
|
358
|
+
for t in sorted((to - tr).elements()):
|
|
359
|
+
items2.append("NUMBER-LOST %s" % t)
|
|
360
|
+
bad2 = True
|
|
361
|
+
for t in sorted((to & tr).elements()):
|
|
362
|
+
items2.append("NUMBER-KEPT %s" % t)
|
|
363
|
+
for v in VAGUE:
|
|
364
|
+
if v in o:
|
|
365
|
+
if v in r:
|
|
366
|
+
items2.append("VAGUE-KEPT %s" % v)
|
|
367
|
+
elif v in listed:
|
|
368
|
+
items2.append("VAGUE-LISTED %s (author decision via --listed)" % v)
|
|
369
|
+
else:
|
|
370
|
+
# 모호 수량은 본문에 그대로 둔다 — 자리표시자나 숫자로 바꾸는 것도 소실이다. 면죄는 --listed 로 이름을 적는 것(저자 결정)뿐.
|
|
371
|
+
items2.append("VAGUE-LOST %s (removed from the body; only --listed excuses it)" % v)
|
|
372
|
+
bad2 = True
|
|
373
|
+
# ③ 고칠 곳
|
|
374
|
+
def per_lane(path):
|
|
375
|
+
out = {}
|
|
376
|
+
for label, _, _ in scan(path)[0]:
|
|
377
|
+
out[label.split()[0]] = out.get(label.split()[0], 0) + 1
|
|
378
|
+
return out
|
|
379
|
+
lo, lr = per_lane(orig_path), per_lane(rw_path)
|
|
380
|
+
items3, bad3 = [], False
|
|
381
|
+
for lid in sorted(set(lo) | set(lr), key=lambda x: int(re.sub(r"\D", "", x))):
|
|
382
|
+
a, b = lo.get(lid, 0), lr.get(lid, 0)
|
|
383
|
+
tag = "FIXED" if a and not b else "REDUCED" if a > b > 0 else "SAME" if a and a == b else "WORSE" if a and b > a else "NEW"
|
|
384
|
+
if tag in ("SAME", "WORSE", "NEW", "REDUCED") and lid not in listed:
|
|
385
|
+
bad3 = True
|
|
386
|
+
tag += "-UNLISTED"
|
|
387
|
+
elif tag in ("SAME", "WORSE", "NEW", "REDUCED"):
|
|
388
|
+
tag += "-LISTED"
|
|
389
|
+
items3.append("%s %s %d->%d" % (tag, lid, a, b))
|
|
390
|
+
if not lo:
|
|
391
|
+
items3.append("NO-CLASS-FIRED in the original (nothing to resolve)")
|
|
392
|
+
return {"keep": (keep_state, items), "verify": ("FAIL" if bad2 else "PASS", items2),
|
|
393
|
+
"fix": ("FAIL" if bad3 else "PASS", items3)}
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
def rw_edge_cases():
|
|
397
|
+
"""[(이름, 통과여부)] — --check-rewrite 의 경계 사례(R1 교차검토). 각 사례는 기대한 칸의 상태까지 단언한다."""
|
|
398
|
+
import tempfile
|
|
399
|
+
out = []
|
|
400
|
+
with tempfile.TemporaryDirectory() as d:
|
|
401
|
+
def w(name, text):
|
|
402
|
+
fp = os.path.join(d, name)
|
|
403
|
+
with open(fp, "w", encoding="utf-8") as fh:
|
|
404
|
+
fh.write(text)
|
|
405
|
+
return fp
|
|
406
|
+
|
|
407
|
+
def run(o, r, keep=None, listed=()):
|
|
408
|
+
try:
|
|
409
|
+
return check_rewrite(w("o.md", o), w("r.md", r), w("k.txt", keep) if keep is not None else None, listed)
|
|
410
|
+
except ValueError:
|
|
411
|
+
return "ERR"
|
|
412
|
+
|
|
413
|
+
def v(res, kind=None):
|
|
414
|
+
if res == "ERR":
|
|
415
|
+
return "ERR"
|
|
416
|
+
st, items = res["verify"]
|
|
417
|
+
return st if kind is None else (st, any(x.startswith(kind) for x in items))
|
|
418
|
+
|
|
419
|
+
out.append(("S1 unit 3배 -> 3천 배 fails (NUMBER-NEW/LOST)", v(run("속도는 3배 빨라졌습니다.", "속도는 3천 배 빨라졌습니다."), "NUMBER-") == ("FAIL", True)))
|
|
420
|
+
out.append(("S1 unit 12% -> 12배 fails", v(run("오류율은 12% 입니다.", "오류율은 12배 입니다.")) == "FAIL"))
|
|
421
|
+
out.append(("S1 control: same number tokens in another order pass", v(run("오류율은 12% 입니다. 지연은 30ms 입니다.", "지연은 30ms 입니다. 오류율은 12% 입니다.")) == "PASS"))
|
|
422
|
+
out.append(("S2 number inside a fenced block is seen", v(run("본문\n```\nx = 1\n```\n", "본문\n```\nx = 2\n```\n"), "NUMBER-") == ("FAIL", True)))
|
|
423
|
+
out.append(("S3 empty keep phrase is a harness error", run("본문입니다.", "본문입니다.", "\t사유\n") == "ERR"))
|
|
424
|
+
out.append(("S3 empty rewrite is a harness error", run("본문입니다.", " \n") == "ERR"))
|
|
425
|
+
out.append(("S3 empty original is a harness error", run("", "본문입니다.") == "ERR"))
|
|
426
|
+
saved, rcs = sys.stderr, []
|
|
427
|
+
sys.stderr = open(os.devnull, "w")
|
|
428
|
+
try:
|
|
429
|
+
rcs = [check_main(["--original", w("o.md", "가"), "--rewrite", w("r.md", "가"), "--listed"]),
|
|
430
|
+
check_main(["--original", w("o.md", "가"), "--rewrite", w("r.md", "가"), "--keep"]),
|
|
431
|
+
check_main(["--original", w("o.md", "가"), "--rewrite"])]
|
|
432
|
+
finally:
|
|
433
|
+
sys.stderr.close()
|
|
434
|
+
sys.stderr = saved
|
|
435
|
+
out.append(("S4 a flag missing its value exits 10", rcs == [10, 10, 10]))
|
|
436
|
+
ph = run("처리 시간이 크게 줄었습니다.", "처리 시간이 [확인 필요: 전후 수치] 줄었습니다.")
|
|
437
|
+
far = run("처리 시간이 대폭 줄었습니다.\n다른 문장입니다.", "처리 시간이 줄었습니다.\n다른 문장은 확인 필요.")
|
|
438
|
+
listed_ok = run("처리 시간이 크게 줄었습니다.", "처리 시간이 줄었습니다.", listed=("크게",))
|
|
439
|
+
out.append(("S5 a placeholder replacing a vague word is VAGUE-LOST", v(ph, "VAGUE-LOST") == ("FAIL", True)))
|
|
440
|
+
out.append(("S5 a marker elsewhere does not excuse VAGUE-LOST", v(far, "VAGUE-LOST") == ("FAIL", True)))
|
|
441
|
+
out.append(("S5 control: naming the word in --listed excuses it", v(listed_ok) == "PASS"))
|
|
442
|
+
out.append(("A1 a wrap inside a Korean word is KEEP-UNSURE (not PASS, not DROPPED)", run("요술램프 같은 도구입니다.", "요술\n램프 같은 도구입니다.", "요술램프\n")["keep"][0] == "UNSURE"))
|
|
443
|
+
out.append(("A2 1.0 vs 1.00 shows as NEW/LOST (a person looks)", v(run("정확도 1.0 입니다.", "정확도 1.00 입니다.")) == "FAIL"))
|
|
444
|
+
out.append(("A2 control: 1,000 == 1000 and full-width digits normalise by NFKC/commas", v(run("건수 1,000건 12건", "건수 1000건 12건")) == "PASS"))
|
|
445
|
+
# R2 (codex): 정규화 수리가 만든 구멍 다섯 — 각 사례는 PASS 로 끝나면 안 된다
|
|
446
|
+
k = run("데이터가 쌓입니다.", "데이터 가공이 쌓입니다.", "데이터가\n")
|
|
447
|
+
out.append(("R2-1 keep across a word boundary is UNSURE, never PASS", k != "ERR" and k["keep"][0] == "UNSURE"))
|
|
448
|
+
out.append(("R2-2 a fabricated line-start number fails", v(run("1. 첫째\n2. 둘째\n", "999. 첫째\n2. 둘째\n")) == "FAIL"))
|
|
449
|
+
out.append(("R2-3 a dropped sign (3 vs -3) fails", v(run("변화량은 3 입니다.", "변화량은 -3 입니다.")) == "FAIL"))
|
|
450
|
+
out.append(("R2-4 a detached unit (30ms vs 30 ms) fails", v(run("지연은 30ms 입니다.", "지연은 30 ms 입니다.")) == "FAIL"))
|
|
451
|
+
k5 = run("ABC 도구를 씁니다.", "ABC 도구를 씁니다.", "ABC\n")
|
|
452
|
+
out.append(("R2-5 keep phrases are NFKC-normalised like the documents", k5 != "ERR" and k5["keep"][0] == "PASS"))
|
|
453
|
+
same = run("지연은 30ms 입니다. 크게 줄었습니다.", "지연은 30ms 입니다. 크게 줄었습니다.", "크게 줄었습니다\n")
|
|
454
|
+
out.append(("R2 control: identical text passes every bucket", same != "ERR" and all(same[b][0] == "PASS" for b in same)))
|
|
455
|
+
return out
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
BUCKET_KO = {"keep": "남길 곳", "verify": "확인할 곳", "fix": "고칠 곳"}
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
def check_main(args):
|
|
462
|
+
opts, it = {}, iter(args)
|
|
463
|
+
for a in it:
|
|
464
|
+
if a in ("--original", "--rewrite", "--keep", "--listed"):
|
|
465
|
+
val = next(it, None)
|
|
466
|
+
if val is None or val.startswith("--"):
|
|
467
|
+
sys.stderr.write("usage error: %s needs a value\n" % a)
|
|
468
|
+
return 10
|
|
469
|
+
opts[a] = val
|
|
470
|
+
else:
|
|
471
|
+
opts["bad"] = a
|
|
472
|
+
if "bad" in opts or not opts.get("--original") or not opts.get("--rewrite"):
|
|
473
|
+
sys.stderr.write("usage: ko_tech_writer_calibrate.py --check-rewrite --original F --rewrite F [--keep LIST] [--listed C9,C15]\n")
|
|
474
|
+
return 10
|
|
475
|
+
listed = tuple(x.strip() for x in (opts.get("--listed") or "").split(",") if x.strip())
|
|
476
|
+
try:
|
|
477
|
+
res = check_rewrite(opts["--original"], opts["--rewrite"], opts.get("--keep"), listed)
|
|
478
|
+
except (OSError, UnicodeDecodeError, ValueError) as e:
|
|
479
|
+
sys.stderr.write("harness error: %s\n" % e)
|
|
480
|
+
return 10
|
|
481
|
+
for k in ("keep", "verify", "fix"):
|
|
482
|
+
state, items = res[k]
|
|
483
|
+
print("BUCKET %s(%s) %s" % (BUCKET_KO[k], k, state))
|
|
484
|
+
for x in items:
|
|
485
|
+
print(" " + x)
|
|
486
|
+
states = [res[k][0] for k in res]
|
|
487
|
+
return 1 if ("FAIL" in states or "UNSURE" in states) else 2 if "UNMEASURED" in states else 0
|
|
488
|
+
|
|
489
|
+
|
|
249
490
|
def scan_main(args):
|
|
250
491
|
"""--scan FILE [--s7-common LIST]. 입력 오류는 stderr + 10, 안 닫힌 블록은 경고 + 3."""
|
|
251
492
|
path = common_path = None
|
|
@@ -287,7 +528,9 @@ def main():
|
|
|
287
528
|
if len(sys.argv) > 1:
|
|
288
529
|
if sys.argv[1] == "--scan":
|
|
289
530
|
return scan_main(sys.argv[2:])
|
|
290
|
-
sys.
|
|
531
|
+
if sys.argv[1] == "--check-rewrite":
|
|
532
|
+
return check_main(sys.argv[2:])
|
|
533
|
+
sys.stderr.write("usage: ko_tech_writer_calibrate.py [--scan FILE [--s7-common LIST] | --check-rewrite ...]\n")
|
|
291
534
|
return 10
|
|
292
535
|
for p in (POS, NEG):
|
|
293
536
|
if not os.path.isfile(p):
|
|
@@ -305,12 +548,13 @@ def main():
|
|
|
305
548
|
for lane in LANES:
|
|
306
549
|
label, pat, flags = lane[0], lane[1], lane[2:]
|
|
307
550
|
candidate = "candidate" in flags
|
|
551
|
+
fl = [f for f in flags if f in FUNC_LANES]
|
|
308
552
|
if candidate or "s7" in flags:
|
|
309
553
|
ncand.append(label.split()[0] + (" UNCALIBRATED" if "uncalibrated" in flags else ""))
|
|
310
|
-
if
|
|
311
|
-
p, n = len(
|
|
554
|
+
if fl:
|
|
555
|
+
p, n = len(FUNC_LANES[fl[0]](POS)), len(FUNC_LANES[fl[0]](NEG))
|
|
312
556
|
if p >= 1 and n == 0:
|
|
313
|
-
print("OK %s --
|
|
557
|
+
print("OK %s -- positive %d / negative 0 (discriminates the constructed pair; "
|
|
314
558
|
"precision on real documents UNMEASURED, hits need per-case judgment)" % (label, p))
|
|
315
559
|
npass += 1
|
|
316
560
|
else:
|
|
@@ -373,6 +617,39 @@ def main():
|
|
|
373
617
|
% (unclosed(su), unclosed(sn), sn.skipped))
|
|
374
618
|
nfail += 1
|
|
375
619
|
|
|
620
|
+
# 개고 사후 점검 레인 — 세 쌍이 각자 «자기 칸만» 빨개져야 한다. 컨트롤 값(키 구절·숫자·발화 클래스 수)을 같이 찍는다: 죽은 점검기는 깨끗한 개고의 PASS 와 똑같이 생겼다.
|
|
621
|
+
rwd = os.path.join(FIX, "rewrite_")
|
|
622
|
+
exp = [("clean", ("PASS", "PASS", "PASS")),
|
|
623
|
+
("drops_metaphor", ("FAIL", "PASS", "PASS")),
|
|
624
|
+
("invents_number", ("PASS", "FAIL", "PASS"))]
|
|
625
|
+
try:
|
|
626
|
+
for name, want in exp:
|
|
627
|
+
res = check_rewrite(rwd + "original.md", rwd + name + ".md", rwd + "keep.txt")
|
|
628
|
+
got = tuple(res[k][0] for k in ("keep", "verify", "fix"))
|
|
629
|
+
ctl = (sum(1 for x in res["keep"][1] if x.startswith("KEEP-")),
|
|
630
|
+
sum(1 for x in res["verify"][1] if x.startswith("NUMBER-")),
|
|
631
|
+
sum(1 for x in res["fix"][1] if x.startswith(("FIXED", "SAME", "NEW", "WORSE", "REDUCED"))))
|
|
632
|
+
if got == want and min(ctl) >= 1:
|
|
633
|
+
print("OK RW rewrite-check %s -- keep/verify/fix = %s (controls: keep items %d, numbers %d, classes fired %d)"
|
|
634
|
+
% (name, "/".join(got), ctl[0], ctl[1], ctl[2]))
|
|
635
|
+
npass += 1
|
|
636
|
+
else:
|
|
637
|
+
print("FAIL RW rewrite-check %s -- got %s want %s (controls %s; a control of 0 means the checker saw nothing)"
|
|
638
|
+
% (name, "/".join(got), "/".join(want), ctl))
|
|
639
|
+
nfail += 1
|
|
640
|
+
except (OSError, ValueError) as e:
|
|
641
|
+
print("FAIL RW rewrite-check -- fixture/keep list problem: %s" % e)
|
|
642
|
+
nfail += 1
|
|
643
|
+
|
|
644
|
+
# 개고 점검 R1 교차검토 수리 레인 — 입력 문자열을 임시 파일로 써서 같은 check_rewrite/check_main 을 부른다. 기대는 «그 칸만» 정확히 맞아야 한다.
|
|
645
|
+
for name, ok in rw_edge_cases():
|
|
646
|
+
if ok:
|
|
647
|
+
print("OK RW2 %s" % name)
|
|
648
|
+
npass += 1
|
|
649
|
+
else:
|
|
650
|
+
print("FAIL RW2 %s" % name)
|
|
651
|
+
nfail += 1
|
|
652
|
+
|
|
376
653
|
# META 컨트롤 1 — 없는 토큰이 양쪽 다 0인가 (계기가 «늘 잡는다» 를 내지 않는다)
|
|
377
654
|
if count(POS, NEVER) == 0 and count(NEG, NEVER) == 0:
|
|
378
655
|
print("OK META control -- an absent token matches nothing in either fixture")
|
package/scripts/selfcheck.sh
CHANGED
|
@@ -1142,6 +1142,7 @@ for _pair in \
|
|
|
1142
1142
|
"scripts/stale_clone_guard.sh|scripts/test_stale_clone_guard_lanes.sh" \
|
|
1143
1143
|
"scripts/proposal_hook.sh|scripts/test_proposal_hook_lanes.sh" \
|
|
1144
1144
|
"plugins/fh-commons/skills/ko-tech-writer/SKILL.md|scripts/test_ko_tech_writer_lanes.sh" \
|
|
1145
|
+
"scripts/absorption_queue.py|scripts/test_absorption_queue_lanes.sh" \
|
|
1145
1146
|
"scripts/script_caller_ratchet.sh|scripts/test_script_caller_ratchet_lanes.sh" \
|
|
1146
1147
|
"scripts/script_caller_ratchet.sh|scripts/test_runner_surface_index_lanes.sh" \
|
|
1147
1148
|
"scripts/mapped_tracks.sh|scripts/test_mapped_tracks_lanes.sh" \
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# test_absorption_queue_lanes.sh — absorption_queue.py 의 기록 규칙 known-pair (얇은 래퍼).
|
|
3
|
+
# 닫기 근거(landed=PR#·커밋 · declined/deferred=사유) · 중복 추가 · digest 후보 추출(같은 체커의 --extract)
|
|
4
|
+
# · 깨진 행/절 없는 digest 는 오류(0 아님) · 자산 후보 색인(스킬 + 에이전트). 레인은 파이썬 안에 있다.
|
|
5
|
+
# exit: 0 전 레인 PASS · 1 실패 · 10 harness error(python3 부재)
|
|
6
|
+
set -uo pipefail
|
|
7
|
+
SRC="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
8
|
+
command -v python3 >/dev/null 2>&1 || {
|
|
9
|
+
echo "harness error: python3 absent -- cannot measure. Not a pass." >&2; exit 10; }
|
|
10
|
+
python3 "$SRC/absorption_queue.py" --self-test
|