@chrono-meta/fh-gate 3.46.0 → 3.48.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 (36) hide show
  1. package/.claude/rules/fh_4axis_gate.md +1 -1
  2. package/.claude-plugin/marketplace.json +4 -4
  3. package/CHEATSHEET.md +2 -2
  4. package/README.ja.md +4 -0
  5. package/README.ko.md +22 -0
  6. package/README.md +24 -0
  7. package/README.zh.md +4 -0
  8. package/docs/codex-compat.md +4 -4
  9. package/knowledge/shared/harness-core/agents_md_runtime_details.md +2 -2
  10. package/knowledge/shared/harness-core/builtin_capability_map.md +6 -3
  11. package/knowledge/shared/harness-core/claude_md_full_reference.md +5 -1
  12. package/knowledge/shared/harness-core/fh_4axis_gate_detail.md +15 -0
  13. package/knowledge/shared/harness-core/fh_integration_contract.md +2 -2
  14. package/knowledge/shared/learnings/subagent_invocations_log.yaml +14 -0
  15. package/package.json +1 -1
  16. package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
  17. package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
  18. package/plugins/fh-meta/CHANGELOG.md +96 -0
  19. package/plugins/fh-meta/skills/frontier-digest/SKILL_detail.md +13 -7
  20. package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
  21. package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
  22. package/scripts/destructive_pre_gate.sh +170 -22
  23. package/scripts/fh-gate.sh +181 -22
  24. package/scripts/fh-goal.sh +17 -4
  25. package/scripts/fh-run.sh +17 -4
  26. package/scripts/test_action_yml_lanes.sh +162 -0
  27. package/scripts/test_destructive_pre_gate_lanes.sh +145 -3
  28. package/scripts/test_fh_gate_absorb_lanes.sh +1 -0
  29. package/scripts/test_fh_gate_defaults_lanes.sh +207 -0
  30. package/scripts/test_fh_gate_fusion_lanes.sh +1 -0
  31. package/scripts/test_fh_gate_regressions.sh +1 -0
  32. package/scripts/test_fh_goal_change_detection_lanes.sh +47 -0
  33. package/scripts/test_fh_run_resolver_lanes.sh +47 -0
  34. package/templates/predelete_check.sh +2 -0
  35. package/templates/predelete_check.test.sh +10 -0
  36. package/templates/settings.PreToolUse.snippet.json +6 -1
@@ -17,6 +17,11 @@
17
17
  # D10 FH_REVIEWER=fh and the elephant pass get exactly Read/Glob/Grep — no shell, no MCP, no skill (D10b: control)
18
18
  # D11 FH_REVIEWER=code-review keeps git but runs without the five GITHUB_* command-file variables
19
19
  # D12 run from a copy with no action.yml (package shape): D7 is SKIPPED by name — not a pass, not a fail
20
+ # D14 FH_REVIEWER=code-review loads user settings only, and its prompt comes after `--` (the real CLI reads it then)
21
+ # D15 every codex review call (default, goldfish, elephant) has --ignore-user-config before its prompt marker
22
+ # D17 codex with no FH_MODEL passes no -m (codex picks a model its login accepts); FH_MODEL=x passes -m x
23
+ # D16 a codex user config that names where requests go (model_provider other than openai, model_providers,
24
+ # openai_base_url, chatgpt_base_url) or cannot be read → exit 10, no codex call; a plain or absent config proceeds
20
25
  # D7 action.yml does not put FH_TIMEOUT in the step env; it exports it only when the `timeout` input (default '') is non-empty
21
26
  # (known pair: the shipped file passes; a planted «FH_TIMEOUT: ${{ inputs.timeout }}» env line is caught)
22
27
  # Token-free: claude and codex are stubs that answer by request kind and log what they were asked.
@@ -41,16 +46,22 @@ case "$args" in *"/code-review "*) kind=cr ;; esac
41
46
  case "$in" in *"FH ELEPHANT PASS"*) kind=ele ;; *"FH REVIEW PASS"*) kind=abs ;; esac
42
47
  : > "${LOGDIR:-/tmp}/claude_${kind}.called"
43
48
  printf '%s\n' "$@" > "${LOGDIR:-/tmp}/claude_${kind}.args"; env > "${LOGDIR:-/tmp}/claude_${kind}.env"
49
+ pwd -P > "${LOGDIR:-/tmp}/claude_${kind}.cwd"
44
50
  empty='{"status":"SUCCESS","findings":[]}'
45
51
  case "$kind" in legacy) p="$FAKE_PAYLOAD" ;; *) p="$empty" ;; esac
46
52
  printf '{"is_error":false,"subtype":"success","structured_output":%s}\n' "$p"
47
53
  FAKE
48
54
  cat > "$FAKEBIN/codex" <<'FAKE'
49
55
  #!/usr/bin/env bash
56
+ all=$(printf '%s\n' "$@")
50
57
  out=""; while [ $# -gt 0 ]; do case "$1" in -o) out="$2"; shift 2 ;; *) shift ;; esac; done
51
58
  in=$(cat); kind=legacy
52
59
  case "$in" in *"FH ELEPHANT PASS"*) kind=ele ;; *"FH REVIEW PASS"*) kind=abs ;; esac
53
60
  : > "${LOGDIR:-/tmp}/codex_${kind}.called"
61
+ bn="${FAKE_CODEX_BANNER:-}"; [ "$kind" = ele ] && [ -n "${FAKE_CODEX_BANNER_ELE:-}" ] && bn="$FAKE_CODEX_BANNER_ELE"
62
+ if [ -n "$bn" ]; then printf 'OpenAI Codex (stub)\n--------\nmodel: %s\n--------\nuser\nmodel: echoed-from-prompt\n' "$bn" >&2; fi
63
+ if [ -n "${FAKE_CODEX_ECHO_ONLY:-}" ]; then printf 'OpenAI Codex (stub)\n--------\nuser\nmodel: echoed-from-prompt\n' >&2; fi
64
+ printf '%s\n' "$all" > "${LOGDIR:-/tmp}/codex_${kind}.args"; pwd -P > "${LOGDIR:-/tmp}/codex_${kind}.cwd"
54
65
  empty='{"status":"SUCCESS","findings":[]}'
55
66
  case "$kind" in legacy) p="$FAKE_PAYLOAD" ;; *) p="$empty" ;; esac
56
67
  [ -n "$out" ] && printf '%s' "$p" > "$out"
@@ -58,6 +69,9 @@ exit 0
58
69
  FAKE
59
70
  chmod +x "$FAKEBIN/claude" "$FAKEBIN/codex"
60
71
  export PATH="$FAKEBIN:$PATH"
72
+ # The codex calls read the runner's codex user config (the provider guard does); pin it to an empty home so the lane
73
+ # does not depend on whose machine runs it. D16 points CODEX_HOME at its own fixtures.
74
+ export CODEX_HOME="$TMPROOT/codexhome-none"
61
75
  export FAKE_PAYLOAD='{"status":"SUCCESS","verdict":"PASS","findings_count":0,"findings_a":0,"findings_b":0,"findings":[]}'
62
76
 
63
77
  REPO="$TMPROOT/repo"; mkdir -p "$REPO/scripts"
@@ -123,6 +137,7 @@ else bad "D9 --help default reviewer" "$(grep -m2 -F 'FH_REVIEWER' "$TMPROOT/hel
123
137
  # and git's read commands write files through --output=. The whole policy is asserted, not one token of it.
124
138
  # Known pair: on the 3.45.0 merge (7c5a6b7) both calls allow Bash(git diff:*) and carry none of the three flags.
125
139
  argv_after() { awk -v f="$2" 'p{print; exit} $0==f{p=1}' "$1"; }
140
+ has_pair() { awk -v f="$2" -v v="$3" 'p&&$0==v{ok=1} {p=($0==f)} END{exit !ok}' "$1"; } # «f v» adjacent in argv
126
141
  has_flag() { grep -qxF -- "$2" "$1"; }
127
142
  policy_ok() { # policy_ok <args file> — prints what is wrong, nothing when the policy holds
128
143
  local a="$1" t al d need
@@ -134,6 +149,8 @@ policy_ok() { # policy_ok <args file> — prints what is wrong, nothing when t
134
149
  has_flag "$a" --strict-mcp-config || echo "no --strict-mcp-config"
135
150
  has_flag "$a" --disable-slash-commands || echo "no --disable-slash-commands"
136
151
  ! has_flag "$a" --mcp-config || echo "an --mcp-config was passed"
152
+ # the reviewed checkout is untrusted: its project/local settings and hooks must not load (2026-11-22)
153
+ [ "$(argv_after "$a" --setting-sources)" = "user" ] || echo "setting-sources=[$(argv_after "$a" --setting-sources)]"
137
154
  }
138
155
  gate d10 FH_REVIEWER=fh FH_GATE_ELEPHANT=on
139
156
  p_abs=$(policy_ok "$TMPROOT/d10/claude_abs.args" | tr '\n' ' '); p_ele=$(policy_ok "$TMPROOT/d10/claude_ele.args" | tr '\n' ' ')
@@ -144,6 +161,39 @@ printf '%s\n' --tools Read,Glob,Grep --strict-mcp-config --disable-slash-command
144
161
  --disallowedTools Bash,PowerShell,Write,Edit,NotebookEdit,WebFetch,WebSearch > "$TMPROOT/planted.args"
145
162
  [ -n "$(policy_ok "$TMPROOT/planted.args")" ] && ok "D10b the policy check catches a planted extra allowed tool (control alive)" || bad "D10b policy check blind" "planted Write in the allow list passed"
146
163
 
164
+ # D13 — the DEFAULT review call (fh-legacy, run_backend) gets the same read-only policy as the goldfish and
165
+ # elephant passes, and runs at the repository root like them. Before 2026-11-22 run_backend passed none of
166
+ # --tools / --strict-mcp-config / --disable-slash-commands / -s read-only (found by a codex review of a README
167
+ # claim). Run from a subfolder so «runs at the repo root» is distinguishable from «runs where it was called».
168
+ mkdir -p "$TMPROOT/d13c" "$TMPROOT/d13x"
169
+ ( cd "$REPO/scripts" && env LOGDIR="$TMPROOT/d13c" bash "$GATE" ) > "$TMPROOT/d13c.out" 2>&1 < /dev/null; rc_c=$?
170
+ ( cd "$REPO/scripts" && env LOGDIR="$TMPROOT/d13x" FH_BACKEND=codex bash "$GATE" ) > "$TMPROOT/d13x.out" 2>&1 < /dev/null; rc_x=$?
171
+ root_p=$(cd "$REPO" && pwd -P)
172
+ p_leg=$(policy_ok "$TMPROOT/d13c/claude_legacy.args" | tr '\n' ' ')
173
+ [ "$(cat "$TMPROOT/d13c/claude_legacy.cwd" 2>/dev/null)" = "$root_p" ] || p_leg="${p_leg}cwd=[$(cat "$TMPROOT/d13c/claude_legacy.cwd" 2>/dev/null)] "
174
+ if [ "$rc_c" -eq 0 ] && [ -z "$p_leg" ]; then ok "D13a default claude review: exactly Read/Glob/Grep, no MCP, no skill, at the repo root"
175
+ else bad "D13a default claude review policy" "rc=$rc_c ${p_leg:-ok}"; fi
176
+ x_bad=""
177
+ grep -qxF -- "-s" "$TMPROOT/d13x/codex_legacy.args" 2>/dev/null && [ "$(argv_after "$TMPROOT/d13x/codex_legacy.args" -s)" = "read-only" ] || x_bad="no -s read-only "
178
+ [ "$(cat "$TMPROOT/d13x/codex_legacy.cwd" 2>/dev/null)" = "$root_p" ] || x_bad="${x_bad}cwd=[$(cat "$TMPROOT/d13x/codex_legacy.cwd" 2>/dev/null)]"
179
+ has_pair "$TMPROOT/d13x/codex_legacy.args" -c "project_doc_max_bytes=0" 2>/dev/null || x_bad="${x_bad}reads the checkout AGENTS.md (no -c project_doc_max_bytes=0) "
180
+ if [ "$rc_x" -eq 0 ] && [ -z "$x_bad" ]; then ok "D13b default codex review: -s read-only, no checkout AGENTS.md, at the repo root"
181
+ else bad "D13b default codex review policy" "rc=$rc_x ${x_bad:-ok}"; fi
182
+
183
+ # D13c — the opt-in codex goldfish and elephant passes do not read the reviewed checkout's AGENTS.md either.
184
+ # Measured 2026-11-22 (real codex 0.164.0, local fake API, planted fixture): without the flag the request
185
+ # carries the checkout's AGENTS.md; with `-c project_doc_max_bytes=0` it does not.
186
+ gate d13y FH_BACKEND=codex FH_REVIEWER=fh FH_GATE_ELEPHANT=on
187
+ y_bad=""
188
+ for k in abs ele; do
189
+ f="$TMPROOT/d13y/codex_${k}.args"
190
+ [ -s "$f" ] || { y_bad="${y_bad}${k}: no call recorded "; continue; }
191
+ has_pair "$f" -c "project_doc_max_bytes=0" || y_bad="${y_bad}${k}: no -c project_doc_max_bytes=0 "
192
+ [ "$(argv_after "$f" -s)" = "read-only" ] || y_bad="${y_bad}${k}: no -s read-only "
193
+ done
194
+ if [ "$RC" -eq 0 ] && [ -z "$y_bad" ]; then ok "D13c codex goldfish and elephant passes: -s read-only, no checkout AGENTS.md"
195
+ else bad "D13c codex opt-in passes" "rc=$RC ${y_bad:-ok}"; fi
196
+
147
197
  # D11 — /code-review keeps git (it needs it), so its call runs without the runner's five command-file variables.
148
198
  # (This only removes the direct reference — the path stays labelled not read-only.)
149
199
  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"
@@ -152,6 +202,163 @@ if [ "$RC" -eq 0 ] && [ -s "$TMPROOT/d11/claude_cr.env" ] && ! grep -qE '^GITHUB
152
202
  ok "D11 /code-review call: git kept, none of the five GITHUB_* command-file variables in its environment"
153
203
  else bad "D11 code-review env" "rc=$RC $(grep -E '^GITHUB_(ENV|PATH|OUTPUT|STATE|STEP_SUMMARY)=' "$TMPROOT/d11/claude_cr.env" 2>/dev/null | cut -d= -f1 | tr '\n' ' ')"; fi
154
204
 
205
+ # D14 — the opt-in /code-review call. Measured 2026-11-22 with real claude 2.1.330 on a planted checkout:
206
+ # ① without --setting-sources user, the checkout's project and local hooks ran, its .mcp.json server started and
207
+ # its CLAUDE.md, CLAUDE.local.md and .claude/rules text reached the call (3/3); with the flag, none of them (3/3).
208
+ # ② the CLI reads a word after --disallowedTools as that option's value («"/code-review low" was read as a value
209
+ # of --disallowedTools, not as a prompt»), so the call failed before any review (exit 10). With `--` in front
210
+ # the prompt is read as a prompt. This stub does not parse argv like the real CLI, so ② is asserted on the
211
+ # argv shape: the line before the /code-review prompt must be `--`.
212
+ cr_ok() { # cr_ok <args file> — prints what is wrong. Options count only before the first `--` (after it, everything
213
+ # is positional); exactly one `--`, followed by the /code-review prompt and nothing else.
214
+ [ -s "$1" ] || { echo "no call recorded"; return; }
215
+ awk '
216
+ !seen && $0=="--" { seen=NR; next }
217
+ !seen && prev=="--setting-sources" && $0=="user" { src=1 }
218
+ seen && NR==seen+1 { if ($0 ~ /^\/code-review /) pr=1 }
219
+ seen && NR>seen+1 { extra=1 }
220
+ seen && $0=="--" { dup=1 }
221
+ { prev=$0 }
222
+ END {
223
+ if (!seen) print "no --"
224
+ if (!src) print "no --setting-sources user before --"
225
+ if (!pr) print "prompt not right after --"
226
+ if (extra || dup) print "more after the prompt"
227
+ }' "$1"
228
+ }
229
+ gate d14 FH_REVIEWER=code-review
230
+ z_bad=$(cr_ok "$TMPROOT/d14/claude_cr.args" | tr '\n' ' ')
231
+ if [ "$RC" -eq 0 ] && [ -z "$z_bad" ]; then ok "D14 /code-review call: user settings only, prompt after --"
232
+ else bad "D14 code-review call" "rc=$RC ${z_bad:-ok}"; fi
233
+ # D14b — the checker sees a planted evasion (cross-family R2): --setting-sources user moved after the first `--`
234
+ # (positional there) with a second `--` before the prompt. Control: the shipped shape passes the same checker.
235
+ printf '%s\n' --print --allowedTools Read --disallowedTools Write -- --setting-sources user -- "/code-review low" > "$TMPROOT/cr_planted.args"
236
+ printf '%s\n' --print --setting-sources user --allowedTools Read --disallowedTools Write -- "/code-review low" > "$TMPROOT/cr_good.args"
237
+ if [ -n "$(cr_ok "$TMPROOT/cr_planted.args")" ] && [ -z "$(cr_ok "$TMPROOT/cr_good.args")" ]; then
238
+ ok "D14b the /code-review check catches a flag moved after -- (and passes the good shape)"
239
+ else bad "D14b code-review checker" "planted=[$(cr_ok "$TMPROOT/cr_planted.args" | tr '\n' ' ')] good=[$(cr_ok "$TMPROOT/cr_good.args" | tr '\n' ' ')]"; fi
240
+
241
+ # D15 — every codex review call drops the user config layer. Measured 2026-11-22 (real codex 0.164.0, isolated
242
+ # CODEX_HOME, local fake API): when the user config marks the checkout trusted, the checkout's .codex/config.toml
243
+ # MCP server starts and writes outside -s read-only (3/3; untrusted 0/3); `-c mcp_servers={}`, `-c projects={}`
244
+ # and a per-path trust override did not stop it; --ignore-user-config did (0/3). Reuses the D13b/D13c calls.
245
+ # The flag must come before the `-` prompt marker and with no `--` before it (after `--` it is a positional).
246
+ cx_ok() { # cx_ok <args file> — prints what is wrong
247
+ [ -s "$1" ] || { echo "no call recorded"; return; }
248
+ awk '$0=="--"{dd=1} $0=="--ignore-user-config" && !dd && !dash {f=1} $0=="-"{dash=1}
249
+ END{ if(!f) print "no --ignore-user-config before the prompt marker" }' "$1"
250
+ }
251
+ w_bad=""
252
+ for k in d13x/codex_legacy d13y/codex_abs d13y/codex_ele; do
253
+ r=$(cx_ok "$TMPROOT/$k.args" | tr '\n' ' '); [ -z "$r" ] || w_bad="${w_bad}${k##*/}: $r"
254
+ done
255
+ printf '%s\n' exec -m x -s read-only -c project_doc_max_bytes=0 -- --ignore-user-config > "$TMPROOT/cx_planted.args"
256
+ printf '%s\n' exec -m x -s read-only --ignore-user-config -c project_doc_max_bytes=0 - > "$TMPROOT/cx_good.args"
257
+ [ -n "$(cx_ok "$TMPROOT/cx_planted.args")" ] && [ -z "$(cx_ok "$TMPROOT/cx_good.args")" ] || w_bad="${w_bad}checker control dead "
258
+ if [ -z "$w_bad" ]; then ok "D15 codex review calls (default, goldfish, elephant): --ignore-user-config (checker control alive)"
259
+ else bad "D15 codex user config" "$w_bad"; fi
260
+
261
+ # D16 — with the user config dropped (D15), a config that names where requests go would silently send the review to
262
+ # codex's default provider instead. fh-gate reads that config first and fails closed (exit 10, no codex call)
263
+ # when it sets model_provider (other than "openai"), model_providers, openai_base_url or chatgpt_base_url
264
+ # (codex 0.164.0 config reference), or when it cannot be read. A plain or absent config proceeds.
265
+ d16() { # d16 <name> <config text|-absent|-unreadable> → sets RC, CALLED
266
+ local n="$1" t="$2" h="$TMPROOT/d16_$1"; mkdir -p "$h"
267
+ case "$t" in -absent) ;; -unreadable) printf 'model = "x"\n' > "$h/config.toml"; chmod 000 "$h/config.toml" ;; *) printf '%s\n' "$t" > "$h/config.toml" ;; esac
268
+ gate "d16$n" FH_BACKEND=codex CODEX_HOME="$h"
269
+ CALLED=no; called "d16$n" codex_legacy && CALLED=yes
270
+ chmod 600 "$h/config.toml" 2>/dev/null || true
271
+ }
272
+ v_bad=""
273
+ for c in 'mp|model_provider = "corp-proxy"' 'mpq|"model_provider"="corp"' 'tbl|[model_providers.corp]' 'dot|model_providers.corp.base_url = "https://x"' \
274
+ 'obu|openai_base_url = "https://proxy.example/v1"' 'cbu|chatgpt_base_url = "https://x"' \
275
+ 'prof|[profiles.work]
276
+ model_provider = "corp"' 'inl|profiles = { work = { model_provider = "corp" } }'; do
277
+ n="${c%%|*}"; d16 "$n" "${c#*|}"
278
+ { [ "$RC" -eq 10 ] && [ "$CALLED" = no ] && grep -qE 'model_provider|model_providers|openai_base_url|chatgpt_base_url' "$TMPROOT/d16$n.err"; } \
279
+ || v_bad="${v_bad}${n}: rc=$RC called=$CALLED "
280
+ done
281
+ if [ "$(id -u)" = 0 ]; then
282
+ printf ' SKIP D16 unreadable config — NOT-APPLICABLE as root (chmod 000 is still readable; not measured, not a pass)\n'; skipped=$((skipped + 1))
283
+ else
284
+ # exit 10 alone would not tell the named refusal from fh-gate's generic ERR trap (a failed `cat` trips that too),
285
+ # so the message that names the reason is asserted as well
286
+ d16 unr -unreadable
287
+ { [ "$RC" -eq 10 ] && [ "$CALLED" = no ] && grep -qF 'cannot read the codex user config' "$TMPROOT/d16unr.err"; } \
288
+ || v_bad="${v_bad}unreadable: rc=$RC called=$CALLED named=$(grep -cF 'cannot read the codex user config' "$TMPROOT/d16unr.err") "
289
+ # cross-family R1 B: absence counts only when confirmed — a CODEX_HOME that cannot be searched is not «no config»
290
+ h="$TMPROOT/d16_lockedhome"; mkdir -p "$h"; printf 'model_provider = "corp"\n' > "$h/config.toml"; chmod 000 "$h"
291
+ gate d16lock FH_BACKEND=codex CODEX_HOME="$h"; chmod 700 "$h"
292
+ { [ "$RC" -eq 10 ] && ! called d16lock codex_legacy && grep -qF 'cannot read the codex user config' "$TMPROOT/d16lock.err"; } \
293
+ || v_bad="${v_bad}locked-home: rc=$RC "
294
+ fi
295
+ # a dangling config.toml link is not «no config» either
296
+ h="$TMPROOT/d16_dangling"; mkdir -p "$h"; ln -s "$TMPROOT/nowhere.toml" "$h/config.toml"
297
+ gate d16dang FH_BACKEND=codex CODEX_HOME="$h"
298
+ { [ "$RC" -eq 10 ] && ! called d16dang codex_legacy && grep -qF 'cannot read the codex user config' "$TMPROOT/d16dang.err"; } \
299
+ || v_bad="${v_bad}dangling-link: rc=$RC "
300
+ # cross-family R1 A: a quoted key may spell a routing key with an escape (all three are valid TOML for the real key)
301
+ for c in 'esc1|"openai\u005fbase_url" = "https://corp.example/v1"' 'esc2|"model\u005fprovider" = "azure"' \
302
+ 'esc3|"model\U0000005Fproviders".corp.base_url = "https://x"' 'esc4|"chatgpt\x5fbase_url" = "https://x"'; do
303
+ n="${c%%|*}"; d16 "$n" "${c#*|}"
304
+ { [ "$RC" -eq 10 ] && [ "$CALLED" = no ] && grep -qF 'escape' "$TMPROOT/d16$n.err"; } || v_bad="${v_bad}${n}: rc=$RC called=$CALLED "
305
+ done
306
+ for c in 'plain|model = "gpt-x"' 'oai|model_provider = "openai"' 'cmt|# model_provider = "corp"' \
307
+ "oaisq|'model_provider' = 'openai'" 'oaitq|model_provider = """openai"""'; do
308
+ n="${c%%|*}"; d16 "$n" "${c#*|}"
309
+ { [ "$RC" -eq 0 ] && [ "$CALLED" = yes ]; } || v_bad="${v_bad}${n}(should proceed): rc=$RC called=$CALLED "
310
+ done
311
+ d16 abs -absent; { [ "$RC" -eq 0 ] && [ "$CALLED" = yes ]; } || v_bad="${v_bad}absent(should proceed): rc=$RC called=$CALLED "
312
+ if [ -z "$v_bad" ]; then ok "D16 codex provider guard: 8 route-changing configs, 4 escaped keys, unreadable/locked/dangling → exit 10, no call; plain/openai(3 spellings)/comment/absent proceed"
313
+ else bad "D16 codex provider guard" "$v_bad"; fi
314
+
315
+ # D17 — the codex default model. Measured 2026-11-22 on codex 0.164.0 with a ChatGPT-account login: `-m gpt-5.5`
316
+ # (the old default) → 400 «The 'gpt-5.5' model is not supported when using Codex with a ChatGPT account»; no -m
317
+ # → codex picked gpt-6.1-terra from its own catalog and answered. So with FH_MODEL unset fh-gate passes no -m;
318
+ # an explicit FH_MODEL is still passed as -m. The governance record names the model codex resolved, read from the
319
+ # banner line above `user` only (cross-family R1: «not pinned» alone hides which model gave the verdict).
320
+ d17gate() { local n="$1"; shift; mkdir -p "$TMPROOT/rec_$n"; gate "$n" FH_RECORD_BASE="$TMPROOT/rec_$n" "$@"; eval "RC_$n=$RC"; }
321
+ d17rec() { awk '/^ model: /{print; exit}' "$TMPROOT/rec_$1"/governance_log_*.yaml 2>/dev/null || true; }
322
+ d17gate d17 FH_BACKEND=codex FH_MODEL=
323
+ d17gate d17b FH_BACKEND=codex FH_MODEL= FAKE_CODEX_BANNER=gpt-banner-x
324
+ d17gate d17e FH_BACKEND=codex FH_MODEL= "FAKE_CODEX_BANNER=evil; touch /tmp/x"
325
+ d17gate d17n FH_BACKEND=codex FH_MODEL= FAKE_CODEX_ECHO_ONLY=1 # a «model:» only below `user` (prompt echo) must not count
326
+ d17gate d17x FH_BACKEND=codex FH_MODEL=gpt-pinned-x
327
+ d17gate d17y FH_BACKEND=codex FH_REVIEWER=fh FH_GATE_ELEPHANT=on FH_MODEL=
328
+ d17gate d17z FH_BACKEND=codex FH_REVIEWER=fh FH_GATE_ELEPHANT=on FH_MODEL=gpt-pinned-y
329
+ d17gate d17p FH_BACKEND=codex FH_REVIEWER=fh FH_GATE_ELEPHANT=on FH_MODEL= FAKE_CODEX_BANNER=gpt-rev-a FAKE_CODEX_BANNER_ELE=gpt-ele-b
330
+ u_bad=""
331
+ for n in d17 d17b d17e d17n d17x d17y d17z d17p; do eval "r=\$RC_$n"; [ "$r" -eq 0 ] || u_bad="${u_bad}$n rc=$r "; done
332
+ [ -s "$TMPROOT/d17/codex_legacy.args" ] || u_bad="${u_bad}no codex call "
333
+ has_flag "$TMPROOT/d17/codex_legacy.args" -m 2>/dev/null && u_bad="${u_bad}unset FH_MODEL still passes -m "
334
+ for k in abs ele; do
335
+ [ -s "$TMPROOT/d17y/codex_${k}.args" ] || u_bad="${u_bad}${k}: no call "
336
+ has_flag "$TMPROOT/d17y/codex_${k}.args" -m 2>/dev/null && u_bad="${u_bad}${k}: unset FH_MODEL still passes -m "
337
+ has_pair "$TMPROOT/d17z/codex_${k}.args" -m gpt-pinned-y 2>/dev/null || u_bad="${u_bad}${k}: explicit FH_MODEL not passed as -m "
338
+ done
339
+ has_pair "$TMPROOT/d17x/codex_legacy.args" -m gpt-pinned-x 2>/dev/null || u_bad="${u_bad}legacy: explicit FH_MODEL not passed as -m "
340
+ [ "$(d17rec d17)" = " model: codex default (not pinned, resolved review unknown)" ] || u_bad="${u_bad}record(no banner)=[$(d17rec d17)] "
341
+ [ "$(d17rec d17b)" = " model: codex default (not pinned, resolved review gpt-banner-x)" ] || u_bad="${u_bad}record(banner)=[$(d17rec d17b)] "
342
+ [ "$(d17rec d17e)" = " model: codex default (not pinned, resolved review unknown)" ] || u_bad="${u_bad}record(bad banner)=[$(d17rec d17e)] "
343
+ [ "$(d17rec d17n)" = " model: codex default (not pinned, resolved review unknown)" ] || u_bad="${u_bad}record(echo only)=[$(d17rec d17n)] "
344
+ [ "$(d17rec d17p)" = " model: codex default (not pinned, resolved review gpt-rev-a, elephant gpt-ele-b)" ] || u_bad="${u_bad}record(per pass)=[$(d17rec d17p)] "
345
+ # the record stays valid YAML (cross-family R2: «resolved: x» inside a plain scalar broke it): no «: » in any value,
346
+ # and where PyYAML is present the files parse and give the model back as a string
347
+ for n in d17 d17p d17x; do
348
+ v=$(d17rec "$n"); v="${v# model: }"; [[ "$v" != *": "* ]] || u_bad="${u_bad}$n model value has «: » "
349
+ if python3 -c 'import yaml' 2>/dev/null; then
350
+ python3 - "$TMPROOT/rec_$n" <<'PYY' || u_bad="${u_bad}$n record does not parse as YAML "
351
+ import glob, sys, yaml
352
+ for f in glob.glob(sys.argv[1] + "/governance_log_*.yaml"):
353
+ d = yaml.safe_load(open(f))
354
+ assert isinstance(d, list) and all(isinstance(x.get("model"), str) for x in d), f
355
+ PYY
356
+ fi
357
+ done
358
+ [ "$(d17rec d17x)" = " model: gpt-pinned-x" ] || u_bad="${u_bad}record(pinned)=[$(d17rec d17x)] "
359
+ if [ -z "$u_bad" ]; then ok "D17 codex: no FH_MODEL → no -m on all three calls, record names the resolved model per pass (unknown if not shown or not an id) and parses as YAML; FH_MODEL=x → -m x everywhere"
360
+ else bad "D17 codex default model" "${u_bad}"; fi
361
+
155
362
  # D7 — action.yml's step env must not carry FH_TIMEOUT; the run block exports it only from a non-empty input.
156
363
  envblock() { awk '/^ *env: *$/{e=1; next} e && /^ *run: *\|/{exit} e{print}' "$1"; }
157
364
  if [ -r "$ACTION" ]; then
@@ -29,6 +29,7 @@ HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
29
29
  GATE="$HERE/fh-gate.sh"
30
30
  TMPROOT=$(mktemp -d "${TMPDIR:-/tmp}/fh_gate_fusion_XXXXXX")
31
31
  trap 'rm -rf "$TMPROOT"' EXIT
32
+ export CODEX_HOME="$TMPROOT/codexhome-none" # fh-gate reads the codex user config (provider guard): not the runner's
32
33
  export FH_RECORD_BASE="$TMPROOT/records"; mkdir -p "$FH_RECORD_BASE"
33
34
  # These lanes exercise the opt-in review and execution layer (3.45.0: defaults are fh-legacy · exec off · elephant
34
35
  # off — pinned by test_fh_gate_defaults_lanes.sh). Each lane that needs otherwise sets its own value.
@@ -21,6 +21,7 @@ GATE="scripts/fh-gate.sh"
21
21
  pass=0; fail=0
22
22
  TMPROOT=$(mktemp -d "${TMPDIR:-/tmp}/fh_gate_test_XXXXXX")
23
23
  trap 'rm -rf "$TMPROOT"' EXIT
24
+ export CODEX_HOME="$TMPROOT/codexhome-none" # fh-gate reads the codex user config (provider guard): not the runner's
24
25
 
25
26
  # 🟥 The gate APPENDS every invocation to $FH_RECORD_BASE/governance_log_<date>.yaml, defaulting to
26
27
  # the hub's own tracks/_meta. Measured 2026-11-16 (clean-room audit round 9): one run of this suite
@@ -186,5 +186,52 @@ else
186
186
  echo " ⬜ ARM H NOT RUN: no git on PATH — not a pass"
187
187
  fi
188
188
 
189
+
190
+ # --- codex model (2026-11-22): with FH_MODEL unset no -m is passed and stderr names what codex resolved ---------
191
+ # Stub records its argv one per line and prints a codex-like banner on stderr (`model: <id>` above `user`).
192
+ _MD=$(mktemp -d)
193
+ mkdir -p "$_MD/bin"
194
+ cat > "$_MD/bin/codex" <<'CX'
195
+ #!/usr/bin/env bash
196
+ printf '%s\n' "$@" > "$CODEX_ARGV_FILE"
197
+ [[ -n "${FAKE_CODEX_BANNER:-}" ]] && printf 'model: %s\n' "$FAKE_CODEX_BANNER" >&2
198
+ printf 'user\nmodel: not-this-one\n' >&2
199
+ cat >/dev/null
200
+ echo "stub output"
201
+ exit 0
202
+ CX
203
+ chmod +x "$_MD/bin/codex"
204
+
205
+ _mrun() { # $@ = env assignments; argv → $_MD/argv, stderr → $_MD/err
206
+ env "$@" PATH="$_MD/bin:$PATH" CODEX_ARGV_FILE="$_MD/argv" FH_TIMEOUT=20 PATH="$_MD/bin:$FIX/bin:$PATH" FH_BACKEND=codex FAKE_GIT_STATUS_OUT= bash "$TARGET" --prompt "noop" --root "$FIX/work" >"$_MD/out" 2>"$_MD/err"; _MRC=$?
207
+ }
208
+ : > "$_MD/argv"; _mrun -u FH_MODEL FAKE_CODEX_BANNER=gpt-test-x
209
+ if [[ "$_MRC" -eq 0 ]] && [[ "$(cat "$_MD/argv")" == "$(printf 'exec\n-')" ]] \
210
+ && /usr/bin/grep -q 'fh-goal: codex default (not pinned, resolved gpt-test-x)' "$_MD/err"; then
211
+ ok "M1 fh-goal: FH_MODEL unset → no -m to codex, stderr names the resolved model from the banner"
212
+ else
213
+ no "M1 fh-goal: FH_MODEL unset → argv $(tr '\n' ' ' < "$_MD/argv") · stderr note: $(/usr/bin/grep -c 'not pinned' "$_MD/err")"
214
+ fi
215
+ : > "$_MD/argv"; _mrun FH_MODEL=pin-1 FAKE_CODEX_BANNER=gpt-test-x
216
+ if [[ "$_MRC" -eq 0 ]] && [[ "$(cat "$_MD/argv")" == "$(printf 'exec\n-m\npin-1\n-')" ]] \
217
+ && ! /usr/bin/grep -q 'not pinned' "$_MD/err"; then
218
+ ok "M2 fh-goal: FH_MODEL=pin-1 → -m pin-1, no «not pinned» note"
219
+ else
220
+ no "M2 fh-goal: FH_MODEL=pin-1 → argv $(tr '\n' ' ' < "$_MD/argv")"
221
+ fi
222
+ : > "$_MD/argv"; _mrun -u FH_MODEL FAKE_CODEX_BANNER='bad id; rm'
223
+ if [[ "$_MRC" -eq 0 ]] && [[ -s "$_MD/argv" ]] && /usr/bin/grep -q 'fh-goal: codex default (not pinned, resolved unknown)' "$_MD/err"; then
224
+ ok "M3 fh-goal: a banner that is not id-shaped → «unknown», never the text (the line after «user» is never read)"
225
+ else
226
+ no "M3 fh-goal: non-id banner → $(awk '/resolved /{print; exit}' "$_MD/err")"
227
+ fi
228
+
229
+ : > "$_MD/argv"; _mrun -u FH_MODEL -u FAKE_CODEX_BANNER
230
+ if [[ "$_MRC" -eq 0 ]] && [[ -s "$_MD/argv" ]] && /usr/bin/grep -q 'fh-goal: codex default (not pinned, resolved unknown)' "$_MD/err"; then
231
+ ok "M4 fh-goal: no model line above «user», an id-shaped one below it → «unknown» (only the banner counts)"
232
+ else
233
+ no "M4 fh-goal: post-user model line → $(awk '/resolved /{print; exit}' "$_MD/err")"
234
+ fi
235
+ /bin/rm -rf "$_MD"
189
236
  echo "fh-goal change-detection: $PASS passed, $FAIL failed"
190
237
  [[ "$FAIL" -eq 0 ]] || exit 1
@@ -142,6 +142,53 @@ else
142
142
  ng "F8 package.json 없는 트리: rc=$R8rc · 출력 $(printf '%s' "$R8" | wc -l | tr -d ' ')줄 (수리 전 = 0줄 · rc 1)"
143
143
  fi
144
144
 
145
+
146
+ # --- codex model (2026-11-22): with FH_MODEL unset no -m is passed and stderr names what codex resolved ---------
147
+ # Stub records its argv one per line and prints a codex-like banner on stderr (`model: <id>` above `user`).
148
+ _MD=$(mktemp -d)
149
+ mkdir -p "$_MD/bin"
150
+ cat > "$_MD/bin/codex" <<'CX'
151
+ #!/usr/bin/env bash
152
+ printf '%s\n' "$@" > "$CODEX_ARGV_FILE"
153
+ [[ -n "${FAKE_CODEX_BANNER:-}" ]] && printf 'model: %s\n' "$FAKE_CODEX_BANNER" >&2
154
+ printf 'user\nmodel: not-this-one\n' >&2
155
+ cat >/dev/null
156
+ echo "stub output"
157
+ exit 0
158
+ CX
159
+ chmod +x "$_MD/bin/codex"
160
+
161
+ _mrun() { # $@ = env assignments; argv → $_MD/argv, stderr → $_MD/err
162
+ env "$@" PATH="$_MD/bin:$PATH" CODEX_ARGV_FILE="$_MD/argv" FH_TIMEOUT=20 bash "$HERE/scripts/fh-run.sh" --backend codex --skill preprep >"$_MD/out" 2>"$_MD/err"; _MRC=$?
163
+ }
164
+ : > "$_MD/argv"; _mrun -u FH_MODEL FAKE_CODEX_BANNER=gpt-test-x
165
+ if [[ "$_MRC" -eq 0 ]] && [[ "$(cat "$_MD/argv")" == "$(printf 'exec\n-')" ]] \
166
+ && /usr/bin/grep -q 'fh-run: codex default (not pinned, resolved gpt-test-x)' "$_MD/err"; then
167
+ ok "M1 fh-run: FH_MODEL unset → no -m to codex, stderr names the resolved model from the banner"
168
+ else
169
+ ng "M1 fh-run: FH_MODEL unset → argv $(tr '\n' ' ' < "$_MD/argv") · stderr note: $(/usr/bin/grep -c 'not pinned' "$_MD/err")"
170
+ fi
171
+ : > "$_MD/argv"; _mrun FH_MODEL=pin-1 FAKE_CODEX_BANNER=gpt-test-x
172
+ if [[ "$_MRC" -eq 0 ]] && [[ "$(cat "$_MD/argv")" == "$(printf 'exec\n-m\npin-1\n-')" ]] \
173
+ && ! /usr/bin/grep -q 'not pinned' "$_MD/err"; then
174
+ ok "M2 fh-run: FH_MODEL=pin-1 → -m pin-1, no «not pinned» note"
175
+ else
176
+ ng "M2 fh-run: FH_MODEL=pin-1 → argv $(tr '\n' ' ' < "$_MD/argv")"
177
+ fi
178
+ : > "$_MD/argv"; _mrun -u FH_MODEL FAKE_CODEX_BANNER='bad id; rm'
179
+ if [[ "$_MRC" -eq 0 ]] && [[ -s "$_MD/argv" ]] && /usr/bin/grep -q 'fh-run: codex default (not pinned, resolved unknown)' "$_MD/err"; then
180
+ ok "M3 fh-run: a banner that is not id-shaped → «unknown», never the text (the line after «user» is never read)"
181
+ else
182
+ ng "M3 fh-run: non-id banner → $(awk '/resolved /{print; exit}' "$_MD/err")"
183
+ fi
184
+
185
+ : > "$_MD/argv"; _mrun -u FH_MODEL -u FAKE_CODEX_BANNER
186
+ if [[ "$_MRC" -eq 0 ]] && [[ -s "$_MD/argv" ]] && /usr/bin/grep -q 'fh-run: codex default (not pinned, resolved unknown)' "$_MD/err"; then
187
+ ok "M4 fh-run: no model line above «user», an id-shaped one below it → «unknown» (only the banner counts)"
188
+ else
189
+ ng "M4 fh-run: post-user model line → $(awk '/resolved /{print; exit}' "$_MD/err")"
190
+ fi
191
+ /bin/rm -rf "$_MD"
145
192
  echo
146
193
  echo "════════════════════════════════════════"
147
194
  printf ' PASS %s FAIL %s\n' "$PASS" "$FAIL"
@@ -95,4 +95,6 @@ EOF
95
95
  done <<< "$branches_raw"
96
96
  echo "--"
97
97
  echo "Gate order: enumerate -> recover -> destroy. REVIEW blocks; CHECK needs a judged look; only then delete."
98
+ # Prose reminder only — no verdict, no exit-code effect (judgment question; this script cannot answer it).
99
+ echo "Also ask, before deleting: is anything else using this target right now (another session or worktree, a live site, a shared database or config)? SAFE means merged, not idle — look (git worktree list, ps/lsof, sibling dirs and notes), do not recall."
98
100
  exit $fail
@@ -52,5 +52,15 @@ out=$("$SCRIPT" "$D5/wc" origin/main 2>/dev/null); rc=$?
52
52
  { echo "$out" | grep -q "SAFE merged" && [ "$rc" -eq 0 ]; } \
53
53
  && ok "merged branch → SAFE exit 0" || no "merged branch: $out (exit $rc)"
54
54
 
55
+ # 6. the closing output asks who else is using the target — on SAFE, REVIEW and the exit-0 path alike,
56
+ # and asking it changes no exit code (prose reminder only; the verdict above still decides).
57
+ echo "$out" | grep -q "is anything else using this target right now" \
58
+ && ok "closing output asks the in-use question (SAFE path)" \
59
+ || no "closing output lacks the in-use question (SAFE path)"
60
+ out4=$("$SCRIPT" "$D4/wc" origin/main 2>/dev/null)
61
+ echo "$out4" | grep -q "is anything else using this target right now" \
62
+ && ok "closing output asks the in-use question (REVIEW path)" \
63
+ || no "closing output lacks the in-use question (REVIEW path)"
64
+
55
65
  echo "---- predelete_check.test: $pass passed, $fail failed ----"
56
66
  [ "$fail" -eq 0 ]
@@ -39,7 +39,12 @@
39
39
  "the pre-push hook remains the hard floor for the push-time surface (role deconfliction in the",
40
40
  "script header). Advisory by design, same contract as pipe_verdict_guard (additionalContext +",
41
41
  "systemMessage, no permissionDecision); escalate with FH_DESTRUCTIVE_BLOCK=1. Under",
42
- "permission_mode=bypassPermissions it blocks by default (FH_DESTRUCTIVE_BLOCK=0 keeps advisory). Opt out with",
42
+ "permission_mode=bypassPermissions or auto it blocks by default (FH_DESTRUCTIVE_BLOCK=0 keeps advisory).",
43
+ "In BLOCK mode an override written into the command is not honored — `# noqa: destructive-op`,",
44
+ "`DESTRUCTIVE_OP_OK=`, `git push --no-verify`, core.hooksPath via -c or git config — and remote",
45
+ "deletes (push --delete/-d/:ref/--mirror/--prune) also block; the block text tells the agent to ask",
46
+ "the operator, who runs the command from their own terminal (measured 2026-11-23: the agent took",
47
+ "both printed overrides and force-pushed, haiku 3/3). In ADVISORY mode, opt out with",
43
48
  "`# noqa: destructive-op` — the opt-out exempts the ENTIRE Bash payload (whole-command match),",
44
49
  "not a single line: a multi-statement payload with a destructive line 1 and a noqa on line 2 is",
45
50
  "fully exempt (accepted advisory-surface residual — see the script header's PRECISION OVER RECALL list).",