@chrono-meta/fh-gate 2.11.0 β 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/README.ja.md +58 -28
- package/README.ko.md +201 -184
- package/README.md +59 -43
- package/README.zh.md +74 -47
- package/docs/USER_GUIDE.md +6 -6
- package/knowledge/shared/learnings/subagent_invocations_log.yaml +98 -0
- package/package.json +2 -1
- package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-meta/CHANGELOG.md +32 -0
- package/plugins/fh-meta/skills/salience-splitter/SKILL.md +26 -0
- package/scripts/degrade_direction_scan.sh +118 -0
- package/scripts/fh-goal.sh +22 -2
- package/scripts/fh_session_load.sh +14 -1
- package/scripts/package_coverage_check.sh +7 -4
- package/scripts/selfcheck.sh +3 -1
- package/scripts/session_close_check.sh +36 -3
- package/scripts/test_card_drift_probe.sh +27 -0
- package/scripts/test_degrade_scan_shell_probes.sh +130 -1
- package/scripts/test_dispatch_log_lanes.sh +54 -2
- package/scripts/test_fh_goal_change_detection_lanes.sh +89 -0
- package/scripts/test_session_close_chain_lanes.sh +27 -0
- package/scripts/test_session_close_lanes.sh +35 -1
- package/templates/degrade_direction_scan.sh +118 -0
|
@@ -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
|
|
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'."
|