@chrono-meta/fh-gate 3.44.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/CATALOG.md +21 -0
- package/CHEATSHEET.md +7 -1
- 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/heavy_skill_to_cartridge.md +185 -0
- package/knowledge/shared/learnings/subagent_invocations_log.yaml +209 -0
- package/package.json +17 -1
- package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-commons/skills/ko-tech-writer/SKILL.md +9 -8
- package/plugins/fh-commons/skills/ko-tech-writer/SKILL_detail.md +20 -0
- package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-meta/CHANGELOG.md +95 -0
- package/plugins/fh-meta/skills/auto-decorrelation/SKILL.md +13 -0
- package/plugins/fh-meta/skills/install-wizard/SKILL_detail.md +4 -0
- package/plugins/fh-meta/skills/steel-quench/SKILL_detail.md +2 -1
- 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 +117 -1
- package/scripts/below_floor_scan.sh +30 -0
- package/scripts/codex_launch_guard.sh +38 -2
- 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 +2 -1
- package/scripts/finding_verifier.sh +2 -1
- 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/live_eval_matrix.py +128 -0
- package/scripts/live_eval_trace.py +176 -1
- package/scripts/package_coverage_check.sh +18 -0
- package/scripts/prepush_guard_check.sh +8 -0
- package/scripts/probe_live_eval.sh +32 -0
- package/scripts/probe_live_eval_lib.py +8 -2
- package/scripts/selfcheck.sh +111 -0
- package/scripts/selfcheck_shard_weights.txt +2 -0
- package/scripts/sidecar_calibrate.sh +7 -5
- package/scripts/sim_isolated_run.sh +20 -0
- package/scripts/test_agy_launch_guard_lanes.sh +120 -0
- package/scripts/test_below_floor_scan_lanes.sh +85 -0
- package/scripts/test_codex_launch_guard_lanes.sh +45 -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 +35 -1
- 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 +112 -5
- package/scripts/test_name_boundary_locale_lanes.sh +36 -5
- 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_sidecar_calibrate_lanes.sh +1 -1
- 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,255 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# test_fh_gate_absorb_lanes.sh — lanes for fh-gate's own review when /code-review is absent (the «goldfish» pass that
|
|
3
|
+
# absorbs /code-review's method) and for the «elephant» pass (repo history). Token-free: `claude`/`codex` are stubs.
|
|
4
|
+
#
|
|
5
|
+
# A1 FH_REVIEWER=fh sends the absorbed method: 8 named angles, candidates per angle, 1-vote 3-state verify,
|
|
6
|
+
# severity order, a cap (10 at full / 8 at quick) — and its schema carries the cap
|
|
7
|
+
# A2 goldfish: FH_TASK_DESCRIPTION never reaches the absorbed pass; it does reach the elephant pass
|
|
8
|
+
# A3 absorbed important + nit → PENDING, B + C, source review, summary verbatim
|
|
9
|
+
# A4 a finding the verifier refuted (verify REFUTED) in the output → 10
|
|
10
|
+
# A5 more findings than the cap → 10
|
|
11
|
+
# A6 no structured object from the absorbed pass → 10
|
|
12
|
+
# A7 elephant: on at full, off at quick, FH_GATE_ELEPHANT=off/on overrides, its line says which
|
|
13
|
+
# A8 the elephant prompt carries the touched file's history, including a past fix commit
|
|
14
|
+
# A9 an elephant finding (important) → PENDING, source elephant; an elephant with no structured object → 10
|
|
15
|
+
# A10 with /code-review as reviewer (FH_REVIEWER=code-review) the elephant pass still runs at full
|
|
16
|
+
# A11 codex backend with FH_REVIEWER=fh → the absorbed pass; its call is read-only
|
|
17
|
+
# A12 FH_REVIEWER=fh-legacy → the older steel-quench prompt
|
|
18
|
+
# A13 not a git repository → elephant NOT RUN (not applicable), no finding
|
|
19
|
+
# A14 FH_GATE_ELEPHANT outside its set → 11 · FH_REVIEWER outside its set → 11
|
|
20
|
+
# A15 no fence check reads a variable through a pipe into grep -q (shape; planted known positive)
|
|
21
|
+
# A16 the goldfish process does not inherit FH_TASK_DESCRIPTION (the elephant's does)
|
|
22
|
+
# A17 the change's diff cannot be computed → a B finding, said on the reviewer line
|
|
23
|
+
# A18 a diff past 80000 bytes is truncated aloud (prompt and reviewer line)
|
|
24
|
+
# A19 codex output with more than one JSON value → 10
|
|
25
|
+
# A20 CI-shaped checkout (detached, no local base branch): base falls back to origin/<base>; with no base at all
|
|
26
|
+
# the missing diff is named, not graded, only for fh-legacy with the elephant off
|
|
27
|
+
#
|
|
28
|
+
# Run: bash scripts/test_fh_gate_absorb_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
|
+
GATE="$HERE/fh-gate.sh"
|
|
33
|
+
TMPROOT=$(mktemp -d "${TMPDIR:-/tmp}/fh_gate_absorb_XXXXXX")
|
|
34
|
+
trap 'rm -rf "$TMPROOT"' EXIT
|
|
35
|
+
export FH_RECORD_BASE="$TMPROOT/records"; mkdir -p "$FH_RECORD_BASE"
|
|
36
|
+
export FH_GATE_EXEC=off
|
|
37
|
+
# The elephant is opt-in since 3.45.0 (default off — pinned by test_fh_gate_defaults_lanes.sh); these lanes test it
|
|
38
|
+
# at its «auto» setting (on at level full). Lanes that test another setting pass their own.
|
|
39
|
+
export FH_GATE_ELEPHANT=auto
|
|
40
|
+
pass=0; fail=0
|
|
41
|
+
ok() { printf 'PASS %s\n' "$1"; pass=$((pass + 1)); }
|
|
42
|
+
bad() { printf 'FAIL %s — %s\n' "$1" "$2"; fail=$((fail + 1)); }
|
|
43
|
+
g() { git -c user.name=t -c user.email=t@t -c commit.gpgsign=false -c core.hooksPath=/dev/null "$@"; }
|
|
44
|
+
|
|
45
|
+
# Stubs pick their answer by what they were asked: the absorbed pass, the elephant pass, /code-review, or the legacy pass.
|
|
46
|
+
FAKEBIN="$TMPROOT/bin"; mkdir -p "$FAKEBIN"
|
|
47
|
+
cat > "$FAKEBIN/claude" <<'FAKE'
|
|
48
|
+
#!/usr/bin/env bash
|
|
49
|
+
in=$(cat); args=" $* "
|
|
50
|
+
kind=legacy
|
|
51
|
+
case "$args" in *"/code-review "*) kind=cr ;; esac
|
|
52
|
+
case "$in" in *"FH ELEPHANT PASS"*) kind=ele ;; *"FH REVIEW PASS"*) kind=abs ;; esac
|
|
53
|
+
printf '%s\n' "$in" > "${LOGDIR:-/tmp}/claude_${kind}.stdin" 2>/dev/null
|
|
54
|
+
printf '%s\n' "$@" > "${LOGDIR:-/tmp}/claude_${kind}.argv" 2>/dev/null
|
|
55
|
+
printf '%s\n' "${FH_TASK_DESCRIPTION:-<unset>}" > "${LOGDIR:-/tmp}/claude_${kind}.env" 2>/dev/null
|
|
56
|
+
empty='{"status":"SUCCESS","findings":[]}'
|
|
57
|
+
case "$kind" in
|
|
58
|
+
cr) p="${FAKE_CR:-$empty}" ;;
|
|
59
|
+
abs) p="${FAKE_ABS:-$empty}" ;;
|
|
60
|
+
ele) p="${FAKE_ELE:-$empty}" ;;
|
|
61
|
+
*) p="${FAKE_PAYLOAD}" ;;
|
|
62
|
+
esac
|
|
63
|
+
[ "$p" = NONE ] && { printf '{"is_error":false,"subtype":"success","result":"prose only"}\n'; exit 0; }
|
|
64
|
+
printf '{"is_error":false,"subtype":"success","structured_output":%s}\n' "$p"
|
|
65
|
+
FAKE
|
|
66
|
+
cat > "$FAKEBIN/codex" <<'FAKE'
|
|
67
|
+
#!/usr/bin/env bash
|
|
68
|
+
out=""; args=" $* "
|
|
69
|
+
while [ $# -gt 0 ]; do case "$1" in -o) out="$2"; shift 2 ;; *) shift ;; esac; done
|
|
70
|
+
in=$(cat); kind=legacy
|
|
71
|
+
case "$in" in *"FH ELEPHANT PASS"*) kind=ele ;; *"FH REVIEW PASS"*) kind=abs ;; esac
|
|
72
|
+
printf '%s\n' "$in" > "${LOGDIR:-/tmp}/codex_${kind}.stdin" 2>/dev/null
|
|
73
|
+
printf '%s\n' "$args" > "${LOGDIR:-/tmp}/codex_${kind}.argv" 2>/dev/null
|
|
74
|
+
empty='{"status":"SUCCESS","findings":[]}'
|
|
75
|
+
case "$kind" in abs) p="${FAKE_ABS:-$empty}" ;; ele) p="${FAKE_ELE:-$empty}" ;; *) p="$FAKE_PAYLOAD" ;; esac
|
|
76
|
+
[ -n "$out" ] && printf '%s' "$p" > "$out"
|
|
77
|
+
[ -n "$out" ] && [ -n "${FAKE_CODEX_TWICE:-}" ] && printf '%s' "$p" >> "$out"
|
|
78
|
+
exit 0
|
|
79
|
+
FAKE
|
|
80
|
+
chmod +x "$FAKEBIN/claude" "$FAKEBIN/codex"
|
|
81
|
+
export PATH="$FAKEBIN:$PATH"
|
|
82
|
+
export FAKE_PAYLOAD='{"status":"SUCCESS","verdict":"PASS","findings_count":0,"findings_a":0,"findings_b":0,"findings":[]}'
|
|
83
|
+
|
|
84
|
+
REPO="$TMPROOT/repo"; mkdir -p "$REPO/scripts"
|
|
85
|
+
g -C "$REPO" init -q -b main
|
|
86
|
+
printf '#!/usr/bin/env bash\necho ok\n' > "$REPO/scripts/foo.sh"; g -C "$REPO" add -A; g -C "$REPO" commit -qm "add foo"
|
|
87
|
+
printf '#!/usr/bin/env bash\n[ -n "$1" ] || exit 2\necho ok\n' > "$REPO/scripts/foo.sh"; g -C "$REPO" commit -qam "fix: guard empty input in foo (PAST-FIX-MARK)"
|
|
88
|
+
g -C "$REPO" checkout -qb feat
|
|
89
|
+
printf '#!/usr/bin/env bash\necho ok\n' > "$REPO/scripts/foo.sh"; g -C "$REPO" commit -qam "simplify foo"
|
|
90
|
+
|
|
91
|
+
# gate <name> [env...] → stdout/err files, rc in $RC, stub logs in $TMPROOT/<name>/
|
|
92
|
+
gate() {
|
|
93
|
+
local name="$1"; shift
|
|
94
|
+
mkdir -p "$TMPROOT/$name"
|
|
95
|
+
( cd "${RUN_DIR:-$REPO}" && env LOGDIR="$TMPROOT/$name" "$@" bash "$GATE" ) > "$TMPROOT/$name.out" 2> "$TMPROOT/$name.err" < /dev/null
|
|
96
|
+
RC=$?
|
|
97
|
+
}
|
|
98
|
+
has() { grep -qF -- "$2" "$TMPROOT/$1.out"; }
|
|
99
|
+
logh() { grep -qF -- "$3" "$TMPROOT/$1/$2" 2>/dev/null; } # logh <name> <logfile> <text>
|
|
100
|
+
|
|
101
|
+
ABS_IMP_NIT='{"status":"SUCCESS","findings":[{"file":"scripts/foo.sh","line":2,"severity":"important","verify":"CONFIRMED","angle":"removed-behavior","summary":"The empty-input guard is gone «exact» $x","failure_scenario":"foo with no argument prints ok"},{"file":"scripts/foo.sh","line":0,"severity":"nit","verify":"PLAUSIBLE","angle":"simplification","summary":"n","failure_scenario":""}]}'
|
|
102
|
+
|
|
103
|
+
# A1
|
|
104
|
+
gate a1 FH_REVIEWER=fh FH_GATE_LEVEL=full FH_GATE_ELEPHANT=off
|
|
105
|
+
gate a1q FH_REVIEWER=fh FH_GATE_ELEPHANT=off
|
|
106
|
+
if [ "$RC" -eq 0 ] && logh a1 claude_abs.stdin 'FH REVIEW PASS' && logh a1 claude_abs.stdin 'line-by-line' \
|
|
107
|
+
&& logh a1 claude_abs.stdin 'removed-behavior' && logh a1 claude_abs.stdin 'cross-file' && logh a1 claude_abs.stdin 'CONFIRMED / PLAUSIBLE / REFUTED' \
|
|
108
|
+
&& logh a1 claude_abs.stdin 'at most 10' && logh a1q claude_abs.stdin 'at most 8' && logh a1 claude_abs.argv '"maxItems":10' \
|
|
109
|
+
&& has a1 'FH_GATE_REVIEWER: fh — goldfish pass'; then
|
|
110
|
+
ok "A1 FH_REVIEWER=fh sends the absorbed method (angles · verify · cap 10/8, cap in the schema)"
|
|
111
|
+
else bad "A1 absorbed method" "rc=$RC $(grep REVIEWER "$TMPROOT/a1.out")"; fi
|
|
112
|
+
|
|
113
|
+
# A2
|
|
114
|
+
gate a2 FH_REVIEWER=fh FH_GATE_LEVEL=full FH_TASK_DESCRIPTION='AUTHOR-INTENT-7Q'
|
|
115
|
+
if ! logh a2 claude_abs.stdin 'AUTHOR-INTENT-7Q' && logh a2 claude_ele.stdin 'AUTHOR-INTENT-7Q'; then
|
|
116
|
+
ok "A2 goldfish never sees the author's description; the elephant does"
|
|
117
|
+
else bad "A2 goldfish isolation" "abs_has=$(logh a2 claude_abs.stdin AUTHOR-INTENT-7Q && echo yes || echo no) ele_has=$(logh a2 claude_ele.stdin AUTHOR-INTENT-7Q && echo yes || echo no)"; fi
|
|
118
|
+
|
|
119
|
+
# A3
|
|
120
|
+
gate a3 FH_REVIEWER=fh FAKE_ABS="$ABS_IMP_NIT"
|
|
121
|
+
if [ "$RC" -eq 1 ] && has a3 'FH_FINDINGS_B: 1' && has a3 'FH_FINDINGS_COUNT: 2' && has a3 'title: "The empty-input guard is gone «exact» $x"' && has a3 'source: "review"'; then
|
|
122
|
+
ok "A3 absorbed important + nit → PENDING, B + C, verbatim"
|
|
123
|
+
else bad "A3 absorbed mapping" "rc=$RC $(head -c 500 "$TMPROOT/a3.out")"; fi
|
|
124
|
+
|
|
125
|
+
# A4
|
|
126
|
+
gate a4 FH_REVIEWER=fh FAKE_ABS='{"status":"SUCCESS","findings":[{"file":"a","line":1,"severity":"nit","verify":"REFUTED","angle":"x","summary":"s","failure_scenario":""}]}'
|
|
127
|
+
if [ "$RC" -eq 10 ]; then ok "A4 a refuted finding in the output → 10"; else bad "A4 REFUTED → 10" "rc=$RC"; fi
|
|
128
|
+
|
|
129
|
+
# A5 — 9 findings at quick (cap 8)
|
|
130
|
+
NINE=$(python3 -c 'import json;print(json.dumps({"status":"SUCCESS","findings":[{"file":"a","line":i,"severity":"nit","verify":"PLAUSIBLE","angle":"x","summary":"s","failure_scenario":""} for i in range(1,10)]}))')
|
|
131
|
+
gate a5 FH_REVIEWER=fh FAKE_ABS="$NINE"
|
|
132
|
+
if [ "$RC" -eq 10 ]; then ok "A5 more findings than the cap → 10"; else bad "A5 cap → 10" "rc=$RC"; fi
|
|
133
|
+
|
|
134
|
+
# A6
|
|
135
|
+
gate a6 FH_REVIEWER=fh FAKE_ABS=NONE
|
|
136
|
+
if [ "$RC" -eq 10 ]; then ok "A6 absorbed pass with no structured object → 10"; else bad "A6 no structured → 10" "rc=$RC"; fi
|
|
137
|
+
|
|
138
|
+
# A7
|
|
139
|
+
gate a7f FH_REVIEWER=fh FH_GATE_LEVEL=full
|
|
140
|
+
gate a7q FH_REVIEWER=fh
|
|
141
|
+
gate a7off FH_REVIEWER=fh FH_GATE_LEVEL=full FH_GATE_ELEPHANT=off
|
|
142
|
+
gate a7on FH_REVIEWER=fh FH_GATE_ELEPHANT=on
|
|
143
|
+
if has a7f 'FH_GATE_ELEPHANT: ran' && [ -e "$TMPROOT/a7f/claude_ele.stdin" ] \
|
|
144
|
+
&& has a7q 'FH_GATE_ELEPHANT: not-run — NOT RUN (level quick' && [ ! -e "$TMPROOT/a7q/claude_ele.stdin" ] \
|
|
145
|
+
&& has a7off 'NOT RUN (FH_GATE_ELEPHANT=off)' && [ ! -e "$TMPROOT/a7off/claude_ele.stdin" ] \
|
|
146
|
+
&& has a7on 'FH_GATE_ELEPHANT: ran' && [ -e "$TMPROOT/a7on/claude_ele.stdin" ]; then
|
|
147
|
+
ok "A7 elephant: on at full, off at quick, overrides honoured, the line says which"
|
|
148
|
+
else bad "A7 elephant switch" "$(grep -h ELEPHANT "$TMPROOT"/a7*.out | tr '\n' '|')"; fi
|
|
149
|
+
|
|
150
|
+
# A8
|
|
151
|
+
if logh a7f claude_ele.stdin 'PAST-FIX-MARK' && logh a7f claude_ele.stdin 'scripts/foo.sh' && logh a7f claude_ele.stdin 'FH ELEPHANT PASS'; then
|
|
152
|
+
ok "A8 the elephant prompt carries the touched file's history and its past fix"
|
|
153
|
+
else bad "A8 elephant history" "$(head -c 300 "$TMPROOT/a7f/claude_ele.stdin" 2>/dev/null)"; fi
|
|
154
|
+
|
|
155
|
+
# A9
|
|
156
|
+
ELE_IMP='{"status":"SUCCESS","findings":[{"file":"scripts/foo.sh","line":2,"severity":"important","verify":"CONFIRMED","angle":"past-fix-reverted","summary":"undoes PAST-FIX-MARK","failure_scenario":"empty input accepted again"}]}'
|
|
157
|
+
gate a9 FH_REVIEWER=fh FH_GATE_LEVEL=full FAKE_ELE="$ELE_IMP"; r1=$RC
|
|
158
|
+
gate a9b FH_REVIEWER=fh FH_GATE_LEVEL=full FAKE_ELE=NONE; r2=$RC
|
|
159
|
+
if [ "$r1" -eq 1 ] && has a9 'source: "elephant"' && has a9 'FH_GATE_VERDICT: PENDING' && [ "$r2" -eq 10 ]; then
|
|
160
|
+
ok "A9 elephant finding → PENDING (source elephant); elephant without a structured object → 10"
|
|
161
|
+
else bad "A9 elephant mapping / fail-closed" "found=$r1 none=$r2"; fi
|
|
162
|
+
|
|
163
|
+
# A10
|
|
164
|
+
gate a10 FH_REVIEWER=code-review FH_GATE_LEVEL=full
|
|
165
|
+
if [ -e "$TMPROOT/a10/claude_cr.argv" ] && [ -e "$TMPROOT/a10/claude_ele.stdin" ] && has a10 'FH_GATE_REVIEWER: /code-review high'; then
|
|
166
|
+
ok "A10 /code-review reviewer + elephant both run at full"
|
|
167
|
+
else bad "A10 cr + elephant" "cr=$([ -e "$TMPROOT/a10/claude_cr.argv" ] && echo y || echo n) ele=$([ -e "$TMPROOT/a10/claude_ele.stdin" ] && echo y || echo n)"; fi
|
|
168
|
+
|
|
169
|
+
# A11
|
|
170
|
+
gate a11 FH_BACKEND=codex FH_REVIEWER=fh
|
|
171
|
+
if [ "$RC" -eq 0 ] && has a11 'FH_GATE_REVIEWER: fh — goldfish pass' && logh a11 codex_abs.stdin 'FH REVIEW PASS' && logh a11 codex_abs.argv 'read-only'; then
|
|
172
|
+
ok "A11 codex + FH_REVIEWER=fh → absorbed pass, read-only"
|
|
173
|
+
else bad "A11 codex absorbed" "rc=$RC $(grep REVIEWER "$TMPROOT/a11.out")"; fi
|
|
174
|
+
|
|
175
|
+
# A12
|
|
176
|
+
gate a12 FH_REVIEWER=fh-legacy
|
|
177
|
+
if [ "$RC" -eq 0 ] && logh a12 claude_legacy.stdin 'FH GOVERNANCE GATE' && has a12 'FH_GATE_REVIEWER: fh-legacy'; then ok "A12 fh-legacy keeps the older pass"
|
|
178
|
+
else bad "A12 legacy" "rc=$RC"; fi
|
|
179
|
+
|
|
180
|
+
# A13
|
|
181
|
+
NG="$TMPROOT/nogit"; mkdir -p "$NG"; printf 'x\n' > "$NG/f.txt"
|
|
182
|
+
RUN_DIR="$NG" gate a13 FH_REVIEWER=fh FH_GATE_LEVEL=full FH_TARGET_FILES=f.txt
|
|
183
|
+
if [ "$RC" -eq 0 ] && has a13 'FH_GATE_ELEPHANT: not-run — NOT RUN (not a git repository)'; then ok "A13 not a git repository → elephant not applicable"
|
|
184
|
+
else bad "A13 no git" "rc=$RC $(grep ELEPHANT "$TMPROOT/a13.out")"; fi
|
|
185
|
+
|
|
186
|
+
# A14
|
|
187
|
+
gate a14 FH_GATE_ELEPHANT=sometimes; r1=$RC
|
|
188
|
+
gate a14b FH_REVIEWER=steel; r2=$RC
|
|
189
|
+
if [ "$r1" -eq 11 ] && [ "$r2" -eq 11 ]; then ok "A14 FH_GATE_ELEPHANT / FH_REVIEWER outside their sets → 11"
|
|
190
|
+
else bad "A14 bad values" "ele=$r1 rev=$r2"; fi
|
|
191
|
+
|
|
192
|
+
# A15 — the fence check never reads a variable through a pipe into grep -q. Under pipefail a match makes grep exit
|
|
193
|
+
# early, the writer fails on the closed pipe, and the `if` reads «no match»: measured 2026-11-20 on a 400 KB value
|
|
194
|
+
# (pipe form missed the nonce, here-string found it). The nonce is random per run, so this lane checks the shape,
|
|
195
|
+
# with a planted line as its known positive.
|
|
196
|
+
FENCE_PIPE_RE='printf .%s. "[$][A-Za-z_]+" [|] grep -qF "[$]FENCE"'
|
|
197
|
+
n_gate=$(grep -cE "$FENCE_PIPE_RE" "$GATE" || true)
|
|
198
|
+
printf ' if printf %s "$X" | grep -qF "$FENCE"; then\n' "'%s'" > "$TMPROOT/planted.sh"
|
|
199
|
+
n_plant=$(grep -cE "$FENCE_PIPE_RE" "$TMPROOT/planted.sh" || true)
|
|
200
|
+
if [ "${n_gate:-x}" = 0 ] && [ "${n_plant:-0}" = 1 ]; then ok "A15 no fence check reads a variable through a pipe (planted line caught)"
|
|
201
|
+
else bad "A15 pipe-form fence check" "gate=$n_gate planted=$n_plant"; fi
|
|
202
|
+
|
|
203
|
+
# A16 — the goldfish PROCESS does not inherit the description either (not only its prompt); the elephant's does
|
|
204
|
+
gate a16 FH_REVIEWER=fh FH_GATE_LEVEL=full FH_TASK_DESCRIPTION='AUTHOR-INTENT-7Q'
|
|
205
|
+
if [ "$(cat "$TMPROOT/a16/claude_abs.env" 2>/dev/null)" = '<unset>' ] && [ "$(cat "$TMPROOT/a16/claude_ele.env" 2>/dev/null)" = 'AUTHOR-INTENT-7Q' ]; then
|
|
206
|
+
ok "A16 the goldfish process does not inherit FH_TASK_DESCRIPTION; the elephant's does"
|
|
207
|
+
else bad "A16 goldfish env" "abs=$(cat "$TMPROOT/a16/claude_abs.env" 2>/dev/null) ele=$(cat "$TMPROOT/a16/claude_ele.env" 2>/dev/null)"; fi
|
|
208
|
+
|
|
209
|
+
# A17 — the change's diff cannot be computed (base missing) → a B, so the review cannot come back PASS
|
|
210
|
+
gate a17 FH_REVIEWER=fh FH_GATE_BASE=no-such-ref
|
|
211
|
+
if [ "$RC" -eq 1 ] && has a17 'NO CHANGE DIFF' && has a17 'location: "(diff)"'; then ok "A17 no change diff → B and said on the reviewer line"
|
|
212
|
+
else bad "A17 diff failure" "rc=$RC $(grep -E 'REVIEWER|VERDICT' "$TMPROOT/a17.out" | tr '\n' '|')"; fi
|
|
213
|
+
|
|
214
|
+
# A18 — a diff past 80000 bytes is truncated in the prompt, and both the prompt and the reviewer line say so
|
|
215
|
+
g -C "$REPO" checkout -q -b big feat
|
|
216
|
+
python3 -c 'import sys;sys.stdout.write("".join("line %d of a large change\n" % i for i in range(6000)))' > "$REPO/scripts/big.txt"
|
|
217
|
+
g -C "$REPO" add scripts/big.txt; g -C "$REPO" commit -qm "big change"
|
|
218
|
+
gate a18 FH_REVIEWER=fh FH_TARGET_FILES=scripts/foo.sh
|
|
219
|
+
g -C "$REPO" checkout -q feat
|
|
220
|
+
if logh a18 claude_abs.stdin 'TRUNCATED: 80000 of' && has a18 'diff truncated in the prompt'; then ok "A18 an oversized diff is truncated aloud (prompt + reviewer line)"
|
|
221
|
+
else bad "A18 truncation note" "$(grep REVIEWER "$TMPROOT/a18.out")"; fi
|
|
222
|
+
|
|
223
|
+
# A19 — codex writes two JSON values → not exactly one object → 10
|
|
224
|
+
gate a19 FH_BACKEND=codex FH_REVIEWER=fh FAKE_CODEX_TWICE=1
|
|
225
|
+
# (the ERR trap would also turn the later merge crash into 10 — check that the single-value guard is what fired)
|
|
226
|
+
if [ "$RC" -eq 10 ] && grep -qF 'not exactly one' "$TMPROOT/a19.err"; then ok "A19 codex output with two JSON values → 10, by the single-value guard"
|
|
227
|
+
else bad "A19 two values → 10 by the guard" "rc=$RC"; fi
|
|
228
|
+
|
|
229
|
+
# A20 — a CI-shaped checkout: a detached HEAD with no local base branch (actions/checkout on a pull request).
|
|
230
|
+
# Found 2026-11-20 on #1147: CI ran the regression lanes in such a checkout, `merge-base main HEAD` failed, the
|
|
231
|
+
# missing change diff became a B, and five clean-PASS lanes came back PENDING. Two rules are pinned:
|
|
232
|
+
# (a) the base falls back to the remote-tracking branch (origin/<base>) when the local branch is absent
|
|
233
|
+
# (b) when no base resolves at all, the missing diff is named, not graded, only for fh-legacy with the elephant
|
|
234
|
+
# off (that pass never reads it). The FH pass and /code-review stay graded B: they review the change.
|
|
235
|
+
C1="$TMPROOT/ci_with_remote"; g clone -q --no-local "$REPO" "$C1"; g -C "$C1" checkout -q --detach
|
|
236
|
+
C2="$TMPROOT/ci_single_branch"; g clone -q --no-local --single-branch --branch feat "$REPO" "$C2"; g -C "$C2" checkout -q --detach
|
|
237
|
+
RUN_DIR="$C1" gate a20a FH_REVIEWER=fh FH_TARGET_FILES=scripts/foo.sh
|
|
238
|
+
RUN_DIR="$C2" gate a20b FH_REVIEWER=fh-legacy FH_TARGET_FILES=scripts/foo.sh; rc_b=$RC
|
|
239
|
+
RUN_DIR="$C2" gate a20c FH_REVIEWER=code-review FH_TARGET_FILES=scripts/foo.sh; rc_c=$RC # /code-review, quick: no elephant
|
|
240
|
+
RUN_DIR="$C2" gate a20d FH_REVIEWER=fh FH_TARGET_FILES=scripts/foo.sh; rc_d=$RC
|
|
241
|
+
if grep -qF 'The change (git diff against' "$TMPROOT/a20a/claude_abs.stdin" 2>/dev/null \
|
|
242
|
+
&& grep -qF -- '-[ -n "$1" ] || exit 2' "$TMPROOT/a20a/claude_abs.stdin" 2>/dev/null \
|
|
243
|
+
&& ! has a20a 'NO CHANGE DIFF' && has a20a 'FH_GATE_VERDICT: PASS'; then
|
|
244
|
+
ok "A20a no local base branch → the change is diffed against origin/main, clean PASS stays PASS"
|
|
245
|
+
else bad "A20a origin/<base> fallback" "$(grep -E 'REVIEWER|VERDICT' "$TMPROOT/a20a.out" | tr '\n' '|')"; fi
|
|
246
|
+
if [ "$rc_b" -eq 0 ] && has a20b 'no change diff' && ! has a20b 'location: "(diff)"' \
|
|
247
|
+
&& [ "$rc_c" -eq 1 ] && has a20c 'NO CHANGE DIFF' && has a20c 'location: "(diff)"'; then
|
|
248
|
+
ok "A20b no base at all → fh-legacy keeps a clean PASS and names the gap; /code-review stays B"
|
|
249
|
+
else bad "A20b no base: legacy named, /code-review graded" "legacy rc=$rc_b cr rc=$rc_c $(grep REVIEWER "$TMPROOT/a20b.out" "$TMPROOT/a20c.out" | tr '\n' '|')"; fi
|
|
250
|
+
if [ "$rc_d" -eq 1 ] && has a20d 'NO CHANGE DIFF' && has a20d 'location: "(diff)"'; then
|
|
251
|
+
ok "A20c no base at all → the FH pass (which reads the diff) still cannot come back PASS"
|
|
252
|
+
else bad "A20c FH pass without its diff" "rc=$rc_d $(grep -E 'REVIEWER|VERDICT' "$TMPROOT/a20d.out" | tr '\n' '|')"; fi
|
|
253
|
+
|
|
254
|
+
echo "absorb lanes: $pass passed, $fail failed"
|
|
255
|
+
[ "$fail" -eq 0 ]
|
|
@@ -0,0 +1,169 @@
|
|
|
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
|
+
# D7 action.yml does not put FH_TIMEOUT in the step env; it exports it only when the `timeout` input (default '') is non-empty
|
|
20
|
+
# (known pair: the shipped file passes; a planted «FH_TIMEOUT: ${{ inputs.timeout }}» env line is caught)
|
|
21
|
+
# Token-free: claude and codex are stubs that answer by request kind and log what they were asked.
|
|
22
|
+
set -uo pipefail
|
|
23
|
+
. "$(dirname "${BASH_SOURCE[0]}")/fixture_guard_lib.sh"
|
|
24
|
+
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
25
|
+
GATE="$HERE/fh-gate.sh"; ACTION="$HERE/../action.yml"
|
|
26
|
+
TMPROOT=$(mktemp -d "${TMPDIR:-/tmp}/fh_gate_defaults_XXXXXX")
|
|
27
|
+
trap 'rm -rf "$TMPROOT"' EXIT
|
|
28
|
+
export FH_RECORD_BASE="$TMPROOT/records"; mkdir -p "$FH_RECORD_BASE"
|
|
29
|
+
unset FH_REVIEWER FH_GATE_ELEPHANT FH_GATE_EXEC FH_TIMEOUT FH_GATE_LEVEL
|
|
30
|
+
pass=0; fail=0
|
|
31
|
+
ok() { printf 'PASS %s\n' "$1"; pass=$((pass + 1)); }
|
|
32
|
+
bad() { printf 'FAIL %s — %s\n' "$1" "$2"; fail=$((fail + 1)); }
|
|
33
|
+
g() { git -c user.name=t -c user.email=t@t -c commit.gpgsign=false -c core.hooksPath=/dev/null "$@"; }
|
|
34
|
+
|
|
35
|
+
FAKEBIN="$TMPROOT/bin"; mkdir -p "$FAKEBIN"
|
|
36
|
+
cat > "$FAKEBIN/claude" <<'FAKE'
|
|
37
|
+
#!/usr/bin/env bash
|
|
38
|
+
in=$(cat); args=" $* "; kind=legacy
|
|
39
|
+
case "$args" in *"/code-review "*) kind=cr ;; esac
|
|
40
|
+
case "$in" in *"FH ELEPHANT PASS"*) kind=ele ;; *"FH REVIEW PASS"*) kind=abs ;; esac
|
|
41
|
+
: > "${LOGDIR:-/tmp}/claude_${kind}.called"
|
|
42
|
+
printf '%s\n' "$@" > "${LOGDIR:-/tmp}/claude_${kind}.args"; env > "${LOGDIR:-/tmp}/claude_${kind}.env"
|
|
43
|
+
empty='{"status":"SUCCESS","findings":[]}'
|
|
44
|
+
case "$kind" in legacy) p="$FAKE_PAYLOAD" ;; *) p="$empty" ;; esac
|
|
45
|
+
printf '{"is_error":false,"subtype":"success","structured_output":%s}\n' "$p"
|
|
46
|
+
FAKE
|
|
47
|
+
cat > "$FAKEBIN/codex" <<'FAKE'
|
|
48
|
+
#!/usr/bin/env bash
|
|
49
|
+
out=""; while [ $# -gt 0 ]; do case "$1" in -o) out="$2"; shift 2 ;; *) shift ;; esac; done
|
|
50
|
+
in=$(cat); kind=legacy
|
|
51
|
+
case "$in" in *"FH ELEPHANT PASS"*) kind=ele ;; *"FH REVIEW PASS"*) kind=abs ;; esac
|
|
52
|
+
: > "${LOGDIR:-/tmp}/codex_${kind}.called"
|
|
53
|
+
empty='{"status":"SUCCESS","findings":[]}'
|
|
54
|
+
case "$kind" in legacy) p="$FAKE_PAYLOAD" ;; *) p="$empty" ;; esac
|
|
55
|
+
[ -n "$out" ] && printf '%s' "$p" > "$out"
|
|
56
|
+
exit 0
|
|
57
|
+
FAKE
|
|
58
|
+
chmod +x "$FAKEBIN/claude" "$FAKEBIN/codex"
|
|
59
|
+
export PATH="$FAKEBIN:$PATH"
|
|
60
|
+
export FAKE_PAYLOAD='{"status":"SUCCESS","verdict":"PASS","findings_count":0,"findings_a":0,"findings_b":0,"findings":[]}'
|
|
61
|
+
|
|
62
|
+
REPO="$TMPROOT/repo"; mkdir -p "$REPO/scripts"
|
|
63
|
+
g -C "$REPO" init -q -b main
|
|
64
|
+
printf '#!/usr/bin/env bash\necho ok\n' > "$REPO/scripts/foo.sh"; g -C "$REPO" add -A; g -C "$REPO" commit -qm "add foo"
|
|
65
|
+
g -C "$REPO" checkout -qb feat
|
|
66
|
+
printf '#!/usr/bin/env bash\necho ok two\n' > "$REPO/scripts/foo.sh"; g -C "$REPO" commit -qam "change foo"
|
|
67
|
+
|
|
68
|
+
gate() { # gate <name> [env...]
|
|
69
|
+
local name="$1"; shift
|
|
70
|
+
mkdir -p "$TMPROOT/$name"
|
|
71
|
+
( cd "$REPO" && env LOGDIR="$TMPROOT/$name" "$@" bash "$GATE" ) > "$TMPROOT/$name.out" 2> "$TMPROOT/$name.err" < /dev/null
|
|
72
|
+
RC=$?
|
|
73
|
+
}
|
|
74
|
+
has() { grep -qF -- "$2" "$TMPROOT/$1.out"; }
|
|
75
|
+
called() { [ -e "$TMPROOT/$1/$2.called" ]; }
|
|
76
|
+
|
|
77
|
+
gate d1 FH_GATE_LEVEL=full
|
|
78
|
+
if [ "$RC" -eq 0 ] && has d1 'FH_GATE_REVIEWER: fh-legacy' && called d1 claude_legacy && ! called d1 claude_cr \
|
|
79
|
+
&& ! called d1 claude_abs && ! called d1 claude_ele && has d1 'FH_GATE_E1: not-run — NOT RUN (off by default' \
|
|
80
|
+
&& has d1 'FH_GATE_ELEPHANT: not-run — NOT RUN (off by default'; then
|
|
81
|
+
ok "D1 claude, nothing set, level full → fh-legacy · no /code-review · no elephant · E1 off by default"
|
|
82
|
+
else bad "D1 claude defaults" "rc=$RC $(grep -E 'REVIEWER|ELEPHANT|E1' "$TMPROOT/d1.out" | tr '\n' '|') calls=$(ls "$TMPROOT/d1" | tr '\n' ' ')"; fi
|
|
83
|
+
|
|
84
|
+
gate d2 FH_BACKEND=codex
|
|
85
|
+
if [ "$RC" -eq 0 ] && has d2 'FH_GATE_REVIEWER: fh-legacy' && ! has d2 'fallback' && called d2 codex_legacy && ! called d2 codex_abs; then
|
|
86
|
+
ok "D2 codex, nothing set → fh-legacy, not the absorbed pass, not labelled fallback"
|
|
87
|
+
else bad "D2 codex default" "rc=$RC $(grep REVIEWER "$TMPROOT/d2.out") calls=$(ls "$TMPROOT/d2" | tr '\n' ' ')"; fi
|
|
88
|
+
|
|
89
|
+
gate d3 FH_REVIEWER=code-review
|
|
90
|
+
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"
|
|
91
|
+
else bad "D3 code-review opt-in" "rc=$RC $(grep REVIEWER "$TMPROOT/d3.out") calls=$(ls "$TMPROOT/d3" | tr '\n' ' ')"; fi
|
|
92
|
+
|
|
93
|
+
gate d4 FH_REVIEWER=fh
|
|
94
|
+
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"
|
|
95
|
+
else bad "D4 fh opt-in" "rc=$RC $(grep REVIEWER "$TMPROOT/d4.out") calls=$(ls "$TMPROOT/d4" | tr '\n' ' ')"; fi
|
|
96
|
+
|
|
97
|
+
gate d5 FH_GATE_LEVEL=full FH_GATE_ELEPHANT=auto
|
|
98
|
+
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"
|
|
99
|
+
else bad "D5 elephant opt-in" "rc=$RC $(grep ELEPHANT "$TMPROOT/d5.out") calls=$(ls "$TMPROOT/d5" | tr '\n' ' ')"; fi
|
|
100
|
+
|
|
101
|
+
gate d6 FH_GATE_EXEC=on
|
|
102
|
+
grep '^FH_GATE_E1: ' "$TMPROOT/d6.out" > "$TMPROOT/d6.e1" 2>/dev/null
|
|
103
|
+
# the layer ran: E0 says «ran» (the fixture has no target lane, so E1 legitimately says «no target lane found»)
|
|
104
|
+
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»"
|
|
105
|
+
else bad "D6 exec opt-in" "rc=$RC $(grep -E '^FH_GATE_E[01]' "$TMPROOT/d6.out" | tr '\n' '|')"; fi
|
|
106
|
+
|
|
107
|
+
# D8 — cross with nothing set: the legs report the execution layer «off by default», not «FH_GATE_EXEC=off»
|
|
108
|
+
gate d8 FH_BACKEND=cross FH_GATE_CROSS_ALLOW_SINGLE=1
|
|
109
|
+
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
|
|
110
|
+
ok "D8 cross, nothing set → the legs say the execution layer is off by default"
|
|
111
|
+
else bad "D8 cross defaults" "rc=$RC $(grep -E 'E1' "$TMPROOT/d8.out" | tr '\n' '|')"; fi
|
|
112
|
+
|
|
113
|
+
# D9 — --help states the default reviewer the code applies (Area B 3.45.0: --help still said /code-review)
|
|
114
|
+
bash "$GATE" --help > "$TMPROOT/help.out" 2>&1
|
|
115
|
+
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
|
|
116
|
+
ok "D9 --help names fh-legacy as the default reviewer"
|
|
117
|
+
else bad "D9 --help default reviewer" "$(grep -m2 -F 'FH_REVIEWER' "$TMPROOT/help.out" | tr '\n' '|')"; fi
|
|
118
|
+
|
|
119
|
+
# D10 — the goldfish (FH_REVIEWER=fh) and elephant passes get exactly Read/Glob/Grep: the built-in set limited by
|
|
120
|
+
# --tools, no MCP server (--strict-mcp-config), no skill or command (--disable-slash-commands), and shells and
|
|
121
|
+
# writers denied. An allow list alone is additive (settings, MCP write tools, skills, PowerShell stay reachable),
|
|
122
|
+
# and git's read commands write files through --output=. The whole policy is asserted, not one token of it.
|
|
123
|
+
# Known pair: on the 3.45.0 merge (7c5a6b7) both calls allow Bash(git diff:*) and carry none of the three flags.
|
|
124
|
+
argv_after() { awk -v f="$2" 'p{print; exit} $0==f{p=1}' "$1"; }
|
|
125
|
+
has_flag() { grep -qxF -- "$2" "$1"; }
|
|
126
|
+
policy_ok() { # policy_ok <args file> — prints what is wrong, nothing when the policy holds
|
|
127
|
+
local a="$1" t al d need
|
|
128
|
+
[ -s "$a" ] || { echo "no call recorded"; return; }
|
|
129
|
+
t=$(argv_after "$a" --tools); al=$(argv_after "$a" --allowedTools); d=$(argv_after "$a" --disallowedTools)
|
|
130
|
+
[ "$t" = "Read,Glob,Grep" ] || echo "tools=[$t]"
|
|
131
|
+
[ "$al" = "Read,Glob,Grep" ] || echo "allow=[$al]"
|
|
132
|
+
for need in Bash PowerShell Write Edit NotebookEdit WebFetch WebSearch; do [[ ",$d," == *",$need,"* ]] || echo "deny lacks $need"; done
|
|
133
|
+
has_flag "$a" --strict-mcp-config || echo "no --strict-mcp-config"
|
|
134
|
+
has_flag "$a" --disable-slash-commands || echo "no --disable-slash-commands"
|
|
135
|
+
! has_flag "$a" --mcp-config || echo "an --mcp-config was passed"
|
|
136
|
+
}
|
|
137
|
+
gate d10 FH_REVIEWER=fh FH_GATE_ELEPHANT=on
|
|
138
|
+
p_abs=$(policy_ok "$TMPROOT/d10/claude_abs.args" | tr '\n' ' '); p_ele=$(policy_ok "$TMPROOT/d10/claude_ele.args" | tr '\n' ' ')
|
|
139
|
+
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"
|
|
140
|
+
else bad "D10 reviewer tool policy" "rc=$RC goldfish: ${p_abs:-ok} · elephant: ${p_ele:-ok}"; fi
|
|
141
|
+
# D10b — the checker itself sees a planted widening (control: one extra allowed tool on an otherwise good call)
|
|
142
|
+
printf '%s\n' --tools Read,Glob,Grep --strict-mcp-config --disable-slash-commands --allowedTools Read,Glob,Grep,Write \
|
|
143
|
+
--disallowedTools Bash,PowerShell,Write,Edit,NotebookEdit,WebFetch,WebSearch > "$TMPROOT/planted.args"
|
|
144
|
+
[ -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"
|
|
145
|
+
|
|
146
|
+
# D11 — /code-review keeps git (it needs it), so its call runs without the runner's five command-file variables.
|
|
147
|
+
# (This only removes the direct reference — the path stays labelled not read-only.)
|
|
148
|
+
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"
|
|
149
|
+
if [ "$RC" -eq 0 ] && [ -s "$TMPROOT/d11/claude_cr.env" ] && ! grep -qE '^GITHUB_(ENV|PATH|OUTPUT|STATE|STEP_SUMMARY)=' "$TMPROOT/d11/claude_cr.env" \
|
|
150
|
+
&& [[ "$(argv_after "$TMPROOT/d11/claude_cr.args" --allowedTools)" == *"Bash(git diff:*)"* ]]; then
|
|
151
|
+
ok "D11 /code-review call: git kept, none of the five GITHUB_* command-file variables in its environment"
|
|
152
|
+
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
|
|
153
|
+
|
|
154
|
+
# D7 — action.yml's step env must not carry FH_TIMEOUT; the run block exports it only from a non-empty input.
|
|
155
|
+
envblock() { awk '/^ *env: *$/{e=1; next} e && /^ *run: *\|/{exit} e{print}' "$1"; }
|
|
156
|
+
if [ -r "$ACTION" ]; then
|
|
157
|
+
envblock "$ACTION" > "$TMPROOT/env_shipped"
|
|
158
|
+
sed 's/^\( *\)FH_CALLER: github-action$/\1FH_CALLER: github-action\n\1FH_TIMEOUT: ${{ inputs.timeout }}/' "$ACTION" > "$TMPROOT/action_planted.yml"
|
|
159
|
+
envblock "$TMPROOT/action_planted.yml" > "$TMPROOT/env_planted"
|
|
160
|
+
n_ship=$(grep -cE '^ *FH_TIMEOUT:' "$TMPROOT/env_shipped"); n_plant=$(grep -cE '^ *FH_TIMEOUT:' "$TMPROOT/env_planted")
|
|
161
|
+
if [ -s "$TMPROOT/env_shipped" ] && [ "$n_ship" = 0 ] && [ "$n_plant" = 1 ] \
|
|
162
|
+
&& grep -qF 'if [ -n "${FH_ACTION_TIMEOUT:-}" ]; then export FH_TIMEOUT="$FH_ACTION_TIMEOUT"; fi' "$ACTION" \
|
|
163
|
+
&& grep -qE "^ *default: ''" <<<"$(awk '/^ timeout:/{f=1} f&&/default:/{print; exit}' "$ACTION")"; then
|
|
164
|
+
ok "D7 action.yml: FH_TIMEOUT only from a non-empty timeout input (a planted env line is caught)"
|
|
165
|
+
else bad "D7 action timeout pass-through" "env lines with FH_TIMEOUT: shipped=$n_ship planted=$n_plant"; fi
|
|
166
|
+
else bad "D7 action timeout pass-through" "action.yml not readable at $ACTION (not measured)"; fi
|
|
167
|
+
|
|
168
|
+
echo "fh-gate defaults lanes: $pass passed, $fail failed"
|
|
169
|
+
[ "$fail" -eq 0 ]
|