@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,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 "────────────────────────────────────────────────────────────────────"
@@ -28,8 +28,8 @@ mkdir -p "$FIX/bin" "$FIX/work"
28
28
  # --- git shim: real enough to pass the GIT_OK probe, scriptable for diff/status -------------
29
29
  cat > "$FIX/bin/git" <<'GIT'
30
30
  #!/usr/bin/env bash
31
- # args may be prefixed with -C <dir>
32
- while [[ "${1:-}" == "-C" ]]; do shift 2; done
31
+ # args may be prefixed with -C <dir> and -c <key=value> (fh-goal passes -c core.quotePath=false)
32
+ while [[ "${1:-}" == "-C" || "${1:-}" == "-c" ]]; do shift 2; done
33
33
  case "${1:-}" in
34
34
  rev-parse)
35
35
  case "${2:-}" in
@@ -40,7 +40,8 @@ case "${1:-}" in
40
40
  diff) exit "${FAKE_GIT_DIFF_RC:-0}" ;;
41
41
  status)
42
42
  if [[ "${FAKE_GIT_STATUS_RC:-0}" -ne 0 ]]; then exit "${FAKE_GIT_STATUS_RC}"; fi
43
- [[ -n "${FAKE_GIT_STATUS_OUT:-}" ]] && printf '%s\n' "$FAKE_GIT_STATUS_OUT"
43
+ # fh-goal asks for `status --porcelain -z` (AQ-20261119-8): entries are NUL-terminated, as real git prints them
44
+ [[ -n "${FAKE_GIT_STATUS_OUT:-}" ]] && printf '%s\0' "$FAKE_GIT_STATUS_OUT"
44
45
  exit 0 ;;
45
46
  esac
46
47
  exit 0
@@ -86,5 +87,104 @@ else
86
87
  sed -n 1,6p "$FIX/err" | sed 's/^/ /'
87
88
  fi
88
89
 
90
+ # ARM D — real git, a Korean-named untracked file: fh-goal must hand fh-gate the name itself, not git's quoted
91
+ # octal form («"\355\225…"») — 2026-11-19, the same defect fh-gate had with core.quotePath.
92
+ if command -v git >/dev/null 2>&1; then
93
+ mkdir -p "$FIX/realbin" "$FIX/realwork"; cp "$FIX/bin/codex" "$FIX/realbin/codex"
94
+ git -C "$FIX/realwork" init -q; echo seed > "$FIX/realwork/README" # a HEAD for fh-goal's diff to start from
95
+ git -C "$FIX/realwork" add README; git -C "$FIX/realwork" -c user.name=lane -c user.email=lane@example.invalid commit -qm seed
96
+ echo "본문" > "$FIX/realwork/한글문서.md"
97
+ # run from inside the scratch repo: fh-goal takes the work tree from the caller's folder
98
+ ( cd "$FIX/realwork" && env PATH="$FIX/realbin:$PATH" FH_BACKEND=codex FH_TIMEOUT=20 \
99
+ bash "$TARGET" --prompt "noop" --root "$FIX/realwork" ) >"$FIX/out" 2>"$FIX/err"
100
+ if grep -qF "running fh-gate on 한글문서.md" "$FIX/err"; then
101
+ ok "ARM D real git: a Korean file name reaches fh-gate as itself"
102
+ else
103
+ no "ARM D real git: the Korean name did not reach fh-gate as itself"
104
+ grep -m2 "running fh-gate on\|no changed files" "$FIX/err" | sed 's/^/ /'
105
+ fi
106
+ else
107
+ echo " ⬜ ARM D NOT RUN: no git on PATH — not a pass"
108
+ fi
109
+
110
+ # ARM E — real git, untracked names with a quote and a space (AQ-20261119-8). The old path joined names with
111
+ # `xargs`, which aborts on an unmatched quote; `|| true` folded that into an empty list → «no changed files
112
+ # detected» → exit 0, fh-gate never ran. Now: NUL-delimited listing, newline-delimited hand-off to fh-gate.
113
+ if command -v git >/dev/null 2>&1; then
114
+ mkdir -p "$FIX/realwork2"
115
+ git -C "$FIX/realwork2" init -q; echo seed > "$FIX/realwork2/README"
116
+ git -C "$FIX/realwork2" add README; git -C "$FIX/realwork2" -c user.name=lane -c user.email=lane@example.invalid commit -qm seed
117
+ echo q > "$FIX/realwork2/it's here.md"
118
+ ( cd "$FIX/realwork2" && env PATH="$FIX/realbin:$PATH" FH_BACKEND=codex FH_TIMEOUT=20 \
119
+ bash "$TARGET" --prompt "noop" --root "$FIX/realwork2" ) >"$FIX/out" 2>"$FIX/err"
120
+ if grep -qF "running fh-gate on it's here.md" "$FIX/err" && ! grep -q "review is partial\|could be read" "$FIX/err"; then
121
+ ok "ARM E real git: a name with a quote and a space reaches fh-gate whole and is read"
122
+ else
123
+ no "ARM E real git: the quoted/spaced name did not reach fh-gate whole"
124
+ grep -m3 "running fh-gate on\|no changed files\|partial\|could be read" "$FIX/err" | sed 's/^/ /'
125
+ fi
126
+ else
127
+ echo " ⬜ ARM E NOT RUN: no git on PATH — not a pass"
128
+ fi
129
+
130
+ # ARM F — real git, a staged rename: with `status --porcelain -z` the OLD path follows as its own field and must
131
+ # be skipped, not handed to fh-gate as a second (missing) target. Guards the new skip logic only — the old sed
132
+ # path also got renames right, so this arm is green on the pre-fix script too.
133
+ if command -v git >/dev/null 2>&1; then
134
+ mkdir -p "$FIX/realwork3"
135
+ git -C "$FIX/realwork3" init -q; echo seed > "$FIX/realwork3/old name.md"
136
+ git -C "$FIX/realwork3" add .; git -C "$FIX/realwork3" -c user.name=lane -c user.email=lane@example.invalid commit -qm seed
137
+ git -C "$FIX/realwork3" mv "old name.md" "new name.md"
138
+ ( cd "$FIX/realwork3" && env PATH="$FIX/realbin:$PATH" FH_BACKEND=codex FH_TIMEOUT=20 \
139
+ bash "$TARGET" --prompt "noop" --root "$FIX/realwork3" ) >"$FIX/out" 2>"$FIX/err"
140
+ if grep -qxF "→ fh-goal: running fh-gate on new name.md" "$FIX/err"; then
141
+ ok "ARM F real git: a rename hands fh-gate the new path only"
142
+ else
143
+ no "ARM F real git: a rename did not hand fh-gate exactly the new path"
144
+ grep -m2 "running fh-gate on\|no changed files" "$FIX/err" | sed 's/^/ /'
145
+ fi
146
+ else
147
+ echo " ⬜ ARM F NOT RUN: no git on PATH — not a pass"
148
+ fi
149
+
150
+ # ARM G — real git, the only change is a name holding a newline: it cannot travel to fh-gate, and an empty list
151
+ # must not become «no changed files» → exit 0. Must exit 10.
152
+ if command -v git >/dev/null 2>&1; then
153
+ mkdir -p "$FIX/realwork4"
154
+ git -C "$FIX/realwork4" init -q; echo seed > "$FIX/realwork4/README"
155
+ git -C "$FIX/realwork4" add README; git -C "$FIX/realwork4" -c user.name=lane -c user.email=lane@example.invalid commit -qm seed
156
+ printf 'n\n' > "$FIX/realwork4/new
157
+ line.md"
158
+ ( cd "$FIX/realwork4" && env PATH="$FIX/realbin:$PATH" FH_BACKEND=codex FH_TIMEOUT=20 \
159
+ bash "$TARGET" --prompt "noop" --root "$FIX/realwork4" ) >"$FIX/out" 2>"$FIX/err"; RC=$?
160
+ if [[ "$RC" == "10" ]] && grep -q "holds a newline" "$FIX/err"; then
161
+ ok "ARM G real git: a newline-only change fails closed (exit 10), not «no changed files»"
162
+ else
163
+ no "ARM G real git: a newline-only change gave rc=$RC"
164
+ grep -m2 "running fh-gate on\|no changed files\|newline" "$FIX/err" | sed 's/^/ /'
165
+ fi
166
+ else
167
+ echo " ⬜ ARM G NOT RUN: no git on PATH — not a pass"
168
+ fi
169
+
170
+ # ARM H — real git, a newline-named file BESIDE a normal one: fh-gate would review only the normal one and its
171
+ # verdict would read as the whole change. Must exit 10 before fh-gate runs (security review 2026-11-20).
172
+ if command -v git >/dev/null 2>&1; then
173
+ mkdir -p "$FIX/realwork5"
174
+ git -C "$FIX/realwork5" init -q; echo seed > "$FIX/realwork5/README"
175
+ git -C "$FIX/realwork5" add README; git -C "$FIX/realwork5" -c user.name=lane -c user.email=lane@example.invalid commit -qm seed
176
+ printf 'n\n' > "$FIX/realwork5/new
177
+ line.md"; echo two > "$FIX/realwork5/README"
178
+ ( cd "$FIX/realwork5" && env PATH="$FIX/realbin:$PATH" FH_BACKEND=codex FH_TIMEOUT=20 \
179
+ bash "$TARGET" --prompt "noop" --root "$FIX/realwork5" ) >"$FIX/out" 2>"$FIX/err"; RC=$?
180
+ if [[ "$RC" == "10" ]] && grep -q "would review only the rest" "$FIX/err" && ! grep -q "running fh-gate on" "$FIX/err"; then
181
+ ok "ARM H real git: a newline name beside a normal change fails closed (exit 10) before fh-gate runs"
182
+ else
183
+ no "ARM H real git: a newline name beside a normal change gave rc=$RC"
184
+ fi
185
+ else
186
+ echo " ⬜ ARM H NOT RUN: no git on PATH — not a pass"
187
+ fi
188
+
89
189
  echo "fh-goal change-detection: $PASS passed, $FAIL failed"
90
190
  [[ "$FAIL" -eq 0 ]] || exit 1
@@ -28,6 +28,11 @@ OUT=$(bash "$HERE/finding_fleet.sh" --selftest 2>&1); RC=$?
28
28
 
29
29
  D="$(mktemp -d 2>/dev/null)" || D=""
30
30
  [ -n "$D" ] && [ -w "$D" ] || { no "L3 환경" "mktemp -d 불가 — 레인 미측정(통과 아님)"; echo "PASS=$PASS FAIL=$FAIL"; echo "FAILED=1"; exit 1; }
31
+ # Work from the lane's own folder, never from the checkout (pmh-dev #106). codex_launch_guard.sh refuses a launch
32
+ # whose working folder is a configured company-repo root, and a company checkout lists itself there — so every stub
33
+ # pipeline below was refused when the suite ran from the checkout root (7 lanes red). The roots list stays as
34
+ # configured: the guard keeps refusing a company working folder, a company path in a prompt or an argument (L128).
35
+ cd "$D" || { no "L3 환경" "레인 작업 폴더로 이동 불가 — 레인 미측정(통과 아님)"; echo "PASS=$PASS FAIL=$FAIL"; echo "FAILED=1"; exit 1; }
31
36
 
32
37
  cat > "$D/f.jsonl" <<'EOS'
33
38
  {"id":"a1","title":"real defect","file":"x.py","line":3,"severity":"A","producer_family":"alpha"}
@@ -2093,6 +2098,35 @@ else
2093
2098
  no "L127 맨 앞 한 발견 철회" "failed:$r127"
2094
2099
  fi
2095
2100
 
2096
- /bin/rm -rf "$D"
2101
+ # L128 (pmh-dev #106) — with the checkout listed as a company root (through a roots FILE, the way a company checkout
2102
+ # configures it), a stub pipeline runs from the lane's folder, and the same stub launched from the checkout itself is
2103
+ # still refused. Known pair: a fix that blanks the list or skips the guard for stub binaries passes (a) but fails (b);
2104
+ # the unfixed suite (run from the checkout) fails (a).
2105
+ REPO_ROOT="$(cd "$HERE/.." && pwd -P)"
2106
+ printf '%s\n' "$REPO_ROOT" > "$D/roots128"
2107
+ V128=$(env -u FH_COMPANY_ROOTS FH_COMPANY_ROOTS_FILE="$D/roots128" FH_CODEX_BIN="$D/fake_ok.sh" bash "$VERIFIER" --family codex --target "$D/tgt.py" < "$D/f.jsonl" 2>"$D/e128a"); R128A=$?
2108
+ N128=$(printf '%s\n' "$V128" | grep -c '^{')
2109
+ ( cd "$REPO_ROOT" && env -u FH_COMPANY_ROOTS FH_COMPANY_ROOTS_FILE="$D/roots128" FH_CODEX_BIN="$D/fake_ok.sh" bash "$VERIFIER" --family codex --target "$D/tgt.py" < "$D/f.jsonl" ) >/dev/null 2>"$D/e128b"; R128B=$?
2110
+ if [ "$R128A" -eq 0 ] && [ "$N128" = 2 ] && [ "$R128B" -ne 0 ] && grep -q 'CODEX-REFUSED' "$D/e128b"; then
2111
+ ok "L128 회사 루트로 등록된 체크아웃(목록 파일): 레인 폴더의 스텁 파이프라인은 돈다 · 체크아웃 안에서 띄운 같은 스텁은 여전히 거부 (가드 무장 유지)"
2112
+ else
2113
+ no "L128 회사 루트 + 레인 폴더" "lane-folder rc=$R128A n=$N128 · checkout rc=$R128B · $(grep -m1 -E 'CODEX|HARNESS' "$D/e128a" "$D/e128b" | tr '\n' ' ')"
2114
+ fi
2115
+ # L129 — the suite itself never re-points or blanks the roots configuration (cross-family R1: L128 alone would not
2116
+ # catch a suite-wide FH_COMPANY_ROOTS_FILE=/dev/null). Shape check over this file: an assignment or export of either
2117
+ # variable is allowed only inside L128's own `env ... FH_COMPANY_ROOTS_FILE="$D/roots128"` prefixes. Planted line = known positive.
2118
+ SELF129="$HERE/$(basename "${BASH_SOURCE[0]}")" # absolute: the suite has cd-ed into its lane folder, so $0 may no longer resolve
2119
+ ROOTS_ASSIGN_RE='(^|[^A-Za-z_])(export[[:space:]]+|unset[[:space:]]+|declare[^=]*[[:space:]])?FH_COMPANY_ROOTS(_FILE)?([=[:space:]]|$)'
2120
+ grep -vF -e 'roots128' -e 'planted129' "$SELF129" > "$D/self129a" 2>/dev/null
2121
+ grep -v -e '^ *#' -e 'ROOTS_ASSIGN_RE=' "$D/self129a" > "$D/self129b"
2122
+ grep -nE "$ROOTS_ASSIGN_RE" "$D/self129b" > "$D/hits129"
2123
+ n129=$(wc -l < "$D/hits129" | tr -d ' ')
2124
+ printf 'export FH_COMPANY_ROOTS_FILE=/dev/null\n' > "$D/planted129.sh"
2125
+ grep -E "$ROOTS_ASSIGN_RE" "$D/planted129.sh" > "$D/phits129"
2126
+ p129=$(wc -l < "$D/phits129" | tr -d ' ')
2127
+ if [ -r "$SELF129" ] && [ -s "$D/self129a" ] && [ "${n129:-x}" = 0 ] && [ "${p129:-0}" = 1 ]; then ok "L129 이 스위트는 회사 루트 설정(FH_COMPANY_ROOTS[_FILE])을 L128 밖에서 바꾸지 않는다 (심은 줄은 잡힘)"
2128
+ else no "L129 루트 설정 바꿔치기" "self=$SELF129 suite=$n129 planted=$p129 · $(sed -n '1,2p' "$D/hits129" | tr '\n' ' ')"; fi
2129
+
2130
+ cd / && /bin/rm -rf "$D"
2097
2131
  echo "PASS=$PASS FAIL=$FAIL"
2098
2132
  [ "$FAIL" -eq 0 ] && { echo "FAILED=0"; exit 0; } || { echo "FAILED=1"; exit 1; }
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env bash
2
+ # test_guard_anchor_override_env_lanes.sh — the two guard anchors must measure the hook as it behaves by default,
3
+ # whatever override the calling shell has exported.
4
+ #
5
+ # Why (2026-11-15, reported from a field harness intake, pmh-dev #91 item 2): the pre-commit hook calls
6
+ # universal_guard_check.sh with `env -u GIT_INDEX_FILE -u GIT_DIR -u GIT_WORK_TREE` but not `-u PUBLIC_SURFACE_OK`.
7
+ # A commit made with PUBLIC_SURFACE_OK=1 that stages the hook or the pattern source then runs the anchor with the
8
+ # override inherited: the hook under test lets its own planted leaks through, the anchor's known pairs break, and
9
+ # the commit is blocked for a reason that has nothing to do with the change. Measured on main 3572903:
10
+ # universal_guard_check.sh plain rc=0 · PUBLIC_SURFACE_OK=1 rc=1
11
+ # prepush_guard_check.sh plain rc=0 · PUBLIC_SURFACE_OK=1 rc=1
12
+ # The fix is inside each anchor (it unsets the hook overrides before building its sandbox), so every caller —
13
+ # the hook, selfcheck, CI, a person — gets the same verdict.
14
+ #
15
+ # Lanes:
16
+ # A1/P1 anchor with PUBLIC_SURFACE_OK=1 exported → rc 0 (the default-hook verdict)
17
+ # A2/P2 anchor with every other hook override exported at once → rc 0
18
+ # A3/P3 the two non-override inputs the pre-push hook reads (PSA_PATTERNS, FH_DESTRUCTIVE_BASE) → rc 0
19
+ # A4/P4 PSA_ALLOWLIST naming the anchors' own planted positive → rc 0
20
+ # A0/P0 control: the same anchor with no override → rc 0 (if this is red, the anchor is broken, not this lane)
21
+ # R1/R2 revert probes: a copy of each anchor with its unset line removed, PUBLIC_SURFACE_OK=1 → rc ≠ 0
22
+ # (proves A1/P1 are green because of the fix, not because the override stopped mattering)
23
+ # Exit 0 all lanes pass · 1 a lane failed · 2 harness error.
24
+ set -uo pipefail
25
+ source "$(dirname "$0")/fixture_guard_lib.sh" 2>/dev/null || { echo "HARNESS-ERROR: fixture_guard_lib.sh not found"; exit 2; }
26
+ ROOT=$(cd "$(dirname "$0")/.." 2>/dev/null && pwd) || { echo "HARNESS-ERROR: cannot resolve the repo root"; exit 2; }
27
+ cd "$ROOT" || exit 2
28
+ UG=scripts/universal_guard_check.sh; PG=scripts/prepush_guard_check.sh
29
+ for f in "$UG" "$PG"; do [ -f "$f" ] || { echo "HARNESS-ERROR: $f missing"; exit 2; }; done
30
+ OTHERS="DESTRUCTIVE_OP_OK=1 FH_NOVELTY_OK=1 MAIN_PUSH_OK=1 PUSH_ZONE_OK=1 TAG_VERSION_OK=1 TRACKS_GITLINK_OK=1 TRACKS_PUBLIC_OK=1"
31
+ pass=0; fail=0
32
+ lane() { # $1 id · $2 want (0 | nonzero) · $3… command
33
+ local id="$1" want="$2"; shift 2
34
+ local out rc; out=$("$@" 2>&1); rc=$?
35
+ if { [ "$want" = 0 ] && [ "$rc" -eq 0 ]; } || { [ "$want" = nonzero ] && [ "$rc" -ne 0 ]; }; then
36
+ pass=$((pass+1)); echo " ✅ $id (rc=$rc)"
37
+ else
38
+ fail=$((fail+1)); echo " ❌ $id — want rc $want, got rc=$rc"; printf '%s\n' "$out" | grep -E '❌' | head -4 | sed 's/^/ /'
39
+ fi
40
+ }
41
+ echo "guard-anchor override-env lanes"
42
+ lane A0 0 env -u PUBLIC_SURFACE_OK bash "$UG"
43
+ lane A1 0 env PUBLIC_SURFACE_OK=1 bash "$UG"
44
+ lane A2 0 env $OTHERS bash "$UG"
45
+ lane P0 0 env -u PUBLIC_SURFACE_OK bash "$PG"
46
+ lane P1 0 env PUBLIC_SURFACE_OK=1 bash "$PG"
47
+ lane P2 0 env $OTHERS bash "$PG"
48
+ # R1 revert probe — run the copy from the real scripts/ dir so its relative lookups resolve the same way.
49
+ lane A3 0 env PSA_PATTERNS=/dev/null FH_DESTRUCTIVE_BASE=HEAD bash "$UG"
50
+ lane P3 0 env PSA_PATTERNS=/dev/null FH_DESTRUCTIVE_BASE=HEAD bash "$PG"
51
+ AL=$(mktemp) || { echo "HARNESS-ERROR: mktemp"; exit 2; }
52
+ printf 'notes.md\tzzsynthoperator\n' > "$AL" # an allowlist row naming the anchors' own planted positive
53
+ lane A4 0 env PSA_ALLOWLIST="$AL" bash "$UG"
54
+ lane P4 0 env PSA_ALLOWLIST="$AL" bash "$PG"
55
+ RV="scripts/.rv_universal_guard_check_$$.sh"; RVP="scripts/.rv_prepush_guard_check_$$.sh"
56
+ trap 'rm -f "$RV" "$RVP" "$AL"' EXIT
57
+ # The revert runs start from a clean baseline (codex R2): the copy lacks the WHOLE fix line, so any inherited
58
+ # override or PSA_ input would otherwise turn its «plain» control red for a reason that is not the probe.
59
+ CLEAN_ENV="-u PUBLIC_SURFACE_OK -u DESTRUCTIVE_OP_OK -u FH_NOVELTY_OK -u MAIN_PUSH_OK -u PUSH_ZONE_OK -u TAG_VERSION_OK -u TRACKS_GITLINK_OK -u TRACKS_PUBLIC_OK -u FH_DESTRUCTIVE_BASE"
60
+ for _v in $(compgen -v | grep '^PSA_'); do CLEAN_ENV="$CLEAN_ENV -u $_v"; done
61
+ revert_probe() { # $1 id · $2 subject · $3 copy path
62
+ # A red copy proves the fix only if the copy is a working anchor minus exactly the unset line (codex R1):
63
+ # ① the copy was written and differs from the subject by exactly one removed line
64
+ # ② the copy is green with no override (it still runs and its pairs hold)
65
+ # ③ with PUBLIC_SURFACE_OK=1 it is red AND prints a known-pair ❌ line (a broken pair, not a crash)
66
+ local want_rm out rc
67
+ if ! grep -v '^unset .*PUBLIC_SURFACE_OK' "$2" > "$3" || [ ! -s "$3" ]; then
68
+ fail=$((fail+1)); echo " ❌ $1 — could not write the reverted copy"; return; fi
69
+ want_rm=$(diff "$2" "$3" | grep -c '^<')
70
+ if [ "$want_rm" -ne 1 ] || [ "$(diff "$2" "$3" | grep -c '^>')" -ne 0 ]; then
71
+ fail=$((fail+1)); echo " ❌ $1 — reverted copy differs by $want_rm removed line(s), want exactly 1"; return; fi
72
+ out=$(env $CLEAN_ENV bash "$3" 2>&1); rc=$?
73
+ if [ "$rc" -ne 0 ]; then fail=$((fail+1)); echo " ❌ $1 — reverted copy is red even without the override (rc=$rc) — it is not a working anchor"; return; fi
74
+ out=$(env $CLEAN_ENV PUBLIC_SURFACE_OK=1 bash "$3" 2>&1); rc=$?
75
+ if [ "$rc" -ne 0 ] && printf '%s\n' "$out" | grep -q '❌'; then
76
+ pass=$((pass+1)); echo " ✅ $1 (reverted copy: green plain · rc=$rc with the override, $(printf '%s\n' "$out" | grep -c '❌') ❌ line(s))"
77
+ else
78
+ fail=$((fail+1)); echo " ❌ $1 — reverted copy with the override: rc=$rc, ❌ lines $(printf '%s\n' "$out" | grep -c '❌') (want red with a known-pair line)"
79
+ fi
80
+ }
81
+ revert_probe R1 "$UG" "$RV"
82
+ revert_probe R2 "$PG" "$RVP"
83
+ echo "guard-anchor override-env lanes: $pass passed, $fail failed"
84
+ [ "$fail" -eq 0 ]