@chrono-meta/fh-gate 3.26.1 → 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.
@@ -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.26.1",
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,6 +1,6 @@
1
1
  {
2
2
  "name": "fh-commons",
3
- "version": "3.26.1",
3
+ "version": "3.27.0",
4
4
  "engines": {
5
5
  "claudeCode": ">=1.0.0"
6
6
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fh-meta",
3
- "version": "3.26.1",
3
+ "version": "3.27.0",
4
4
  "engines": {
5
5
  "claudeCode": ">=1.0.0"
6
6
  },
@@ -1,5 +1,25 @@
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
+
16
+ ### [3.26.2] — 2026-10-14 — self-test 가 Windows 에서 실행 파일을 대량 복사하던 것
17
+
18
+ **patch.** 수리.
19
+
20
+ - `capability_effect_probe.sh --self-test`(selfcheck 가 부른다): shim 빌더가 PATH 의 모든 실행 파일을 임시 폴더에 링크했고, Windows Git Bash 는 그 링크를 복사로 바꿔 보안 제품 오탐이 났다. 허용 목록만 링크하고, 심링크가 안 되는 환경이면 실행 파일을 하나도 넘기지 않고 해당 레인을 SKIP(미측정, 통과 아님)으로 남긴다(#890).
21
+ - 같은 파일: 홈 디렉터리 감시가 `shasum` 을 직접 불러, shasum 이 없는 호스트에서는 홈 쓰기를 늘 «안 바뀜» 으로 봤다 — 목록을 직접 비교한다(#890).
22
+
3
23
  ### [3.26.1] — 2026-10-13 — README 정리 · 레인 플레이크 · live-eval 거짓 적색
4
24
 
5
25
  **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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fh-preprep",
3
- "version": "3.26.1",
3
+ "version": "3.27.0",
4
4
  "engines": {
5
5
  "claudeCode": ">=1.0.0"
6
6
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fh-qp",
3
- "version": "3.26.1",
3
+ "version": "3.27.0",
4
4
  "engines": {
5
5
  "claudeCode": ">=1.0.0"
6
6
  },
@@ -316,7 +316,9 @@ probe_one() { # $1=capfile → rc
316
316
  # (d) 가 말하는 결함을 프로브 자신이 갖고 있었던 것이다. 절대경로 쓰기의 가장 흔한
317
317
  # 표적이 홈이므로 여기에도 감시를 둔다. ⚠️ 완전하지 않다 — 아래 §잔여 참조.
318
318
  local home_before home_after
319
- home_before=$(ls -A "$HOME" 2>/dev/null | LC_ALL=C sort | shasum -a 256 | cut -d" " -f1)
319
+ # 해시 없이 목록 자체를 비교한다 — `shasum` 직접 호출은 shasum 없는 Linux 에서 앞뒤 모두 빈 값이 돼
320
+ # 홈 감시가 늘 «안 바뀜» 으로 죽었다(2026-10-14, L20b 문구 검사가 드러냄). 해시 도구 의존 자체를 뺀다.
321
+ home_before=$(ls -A "$HOME" 2>/dev/null | LC_ALL=C sort; echo "|end") # 표지: 치환이 끝 줄바꿈을 먹지 않게(codex R3 #2)
320
322
  mkdir -p "$sandbox/scripts"; printf 'x\n' > "$sandbox/scripts/CANARY_SCRIPTS"
321
323
 
322
324
  local before after out rc
@@ -388,7 +390,7 @@ $out2"
388
390
  _cleanup_probe
389
391
  rm -rf "$outside"
390
392
 
391
- home_after=$(ls -A "$HOME" 2>/dev/null | LC_ALL=C sort | shasum -a 256 | cut -d" " -f1)
393
+ home_after=$(ls -A "$HOME" 2>/dev/null | LC_ALL=C sort; echo "|end") # 표지: 치환이 끝 줄바꿈을 먹지 않게(codex R3 #2)
392
394
  local home_changed
393
395
  home_changed=$([ "$home_before" = "$home_after" ] && echo 0 || echo 1)
394
396
 
@@ -873,55 +875,128 @@ EOF
873
875
  # ⓑ shim 빌더가 `set -f`(전역 noglob) 때문에 확장이 안 됨 — **캘리브레이션 짝**이 적발
874
876
  # 여기서는 도구를 **하나씩** 빼고, 매 arm 에 기대값을 다르게 건다.
875
877
  # ★PATH 원소 분해는 공백/글롭 안전하게(`tr` → 줄 단위). cross-family 지목 #7.
876
- _mkshim() { # $1=shim경로 $2..=제외할 도구명
878
+ # 🟥 PATH 전체가 아니라 **허용 목록**만 링크한다 (pmh-dev #87). 옛 판은 PATH 의 모든 실행 파일을
879
+ # 깔았고, Windows Git Bash 는 `ln -s` 를 «복사» 로 바꾸므로 System32 까지 수천 개가 임시 트리로
880
+ # 복사돼 EDR 이 짖었다. 이제 실행 파일을 넘기기 전에 텍스트 탐침으로 심링크가 되는지 묻고, 안 되면
881
+ # rc=2 로 돌아가 부르는 쪽이 그 레인을 SKIP(미측정, 통과 아님)한다.
882
+ # ⚠️ 보장 범위(codex R3 #1): MSYS/Git Bash 처럼 폴백이 «균일한» ln 에서는 실행 파일 복사 0 이다.
883
+ # 텍스트는 링크하고 실행 파일만 복사하는 ln 이라면 첫 실행 파일 하나가 복사된 뒤 rc=3(FAIL)로 멈춘다.
884
+ _SHIM_TOOLS="bash sh env cat cp mv rm ln mkdir mktemp touch chmod ls find stat readlink realpath
885
+ dirname basename sed awk grep egrep tr cut head tail sort uniq wc comm diff cmp xargs od
886
+ date sleep uname id expr git perl shasum sha256sum"
887
+ _mkshim() { # $1=shim경로 $2..=제외할 도구명 · rc=2 = 심링크를 못 만드는 환경(복사 폴백)
877
888
  local shimd="$1"; shift
878
889
  mkdir -p "$shimd"
879
- printf '%s\n' "$PATH" | tr ':' '\n' > "$d/_pathdirs"
880
- local _p _f _b _x _skip
881
- set +f
882
- while IFS= read -r _p; do
883
- [ -n "$_p" ] && [ -d "$_p" ] || continue
884
- for _f in "$_p"/*; do
885
- [ -e "$_f" ] || continue
886
- _b=${_f##*/}; _skip=0
887
- for _x in "$@"; do [ "$_b" = "$_x" ] && { _skip=1; break; }; done
888
- [ "$_skip" = 1 ] && continue
889
- [ -e "$shimd/$_b" ] || ln -s "$_f" "$shimd/$_b" 2>/dev/null
890
- done
891
- done < "$d/_pathdirs"
892
- set -f
890
+ # 실행 파일을 넘기기 «전에» 무해한 텍스트 파일로 심링크가 되는지 묻는다 — 복사 폴백이면
891
+ # 복사되는 것은 이 텍스트 한 장뿐이다(cross-family codex R1 #1: 사후 감지는 이미 복사한 뒤다)
892
+ printf 'symlink probe\n' > "$shimd/.lnprobe.txt"
893
+ MSYS=winsymlinks:nativestrict ln -s "$shimd/.lnprobe.txt" "$shimd/.lnprobe" 2>/dev/null
894
+ if [ ! -L "$shimd/.lnprobe" ]; then rm -f "$shimd/.lnprobe" "$shimd/.lnprobe.txt"; return 2; fi
895
+ rm -f "$shimd/.lnprobe" "$shimd/.lnprobe.txt"
896
+ hash -r # type -P 가 해시 캐시가 아니라 지금 PATH 의 첫 일치를 고르게(codex R1 #2)
897
+ local _t _x _skip _src
898
+ for _t in $_SHIM_TOOLS; do
899
+ _skip=0
900
+ for _x in "$@"; do [ "$_t" = "$_x" ] && { _skip=1; break; }; done
901
+ [ "$_skip" = 1 ] && continue
902
+ _src=$(type -P "$_t" 2>/dev/null) || continue
903
+ [ -n "$_src" ] || continue
904
+ # 탐침이 심링크였는데 실행 파일에서 실패·복사하면 «환경 미지원» 이 아니라 구성 오류다 — rc=3(codex R2 #1·#2)
905
+ MSYS=winsymlinks:nativestrict ln -s "$_src" "$shimd/$_t" 2>/dev/null || return 3
906
+ if [ ! -L "$shimd/$_t" ]; then rm -f "$shimd/$_t"; return 3; fi
907
+ done
908
+ }
909
+ _shim_skip() { echo "⏭ $1 SKIP — 이 환경에서는 심링크를 못 만든다(복사 폴백). 복사하지 않는다 — 미측정, 통과 아님"; }
910
+ # rc=2 만 SKIP 이다. 그 밖의 실패(링크 도중 오류)는 SKIP 으로 접지 않고 FAIL 로 센다(codex R2 #2)
911
+ _shim_ready() { # $1=레인 $2=shim경로 $3..=제외할 도구명 · 0=준비됨
912
+ local _lane="$1" _rc; shift
913
+ _mkshim "$@"; _rc=$?
914
+ [ "$_rc" = 0 ] && return 0
915
+ if [ "$_rc" = 2 ]; then _shim_skip "$_lane"
916
+ else fails=$((fails+1)); echo "❌ $_lane shim 구성 오류 rc=$_rc — 링크 도중 실패/복사(SKIP 아님)"; fi
917
+ return 1
893
918
  }
919
+ # 정상 위반 판정인가 — rc 만이 아니라 판정 문구가 있고 도구 조회 오류가 없어야 한다(codex R1 #3 · R2 #3)
920
+ _viol_ok() { printf '%s' "$1" | grep -q '^🟥 VIOLATION .*샌드박스가 바뀌었다' \
921
+ && ! printf '%s' "$1" | grep -qiE 'command not found|not found|no such file'; }
922
+
923
+ # L20g **판정 문구 검사 자체의 짝** — 위반 문구만 있으면 참, 도구 조회 오류가 섞이면 거짓, 문구가 없으면 거짓.
924
+ if _viol_ok '🟥 VIOLATION /x/a.cap — `writes: read-only` 선언인데 샌드박스가 바뀌었다' \
925
+ && ! _viol_ok "$(printf 'bash: touch: command not found\n🟥 VIOLATION /x/a.cap — 샌드박스가 바뀌었다')" \
926
+ && ! _viol_ok '✅ VERIFIED /x/a.cap'; then
927
+ pass=$((pass+1)); echo "✅ L20g 판정 문구 검사: 양성 1 참 · 조회 오류 섞임 거짓 · 문구 없음 거짓"
928
+ else
929
+ fails=$((fails+1)); echo "❌ L20g 판정 문구 검사가 짝을 못 가른다 — rc=1 만으로 통과하는 레인이 된다"
930
+ fi
931
+
932
+ # L20-ctl **허용 목록 컨트롤** — 아무것도 안 뺀 shim 에서 «정상 위반 판정» 이 나와야 한다.
933
+ # rc 만 보면 의존 도구가 빠져 오류로 끝난 rc=1 도 통과한다(codex R1 #3) — 판정 문구까지 본다.
934
+ # 이게 빨갛면 허용 목록에 프로브가 쓰는 도구가 빠진 것이고, 아래 L20 계열의 rc 는 의미가 없다.
935
+ if _shim_ready "L20-ctl" "$d/bin_all"; then
936
+ out=$(PATH="$d/bin_all" "${BASH:-/bin/bash}" "$0" "$d/agg_viol.cap" 2>&1); rc=$?
937
+ if [ "$rc" = "1" ] && _viol_ok "$out"; then
938
+ pass=$((pass+1)); echo "✅ L20-ctl 허용 목록 shim 에서 정상 위반 판정(도구 누락 없음)"
939
+ else
940
+ fails=$((fails+1)); echo "❌ L20-ctl rc=$rc (1 + 위반 문구 기대) — 허용 목록에 프로브가 쓰는 도구가 빠졌다: $(printf '%s' "$out" | head -1)"
941
+ fi
942
+ fi
943
+ # L20e **복사 폴백이면 실행 파일을 하나도 안 넘긴다** — 복사하는 가짜 ln 이 받은 원본을 전부 적는다.
944
+ mkdir -p "$d/fakeln"; : > "$d/fakeln_sources"
945
+ printf '#!/bin/sh\n# 심링크 대신 복사하는 ln (MSYS 기본 폴백 재현) — 받은 원본을 적는다\nshift; printf "%%s\\n" "$1" >> "%s"; cp "$1" "$2"\n' "$d/fakeln_sources" > "$d/fakeln/ln"; chmod +x "$d/fakeln/ln"
946
+ ( PATH="$d/fakeln:$PATH"; _mkshim "$d/bin_copy" ); rc=$?
947
+ _nsrc=$(wc -l < "$d/fakeln_sources" | tr -d ' ')
948
+ _nexe=$(grep -vc '\.lnprobe\.txt$' "$d/fakeln_sources")
949
+ _nleft=$(find "$d/bin_copy" -type f 2>/dev/null | wc -l | tr -d ' ')
950
+ if [ "$rc" = "2" ] && [ "$_nsrc" = "1" ] && [ "$_nexe" = "0" ] && [ "$_nleft" = "0" ]; then
951
+ pass=$((pass+1)); echo "✅ L20e 복사 폴백 환경: 텍스트 탐침 한 장만 넘기고 rc=2 · 실행 파일 0 · 남은 사본 0"
952
+ else
953
+ fails=$((fails+1)); echo "❌ L20e rc=$rc 넘긴 원본=$_nsrc 그중 실행 파일=$_nexe 남은 사본=$_nleft (2·1·0·0 기대) — 복사 폴백에서 실행 파일을 넘긴다"
954
+ fi
894
955
 
895
956
  # L20 해시 도구가 **둘 다** 없으면 판정하지 않는다.
896
- _mkshim "$d/bin_none" shasum sha256sum
957
+ if _shim_ready "L20" "$d/bin_none" shasum sha256sum; then
897
958
  out=$(PATH="$d/bin_none" "${BASH:-/bin/bash}" "$0" "$d/agg_viol.cap" 2>&1); rc=$?
898
959
  if [ "$rc" = "10" ] && printf '%s' "$out" | grep -q "sha256sum"; then
899
960
  pass=$((pass+1)); echo "✅ L20 해시 도구 전무는 HARNESS_ERROR (이유도 찍힌다)"
900
961
  else
901
962
  fails=$((fails+1)); echo "❌ L20 rc=$rc (10 기대) — 계기 사망이 통과/판정으로 렌더된다"
902
963
  fi
964
+ fi
903
965
  # L20b **과차단 방지** — `shasum` 만 없고 `sha256sum` 이 있으면 정상 판정해야 한다.
904
966
  # cross-family 지목 #3: 이 파일은 files[] 로 출하되고 Linux 소비자는 sha256sum 만 갖는다.
905
967
  if command -v sha256sum >/dev/null 2>&1; then
906
- _mkshim "$d/bin_s256" shasum
968
+ if _shim_ready "L20b" "$d/bin_s256" shasum; then
907
969
  out=$(PATH="$d/bin_s256" "${BASH:-/bin/bash}" "$0" "$d/agg_viol.cap" 2>&1); rc=$?
908
- if [ "$rc" = "1" ]; then
970
+ if [ "$rc" = "1" ] && _viol_ok "$out"; then
909
971
  pass=$((pass+1)); echo "✅ L20b shasum 부재+sha256sum 존재 → 폴백이 정상 판정(과차단 없음)"
910
972
  else
911
973
  fails=$((fails+1)); echo "❌ L20b rc=$rc (1 기대) — 폴백이 없거나 과차단한다"
912
974
  fi
975
+ fi
976
+ # L20f **shasum 없이도 홈 감시가 산다** — 옛 판은 홈 목록을 `shasum` 으로 직접 해시해서, shasum 없는
977
+ # Linux 에서 앞뒤가 둘 다 빈 값 → 홈 쓰기가 늘 «안 바뀜» 이었다. L14b 와 같은 과녁을 shim 아래에서 친다.
978
+ if _shim_ready "L20f" "$d/bin_s256f" shasum; then
979
+ out=$(PATH="$d/bin_s256f" "${BASH:-/bin/bash}" "$0" "$d/outside.cap" 2>&1); rc=$?
980
+ rm -f "$_homemark"
981
+ if [ "$rc" = "1" ] && printf '%s' "$out" | grep -q '홈 디렉토리'; then
982
+ pass=$((pass+1)); echo "✅ L20f shasum 부재에서도 홈 쓰기는 VIOLATION(이유 «홈»)"
983
+ else
984
+ fails=$((fails+1)); echo "❌ L20f rc=$rc · 이유=[$(printf '%s' "$out" | tail -1)] — shasum 없는 환경에서 홈 감시가 죽었다"
985
+ fi
986
+ fi
913
987
  else
914
- echo "⏭ L20b SKIP — 이 머신에 sha256sum 이 없다(미측정, 통과 아님)"
988
+ echo "⏭ L20b · L20f SKIP — 이 머신에 sha256sum 이 없다(미측정, 통과 아님)"
915
989
  fi
916
990
  # L20c **«있는데 고장난» 해시 도구** — cross-family 지목 #1. 프리플라이트는 통과한다.
917
- _mkshim "$d/bin_broken" shasum sha256sum
991
+ if _shim_ready "L20c" "$d/bin_broken" shasum sha256sum; then
918
992
  printf '#!/bin/sh\nexit 1\n' > "$d/bin_broken/shasum"; chmod +x "$d/bin_broken/shasum"
919
993
  out=$(PATH="$d/bin_broken" "${BASH:-/bin/bash}" "$0" "$d/agg_viol.cap" 2>&1); rc=$?
920
- if [ "$rc" = "1" ]; then
994
+ if [ "$rc" = "1" ] && _viol_ok "$out"; then
921
995
  pass=$((pass+1)); echo "✅ L20c 해시 도구가 고장나도 파일 생성은 잡힌다(이름 목록 축)"
922
996
  else
923
997
  fails=$((fails+1)); echo "❌ L20c rc=$rc (1 기대) — 고장난 계기가 거짓 VERIFIED 를 낸다"
924
998
  fi
999
+ fi
925
1000
  # L20d **읽을 수 없는 파일** — 가짜 도구 없이 재현되는 형태(cross-family 지목 #1 두 번째).
926
1001
  cat > "$d/unreadable.cap" <<EOF
927
1002
  id: t:unread
@@ -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). [LOW]: `-e .git` (not `-d`) so git worktrees/submodules (`.git` is a file) count.
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 = worktree)
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 억제는 **표시 판단보다 먼저** 접는다 ─────────────────────────