@chrono-meta/fh-gate 3.31.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/README.md +6 -3
- package/docs/USER_GUIDE.md +1 -1
- package/knowledge/shared/harness-core/claude_md_full_reference.md +19 -0
- package/knowledge/shared/harness-core/dispatch_conditional_prohibition.md +17 -0
- package/knowledge/shared/learnings/subagent_invocations_log.yaml +84 -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 +35 -0
- package/plugins/fh-meta/skills/install-wizard/SKILL.md +11 -5
- 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_detach.py +41 -19
- package/scripts/fh_session_load.sh +29 -0
- package/scripts/ko_tech_writer_calibrate.py +284 -7
- package/scripts/mutation_probe.py +16 -0
- package/scripts/selfcheck.sh +1 -0
- package/scripts/test_absorption_queue_lanes.sh +10 -0
- package/scripts/test_fh_detach_lanes.sh +52 -2
- package/scripts/test_fh_run_resolver_lanes.sh +16 -0
- package/scripts/test_mutation_probe_lanes.sh +17 -35
- package/scripts/test_prepush_real_fire_lanes.sh +1 -1
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# forge-harness (fh-meta) Changelog
|
|
2
2
|
|
|
3
|
+
### [Unreleased]
|
|
4
|
+
|
|
5
|
+
### [3.33.0] — 2026-10-28 — 빌더에게 일을 넘길 때 카드 두 줄(CC · Codex 진입점 둘 다) · 주간 감사 앵커 되돌림 표본 · ko-tech-writer 개고 사후 검사 · 흡수 대기열
|
|
6
|
+
|
|
7
|
+
훅 변경은 없다. 스크립트는 하나 늘고(`scripts/absorption_queue.py`) 하나에 검사 모드가 늘었다(`scripts/ko_tech_writer_calibrate.py`). 세션 시작 로더와 digest 러너에 대기열 줄이 하나씩 들어갔다. 나머지는 문서다. 빌더에게 일을 넘기는 방식을 바꾸는 규칙이 들어 있어 버전 정책상 minor 다(블라인드 sim, 팔당 n=3).
|
|
8
|
+
|
|
9
|
+
소비자에게 닿는 변화:
|
|
10
|
+
- `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회). 그래서 이 검사는 날조를 고친 수리가 아니라 «남길 곳이 남았나» 를 고정하는 회귀 장치로 넣었다.
|
|
11
|
+
- `CATALOG.md`: 색인에 없던 knowledge 문서 5개와 v3.22–v3.32 릴리스 목록 한 줄을 더했다.
|
|
12
|
+
- 흡수 대기열(새 스크립트 `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개.
|
|
13
|
+
- 형제 자산 프로토콜 · `CLAUDE.md` 의도 표: 운영자가 무언가를 고치려고 바깥 자료를 건네면, 그 자료를 대기열에 넣고 `match` 로 닿는 자산을 이름 붙인 뒤, 고친 PR 로 닫는다. 이건 기록 절차이고 작업을 막지 않는다(대기열 오류 · 짝 없음 · 열린 항목이 있어도 요청받은 일은 계속한다).
|
|
14
|
+
- `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`.
|
|
15
|
+
- `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 런타임에서는 안 쟀다.
|
|
16
|
+
- `knowledge/shared/rules/operations.md` 주간 감사 2b: «앵커 되돌림 표본» — 창 안에 머지된 변경 3개의 앵커 레인을 일회용 워크트리에서 수리 줄만 `git apply -R` 로 되돌려 빨개지는지 본다(그 워크트리는 빌더 줄 2 의 «받은 트리» 가 아니다). 첫 실행은 n=2.
|
|
17
|
+
|
|
18
|
+
허브 운영자 참고(소비자 설치본과 다름):
|
|
19
|
+
- `dispatch_conditional_prohibition.md §Two-Purposes`: 저자 체크아웃(운영자 전용 CLAUDE.local.md · 메모리 색인 포함)의 첫 호출 입력 토큰이 빈 폴더보다 +62,600~64,800(haiku · 한 낱말 과제 · 팔당 3회). npm 설치본에는 그 두 파일이 없으니 이 숫자를 자기 설치의 비용으로 읽지 말 것.
|
|
20
|
+
- 바깥 근거로 든 arXiv 수치(2610.34491 · 2610.34167)는 그날 frontier digest 요약 기준이고 원문은 열지 않았다.
|
|
21
|
+
|
|
22
|
+
### [3.32.0] — 2026-10-28 — fh_detach 기본 = 프로젝트 하나 · CI 에서 pipefail 델타 잠금이 실제로 돈다 · 레인 앵커 보강
|
|
23
|
+
|
|
24
|
+
**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.
|
|
25
|
+
|
|
26
|
+
BREAKING (gate): (hub clones only — not in the npm package) selfcheck's pipefail class-lock lane now FAILS under `GITHUB_ACTIONS=true` when the delta cannot find a base — check out with `fetch-depth: 0`, and on a push pass the event's `before` as `PIPESCAN_BASE` (this repository's `validate.yml` now does both). A `before` missing after a force-push falls back to `merge-base(HEAD, origin/main)` with a warning; if that is HEAD itself (force-push to main), it fails.
|
|
27
|
+
|
|
28
|
+
소비자에게 닿는 변화:
|
|
29
|
+
- `scripts/fh_detach.py`: 기본 범위가 **그 프로젝트 하나**다(실행은 여전히 `--apply` 가 있어야 한다). 지우는 것 = 그 프로젝트의 `.claude/settings*.json` FH 훅 · `CLAUDE.local.md` 동반 절 · 그 프로젝트의 `~/.cc_sentinels` 이름 · 안 고친 템플릿 사본. 남는 것 = `~/.zshrc` 블록 · FH 클론 자신의 훅과 동반 절 · `core.hooksPath` · 다른 프로젝트 · 플러그인 — 공유분은 `kept (machine-wide …)` 줄로 보인다. `--machine` 을 주면 공유분까지 지운다(그래도 다른 프로젝트는 그대로 — 각자 `--project` 로 먼저 떼고 `--machine` 은 마지막에). 🟥 3.31.0 에서 `--apply` 로 머신 전체를 떼던 사람은 이제 `--machine` 을 더해야 같은 결과다. 예외: `--project` 가 FH 클론 자신이면 그 클론의 훅·동반 절은 «그 프로젝트 것» 이라 `--machine` 없이도 지워진다(셸 블록·hooksPath 는 여전히 `--machine` 만). 공유 단계(셸 블록 · 클론 settings · hooksPath)의 읽기 오류는 `--machine` 일 때만 종료 10 이고, 없으면 `kept (machine-wide, could not be read …)` 로 보인다. 그 프로젝트 자신의 파일이나 배포 스니펫을 못 읽으면 종래대로 종료 10(트레이스백 대신 `HARNESS-ERROR`, #968). install-wizard SKILL.md §Detach · README · USER_GUIDE(#965 · #968).
|
|
30
|
+
- `scripts/pipefail_earlyexit_scan.sh changed`(새 pipefail 조기종료 줄을 막는 델타 잠금): 기준(`merge-base HEAD origin/main`)을 못 구하면 HEAD 로 떨어져 «변경 없음 SKIP» rc 0 을 내던 폴백을 없앴다 — 이제 rc 2(측정 못 함). 얕은 CI 체크아웃에서 이 잠금이 한 번도 물지 않았다(하류 실측 2026-10-27). 기준은 두 번째 인자(주었는데 체크아웃에 없으면 rc 2) 또는 새 환경변수 `PIPESCAN_BASE`(0 으로만 된 sha 는 미설정 · 체크아웃에 없으면 경고 뒤 merge-base, 그게 HEAD 면 rc 2)로 줄 수 있다. selfcheck 의 이 레인은 CI(`GITHUB_ACTIONS=true`)에서 측정 못 하면 실패한다(로컬은 종전대로 경고). 같은 PR 에서 배포되는 레인 `test_prepush_real_fire_lanes.sh` 의 `stdin_has` 를 파이프 없이 고쳤다(`grep -q` 조기 종료가 생산자를 SIGPIPE 로 죽이는 형태)(#966 · #968).
|
|
31
|
+
- `scripts/test_mutation_probe_lanes.sh` R7-1: 다른 프로브가 «읽은 뒤·잠그기 전» 에 대상을 되돌리는 경우를, 시간 추정(잠금까지 걸린 시간의 절반) 대신 관측으로 맞춘다 — `scripts/mutation_probe.py` 의 테스트 전용 환경변수 `MUTATION_PROBE_TEST_AFTER_READ`(설정하지 않으면 효과 없음)가 읽은 직후 `<경로>.read` 를 만들고 `<경로>.go` 를 60초까지 기다린다. 표지 자리에 미리 있는 링크·파일은 따라가지 않고 종료 2(R7-1c). 빠른 러너에서 복원이 잠금 뒤로 밀려 옳은 프로브가 빨개지던 하류 실측이 계기다(#966).
|
|
32
|
+
- `scripts/test_fh_run_resolver_lanes.sh` F8: `package.json` 없는 트리에서 `fh-run.sh` 가 경고를 내고 버전을 `UNKNOWN-no-package-json` 으로 적고 계속 해석하는지 직접 돈다. 3.7.0 의 «무음 사망» 수리(#715)가 이 파일을 앵커로 적었지만 그 경우를 한 번도 안 돌렸다(수리 전 코드로 되돌려도 초록이었다 — 2026-10-28 플로어 재검). `dispatch_conditional_prohibition.md §Two-Purposes`: 도구 정의 개수를 한 번 실측해 적었다(쓸 수 있는 도구 112 · FH 가 더하는 도구 0) — 로드된 개수는 여전히 `UNMEASURED`(#967).
|
|
33
|
+
- `scripts/fh_session_load.sh`(배포됨): 아래 허브 동기화가 거부 표지를 남겼을 때만 세션 시작에 두 줄을 띄운다 — 표지가 없으면 아무것도 안 한다(#964).
|
|
34
|
+
|
|
35
|
+
허브에서만(이 레포를 클론해 컴패니언 스토어 동기화를 쓰는 경우 — `sync-to-be.sh` 는 npm 패키지에 없다):
|
|
36
|
+
- `scripts/sync-to-be.sh` 가 대량 유입으로 거부(rc 14)하면 표지를 남긴다. 표지는 원인을 고친 뒤(제외 · 삭제 · `FH_SYNC_BULK_OK=1`) **다음 동기화가 «커밋할 것 없음» 이나 커밋까지 가야** 지워진다. 다른 스토어의 표지는 표지와 현재 스토어 경로가 둘 다 있을 때만 걸러진다(#964).
|
|
37
|
+
|
|
3
38
|
### [3.31.0] — 2026-10-27 — 설치 마법사 되돌리기(fh_detach) · 디스패치마다 목적 적기 · selfcheck 시간 상한 · 바깥 질문 검사기(실험 종료 · 호출부 없음)
|
|
4
39
|
|
|
5
40
|
**minor.** In short (for upgraders): one new tool takes off what `/install-wizard` put on (`scripts/fh_detach.py`, dry run by default), one new checker screens a question before it goes to an outside model (`scripts/abstract_consult_check.py`, nothing calls it — off by default), and `selfcheck.sh` gives the mutation-probe lane suite a longer time budget. `fh_detach.py` takes FH off the whole machine setup (the `~/.zshrc` block and the FH clone's hooks go too), not one project — run the dry run first. The pre-send checker is an ended experiment (it missed its pre-registered bar) kept as an inert tool: it sends nothing and nothing calls it. For npm consumers nothing that passed before is refused now; upgrading from 3.30.0 needs no action. The one `BREAKING (gate)` line below applies only if you run the companion-store sync script (`scripts/sync-to-be.sh`) from a clone of this repository — that script is not in the npm package.
|
|
@@ -289,16 +289,22 @@ When run again in an environment that has already passed the wizard (`~/.cc_sent
|
|
|
289
289
|
|
|
290
290
|
## Detach (undo the wizard)
|
|
291
291
|
|
|
292
|
-
What this wizard writes can be taken back with one command (the named residuals below are the exceptions).
|
|
293
|
-
takes FH off
|
|
294
|
-
|
|
292
|
+
What this wizard writes can be taken back with one command (the named residuals below are the exceptions). By
|
|
293
|
+
default it takes FH off **one project** — that project's hooks, companion section, sentinels and template copies.
|
|
294
|
+
`--machine` also removes what every project shares: the zshrc block, the FH clone's own hooks and `core.hooksPath`;
|
|
295
|
+
without it those are listed as `kept (machine-wide …)` and left alone. Neither touches another project the wizard
|
|
296
|
+
ran in — detach each one with its own `--project`, and run `--machine` last. Changed in 3.32.0 (before, `--apply` also
|
|
297
|
+
removed the shared setup). When `--project` is the FH clone itself, its own hooks and companion section are that
|
|
298
|
+
project's and go without `--machine`. With no clone (plugin only), use
|
|
299
|
+
`claude plugin uninstall fh-meta@forge-harness` instead:
|
|
295
300
|
|
|
296
301
|
```bash
|
|
297
302
|
python3 "$FH_DIR/scripts/fh_detach.py" --project . # dry run — prints the plan, changes nothing
|
|
298
|
-
python3 "$FH_DIR/scripts/fh_detach.py" --project . --apply # carry it out
|
|
303
|
+
python3 "$FH_DIR/scripts/fh_detach.py" --project . --apply # carry it out for this project
|
|
304
|
+
python3 "$FH_DIR/scripts/fh_detach.py" --project . --machine --apply # this project + what every project shares (--plugin also uninstalls fh-meta and removes the forge-harness marketplace entry)
|
|
299
305
|
```
|
|
300
306
|
|
|
301
|
-
|
|
307
|
+
Together (with `--machine`) they remove the zshrc block, the FH hook entries (every field equal to a shipped snippet entry, key order ignored),
|
|
302
308
|
the companion section in `CLAUDE.local.md`, the gate's `core.hooksPath`, this project's `~/.cc_sentinels/*_wizard_*`
|
|
303
309
|
files and unchanged template copies. A user's own hook survives, even one sharing a script name or a group with FH —
|
|
304
310
|
unless it is identical to FH's shipped entry, which the tool cannot tell apart.
|
|
@@ -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:]))
|
package/scripts/fh_detach.py
CHANGED
|
@@ -2,19 +2,22 @@
|
|
|
2
2
|
"""fh_detach.py — undo what /install-wizard wrote, and nothing else.
|
|
3
3
|
|
|
4
4
|
Usage:
|
|
5
|
-
python3 scripts/fh_detach.py [--project DIR] [--fh-dir DIR] [--home DIR] [--apply] [--plugin]
|
|
5
|
+
python3 scripts/fh_detach.py [--project DIR] [--machine] [--fh-dir DIR] [--home DIR] [--apply] [--plugin]
|
|
6
6
|
|
|
7
7
|
Default is a dry run: it prints the plan and changes nothing. `--apply` carries it out.
|
|
8
8
|
|
|
9
|
+
Scope: by default only the project — ②(the project's files) ③ ⑤ ⑥. `--machine` adds what every project shares:
|
|
10
|
+
① ~/.zshrc, ② and ③ in the FH clone itself, and ④. Without it, those are listed as kept, never touched.
|
|
11
|
+
|
|
9
12
|
What counts as FH's (each is removed only on an EXACT match with what the wizard writes today):
|
|
10
|
-
① ~/.zshrc the wizard's block (marked `# >>> forge-harness >>>` … or the older unmarked 4 lines)
|
|
13
|
+
① ~/.zshrc [--machine] the wizard's block (marked `# >>> forge-harness >>>` … or the older unmarked 4 lines)
|
|
11
14
|
② <dir>/.claude/settings.json · settings.local.json
|
|
12
15
|
hook entries equal in every field (key order ignored) to an entry in a shipped
|
|
13
16
|
templates/settings.*.snippet.json, or to the Mode-D companion hook form. A file the wizard created is deleted when
|
|
14
17
|
nothing else is left in it; if a .prewizard backup equals the stripped file, its bytes are
|
|
15
18
|
put back (so the user's own formatting returns).
|
|
16
19
|
③ <dir>/CLAUDE.local.md the «Companion-store session-start read» section the wizard appended
|
|
17
|
-
④ git core.hooksPath only when it is `templates/.git-hooks` (the wizard's value) in the FH clone
|
|
20
|
+
④ git core.hooksPath [--machine] only when it is `templates/.git-hooks` (the wizard's value) in the FH clone
|
|
18
21
|
⑤ ~/.cc_sentinels/<project>_wizard_* (and the folder, when that leaves it empty)
|
|
19
22
|
⑥ .claude/rules/local_fh_context.md · fh_env_context.jsonc only when byte-equal to the shipped template,
|
|
20
23
|
plus their exact lines in .git/info/exclude
|
|
@@ -22,10 +25,9 @@ What counts as FH's (each is removed only on an EXACT match with what the wizard
|
|
|
22
25
|
|
|
23
26
|
What it never does: delete a user's own hook (even one sharing a group or a script name with FH — a hook identical
|
|
24
27
|
to FH's shipped entry cannot be told apart and is treated as FH's), edit a line it did not write, or touch a file
|
|
25
|
-
it cannot parse (that is exit 10, file untouched).
|
|
26
|
-
whole setup, not one project.
|
|
28
|
+
it cannot parse (that is exit 10, file untouched).
|
|
27
29
|
|
|
28
|
-
Exit: 0 = no recognised FH trace left · 1 = something FH-like is left that needs a human look (listed) ·
|
|
30
|
+
Exit: 0 = no recognised FH trace left in the chosen scope (machine-wide ones kept without --machine are listed) · 1 = something FH-like is left that needs a human look (listed) ·
|
|
29
31
|
10 = could not read something it needed (nothing changed past that point) · 11 = bad arguments.
|
|
30
32
|
"""
|
|
31
33
|
import argparse
|
|
@@ -378,11 +380,14 @@ def plan_plugin(plan):
|
|
|
378
380
|
|
|
379
381
|
def main(argv=None):
|
|
380
382
|
ap = argparse.ArgumentParser(
|
|
381
|
-
description="Undo what /install-wizard wrote (dry run unless --apply).
|
|
382
|
-
"the FH clone's hooks and core.hooksPath
|
|
383
|
+
description="Undo what /install-wizard wrote (dry run unless --apply). Default: only --project. "
|
|
384
|
+
"--machine also takes the ~/.zshrc block, the FH clone's hooks and core.hooksPath.",
|
|
383
385
|
epilog="exit: 0 no recognised FH trace left · 1 something FH-like is LEFT (listed) for a human look · "
|
|
384
386
|
"10 could not read something it needed · 11 bad arguments")
|
|
385
387
|
ap.add_argument("--project", default=os.getcwd(), help="project the wizard ran in (default: cwd)")
|
|
388
|
+
ap.add_argument("--machine", action="store_true",
|
|
389
|
+
help="also remove what every project shares: the ~/.zshrc block, the FH clone's own hooks and "
|
|
390
|
+
"companion section, and core.hooksPath (default: only --project)")
|
|
386
391
|
ap.add_argument("--fh-dir", default=os.environ.get("FH_DIR") or os.path.dirname(os.path.dirname(
|
|
387
392
|
os.path.abspath(__file__))), help="FH clone/package (default: $FH_DIR, else this script's repo)")
|
|
388
393
|
ap.add_argument("--home", default=os.path.expanduser("~"), help="home directory to clean (default: ~)")
|
|
@@ -396,27 +401,37 @@ def main(argv=None):
|
|
|
396
401
|
proj = os.path.abspath(a.project)
|
|
397
402
|
fh = os.path.abspath(a.fh_dir)
|
|
398
403
|
plan = Plan(a.apply)
|
|
404
|
+
# machine-wide steps go to their own plan; without --machine they are only reported, never run
|
|
405
|
+
shared = plan if a.machine else Plan(False)
|
|
406
|
+
unread = [] # without --machine an unreadable shared file is reported, never a reason to stop (codex R1)
|
|
407
|
+
|
|
408
|
+
def plan_shared(fn, *args):
|
|
409
|
+
try:
|
|
410
|
+
fn(shared, *args)
|
|
411
|
+
except (HarnessError, OSError, UnicodeDecodeError) as e: # a read failure, not only a parse one (codex R2)
|
|
412
|
+
if a.machine:
|
|
413
|
+
raise e if isinstance(e, HarnessError) else HarnessError(str(e))
|
|
414
|
+
unread.append(str(e))
|
|
399
415
|
try:
|
|
400
416
|
cmds, keys = snippet_commands(fh)
|
|
401
|
-
plan_zshrc
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
seen.add(d)
|
|
417
|
+
plan_shared(plan_zshrc, a.home)
|
|
418
|
+
for name in ("settings.json", "settings.local.json"):
|
|
419
|
+
plan_settings(plan, os.path.join(proj, ".claude", name), cmds, keys)
|
|
420
|
+
plan_claude_local(plan, proj)
|
|
421
|
+
if fh != proj: # fh == proj: the clone is the project, already planned above
|
|
407
422
|
for name in ("settings.json", "settings.local.json"):
|
|
408
|
-
plan_settings
|
|
409
|
-
plan_claude_local
|
|
410
|
-
plan_hookspath
|
|
423
|
+
plan_shared(plan_settings, os.path.join(fh, ".claude", name), cmds, keys)
|
|
424
|
+
plan_shared(plan_claude_local, fh)
|
|
425
|
+
plan_shared(plan_hookspath, fh)
|
|
411
426
|
plan_sentinels(plan, a.home, os.path.basename(proj))
|
|
412
427
|
plan_copies(plan, fh, proj)
|
|
413
428
|
plan_rules_dir(plan, proj)
|
|
414
429
|
if a.plugin:
|
|
415
430
|
plan_plugin(plan)
|
|
416
|
-
except HarnessError as e:
|
|
431
|
+
except (HarnessError, OSError, UnicodeDecodeError) as e: # a project file that cannot be READ is exit 10 too, not a traceback
|
|
417
432
|
print("fh-detach: HARNESS-ERROR — %s" % e, file=sys.stderr)
|
|
418
433
|
return 10
|
|
419
|
-
steps =
|
|
434
|
+
steps =[l for l, _ in plan.actions if l]
|
|
420
435
|
print("fh-detach %s — %d step(s)" % ("APPLY" if a.apply else "DRY RUN (nothing changed; add --apply)", len(steps)))
|
|
421
436
|
for l in steps:
|
|
422
437
|
print(" - " + l)
|
|
@@ -427,6 +442,13 @@ def main(argv=None):
|
|
|
427
442
|
except (OSError, subprocess.CalledProcessError) as e:
|
|
428
443
|
print("fh-detach: HARNESS-ERROR at «%s»: %s" % (label, e), file=sys.stderr)
|
|
429
444
|
return 10
|
|
445
|
+
if shared is not plan:
|
|
446
|
+
for l in [l for l, _ in shared.actions if l]:
|
|
447
|
+
print(" kept (machine-wide — every project shares it; --machine removes it): " + l)
|
|
448
|
+
for l in shared.left:
|
|
449
|
+
print(" kept (machine-wide, not an exact FH match — --machine would leave it too; look at it): " + l)
|
|
450
|
+
for l in unread:
|
|
451
|
+
print(" kept (machine-wide, could not be read — not checked; --machine would stop with exit 10): " + l)
|
|
430
452
|
for n in plan.notes:
|
|
431
453
|
print(" note: " + n)
|
|
432
454
|
for l in plan.left:
|