@chrono-meta/fh-gate 3.29.0 → 3.31.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 +7 -2
- package/CLAUDE.md +1 -1
- package/README.ja.md +6 -5
- package/README.ko.md +6 -5
- package/README.md +15 -5
- package/README.zh.md +6 -5
- package/docs/REFERENCE.md +6 -5
- package/docs/USER_GUIDE.md +3 -0
- package/knowledge/shared/harness-core/claude_md_gate_details.md +1 -1
- package/knowledge/shared/harness-core/dispatch_conditional_prohibition.md +42 -0
- package/knowledge/shared/harness-core/sonnet_floor_doctrine.md +7 -0
- package/knowledge/shared/learnings/subagent_invocations_log.yaml +161 -0
- package/package.json +6 -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 +35 -0
- package/plugins/fh-meta/skills/install-wizard/SKILL.md +25 -0
- package/plugins/fh-meta/skills/install-wizard/SKILL_detail.md +24 -6
- package/plugins/fh-meta/skills/phantom-quench/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/abstract_consult_check.py +573 -0
- package/scripts/fh_detach.py +444 -0
- package/scripts/mapped_tracks.sh +20 -13
- package/scripts/memory_gc_report.py +55 -5
- package/scripts/pr_merge_verified.sh +56 -8
- package/scripts/selfcheck.sh +85 -6
- package/scripts/session_checklist.py +3 -2
- package/scripts/session_close_check.sh +1 -1
- package/scripts/sim_isolated_run.sh +62 -0
- package/scripts/stale_ref_scan.py +47 -3
- package/scripts/test_abstract_consult_check_lanes.sh +201 -0
- package/scripts/test_fh_detach_lanes.sh +252 -0
- package/scripts/test_hook_source_gate_lanes.sh +16 -2
- package/scripts/test_mapped_tracks_lanes.sh +55 -1
- package/scripts/test_memory_gc_report_lanes.sh +91 -1
- package/scripts/test_mutation_probe_lanes.sh +86 -10
- package/scripts/test_ollama_panel_lanes.sh +107 -11
- package/scripts/test_pr_merge_verified_lanes.sh +48 -1
- package/scripts/test_prepush_real_fire_lanes.sh +215 -0
- package/scripts/test_selfcheck_state_lanes.sh +73 -1
- package/scripts/test_session_checklist_lanes.sh +34 -0
- package/scripts/test_sim_isolated_run_lanes.sh +88 -0
- package/scripts/test_stale_ref_scan_lanes.sh +11 -1
- package/templates/.git-hooks/pre-push +82 -1
- package/templates/CLAUDE.md +16 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# abstract_consult_check.py 레인 — 아는 쌍(걸려야 할 질문 / 통과해야 할 질문)을 같은 실행에 둔다.
|
|
3
|
+
# 🟥 게이트는 «막나» 와 «정상 질문을 안 막나» 를 같이 잰다 — 역할로 바꾼 질문까지 막으면 이 길은 쓸모가 없다.
|
|
4
|
+
# 사전은 픽스처다(/usr/share/dict/words 가 없는 CI 에서도 같은 판정). 실제 사전 · 실제 레포 과차단 비율은 D2 가 잰다.
|
|
5
|
+
# rc 계약: 0 = clean · 1 = hit · 3 = NOT SCANNED
|
|
6
|
+
set -uo pipefail
|
|
7
|
+
HERE=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
8
|
+
C="$HERE/abstract_consult_check.py"
|
|
9
|
+
T=$(mktemp -d -t acc.XXXXXX) || exit 3
|
|
10
|
+
trap 'rm -rf "$T"' EXIT
|
|
11
|
+
PASS=0; FAIL=0
|
|
12
|
+
chk() { if [ "$2" = "$3" ]; then PASS=$((PASS+1)); printf ' ✅ %-58s %s\n' "$1" "$2"; else FAIL=$((FAIL+1)); printf ' ❌ %-58s got=%s want=%s\n' "$1" "$2" "$3"; fi; }
|
|
13
|
+
|
|
14
|
+
R="$T/repo"; mkdir -p "$R/src"
|
|
15
|
+
git -C "$R" init -q -b main
|
|
16
|
+
cat > "$R/src/settle.py" <<'EOF'
|
|
17
|
+
import requests
|
|
18
|
+
ZQPAY_HOST = "pg-settle-01.shop.internal"
|
|
19
|
+
def processPayment(order):
|
|
20
|
+
return requests.post("https://" + ZQPAY_HOST + "/zqpayGateway/approve", json={"order": order, "retry": 3})
|
|
21
|
+
if order is None: return retry(order, safe)
|
|
22
|
+
ALT = "settle.internal"
|
|
23
|
+
EOF
|
|
24
|
+
echo 'VelnoraKey = 1' > "$R/src/secret.py"
|
|
25
|
+
python3 -c "import sys; open(sys.argv[1],'w').write('QuorvexId = 1\n' + 'x = 1\n' * 400000)" "$R/big.txt"
|
|
26
|
+
echo '{}' > "$R/config.json"
|
|
27
|
+
printf 'MSGS = ["tHe", "bE", "iT"]\nusingMappedValues = 1\nnumericWhitespaceTable = 2\nmapness = 3\nmappes = 4\nEDGE = "getSetGetSetGetSetGetSetGetSetGetSet.internal"\n' > "$R/src/strings.py"
|
|
28
|
+
ln -s /private/QorvianLink/settings.py "$R/linked.py"
|
|
29
|
+
git -C "$R" add -A
|
|
30
|
+
git -C "$R" -c user.name="Jimin Parkova" -c user.email="jparkova@shop.example" commit -qm init
|
|
31
|
+
echo "# notes" > "$R/NOTES.md"; git -C "$R" add NOTES.md
|
|
32
|
+
git -C "$R" -c user.name="test" -c user.email="test@t" commit -qm notes
|
|
33
|
+
echo "# more" >> "$R/NOTES.md"; git -C "$R" add NOTES.md
|
|
34
|
+
git -C "$R" -c user.name="Sora M. Kitavane" -c user.email="sk@shop.example" commit -qm more
|
|
35
|
+
|
|
36
|
+
cat > "$T/dict" <<'EOF'
|
|
37
|
+
a
|
|
38
|
+
about
|
|
39
|
+
approval
|
|
40
|
+
approve
|
|
41
|
+
call
|
|
42
|
+
shop
|
|
43
|
+
external
|
|
44
|
+
gate
|
|
45
|
+
gateway
|
|
46
|
+
handle
|
|
47
|
+
host
|
|
48
|
+
how
|
|
49
|
+
import
|
|
50
|
+
internal
|
|
51
|
+
is
|
|
52
|
+
order
|
|
53
|
+
park
|
|
54
|
+
payment
|
|
55
|
+
post
|
|
56
|
+
process
|
|
57
|
+
request
|
|
58
|
+
retry
|
|
59
|
+
return
|
|
60
|
+
safe
|
|
61
|
+
safely
|
|
62
|
+
service
|
|
63
|
+
settle
|
|
64
|
+
should
|
|
65
|
+
slow
|
|
66
|
+
test
|
|
67
|
+
the
|
|
68
|
+
this
|
|
69
|
+
timeout
|
|
70
|
+
way
|
|
71
|
+
why
|
|
72
|
+
wrapper
|
|
73
|
+
write
|
|
74
|
+
around
|
|
75
|
+
fail
|
|
76
|
+
none
|
|
77
|
+
notes
|
|
78
|
+
use
|
|
79
|
+
map
|
|
80
|
+
value
|
|
81
|
+
EOF
|
|
82
|
+
printf '#!/bin/bash\necho " ✅ outbound clean" >&2\nexit 0\n' > "$T/g0.sh"
|
|
83
|
+
printf '#!/bin/bash\nexit 1\n' > "$T/g1.sh"
|
|
84
|
+
printf '#!/bin/bash\nexit 3\n' > "$T/g3.sh"
|
|
85
|
+
printf '#!/bin/bash\n[ "${OUTBOUND_QUERY_OK:-0}" = 1 ] && { echo " ✅ outbound clean" >&2; exit 0; }\nexit 1\n' > "$T/gok.sh"
|
|
86
|
+
: > "$T/gempty.sh"
|
|
87
|
+
|
|
88
|
+
kinds() { python3 -c 'import json,sys; d=json.load(open(sys.argv[1])); print(",".join(sorted({h["kind"] for h in d.get(sys.argv[2],[])})))' "$T/out" "$1"; }
|
|
89
|
+
run() { # run <question> [extra args...] → rc
|
|
90
|
+
local q=$1; shift
|
|
91
|
+
printf '%s' "$q" > "$T/q"
|
|
92
|
+
python3 "$C" check --repo "$R" --question-file "$T/q" --dict "$T/dict" --guard "$T/g0.sh" --ledger "$T/ledger.jsonl" "$@" >"$T/out" 2>"$T/err"
|
|
93
|
+
echo $?
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
echo "── 통과해야 할 것(과차단 컨트롤) ──"
|
|
97
|
+
chk "A1 역할로 바꾼 질문 → clean" "$(run 'How should a retry wrapper around an external payment approval call handle timeouts?')" 0
|
|
98
|
+
chk "A5n 산문 «process payment» → clean" "$(run 'how to process payment safely')" 0
|
|
99
|
+
chk "A7n 한 낱말 작성자 «test» 는 사전 낱말을 막지 않는다" "$(run 'test the gate')" 0
|
|
100
|
+
chk "A7n2 굴절형(requests · returns) → clean" "$(run 'the service returns none when requests time out')" 0
|
|
101
|
+
|
|
102
|
+
echo "── 걸려야 할 것 ──"
|
|
103
|
+
chk "A2 불투명 식별자 그대로" "$(run 'Why does zqpayGateway approve fail')" 1
|
|
104
|
+
chk "A3 대소문자 · 띄어 쓴 불투명 식별자" "$(run 'the ZQPAY gate way returns 500')" 1
|
|
105
|
+
chk "A4 불투명 조각 하나만(zqpay)" "$(run 'the zqpay service is slow')" 1
|
|
106
|
+
chk "A5 낱말 합성 식별자 → 막지 않고 flags(compound)" "$(run 'processPayment returns None')/$(kinds flags)" "0/compound"
|
|
107
|
+
chk "A6 호스트명을 띄어 씀" "$(run 'host pg settle 01 shop internal is slow')" 1
|
|
108
|
+
chk "A6b 호스트명 그대로" "$(run 'host pg-settle-01.shop.internal is slow')" 1
|
|
109
|
+
chk "A7 작성자 이름(여러 낱말)" "$(run 'Jimin Parkova wrote this')" 1
|
|
110
|
+
chk "A7b 작성자 메일" "$(run 'ask jparkova@shop.example about it')" 1
|
|
111
|
+
chk "A8 원문 코드 조각(이름 섞임)" "$(run 'return requests.post("https://" + ZQPAY_HOST')" 1
|
|
112
|
+
|
|
113
|
+
echo "── codex R1 (2026-10-26) ──"
|
|
114
|
+
rm "$R/src/secret.py" # 작업 트리에서만 지움 — 추적 파일의 이름은 마지막 커밋본에서 읽어야 한다
|
|
115
|
+
chk "X1 합성 식별자 대문자 · 밑줄 표기 → flags" "$(run 'PROCESSPAYMENT returns None')$(kinds flags)/$(run 'process_payment returns None')$(kinds flags)" "0compound/0compound"
|
|
116
|
+
chk "X2 불투명 이름의 복수형" "$(run 'Why do zqpays fail?')" 1
|
|
117
|
+
chk "X3 순서를 바꾼 작성자 이름" "$(run 'Parkova, Jimin wrote this; is the approach safe?')" 1
|
|
118
|
+
chk "X4 두 조각 호스트명" "$(run 'Why is host SETTLE.INTERNAL slow?')" 1
|
|
119
|
+
chk "X4n 파일 이름(config.json)은 호스트 · 합성 · flags 어디에도 안 든다" "$(run 'why is config.json slow')/$(kinds hits)/$(kinds flags)" "0//"
|
|
120
|
+
chk "X5 작업 트리에서 지운 추적 파일 속 이름" "$(run 'Why does VelnoraKey fail?')" 1
|
|
121
|
+
chk "X5b 1MiB 넘는 파일 앞부분 속 이름" "$(run 'Why does QuorvexId fail?')" 1
|
|
122
|
+
git -C "$R" checkout -q -- src/secret.py
|
|
123
|
+
run 'Why does zqpay fail?' >/dev/null
|
|
124
|
+
chk "X6 원장에 레포 경로를 평문으로 안 쓴다" "$(grep -cF "$R" "$T/ledger.jsonl")" 0
|
|
125
|
+
X7RC=$(run 'how should we handle it? if order is None: return retry(order, safe)')
|
|
126
|
+
chk "X7 원문 조각(L3)만으로 걸린다 — 종료 코드와 걸린 층" "$X7RC/$(python3 -c 'import json,sys; print(",".join(sorted({h["layer"]+":"+h["kind"] for h in json.load(open(sys.argv[1]))["hits"]})))' "$T/out")" "1/L3:verbatim"
|
|
127
|
+
echo "── codex R2 (2026-10-26) ──"
|
|
128
|
+
chk "Y1 추적 중인 심볼릭 링크의 대상 경로 속 이름" "$(run 'Why does QorvianLink fail?')" 1
|
|
129
|
+
chk "Y2 빈 가드 파일 → NOT SCANNED" "$(run 'How should a retry wrapper handle timeouts?' --guard "$T/gempty.sh")" 3
|
|
130
|
+
chk "Y3 가운데 이니셜을 뺀 작성자 이름" "$(run 'Sora Kitavane wrote this; is the approach safe?')" 1
|
|
131
|
+
|
|
132
|
+
echo "── D2A 과차단 · 회피 (2026-10-26, RESULTS_D2A.md) ──"
|
|
133
|
+
chk "Z1 표준 라이브러리 어휘(numeric · whitespace) → clean" "$(run 'a numeric whitespace table maps each code point')" 0
|
|
134
|
+
chk "Z1n 같은 질문, 표준 라이브러리 어휘 끔 → hit(컨트롤)" "$(run 'a numeric whitespace table maps each code point' --no-stdlib-vocab)" 1
|
|
135
|
+
chk "Z2 레포의 짧은 합성(tHe · bE · iT)은 flags 에도 없다" "$(run 'it is to be the one that fails')/$(kinds flags)" "0/"
|
|
136
|
+
chk "Z3 굴절형(using · mapped) → 막지 않음" "$(run 'using mapped values fails' --no-stdlib-vocab)" 0
|
|
137
|
+
chk "Z4 다른 낱말에 붙여 쓴 불투명 이름(ZqpayClient) — 걸린 종류까지" "$(run 'ZqpayClient fails')/$(kinds hits)" "1/opaque"
|
|
138
|
+
chk "Z5 글자마다 띄어 쓴 불투명 이름(7자) — 걸린 종류까지" "$(run 'v e l n o r a fails')/$(kinds hits)" "1/opaque-split"
|
|
139
|
+
echo "── codex R1 (precision, 2026-10-26) ──"
|
|
140
|
+
chk "W1 긴 camel 호스트명 그대로" "$(run 'Why is getSetGetSetGetSetGetSetGetSetGetSet.internal slow?')" 1
|
|
141
|
+
chk "W3 파생 접미로 지어낸 이름(mapness)은 공개 낱말이 아니다" "$(run 'Why does mapness fail?' --no-stdlib-vocab)" 1
|
|
142
|
+
mkdir -p "$T/cache"
|
|
143
|
+
# 경로를 레인 안에서 직접 계산한다 — 검사기 함수로 계산하면 그 함수가 없는 옛 코드에서 오염이 엉뚱한 자리에 쓰여 레인이 장식이 된다
|
|
144
|
+
CP=$(python3 -c 'import hashlib,os,sys,sysconfig; std=sysconfig.get_paths()["stdlib"]; print(os.path.join(sys.argv[1], "fh-abstract-consult", "stdlib-%s.json" % hashlib.sha256((std + sys.version).encode()).hexdigest()[:16]))' "$T/cache")
|
|
145
|
+
mkdir -p "$(dirname "$CP")"
|
|
146
|
+
python3 -c 'import json,sys; json.dump(["zqpay"] + ["word"] * 1500, open(sys.argv[1], "w"))' "$CP"
|
|
147
|
+
chk "W2 중복으로 부풀린 캐시를 믿지 않는다(zqpay 그대로 걸림)" "$(XDG_CACHE_HOME="$T/cache" run 'Why does zqpay fail?')" 1
|
|
148
|
+
chk "W2b 캐시를 다시 지었다(출처 · 버전 · 해시 칸까지)" "$(python3 -c 'import hashlib,json,sys,sysconfig; d=json.load(open(sys.argv[1])); w=d.get("words",[]); print(d.get("std")==sysconfig.get_paths()["stdlib"] and d.get("version")==sys.version and d.get("sha")==hashlib.sha256("\n".join(w).encode()).hexdigest() and len(set(w))==len(w)>1000 and "zqpay" not in w)' "$CP")" True
|
|
149
|
+
chk "W4 자음 겹침을 아무 접미에나 쓰지 않는다(mappes)" "$(run 'Why does mappes fail?' --no-stdlib-vocab)" 1
|
|
150
|
+
run 'processPayment returns None' >/dev/null
|
|
151
|
+
chk "Z6 원장의 flags 는 해시만(이름 · token 칸 없음)" "$(tail -1 "$T/ledger.jsonl" | python3 -c 'import json,sys; f=json.load(sys.stdin)["flags"]; print(len(f), all(set(x)=={"layer","kind","sha256"} for x in f))')" "1 True"
|
|
152
|
+
|
|
153
|
+
echo "── L1 운영자 리터럴 가드 ──"
|
|
154
|
+
chk "A9 가드 rc1 → hit" "$(run 'How should a retry wrapper handle timeouts?' --guard "$T/g1.sh")" 1
|
|
155
|
+
chk "A9b 가드 rc3 → NOT SCANNED" "$(run 'How should a retry wrapper handle timeouts?' --guard "$T/g3.sh")" 3
|
|
156
|
+
chk "A9c 가드 없음 → NOT SCANNED" "$(run 'How should a retry wrapper handle timeouts?' --guard "$T/nope.sh")" 3
|
|
157
|
+
chk "A9d OUTBOUND_QUERY_OK=1 이 가드를 통과시키지 못한다" \
|
|
158
|
+
"$(OUTBOUND_QUERY_OK=1 run 'How should a retry wrapper handle timeouts?' --guard "$T/gok.sh")" 1
|
|
159
|
+
|
|
160
|
+
echo "── L1 실물 가드(패턴 픽스처 주입) ──"
|
|
161
|
+
printf 'HIGH\tZZFIXTURETOKEN\n' > "$T/defaults"; printf 'HIGH\tZZOVERRIDETOKEN\n' > "$T/override"
|
|
162
|
+
chk "A13 실물 가드 · override 리터럴 → hit" \
|
|
163
|
+
"$(PSA_DEFAULTS_FILE="$T/defaults" PSA_OVERRIDE_FILE="$T/override" run 'why does ZZOVERRIDETOKEN time out' --guard "$HERE/outbound_query_guard.sh")" 1
|
|
164
|
+
chk "A13n 실물 가드 · 깨끗한 질문 → clean" \
|
|
165
|
+
"$(PSA_DEFAULTS_FILE="$T/defaults" PSA_OVERRIDE_FILE="$T/override" run 'How should a retry wrapper handle timeouts?' --guard "$HERE/outbound_query_guard.sh")" 0
|
|
166
|
+
|
|
167
|
+
echo "── 미측정 = 막음 ──"
|
|
168
|
+
chk "A10 사전 없음" "$(run 'How should a retry wrapper handle timeouts?' --dict "$T/nodict")" 3
|
|
169
|
+
mkdir -p "$T/notgit"
|
|
170
|
+
chk "A10b git 레포 아님" "$(printf 'x' > "$T/q"; python3 "$C" check --repo "$T/notgit" --question-file "$T/q" --dict "$T/dict" --guard "$T/g0.sh" --no-ledger >/dev/null 2>&1; echo $?)" 3
|
|
171
|
+
mkdir -p "$T/empty"; git -C "$T/empty" init -q
|
|
172
|
+
chk "A10c 추적 파일 0" "$(printf 'x' > "$T/q"; python3 "$C" check --repo "$T/empty" --question-file "$T/q" --dict "$T/dict" --guard "$T/g0.sh" --no-ledger >/dev/null 2>&1; echo $?)" 3
|
|
173
|
+
mkdir -p "$T/plain"; git -C "$T/plain" init -q; echo "the gate is safe" > "$T/plain/notes"; git -C "$T/plain" add -A
|
|
174
|
+
chk "A10e 비공개 후보 이름 0 개(사전 낱말뿐) → NOT SCANNED" "$(printf 'x' > "$T/q"; python3 "$C" check --repo "$T/plain" --question-file "$T/q" --dict "$T/dict" --guard "$T/g0.sh" --no-ledger >/dev/null 2>&1; echo $?)" 3
|
|
175
|
+
chk "A10d 빈 질문" "$(run ' ')" 3
|
|
176
|
+
chk "A11b 공개 말뭉치 경로 없음" "$(run 'How should a retry wrapper handle timeouts?' --public-corpus "$T/nopub")" 3
|
|
177
|
+
|
|
178
|
+
echo "── 공개 말뭉치 ──"
|
|
179
|
+
mkdir -p "$T/pub"; echo 'zqpayGateway = 1' > "$T/pub/x.py"
|
|
180
|
+
chk "A11 공개 말뭉치에 있는 이름은 비공개 실체로 안 친다" "$(run 'Why does zqpayGateway approve fail' --public-corpus "$T/pub")" 0
|
|
181
|
+
chk "A11n 말뭉치에 없는 이름은 그대로 걸린다" "$(run 'host pg settle 01 shop internal is slow' --public-corpus "$T/pub")" 1
|
|
182
|
+
|
|
183
|
+
echo "── 원장 ──"
|
|
184
|
+
: > "$T/ledger.jsonl"
|
|
185
|
+
run 'Why does zqpayGateway approve fail' >/dev/null
|
|
186
|
+
HID=$(python3 -c "import json;print(json.load(open('$T/out'))['id'])")
|
|
187
|
+
run 'How should a retry wrapper around an external payment approval call handle timeouts?' >/dev/null
|
|
188
|
+
CID=$(python3 -c "import json;print(json.load(open('$T/out'))['id'])")
|
|
189
|
+
chk "A12 걸린 질문의 이름 · 본문이 원장에 없다" "$(grep -ci 'zqpay' "$T/ledger.jsonl")" 0
|
|
190
|
+
chk "A12b 깨끗한 질문은 본문을 남긴다" "$(grep -c 'retry wrapper around' "$T/ledger.jsonl")" 1
|
|
191
|
+
chk "A12c 원장 권한 600" "$(stat -c '%a' "$T/ledger.jsonl" 2>/dev/null || stat -f '%Lp' "$T/ledger.jsonl")" 600
|
|
192
|
+
d() { python3 "$C" "$@" --ledger "$T/ledger.jsonl" >/dev/null 2>&1; echo $?; }
|
|
193
|
+
chk "A12d 걸린 질문을 «보냄» 으로 기록 → 거부" "$(d decide --id "$HID" --decision sent)" 1
|
|
194
|
+
chk "A12e 없는 id → 거부" "$(d decide --id nope --decision dropped)" 1
|
|
195
|
+
chk "A12f 보냄 기록 없이 재현 결과 → 거부" "$(d replay --id "$CID" --rc 0)" 1
|
|
196
|
+
chk "A12g 깨끗한 질문 «보냄»" "$(d decide --id "$CID" --decision sent)" 0
|
|
197
|
+
chk "A12h 보낸 뒤 재현 결과" "$(d replay --id "$CID" --rc 0)" 0
|
|
198
|
+
|
|
199
|
+
echo
|
|
200
|
+
echo "abstract_consult_check lanes: $PASS passed · $FAIL failed"
|
|
201
|
+
[ "$FAIL" -eq 0 ]
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# test_fh_detach_lanes.sh — install-wizard writes, fh_detach.py undoes them, byte for byte.
|
|
3
|
+
#
|
|
4
|
+
# The install side is NOT re-typed here: the lane extracts the wizard's own bash blocks
|
|
5
|
+
# (SKILL_detail.md §Step4-Baseline-Bash and §Mode-D-Companion-Setup) and runs them, so a change to what the
|
|
6
|
+
# wizard writes is exercised by the next run of this lane. Everything happens under a temp HOME and a temp hub.
|
|
7
|
+
#
|
|
8
|
+
# D* detach (known-positive: install changes the tree · known-negative: detach restores it exactly)
|
|
9
|
+
# G* the wizard's 4-axis gate block needs FH_WIZARD_GATE_CONSENT=Y
|
|
10
|
+
# P1 --plugin calls the Claude Code uninstall (a fake `claude` records the argv)
|
|
11
|
+
set -u
|
|
12
|
+
HERE="$(cd "$(dirname "$0")" && pwd)"
|
|
13
|
+
ROOT="$(cd "$HERE/.." && pwd)"
|
|
14
|
+
DETACH="$HERE/fh_detach.py"
|
|
15
|
+
DETAIL="$ROOT/plugins/fh-meta/skills/install-wizard/SKILL_detail.md"
|
|
16
|
+
T="$(mktemp -d)"
|
|
17
|
+
trap 'rm -rf "$T"' EXIT
|
|
18
|
+
pass=0; fail=0
|
|
19
|
+
chk() { # chk <name> <got> <want>
|
|
20
|
+
if [ "$2" = "$3" ]; then pass=$((pass+1)); printf ' ✅ %-58s %s\n' "$1" "$2"
|
|
21
|
+
else fail=$((fail+1)); printf ' ❌ %-58s got=%s want=%s\n' "$1" "$2" "$3"; fi
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
block() { # block <section heading> → the first ```bash fence after it
|
|
25
|
+
python3 - "$DETAIL" "$1" <<'PY'
|
|
26
|
+
import sys
|
|
27
|
+
s = open(sys.argv[1], encoding="utf-8").read().split("\n")
|
|
28
|
+
i = s.index("## " + sys.argv[2])
|
|
29
|
+
while not s[i].startswith("```bash"):
|
|
30
|
+
i += 1
|
|
31
|
+
j = i + 1
|
|
32
|
+
while s[j] != "```":
|
|
33
|
+
j += 1
|
|
34
|
+
print("\n".join(s[i + 1:j]))
|
|
35
|
+
PY
|
|
36
|
+
}
|
|
37
|
+
block "§Step4-Baseline-Bash" > "$T/step4.sh" || { echo "HARNESS-ERROR: cannot extract §Step4-Baseline-Bash"; exit 10; }
|
|
38
|
+
block "§Mode-D-Companion-Setup" > "$T/moded.sh" || { echo "HARNESS-ERROR: cannot extract §Mode-D-Companion-Setup"; exit 10; }
|
|
39
|
+
grep -q 'core.hooksPath templates/.git-hooks' "$T/step4.sh" || { echo "HARNESS-ERROR: step4 block has no gate install"; exit 10; }
|
|
40
|
+
grep -q 'settings.local.json' "$T/moded.sh" || { echo "HARNESS-ERROR: Mode-D block has no settings.local.json write"; exit 10; }
|
|
41
|
+
cat > "$T/edit_json.py" <<'PY'
|
|
42
|
+
import json, sys
|
|
43
|
+
# edit_json.py <settings.json> <hooks-to-merge JSON> <indent>
|
|
44
|
+
p = sys.argv[1]; d = json.load(open(p)); d.setdefault("hooks", {}).update(json.loads(sys.argv[2]))
|
|
45
|
+
open(p, "w").write(json.dumps(d, indent=int(sys.argv[3])) + "\n")
|
|
46
|
+
PY
|
|
47
|
+
cat > "$T/race.py" <<'PY'
|
|
48
|
+
import importlib.util, json, os, sys
|
|
49
|
+
# race.py <fh_detach.py> <world>: plan, then another writer changes settings.json, then apply
|
|
50
|
+
spec = importlib.util.spec_from_file_location("d", sys.argv[1]); d = importlib.util.module_from_spec(spec); spec.loader.exec_module(d)
|
|
51
|
+
hub = os.path.join(sys.argv[2], "hub"); S = os.path.join(hub, ".claude", "settings.json")
|
|
52
|
+
plan = d.Plan(True); cmds, keys = d.snippet_commands(hub)
|
|
53
|
+
d.plan_settings(plan, S, cmds, keys)
|
|
54
|
+
x = json.load(open(S)); x["hooks"].setdefault("Stop", []).append({"hooks": [{"type": "command", "command": "bash late.sh"}]})
|
|
55
|
+
open(S, "w").write(json.dumps(x, indent=2) + "\n")
|
|
56
|
+
for _, fn in plan.actions:
|
|
57
|
+
fn()
|
|
58
|
+
print("late=%d left=%d" % (open(S).read().count("late.sh"), sum("changed after the plan" in l for l in plan.left)))
|
|
59
|
+
PY
|
|
60
|
+
|
|
61
|
+
snap() { # snap <home> <hub> → one sha per file (+ hooksPath + exclude), hub/.git internals skipped
|
|
62
|
+
python3 - "$1" "$2" <<'PY'
|
|
63
|
+
import hashlib, os, subprocess, sys
|
|
64
|
+
out = []
|
|
65
|
+
for root in sys.argv[1:]:
|
|
66
|
+
for dp, dn, fn in os.walk(root):
|
|
67
|
+
dn[:] = sorted(d for d in dn if d != ".git")
|
|
68
|
+
out.append("D " + os.path.relpath(dp, root))
|
|
69
|
+
for f in sorted(fn):
|
|
70
|
+
p = os.path.join(dp, f)
|
|
71
|
+
out.append("F %s %s" % (os.path.relpath(p, root), hashlib.sha256(open(p, "rb").read()).hexdigest()[:16]))
|
|
72
|
+
hub = sys.argv[2]
|
|
73
|
+
r = subprocess.run(["git", "-C", hub, "config", "--local", "--get", "core.hooksPath"], capture_output=True, text=True)
|
|
74
|
+
out.append("hooksPath=" + r.stdout.strip())
|
|
75
|
+
ex = os.path.join(hub, ".git", "info", "exclude")
|
|
76
|
+
out.append("exclude=" + (hashlib.sha256(open(ex, "rb").read()).hexdigest()[:16] if os.path.exists(ex) else "-"))
|
|
77
|
+
print("\n".join(out))
|
|
78
|
+
PY
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
mkworld() { # mkworld <dir> → fresh HOME + hub with the user's own config already in place
|
|
82
|
+
local W="$1"; mkdir -p "$W/home" "$W/hub/templates" "$W/hub/scripts" "$W/store" "$W/hub/.claude"
|
|
83
|
+
git -C "$W/hub" init -q
|
|
84
|
+
cp "$ROOT"/templates/settings.*.snippet.json "$ROOT/templates/fh_audit_check.zsh" \
|
|
85
|
+
"$ROOT/templates/local_fh_context.md" "$ROOT/templates/fh_env_context.jsonc" "$W/hub/templates/"
|
|
86
|
+
mkdir -p "$W/hub/templates/.git-hooks" && echo '#!/bin/sh' > "$W/hub/templates/.git-hooks/pre-commit"
|
|
87
|
+
cp "$ROOT/scripts/fh_node_check.sh" "$W/hub/scripts/"
|
|
88
|
+
printf '#!/bin/sh\necho "companion-store freshness (stub)"\n' > "$W/hub/scripts/fh_session_load.sh"
|
|
89
|
+
printf 'export PATH=/opt/x:$PATH\nalias ll="ls -l"\n' > "$W/home/.zshrc"
|
|
90
|
+
printf '# mine\nkeep this line\n' > "$W/hub/CLAUDE.local.md"
|
|
91
|
+
# the user's own hooks — one shares a script NAME with FH but not its path; formatting is not indent=2
|
|
92
|
+
python3 - "$W/hub/.claude/settings.json" <<'PY'
|
|
93
|
+
import json, sys
|
|
94
|
+
d = {"model": "x", "hooks": {
|
|
95
|
+
"SessionStart": [{"hooks": [{"type": "command", "command": "bash ~/tools/scripts/fh_node_check.sh"}]}],
|
|
96
|
+
"PreToolUse": [{"matcher": "Bash", "hooks": [{"type": "command", "command": "bash my_guard.sh"}]}]}}
|
|
97
|
+
open(sys.argv[1], "w").write(json.dumps(d, indent=4) + "\n")
|
|
98
|
+
PY
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
install() { # install <world> [gate-consent | unset]
|
|
102
|
+
local W="$1" G="${2:-Y}"
|
|
103
|
+
if [ "$G" = unset ]; then
|
|
104
|
+
( cd "$W/hub" && env -u FH_WIZARD_GATE_CONSENT HOME="$W/home" FH_DIR="$W/hub" CC_HUB_DIR="$W/hub" FH_WIZARD_ZSHRC_CONSENT=Y \
|
|
105
|
+
bash "$T/step4.sh" ) > "$W/step4.out" 2>&1
|
|
106
|
+
else
|
|
107
|
+
( cd "$W/hub" && env HOME="$W/home" FH_DIR="$W/hub" CC_HUB_DIR="$W/hub" FH_WIZARD_ZSHRC_CONSENT=Y \
|
|
108
|
+
FH_WIZARD_GATE_CONSENT="$G" bash "$T/step4.sh" ) > "$W/step4.out" 2>&1
|
|
109
|
+
fi
|
|
110
|
+
( cd "$W/hub" && env HOME="$W/home" HUB_DIR="$W/hub" BE_DIR="$W/store" bash "$T/moded.sh" ) > "$W/moded.out" 2>&1
|
|
111
|
+
# §Step3 «Copy: templates/local_fh_context.md → .claude/rules/ · add pattern to .git/info/exclude»
|
|
112
|
+
mkdir -p "$W/hub/.claude/rules" && cp "$W/hub/templates/local_fh_context.md" "$W/hub/.claude/rules/"
|
|
113
|
+
echo ".claude/rules/local_fh_context.md" >> "$W/hub/.git/info/exclude"
|
|
114
|
+
}
|
|
115
|
+
detach() { # detach <world> [args…] → rc
|
|
116
|
+
local W="$1"; shift
|
|
117
|
+
( cd "$W/hub" && python3 "$DETACH" --project "$W/hub" --fh-dir "$W/hub" --home "$W/home" "$@" ) > "$W/detach.out" 2>&1
|
|
118
|
+
echo $?
|
|
119
|
+
}
|
|
120
|
+
fhhooks() { python3 -c '
|
|
121
|
+
import json,sys,re
|
|
122
|
+
d=json.load(open(sys.argv[1])); n=0
|
|
123
|
+
for gs in d.get("hooks",{}).values():
|
|
124
|
+
for g in gs:
|
|
125
|
+
for h in g["hooks"]: n+=bool(re.search(r"CLAUDE_PROJECT_DIR|forge-harness", h["command"]))
|
|
126
|
+
print(n)' "$1"; }
|
|
127
|
+
|
|
128
|
+
echo "── D: install → detach restores the tree ──"
|
|
129
|
+
W="$T/w1"; mkworld "$W"
|
|
130
|
+
PRE="$(snap "$W/home" "$W/hub")"
|
|
131
|
+
install "$W"
|
|
132
|
+
POST="$(snap "$W/home" "$W/hub")"
|
|
133
|
+
chk "D1 install changed the tree (known-positive)" "$([ "$PRE" != "$POST" ] && echo changed)" changed
|
|
134
|
+
chk "D1b zshrc block carries begin/end markers" "$(grep -c 'forge-harness (install-wizard)' "$W/home/.zshrc")" 2
|
|
135
|
+
chk "D1c FH hooks registered in settings.json" "$([ "$(fhhooks "$W/hub/.claude/settings.json")" -gt 3 ] && echo yes)" yes
|
|
136
|
+
chk "D1d hooksPath set by the gate block" "$(git -C "$W/hub" config --get core.hooksPath)" "templates/.git-hooks"
|
|
137
|
+
chk "D2 dry run: rc 0" "$(detach "$W")" 0
|
|
138
|
+
chk "D2b dry run changed nothing" "$([ "$(snap "$W/home" "$W/hub")" = "$POST" ] && echo same)" same
|
|
139
|
+
chk "D2c dry run lists the steps (≥ 6)" "$([ "$(grep -c '^ - ' "$W/detach.out")" -ge 6 ] && echo yes)" yes
|
|
140
|
+
chk "D3 --apply: rc 0" "$(detach "$W" --apply)" 0
|
|
141
|
+
AFTER="$(snap "$W/home" "$W/hub")"
|
|
142
|
+
chk "D3b tree is byte-equal to before install" "$([ "$AFTER" = "$PRE" ] && echo equal)" equal
|
|
143
|
+
[ "$AFTER" = "$PRE" ] || diff <(echo "$PRE") <(echo "$AFTER") | head -10
|
|
144
|
+
chk "D4 second --apply is a no-op (0 steps, rc 0)" "$(detach "$W" --apply)/$(grep -c '^ - ' "$W/detach.out")" "0/0"
|
|
145
|
+
|
|
146
|
+
echo "── D: what must NOT be removed ──"
|
|
147
|
+
W="$T/w2"; mkworld "$W"; install "$W"
|
|
148
|
+
python3 - "$W/hub/.claude/settings.json" <<'PY'
|
|
149
|
+
import json, sys
|
|
150
|
+
p = sys.argv[1]; d = json.load(open(p))
|
|
151
|
+
d["hooks"].setdefault("Stop", []).append({"hooks": [{"type": "command", "command": "bash after_install.sh"}]})
|
|
152
|
+
d["hooks"]["PreToolUse"].append({"hooks": [{"type": "command", "command": 'bash "$CLAUDE_PROJECT_DIR/scripts/pipe_verdict_guard.sh" --old-flag'}]})
|
|
153
|
+
open(p, "w").write(json.dumps(d, indent=2) + "\n")
|
|
154
|
+
PY
|
|
155
|
+
echo "user note" >> "$W/hub/.claude/rules/local_fh_context.md"
|
|
156
|
+
rc=$(detach "$W" --apply)
|
|
157
|
+
S="$W/hub/.claude/settings.json"
|
|
158
|
+
chk "D5 user's hook added after install survives" "$(grep -c 'after_install.sh' "$S")" 1
|
|
159
|
+
chk "D5b user's own fh_node_check.sh (not FH's path) survives" "$(grep -c '~/tools/scripts/fh_node_check.sh' "$S")" 1
|
|
160
|
+
chk "D5c non-hook keys survive" "$(python3 -c 'import json,sys;print(json.load(open(sys.argv[1]))["model"])' "$S")" x
|
|
161
|
+
chk "D7 FH-like hook that is not byte-equal → kept + LEFT + rc 1" "$rc/$(grep -c 'pipe_verdict_guard.sh\\" --old-flag' "$S")/$(grep -c 'LEFT (look at it).*older version' "$W/detach.out")" "1/1/1"
|
|
162
|
+
chk "D9 edited template copy kept + LEFT" "$([ -f "$W/hub/.claude/rules/local_fh_context.md" ] && echo kept)/$(grep -c 'you edited this copy' "$W/detach.out")" "kept/1"
|
|
163
|
+
chk "D9b … and its .git/info/exclude line stays" "$(grep -c '^.claude/rules/local_fh_context.md$' "$W/hub/.git/info/exclude")" 1
|
|
164
|
+
chk "D5d .prewizard that no longer matches is kept and named" "$([ -f "$S.prewizard" ] && echo kept)/$(grep -c 'note: .*settings.json.prewizard' "$W/detach.out")" "kept/1"
|
|
165
|
+
chk "D5e every byte-equal FH hook is gone" "$(fhhooks "$S")" 1
|
|
166
|
+
|
|
167
|
+
echo "── D: legacy zshrc · foreign hooksPath · unreadable config ──"
|
|
168
|
+
W="$T/w3"; mkworld "$W"
|
|
169
|
+
printf 'export FH_DIR="/x/fh"\nexport CC_HUB_DIR="/x/fh"\nexport CC_SENTINELS_DIR="$HOME/.cc_sentinels"\nsource "$FH_DIR/templates/fh_audit_check.zsh"\n' >> "$W/home/.zshrc"
|
|
170
|
+
git -C "$W/hub" config core.hooksPath custom/hooks
|
|
171
|
+
rc=$(detach "$W" --apply)
|
|
172
|
+
chk "D6 legacy unmarked 4-line block removed, user lines kept" "$(grep -c fh_audit_check "$W/home/.zshrc")/$(grep -c 'alias ll' "$W/home/.zshrc")" "0/1"
|
|
173
|
+
chk "D11 a hooksPath that is not the wizard's is left alone" "$(git -C "$W/hub" config --get core.hooksPath)" custom/hooks
|
|
174
|
+
W="$T/w4"; mkworld "$W"; install "$W"
|
|
175
|
+
printf '{ "hooks": ' > "$W/hub/.claude/settings.json"; B="$(shasum "$W/hub/.claude/settings.json")"
|
|
176
|
+
chk "D10 unparsable settings.json → rc 10" "$(detach "$W" --apply)" 10
|
|
177
|
+
chk "D10b … and the file is untouched" "$([ "$(shasum "$W/hub/.claude/settings.json")" = "$B" ] && echo same)" same
|
|
178
|
+
|
|
179
|
+
echo "── codex R1 (2026-10-26) ──"
|
|
180
|
+
W="$T/w7"; mkworld "$W"; install "$W"
|
|
181
|
+
python3 - "$W/home/.zshrc" <<'PY'
|
|
182
|
+
import sys
|
|
183
|
+
p = sys.argv[1]; s = open(p).read()
|
|
184
|
+
s = s.replace('source "$FH_DIR/templates/fh_audit_check.zsh"\n', 'source "$FH_DIR/templates/fh_audit_check.zsh"\nexport MY_SETTING=1\n')
|
|
185
|
+
open(p, "w").write(s)
|
|
186
|
+
PY
|
|
187
|
+
python3 - "$W/hub/.claude/settings.json" <<'PY'
|
|
188
|
+
import json, sys
|
|
189
|
+
p = sys.argv[1]; d = json.load(open(p))
|
|
190
|
+
for g in d["hooks"]["PreToolUse"]:
|
|
191
|
+
for h in g["hooks"]:
|
|
192
|
+
if "backtick_guard.sh" in h["command"]:
|
|
193
|
+
h["timeout"] = 99
|
|
194
|
+
open(p, "w").write(json.dumps(d, indent=2) + "\n")
|
|
195
|
+
PY
|
|
196
|
+
printf 'x\r\n' > "$T/crlf" && python3 -c 'import sys;b=open(sys.argv[1],"rb").read().replace(b"\n",b"\r\n");open(sys.argv[1],"wb").write(b)' "$W/hub/.claude/rules/local_fh_context.md"
|
|
197
|
+
rc=$(detach "$W" --apply)
|
|
198
|
+
chk "K1 a user line inside the marked zshrc block keeps the whole block + LEFT" "$(grep -c MY_SETTING "$W/home/.zshrc")/$(grep -cE 'forge-harness \(install-wizard\)|^export (FH_DIR|CC_HUB_DIR|CC_SENTINELS_DIR)=|fh_audit_check' "$W/home/.zshrc")/$(grep -c 'LEFT.*zshrc' "$W/detach.out")" "1/6/1"
|
|
199
|
+
chk "K2 FH hook whose timeout the user changed is kept + LEFT" "$(grep -c '"timeout": 99' "$W/hub/.claude/settings.json")/$(grep -c 'LEFT.*backtick_guard' "$W/detach.out")" "1/1"
|
|
200
|
+
chk "K3 CRLF-converted template copy counts as edited (kept)" "$([ -f "$W/hub/.claude/rules/local_fh_context.md" ] && echo kept)" kept
|
|
201
|
+
chk "K3b rc 1 while those are left" "$rc" 1
|
|
202
|
+
W="$T/w8"; mkworld "$W"
|
|
203
|
+
git -C "$W/hub" -c user.email=t@t -c user.name=t commit -q --allow-empty -m init
|
|
204
|
+
git -C "$W/hub" worktree add -q "$W/wt" 2>/dev/null
|
|
205
|
+
mkdir -p "$W/wt/.claude/rules" && cp "$W/hub/templates/local_fh_context.md" "$W/wt/.claude/rules/"
|
|
206
|
+
EX="$(git -C "$W/wt" rev-parse --path-format=absolute --git-path info/exclude)"; mkdir -p "$(dirname "$EX")"
|
|
207
|
+
echo ".claude/rules/local_fh_context.md" >> "$EX"
|
|
208
|
+
( cd "$W/wt" && python3 "$DETACH" --project "$W/wt" --fh-dir "$W/hub" --home "$W/home" --apply ) > "$W/detach.out" 2>&1
|
|
209
|
+
chk "K4 git worktree (.git is a file): copy and its exclude line both go" "$([ -f "$W/wt/.claude/rules/local_fh_context.md" ] && echo kept || echo gone)/$(grep -c 'local_fh_context' "$EX")" "gone/0"
|
|
210
|
+
W="$T/w9"; mkworld "$W"; mkdir -p "$T/bin2"
|
|
211
|
+
printf '#!/bin/sh
|
|
212
|
+
exit 1
|
|
213
|
+
' > "$T/bin2/claude"; chmod +x "$T/bin2/claude"
|
|
214
|
+
chk "K5 a failed plugin uninstall → rc 1 + LEFT" "$(PATH="$T/bin2:$PATH" detach "$W" --apply --plugin)/$(grep -c 'LEFT.*plugin' "$W/detach.out")" "1/2"
|
|
215
|
+
|
|
216
|
+
echo "── codex R2 (2026-10-26) ──"
|
|
217
|
+
W="$T/w10"; mkworld "$W"
|
|
218
|
+
python3 "$T/edit_json.py" "$W/hub/.claude/settings.json" '{"Notification": [{"matcher": "mine", "hooks": []}]}' 4
|
|
219
|
+
install "$W"; install "$W" # the wizard run twice: .prewizard now holds the first run's FH hooks
|
|
220
|
+
detach "$W" --apply >/dev/null
|
|
221
|
+
chk "Q1 a user group with an empty hook list survives" "$(grep -c '"matcher": "mine"' "$W/hub/.claude/settings.json")" 1
|
|
222
|
+
chk "Q2 after two installs no .prewizard is left behind" "$(ls "$W/hub/.claude/" | grep -c prewizard)" 0
|
|
223
|
+
W="$T/w11"; mkworld "$W"; install "$W"
|
|
224
|
+
rm "$W/hub/.claude/rules/local_fh_context.md" # a partial apply removed the copy but not its exclude line
|
|
225
|
+
detach "$W" --apply >/dev/null
|
|
226
|
+
chk "Q3 rerun after a partial apply still drops the exclude line" "$(grep -c local_fh_context "$W/hub/.git/info/exclude")" 0
|
|
227
|
+
W="$T/w12"; mkworld "$W"; mv "$W/hub" "$W/my hub"
|
|
228
|
+
( cd "$W/my hub" && env HOME="$W/home" FH_DIR="$W/my hub" CC_HUB_DIR="$W/my hub" FH_WIZARD_ZSHRC_CONSENT=Y FH_WIZARD_GATE_CONSENT=Y bash "$T/step4.sh" ) > "$W/step4.out" 2>&1
|
|
229
|
+
chk "Q4 a project name with a space gets one sentinel, named whole" "$(ls "$W/home/.cc_sentinels" | tr '\n' '|')/$(ls "$W/my hub" | grep -c _wizard_done)" "my hub_wizard_done|/0"
|
|
230
|
+
( cd "$W/my hub" && python3 "$DETACH" --project "$W/my hub" --fh-dir "$W/my hub" --home "$W/home" --apply ) > "$W/detach.out" 2>&1
|
|
231
|
+
chk "Q4b … and detach removes it" "$([ -d "$W/home/.cc_sentinels" ] && echo present || echo gone)" gone
|
|
232
|
+
W="$T/w13"; mkworld "$W"; install "$W"
|
|
233
|
+
chk "Q5 a write between plan and apply is not overwritten (LEFT instead)" "$(python3 "$T/race.py" "$DETACH" "$W")" "late=1 left=1"
|
|
234
|
+
|
|
235
|
+
echo "── G: the wizard's 4-axis gate block needs explicit consent ──"
|
|
236
|
+
W="$T/w5"; mkworld "$W"; install "$W" unset
|
|
237
|
+
chk "G1 FH_WIZARD_GATE_CONSENT unset → hooksPath not set" "$(git -C "$W/hub" config --get core.hooksPath || echo unset)" unset
|
|
238
|
+
chk "G1b … and it says SKIPPED" "$(grep -c '4-axis pre-commit gate: SKIPPED' "$W/step4.out")" 1
|
|
239
|
+
|
|
240
|
+
echo "── P: plugin uninstall ──"
|
|
241
|
+
W="$T/w6"; mkworld "$W"; mkdir -p "$T/bin"
|
|
242
|
+
printf '#!/bin/sh\necho "$@" >> "%s/claude.argv"\n' "$T" > "$T/bin/claude"; chmod +x "$T/bin/claude"
|
|
243
|
+
PATH="$T/bin:$PATH" detach "$W" --apply --plugin >/dev/null
|
|
244
|
+
chk "P1 --plugin uninstalls fh-meta and removes the marketplace" "$(cat "$T/claude.argv" 2>/dev/null | tr '\n' '|')" "plugin uninstall fh-meta@forge-harness|plugin marketplace remove forge-harness|"
|
|
245
|
+
|
|
246
|
+
echo "── W: wiring ──"
|
|
247
|
+
chk "W1 package.json ships fh_detach.py" "$(grep -c '"scripts/fh_detach.py"' "$ROOT/package.json")" 1
|
|
248
|
+
chk "W2 install-wizard SKILL.md points at the detach command" "$(grep -q 'scripts/fh_detach.py" --project . --apply' "$ROOT/plugins/fh-meta/skills/install-wizard/SKILL.md" && echo yes)" yes
|
|
249
|
+
|
|
250
|
+
echo
|
|
251
|
+
echo "fh_detach lanes: $pass passed · $fail failed"
|
|
252
|
+
[ "$fail" -eq 0 ]
|
|
@@ -72,7 +72,9 @@ echo " ── ①-c peer 스캔: claude-agents 스코프 ──"
|
|
|
72
72
|
CC="$D/session_close_check.sh"
|
|
73
73
|
if [ -f "$CC" ]; then
|
|
74
74
|
a=$(CLAUDE_CODE_CHILD_SESSION=1 bash "$CC" 2>/dev/null | grep -cE '^[^[:space:]]+ +①-c' || true)
|
|
75
|
-
|
|
75
|
+
# 아래 ①-g 팔이 읽는다 — 체커가 스텁을 «안 불렀다» 와 «가리고 진짜를 불렀다» 는 다르다.
|
|
76
|
+
_CCOUT="$(env -u CLAUDE_CODE_CHILD_SESSION -u CLAUDE_CODE_AGENT bash "$CC" 2>/dev/null || true)"
|
|
77
|
+
b=$(printf '%s\n' "$_CCOUT" | grep -cE '^[^[:space:]]+ +①-c' || true)
|
|
76
78
|
c=$(env -u CLAUDE_CODE_CHILD_SESSION -u CLAUDE_CODE_AGENT FH_PEER_SCAN_FORCE=1 bash "$CC" 2>/dev/null | grep -cE '^[^[:space:]]+ +①-c' || true)
|
|
77
79
|
[ "$a" -gt 0 ] && ok "자식 세션 → ①-c 뜬다" || ng "자식 세션인데 ①-c 없음"
|
|
78
80
|
[ "$b" -eq 0 ] && ok "톱레벨(env 부재 시뮬) → 침묵 (솔로 세션 나그 금지)" || ng "env 부재인데 ①-c 떴다"
|
|
@@ -84,7 +86,19 @@ fi
|
|
|
84
86
|
|
|
85
87
|
if [ -f "$CC" ]; then
|
|
86
88
|
lane_stub_env_used gh && ok "lane_stub_env: gh 스텁 선택 확인(FH_LANE_STUB=off 면 해당 없음)" || ng "lane_stub_env: gh 스텁 미사용 — PATH 가림"
|
|
87
|
-
|
|
89
|
+
# 🟥 «스텁이 안 불렸다» 의 원인이 둘이고, 초판은 둘을 한 문장으로 접어 **거짓 진단**을 냈다.
|
|
90
|
+
# 2026-10-19 클린룸 감사 실측: 깃 없는 소비자 타르볼에서 이 스위트가 재현성 있게 빨갛고
|
|
91
|
+
# (깃 트리 두 곳은 초록) 메시지가 「진짜 스캐너가 돌았다」였다. 실제로는 체커 자신이
|
|
92
|
+
# «①-g stale-ref: git 없음/비-레포 — 대상 목록을 못 만들었다. UNMEASURED» 를 찍고
|
|
93
|
+
# 스캐너를 **아예 안 불렀다**. 즉 가림이 아니라 미측정이고, 「진짜가 돌았다」는 거짓이다.
|
|
94
|
+
# ⇒ 체커 자신의 출력으로 가른다(기록의 속성을 보는 것이지 결론을 보는 게 아니다).
|
|
95
|
+
if lane_stub_env_used stale-ref; then
|
|
96
|
+
ok "lane_stub_env: ①-g 스텁 선택 확인(FH_LANE_STUB=off 면 해당 없음)"
|
|
97
|
+
elif printf '%s\n' "${_CCOUT:-}" | grep -q '①-g stale-ref: git 없음/비-레포'; then
|
|
98
|
+
ok "lane_stub_env: ①-g 는 체커가 UNMEASURED 를 선언해 스캐너를 안 불렀다 — 미측정(통과 아님), 가림 아님"
|
|
99
|
+
else
|
|
100
|
+
ng "lane_stub_env: ①-g 스텁 미사용 — PATH 가림(진짜 스캐너가 돌았다)"
|
|
101
|
+
fi
|
|
88
102
|
fi
|
|
89
103
|
|
|
90
104
|
echo
|
|
@@ -269,7 +269,7 @@ else
|
|
|
269
269
|
python3 - "$SUT" "$MUTP" <<'PY'
|
|
270
270
|
import io, sys
|
|
271
271
|
src = io.open(sys.argv[1], encoding='utf-8').read()
|
|
272
|
-
old = '
|
|
272
|
+
old = ' case "$_TRACKED_NL" in *$\'\\n\'"$1"$\'\\n\'*) return 0;; *) return 1;; esac'
|
|
273
273
|
new = ' printf \'%s\\n\' "$_TRACKED" | grep -qxF "$1"'
|
|
274
274
|
if src.count(old) != 1:
|
|
275
275
|
sys.stderr.write("SUBN=%d\n" % src.count(old)); sys.exit(3)
|
|
@@ -287,6 +287,60 @@ PY
|
|
|
287
287
|
fi
|
|
288
288
|
rm -rf "$BIG"
|
|
289
289
|
|
|
290
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
291
|
+
# L-glob — 🟥 `case "$_TRACKED_NL"` 전환 시 경로의 글로브 문자(`[`, `]`, `*`, `?`)가 패턴이 아닌
|
|
292
|
+
# 리터럴로 매치돼야 한다(`"$1"` 인용 필수). 인용이 빠지면:
|
|
293
|
+
# ① tracked 인 `shipped_[v1].md` 는 패턴 `[v1]` 이 리터럴 `[v1]` 과 불일치해 동봉 파일로 안 읽히고,
|
|
294
|
+
# ② untracked 인 근접 경로(`harness_bench_[i]ssue_monitor.md` 등)나 `[v1]` 문자클래스 전개(`shipped_v.md`)가
|
|
295
|
+
# 동봉 파일과 오매치될 수 있다.
|
|
296
|
+
printf '# bracket\n' > "$BR/tracks/_meta/shipped_[v1].md"
|
|
297
|
+
printf '# star\n' > "$BR/tracks/_meta/shipped_*.md"
|
|
298
|
+
git -C "$BR" add -f "tracks/_meta/shipped_[v1].md" "tracks/_meta/shipped_*.md" >/dev/null 2>&1
|
|
299
|
+
git -C "$BR" -c user.email=t@t -c user.name=t commit -q -m ship-glob 2>/dev/null
|
|
300
|
+
v=$(_bv "$BR")
|
|
301
|
+
[ "$v" = "new" ] \
|
|
302
|
+
&& ok "L-glob tracked paths containing '[' or '*' are still recognised as shipped (got new)" \
|
|
303
|
+
|| ng "L-glob tracked path with '[' or '*' misread as user-made (got '$v' — missing quoting on \"\$1\"?)"
|
|
304
|
+
|
|
305
|
+
printf '# near-miss class\n' > "$BR/tracks/_meta/shipped_v.md"
|
|
306
|
+
printf '# near-miss pattern\n' > "$BR/tracks/_meta/harness_bench_[i]ssue_monitor.md"
|
|
307
|
+
_g_out=$( cd "$BR" && bash scripts/mapped_tracks.sh 2>&1 )
|
|
308
|
+
_g_sess=$(printf '%s\n' "$_g_out" | sed -n 's/^session_files=//p')
|
|
309
|
+
_g_br=$(printf '%s\n' "$_g_out" | sed -n 's/^onboarding_branch=//p')
|
|
310
|
+
[ "$_g_sess" = "2" ] && [ "$_g_br" = "returning" ] \
|
|
311
|
+
&& ok "L-glob control — untracked near-miss paths are NOT recognised as shipped (session_files=$_g_sess · $_g_br)" \
|
|
312
|
+
|| ng "L-glob control — untracked near-miss path was swallowed as shipped (session_files=$_g_sess branch=$_g_br)"
|
|
313
|
+
rm -f "$BR/tracks/_meta/shipped_v.md" "$BR/tracks/_meta/harness_bench_[i]ssue_monitor.md"
|
|
314
|
+
|
|
315
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
316
|
+
# L-fork — 🟥 파일 수에 비례하는 fork 가 없어야 한다(온보딩 지연 7~12s 의 원인, 2026-10-23 실측).
|
|
317
|
+
# grep · basename 을 세는 심(shim)을 PATH 앞에 두고 untracked 200개 위에서 돌린다. 수정판은 상수 회,
|
|
318
|
+
# 뮤턴트(here-string grep 복원)는 파일마다 1회 이상 → 이 레인이 «빨라짐» 의 기계 앵커다(codex: L-glob 은
|
|
319
|
+
# 옛 grep 에서도 초록이라 fork 제거를 증명하지 못한다).
|
|
320
|
+
SHIM="$(mktemp -d)"; CNT="$SHIM/count"; : > "$CNT"
|
|
321
|
+
for _t in grep basename; do
|
|
322
|
+
_real=$(command -v "$_t")
|
|
323
|
+
printf '#!/bin/bash\necho %s >> "%s"\nexec "%s" "$@"\n' "$_t" "$CNT" "$_real" > "$SHIM/$_t"; chmod +x "$SHIM/$_t"
|
|
324
|
+
done
|
|
325
|
+
for _i in $(seq 1 200); do printf '# u\n' > "$BR/tracks/_meta/u_$_i.md"; done
|
|
326
|
+
( cd "$BR" && PATH="$SHIM:$PATH" bash scripts/mapped_tracks.sh >/dev/null 2>&1 )
|
|
327
|
+
_n=$(wc -l < "$CNT" | tr -d ' ')
|
|
328
|
+
[ "$_n" -lt 50 ] \
|
|
329
|
+
&& ok "L-fork 200 files → grep/basename calls $_n (< 50, not per file)" \
|
|
330
|
+
|| ng "L-fork 200 files → grep/basename calls $_n — forks per file again"
|
|
331
|
+
sed 's|case "\$_TRACKED_NL" in \*\$'"'"'\\n'"'"'"\$1"\$'"'"'\\n'"'"'\*) return 0;; \*) return 1;; esac|grep -qxF "$1" <<<"$_TRACKED"|' \
|
|
332
|
+
"$BR/scripts/mapped_tracks.sh" > "$BR/scripts/mapped_tracks_fork_mut.sh"
|
|
333
|
+
if cmp -s "$BR/scripts/mapped_tracks.sh" "$BR/scripts/mapped_tracks_fork_mut.sh"; then
|
|
334
|
+
ng "L-fork revert — 뮤턴트 생성 실패(치환 대상 부재). HARNESS ERROR, 초록으로 안 읽는다"
|
|
335
|
+
else
|
|
336
|
+
: > "$CNT"; ( cd "$BR" && PATH="$SHIM:$PATH" bash scripts/mapped_tracks_fork_mut.sh >/dev/null 2>&1 )
|
|
337
|
+
_m=$(wc -l < "$CNT" | tr -d ' ')
|
|
338
|
+
[ "$_m" -ge 200 ] \
|
|
339
|
+
&& ok "L-fork revert — here-string grep 을 되돌리면 호출이 $_m 회로 늘어난다(레인이 결함에 결박됨)" \
|
|
340
|
+
|| ng "L-fork revert — 뮤턴트도 $_m 회 — 이 레인은 fork 를 재지 못한다"
|
|
341
|
+
fi
|
|
342
|
+
rm -f "$BR"/tracks/_meta/u_*.md "$BR/scripts/mapped_tracks_fork_mut.sh"; rm -rf "$SHIM"
|
|
343
|
+
|
|
290
344
|
if [ "$FAIL" -eq 0 ]; then
|
|
291
345
|
echo "MAPPED-TRACKS LANES: PASS ($PASS/$PASS)"
|
|
292
346
|
echo " NOT covered: whether the synergy skill (or any other consumer) actually CALLS this."
|