@chrono-meta/fh-gate 1.4.96 → 1.4.97

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.
@@ -15,6 +15,78 @@ set -u
15
15
  cd "$(dirname "${BASH_SOURCE[0]}")/.."
16
16
  fail=0
17
17
 
18
+ # Single source of "declared legitimately unshipped" — package_coverage_check.sh's ACCEPTED_ABSENT,
19
+ # read once via its --list-accepted flag. Two blocks below (ref-path, SessionStart anchor pairs) used
20
+ # to each re-derive "is this absence OK" from an environment predicate (`.git` presence) instead of
21
+ # consulting this declaration — which reproduces the exact bug the declaration exists to prevent in
22
+ # any git-TRACKED tree that vendors this package (a monorepo committing node_modules, or a consumer
23
+ # who runs `git init` after install): `.git` is present there, so the environment predicate answered
24
+ # "source checkout", ran the full check, and FAILed on paths the declaration had already said were
25
+ # fine to omit. Cross-family review, 2026-08-12 (reship axis, card §🔱⑮ G). `--list-accepted` has no
26
+ # git/package.json dependency itself, so this load is safe to attempt unconditionally.
27
+ _PKG_ACCEPTED_ABSENT=""
28
+ if [ -f scripts/package_coverage_check.sh ]; then
29
+ _PKG_ACCEPTED_ABSENT="$(bash scripts/package_coverage_check.sh --list-accepted 2>/dev/null)"
30
+ fi
31
+ _pkg_accepted_absent() { printf '%s\n' "$_PKG_ACCEPTED_ABSENT" | grep -qxF "$1"; }
32
+
33
+ # Is this path DECLARED shipped by package.json files[]? The companion question to the one above:
34
+ # ACCEPTED_ABSENT answers "is this absence legitimate", this answers "should this be here at all".
35
+ # Together they turn a bare "file missing" into a routed verdict instead of a blanket SKIP.
36
+ # Directory entries in files[] cover everything under them, which is how `templates/.git-hooks`
37
+ # covers `templates/.git-hooks/pre-push` — a prefix test, not equality (getting this wrong is what
38
+ # made a comment claim the hook does not ship while package.json:117 declared its whole directory).
39
+ # NOTE ON WHAT THIS DOES *NOT* PROVE: files[] membership is a DECLARATION, not the tarball. This repo
40
+ # has already measured the two diverging (card §🔱⑮ G/C: repo ✅ / files[] ❌). Here the direction is
41
+ # safe — an over-declaration makes this check stricter, never more lenient — but do not reuse this
42
+ # helper anywhere the answer needs to be "what the consumer actually received"; that needs
43
+ # `npm pack --dry-run --json`.
44
+ _ships_per_files() {
45
+ python3 - "$1" <<'SHIPPY' 2>/dev/null
46
+ import json, sys
47
+ p = sys.argv[1]
48
+ try:
49
+ files = json.load(open('package.json'))['files']
50
+ except Exception:
51
+ sys.exit(2) # unreadable manifest: UNKNOWN, and the caller must not read that as "no"
52
+ sys.exit(0 if any(p == f or p.startswith(f.rstrip('/') + '/') for f in files) else 1)
53
+ SHIPPY
54
+ }
55
+
56
+ # ── The single verdict for "my subject is not here" ───────────────────────────────────────────
57
+ # Measured 2026-08-12 (card §🔱⑮ A2): **18 blocks in this file** rendered a green SKIP when their
58
+ # subject was absent, and **all 18 subjects are declared in package.json files[] and present in the
59
+ # real tarball** (verified with `npm pack --dry-run --json`, 20/20 — so routing them to FAIL cannot
60
+ # over-block a legitimate consumer). For a subject that always ships, "absent" cannot mean "package
61
+ # mode"; the only ways to reach it are DELETION or a broken install, and both were reported green.
62
+ # That is the fourth face of the axis the card names three of: 미측정→clean · 미측정→findings ·
63
+ # 해당없음→FAIL · **삭제→SKIP** — and it is the quiet one, which is why it survived longest.
64
+ #
65
+ # Two of the eighteen are worth naming because they read as already-handled and were not:
66
+ # · the gate_pathspec block printed "— not-checked, NOT a pass" and then did not set fail. The
67
+ # LABEL was honest and the VERDICT was green; a reader greps the message and believes it.
68
+ # · the --self-test loop's comment says "never a silent pass" directly above the arm that was one.
69
+ # A comment asserting a property is not the property. Both were hand-verified by eye, not inferred.
70
+ #
71
+ # THE UNKNOWN ARM IS NOT A SKIP. `_ships_per_files` exits 2 when package.json is unreadable, and an
72
+ # unreadable manifest means we cannot tell deletion from package mode — `not found != 0`, so that
73
+ # case must not silently take the lenient branch (this repo's whole §Instrument-Calibration rule).
74
+ # Usage: [ -f "$subj" ] || { _absent_subject_verdict "<label>" "$subj" || fail=1; }
75
+ _absent_subject_verdict() {
76
+ local label="$1" subj="$2"
77
+ _ships_per_files "$subj"
78
+ case $? in
79
+ 0) echo "FAIL $label: $subj is DECLARED SHIPPED (package.json files[]) but absent — that is a"
80
+ echo " deletion or a broken install, not package mode. The subject itself is missing."
81
+ return 1 ;;
82
+ 1) echo "SKIP $label (subject $subj not in package.json files[], and absent)"
83
+ return 0 ;;
84
+ *) echo "FAIL $label: cannot read package.json, so '$subj absent' is UNDECIDABLE between a"
85
+ echo " deletion and package mode — unmeasured, not clean."
86
+ return 1 ;;
87
+ esac
88
+ }
89
+
18
90
  check() { # check <label> <cmd...>
19
91
  local label="$1"; shift
20
92
  if "$@" 2>/dev/null; then
@@ -152,12 +224,32 @@ fi
152
224
  # above the ref loop drains git's ref list → Destructive-Op gate silently allows a delete/force push).
153
225
  # Wired here, not left standalone: an unwired checker is the exact defect this session found in
154
226
  # session_close_check.sh — building the test and not running it repeats it one layer up.
155
- # Package-mode guard: neither the test nor its subject (templates/.git-hooks/pre-push) is in
156
- # package.json files[] both are source-tree-only infra. Without this guard the SHIPPED selfcheck
157
- # fails for every consumer running `npm test` on the installed package. Caught pre-publish 2026-07-20
158
- # by reproducing package mode; mirrors the ref-path SKIP below.
227
+ # ⚠️ CORRECTED 2026-08-12 (innovator Mode F scan resolved by measurement). This comment used to
228
+ # read: "neither the test nor its subject (templates/.git-hooks/pre-push) is in package.json files[]
229
+ # both are source-tree-only infra." **That was false**, and it had been false long enough to be
230
+ # load-bearing. `npm pack --dry-run --json` on this tree returns 262 files including
231
+ # templates/.git-hooks/pre-push, templates/.git-hooks/pre-commit AND
232
+ # scripts/test_prepush_stdin_integrity.sh — subject and anchor both ship (package.json:117 declares
233
+ # the whole `templates/.git-hooks` directory).
234
+ # The consequence is what makes this worth fixing rather than just re-wording: if the subject always
235
+ # ships, then "subject absent" can no longer mean "package mode" — the only way to reach that arm is
236
+ # that **the hook was deleted**, and it was rendering that as a green SKIP. This is the fourth face
237
+ # of the axis the card names three of at §🔱⑮ (미측정→clean · 미측정→findings · 해당없음→FAIL):
238
+ # **삭제→SKIP**. A deleted Destructive-Op gate reporting green on every surface is the worst of the
239
+ # four, because the other three are loud.
240
+ # Kept as a three-valued check rather than a bare FAIL: a consumer's tree can legitimately lack the
241
+ # directory if they installed with --ignore-scripts and pruned, so the *declaration* is what decides,
242
+ # not the environment (same discipline as `_pkg_accepted_absent` above — consult what ships, do not
243
+ # re-derive it from what happens to be on disk).
159
244
  if [ ! -f templates/.git-hooks/pre-push ]; then
160
- echo "SKIP pre-push stdin integrity (package mode: templates/.git-hooks absent)"
245
+ if _ships_per_files "templates/.git-hooks/pre-push"; then
246
+ echo "FAIL pre-push stdin integrity: templates/.git-hooks/pre-push is DECLARED SHIPPED but absent"
247
+ echo " — that is a deletion or a broken install, not package mode. The Destructive-Op gate"
248
+ echo " this anchors is the thing that is missing."
249
+ fail=1
250
+ else
251
+ echo "SKIP pre-push stdin integrity (not shipped per package.json files[], and absent)"
252
+ fi
161
253
  elif [ -f scripts/test_prepush_stdin_integrity.sh ]; then
162
254
  if ! bash scripts/test_prepush_stdin_integrity.sh; then
163
255
  fail=1
@@ -173,7 +265,7 @@ fi
173
265
  # (scripts/degrade_direction_scan.sh) and the anchor both ship, so this runs in package mode too;
174
266
  # only a missing SUBJECT is a legitimate skip.
175
267
  if [ ! -f scripts/degrade_direction_scan.sh ]; then
176
- echo "SKIP degrade-scan shell probes (subject scripts/degrade_direction_scan.sh absent)"
268
+ _absent_subject_verdict "degrade-scan shell probes" "scripts/degrade_direction_scan.sh" || fail=1
177
269
  elif [ -f scripts/test_degrade_scan_shell_probes.sh ]; then
178
270
  if ! bash scripts/test_degrade_scan_shell_probes.sh; then
179
271
  fail=1
@@ -189,7 +281,7 @@ fi
189
281
  # pair, a template that defeats the gate (a rendered newline turns the pattern into an OR search)
190
282
  # passes silently — measured 2026-08-12 on a stale README that the gate reported as PASS.
191
283
  if [ ! -f scripts/count_check.sh ]; then
192
- echo "SKIP count_check README-format lanes (subject scripts/count_check.sh absent)"
284
+ _absent_subject_verdict "count_check README-format lanes" "scripts/count_check.sh" || fail=1
193
285
  elif [ -f scripts/test_count_check_readme_format_lanes.sh ]; then
194
286
  if ! bash scripts/test_count_check_readme_format_lanes.sh; then
195
287
  fail=1
@@ -199,6 +291,22 @@ else
199
291
  fail=1
200
292
  fi
201
293
 
294
+ # The public-surface scanner's SINGLE-FILE and MISUSE paths. Same subject-present/anchor-gone shape:
295
+ # the scanner is a fail-closed gate on an irreversible surface, and its failure mode is a green that
296
+ # was never earned — a misuse, an unloaded pattern set, or dead plumbing all used to render as clean.
297
+ # Wired here on purpose (cross-family round 2): the lane file existed and was syntax-checked only, so
298
+ # `npm test` and `prepublishOnly` never executed it. A checker nobody calls is prose.
299
+ if [ ! -f scripts/psa_scan_lib.sh ]; then
300
+ _absent_subject_verdict "psa single-file lanes" "scripts/psa_scan_lib.sh" || fail=1
301
+ elif [ -f scripts/test_psa_singlefile_lanes.sh ]; then
302
+ if ! bash scripts/test_psa_singlefile_lanes.sh; then
303
+ fail=1
304
+ fi
305
+ else
306
+ echo "FAIL psa single-file lanes: psa_scan_lib.sh present but its anchor is missing"
307
+ fail=1
308
+ fi
309
+
202
310
  # package-coverage — a shipped doc must not point at a file the tarball omits. Distinct from the
203
311
  # ref-path check below: that one asks "does this path exist at all", this one asks "does the
204
312
  # CONSUMER get it". Measured 2026-07-28: 35 paths existed, were named by a shipped doc, and were
@@ -213,7 +321,7 @@ fi
213
321
  # to reason about CI. scripts/test_package_coverage_lanes.sh pins the predicate across all four
214
322
  # tree shapes plus a known pair.
215
323
  if [ ! -f scripts/package_coverage_check.sh ]; then
216
- echo "SKIP test_package_coverage_lanes.sh (subject scripts/package_coverage_check.sh absent)"
324
+ _absent_subject_verdict "test_package_coverage_lanes.sh" "scripts/package_coverage_check.sh" || fail=1
217
325
  elif [ -f scripts/test_package_coverage_lanes.sh ]; then
218
326
  if ! bash scripts/test_package_coverage_lanes.sh; then
219
327
  fail=1
@@ -226,6 +334,138 @@ else
226
334
  fail=1
227
335
  fi
228
336
 
337
+ # lane-runner — sibling of package-coverage one level up: that one asks "does the CONSUMER get the
338
+ # file a shipped doc names", this one asks "does ANYTHING execute the lane suite we wrote". Measured
339
+ # 2026-08-12 (reship axis, card §🔱⑮ A): 12 of 43 suites under scripts/ had no runner in selfcheck,
340
+ # the git hooks, or CI — including scripts/test_marker_crossfamily_lanes.sh, whose subject is a
341
+ # marker field that hard-blocks commits, and scripts/test_marker_floor_lanes.sh, whose subject is
342
+ # pre-commit's live validate_marker_floor(). Both gates ship; neither calibration had ever run.
343
+ # The card recorded this as three specific repairs needing "one anchor each"; wiring three anchors
344
+ # would have closed those three and stayed blind to the other nine and to the thirteenth. This runs
345
+ # unconditionally when present because its own absence is the defect class it exists to detect —
346
+ # there is no package-mode arm to skip into (a consumer running `npm test` should learn that a
347
+ # shipped suite of theirs is dead code just as much as we should).
348
+ # THREE-VALUED, and the third value exists because the two-valued version was this session's own
349
+ # instance of the defect it detects. The first draft was `if [ -f … ]; then run; fi` — an absent
350
+ # checker fell through to nothing, silently. That is "미측정을 0으로 렌더" reproduced by the commit
351
+ # that closed it: a 1.4.96 consumer has no lane_runner_check.sh (it was added to files[] AFTER that
352
+ # publish), so on their machine this block would have printed nothing at all and `npm test` would
353
+ # have reported a clean run of a check that never existed there.
354
+ # The three states are distinguished by the DECLARATION, not by the environment (same discipline as
355
+ # the pre-push block above): present → run · absent-but-declared-shipped → FAIL (deletion or broken
356
+ # install) · absent-and-not-declared → SKIP, saying so. For a 1.4.96 consumer the third arm is the
357
+ # correct and honest answer, and it names itself rather than being silent.
358
+ if [ -f scripts/lane_runner_check.sh ]; then
359
+ if ! bash scripts/lane_runner_check.sh; then
360
+ fail=1
361
+ fi
362
+ elif _ships_per_files "scripts/lane_runner_check.sh"; then
363
+ echo "FAIL lane-runner: scripts/lane_runner_check.sh is DECLARED SHIPPED but absent — deletion or"
364
+ echo " broken install. The check that detects unrun lane suites is itself missing."
365
+ fail=1
366
+ else
367
+ echo "SKIP lane-runner (not in this package's files[] — predates the version that ships it)"
368
+ fi
369
+
370
+ # ── the twelve suites lane_runner_check.sh measured as having NO runner (2026-08-12) ───────────
371
+ # The check directly above COUNTS them; this block is what makes the count go down. Until now the
372
+ # repo shipped a checker that reported its own todo list every run and nothing that discharged it,
373
+ # which is a decision surface only for as long as someone acts on it.
374
+ #
375
+ # What was actually measured before this wiring existed, because the size of the fact is the reason
376
+ # the block is here: all twelve pass when run by hand (rc=0, ~40s total), and NINE OF THE TWELVE
377
+ # ARE IN THE PUBLISHED TARBALL (`npm pack --dry-run --json`, 263 files). So a consumer running
378
+ # `npm test` was shipping-and-carrying nine test suites that nothing on their machine ever called.
379
+ # The two that hurt most: test_marker_crossfamily_lanes.sh calibrates the `crossfamily:` marker enum
380
+ # that hard-blocks commits, and test_marker_floor_lanes.sh calibrates pre-commit's live
381
+ # validate_marker_floor(). Both gates ship and block; neither calibration had ever executed.
382
+ #
383
+ # ONE loop, not twelve blocks, and that is deliberate: the four-value routing below would otherwise
384
+ # be hand-copied twelve times, and this repo has already measured what that produces — two copies of
385
+ # a normalizer drifting in leniency until one of them silently drops its input
386
+ # ([[feedback_divergent_leniency_duplicate_normalizers]]). The pair table is data; the verdict logic
387
+ # exists once. The existing SessionStart pair-loop below/above uses the same shape.
388
+ #
389
+ # FOUR values, and every arm is reachable on a real machine:
390
+ # subject absent → _absent_subject_verdict (deletion vs package mode, decided by files[])
391
+ # anchor present → run it. exit 10 is called out separately: several of these suites use it
392
+ # for "I could not set myself up" (mktemp failure), which is not a lane
393
+ # failure and must not be reported as one — it still sets fail, because a
394
+ # harness that could not measure did not pass ([[not_found_is_not_zero]]).
395
+ # anchor absent+shipped → FAIL. Deletion or broken install, exactly like the block above.
396
+ # anchor absent+unshipped → SKIP, naming itself. Three anchors genuinely do not ship
397
+ # (chamber_run · frontier_digest_retry · residency_closure), so for a
398
+ # consumer this arm is the honest answer, not a dodge.
399
+ #
400
+ # Subject choice is the file whose behaviour the suite pins, so that deleting the subject routes to
401
+ # "your install is broken" rather than to a green run of a test about nothing.
402
+ # test_capability_entrypoint_shipping.sh pins two (degrade_probe_capability.sh and
403
+ # psa_probe_capability.sh); degrade is named here as the sentinel — the suite itself checks both and
404
+ # fails if either is gone, so nothing is lost by not listing both in this table.
405
+ _LANE_TO=""; command -v timeout >/dev/null 2>&1 && _LANE_TO="timeout 300"
406
+ for _pair in \
407
+ "scripts/degrade_probe_capability.sh|scripts/test_capability_entrypoint_shipping.sh" \
408
+ "scripts/chamber_run.sh|scripts/test_chamber_run_lanes.sh" \
409
+ "scripts/destructive_pre_gate.sh|scripts/test_destructive_pre_gate_lanes.sh" \
410
+ "scripts/env_purity_scan.sh|scripts/test_env_purity_lanes.sh" \
411
+ "scripts/frontier_digest_daily.sh|scripts/test_frontier_digest_retry.sh" \
412
+ "scripts/knowledge_seam_check.sh|scripts/test_knowledge_seam_lanes.sh" \
413
+ "templates/.git-hooks/pre-commit|scripts/test_marker_crossfamily_lanes.sh" \
414
+ "templates/.git-hooks/pre-commit|scripts/test_marker_floor_lanes.sh" \
415
+ "scripts/residency_closure_scan.py|scripts/test_residency_closure_lanes.sh" \
416
+ "scripts/reviewer_capability_corpus.tsv|scripts/test_reviewer_capability_conformance.sh"
417
+ do
418
+ _subj="${_pair%%|*}"; _anc="${_pair##*|}"; _lbl="${_anc##*/}"
419
+ if [ ! -f "$_subj" ]; then
420
+ _absent_subject_verdict "$_lbl" "$_subj" || fail=1
421
+ elif [ -f "$_anc" ]; then
422
+ # `< /dev/null` and the timeout are not decoration: test_frontier_digest_retry.sh deliberately
423
+ # plants a `sleep 300` stub and asserts a 3s watchdog kills it. If that watchdog ever regresses
424
+ # — which is the single defect this suite exists to catch — an unguarded call does not go RED,
425
+ # it HANGS, and CI dies on a job timeout with the cause unattributable. The suite that detects
426
+ # a broken watchdog must not be able to inherit the hang. Same `command -v timeout` guard as the
427
+ # --self-test loop below, because `timeout` is GNU coreutils and stock macOS has neither it nor
428
+ # a substitute; without it `< /dev/null` is the whole defence and a suite that reads stdin ends
429
+ # immediately instead of waiting forever.
430
+ $_LANE_TO bash "$_anc" < /dev/null; _rc=$?
431
+ case "$_rc" in
432
+ 0) ;;
433
+ # The suite could not MEASURE. Distinguished from "the lane failed" because the two send a
434
+ # reader to different places, and a bare fail=1 sends them to the wrong one. 10 = the suite's
435
+ # own setup failed (mktemp, used by several of these); 2 = its subject was missing when it
436
+ # looked (test_knowledge_seam_lanes.sh:7 FATALs this way); 126/127 = the anchor is not
437
+ # executable or not found at all, i.e. a broken install that reached this arm anyway.
438
+ # Every one of them still sets fail — a harness that could not measure did not pass — but it
439
+ # is LABELLED, so the next reader debugs the instrument instead of the lane.
440
+ # The first draft of this loop routed only 10 and let everything else fall into an unlabelled
441
+ # fail=1. That is the same "assumed impossible rather than routed" shape that the sibling
442
+ # commit in lane_runner_check.sh had just written a paragraph against; adversarial review
443
+ # caught the inconsistency between the two files.
444
+ 10|2|126|127)
445
+ echo "HARNESS ERROR $_lbl: the suite exited $_rc — it could not measure, so its verdicts"
446
+ echo " prove nothing about $_subj. Not a lane failure, and not a pass either."
447
+ fail=1 ;;
448
+ *) fail=1 ;;
449
+ esac
450
+ elif _pkg_accepted_absent "$_anc"; then
451
+ # DECLARED legitimately unshipped — the single source for that answer, not a guess from the
452
+ # environment. The first draft printed "this package predates it", which is a WRONG DIAGNOSIS
453
+ # printed forever on every consumer machine: these anchors do not lag the package, they are
454
+ # deliberately not in it (their subjects do not ship either). A confident wrong reason in a
455
+ # verdict line is worse than no reason, because it is the line the next person greps.
456
+ echo "SKIP $_lbl (declared legitimately unshipped — package_coverage_check.sh ACCEPTED_ABSENT)"
457
+ else
458
+ # Not present, and NOT declared absent — so either it should be here (deletion / broken
459
+ # install) or the declaration is stale. Routed through the same three-valued helper as the
460
+ # subject arm above, and for the identical reason: `elif _ships_per_files "$_anc"` was a
461
+ # BOOLEAN test over a THREE-valued function, so its exit 2 (package.json unreadable = UNKNOWN)
462
+ # fell through to a green SKIP. That is the lenient branch the helper's own comment forbids
463
+ # ("THE UNKNOWN ARM IS NOT A SKIP"), rebuilt twelve times in one loop, thirty lines under the
464
+ # helper that exists to prevent it. Found by adversarial review; I had written both.
465
+ _absent_subject_verdict "$_lbl (anchor)" "$_anc" || fail=1
466
+ fi
467
+ done
468
+
229
469
  # embedded --self-test suites (compaction_probe · judgment_circuit_lint · novelty_claim_check).
230
470
  # These three carry their lanes INSIDE the script (`--self-test`) rather than in a sibling
231
471
  # test_*_lanes.sh, so the name-list wiring above skipped them silently: 48 lanes existed and ran
@@ -235,7 +475,7 @@ fi
235
475
  # but self-test missing → FAIL, never a silent pass.
236
476
  for _subj in compaction_probe judgment_circuit_lint novelty_claim_check; do
237
477
  if [ ! -f "scripts/$_subj.sh" ]; then
238
- echo "SKIP $_subj --self-test (subject scripts/$_subj.sh absent)"
478
+ _absent_subject_verdict "$_subj --self-test" "scripts/$_subj.sh" || fail=1
239
479
  else
240
480
  # ⚠️ **문자열 존재로 판정하지 마라.** 초판은 `grep -q -- '--self-test'` 였는데, 그 문자열은
241
481
  # 헤더 주석과 usage echo 에도 있어서 **디스패처 한 줄만 지워도 여전히 매치**한다. 그리고
@@ -249,7 +489,16 @@ for _subj in compaction_probe judgment_circuit_lint novelty_claim_check; do
249
489
  # 난다(실측: homebrew 없는 PATH 에서 3개 subject 전부). 소비자 머신에서 `npm test` 와
250
490
  # `prepublishOnly` 를 깨뜨리는 경로다. 정답 폼은 이미 레포에 있다(sync-from-be.sh:134).
251
491
  # 없으면 무한대기 방지를 잃는 대신 도는 쪽을 택한다 — `< /dev/null` 이 그 방어의 본체다.
252
- local _to=""; command -v timeout >/dev/null 2>&1 && _to="timeout 120"
492
+ # `local` OUTSIDE A FUNCTION, which this loop is. bash prints
493
+ # "selfcheck.sh: line N: local: can only be used in a function"
494
+ # on stderr, the assignment never happens, and `_to` stays empty — so the timeout this line
495
+ # exists to install was NEVER INSTALLED. The guard has been decoration since it was written;
496
+ # the comment above it describing what it protects against was true and unimplemented. Measured
497
+ # 2026-08-13: the error printed three times (once per subject) in a full run, and had been
498
+ # printing in every run before that, unread, because stderr scrolls past a 240-second check.
499
+ # ★ A guard that announces its own failure every single run is still a silent failure if
500
+ # nothing reads the announcement. Fixed by deleting one word.
501
+ _to=""; command -v timeout >/dev/null 2>&1 && _to="timeout 120"
253
502
  _st_out="$($_to bash "scripts/$_subj.sh" --self-test < /dev/null 2>&1)"; _st_rc=$?
254
503
  case "$_st_out" in
255
504
  *캘리브레이션*) : ;;
@@ -291,7 +540,7 @@ fi
291
540
  # anchor was written into tests/ with ZERO callers first — the same defect this file already
292
541
  # records twice above; wiring it here is the fix, not a note about the fix.
293
542
  if [ ! -f scripts/consent_registry_check.sh ]; then
294
- echo "SKIP test_consent_registry.sh (subject scripts/consent_registry_check.sh absent)"
543
+ _absent_subject_verdict "test_consent_registry.sh" "scripts/consent_registry_check.sh" || fail=1
295
544
  elif [ -f scripts/test_consent_registry.sh ]; then
296
545
  if ! bash scripts/test_consent_registry.sh; then
297
546
  fail=1
@@ -306,7 +555,7 @@ fi
306
555
  # cross-family verification. The anchor's first version shipped in tests/ with ZERO callers — the
307
556
  # same defect the comment above records for test_card_drift_probe.sh, repeated one file later.
308
557
  if [ ! -f scripts/sidecar_wait.sh ]; then
309
- echo "SKIP test_sidecar_wait_stdin.sh (subject scripts/sidecar_wait.sh absent)"
558
+ _absent_subject_verdict "test_sidecar_wait_stdin.sh" "scripts/sidecar_wait.sh" || fail=1
310
559
  elif [ -f scripts/test_sidecar_wait_stdin.sh ]; then
311
560
  if ! bash scripts/test_sidecar_wait_stdin.sh; then
312
561
  fail=1
@@ -325,7 +574,7 @@ fi
325
574
  # states that look identical from outside ("the sidecar ran" vs "the model I pinned answered",
326
575
  # "absent" vs "unmeasured"), and its lanes are hermetic stubs, so running them costs nothing.
327
576
  if [ ! -f scripts/sidecar_calibrate.sh ]; then
328
- echo "SKIP test_sidecar_calibrate_lanes.sh (subject scripts/sidecar_calibrate.sh absent)"
577
+ _absent_subject_verdict "test_sidecar_calibrate_lanes.sh" "scripts/sidecar_calibrate.sh" || fail=1
329
578
  elif [ -f scripts/test_sidecar_calibrate_lanes.sh ]; then
330
579
  if ! bash scripts/test_sidecar_calibrate_lanes.sh; then
331
580
  fail=1
@@ -422,7 +671,7 @@ _gps_missing=""
422
671
  [ -f templates/.git-hooks/pre-commit ] || _gps_missing="templates/.git-hooks/pre-commit"
423
672
  [ -f templates/regression_guard.sh ] || _gps_missing="${_gps_missing:+$_gps_missing, }templates/regression_guard.sh"
424
673
  if [ -n "$_gps_missing" ]; then
425
- echo "SKIP gate_pathspec_check.sh (subject absent: $_gps_missing) not-checked, NOT a pass"
674
+ _absent_subject_verdict "gate_pathspec_check.sh" "$_gps_missing" || fail=1
426
675
  elif [ -f scripts/gate_pathspec_check.sh ]; then
427
676
  if ! bash scripts/gate_pathspec_check.sh; then
428
677
  fail=1
@@ -444,7 +693,7 @@ else
444
693
  fi
445
694
 
446
695
  if [ ! -f scripts/fh_node_check.sh ]; then
447
- echo "SKIP test_node_check_lanes.sh (subject scripts/fh_node_check.sh absent)"
696
+ _absent_subject_verdict "test_node_check_lanes.sh" "scripts/fh_node_check.sh" || fail=1
448
697
  elif [ -f scripts/test_node_check_lanes.sh ]; then
449
698
  if ! bash scripts/test_node_check_lanes.sh; then
450
699
  fail=1
@@ -457,7 +706,7 @@ fi
457
706
  # The infra-delta half of the same subject. Separate suite, same pairing rule: it exists only because
458
707
  # fh_node_check.sh does, so its absence beside a present subject is a FAIL, not a skip.
459
708
  if [ ! -f scripts/fh_node_check.sh ]; then
460
- echo "SKIP test_node_infra_delta_lanes.sh (subject scripts/fh_node_check.sh absent)"
709
+ _absent_subject_verdict "test_node_infra_delta_lanes.sh" "scripts/fh_node_check.sh" || fail=1
461
710
  elif [ -f scripts/test_node_infra_delta_lanes.sh ]; then
462
711
  if ! bash scripts/test_node_infra_delta_lanes.sh; then
463
712
  fail=1
@@ -468,14 +717,43 @@ else
468
717
  fi
469
718
 
470
719
  # SessionStart multi-hook + install-wizard snippet merge. Subject for both = the shipped settings
471
- # snippets; a clone without them is a legitimate SKIP, a clone with them and no anchor is not.
720
+ # snippets; a clone without them is a legitimate SKIP, a clone with them and no anchor is not
721
+ # UNLESS the anchor itself is declared package-mode-optional. test_sessionstart_multihook_lanes.sh
722
+ # is exactly that. Its ACCEPTED_ABSENT entry (package_coverage_check.sh) covers a DIFFERENT case than
723
+ # this loop implements: that entry's "selfcheck reports it NOT EXERCISED (exit 2)" describes the
724
+ # anchor RUNNING and finding no CLI (handled a few lines below, rc==2). It never claimed anything
725
+ # about the anchor FILE being missing — a real consumer never gets to run it at all (the file is not
726
+ # in files[]), and this loop had no branch for that at all, so every installed package hit
727
+ # "FAIL … anchor is missing" (corrected 2026-08-12, cross-family review — an earlier revision of this
728
+ # comment miscited the ACCEPTED_ABSENT entry as already covering the missing-file case). Fixed by
729
+ # consulting the SAME declaration (`_pkg_accepted_absent`, loaded once near the top of this file) that
730
+ # the ref-path block above uses — not an environment predicate — because `.git` presence answers "is
731
+ # there a git repo here", not "was this anchor declared intentionally unshipped", and the two diverge
732
+ # in a git-tracked vendored tree (a monorepo committing node_modules, `git init` after install): `.git`
733
+ # exists there too, which would silently reproduce the original FAIL.
734
+ # test_wizard_snippet_merge_lanes.sh is NOT in ACCEPTED_ABSENT (it does ship, per files[]) — routing
735
+ # both anchors through the same declaration lookup, rather than hardcoding one as always-FAIL, means a
736
+ # future person who genuinely needs to exempt it does so by editing ONE list, not by finding this loop.
472
737
  for _pair in \
473
- "templates/settings.SessionStart.snippet.json|scripts/test_sessionstart_multihook_lanes.sh" \
474
- "templates/settings.SessionStart.snippet.json|scripts/test_wizard_snippet_merge_lanes.sh"
738
+ "templates/settings.SessionStart.snippet.json|scripts/test_sessionstart_multihook_lanes.sh|package-optional" \
739
+ "templates/settings.SessionStart.snippet.json|scripts/test_wizard_snippet_merge_lanes.sh|always-shipped"
475
740
  do
476
- _subj="${_pair%%|*}"; _anc="${_pair#*|}"
741
+ _subj="${_pair%%|*}"; _rest="${_pair#*|}"; _anc="${_rest%%|*}"; _mode="${_rest#*|}"
742
+ # This mode field is a gate-verdict policy value (does a missing anchor FAIL or SKIP), not free
743
+ # text — an unrecognized value must not silently fall through to whichever branch string-matching
744
+ # happens to miss. Cross-family review, 2026-08-12: the two known values were previously the only
745
+ # ones exercised, so a typo (e.g. "alway-shipped") landed in the `else` FAIL branch by accident of
746
+ # string mismatch rather than by a checked policy — fail-closed in practice, but undeclared.
747
+ case "$_mode" in
748
+ package-optional|always-shipped) ;;
749
+ *)
750
+ echo "FAIL ${_anc##*/}: unrecognized pair mode '$_mode' (expected package-optional or always-shipped)"
751
+ fail=1
752
+ continue
753
+ ;;
754
+ esac
477
755
  if [ ! -f "$_subj" ]; then
478
- echo "SKIP ${_anc##*/} (subject $_subj absent)"
756
+ _absent_subject_verdict "${_anc##*/}" "$_subj" || fail=1
479
757
  elif [ -f "$_anc" ]; then
480
758
  # THREE-valued, like the session-close anchors above — and for a third reason they do not have.
481
759
  # test_sessionstart_multihook_lanes.sh measures what the LIVE `claude` CLI does with several
@@ -494,6 +772,8 @@ do
494
772
  elif [ "$_rc" -ne 0 ]; then
495
773
  fail=1
496
774
  fi
775
+ elif [ "$_mode" = "package-optional" ] && _pkg_accepted_absent "$_anc"; then
776
+ echo "SKIP ${_anc##*/} (declared ACCEPTED_ABSENT — CLI/cost-gated, see package_coverage_check.sh)"
497
777
  else
498
778
  echo "FAIL ${_anc##*/}: $_subj present but its anchor is missing"
499
779
  fail=1
@@ -504,7 +784,7 @@ done
504
784
  # 2026-07-31; the pipe-verdict lane shipped in PR #209 WITHOUT this wiring, which is itself the
505
785
  # half-fix class the second guard exists to catch — found by running that guard on this repo.
506
786
  if [ ! -f scripts/sidecar_calibrate.sh ]; then
507
- echo "SKIP test_ollama_panel_lanes.sh (subject scripts/sidecar_calibrate.sh absent)"
787
+ _absent_subject_verdict "test_ollama_panel_lanes.sh" "scripts/sidecar_calibrate.sh" || fail=1
508
788
  elif [ -f scripts/test_ollama_panel_lanes.sh ]; then
509
789
  if ! bash scripts/test_ollama_panel_lanes.sh; then
510
790
  fail=1
@@ -515,7 +795,7 @@ else
515
795
  fi
516
796
 
517
797
  if [ ! -f scripts/pipe_verdict_guard.sh ]; then
518
- echo "SKIP test_pipe_verdict_guard_lanes.sh (subject scripts/pipe_verdict_guard.sh absent)"
798
+ _absent_subject_verdict "test_pipe_verdict_guard_lanes.sh" "scripts/pipe_verdict_guard.sh" || fail=1
519
799
  elif [ -f scripts/test_pipe_verdict_guard_lanes.sh ]; then
520
800
  if ! bash scripts/test_pipe_verdict_guard_lanes.sh; then
521
801
  fail=1
@@ -526,7 +806,7 @@ else
526
806
  fi
527
807
 
528
808
  if [ ! -f scripts/halffix_propagation_scan.sh ]; then
529
- echo "SKIP test_halffix_lanes.sh (subject scripts/halffix_propagation_scan.sh absent)"
809
+ _absent_subject_verdict "test_halffix_lanes.sh" "scripts/halffix_propagation_scan.sh" || fail=1
530
810
  elif [ -f scripts/test_halffix_lanes.sh ]; then
531
811
  if ! bash scripts/test_halffix_lanes.sh; then
532
812
  fail=1
@@ -550,7 +830,7 @@ fi
550
830
 
551
831
  for _anchor in scripts/test_session_close_lanes.sh scripts/test_card_drift_probe.sh scripts/test_session_close_chain_lanes.sh; do
552
832
  if [ ! -f scripts/session_close_check.sh ]; then
553
- echo "SKIP ${_anchor##*/} (subject scripts/session_close_check.sh absent)"
833
+ _absent_subject_verdict "${_anchor##*/}" "scripts/session_close_check.sh" || fail=1
554
834
  elif [ -f "$_anchor" ]; then
555
835
  # Preserve the anchor's two failure CLASSES instead of flattening them into one `fail=1`.
556
836
  # An anchor exits 3 when a fixture's premise never obtained — "this run's verdicts prove
@@ -660,7 +940,7 @@ fi
660
940
  # tag reached the remote and a publish from the wrong tree was stopped only by npm's own collision
661
941
  # check, so an unrun anchor here would be the same luck-as-floor arrangement one layer up.
662
942
  if [ ! -f templates/.git-hooks/pre-push ]; then
663
- echo "SKIP test_tag_version_lanes.sh (subject templates/.git-hooks/pre-push absent)"
943
+ _absent_subject_verdict "test_tag_version_lanes.sh" "templates/.git-hooks/pre-push" || fail=1
664
944
  elif [ -f scripts/test_tag_version_lanes.sh ]; then
665
945
  # RUN-ONCE, CAPTURE (2026-08-05) — rationale in the sync_from_be_lanes block later in this file.
666
946
  if _out=$(bash scripts/test_tag_version_lanes.sh 2>&1); then
@@ -680,7 +960,7 @@ fi
680
960
  # per-plugin entries inside marketplace.json, which the tag lane never opens. Measured 2026-08-06:
681
961
  # a bump left the second marketplace entry behind and the tag lane passed 8/8 straight through it.
682
962
  if [ ! -f scripts/version_lockstep_check.sh ]; then
683
- echo "SKIP test_version_lockstep_lanes.sh (subject scripts/version_lockstep_check.sh absent)"
963
+ _absent_subject_verdict "test_version_lockstep_lanes.sh" "scripts/version_lockstep_check.sh" || fail=1
684
964
  elif [ -f scripts/test_version_lockstep_lanes.sh ]; then
685
965
  if _out=$(bash scripts/test_version_lockstep_lanes.sh 2>&1); then
686
966
  echo "PASS test_version_lockstep_lanes.sh (drift blocks · aligned silent · unreadable = exit 2, not pass)"
@@ -766,7 +1046,28 @@ fi
766
1046
 
767
1047
  # Referenced-path existence is a source-tree check. The npm package intentionally
768
1048
  # ships a narrower runtime surface, so package-mode selfcheck skips this section.
769
- if [ -d ".claude/rules" ]; then
1049
+ # ⚠️ The skip predicate used to be `[ -d ".claude/rules" ]`. That broke the moment the tarball
1050
+ # started shipping PART of that directory (`.claude/rules/fh_4axis_gate.md` etc. are in files[]) —
1051
+ # the directory then exists in BOTH source and package mode, so the check never skipped in package
1052
+ # mode at all. It ran, extracted refs from the shipped CLAUDE.md/.claude/rules/*.md (which still
1053
+ # name `.claude/regression/ablation_verdicts.md` and `scripts/probe_scope_check.sh` — both
1054
+ # deliberately unshipped, per package_coverage_check.sh's own ACCEPTED_ABSENT list), then tried
1055
+ # `git check-ignore` against a tree with no `.git` at all (a real `npm pack` tarball is not a git
1056
+ # repo) — that call errors rather than confirming "ignored", so the fallback `[ -f "$p" ]` ran and
1057
+ # correctly found nothing, and the check reported FAIL on two paths it had already been told, one
1058
+ # check over, were fine to omit. First fix (2026-08-12, reship axis, card §🔱⑮ G/D) swapped the skip
1059
+ # predicate for `[ -e .git ]`. Cross-family review then caught that `[ -e .git ]` answers a different
1060
+ # question than the one this check needs: a git-TRACKED vendor of this package (a monorepo that
1061
+ # commits node_modules, or a consumer who runs `git init` after installing) has `.git` and IS a
1062
+ # legitimate package consumer, yet the predicate would route it into the full extraction and
1063
+ # reproduce the exact original FAIL on these same two paths — the fix would have closed the bug only
1064
+ # in the one shape it was tested against. The general fix is not a better environment predicate; it
1065
+ # is not re-deriving "is this legitimately absent" from the environment at all when a DECLARED answer
1066
+ # already exists — `_pkg_accepted_absent()`, loaded once near the top of this file — this block now
1067
+ # consults it before FAILing, so the two paths render SKIP regardless of how `.git` happens to be
1068
+ # shaped in the consumer's tree. `[ -e .git ]` still gates whether the SCAN runs at all (an installed
1069
+ # package with no tracked-refs source to lint), which is a real and unrelated question.
1070
+ if [ -e ".git" ]; then
770
1071
  # Backtick-quoted repo-relative file refs in the always-loaded governance surface
771
1072
  # (CLAUDE.md + .claude/rules/*.md) must exist. Phantom-reference class recurred
772
1073
  # N>=3 in the 2026-06-11 audit window — instrument-not-habit.
@@ -811,6 +1112,8 @@ REFPY
811
1112
  echo "SKIP ref-path (gitignored): $p"
812
1113
  elif [ -f "$p" ]; then
813
1114
  echo "PASS ref-path: $p"
1115
+ elif _pkg_accepted_absent "$p"; then
1116
+ echo "SKIP ref-path (declared ACCEPTED_ABSENT — see package_coverage_check.sh): $p"
814
1117
  else
815
1118
  echo "FAIL ref-path: $p — referenced in CLAUDE.md/.claude/rules but missing"
816
1119
  fail=1
@@ -820,7 +1123,7 @@ $_refs
820
1123
  REFS
821
1124
  fi
822
1125
  else
823
- echo "SKIP ref-path (package mode: .claude/rules absent)"
1126
+ echo "SKIP ref-path (package mode: no .git at package root — source-tree-only check)"
824
1127
  fi
825
1128
 
826
1129
  if [ "$fail" -ne 0 ]; then
@@ -728,6 +728,60 @@ YAML
728
728
  lane "P-SPELL a grant WIDER than its class is still refused (the paired control)" 1 "R7"
729
729
 
730
730
 
731
+ # ── PROV : every verdict states what it measured WITH, and it states the TRUTH ──────────────────
732
+ # 2026-08-12. This gate rides selfcheck → prepublishOnly. A release shipped green from a session whose
733
+ # `python3` resolved to an unrelated project's venv that had PyYAML, while the machine's own python3
734
+ # did not. Nothing was bypassed — the PASS was simply not portable, and said nothing about what
735
+ # produced it.
736
+ #
737
+ # 🟥 The first version of this lane compared two arms, one of them "PyYAML hidden" via
738
+ # `env -i PATH=/usr/bin:/bin PYTHONNOUSERSITE=1`. It passed locally and FAILED IN CI — because
739
+ # `PYTHONNOUSERSITE` suppresses only the USER site directory. On this author's machine PyYAML was a
740
+ # `--user` install so it hid; on the CI runner it is a system `dist-packages` install so it did not,
741
+ # both arms returned the same value, and the lane called its own subject decorative.
742
+ # **The control worked only by accident of how the author happened to install a package** — which is
743
+ # the exact defect class the subject under test exists to catch, reproduced inside its own lane.
744
+ #
745
+ # So the lane no longer manufactures an environment. It compares the reported value against an
746
+ # INDEPENDENT ORACLE computed in the same run: whatever `find_spec` says here, the instrument line
747
+ # must say the same thing. That catches removal, hard-coding, truncation, and drift — everywhere,
748
+ # with no assumption about how PyYAML got installed.
749
+ _prov_line=$(bash "$CHK" 2>&1 | grep -o 'instrument (consent-registry): .*' | head -1)
750
+ _prov_oracle=$(python3 - <<'ORACLE' 2>/dev/null
751
+ import importlib.util, sys
752
+ s = importlib.util.find_spec("yaml")
753
+ print((s.origin or "namespace-package") if s is not None else "ABSENT")
754
+ ORACLE
755
+ )
756
+ if [ -z "$_prov_line" ]; then
757
+ echo " ❌ PROV-1 no instrument line on the ordinary path"; fail=$((fail+1))
758
+ elif [ -z "$_prov_oracle" ]; then
759
+ echo " ❌ PROV-1 oracle produced nothing — NOT RUN (unmeasured, not a pass)"; fail=$((fail+1))
760
+ elif ! printf '%s' "$_prov_line" | grep -q ': /'; then
761
+ echo " ❌ PROV-1 line does not name an absolute interpreter path: [$_prov_line]"; fail=$((fail+1))
762
+ elif ! printf '%s' "$_prov_line" | grep -qF "PyYAML $_prov_oracle"; then
763
+ echo " ❌ PROV-1 line disagrees with the oracle — reported [$_prov_line] vs actual [$_prov_oracle]"; fail=$((fail+1))
764
+ else
765
+ echo " ✅ PROV-1 instrument line matches an independent resolution of PyYAML [$_prov_oracle]"; pass=$((pass+1))
766
+ fi
767
+
768
+ # PROV-2 — the ABSENT branch, exercised DETERMINISTICALLY rather than by hiding a package.
769
+ # A `yaml.py` MODULE FILE placed first on PYTHONPATH wins by path order, so find_spec resolves to it
770
+ # — a different, predictable answer that does not depend on how the real PyYAML was installed.
771
+ # ⚠️ A `yaml/` DIRECTORY does NOT work and the first draft used one: a namespace package has LOWER
772
+ # precedence than a regular package, so Python keeps scanning the whole path and still finds the real
773
+ # one. Measured — the arm did not move, and the lane correctly called itself decorative.
774
+ _prov_tmp=$(mktemp -d); printf '# shadow module for the PROV-2 arm\n' > "$_prov_tmp/yaml.py"
775
+ _prov_shadow=$(PYTHONPATH="$_prov_tmp" bash "$CHK" 2>&1 | grep -o 'instrument (consent-registry): .*' | head -1)
776
+ rm -rf "$_prov_tmp"
777
+ if [ -z "$_prov_shadow" ]; then
778
+ echo " ❌ PROV-2 no instrument line under a shadowed yaml"; fail=$((fail+1))
779
+ elif [ "$_prov_shadow" = "$_prov_line" ]; then
780
+ echo " ❌ PROV-2 line did not move when the resolution moved — decorative [$_prov_line]"; fail=$((fail+1))
781
+ else
782
+ echo " ✅ PROV-2 line tracks the resolution when it changes (shadowed → different value)"; pass=$((pass+1))
783
+ fi
784
+
731
785
  echo "----"
732
786
  echo "consent-registry anchor: $pass passed, $fail failed"
733
787
  [ "$fail" -eq 0 ] || exit 1
@@ -17,7 +17,16 @@
17
17
  # Usage: bash scripts/test_marker_crossfamily_lanes.sh Exit: 0 = all behave; 1 = regression.
18
18
 
19
19
  set -uo pipefail
20
- REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
20
+ # Script-relative, NOT `git rev-parse --show-toplevel`. Measured 2026-08-13 in a vendored tree
21
+ # (npm install, then `git init` at a level above — a monorepo committing node_modules is the
22
+ # same shape): rev-parse answers with the OUTER repo's root, so this suite looked for the
23
+ # package's own files inside somebody else's checkout, found nothing, and reported
24
+ # HARNESS-ERROR. The consumer sees a red `npm test` caused entirely by where their .git is.
25
+ # The subject of these lanes ships INSIDE this package, so the package root is the only root
26
+ # that can be right. Same form as test_capability_entrypoint_shipping.sh:29.
27
+ # The exposure is new: before these suites were wired into selfcheck.sh they ran nowhere, so
28
+ # the wrong root never cost anything. Wiring a dead lane surfaces every assumption it made.
29
+ REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
21
30
  HOOK="$REPO_ROOT/templates/.git-hooks/pre-commit"
22
31
  T=$(mktemp -d); trap 'rm -rf "$T"' EXIT
23
32