@chrono-meta/fh-gate 3.26.2 → 3.27.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 +2 -1
- package/CLAUDE.md +84 -1329
- package/knowledge/shared/dialogue/memory_intent_recall.md +35 -0
- package/knowledge/shared/harness-core/builtin_capability_map.md +70 -0
- package/knowledge/shared/harness-core/claude_md_full_reference.md +1277 -0
- package/knowledge/shared/harness-core/multi_model_sidecar_strategy.md +64 -0
- package/knowledge/shared/learnings/subagent_invocations_log.yaml +64 -0
- package/package.json +5 -1
- package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-meta/CHANGELOG.md +13 -0
- package/plugins/fh-meta/skills/context-doctor/SKILL.md +1 -1
- package/plugins/fh-meta/skills/install-doctor/SKILL.md +1 -1
- package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
- package/scripts/fh_env_delta_scan.sh +20 -4
- package/scripts/memory_gc_report.py +270 -0
- package/scripts/selfcheck.sh +27 -0
- package/scripts/test_env_delta_worktree_lanes.sh +61 -0
- package/scripts/test_memory_gc_report_lanes.sh +210 -0
- package/scripts/test_regression_guard_sibling_lanes.sh +193 -0
- package/templates/regression_guard.sh +30 -12
|
@@ -268,6 +268,70 @@ audit. (Derived 2026-07-04, operator + H1 measurement; the batch-side dual of th
|
|
|
268
268
|
above. The native-harness Gemini path via `agy` is headless-usable again once tool-permission auto-proceed
|
|
269
269
|
is set — see [[reference_agy_model_catalog]] for the pin/permission mechanics.)
|
|
270
270
|
|
|
271
|
+
### Local typed-decision models — a review-surface candidate, never a gate (measured 2026-10-15)
|
|
272
|
+
|
|
273
|
+
A newer class sits next to the batch judges above: a **small local model that answers only typed
|
|
274
|
+
questions** (yes/no · category · score with probabilities) and never writes prose. The hosted
|
|
275
|
+
original is TypeSafe's Jev; `local-jev` (MIT, 2 commits at the time) is a wire-compatible local server
|
|
276
|
+
running Qwen 4B or an English NLI model. The pitch reads like a gate — put it on `PreToolUse:Bash` and
|
|
277
|
+
ask "is this command safe?". Measured on a 4090, one run each, before you wire one:
|
|
278
|
+
|
|
279
|
+
| Question | Corpus | Baseline | Local model |
|
|
280
|
+
|---|---|---|---|
|
|
281
|
+
| "should a careful developer stop and confirm?" | 318 git commands labelled blocked/allowed by an external tool's own test suite | keyword regex **67.6 %** | Qwen3.5-4B **76.7 %** at threshold 0.7 (0.708 at 0.5) |
|
|
282
|
+
| "does this record show the operator's request landed?" | 60 utterance→record pairs + 60 same-session neighbour records as negatives | word overlap **65.8 %** | Qwen3.5-4B **78.3 %** at 0.5 · English NLI model on Korean **≈ 50 %** (chance) |
|
|
283
|
+
| same, with the governor's preceding message added | 48 of those utterances found in transcripts → 96 pairs, **both arms on the same 96** | — | **0.812 → 0.583** — this context construction hurt |
|
|
284
|
+
|
|
285
|
+
Readings — **scoped to these configurations** (one 4B model, one question wording per row, one run).
|
|
286
|
+
They are working hypotheses for your own measurement, not properties of the whole class:
|
|
287
|
+
|
|
288
|
+
1. **Calibrate on a known pair first — as a sanity check, not as the adoption test.** The server's
|
|
289
|
+
default model scored `git status` 0.24 and `git reset --hard` 0.23. An instrument that cannot
|
|
290
|
+
separate a pair you already know is not measuring (§Instrument Calibration in `CLAUDE.md`). Language
|
|
291
|
+
is part of the pair: an English NLI model on Korean records was at chance. Passing the pair only
|
|
292
|
+
licenses the next step (item 6); it says nothing about realistic inputs.
|
|
293
|
+
2. **The top errors were missing information, which re-asking cannot supply.** The top misses were
|
|
294
|
+
`./forbidden-script.sh` (the danger lives in a file the classifier never sees) and `ㅇㅇ 둘 다 ㄱㄱ`
|
|
295
|
+
(the meaning lives in the previous turn). The top false alarms were dangerous words inside `echo`,
|
|
296
|
+
comments and heredocs — and the keyword regex made **the same** errors. Two separate claims: ⓐ for
|
|
297
|
+
these errors, asking again cannot help, because the missing file or turn is still missing; ⓑ the
|
|
298
|
+
server documents its default backend as one forward pass reading answer-token probabilities with no
|
|
299
|
+
sampling, i.e. deterministic — re-check that for your backend and settings before relying on it, and
|
|
300
|
+
do run repeats when you need to *measure* variability. Not every miss was hand-checked; these are the
|
|
301
|
+
top-ranked ones. What can move the number is **changing the input** — see item 3 for why that alone
|
|
302
|
+
is not enough. This is the axis of [[feedback_decorrelation_axis_is_what_you_send]], applied to a
|
|
303
|
+
classifier.
|
|
304
|
+
3. **Changing the input is necessary, not sufficient.** Adding the governor's preceding message brought
|
|
305
|
+
back short acknowledgements (missed 6 → 1) but collapsed specificity (false alarms 1 → 38).
|
|
306
|
+
*Hypothesis, not established*: the context carried the topic, and the negatives shared the topic.
|
|
307
|
+
Before adding a context field, ask whether it separates positives from negatives or only describes
|
|
308
|
+
both — then measure it.
|
|
309
|
+
4. **Observing a command's effects needs a real sandbox, not a throwaway clone.** A disposable
|
|
310
|
+
repository copy does not isolate credentials, the rest of the host filesystem or the network, so
|
|
311
|
+
running an unknown script there is not a safe way to find out what it does. If you feed observed
|
|
312
|
+
effects to the classifier, run under real isolation (no credentials, no network, a disposable
|
|
313
|
+
filesystem) and forbid real external side effects. Effects on remote systems (push, publish, remote
|
|
314
|
+
delete) are not observed by such a run, and those stay with a human.
|
|
315
|
+
5. **Surface class decides where it may sit — accuracy alone does not.** It never clears an irreversible
|
|
316
|
+
surface by itself, whatever its number (§Irreversibility Gates — Surface-Class Degrade Invariant). A
|
|
317
|
+
review surface is a *candidate*, not a default: an aggregate percentage hides class balance and which
|
|
318
|
+
errors cost what, and an advisory can make readers skip an unflagged item or discard a valid one. Before
|
|
319
|
+
placing it, analyse its false negatives and false positives for that task, and keep human review of
|
|
320
|
+
what it does **not** flag or what it drops.
|
|
321
|
+
6. **Adopt only on a representative held-out comparison.** Beyond the known pair, run it and the current
|
|
322
|
+
method on a held-out sample of that harness's real inputs, with the error costs that matter there, and
|
|
323
|
+
switch it on only if it wins. Pick thresholds on a different sample from the one you report.
|
|
324
|
+
7. **Where it can be worth more: residency — once verified.** A local model *can* keep data on the
|
|
325
|
+
machine, which matters for a field harness that may not send logs or commands to a cloud model
|
|
326
|
+
(company QA logs, an offline gate on a company laptop). That is a property of your deployment, not of
|
|
327
|
+
the model: confirm the endpoint is local, that the server has no outbound network or telemetry path,
|
|
328
|
+
and that weight downloads happen before sensitive data is sent. Offer it as an **optional slot** —
|
|
329
|
+
on only when a verified-local endpoint is configured, today's behaviour otherwise.
|
|
330
|
+
|
|
331
|
+
Limits of these numbers: one run each, no sealed pre-registration, threshold 0.7 chosen after seeing
|
|
332
|
+
three values (optimistic), one 4B model, one question wording per table row, and the git labels are an
|
|
333
|
+
external tool's policy rather than "needed a human".
|
|
334
|
+
|
|
271
335
|
**Maintenance-Cost Rule** — a compatibility layer is cheap as a *thin entrypoint*, expensive when it
|
|
272
336
|
*duplicates canonical knowledge*. The test:
|
|
273
337
|
|
|
@@ -4724,3 +4724,67 @@
|
|
|
4724
4724
|
evidence: governor re-ran lanes each round (51/0, 56/0, 62/0) + revert probe script 8/8; real ~/.claude unchanged; branch pushed
|
|
4725
4725
|
tokens: 1095435
|
|
4726
4726
|
note: partial = fix landed safely but only real case M1 is unblocked; M2/M3 back to residual after closing to allowlists. No gate-block reroute after the rule was added to the brief.
|
|
4727
|
+
- date: 2026-10-14
|
|
4728
|
+
agent: general-purpose (sonnet) — B11 test author + B11b test author
|
|
4729
|
+
task: FoD v1 cleanroom B11 assembly tests (128) and B11b blocked trio (Z125 ledger shim, Z126, Z127) with reference impl set aside
|
|
4730
|
+
trigger: FoD v1 cleanroom pipeline (operator «Write 도구 허용» for B11b delta files)
|
|
4731
|
+
outcome: accepted
|
|
4732
|
+
evidence: B11 full suite 3101/3101, B11b 8 tests fail 8/8 without reference impl (tests valid); home_guard OK
|
|
4733
|
+
tokens: UNMEASURED
|
|
4734
|
+
note: B11 author blocked 3x by old installed gate mention=write over-block; resumed after #213 install. Governor fixed X-Z126b writing salt to HOME (temp ledger env).
|
|
4735
|
+
- date: 2026-10-14
|
|
4736
|
+
agent: run_isolated arms (claude sonnet, codexm, codexh) — B11b
|
|
4737
|
+
task: implement B11b from sealed spec in isolation
|
|
4738
|
+
trigger: cleanroom isolated-arm stage
|
|
4739
|
+
outcome: accepted
|
|
4740
|
+
evidence: all 3 arms 3122/3122, audit hits 0, verdict_v2 claude PASS, codexm PASS, codexh HUMAN 1; codexm adopted, suite 3109/3109
|
|
4741
|
+
tokens: UNMEASURED
|
|
4742
|
+
note: consolidated entry for three arms.
|
|
4743
|
+
- date: 2026-10-14
|
|
4744
|
+
agent: general-purpose (sonnet) — FoD settings arm (fix/chat-model-follow-agent)
|
|
4745
|
+
task: settings 7 items (agent-default model, badge row, harness subtitle, git-based chips, work-folder line, usage card, usage count)
|
|
4746
|
+
trigger: operator «ㅇㅇ» / «같이 얹어줘» / «칸도 있으면 좋겠다»
|
|
4747
|
+
outcome: accepted
|
|
4748
|
+
evidence: gate 613/0, live lanes 9 kinds pass, merged #218 (377068c), installed
|
|
4749
|
+
tokens: UNMEASURED
|
|
4750
|
+
note: arm's first usage-counter write landed in real ~/.claude (caught by chatux live); moved to userData. Arm heredoc edit blocked by gate; governor rephrased via Edit tool.
|
|
4751
|
+
- date: 2026-10-14
|
|
4752
|
+
agent: general-purpose (sonnet) — FoD multisend/observe arm
|
|
4753
|
+
task: governor chat multi-@ send + per-session reply observation (design r3 final)
|
|
4754
|
+
trigger: operator «설계 확정되면 구현까지 ㄱㄱ»
|
|
4755
|
+
outcome: accepted
|
|
4756
|
+
evidence: lanes 155/0, gate 615/0, live fh_chat main 77/0, codex impl r1-r3 fixes applied, branch feat/chat-multisend-observe ceb627e pushed (PR not opened)
|
|
4757
|
+
tokens: UNMEASURED
|
|
4758
|
+
note: arm report labelled the equal-time tie rule «operator-approved»; corrected — it was a governor decision from codex r3.
|
|
4759
|
+
- date: 2026-10-15
|
|
4760
|
+
agent: general-purpose (sonnet) — FoD v1 B12 pipeline (spec author · test author · LIVE_ONLY runner) + run_isolated arms (claude, codexm, codexh)
|
|
4761
|
+
task: B12 renderer cleanroom bundle end to end
|
|
4762
|
+
trigger: operator «1 승인 2 추천대로 3 그렇게하자» · «합본 오면 추천대로 결정해줘»
|
|
4763
|
+
outcome: accepted
|
|
4764
|
+
evidence: spec r4 cap, 805 tests, 3 arms 3932/3932 audit 0, verdict_v2 codexh PASS364 HUMAN0 adopted, suite 3914/3914
|
|
4765
|
+
tokens: UNMEASURED
|
|
4766
|
+
note: consolidated. LIVE_ONLY runner agent opened Electron dialogs on the operator's screen (stopped; memory feedback_live_lanes_must_not_show_on_operator_screen).
|
|
4767
|
+
- date: 2026-10-15
|
|
4768
|
+
agent: general-purpose (sonnet) — FoD B12b (spec author · test author) + run_isolated arms (claude, codexm, codexh)
|
|
4769
|
+
task: B12b settings views from B7 §4-5
|
|
4770
|
+
trigger: operator «ㅇㅇ 가자»
|
|
4771
|
+
outcome: accepted
|
|
4772
|
+
evidence: 136 cases, codex r1 REVISE→r2 PASS, 172 tests (clean 0/172), 3 arms 172/172 audit 0, v2 all PASS, claude adopted
|
|
4773
|
+
tokens: UNMEASURED
|
|
4774
|
+
note: governor iface omitted test/live → B11c 2 failures in all arms (governor defect, not arm).
|
|
4775
|
+
- date: 2026-10-15
|
|
4776
|
+
agent: general-purpose (sonnet) — FoD glue implementers (B11c, B12c, palette, confirm §5, stage themes, B11d + gate reaction, mac packaging + L-PERM)
|
|
4777
|
+
task: wire bundles into the running app; palette B; permission center; stamp reactions; mac dmg
|
|
4778
|
+
trigger: operator «ㄱㄱㄱ» · «B로 ㄱㄱ» · «A ㄱ» · «야간주행»
|
|
4779
|
+
outcome: accepted
|
|
4780
|
+
evidence: suite 3914→4238, live 10/9/5/10→19/1/0/14, L-PERM 9/9, dmg arm64/x64 codesign verify rc=0; GLUE 3-arm debt paid (codexh PASS375 HUMAN0 adopted)
|
|
4781
|
+
tokens: UNMEASURED
|
|
4782
|
+
note: consolidated 7 dispatches. B11d and packaging are single-implementer (3-arm debt remains). One agent rewrote spec drafts (history) — restored from the companion-store mirror.
|
|
4783
|
+
- date: 2026-10-15
|
|
4784
|
+
agent: general-purpose (sonnet) — research and sims (local-jev none; built-in map facts + context:fork probe; memory hits backfill; floor sims x6 arms; local spec colour edit)
|
|
4785
|
+
task: cheat-sheet internalization, memory GC backfill, doc floor sims
|
|
4786
|
+
trigger: operator «ㄱㄱ» · «ㅇㅇㅇ 그러자»
|
|
4787
|
+
outcome: partial
|
|
4788
|
+
evidence: built-in facts 19/19 doc-verified, fork probe controls alive (F 3/3 canary), hits proposals 681 lines (2 files inflated, corrected), live-repo doc sims contaminated by git status cue (not counted)
|
|
4789
|
+
tokens: UNMEASURED
|
|
4790
|
+
note: partial because 3 live-repo sim arms were contaminated and the hits extraction was not line-verified.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chrono-meta/fh-gate",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.27.0",
|
|
4
4
|
"description": "FH runtime adapters — run FH governance, skills, and agents via Claude or Codex with machine-parseable gates.",
|
|
5
5
|
"homepage": "https://github.com/chrono-meta/forge-harness#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -316,6 +316,9 @@
|
|
|
316
316
|
"scripts/test_memory_link_check.sh",
|
|
317
317
|
"scripts/test_node_check_lanes.sh",
|
|
318
318
|
"scripts/test_node_infra_delta_lanes.sh",
|
|
319
|
+
"scripts/test_env_delta_worktree_lanes.sh",
|
|
320
|
+
"scripts/memory_gc_report.py",
|
|
321
|
+
"scripts/test_memory_gc_report_lanes.sh",
|
|
319
322
|
"scripts/test_ollama_panel_lanes.sh",
|
|
320
323
|
"scripts/test_outbound_pr_gate_lanes.sh",
|
|
321
324
|
"scripts/test_outbound_query_hook_lanes.sh",
|
|
@@ -344,6 +347,7 @@
|
|
|
344
347
|
"scripts/test_psa_singlefile_lanes.sh",
|
|
345
348
|
"scripts/test_push_zone_lanes.sh",
|
|
346
349
|
"scripts/test_regression_guard_ci_lanes.sh",
|
|
350
|
+
"scripts/test_regression_guard_sibling_lanes.sh",
|
|
347
351
|
"scripts/test_relay_channel_lanes.sh",
|
|
348
352
|
"scripts/test_remote_marker_gate_lanes.sh",
|
|
349
353
|
"scripts/test_residency_admission_lanes.sh",
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# forge-harness (fh-meta) Changelog
|
|
2
2
|
|
|
3
|
+
### [3.27.0] — 2026-10-16 — CLAUDE.md 를 95줄 상주 핵심으로 · 내장 기능 지도 · 메모리 수명 GC
|
|
4
|
+
|
|
5
|
+
**minor.** 매 세션 실리는 지침이 1,274줄(13.2만 자)에서 95줄(1.5만 자)로 줄어든다. 행동 교리의 위치가 바뀌고 회귀 가드 한 칸이 조여진다.
|
|
6
|
+
|
|
7
|
+
BREAKING (gate): Axis 1 회귀 가드가 «짝 파일로 옮겼다」(SKILL.md ↔ SKILL_detail.md, 새로 CLAUDE.md ↔ claude_md_full_reference.md)를 **이번 변경에서 짝 파일이 늘어난 만큼만** 인정한다 — 짝 파일에 이미 있던 내용으로 삭제를 가리던 커밋이 이제 차단된다. 처방: 지운 내용을 같은 커밋에서 짝 파일로 실제로 옮기거나, 손실이 의도면 이유를 적고 Axes 2–3 를 돈다.
|
|
8
|
+
|
|
9
|
+
- `CLAUDE.md`: 읽기 전에 발동해야 하고 훅이 없는 규칙만 남긴 95줄 상주 핵심. 전문은 `knowledge/shared/harness-core/claude_md_full_reference.md`(절 이름 불변 — 다른 곳의 `CLAUDE.md §X` 는 §X 가 여기 없으면 그 파일 §X). 격리 클론 플로어 sim(Sonnet, 의도 11종 ×3, 사전등록) 후퇴 0. 권한 거부 안내는 상주에 넣으면 인사 발동이 0/3 으로 떨어져 참조 쪽에 남겼다(#900).
|
|
10
|
+
- `templates/regression_guard.sh`: 짝 파일 조회에 CLAUDE.md 쌍 추가 + 증가분 기준(위 BREAKING), 레인 `scripts/test_regression_guard_sibling_lanes.sh` 13개(되돌림 3)(#900).
|
|
11
|
+
- 새 문서 `knowledge/shared/harness-core/builtin_capability_map.md`: Claude Code 내장 기능(/context · /compact · /doctor · /rewind · /branch · /fork · /simplify 등)을 먼저 쓰고 FH 는 그 위에 더하는 것만 — 지도 유무 플로어 sim /rewind 3v0 · /doctor 3v0. 행마다 한국어 의도어(#897 · #899).
|
|
12
|
+
- 새 도구 `scripts/memory_gc_report.py`(읽기 전용): 메모리 재발 기록(hits)으로 목록 순서 · 승격 후보 · cold 를 제안한다. 레인 28(#896).
|
|
13
|
+
- 문서: 작은 로컬 판정 모델(local-jev)은 게이트가 아니라 검토 표면 후보(#895) · CLAUDE.md 겹치는 4개 절 요약(#894).
|
|
14
|
+
- 수리: env-delta 가 연결된 워크트리를 «미매핑 형제 레포」로 세던 것(#893).
|
|
15
|
+
|
|
3
16
|
### [3.26.2] — 2026-10-14 — self-test 가 Windows 에서 실행 파일을 대량 복사하던 것
|
|
4
17
|
|
|
5
18
|
**patch.** 수리.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: context-doctor
|
|
3
|
-
description: Reduces token waste in Claude Code sessions across two axes — context footprint (auto-generates .claudeignore, guides over-read files and /clear timing) and command output (routes to a command-output proxy/hook such as rtk to trim verbose CLI stdout). In hub environments, regularly audits bloated CLAUDE.md/MEMORY.md/memory/*.md files and proposes compression. Usable standalone without a hub clone.
|
|
3
|
+
description: Reduces token waste in Claude Code sessions (run the built-in `/context` first; this skill covers what it does not) across two axes — context footprint (auto-generates .claudeignore, guides over-read files and /clear timing) and command output (routes to a command-output proxy/hook such as rtk to trim verbose CLI stdout). In hub environments, regularly audits bloated CLAUDE.md/MEMORY.md/memory/*.md files and proposes compression. Usable standalone without a hub clone.
|
|
4
4
|
user-invocable: true
|
|
5
5
|
allowed-tools: ["Read", "Write", "Bash", "Glob", "Grep"]
|
|
6
6
|
model: sonnet
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: install-doctor
|
|
3
|
-
description: Scans the existing environment before and after meta-harness plugin install to diagnose conflicts, duplicates, and silent overwrite risks. Reports potential conflict areas with existing CLAUDE.md, skills, hooks, and audit practices. Activates on "install conflict", "any overlaps?", "is it safe to install?".
|
|
3
|
+
description: Scans the existing environment (after the built-in `/doctor` — this covers FH-plugin conflicts it does not) before and after meta-harness plugin install to diagnose conflicts, duplicates, and silent overwrite risks. Reports potential conflict areas with existing CLAUDE.md, skills, hooks, and audit practices. Activates on "install conflict", "any overlaps?", "is it safe to install?".
|
|
4
4
|
user-invocable: true
|
|
5
5
|
allowed-tools: ["Read", "Bash", "Glob", "Grep"]
|
|
6
6
|
model: sonnet
|
|
@@ -60,12 +60,28 @@ BE_ABS=""; [ -n "$BE" ] && BE_ABS="$(_abspath "$BE")"
|
|
|
60
60
|
# _candidate DIR → echoes basename if DIR is an unmapped mapping candidate, else nothing + returns 1.
|
|
61
61
|
# ONE predicate for BOTH sibling-scan and current-cwd (codex [MED]×2: cwd previously had weaker
|
|
62
62
|
# exclusions + ignored the skip sentinel → could propose the hub/companion/hidden repo and re-nag a
|
|
63
|
-
# skipped repo).
|
|
63
|
+
# skipped repo). `-e .git` (not `-d`) so a `.git` FILE still counts as a repo (submodule).
|
|
64
|
+
# A LINKED WORKTREE is not a new project — it is another checkout of its main repo. The sibling scan
|
|
65
|
+
# skips it (the main repo is scanned on its own); the cwd check resolves it to the main repo, so
|
|
66
|
+
# working inside a worktree of a mapped repo stays silent. Measured 2026-10-15: 30 of 33 «unmapped
|
|
67
|
+
# siblings» were worktrees of friends-on-desk / qasp-dev / clawd-on-desk / the hub itself.
|
|
68
|
+
# _main_of_worktree DIR → main repo root if DIR's `.git` file points at `<main>/.git/worktrees/<x>`.
|
|
69
|
+
# Pure file read (no git call): the hook stays offline-safe and fast.
|
|
70
|
+
_main_of_worktree() {
|
|
71
|
+
local gd
|
|
72
|
+
[ -f "$1/.git" ] || return 1
|
|
73
|
+
gd="$(sed -n 's/^gitdir: //p' "$1/.git" 2>/dev/null | head -1)"
|
|
74
|
+
case "$gd" in */.git/worktrees/*) printf '%s' "${gd%%/.git/worktrees/*}" ;; *) return 1 ;; esac
|
|
75
|
+
}
|
|
64
76
|
_candidate() {
|
|
65
|
-
local d abs name
|
|
77
|
+
local d abs name main mode="${2:-sibling}"
|
|
66
78
|
abs="$(_abspath "$1")" || return 1
|
|
67
79
|
[ -n "$abs" ] || return 1
|
|
68
|
-
[ -e "$abs/.git" ] || return 1 # real repo (dir OR file .git
|
|
80
|
+
[ -e "$abs/.git" ] || return 1 # real repo (dir OR file .git)
|
|
81
|
+
if main="$(_main_of_worktree "$abs")"; then
|
|
82
|
+
[ "$mode" = cwd ] || return 1 # sibling scan: the main repo stands for it
|
|
83
|
+
abs="$(_abspath "$main")" || return 1; [ -n "$abs" ] || return 1
|
|
84
|
+
fi
|
|
69
85
|
name="$(basename "$abs")"
|
|
70
86
|
[ "$abs" = "$FH_ABS" ] && return 1 # not the hub
|
|
71
87
|
[ -n "$BE_ABS" ] && [ "$abs" = "$BE_ABS" ] && return 1 # not the companion store
|
|
@@ -88,7 +104,7 @@ done
|
|
|
88
104
|
|
|
89
105
|
# Current cwd itself an unmapped project? (the pmh-pull / task-first-in-new-project case) — SAME
|
|
90
106
|
# predicate, so identical exclusions + skip-sentinel apply.
|
|
91
|
-
CWD_UNMAPPED="$(_candidate "${CLAUDE_PROJECT_DIR:-$PWD}")" || CWD_UNMAPPED=""
|
|
107
|
+
CWD_UNMAPPED="$(_candidate "${CLAUDE_PROJECT_DIR:-$PWD}" cwd)" || CWD_UNMAPPED=""
|
|
92
108
|
|
|
93
109
|
# Nothing new → silent no-op (majority path).
|
|
94
110
|
# ── /clear·compact 억제는 **표시 판단보다 먼저** 접는다 ─────────────────────────
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""memory_gc_report.py — read-only lifecycle report for a Claude Code memory directory.
|
|
3
|
+
|
|
4
|
+
WHY: MEMORY.md is a capped overview (the loader stops at ~25,000 chars and silently drops the
|
|
5
|
+
rest), but nothing decides WHICH entries stay above the cap. Ordering by recency pushes
|
|
6
|
+
long-confirmed feedback below the cut, and recurrence lived only in prose ("하루 3회"), so no
|
|
7
|
+
machine could rank by it. Generational-GC framing (imweb tech, 2026-10-06): an entry's AGE rises
|
|
8
|
+
only when the same observation is recorded again; recurrence across several days marks a
|
|
9
|
+
promotion candidate.
|
|
10
|
+
|
|
11
|
+
WHAT: reads every topic file's frontmatter and the index, and reports
|
|
12
|
+
· index hygiene — unlisted files · duplicate index lines · dangling local links
|
|
13
|
+
· loader cap — the character offset where the cap cuts, and the line it falls in
|
|
14
|
+
· every entry — status, type, age (from `metadata.hits`), distinct days, last hit, index line
|
|
15
|
+
· cold — non-user, age 1, last hit ≥ --cold-days ago → drop from the INDEX only
|
|
16
|
+
· promote — age ≥ --promote-age across ≥ 2 distinct days → propose a rule/hook (human approves)
|
|
17
|
+
· order — user entries in index order, then valid measured entries by age (ties: index
|
|
18
|
+
order), then the rest in index order; cold entries leave the order. Entries with an
|
|
19
|
+
error status never drive cold / promote / measured ranking until repaired
|
|
20
|
+
|
|
21
|
+
INVARIANTS:
|
|
22
|
+
· Read-only. It never edits, moves or deletes anything.
|
|
23
|
+
· No `hits` = UNMEASURED, never age 1, never cold. A rule that is followed well also stops
|
|
24
|
+
recurring; absence of a record is not a zero.
|
|
25
|
+
· Unreadable files, missing/unterminated frontmatter, inline or malformed `hits`, invalid or
|
|
26
|
+
future dates are reported as such (status / bad lines) — never folded into "no hits".
|
|
27
|
+
· Same-day repeats count once toward the distinct-days condition.
|
|
28
|
+
|
|
29
|
+
`hits` format (a child of the frontmatter `metadata:` block; one occurrence per item, first = founding):
|
|
30
|
+
metadata:
|
|
31
|
+
hits:
|
|
32
|
+
- 2026-10-15 | live lane windows covered the operator's screen
|
|
33
|
+
usage: memory_gc_report.py <memory_dir> [--index MEMORY.md] [--today YYYY-MM-DD]
|
|
34
|
+
[--cold-days 30] [--promote-age 3] [--cap 25000] [--json]
|
|
35
|
+
exit: 0 report printed · 2 memory dir or index unreadable (instrument error, never an empty report)
|
|
36
|
+
"""
|
|
37
|
+
import argparse, datetime as dt, json, os, re, sys, urllib.parse
|
|
38
|
+
|
|
39
|
+
def link_dests(line):
|
|
40
|
+
"""Markdown inline-link destinations with their start offset: <...> form, balanced parens, title dropped."""
|
|
41
|
+
out, i = [], 0
|
|
42
|
+
while True:
|
|
43
|
+
j = line.find('](', i)
|
|
44
|
+
if j < 0:
|
|
45
|
+
return out
|
|
46
|
+
k = j + 2
|
|
47
|
+
while k < len(line) and line[k] == ' ':
|
|
48
|
+
k += 1
|
|
49
|
+
start = k
|
|
50
|
+
if k < len(line) and line[k] == '<':
|
|
51
|
+
e = line.find('>', k + 1)
|
|
52
|
+
if e < 0:
|
|
53
|
+
i = j + 2; continue
|
|
54
|
+
out.append((line[k + 1:e], start)); i = e + 1; continue
|
|
55
|
+
depth, d = 0, k
|
|
56
|
+
while d < len(line):
|
|
57
|
+
c = line[d]
|
|
58
|
+
if c == '(':
|
|
59
|
+
depth += 1
|
|
60
|
+
elif c == ')':
|
|
61
|
+
if depth == 0:
|
|
62
|
+
break
|
|
63
|
+
depth -= 1
|
|
64
|
+
elif c in ' \t' and depth == 0:
|
|
65
|
+
break
|
|
66
|
+
d += 1
|
|
67
|
+
if d > k:
|
|
68
|
+
out.append((line[k:d], start))
|
|
69
|
+
i = d
|
|
70
|
+
HIT_RE = re.compile(r'^-\s*(\S+)\s*\|\s*(.+?)\s*$')
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def indent(line):
|
|
74
|
+
return len(line) - len(line.lstrip(' '))
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def parse_entry(path, today):
|
|
78
|
+
"""-> dict(status, type, hits[(date,str)], bad[str])"""
|
|
79
|
+
out = {'status': 'OK', 'type': None, 'hits': [], 'bad': []}
|
|
80
|
+
try:
|
|
81
|
+
text = open(path, encoding='utf-8').read()
|
|
82
|
+
except (OSError, UnicodeDecodeError) as e:
|
|
83
|
+
out['status'] = 'READ_ERROR'
|
|
84
|
+
out['bad'].append(type(e).__name__)
|
|
85
|
+
return out
|
|
86
|
+
lines = text.splitlines()
|
|
87
|
+
if not lines or lines[0].strip() != '---':
|
|
88
|
+
out['status'] = 'NO_FRONTMATTER'
|
|
89
|
+
return out
|
|
90
|
+
try:
|
|
91
|
+
end = next(i for i in range(1, len(lines)) if lines[i].strip() == '---')
|
|
92
|
+
except StopIteration:
|
|
93
|
+
out['status'] = 'UNTERMINATED_FRONTMATTER'
|
|
94
|
+
return out
|
|
95
|
+
fm = lines[1:end]
|
|
96
|
+
meta_i = next((i for i, l in enumerate(fm) if indent(l) == 0 and re.match(r'^metadata:\s*$', l)), None)
|
|
97
|
+
if meta_i is None:
|
|
98
|
+
return out
|
|
99
|
+
meta = []
|
|
100
|
+
for l in fm[meta_i + 1:]:
|
|
101
|
+
if l.strip() and not l.lstrip().startswith('#') and indent(l) == 0:
|
|
102
|
+
break
|
|
103
|
+
meta.append(l)
|
|
104
|
+
child = min((indent(l) for l in meta if l.strip() and not l.lstrip().startswith('#')), default=None)
|
|
105
|
+
hits_i = None
|
|
106
|
+
for i, l in enumerate(meta):
|
|
107
|
+
if not l.strip() or l.lstrip().startswith('#'):
|
|
108
|
+
continue
|
|
109
|
+
if indent(l) == child:
|
|
110
|
+
m = re.match(r'^\s*type:\s*(.*)$', l)
|
|
111
|
+
if m and out['type'] is None:
|
|
112
|
+
out['type'] = m.group(1).strip().strip('"\'') or None
|
|
113
|
+
if re.match(r'^\s*hits:', l):
|
|
114
|
+
if re.match(r'^\s*hits:\s*$', l):
|
|
115
|
+
hits_i = i
|
|
116
|
+
else:
|
|
117
|
+
out['status'] = 'HITS_MALFORMED'
|
|
118
|
+
out['bad'].append(l.strip())
|
|
119
|
+
if hits_i is None:
|
|
120
|
+
return out
|
|
121
|
+
hind = indent(meta[hits_i])
|
|
122
|
+
for l in meta[hits_i + 1:]:
|
|
123
|
+
if not l.strip() or l.lstrip().startswith('#'):
|
|
124
|
+
continue
|
|
125
|
+
if indent(l) == hind and l.lstrip().startswith('- '):
|
|
126
|
+
out['bad'].append(l.strip() + ' (indentless list item — indent it under hits:)')
|
|
127
|
+
continue
|
|
128
|
+
if indent(l) <= hind:
|
|
129
|
+
break
|
|
130
|
+
s = l.strip()
|
|
131
|
+
m = HIT_RE.match(s)
|
|
132
|
+
if not m:
|
|
133
|
+
out['bad'].append(s)
|
|
134
|
+
continue
|
|
135
|
+
try:
|
|
136
|
+
d = dt.date.fromisoformat(m.group(1))
|
|
137
|
+
except ValueError:
|
|
138
|
+
out['bad'].append(s)
|
|
139
|
+
continue
|
|
140
|
+
if d > today:
|
|
141
|
+
out['bad'].append(s + ' (future date)')
|
|
142
|
+
continue
|
|
143
|
+
out['hits'].append((d.isoformat(), m.group(2)))
|
|
144
|
+
if out['bad'] and out['status'] == 'OK':
|
|
145
|
+
out['status'] = 'HITS_MALFORMED'
|
|
146
|
+
return out
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def local_target(dest, index_dir):
|
|
150
|
+
if re.match(r'^[a-zA-Z][a-zA-Z0-9+.-]*:', dest): # https:, mailto:, file: …
|
|
151
|
+
return None
|
|
152
|
+
dest = urllib.parse.unquote(dest.split('#', 1)[0].split('?', 1)[0])
|
|
153
|
+
if not dest.endswith('.md'):
|
|
154
|
+
return None
|
|
155
|
+
return os.path.normpath(dest)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def main():
|
|
159
|
+
ap = argparse.ArgumentParser()
|
|
160
|
+
ap.add_argument('memory_dir')
|
|
161
|
+
ap.add_argument('--index', default='MEMORY.md')
|
|
162
|
+
ap.add_argument('--today')
|
|
163
|
+
ap.add_argument('--cold-days', type=int, default=30)
|
|
164
|
+
ap.add_argument('--promote-age', type=int, default=3)
|
|
165
|
+
ap.add_argument('--cap', type=int, default=25000)
|
|
166
|
+
ap.add_argument('--json', action='store_true')
|
|
167
|
+
a = ap.parse_args()
|
|
168
|
+
|
|
169
|
+
idx_path = os.path.join(a.memory_dir, a.index)
|
|
170
|
+
try:
|
|
171
|
+
names = sorted(f for f in os.listdir(a.memory_dir) if f.endswith('.md') and f != a.index)
|
|
172
|
+
idx_text = open(idx_path, encoding='utf-8').read()
|
|
173
|
+
except (OSError, UnicodeDecodeError) as e:
|
|
174
|
+
print(f'HARNESS-ERROR: {e}', file=sys.stderr)
|
|
175
|
+
return 2
|
|
176
|
+
today = dt.date.fromisoformat(a.today) if a.today else dt.date.today()
|
|
177
|
+
|
|
178
|
+
# loader cap: character offset, and the line it falls in (prefix of that line is still loaded)
|
|
179
|
+
cut = None
|
|
180
|
+
if len(idx_text) > a.cap:
|
|
181
|
+
line_no = idx_text.count('\n', 0, a.cap) + 1
|
|
182
|
+
line_start = idx_text.rfind('\n', 0, a.cap) + 1
|
|
183
|
+
cut = {'char': a.cap, 'line': line_no, 'chars_loaded_in_line': a.cap - line_start}
|
|
184
|
+
pos, dups, dangling, offset = {}, [], [], 0
|
|
185
|
+
for i, line in enumerate(idx_text.splitlines(keepends=True), 1):
|
|
186
|
+
for dest, at in link_dests(line):
|
|
187
|
+
t = local_target(dest, a.memory_dir)
|
|
188
|
+
if t is None:
|
|
189
|
+
continue
|
|
190
|
+
if not os.path.isfile(os.path.join(a.memory_dir, t)):
|
|
191
|
+
dangling.append([t, i])
|
|
192
|
+
continue
|
|
193
|
+
if t in pos:
|
|
194
|
+
dups.append([t, pos[t]['line'], i])
|
|
195
|
+
else:
|
|
196
|
+
pos[t] = {'line': i, 'ord': len(pos), 'past_cap': cut is not None and offset + at >= a.cap}
|
|
197
|
+
offset += len(line)
|
|
198
|
+
|
|
199
|
+
entries = []
|
|
200
|
+
for n in names:
|
|
201
|
+
p = parse_entry(os.path.join(a.memory_dir, n), today)
|
|
202
|
+
e = {'file': n, 'status': p['status'], 'type': p['type'], 'bad': p['bad'],
|
|
203
|
+
'index_line': pos.get(n, {}).get('line'), 'index_ord': pos.get(n, {}).get('ord'),
|
|
204
|
+
'past_cap': pos.get(n, {}).get('past_cap', False)}
|
|
205
|
+
if p['hits']:
|
|
206
|
+
days = sorted({d for d, _ in p['hits']})
|
|
207
|
+
e.update(age=len(p['hits']), distinct_days=len(days), last_hit=days[-1])
|
|
208
|
+
else:
|
|
209
|
+
e.update(age=None, distinct_days=None, last_hit=None) # UNMEASURED, not age 1
|
|
210
|
+
entries.append(e)
|
|
211
|
+
|
|
212
|
+
def days_since(d):
|
|
213
|
+
return (today - dt.date.fromisoformat(d)).days
|
|
214
|
+
|
|
215
|
+
ok = lambda e: e['status'] == 'OK'
|
|
216
|
+
cold = [e for e in entries if ok(e) and e['type'] != 'user' and e['age'] == 1
|
|
217
|
+
and days_since(e['last_hit']) >= a.cold_days]
|
|
218
|
+
promote = [e for e in entries if ok(e) and e['age'] is not None and e['age'] >= a.promote_age
|
|
219
|
+
and e['distinct_days'] >= 2]
|
|
220
|
+
cold_set = {e['file'] for e in cold}
|
|
221
|
+
listed = sorted((e for e in entries if e['index_line'] is not None), key=lambda e: e['index_ord'])
|
|
222
|
+
users = [e for e in listed if e['type'] == 'user']
|
|
223
|
+
meas = sorted((e for e in listed if e['type'] != 'user' and ok(e) and e['age'] is not None and e['file'] not in cold_set),
|
|
224
|
+
key=lambda e: (-e['age'], e['index_ord'])) # age ties keep index (link) order
|
|
225
|
+
rest = [e for e in listed if e['type'] != 'user' and not (ok(e) and e['age'] is not None)]
|
|
226
|
+
order = [e['file'] for e in users + meas + rest]
|
|
227
|
+
|
|
228
|
+
rep = {'memory_dir': a.memory_dir, 'today': today.isoformat(), 'files': len(entries),
|
|
229
|
+
'index_chars': len(idx_text), 'cap': a.cap, 'cut': cut,
|
|
230
|
+
'unlisted': [e['file'] for e in entries if e['index_line'] is None],
|
|
231
|
+
'duplicates': dups, 'dangling': dangling,
|
|
232
|
+
'measured': sum(e['age'] is not None for e in entries),
|
|
233
|
+
'unmeasured': sum(e['age'] is None for e in entries),
|
|
234
|
+
'errors': [[e['file'], e['status'], e['bad']] for e in entries if e['status'] != 'OK'],
|
|
235
|
+
'cold': [e['file'] for e in cold],
|
|
236
|
+
'promote': [[e['file'], e['age'], e['distinct_days']] for e in promote],
|
|
237
|
+
'order': order, 'entries': entries}
|
|
238
|
+
if a.json:
|
|
239
|
+
print(json.dumps(rep, ensure_ascii=False, indent=1))
|
|
240
|
+
return 0
|
|
241
|
+
cut_s = 'within cap' if cut is None else f"cap cuts at char {cut['char']} = line {cut['line']} (first {cut['chars_loaded_in_line']} chars of it load)"
|
|
242
|
+
print(f"memory GC report — {rep['files']} topic files · index {len(idx_text)} chars, {cut_s} · today {rep['today']}")
|
|
243
|
+
print(f" index: unlisted {len(rep['unlisted'])} · duplicate lines {len(dups)} · dangling local links {len(dangling)}")
|
|
244
|
+
for t, first, again in dups:
|
|
245
|
+
print(f" dup {t} (lines {first} and {again})")
|
|
246
|
+
for t, ln in dangling:
|
|
247
|
+
print(f" dangling {t} (line {ln})")
|
|
248
|
+
print(f" errors (not folded into 'no hits'): {len(rep['errors'])}")
|
|
249
|
+
for f, st, bad in rep['errors']:
|
|
250
|
+
print(f" {st:<24} {f} {'; '.join(bad)[:120]}")
|
|
251
|
+
print(f" age: measured {rep['measured']} · UNMEASURED {rep['unmeasured']} (no `hits` — never age 1, never cold)")
|
|
252
|
+
for e in sorted(entries, key=lambda e: (e['age'] is None, -(e['age'] or 0), e['file'])):
|
|
253
|
+
age = 'UNMEAS' if e['age'] is None else f"age {e['age']:>2}"
|
|
254
|
+
print(f" {age} · {e['type'] or '-'} · {e['status']} · days {e['distinct_days']} · last {e['last_hit']} · "
|
|
255
|
+
f"{'line ' + str(e['index_line']) if e['index_line'] else 'unlisted'}{' (past cap)' if e['past_cap'] else ''} · {e['file']}")
|
|
256
|
+
print(f" cold (non-user, age 1, no recurrence for ≥ {a.cold_days}d → drop from index only, keep file): {len(cold)}")
|
|
257
|
+
for e in cold:
|
|
258
|
+
print(f" cold {e['file']} last {e['last_hit']}")
|
|
259
|
+
print(f" promote candidates (age ≥ {a.promote_age} over ≥ 2 days → propose rule/hook, human approves): {len(promote)}")
|
|
260
|
+
for e in promote:
|
|
261
|
+
print(f" promote {e['file']} age {e['age']} · days {e['distinct_days']} · last {e['last_hit']}")
|
|
262
|
+
print(f" proposed order ({len(order)}):")
|
|
263
|
+
for n, f in enumerate(order, 1):
|
|
264
|
+
print(f" {n:>3}. {f}")
|
|
265
|
+
print(' read-only: nothing was changed.')
|
|
266
|
+
return 0
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
if __name__ == '__main__':
|
|
270
|
+
sys.exit(main())
|
package/scripts/selfcheck.sh
CHANGED
|
@@ -990,6 +990,7 @@ for _pair in \
|
|
|
990
990
|
"templates/.git-hooks/pre-commit|scripts/test_marker_crossfamily_lanes.sh" \
|
|
991
991
|
"templates/.git-hooks/pre-commit|scripts/test_marker_floor_lanes.sh" \
|
|
992
992
|
".github/workflows/regression-guard.yml|scripts/test_regression_guard_ci_lanes.sh" \
|
|
993
|
+
"templates/regression_guard.sh|scripts/test_regression_guard_sibling_lanes.sh" \
|
|
993
994
|
".github/workflows/validate.yml|scripts/test_leak_scan_control_lanes.sh" \
|
|
994
995
|
"templates/.git-hooks/pre-commit|scripts/test_marker_standpoint_lanes.sh" \
|
|
995
996
|
"templates/.git-hooks/pre-commit|scripts/test_marker_thirdparty_lanes.sh" \
|
|
@@ -2101,6 +2102,32 @@ else
|
|
|
2101
2102
|
fail=1
|
|
2102
2103
|
fi
|
|
2103
2104
|
|
|
2105
|
+
# env-delta SessionStart hook — linked worktrees are not new sibling repos (2026-10-15: 30 of 33
|
|
2106
|
+
# «unmapped siblings» were worktrees). Same pairing rule as above.
|
|
2107
|
+
if [ ! -f scripts/fh_env_delta_scan.sh ]; then
|
|
2108
|
+
_absent_subject_verdict "test_env_delta_worktree_lanes.sh" "scripts/fh_env_delta_scan.sh" || fail=1
|
|
2109
|
+
elif [ -f scripts/test_env_delta_worktree_lanes.sh ]; then
|
|
2110
|
+
if ! bash scripts/test_env_delta_worktree_lanes.sh; then
|
|
2111
|
+
fail=1
|
|
2112
|
+
fi
|
|
2113
|
+
else
|
|
2114
|
+
echo "FAIL test_env_delta_worktree_lanes.sh: fh_env_delta_scan.sh present but its anchor is missing"
|
|
2115
|
+
fail=1
|
|
2116
|
+
fi
|
|
2117
|
+
|
|
2118
|
+
# memory_gc_report.py — read-only lifecycle report over a memory dir (age from `hits`, cold, promote,
|
|
2119
|
+
# index hygiene, loader cap). Same pairing rule as above.
|
|
2120
|
+
if [ ! -f scripts/memory_gc_report.py ]; then
|
|
2121
|
+
_absent_subject_verdict "test_memory_gc_report_lanes.sh" "scripts/memory_gc_report.py" || fail=1
|
|
2122
|
+
elif [ -f scripts/test_memory_gc_report_lanes.sh ]; then
|
|
2123
|
+
if ! bash scripts/test_memory_gc_report_lanes.sh; then
|
|
2124
|
+
fail=1
|
|
2125
|
+
fi
|
|
2126
|
+
else
|
|
2127
|
+
echo "FAIL test_memory_gc_report_lanes.sh: memory_gc_report.py present but its anchor is missing"
|
|
2128
|
+
fail=1
|
|
2129
|
+
fi
|
|
2130
|
+
|
|
2104
2131
|
# SessionStart multi-hook + install-wizard snippet merge. Subject for both = the shipped settings
|
|
2105
2132
|
# snippets; a clone without them is a legitimate SKIP, a clone with them and no anchor is not —
|
|
2106
2133
|
# UNLESS the anchor itself is declared package-mode-optional. test_sessionstart_multihook_lanes.sh
|