@chrono-meta/fh-gate 3.44.0 → 3.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/.claude/rules/fh_4axis_gate.md +50 -608
  2. package/.claude-plugin/marketplace.json +4 -4
  3. package/CATALOG.md +21 -0
  4. package/CHEATSHEET.md +13 -3
  5. package/docs/codex-compat.md +1 -1
  6. package/knowledge/shared/harness-core/fh_4axis_gate_detail.md +679 -0
  7. package/knowledge/shared/harness-core/fh_detail_protocols.md +1 -0
  8. package/knowledge/shared/harness-core/fh_integration_contract.md +1 -1
  9. package/knowledge/shared/harness-core/fh_module_contract.md +106 -3
  10. package/knowledge/shared/harness-core/heavy_skill_to_cartridge.md +185 -0
  11. package/knowledge/shared/learnings/subagent_invocations_log.yaml +209 -0
  12. package/package.json +19 -1
  13. package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
  14. package/plugins/fh-commons/skills/ko-tech-writer/SKILL.md +9 -8
  15. package/plugins/fh-commons/skills/ko-tech-writer/SKILL_detail.md +20 -0
  16. package/plugins/fh-commons/skills/mcp-circuit-breaker/SKILL.md +12 -6
  17. package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
  18. package/plugins/fh-meta/CHANGELOG.md +122 -0
  19. package/plugins/fh-meta/skills/auto-decorrelation/SKILL.md +13 -0
  20. package/plugins/fh-meta/skills/context-doctor/SKILL.md +1 -0
  21. package/plugins/fh-meta/skills/deep-clarify/SKILL.md +76 -22
  22. package/plugins/fh-meta/skills/harvest-loop/SKILL.md +2 -2
  23. package/plugins/fh-meta/skills/install-wizard/SKILL_detail.md +4 -0
  24. package/plugins/fh-meta/skills/memory-hygiene/SKILL.md +6 -0
  25. package/plugins/fh-meta/skills/steel-quench/SKILL_detail.md +2 -1
  26. package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
  27. package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
  28. package/scripts/agy_launch_guard.sh +117 -1
  29. package/scripts/below_floor_scan.sh +30 -0
  30. package/scripts/codex_launch_guard.sh +38 -2
  31. package/scripts/correction_moments.py +23 -2
  32. package/scripts/fh-gate.sh +612 -14
  33. package/scripts/fh-goal.sh +56 -12
  34. package/scripts/fh-run.sh +1 -1
  35. package/scripts/fh_gate_exec.sh +272 -0
  36. package/scripts/fh_session_load.sh +17 -0
  37. package/scripts/finding_fleet.sh +2 -1
  38. package/scripts/finding_verifier.sh +2 -1
  39. package/scripts/fixtures/heavy_skill_smell/clean/tidy-notes/README.md +16 -0
  40. package/scripts/fixtures/heavy_skill_smell/clean/tidy-notes/scripts/check_refs.py +12 -0
  41. package/scripts/fixtures/heavy_skill_smell/clean/tidy-notes/scripts/test_check_refs.py +24 -0
  42. package/scripts/fixtures/heavy_skill_smell/clean/tidy-notes/skills/tidy-notes/SKILL.md +16 -0
  43. package/scripts/fixtures/heavy_skill_smell/clean/tidy-notes/skills/tidy-notes/fh-module.yaml +20 -0
  44. package/scripts/fixtures/heavy_skill_smell/heavy/docs-publisher-pro/SKILL.md +25 -0
  45. package/scripts/fixtures/heavy_skill_smell/heavy/docs-publisher-pro/hooks/hooks.json +7 -0
  46. package/scripts/fixtures/heavy_skill_smell/heavy/docs-publisher-pro/scripts/check_links.py +25 -0
  47. package/scripts/fixtures/heavy_skill_smell/heavy/docs-publisher-pro/scripts/publish.sh +9 -0
  48. package/scripts/fixtures/heavy_skill_smell/heavy/docs-publisher-pro/scripts/publish_guard.py +6 -0
  49. package/scripts/fixtures/heavy_skill_smell/heavy/docs-publisher-pro/scripts/setup.sh +5 -0
  50. package/scripts/fixtures/heavy_skill_smell/heavy/release-notes-pro/SKILL.md +25 -0
  51. package/scripts/fixtures/heavy_skill_smell/heavy/release-notes-pro/hooks/hooks.json +10 -0
  52. package/scripts/fixtures/heavy_skill_smell/heavy/release-notes-pro/scripts/check_refs.py +12 -0
  53. package/scripts/fixtures/heavy_skill_smell/heavy/release-notes-pro/scripts/guard_push.py +9 -0
  54. package/scripts/fixtures/heavy_skill_smell/heavy/release-notes-pro/scripts/install.sh +6 -0
  55. package/scripts/fixtures/heavy_skill_smell/heavy/release-notes-pro/scripts/ship.sh +9 -0
  56. package/scripts/heavy_skill_smell.py +311 -0
  57. package/scripts/job_heartbeat.py +186 -0
  58. package/scripts/live_eval_matrix.py +128 -0
  59. package/scripts/live_eval_trace.py +197 -4
  60. package/scripts/package_coverage_check.sh +18 -0
  61. package/scripts/pr_merge_verified.sh +14 -4
  62. package/scripts/prepush_guard_check.sh +8 -0
  63. package/scripts/probe_live_eval.sh +32 -0
  64. package/scripts/probe_live_eval_lib.py +8 -2
  65. package/scripts/selfcheck.sh +113 -0
  66. package/scripts/selfcheck_shard_weights.txt +2 -0
  67. package/scripts/sidecar_calibrate.sh +7 -5
  68. package/scripts/sim_isolated_run.sh +20 -0
  69. package/scripts/test_agy_launch_guard_lanes.sh +120 -0
  70. package/scripts/test_below_floor_scan_lanes.sh +85 -0
  71. package/scripts/test_codex_launch_guard_lanes.sh +45 -0
  72. package/scripts/test_correction_moments_lanes.sh +37 -0
  73. package/scripts/test_deep_clarify_interview_lanes.sh +108 -0
  74. package/scripts/test_deep_clarify_spec_path_lanes.sh +91 -0
  75. package/scripts/test_fh_gate_absorb_lanes.sh +255 -0
  76. package/scripts/test_fh_gate_defaults_lanes.sh +188 -0
  77. package/scripts/test_fh_gate_exec_lanes.sh +244 -0
  78. package/scripts/test_fh_gate_fusion_lanes.sh +202 -0
  79. package/scripts/test_fh_gate_regressions.sh +92 -1
  80. package/scripts/test_fh_goal_change_detection_lanes.sh +103 -3
  81. package/scripts/test_finding_pipeline_lanes.sh +35 -1
  82. package/scripts/test_guard_anchor_override_env_lanes.sh +84 -0
  83. package/scripts/test_heavy_skill_smell_lanes.sh +160 -0
  84. package/scripts/test_job_heartbeat_lanes.sh +96 -0
  85. package/scripts/test_live_eval_construct_lanes.sh +29 -6
  86. package/scripts/test_live_eval_matrix_lanes.sh +53 -0
  87. package/scripts/test_live_eval_trace_lanes.sh +132 -5
  88. package/scripts/test_name_boundary_locale_lanes.sh +36 -5
  89. package/scripts/test_pr_merge_verified_lanes.sh +15 -2
  90. package/scripts/test_prepush_marker_lookup_lanes.sh +143 -0
  91. package/scripts/test_probe_live_eval_lanes.sh +44 -0
  92. package/scripts/test_regression_guard_sibling_lanes.sh +52 -1
  93. package/scripts/test_sidecar_calibrate_lanes.sh +1 -1
  94. package/scripts/test_sim_isolated_run_lanes.sh +43 -0
  95. package/scripts/universal_guard_check.sh +8 -0
  96. package/scripts/worktree_reclaim.sh +1 -1
  97. package/templates/.claude/rules/mcp_tool_gating.md +27 -0
  98. package/templates/.git-hooks/pre-push +60 -3
  99. package/templates/PRE-PUBLISH-CHECKLIST.md +22 -0
  100. package/templates/regression_guard.sh +8 -4
  101. package/templates/settings.LaneGap.snippet.json +27 -0
@@ -0,0 +1,188 @@
1
+ #!/usr/bin/env bash
2
+ # test_fh_gate_defaults_lanes.sh — what fh-gate does when the caller opts into nothing (3.45.0).
3
+ #
4
+ # WHY. #1147 made /code-review the default review on the claude backend, added an «elephant» pass at level full and
5
+ # an execution layer (E1 runs the repository's own lanes) — all on by default. Whether a headless `/code-review` (or
6
+ # the absorbed FH pass) returns the structured object the gate needs was never measured, and the GitHub Action always
7
+ # passed FH_TIMEOUT=120. Published as is, a consumer who changed nothing could get exit 10 on every run, and E1 would
8
+ # start executing their repository's code. So until those paths are measured, the default is the 3.44.0 review:
9
+ # D1 claude backend, nothing set, level full → fh-legacy · no elephant call · E0/E1 «NOT RUN (off by default …)»
10
+ # D2 codex backend, nothing set → fh-legacy (not the absorbed pass, not labelled fallback)
11
+ # D3 FH_REVIEWER=code-review (opt-in) → the /code-review call is made
12
+ # D4 FH_REVIEWER=fh (opt-in) → the absorbed pass is made
13
+ # D5 FH_GATE_ELEPHANT=auto at level full (opt-in) → the elephant pass is made
14
+ # D6 FH_GATE_EXEC=on (opt-in) → E1 is not «NOT RUN (off by default …)»
15
+ # D8 cross with nothing set → the legs say the execution layer is off by default (cross-family R1)
16
+ # D9 --help names fh-legacy as the default reviewer
17
+ # D10 FH_REVIEWER=fh and the elephant pass get exactly Read/Glob/Grep — no shell, no MCP, no skill (D10b: control)
18
+ # D11 FH_REVIEWER=code-review keeps git but runs without the five GITHUB_* command-file variables
19
+ # D12 run from a copy with no action.yml (package shape): D7 is SKIPPED by name — not a pass, not a fail
20
+ # D7 action.yml does not put FH_TIMEOUT in the step env; it exports it only when the `timeout` input (default '') is non-empty
21
+ # (known pair: the shipped file passes; a planted «FH_TIMEOUT: ${{ inputs.timeout }}» env line is caught)
22
+ # Token-free: claude and codex are stubs that answer by request kind and log what they were asked.
23
+ set -uo pipefail
24
+ . "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh"
25
+ HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
26
+ GATE="$HERE/fh-gate.sh"; ACTION="$HERE/../action.yml"
27
+ TMPROOT=$(mktemp -d "${TMPDIR:-/tmp}/fh_gate_defaults_XXXXXX")
28
+ trap 'rm -rf "$TMPROOT"' EXIT
29
+ export FH_RECORD_BASE="$TMPROOT/records"; mkdir -p "$FH_RECORD_BASE"
30
+ unset FH_REVIEWER FH_GATE_ELEPHANT FH_GATE_EXEC FH_TIMEOUT FH_GATE_LEVEL
31
+ pass=0; fail=0; skipped=0
32
+ ok() { printf 'PASS %s\n' "$1"; pass=$((pass + 1)); }
33
+ bad() { printf 'FAIL %s — %s\n' "$1" "$2"; fail=$((fail + 1)); }
34
+ g() { git -c user.name=t -c user.email=t@t -c commit.gpgsign=false -c core.hooksPath=/dev/null "$@"; }
35
+
36
+ FAKEBIN="$TMPROOT/bin"; mkdir -p "$FAKEBIN"
37
+ cat > "$FAKEBIN/claude" <<'FAKE'
38
+ #!/usr/bin/env bash
39
+ in=$(cat); args=" $* "; kind=legacy
40
+ case "$args" in *"/code-review "*) kind=cr ;; esac
41
+ case "$in" in *"FH ELEPHANT PASS"*) kind=ele ;; *"FH REVIEW PASS"*) kind=abs ;; esac
42
+ : > "${LOGDIR:-/tmp}/claude_${kind}.called"
43
+ printf '%s\n' "$@" > "${LOGDIR:-/tmp}/claude_${kind}.args"; env > "${LOGDIR:-/tmp}/claude_${kind}.env"
44
+ empty='{"status":"SUCCESS","findings":[]}'
45
+ case "$kind" in legacy) p="$FAKE_PAYLOAD" ;; *) p="$empty" ;; esac
46
+ printf '{"is_error":false,"subtype":"success","structured_output":%s}\n' "$p"
47
+ FAKE
48
+ cat > "$FAKEBIN/codex" <<'FAKE'
49
+ #!/usr/bin/env bash
50
+ out=""; while [ $# -gt 0 ]; do case "$1" in -o) out="$2"; shift 2 ;; *) shift ;; esac; done
51
+ in=$(cat); kind=legacy
52
+ case "$in" in *"FH ELEPHANT PASS"*) kind=ele ;; *"FH REVIEW PASS"*) kind=abs ;; esac
53
+ : > "${LOGDIR:-/tmp}/codex_${kind}.called"
54
+ empty='{"status":"SUCCESS","findings":[]}'
55
+ case "$kind" in legacy) p="$FAKE_PAYLOAD" ;; *) p="$empty" ;; esac
56
+ [ -n "$out" ] && printf '%s' "$p" > "$out"
57
+ exit 0
58
+ FAKE
59
+ chmod +x "$FAKEBIN/claude" "$FAKEBIN/codex"
60
+ export PATH="$FAKEBIN:$PATH"
61
+ export FAKE_PAYLOAD='{"status":"SUCCESS","verdict":"PASS","findings_count":0,"findings_a":0,"findings_b":0,"findings":[]}'
62
+
63
+ REPO="$TMPROOT/repo"; mkdir -p "$REPO/scripts"
64
+ g -C "$REPO" init -q -b main
65
+ printf '#!/usr/bin/env bash\necho ok\n' > "$REPO/scripts/foo.sh"; g -C "$REPO" add -A; g -C "$REPO" commit -qm "add foo"
66
+ g -C "$REPO" checkout -qb feat
67
+ printf '#!/usr/bin/env bash\necho ok two\n' > "$REPO/scripts/foo.sh"; g -C "$REPO" commit -qam "change foo"
68
+
69
+ gate() { # gate <name> [env...]
70
+ local name="$1"; shift
71
+ mkdir -p "$TMPROOT/$name"
72
+ ( cd "$REPO" && env LOGDIR="$TMPROOT/$name" "$@" bash "$GATE" ) > "$TMPROOT/$name.out" 2> "$TMPROOT/$name.err" < /dev/null
73
+ RC=$?
74
+ }
75
+ has() { grep -qF -- "$2" "$TMPROOT/$1.out"; }
76
+ called() { [ -e "$TMPROOT/$1/$2.called" ]; }
77
+
78
+ gate d1 FH_GATE_LEVEL=full
79
+ if [ "$RC" -eq 0 ] && has d1 'FH_GATE_REVIEWER: fh-legacy' && called d1 claude_legacy && ! called d1 claude_cr \
80
+ && ! called d1 claude_abs && ! called d1 claude_ele && has d1 'FH_GATE_E1: not-run — NOT RUN (off by default' \
81
+ && has d1 'FH_GATE_ELEPHANT: not-run — NOT RUN (off by default'; then
82
+ ok "D1 claude, nothing set, level full → fh-legacy · no /code-review · no elephant · E1 off by default"
83
+ else bad "D1 claude defaults" "rc=$RC $(grep -E 'REVIEWER|ELEPHANT|E1' "$TMPROOT/d1.out" | tr '\n' '|') calls=$(ls "$TMPROOT/d1" | tr '\n' ' ')"; fi
84
+
85
+ gate d2 FH_BACKEND=codex
86
+ if [ "$RC" -eq 0 ] && has d2 'FH_GATE_REVIEWER: fh-legacy' && ! has d2 'fallback' && called d2 codex_legacy && ! called d2 codex_abs; then
87
+ ok "D2 codex, nothing set → fh-legacy, not the absorbed pass, not labelled fallback"
88
+ else bad "D2 codex default" "rc=$RC $(grep REVIEWER "$TMPROOT/d2.out") calls=$(ls "$TMPROOT/d2" | tr '\n' ' ')"; fi
89
+
90
+ gate d3 FH_REVIEWER=code-review
91
+ if [ "$RC" -eq 0 ] && called d3 claude_cr && has d3 'FH_GATE_REVIEWER: /code-review'; then ok "D3 FH_REVIEWER=code-review (opt-in) → the /code-review call is made"
92
+ else bad "D3 code-review opt-in" "rc=$RC $(grep REVIEWER "$TMPROOT/d3.out") calls=$(ls "$TMPROOT/d3" | tr '\n' ' ')"; fi
93
+
94
+ gate d4 FH_REVIEWER=fh
95
+ if [ "$RC" -eq 0 ] && called d4 claude_abs && has d4 'FH_GATE_REVIEWER: fh — goldfish pass'; then ok "D4 FH_REVIEWER=fh (opt-in) → the absorbed pass is made"
96
+ else bad "D4 fh opt-in" "rc=$RC $(grep REVIEWER "$TMPROOT/d4.out") calls=$(ls "$TMPROOT/d4" | tr '\n' ' ')"; fi
97
+
98
+ gate d5 FH_GATE_LEVEL=full FH_GATE_ELEPHANT=auto
99
+ if [ "$RC" -eq 0 ] && called d5 claude_ele && has d5 'FH_GATE_ELEPHANT: ran'; then ok "D5 FH_GATE_ELEPHANT=auto at full (opt-in) → the elephant pass is made"
100
+ else bad "D5 elephant opt-in" "rc=$RC $(grep ELEPHANT "$TMPROOT/d5.out") calls=$(ls "$TMPROOT/d5" | tr '\n' ' ')"; fi
101
+
102
+ gate d6 FH_GATE_EXEC=on
103
+ grep '^FH_GATE_E1: ' "$TMPROOT/d6.out" > "$TMPROOT/d6.e1" 2>/dev/null
104
+ # the layer ran: E0 says «ran» (the fixture has no target lane, so E1 legitimately says «no target lane found»)
105
+ if [ "$RC" -eq 0 ] && has d6 'FH_GATE_E0: ran' && [ -s "$TMPROOT/d6.e1" ] && ! grep -qF 'off by default' "$TMPROOT/d6.e1" && ! grep -qF 'FH_GATE_EXEC=off' "$TMPROOT/d6.e1"; then ok "D6 FH_GATE_EXEC=on (opt-in) → E1 is not «off by default»"
106
+ else bad "D6 exec opt-in" "rc=$RC $(grep -E '^FH_GATE_E[01]' "$TMPROOT/d6.out" | tr '\n' '|')"; fi
107
+
108
+ # D8 — cross with nothing set: the legs report the execution layer «off by default», not «FH_GATE_EXEC=off»
109
+ gate d8 FH_BACKEND=cross FH_GATE_CROSS_ALLOW_SINGLE=1
110
+ if grep -qF '# FH_GATE_E1: not-run — NOT RUN (off by default' "$TMPROOT/d8.out" && ! grep -qF 'NOT RUN (FH_GATE_EXEC=off)' "$TMPROOT/d8.out"; then
111
+ ok "D8 cross, nothing set → the legs say the execution layer is off by default"
112
+ else bad "D8 cross defaults" "rc=$RC $(grep -E 'E1' "$TMPROOT/d8.out" | tr '\n' '|')"; fi
113
+
114
+ # D9 — --help states the default reviewer the code applies (Area B 3.45.0: --help still said /code-review)
115
+ bash "$GATE" --help > "$TMPROOT/help.out" 2>&1
116
+ if grep -qF 'FH_REVIEWER=fh-legacy|code-review|fh review stage (default: fh-legacy' "$TMPROOT/help.out" && ! grep -qF 'default on claude: built-in /code-review' "$TMPROOT/help.out"; then
117
+ ok "D9 --help names fh-legacy as the default reviewer"
118
+ else bad "D9 --help default reviewer" "$(grep -m2 -F 'FH_REVIEWER' "$TMPROOT/help.out" | tr '\n' '|')"; fi
119
+
120
+ # D10 — the goldfish (FH_REVIEWER=fh) and elephant passes get exactly Read/Glob/Grep: the built-in set limited by
121
+ # --tools, no MCP server (--strict-mcp-config), no skill or command (--disable-slash-commands), and shells and
122
+ # writers denied. An allow list alone is additive (settings, MCP write tools, skills, PowerShell stay reachable),
123
+ # and git's read commands write files through --output=. The whole policy is asserted, not one token of it.
124
+ # Known pair: on the 3.45.0 merge (7c5a6b7) both calls allow Bash(git diff:*) and carry none of the three flags.
125
+ argv_after() { awk -v f="$2" 'p{print; exit} $0==f{p=1}' "$1"; }
126
+ has_flag() { grep -qxF -- "$2" "$1"; }
127
+ policy_ok() { # policy_ok <args file> — prints what is wrong, nothing when the policy holds
128
+ local a="$1" t al d need
129
+ [ -s "$a" ] || { echo "no call recorded"; return; }
130
+ t=$(argv_after "$a" --tools); al=$(argv_after "$a" --allowedTools); d=$(argv_after "$a" --disallowedTools)
131
+ [ "$t" = "Read,Glob,Grep" ] || echo "tools=[$t]"
132
+ [ "$al" = "Read,Glob,Grep" ] || echo "allow=[$al]"
133
+ for need in Bash PowerShell Write Edit NotebookEdit WebFetch WebSearch; do [[ ",$d," == *",$need,"* ]] || echo "deny lacks $need"; done
134
+ has_flag "$a" --strict-mcp-config || echo "no --strict-mcp-config"
135
+ has_flag "$a" --disable-slash-commands || echo "no --disable-slash-commands"
136
+ ! has_flag "$a" --mcp-config || echo "an --mcp-config was passed"
137
+ }
138
+ gate d10 FH_REVIEWER=fh FH_GATE_ELEPHANT=on
139
+ p_abs=$(policy_ok "$TMPROOT/d10/claude_abs.args" | tr '\n' ' '); p_ele=$(policy_ok "$TMPROOT/d10/claude_ele.args" | tr '\n' ' ')
140
+ if [ "$RC" -eq 0 ] && [ -z "$p_abs" ] && [ -z "$p_ele" ]; then ok "D10 goldfish and elephant passes: exactly Read/Glob/Grep — no shell, no MCP, no skill"
141
+ else bad "D10 reviewer tool policy" "rc=$RC goldfish: ${p_abs:-ok} · elephant: ${p_ele:-ok}"; fi
142
+ # D10b — the checker itself sees a planted widening (control: one extra allowed tool on an otherwise good call)
143
+ printf '%s\n' --tools Read,Glob,Grep --strict-mcp-config --disable-slash-commands --allowedTools Read,Glob,Grep,Write \
144
+ --disallowedTools Bash,PowerShell,Write,Edit,NotebookEdit,WebFetch,WebSearch > "$TMPROOT/planted.args"
145
+ [ -n "$(policy_ok "$TMPROOT/planted.args")" ] && ok "D10b the policy check catches a planted extra allowed tool (control alive)" || bad "D10b policy check blind" "planted Write in the allow list passed"
146
+
147
+ # D11 — /code-review keeps git (it needs it), so its call runs without the runner's five command-file variables.
148
+ # (This only removes the direct reference — the path stays labelled not read-only.)
149
+ gate d11 FH_REVIEWER=code-review GITHUB_ENV="$TMPROOT/gh1" GITHUB_PATH="$TMPROOT/gh2" GITHUB_OUTPUT="$TMPROOT/gh3" GITHUB_STATE="$TMPROOT/gh4" GITHUB_STEP_SUMMARY="$TMPROOT/gh5"
150
+ if [ "$RC" -eq 0 ] && [ -s "$TMPROOT/d11/claude_cr.env" ] && ! grep -qE '^GITHUB_(ENV|PATH|OUTPUT|STATE|STEP_SUMMARY)=' "$TMPROOT/d11/claude_cr.env" \
151
+ && [[ "$(argv_after "$TMPROOT/d11/claude_cr.args" --allowedTools)" == *"Bash(git diff:*)"* ]]; then
152
+ ok "D11 /code-review call: git kept, none of the five GITHUB_* command-file variables in its environment"
153
+ else bad "D11 code-review env" "rc=$RC $(grep -E '^GITHUB_(ENV|PATH|OUTPUT|STATE|STEP_SUMMARY)=' "$TMPROOT/d11/claude_cr.env" 2>/dev/null | cut -d= -f1 | tr '\n' ' ')"; fi
154
+
155
+ # D7 — action.yml's step env must not carry FH_TIMEOUT; the run block exports it only from a non-empty input.
156
+ envblock() { awk '/^ *env: *$/{e=1; next} e && /^ *run: *\|/{exit} e{print}' "$1"; }
157
+ if [ -r "$ACTION" ]; then
158
+ envblock "$ACTION" > "$TMPROOT/env_shipped"
159
+ sed 's/^\( *\)FH_CALLER: github-action$/\1FH_CALLER: github-action\n\1FH_TIMEOUT: ${{ inputs.timeout }}/' "$ACTION" > "$TMPROOT/action_planted.yml"
160
+ envblock "$TMPROOT/action_planted.yml" > "$TMPROOT/env_planted"
161
+ n_ship=$(grep -cE '^ *FH_TIMEOUT:' "$TMPROOT/env_shipped"); n_plant=$(grep -cE '^ *FH_TIMEOUT:' "$TMPROOT/env_planted")
162
+ if [ -s "$TMPROOT/env_shipped" ] && [ "$n_ship" = 0 ] && [ "$n_plant" = 1 ] \
163
+ && grep -qF 'if [ -n "${FH_ACTION_TIMEOUT:-}" ]; then export FH_TIMEOUT="$FH_ACTION_TIMEOUT"; fi' "$ACTION" \
164
+ && grep -qE "^ *default: ''" <<<"$(awk '/^ timeout:/{f=1} f&&/default:/{print; exit}' "$ACTION")"; then
165
+ ok "D7 action.yml: FH_TIMEOUT only from a non-empty timeout input (a planted env line is caught)"
166
+ else bad "D7 action timeout pass-through" "env lines with FH_TIMEOUT: shipped=$n_ship planted=$n_plant"; fi
167
+ else
168
+ # No action.yml here: the npm package does not ship it, and a field harness that syncs FH's lanes has none.
169
+ # Not a pass and not a fail — named. In an FH checkout its absence is caught by test_action_yml_lanes.sh (exit 10).
170
+ printf ' SKIP D7 action timeout pass-through — NOT-APPLICABLE: no action.yml at %s (not measured, not a pass)\n' "$ACTION"
171
+ skipped=$((skipped + 1))
172
+ fi
173
+
174
+ # D12 — the same lane file run from a copy with no action.yml (an installed package's shape) must SKIP D7 by name,
175
+ # exit 0 and print no PASS for it (3.45.0 shipped this lane failing there: pmh-dev intake 2026-11-21).
176
+ if [ -z "${FHGD_INNER:-}" ]; then
177
+ mkdir -p "$TMPROOT/pkg"; cp -R "$HERE" "$TMPROOT/pkg/scripts"
178
+ if [ -e "$TMPROOT/pkg/action.yml" ]; then bad "D12 package-shape copy" "action.yml present in the copy — the fixture is not package-shaped"
179
+ else
180
+ ( cd "$TMPROOT/pkg" && FHGD_INNER=1 bash scripts/test_fh_gate_defaults_lanes.sh ) > "$TMPROOT/d12.out" 2>&1 < /dev/null; d12rc=$?
181
+ if [ "$d12rc" -eq 0 ] && grep -q '^ SKIP D7 .*NOT-APPLICABLE' "$TMPROOT/d12.out" && ! grep -q '^PASS D7' "$TMPROOT/d12.out" \
182
+ && grep -q '1 skipped (not a pass)' "$TMPROOT/d12.out"; then ok "D12 without action.yml: D7 is skipped by name, exit 0, not counted as passed"
183
+ else bad "D12 package-shape run" "rc=$d12rc $(grep -E 'D7|lanes:' "$TMPROOT/d12.out" | tr '\n' '|')"; fi
184
+ fi
185
+ fi
186
+
187
+ echo "fh-gate defaults lanes: $pass passed, $fail failed$( [ "$skipped" -gt 0 ] && printf ', %s skipped (not a pass)' "$skipped")"
188
+ [ "$fail" -eq 0 ]
@@ -0,0 +1,244 @@
1
+ #!/usr/bin/env bash
2
+ # test_fh_gate_exec_lanes.sh — known-pair lanes for fh-gate's execution layer (scripts/fh_gate_exec.sh).
3
+ #
4
+ # Each lane builds a scratch git repo, makes a change, runs the execution layer against it and checks
5
+ # the JSON it returns. Token-free: no model is called anywhere in this file.
6
+ #
7
+ # X1 a change that turns its lane red → one A finding from E1
8
+ # X2 a lane that was red before the change too → C, not A
9
+ # X3 a change whose lane stays green → no finding, «1 lane, 0 red»
10
+ # X4 a change no lane names → E1 NOT RUN (no target lane), no finding
11
+ # X5 a lane that does not finish in time → B «did not finish», never green
12
+ # X6 a change that adds a pipefail early-exit pipe → one B finding from E0
13
+ # X7 lanes run in a copy → the work tree is untouched
14
+ # X8 an uncommitted change (HEAD = base) → the copy carries it; its lane goes red → A
15
+ # X9 --plan → lanes are listed, not run
16
+ # X10 nested gates inside a lane → the lane sees FH_GATE_EXEC=off
17
+ # X11 FH_GATE_LANES (declared lanes) → run even when discovery finds none
18
+ # X12 not a git repository → NOT RUN with the reason, exit 0
19
+ # X13 a base ref that does not exist → NOT RUN with the reason and a B finding, exit 0
20
+ # X14 more lanes than FH_GATE_MAX_LANES → capped, and the detail says so
21
+ # X15 the scanner's own self-test fails → B «instrument error», never «0 new»
22
+ # X16 under a cap, the lane named after the changed file is kept over one that only mentions it
23
+ # X17 red after the change, base run does not finish → B «not compared», never C
24
+ # X18 a lane file name with shell syntax in it → run as a path; its spelling runs nothing
25
+ # X19 no temporary folder can be made → B «could not run», never a silent NOT RUN
26
+ # X20 a declared lane that is new with the change, red → A, not «red before»
27
+ #
28
+ # Run: bash scripts/test_fh_gate_exec_lanes.sh
29
+ set -uo pipefail
30
+ . "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # scrub inherited GIT_* env first (#1088)
31
+ HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
32
+ EXEC="$HERE/fh_gate_exec.sh"
33
+ TMPROOT=$(mktemp -d "${TMPDIR:-/tmp}/fh_gate_exec_lanes_XXXXXX")
34
+ trap 'rm -rf "$TMPROOT"' EXIT
35
+ pass=0; fail=0
36
+
37
+ ok() { printf 'PASS %s\n' "$1"; pass=$((pass + 1)); }
38
+ bad() { printf 'FAIL %s — %s\n' "$1" "$2"; fail=$((fail + 1)); }
39
+
40
+ g() { git -c user.name=t -c user.email=t@t -c commit.gpgsign=false -c core.hooksPath=/dev/null "$@"; }
41
+
42
+ # mkrepo <dir> <foo.sh body> — scripts/foo.sh + a lane that asserts it prints «ok»
43
+ mkrepo() {
44
+ local d="$1" body="$2"
45
+ mkdir -p "$d/scripts"
46
+ g -C "$d" init -q -b main
47
+ printf '#!/usr/bin/env bash\n%s\n' "$body" > "$d/scripts/foo.sh"
48
+ cat > "$d/scripts/test_foo_lanes.sh" <<'LANE'
49
+ #!/usr/bin/env bash
50
+ out=$(bash scripts/foo.sh)
51
+ [ "$out" = ok ] || { echo "FAIL foo printed: $out"; exit 1; }
52
+ echo "PASS foo"
53
+ LANE
54
+ printf 'readme\n' > "$d/README.md"
55
+ g -C "$d" add -A && g -C "$d" commit -q -m base
56
+ }
57
+
58
+ # run_exec <name> <repo> <base> [args...] — stores JSON in $TMPROOT/<name>.json, rc in $RC
59
+ run_exec() {
60
+ local name="$1" repo="$2" base="$3"; shift 3
61
+ bash "$EXEC" "$repo" "$base" "$@" > "$TMPROOT/$name.json" 2> "$TMPROOT/$name.err" < /dev/null
62
+ RC=$?
63
+ }
64
+ q() { jq -r "$2" "$TMPROOT/$1.json" 2>/dev/null; }
65
+ # qm <name> <jq expr> <ERE> [i] — the field matches; no `q … | grep -q` (an early-exit consumer under pipefail is the very
66
+ # class E0 scans for, and the class lock counts its shape)
67
+ qm() { local v; v=$(q "$1" "$2"); if [ "${4:-}" = i ]; then v=$(printf '%s' "$v" | tr '[:upper:]' '[:lower:]'); fi; [[ "$v" =~ $3 ]]; }
68
+
69
+ [ -f "$EXEC" ] || { echo "FAIL fh_gate_exec.sh missing"; echo "exec lanes: 0 passed, 1 failed"; exit 1; }
70
+ command -v jq >/dev/null 2>&1 || { echo "FAIL jq missing — the execution layer needs it"; exit 1; }
71
+
72
+ # ── X1 ─────────────────────────────────────────────────────────────────────────────────────────
73
+ R="$TMPROOT/x1"; mkrepo "$R" 'echo ok'; B=$(g -C "$R" rev-parse HEAD)
74
+ printf '#!/usr/bin/env bash\necho broken\n' > "$R/scripts/foo.sh"; g -C "$R" commit -qam change
75
+ run_exec x1 "$R" "$B"
76
+ if [ "$RC" -eq 0 ] && [ "$(q x1 '[.findings[]|select(.grade=="A" and .source=="E1")]|length')" = 1 ] \
77
+ && [ "$(q x1 '.e1.status')" = ran ]; then ok "X1 change turns its lane red → one A from E1"
78
+ else bad "X1 change turns its lane red → one A from E1" "rc=$RC $(head -c 400 "$TMPROOT/x1.json")"; fi
79
+
80
+ # ── X2 ─────────────────────────────────────────────────────────────────────────────────────────
81
+ R="$TMPROOT/x2"; mkrepo "$R" 'echo broken'; B=$(g -C "$R" rev-parse HEAD)
82
+ printf '#!/usr/bin/env bash\n# a comment\necho broken\n' > "$R/scripts/foo.sh"; g -C "$R" commit -qam change
83
+ run_exec x2 "$R" "$B"
84
+ if [ "$(q x2 '[.findings[]|select(.source=="E1")]|map(.grade)|join(",")')" = C ]; then ok "X2 red before the change too → C, not A"
85
+ else bad "X2 red before the change too → C, not A" "$(head -c 400 "$TMPROOT/x2.json")"; fi
86
+
87
+ # ── X3 ─────────────────────────────────────────────────────────────────────────────────────────
88
+ R="$TMPROOT/x3"; mkrepo "$R" 'echo ok'; B=$(g -C "$R" rev-parse HEAD)
89
+ printf '#!/usr/bin/env bash\n# still fine\necho ok\n' > "$R/scripts/foo.sh"; g -C "$R" commit -qam change
90
+ run_exec x3 "$R" "$B"
91
+ if [ "$(q x3 '.findings|length')" = 0 ] && qm x3 '.e1.detail' '1 lane.* 0 red'; then ok "X3 lane stays green → no finding, «1 lane … 0 red»"
92
+ else bad "X3 lane stays green → no finding" "$(head -c 400 "$TMPROOT/x3.json")"; fi
93
+
94
+ # ── X4 ─────────────────────────────────────────────────────────────────────────────────────────
95
+ R="$TMPROOT/x4"; mkrepo "$R" 'echo ok'; B=$(g -C "$R" rev-parse HEAD)
96
+ printf 'readme 2\n' > "$R/README.md"; g -C "$R" commit -qam change
97
+ run_exec x4 "$R" "$B"
98
+ if [ "$(q x4 '.e1.status')" = not-run ] && qm x4 '.e1.detail' 'no target lane' && [ "$(q x4 '.findings|length')" = 0 ]; then
99
+ ok "X4 no lane names the change → E1 NOT RUN (no target lane)"
100
+ else bad "X4 no lane names the change → E1 NOT RUN" "$(head -c 400 "$TMPROOT/x4.json")"; fi
101
+
102
+ # ── X5 ─────────────────────────────────────────────────────────────────────────────────────────
103
+ R="$TMPROOT/x5"; mkrepo "$R" 'echo ok'; B=$(g -C "$R" rev-parse HEAD)
104
+ printf '#!/usr/bin/env bash\nsleep 6\necho ok\n' > "$R/scripts/foo.sh"; g -C "$R" commit -qam change
105
+ FH_LANE_TIMEOUT=1 run_exec x5 "$R" "$B"
106
+ if [ "$(q x5 '[.findings[]|select(.grade=="B" and .source=="E1")]|length')" = 1 ] && qm x5 '.findings[0].title' 'did not finish' i; then
107
+ ok "X5 lane does not finish in time → B, never green"
108
+ else bad "X5 lane does not finish in time → B" "$(head -c 400 "$TMPROOT/x5.json")"; fi
109
+
110
+ # ── X6 ─────────────────────────────────────────────────────────────────────────────────────────
111
+ skip=0
112
+ if [ ! -f "$HERE/pipefail_earlyexit_scan.sh" ]; then
113
+ # the npm package does not ship the class scanner (scripts/package_coverage_check.sh says why); E0 then
114
+ # reports «NOT RUN (scanner not shipped here)», which X15's sibling path covers
115
+ printf 'SKIP X6 pipefail scanner not shipped in this install — not a pass\n'; skip=1
116
+ else
117
+ R="$TMPROOT/x6"; mkrepo "$R" 'echo ok'; B=$(g -C "$R" rev-parse HEAD)
118
+ printf '#!/usr/bin/env bash\nset -o pipefail\nif cat "$1" | grep -q needle; then echo found; fi\n' > "$R/scripts/bar.sh"
119
+ g -C "$R" add scripts/bar.sh; g -C "$R" commit -qm change
120
+ run_exec x6 "$R" "$B"
121
+ if [ "$(q x6 '[.findings[]|select(.grade=="B" and .source=="E0")]|map(.location)|join(",")')" = scripts/bar.sh ] \
122
+ && qm x6 '.findings[0].evidence' 'grep -q needle' && [ "$(q x6 '.e0.status')" = ran ]; then
123
+ ok "X6 change adds a pipefail early-exit pipe → one B from E0"
124
+ else bad "X6 change adds a pipefail early-exit pipe → one B from E0" "$(head -c 500 "$TMPROOT/x6.json")"; fi
125
+ fi
126
+
127
+ # ── X7 ─────────────────────────────────────────────────────────────────────────────────────────
128
+ R="$TMPROOT/x7"; mkrepo "$R" 'echo ok'; B=$(g -C "$R" rev-parse HEAD)
129
+ printf '#!/usr/bin/env bash\ntouch touched_by_lane\necho ok\n' > "$R/scripts/foo.sh"; g -C "$R" commit -qam change
130
+ run_exec x7 "$R" "$B"
131
+ if [ "$(q x7 '.e1.status')" = ran ] && [ ! -e "$R/touched_by_lane" ] && [ -z "$(g -C "$R" status --porcelain)" ]; then
132
+ ok "X7 lanes run in a copy → the work tree is untouched"
133
+ else bad "X7 lanes run in a copy" "touched=$([ -e "$R/touched_by_lane" ] && echo yes || echo no) status=$(g -C "$R" status --porcelain | head -3)"; fi
134
+
135
+ # ── X8 ─────────────────────────────────────────────────────────────────────────────────────────
136
+ R="$TMPROOT/x8"; mkrepo "$R" 'echo ok'; B=$(g -C "$R" rev-parse HEAD)
137
+ printf '#!/usr/bin/env bash\necho broken\n' > "$R/scripts/foo.sh" # left uncommitted
138
+ run_exec x8 "$R" "$B"
139
+ if [ "$(q x8 '[.findings[]|select(.grade=="A" and .source=="E1")]|length')" = 1 ]; then ok "X8 uncommitted change is what the copy tests → A"
140
+ else bad "X8 uncommitted change is what the copy tests → A" "$(head -c 400 "$TMPROOT/x8.json")"; fi
141
+
142
+ # ── X9 ─────────────────────────────────────────────────────────────────────────────────────────
143
+ R="$TMPROOT/x9"; mkrepo "$R" 'echo ok'; B=$(g -C "$R" rev-parse HEAD)
144
+ printf '#!/usr/bin/env bash\ntouch "%s/x9_ran"\necho ok\n' "$TMPROOT" > "$R/scripts/foo.sh"; g -C "$R" commit -qam change
145
+ run_exec x9 "$R" "$B" --plan
146
+ if [ ! -e "$TMPROOT/x9_ran" ] && qm x9 '.e1.detail' 'would run 1 lane' && [ "$(q x9 '.findings|length')" = 0 ]; then
147
+ ok "X9 --plan lists the lanes and runs none"
148
+ else bad "X9 --plan lists the lanes and runs none" "ran=$([ -e "$TMPROOT/x9_ran" ] && echo yes || echo no) $(head -c 300 "$TMPROOT/x9.json")"; fi
149
+
150
+ # ── X10 ────────────────────────────────────────────────────────────────────────────────────────
151
+ R="$TMPROOT/x10"; mkrepo "$R" 'echo ok'; B=$(g -C "$R" rev-parse HEAD)
152
+ printf '#!/usr/bin/env bash\nprintf %%s "${FH_GATE_EXEC:-unset}" > "%s/x10_env"\necho ok\n' "$TMPROOT" > "$R/scripts/foo.sh"; g -C "$R" commit -qam change
153
+ run_exec x10 "$R" "$B"
154
+ if [ "$(cat "$TMPROOT/x10_env" 2>/dev/null)" = off ]; then ok "X10 a lane sees FH_GATE_EXEC=off (nested gates do not re-run the layer)"
155
+ else bad "X10 a lane sees FH_GATE_EXEC=off" "got: $(cat "$TMPROOT/x10_env" 2>/dev/null || echo missing)"; fi
156
+
157
+ # ── X11 ────────────────────────────────────────────────────────────────────────────────────────
158
+ R="$TMPROOT/x11"; mkrepo "$R" 'echo broken'; B=$(g -C "$R" rev-parse HEAD)
159
+ printf 'readme 2\n' > "$R/README.md"; g -C "$R" commit -qam change
160
+ FH_GATE_LANES='bash scripts/test_foo_lanes.sh' run_exec x11 "$R" "$B"
161
+ if [ "$(q x11 '.e1.status')" = ran ] && qm x11 '.e1.detail' 'declared' && [ "$(q x11 '[.findings[]|select(.source=="E1")]|length')" = 1 ]; then
162
+ ok "X11 declared lanes run even when discovery finds none"
163
+ else bad "X11 declared lanes run" "$(head -c 400 "$TMPROOT/x11.json")"; fi
164
+
165
+ # ── X12 ────────────────────────────────────────────────────────────────────────────────────────
166
+ mkdir -p "$TMPROOT/x12"
167
+ run_exec x12 "$TMPROOT/x12" HEAD
168
+ if [ "$RC" -eq 0 ] && [ "$(q x12 '.e1.status')" = not-run ] && qm x12 '.e1.detail' 'not a git'; then ok "X12 not a git repository → NOT RUN with the reason"
169
+ else bad "X12 not a git repository → NOT RUN" "rc=$RC $(head -c 300 "$TMPROOT/x12.json")"; fi
170
+
171
+ # ── X13 ────────────────────────────────────────────────────────────────────────────────────────
172
+ R="$TMPROOT/x13"; mkrepo "$R" 'echo ok'
173
+ run_exec x13 "$R" no-such-ref
174
+ if [ "$RC" -eq 0 ] && [ "$(q x13 '.e0.status')" = not-run ] && qm x13 '.e0.detail' 'no-such-ref' \
175
+ && [ "$(q x13 '[.findings[]|select(.grade=="B" and .source=="exec")]|length')" = 1 ]; then ok "X13 base ref missing → NOT RUN naming the ref, and a B (could not run ≠ not applicable)"
176
+ else bad "X13 base ref missing → NOT RUN" "rc=$RC $(head -c 300 "$TMPROOT/x13.json")"; fi
177
+
178
+ # ── X14 ────────────────────────────────────────────────────────────────────────────────────────
179
+ R="$TMPROOT/x14"; mkrepo "$R" 'echo ok'
180
+ for i in 2 3; do cp "$R/scripts/test_foo_lanes.sh" "$R/scripts/test_foo${i}_lanes.sh"; done
181
+ g -C "$R" add -A; g -C "$R" commit -qm more; B=$(g -C "$R" rev-parse HEAD)
182
+ printf '#!/usr/bin/env bash\n# touch\necho ok\n' > "$R/scripts/foo.sh"; g -C "$R" commit -qam change
183
+ FH_GATE_MAX_LANES=2 run_exec x14 "$R" "$B"
184
+ if qm x14 '.e1.detail' 'capped' && qm x14 '.e1.detail' '2 lane'; then ok "X14 more lanes than the cap → capped, and the detail says so"
185
+ else bad "X14 lane cap is stated" "$(head -c 400 "$TMPROOT/x14.json")"; fi
186
+
187
+ # ── X16 ────────────────────────────────────────────────────────────────────────────────────────
188
+ # Under a cap, the lane named after the changed file outranks a lane that only mentions it (aaa_* sorts first).
189
+ R="$TMPROOT/x16"; mkrepo "$R" 'echo ok'
190
+ printf '#!/usr/bin/env bash\n# mentions foo.sh only\nexit 0\n' > "$R/scripts/test_aaa_lanes.sh"
191
+ g -C "$R" add -A; g -C "$R" commit -qm more; B=$(g -C "$R" rev-parse HEAD)
192
+ printf '#!/usr/bin/env bash\n# touch\necho ok\n' > "$R/scripts/foo.sh"; g -C "$R" commit -qam change
193
+ FH_GATE_MAX_LANES=1 run_exec x16 "$R" "$B" --plan
194
+ if qm x16 '.e1.detail' 'test_foo_lanes.sh' && ! qm x16 '.e1.detail' 'test_aaa_lanes.sh'; then
195
+ ok "X16 under a cap, the lane named after the changed file is kept"
196
+ else bad "X16 cap keeps the lane named after the file" "$(q x16 '.e1.detail')"; fi
197
+
198
+ # ── X17 ────────────────────────────────────────────────────────────────────────────────────────
199
+ R="$TMPROOT/x17"; mkrepo "$R" 'sleep 8; echo ok'; B=$(g -C "$R" rev-parse HEAD)
200
+ printf '#!/usr/bin/env bash\necho broken\n' > "$R/scripts/foo.sh"; g -C "$R" commit -qam change
201
+ FH_LANE_TIMEOUT=2 run_exec x17 "$R" "$B"
202
+ if [ "$(q x17 '[.findings[]|select(.source=="E1")]|map(.grade)|join(",")')" = B ] && qm x17 '.findings[0].title' 'not compared'; then
203
+ ok "X17 red after, base run did not finish → B «not compared», never C"
204
+ else bad "X17 base did not finish → B" "$(head -c 400 "$TMPROOT/x17.json")"; fi
205
+
206
+ # ── X18 ────────────────────────────────────────────────────────────────────────────────────────
207
+ R="$TMPROOT/x18"; mkrepo "$R" 'echo ok'; B=$(g -C "$R" rev-parse HEAD)
208
+ LN='scripts/test_$(touch PWNED)_lanes.sh'
209
+ printf '#!/usr/bin/env bash\necho fine\n' > "$R/$LN"; g -C "$R" add -A; g -C "$R" commit -qm change
210
+ run_exec x18 "$R" "$B"
211
+ # (no `find | grep -q`: under pipefail an early-exit consumer can turn a found PWNED into a false green — the class E0 scans for)
212
+ PW=$(find "$TMPROOT" -name PWNED -print 2>/dev/null)
213
+ if [ "$(q x18 '.e1.status')" = ran ] && [ -z "$PW" ] && [ "$(q x18 '.findings|length')" = 0 ]; then
214
+ ok "X18 a lane file name with shell syntax runs as a path, its spelling runs nothing"
215
+ else bad "X18 lane name is not code" "pwned=${PW:-none} $(head -c 300 "$TMPROOT/x18.json")"; fi
216
+
217
+ # ── X19 ────────────────────────────────────────────────────────────────────────────────────────
218
+ R="$TMPROOT/x19"; mkrepo "$R" 'echo ok'; B=$(g -C "$R" rev-parse HEAD)
219
+ printf '#!/usr/bin/env bash\n# touch\necho ok\n' > "$R/scripts/foo.sh"; g -C "$R" commit -qam change
220
+ TMPDIR="$TMPROOT/no/such/dir" run_exec x19 "$R" "$B"
221
+ if [ "$RC" -eq 0 ] && [ "$(q x19 '[.findings[]|select(.grade=="B" and .source=="exec")]|length')" = 1 ] && [ "$(q x19 '.e1.status')" = not-run ]; then
222
+ ok "X19 no temporary folder → B «could not run», not a silent NOT RUN"
223
+ else bad "X19 mktemp fails → B" "rc=$RC $(head -c 300 "$TMPROOT/x19.json")"; fi
224
+
225
+ # ── X20 ────────────────────────────────────────────────────────────────────────────────────────
226
+ R="$TMPROOT/x20"; mkrepo "$R" 'echo ok'; B=$(g -C "$R" rev-parse HEAD)
227
+ printf '#!/usr/bin/env bash\necho red; exit 1\n' > "$R/scripts/new_check.sh"; g -C "$R" add -A; g -C "$R" commit -qm change
228
+ FH_GATE_LANES='bash scripts/new_check.sh' run_exec x20 "$R" "$B"
229
+ if [ "$(q x20 '[.findings[]|select(.source=="E1")]|map(.grade)|join(",")')" = A ]; then ok "X20 a declared lane new with this change, red → A (not «red before»)"
230
+ else bad "X20 new declared lane → A" "$(head -c 400 "$TMPROOT/x20.json")"; fi
231
+
232
+ # ── X15 ────────────────────────────────────────────────────────────────────────────────────────
233
+ # A scanner whose own known pair fails must not report «0 new». The fake scanner below exits 2 the way
234
+ # pipefail_earlyexit_scan.sh does when its self-test fails.
235
+ R="$TMPROOT/x15"; mkrepo "$R" 'echo ok'; B=$(g -C "$R" rev-parse HEAD)
236
+ printf '#!/usr/bin/env bash\n# touch\necho ok\n' > "$R/scripts/foo.sh"; g -C "$R" commit -qam change
237
+ FAKESCAN="$TMPROOT/fake_scan.sh"; printf '#!/usr/bin/env bash\necho "INSTRUMENT ERROR" >&2\nexit 2\n' > "$FAKESCAN"
238
+ FH_GATE_E0_SCANNER="$FAKESCAN" run_exec x15 "$R" "$B"
239
+ if [ "$(q x15 '[.findings[]|select(.grade=="B" and .source=="E0")]|length')" = 1 ] && qm x15 '.e0.detail' 'instrument error' i; then
240
+ ok "X15 scanner self-test fails → B «instrument error», not «0 new»"
241
+ else bad "X15 scanner instrument error → B" "$(head -c 400 "$TMPROOT/x15.json")"; fi
242
+
243
+ echo "exec lanes: $pass passed, $fail failed$([ "${skip:-0}" -gt 0 ] && printf ', %s skipped (not a pass)' "$skip")"
244
+ [ "$fail" -eq 0 ]