@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.
Files changed (56) hide show
  1. package/.claude-plugin/marketplace.json +4 -4
  2. package/AGENTS.md +7 -2
  3. package/CHEATSHEET.md +2 -2
  4. package/CLAUDE.md +5 -2
  5. package/docs/REFERENCE.md +4 -1
  6. package/knowledge/shared/harness-core/claude_md_full_reference.md +2 -0
  7. package/knowledge/shared/harness-core/claude_md_gate_details.md +8 -1
  8. package/knowledge/shared/harness-core/dispatch_conditional_prohibition.md +12 -0
  9. package/knowledge/shared/harness-core/fh_three_layer_canon.md +12 -0
  10. package/knowledge/shared/harness-core/measurement-integrity-checklist.md +16 -0
  11. package/knowledge/shared/learnings/subagent_invocations_log.yaml +161 -0
  12. package/package.json +4 -1
  13. package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
  14. package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
  15. package/plugins/fh-meta/CHANGELOG.md +41 -0
  16. package/plugins/fh-meta/skills/auto-decorrelation/SKILL.md +17 -0
  17. package/plugins/fh-meta/skills/phantom-quench/SKILL.md +1 -1
  18. package/plugins/fh-meta/skills/sim-conductor/SKILL.md +2 -2
  19. package/plugins/fh-meta/skills/sim-conductor/SKILL_detail.md +3 -3
  20. package/plugins/fh-meta/skills/steel-quench/SKILL.md +25 -1
  21. package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
  22. package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
  23. package/scripts/degrade_direction_scan.sh +43 -0
  24. package/scripts/dispatch_receipt.py +185 -0
  25. package/scripts/doc_claim_triad_scan.py +43 -4
  26. package/scripts/fh-gate.sh +71 -11
  27. package/scripts/finding_fleet.sh +15 -3
  28. package/scripts/mapped_tracks.sh +20 -13
  29. package/scripts/memory_gc_report.py +55 -5
  30. package/scripts/package_coverage_check.sh +5 -0
  31. package/scripts/pr_merge_verified.sh +56 -8
  32. package/scripts/selfcheck.sh +43 -20
  33. package/scripts/session_checklist.py +158 -14
  34. package/scripts/session_close_check.sh +1 -1
  35. package/scripts/sim_isolated_run.sh +62 -0
  36. package/scripts/stale_ref_scan.py +47 -3
  37. package/scripts/test_degrade_scan_shell_probes.sh +81 -0
  38. package/scripts/test_dispatch_receipt_lanes.sh +95 -0
  39. package/scripts/test_doc_claim_triad_lanes.sh +30 -0
  40. package/scripts/test_fh_audit_check_lanes.sh +10 -5
  41. package/scripts/test_fh_gate_regressions.sh +71 -1
  42. package/scripts/test_finding_pipeline_lanes.sh +83 -0
  43. package/scripts/test_hook_source_gate_lanes.sh +16 -2
  44. package/scripts/test_locale_invariance_lanes.sh +19 -0
  45. package/scripts/test_mapped_tracks_lanes.sh +55 -1
  46. package/scripts/test_memory_gc_report_lanes.sh +91 -1
  47. package/scripts/test_mutation_probe_lanes.sh +40 -8
  48. package/scripts/test_pr_merge_verified_lanes.sh +48 -1
  49. package/scripts/test_prepush_real_fire_lanes.sh +215 -0
  50. package/scripts/test_selfcheck_state_lanes.sh +32 -0
  51. package/scripts/test_session_checklist_lanes.sh +172 -0
  52. package/scripts/test_sim_isolated_run_lanes.sh +88 -0
  53. package/scripts/test_stale_ref_scan_lanes.sh +11 -1
  54. package/templates/.git-hooks/pre-push +82 -1
  55. package/templates/PRE-PUBLISH-CHECKLIST.md +10 -0
  56. package/templates/degrade_direction_scan.sh +43 -0
@@ -72,7 +72,9 @@ echo " ── ①-c peer 스캔: claude-agents 스코프 ──"
72
72
  CC="$D/session_close_check.sh"
73
73
  if [ -f "$CC" ]; then
74
74
  a=$(CLAUDE_CODE_CHILD_SESSION=1 bash "$CC" 2>/dev/null | grep -cE '^[^[:space:]]+ +①-c' || true)
75
- b=$(env -u CLAUDE_CODE_CHILD_SESSION -u CLAUDE_CODE_AGENT bash "$CC" 2>/dev/null | grep -cE '^[^[:space:]]+ +①-c' || true)
75
+ # 아래 ①-g 팔이 읽는다 — 체커가 스텁을 «안 불렀다» 와 «가리고 진짜를 불렀다» 는 다르다.
76
+ _CCOUT="$(env -u CLAUDE_CODE_CHILD_SESSION -u CLAUDE_CODE_AGENT bash "$CC" 2>/dev/null || true)"
77
+ b=$(printf '%s\n' "$_CCOUT" | grep -cE '^[^[:space:]]+ +①-c' || true)
76
78
  c=$(env -u CLAUDE_CODE_CHILD_SESSION -u CLAUDE_CODE_AGENT FH_PEER_SCAN_FORCE=1 bash "$CC" 2>/dev/null | grep -cE '^[^[:space:]]+ +①-c' || true)
77
79
  [ "$a" -gt 0 ] && ok "자식 세션 → ①-c 뜬다" || ng "자식 세션인데 ①-c 없음"
78
80
  [ "$b" -eq 0 ] && ok "톱레벨(env 부재 시뮬) → 침묵 (솔로 세션 나그 금지)" || ng "env 부재인데 ①-c 떴다"
@@ -84,7 +86,19 @@ fi
84
86
 
85
87
  if [ -f "$CC" ]; then
86
88
  lane_stub_env_used gh && ok "lane_stub_env: gh 스텁 선택 확인(FH_LANE_STUB=off 면 해당 없음)" || ng "lane_stub_env: gh 스텁 미사용 — PATH 가림"
87
- lane_stub_env_used stale-ref && ok "lane_stub_env: ①-g 스텁 선택 확인(FH_LANE_STUB=off 면 해당 없음)" || ng "lane_stub_env: ①-g 스텁 미사용 — 진짜 스캐너가 돌았다"
89
+ # 🟥 «스텁이 안 불렸다» 의 원인이 둘이고, 초판은 둘을 한 문장으로 접어 **거짓 진단**을 냈다.
90
+ # 2026-10-19 클린룸 감사 실측: 깃 없는 소비자 타르볼에서 이 스위트가 재현성 있게 빨갛고
91
+ # (깃 트리 두 곳은 초록) 메시지가 「진짜 스캐너가 돌았다」였다. 실제로는 체커 자신이
92
+ # «①-g stale-ref: git 없음/비-레포 — 대상 목록을 못 만들었다. UNMEASURED» 를 찍고
93
+ # 스캐너를 **아예 안 불렀다**. 즉 가림이 아니라 미측정이고, 「진짜가 돌았다」는 거짓이다.
94
+ # ⇒ 체커 자신의 출력으로 가른다(기록의 속성을 보는 것이지 결론을 보는 게 아니다).
95
+ if lane_stub_env_used stale-ref; then
96
+ ok "lane_stub_env: ①-g 스텁 선택 확인(FH_LANE_STUB=off 면 해당 없음)"
97
+ elif printf '%s\n' "${_CCOUT:-}" | grep -q '①-g stale-ref: git 없음/비-레포'; then
98
+ ok "lane_stub_env: ①-g 는 체커가 UNMEASURED 를 선언해 스캐너를 안 불렀다 — 미측정(통과 아님), 가림 아님"
99
+ else
100
+ ng "lane_stub_env: ①-g 스텁 미사용 — PATH 가림(진짜 스캐너가 돌았다)"
101
+ fi
88
102
  fi
89
103
 
90
104
  echo
@@ -59,6 +59,25 @@ KO='성공 정의는 이것이고 절대 안 하는 것은 저것이다'
59
59
 
60
60
  # ── 계기 교정 ②: 이 기계에서 위험이 «실재하나» — wc -w 가 실제로 갈리는지 먼저 보인다.
61
61
  # 안 갈리면(예: POSIX 구현이 멀티바이트를 알아서 처리) 아래 레인들은 아무것도 못 가른다.
62
+ # 🟥 2026-10-20: ubuntu 26.04 의 `wc` 는 uutils(Rust) 0.10 이라 POSIX 에서도 한글을 8 낱말로
63
+ # 센다(8/8) — 그래서 이 스위트가 L0 에서 rc=2 로 끝났고, wc 와 무관한 레인(L9 브래킷 fail-OPEN ·
64
+ # L11–L14)까지 같이 안 돌았다(main 이 빨개진 원인, #928). 그 이미지에도 GNU 판이 `gnuwc` 로
65
+ # 들어 있고 그건 갈린다(11/8). 되돌림 프로브가 재는 것은 «옛 훅이 쓰던 `wc -w` 가 로케일로
66
+ # 갈리는 기계»이므로, 시스템 wc 가 안 갈릴 때만 **실제로 갈리는** 후보를 찾아 PATH 앞에 둔다.
67
+ # 고르는 기준은 이름이 아니라 실측(같은 KO 를 두 로케일로 세어 달라야 채택). 하나도 없으면
68
+ # 종전대로 rc=2 — 대조군 없는 초록은 측정이 아니다.
69
+ _wc_splits(){ [ "$(LC_ALL=POSIX bash -c 'printf "%s" "$1" | "$0" -w | tr -d " "' "$1" "$KO")" \
70
+ != "$(LC_ALL="$UTF8" bash -c 'printf "%s" "$1" | "$0" -w | tr -d " "' "$1" "$KO")" ]; }
71
+ if ! _wc_splits wc; then
72
+ for _wc in gnuwc gwc; do
73
+ _wcp=$(command -v "$_wc" 2>/dev/null) || continue
74
+ if _wc_splits "$_wcp"; then
75
+ mkdir -p "$T/wcbin" && ln -s "$_wcp" "$T/wcbin/wc" && export PATH="$T/wcbin:$PATH"
76
+ echo " wc 계기: $_wcp (시스템 wc 는 로케일로 안 갈린다 — 갈리는 구현으로 대조군을 세운다)"
77
+ break
78
+ fi
79
+ done
80
+ fi
62
81
  w_posix=$(LC_ALL=POSIX bash -c 'printf "%s" "$1" | wc -w | tr -d " "' _ "$KO")
63
82
  w_utf8=$(LC_ALL="$UTF8" bash -c 'printf "%s" "$1" | wc -w | tr -d " "' _ "$KO")
64
83
  _t "L0 계기 교정 — 이 기계에서 \`wc -w\` 가 로케일로 갈린다"
@@ -269,7 +269,7 @@ else
269
269
  python3 - "$SUT" "$MUTP" <<'PY'
270
270
  import io, sys
271
271
  src = io.open(sys.argv[1], encoding='utf-8').read()
272
- old = ' grep -qxF "$1" <<<"$_TRACKED"'
272
+ old = ' case "$_TRACKED_NL" in *$\'\\n\'"$1"$\'\\n\'*) return 0;; *) return 1;; esac'
273
273
  new = ' printf \'%s\\n\' "$_TRACKED" | grep -qxF "$1"'
274
274
  if src.count(old) != 1:
275
275
  sys.stderr.write("SUBN=%d\n" % src.count(old)); sys.exit(3)
@@ -287,6 +287,60 @@ PY
287
287
  fi
288
288
  rm -rf "$BIG"
289
289
 
290
+ # ─────────────────────────────────────────────────────────────────────────────
291
+ # L-glob — 🟥 `case "$_TRACKED_NL"` 전환 시 경로의 글로브 문자(`[`, `]`, `*`, `?`)가 패턴이 아닌
292
+ # 리터럴로 매치돼야 한다(`"$1"` 인용 필수). 인용이 빠지면:
293
+ # ① tracked 인 `shipped_[v1].md` 는 패턴 `[v1]` 이 리터럴 `[v1]` 과 불일치해 동봉 파일로 안 읽히고,
294
+ # ② untracked 인 근접 경로(`harness_bench_[i]ssue_monitor.md` 등)나 `[v1]` 문자클래스 전개(`shipped_v.md`)가
295
+ # 동봉 파일과 오매치될 수 있다.
296
+ printf '# bracket\n' > "$BR/tracks/_meta/shipped_[v1].md"
297
+ printf '# star\n' > "$BR/tracks/_meta/shipped_*.md"
298
+ git -C "$BR" add -f "tracks/_meta/shipped_[v1].md" "tracks/_meta/shipped_*.md" >/dev/null 2>&1
299
+ git -C "$BR" -c user.email=t@t -c user.name=t commit -q -m ship-glob 2>/dev/null
300
+ v=$(_bv "$BR")
301
+ [ "$v" = "new" ] \
302
+ && ok "L-glob tracked paths containing '[' or '*' are still recognised as shipped (got new)" \
303
+ || ng "L-glob tracked path with '[' or '*' misread as user-made (got '$v' — missing quoting on \"\$1\"?)"
304
+
305
+ printf '# near-miss class\n' > "$BR/tracks/_meta/shipped_v.md"
306
+ printf '# near-miss pattern\n' > "$BR/tracks/_meta/harness_bench_[i]ssue_monitor.md"
307
+ _g_out=$( cd "$BR" && bash scripts/mapped_tracks.sh 2>&1 )
308
+ _g_sess=$(printf '%s\n' "$_g_out" | sed -n 's/^session_files=//p')
309
+ _g_br=$(printf '%s\n' "$_g_out" | sed -n 's/^onboarding_branch=//p')
310
+ [ "$_g_sess" = "2" ] && [ "$_g_br" = "returning" ] \
311
+ && ok "L-glob control — untracked near-miss paths are NOT recognised as shipped (session_files=$_g_sess · $_g_br)" \
312
+ || ng "L-glob control — untracked near-miss path was swallowed as shipped (session_files=$_g_sess branch=$_g_br)"
313
+ rm -f "$BR/tracks/_meta/shipped_v.md" "$BR/tracks/_meta/harness_bench_[i]ssue_monitor.md"
314
+
315
+ # ─────────────────────────────────────────────────────────────────────────────
316
+ # L-fork — 🟥 파일 수에 비례하는 fork 가 없어야 한다(온보딩 지연 7~12s 의 원인, 2026-10-23 실측).
317
+ # grep · basename 을 세는 심(shim)을 PATH 앞에 두고 untracked 200개 위에서 돌린다. 수정판은 상수 회,
318
+ # 뮤턴트(here-string grep 복원)는 파일마다 1회 이상 → 이 레인이 «빨라짐» 의 기계 앵커다(codex: L-glob 은
319
+ # 옛 grep 에서도 초록이라 fork 제거를 증명하지 못한다).
320
+ SHIM="$(mktemp -d)"; CNT="$SHIM/count"; : > "$CNT"
321
+ for _t in grep basename; do
322
+ _real=$(command -v "$_t")
323
+ printf '#!/bin/bash\necho %s >> "%s"\nexec "%s" "$@"\n' "$_t" "$CNT" "$_real" > "$SHIM/$_t"; chmod +x "$SHIM/$_t"
324
+ done
325
+ for _i in $(seq 1 200); do printf '# u\n' > "$BR/tracks/_meta/u_$_i.md"; done
326
+ ( cd "$BR" && PATH="$SHIM:$PATH" bash scripts/mapped_tracks.sh >/dev/null 2>&1 )
327
+ _n=$(wc -l < "$CNT" | tr -d ' ')
328
+ [ "$_n" -lt 50 ] \
329
+ && ok "L-fork 200 files → grep/basename calls $_n (< 50, not per file)" \
330
+ || ng "L-fork 200 files → grep/basename calls $_n — forks per file again"
331
+ sed 's|case "\$_TRACKED_NL" in \*\$'"'"'\\n'"'"'"\$1"\$'"'"'\\n'"'"'\*) return 0;; \*) return 1;; esac|grep -qxF "$1" <<<"$_TRACKED"|' \
332
+ "$BR/scripts/mapped_tracks.sh" > "$BR/scripts/mapped_tracks_fork_mut.sh"
333
+ if cmp -s "$BR/scripts/mapped_tracks.sh" "$BR/scripts/mapped_tracks_fork_mut.sh"; then
334
+ ng "L-fork revert — 뮤턴트 생성 실패(치환 대상 부재). HARNESS ERROR, 초록으로 안 읽는다"
335
+ else
336
+ : > "$CNT"; ( cd "$BR" && PATH="$SHIM:$PATH" bash scripts/mapped_tracks_fork_mut.sh >/dev/null 2>&1 )
337
+ _m=$(wc -l < "$CNT" | tr -d ' ')
338
+ [ "$_m" -ge 200 ] \
339
+ && ok "L-fork revert — here-string grep 을 되돌리면 호출이 $_m 회로 늘어난다(레인이 결함에 결박됨)" \
340
+ || ng "L-fork revert — 뮤턴트도 $_m 회 — 이 레인은 fork 를 재지 못한다"
341
+ fi
342
+ rm -f "$BR"/tracks/_meta/u_*.md "$BR/scripts/mapped_tracks_fork_mut.sh"; rm -rf "$SHIM"
343
+
290
344
  if [ "$FAIL" -eq 0 ]; then
291
345
  echo "MAPPED-TRACKS LANES: PASS ($PASS/$PASS)"
292
346
  echo " NOT covered: whether the synergy skill (or any other consumer) actually CALLS this."
@@ -34,7 +34,7 @@ w fb_promote.md "$hdr
34
34
  - 2026-10-01 | same day again
35
35
  - 2026-10-05 | other day
36
36
  ---
37
- body"
37
+ body — fixed in 4cab596 (an evidence anchor, so this one may be promoted)"
38
38
  w fb_two_two.md "$hdr
39
39
  type: feedback
40
40
  hits:
@@ -206,5 +206,95 @@ Q="$T/q"; mkdir -p "$Q"; for f in z a; do printf -- '---\nmetadata:\n type: use
206
206
  printf -- '- [z](z.md) [a](a.md)\n' > "$Q/MEMORY.md"
207
207
  eq "L27 same-line links keep link order" "$(python3 "$HERE/memory_gc_report.py" "$Q" --json | "$PY" -c "import json,sys;print(json.load(sys.stdin)['order'])")" "['z.md', 'a.md']"
208
208
 
209
+
210
+ # 🟥 residual edges NOT chased (round cap 2, static matcher does not converge): '#123456 ' CSS colours without ';' · repo#N inside
211
+ # URLs counted twice (presence only, harmless) · sha-looking words in prose with mixed letters/digits (e.g. 'b2c3d4e') count.
212
+ # ── evidence anchors (harness2: a lesson is stored/promoted only with a cited contrast) — own fixture dir ──
213
+ M2="$T/m2"; mkdir -p "$M2"
214
+ w2(){ printf '%s\n' "$2" > "$M2/$1"; }
215
+ w2 fb_anchored.md "$hdr
216
+ type: feedback
217
+ hits:
218
+ - 2026-10-01 | a
219
+ - 2026-10-02 | b
220
+ - 2026-10-03 | c
221
+ ---
222
+ fixed in 4cab596 — measured with scripts/test_x.sh"
223
+ w2 fb_held.md "$hdr
224
+ type: feedback
225
+ hits:
226
+ - 2026-10-01 | a
227
+ - 2026-10-02 | b
228
+ - 2026-10-03 | c
229
+ ---
230
+ happened on 2026-10-03, three times (a date is not an evidence anchor)"
231
+ pos(){ w2 "$1" "$hdr
232
+ type: project
233
+ ---
234
+ $2"; }
235
+ pos a_sha.md "fixed in 4cab596"
236
+ pos a_sha_ctx.md "landed as commit 1234567"
237
+ pos a_pr.md "see #1"
238
+ pos a_repo_pr.md "see chrono-meta/forge-harness#938"
239
+ pos a_path.md "the bug was in src/main.rs"
240
+ pos a_upper.md "documented in README.MD"
241
+ pos a_docker.md "the Dockerfile pins it"
242
+ pos a_arxiv.md "per arXiv:2610.29609"
243
+ pos a_url.md "see https://example.org/x"
244
+ w2 a_hitline.md "$hdr
245
+ type: feedback
246
+ hits:
247
+ - 2026-10-01 | fixed in 4cab596
248
+ ---
249
+ the rule, stated without citing anything"
250
+ pos n_noise.md "color #fff, version 3.29, the word deadbeef, abcdefg, C# and &#39; are not anchors"
251
+ pos n_css.md "color: #123456;"
252
+ pos n_uuid.md "request 3f2a9c1e-8b7d-4e21-9a3b-0c5d6e7f8a9b failed"
253
+ pos n_slug.md "see [intro](#2-intro)"
254
+ pos n_wiki.md "see [[feedback_x]] for the relation"
255
+ pos n_wiki_ext.md "see [[feedback_x.md]] for the relation"
256
+ pos n_frag.md "see [step](#2)"
257
+ pos n_uuid_ctx.md "commit 1234567-dead-beef-1234-123456789abc"
258
+ pos a_arxiv_old.md "per arXiv:hep-th/9901001"
259
+ pos n_date.md "happened on 2026-10-03, three times"
260
+ w2 n_fm.md "---
261
+ name: x
262
+ description: |
263
+ quoted
264
+ ---
265
+ see https://example.org/frontmatter
266
+ metadata:
267
+ type: project
268
+ ---
269
+ plain body"
270
+ w2 MEMORY.md "# Memory Index
271
+ - [A](fb_anchored.md)
272
+ - [H](fb_held.md)
273
+ - [U](user_plain.md)
274
+ - [a1](a_sha.md)
275
+ - [a2](a_sha_ctx.md)
276
+ - [a3](a_pr.md)
277
+ - [a4](a_repo_pr.md)
278
+ - [a5](a_path.md)
279
+ - [a6](a_upper.md)
280
+ - [a7](a_docker.md)
281
+ - [a8](a_arxiv.md)
282
+ - [a9](a_url.md)
283
+ - [a10](a_hitline.md)
284
+ - [n1](n_noise.md)
285
+ - [n2](n_css.md)
286
+ - [n3](n_uuid.md)
287
+ - [n4](n_slug.md)
288
+ - [n5](n_wiki.md)
289
+ - [n6](n_date.md)
290
+ - [n7](n_fm.md)
291
+ - [n8](n_wiki_ext.md)
292
+ - [n9](n_frag.md)
293
+ - [n10](n_uuid_ctx.md)
294
+ - [a11](a_arxiv_old.md)"
295
+ q2(){ "$PY" "$HERE/memory_gc_report.py" "$M2" --today 2026-10-15 --json | "$PY" -c "import json,sys; d=json.load(sys.stdin); print($1)"; }
296
+ eq "L30 promote needs an evidence anchor; a recurring entry citing only dates is held, not promoted" "$(q2 "(d['promote'], d['promote_held'])")" "([['fb_anchored.md', 3, 3]], [['fb_held.md', 3, 3]])"
297
+ eq "L31 each anchor class counts on its own (sha · named sha · #N · owner/repo#N · path · upper-case ext · Dockerfile · arXiv · URL · hit line); every non-anchor stays unanchored (#fff · CSS · UUID · #slug · [[wiki]] · date · frontmatter URL)" "$(q2 "sorted(d['unanchored'])")" "['fb_held.md', 'n_css.md', 'n_date.md', 'n_fm.md', 'n_frag.md', 'n_noise.md', 'n_slug.md', 'n_uuid.md', 'n_uuid_ctx.md', 'n_wiki.md', 'n_wiki_ext.md']"
298
+ eq "L32 user entries are never listed as unanchored (and the list is not empty, so this is not vacuous)" "$(q2 "('user_plain.md' in d['unanchored'], len(d['unanchored']) > 0)")" "(False, True)"
209
299
  echo "memory_gc_report lanes: $pass pass · $fail fail"
210
300
  [ $fail -eq 0 ]
@@ -152,6 +152,7 @@ grep -q 'TIMEOUT L2' <<<"$out" ; chk $? "R3 a hang is reported as TIMEOUT, its
152
152
 
153
153
  echo "── S: in-place safety — each lane is a blocking repro from the 2026-10-07 blind review"
154
154
  bkpath() { python3 -c 'import hashlib,os,sys;print("/tmp/mutation_probe-%d/path-%s.backup"%(os.getuid(),hashlib.sha256(os.path.realpath(sys.argv[1]).encode()).hexdigest()[:16]))' "$1"; }
155
+ ibkpath() { python3 -c 'import os,sys;st=os.stat(sys.argv[1]);print("/tmp/mutation_probe-%d/inode-%d-%d.backup"%(os.getuid(),st.st_dev,st.st_ino))' "$1"; }
155
156
  sha_of() { python3 -c 'import hashlib,sys;print(hashlib.sha256(open(sys.argv[1],"rb").read()).hexdigest())' "$1"; }
156
157
  procs_matching() { # count live processes whose WHOLE cmdline is $1 — /proc, not pgrep (pgrep absent → vacuous);
157
158
  local n=0 c # exact match, so the counter never counts itself (a substring grep did)
@@ -482,8 +483,23 @@ out=$(python3 "$PROBE" z16.sh lane_z16.sh --timeout 30 2>&1); rc=$?
482
483
  # Z17 — a closed stdout does not lose the run
483
484
  cp age.sh z17.sh; h0=$(sha_of z17.sh)
484
485
  sed 's#age\.sh#z17.sh#' lane_strong.sh > lane_z17.sh # v6 ran lane_strong here, which never sources z17.sh — the v7 control caught it
485
- python3 "$PROBE" z17.sh lane_z17.sh --timeout 30 2>z17.err | head -c 1 >/dev/null; rc=${PIPESTATUS[0]}; [ "$rc" -eq 0 ] || { echo " (Z17 rc=$rc)"; sed 's/^/ /' z17.err; }
486
- [ "$rc" -eq 0 ] && [ "$(sha_of z17.sh)" = "$h0" ] ; chk $? "Z17 stdout closed mid-run → still rc 0 and restored (v5: BrokenPipe traceback rc 1)"
486
+ # 🟥 전제 먼저 — 상태 디렉터리는 컨테이너 전역(`/tmp/mutation_probe-$uid`)이고 inode 키는
487
+ # 파일이 지워지면 재사용된다. 그래서 **다른 트리가 지난주에 남긴 백업**이 이번 픽스처의
488
+ # inode 와 같은 이름일 수 있고, 그러면 프로브는 (옳게) rc=2 «CANNOT JUDGE» 로 거절한다.
489
+ # 초판은 그 rc=2 를 `❌ Z17 stdout closed mid-run` 으로 찍었다 — 즉 **안 재어진 것을
490
+ # 「이 동작이 깨졌다」로 거짓 진단**했다. 2026-10-19 클린룸 감사 실측: 컨테이너 재사용 4회차,
491
+ # 10-12 자 백업 inode-65024-1941405 이 10-19 의 z17 픽스처와 같은 이름이었다.
492
+ # ⇒ 실행 **전에** 두 키(path·inode)를 보고, 이미 있으면 UNMEASURED 로 센다(통과 아님 —
493
+ # 스위트는 그래도 exit 1 이다). 메시지 문자열을 grep 하지 않고 기록의 존재만 본다.
494
+ _z17stale=""
495
+ for _b in "$(bkpath z17.sh)" "$(ibkpath z17.sh)"; do [ -e "$_b" ] && _z17stale="$_b"; done
496
+ if [ -n "$_z17stale" ]; then
497
+ echo " ⚠️ Z17 UNMEASURED — 전역 상태 디렉터리에 남의 백업이 먼저 있다: $_z17stale (inode 재사용). 비우고 다시 돌려라"
498
+ UNMEASURED=$((UNMEASURED+1))
499
+ else
500
+ python3 "$PROBE" z17.sh lane_z17.sh --timeout 30 2>z17.err | head -c 1 >/dev/null; rc=${PIPESTATUS[0]}; [ "$rc" -eq 0 ] || { echo " (Z17 rc=$rc)"; sed 's/^/ /' z17.err; }
501
+ [ "$rc" -eq 0 ] && [ "$(sha_of z17.sh)" = "$h0" ] ; chk $? "Z17 stdout closed mid-run → still rc 0 and restored (v5: BrokenPipe traceback rc 1)"
502
+ fi
487
503
  # Z18 — --json through a hard link to the subject
488
504
  cp age.sh z18.sh; ln -f z18.sh z18.json; h0=$(sha_of z18.sh)
489
505
  out=$(python3 "$PROBE" z18.sh lane_weak.sh --timeout 30 --json z18.json 2>&1); rc=$?
@@ -650,15 +666,31 @@ grep -qE 'invalid=0' <<<"$out" && grep -qE 'mutants=2 killed=1 survived=1 ' <<<"
650
666
 
651
667
  echo "── R7: blind review of v7 (2026-10-08) — each lane red on fbfe773"
652
668
  # R7-1 — a probe that READ the subject while another probe's mutant was live, and locked it only after that
653
- # probe had restored it, must not adopt the mutant. Deterministic: the subject is large enough that
654
- # reading + enumerating it outlasts the 0.4 s after which «the other probe» puts the original back.
669
+ # probe had restored it, must not adopt the mutant. The restore must land after the probe READ the
670
+ # subject (first thing it does) and before it LOCKED it (after enumerating every mutant).
671
+ # 🟥 2026-10-20: this used a fixed 0.4 s over a 6000-line subject and called it deterministic. It was
672
+ # not: time-to-lock measured 468 ms on macOS, 523 ms on ubuntu 24.04 and 288 ms on 26.04 (Python 3.14)
673
+ # — so on 26.04 the restore landed AFTER the lock, the probe refused for a different reason (the
674
+ # lane wrote the subject during the control run) and this lane went red on a correct probe. Now the
675
+ # delay is measured on this machine: one undisturbed run times its «subject:» header (printed after
676
+ # the lock), and the restore fires at half of that. Twice the lines makes that window seconds wide.
655
677
  printf '#!/usr/bin/env bash\n[ "$a" -ne 1 ] && echo x1\n' > r71.orig
656
- for k in $(seq 2 6000); do printf '[ "$a" -eq %d ] && echo x%d\n' "$k" "$k"; done >> r71.orig
657
- sed '2s/-ne 1/-eq 1/' r71.orig > r71.sh # the other probe's mutant is live
678
+ for k in $(seq 2 12000); do printf '[ "$a" -eq %d ] && echo x%d\n' "$k" "$k"; done >> r71.orig
658
679
  printf 'grep -q "exit 113" r71.sh && exit 1\nexit 0\n' > lane_r71.sh
659
- s71=$(date +%s%N)
680
+ cp r71.orig r71.sh
681
+ _ms(){ python3 -c 'import time; print(int(time.time() * 1000))'; } # BSD date has no %N
682
+ c71=$(_ms); h71=""
683
+ while IFS= read -r l; do
684
+ case "$l" in subject:*) [ -n "$h71" ] || h71=$(( $(_ms) - c71 )) ;; esac
685
+ done < <(python3 "$PROBE" r71.sh lane_r71.sh --max 1 --timeout 30 2>&1)
686
+ 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, so the lane fails below
688
+ # (d71 stays 0 → the restore lands before the read → no refusal) rather than guessing a number.
689
+ [ -n "$h71" ] || echo " ⚠️ R7-1 calibration: no «subject:» header — time-to-lock unknown on this machine"
690
+ d71=$(awk -v ms="${h71:-0}" 'BEGIN { printf "%.3f", ms / 2000 }')
691
+ sed '2s/-ne 1/-eq 1/' r71.orig > r71.sh # the other probe's mutant is live
660
692
  python3 "$PROBE" r71.sh lane_r71.sh --max 1 --timeout 30 > r71.out 2>&1 & pb=$!
661
- sleep 0.4; cat r71.orig > r71.sh; t71=$(date +%s%N) # … and now it restores (same inode)
693
+ sleep "$d71"; cat r71.orig > r71.sh # … and now it restores (same inode)
662
694
  wait "$pb"; rc=$?
663
695
  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)"
664
696
  cp r71.orig r71.sh
@@ -21,6 +21,8 @@ setup() {
21
21
  git init -q --bare -b main "$d/origin.git"
22
22
  git clone -q "$d/origin.git" "$d/seed" 2>/dev/null
23
23
  printf 'a1\n' > "$d/seed/a"; printf 'b1\n' > "$d/seed/b"
24
+ # SETUP_EXTRA=1: a tracked dir whose listing names `a`, and a runner whose text names `a` — the shapes a glob/dir word can drag in
25
+ [ -n "${SETUP_EXTRA:-}" ] && { mkdir -p "$d/seed/d"; printf 'x\n' > "$d/seed/d/a"; printf 'grep -q a2 a\n' > "$d/seed/r.sh"; }
24
26
  git -C "$d/seed" add -A; git -C "$d/seed" commit -qm init --no-verify; git -C "$d/seed" push -q origin HEAD:main
25
27
  git -C "$d/seed" switch -qc feat; printf 'a2\n' > "$d/seed/a"; printf 'b2\n' > "$d/seed/b"
26
28
  git -C "$d/seed" commit -qam feat --no-verify; git -C "$d/seed" push -q origin feat
@@ -67,7 +69,11 @@ esac
67
69
  EOF
68
70
  chmod +x "$D/bin/gh"
69
71
  }
70
- run() { local D="$1"; shift; OUT=$(cd "$D/work" && PATH="$D/bin:$PATH" PMV_RETRY_SLEEP=0 bash "$SC" "$@" 2>&1); RC=$?; }
72
+ # 🟥 env -u CLAUDECODE: the lane itself often runs inside Claude Code; without it every «no agent marker» control inherits the
73
+ # marker and reads agent-session (measured on the first run of L18).
74
+ run() { local D="$1"; shift; OUT=$(cd "$D/work" && env -u CLAUDECODE PATH="$D/bin:$PATH" PMV_RETRY_SLEEP=0 PMV_RECEIPTS="$D/receipts.jsonl" bash "$SC" "$@" 2>&1); RC=$?; }
75
+ # receipt field reader: rcpt <dir> <field> → value of the LAST receipt line (empty if none)
76
+ rcpt() { [ -s "$1/receipts.jsonl" ] && tail -1 "$1/receipts.jsonl" | python3 -c "import json,sys;v=json.load(sys.stdin).get(sys.argv[1]);print('' if v is None else v)" "$2"; }
71
77
  merged() { [ -s "$1/merge.log" ]; }
72
78
  GOOD='grep -q a2 a && grep -q b2 b && echo instrument-ok'
73
79
 
@@ -147,5 +153,46 @@ setup st; mkgh "$T/st"; : > "$T/st/local_fail"; : > "$T/st/stuck"; run "$T/st" 7
147
153
  { [ "$RC" -eq 5 ] && printf '%s' "$OUT" | grep -q 'NOT observed' && printf '%s' "$OUT" | grep -q 'read 3 time' && ! printf '%s' "$OUT" | grep -q 'nothing merged'; } \
148
154
  && ok "L16 stale OPEN through all re-reads → rc=5 «NOT observed», no false «nothing merged»" || { bad "L16 rc=$RC"; printf '%s\n' "$OUT" | tail -2; }
149
155
 
156
+ # ── merge receipt: actor + lease (frontier digest 2026-10-23, arXiv:2610.28683) ──
157
+ # L17 an agent session merging under a named lease → one receipt line naming both, with the merge commit and outcome
158
+ setup rl; mkgh "$T/rl"; OUT=$(cd "$T/rl/work" && CLAUDECODE=1 PATH="$T/rl/bin:$PATH" PMV_RETRY_SLEEP=0 PMV_RECEIPTS="$T/rl/receipts.jsonl" bash "$SC" 7 --rerun "$GOOD" --lease "night-2026-10-22" 2>&1); RC=$?
159
+ { [ "$RC" -eq 0 ] && [ "$(rcpt "$T/rl" actor)" = "agent-session:claude-code" ] && [ "$(rcpt "$T/rl" lease)" = "night-2026-10-22" ] \
160
+ && [ "$(rcpt "$T/rl" outcome)" = "verified" ] && [ "$(rcpt "$T/rl" merge)" = "$(cat "$T/rl/merge.oid")" ] && [ "$(wc -l < "$T/rl/receipts.jsonl")" -eq 1 ]; } \
161
+ && ok "L17 agent merge under a lease → receipt: actor agent-session · lease · verified · merge oid" || { bad "L17 rc=$RC receipt=$(cat "$T/rl/receipts.jsonl" 2>/dev/null)"; printf '%s\n' "$OUT" | tail -3; }
162
+ # L18 control: no lease, no agent marker → actor human-or-unknown, lease NONE (recorded, not refused)
163
+ { [ "$(rcpt "$T/ok" actor)" = "human-or-unknown" ] && [ "$(rcpt "$T/ok" lease)" = "NONE" ]; } \
164
+ && ok "L18 no lease, no agent marker → human-or-unknown · NONE (merge still allowed)" || bad "L18 receipt=$(cat "$T/ok/receipts.jsonl" 2>/dev/null)"
165
+ # L19 negative control — a refusal BEFORE the merge, or a merge GitHub did not take, leaves no receipt. It cannot detect the feature
166
+ # being removed on its own (codex R1); L17 · L18 · L21 are its positive pair.
167
+ { [ ! -s "$T/nore/receipts.jsonl" ] && [ ! -s "$T/triv/receipts.jsonl" ] && [ ! -s "$T/mf/receipts.jsonl" ]; } \
168
+ && ok "L19 refused / not-merged runs leave no receipt" || bad "L19 a receipt was written for a run that did not merge"
169
+ # L20 an empty --lease is a usage error before the merge
170
+ setup le; mkgh "$T/le"; run "$T/le" 7 --rerun "$GOOD" --lease ""
171
+ # the message names --lease: an unknown-option rc=2 alone would also pass (codex R1)
172
+ { [ "$RC" -eq 2 ] && ! merged "$T/le" && printf '%s' "$OUT" | grep -qF -- '--lease needs a non-empty label'; } && ok "L20 empty --lease → rc=2 «needs a non-empty label», no merge" || bad "L20 empty lease rc=$RC out=$OUT"
173
+ # L22 a queued merge (GitHub accepted the request, not completed) is receipted as such — the request was made
174
+ [ "$(rcpt "$T/q" outcome)" = "accepted-not-completed" ] && ok "L22 queued merge → receipt outcome accepted-not-completed" || bad "L22 receipt=$(cat "$T/q/receipts.jsonl" 2>/dev/null)"
175
+ # L21 a merged-but-failed verification still gets its receipt, with that outcome
176
+ [ "$(rcpt "$T/drop" outcome)" = "verify-failed" ] && ok "L21 verify FAILED after merge → receipt outcome verify-failed" || bad "L21 receipt=$(cat "$T/drop/receipts.jsonl" 2>/dev/null)"
177
+
178
+ # ── --rerun coverage advisory (warning only) ──
179
+ # L23 a real but unrelated --rerun (touches none of the PR's changed files) → warning, yet the merge and verify still go through
180
+ setup cv; mkgh "$T/cv"; run "$T/cv" 7 --rerun 'git --version && echo unrelated-ok'
181
+ { [ "$RC" -eq 0 ] && merged "$T/cv" && printf '%s' "$OUT" | grep -q 'mentions none of this PR'"'"'s 2 changed file'; } \
182
+ && ok "L23 --rerun naming no changed file → advisory warning, merge + verify unchanged (rc=0)" || { bad "L23 rc=$RC"; printf '%s\n' "$OUT" | tail -4; }
183
+ # L24 control: a --rerun that names the changed files stays silent (L1's GOOD names a and b)
184
+ setup cv2; mkgh "$T/cv2"; run "$T/cv2" 7 --rerun "$GOOD"
185
+ { [ "$RC" -eq 0 ] && ! printf '%s' "$OUT" | grep -q 'mentions none of this PR'; } \
186
+ && ok "L24 --rerun naming the changed files → no advisory" || bad "L24 rc=$RC (advisory fired on a covering --rerun?)"
187
+
188
+ # L25 a glob in --rerun is NOT expanded against the checkout — `echo *` would pull in r.sh (whose text names `a`) and silence the advisory (cross-family R1)
189
+ SETUP_EXTRA=1 setup cvg; mkgh "$T/cvg"; run "$T/cvg" 7 --rerun 'git --version && echo *'
190
+ { [ "$RC" -eq 0 ] && printf '%s' "$OUT" | grep -q 'mentions none of this PR'; } \
191
+ && ok "L25 --rerun with a bare glob → advisory still fires (no pathname expansion)" || bad "L25 rc=$RC (glob expanded into a runner that names a changed file?)"
192
+ # L25b a word naming a tracked DIRECTORY adds nothing — its tree listing (here `a`) is not a script's text (cross-family R1)
193
+ SETUP_EXTRA=1 setup cvd; mkgh "$T/cvd"; run "$T/cvd" 7 --rerun 'git --version && ls d'
194
+ { [ "$RC" -eq 0 ] && printf '%s' "$OUT" | grep -q 'mentions none of this PR'; } \
195
+ && ok "L25b --rerun naming a tracked dir → advisory still fires (blobs only)" || bad "L25b rc=$RC (dir listing counted as coverage?)"
196
+
150
197
  printf 'PASS %d · FAIL %d\n' "$PASS" "$FAIL"
151
198
  [ "$FAIL" -eq 0 ]
@@ -0,0 +1,215 @@
1
+ #!/usr/bin/env bash
2
+ # test_prepush_real_fire_lanes.sh — does git ACTUALLY run the pre-push hook, with the ref lines its header claims,
3
+ # for every destructive push the header says it covers? And does the remote stay untouched when it blocks?
4
+ #
5
+ # ── WHY THIS FILE EXISTS ─────────────────────────────────────────────────────────────────────────
6
+ # templates/.git-hooks/pre-push claims (header, «honest scope») to cover: remote branch deletion · tag / notes ref
7
+ # deletion · force / non-fast-forward push · implicit deletes from `git push --mirror` / `--prune`.
8
+ # scripts/test_prepush_destructive_lanes.sh anchors the hook's VERDICT by printing synthetic ref lines into its stdin.
9
+ # Nothing measured the other half: that git invokes the hook for each of those operations and hands it those lines.
10
+ # A sibling harness lost 366 protected files to exactly that gap (2026-10-23, reported back to this hub): a guard's header said
11
+ # «only this hook sees fast-forward merges», and a scratch-repo count showed the hook fired 0 times on
12
+ # `git merge --ff-only`. A claim about WHEN a hook fires is a claim about git, and only running git measures it.
13
+ #
14
+ # Each lane runs a real `git push` from a clone (core.hooksPath → a wrapper that counts calls and records stdin, then
15
+ # execs the real hook) to a real bare remote, and asserts three things: the hook fired, its stdin carried the ref line
16
+ # the claim depends on, and the remote ref is unchanged after the block. L0 is the control: with no hook wired, the
17
+ # same delete succeeds — so «remote unchanged» is something these lanes can see fail.
18
+ #
19
+ # Usage: bash scripts/test_prepush_real_fire_lanes.sh → exit 0 all lanes hold · 1 a lane failed · 2 setup failed
20
+ set -uo pipefail
21
+ . "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # 픽스처는 실레포에 쓰지 않는다
22
+
23
+ REPO_ROOT="${FH_TEST_SUBJECT_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"
24
+ HOOK_SRC="$REPO_ROOT/templates/.git-hooks/pre-push"
25
+ DEF_SRC="$REPO_ROOT/.claude/rules/.public-surface-patterns.defaults"
26
+ [ -f "$HOOK_SRC" ] || { echo "HARNESS_ERROR — pre-push hook not found at $HOOK_SRC (subject absent; NOT a pass)"; exit 2; }
27
+
28
+ WORK="$(fh_fixture_root "$(mktemp -d)")" || exit 2
29
+ : "${WORK:?fixture root unset — refusing to run git in cwd}"
30
+ trap 'rm -rf "$WORK"' EXIT
31
+ PASSED=0; FAILED=0
32
+ ok() { PASSED=$((PASSED + 1)); echo " ✅ $1"; }
33
+ bad() { FAILED=$((FAILED + 1)); echo " ❌ $1"; }
34
+
35
+ # ── fixture: bare remote with main · feat · old (merged into main) · uniq (one commit off main) · tag v1 · notes ─────
36
+ # The hook allows deleting a fully merged branch by design (pre-push «SAFE: fully merged … allowed») and holds one
37
+ # with unique work — so the delete lanes target `uniq`, and deleting `old` is a known-negative (fires, passes).
38
+ setup() { # $1 = name; wires the hook unless $2 = nohook
39
+ local d="$WORK/$1"
40
+ mkdir -p "$d" || return 1
41
+ git init -q --bare "$d/remote.git" || return 1
42
+ git -C "$d/remote.git" symbolic-ref HEAD refs/heads/main || return 1
43
+ mkdir -p "$d/seed" && (
44
+ cd "$d/seed" || exit 1
45
+ git init -q && git symbolic-ref HEAD refs/heads/main && git config user.email t@example.com && git config user.name t || exit 1
46
+ printf 'base\n' > a.txt && git add a.txt && git commit -qm base || exit 1
47
+ git branch old && git branch feat && git tag v1 || exit 1
48
+ git notes add -m n HEAD || exit 1
49
+ git switch -q -c uniq && printf 'u\n' > u.txt && git add u.txt && git commit -qm uniq && git switch -q main || exit 1
50
+ git switch -q feat && printf 'f1\n' > f.txt && git add f.txt && git commit -qm f1 || exit 1
51
+ git push -q "$d/remote.git" main old feat uniq v1 refs/notes/commits 2>/dev/null || exit 1
52
+ ) || return 1
53
+ git clone -q "$d/remote.git" "$d/clone" 2>/dev/null || return 1
54
+ (
55
+ cd "$d/clone" || exit 1
56
+ git config user.email t@example.com && git config user.name t || exit 1
57
+ git fetch -q origin 'refs/notes/*:refs/notes/*' 'refs/tags/*:refs/tags/*' || exit 1
58
+ git branch -q --track feat origin/feat 2>/dev/null; git branch -q --track old origin/old 2>/dev/null; git branch -q --track uniq origin/uniq 2>/dev/null; true
59
+ ) || return 1
60
+ if [ "${2:-}" != nohook ]; then
61
+ mkdir -p "$d/clone/.claude/rules" "$d/clone/scripts" "$d/hooks" || return 1
62
+ [ -f "$DEF_SRC" ] && cp "$DEF_SRC" "$d/clone/.claude/rules/.public-surface-patterns.defaults"
63
+ [ -f "$REPO_ROOT/scripts/psa_scan_lib.sh" ] && cp "$REPO_ROOT/scripts/psa_scan_lib.sh" "$d/clone/scripts/psa_scan_lib.sh"
64
+ cp "$HOOK_SRC" "$d/hooks/pre-push.real" || return 1
65
+ # wrapper: count the call, keep a copy of stdin, then hand the same bytes to the real hook
66
+ cat > "$d/hooks/pre-push" <<EOF
67
+ #!/usr/bin/env bash
68
+ echo x >> "$d/fired"
69
+ tee "$d/stdin.\$(wc -l < "$d/fired" | tr -d ' ')" | bash "$d/hooks/pre-push.real" "\$@"
70
+ exit \${PIPESTATUS[1]}
71
+ EOF
72
+ chmod +x "$d/hooks/pre-push" || return 1
73
+ git -C "$d/clone" config core.hooksPath "$d/hooks" || return 1
74
+ fi
75
+ : > "$d/fired"
76
+ printf '%s' "$d"
77
+ }
78
+ remote_ref() { git -C "$1/remote.git" rev-parse -q --verify "$2" 2>/dev/null || echo ABSENT; }
79
+ fired() { wc -l < "$1/fired" | tr -d ' '; }
80
+ stdin_has() { cat "$1"/stdin.* 2>/dev/null | grep -qE "$2"; }
81
+
82
+ # run_lane <name> <ref-to-watch> <stdin-regex> <push args...>
83
+ run_lane() {
84
+ local name="$1" ref="$2" rx="$3"; shift 3
85
+ local d; d=$(setup "$name") || { echo " ⛔ SETUP FAILED ($name) — HARNESS_ERROR, not a pass"; exit 2; }
86
+ local before; before=$(remote_ref "$d" "$ref")
87
+ [ "$before" = ABSENT ] && { echo " ⛔ SETUP: $ref missing on the remote before the lane ($name)"; exit 2; }
88
+ ( cd "$d/clone" && env -u DESTRUCTIVE_OP_OK -u MAIN_PUSH_OK git push "$@" >/dev/null 2>&1 ); local rc=$?
89
+ local after; after=$(remote_ref "$d" "$ref")
90
+ local f; f=$(fired "$d")
91
+ if [ "$f" -ge 1 ] && stdin_has "$d" "$rx" && [ "$rc" -ne 0 ] && [ "$after" = "$before" ]; then
92
+ ok "$name — hook fired ${f}× · stdin carried the claimed ref line · push refused · $ref unchanged"
93
+ else
94
+ bad "$name — fired=$f stdin_match=$(stdin_has "$d" "$rx" && echo yes || echo no) push_rc=$rc $ref: $before → $after"
95
+ fi
96
+ }
97
+
98
+ ZERO40='0{40}'
99
+ echo "pre-push real-fire lanes (subject: $HOOK_SRC)"
100
+
101
+ # L0 control — no hook wired: the same remote delete goes through. Without this, «remote unchanged» could be a property
102
+ # of the fixture (e.g. a push that never reached the remote) rather than of the hook.
103
+ d0=$(setup L0 nohook) || { echo " ⛔ SETUP FAILED (L0)"; exit 2; }
104
+ ( cd "$d0/clone" && git push origin --delete old >/dev/null 2>&1 )
105
+ [ "$(remote_ref "$d0" refs/heads/old)" = ABSENT ] && ok "L0 control — no hook: the delete reaches the remote (the lanes can see a real change)" \
106
+ || bad "L0 control — without a hook the delete did NOT land: the fixture cannot show a hook's effect"
107
+
108
+ # L1 known-negative — an ordinary fast-forward push of a feature branch fires the hook and is NOT refused
109
+ d1=$(setup L1) || { echo " ⛔ SETUP FAILED (L1)"; exit 2; }
110
+ before1=$(remote_ref "$d1" refs/heads/feat)
111
+ ( cd "$d1/clone" && git switch -q feat && printf 'f2\n' >> f.txt && git commit -qam f2 && env -u DESTRUCTIVE_OP_OK git push -q origin feat >/dev/null 2>&1 ); rc1=$?
112
+ if [ "$(fired "$d1")" -ge 1 ] && [ "$rc1" -eq 0 ] && [ "$(remote_ref "$d1" refs/heads/feat)" != "$before1" ]; then
113
+ ok "L1 known-negative — fast-forward feature push: hook fired, push accepted, remote advanced"
114
+ else
115
+ bad "L1 known-negative — fired=$(fired "$d1") rc=$rc1 (a plain ff push must pass; otherwise every block below is uninformative)"
116
+ fi
117
+
118
+ # L2b known-negative — deleting a FULLY MERGED branch fires the hook and is allowed (by design: nothing unique is lost)
119
+ d2b=$(setup L2b) || { echo " ⛔ SETUP FAILED (L2b)"; exit 2; }
120
+ ( cd "$d2b/clone" && env -u DESTRUCTIVE_OP_OK git push origin --delete old >/dev/null 2>&1 ); rc2b=$?
121
+ if [ "$(fired "$d2b")" -ge 1 ] && stdin_has "$d2b" "^\(delete\) ${ZERO40} refs/heads/old " && [ "$rc2b" -eq 0 ] && [ "$(remote_ref "$d2b" refs/heads/old)" = ABSENT ]; then
122
+ ok "L2b known-negative — merged branch delete: hook fired with the (delete) line and allowed it (SAFE)"
123
+ else
124
+ bad "L2b known-negative — fired=$(fired "$d2b") rc=$rc2b (a fully merged delete is allowed by design)"
125
+ fi
126
+ run_lane "L2 unmerged branch delete (--delete)" refs/heads/uniq "^\(delete\) ${ZERO40} refs/heads/uniq " origin --delete uniq
127
+ run_lane "L3 unmerged branch delete (:ref)" refs/heads/uniq "^\(delete\) ${ZERO40} refs/heads/uniq " origin :uniq
128
+ run_lane "L4 tag delete" refs/tags/v1 "^\(delete\) ${ZERO40} refs/tags/v1 " origin :refs/tags/v1
129
+ run_lane "L5 notes ref delete" refs/notes/commits "^\(delete\) ${ZERO40} refs/notes/commits " origin :refs/notes/commits
130
+
131
+ # L6 force / non-fast-forward: rewrite feat locally, then force-push
132
+ d6=$(setup L6) || { echo " ⛔ SETUP FAILED (L6)"; exit 2; }
133
+ before6=$(remote_ref "$d6" refs/heads/feat)
134
+ ( cd "$d6/clone" && git switch -q feat && git reset -q --hard HEAD~1 && printf 'rewritten\n' > r.txt && git add r.txt && git commit -qm rewrite \
135
+ && env -u DESTRUCTIVE_OP_OK git push -f origin feat >/dev/null 2>&1 ); rc6=$?
136
+ if [ "$(fired "$d6")" -ge 1 ] && stdin_has "$d6" "^refs/heads/feat [0-9a-f]{40} refs/heads/feat ${before6}" && [ "$rc6" -ne 0 ] && [ "$(remote_ref "$d6" refs/heads/feat)" = "$before6" ]; then
137
+ ok "L6 force push — hook fired · stdin carried the old remote tip · refused · feat unchanged"
138
+ else
139
+ bad "L6 force push — fired=$(fired "$d6") rc=$rc6 feat: $before6 → $(remote_ref "$d6" refs/heads/feat)"
140
+ fi
141
+
142
+ # L7 --prune: a branch deleted locally disappears on the remote through a refspec push with --prune
143
+ d7=$(setup L7) || { echo " ⛔ SETUP FAILED (L7)"; exit 2; }
144
+ before7=$(remote_ref "$d7" refs/heads/uniq)
145
+ ( cd "$d7/clone" && git branch -q -D uniq && env -u DESTRUCTIVE_OP_OK git push --prune origin 'refs/heads/*:refs/heads/*' >/dev/null 2>&1 ); rc7=$?
146
+ if [ "$(fired "$d7")" -ge 1 ] && stdin_has "$d7" "^\(delete\) ${ZERO40} refs/heads/uniq " && [ "$rc7" -ne 0 ] && [ "$(remote_ref "$d7" refs/heads/uniq)" = "$before7" ]; then
147
+ ok "L7 --prune — the implicit delete reached the hook as a (delete) line · refused · uniq unchanged"
148
+ else
149
+ bad "L7 --prune — fired=$(fired "$d7") rc=$rc7 uniq: $before7 → $(remote_ref "$d7" refs/heads/uniq)"
150
+ fi
151
+
152
+ # L8 --mirror: a mirror push from a clone missing `uniq` locally would delete it on the remote
153
+ d8=$(setup L8) || { echo " ⛔ SETUP FAILED (L8)"; exit 2; }
154
+ before8=$(remote_ref "$d8" refs/heads/uniq)
155
+ ( cd "$d8/clone" && git branch -q -D uniq && git update-ref -d refs/remotes/origin/uniq && env -u DESTRUCTIVE_OP_OK git push --mirror origin >"$d8/push.out" 2>&1 ); rc8=$?
156
+ if [ "$(fired "$d8")" -ge 1 ] && [ "$rc8" -ne 0 ] && [ "$(remote_ref "$d8" refs/heads/uniq)" = "$before8" ] \
157
+ && grep -q "refs/heads/uniq — REVIEW" "$d8/push.out"; then # the refusal must be the uniq verdict, not any refusal (cross-family R1)
158
+ ok "L8 --mirror — hook fired · refused · uniq unchanged (stdin carried: $(cat "$d8"/stdin.* 2>/dev/null | awk '{print $1" "$3}' | paste -sd',' - | cut -c1-120))"
159
+ else
160
+ bad "L8 --mirror — fired=$(fired "$d8") rc=$rc8 uniq: $before8 → $(remote_ref "$d8" refs/heads/uniq)" ; echo " stdin the hook got:"; sed "s/^/ /" "$d8"/stdin.* 2>/dev/null; echo " push output (tail):"; tail -12 "$d8/push.out" | sed "s/^/ /"
161
+ fi
162
+
163
+ # L8-ctl — no hook: the same mirror push really deletes `uniq` (so L8's «unchanged» is the hook's doing)
164
+ d8x=$(setup L8x nohook) || { echo " ⛔ SETUP FAILED (L8x)"; exit 2; }
165
+ ( cd "$d8x/clone" && git branch -q -D uniq && git update-ref -d refs/remotes/origin/uniq && git push --mirror origin >/dev/null 2>&1 )
166
+ [ "$(remote_ref "$d8x" refs/heads/uniq)" = ABSENT ] && ok "L8-ctl — no hook: the mirror push deletes uniq on the remote" \
167
+ || bad "L8-ctl — without a hook the mirror push did NOT delete uniq: L8 cannot show the hook's effect"
168
+
169
+ # L8d — abbreviated option: git accepts `--mir` for --mirror
170
+ d8d=$(setup L8d) || { echo " ⛔ SETUP FAILED (L8d)"; exit 2; }
171
+ before8d=$(remote_ref "$d8d" refs/heads/uniq)
172
+ ( cd "$d8d/clone" && git branch -q -D uniq && git update-ref -d refs/remotes/origin/uniq && env -u DESTRUCTIVE_OP_OK git push --mir origin >"$d8d/push.out" 2>&1 ); rc8d=$?
173
+ if [ "$rc8d" -ne 0 ] && [ "$(remote_ref "$d8d" refs/heads/uniq)" = "$before8d" ] && grep -q "refs/heads/uniq — REVIEW" "$d8d/push.out"; then
174
+ ok "L8d --mir (abbreviation) — detected as a mirror push · uniq held"
175
+ else
176
+ bad "L8d --mir — rc=$rc8d uniq: $before8d → $(remote_ref "$d8d" refs/heads/uniq)"; tail -6 "$d8d/push.out" | sed 's/^/ /'
177
+ fi
178
+
179
+ # L8e — git itself refuses `--no-mirror <refspec>` when remote.<name>.mirror is set (measured: «--mirror can't be combined
180
+ # with refspecs»), so the hook does not treat --no-mirror as overriding the config. This lane pins git's refusal: if a
181
+ # future git accepts it, the hook's «config ⇒ mirror» rule needs revisiting and this lane goes red to say so.
182
+ d8e=$(setup L8e) || { echo " ⛔ SETUP FAILED (L8e)"; exit 2; }
183
+ ( cd "$d8e/clone" && { git config remote.origin.mirror true && git switch -q feat && printf 'f3\n' >> f.txt && git commit -qam f3 \
184
+ && env -u DESTRUCTIVE_OP_OK git push --no-mirror origin feat; } >"$d8e/push.out" 2>&1 ); rc8e=$?
185
+ if [ "$rc8e" -ne 0 ] && grep -q "can't be combined with refspecs" "$d8e/push.out" && [ "$(fired "$d8e")" -eq 0 ]; then
186
+ ok "L8e git refuses --no-mirror <refspec> under a mirror config (before any hook runs) — config ⇒ mirror stays safe"
187
+ else
188
+ bad "L8e git's behaviour changed — rc=$rc8e fired=$(fired "$d8e"): revisit the hook's config ⇒ mirror rule"; tail -4 "$d8e/push.out" | sed 's/^/ /'
189
+ fi
190
+
191
+ # L8b known-negative — a mirror push that deletes nothing (every remote branch/tag/note exists locally) is not refused
192
+ d8b=$(setup L8b) || { echo " ⛔ SETUP FAILED (L8b)"; exit 2; }
193
+ ( cd "$d8b/clone" && env -u DESTRUCTIVE_OP_OK git push --mirror origin >"$d8b/push.out" 2>&1 ); rc8b=$?
194
+ if [ "$(fired "$d8b")" -ge 1 ] && [ "$rc8b" -eq 0 ] && [ "$(remote_ref "$d8b" refs/heads/uniq)" != ABSENT ]; then
195
+ ok "L8b known-negative — mirror push with nothing to delete: hook fired, push accepted"
196
+ else
197
+ bad "L8b known-negative — fired=$(fired "$d8b") rc=$rc8b (a mirror push that deletes nothing must pass)"; tail -8 "$d8b/push.out" | sed 's/^/ /'
198
+ fi
199
+
200
+ # L8c — mirror by CONFIG (remote.origin.mirror=true, plain `git push`): no --mirror on any command line
201
+ d8c=$(setup L8c) || { echo " ⛔ SETUP FAILED (L8c)"; exit 2; }
202
+ before8c=$(remote_ref "$d8c" refs/heads/uniq)
203
+ ( cd "$d8c/clone" && git config remote.origin.mirror true && git branch -q -D uniq && git update-ref -d refs/remotes/origin/uniq \
204
+ && env -u DESTRUCTIVE_OP_OK git push origin >"$d8c/push.out" 2>&1 ); rc8c=$?
205
+ if [ "$(fired "$d8c")" -ge 1 ] && [ "$rc8c" -ne 0 ] && [ "$(remote_ref "$d8c" refs/heads/uniq)" = "$before8c" ] \
206
+ && grep -q "refs/heads/uniq — REVIEW" "$d8c/push.out"; then
207
+ ok "L8c mirror by config — hook fired · refused · uniq unchanged"
208
+ else
209
+ bad "L8c mirror by config — fired=$(fired "$d8c") rc=$rc8c uniq: $before8c → $(remote_ref "$d8c" refs/heads/uniq)"; tail -8 "$d8c/push.out" | sed 's/^/ /'
210
+ fi
211
+ # Not measured here (named): a mirror push whose `git ls-remote` fails while the push itself would work — the hook
212
+ # blocks it (MIRROR_UNREADABLE), but no fixture makes ls-remote fail without also failing the push.
213
+
214
+ echo "── pre-push real-fire: $PASSED passed, $FAILED failed ──"
215
+ [ "$FAILED" -eq 0 ]