Repository navigation
Description
Summary
services/sandbox/src/session/buildkit-network-guard.test.ts › "refuses a foreign network without touching its firewall or attaching" failed once in a merge-group run and passes on its own. Its failure took a PR out of the merge queue.
What was observed
-
Merge-group run 38683015237, job Unit (workspaces) (116251549542), 2026-10-15 04:44Z, for feat(platform): one template catalog, general syncs, no default automations #4988 — a PR that changes nothing under
services/sandbox:error: Expected network attachment to fail at expectFailure (services/sandbox/src/session/buildkit-network-guard.test.ts:132:13) at async <anonymous> (services/sandbox/src/session/buildkit-network-guard.test.ts:309:13) (fail) verified session build-network attachment > refuses a foreign network without touching its firewall or attaching [43.96ms]Every other case in the file passed in that run, including the sibling "refuses a foreign session …" right before it.
-
The same file passed 25/25 eight times in a row on a laptop (macOS, Bun 1.4.2) against
main56c44e3. The file was last changed in perf(sandbox): cut BuildKit stack upkeep, idle time and disk #4604. -
Not examined: how often it fails across runs (only this one failure was seen), and whether the code under test leaves a
dockercall running afterattachBuildkitNetworkreturns or throws.
How the test works (main 56c44e3)
beforeAllwrites a fakedockerscript into one temp directory shared by every case (buildkit-network-guard.test.ts:141-147);beforeEachrewritesstate.jsonand emptiescalls.jsonlthere (:148-151).- The fake reads
state.jsonwhen it starts (:24-25) and writes it back when it ends (:28-29), whatever the command. - The foreign-network case puts
tale.org: other-orgon the network instate.json(:301-308) and expects the guard to refuse (:309).
A plausible mechanism, not confirmed: a fake docker process from the previous case (or from the code's own background work) still running when this case saves its state, writing its older copy of state.json back on exit — the guard then reads a network of its own organization and attaches.
Options
- A temp directory (state and calls) per case instead of per file.
- The fake writes
state.jsononly for commands that change it. - Confirm and remove any
dockercall the code under test leaves running after it returns. - Retry the case on failure in CI.
Questions
- Does
attachBuildkitNetworkor anything it calls start adockerprocess it does not await? - Has this case failed in other merge-group or PR runs?
Activity
fix(sandbox): wait for both build-network reads before refusing