Repository navigation
Batch 673: sandbox refusal alerts once across reloads; worker pipes closed (BACKLOG #6830, #6831) - #3257
Batch 673: sandbox refusal alerts once across reloads; worker pipes closed (BACKLOG #6830, #6831)#3257wshallwshall wants to merge 13 commits into
Conversation
The cache keyed on `is`, so a graph callable returning an equal but new GraphShape per call spawned a worker and raised a first refusal per spawn. Compared with `==`; a hit only refuses. The mid-write latch half is not a bug: workers run the session's snapshot and never read the directory; a test pins it. BACKLOG #6830 Proposed banner: CLOSED. Half 1 real (unmemoized graph callable missed the cache), fixed with a value compare and a failing test. Half 2 not a bug: snapshot, not disk, feeds every respawn; pinned.
A cache hit now carries the graph the worker was compared with. The runner lock comment names the alert gate as the reason for one shape per registry. The changelog fragment is a bullet scoped to direct SandboxSession callers. The duplicate mid-write test is dropped: tests/test_config_snapshot.py already pins that a respawn runs the snapshot, not the disk. BACKLOG #6830 Proposed banner: CLOSED. Half 1 real (unmemoized graph callable missed the cache), fixed with a value compare and a failing test. Half 2 not a bug: the snapshot, not the disk, feeds every respawn.
BACKLOG #6830 Proposed banner: CLOSED. Half 1 real: a SandboxSession graph callable returning an equal but new GraphShape missed the refusal cache, so each spawn started a worker; fixed with a value compare and a failing test (the runner memoizes, so serve was not affected). Half 2 not a bug for any session given a snapshot, which every runner session for a loaded registry is: respawns run the snapshot, never the disk. A snapshot=None session reads the disk once and keeps it by #2596 design; that is the snapshot cache, not the refusal latch.
The session cache matches an equal graph, so its later hits are never first. The gate compared by identity, so a first refusal raised against an equal graph the runner was not serving the same object of (a swap to an equal registry) dropped the alert for the session's life. A runner-level test covers the cache and the gate together. BACKLOG #6830 Proposed banner: CLOSED. Half 1 real: an equal but new GraphShape missed the refusal cache; the cache and the runner's alert gate now both compare by value, with tests. Half 2 not a bug for sessions given a snapshot: respawns run the snapshot, never the disk.
A reload to an equal graph discards the session; with the by-value gate, a refusal still in flight then alerted beside the fresh session's own. The gate now also requires that the refusing session is the one the runner holds for the inbound. Docs, docstrings, the changelog and the replaced-graph test say what the code does. BACKLOG #6830 Proposed banner: CLOSED. Half 1 real: an equal but new GraphShape missed the refusal cache; the cache and the runner's alert gate now compare by value, and the gate alerts only for the live session. Half 2 not a bug for sessions given a snapshot.
The alert gate in _off_loop_sandboxed traded one defect for another: compared by value alone it raised a duplicate alert when a refusal straddled a reload to an equal graph, and with the live-session check added it lost the alert when a same-registry reload (reload(None), a rollback) discarded the session under stop or with no next message. A refusal from a session a reload or a rollback discarded, or against a graph unequal to the one served, is now raised as SandboxSessionClosed by the new _sandboxed_dispatch. It is retried on a fresh session while the same registry is served and the runner is not stopping, and re-pended otherwise, so it neither alerts nor dead-letters; the message's own rerun compares again and that refusal raises the one alert. Functions touched in wiring_runner.py: _off_loop_sandboxed (alert gate and re-pend path) and the new _sandboxed_dispatch. Docs and changelog now state this exactly. BACKLOG #6830
Measured: closing a session left the worker's stdin, stdout and stderr to the collector, which raised three ResourceWarnings, and a reap whose wait timed out passed silently. The reap now closes stdin unless a lookup helper the dispatch gave up on still holds it, in which case that helper closes it when it ends; each drain thread closes the stream it reads; a TimeoutExpired or OSError from the wait logs a WARNING with the inbound and pid only. BACKLOG #6831 Proposed vault banners: #6830: CLOSED (fixed) -- the refusal cache and the alert gate compare the graph by value; a refusal a reload overtook re-pends as a closed session; one alert per refusal across an equal-registry swap, a reload to an equal graph and a same-registry reload, each pinned by a test. #6831: CLOSED (fixed) -- real, measured as three ResourceWarnings; the reap and the drains close the pipes, and a timed-out wait is logged.
The rule for an overtaken refusal is stated in _sandboxed_dispatch alone; the alert sink docstring and the GRAPH_MISMATCH comment point at it instead of restating a narrower copy (it also names a stop, and the same-session rerun when only the graph changed). The new _overtaken helper skips the comparison by value when the compared graph is the served object, the common case for every cached refusal. The retry log line names an overtaken refusal as well as a recycled worker. BACKLOG #6830
Who closes the request pipe is now decided under a lock shared by the dispatch thread and its lookup helper: a helper that had already ended when the dispatch gave up leaves the pipe to the reap, so no pipe is left open and no worker kept in _stdin_held. A failed close logs at DEBUG by exception type. The reap-timeout WARNING says the process tree was reaped rather than killed, since a reap also runs for a worker that exited on its own. A test pins both closers. BACKLOG #6831
A refusal overtaken only by a graph change, with the session still serving, left the overtaken refusal in that session's cache; once an equal graph was served again the rerun was refused from the cache, not first, and no alert was ever raised. _sandboxed_dispatch now discards and closes that session, so the rerun always compares on a fresh one. The _overtaken helper is folded back in. The operator doc no longer says a refusal at stop is never failed: only a discarded session's is. BACKLOG #6830
The stderr relay closes its stream in a nested finally, so a fault in its final flush cannot leave the pipe to the collector. The reap's comment on who writes the request pipe now names the helper the dispatch thread waits on. The ResourceWarning test counts only this worker's three pipes, and the module reuses test_sandbox's session builder. BACKLOG #6831 Proposed vault banners: #6830: CLOSED (fixed) -- half 1 (is vs ==) REAL and fixed: the refusal cache and the alert gate compare the graph by value; a refusal a reload, rollback or graph change overtook re-pends as a closed session (a still-serving session is discarded), so there is one alert per refusal across an equal-registry swap, a reload to an equal graph and a same-registry reload, each pinned by a test. Half 2 (transient latch) not adjudicated here. #6831: CLOSED (fixed) -- REAL, measured as three ResourceWarnings per worker; the reap and the drains close the pipes, an abandoned lookup helper closes the request pipe itself, and a timed-out wait is logged.
In _sandboxed_dispatch's graph-overtaken branch, a session.close() that raises is logged with the inbound only and the refusal is still raised as SandboxSessionClosed, so the message is re-pended, not dead-lettered as a Router or Handler fault. The SandboxSessionClosed text names the overtaken cause generically rather than a reload. CONFIGURATION.md now says a reload refused before its swap keeps the session and its cached refusal, with no new comparison or alert. BACKLOG #6830
CONFIGURATION.md's [sandbox] kill-line paragraph and ADR 0187, as a dated note under Amendment B, now say that a refusal overtaken by a reload, even one re-applying the same registry, gets no alert or runner line and that the message's rerun alerts. Step 4 no longer claims the message always runs again: a row whose inbound the reload removed never runs, and repeated re-pends on a pooled lane count toward infra_fault_stop_after. Text only. BACKLOG #6830
|
QA: level xhigh. Rounds: 2 + 2 unrepaired. Tag: |
|
OWNER RULING, 2026-11-24, in the batch 673 Manager's chat. The question was whether re-pending an overtaken refusal, whose rerun still alerts and dead-letters a real mismatch, fits the 2026-10-16 ruling 'alert, keep dead-letter'. The owner answered: 'Fits; merge'. The hold is lifted, and the Lander may merge on its usual checks. |
|
Lander hold on head 3043fe6. Held: a red check caused by this PR. Shard 3 fails on ubuntu-latest and windows-2022 in Also needed: say whether the relayed ruling covers findings 1 and 2. The owner ruling "Fits; merge" (relayed at 16:59Z) answers whether re-pending fits. QA findings 1 and 2 are separate behaviour changes: (1) an overtaken refusal logs ERROR with a traceback, then backs off 1 s; (2) the inline close can stall the inbound's worker. Finding 2 is a liveness risk, not a fail-closed refusal. Either state that the ruling covered both, quoting the owner's question and answer, or fix them, for example by moving the close off the worker. A fix commit needs its own review round. |
Batch 673 (pipeline). This is its own PR because it changes the sandbox refusal alert and the sandbox's re-pend path, and adds a dated note to ADR 0187. It merges clean with current main (
git merge-treeexit 0).OWNER QUESTION -- this PR holds until the owner rules. With this change, a graph-mismatch refusal that a reload, rollback or graph change has overtaken is raised as
SandboxSessionClosed. It is re-pended or retried on a fresh session, with no alert, instead of being dead-lettered. The message's rerun compares against the current graph. If the mismatch still stands, the rerun alerts and dead-letters as before. A reviewer reads this as departing from the owner ruling of 2026-10-16 (vault #2724: "alert, keep dead-letter"). The Manager reads that ruling as still met on the rerun. The Manager has put the question to the owner; record the answer here.BACKLOG #6830 -- one alert per refusal across reloads
b673/6830-graphshape-compare, head3043fe660c388c3f4c6dfff833f7a90631835f50.isagainst==) is real and fixed, and==is kept in the session's refusal cache.wiring_runner.py:_off_loop_sandboxed(the alert gate and the retry/re-pend path) and adds a new_sandboxed_dispatch.SandboxSessionClosed.session.close()raises in that branch, a WARNING is logged andSandboxSessionClosedis still raised.changelog.d/6830.fixed.md.isvs==) REAL and fixed; a refusal overtaken by a reload, a rollback or a graph change re-pends as a closed session, and its rerun alerts if the cause stands; one alert per refusal, each case pinned. Half 2 (the transient-mismatch latch) not adjudicated.BACKLOG #6831 -- the sandbox closes its worker's pipes
tests/test_sandbox_pipe_close.py, andchangelog.d/6831.fixed.md.Checks (Builder):
QA: xhigh. Rounds: 2 + 2 unrepaired. Tag:
xhigh effort -> 10 inline angles -> dedup (no verify) -> sweep -> <=15 findings(round-ec855c51, round-22802361, round-b8dd91aa, round-c121d5af). Manager-directed repairs followed each unrepaired round. The head,3043fe66, is text only, and no review round ran on it.Open findings, to file under R2:
stopcancels it.name=<fd>filter, and_reapis not called on a held or released worker in the tests.