@chrono-meta/fh-gate 3.28.0 → 3.30.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/CHEATSHEET.md +2 -2
- package/CLAUDE.md +5 -2
- package/docs/REFERENCE.md +4 -1
- package/knowledge/shared/harness-core/claude_md_full_reference.md +2 -0
- package/knowledge/shared/harness-core/claude_md_gate_details.md +8 -1
- package/knowledge/shared/harness-core/dispatch_conditional_prohibition.md +12 -0
- package/knowledge/shared/harness-core/fh_three_layer_canon.md +12 -0
- package/knowledge/shared/harness-core/measurement-integrity-checklist.md +16 -0
- package/knowledge/shared/learnings/subagent_invocations_log.yaml +161 -0
- package/package.json +4 -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 +41 -0
- package/plugins/fh-meta/skills/auto-decorrelation/SKILL.md +17 -0
- package/plugins/fh-meta/skills/phantom-quench/SKILL.md +1 -1
- package/plugins/fh-meta/skills/sim-conductor/SKILL.md +2 -2
- package/plugins/fh-meta/skills/sim-conductor/SKILL_detail.md +3 -3
- package/plugins/fh-meta/skills/steel-quench/SKILL.md +25 -1
- package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
- package/scripts/degrade_direction_scan.sh +43 -0
- package/scripts/dispatch_receipt.py +185 -0
- package/scripts/doc_claim_triad_scan.py +43 -4
- package/scripts/fh-gate.sh +71 -11
- package/scripts/finding_fleet.sh +15 -3
- package/scripts/mapped_tracks.sh +20 -13
- package/scripts/memory_gc_report.py +55 -5
- package/scripts/package_coverage_check.sh +5 -0
- package/scripts/pr_merge_verified.sh +56 -8
- package/scripts/selfcheck.sh +43 -20
- package/scripts/session_checklist.py +158 -14
- 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_degrade_scan_shell_probes.sh +81 -0
- package/scripts/test_dispatch_receipt_lanes.sh +95 -0
- package/scripts/test_doc_claim_triad_lanes.sh +30 -0
- package/scripts/test_fh_audit_check_lanes.sh +10 -5
- package/scripts/test_fh_gate_regressions.sh +71 -1
- package/scripts/test_finding_pipeline_lanes.sh +83 -0
- package/scripts/test_hook_source_gate_lanes.sh +16 -2
- package/scripts/test_locale_invariance_lanes.sh +19 -0
- 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 +40 -8
- 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 +32 -0
- package/scripts/test_session_checklist_lanes.sh +172 -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/PRE-PUBLISH-CHECKLIST.md +10 -0
- package/templates/degrade_direction_scan.sh +43 -0
|
@@ -532,6 +532,67 @@ fh_timeout() {
|
|
|
532
532
|
OUTDIR="${OUTDIR:-$(mktemp -d "${TMPDIR:-/tmp}/fh-sim-XXXXXX")}"
|
|
533
533
|
mkdir -p "$OUTDIR"
|
|
534
534
|
|
|
535
|
+
# ── ancestor-instruction guard (2026-10-23) ───────────────────────────────────────────────────────
|
|
536
|
+
# 🟥 Every arm's clone lives under $OUTDIR, and `claude -p` loads CLAUDE.md / CLAUDE.local.md / .claude/rules
|
|
537
|
+
# from EVERY ancestor of its cwd. An --out inside a checkout (e.g. tracks/_meta/<exp>/out) therefore hands
|
|
538
|
+
# every arm the LIVE repo's instructions on top of the clone's own — measured 2026-10-23 with a known pair:
|
|
539
|
+
# under the FH checkout 3 instruction files, under /private/tmp NONE. A whole experiment series
|
|
540
|
+
# (P8/P8b/P9) ran that way; agents then edited the live repos by absolute path. Refuse before any arm
|
|
541
|
+
# starts (and again per rep for the wrapper the clone actually lands in — a pre-existing w_* can carry
|
|
542
|
+
# its own CLAUDE.md, codex R1). A bare .git is NOT an instruction source and is not refused (codex R1).
|
|
543
|
+
# FH_SIM_ALLOW_INHERIT=1 is the logged override for a run that WANTS the inheritance.
|
|
544
|
+
# --out is resolved to an absolute physical path once, so the walk below and every later `$OUTDIR/...`
|
|
545
|
+
# (including redirects made from inside `cd "$WORK"`) see the same place (Gemini R1: relative --out,
|
|
546
|
+
# logical vs physical symlink paths). An unresolvable --out stops here instead of looping on `dirname ""`.
|
|
547
|
+
OUTDIR=$(cd "$OUTDIR" 2>/dev/null && pwd -P) || { echo "FAIL: --out could not be resolved" >&2; exit 2; }
|
|
548
|
+
[ -n "$OUTDIR" ] || { echo "FAIL: --out resolved to an empty path" >&2; exit 2; }
|
|
549
|
+
# 🟥 사용자 설정 디렉터리(${CLAUDE_CONFIG_DIR:-$HOME/.claude})는 모든 팔이 어차피 싣는다 — 워크가 그 .claude 의 부모(보통 $HOME)에
|
|
550
|
+
# 닿았을 때 그 안의 CLAUDE.md/CLAUDE.local.md/AGENTS.md/rules 는 hit 가 아니다(아래 정보 줄이 한 번 찍는다). $HOME 에 직접 놓인
|
|
551
|
+
# CLAUDE.md 는 여전히 hit. 물리 경로(pwd -P)로 비교해 심볼릭 HOME/설정 디렉터리도 같게 동작한다.
|
|
552
|
+
_user_cfg="${CLAUDE_CONFIG_DIR:-$HOME/.claude}"
|
|
553
|
+
_user_cfg_phys=$(cd "$_user_cfg" 2>/dev/null && pwd -P) || _user_cfg_phys=""
|
|
554
|
+
FH_SIM_REPORTED_HITS=" " # 이미 경고한 hit — --reps N 에서 같은 경고를 매 rep 반복하지 않는다
|
|
555
|
+
fh_sim_instr_hits() { # $1=absolute dir → prints instruction sources in $1 and every ancestor (space-separated)
|
|
556
|
+
local d="$1" n hits="" skipclaude cp
|
|
557
|
+
while [ -n "$d" ]; do
|
|
558
|
+
skipclaude=0
|
|
559
|
+
if [ -n "$_user_cfg_phys" ] && [ -d "$d/.claude" ]; then
|
|
560
|
+
cp=$(cd "$d/.claude" 2>/dev/null && pwd -P) && [ "$cp" = "$_user_cfg_phys" ] && skipclaude=1
|
|
561
|
+
fi
|
|
562
|
+
for n in CLAUDE.md CLAUDE.local.md .claude/CLAUDE.md .claude/CLAUDE.local.md AGENTS.md .claude/AGENTS.md; do # not GEMINI.md: Claude does not load it (codex R2)
|
|
563
|
+
case "$n" in .claude/*) [ "$skipclaude" = 1 ] && continue ;; esac
|
|
564
|
+
[ -e "$d/$n" ] && hits="$hits $d/$n"
|
|
565
|
+
done
|
|
566
|
+
if [ "$skipclaude" = 0 ] && [ -d "$d/.claude/rules" ] && [ -n "$(find -L "$d/.claude/rules" -name '*.md' -print 2>/dev/null | head -1)" ]; then # -L: symlinked rules dirs load too (codex R2)
|
|
567
|
+
hits="$hits $d/.claude/rules/"
|
|
568
|
+
fi
|
|
569
|
+
[ "$d" = "/" ] && break
|
|
570
|
+
d=$(dirname "$d")
|
|
571
|
+
done
|
|
572
|
+
printf '%s' "$hits"
|
|
573
|
+
}
|
|
574
|
+
fh_sim_refuse_inherit() { # $1=dir $2=what → returns 0 to proceed, exits 2 on refusal
|
|
575
|
+
local hits h newhits=""; hits=$(fh_sim_instr_hits "$1")
|
|
576
|
+
[ -z "$hits" ] && return 0
|
|
577
|
+
if [ "${FH_SIM_ALLOW_INHERIT:-0}" = 1 ]; then
|
|
578
|
+
for h in $hits; do
|
|
579
|
+
case "$FH_SIM_REPORTED_HITS" in *" $h "*) ;; *) newhits="$newhits $h"; FH_SIM_REPORTED_HITS="$FH_SIM_REPORTED_HITS$h " ;; esac
|
|
580
|
+
done
|
|
581
|
+
[ -n "$newhits" ] && echo "⚠️ FH_SIM_ALLOW_INHERIT=1 — arms WILL inherit ($2):$newhits" >&2
|
|
582
|
+
return 0
|
|
583
|
+
fi
|
|
584
|
+
echo "🟥 REFUSED: $2 ($1) sits under instruction files — every arm would load them:$hits" >&2
|
|
585
|
+
echo " use an --out outside any checkout and outside \$HOME (default: mktemp under \$TMPDIR), or FH_SIM_ALLOW_INHERIT=1 if inheritance is the point" >&2
|
|
586
|
+
exit 2
|
|
587
|
+
}
|
|
588
|
+
fh_sim_refuse_inherit "$OUTDIR" "--out"
|
|
589
|
+
# User-level instructions load for every project whatever the cwd — not refused (identical for every arm),
|
|
590
|
+
# but printed so a reader of the run knows they were there (codex R1).
|
|
591
|
+
_user_instr=""
|
|
592
|
+
[ -e "$_user_cfg/CLAUDE.md" ] && _user_instr="$_user_instr $_user_cfg/CLAUDE.md"
|
|
593
|
+
[ -d "$_user_cfg/rules" ] && [ -n "$(find -L "$_user_cfg/rules" -name '*.md' -print 2>/dev/null | head -1)" ] && _user_instr="$_user_instr $_user_cfg/rules/"
|
|
594
|
+
[ -n "$_user_instr" ] && echo "ℹ️ user-level instructions load in every arm (same for all, not refused):$_user_instr" >&2
|
|
595
|
+
|
|
535
596
|
# ── machine-surface snapshot ──────────────────────────────────────────────────────────────────
|
|
536
597
|
# Enumerated, not guessed. Each line is a surface a past run actually touched or plausibly could.
|
|
537
598
|
# `not found` is written as `ABSENT`, never as an empty string — an unreadable surface and an
|
|
@@ -581,6 +642,7 @@ for r in $(seq 1 "$REPS"); do
|
|
|
581
642
|
# isolated, but their EXISTENCE leaked into the arm's reasoning, which is enough to change an
|
|
582
643
|
# answer about "what projects are around". Isolation has to hold for the parent too.
|
|
583
644
|
WRAP="$OUTDIR/w_${ARM}_r${r}"; mkdir -p "$WRAP"
|
|
645
|
+
fh_sim_refuse_inherit "$(cd "$WRAP" && pwd -P)" "rep wrapper" # a pre-existing w_* may carry its own instructions
|
|
584
646
|
WORK="$WRAP/repo"
|
|
585
647
|
# A disposable clone per REP, not per arm: two reps of the same arm contaminate each other
|
|
586
648
|
# exactly as two different arms do. That was the measured failure — reps 1 and 2 of build_cron.
|
|
@@ -95,7 +95,16 @@ CHANGELOG_WORD_RE = re.compile(_CL_WORDS, re.IGNORECASE)
|
|
|
95
95
|
#: 되므로 구조적으로 수리 불가능한 SUPERSEDED 를 영구히 낸다(적대검증 A-5: 이 레포에만 셋).
|
|
96
96
|
#: 만족 불가능한 요구는 override 를 훈련시키므로, 파일이 스스로 «이건 스냅샷이다» 라고
|
|
97
97
|
#: 말할 수단을 준다. 🟥 **파일명 추론이 아니라 «파일이 선언한 것»** 이다 — 추론은 조용히 틀린다.
|
|
98
|
-
|
|
98
|
+
#: 🟥 (2026-10-23) 선언은 **HTML 주석 안에서만**, 낱말은 **경계까지**: 산문이 마커 문법을 언급만 해도
|
|
99
|
+
#: 파일이 통째로 꺼지던 것(Argon R1 #4)과 `pinned-off` · `pinned_line` 같은 접두 일치(#2)를 닫는다.
|
|
100
|
+
PIN_MARKER_RE = re.compile(r"<!--\s*stale-ref:\s*pinned(?=\s|-->)", re.IGNORECASE)
|
|
101
|
+
#: 🟥 **줄 단위 pin (2026-10-23).** 살아 있는 문서 안에서 «v1 논문은 옛 이름을 쓴다» 처럼 옛 판을
|
|
102
|
+
#: 일부러 가리키는 한 줄 때문에 파일 전체를 pin 하면, 그 파일에 뒤에 생기는 진짜 낡은 인용까지 묻힌다.
|
|
103
|
+
#: 형식 `<!-- stale-ref: pinned-line=<id>[,<id>] -->` — **이름 붙인 id 만** 그 줄에서 기록으로 친다.
|
|
104
|
+
#: 같은 줄(표의 한 행)의 다른 DOI 는 살아 있다(Argon R1 #3). id 없는 형식 · `pinned-lines` ·
|
|
105
|
+
#: `pinned-line-disabled` 는 선언이 아니다(접두 일치는 낡은 인용을 조용히 숨긴다, codex R1). `-->`
|
|
106
|
+
#: 앞 공백은 없어도 된다(Argon R1 #1). 줄 pin 은 `pinned` 뒤가 `-` 라 파일 pin 으로 번지지 않는다(ⓕ-3).
|
|
107
|
+
LINE_PIN_RE = re.compile(r"<!--\s*stale-ref:\s*pinned-line=(\d+(?:,\d+)*)\s*-->", re.IGNORECASE)
|
|
99
108
|
|
|
100
109
|
#: 못 읽은 입력의 판별 — NUL 바이트 또는 디코드 실패율. 적대검증 S-1.
|
|
101
110
|
UNSCANNABLE_REPLACEMENT_RATIO = 0.02
|
|
@@ -143,7 +152,8 @@ def scan_body(path, lines):
|
|
|
143
152
|
for the printed snippet. `in_changelog` reflects the flag's state AFTER this line is checked for a
|
|
144
153
|
heading, so a heading line itself and everything after it (same file) are marked True."""
|
|
145
154
|
in_changelog = False
|
|
146
|
-
pinned
|
|
155
|
+
# 앞 40줄을 합쳐서 찾는다 — 주석이 `<!--` / `stale-ref: pinned` / `-->` 로 여러 줄에 걸쳐도 선언이다(codex R2)
|
|
156
|
+
pinned = bool(PIN_MARKER_RE.search("\n".join(lines[:40])))
|
|
147
157
|
sites = []
|
|
148
158
|
for i, line in enumerate(lines, 1):
|
|
149
159
|
if is_changelog_heading(line):
|
|
@@ -151,9 +161,11 @@ def scan_body(path, lines):
|
|
|
151
161
|
if pinned:
|
|
152
162
|
in_changelog = True # 스냅샷 파일 전체를 «기록» 으로 취급
|
|
153
163
|
flat = TAG_RE.sub("", line)
|
|
164
|
+
# 원문 줄에서 찾는다 — 마커가 HTML 주석이라 TAG_RE 가 지운다
|
|
165
|
+
line_pinned = {x for m in LINE_PIN_RE.finditer(line) for x in m.group(1).split(",")}
|
|
154
166
|
for m in ZID_RE.finditer(flat):
|
|
155
167
|
snippet = line.strip()[:140]
|
|
156
|
-
sites.append((i, m.group(1), snippet, in_changelog))
|
|
168
|
+
sites.append((i, m.group(1), snippet, in_changelog or m.group(1) in line_pinned))
|
|
157
169
|
return sites
|
|
158
170
|
|
|
159
171
|
|
|
@@ -355,6 +367,38 @@ def run_self_check():
|
|
|
355
367
|
got = [(r, inc) for _, r, _, inc in scan_body("x.html", pin)]
|
|
356
368
|
lane("exclude: 'stale-ref: pinned' marks the whole file a record", got == [("20397566", True)], str(got))
|
|
357
369
|
|
|
370
|
+
# ⓕ-2 줄 pin — 그 줄의 «이름 붙인 id» 만 기록, 같은 파일의 다른 인용은 살아 있다
|
|
371
|
+
lp = ['The v1 paper (Zenodo 10.5281/zenodo.20397566) cites the old name <!-- stale-ref: pinned-line=20397566 -->',
|
|
372
|
+
'cite 10.5281/zenodo.22542168 for the method']
|
|
373
|
+
got = [(r, inc) for _, r, _, inc in scan_body("x.md", lp)]
|
|
374
|
+
lane("exclude: 'pinned-line=<id>' excludes only that id on its own line",
|
|
375
|
+
got == [("20397566", True), ("22542168", False)], str(got))
|
|
376
|
+
|
|
377
|
+
# ⓕ-3 🟥 known-NEGATIVE — 앞 40줄 안의 줄 pin 이 파일 pin 으로 번지지 않는다(같은 id 가 아래 줄에 다시)
|
|
378
|
+
got = [inc for _, _, _, inc in scan_body("x.md", lp[:1] + ['later 10.5281/zenodo.20397566 again'])]
|
|
379
|
+
lane("exclude NEG: a line pin is not a file pin", got == [True, False], str(got))
|
|
380
|
+
|
|
381
|
+
# ⓕ-4 🟥 known-NEGATIVE — 선언이 아닌 것들: 긴 낱말 · id 없음 · 산문 언급 · 파일 pin 접두
|
|
382
|
+
near = ['a 10.5281/zenodo.20397566 <!-- stale-ref: pinned-line-disabled -->',
|
|
383
|
+
'b 10.5281/zenodo.20397566 <!-- stale-ref: pinned-lines=20397566 -->',
|
|
384
|
+
'c 10.5281/zenodo.20397566 <!-- stale-ref: pinned-line -->',
|
|
385
|
+
'd 10.5281/zenodo.20397566 write `stale-ref: pinned-line=20397566` to pin a line']
|
|
386
|
+
got = [inc for _, _, _, inc in scan_body("x.md", near)]
|
|
387
|
+
lane("exclude NEG: near-miss / id-less / prose markers are not line pins", got == [False] * 4, str(got))
|
|
388
|
+
for fp in ('<!-- stale-ref: pinned-off -->', '<!-- stale-ref: pinned_line -->', 'see `stale-ref: pinned` in prose'):
|
|
389
|
+
got = [inc for _, _, _, inc in scan_body("x.md", [fp, 'cite 10.5281/zenodo.20397566'])]
|
|
390
|
+
lane("exclude NEG: %r is not a file pin" % fp, got == [False], str(got))
|
|
391
|
+
|
|
392
|
+
# ⓕ-4b 여러 줄 주석의 파일 pin 도 선언이다(codex R2 — 줄마다 찾으면 놓친다)
|
|
393
|
+
got = [inc for _, _, _, inc in scan_body("x.html", ['<!--', 'stale-ref: pinned', '-->', 'cite 10.5281/zenodo.20397566'])]
|
|
394
|
+
lane("exclude: a multi-line comment file pin is honoured", got == [True], str(got))
|
|
395
|
+
|
|
396
|
+
# ⓕ-5 같은 줄 두 DOI — 이름 붙인 쪽만 빠진다 · `-->` 앞 공백 없어도 된다 · 40줄 밖에서도 된다
|
|
397
|
+
row = [''] * 60 + ['| a | 10.5281/zenodo.20397566 | 10.5281/zenodo.22542168 |<!-- stale-ref: pinned-line=20397566-->']
|
|
398
|
+
got = [(r, inc) for _, r, _, inc in scan_body("x.md", row)]
|
|
399
|
+
lane("exclude: line pin names one id of two, no space before -->, past line 40",
|
|
400
|
+
got == [("20397566", True), ("22542168", False)], str(got))
|
|
401
|
+
|
|
358
402
|
# ⓖ 🟥 못 읽은 입력 — 이 파일 자신을 바이너리로 만들어 본다(임시 파일)
|
|
359
403
|
import tempfile
|
|
360
404
|
with tempfile.NamedTemporaryFile(suffix=".bin", delete=False) as tf:
|
|
@@ -835,5 +835,86 @@ else
|
|
|
835
835
|
fi
|
|
836
836
|
rm -rf "$_s1bc"
|
|
837
837
|
|
|
838
|
+
# ── S7: `set -e` under an exit contract with its own error code, no ERR trap (fh-gate.sh, 2026-10-20) ──
|
|
839
|
+
# POS = the pre-#927 shape. CTL1 = same file with the ERR trap. CTL2 = a contract with no separate error
|
|
840
|
+
# code ("0 pass / 1 fail" — an unexpected 1 already points the safe way). POS must fire for the two
|
|
841
|
+
# zeros to be readable.
|
|
842
|
+
_s7=$(mktemp -d "${TMPDIR:-/tmp}/s7_XXXXXX")
|
|
843
|
+
cat > "$_s7/pos.sh" <<'P1'
|
|
844
|
+
#!/usr/bin/env bash
|
|
845
|
+
# Exit codes:
|
|
846
|
+
# 0 — PASS
|
|
847
|
+
# 1 — PENDING (proceed with awareness)
|
|
848
|
+
# 10 — Harness error
|
|
849
|
+
set -euo pipefail
|
|
850
|
+
F=$(mktemp "$TMPDIR/x_XXXXXX")
|
|
851
|
+
echo "FH_GATE_VERDICT: PASS"; exit 0
|
|
852
|
+
P1
|
|
853
|
+
cat > "$_s7/ctl1.sh" <<'P2'
|
|
854
|
+
#!/usr/bin/env bash
|
|
855
|
+
# Exit codes:
|
|
856
|
+
# 0 — PASS
|
|
857
|
+
# 1 — PENDING (proceed with awareness)
|
|
858
|
+
# 10 — Harness error
|
|
859
|
+
set -euo pipefail
|
|
860
|
+
trap 'exit 10' ERR
|
|
861
|
+
F=$(mktemp "$TMPDIR/x_XXXXXX")
|
|
862
|
+
echo "FH_GATE_VERDICT: PASS"; exit 0
|
|
863
|
+
P2
|
|
864
|
+
cat > "$_s7/ctl2.sh" <<'P3'
|
|
865
|
+
#!/usr/bin/env bash
|
|
866
|
+
# Exit: 0 = all assertions pass; 1 = a regression.
|
|
867
|
+
set -euo pipefail
|
|
868
|
+
run_assertions
|
|
869
|
+
P3
|
|
870
|
+
# Round-1 cross-family additions: a trap that does not exit is no guard (POS2); `set -o errexit` with an
|
|
871
|
+
# EXIT_*ERROR constant and no comment header is the same contract (POS3); a named handler that exits is a
|
|
872
|
+
# guard (CTL3).
|
|
873
|
+
cat > "$_s7/pos2.sh" <<'P4'
|
|
874
|
+
#!/usr/bin/env bash
|
|
875
|
+
# Exit codes: 0 PASS · 1 PENDING · 10 harness error
|
|
876
|
+
set -euo pipefail
|
|
877
|
+
cleanup() { rm -f "$F"; }
|
|
878
|
+
trap cleanup ERR
|
|
879
|
+
F=$(mktemp "$TMPDIR/x_XXXXXX")
|
|
880
|
+
P4
|
|
881
|
+
cat > "$_s7/pos3.sh" <<'P5'
|
|
882
|
+
#!/usr/bin/env bash
|
|
883
|
+
set -o errexit
|
|
884
|
+
EXIT_PASS=0
|
|
885
|
+
EXIT_HARNESS_ERROR=10
|
|
886
|
+
F=$(mktemp "$TMPDIR/x_XXXXXX")
|
|
887
|
+
P5
|
|
888
|
+
cat > "$_s7/ctl3.sh" <<'P6'
|
|
889
|
+
#!/usr/bin/env bash
|
|
890
|
+
# Exit codes: 0 PASS · 1 PENDING · 10 harness error
|
|
891
|
+
set -euo pipefail
|
|
892
|
+
on_err() {
|
|
893
|
+
echo "failed" >&2
|
|
894
|
+
exit 10
|
|
895
|
+
}
|
|
896
|
+
trap on_err ERR
|
|
897
|
+
F=$(mktemp "$TMPDIR/x_XXXXXX")
|
|
898
|
+
P6
|
|
899
|
+
_s7n(){ bash "$SCAN" "$1" 2>/dev/null | grep -c 'S7:' || true; }
|
|
900
|
+
_p=$(_s7n "$_s7/pos.sh"); _c1=$(_s7n "$_s7/ctl1.sh"); _c2=$(_s7n "$_s7/ctl2.sh")
|
|
901
|
+
_p2=$(_s7n "$_s7/pos2.sh"); _p3=$(_s7n "$_s7/pos3.sh"); _c3=$(_s7n "$_s7/ctl3.sh")
|
|
902
|
+
if [ "$_p2" -eq 1 ]; then ok "S7 POS2: a trap that does not exit (trap cleanup ERR) is not a guard"
|
|
903
|
+
else bad "S7 POS2: trap cleanup ERR suppressed the finding ($_p2)"; fi
|
|
904
|
+
if [ "$_p3" -eq 1 ]; then ok "S7 POS3: set -o errexit + EXIT_HARNESS_ERROR constant (no comment header) is flagged"
|
|
905
|
+
else bad "S7 POS3: errexit/constant spelling missed ($_p3)"; fi
|
|
906
|
+
if [ "$_c3" -eq 0 ]; then ok "S7 CTL3: a named ERR handler that exits is a guard"
|
|
907
|
+
else bad "S7 CTL3: flagged a file whose ERR handler exits ($_c3)"; fi
|
|
908
|
+
if [ "$_p" -eq 1 ]; then
|
|
909
|
+
ok "S7 POS: set -e + own error code + no ERR trap is flagged once ($_p)"
|
|
910
|
+
if [ "$_c1" -eq 0 ]; then ok "S7 CTL1: the same file with an ERR trap is silent"
|
|
911
|
+
else bad "S7 CTL1: flagged a file that has the ERR trap ($_c1)"; fi
|
|
912
|
+
if [ "$_c2" -eq 0 ]; then ok "S7 CTL2: a pass/fail-only contract is silent"
|
|
913
|
+
else bad "S7 CTL2: flagged a contract without a separate error code ($_c2)"; fi
|
|
914
|
+
else
|
|
915
|
+
bad "S7 POS: expected exactly 1 hit, got $_p — CTL results UNINTERPRETABLE"
|
|
916
|
+
fi
|
|
917
|
+
rm -rf "$_s7"
|
|
918
|
+
|
|
838
919
|
echo "degrade-scan shell probes: $pass passed, $fail failed"
|
|
839
920
|
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# test_dispatch_receipt_lanes.sh — lanes for scripts/dispatch_receipt.py (governor's receipt for dispatched edit work).
|
|
3
|
+
# Each lane builds a throwaway git repo under mktemp. Exit: 0 all lanes pass · 1 a lane failed · 10 harness error.
|
|
4
|
+
# codex 2026-10-20 R1 shaped the second half: quoted paths, renames, submodules, swallowed tool errors, rewritten claims, and a
|
|
5
|
+
# revert probe that runs the mismatch lanes themselves against a mutant (they must go red there).
|
|
6
|
+
set -uo pipefail
|
|
7
|
+
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
8
|
+
R="$HERE/dispatch_receipt.py"
|
|
9
|
+
[ -r "$R" ] || { echo "HARNESS-ERROR: $R missing"; exit 10; }
|
|
10
|
+
command -v python3 >/dev/null || { echo "HARNESS-ERROR: python3 missing"; exit 10; }
|
|
11
|
+
T=$(mktemp -d) || exit 10; trap 'rm -rf "$T"' EXIT
|
|
12
|
+
FAIL=0
|
|
13
|
+
TOOL=$R
|
|
14
|
+
check(){ local want=$1 pat=$2; shift 2; local out rc
|
|
15
|
+
out=$(python3 "$TOOL" "$@" 2>&1); rc=$?
|
|
16
|
+
[ "$rc" = "$want" ] && { [ -z "$pat" ] || grep -qE -- "$pat" <<<"$out"; }; } # here-string, not a pipe: grep -q + pipefail = SIGPIPE flip
|
|
17
|
+
lane(){ local name=$1; shift
|
|
18
|
+
if check "$@"; then echo " ✅ $name"; else echo " ❌ $name — want rc=$1 /$2/"; local o; o=$(python3 "$TOOL" "${@:3}" 2>&1); sed -n '1,8s/^/ /p' <<<"$o"; FAIL=1; fi; }
|
|
19
|
+
|
|
20
|
+
mk(){ local d="$T/$1"; mkdir -p "$d"; git -C "$d" init -q; git -C "$d" config user.email t@t; git -C "$d" config user.name t
|
|
21
|
+
git -C "$d" config commit.gpgsign false; echo base > "$d/base.txt"; echo old > "$d/old.txt"; git -C "$d" add base.txt old.txt
|
|
22
|
+
git -C "$d" commit -qm base; echo "$d"; }
|
|
23
|
+
|
|
24
|
+
echo "── dispatch_receipt lanes ──"
|
|
25
|
+
A=$(mk a); echo x > "$A/a.txt"; echo y > "$A/sp ace.txt"; git -C "$A" add a.txt "sp ace.txt"; git -C "$A" commit -qm work
|
|
26
|
+
lane "L1 claimed = changed → match" 0 'CLAIMED-MATCHES: 2' "$A" HEAD~1 --claimed "a.txt,sp ace.txt"
|
|
27
|
+
lane "L2 claimed a path that did not change" 1 '^ b\.txt$' "$A" HEAD~1 --claimed "a.txt,sp ace.txt,b.txt"
|
|
28
|
+
lane "L3 changed a path the claim left out" 1 '^ sp ace\.txt$' "$A" HEAD~1 --claimed "a.txt"
|
|
29
|
+
lane "L4 no claim: receipt only" 0 'commits=1 paths=2' "$A" HEAD~1
|
|
30
|
+
lane "L4b per-path hash line" 0 '^ path [0-9a-f]{16} +a\.txt$' "$A" HEAD~1
|
|
31
|
+
B=$(mk b)
|
|
32
|
+
lane "L5 nothing changed but paths claimed → rc 1" 1 'CLAIMED-NOT-CHANGED:' "$B" HEAD --claimed "a.txt"
|
|
33
|
+
lane "L5b nothing changed, nothing claimed" 0 'paths=0' "$B" HEAD
|
|
34
|
+
echo dirty >> "$B/base.txt"
|
|
35
|
+
lane "L6 uncommitted tracked change" 1 'NOT-COMMITTED: 1' "$B" HEAD
|
|
36
|
+
lane "L7 unresolvable base → harness error" 10 'HARNESS-ERROR' "$A" no-such-ref
|
|
37
|
+
lane "L8 not a directory → harness error" 10 'not a directory' "$T/nope" HEAD
|
|
38
|
+
lane "L9 usage" 2 'usage:' "$A"
|
|
39
|
+
lane "L9b unknown option" 2 'usage:' "$A" HEAD --bogus
|
|
40
|
+
# ── codex R1 cases ──
|
|
41
|
+
C=$(mk c); git -C "$C" mv old.txt new.txt; git -C "$C" commit -qm mv
|
|
42
|
+
lane "R1 a rename lists BOTH paths (claiming only the new one is rc 1)" 1 '^ old\.txt$' "$C" HEAD~1 --claimed "new.txt"
|
|
43
|
+
lane "R1b claiming both sides of the move matches" 0 'CLAIMED-MATCHES: 2' "$C" HEAD~1 --claimed "new.txt,old.txt"
|
|
44
|
+
D=$(mk d); printf 'z\n' > "$D/$(printf 'nl\nname')"; git -C "$D" add -A; git -C "$D" commit -qm nl
|
|
45
|
+
git -C "$D" -c core.quotePath=true diff --name-only HEAD~1 HEAD > "$T/claim_quoted" # git's own quoted spelling, taken from git
|
|
46
|
+
grep -qx '"nl\\nname"' "$T/claim_quoted" || { echo "HARNESS-ERROR: fixture is not git's quoted spelling: $(cat "$T/claim_quoted")"; exit 10; }
|
|
47
|
+
lane "R2 git's quoted spelling of a newline path is not that path" 1 'CLAIMED-NOT-CHANGED' "$D" HEAD~1 --claimed-file "$T/claim_quoted"
|
|
48
|
+
printf 'nl\nname\0' > "$T/claim_nul"
|
|
49
|
+
lane "R2b the real newline path (NUL-separated claim) matches" 0 'CLAIMED-MATCHES: 1' "$D" HEAD~1 --claimed-file "$T/claim_nul"
|
|
50
|
+
lane "R3 a claim with a stray space is refused, not rewritten" 2 'leading/trailing space' "$A" HEAD~1 --claimed " a.txt,sp ace.txt"
|
|
51
|
+
lane "R3b an empty entry (trailing comma) is refused" 2 'empty entry' "$A" HEAD~1 --claimed "a.txt,sp ace.txt,"
|
|
52
|
+
lane "R3c a duplicate entry is refused" 2 'duplicate' "$A" HEAD~1 --claimed "a.txt,a.txt"
|
|
53
|
+
E=$(mk e); S=$(mk sub); git -C "$E" -c protocol.file.allow=always submodule add -q "$S" sm 2>/dev/null; git -C "$E" commit -qm sm
|
|
54
|
+
lane "R4 a submodule is shown as a submodule, not hashed as a blob" 0 '^ path submodule [0-9a-f]{12} +sm$' "$E" HEAD~1
|
|
55
|
+
SIDE=$(git -C "$A" commit-tree "HEAD~1^{tree}" -p HEAD~1 -m side) # same repo, diverged: not an ancestor of HEAD
|
|
56
|
+
lane "R5 base not an ancestor of head → harness error" 10 'not an ancestor' "$A" "$SIDE"
|
|
57
|
+
lane "R5b (a foreign sha is unresolvable here)" 10 'HARNESS-ERROR' "$A" 0000000000000000000000000000000000000001
|
|
58
|
+
|
|
59
|
+
# ── codex R2 cases ──
|
|
60
|
+
F=$(mk f); S2=$(mk sub2); git -C "$F" -c protocol.file.allow=always submodule add -q "$S2" sm 2>/dev/null; git -C "$F" commit -qm sm
|
|
61
|
+
echo more > "$S2/m.txt"; git -C "$S2" add m.txt; git -C "$S2" commit -qm m; git -C "$F/sm" pull -q 2>/dev/null; git -C "$F" add sm; git -C "$F" commit -qm bump
|
|
62
|
+
git -C "$F" config diff.ignoreSubmodules all
|
|
63
|
+
lane "R6 repo config diff.ignoreSubmodules=all cannot hide a gitlink bump" 1 '^ sm$' "$F" HEAD~1 --claimed "x.txt"
|
|
64
|
+
G=$(mk g); git -C "$G" update-index --assume-unchanged base.txt; echo edited >> "$G/base.txt"
|
|
65
|
+
lane "R7 an assume-unchanged edit makes «committed» unprovable" 1 'UNPROVABLE-CLEAN: 1' "$G" HEAD
|
|
66
|
+
printf 'a.txt\n\n' > "$T/claim_dbl"
|
|
67
|
+
lane "R8 a doubled trailing terminator is an empty entry" 2 'empty entry' "$A" HEAD~1 --claimed-file "$T/claim_dbl"
|
|
68
|
+
printf 'a.txt\n' > "$T/claim_one"
|
|
69
|
+
lane "R9 a duplicate across --claimed and --claimed-file is refused" 2 'across claim options' "$A" HEAD~1 --claimed "a.txt,sp ace.txt" --claimed-file "$T/claim_one"
|
|
70
|
+
lane "R9b … and across two --claimed options" 2 'across claim options' "$A" HEAD~1 --claimed "a.txt" --claimed "a.txt"
|
|
71
|
+
|
|
72
|
+
# ── codex R3 cases ──
|
|
73
|
+
H=$(mk h); mkdir -p "$H/sub"; echo s > "$H/sub/in.txt"; git -C "$H" add sub/in.txt; git -C "$H" commit -qm sub; echo o >> "$H/old.txt"; git -C "$H" commit -qam outside
|
|
74
|
+
git -C "$H" config diff.relative true
|
|
75
|
+
lane "R10 run from a subdirectory with diff.relative=true still sees the outside change" 1 '^ old\.txt$' "$H/sub" HEAD~1 --claimed "x.txt"
|
|
76
|
+
I=$(mk i); echo y > "$I/z.txt"; git -C "$I" add z.txt; git -C "$I" commit -qm z
|
|
77
|
+
if out=$(GIT_DIR="$B/.git" GIT_WORK_TREE="$B" python3 "$R" "$I" HEAD~1 --claimed "z.txt" 2>&1) && grep -q 'CLAIMED-MATCHES: 1' <<<"$out"; then
|
|
78
|
+
echo " ✅ R11 inherited GIT_DIR/GIT_WORK_TREE do not redirect the measurement"
|
|
79
|
+
else echo " ❌ R11 inherited GIT_DIR redirected the receipt"; sed -n '1,5s/^/ /p' <<<"$out"; FAIL=1; fi
|
|
80
|
+
|
|
81
|
+
# ── revert probe: neuter the claimed-vs-actual comparison; the mismatch lanes (L2, L3, L5, R1) must go RED on the mutant ──
|
|
82
|
+
M="$T/mut.py"; sed 's/missing, extra = sorted(claim - actual), sorted(actual - claim)/missing, extra = [], []/' "$R" > "$M"
|
|
83
|
+
if grep -q 'missing, extra = \[\], \[\]' "$M"; then
|
|
84
|
+
TOOL=$M; red=0
|
|
85
|
+
check 1 '^ b\.txt$' "$A" HEAD~1 --claimed "a.txt,sp ace.txt,b.txt" || red=$((red+1))
|
|
86
|
+
check 1 '^ sp ace\.txt$' "$A" HEAD~1 --claimed "a.txt" || red=$((red+1))
|
|
87
|
+
check 1 'CLAIMED-NOT-CHANGED:' "$B" HEAD --claimed "a.txt" || red=$((red+1))
|
|
88
|
+
check 1 '^ old\.txt$' "$C" HEAD~1 --claimed "new.txt" || red=$((red+1))
|
|
89
|
+
TOOL=$R
|
|
90
|
+
if [ "$red" = 4 ]; then echo " ✅ RV comparison off → 4/4 mismatch lanes red on the mutant"
|
|
91
|
+
else echo " ❌ RV only $red/4 mismatch lanes went red on the mutant — they do not measure the comparison"; FAIL=1; fi
|
|
92
|
+
else echo " ❌ RV mutation did not apply (HARNESS-ERROR in the probe)"; FAIL=1; fi
|
|
93
|
+
|
|
94
|
+
[ "$FAIL" = 0 ] && echo "── all lanes ok ──"
|
|
95
|
+
exit "$FAIL"
|
|
@@ -119,6 +119,36 @@ else
|
|
|
119
119
|
no "L7 되돌림 전이" "주입rc=$INJ 복원rc=$RST 잔존=$LEFT"
|
|
120
120
|
fi
|
|
121
121
|
|
|
122
|
+
# L9 — 2026-10-20: 이름 대체 찾기는 git 이면 «추적된» 파일만 본다. 미추적 사본(실험 복제본)이 이름을 겹치게 해 보정이 거짓 실패하던 것.
|
|
123
|
+
G8="$TMP/l8repo"; mkdir -p "$G8/templates" "$G8/junk/a" "$G8/junk/b" "$TMP/l8plain"
|
|
124
|
+
git -C "$G8" init -q && echo t > "$G8/templates/known.sh" && git -C "$G8" add templates/known.sh \
|
|
125
|
+
&& git -C "$G8" -c user.email=t@t -c user.name=t -c commit.gpgsign=false commit -qm k
|
|
126
|
+
cp "$G8/templates/known.sh" "$G8/junk/a/known.sh"; cp "$G8/templates/known.sh" "$G8/junk/b/known.sh"; echo u > "$G8/junk/a/only_untracked.sh"
|
|
127
|
+
echo p > "$TMP/l8plain/plain.sh"
|
|
128
|
+
L8=$(python3 - "$SCAN" "$G8" "$TMP/l8plain" <<'PY8'
|
|
129
|
+
import importlib.util, sys
|
|
130
|
+
spec = importlib.util.spec_from_file_location("s", sys.argv[1]); m = importlib.util.module_from_spec(spec); spec.loader.exec_module(m)
|
|
131
|
+
g, plain = sys.argv[2], sys.argv[3]
|
|
132
|
+
a = m.resolve(g, "scripts/known.sh")
|
|
133
|
+
b = m.resolve(g, "scripts/only_untracked.sh")
|
|
134
|
+
c = m.resolve(plain, "x/plain.sh")
|
|
135
|
+
print("A=%s B=%s C=%s" % (bool(a and a.endswith("templates/known.sh")), b is None, bool(c and c.endswith("plain.sh"))))
|
|
136
|
+
PY8
|
|
137
|
+
)
|
|
138
|
+
if [ "$L8" = "A=True B=True C=True" ]; then ok "L9 이름 찾기: 미추적 사본 둘이 있어도 추적된 하나 · 미추적에만 있으면 없음 · git 밖은 종전대로"
|
|
139
|
+
else no "L9 이름 찾기 (추적 파일 기준)" "$L8"; fi
|
|
140
|
+
|
|
141
|
+
# L9b — codex R1: git 이 «git 밖» 이 아닌 이유로 실패하면 옛 전체 훑기로 돌아가지 않고 못 찾은 것으로 닫힌다
|
|
142
|
+
mkdir -p "$TMP/fakegit"; printf '#!/bin/sh\necho "fatal: index file corrupt" >&2\nexit 128\n' > "$TMP/fakegit/git"; chmod +x "$TMP/fakegit/git"
|
|
143
|
+
L9B=$(PATH="$TMP/fakegit:/usr/bin:/bin" python3 - "$SCAN" "$G8" <<'PY9'
|
|
144
|
+
import importlib.util, sys
|
|
145
|
+
spec = importlib.util.spec_from_file_location("s", sys.argv[1]); m = importlib.util.module_from_spec(spec); spec.loader.exec_module(m)
|
|
146
|
+
print("FAILED=%s R=%s" % (m._tracked(sys.argv[2]) == m._INVENTORY_FAILED, m.resolve(sys.argv[2], "templates/known.sh")))
|
|
147
|
+
PY9
|
|
148
|
+
)
|
|
149
|
+
if [ "$L9B" = "FAILED=True R=None" ]; then ok "L9b git 목록 실패 → 못 찾음(닫힌 쪽) · 옛 전체 훑기로 안 떨어진다"
|
|
150
|
+
else no "L9b git 목록 실패의 방향" "$L9B"; fi
|
|
151
|
+
|
|
122
152
|
echo "── PASS=$PASS FAIL=$FAIL ──"
|
|
123
153
|
[ "$FAIL" -eq 0 ] || { echo "FAILED=1"; exit 1; }
|
|
124
154
|
echo "FAILED=0"
|
|
@@ -89,10 +89,11 @@ run_new() {
|
|
|
89
89
|
echo "── ② frontier digest"
|
|
90
90
|
hasnt "$S" "$F8" "$T/f8.sent" "frontier" "L8 old diagnosis file, fresh digest → silent"
|
|
91
91
|
has "$S" "$F9" "$T/f9.sent" "frontier_digest 10d" "L9 KP: digest 10d → warns"
|
|
92
|
-
echo "── ③ sim Area B"
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
echo "── ③ sim Area B — event-bound since 2026-10-19: no terminal line at any age"
|
|
93
|
+
hasnt "$S" "$F4" "$T/f4.sent" "FH internal sim" "L4 Area B 40d → silent (event-bound, no clock)"
|
|
94
|
+
hasnt "$S" "$F5" "$T/f5.sent" "FH internal sim" "L5 Area B 116d → silent (the old true alarm is retired by decision)"
|
|
95
95
|
hasnt "$S" "$F1" "$T/f1.sent" "FH internal sim" "L5b Area B 3d → silent"
|
|
96
|
+
has "$S" "$F2" "$T/f2.sent" "weekly_audit 10d" "L5c control: the banner still prints (removal did not silence ①)"
|
|
96
97
|
echo "── ④ sentinels"
|
|
97
98
|
for m in projA_mapping_skipped projB_wizard_done projC_wizard_declined projD_wizard_reminder_muted; do
|
|
98
99
|
hasnt "$S" "$F6" "$S6" "$m sentinel" "L6 state marker $m not aged"
|
|
@@ -127,11 +128,15 @@ probe() { # name sed-expr lane-fn
|
|
|
127
128
|
}
|
|
128
129
|
lane1() { hasnt "$1" "$F1" "$T/f1.sent" "weekly audit history" "L1-probe"; }
|
|
129
130
|
lane2() { hasnt "$1" "$F8" "$T/f8.sent" "frontier" "L8-probe"; has "$1" "$F9" "$T/f9.sent" "frontier_digest 10d" "L9-probe"; }
|
|
130
|
-
lane3
|
|
131
|
+
# lane3: the retired ③ — a warning-presence mutant: insert an Area B line (no threshold, no dir guard)
|
|
132
|
+
# in a copy; the 116d fixture must make it speak, so the lane proves «no Area B line» is really asserted
|
|
133
|
+
lane3() { hasnt "$1" "$F5" "$T/f5.sent" "FH internal sim" "L5-probe"; }
|
|
131
134
|
lane4() { hasnt "$1" "$F6" "$S6" "projA_mapping_skipped sentinel" "L6-probe"; }
|
|
132
135
|
probe weekly 's#tracks/_audit"/weekly_audit_\*\.md#tracks/_audit"/harvest_*.md#' lane1
|
|
133
136
|
probe frontier 's#tracks/_meta"/frontier_digest_\*\.md#knowledge/shared/harness-core"/harness_frontier_diagnosis_*.md#' lane2
|
|
134
|
-
probe sim '
|
|
137
|
+
probe sim '/# ④ Custom sentinels/i\
|
|
138
|
+
local -a _fh_sims; _fh_sims=( "${FH_DIR}/tracks/_meta"/sim_*_area_B*.md(N.om) ); local sim="${_fh_sims[1]:-}"; [[ -n "$sim" ]] \&\& warns+=("FH internal sim (re-inserted mutant)")
|
|
139
|
+
' lane3
|
|
135
140
|
probe sentinel '/\*_wizard_done|\*_mapping_skipped/d' lane4
|
|
136
141
|
lane5() { hasntk "$1" "$F10" "$T/f10.sent" "weekly_audit" "L10-probe"; }
|
|
137
142
|
probe emulate '/^ emulate -L zsh$/d' lane5
|
|
@@ -250,13 +250,83 @@ check_out "cross: both legs' findings survive the union" 2 'FH_GATE_LEGS: claude
|
|
|
250
250
|
run_cross "$CROSS_BLOCK" "$CROSS_BLOCK"
|
|
251
251
|
# A machine with only one family is the COMMON case, not an edge case. It must not be silent.
|
|
252
252
|
ONELEG="$TMPROOT/oneleg"; mkdir -p "$ONELEG"; cp "$FAKEBIN/claude" "$ONELEG/claude"
|
|
253
|
-
|
|
253
|
+
# the gate needs jq; with PATH cut to $ONELEG:/usr/bin:/bin a Homebrew-only jq vanishes and every single-leg lane
|
|
254
|
+
# would end at 10 before reaching the code under test (codex R1, 2026-10-22) — carry jq, never the other backend
|
|
255
|
+
_jq=$(command -v jq 2>/dev/null) && [ ! -e "$ONELEG/jq" ] && ln -s "$_jq" "$ONELEG/jq"
|
|
256
|
+
check_out "cross: codex absent → single leg, DECORRELATED: no" 3 'FH_GATE_DECORRELATED: no' \
|
|
254
257
|
env PATH="$ONELEG:/usr/bin:/bin" FH_BACKEND=cross FH_MODEL=fake \
|
|
255
258
|
FAKE_PAYLOAD_CLAUDE="$CROSS_PASS" FAKE_PAYLOAD="$CROSS_PASS" \
|
|
256
259
|
bash "$GATE" "$SUBJECT" quick test
|
|
260
|
+
# 🟥 2026-10-22: a single-leg PASS used to exit 0 — the same code as a two-family PASS, so a caller that reads
|
|
261
|
+
# only the exit code (a pre-commit hook, `fh-gate && merge`) could not tell them apart; only text lines differed
|
|
262
|
+
# (LLM call-site inventory, arXiv:2610.24545). Cross was REQUESTED, so a run that could not provide it is not
|
|
263
|
+
# a pass: it goes to a person (ESCALATE, 3) with the reason in a machine-readable line.
|
|
264
|
+
check_out "cross: single leg PASS → ESCALATE (3), not a pass" 3 'FH_GATE_VERDICT: ESCALATE' \
|
|
265
|
+
env PATH="$ONELEG:/usr/bin:/bin" FH_BACKEND=cross FH_MODEL=fake \
|
|
266
|
+
FAKE_PAYLOAD_CLAUDE="$CROSS_PASS" FAKE_PAYLOAD="$CROSS_PASS" \
|
|
267
|
+
bash "$GATE" "$SUBJECT" quick test
|
|
268
|
+
check_out "cross: single leg PASS → the reason is machine-readable" 3 '^FH_GATE_ESCALATE_REASON: cross-degraded' \
|
|
269
|
+
env PATH="$ONELEG:/usr/bin:/bin" FH_BACKEND=cross FH_MODEL=fake \
|
|
270
|
+
FAKE_PAYLOAD_CLAUDE="$CROSS_PASS" FAKE_PAYLOAD="$CROSS_PASS" \
|
|
271
|
+
bash "$GATE" "$SUBJECT" quick test
|
|
272
|
+
CROSS_PEND='{"status":"SUCCESS","verdict":"PENDING","findings_count":1,"findings_a":0,"findings_b":1,"findings":[{"grade":"B","location":"x:1","title":"t","evidence":"e","fix":"f"}]}'
|
|
273
|
+
check_out "cross: single leg PENDING → ESCALATE (1 is «proceed»)" 3 'FH_GATE_VERDICT: ESCALATE' \
|
|
274
|
+
env PATH="$ONELEG:/usr/bin:/bin" FH_BACKEND=cross FH_MODEL=fake \
|
|
275
|
+
FAKE_PAYLOAD_CLAUDE="$CROSS_PEND" FAKE_PAYLOAD="$CROSS_PEND" \
|
|
276
|
+
bash "$GATE" "$SUBJECT" quick test
|
|
277
|
+
# control: a single-leg BLOCKED keeps its own, stricter code
|
|
278
|
+
check_out "cross: single leg BLOCKED stays BLOCKED (2)" 2 'FH_GATE_VERDICT: BLOCKED' \
|
|
279
|
+
env PATH="$ONELEG:/usr/bin:/bin" FH_BACKEND=cross FH_MODEL=fake \
|
|
280
|
+
FAKE_PAYLOAD_CLAUDE="$CROSS_BLOCK" FAKE_PAYLOAD="$CROSS_BLOCK" \
|
|
281
|
+
bash "$GATE" "$SUBJECT" quick test
|
|
282
|
+
# the explicit, logged override keeps the leg's verdict — and says so in the output
|
|
283
|
+
check_out "cross: single leg + FH_GATE_CROSS_ALLOW_SINGLE=1 → PASS, override logged" 0 '^FH_GATE_CROSS_OVERRIDE: FH_GATE_CROSS_ALLOW_SINGLE=1' \
|
|
284
|
+
env PATH="$ONELEG:/usr/bin:/bin" FH_BACKEND=cross FH_MODEL=fake FH_GATE_CROSS_ALLOW_SINGLE=1 \
|
|
285
|
+
FAKE_PAYLOAD_CLAUDE="$CROSS_PASS" FAKE_PAYLOAD="$CROSS_PASS" \
|
|
286
|
+
bash "$GATE" "$SUBJECT" quick test
|
|
287
|
+
# control: the override is exact — any other value does not unlock it
|
|
288
|
+
check_out "cross: FH_GATE_CROSS_ALLOW_SINGLE=yes is not the override" 3 'FH_GATE_VERDICT: ESCALATE' \
|
|
289
|
+
env PATH="$ONELEG:/usr/bin:/bin" FH_BACKEND=cross FH_MODEL=fake FH_GATE_CROSS_ALLOW_SINGLE=yes \
|
|
290
|
+
FAKE_PAYLOAD_CLAUDE="$CROSS_PASS" FAKE_PAYLOAD="$CROSS_PASS" \
|
|
291
|
+
bash "$GATE" "$SUBJECT" quick test
|
|
257
292
|
check "cross: no family available → fails closed" 10 \
|
|
258
293
|
env PATH="/usr/bin:/bin" FH_BACKEND=cross bash "$GATE" "$SUBJECT" quick test
|
|
259
294
|
|
|
295
|
+
# An unexpected failure must not leave as status 1 (= PENDING, "proceed"). Reported from outside
|
|
296
|
+
# (2026-10-20); measured: `mktemp` failing under `set -e` ended the gate with 1, also through the npm bin.
|
|
297
|
+
check "unexpected failure (mktemp) → HARNESS_ERROR, not PENDING" 10 \
|
|
298
|
+
env TMPDIR="$TMPROOT/does-not-exist" FH_DRY_RUN=1 bash "$GATE" "$SUBJECT" quick test
|
|
299
|
+
check "unexpected failure via npm bin → HARNESS_ERROR, not PENDING" 10 \
|
|
300
|
+
env TMPDIR="$TMPROOT/does-not-exist" FH_DRY_RUN=1 node bin/fh-gate.js "$SUBJECT" quick test
|
|
301
|
+
# `set -u` ends the script with 1 WITHOUT firing ERR — only the exit-time check sees it (cross-family review).
|
|
302
|
+
# Outside an FH checkout the record base falls back to $HOME, so an unset HOME is an unbound variable there.
|
|
303
|
+
# cross mode must pass a leg's 11/12 through — every leg gets the same arguments (local-model self-audit
|
|
304
|
+
# candidate, reproduced 2026-10-20: both came out as 10). Control: the non-cross bad level is 11.
|
|
305
|
+
check "cross + bad gate level → 11 (argument error), not 10" 11 \
|
|
306
|
+
env PATH="$FAKEBIN:/usr/bin:/bin" FH_BACKEND=cross FH_MODEL=fake bash "$GATE" "$SUBJECT" medium test
|
|
307
|
+
check "cross + FH_DRY_RUN=1 → 12 (dry-run), not 10" 12 \
|
|
308
|
+
env PATH="$FAKEBIN:/usr/bin:/bin" FH_BACKEND=cross FH_DRY_RUN=1 FH_MODEL=fake bash "$GATE" "$SUBJECT" quick test
|
|
309
|
+
check_out "cross + FH_DRY_RUN=1 → the prompt is printed" 12 'FH GOVERNANCE GATE' \
|
|
310
|
+
env PATH="$FAKEBIN:/usr/bin:/bin" FH_BACKEND=cross FH_DRY_RUN=1 FH_MODEL=fake bash "$GATE" "$SUBJECT" quick test
|
|
311
|
+
check "control: non-cross bad gate level → 11" 11 \
|
|
312
|
+
env PATH="$FAKEBIN:/usr/bin:/bin" FH_BACKEND=claude FH_MODEL=fake bash "$GATE" "$SUBJECT" medium test
|
|
313
|
+
# With stderr closed every message fails; the handlers' own messages must not stop their `exit`, and a real
|
|
314
|
+
# verdict must keep its code (cross-family review round 2: `--invalid 2>&-` returned 1).
|
|
315
|
+
check "stderr closed + unexpected failure → still HARNESS_ERROR" 10 \
|
|
316
|
+
env TMPDIR="$TMPROOT/does-not-exist" FH_DRY_RUN=1 bash -c 'exec 2>&-; exec bash "$@"' _ "$GATE" "$SUBJECT" quick test
|
|
317
|
+
# With stderr closed a PASS run either keeps 0 or fails closed with 10 — which one depends on whether some
|
|
318
|
+
# ordinary `>&2` line on the way fails first (macOS bash 3.2 here: 0; the Linux CI runner: 10). What it must
|
|
319
|
+
# never do is leave as 1/2/3, i.e. a verdict it did not reach. (First draft pinned 0 and CI showed 10.)
|
|
320
|
+
env PATH="$FAKEBIN:/usr/bin:/bin" FH_BACKEND=claude FH_MODEL=fake FAKE_PAYLOAD="$CROSS_PASS" \
|
|
321
|
+
bash -c 'exec 2>&-; exec bash "$@"' _ "$GATE" "$SUBJECT" quick test >/dev/null 2>&1
|
|
322
|
+
_sc=$?
|
|
323
|
+
case "$_sc" in
|
|
324
|
+
0|10) printf 'PASS %-58s (exit %s)\n' "stderr closed + PASS run → 0 or 10, never a lower verdict" "$_sc"; pass=$((pass + 1)) ;;
|
|
325
|
+
*) printf 'FAIL %-58s expected 0 or 10, got %s\n' "stderr closed + PASS run → 0 or 10, never a lower verdict" "$_sc"; fail=$((fail + 1)) ;;
|
|
326
|
+
esac
|
|
327
|
+
check "unbound variable (HOME unset, outside a checkout) → HARNESS_ERROR" 10 \
|
|
328
|
+
env -u HOME FH_DRY_RUN=1 bash -c 'cd "$1" && exec bash "$2" "$3" quick test' _ "$TMPROOT" "$PWD/$GATE" "$SUBJECT"
|
|
329
|
+
|
|
260
330
|
echo
|
|
261
331
|
echo "────────────────────────────────────────────────────────────────────"
|
|
262
332
|
printf 'fh-gate regressions: %d passed, %d failed\n' "$pass" "$fail"
|
|
@@ -2006,6 +2006,89 @@ else
|
|
|
2006
2006
|
no "L124 빈 1차 fail-open" "empty_rc=$R124 (3 기대) '$(printf '%s' "$O124" | /usr/bin/grep -o 'status=[A-Z_0-9]*' | head -1)' ctrl_rc=$R124c (0 기대)"
|
|
2007
2007
|
fi
|
|
2008
2008
|
|
|
2009
|
+
# ── L125/L126 🟥 2차 철회 대조가 «부분 문자열» 이라 남의 발견을 삼키던 구멍 (2026-10-22, 호출지점 재고 조사) ──
|
|
2010
|
+
# 기전: `if _id in _body` — `DROPPED: codex-logic-10` 이 `codex-logic-1` 도 «철회됨» 으로 세서, 2차에서 조용히
|
|
2011
|
+
# 빠진 1번이 «설명됨» 이 되고 폴백도 안 돌았다(무음 삭제). 제목도 같은 부류(`Q1` ⊂ `Q10`).
|
|
2012
|
+
# 픽스처는 뚫리는 표기 그대로: 1차 10건 → 2차가 2~9 를 KEEP · 10 을 DROPPED · 1 은 말없이 뺀다.
|
|
2013
|
+
cat > "$D/x_ten.sh" <<'EOS'
|
|
2014
|
+
#!/bin/sh
|
|
2015
|
+
IN=$(cat); [ -n "$IN" ] || IN="$*"
|
|
2016
|
+
row(){ printf '{"id":"codex-logic-%s","title":"%s","file":"x_t.py","line":%s,"severity":"B","category":"s","detail":"x","defeater":"y","confidence":0.6}\n' "$1" "$2" "$1"; }
|
|
2017
|
+
case "$IN" in
|
|
2018
|
+
*"YOUR OWN ROUND-1 FINDINGS"*)
|
|
2019
|
+
for i in 2 3 4 5 6 7 8 9; do row $i "kept-$i"; done
|
|
2020
|
+
if [ -n "$TEN_DROP_BOTH" ]; then echo 'DROPPED: codex-logic-1 — re-read; not a defect'; fi
|
|
2021
|
+
echo 'DROPPED: codex-logic-10 — re-read; not a defect' ;;
|
|
2022
|
+
*) for i in 1 2 3 4 5 6 7 8 9 10; do printf '{"title":"r1-%s","file":"x_t.py","line":%s,"severity":"B","category":"s","detail":"x","defeater":"y","confidence":0.6}\n' "$i" "$i"; done ;;
|
|
2023
|
+
esac
|
|
2024
|
+
EOS
|
|
2025
|
+
cat > "$D/x_qtitle.sh" <<'EOS'
|
|
2026
|
+
#!/bin/sh
|
|
2027
|
+
IN=$(cat); [ -n "$IN" ] || IN="$*"
|
|
2028
|
+
case "$IN" in
|
|
2029
|
+
*"YOUR OWN ROUND-1 FINDINGS"*) echo 'DROPPED: Q10 — re-read; not a defect' ;;
|
|
2030
|
+
*) echo '{"title":"Q1","file":"x_t.py","line":1,"severity":"A","category":"d","detail":"x","defeater":"y","confidence":0.7}'
|
|
2031
|
+
echo '{"title":"Q10","file":"x_t.py","line":2,"severity":"B","category":"d","detail":"x","defeater":"y","confidence":0.7}' ;;
|
|
2032
|
+
esac
|
|
2033
|
+
EOS
|
|
2034
|
+
chmod +x "$D/x_ten.sh" "$D/x_qtitle.sh"
|
|
2035
|
+
printf 'codex|logic|sh %s\n' "$D/x_ten.sh" > "$D/f125.tbl"
|
|
2036
|
+
O125=$(bash "$FL" "$D/x_t.py" --out "$D/f125" --fleet "$D/f125.tbl" --round2 2>&1)
|
|
2037
|
+
# 컨트롤: 1 과 10 을 둘 다 «명시적으로» 내리면 폴백 없이 철회된다 — 경계 비교가 정당한 철회까지 막지 않는다
|
|
2038
|
+
O125c=$(TEN_DROP_BOTH=1 bash "$FL" "$D/x_t.py" --out "$D/f125c" --fleet "$D/f125.tbl" --round2 2>&1)
|
|
2039
|
+
if printf '%s\n' "$O125" | /usr/bin/grep -q 'unaccounted_r1=codex-logic-1 ' \
|
|
2040
|
+
&& /usr/bin/grep -q '"r1-1"' "$D/f125/findings.jsonl" 2>/dev/null \
|
|
2041
|
+
&& ! printf '%s\n' "$O125c" | /usr/bin/grep -q 'unaccounted_r1=' \
|
|
2042
|
+
&& ! /usr/bin/grep -q '"r1-1"' "$D/f125c/findings.jsonl" 2>/dev/null \
|
|
2043
|
+
&& /usr/bin/grep -q '"kept-2"' "$D/f125c/findings.jsonl" 2>/dev/null; then
|
|
2044
|
+
ok "L125 🟥 «DROPPED: codex-logic-10» 은 codex-logic-1 을 철회하지 않는다(말없이 빠진 1 → 폴백) · 컨트롤: 둘 다 명시 철회 → 폴백 없음"
|
|
2045
|
+
else
|
|
2046
|
+
no "L125 id 부분일치 철회" "$(printf '%s\n' "$O125" | /usr/bin/grep -E 'unaccounted|MEMBER2' | head -2) | ctrl: $(printf '%s\n' "$O125c" | /usr/bin/grep -E 'unaccounted|MEMBER2' | head -2)"
|
|
2047
|
+
fi
|
|
2048
|
+
printf 'codex|logic|sh %s\n' "$D/x_qtitle.sh" > "$D/f126.tbl"
|
|
2049
|
+
O126=$(bash "$FL" "$D/x_t.py" --out "$D/f126" --fleet "$D/f126.tbl" --round2 2>&1)
|
|
2050
|
+
if printf '%s\n' "$O126" | /usr/bin/grep -q 'unaccounted_r1=' \
|
|
2051
|
+
&& /usr/bin/grep -q '"Q1"' "$D/f126/findings.jsonl" 2>/dev/null; then
|
|
2052
|
+
ok "L126 🟥 제목 «Q10» 철회가 제목 «Q1» 을 삼키지 않는다(Q1 은 설명 안 됨 → 폴백, 1차 그대로)"
|
|
2053
|
+
else
|
|
2054
|
+
no "L126 제목 부분일치 철회" "$(printf '%s\n' "$O126" | /usr/bin/grep -E 'unaccounted|MEMBER2' | head -2)"
|
|
2055
|
+
fi
|
|
2056
|
+
|
|
2057
|
+
# ── L127 🟥 codex R1 (같은 날) — 줄 «어디서든» 찾으면 이름만 «언급된» 발견도 철회로 셌다 ──
|
|
2058
|
+
# 처방 = DROPPED 줄은 «맨 앞에 오는» 한 발견만 철회한다(가장 긴 일치). 네 형태, 앞 셋은 말없이 빠진 A 가 살아 폴백해야,
|
|
2059
|
+
# 넷째(한국어 조사)는 정당한 철회로 인정돼야 한다 — 과차단 컨트롤.
|
|
2060
|
+
cat > "$D/x_two.sh" <<'EOS'
|
|
2061
|
+
#!/bin/sh
|
|
2062
|
+
IN=$(cat); [ -n "$IN" ] || IN="$*"
|
|
2063
|
+
case "$IN" in
|
|
2064
|
+
*"YOUR OWN ROUND-1 FINDINGS"*) printf '%s\n' "$TWO_DROP" ;;
|
|
2065
|
+
*) printf '{"title":"%s","file":"x_t.py","line":1,"severity":"A","category":"d","detail":"x","defeater":"y","confidence":0.7}\n' "$TWO_A"
|
|
2066
|
+
printf '{"title":"%s","file":"x_t.py","line":2,"severity":"B","category":"d","detail":"x","defeater":"y","confidence":0.7}\n' "$TWO_B" ;;
|
|
2067
|
+
esac
|
|
2068
|
+
EOS
|
|
2069
|
+
chmod +x "$D/x_two.sh"
|
|
2070
|
+
printf 'codex|logic|sh %s\n' "$D/x_two.sh" > "$D/f127.tbl"
|
|
2071
|
+
r127=""
|
|
2072
|
+
t127(){ # $1=label $2=A title $3=B title $4=DROPPED line $5=expect (fallback|withdrawn)
|
|
2073
|
+
_o=$(TWO_A="$2" TWO_B="$3" TWO_DROP="$4" bash "$FL" "$D/x_t.py" --out "$D/f127_$1" --fleet "$D/f127.tbl" --round2 2>&1)
|
|
2074
|
+
if [ "$5" = fallback ]; then
|
|
2075
|
+
printf '%s\n' "$_o" | /usr/bin/grep -q 'unaccounted_r1=' && /usr/bin/grep -qF "\"title\": \"$2\"" "$D/f127_$1/findings.jsonl" 2>/dev/null \
|
|
2076
|
+
|| /usr/bin/grep -qF "\"title\":\"$2\"" "$D/f127_$1/findings.jsonl" 2>/dev/null || r127="$r127 $1"
|
|
2077
|
+
else
|
|
2078
|
+
printf '%s\n' "$_o" | /usr/bin/grep -q 'status=ZERO_SELFDROPPED' || r127="$r127 $1"
|
|
2079
|
+
fi
|
|
2080
|
+
}
|
|
2081
|
+
t127 punct 'Race' 'Race-condition' 'DROPPED: Race-condition — invalid' fallback
|
|
2082
|
+
t127 inid 'logic' 'Other' 'DROPPED: codex-logic-2 — invalid' fallback
|
|
2083
|
+
t127 reason 'Race condition' 'Other' 'DROPPED: codex-logic-2 — duplicate; Race condition remains valid' fallback
|
|
2084
|
+
# 컨트롤: 두 줄이 각자 «맨 앞» 에 한 발견씩 — 한국어 조사가 붙어도 정당한 철회로 셈 → 전원 철회
|
|
2085
|
+
t127 korean '경쟁 조건' 'Other' "$(printf 'DROPPED: 경쟁 조건은 오탐\nDROPPED: codex-logic-2은 오탐')" withdrawn
|
|
2086
|
+
if [ -z "$r127" ]; then
|
|
2087
|
+
ok "L127 🟥 DROPPED 는 맨 앞 한 발견만 철회(구두점 붙은 긴 제목 · id 속 제목 · 사유 속 언급 → 폴백) · 컨트롤: 한국어 조사 붙은 정당 철회는 인정"
|
|
2088
|
+
else
|
|
2089
|
+
no "L127 맨 앞 한 발견 철회" "failed:$r127"
|
|
2090
|
+
fi
|
|
2091
|
+
|
|
2009
2092
|
/bin/rm -rf "$D"
|
|
2010
2093
|
echo "PASS=$PASS FAIL=$FAIL"
|
|
2011
2094
|
[ "$FAIL" -eq 0 ] && { echo "FAILED=0"; exit 0; } || { echo "FAILED=1"; exit 1; }
|