@chrono-meta/fh-gate 3.43.0 β 3.45.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/rules/fh_4axis_gate.md +50 -608
- package/.claude-plugin/marketplace.json +4 -4
- package/AGENTS.md +5 -1
- package/CATALOG.md +21 -0
- package/CHEATSHEET.md +7 -1
- package/docs/USER_GUIDE.md +95 -0
- package/docs/codex-compat.md +1 -1
- package/knowledge/shared/harness-core/fh_4axis_gate_detail.md +679 -0
- package/knowledge/shared/harness-core/fh_integration_contract.md +1 -1
- package/knowledge/shared/harness-core/fh_module_contract.md +106 -3
- package/knowledge/shared/harness-core/governance_engineering_definition.md +16 -0
- package/knowledge/shared/harness-core/heavy_skill_to_cartridge.md +185 -0
- package/knowledge/shared/learnings/subagent_invocations_log.yaml +221 -0
- package/knowledge/shared/plugin-catalog/recommended_plugins.md +53 -9
- package/package.json +24 -1
- package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-commons/skills/ko-tech-writer/SKILL.md +50 -14
- package/plugins/fh-commons/skills/ko-tech-writer/SKILL_detail.md +80 -0
- package/plugins/fh-commons/skills/ko-tech-writer/fixtures/sense_negative.md +30 -0
- package/plugins/fh-commons/skills/ko-tech-writer/fixtures/sense_positive.md +56 -0
- package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-meta/CHANGELOG.md +118 -0
- package/plugins/fh-meta/skills/auto-decorrelation/SKILL.md +58 -1
- package/plugins/fh-meta/skills/install-wizard/SKILL_detail.md +4 -0
- package/plugins/fh-meta/skills/sim-conductor/SKILL_detail.md +3 -3
- package/plugins/fh-meta/skills/steel-quench/SKILL_detail.md +9 -4
- package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
- package/scripts/agy_launch_guard.sh +165 -0
- package/scripts/agy_remote_run.sh +187 -0
- package/scripts/below_floor_scan.sh +30 -0
- package/scripts/codex_launch_guard.sh +123 -0
- package/scripts/correction_moments.py +23 -2
- package/scripts/fh-gate.sh +612 -14
- package/scripts/fh-goal.sh +56 -12
- package/scripts/fh-run.sh +1 -1
- package/scripts/fh_gate_exec.sh +272 -0
- package/scripts/fh_session_load.sh +17 -0
- package/scripts/finding_fleet.sh +36 -2
- package/scripts/finding_verifier.sh +7 -2
- package/scripts/fixtures/heavy_skill_smell/clean/tidy-notes/README.md +16 -0
- package/scripts/fixtures/heavy_skill_smell/clean/tidy-notes/scripts/check_refs.py +12 -0
- package/scripts/fixtures/heavy_skill_smell/clean/tidy-notes/scripts/test_check_refs.py +24 -0
- package/scripts/fixtures/heavy_skill_smell/clean/tidy-notes/skills/tidy-notes/SKILL.md +16 -0
- package/scripts/fixtures/heavy_skill_smell/clean/tidy-notes/skills/tidy-notes/fh-module.yaml +20 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/docs-publisher-pro/SKILL.md +25 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/docs-publisher-pro/hooks/hooks.json +7 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/docs-publisher-pro/scripts/check_links.py +25 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/docs-publisher-pro/scripts/publish.sh +9 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/docs-publisher-pro/scripts/publish_guard.py +6 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/docs-publisher-pro/scripts/setup.sh +5 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/release-notes-pro/SKILL.md +25 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/release-notes-pro/hooks/hooks.json +10 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/release-notes-pro/scripts/check_refs.py +12 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/release-notes-pro/scripts/guard_push.py +9 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/release-notes-pro/scripts/install.sh +6 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/release-notes-pro/scripts/ship.sh +9 -0
- package/scripts/heavy_skill_smell.py +311 -0
- package/scripts/job_heartbeat.py +186 -0
- package/scripts/ko_tech_writer_calibrate.py +88 -1
- package/scripts/live_eval_matrix.py +128 -0
- package/scripts/live_eval_trace.py +199 -5
- package/scripts/package_coverage_check.sh +18 -0
- package/scripts/prepush_guard_check.sh +41 -20
- package/scripts/probe_live_eval.sh +33 -1
- package/scripts/probe_live_eval_lib.py +14 -6
- package/scripts/selfcheck.sh +162 -2
- package/scripts/selfcheck_shard_weights.txt +2 -0
- package/scripts/session_checklist.py +109 -5
- package/scripts/sidecar_calibrate.sh +15 -5
- package/scripts/sidecar_wait.sh +21 -1
- package/scripts/sim_isolated_run.sh +20 -0
- package/scripts/test_agy_launch_guard_lanes.sh +347 -0
- package/scripts/test_agy_remote_run_lanes.sh +228 -0
- package/scripts/test_below_floor_scan_lanes.sh +85 -0
- package/scripts/test_codex_launch_guard_lanes.sh +183 -0
- package/scripts/test_correction_moments_lanes.sh +37 -0
- package/scripts/test_fh_gate_absorb_lanes.sh +255 -0
- package/scripts/test_fh_gate_defaults_lanes.sh +169 -0
- package/scripts/test_fh_gate_exec_lanes.sh +244 -0
- package/scripts/test_fh_gate_fusion_lanes.sh +202 -0
- package/scripts/test_fh_gate_regressions.sh +92 -1
- package/scripts/test_fh_goal_change_detection_lanes.sh +103 -3
- package/scripts/test_finding_pipeline_lanes.sh +41 -3
- package/scripts/test_guard_anchor_override_env_lanes.sh +84 -0
- package/scripts/test_heavy_skill_smell_lanes.sh +160 -0
- package/scripts/test_job_heartbeat_lanes.sh +96 -0
- package/scripts/test_live_eval_construct_lanes.sh +29 -6
- package/scripts/test_live_eval_matrix_lanes.sh +53 -0
- package/scripts/test_live_eval_trace_lanes.sh +165 -12
- package/scripts/test_name_boundary_locale_lanes.sh +36 -5
- package/scripts/test_preprep_speech_coach_lanes.sh +18 -2
- package/scripts/test_prepush_guard_failure_visibility_lanes.sh +152 -0
- package/scripts/test_prepush_marker_lookup_lanes.sh +143 -0
- package/scripts/test_probe_live_eval_lanes.sh +43 -0
- package/scripts/test_regression_guard_sibling_lanes.sh +52 -1
- package/scripts/test_session_checklist_lanes.sh +205 -0
- package/scripts/test_sidecar_calibrate_lanes.sh +5 -1
- package/scripts/test_sidecar_wait_stdin.sh +18 -0
- package/scripts/test_sim_isolated_run_lanes.sh +43 -0
- package/scripts/universal_guard_check.sh +8 -0
- package/templates/.claude/rules/mcp_tool_gating.md +27 -0
- package/templates/.git-hooks/pre-push +60 -3
- package/templates/regression_guard.sh +8 -4
- package/templates/settings.LaneGap.snippet.json +27 -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 ]
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# test_fh_gate_fusion_lanes.sh β lanes for fh-gate's opt-in /code-review review stage (FH_REVIEWER=code-review) and its
|
|
3
|
+
# merge with the execution layer. Token-free: `claude` and `codex` are stubs on PATH.
|
|
4
|
+
#
|
|
5
|
+
# F1 FH_REVIEWER=code-review calls Β«/code-review mediumΒ» (quick) / Β«highΒ» (full) with a schema, read-only tools
|
|
6
|
+
# F2 Important + Nit β PENDING (exit 1), grades B and C, the summary carried verbatim
|
|
7
|
+
# F3 Nit + Pre-existing only β PASS (exit 0)
|
|
8
|
+
# F4 no structured object β 10, no fallback to another reviewer
|
|
9
|
+
# F5 a severity outside the label set β 10
|
|
10
|
+
# F5b keys outside the schema (top level or in a finding) β 10
|
|
11
|
+
# F6 status ERROR β 10
|
|
12
|
+
# F7 FH_REVIEWER=fh-legacy β the older FH pass (its prompt on stdin, its verdict)
|
|
13
|
+
# F8 codex backend with FH_REVIEWER=fh β the absorbed FH pass, not labelled fallback (it was asked for)
|
|
14
|
+
# F9 FH_REVIEWER=code-review on codex β 11
|
|
15
|
+
# F10 FH_REVIEWER / FH_GATE_EXEC outside their sets β 11
|
|
16
|
+
# F11 a change that turns its lane red, /code-review with no finding β BLOCKED (2), finding source E1
|
|
17
|
+
# F12 dry run β 12, the reviewer is not called, E1 Β«plannedΒ»
|
|
18
|
+
# F13 FH_GATE_EXEC=off β E0/E1 lines say NOT RUN (FH_GATE_EXEC=off)
|
|
19
|
+
# F14 cross with FH_REVIEWER=code-review β the codex leg gets the goldfish pass, labelled fallback; both lines kept;
|
|
20
|
+
# the execution layer runs once
|
|
21
|
+
# F15 /code-review call fails (rc β 0) β 10
|
|
22
|
+
# F16 /code-review runs in the repository root even when fh-gate is called from a subfolder
|
|
23
|
+
# F17 a Nit-only review cannot be lifted to PASS past a red lane, and a C lane note does not move PASS
|
|
24
|
+
#
|
|
25
|
+
# Run: bash scripts/test_fh_gate_fusion_lanes.sh
|
|
26
|
+
set -uo pipefail
|
|
27
|
+
. "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # scrub inherited GIT_* env first (#1088)
|
|
28
|
+
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
29
|
+
GATE="$HERE/fh-gate.sh"
|
|
30
|
+
TMPROOT=$(mktemp -d "${TMPDIR:-/tmp}/fh_gate_fusion_XXXXXX")
|
|
31
|
+
trap 'rm -rf "$TMPROOT"' EXIT
|
|
32
|
+
export FH_RECORD_BASE="$TMPROOT/records"; mkdir -p "$FH_RECORD_BASE"
|
|
33
|
+
# These lanes exercise the opt-in review and execution layer (3.45.0: defaults are fh-legacy Β· exec off Β· elephant
|
|
34
|
+
# off β pinned by test_fh_gate_defaults_lanes.sh). Each lane that needs otherwise sets its own value.
|
|
35
|
+
export FH_REVIEWER=code-review FH_GATE_EXEC=on
|
|
36
|
+
pass=0; fail=0
|
|
37
|
+
ok() { printf 'PASS %s\n' "$1"; pass=$((pass + 1)); }
|
|
38
|
+
bad() { printf 'FAIL %s β %s\n' "$1" "$2"; fail=$((fail + 1)); }
|
|
39
|
+
g() { git -c user.name=t -c user.email=t@t -c commit.gpgsign=false -c core.hooksPath=/dev/null "$@"; }
|
|
40
|
+
|
|
41
|
+
FAKEBIN="$TMPROOT/bin"; mkdir -p "$FAKEBIN"
|
|
42
|
+
cat > "$FAKEBIN/claude" <<'FAKE'
|
|
43
|
+
#!/usr/bin/env bash
|
|
44
|
+
printf '%s\n' "$@" >> "${ARGV_LOG:-/dev/null}" # append: one gate run may call the backend more than once
|
|
45
|
+
pwd -P > "${PWD_LOG:-/dev/null}"
|
|
46
|
+
in=$(cat); printf '%s\n' "$in" > "${STDIN_LOG:-/dev/null}"
|
|
47
|
+
[ -n "${FAKE_RC:-}" ] && exit "$FAKE_RC"
|
|
48
|
+
case "$in" in *"FH ELEPHANT PASS"*|*"FH REVIEW PASS"*)
|
|
49
|
+
printf '{"is_error":false,"subtype":"success","structured_output":{"status":"SUCCESS","findings":[]}}\n'; exit 0 ;; esac
|
|
50
|
+
if [ -n "${FAKE_ENVELOPE:-}" ]; then printf '%s\n' "$FAKE_ENVELOPE"; exit 0; fi
|
|
51
|
+
cr="${FAKE_CR:-}"; [ -n "$cr" ] || cr='{"status":"SUCCESS","findings":[]}'
|
|
52
|
+
case " $* " in
|
|
53
|
+
*"/code-review "*) printf '{"is_error":false,"subtype":"success","structured_output":%s}\n' "$cr" ;;
|
|
54
|
+
*) printf '{"is_error":false,"subtype":"success","structured_output":%s}\n' "$FAKE_PAYLOAD" ;;
|
|
55
|
+
esac
|
|
56
|
+
FAKE
|
|
57
|
+
cat > "$FAKEBIN/codex" <<'FAKE'
|
|
58
|
+
#!/usr/bin/env bash
|
|
59
|
+
out=""
|
|
60
|
+
while [ $# -gt 0 ]; do case "$1" in -o) out="$2"; shift 2 ;; *) shift ;; esac; done
|
|
61
|
+
in=$(cat); printf '%s\n' "$in" > "${CODEX_STDIN_LOG:-/dev/null}"
|
|
62
|
+
p="$FAKE_PAYLOAD"
|
|
63
|
+
case "$in" in *"FH REVIEW PASS"*|*"FH ELEPHANT PASS"*) p='{"status":"SUCCESS","findings":[]}' ;; esac
|
|
64
|
+
[ -n "$out" ] && printf '%s' "$p" > "$out"
|
|
65
|
+
exit 0
|
|
66
|
+
FAKE
|
|
67
|
+
chmod +x "$FAKEBIN/claude" "$FAKEBIN/codex"
|
|
68
|
+
export PATH="$FAKEBIN:$PATH"
|
|
69
|
+
export FAKE_PAYLOAD='{"status":"SUCCESS","verdict":"PASS","findings_count":0,"findings_a":0,"findings_b":0,"findings":[]}'
|
|
70
|
+
|
|
71
|
+
# a repo with one change on a branch (scripts/foo.sh + its lane), so auto-detect has files
|
|
72
|
+
REPO="$TMPROOT/repo"; mkdir -p "$REPO/scripts/sub"
|
|
73
|
+
g -C "$REPO" init -q -b main
|
|
74
|
+
printf '#!/usr/bin/env bash\necho ok\n' > "$REPO/scripts/foo.sh"
|
|
75
|
+
printf '#!/usr/bin/env bash\n[ "$(bash scripts/foo.sh)" = ok ] || { echo "FAIL foo"; exit 1; }\necho PASS\n' > "$REPO/scripts/test_foo_lanes.sh"
|
|
76
|
+
g -C "$REPO" add -A; g -C "$REPO" commit -qm base
|
|
77
|
+
g -C "$REPO" checkout -qb feat
|
|
78
|
+
printf '#!/usr/bin/env bash\n# harmless\necho ok\n' > "$REPO/scripts/foo.sh"; g -C "$REPO" commit -qam harmless
|
|
79
|
+
|
|
80
|
+
# gate <name> [env...] β run fh-gate in $REPO (or $RUN_DIR), stdout/err to files, rc in $RC
|
|
81
|
+
gate() {
|
|
82
|
+
local name="$1"; shift
|
|
83
|
+
( cd "${RUN_DIR:-$REPO}" && env "$@" bash "$GATE" ) > "$TMPROOT/$name.out" 2> "$TMPROOT/$name.err" < /dev/null
|
|
84
|
+
RC=$?
|
|
85
|
+
}
|
|
86
|
+
has() { grep -qF -- "$2" "$TMPROOT/$1.out"; }
|
|
87
|
+
|
|
88
|
+
CR_IMP_NIT='{"status":"SUCCESS","findings":[{"file":"scripts/foo.sh","line":2,"severity":"important","summary":"Off-by-one Β«exactΒ» text β kept: $x `y`","failure_scenario":"input 0 crashes"},{"file":"scripts/foo.sh","line":0,"severity":"nit","summary":"naming","failure_scenario":""}]}'
|
|
89
|
+
CR_NIT_PRE='{"status":"SUCCESS","findings":[{"file":"a","line":1,"severity":"nit","summary":"n","failure_scenario":""},{"file":"b","line":3,"severity":"pre_existing","summary":"p","failure_scenario":"old"}]}'
|
|
90
|
+
|
|
91
|
+
# F1
|
|
92
|
+
gate f1 FH_GATE_EXEC=off ARGV_LOG="$TMPROOT/f1.argv"
|
|
93
|
+
gate f1b FH_GATE_EXEC=off FH_GATE_LEVEL=full ARGV_LOG="$TMPROOT/f1b.argv"
|
|
94
|
+
if [ "$RC" -eq 0 ] && grep -qx '/code-review medium' "$TMPROOT/f1.argv" && grep -qx '/code-review high' "$TMPROOT/f1b.argv" \
|
|
95
|
+
&& grep -qx -- '--json-schema' "$TMPROOT/f1.argv" && grep -q 'Write,Edit' "$TMPROOT/f1.argv" \
|
|
96
|
+
&& has f1 'FH_GATE_REVIEWER: /code-review medium (built-in)'; then
|
|
97
|
+
ok "F1 FH_REVIEWER=code-review calls /code-review (medium quick Β· high full), schema, read-only tools"
|
|
98
|
+
else bad "F1 /code-review opt-in" "rc=$RC argv=$(tr '\n' ' ' < "$TMPROOT/f1.argv" 2>/dev/null)"; fi
|
|
99
|
+
|
|
100
|
+
# F2
|
|
101
|
+
gate f2 FH_GATE_EXEC=off FAKE_CR="$CR_IMP_NIT"
|
|
102
|
+
if [ "$RC" -eq 1 ] && has f2 'FH_GATE_VERDICT: PENDING' && has f2 'FH_FINDINGS_B: 1' && has f2 'FH_FINDINGS_COUNT: 2' \
|
|
103
|
+
&& has f2 'title: "Off-by-one Β«exactΒ» text β kept: $x `y`"' && has f2 'location: "scripts/foo.sh:2"'; then
|
|
104
|
+
ok "F2 Important + Nit β PENDING, B + C, summary verbatim"
|
|
105
|
+
else bad "F2 Important + Nit β PENDING" "rc=$RC $(head -c 600 "$TMPROOT/f2.out")"; fi
|
|
106
|
+
|
|
107
|
+
# F3
|
|
108
|
+
gate f3 FH_GATE_EXEC=off FAKE_CR="$CR_NIT_PRE"
|
|
109
|
+
if [ "$RC" -eq 0 ] && has f3 'FH_GATE_VERDICT: PASS' && has f3 'FH_FINDINGS_COUNT: 2'; then ok "F3 Nit + Pre-existing only β PASS"
|
|
110
|
+
else bad "F3 Nit + Pre-existing β PASS" "rc=$RC $(head -c 400 "$TMPROOT/f3.out")"; fi
|
|
111
|
+
|
|
112
|
+
# F4
|
|
113
|
+
gate f4 FH_GATE_EXEC=off FAKE_ENVELOPE='{"is_error":false,"subtype":"success","result":"8 findings, most severe first: ..."}'
|
|
114
|
+
if [ "$RC" -eq 10 ]; then ok "F4 no structured object β 10 (no fallback)"; else bad "F4 no structured object β 10" "rc=$RC"; fi
|
|
115
|
+
|
|
116
|
+
# F5
|
|
117
|
+
gate f5 FH_GATE_EXEC=off FAKE_CR='{"status":"SUCCESS","findings":[{"file":"a","line":1,"severity":"critical","summary":"s","failure_scenario":""}]}'
|
|
118
|
+
if [ "$RC" -eq 10 ]; then ok "F5 severity outside the label set β 10"; else bad "F5 severity outside set β 10" "rc=$RC"; fi
|
|
119
|
+
|
|
120
|
+
# F5b β keys outside the schema (top level or in a finding) β 10
|
|
121
|
+
gate f5b FH_GATE_EXEC=off FAKE_CR='{"status":"SUCCESS","findings":[],"extra":true}'; r1=$RC
|
|
122
|
+
gate f5c FH_GATE_EXEC=off FAKE_CR='{"status":"SUCCESS","findings":[{"file":"a","line":1,"severity":"nit","summary":"s","failure_scenario":"","verdict":"PASS"}]}'; r2=$RC
|
|
123
|
+
if [ "$r1" -eq 10 ] && [ "$r2" -eq 10 ]; then ok "F5b keys outside the schema β 10"; else bad "F5b extra keys β 10" "top=$r1 finding=$r2"; fi
|
|
124
|
+
|
|
125
|
+
# F6
|
|
126
|
+
gate f6 FH_GATE_EXEC=off FAKE_CR='{"status":"ERROR","findings":[]}'
|
|
127
|
+
if [ "$RC" -eq 10 ]; then ok "F6 status ERROR β 10"; else bad "F6 status ERROR β 10" "rc=$RC"; fi
|
|
128
|
+
|
|
129
|
+
# F7
|
|
130
|
+
gate f7 FH_GATE_EXEC=off FH_REVIEWER=fh-legacy STDIN_LOG="$TMPROOT/f7.stdin" \
|
|
131
|
+
FAKE_PAYLOAD='{"status":"SUCCESS","verdict":"PENDING","findings_count":1,"findings_a":0,"findings_b":1,"findings":[{"grade":"B","location":"x","title":"t","evidence":"e","fix":"f"}]}'
|
|
132
|
+
if [ "$RC" -eq 1 ] && grep -q 'FH GOVERNANCE GATE' "$TMPROOT/f7.stdin" && has f7 'FH_GATE_REVIEWER: fh-legacy'; then
|
|
133
|
+
ok "F7 FH_REVIEWER=fh-legacy β the older FH pass"
|
|
134
|
+
else bad "F7 FH_REVIEWER=fh-legacy β FH pass" "rc=$RC"; fi
|
|
135
|
+
|
|
136
|
+
# F8
|
|
137
|
+
gate f8 FH_GATE_EXEC=off FH_BACKEND=codex FH_REVIEWER=fh CODEX_STDIN_LOG="$TMPROOT/f8.stdin"
|
|
138
|
+
if [ "$RC" -eq 0 ] && has f8 'FH_GATE_REVIEWER: fh β goldfish pass' && ! has f8 'fallback' && grep -q 'FH REVIEW PASS' "$TMPROOT/f8.stdin"; then
|
|
139
|
+
ok "F8 codex + FH_REVIEWER=fh β the absorbed FH pass, not labelled fallback"
|
|
140
|
+
else bad "F8 codex + fh" "rc=$RC $(grep REVIEWER "$TMPROOT/f8.out")"; fi
|
|
141
|
+
|
|
142
|
+
# F9
|
|
143
|
+
gate f9 FH_GATE_EXEC=off FH_BACKEND=codex FH_REVIEWER=code-review
|
|
144
|
+
if [ "$RC" -eq 11 ]; then ok "F9 FH_REVIEWER=code-review on codex β 11"; else bad "F9 code-review on codex β 11" "rc=$RC"; fi
|
|
145
|
+
|
|
146
|
+
# F10
|
|
147
|
+
gate f10a FH_REVIEWER=bogus; r1=$RC
|
|
148
|
+
gate f10b FH_GATE_EXEC=maybe; r2=$RC
|
|
149
|
+
if [ "$r1" -eq 11 ] && [ "$r2" -eq 11 ]; then ok "F10 FH_REVIEWER / FH_GATE_EXEC outside their sets β 11"
|
|
150
|
+
else bad "F10 bad values β 11" "reviewer=$r1 exec=$r2"; fi
|
|
151
|
+
|
|
152
|
+
# F11 β a change that turns its lane red
|
|
153
|
+
g -C "$REPO" checkout -q -b red main
|
|
154
|
+
printf '#!/usr/bin/env bash\necho broken\n' > "$REPO/scripts/foo.sh"; g -C "$REPO" commit -qam red
|
|
155
|
+
gate f11
|
|
156
|
+
if [ "$RC" -eq 2 ] && has f11 'FH_GATE_VERDICT: BLOCKED' && has f11 'source: "E1"' && has f11 'FH_GATE_E1: ran β ran 1 lane(s)'; then
|
|
157
|
+
ok "F11 lane turned red by the change, clean review β BLOCKED from E1"
|
|
158
|
+
else bad "F11 red lane β BLOCKED" "rc=$RC $(head -c 700 "$TMPROOT/f11.out") $(tail -c 300 "$TMPROOT/f11.err")"; fi
|
|
159
|
+
|
|
160
|
+
# F12
|
|
161
|
+
rm -f "$TMPROOT/f12.argv"
|
|
162
|
+
gate f12 FH_DRY_RUN=1 ARGV_LOG="$TMPROOT/f12.argv"
|
|
163
|
+
if [ "$RC" -eq 12 ] && [ ! -e "$TMPROOT/f12.argv" ] && has f12 'FH_GATE_E1: planned β would run 1 lane(s)'; then
|
|
164
|
+
ok "F12 dry run β 12, reviewer not called, E1 planned"
|
|
165
|
+
else bad "F12 dry run" "rc=$RC called=$([ -e "$TMPROOT/f12.argv" ] && echo yes || echo no) $(grep E1 "$TMPROOT/f12.out")"; fi
|
|
166
|
+
|
|
167
|
+
# F13
|
|
168
|
+
gate f13 FH_GATE_EXEC=off
|
|
169
|
+
if has f13 'FH_GATE_E0: not-run β NOT RUN (FH_GATE_EXEC=off)' && has f13 'FH_GATE_E1: not-run β NOT RUN (FH_GATE_EXEC=off)'; then
|
|
170
|
+
ok "F13 FH_GATE_EXEC=off β NOT RUN lines"
|
|
171
|
+
else bad "F13 exec off lines" "$(grep -E 'E0|E1' "$TMPROOT/f13.out")"; fi
|
|
172
|
+
|
|
173
|
+
# F14 β cross: the red lane is seen once, both reviewer lines are kept
|
|
174
|
+
gate f14 FH_BACKEND=cross
|
|
175
|
+
if [ "$RC" -eq 2 ] && has f14 '# FH_GATE_REVIEWER: /code-review' && has f14 '(fallback β /code-review unavailable on codex)' \
|
|
176
|
+
&& has f14 '# FH_GATE_E1: not-run β NOT RUN (FH_GATE_EXEC=off)' && [ "$(grep -c 'source: "E1"' "$TMPROOT/f14.out")" -eq 1 ]; then
|
|
177
|
+
ok "F14 cross keeps both reviewer lines; execution layer runs once"
|
|
178
|
+
else bad "F14 cross" "rc=$RC $(grep -E 'REVIEWER|E1|source' "$TMPROOT/f14.out" | head -8)"; fi
|
|
179
|
+
|
|
180
|
+
# F15
|
|
181
|
+
g -C "$REPO" checkout -q feat
|
|
182
|
+
gate f15 FH_GATE_EXEC=off FAKE_RC=1
|
|
183
|
+
if [ "$RC" -eq 10 ]; then ok "F15 /code-review call fails β 10"; else bad "F15 call fails β 10" "rc=$RC"; fi
|
|
184
|
+
|
|
185
|
+
# F16
|
|
186
|
+
RUN_DIR="$REPO/scripts/sub" gate f16 FH_GATE_EXEC=off PWD_LOG="$TMPROOT/f16.pwd"
|
|
187
|
+
if [ "$(cat "$TMPROOT/f16.pwd" 2>/dev/null)" = "$(cd "$REPO" && pwd -P)" ]; then ok "F16 /code-review runs in the repository root"
|
|
188
|
+
else bad "F16 cwd = repo root" "got $(cat "$TMPROOT/f16.pwd" 2>/dev/null)"; fi
|
|
189
|
+
|
|
190
|
+
# F17 β Nit-only review + red lane stays BLOCKED; a lane red before the change too (C) leaves PASS alone
|
|
191
|
+
g -C "$REPO" checkout -q red
|
|
192
|
+
gate f17a FAKE_CR="$CR_NIT_PRE"
|
|
193
|
+
g -C "$REPO" checkout -q -b prered red
|
|
194
|
+
printf '#!/usr/bin/env bash\n# still broken\necho broken\n' > "$REPO/scripts/foo.sh"; g -C "$REPO" commit -qam again
|
|
195
|
+
gate f17b FH_GATE_BASE=red
|
|
196
|
+
if [ "$(sed -n 1p "$TMPROOT/f17a.out" >/dev/null; grep -c 'FH_GATE_VERDICT: BLOCKED' "$TMPROOT/f17a.out")" -eq 1 ] \
|
|
197
|
+
&& has f17b 'FH_GATE_VERDICT: PASS' && has f17b 'grade: C'; then
|
|
198
|
+
ok "F17 Nit-only cannot lift a red lane to PASS; a pre-existing red (C) leaves PASS"
|
|
199
|
+
else bad "F17 merge rule" "a=$(grep VERDICT "$TMPROOT/f17a.out") b=$(grep -m4 -E 'VERDICT|grade' "$TMPROOT/f17b.out")"; fi
|
|
200
|
+
|
|
201
|
+
echo "fusion lanes: $pass passed, $fail failed"
|
|
202
|
+
[ "$fail" -eq 0 ]
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
# Run: bash scripts/test_fh_gate_regressions.sh
|
|
15
15
|
|
|
16
16
|
set -uo pipefail
|
|
17
|
+
. "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh" # scrub inherited GIT_* env first (#1088)
|
|
17
18
|
cd "$(dirname "${BASH_SOURCE[0]}")/.." || { echo "FATAL: cannot cd to repo root"; exit 1; }
|
|
18
19
|
|
|
19
20
|
GATE="scripts/fh-gate.sh"
|
|
@@ -21,6 +22,25 @@ pass=0; fail=0
|
|
|
21
22
|
TMPROOT=$(mktemp -d "${TMPDIR:-/tmp}/fh_gate_test_XXXXXX")
|
|
22
23
|
trap 'rm -rf "$TMPROOT"' EXIT
|
|
23
24
|
|
|
25
|
+
# π₯ The gate APPENDS every invocation to $FH_RECORD_BASE/governance_log_<date>.yaml, defaulting to
|
|
26
|
+
# the hub's own tracks/_meta. Measured 2026-11-16 (clean-room audit round 9): one run of this suite
|
|
27
|
+
# added 19 rows to the live dated ledger (57 -> 76), and every row in every governance_log_*.yaml in
|
|
28
|
+
# a fresh container was `caller: test Β· model: fake` β 57, 57, 95, 57 across four rounds, 19 per
|
|
29
|
+
# selfcheck run, with zero real gate runs among them. So a reader opening that ledger as evidence of
|
|
30
|
+
# gate activity reads dozens of fixture PASSes, which is this audit's own defect class one step over:
|
|
31
|
+
# a record channel that renders "never ran for real" as "57 PASS". fh-gate.sh:30 documents
|
|
32
|
+
# FH_RECORD_BASE for exactly this, and this suite simply was not using it. The ledger is not asserted
|
|
33
|
+
# on anywhere in this file, so redirecting it changes no lane's verdict.
|
|
34
|
+
export FH_RECORD_BASE="$TMPROOT/records"
|
|
35
|
+
mkdir -p "$FH_RECORD_BASE"
|
|
36
|
+
|
|
37
|
+
# This suite anchors the older FH review pass (FH_REVIEWER=fh-legacy: its prompt, its schema, its cross-field
|
|
38
|
+
# verdict invariants). Since
|
|
39
|
+
# 2026-11-19 the claude backend reviews with the built-in /code-review by default β that path has its own
|
|
40
|
+
# lanes in scripts/test_fh_gate_fusion_lanes.sh. Pin the FH pass here, and keep the execution layer off: this
|
|
41
|
+
# suite runs from the repo root, so the layer would test whatever the developer's tree happens to change.
|
|
42
|
+
export FH_REVIEWER=fh-legacy FH_GATE_EXEC=off FH_GATE_ELEPHANT=off
|
|
43
|
+
|
|
24
44
|
# Review SUBJECT β a fixture this suite creates, NOT a file it hopes the repo has.
|
|
25
45
|
# Every gate invocation below used the literal `package.json` as its subject. That is an npm-package
|
|
26
46
|
# assumption smuggled into a test: this suite passed here only because this repo happens to ship one.
|
|
@@ -112,6 +132,72 @@ echo "ββ impossible-zero: an unperformed review is not a verdict ββ"
|
|
|
112
132
|
check "0 of N targets resolved β harness error" 10 \
|
|
113
133
|
env FH_DRY_RUN=1 bash "$GATE" "no_such_file_xyz.md" quick test
|
|
114
134
|
|
|
135
|
+
echo
|
|
136
|
+
echo "ββ non-ASCII target names (2026-11-19: Korean names came back quoted, so they were never reviewed) ββ"
|
|
137
|
+
# Auto-detected targets come from `git diff --name-only` / `git ls-files`. Under git's default core.quotePath a
|
|
138
|
+
# Korean name is printed as "\355\225β¦" in quotes; the gate then cannot open it. A Korean-only change exited 10
|
|
139
|
+
# (Β«0 of N β¦ nothing was reviewedΒ»); a mixed change reviewed only the ASCII file.
|
|
140
|
+
ABS_GATE="$(pwd -P)/$GATE"
|
|
141
|
+
NA="$TMPROOT/nonascii"; mkdir -p "$NA"
|
|
142
|
+
_ng() { git -C "$NA" -c user.name=lane -c user.email=lane@example.invalid -c commit.gpgsign=false "$@"; }
|
|
143
|
+
_ng init -q -b main; echo seed > "$NA/README"; _ng add README; _ng commit -qm seed
|
|
144
|
+
_ng switch -q -c change; echo "λ³Έλ¬Έ" > "$NA/νκΈλ¬Έμ.md"; _ng add "νκΈλ¬Έμ.md"; _ng commit -qm ko
|
|
145
|
+
check "Korean-only change: the file is resolved (dry-run 12, not 10)" 12 \
|
|
146
|
+
env -C "$NA" FH_DRY_RUN=1 FH_BASE_BRANCH=main bash "$ABS_GATE"
|
|
147
|
+
echo "x" > "$NA/ascii.md"; _ng add ascii.md; _ng commit -qm ascii
|
|
148
|
+
check "Korean + ASCII change: still dry-run 12" 12 env -C "$NA" FH_DRY_RUN=1 FH_BASE_BRANCH=main bash "$ABS_GATE"
|
|
149
|
+
if grep -q "only 1/2 target file" "$TMPROOT/err"; then
|
|
150
|
+
printf 'FAIL %-58s %s\n' "Korean + ASCII change: both files resolved" "a WARN says only 1/2 resolved"; fail=$((fail + 1))
|
|
151
|
+
else
|
|
152
|
+
printf 'PASS %-58s\n' "Korean + ASCII change: both files resolved (no partial-review WARN)"; pass=$((pass + 1))
|
|
153
|
+
fi
|
|
154
|
+
_ng switch -q main; echo "μμ
μ€" > "$NA/λ―ΈμΆμ .md"
|
|
155
|
+
check "Korean untracked file (ls-files path): resolved (dry-run 12)" 12 \
|
|
156
|
+
env -C "$NA" FH_DRY_RUN=1 FH_BASE_BRANCH=main bash "$ABS_GATE"
|
|
157
|
+
|
|
158
|
+
echo
|
|
159
|
+
echo "ββ names git quotes even with core.quotePath=false: quote, backslash, tab (AQ-20261119-8) ββ"
|
|
160
|
+
# The plain listing still wraps these in quotes with C escapes (Β«"a\"b.md"Β»), so the gate could not open them and
|
|
161
|
+
# warned Β«review is partialΒ». The listings are now read NUL-delimited (-z), where git prints every name raw.
|
|
162
|
+
SQ="$TMPROOT/specialq"; mkdir -p "$SQ"
|
|
163
|
+
_sq() { git -C "$SQ" -c user.name=lane -c user.email=lane@example.invalid -c commit.gpgsign=false "$@"; }
|
|
164
|
+
_sq init -q -b main; echo seed > "$SQ/README"; _sq add README; _sq commit -qm seed
|
|
165
|
+
_sq switch -q -c change
|
|
166
|
+
printf 'q\n' > "$SQ/quo\"te.md"; printf 'b\n' > "$SQ/back\\slash.md"; printf 't\n' > "$SQ/ta$(printf '\t')b.md"
|
|
167
|
+
_sq add -A; _sq commit -qm special
|
|
168
|
+
check "quote/backslash/tab names (diff path): dry-run 12" 12 env -C "$SQ" FH_DRY_RUN=1 FH_BASE_BRANCH=main bash "$ABS_GATE"
|
|
169
|
+
if grep -q "review is partial" "$TMPROOT/err"; then
|
|
170
|
+
printf 'FAIL %-58s %s\n' "quote/backslash/tab names: all 3 resolved" "$(grep -m1 'review is partial' "$TMPROOT/err")"; fail=$((fail + 1))
|
|
171
|
+
else
|
|
172
|
+
printf 'PASS %-58s\n' "quote/backslash/tab names: all 3 resolved (no partial WARN)"; pass=$((pass + 1))
|
|
173
|
+
fi
|
|
174
|
+
_sq switch -q main; printf 'u\n' > "$SQ/untr\"acked.md"
|
|
175
|
+
check "quote name untracked (ls-files path): dry-run 12" 12 env -C "$SQ" FH_DRY_RUN=1 FH_BASE_BRANCH=main bash "$ABS_GATE"
|
|
176
|
+
if grep -q "review is partial\|could be read" "$TMPROOT/err"; then
|
|
177
|
+
printf 'FAIL %-58s\n' "quote name untracked: resolved"; fail=$((fail + 1))
|
|
178
|
+
else
|
|
179
|
+
printf 'PASS %-58s\n' "quote name untracked: resolved"; pass=$((pass + 1))
|
|
180
|
+
fi
|
|
181
|
+
rm -f "$SQ/untr\"acked.md"
|
|
182
|
+
# A newline cannot travel in the newline-delimited target list: it must be NAMED in a WARN, and since the rest would
|
|
183
|
+
# get a verdict on part of the change, the gate fails closed (10) instead of reviewing the others (security review
|
|
184
|
+
# 2026-11-20; before, this case went on to a dry-run 12 and, with a backend, to PASS).
|
|
185
|
+
_sq switch -q change; printf 'n\n' > "$SQ/new
|
|
186
|
+
line.md"; _sq add -A; _sq commit -qm nl
|
|
187
|
+
check "newline name beside others: fails closed 10" 10 env -C "$SQ" FH_DRY_RUN=1 FH_BASE_BRANCH=main bash "$ABS_GATE"
|
|
188
|
+
if grep -q "contains a newline" "$TMPROOT/err" && grep -q "cover only part of the change" "$TMPROOT/err"; then
|
|
189
|
+
printf 'PASS %-58s\n' "newline name: named in a WARN, not dropped silently"; pass=$((pass + 1))
|
|
190
|
+
else
|
|
191
|
+
printf 'FAIL %-58s\n' "newline name: no WARN names it"; fail=$((fail + 1))
|
|
192
|
+
fi
|
|
193
|
+
# Only a newline name changed, tree otherwise dirty: must fail closed (10), not fall back to the dirty file.
|
|
194
|
+
NO="$TMPROOT/nlonly"; mkdir -p "$NO"
|
|
195
|
+
_no() { git -C "$NO" -c user.name=lane -c user.email=lane@example.invalid -c commit.gpgsign=false "$@"; }
|
|
196
|
+
_no init -q -b main; echo seed > "$NO/README"; _no add README; _no commit -qm seed
|
|
197
|
+
_no switch -q -c change; printf 'n\n' > "$NO/only
|
|
198
|
+
nl.md"; _no add -A; _no commit -qm nl; echo dirty >> "$NO/README"
|
|
199
|
+
check "newline name is the only change: fails closed (10)" 10 env -C "$NO" FH_DRY_RUN=1 FH_BASE_BRANCH=main bash "$ABS_GATE"
|
|
200
|
+
|
|
115
201
|
echo
|
|
116
202
|
echo "ββ cross-field verdict invariants (the gate's own worst class) ββ"
|
|
117
203
|
# THE hole: enum-membership passed, verdict dispatched on the enum alone, findings_a was
|
|
@@ -324,8 +410,13 @@ case "$_sc" in
|
|
|
324
410
|
0|10) printf 'PASS %-58s (exit %s)\n' "stderr closed + PASS run β 0 or 10, never a lower verdict" "$_sc"; pass=$((pass + 1)) ;;
|
|
325
411
|
*) printf 'FAIL %-58s expected 0 or 10, got %s\n' "stderr closed + PASS run β 0 or 10, never a lower verdict" "$_sc"; fail=$((fail + 1)) ;;
|
|
326
412
|
esac
|
|
413
|
+
# π₯ `-u FH_RECORD_BASE` is load-bearing: this lane's whole subject is the $HOME fallback the record
|
|
414
|
+
# base takes outside a checkout, so the suite-wide FH_RECORD_BASE export (added above to keep fixture
|
|
415
|
+
# rows out of the hub's live ledger) has to be dropped for this one invocation or the fallback never
|
|
416
|
+
# runs. Measured: with it inherited the lane reads 12 instead of 10 β i.e. the lane went green-adjacent
|
|
417
|
+
# about a path it no longer visited. The suite caught the masking itself.
|
|
327
418
|
check "unbound variable (HOME unset, outside a checkout) β HARNESS_ERROR" 10 \
|
|
328
|
-
env -u HOME FH_DRY_RUN=1 bash -c 'cd "$1" && exec bash "$2" "$3" quick test' _ "$TMPROOT" "$PWD/$GATE" "$SUBJECT"
|
|
419
|
+
env -u HOME -u FH_RECORD_BASE FH_DRY_RUN=1 bash -c 'cd "$1" && exec bash "$2" "$3" quick test' _ "$TMPROOT" "$PWD/$GATE" "$SUBJECT"
|
|
329
420
|
|
|
330
421
|
echo
|
|
331
422
|
echo "ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
|