Repository navigation
fix(container-gateway-hook): wait for a serving backend; review follow-ups - #1826
Merged
potiuk merged 1 commit intoOct 25, 2026
Merged
Conversation
…w-ups The gateway takes its pid lock before it discovers backends and binds its sockets, so waiting on `running` let the triggering command race the bind. ensure now waits for `status` to report a serving backend, and stops early once the gateway has come up and gone again (no backend) or never came up, instead of stalling every container command for five seconds. A settings path that is not a regular file now refuses the start without being opened: a FIFO planted by sandboxed code blocked jq until the hook timed out. The PreToolUse wiring drops its `if` filters, which missed docker-compose, podman-compose and path-qualified CLIs; the script's own check leaves within about 10 ms. The spec's sample wiring uses absolute per-machine paths, and the agent-isolation README no longer claims the hook uses an .apache-magpie/ snapshot. Generated-by: Claude Code (Claude Opus 5)
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
Follow-up to #1814. It was merged at its third commit, so the fixes from its review round never reached
main:ensurewaits on the wrong signal. The gateway takes its pid lock before it discovers backends, probes egress and binds its sockets. Waiting onstatus'srunningtherefore lets the triggeringdocker/podmancommand race the bind, the race the wait exists to prevent.ensurenow waits forstatusto report a serving backend (servingnon-empty).runningnever became true and every container command polled for the full five seconds. The wait now ends once the gateway has come up and gone again, or never came up within the first second.-rtest. A FIFO planted by sandboxed code where a settings file would be (in a subdirectory the agentcds into, which Claude Code does not write-protect) blockedjquntil the 30 s hook timeout, before every container command. A settings path that exists but is not a regular file now refuses the start without being opened.iffilters miss commands.Bash(docker *)/Bash(podman *)cannot matchdocker-compose,podman-composeor/usr/local/bin/docker. The documentedPreToolUsewiring drops them; the script's own check leaves within about 10 ms for any other command.~there is expanded from$HOME, which the setup guide already rules out..apache-magpie/snapshot. It never does.Type of change
.claude/skills/<name>/) — eval fixtures updated belowtools/<system>/*.md)tools/*/withpyproject.toml)docs/,README.md,CONTRIBUTING.md)projects/_template/)prek, workflows, validators)Test plan
tools/agent-isolation/tests/test_container_gateway_hook.py, run for real (not dry-run) against a fake gateway package:statuscall);main's hook.uv run pytest tests/test_container_gateway_hook.pyintools/agent-isolation: all 118 pass, outside the sandbox.ensurefordocker-compose psbrought it up and serving in 0.63 s;ensureforlsexited in 8 ms;docker runsucceeded straight after.prek run --all-filespasses locallyprek run --all-filesin CIRFC-AI-0004 compliance
Linked issues
Follows #1814.
Notes for reviewers (optional)
These came from the second reads on #1814: codex via
adversarial-review, and an independent review. Neither found a sandbox escape. A microseconds-wide pid-file race in the gateway (probe_pid_lockunlocks before it unlinks) predates both PRs and is left for a separate change.🤖 Generated with Claude Code