test(FAFF-367): add merge-gate shell control-flow tests#286
Merged
alechill merged 2 commits intoJul 7, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
node:testcoverage for the impure SHELL control-flow branches offaff merge-gatethatmergeGateSelftest(pure cores) andtest/merge-gate.test.mjs(arg validation) don't reach — the--check-onlyshort-circuit, the plain-refuse exit, the already-MERGED idempotent no-op, and the FAFF-375--human-overrideTTY fence. Test-only: no production change to the merge interlock.Mechanism: a stub
ghexecutable is prepended toPATH, the realfaff merge-gateis driven viarunCliwith a doctored env, and assertions bind to the CLI seam (exit code /--jsonstdout / on-disk artifacts) per ADR 0002. A merge sentinel file (touched only ongh pr merge) proves whether an actual merge was attempted; the stub exits non-zero on any unhandled subcommand so a drift in the shell'sghsurface fails loudly.Acceptance Criteria
--check-only(merge-ok floor + refuse floor) and the--human-overridefence; all assertions bind to exit code /--jsonstdout / on-disk artifacts (no narrative asserts).Verified:
test/merge-gate-controlflow.test.mjs— 7/7 passing (node --test).node --testwith no new dependency and no network.Verified: zero deps (
node:test/node:child_process/node:fsonly); the stub answers all gh calls locally.ghrecordspr mergevia a sentinel; unhandled subcommand exits non-zero.Verified:
STUB_GHcase-dispatch +exit 3default; execute-on-merge-ok test asserts sentinel PRESENT, check-only tests assert ABSENT.Verified: cases 1-5 in the test file.
--interactive --human-override→ exit 2 before any gh call, no override file written.Verified: cases 6-7.
Drift note (FAFF-375, PR #285)
FAFF-375 merged ~1h before this build and fences
--human-override/--allow-no-cionprocess.stdin.isTTY===true AND --interactive, returning exit 2 before any gh call.runClispawns a non-TTY child, so the spec's original "override recorded + merge falls through" scenario is unreachable from the harness — the fence fires first. Tests assert the current behaviour. Separately, the shipped refuse-return precedes the--check-onlyshort-circuit, so--check-onlyon a refuse floor returns exit 1 refuse (not a false-green merge-ok) — the code is safer than the spec's test-case prose implied. Tests follow the code.Closes FAFF-367.