fix(loop-audit,loop-sandbox): correct gate.yaml auto-fix schema and Windows spawn ENOENT#382
Merged
cobusgreyling merged 1 commit intoJul 25, 2026
Conversation
…indows spawn ENOENT
loop-audit --auto-fix generated a gate.yaml shaped { gates: [...] },
which loop-gate check's loadGateConfig rejects outright (it requires
{ version: 1, denylist: string[], ... }). The auto-fix silently produced
a file that broke the tool it was meant to satisfy. Now emits the real
schema, mirroring templates/gate.yaml.template.
loop-sandbox run spawns an arbitrary user command; on Windows, npm .cmd/
.bat shims (npx, tsc, ...) fail with ENOENT without shell: true, but
forcing shell: true unconditionally breaks commands relying on exact
argv quoting (node -e "..."). Now retries once with a shell only after
an ENOENT on Windows, guarding against the failed attempt's late 'close'
event resolving the run with a stale exit code ahead of the retry.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
cobusgreyling
approved these changes
Jul 25, 2026
cobusgreyling
left a comment
Owner
There was a problem hiding this comment.
LGTM — real bugs: gate.yaml auto-fix schema now matches loop-gate; Windows ENOENT retry for npm shims with superseded-close race guarded. Regression test added. CI green.
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.
Summary
Two independent, real bugs found while surveying recent upstream work
(loop-sandbox, MCP loop-gate/loop-audit integration,
--auto-fix).What
1.
loop-audit --auto-fixgenerated agate.yamlthatloop-gaterejects.loop-gate checkrequires{ version: 1, denylist: string[], maxFiles?, autoMergeAllowlist? }and throws on anything else. The auto-fix templateinstead wrote
{ gates: [{ name, description, required_approvers }] }-- ashape
loop-gatehas never understood. Sinceloop-audit's own gateYamlsignal only checks that the file exists (not its contents), this passed
audit cleanly while silently breaking
loop-gate checkdownstream. FixedGATE_YAML_TEMPLATEintools/loop-audit/src/autofixer.tsto emit the realschema, mirroring
templates/gate.yaml.template.2.
loop-sandbox runfails on Windows for any npm-installed CLI.loop-sandboxspawns the user's command withshell: falseby default. OnWindows, npm
.cmd/.batshims (npx,tsc,eslint, ...) can't beexec'd directly without a shell and fail with
ENOENT-- the package's ownREADME example (
loop-sandbox run -- npx my-agent) doesn't work as written.Fixed by retrying once with
shell: truespecifically onENOENT+Windows, rather than forcing
shell: trueunconditionally (which breakscommands relying on exact argv quoting, e.g.
node -e "...", since cmd.exereparses the command line differently).
Tested
Both packages: full clean rebuild (
rm -rf node_modules dist && npm install) +npm test, all green.Added a regression test for the gate.yaml fix (
tools/loop-audit/test/autofixer.test.mjs)asserting the generated file actually parses to the schema
loop-gateexpects.
The sandbox fix went through two more rounds after the first version looked
done: the initial "always use shell:true on Windows" attempt broke an
existing test (
node -e "..."with embedded quotes), so it was narrowed toretry-on-ENOENT only. Then, testing the retry path directly against a real
Windows machine turned up a second bug: the failed first attempt's
closeevent still fires a few milliseconds after its
errorevent, and without aguard it would resolve the run's promise with the failed attempt's bogus
exit code before the retry (still running) produced its real result --
meaning cleanup could run while the actual command was still executing
against the worktree. Fixed with a small flag that ignores the superseded
first attempt's late events once a retry is in flight, and reproduced the
race locally both before and after the fix to confirm it's actually closed.