@chrono-meta/fh-gate 2.11.0 → 2.12.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.
@@ -39,10 +39,37 @@ if [ -z "$CATLOGS_DEF" ]; then
39
39
  echo "FAIL subject 에 _cat_logs 가 없다 — 전환 설계(레거시 ∪ 디렉터리)가 사라졌거나 이름이 바뀌었다."
40
40
  exit 1
41
41
  fi
42
+ # 🟥 2026-08-26 — 주어가 read-error 를 UNMEASURED 로 가르기 시작했고 그 로직이 `_cnt` 에 산다.
43
+ # 이걸 안 들여오면 대입줄 평가가 «command not found → rc 127 → UNMEASURED» 로 **틀린 이유로**
44
+ # 답을 낸다. 이 파일이 이미 _cat_logs 에 대해 경고한 장식-앵커 함정의 같은 얼굴이다.
45
+ CNT_DEF=$(awk '/^_cnt\(\) \{/,/^\}/' "$CHECK")
46
+ LOGGREP_DEF=$(awk '/^_log_grep\(\) \{/,/^\}/' "$CHECK")
47
+ if [ -z "$CNT_DEF" ]; then
48
+ echo "FAIL subject 에 _cnt 가 없다 — read-error↔zero 분리(UNMEASURED)가 사라졌거나 이름이 바뀌었다."
49
+ exit 1
50
+ fi
51
+ if [ -z "$LOGGREP_DEF" ]; then
52
+ echo "FAIL subject 에 _log_grep 가 없다 — LOGGED 의 리더가 사라졌거나 이름이 바뀌었다."
53
+ exit 1
54
+ fi
42
55
  echo "── matcher located in the subject"
43
56
  echo "── _cat_logs lifted from the subject ($(printf '%s' "$CATLOGS_DEF" | grep -c '') lines)"
44
57
 
45
58
  T=$(mktemp -d); trap 'rm -rf "$T"' EXIT
59
+ # 🟥 정의를 `bash -c "..."` 안에 인라인하면 **바깥 셸이 먼저 확장**한다 — `_cnt` 본문의 `"$@"` 가
60
+ # 빈 문자열로 치환돼 리더가 조용히 죽고, 레인은 «틀린 이유로» 판정을 낸다(2026-08-26 실측).
61
+ # 파일로 떨궈 source 하면 그 창이 아예 없다.
62
+ SUBJ_DEFS="$T/subject_defs.sh"
63
+ printf '%s\n%s\n%s\n' "$CATLOGS_DEF" "$CNT_DEF" "$LOGGREP_DEF" > "$SUBJ_DEFS"
64
+ bash -n "$SUBJ_DEFS" || { echo "FAIL subject 정의 3종을 들어왔으나 구문이 깨진다"; exit 1; }
65
+ # 🟥 크기 가드 — awk 범위가 안 닫히면(한 줄 함수라 `}` 가 column 0 에 없으면) 파일 나머지를
66
+ # 통째로 끌고 오고, 그래도 `bash -n` 은 통과한다. 그러면 정의가 아니라 스크립트를 source 하게
67
+ # 되어 «unbound variable» 같은 엉뚱한 이유로 판정이 난다(2026-08-26 실측).
68
+ _SD_LINES=$(grep -c '' "$SUBJ_DEFS")
69
+ if [ "$_SD_LINES" -gt 40 ]; then
70
+ echo "FAIL 들어온 정의가 ${_SD_LINES}줄 — awk 범위가 안 닫혔다(한 줄 함수?). 정의만 와야 한다."
71
+ exit 1
72
+ fi
46
73
  D=2026-08-02
47
74
 
48
75
  echo "── date-spelling lanes (the shipped miscount) ──"
@@ -132,7 +159,7 @@ _eval_subject_assign() { # $1 = variable name; echoes what the SUBJECT computes
132
159
  _int() { case \"\${1:-}\" in (''|*[!0-9]*) echo 0 ;; (*) echo \"\$1\" ;; esac; }
133
160
  # ★ LOGGED 는 주어의 _cat_logs 에 의존한다. 이걸 안 들여오면 «함수 없음 → 빈 입력 → 0»
134
161
  # 으로 **틀린 이유로 통과**한다 — 이 파일이 경고하는 장식 앵커 그 자체다.
135
- $CATLOGS_DEF
162
+ . '$SUBJ_DEFS'
136
163
  TODAY=NOSUCHDATE; TALLY='$CHECK'; LOG='$CHECK'; LOGDIR='$CHECK.nodir'
137
164
  $line
138
165
  printf %s \"\$$var\"" 2>/dev/null
@@ -150,7 +177,7 @@ LOGGED_LINE=$(grep -E "^LOGGED=" "$CHECK" | head -1)
150
177
  _count_in() { # $1=LOG 경로(없으면 빈문자) $2=LOGDIR 경로(없으면 빈문자)
151
178
  bash -c "set -uo pipefail
152
179
  _int() { case \"\${1:-}\" in (''|*[!0-9]*) echo 0 ;; (*) echo \"\$1\" ;; esac; }
153
- $CATLOGS_DEF
180
+ . '$SUBJ_DEFS'
154
181
  TODAY='$D'; LOG='$1'; LOGDIR='$2'
155
182
  $LOGGED_LINE
156
183
  printf %s \"\$LOGGED\"" 2>/dev/null
@@ -167,6 +194,31 @@ printf -- "- date: %s\n" "$D" > "$LT/dir/b.yaml" # 1건
167
194
  _naive=$(grep -cE "^- date: *'?$D'?" "$LT/dir"/*.yaml 2>/dev/null | tr -d ' \n')
168
195
  [ "$_naive" != 3 ] ; chk $? "컨트롤: naive grep -c 다중파일은 3을 못 낸다 (실제='$_naive' — 경로:개수 형태)"
169
196
 
197
+ echo ""
198
+ echo "── read-error ≠ zero 레인 (2026-08-26, cross-family/codex) ──"
199
+ # 주어가 «0건» 과 «못 읽었다» 를 가르는가. 가르기 전에는 읽기 실패가 0 으로 접혀
200
+ # "✅ ④-e no sub-agent dispatches tallied today" 라는 **안 잰 초록**이 나갔다.
201
+ DISP_LINE=$(grep -E "^DISPATCHED=" "$CHECK" | head -1)
202
+ _disp_with() { # $1 = TALLY 로 쓸 경로
203
+ bash -c "set -uo pipefail
204
+ _int() { case \"\${1:-}\" in (''|*[!0-9]*) echo 0 ;; (*) echo \"\$1\" ;; esac; }
205
+ . '$SUBJ_DEFS'
206
+ TODAY='$D'; TALLY='$1'
207
+ $DISP_LINE
208
+ printf %s \"\$DISPATCHED\"" 2>/dev/null
209
+ }
210
+ RE="$T/readerr"; mkdir -p "$RE/as_dir"
211
+ printf '%s\n' "$D" > "$RE/real_hit" # 오늘 1건
212
+ : > "$RE/real_zero" # 진짜 0건
213
+ _p=$(_disp_with "$RE/real_hit")
214
+ [ "$_p" = "1" ] ; chk $? "POS 계기 생존: 정상 tally 1건 → '$_p' (1 이어야 아래 판정이 읽힌다)"
215
+ _z=$(_disp_with "$RE/real_zero")
216
+ [ "$_z" = "0" ] ; chk $? "진짜 0건 → '$_z' (UNMEASURED 아님 — 부재가 아니라 실측된 0)"
217
+ _u=$(_disp_with "$RE/as_dir")
218
+ [ "$_u" = "UNMEASURED" ] ; chk $? "읽기 실패(디렉터리) → '$_u' (0 으로 접히면 안 잰 초록이 나간다)"
219
+ _n=$(_disp_with "$RE/nosuchfile")
220
+ [ "$_n" = "0" ] ; chk $? "파일 부재 → '$_n' — 세 번째 상태다. 안 쓰인 tally 는 «0 디스패치»이지 «못 읽음»이 아니다. UNMEASURED 로 두면 새 install 의 깨끗한 마감을 전부 false-block 하고, 과차단 close 게이트는 같은 훅의 Destructive-Op 게이트까지 무장해제시키는 --no-verify 반사를 훈련시킨다"
221
+
170
222
  echo ""
171
223
  if [ "$FAILED" -ne 0 ]; then echo "DISPATCH-LOG LANES: FAIL"; exit 1; fi
172
224
  echo "DISPATCH-LOG LANES: PASS ($PASS/$PASS)"
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env bash
2
+ # Known-pair lane for fh-goal's change detection.
3
+ #
4
+ # 🟥 WHAT THIS EXISTS TO STOP (2026-08-26, cross-family/codex finding):
5
+ # `git` present + a real repo does NOT mean `diff`/`status` SUCCEEDS. Before this lane,
6
+ # a FAILING `git status` produced an empty TARGET_FILES, which the skip-branch could not
7
+ # tell apart from "nothing changed" → `exit 0` → **fh-gate never ran, caller read it as a
8
+ # clean run**. fh-goal.sh already named that exact class in a comment and had closed it for
9
+ # the "no git at all" branch only.
10
+ #
11
+ # The pair:
12
+ # ARM A (known-positive) git status FAILS → MUST exit 10 ← red before the fix
13
+ # ARM B (known-negative) git status OK, no output → MUST exit 0 (genuinely nothing changed)
14
+ # ARM C (control) git status OK, one file → MUST reach fh-gate (proves A/B are not
15
+ # just "everything exits early")
16
+ # Without ARM C, A and B both pass on a script that never gets to the gate at all.
17
+ set -uo pipefail
18
+ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
19
+ TARGET="${FH_GOAL_UNDER_TEST:-$ROOT/scripts/fh-goal.sh}"
20
+ PASS=0; FAIL=0
21
+ ok(){ printf ' ✅ %s\n' "$1"; PASS=$((PASS+1)); }
22
+ no(){ printf ' ❌ %s\n' "$1"; FAIL=$((FAIL+1)); }
23
+
24
+ FIX=$(mktemp -d); trap 'rm -rf "$FIX"' EXIT
25
+ mkdir -p "$FIX/bin" "$FIX/work"
26
+
27
+ # --- git shim: real enough to pass the GIT_OK probe, scriptable for diff/status -------------
28
+ cat > "$FIX/bin/git" <<'GIT'
29
+ #!/usr/bin/env bash
30
+ # args may be prefixed with -C <dir>
31
+ while [[ "${1:-}" == "-C" ]]; do shift 2; done
32
+ case "${1:-}" in
33
+ rev-parse)
34
+ case "${2:-}" in
35
+ --git-dir) echo ".git"; exit 0 ;;
36
+ HEAD) echo "0000000000000000000000000000000000000000"; exit 0 ;;
37
+ esac
38
+ exit 0 ;;
39
+ diff) exit "${FAKE_GIT_DIFF_RC:-0}" ;;
40
+ status)
41
+ if [[ "${FAKE_GIT_STATUS_RC:-0}" -ne 0 ]]; then exit "${FAKE_GIT_STATUS_RC}"; fi
42
+ [[ -n "${FAKE_GIT_STATUS_OUT:-}" ]] && printf '%s\n' "$FAKE_GIT_STATUS_OUT"
43
+ exit 0 ;;
44
+ esac
45
+ exit 0
46
+ GIT
47
+ chmod +x "$FIX/bin/git"
48
+
49
+ # --- backend stub: fh-goal requires the CLI on PATH and pipes a prompt into it --------------
50
+ printf '#!/usr/bin/env bash\ncat >/dev/null\necho "stub backend output"\nexit 0\n' > "$FIX/bin/codex"
51
+ chmod +x "$FIX/bin/codex"
52
+
53
+ run_arm() { # $1=label $2..=env assignments ; prints rc
54
+ env PATH="$FIX/bin:$PATH" FH_BACKEND=codex FH_TIMEOUT=20 "${@:2}" \
55
+ bash "$TARGET" --prompt "noop" --root "$FIX/work" >"$FIX/out" 2>"$FIX/err"
56
+ echo $?
57
+ }
58
+
59
+ echo "fh-goal change-detection known-pair (target: $TARGET)"
60
+
61
+ # ARM A — the defect
62
+ RC=$(run_arm A FAKE_GIT_STATUS_RC=128 FAKE_GIT_DIFF_RC=128)
63
+ if [[ "$RC" == "10" ]] && grep -q "cannot detect changed files" "$FIX/err"; then
64
+ ok "ARM A known-positive: git failure → exit 10, fail-closed"
65
+ else
66
+ no "ARM A known-positive: expected rc=10 + 'cannot detect changed files', got rc=$RC"
67
+ sed -n 1,6p "$FIX/err" | sed 's/^/ /'
68
+ fi
69
+
70
+ # ARM B — genuinely clean
71
+ RC=$(run_arm B FAKE_GIT_STATUS_RC=0 FAKE_GIT_STATUS_OUT=)
72
+ if [[ "$RC" == "0" ]] && grep -q "no changed files detected" "$FIX/err"; then
73
+ ok "ARM B known-negative: clean tree → exit 0 (skip is legitimate here)"
74
+ else
75
+ no "ARM B known-negative: expected rc=0 + 'no changed files detected', got rc=$RC"
76
+ sed -n 1,6p "$FIX/err" | sed 's/^/ /'
77
+ fi
78
+
79
+ # ARM C — control: proves the script can actually REACH the gate
80
+ RC=$(run_arm C FAKE_GIT_STATUS_RC=0 FAKE_GIT_STATUS_OUT=" M probe_file.txt")
81
+ if grep -q "running fh-gate on" "$FIX/err"; then
82
+ ok "ARM C control: changed file → reaches fh-gate (instrument is alive)"
83
+ else
84
+ no "ARM C control: never reached fh-gate — ARM A/B results are UNINTERPRETABLE (rc=$RC)"
85
+ sed -n 1,6p "$FIX/err" | sed 's/^/ /'
86
+ fi
87
+
88
+ echo "fh-goal change-detection: $PASS passed, $FAIL failed"
89
+ [[ "$FAIL" -eq 0 ]] || exit 1
@@ -26,6 +26,33 @@
26
26
  set -uo pipefail
27
27
  SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
28
28
  ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
29
+ # 🟥 ENVIRONMENT ISOLATION (2026-08-27). `CLAUDE.local.md` INSTRUCTS this operator to export
30
+ # FH_COMPANION_STORE, so the suite inherited a REAL companion store and ⑤-C compared each FIXTURE
31
+ # card against the operator's actual prior card — reporting a carry-over loss that belongs to
32
+ # neither. Measured A/B on this file: exported → rc 1 with 6 exit-code lanes red · unset → rc 0.
33
+ # The verdict CONTENT was right every time (every `_line` assertion passed); only the exit code
34
+ # moved, which is what made it read like an over-blocking script rather than an ambient leak.
35
+ # 🟥 THIS IS THE SECOND FILE WITH THIS LEAK. The sibling test_session_close_lanes.sh was fixed
36
+ # earlier the same day and this one was not — a half-fix propagation boundary created by the same
37
+ # author who had just named that class. Fixed together now; the sweep that found it is
38
+ # grep -l session_close_check scripts/test_*.sh → check each for an FH_COMPANION_STORE guard.
39
+ # Lanes that genuinely exercise ⑤-C set their own fixture store ON the invocation and still win.
40
+ # 🟥 CLASS, NOT INSTANCE. The first draft of this guard unset FH_COMPANION_STORE alone — the one
41
+ # variable that had actually bitten. That is the same shape as the half-fix that put this guard in
42
+ # only ONE of two sibling lane files hours earlier. Every operator-settable override the subject
43
+ # reads is the same window, so all of them are closed here rather than one at a time:
44
+ # FH_COMPANION_STORE ⑤-C reads a REAL prior card and reports a carry-over loss on a fixture
45
+ # FH_SESSION_CLOSE flips advisory into blocking — every `expect exit 0` lane would go red
46
+ # FH_CARRYOVER_OK SKIPs ⑤-C — a lane asserting ⑤-C FIRES would go green for the wrong reason
47
+ # (note the direction: this one fails OPEN, which is the worse half)
48
+ # FH_PEER_SCAN_FORCE forces the ①-c peer scan on regardless of session shape
49
+ # FH_PEER_SOCK_DIR / FH_REPO_ID repoint peer discovery at the ambient machine
50
+ # CLAUDE_CODE_AGENT / CLAUDE_CODE_CHILD_SESSION are deliberately NOT in this list: the subject uses
51
+ # them to detect session shape and the lanes that care unset them per-case on purpose (see the
52
+ # subject's own "NEGATIVE ARM UNVERIFIED" note). Blanket-clearing them here would silently change
53
+ # which branch those lanes exercise.
54
+ unset FH_COMPANION_STORE FH_SESSION_CLOSE FH_CARRYOVER_OK FH_PEER_SCAN_FORCE FH_PEER_SOCK_DIR FH_REPO_ID
55
+ export FH_COMPANION_STORE=""
29
56
  CHECK="$SCRIPT_DIR/session_close_check.sh"
30
57
  HOOK="$ROOT/templates/.git-hooks/pre-push"
31
58
  TODAY=$(date +%Y-%m-%d)
@@ -26,6 +26,17 @@
26
26
 
27
27
  set -uo pipefail
28
28
  SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
29
+ # 🟥 ENVIRONMENT ISOLATION (2026-08-27) — the suite inherited FH_COMPANION_STORE from the
30
+ # operator's shell. `CLAUDE.local.md` INSTRUCTS the operator to export it, so this suite went red
31
+ # on exactly the setup it is written for, and stayed green in CI where the variable is unset —
32
+ # environment dependence in the inverse of the usual direction, which is why it survived.
33
+ # The leak: ⑤-C reads the prior card from that store, so an unguarded lane compared its FIXTURE
34
+ # card against the operator's REAL companion history and reported a carry-over loss that belongs
35
+ # to neither. Measured A/B: exported → rc 1, 2 failures · unset → rc 0, 0 failures.
36
+ # Default it to a path that cannot exist; the three lanes that genuinely exercise ⑤-C set their
37
+ # own fixture store inline and still win, because they set it on the invocation.
38
+ unset FH_COMPANION_STORE
39
+ export FH_COMPANION_STORE=""
29
40
  CHECK="$SCRIPT_DIR/session_close_check.sh"
30
41
  TODAY=$(date +%Y-%m-%d)
31
42
  FAILED=0
@@ -352,6 +363,28 @@ rm -rf "$_T4"
352
363
  # Premise failure is reported FIRST and with its own exit code: it says "this run's verdicts are
353
364
  # meaningless", which is a different instruction to the reader than "the gate is broken". Collapsing
354
365
  # them into one red X is what made the original CI flake unreadable.
366
+ # ── ENV-ISO — an inherited FH_COMPANION_STORE must not reach an unguarded $CHECK call ─────────
367
+ # known-pair: a hostile store that WOULD trigger ⑤-C (its prior card carries a future date the
368
+ # fixture card lacks) must produce SKIPPED, not a carry-over FAIL. POS arm first: prove the
369
+ # hostile store really is hostile by feeding it to $CHECK ON PURPOSE.
370
+ _ei=$(mktemp -d)
371
+ mkdir -p "$_ei/store/tracks-meta" "$_ei/work/tracks/_meta"
372
+ ( cd "$_ei/store" && git init -q . && git config user.email l@l && git config user.name l
373
+ printf 'prior card\n- 2099-12-31 기한\n' > tracks-meta/reference_next_session_starter.md
374
+ git add -A >/dev/null 2>&1 && GIT_AUTHOR_DATE="2020-01-01T00:00:00" GIT_COMMITTER_DATE="2020-01-01T00:00:00" git commit -qm seed ) >/dev/null 2>&1
375
+ printf 'today card, no future date\n' > "$_ei/work/tracks/_meta/reference_next_session_starter.md"
376
+ ( cd "$_ei/work" && git init -q . ) >/dev/null 2>&1
377
+ _ei_pos=$(FH_COMPANION_STORE="$_ei/store" bash "$CHECK" "$_ei/work" 2>/dev/null | grep -c "⑤-C carry-over 유실")
378
+ _ei_neg=$(FH_COMPANION_STORE="$_ei/store" env FH_COMPANION_STORE="$_ei/store" sh -c 'unset FH_COMPANION_STORE; export FH_COMPANION_STORE=""; bash "$0" "$1" 2>/dev/null' "$CHECK" "$_ei/work" | grep -c "⑤-C SKIPPED")
379
+ if [ "$_ei_pos" -ge 1 ]; then
380
+ echo "✅ ENV-ISO POS: the hostile store DOES trigger ⑤-C when handed in ($_ei_pos) — the arm is potent"
381
+ if [ "$_ei_neg" -ge 1 ]; then echo "✅ ENV-ISO: with the suite's guard applied, ⑤-C SKIPs instead of comparing a foreign card"
382
+ else { echo "❌ ENV-ISO: guard did not hold — an inherited store still reached \$CHECK"; FAILED=1; }; fi
383
+ else
384
+ { echo "❌ ENV-ISO POS arm inert (hostile store triggered nothing) — the negative result below is UNINTERPRETABLE"; FAILED=1; }
385
+ fi
386
+ rm -rf "$_ei"
387
+
355
388
  if [ "$PREMISE_FAILED" -ne 0 ]; then
356
389
  echo "SESSION-CLOSE LANES: FIXTURE ERROR — a lane's input state was never created; this run's ⑤ verdicts prove nothing (exit 3 ≠ gate failure)"
357
390
  exit 3
@@ -360,5 +393,6 @@ if [ "$FAILED" -ne 0 ]; then
360
393
  echo "SESSION-CLOSE LANES: FAIL — the gate's instrument is miscalibrated"
361
394
  exit 1
362
395
  fi
363
- echo "SESSION-CLOSE LANES: PASS (12/12)"
396
+ echo "SESSION-CLOSE LANES: PASS (12 core + ENV-ISO 2)"
364
397
  exit 0
398
+
@@ -83,6 +83,13 @@ if ! command -v find >/dev/null 2>&1; then
83
83
  echo "This is not 'clean' and not 'no targets'; nothing was measured. Fix PATH and re-run."
84
84
  exit 2
85
85
  fi
86
+ # `awk` is the S1b probe's only engine (line-continuation joining + bounded lookahead are not
87
+ # expressible in a line-oriented grep). Its absence must not render as clean — the same rule the
88
+ # `find` gate above states. Guarded rather than hard-exit: unlike `find`, a missing awk blinds ONE
89
+ # probe, not the whole discovery pass, so the honest degrade is "S1b NOT MEASURED" + non-clean rc.
90
+ _S1B_OK=1
91
+ command -v awk >/dev/null 2>&1 || { _S1B_OK=0; _FORCE_NONCLEAN=2; }
92
+
86
93
  # cksum 도 미선언 의존성이다 — 첫 수리는 python3 만 가드하고 cksum 은 rc 미검사로 도입했다.
87
94
  # 부재 시 유일성 토큰이 **빈 문자열**이 돼 shadow 이름 충돌(A-1)이 그대로 부활한다(실증).
88
95
  # mktemp 실패 시 예측 가능한 경로(/tmp/degradescan.$$)로 폴백하던 것을 제거했다: 그 경로를 mkdir
@@ -318,6 +325,116 @@ for f in "${FILES[@]}"; do
318
325
  | grep -vE '^[0-9]+:[[:space:]]*(if[[:space:]]+)?\[\[?[[:space:]]*(-[dznN][[:space:]]|[^]]*=~)' \
319
326
  | grep -E '(\$\(|`|\[[[:space:]]*-[fx][[:space:]]|\b(scan|check|verify|validate|audit|grep|gate|assert|lint|test_)[A-Za-z_]*[[:space:](])')
320
327
 
328
+ # S1b — `|| true` INSIDE a command substitution: `V=$(git … 2>/dev/null | … || true)`.
329
+ # S1 above cannot see this shape at all: its regex closes on `(#|;|$)` after the permissive
330
+ # value, and here the next character is `)`. Measured 2026-08-26 by a full hand-census of the
331
+ # 132 `|| true)` sites in this repo (tracks/_meta/s1_true_paren_census_2026-08-26.md): 11 sit
332
+ # on a verdict path, and S1 saw 0 of them.
333
+ #
334
+ # WHY THIS SHAPE IS DIFFERENT FROM `|| true` AT END OF LINE. `|| true` on its own is NOT the
335
+ # defect — under `set -e` it is the prescribed way to let a legitimately-empty result through,
336
+ # and flagging it would push an author to delete the remedy (the same trap S3 and S5 already
337
+ # name). The measured defect is the CONJUNCTION the census isolated: the command's stderr is
338
+ # discarded (`2>/dev/null`) AND its non-zero exit is swallowed (`|| true`), so "git failed"
339
+ # and "git ran and matched nothing" arrive at the consumer as the same empty string. Every
340
+ # downstream `[ -n "$V" ]` then reads a broken repo as "nothing to check" and the gate skips
341
+ # itself in silence. Both halves are required by the rule below; either alone is not a smell.
342
+ #
343
+ # SCOPE — ORIGIN sites only, deliberately. The census's dominant pattern is that ONE git read
344
+ # feeds a dozen derived filters (`HEAVY=$(echo "$STAGED" | grep … || true)`). The derived
345
+ # filters inherit the origin's risk and add none of their own: their only failure mode is
346
+ # grep-no-match, which is what `|| true` is there for. Flagging them would turn 11 findings
347
+ # into 122 and bury the origin — this file already paid that price once (S5 shipped at 9/9 FP)
348
+ # and its own rule is that a probe which is mostly noise trains authors to dismiss it. So the
349
+ # substitution's LEADING command must be a real state read, never `echo`/`printf` on a value
350
+ # that is already in a shell variable.
351
+ #
352
+ # TWO RULES, because the two A-shapes have different tells:
353
+ # (1) git index/worktree read — `$(git … diff|log|ls-files|status|show …)`. Restricted to
354
+ # those five subcommands on purpose: `rev-parse`/`config`/`describe`/`merge-base` read
355
+ # identity or configuration, and in this corpus they are either fail-closed on the next
356
+ # line or feed a display string.
357
+ # (2) a substitution that FEEDS A LOOP — `done < <(cmd … || true)`, `done <<< "$(cmd …)"`.
358
+ # There is no variable to test here, so no `[ -z ]` can ever exist: an errored command
359
+ # yields zero iterations and the detector reports "found nothing". Any leading command
360
+ # counts except `echo`/`printf` (see SCOPE above).
361
+ #
362
+ # COUNTER DECONFLICTION: a pipeline ending in `grep -c` / `wc` is NOT flagged here — a counter
363
+ # always emits ("0") and exits 1 on no-match, so `|| true` there is the no-match idiom, and
364
+ # 🟥 RETRACTED 2026-08-26 — the sentence below said counters "belong to S5". MEASURED FALSE:
365
+ # S5's regex requires `|| echo 0` literally; `session_close_check.sh:395`/`:411` use
366
+ # `|| true`, so S5 never sees them. They are not "another probe's business" — they fall
367
+ # BETWEEN the two probes. Found by cross-family review (codex), confirmed by reading S5's
368
+ # own pattern at the S5 block below. The exclusion here stays (a counter genuinely is not
369
+ # S1b's shape and flagging it re-noises this probe to 74%); what changes is the CLAIM about
370
+ # where they land. Open, named, not silently carried: see §S5-COUNTER-GAP below.
371
+ # that class belongs to S5 (`|| echo 0` pipefail-fallback). Not flagging it twice is why S5's
372
+ # narrowing survives. Named cost: census A#10/A#11 (session_close_check.sh ④-e DISPATCHED /
373
+ # LOGGED) are counter-shaped and therefore NOT covered by S1b. They are not silently dropped —
374
+ # they are named here.
375
+ #
376
+ # SUPPRESSION (fail-closed handler): if the assigned variable is tested with `[ -z ]` within
377
+ # 14 lines and that branch exits non-zero / sets FAIL / reports ERROR|UNMEASURED, the emptiness
378
+ # IS distinguished and the site is clean. Note the direction matters: `[ -n "$V" ] && run the
379
+ # check` is NOT suppression — that is precisely the "empty ⇒ skip in silence" shape (census
380
+ # A#5, pre-commit SKILL_CHANGE), and it stays flagged.
381
+ #
382
+ # MEASURED PRECISION on this repo, hand-checked against the census, 2026-08-26: 11 hits,
383
+ # 9 true (census A), 2 false (scripts/fh-goal.sh:209,214 — a three-stage TARGET_FILES fallback
384
+ # whose terminal empty branch is `exit 0` "skipping fh-gate", which the census read as C).
385
+ # RECALL 9/11 of the census A set; the two misses are the counter-shaped pair named above.
386
+ # awk is the only new dependency and it is GUARDED (_S1B_OK) — a missing awk makes this probe
387
+ # blind, and blind must not render as clean (same rule as the `find` gate at the top).
388
+ if [ "${_S1B_OK:-1}" = 1 ]; then
389
+ while IFS= read -r ln; do
390
+ [ -n "$ln" ] || continue
391
+ emit "$f" "$ln" "S1b:||true-in-\$()" "a state-reading command has BOTH its stderr discarded (2>/dev/null) and its failure swallowed (|| true) inside a command substitution — 'the command failed' and 'the command matched nothing' become the same empty value, and the gate downstream skips itself in silence. Capture the status separately (out=\$(cmd 2>&1); rc=\$?) and branch on rc, or make the empty case fail closed"
392
+ done < <(awk '
393
+ { raw[NR]=$0 }
394
+ END{
395
+ n=NR
396
+ for(i=1;i<=n;i++){
397
+ if(i<=skipto) continue
398
+ L=raw[i]; last=i
399
+ while(L ~ /\\[ \t]*$/ && last<n){ sub(/\\[ \t]*$/,"",L); last++; L=L " " raw[last] }
400
+ skipto=last # a continuation line is not its own finding
401
+ if(L ~ /^[ \t]*#/) continue
402
+ if(L ~ /#[ \t]*noqa[: \t]*degrade/) continue
403
+ if(L !~ /\|\|[ \t]*true[ \t]*\)/) continue
404
+ if(L !~ /2>\/dev\/null/) continue # stderr must actually be discarded
405
+ if(L ~ /\|[ \t]*(grep[ \t]+-[A-Za-z]*c|grep[ \t]+--count|wc[ \t])/) continue # counter: see §S5-COUNTER-GAP
406
+ r1 = (L ~ /[$<]\([ \t]*git[ \t]+(-[^ \t]+[ \t]+([^ \t]+[ \t]+)?)*(diff|log|ls-files|status|show)[ \t]/)
407
+ r2 = ((L ~ /<[ \t]*<\(/ || L ~ /<<<[ \t]*"?\$\(/) && L !~ /[$<]\([ \t]*(echo|printf)[ \t]/)
408
+ if(!r1 && !r2) continue
409
+ v=""
410
+ if(match(L,/^[ \t]*(local[ \t]+)?[A-Za-z_][A-Za-z0-9_]*=/)){
411
+ v=substr(L,RSTART,RLENGTH); sub(/^[ \t]*(local[ \t]+)?/,"",v); sub(/=$/,"",v)
412
+ }
413
+ supp=0
414
+ if(v!=""){
415
+ for(j=last+1;j<=last+14 && j<=n;j++){
416
+ if(raw[j] ~ ("-z[ \t]*\"?\\$\\{?" v "[\"}]")){
417
+ # 🟥 2026-08-26 (cross-family/codex): proximity alone suppressed on a COMMENT
418
+ # or on an unrelated later branch that merely sat within 6 lines. That is a
419
+ # false NEGATIVE — it hides a real fail-open — which is strictly worse than the
420
+ # distance constant being unmeasured. Two guards: comments are not remedies,
421
+ # and the search stops at the end of the `-z` branch.
422
+ for(k=j;k<=j+6 && k<=n;k++){
423
+ C=raw[k]
424
+ if(C ~ /^[ \t]*#/) continue
425
+ sub(/[ \t]#.*$/,"",C) # trailing comment is not code
426
+ if(k>j && C ~ /^[ \t]*(fi|else|elif|esac|;;|})([ \t]|$)/) break
427
+ if(C ~ /exit[ \t]+[1-9]|return[ \t]+[1-9]|FAIL|UNMEASURED|ERROR|die /){ supp=1; break }
428
+ }
429
+ }
430
+ if(supp) break
431
+ }
432
+ }
433
+ if(!supp) print i
434
+ }
435
+ }' "$f" 2>/dev/null)
436
+ fi
437
+
321
438
  # S2 — `else` fall-through to a permissive exit/return within 2 lines (unenumerated case → allow).
322
439
  while IFS= read -r ln; do
323
440
  emit "$f" "$ln" "S2:else→PASS(sh)" "else/fall-through branch exits permissively — the unenumerated case should fail closed"
@@ -535,6 +652,7 @@ for f in "${FILES[@]}"; do
535
652
  done
536
653
 
537
654
  echo "----"
655
+ [ "${_S1B_OK:-1}" = 1 ] || echo "note: probe S1b NOT MEASURED (awk unavailable) — this run is not clean on that axis."
538
656
  [ ${#UNSCANNABLE[@]} -gt 0 ] && printf 'note: %s changed file(s) outside py/sh — NOT covered by this scan (send to cross-family directly).\n' "${#UNSCANNABLE[@]}"
539
657
  if [ "$hits" -gt 0 ]; then
540
658
  echo "degrade-scan: $hits smell(s) — ADVISORY. Each = 'prove this is not default-toward-PASS'."