@chrono-meta/fh-gate 2.8.0 → 2.9.1
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/rules/fh_4axis_gate.md +33 -5
- package/.claude-plugin/marketplace.json +2 -2
- package/AGENTS.md +5 -0
- package/CLAUDE.md +47 -12
- package/README.ja.md +44 -29
- package/README.ko.md +43 -28
- package/README.md +48 -33
- package/README.zh.md +41 -28
- package/docs/ETHOS.md +48 -8
- package/docs/GATE_DAY.md +235 -0
- package/docs/OUTPUT_EVIDENCE.md +13 -2
- package/docs/codex-compat.md +10 -2
- package/knowledge/shared/harness-core/agents_md_runtime_details.md +10 -3
- package/knowledge/shared/harness-core/fh_three_layer_canon.md +20 -2
- package/knowledge/shared/harness-core/field_verdict_crossfamily_gate.md +23 -5
- package/knowledge/shared/harness-core/harness_incubator_doctrine.md +6 -1
- package/knowledge/shared/harness-core/measurement-integrity-checklist.md +31 -0
- package/knowledge/shared/harness-core/ship_readiness_gate.md +2 -2
- package/knowledge/shared/learnings/subagent_invocations_log.yaml +31 -0
- package/knowledge/shared/rules/multi_session_close_protocol.md +8 -1
- package/package.json +17 -3
- 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 +122 -0
- package/plugins/fh-meta/skills/cross-ecosystem-synergy-detection/SKILL.md +93 -3
- package/scripts/chamber_candidate_collect.sh +71 -13
- package/scripts/compaction_probe.sh +17 -2
- package/scripts/fh-gate.sh +58 -0
- package/scripts/files_manifest_shipping_check.sh +314 -0
- package/scripts/mapped_tracks.sh +113 -0
- package/scripts/package_coverage_check.sh +54 -0
- package/scripts/postinstall_notice.js +9 -2
- package/scripts/prior_art_prompt.sh +49 -2
- package/scripts/selfcheck.sh +58 -2
- package/scripts/session_close_check.sh +56 -3
- package/scripts/test_chamber_sig_lanes.sh +151 -0
- package/scripts/test_files_manifest_shipping_lanes.sh +260 -0
- package/scripts/test_leak_scan_control_lanes.sh +163 -0
- package/scripts/test_mapped_tracks_lanes.sh +162 -0
- package/scripts/test_peer_worktree_detect_lanes.sh +138 -0
- package/scripts/test_prepush_destructive_lanes.sh +366 -0
- package/scripts/test_prior_art_prompt_lanes.sh +48 -0
- package/scripts/test_regression_guard_ci_lanes.sh +124 -0
- package/templates/predelete_check.test.sh +56 -0
- package/templates/regression_guard.sh +75 -3
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# test_prepush_destructive_lanes.sh — known pairs for the pre-push hook's DESTRUCTIVE-OP verdict.
|
|
3
|
+
#
|
|
4
|
+
# ── WHY THIS FILE EXISTS (the hole it closes) ────────────────────────────────────────────────
|
|
5
|
+
# CLAUDE.md §Destructive-Op Gate names `templates/.git-hooks/pre-push` as the MECHANICAL FLOOR for
|
|
6
|
+
# the git-side irreversible surfaces (remote branch delete · force / non-ff push · tag delete), and
|
|
7
|
+
# is explicit that `templates/predelete_check.sh` is the operator's HUMAN enumerate tool which no
|
|
8
|
+
# hook executes. So the floor is the hook's own inline per-ref verdict block (pre-push:595-677 —
|
|
9
|
+
# banner at :595, `BLOCK=0` at :598, file ends :677; re-measured 2026-08-22, the old "600-676"
|
|
10
|
+
# was approximate).
|
|
11
|
+
#
|
|
12
|
+
# Measured 2026-08-22, bookshelf pass before writing a line of this file:
|
|
13
|
+
# • scripts/test_destructive_pre_gate_lanes.sh anchors scripts/destructive_pre_gate.sh — the
|
|
14
|
+
# PreToolUse *advisory text-pattern* guard over a proposed command. A DIFFERENT subject.
|
|
15
|
+
# • scripts/prepush_guard_check.sh anchors the same hook but only its PUBLISH boundary: all 20 of
|
|
16
|
+
# its pairs are confidentiality / main-PR-only / tag-version. Grepped for delete|force verdict
|
|
17
|
+
# pairs: ZERO — measured with a known-positive control (the same grep hits 14 times in THIS
|
|
18
|
+
# file, so the zero is a measurement and not a dead grep).
|
|
19
|
+
# ⚠️ "13" stood here until 2026-08-22 and was wrong; the count is 20. The `ZERO` half was
|
|
20
|
+
# re-measured with the control above and survived. A count nobody re-runs decays silently.
|
|
21
|
+
# • templates/predelete_check.test.sh anchors the enumerate tool, and WAS executed by nothing.
|
|
22
|
+
# ⚠️ Corrected 2026-08-22 R2: that present-tense claim went stale the same day it was written —
|
|
23
|
+
# .github/workflows/destructive-op-anchor.yml step 'Anchor 3/3' now runs it, and stage ⑥ of
|
|
24
|
+
# scripts/test_prepush_destructive_liveness.sh guards that runner. A file describing its own
|
|
25
|
+
# machine in a tense that no longer holds is [[feedback_rule_misdescribes_its_own_machine]];
|
|
26
|
+
# it is left visible as a correction rather than quietly overwritten.
|
|
27
|
+
# ⇒ The inline block that actually blocks a force-push or a branch delete had NO known-pair
|
|
28
|
+
# anchor anywhere, and therefore never re-ran in CI. An anchor that never re-runs cannot tell
|
|
29
|
+
# you the gate broke; it tells you it was correct once, on the author's machine.
|
|
30
|
+
#
|
|
31
|
+
# ── DISCIPLINE THIS SUITE INHERITS FROM ITS SIBLING (scripts/prepush_guard_check.sh) ──────────
|
|
32
|
+
# (a) Run the hook FOR REAL. `bash -n` is not an instrument: a `${...}` bad substitution is a
|
|
33
|
+
# RUNTIME fault that parses clean, aborts the hook, and still exits 0 — every push allowed.
|
|
34
|
+
# (b) A runtime fault is checked BEFORE the verdict, else an aborted hook scores as a clean pass.
|
|
35
|
+
# (c) "It blocked" is NOT "it blocked correctly". A missing dependency also exits non-zero and
|
|
36
|
+
# would score every BLOCK pair green while the gate was broken. So a block must NAME a
|
|
37
|
+
# destructive cause; a block for a harness reason is reported as its own distinct failure.
|
|
38
|
+
# (d) A pass must show its marker line — proof the hook ran far enough to make a claim. A hook
|
|
39
|
+
# killed by a signal prints no fault text and rc alone would read as a pass.
|
|
40
|
+
#
|
|
41
|
+
# ── 🟥 WHAT THIS SUITE CLAIMS, AND WHAT IT DOES NOT (narrowed 2026-08-22 R3) ──────────────────
|
|
42
|
+
# It claims: on THESE 12 constructed inputs, the hook reached a verdict, the verdict matched the
|
|
43
|
+
# expected direction, and the hook ATTRIBUTED it to the named cause. That is a known-pair anchor.
|
|
44
|
+
# It does NOT claim to be an analyzer of the hook's execution semantics. Two places where this
|
|
45
|
+
# suite, like its liveness control, matches FORM rather than meaning — named rather than implied:
|
|
46
|
+
# • (a)/(b)'s runtime-fault detector is a fixed vocabulary of bash's own error strings
|
|
47
|
+
# (bad substitution · unbound variable · syntax error · command not found). A runtime fault
|
|
48
|
+
# that words itself differently, or one whose message goes to a closed fd, is not recognised
|
|
49
|
+
# and the lane falls through to the verdict check. Deliberately a vocabulary and not a
|
|
50
|
+
# `set -e` harness: the failure it guards against (a parse-clean `${...}` fault aborting the
|
|
51
|
+
# hook while it exits 0) does emit one of these, and every widening of the list adds false
|
|
52
|
+
# "RUNTIME FAULT" reds on hooks that merely print the word.
|
|
53
|
+
# • (c)/(d)'s attribution is `grep` over the hook's own output. It establishes that the hook
|
|
54
|
+
# SAID the cause, not that the code path that said it is the one that decided.
|
|
55
|
+
# Neither is a defect to be repaired by a bigger regex — a regex chasing shell semantics loses at
|
|
56
|
+
# the edges in both directions at once, which is the class that produced the R3 findings. The
|
|
57
|
+
# thing that settles these is the hook running for real against a real destructive ref, which is
|
|
58
|
+
# what each lane below actually does.
|
|
59
|
+
#
|
|
60
|
+
# Runs entirely in mktemp throwaway repos: never touches this repo's index, worktree, or refs.
|
|
61
|
+
# Portability: git + coreutils only. No `stat -f` (BSD-first breaks the Linux runner), no
|
|
62
|
+
# `|| echo 0` pipefail fallbacks (that disarms the very guard being measured).
|
|
63
|
+
#
|
|
64
|
+
# Usage: bash scripts/test_prepush_destructive_lanes.sh → exit 0 all pairs hold, 1 otherwise.
|
|
65
|
+
set -uo pipefail
|
|
66
|
+
|
|
67
|
+
# FH_TEST_SUBJECT_ROOT points the suite at a COPY of the tree. It exists for the revert probe
|
|
68
|
+
# ("disable the gate on a copy — does exactly this suite go red?"), which is the only way to tell a
|
|
69
|
+
# live anchor from a decorative one without mutating a shared checkout. It selects WHICH subject is
|
|
70
|
+
# measured; it changes no verdict logic and cannot turn a red lane green.
|
|
71
|
+
REPO_ROOT="${FH_TEST_SUBJECT_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"
|
|
72
|
+
HOOK_SRC="$REPO_ROOT/templates/.git-hooks/pre-push"
|
|
73
|
+
DEF_SRC="$REPO_ROOT/.claude/rules/.public-surface-patterns.defaults"
|
|
74
|
+
ZERO="0000000000000000000000000000000000000000"
|
|
75
|
+
|
|
76
|
+
# Fail-closed on a missing subject. A suite that cannot find what it measures reports HARNESS_ERROR
|
|
77
|
+
# and exits non-zero — it never renders "could not measure" as a zero-findings pass.
|
|
78
|
+
if [ ! -f "$HOOK_SRC" ]; then
|
|
79
|
+
echo "HARNESS_ERROR — pre-push hook not found at $HOOK_SRC (subject absent; NOT a pass)"; exit 1
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
# Test the STAGED blob when the hook is staged, same reasoning as the sibling anchor: an anchor that
|
|
83
|
+
# reads the worktree is bypassed by staging a regression and restoring the worktree.
|
|
84
|
+
WORK=$(mktemp -d) || exit 1
|
|
85
|
+
trap 'rm -rf "$WORK"' EXIT
|
|
86
|
+
_status=$(git -C "$REPO_ROOT" -c core.quotePath=false diff --cached --name-status --no-renames 2>/dev/null \
|
|
87
|
+
| awk -F'\t' '$2 == "templates/.git-hooks/pre-push" { print $1; exit }')
|
|
88
|
+
case "$_status" in
|
|
89
|
+
D) echo "❌ FAIL — pre-push is being DELETED from the index — fail-closed."; exit 1 ;;
|
|
90
|
+
'') cp "$HOOK_SRC" "$WORK/hook" ;;
|
|
91
|
+
*) git -C "$REPO_ROOT" show ":templates/.git-hooks/pre-push" > "$WORK/hook" 2>/dev/null \
|
|
92
|
+
|| { echo "❌ FAIL — staged pre-push blob unreadable — fail-closed."; exit 1; } ;;
|
|
93
|
+
esac
|
|
94
|
+
HOOK="$WORK/hook"
|
|
95
|
+
|
|
96
|
+
PASSED=0; FAILED=0
|
|
97
|
+
|
|
98
|
+
# ── fixture ──────────────────────────────────────────────────────────────────────────────────
|
|
99
|
+
# A repo with: main, a real `refs/remotes/origin/main` (the hook's default BASE is `origin/main`
|
|
100
|
+
# and an unresolvable base is itself one of the lanes — it must be resolvable everywhere else, or
|
|
101
|
+
# every delete lane would block for the WRONG reason and the suite would be green for nothing).
|
|
102
|
+
newrepo() {
|
|
103
|
+
local d; d=$(mktemp -d) || return 1
|
|
104
|
+
mkdir -p "$d/.claude/rules" "$d/templates/.git-hooks" "$d/tracks/_meta" "$d/scripts" || return 1
|
|
105
|
+
[ -f "$DEF_SRC" ] && cp "$DEF_SRC" "$d/.claude/rules/.public-surface-patterns.defaults"
|
|
106
|
+
[ -f "$REPO_ROOT/scripts/psa_scan_lib.sh" ] && cp "$REPO_ROOT/scripts/psa_scan_lib.sh" "$d/scripts/psa_scan_lib.sh"
|
|
107
|
+
printf '.claude/rules/.public-surface-patterns\n' > "$d/.gitignore"
|
|
108
|
+
cp "$HOOK" "$d/templates/.git-hooks/pre-push" || return 1
|
|
109
|
+
printf 'base\n' > "$d/a.txt"
|
|
110
|
+
(
|
|
111
|
+
cd "$d" || exit 1
|
|
112
|
+
# `git init -b main` needs git >= 2.28 and is rejected outright by anything older ("unknown
|
|
113
|
+
# switch `b'", rc 129). scripts/test_stale_clone_guard_lanes.sh:34 already builds its fixture
|
|
114
|
+
# via symbolic-ref for exactly this reason; this suite did not, so on an older git
|
|
115
|
+
# it died in SETUP — see the require_repo note below for why that was worse than a red lane.
|
|
116
|
+
# symbolic-ref also pins the branch name against init.defaultBranch differing per machine
|
|
117
|
+
# (main on this operator's, master on a stock image) — the fixture's `main` is load-bearing:
|
|
118
|
+
# the P4 PROTECTED lane and the origin/main base ref both name it.
|
|
119
|
+
git init -q || exit 1
|
|
120
|
+
git symbolic-ref HEAD refs/heads/main || exit 1
|
|
121
|
+
git config user.email t@example.com || exit 1
|
|
122
|
+
git config user.name t || exit 1
|
|
123
|
+
git add -A >/dev/null 2>&1 || exit 1
|
|
124
|
+
git commit -qm base >/dev/null 2>&1 || exit 1
|
|
125
|
+
# Materialise the base ref the hook resolves against.
|
|
126
|
+
git update-ref refs/remotes/origin/main HEAD || exit 1
|
|
127
|
+
) || return 1
|
|
128
|
+
printf '%s' "$d"
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
# 🟥 SETUP FAILURE MUST BE LOUD — and until 2026-08-22 it was the opposite of loud.
|
|
132
|
+
# `newrepo` signals failure by returning 1 without echoing, so `R=$(newrepo)` leaves R EMPTY.
|
|
133
|
+
# `cd ""` is a NO-OP SUCCESS in bash (measured: `cd /tmp; cd "" ; pwd` → /tmp; control:
|
|
134
|
+
# `cd /no/such/dir` → rc 1). So every `( cd "$repo" && ... )` in this file silently ran in the
|
|
135
|
+
# CURRENT directory — this repo — and the lanes graded the operator's REAL tree.
|
|
136
|
+
# Measured on a git<2.28 shim, pre-fix: 6 passed / 6 failed, with P7 and P8 scoring **PASS** off
|
|
137
|
+
# the real repo's own hook output. That is the [[feedback_not_found_is_not_zero_family]] shape at
|
|
138
|
+
# its quietest: not a missing measurement rendered as zero, but a FAILED fixture rendered as a
|
|
139
|
+
# green lane, on the irreversible surface this suite exists to guard. The TOTAL==0 dead-instrument
|
|
140
|
+
# control at the bottom cannot see it either — the lanes did run; they ran against the wrong thing.
|
|
141
|
+
require_repo() { # $1 = candidate repo path, $2 = lane name
|
|
142
|
+
if [ -z "${1:-}" ] || [ ! -d "$1/.git" ]; then
|
|
143
|
+
echo "HARNESS_ERROR — fixture repo not built for $2 (setup failed; NOT a pass)"
|
|
144
|
+
echo " path='${1:-}' — an empty path makes \`cd\` a no-op, so this lane would have graded"
|
|
145
|
+
echo " the REAL working tree instead of a throwaway fixture. Aborting rather than scoring."
|
|
146
|
+
exit 1
|
|
147
|
+
fi
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
# check <name> <repo> <expect: block|pass> <cause-regex> <refline...>
|
|
151
|
+
# cause-regex — what the verdict must be ATTRIBUTED to. For a block, the hook must name this
|
|
152
|
+
# destructive cause; for a pass, this marker must appear. Both directions require the hook to
|
|
153
|
+
# have reached the point of making a claim, so neither can be satisfied by an abort.
|
|
154
|
+
check() {
|
|
155
|
+
local name="$1" repo="$2" expect="$3" cause="$4"; shift 4
|
|
156
|
+
local out rc got
|
|
157
|
+
require_repo "$repo" "$name" # fail-closed: never grade a lane whose fixture did not build
|
|
158
|
+
out=$(printf '%s\n' "$@" | ( cd "$repo" && bash templates/.git-hooks/pre-push origin git@example:x/y.git 2>&1 )); rc=$?
|
|
159
|
+
|
|
160
|
+
# (b) runtime fault first — an aborted hook is not a hook that passed.
|
|
161
|
+
if printf '%s' "$out" | grep -qiE 'bad substitution|unbound variable|syntax error|command not found'; then
|
|
162
|
+
echo " ❌ $name — RUNTIME FAULT in the hook (aborted, not passed)"
|
|
163
|
+
printf '%s\n' "$out" | grep -iE 'bad substitution|unbound|syntax error|command not found' | sed 's/^/ /' | head -3
|
|
164
|
+
FAILED=$((FAILED+1)); return
|
|
165
|
+
fi
|
|
166
|
+
|
|
167
|
+
if [ "$rc" -ne 0 ]; then
|
|
168
|
+
# (c) blocked — but was it blocked for a DESTRUCTIVE reason? A harness error also exits 1.
|
|
169
|
+
if printf '%s' "$out" | grep -qE 'FH Destructive-Op Gate'; then
|
|
170
|
+
got=block
|
|
171
|
+
else
|
|
172
|
+
echo " ❌ $name — blocked, but NOT by the Destructive-Op gate (harness reason ≠ finding)"
|
|
173
|
+
printf '%s\n' "$out" | sed 's/^/ | /' | head -8
|
|
174
|
+
FAILED=$((FAILED+1)); return
|
|
175
|
+
fi
|
|
176
|
+
else
|
|
177
|
+
got=pass
|
|
178
|
+
fi
|
|
179
|
+
|
|
180
|
+
if [ "$got" != "$expect" ]; then
|
|
181
|
+
echo " ❌ $name — expected $expect, got $got"
|
|
182
|
+
printf '%s\n' "$out" | sed 's/^/ | /' | head -10
|
|
183
|
+
FAILED=$((FAILED+1)); return
|
|
184
|
+
fi
|
|
185
|
+
|
|
186
|
+
# (d) the verdict must be attributed — for BOTH directions.
|
|
187
|
+
if ! printf '%s' "$out" | grep -qE "$cause"; then
|
|
188
|
+
echo " ❌ $name — verdict $got is correct but UNATTRIBUTED (missing: $cause)"
|
|
189
|
+
printf '%s\n' "$out" | sed 's/^/ | /' | head -10
|
|
190
|
+
FAILED=$((FAILED+1)); return
|
|
191
|
+
fi
|
|
192
|
+
|
|
193
|
+
echo " ✅ $name (expected $expect)"
|
|
194
|
+
PASSED=$((PASSED+1))
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
echo "[prepush-destructive] known-pair anchor for the pre-push destructive-op verdict"
|
|
198
|
+
echo ""
|
|
199
|
+
echo "── KNOWN-NEGATIVE (must PASS — over-blocking trains the override that disarms the gate) ──"
|
|
200
|
+
|
|
201
|
+
# N1 — ordinary fast-forward push of a feature branch. Nothing destructive.
|
|
202
|
+
# Marker: the hook must reach the publish check, proving it ran past classification.
|
|
203
|
+
R=$(newrepo)
|
|
204
|
+
require_repo "$R" "N1"
|
|
205
|
+
B=$(cd "$R" && git rev-parse HEAD)
|
|
206
|
+
( cd "$R" && printf 'x\n' >> a.txt && git commit -qam ff >/dev/null )
|
|
207
|
+
check "N1 ordinary fast-forward push → PASS " "$R" pass 'FH Pre-Publish' \
|
|
208
|
+
"refs/heads/feat $(cd "$R" && git rev-parse HEAD) refs/heads/feat $B"
|
|
209
|
+
rm -rf "$R"
|
|
210
|
+
|
|
211
|
+
# N2 — deleting a FULLY MERGED branch. The enumerate is load-bearing: nothing unique is lost,
|
|
212
|
+
# so the gate must allow it. This is the lane that proves the gate is not a blanket deny.
|
|
213
|
+
R=$(newrepo)
|
|
214
|
+
require_repo "$R" "N2"
|
|
215
|
+
( cd "$R" && git branch merged-branch ) >/dev/null 2>&1
|
|
216
|
+
TIP=$(cd "$R" && git rev-parse merged-branch)
|
|
217
|
+
check "N2 delete FULLY-MERGED branch → PASS " "$R" pass 'SAFE: fully merged' \
|
|
218
|
+
"(delete) $ZERO refs/heads/merged-branch $TIP"
|
|
219
|
+
rm -rf "$R"
|
|
220
|
+
|
|
221
|
+
echo ""
|
|
222
|
+
echo "── KNOWN-POSITIVE (must BLOCK — and be attributed to the right destructive cause) ──"
|
|
223
|
+
|
|
224
|
+
# P1 — force / non-fast-forward push (history rewrite). Always blocks: a rewrite loses commits.
|
|
225
|
+
R=$(newrepo)
|
|
226
|
+
require_repo "$R" "P1"
|
|
227
|
+
B=$(cd "$R" && git rev-parse HEAD)
|
|
228
|
+
( cd "$R" && printf 'x\n' >> a.txt && git commit -qam one >/dev/null \
|
|
229
|
+
&& git checkout -q --detach "$B" && printf 'y\n' >> a.txt && git commit -qam divergent >/dev/null )
|
|
230
|
+
check "P1 FORCE / non-ff push → BLOCK" "$R" block 'FORCE / non-fast-forward' \
|
|
231
|
+
"refs/heads/feat $(cd "$R" && git rev-parse HEAD) refs/heads/feat $(cd "$R" && git rev-parse main)"
|
|
232
|
+
rm -rf "$R"
|
|
233
|
+
|
|
234
|
+
# P2 — delete a branch carrying UNIQUE PATHS → REVIEW. Recovery is mandatory before deleting.
|
|
235
|
+
R=$(newrepo)
|
|
236
|
+
require_repo "$R" "P2"
|
|
237
|
+
( cd "$R" && git checkout -q -b unique-work && printf 'only here\n' > unique.txt \
|
|
238
|
+
&& git add unique.txt && git commit -qm unique >/dev/null && git checkout -q main )
|
|
239
|
+
TIP=$(cd "$R" && git rev-parse unique-work)
|
|
240
|
+
check "P2 delete branch w/ UNIQUE PATHS → BLOCK" "$R" block 'REVIEW: .* unique path' \
|
|
241
|
+
"(delete) $ZERO refs/heads/unique-work $TIP"
|
|
242
|
+
rm -rf "$R"
|
|
243
|
+
|
|
244
|
+
# P3 — delete a branch with commits off base but ZERO unique paths → CHECK. This is the SILENT
|
|
245
|
+
# loss class: a shared file (an unmerged session card) may hold NEWER content. A gate that
|
|
246
|
+
# only looked at unique paths would auto-SAFE this one.
|
|
247
|
+
R=$(newrepo)
|
|
248
|
+
require_repo "$R" "P3"
|
|
249
|
+
( cd "$R" && git checkout -q -b newer-content && printf 'newer\n' >> a.txt \
|
|
250
|
+
&& git commit -qam newer >/dev/null && git checkout -q main )
|
|
251
|
+
TIP=$(cd "$R" && git rev-parse newer-content)
|
|
252
|
+
check "P3 delete branch, 0 uniq but NEWER → BLOCK" "$R" block 'CHECK: .* commit' \
|
|
253
|
+
"(delete) $ZERO refs/heads/newer-content $TIP"
|
|
254
|
+
rm -rf "$R"
|
|
255
|
+
|
|
256
|
+
# P4 — delete the INTEGRATION branch. Trivially "merged into itself" (n=0, uniq=0), so without an
|
|
257
|
+
# explicit guard it would auto-pass the SAFE branch. The most dangerous auto-pass in the block.
|
|
258
|
+
R=$(newrepo)
|
|
259
|
+
require_repo "$R" "P4"
|
|
260
|
+
TIP=$(cd "$R" && git rev-parse main)
|
|
261
|
+
check "P4 delete INTEGRATION branch (main) → BLOCK" "$R" block 'PROTECTED' \
|
|
262
|
+
"(delete) $ZERO refs/heads/main $TIP"
|
|
263
|
+
rm -rf "$R"
|
|
264
|
+
|
|
265
|
+
# P5 — delete a TAG. predelete_check walks branches only, so tags have no unique-path verdict; a
|
|
266
|
+
# release tag is an external anchor and deleting it is irreversible for consumers.
|
|
267
|
+
R=$(newrepo)
|
|
268
|
+
require_repo "$R" "P5"
|
|
269
|
+
( cd "$R" && git tag v9.9.9 ) >/dev/null 2>&1
|
|
270
|
+
TIP=$(cd "$R" && git rev-parse v9.9.9)
|
|
271
|
+
check "P5 delete TAG (non-branch ref) → BLOCK" "$R" block 'DELETE \(non-branch ref\)' \
|
|
272
|
+
"(delete) $ZERO refs/tags/v9.9.9 $TIP"
|
|
273
|
+
rm -rf "$R"
|
|
274
|
+
|
|
275
|
+
# P6 — remote tip not fetched. An unfetched tip makes a force indistinguishable from a
|
|
276
|
+
# fast-forward, so "cannot decide" must never render as "allowed".
|
|
277
|
+
#
|
|
278
|
+
# 🟥 MEASURED WHILE WRITING THIS SUITE — the destructive block's `CANNOT CLASSIFY` branch is
|
|
279
|
+
# SHADOWED on the default path. The same condition (remote_sha absent locally) also makes the
|
|
280
|
+
# push RANGE unreadable, and the confidentiality guard fail-closes at pre-push:357 — before
|
|
281
|
+
# classification at :598 ever runs. The first draft of this lane asserted the destructive
|
|
282
|
+
# cause, went red, and the honest diagnosis was that the lane's expectation was wrong, not
|
|
283
|
+
# the hook. Two lanes now, because they assert different things:
|
|
284
|
+
# P6a — the SAFETY property on the path a real push takes: it fail-closes. Whichever guard
|
|
285
|
+
# wins, the push does not proceed. This is what protects the operator.
|
|
286
|
+
# P6b — the destructive branch itself, reached by unshadowing the earlier guard with
|
|
287
|
+
# PUBLIC_SURFACE_OK=1. Without this lane that code path is UNMEASURED, and an
|
|
288
|
+
# unmeasured branch is where a silent regression lives.
|
|
289
|
+
# Named residual, not closed here: on the default path :609's CANNOT CLASSIFY line is
|
|
290
|
+
# unreachable. Both guards fail closed so this is not a safety hole — it is a decorative
|
|
291
|
+
# line, and it is recorded rather than deleted because deleting it is a hook change and this
|
|
292
|
+
# file is an anchor, not a repair.
|
|
293
|
+
R=$(newrepo)
|
|
294
|
+
require_repo "$R" "P6"
|
|
295
|
+
( cd "$R" && printf 'x\n' >> a.txt && git commit -qam ff >/dev/null )
|
|
296
|
+
FAKE=deadbeefdeadbeefdeadbeefdeadbeefdeadbeef
|
|
297
|
+
# Asserted directly, NOT through check(): check() requires a block to be attributed to the
|
|
298
|
+
# destructive gate, and here a DIFFERENT guard legitimately wins. Reusing check() would either
|
|
299
|
+
# fail a correct behaviour or force the attribution test to be loosened for every other lane —
|
|
300
|
+
# and that test is what stops a harness error from scoring as a finding.
|
|
301
|
+
out=$(printf 'refs/heads/feat %s refs/heads/feat %s\n' "$(cd "$R" && git rev-parse HEAD)" "$FAKE" \
|
|
302
|
+
| ( cd "$R" && bash templates/.git-hooks/pre-push origin git@example:x/y.git 2>&1 )); rc=$?
|
|
303
|
+
if [ "$rc" -ne 0 ] && printf '%s' "$out" | grep -qF 'unread history is not a clean one'; then
|
|
304
|
+
echo " ✅ P6a remote tip NOT FETCHED → BLOCK, fail-closed (push-range guard wins; see note)"
|
|
305
|
+
PASSED=$((PASSED+1))
|
|
306
|
+
else
|
|
307
|
+
echo " ❌ P6a remote tip NOT FETCHED — expected a fail-closed block, rc=$rc"
|
|
308
|
+
printf '%s\n' "$out" | sed 's/^/ | /' | head -8; FAILED=$((FAILED+1))
|
|
309
|
+
fi
|
|
310
|
+
|
|
311
|
+
out=$(printf 'refs/heads/feat %s refs/heads/feat %s\n' "$(cd "$R" && git rev-parse HEAD)" "$FAKE" \
|
|
312
|
+
| ( cd "$R" && PUBLIC_SURFACE_OK=1 bash templates/.git-hooks/pre-push origin git@example:x/y.git 2>&1 )); rc=$?
|
|
313
|
+
if [ "$rc" -ne 0 ] && printf '%s' "$out" | grep -qF 'CANNOT CLASSIFY (remote tip not fetched)'; then
|
|
314
|
+
echo " ✅ P6b CANNOT CLASSIFY branch (unshadowed) → BLOCK (expected block)"; PASSED=$((PASSED+1))
|
|
315
|
+
else
|
|
316
|
+
echo " ❌ P6b CANNOT CLASSIFY branch (unshadowed) — expected an attributed block, rc=$rc"
|
|
317
|
+
printf '%s\n' "$out" | sed 's/^/ | /' | head -8; FAILED=$((FAILED+1))
|
|
318
|
+
fi
|
|
319
|
+
rm -rf "$R"
|
|
320
|
+
|
|
321
|
+
# P7 — base ref unresolvable → ALL branch deletes blocked. Same fail-closed direction as P6, on a
|
|
322
|
+
# different input: the gate cannot verify SAFE, so it must not grant SAFE.
|
|
323
|
+
R=$(newrepo)
|
|
324
|
+
require_repo "$R" "P7"
|
|
325
|
+
( cd "$R" && git branch merged-branch && git update-ref -d refs/remotes/origin/main ) >/dev/null 2>&1
|
|
326
|
+
TIP=$(cd "$R" && git rev-parse merged-branch)
|
|
327
|
+
check "P7 base ref UNRESOLVABLE → BLOCK" "$R" block "unresolvable" \
|
|
328
|
+
"(delete) $ZERO refs/heads/merged-branch $TIP"
|
|
329
|
+
rm -rf "$R"
|
|
330
|
+
|
|
331
|
+
echo ""
|
|
332
|
+
echo "── OVERRIDE CHANNEL (explicit + logged — the only sanctioned way past a real block) ──"
|
|
333
|
+
|
|
334
|
+
# P8 — DESTRUCTIVE_OP_OK=1 converts P2's REVIEW block into an allow, AND must leave a record.
|
|
335
|
+
# Two assertions, because an override that proceeds without logging is an UNRECORDED
|
|
336
|
+
# irreversible act — the override channel's whole value is the audit trail it leaves.
|
|
337
|
+
R=$(newrepo)
|
|
338
|
+
require_repo "$R" "P8"
|
|
339
|
+
( cd "$R" && git checkout -q -b unique-work && printf 'only here\n' > unique.txt \
|
|
340
|
+
&& git add unique.txt && git commit -qm unique >/dev/null && git checkout -q main )
|
|
341
|
+
TIP=$(cd "$R" && git rev-parse unique-work)
|
|
342
|
+
out=$(printf '%s\n' "(delete) $ZERO refs/heads/unique-work $TIP" \
|
|
343
|
+
| ( cd "$R" && DESTRUCTIVE_OP_OK=1 bash templates/.git-hooks/pre-push origin git@example:x/y.git 2>&1 )); rc=$?
|
|
344
|
+
if [ "$rc" -eq 0 ] && printf '%s' "$out" | grep -qF 'allowed by DESTRUCTIVE_OP_OK=1'; then
|
|
345
|
+
echo " ✅ P8 DESTRUCTIVE_OP_OK=1 overrides REVIEW → PASS (expected pass)"; PASSED=$((PASSED+1))
|
|
346
|
+
else
|
|
347
|
+
echo " ❌ P8 DESTRUCTIVE_OP_OK=1 overrides REVIEW — expected allow, rc=$rc"
|
|
348
|
+
printf '%s\n' "$out" | sed 's/^/ | /' | head -8; FAILED=$((FAILED+1))
|
|
349
|
+
fi
|
|
350
|
+
if [ -s "$R/tracks/_meta/.destructive_op_override_log" ]; then
|
|
351
|
+
echo " ✅ P8b override was LOGGED (unrecorded override would defeat the channel)"; PASSED=$((PASSED+1))
|
|
352
|
+
else
|
|
353
|
+
echo " ❌ P8b override proceeded but wrote NO log entry"; FAILED=$((FAILED+1))
|
|
354
|
+
fi
|
|
355
|
+
rm -rf "$R"
|
|
356
|
+
|
|
357
|
+
echo ""
|
|
358
|
+
# Dead-instrument control. If the suite somehow ran zero pairs, that is HARNESS_ERROR — never a
|
|
359
|
+
# pass. `all/any/count==0` all read clean on an empty set; this is the explicit empty-input answer.
|
|
360
|
+
TOTAL=$((PASSED+FAILED))
|
|
361
|
+
if [ "$TOTAL" -eq 0 ]; then
|
|
362
|
+
echo "HARNESS_ERROR — prepush-destructive 캘리브레이션: 0 pairs executed (dead instrument, NOT a pass)"
|
|
363
|
+
exit 1
|
|
364
|
+
fi
|
|
365
|
+
echo "prepush-destructive 캘리브레이션: $PASSED passed, $FAILED failed ($TOTAL pairs)"
|
|
366
|
+
[ "$FAILED" -eq 0 ]
|
|
@@ -123,6 +123,54 @@ chk "C1 입력이 JSON 이 아니면 무음 exit 0" \
|
|
|
123
123
|
"$(printf 'not json' | bash "$H" >/dev/null 2>&1; echo $?)" 0
|
|
124
124
|
chk "C2 file_path 없으면 무음" "$(printf '{"tool_input":{}}' | bash "$H" 2>/dev/null | wc -c | tr -d ' ')" 0
|
|
125
125
|
|
|
126
|
+
echo "── T2 재무장 (2026-08-22): 세션당 1회가 T2 를 구조적으로 못 잡던 자리 ──"
|
|
127
|
+
# 🟥 실측 기반 픽스처다. 한 세션에서 새 메커니즘 3건이 08:38 · 13:06 · 13:07 에 났고, 세션당 1회는
|
|
128
|
+
# 첫 건만 띄웠다. 뒤의 둘이 정확히 이 훅이 존재 이유로 적어둔 T2 다. 시각은 주입한다 —
|
|
129
|
+
# 4.5시간을 실시간으로 기다리는 앵커는 아무도 안 돌린다.
|
|
130
|
+
_T1=1787387902 # 08:38:22Z
|
|
131
|
+
_T2=1787404013 # 13:06:53Z (+16111s = 4h28m)
|
|
132
|
+
_T3=1787404067 # 13:07:47Z (+54s — T2 와 **같은 메커니즘**: 스크립트와 그 레인 스위트)
|
|
133
|
+
DT=$(mktemp -d); export CLAUDE_PROJECT_DIR="$DT"
|
|
134
|
+
_fire() { # $1=NOW $2=name → 발화면 1
|
|
135
|
+
printf '{"session_id":"t2rearm","tool_input":{"file_path":"%s/scripts/%s"}}' "$DT" "$2" \
|
|
136
|
+
| PRIOR_ART_NOW="$1" bash "$H" 2>/dev/null | grep -c additionalContext | tr -d ' '
|
|
137
|
+
}
|
|
138
|
+
chk "T2-1 첫 메커니즘 → 발화" "$(_fire $_T1 m1.sh)" 1
|
|
139
|
+
chk "T2-2 4h28m 뒤 새 메커니즘 → **재발화** (이 수리의 요점)" "$(_fire $_T2 m2.sh)" 1
|
|
140
|
+
chk "T2-3 54초 뒤 같은 메커니즘의 레인 → 억제 (과발화 방지)" "$(_fire $_T3 m3.sh)" 0
|
|
141
|
+
# 과차단 컨트롤 — 메커니즘 하나짜리 평범한 세션에서 발화가 1회를 넘지 않는다.
|
|
142
|
+
rm -f "$DT/.claude/.prior_art_prompted_"* "$DT/.claude/.prior_art_events.tsv"
|
|
143
|
+
_n=$(( $(_fire $_T1 solo.sh) + $(_fire $((_T1+60)) solo_b.sh) + $(_fire $((_T1+120)) solo_c.sh) ))
|
|
144
|
+
chk "T2-4 과차단 컨트롤: 한 버스트(2분 내 3파일) → 발화 총 1회" "$_n" 1
|
|
145
|
+
# 로그가 실제로 남는가 — 이 상수(N)를 다음에 재정할 유일한 근거다.
|
|
146
|
+
rm -f "$DT/.claude/.prior_art_prompted_"* "$DT/.claude/.prior_art_events.tsv"
|
|
147
|
+
_fire $_T2 g1.sh >/dev/null; _fire $_T3 g2.sh >/dev/null # T2→T3 = 54s, 억제 구간
|
|
148
|
+
chk "T2-5 로그에 FIRE 와 SUPPRESS 가 둘 다 남는다" \
|
|
149
|
+
"$(awk -F'\t' '{print $2}' "$DT/.claude/.prior_art_events.tsv" 2>/dev/null | sort -u | tr '\n' ',' )" "FIRE,SUPPRESS,"
|
|
150
|
+
chk "T2-6 억제 로그가 경과초와 파일명을 같이 싣는다 (옳은 억제였는지 가르려면 필요)" \
|
|
151
|
+
"$(awk -F'\t' '$2=="SUPPRESS" && $4 ~ /^[0-9]+$/ && $5 ~ /g2\.sh$/ {n++} END{print n+0}' "$DT/.claude/.prior_art_events.tsv" 2>/dev/null)" 1
|
|
152
|
+
unset CLAUDE_PROJECT_DIR; rm -rf "$DT"
|
|
153
|
+
|
|
154
|
+
echo "── 특성화: 인용부호 안 텍스트를 빌드로 읽는다 (오발화 5번째 얼굴) ──"
|
|
155
|
+
# 🟥 2026-08-22 실측: 훅을 시험하려고 `echo` 인자 **안에** 픽스처 문자열을 넣은 호출에서 발화했다.
|
|
156
|
+
# 이 파일 머리가 센 cross-family 오발화 4종(tee 경계 · `2>` · 리포트가 .sh · 미확장 변수)의 **5번째**다.
|
|
157
|
+
# 🟥 이 레인은 «현재 동작»을 박는 특성화 레인이고, **수리됐다는 주장이 아니다.** 지금은 의도적으로
|
|
158
|
+
# 미수리다 — 인용 문맥을 정규식으로 가르는 것은 비싸고 표본이 1이다.
|
|
159
|
+
# ⚠️ 다음 사람에게: 정규식을 **넓히면** 이 클래스가 더 나빠진다. 이 줄이 그때 걸린다.
|
|
160
|
+
# 그리고 이 오발화를 실제로 **고쳤다면** 기대값을 1 → 0 으로 뒤집고 이 주석을 지워라.
|
|
161
|
+
# 픽스처는 실물에서 왔다 — 초판은 이스케이프가 뭉개져 «침묵» 이 나왔고, 그건 결함이 사라진 게
|
|
162
|
+
# 아니라 **재현을 못 한 것**이었다. 그래서 heredoc 으로 원문 그대로 넣는다.
|
|
163
|
+
# 🟥 자기 CLAUDE_PROJECT_DIR 를 반드시 준다. 초판은 안 줘서 스탬프가 **레포 안**에 쌓였고,
|
|
164
|
+
# 2회차부터 «침묵» 이 나왔다 — 탐지기가 아니라 스탬프가 억제한 것이라 결함이 사라진 것처럼
|
|
165
|
+
# 보였다. 계기가 자기 부작용에 오염되는 형태이고, 레인이 idempotent 하지 않다는 뜻이다.
|
|
166
|
+
_QD=$(mktemp -d)
|
|
167
|
+
_QJ=$(mktemp); cat > "$_QJ" <<'QEOF'
|
|
168
|
+
{"session_id":"q1","tool_input":{"command":"echo \"cat > scripts/not_real.sh <<EOF\""}}
|
|
169
|
+
QEOF
|
|
170
|
+
chk "Q1 [특성화·미수리] 인용문 안 텍스트에 발화한다" \
|
|
171
|
+
"$(CLAUDE_PROJECT_DIR="$_QD" bash "$H" < "$_QJ" 2>/dev/null | grep -c additionalContext | tr -d ' ')" 1
|
|
172
|
+
rm -f "$_QJ"; rm -rf "$_QD"
|
|
173
|
+
|
|
126
174
|
echo
|
|
127
175
|
if [ "$FAIL" -eq 0 ]; then echo "════ prior-art-prompt lanes: $PASS passed · 0 failed ════"; exit 0
|
|
128
176
|
else echo "🟥 prior-art-prompt lanes: $FAIL 실패 / $((PASS+FAIL))"; exit 1; fi
|
|
@@ -166,5 +166,129 @@ else
|
|
|
166
166
|
echo " ❌ revert probe neutralization was a no-op — the probe measured nothing"; FAIL=1
|
|
167
167
|
fi
|
|
168
168
|
|
|
169
|
+
echo "== script lanes — deleted vs emptied vs unreadable (the folded-branch fail-open) =="
|
|
170
|
+
# WHY (measured 2026-08-22, disposable repo, --staged, one variable at a time):
|
|
171
|
+
# the guard inferred "deleted" from a FAILED READ —
|
|
172
|
+
# read_after "$f" > /dev/null 2>&1 || continue
|
|
173
|
+
# [ -z "$(read_after "$f")" ] && continue
|
|
174
|
+
# — folding *deleted* (intentional), *emptied to 0 bytes* (total content loss) and *unreadable*
|
|
175
|
+
# (instrument error) into one branch whose direction is PASS:
|
|
176
|
+
# CONTROL harmless addition rc=0 M-tier 0 ✅ PASS
|
|
177
|
+
# POSITIVE its `## Done When` deleted rc=2 M-tier 2 ❌ BLOCK ← instrument discriminates
|
|
178
|
+
# 🟥 the SAME file truncated to 0 B rc=0 M-tier 0 ✅ PASS ← everything lost, green
|
|
179
|
+
# CLAUDE.md classifies a skill missing `Done When` as harness-doctor L2 M-tier; a skill with
|
|
180
|
+
# NOTHING passed. The fix asks git directly (`--diff-filter=D`) and gives the other two states
|
|
181
|
+
# their own verdicts — which is what this guard's OWN header (lines 12-19) already prescribed:
|
|
182
|
+
# exit 0 means PASS *or* not-checked, separated by a typed channel, never by silence.
|
|
183
|
+
G=$T/gr; mkdir -p "$G"
|
|
184
|
+
if git init -q "$G" 2>/dev/null; then
|
|
185
|
+
git -C "$G" config user.email lane@local; git -C "$G" config user.name lane
|
|
186
|
+
mkdir -p "$G/plugins/x/skills/y" "$G/templates"
|
|
187
|
+
cat > "$G/plugins/x/skills/y/SKILL.md" <<'EOF'
|
|
188
|
+
---
|
|
189
|
+
name: y
|
|
190
|
+
description: y skill
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## Execution Steps
|
|
194
|
+
1. do
|
|
195
|
+
|
|
196
|
+
## Done When
|
|
197
|
+
- done
|
|
198
|
+
|
|
199
|
+
## Triggers
|
|
200
|
+
- "y"
|
|
201
|
+
EOF
|
|
202
|
+
cp "$GUARD" "$G/templates/regression_guard.sh"
|
|
203
|
+
git -C "$G" add -A >/dev/null 2>&1
|
|
204
|
+
git -C "$G" commit -qm base >/dev/null 2>&1
|
|
205
|
+
BASE_TREE=$(git -C "$G" rev-parse HEAD)
|
|
206
|
+
|
|
207
|
+
greset() { git -C "$G" reset -q --hard "$BASE_TREE" >/dev/null 2>&1; git -C "$G" clean -qfd >/dev/null 2>&1; } # noqa: destructive-op (disposable lane repo)
|
|
208
|
+
grun() { # $1=guard path ; echoes "rc|<matched verdict line>"
|
|
209
|
+
local out rc
|
|
210
|
+
out=$(cd "$G" && bash "$1" --staged 2>&1); rc=$?
|
|
211
|
+
printf '%s|%s' "$rc" "$(printf '%s\n' "$out" | grep -E 'M-TIER|S-TIER' | head -1)"
|
|
212
|
+
}
|
|
213
|
+
glane() { # $1=id $2=expected rc $3=substring('' = none) $4=guard path
|
|
214
|
+
local r rc msg ok=1
|
|
215
|
+
r=$(grun "$4"); rc="${r%%|*}"; msg="${r#*|}"
|
|
216
|
+
[ "$rc" = "$2" ] || ok=0
|
|
217
|
+
[ -z "$3" ] || printf '%s' "$msg" | grep -qF -- "$3" || ok=0
|
|
218
|
+
if [ "$ok" -eq 1 ]; then
|
|
219
|
+
printf ' ✅ %-28s rc=%s %s\n' "$1" "$rc" "$(printf '%s' "$msg" | cut -c1-56)"
|
|
220
|
+
else
|
|
221
|
+
printf ' ❌ %-28s expected rc=%s /%s/, got rc=%s %s\n' "$1" "$2" "$3" "$rc" "$msg"; FAIL=1
|
|
222
|
+
fi
|
|
223
|
+
}
|
|
224
|
+
GP="$G/templates/regression_guard.sh"
|
|
225
|
+
|
|
226
|
+
# G1 — over-block control: an ordinary edit must stay green (a guard that blocks everything is
|
|
227
|
+
# not a strict guard, it trains --no-verify on the hook that also holds the Destructive-Op gate).
|
|
228
|
+
greset; printf '\n- extra\n' >> "$G/plugins/x/skills/y/SKILL.md"
|
|
229
|
+
git -C "$G" add -A >/dev/null 2>&1; glane G1-control-harmless 0 "" "$GP"
|
|
230
|
+
|
|
231
|
+
# G2 — known-positive: the instrument must still discriminate on the defect it always caught.
|
|
232
|
+
greset
|
|
233
|
+
python3 - "$G/plugins/x/skills/y/SKILL.md" <<'PY'
|
|
234
|
+
import sys
|
|
235
|
+
p = sys.argv[1]
|
|
236
|
+
# Read BEFORE opening for write: `open(p,"w")` truncates, and Python evaluates it before the
|
|
237
|
+
# inner read — the first draft of this fixture did exactly that and silently emptied the file,
|
|
238
|
+
# so the known-positive lane measured the emptied-file branch instead of the section-drop one.
|
|
239
|
+
c = open(p, encoding="utf-8").read()
|
|
240
|
+
open(p, "w", encoding="utf-8").write(c.replace("## Done When\n- done\n\n", ""))
|
|
241
|
+
PY
|
|
242
|
+
git -C "$G" add -A >/dev/null 2>&1; glane G2-done-when-deleted 2 "Done When" "$GP"
|
|
243
|
+
|
|
244
|
+
# G3 — THE HOLE: same file, truncated to zero bytes. Must now BLOCK as content loss.
|
|
245
|
+
greset; : > "$G/plugins/x/skills/y/SKILL.md"
|
|
246
|
+
git -C "$G" add -A >/dev/null 2>&1; glane G3-truncated-to-zero 2 "emptied" "$GP"
|
|
247
|
+
|
|
248
|
+
# G4 — over-block guard for the ORIGINAL comment's intent: a real deletion is still intentional
|
|
249
|
+
# and must still pass. Fixing the fail-open by blocking legitimate deletions is not a fix.
|
|
250
|
+
greset; git -C "$G" rm -q plugins/x/skills/y/SKILL.md >/dev/null 2>&1
|
|
251
|
+
glane G4-real-deletion-passes 0 "" "$GP"
|
|
252
|
+
|
|
253
|
+
# G5 — a NEW empty gated file is not content loss (nothing existed to lose), so it warns rather
|
|
254
|
+
# than blocks. Direction split on purpose: S-tier surfaces it, M-tier would over-block.
|
|
255
|
+
greset; mkdir -p "$G/plugins/x/skills/z"; : > "$G/plugins/x/skills/z/SKILL.md"
|
|
256
|
+
git -C "$G" add -A >/dev/null 2>&1; glane G5-new-empty-warns 1 "S-TIER" "$GP"
|
|
257
|
+
|
|
258
|
+
# revert probe — neutralize ONLY the emptied-file M-tier increment. G3 must go green again
|
|
259
|
+
# (reproducing the closed hole exactly) while G2 stays red: the branch, not its neighbours.
|
|
260
|
+
awk '
|
|
261
|
+
/M-TIER emptied:/ { seen = 1 }
|
|
262
|
+
seen && /M_TIER=\$\(\(M_TIER \+ 1\)\)/ { print " :"; seen = 0; next }
|
|
263
|
+
{ print }
|
|
264
|
+
' "$GP" > "$T/guard_neutered.sh"
|
|
265
|
+
if diff -q "$GP" "$T/guard_neutered.sh" >/dev/null; then
|
|
266
|
+
echo " ❌ revert probe (emptied) neutralization was a no-op — the probe measured nothing"; FAIL=1
|
|
267
|
+
else
|
|
268
|
+
greset; : > "$G/plugins/x/skills/y/SKILL.md"; git -C "$G" add -A >/dev/null 2>&1
|
|
269
|
+
r=$(grun "$T/guard_neutered.sh"); rc_n="${r%%|*}"
|
|
270
|
+
greset
|
|
271
|
+
python3 - "$G/plugins/x/skills/y/SKILL.md" <<'PY'
|
|
272
|
+
import sys
|
|
273
|
+
p = sys.argv[1]
|
|
274
|
+
# Read BEFORE opening for write: `open(p,"w")` truncates, and Python evaluates it before the
|
|
275
|
+
# inner read — the first draft of this fixture did exactly that and silently emptied the file,
|
|
276
|
+
# so the known-positive lane measured the emptied-file branch instead of the section-drop one.
|
|
277
|
+
c = open(p, encoding="utf-8").read()
|
|
278
|
+
open(p, "w", encoding="utf-8").write(c.replace("## Done When\n- done\n\n", ""))
|
|
279
|
+
PY
|
|
280
|
+
git -C "$G" add -A >/dev/null 2>&1
|
|
281
|
+
r2=$(grun "$T/guard_neutered.sh"); rc_k="${r2%%|*}"
|
|
282
|
+
if [ "$rc_n" = "0" ] && [ "$rc_k" = "2" ]; then
|
|
283
|
+
echo " ✅ revert probe (emptied) disarmed → G3 passes again (rc=0), G2 still blocks (rc=2)"
|
|
284
|
+
else
|
|
285
|
+
echo " ❌ revert probe (emptied) expected G3 rc=0 / G2 rc=2, got $rc_n / $rc_k"; FAIL=1
|
|
286
|
+
fi
|
|
287
|
+
fi
|
|
288
|
+
greset
|
|
289
|
+
else
|
|
290
|
+
printf ' ⚠️ %-28s git init unavailable — lanes SKIPPED (not passed)\n' "G-empty-vs-deleted"
|
|
291
|
+
fi
|
|
292
|
+
|
|
169
293
|
[ $FAIL -eq 0 ] && { echo "✅ all regression-guard CI lanes behave"; exit 0; }
|
|
170
294
|
echo "❌ regression-guard CI lane regression"; exit 1
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Regression test for predelete_check.sh — the mechanical anchor for the 2026-07-03 fail-closed fix
|
|
3
|
+
# (cross-family default-toward-PASS sweep). Reproduces each closed degrade-OPEN hole. bash-3.2 safe.
|
|
4
|
+
# Run: bash templates/predelete_check.test.sh (exit 0 = all pass)
|
|
5
|
+
set -u
|
|
6
|
+
HERE="$(cd "$(dirname "$0")" && pwd)"
|
|
7
|
+
SCRIPT="$HERE/predelete_check.sh"
|
|
8
|
+
TMP="$(mktemp -d)"
|
|
9
|
+
trap 'rm -rf "$TMP"' EXIT
|
|
10
|
+
pass=0; fail=0
|
|
11
|
+
ok(){ pass=$((pass+1)); echo " ok: $1"; }
|
|
12
|
+
no(){ fail=$((fail+1)); echo " FAIL: $1"; }
|
|
13
|
+
|
|
14
|
+
# helper: make a bare "origin" + a working clone with main
|
|
15
|
+
mkrepo(){
|
|
16
|
+
local d="$1"
|
|
17
|
+
( git init -q --bare "$d/origin.git"
|
|
18
|
+
git clone -q "$d/origin.git" "$d/wc" 2>/dev/null
|
|
19
|
+
cd "$d/wc"
|
|
20
|
+
git config user.email t@t; git config user.name t
|
|
21
|
+
echo base > a.txt; git add a.txt; git commit -qm base
|
|
22
|
+
git push -q origin HEAD:main 2>/dev/null
|
|
23
|
+
git branch -q -m main 2>/dev/null || true ) >/dev/null 2>&1
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
# 1. non-existent repo path → exit 2 (fail-closed, not 0)
|
|
27
|
+
"$SCRIPT" "$TMP/nope" >/dev/null 2>&1; rc=$?
|
|
28
|
+
[ "$rc" -eq 2 ] && ok "non-existent repo → exit 2" || no "non-existent repo exit=$rc (want 2)"
|
|
29
|
+
|
|
30
|
+
# 2. a dir that is not a git repo → exit 2
|
|
31
|
+
mkdir -p "$TMP/plain"; "$SCRIPT" "$TMP/plain" >/dev/null 2>&1; rc=$?
|
|
32
|
+
[ "$rc" -eq 2 ] && ok "non-git dir → exit 2" || no "non-git dir exit=$rc (want 2)"
|
|
33
|
+
|
|
34
|
+
# 3. unresolvable base ref → exit 2 (was: misclassified SAFE, exit 0)
|
|
35
|
+
D3="$TMP/r3"; mkrepo "$D3"
|
|
36
|
+
"$SCRIPT" "$D3/wc" origin/does-not-exist >/dev/null 2>&1; rc=$?
|
|
37
|
+
[ "$rc" -eq 2 ] && ok "bad base ref → exit 2" || no "bad base ref exit=$rc (want 2)"
|
|
38
|
+
|
|
39
|
+
# 4. a branch named 'main-backup' must NOT be substring-excluded — it must be enumerated
|
|
40
|
+
D4="$TMP/r4"; mkrepo "$D4"
|
|
41
|
+
( cd "$D4/wc"; git checkout -q -b main-backup; echo x > uniquefile.txt; git add uniquefile.txt
|
|
42
|
+
git commit -qm x; git push -q origin main-backup ) >/dev/null 2>&1
|
|
43
|
+
out=$("$SCRIPT" "$D4/wc" origin/main 2>/dev/null); rc=$?
|
|
44
|
+
echo "$out" | grep -q "main-backup" && ok "main-backup enumerated (not substring-skipped)" \
|
|
45
|
+
|| no "main-backup was NOT enumerated (substring-exclusion regression)"
|
|
46
|
+
[ "$rc" -eq 1 ] && ok "main-backup w/ unique path → REVIEW exit 1" || no "main-backup exit=$rc (want 1)"
|
|
47
|
+
|
|
48
|
+
# 5. a fully-merged branch → SAFE, exit 0
|
|
49
|
+
D5="$TMP/r5"; mkrepo "$D5"
|
|
50
|
+
( cd "$D5/wc"; git checkout -q -b merged; git push -q origin merged ) >/dev/null 2>&1
|
|
51
|
+
out=$("$SCRIPT" "$D5/wc" origin/main 2>/dev/null); rc=$?
|
|
52
|
+
{ echo "$out" | grep -q "SAFE merged" && [ "$rc" -eq 0 ]; } \
|
|
53
|
+
&& ok "merged branch → SAFE exit 0" || no "merged branch: $out (exit $rc)"
|
|
54
|
+
|
|
55
|
+
echo "---- predelete_check.test: $pass passed, $fail failed ----"
|
|
56
|
+
[ "$fail" -eq 0 ]
|