@chrono-meta/fh-gate 3.30.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/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/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 +56 -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 +16 -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-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/selfcheck.sh +83 -6
- package/scripts/test_abstract_consult_check_lanes.sh +201 -0
- package/scripts/test_fh_detach_lanes.sh +252 -0
- package/scripts/test_mutation_probe_lanes.sh +68 -8
- package/scripts/test_ollama_panel_lanes.sh +107 -11
- package/scripts/test_selfcheck_state_lanes.sh +73 -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 ]
|
|
@@ -159,6 +159,17 @@ procs_matching() { # count live processes whose WHOLE cmdline is $1 — /proc,
|
|
|
159
159
|
for c in /proc/[0-9]*/cmdline; do [ -e "$c" ] || continue; [ "$(tr '\0' ' ' < "$c" 2>/dev/null)" = "$1 " ] && n=$((n+1)); done
|
|
160
160
|
echo "$n"
|
|
161
161
|
}
|
|
162
|
+
# The counter is exact per cmdline but its SCOPE is the whole machine: /proc is not scoped to a
|
|
163
|
+
# checkout, so a fixture named `sleep 4747` is a name two runs can both claim. Measured 2026-10-26:
|
|
164
|
+
# this suite and three others went red only under concurrent load and passed 3/3 standalone in both
|
|
165
|
+
# trees — two copies in DIFFERENT trees each counted the other's live fixtures, so N6/S7-5 ("no
|
|
166
|
+
# orphan is left running") saw the sibling's healthy, about-to-be-killed sleep and called it an
|
|
167
|
+
# orphan. Nothing was broken in the subject; the lanes were reading each other.
|
|
168
|
+
# The fix is to make the fixture's name unique to THIS run. A fractional suffix keeps the cmdline
|
|
169
|
+
# exactly matchable (`sleep 4747.12345` is one argv word) while making the token un-shareable.
|
|
170
|
+
# $$ is unique among live processes and $RANDOM breaks the PID-reuse case; digits only, one dot.
|
|
171
|
+
_PSFX="$$${RANDOM}"
|
|
172
|
+
TOK_N6="4747.$_PSFX"; TOK_K0="4646.$_PSFX"; TOK_S75="4848.$_PSFX"
|
|
162
173
|
if [ -d /proc/self ]; then HAVE_PROC=1; else HAVE_PROC=0; fi
|
|
163
174
|
|
|
164
175
|
# B4 — the baseline lane writes its own subject: refuse, and leave the ORIGINAL bytes
|
|
@@ -227,12 +238,12 @@ out=$(python3 "$PROBE" lat.sh lane_weak.sh 2>&1); rc=$?
|
|
|
227
238
|
[ "$rc" -eq 2 ] && grep -q 'not UTF-8' <<<"$out" ; chk $? "N5 non-UTF-8 subject → 2 with the reason (v1: traceback rc 1)"
|
|
228
239
|
|
|
229
240
|
# N6 — no orphan keeps running a mutant after a timeout
|
|
230
|
-
printf '. ./n1.sh\nis_adult 19 && exit 0\n( touch n6.started; exec sleep
|
|
241
|
+
printf '. ./n1.sh\nis_adult 19 && exit 0\n( touch n6.started; exec sleep %s ) &\nwait\n' "$TOK_N6" > lane_n6.sh
|
|
231
242
|
rm -f n6.started
|
|
232
243
|
out=$(python3 "$PROBE" n1.sh lane_n6.sh --timeout 2 2>&1)
|
|
233
244
|
sleep 0.5
|
|
234
245
|
if [ "$HAVE_PROC" -eq 1 ]; then
|
|
235
|
-
[ -e n6.started ] && grep -q 'TIMEOUT' <<<"$out" && [ "$(procs_matching
|
|
246
|
+
[ -e n6.started ] && grep -q 'TIMEOUT' <<<"$out" && [ "$(procs_matching "sleep $TOK_N6")" -eq 0 ] ; chk $? "N6 the timed-out lane's grandchildren are killed with its process group (counted via /proc — v6 used pgrep, vacuous when absent)"
|
|
236
247
|
else
|
|
237
248
|
echo " ⚠️ N6 UNMEASURED — no /proc"; UNMEASURED=$((UNMEASURED+1))
|
|
238
249
|
fi
|
|
@@ -554,8 +565,16 @@ out=$(python3 "$PROBE" z28.sh --list 2>&1)
|
|
|
554
565
|
! grep -qF '==' <<<"$out" && grep -qF '[=→!=]' <<<"$out" ; chk $? "Z28 #!/bin/sh: '!=' is not flipped to the non-POSIX '==' (= → != still is)"
|
|
555
566
|
|
|
556
567
|
if [ "$HAVE_PROC" -eq 1 ]; then # the process counter itself, on a known pair, before any lane trusts it
|
|
557
|
-
sleep
|
|
568
|
+
sleep "$TOK_K0" & kp=$!; sleep 0.1; k1=$(procs_matching "sleep $TOK_K0"); kill "$kp"; wait "$kp" 2>/dev/null; k0=$(procs_matching "sleep $TOK_K0")
|
|
558
569
|
[ "$k1" -eq 1 ] && [ "$k0" -eq 0 ] ; chk $? "K0 the /proc process counter sees a live sleep (1) and not a dead one (0) — and not itself"
|
|
570
|
+
# K1 (2026-10-26) — the token must be unique to this run, not merely exact. Known pair against a
|
|
571
|
+
# live FOREIGN process carrying the old shared name: the thing a concurrent sibling used to be.
|
|
572
|
+
sleep 4747 & kf=$!; sleep 0.1
|
|
573
|
+
[ "$(procs_matching 'sleep 4747')" -ge 1 ] ; chk $? "K1a known-POSITIVE: the OLD shared token does count a foreign process (the collision was real)"
|
|
574
|
+
[ "$(procs_matching "sleep $TOK_N6")" -eq 0 ] ; chk $? "K1b known-NEGATIVE: this run's unique token does not count it — N6/S7-5 cannot read a sibling's fixtures"
|
|
575
|
+
kill "$kf" 2>/dev/null; wait "$kf" 2>/dev/null
|
|
576
|
+
# And the three tokens must differ from each other, or one lane's fixture answers another's count.
|
|
577
|
+
[ "$TOK_N6" != "$TOK_K0" ] && [ "$TOK_K0" != "$TOK_S75" ] && [ "$TOK_N6" != "$TOK_S75" ] ; chk $? "K1c the three fixture tokens are distinct within a run"
|
|
559
578
|
fi
|
|
560
579
|
echo "── S7: v7 safety contract — each lane red on v6 (2026-10-08, from the v6 capture-recapture detectors)"
|
|
561
580
|
|
|
@@ -592,10 +611,10 @@ out=$(python3 "$PROBE" s74.sh lane_s74.sh --timeout 30 2>&1); rc=$?
|
|
|
592
611
|
# S7-5 — a setsid escapee is killed (Linux subreaper); unmeasurable without /proc → UNMEASURED, never PASS
|
|
593
612
|
if [ "$HAVE_PROC" -eq 1 ] && command -v setsid >/dev/null 2>&1; then
|
|
594
613
|
cp age.sh s75.sh; rm -f s75.started
|
|
595
|
-
printf '. ./s75.sh\nsetsid sh -c "touch s75.started; exec sleep
|
|
614
|
+
printf '. ./s75.sh\nsetsid sh -c "touch s75.started; exec sleep %s" </dev/null >/dev/null 2>&1 &\nsleep 0.3\nis_adult 20 || exit 1\nis_adult 19 || exit 1\nexit 0\n' "$TOK_S75" > lane_s75.sh
|
|
596
615
|
out=$(python3 "$PROBE" s75.sh lane_s75.sh --timeout 30 2>&1)
|
|
597
616
|
sleep 0.3
|
|
598
|
-
[ -e s75.started ] && grep -qE 'mutants=1 ' <<<"$out" && [ "$(procs_matching
|
|
617
|
+
[ -e s75.started ] && grep -qE 'mutants=1 ' <<<"$out" && [ "$(procs_matching "sleep $TOK_S75")" -eq 0 ] ; chk $? "S7-5 a setsid descendant of the lane does not outlive the probe (v6: it kept running with the mutant)"
|
|
599
618
|
else
|
|
600
619
|
echo " ⚠️ S7-5 UNMEASURED — no /proc or no setsid"; UNMEASURED=$((UNMEASURED+1))
|
|
601
620
|
fi
|
|
@@ -679,13 +698,32 @@ for k in $(seq 2 12000); do printf '[ "$a" -eq %d ] && echo x%d\n' "$k" "$k"; do
|
|
|
679
698
|
printf 'grep -q "exit 113" r71.sh && exit 1\nexit 0\n' > lane_r71.sh
|
|
680
699
|
cp r71.orig r71.sh
|
|
681
700
|
_ms(){ python3 -c 'import time; print(int(time.time() * 1000))'; } # BSD date has no %N
|
|
682
|
-
c71=$(_ms); h71=""
|
|
701
|
+
c71=$(_ms); h71=""; _c71out=""
|
|
683
702
|
while IFS= read -r l; do
|
|
703
|
+
_c71out="$_c71out$l
|
|
704
|
+
"
|
|
684
705
|
case "$l" in subject:*) [ -n "$h71" ] || h71=$(( $(_ms) - c71 )) ;; esac
|
|
685
706
|
done < <(python3 "$PROBE" r71.sh lane_r71.sh --max 1 --timeout 30 2>&1)
|
|
686
707
|
cmp -s r71.sh r71.orig || cp r71.orig r71.sh
|
|
687
|
-
# no header = the calibration run never reached the lock: the delay is unknown
|
|
688
|
-
#
|
|
708
|
+
# no header = the calibration run never reached the lock: the delay is unknown.
|
|
709
|
+
# 🟥 2026-10-26: that used to be ONE outcome — the lane ran anyway with d71=0 and went red. Measured
|
|
710
|
+
# here, the common cause is not a defect in the probe at all: the probe's state directory
|
|
711
|
+
# /tmp/mutation_probe-$uid is MACHINE-GLOBAL and its inode key is (st_dev, st_ino), so a fixture this
|
|
712
|
+
# suite creates fresh can land on an inode whose backup an EARLIER run left behind (the suite's own
|
|
713
|
+
# kill/timeout lanes leave backups by design — 26 of them after one round of runs in this container).
|
|
714
|
+
# The probe then answers `CANNOT JUDGE: a previous run left a backup …` BEFORE printing the header,
|
|
715
|
+
# the calibration is unknown, and this lane called that a FAILURE. It is not: it is UNMEASURED, which
|
|
716
|
+
# is neither a pass nor a fail, and the suite already has that counter. Any OTHER reason for a
|
|
717
|
+
# missing header still falls through to the old behaviour — the point is a typed verdict, not a
|
|
718
|
+
# looser one. The aliasing itself lives in scripts/mutation_probe.py (the subject, and the recovery
|
|
719
|
+
# path for a subject's original bytes) and is a NAMED RESIDUAL here, not something a lane may patch.
|
|
720
|
+
if [ -z "$h71" ] && grep -q 'a previous run left a backup' <<<"$_c71out"; then
|
|
721
|
+
echo " ⚠️ R7-1 UNMEASURED — the probe refused the calibration run: a previous run's backup is still in"
|
|
722
|
+
echo " the machine-global state dir and its inode key aliases this fixture. Not a pass, not a failure."
|
|
723
|
+
printf ' %s\n' "$(grep -m1 'a previous run left a backup' <<<"$_c71out")"
|
|
724
|
+
echo " Inspect those backups, restore anything real by hand, remove them, then re-run."
|
|
725
|
+
UNMEASURED=$((UNMEASURED+1))
|
|
726
|
+
else
|
|
689
727
|
[ -n "$h71" ] || echo " ⚠️ R7-1 calibration: no «subject:» header — time-to-lock unknown on this machine"
|
|
690
728
|
d71=$(awk -v ms="${h71:-0}" 'BEGIN { printf "%.3f", ms / 2000 }')
|
|
691
729
|
sed '2s/-ne 1/-eq 1/' r71.orig > r71.sh # the other probe's mutant is live
|
|
@@ -693,6 +731,28 @@ python3 "$PROBE" r71.sh lane_r71.sh --max 1 --timeout 30 > r71.out 2>&1 & pb=$!
|
|
|
693
731
|
sleep "$d71"; cat r71.orig > r71.sh # … and now it restores (same inode)
|
|
694
732
|
wait "$pb"; rc=$?
|
|
695
733
|
grep -q 'changed between reading it and locking it' r71.out && [ "$rc" -eq 2 ] && cmp -s r71.sh r71.orig && [ ! -e "$(bkpath r71.sh)" ] ; chk $? "R7-1 a subject that changed between read and lock → 2, the original stays (fbfe773: the stale mutant was backed up as «original» and written back)"
|
|
734
|
+
fi
|
|
735
|
+
|
|
736
|
+
# R7-1b (2026-10-26) — the known pair for the UNMEASURED arm above. The claim it rests on is that a
|
|
737
|
+
# leftover backup under either key makes the probe refuse BEFORE it prints its header; if that is not
|
|
738
|
+
# true, the arm above is an excuse rather than a verdict. Measured both ways on a throwaway subject,
|
|
739
|
+
# and the planted file is removed in the same lane (it is a 52-byte fixture, not anyone's recovery data).
|
|
740
|
+
cp age.sh r71b.sh
|
|
741
|
+
_r71b_bk="$(ibkpath r71b.sh)"
|
|
742
|
+
mkdir -p "$(dirname "$_r71b_bk")" 2>/dev/null
|
|
743
|
+
if [ -e "$_r71b_bk" ]; then
|
|
744
|
+
echo " ⚠️ R7-1b UNMEASURED — a backup is already at $_r71b_bk; this lane will not touch someone else's"
|
|
745
|
+
UNMEASURED=$((UNMEASURED+1))
|
|
746
|
+
else
|
|
747
|
+
cp age.sh "$_r71b_bk"
|
|
748
|
+
out=$(python3 "$PROBE" r71b.sh lane_weak.sh --max 1 --timeout 30 2>&1); rc=$?
|
|
749
|
+
[ "$rc" -eq 2 ] && grep -q 'a previous run left a backup' <<<"$out" && ! grep -q '^subject:' <<<"$out"
|
|
750
|
+
chk $? "R7-1b known-POSITIVE: a leftover backup at the INODE key makes the probe refuse before its header (so a missing header is UNMEASURED, not a lane failure)"
|
|
751
|
+
rm -f "$_r71b_bk"
|
|
752
|
+
out=$(python3 "$PROBE" r71b.sh lane_weak.sh --max 1 --timeout 30 2>&1); rc=$?
|
|
753
|
+
grep -q '^subject:' <<<"$out"
|
|
754
|
+
chk $? "R7-1b known-NEGATIVE: with the leftover gone, the same subject reaches the header (the refusal was the backup, not the subject)"
|
|
755
|
+
fi
|
|
696
756
|
cp r71.orig r71.sh
|
|
697
757
|
|
|
698
758
|
# R7-2 — the lane hard-links an unrelated file to the subject's path: that file is never written
|