@chrono-meta/fh-gate 3.32.0 → 3.34.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 +105 -0
- package/knowledge/shared/rules/operations.md +11 -0
- package/knowledge/shared/rules/sister_asset_protocol.md +21 -2
- package/package.json +5 -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-commons/skills/persona-cast/SKILL.md +12 -6
- package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-meta/CHANGELOG.md +37 -0
- package/plugins/fh-meta/skills/frontier-digest/SKILL.md +3 -1
- package/plugins/fh-meta/skills/frontier-digest/SKILL_detail.md +12 -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 +493 -0
- package/scripts/digest_landing_check.sh +110 -5
- package/scripts/digest_slow_leg.py +456 -0
- package/scripts/fh_session_load.sh +12 -0
- package/scripts/ko_tech_writer_calibrate.py +284 -7
- package/scripts/selfcheck.sh +2 -0
- package/scripts/test_absorption_queue_lanes.sh +10 -0
- package/scripts/test_digest_slow_leg_lanes.sh +11 -0
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# forge-harness (fh-meta) Changelog
|
|
2
2
|
|
|
3
|
+
### [Unreleased]
|
|
4
|
+
|
|
5
|
+
### [3.34.0] — 2026-10-31 — 다이제스트 주간 느린 갈래 · 흡수 대기열이 원문 문장을 담는다 · 착지 증언이 출처 ID 로 가르고 덜 읽은 «미착지» 를 확정하지 않는다 · persona-cast 위치 없는 지적 버리기
|
|
6
|
+
|
|
7
|
+
훅 변경은 없다. 스크립트가 하나 늘었다(`scripts/digest_slow_leg.py`). 새 자산이 들어가서 버전 정책상 minor 다.
|
|
8
|
+
|
|
9
|
+
소비자에게 닿는 변화:
|
|
10
|
+
- `frontier-digest`(fh-meta) 주 1회 느린 갈래(#978): 컨퍼런스 채널과 기술 블로그의 새 글 · 새 발표 목록을 일주일에 한 번 모은다. 소스 목록은 운영자 로컬의 gitignored 파일(`$FH_DIGEST_SLOW_SOURCES`, 기본 `tracks/_meta/digest_slow_sources.tsv`)에만 둔다 — 누가 어느 회사를 구독하는지가 소속을 드러낼 수 있어서 공개 파일에는 소스 이름이 0 이다. RSS/Atom 과 YouTube 채널(Atom 피드 → 404 일 때만 `yt-dlp --flat-playlist`). 못 읽은 소스는 `UNREACHABLE` · `PARSE-ZERO` · `PARSE-ERROR` 로 적고 0 으로 세지 않는다. 403/429 는 거절이라 다른 방법으로 다시 시도하지 않는다. self-test 41레인(오프라인).
|
|
11
|
+
- `frontier-digest` `SKILL_detail.md §Collection-Bash`(#981): 매일 도는 갈래에도 같은 규칙 — 거절되거나 빈 응답은 `UNREACHABLE(…)` · `PARSE-ZERO` 로 적고, **다른 클라이언트 신원(다른 브라우저 User-Agent · 위조 referrer · 봇 검사 우회용 헤드리스 브라우저)으로 재시도하지 않는다.** 정직하게 자신을 밝히는 UA 를 처음부터 쓰는 것은 괜찮다.
|
|
12
|
+
- `scripts/digest_landing_check.sh`(착지 증언 — digest 후보가 레포에 반영됐는지 고르는 선별기)(#981 · #982):
|
|
13
|
+
- 출처 ID 로 가른다: 백틱 토큰을 첫 콜론에서 잘라 `arXiv:2610.34938` 이 `arXiv` 한 낱말이 되던 것을 고쳤다. 이제 `arXiv:NNNN.NNNN+` 은 번호만(착지문이 `arXiv:` · `arXiv ` 둘 다 써서), `HN:` · `GN:` 은 접두어째 남기고, 둘 다 숫자 경계로 감싼다(`HN:123` 이 `HN:12345` 에 맞지 않게). 그 밖의 `이름:값` 은 종전대로 자른다. 이 레포 전체 digest 에서 토큰이 접두어 하나뿐이던 후보 32/705 → 0.
|
|
14
|
+
- gitignored 축은 깊이 `DLC_IGNORED_DEPTH`(기본 2)까지만 읽는다 — 실험 클론 안의 레포 사본이 착지 근거가 되던 것을 막는다. 상한 `DLC_IGNORED_CAP`(기본 400)을 넘으면 몇 건을 읽었는지 출력하고, 잘린 상태의 «미착지» 는 확정하지 않고 종료 10(미측정)을 낸다. 두 값이 1 이상의 정수가 아니면 종료 10.
|
|
15
|
+
- self-test 25 → 39레인.
|
|
16
|
+
- 흡수 대기열 `import-digest`(#979): 대기열 항목이 검증기의 6낱말 이름표 대신 digest 후보의 머리 문장 전체로 들어간다(표 후보는 본문 칸의 굵은 머리). 원문을 못 찾으면 `[이름표만 — 다이제스트 원문 못 찾음]` 을 붙여, 잘린 항목이 온전한 것처럼 보이지 않게 한다. 이 레포 digest 129개(후보 442개)에서 442/442 대응.
|
|
17
|
+
- `persona-cast`(fh-commons) Step 4(#981): 렌즈 6개가 약속하던 «위치 없는 지적은 디스패처가 버린다» 를 병합 단계가 실제로 한다 — 먼저 버리고, 렌즈마다 버린 수를 `no-loc` 칸에 보인다. `total` 은 버린 뒤 남은 수다.
|
|
18
|
+
|
|
19
|
+
허브 운영자 참고(소비자 설치본과 다름):
|
|
20
|
+
- `knowledge/shared/learnings/subagent_invocations_log.yaml` 에 10-29 ~ 10-31 서브에이전트 호출 기록을 더했다(#980 · #981).
|
|
21
|
+
- 맥에서 `selfcheck.sh` 는 `test_mutation_probe_lanes.sh` 의 두 레인(N6 · S7-5)을 `/proc` 이 없어 UNMEASURED 로 내고 전체를 FAIL 로 끝낸다 — 이 릴리스 전부터 그렇다(리눅스 CI 는 잰다).
|
|
22
|
+
|
|
23
|
+
### [3.33.0] — 2026-10-28 — 빌더에게 일을 넘길 때 카드 두 줄(CC · Codex 진입점 둘 다) · 주간 감사 앵커 되돌림 표본 · ko-tech-writer 개고 사후 검사 · 흡수 대기열
|
|
24
|
+
|
|
25
|
+
훅 변경은 없다. 스크립트는 하나 늘고(`scripts/absorption_queue.py`) 하나에 검사 모드가 늘었다(`scripts/ko_tech_writer_calibrate.py`). 세션 시작 로더와 digest 러너에 대기열 줄이 하나씩 들어갔다. 나머지는 문서다. 빌더에게 일을 넘기는 방식을 바꾸는 규칙이 들어 있어 버전 정책상 minor 다(블라인드 sim, 팔당 n=3).
|
|
26
|
+
|
|
27
|
+
소비자에게 닿는 변화:
|
|
28
|
+
- `ko-tech-writer`(fh-commons) 고쳐 쓴 글의 사후 검사: `ko_tech_writer_calibrate.py --check-rewrite --original <원문> --rewrite <고친 글> [--keep <남길 목록>] [--listed <저자가 이름을 적어 넘긴 레인 코드·모호 표현>]`. 남겨야 할 표현(필자 고유의 비유 등)이 그대로 있으면 KEEP-OK, 사라졌으면 KEEP-DROPPED, 공백을 빼야만 찾히면(낱말 중간 줄바꿈 등) KEEP-UNSURE 로 사람에게 넘긴다. 숫자는 원문과 개수까지 비교해서 새로 생긴 숫자(NUMBER-NEW)나 사라진 숫자(NUMBER-LOST)가 있으면 실패다. 원문의 모호한 수량 표현(«크게» 등)이 본문에서 사라졌는데 `--listed` 에 없어도 실패다 — 숫자나 자리표시자로 바꾼 것도 사라진 것으로 센다. 비교 전 정규화는 NFKC 와 공백 정리뿐이다. 종료 코드: 통과 0 · 실패나 UNSURE 1 · 실패는 없지만 남길 목록이 없음(UNMEASURED) 2 · 입력 오류 10. SKILL.md 에는 Step 4-c(고친 곳 · 남긴 곳 · 확인할 곳 세 칸 표), Done When 한 줄, AI 티 후보 패턴 S25–S29, «점검 출력 규약»(결함은 위치마다 한 건 · 못 본 항목은 `➖ 확인 불가` 와 사유 · 이전 점검을 덮지 않고 `_v2` 로 · 점검하지 않는 것 한 줄)과 선택 항목인 «공개 직전 최소선» 을 더했다. 레인 48개 통과. 계기는 우아콘 2026 테크라이팅 세션이다. 발표의 «프롬프트 한 줄 개고 = 숫자 날조 10회 중 6회» 는 이 스킬 기준으로는 재현되지 않았다(개정 전 스킬도 3회 중 0회). 그래서 이 검사는 날조를 고친 수리가 아니라 «남길 곳이 남았나» 를 고정하는 회귀 장치로 넣었다.
|
|
29
|
+
- `CATALOG.md`: 색인에 없던 knowledge 문서 5개와 v3.22–v3.32 릴리스 목록 한 줄을 더했다.
|
|
30
|
+
- 흡수 대기열(새 스크립트 `scripts/absorption_queue.py`): 바깥에서 온 «가져올 것»(매일 frontier digest 의 적용 후보 · 형제 자산 감사의 가져올 목록 · 운영자가 건넨 링크나 자료)을 `tracks/_meta/absorption_queue.tsv` 에 한 줄씩 남긴다. 세션이 시작되거나 재개될 때 열린 항목이 있으면 한 줄로 알린다(막지 않는다 · `/clear` 나 압축 뒤에는 다시 안 띄운다). 닫으려면 근거가 있어야 한다: landed 는 PR 번호(`#N` · `/pull/N`)나 `commit:<해시>` · `<레포>@<해시>`, declined · deferred 는 사유. 깨진 행이나 오타 status 는 «열린 것 0» 이 아니라 오류로 낸다. digest 러너는 그날 후보를 넣고(FH 허브 자신일 때만), 추출은 기존 `digest_landing_check.sh --extract` 를 그대로 쓴다. `match` 는 스킬과 에이전트 정의의 이름 · 설명에서 겹치는 낱말로 우리 자산 후보를 보여 주는 선별기다(한글 질의 recall 은 낮다). 레인 24개.
|
|
31
|
+
- 형제 자산 프로토콜 · `CLAUDE.md` 의도 표: 운영자가 무언가를 고치려고 바깥 자료를 건네면, 그 자료를 대기열에 넣고 `match` 로 닿는 자산을 이름 붙인 뒤, 고친 PR 로 닫는다. 이건 기록 절차이고 작업을 막지 않는다(대기열 오류 · 짝 없음 · 열린 항목이 있어도 요청받은 일은 계속한다).
|
|
32
|
+
- `CLAUDE.md §Agent Dispatch Operation`: 코드나 파일을 고치는 빌더를 보낼 때 Context Card(목적 · 한 일 · 이번 일 · 제약을 적은 위임 요청서)에 두 줄을 더한다 — «최소 수리부터, 새 장치(캐시 · 예산 · 새 규칙)가 필요하면 짓기 전에 보낸 쪽에 멈추고 보고» · «작업 트리의 미커밋 작업을 버리는 git 명령(`stash` · `checkout --` · `restore` · `reset` · `clean` 류) 금지, 썼으면 작업을 되돌려 놓은 뒤 같은 답에서 바로 보고». 🟥 «멈춤» 만 쓰면 `stash` 직후에 멈춰 작업이 숨은 채 끝날 수 있어 «되돌린 뒤 보고» 로 정했다(Area B 지적). 블라인드 sim(Sonnet, 허브 CLAUDE.md 를 싣고, 팔당 3회, 줄 1 · 줄 2 순): 규칙 없음 0/3 · 0/3 · 세부 문서에만 0/3 · 부분(부분 기재를 반으로 세어 약 1.5/3) · 상주 한 줄 추가 뒤 3/3 · 3/3. 상세 `claude_md_full_reference.md §Context Card`.
|
|
33
|
+
- `AGENTS.md §Builder dispatch brief`(새 절 — 요청을 받았든 아니든 모든 빌더): 같은 두 줄을 Codex 진입점에 런타임 무관 문장으로 옮겼다(그동안 CC 쪽에만 있었다). 블라인드 sim(Sonnet, CLAUDE.md 없이 AGENTS.md 만, 팔당 3회): 줄 1 0/3 → 3/3 · 줄 2 0/3 → 3/3. 실제 Codex 런타임에서는 안 쟀다.
|
|
34
|
+
- `knowledge/shared/rules/operations.md` 주간 감사 2b: «앵커 되돌림 표본» — 창 안에 머지된 변경 3개의 앵커 레인을 일회용 워크트리에서 수리 줄만 `git apply -R` 로 되돌려 빨개지는지 본다(그 워크트리는 빌더 줄 2 의 «받은 트리» 가 아니다). 첫 실행은 n=2.
|
|
35
|
+
|
|
36
|
+
허브 운영자 참고(소비자 설치본과 다름):
|
|
37
|
+
- `dispatch_conditional_prohibition.md §Two-Purposes`: 저자 체크아웃(운영자 전용 CLAUDE.local.md · 메모리 색인 포함)의 첫 호출 입력 토큰이 빈 폴더보다 +62,600~64,800(haiku · 한 낱말 과제 · 팔당 3회). npm 설치본에는 그 두 파일이 없으니 이 숫자를 자기 설치의 비용으로 읽지 말 것.
|
|
38
|
+
- 바깥 근거로 든 arXiv 수치(2610.34491 · 2610.34167)는 그날 frontier digest 요약 기준이고 원문은 열지 않았다.
|
|
39
|
+
|
|
3
40
|
### [3.32.0] — 2026-10-28 — fh_detach 기본 = 프로젝트 하나 · CI 에서 pipefail 델타 잠금이 실제로 돈다 · 레인 앵커 보강
|
|
4
41
|
|
|
5
42
|
**minor.** In short (for upgraders): `scripts/fh_detach.py` (still a dry run unless `--apply`) now takes off only the named project by default; add `--machine` to also remove what every project shares (`~/.zshrc` block, the FH clone's own hooks, `core.hooksPath`). In 3.31.0, `--apply` removed those too — if you relied on that, add `--machine`. Detach your other projects first and run `--machine` last. The pipefail class-lock delta no longer reports «SKIP» when it cannot find a base; the one `BREAKING (gate)` line below applies only to a clone of this repository running its own CI — the scanner and that lane are not in the npm package, so this change does not reach npm consumers.
|
|
@@ -56,6 +56,7 @@ On **cadence-triggered** runs (7d), ask the operator one line before collecting:
|
|
|
56
56
|
|
|
57
57
|
- Operator may skip — zero pressure; the autonomous arms (Step 1) run regardless.
|
|
58
58
|
- Why: walled channels return 403 to machine fetch — **the operator is the only wide-net sensor for them**. This arm turns ad-hoc link-throwing into a scheduled intake (manual-validated n=2).
|
|
59
|
+
- 🟥 **YouTube is half-walled, not walled (corrected 2026-10-29).** A channel's *upload list* is machine-readable: the channel Atom feed, or `yt-dlp --flat-playlist` when that feed answers 404 (measured 2026-10-29: 404 for every channel tried, a well-known control channel included; the same feeds answered again a few hours later — the outage is intermittent, so the fallback stays). Listing new conference talks is the Step 1 `slow-leg` row's job; only *reading* a talk needs the video path below. LinkedIn and X stay operator-only.
|
|
59
60
|
- Received sources route to the sister-asset/triage flow with its **lightweight path**: C-tier (territory already covered) = one-paragraph entry only; full cross-audit reserved for A/B-tier. Partial wall-bypass is allowed first: try WebSearch + secondary sources before declaring unfetchable.
|
|
60
61
|
- **Video sources (local/laptop only — cloud VMs typically 403 on video hosts)**: probe by **capability, not engine name** via the Sidecar Engine Resolution Protocol. Tier 1 = natively multimodal CLI ingesting the URL directly (⚠️ direct `gemini` CLI EOL 2026-06-18 — probe `agy` or the Gemini API after); never route video to a coding-agent CLI without native video access (it burns tokens and recovers only metadata). Tier 3 = `yt-dlp` transcript fallback, **conditional** — probe the environment first, never assume it works. Unresolvable → operator summary remains the path.
|
|
61
62
|
|
|
@@ -78,8 +79,9 @@ Collect from the sources below (bash/endpoint per source in §Collection-Bash).
|
|
|
78
79
|
| Product Hunt `product-hunt` | official Atom feeds, categories `artificial-intelligence` and `developer-tools` | 5 items, or `UNMEASURED` |
|
|
79
80
|
| Show HN `show-hn` | Algolia `search_by_date` with `tags=show_hn`, points floor lower than the main HN leg | 8 items, or `UNMEASURED` |
|
|
80
81
|
| Vendor changelogs/blogs `vendor-changelogs` | Anthropic, OpenAI, Google DeepMind/Gemini, Meta AI, Cursor — RSS where one exists, else the official news/changelog page | 1-2 per vendor, new since last digest, or `UNMEASURED` |
|
|
82
|
+
| Conference channels & tech blogs `slow-leg` | **weekly, not daily**: run only when `python3 scripts/digest_slow_leg.py due` exits 0, then `python3 scripts/digest_slow_leg.py run`. Sources come from an operator-local, gitignored list (`$FH_DIGEST_SLOW_SOURCES`, default `tracks/_meta/digest_slow_sources.tsv`) — which companies someone follows can identify their employer, so no source is named in this public file. Lists new posts and talk uploads only; summarizing a talk goes through `video-ingest` | everything new since last run. `due` exit **3** = not due this week (skip the row); **any other non-zero** (e.g. 2 `STATE-INVALID`) = `UNMEASURED`, never not-due. `run` exit 0 = all read · 4 = some source unread (the listing is still valid; that source waits for next week, so hand it in via Step 0.5) · **any other non-zero** (2 `SOURCES-*`/`STATE-INVALID`, 1 a crash) → `UNMEASURED`. Do not rerun to "retry" — a rerun only appends. Copy **every** source block into the digest, «새 항목 0» lines included (read-and-empty ≠ not read); `UNREACHABLE(…)` · `PARSE-ZERO` · `PARSE-ERROR` lines go in as is and are never `0`. The listing is also saved to `tracks/_meta/digest_slow_<date>.md`. **Never retry a refused feed with a different client identity** — it goes to Step 0.5 as an operator hand-in |
|
|
81
83
|
|
|
82
|
-
Report progress: `📡 HN 15 items · arxiv 5 items · TLDR 5 items · Batch 5 items · GeekNews 5 items · LaunchYC n · PH n · ShowHN n · Vendors n collected` (a leg that could not be read is `UNMEASURED`, never `0`)
|
|
84
|
+
Report progress: `📡 HN 15 items · arxiv 5 items · TLDR 5 items · Batch 5 items · GeekNews 5 items · LaunchYC n · PH n · ShowHN n · Vendors n collected` (+ `· Slow n (+k unread)` on a week the slow leg is due — n = new items listed, k = sources not read; `· Slow not-due` on `due` exit 3; a leg that could not be read is `UNMEASURED`, never `0`)
|
|
83
85
|
|
|
84
86
|
> **Detail**: See `SKILL_detail.md §Collection-Bash` — curl commands per source with parsing notes — read when executing Step 1.
|
|
85
87
|
|
|
@@ -21,6 +21,18 @@ load: on-demand
|
|
|
21
21
|
> through WebFetch on the same URLs. If an environment *does* allow the curl form, it is equivalent —
|
|
22
22
|
> the transport is not the contract, the endpoints and criteria are.
|
|
23
23
|
>
|
|
24
|
+
> 🟥 **A refused or empty response is a result, never a reason to change who you say you are
|
|
25
|
+
> (2026-10-31, AQ-20261030-4 — the slow leg already had this rule; the daily legs did not).** The
|
|
26
|
+
> 10-30 unattended run got 0 B from GeekNews, retried with a User-Agent it made up, and succeeded —
|
|
27
|
+
> and which UA it sent was not logged, so whether that was a browser disguise is `UNMEASURED`. The
|
|
28
|
+
> rule for every daily leg: a block, a 403/429, a captcha page or 0 B is written into the digest as
|
|
29
|
+
> `UNREACHABLE(<code or reason>)`, and a page that came back but parsed to nothing as `PARSE-ZERO` —
|
|
30
|
+
> both are `not found ≠ 0`, never «0 items». **Do not retry with a different client identity**
|
|
31
|
+
> (another browser's User-Agent, a spoofed referrer, a headless-browser fetch to get past a bot
|
|
32
|
+
> check). An honest identifying UA (`forge-harness-digest/<version>`) on the first request is fine;
|
|
33
|
+
> swapping it after a refusal is not. If a refused source matters that day, it goes to Step 0.5 as an
|
|
34
|
+
> operator hand-in. When the curl form is used, the progress line names the UA the leg sent.
|
|
35
|
+
>
|
|
24
36
|
> **arXiv HTTP 429 — fallback is a TRANSPORT change, never a channel change (revised 2026-09-04).**
|
|
25
37
|
> The export API rate-limits this runner (N=11 consecutive by 08-10; 3 consecutive days 09-02·03·04
|
|
26
38
|
> = past the `N≥3` mechanization bar). The 08-10 prescription («fall back to per-item `abs/{id}`
|
|
@@ -0,0 +1,493 @@
|
|
|
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
|
+
labels = []
|
|
173
|
+
for line in p.stdout.splitlines():
|
|
174
|
+
parts = line.split("\t")
|
|
175
|
+
if parts[0] == "TARGET" and len(parts) >= 3:
|
|
176
|
+
labels.append(re.sub(r"^후보\s*", "", parts[2]))
|
|
177
|
+
elif parts[0] == "# UNCHECKABLE" and len(parts) >= 2:
|
|
178
|
+
labels.append(parts[1])
|
|
179
|
+
if not labels:
|
|
180
|
+
return None, "후보 0개 — 절을 못 찾았거나 비었다(0 이 아니라 미측정)"
|
|
181
|
+
heads = digest_heads(digest)
|
|
182
|
+
items = []
|
|
183
|
+
for lab in labels:
|
|
184
|
+
full = heads.get(lab)
|
|
185
|
+
# 원문을 못 찾으면 이름표를 쓰되 그 사실을 항목에 남긴다 — 잘린 줄이 «전체» 처럼 보이지 않게(AQ-20261029-4)
|
|
186
|
+
items.append(full if full else lab + " [이름표만 — 다이제스트 원문 못 찾음]")
|
|
187
|
+
return items, None
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
_HEAD_RE = re.compile(r"^(###+ |\*\*|[0-9]+\. |- \*\*)")
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def digest_heads(digest):
|
|
194
|
+
"""다이제스트 후보 절의 머리 줄 → {검증기 이름표: 머리 문장 전체}.
|
|
195
|
+
이름표는 digest_landing_check.sh 의 awk 와 같은 규칙으로 만든다(머리 표기 떼기 · 첫 굵은 글씨까지 · 공백 기준 앞 6낱말).
|
|
196
|
+
그 규칙이 갈리면 원문을 못 찾고 import-digest 가 «이름표만» 을 붙인다 — 조용히 잘리지 않고 보인다.
|
|
197
|
+
표 행(첫 칸이 id)은 이 대응에 없다 — 그 경우도 «이름표만» 으로 보인다."""
|
|
198
|
+
try:
|
|
199
|
+
lines = open(digest, encoding="utf-8").read().splitlines()
|
|
200
|
+
except Exception:
|
|
201
|
+
return {}
|
|
202
|
+
sec = re.compile(os.environ.get("DLC_SECTION_RE") or r"^## .*Immediate Application Candidates")
|
|
203
|
+
out, inblk = {}, False
|
|
204
|
+
for line in lines:
|
|
205
|
+
if sec.search(line):
|
|
206
|
+
inblk = True
|
|
207
|
+
continue
|
|
208
|
+
if inblk and line.startswith("## "):
|
|
209
|
+
break
|
|
210
|
+
if not inblk:
|
|
211
|
+
continue
|
|
212
|
+
if line.startswith("|"):
|
|
213
|
+
# 표 행 — 검증기는 첫 칸(굵은 글씨 · 공백을 뗀 것)을 이름표로 낸다. 원문은 마지막 칸의 굵은 머리 문장(없으면 칸 전체)
|
|
214
|
+
cells = line.split("|")
|
|
215
|
+
if len(cells) < 4 or re.match(r"^\|[\s]*#", line) or re.match(r"^\|[-:| ]+\|$", line):
|
|
216
|
+
continue
|
|
217
|
+
tid = re.sub(r"[*\s]", "", cells[1])
|
|
218
|
+
body = next((c.strip() for c in reversed(cells[2:]) if c.strip()), "")
|
|
219
|
+
m = re.match(r"^\*\*(.+?)\*\*", body)
|
|
220
|
+
text = (m.group(1) if m else body).strip()
|
|
221
|
+
if tid and text and tid not in out:
|
|
222
|
+
out[tid] = text
|
|
223
|
+
continue
|
|
224
|
+
if not _HEAD_RE.match(line):
|
|
225
|
+
continue
|
|
226
|
+
pid = re.sub(r"^###+ ", "", line)
|
|
227
|
+
pid = re.sub(r"^[0-9]+\. ", "", pid)
|
|
228
|
+
pid = re.sub(r"^- ", "", pid)
|
|
229
|
+
pid = re.sub(r"^\*\*", "", pid)
|
|
230
|
+
pid = re.sub(r"\*\*.*$", "", pid).strip()
|
|
231
|
+
words = pid.split()
|
|
232
|
+
label = " ".join(words[:6]) if len(words) > 6 else pid
|
|
233
|
+
if label and label not in out:
|
|
234
|
+
out[label] = pid
|
|
235
|
+
return out
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def skill_index():
|
|
239
|
+
"""FH 플러그인 + 매핑된 필드 하네스의 SKILL.md 이름 · 설명."""
|
|
240
|
+
roots = [os.path.join(ROOT, "plugins")]
|
|
241
|
+
proj_root = os.environ.get("FH_PROJECTS_ROOT") or os.path.dirname(ROOT)
|
|
242
|
+
tracks = os.path.join(ROOT, "tracks")
|
|
243
|
+
if os.path.isdir(tracks):
|
|
244
|
+
for t in sorted(os.listdir(tracks)):
|
|
245
|
+
if not t.startswith("_") and os.path.isdir(os.path.join(proj_root, t)):
|
|
246
|
+
roots.append(os.path.join(proj_root, t))
|
|
247
|
+
out = []
|
|
248
|
+
for r in roots:
|
|
249
|
+
for d, dirs, files in os.walk(r):
|
|
250
|
+
dirs[:] = [x for x in dirs if x not in (".git", "node_modules", "worktrees", ".claude-worktrees")]
|
|
251
|
+
# 스킬만 보면 검토 에이전트(agents/*.md)가 빠진다 — 10-28 첫 실사용에서 «검토 페르소나 출력»
|
|
252
|
+
# 항목의 짝(persona lens 에이전트)이 후보에 안 나왔다.
|
|
253
|
+
cand = (["SKILL.md"] if "SKILL.md" in files else []) + \
|
|
254
|
+
([f for f in files if f.endswith(".md")] if os.path.basename(d) == "agents" else [])
|
|
255
|
+
for fn in cand:
|
|
256
|
+
p = os.path.join(d, fn)
|
|
257
|
+
try:
|
|
258
|
+
head = open(p, encoding="utf-8", errors="replace").read(4000)
|
|
259
|
+
except OSError:
|
|
260
|
+
continue
|
|
261
|
+
name = re.search(r"^name:\s*(.+)$", head, re.M)
|
|
262
|
+
desc = re.search(r"^description:\s*(.+)$", head, re.M)
|
|
263
|
+
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()))
|
|
264
|
+
return out
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
def tokens(s):
|
|
268
|
+
return {w.lower() for w in re.findall(r"[A-Za-z][A-Za-z0-9_-]{2,}|[가-힣]{2,}", s)}
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
def match(text, top=5):
|
|
272
|
+
want = tokens(text)
|
|
273
|
+
scored = []
|
|
274
|
+
for p, name, desc in skill_index():
|
|
275
|
+
have = tokens(name + " " + desc + " " + name.replace("-", " "))
|
|
276
|
+
hit = want & have
|
|
277
|
+
if hit:
|
|
278
|
+
scored.append((len(hit), p, name, sorted(hit)[:6]))
|
|
279
|
+
scored.sort(key=lambda x: (-x[0], x[1]))
|
|
280
|
+
return scored[:top]
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
def main(argv):
|
|
284
|
+
if not argv or argv[0] in ("-h", "--help"):
|
|
285
|
+
print(__doc__)
|
|
286
|
+
return 0 if argv else 10
|
|
287
|
+
if argv[0] == "--self-test":
|
|
288
|
+
return self_test()
|
|
289
|
+
cmd, rest = argv[0], argv[1:]
|
|
290
|
+
path = qpath()
|
|
291
|
+
lock = None
|
|
292
|
+
if cmd in ("add", "import-digest", "close"):
|
|
293
|
+
# 매일 09:00 잡과 대화 세션이 같은 파일을 읽고-고치고-바꾼다. 잠금 없이는 늦게 쓴 쪽이
|
|
294
|
+
# 먼저 쓴 쪽의 변경을 지운다(codex R1). 잠금은 읽기 전에 잡고 바꾼 뒤에 놓는다.
|
|
295
|
+
try:
|
|
296
|
+
os.makedirs(os.path.dirname(path) or ".", exist_ok=True)
|
|
297
|
+
lock = open(path + ".lock", "w")
|
|
298
|
+
fcntl.flock(lock, fcntl.LOCK_EX)
|
|
299
|
+
except OSError as e:
|
|
300
|
+
print("🟥 잠금 실패: %s" % e, file=sys.stderr)
|
|
301
|
+
return 10
|
|
302
|
+
try:
|
|
303
|
+
rows = load(path)
|
|
304
|
+
except (ValueError, OSError) as e:
|
|
305
|
+
print("🟥 대기열을 못 읽었다: %s" % e, file=sys.stderr)
|
|
306
|
+
return 10
|
|
307
|
+
|
|
308
|
+
def opt(name, many=False):
|
|
309
|
+
vals, i = [], 0
|
|
310
|
+
while i < len(rest):
|
|
311
|
+
if rest[i] == name and i + 1 < len(rest):
|
|
312
|
+
vals.append(rest[i + 1])
|
|
313
|
+
i += 2
|
|
314
|
+
else:
|
|
315
|
+
i += 1
|
|
316
|
+
return vals if many else (vals[-1] if vals else "")
|
|
317
|
+
|
|
318
|
+
if cmd == "add":
|
|
319
|
+
r, how = add_row(rows, opt("--source"), opt("--item"), opt("--asset", many=True))
|
|
320
|
+
if r is None:
|
|
321
|
+
print("🟥 %s" % how, file=sys.stderr)
|
|
322
|
+
return 2
|
|
323
|
+
if how == "added":
|
|
324
|
+
save(path, rows)
|
|
325
|
+
print("%s %s" % ("추가" if how == "added" else "이미 있음", r["id"]))
|
|
326
|
+
return 0
|
|
327
|
+
if cmd == "import-digest":
|
|
328
|
+
if not rest or not os.path.isfile(rest[0]):
|
|
329
|
+
print("🟥 digest 파일이 필요하다", file=sys.stderr)
|
|
330
|
+
return 10
|
|
331
|
+
items, err = extract_digest(rest[0])
|
|
332
|
+
if err:
|
|
333
|
+
print("🟥 %s" % err, file=sys.stderr)
|
|
334
|
+
return 10
|
|
335
|
+
src = "digest:" + os.path.basename(rest[0])
|
|
336
|
+
n_add = 0
|
|
337
|
+
for it in items:
|
|
338
|
+
r, how = add_row(rows, src, it)
|
|
339
|
+
n_add += how == "added"
|
|
340
|
+
if n_add:
|
|
341
|
+
save(path, rows)
|
|
342
|
+
print("digest 후보 %d개 중 새로 %d개 넣음 (%s)" % (len(items), n_add, src))
|
|
343
|
+
return 0
|
|
344
|
+
if cmd == "close":
|
|
345
|
+
if not rest:
|
|
346
|
+
print("🟥 ID 가 필요하다", file=sys.stderr)
|
|
347
|
+
return 10
|
|
348
|
+
err = close_row(rows, rest[0], opt("--status"), opt("--evidence"))
|
|
349
|
+
if err:
|
|
350
|
+
print("🟥 %s — 아무것도 안 썼다" % err, file=sys.stderr)
|
|
351
|
+
return 2
|
|
352
|
+
save(path, rows)
|
|
353
|
+
print("닫음 %s" % rest[0])
|
|
354
|
+
return 0
|
|
355
|
+
if cmd == "list":
|
|
356
|
+
only_open = "--open" in rest
|
|
357
|
+
for r in rows:
|
|
358
|
+
if only_open and r["status"] != "open":
|
|
359
|
+
continue
|
|
360
|
+
print("%s\t%s\t%s\t%s\t%s%s" % (r["id"], r["status"], r["added"], r["item"][:90], r["source"],
|
|
361
|
+
("\t→ " + r["evidence"]) if r["evidence"] else ""))
|
|
362
|
+
return 0
|
|
363
|
+
if cmd == "summary":
|
|
364
|
+
line = summary_line(rows, path)
|
|
365
|
+
if line:
|
|
366
|
+
print(line)
|
|
367
|
+
return 0
|
|
368
|
+
if cmd == "match":
|
|
369
|
+
res = match(" ".join(rest))
|
|
370
|
+
print("# 어휘 선별기 — 겹치는 낱말 수로만 줄 세웠다. 열어서 판단하라(0건 ≠ 짝 없음).")
|
|
371
|
+
for n, p, name, hit in res:
|
|
372
|
+
print("%d\t%s\t%s\t%s" % (n, name, os.path.relpath(p, ROOT), ",".join(hit)))
|
|
373
|
+
return 0
|
|
374
|
+
print("🟥 모르는 명령: %s" % cmd, file=sys.stderr)
|
|
375
|
+
return 10
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
def self_test():
|
|
379
|
+
res = []
|
|
380
|
+
with tempfile.TemporaryDirectory() as td:
|
|
381
|
+
q = os.path.join(td, "q.tsv")
|
|
382
|
+
env = dict(os.environ, FH_ABSORPTION_QUEUE=q, AQ_TODAY="2026-10-28")
|
|
383
|
+
|
|
384
|
+
def run(*a, **kw):
|
|
385
|
+
e = dict(env, **kw.get("env", {}))
|
|
386
|
+
p = subprocess.run([sys.executable, os.path.abspath(__file__)] + list(a), capture_output=True, text=True, env=e)
|
|
387
|
+
return p.returncode, p.stdout + p.stderr
|
|
388
|
+
|
|
389
|
+
rc, out = run("summary")
|
|
390
|
+
res.append(("S1 no queue file → summary prints nothing, rc 0", rc == 0 and out.strip() == ""))
|
|
391
|
+
rc, out = run("add", "--source", "https://example.org/x", "--item", "가져올 것 하나")
|
|
392
|
+
res.append(("A1 add writes an open row", rc == 0 and "AQ-20261028-1" in out))
|
|
393
|
+
rc, out = run("add", "--source", "https://example.org/x", "--item", "가져올 것 하나")
|
|
394
|
+
res.append(("A2 same source+item is not added twice", rc == 0 and "이미 있음" in out and len(load(q)) == 1))
|
|
395
|
+
rc, out = run("add", "--source", "", "--item", "x")
|
|
396
|
+
res.append(("A3 empty source refused (rc 2)", rc == 2))
|
|
397
|
+
rc, out = run("summary", env={"AQ_TODAY": "2026-10-31"})
|
|
398
|
+
res.append(("S2 control: one open row → summary names count 1 and age 3", rc == 0 and "열림 1" in out and "3일" in out))
|
|
399
|
+
rc, out = run("close", "AQ-20261028-1", "--status", "landed", "--evidence", "done")
|
|
400
|
+
res.append(("C1 landed without PR#/commit refused, nothing written", rc == 2 and load(q)[0]["status"] == "open"))
|
|
401
|
+
rc, out = run("close", "AQ-20261028-1", "--status", "declined", "--evidence", "-")
|
|
402
|
+
res.append(("C2 declined without a reason refused", rc == 2 and load(q)[0]["status"] == "open"))
|
|
403
|
+
rc, out = run("close", "AQ-20261028-1", "--status", "landed", "--evidence", "PR #975")
|
|
404
|
+
res.append(("C3 control: landed with PR# closes", rc == 0 and load(q)[0]["status"] == "landed"))
|
|
405
|
+
rc, out = run("close", "AQ-20261028-1", "--status", "landed", "--evidence", "abc")
|
|
406
|
+
res.append(("C4 a 3-char hex is not a commit", rc == 2))
|
|
407
|
+
rc, out = run("summary")
|
|
408
|
+
res.append(("S3 all closed → summary prints nothing", rc == 0 and out.strip() == ""))
|
|
409
|
+
# codex R1 — 근거 규칙의 양쪽
|
|
410
|
+
run("add", "--source", "s2", "--item", "둘")
|
|
411
|
+
rcs = tuple(run("close", "AQ-20261028-2", "--status", st, "--evidence", ev)[0]
|
|
412
|
+
for st, ev in (("landed", "defaced"), ("landed", "1234567"), ("landed", "deadbee"),
|
|
413
|
+
("declined", "__"), ("declined", "123")))
|
|
414
|
+
res.append(("R1 bare hex/digits are not evidence; «__» · «123» are not reasons", rcs == (2, 2, 2, 2, 2)))
|
|
415
|
+
rc, _ = run("close", "AQ-20261028-2", "--status", "landed", "--evidence", "https://github.com/o/r/pull/975")
|
|
416
|
+
res.append(("R2 control: a PR URL is evidence", rc == 0))
|
|
417
|
+
run("add", "--source", "s3", "--item", "셋")
|
|
418
|
+
rc, _ = run("close", "AQ-20261028-3", "--status", "landed", "--evidence", "commit:deadbee (hash without digits)")
|
|
419
|
+
run("add", "--source", "s4", "--item", "넷")
|
|
420
|
+
rc2, _ = run("close", "AQ-20261028-4", "--status", "landed", "--evidence", "friends-on-desk@f1a96e4")
|
|
421
|
+
res.append(("R3 control: commit:<hex> and <repo>@<hex> are evidence (digits not required)", (rc, rc2) == (0, 0)))
|
|
422
|
+
rc, out = run("close", "AQ-nope", "--status", "declined", "--evidence", "중복")
|
|
423
|
+
res.append(("C5 unknown ID refused", rc == 2))
|
|
424
|
+
# digest — 같은 절 규칙(digest_landing_check --extract)을 쓰는지, 두 번 넣어도 한 번인지
|
|
425
|
+
d = os.path.join(td, "frontier_digest_2026_10_28.md")
|
|
426
|
+
with open(d, "w", encoding="utf-8") as f:
|
|
427
|
+
f.write("# d\n\n## FH Immediate Application Candidates\n\n"
|
|
428
|
+
"- **후보 하나 (`builtin_capability_map`).** 본문.\n"
|
|
429
|
+
"- **후보 둘 — 토큰 없음.** 본문.\n\n## Warning Signals\n\n- 무관\n")
|
|
430
|
+
n0 = len(load(q))
|
|
431
|
+
rc, out = run("import-digest", d, env={"CLAUDE_PROJECT_DIR": ROOT})
|
|
432
|
+
n1 = len(load(q))
|
|
433
|
+
rc2, out2 = run("import-digest", d, env={"CLAUDE_PROJECT_DIR": ROOT})
|
|
434
|
+
res.append(("D1 digest candidates enter the queue (incl. UNCHECKABLE), second import adds 0",
|
|
435
|
+
rc == 0 and n1 == n0 + 2 and rc2 == 0 and len(load(q)) == n1 and "새로 0개" in out2))
|
|
436
|
+
e = os.path.join(td, "frontier_digest_empty.md")
|
|
437
|
+
with open(e, "w", encoding="utf-8") as f:
|
|
438
|
+
f.write("# d\n\n## Warning Signals\n\n- 무관\n")
|
|
439
|
+
rc, out = run("import-digest", e, env={"CLAUDE_PROJECT_DIR": ROOT})
|
|
440
|
+
res.append(("D2 digest without the section is an error (rc 10), not 0 candidates", rc == 10 and len(load(q)) == n1))
|
|
441
|
+
# AQ-20261029-4 — 항목은 검증기의 6낱말 이름표가 아니라 머리 문장 전체다(목록 · 표 두 형식)
|
|
442
|
+
lg = os.path.join(td, "frontier_digest_2026_10_29.md")
|
|
443
|
+
long_head = "교차 계열 검증 집계에서 «같은 근거의 재전달» 을 한 표로 센다 (`arXiv:2610.36151`)."
|
|
444
|
+
with open(lg, "w", encoding="utf-8") as f:
|
|
445
|
+
f.write("# d\n\n## FH Immediate Application Candidates\n\n- **" + long_head + "** 본문.\n\n"
|
|
446
|
+
"| # | 티어 | 내용 |\n|---|---|---|\n| **M1** | **M** | **표 후보의 머리 문장 (`gate_locality_principle`)** — 설명 |\n\n"
|
|
447
|
+
"## Warning Signals\n\n- 무관\n")
|
|
448
|
+
rc, out = run("import-digest", lg, env={"CLAUDE_PROJECT_DIR": ROOT})
|
|
449
|
+
got = [r["item"] for r in load(q) if r["source"] == "digest:frontier_digest_2026_10_29.md"]
|
|
450
|
+
res.append(("D3 a head longer than six words is stored whole, not cut at the display label",
|
|
451
|
+
rc == 0 and long_head in got and not any(g.endswith("«같은 근거의") for g in got)))
|
|
452
|
+
res.append(("D4 a table candidate is stored by its body head, not by its id cell («M1»)",
|
|
453
|
+
"표 후보의 머리 문장 (`gate_locality_principle`)" in got and "M1" not in got))
|
|
454
|
+
# 대응을 못 하면(두 규칙이 갈림) 이름표를 쓰되 그 사실이 항목에 보인다 — 조용한 절단 금지
|
|
455
|
+
saved = digest_heads
|
|
456
|
+
try:
|
|
457
|
+
globals()["digest_heads"] = lambda _d: {}
|
|
458
|
+
items, err = extract_digest(lg)
|
|
459
|
+
finally:
|
|
460
|
+
globals()["digest_heads"] = saved
|
|
461
|
+
res.append(("D5 an unmatched label is marked «이름표만», not passed off as the full item",
|
|
462
|
+
err is None and items and all("[이름표만" in i for i in items)))
|
|
463
|
+
# 동시 쓰기 — 잠금이 없으면 늦게 쓴 쪽이 앞의 행을 지운다
|
|
464
|
+
procs = [subprocess.Popen([sys.executable, os.path.abspath(__file__), "add", "--source", "par", "--item", "p%d" % i],
|
|
465
|
+
env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) for i in range(12)]
|
|
466
|
+
for pr in procs:
|
|
467
|
+
pr.wait()
|
|
468
|
+
par = [r for r in load(q) if r["source"] == "par"]
|
|
469
|
+
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))
|
|
470
|
+
good = open(q, encoding="utf-8").read()
|
|
471
|
+
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"),
|
|
472
|
+
("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"),
|
|
473
|
+
("L4 a row with an empty item is an error", "AQ-z\t2026-10-28\ts\t\t\topen\t\t\n"),
|
|
474
|
+
("L5 a row with a bad added date is an error", "AQ-w\t28/10/2026\ts\ti\t\topen\t\t\n"),
|
|
475
|
+
("L1 a malformed row is an error (rc 10), not silently skipped", "broken\trow\n")):
|
|
476
|
+
with open(q, "w", encoding="utf-8") as f:
|
|
477
|
+
f.write(good + row)
|
|
478
|
+
rc, out = run("summary")
|
|
479
|
+
res.append((label, rc == 10))
|
|
480
|
+
m = match("ko-tech-writer 번역투 기술블로그 개고")
|
|
481
|
+
res.append(("M1 match finds ko-tech-writer for its own vocabulary", any(name == "ko-tech-writer" for _, _, name, _ in m)))
|
|
482
|
+
m2 = match("QA 엔지니어 테스트 케이스 재현 화면")
|
|
483
|
+
res.append(("M2 match also indexes agent definitions (qa-lens)", any(p.endswith("agents/qa-lens.md") for _, p, _, _ in m2)))
|
|
484
|
+
ok = 0
|
|
485
|
+
for name, passed in res:
|
|
486
|
+
print("%s %s" % ("OK " if passed else "FAIL", name))
|
|
487
|
+
ok += passed
|
|
488
|
+
print("── PASS=%d FAIL=%d ──" % (ok, len(res) - ok))
|
|
489
|
+
return 0 if ok == len(res) else 1
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
if __name__ == "__main__":
|
|
493
|
+
sys.exit(main(sys.argv[1:]))
|