feat(sdk): decide sandbox waits on the events socket and read the rest in batches
What
Sandbox waits in all three SDKs (Python, TypeScript, Go) now follow the updated
client rules of contract/sandbox-events-protocol.json, copied byte for byte
from the platform's final version of the file (it now also states the
batched confirming reads, the refused-mint and socket-retry jitter, the
answer-specific final check and the batch-wait failure details):
- liveness: while a socket has waiters it sends one
pingafter 5 s of
silence; no frame within 10 s of it closes the socket and reconnects
(backoff, resubscribe). Its waiters stay registered. - no polling while the socket works: the early per-wait status reads are
removed (Python_run_early_probe, TypeScriptrunEarlyProbe, Go
waitProbe), and so is the "final reserve" of single reads. - confirm: every terminal state that is not the wait's target,
destroyedincluded, whether a live frame reports it or the hub already
held it when the wait registered, is provisional until the platform commits
it (a runner can push one that a fresh snapshot repeats), so it is confirmed
by ONE read while budget remains, shared by every wait on that sandbox
that follows the same socket, and that read decides for each wait by its own
targets (one read can end one wait and refute the report for another): a
target returns, a state terminal for the wait that no lag can show (or the
reported state itself, shown again) raises with the read's state and
reason, and any other state refutes the report for that wait. The refuted(wire status, version)is kept per id
(cleared when the id is released): frames and held states repeating it
trigger no read and decide nothing. While it keeps repeating, a refuted
report is read again on a back-off of 2 s, 4 s, 8 s, 16 s, then every
30 s (each lengthened by 0-20%, never shortened, counted from when the
latest read's answer arrived, the same instant for every sandbox one
request read), shared by every
wait on the id while some wait still finds it refuted, because a read can be
answered before the platform commits the report and that commit sends no
new frame: without these re-reads a wait with no deadline (and so no final
check) would never learn of it. The re-reads stop when the stream reports
another state, a read decides, or the id's last wait leaves. Confirming
reads are batched: those that fall due within a 20 ms collection window
for ids of one socket (first reads and back-off re-reads alike) go out as
one unheldGET /sandboxes/batch-wait?ids=…with no wait target, at most
200 sandboxes and 11,000 URL-encoded id bytes per request, each id counted
with its 3-byte%2Cseparator, under the API's 12,288-byte query limit, which the API answers at
once from the same view as the single read; a window holding one id uses
the plainGET /sandboxes/{id}, which also refreshes every detail field.
The answer decides each id as its plain read would; an omitted id is
not found, or unknown when the answer is partial (a region not covered,
or an item the client cannot match, the same rule as the fallback
batches); a failed request is a
failed read of each id, never a not-found. The macOS read after a target
stays a plainGET(it needs fields batch items lack). Cost: 500 sandboxes
failing within a second cost at least 3 requests per endpoint per round
instead of 500 (more when long ids reach the 12,288-byte query-string limit
first: a batch is cut at 200 sandboxes or at the 11,000-byte id budget, whichever comes
first), and a stuck id's back-off re-read joins the next confirming batch due
on its endpoint: the back-off's jitter is drawn once per collection window
and shared by every report that window's requests read (all its chunks
alike), so reports read together fall due
together and stay batched (500 refuted reports collected in one 20 ms
window: at most 3 requests per back-off step, no plain reads, over five
minutes; 500 reports arriving over a second land in several windows that
the shared lengthening keeps together but does not merge: for example
about 13-16 requests per later step and 210-277 over five minutes in the
runs measured; these are examples, not bounds). Each such request is bounded by the latest budget among
its waits when it goes out (a wait that joined during the collection
window counts; one that joins after it went out and outlives a request cut
short by that bound reads again instead of taking the report) and
cancelled once every wait riding it has left; its answer
decides only the waits still waiting. At the final check a snapshot
repeating a refuted report does not count as an answer. The confirming
read goes through one wait's client; if that client itself refuses it
(401, 403, closed), only its waits fail and the others read again through
their own. No budget left, or a read that fails with any other error:
the report itself raises, for the waits it is a terminal state of (the
others wait on; the create and fork waits return their handle instead,
as before). These raise their own error instead: refused credentials and
a closed client (for the waits reading through that client); a 404,
except after a reporteddestroyed, which it confirms; the SDK's own 400
for a response that breaks the contract (all three SDKs); and, in Python
and TypeScript, an unexpected error that is not an SDK error, as it is. A wait whose target is
destroyed(delete) ends on it with no read. Only a held target of
restart()is confirmed by re-subscribing the id: the held target, or a
snapshot answering a subscribe sent before then, confirms nothing; the
snapshot that answers a subscribe sent since then decides, and so does a
live event, a new transition (each id keeps the send times
of its unanswered subscribes; the server may fold queued snapshots of one
id, which leaves one extra old entry per fold until the id's last wait
leaves or the socket closes, so a later bounded wait on that id can cost
one unheld final-check read, because its own answer pairs with the older
send, and a restart step waits for one more snapshot, or reads at its
final check. A fold needs overlapping subscribes of one id under write
back-pressure, so it is rare; an exact rule needs the server to echo a
per-id subscribe generation). Of the errors only a per-idNOT_FOUND,
which is ordered with the snapshots, pops the oldest send time. A per-id
LIMITmeans one subscribe of the id gets no answer, but it travels apart
from the snapshots with no order (subscribe #2'sLIMITcan arrive before
subscribe #1's queued snapshot), so it drops the newest send time instead:
every entry left is at or before the send its answer really answers, so
an answer is never judged newer than it is, and refused retries (one every
2 s while an id is refused) no longer pile up. AMALFORMED, or aLIMIT
without an id, drops nothing. - final_check: a bounded wait the event stream decides (a wait read in
batches has none), still pending when min(15 s, budget/4) (±10%) is left,
re-subscribes its id once (batched into the next subscribe
frame); only if this id's own answer (a snapshot or a per-id NOT_FOUND
answering that re-subscribe) does not arrive within min(10 s, half the
budget left), counted from when the re-subscribe actually went out (not when
it was queued), on the socket that holds the id by then, or the id is
answered withLIMIT(then at once), is the sandbox read once, inside the
budget (a 60 s wait re-subscribes at ~45 s and reads at ~52.5 s). Another
id's frame, a pong and opening a replacement socket do not count. That read is not retried: a transient failure leaves the
wait to run out with it as the cause, an answer that omits the id with
X-Daytona-Cells-Failedends it too (that unread read, a 503
SERVICE_UNAVAILABLEfrom the SDK, becomes the timeout's cause, as does an
ordinary round's partial answer), and any other failure ends the wait
with that error. - fallback: when no socket can decide (a mint 404 or 501
WORKLOAD_PLANE_ELSEWHERE; any other 501 is a failed connect and is
retried; three failed connects, or
DAYTONA_SANDBOX_EVENTS=0; and after a reconnect, until the new socket's
first frame proves it; events off and a permanently refused mint (404,
501WORKLOAD_PLANE_ELSEWHERE, and in Go 401 / 403) read this way for as
long as the waits last, while a mint refused with 429 reads this way only
while the next mint is more than 1 s away; three credential refusals in a row are the
exception: Python and TypeScript end that socket's waits with
AuthenticationErrorand read nothing, while Go reads them in batches,
where the API's own refusal ends them; a mint refused with 401 or 403
likewise ends the waits with that error in Python and TypeScript, while Go
reads them in batches for good),
the client's waits are read together withGET /sandboxes/batch-wait,
grouped by the event endpoint each id would ride (the learned
X-Daytona-Cellvalue, else the id's region tag): at most 200 sandboxes
and 11,000 URL-encoded id bytes per request, each id counted with its
3-byte%2Cseparator, under the API's 12,288-byte query limit, one request per wait status held withwait/
wait_exactandtimeout_ms= 30000 or the shortest remaining budget,
several-state waits unheld. A batch counts sandboxes, not waits: a wait on
a sandbox a batch already reads joins it at no cost, so 1,000 waits on one
sandbox are one request carrying one id.- staggered arrival: a wait that registers while its query's batch is on
the wire joins it; once 1 s, lengthened by 0–20%, has passed since that
request began (at once if it already has), the request is cancelled and re-issued with the
newcomers. So waits that arrive while a batch round is active still share one held
request per 200 ids and query, ≥1 s apart, at most ~1 s extra first-read
latency. - short-circuit ids: an id whose last read showed a state the server
answers a held read at once on (loosewaiton
stopping/stopped/deleting/deleted/failed/lost,wait_exacton
failed/lost) but that its waiter does not take moves to the unheld group,
so one such id does not turn a 200-id held request into polling. - spacing: re-issued no sooner than 1 s after the previous request
went out (timed from the send itself, after the request's credential is
resolved, not from when the round was scheduled), growing to 2 s while
nothing changed; each round's interval is
lengthened by 0–20% and never shortened, so 1 s is a hard floor per
batch; an answer that arrives once the next round was due (a held read,
its first renewal included) delays that round by the lengthening,
counted from the answer (at most 0.4 s). Transient failures back off (200 ms doubling to 5 s, at least the
retry hint, lengthened the same way); a 429/503 retry hint pauses every
batch of the client, each other batch resuming up to 10% of the hint
later, and the batch that got it up to 20% later (its own retry
lengthening); a 503
without a hint holds its batch until the next round. - failures: a fallback batch request follows the single-read retry
policy. A transient failure (no response, a client timeout, a 429, a 5xx
other than 501; batch-wait never answersLIMIT_EXCEEDED) is retried next
round after the shared retry hint (a confirming read and the event-stream
final check's one read are never retried); any other non-2xx answer (401, 403, any other
4xx, 501) ends that batch's waits at once with that error, the final
check's included, never as a not-found. Entries are matched to waits by
sandbox identity, not by the spelling sent. - routing: a learned endpoint is keyed by the region a wait keys on (the
id's region tag, else the sandbox's region), so a sandbox whose id
carries no tag rides, and is batched with, its region's learned endpoint
rather than mixing with another endpoint's. - deadline: a batched answer that arrives once a wait's budget is spent
does not decide it (all three SDKs). - matching: answers are matched to waits by sandbox identity (a bare
UUID, base58 of its 16 bytes, with or withoutsbx_and the region tag),
not by spelling, since the API answers with the canonical id. An id the
response omits is not found (destroyedfor a delete), unless the
response carriesX-Daytona-Cells-Failed, an item that names no id
(skipped: no wait can tell it answers it) or an unrequested item whose id
decodes to no identity: then it is unknown and read again. A malformed
item that names its id fails only its own wait. An id too long for any
request (a subscribe frame or a batched read) is refused with a 400 by
every wait and lifecycle call before any request (Go'sNoWaitand
Start's first read included), and so is a well-formed id of another
kind (vol_,img_,snap_,fn_plus base58 of a UUID, optionally
followed by-and a non-empty region tag), whether or not the tag is
there: the API refuses a whole batch-wait carrying an untagged one with
400, and such an id would share a batch with every untagged sandbox id
(a tagged one the API treats as a sandbox it does not find). - sparse items: batch-wait items carry no labels, lifecycle policy, spot
fields, macOS boot mode, reservation or toolbox URL, and send the run
timestamps as null. The handle takes the item's state; its error message
follows presence (the API always sends it, null when no failure is
recorded, so a null clears a stale one, as a frame without one does; an
omitted one keeps the handle's); every other field it carries (present
and not null) replaces the handle's (a changedcpu, for example); an
omitted or null field keeps the handle's value. A toolbox URL is validated and adopted only when
present. The macOSstart()/resume()read after the target also
follows a batch-decided target. - The socket is tried again 60 s after three failed connects, lengthened by
a random 0–20%.
- staggered arrival: a wait that registers while its query's batch is on
- next connect far away: whenever the socket is not open and its next
connect is more than 1 s (the batches' minimum interval) away, for a retry
hint (a 503 withRetry-After, say), a refused mint or the reconnect
back-off, its waits are read in batches meanwhile; the next socket's first
frame stops them. Before, a hinted retry left the waits unread until the
third failed connect. - mint_refused: a 429 from the ticket mint or from the upgrade (the
socket cap) is not a failed connect; each wait is the larger of the
Retry-Afterlengthened by a random 0–20% and a full-jitter draw of the
reconnect back-off (250 ms doubling to 30 s), so 400 clients refused
together retry spread over at least ~20% of the hint instead of in one
100 ms window; the count resets only when a socket opens; the waits use
batched reads meanwhile only while the next mint is more than 1 s away. - limits: subscribe/unsubscribe frames carry ≤ 1000 ids and ≤ 65,536
encoded bytes (compact JSON); a token bucket of 8000 ids/s with a 32000
burst per socket, refilled to the full burst when a socket opens, which once
spent defers the next flush until min(1000, deferred) tokens have accrued
(Go previously re-armed it every ~125 µs for 1-id frames). A socket's
subscribe and unsubscribe frames go out one batch at a time, in order, so an
unsubscribe never overtakes a re-subscribe waiting for budget. - reconnects: a reconnect waits out the whole of the server's retry hint
(only the backoff is capped); after repeated credential refusals, Go reads
new waits in batches during the fallback window instead of leaving them on
no socket. A batched result that arrives once the budget is spent does not
end the wait (all three SDKs settle the deadline first).
Kept as they were: stop()'s wait_exact, the fork wait targets, process
waits, the token-refresh pause, the reconcile timer, wait errors and timeouts.
Waits on a closed client now raise ClientClosedError in every SDK (the
Python and TypeScript events hub raised a 503 ServiceUnavailableError).
Each SDK README now has one "How waits work" section with the full rule set;
docstrings, the development notes and the changelog fragments state only
their part and point to it.
Why
Every waiting sandbox used to cost its own HTTP reads even while the events
socket was healthy (early probes after ~10 s of socket silence, a final
reserve read), and without a socket every wait polled on its own. Load grew
linearly with the number of waits.
Request counts
HTTP sandbox reads for one minute of waiting with no transition (60 s budget,
one target state), for waits that start together. Waits that keep arriving
cost more in the no-socket columns: 1,000 / 10,000 distinct sandboxes
arriving one per millisecond made 15 / 150 held requests in the first minute
(at most 5 / 50 in flight, the 1 s floor between two requests of one batch
holding), against 10 / 100 for the same waits started together.
"Before" is derived from the previous rules, "after" is what the new tests
count. These are HTTP requests; snapshot rows on the socket are counted
separately below.
| Waits | Healthy socket (before → after) | Open but silent socket (before → after) | No socket, one target (before → after) | No socket, several targets (before → after) |
|---|---|---|---|---|
| 1 | ~1 → 0 | ~6 → 0 sandbox reads, 1 reconnect (silent for the whole minute: 1 batched read, 3 mints, 2 reconnects) | ~2 → ~2 | ~30 → ~30 |
| 1,000 | ~1,000 → 0 | ~6,000 → 0, 1 reconnect (silent for the whole minute: 5 batched reads, 3 mints, 2 reconnects) | ~2,000 → ~10 | ~30,000 → ~150 |
| 10,000 | ~10,000 → 0 | ~60,000 → 0, 1 reconnect per socket (silent for the whole minute: 50 batched reads, 3 mints, 2 reconnects) | ~20,000 → ~100 | ~300,000 → ~1,500 |
- Healthy socket: the final check is a re-subscribe; its snapshot decides. A
terminal report is confirmed by one read per sandbox (shared by its
waits), and reads due together are batched: N sandboxes failing at once
cost at least ceil(N/200) batch-wait requests per endpoint, more when long
ids reach the query-byte budget first (a lone one, one plain read); one the read refutes is re-read on a back-off while the stream keeps
repeating it, batched the same way; not counted above (no transition). - Open but silent socket: the client pings after 5 s, replaces the socket 10 s
later and resubscribes its waits. The first count assumes the replacement
socket answers; when the socket stays silent for the whole minute, the
liveness rule replaces it twice; after the third failed connect its waits
are read in ordinary held fallback batches (the bracketed counts,
measured), not final-check reads. A sandbox is read only if no frame arrives
after the final check: one batched read per 200 waits when the reads fall
due together, but the final check's ±10% mark spreads 1,000 waits started
together over a 3 s envelope for 60 s budgets (the mark is 15 s ±1.5 s;
measured marks 43.5-46.5 s into the wait) and a batch gathers only
5-50 ms, so 1,000 waits
whose re-subscribe goes unanswered measured 56-58 requests (fewer waits
per read, too, when long ids reach the query-byte budget first). - No socket: held batches answer when the state is reached or after 30 s
(2 rounds a minute per 200 waits); unheld batches go out every 2 s while
nothing changes. The counts hold per event endpoint and kind of wait
(target query): each further endpoint or query adds its own batches. They
are lower bounds: a batch is cut at 200 sandboxes or at the 11,000-byte id
budget (each id counted with its 3-byte%2Cseparator, under the API's
12,288-byte query limit), so long ids need more
requests. Staggered arrival adds at most one re-issue per second per
batch while waits keep arriving (test: 1,000 waits arriving over ~1–2 s →
≤ 5 held at once). - Snapshot rows (socket, not HTTP): each subscribe costs the server one
snapshot row per id. Per wait: one at registration, one at the final check,
plus the stale sweep's re-subscribe of an id silent for half its wait's
age (at least 1 s, at most 3 s; 15 s once watched for a minute; all three
SDKs now). Measured at 10,000 silent waits on one socket: about 100,000
rows in the first minute (a mean of about 1,650/s, with single seconds of
10,000–11,500 at registration and at the reconcile; Python's sweep is
capped at 1,500 ids/s), then 670–830 rows/s, including one 10,000-row
reconcile second per minute (Go previously stayed at the 3 s rate for
the whole wait). So long
waits are not free for the server: HTTP reads stay flat as waits grow,
but snapshot work on the socket grows with the number of waiting
sandboxes.
Verification
- Python: full suite (
pytest -n 8 -m "not timing"and-m timing) on 3.15
and 3.11, ruff, mypy;_syncregenerated. - TypeScript: full jest, typecheck, lint, build.
- Go:
go test -race -shuffle=on ./...,go vet(with and without
-tags e2e),golangci-lint. - New tests per SDK (
tests/test_events_socket_only.py,
tests/events-socket-only.test.ts,sdk-go/sandbox_wait_socket_only_test.go,
sdk-go/internal/events/timers_test.go), each shown failing without its
fix: staggered arrival shares held requests (1,000 waits one every ms →
≤ 5 in flight); a wait starting while a batch is held joins it (one
re-issue with both ids, ≥ the min interval later); a sparse batch item keeps
labels / lifecycle policy / spot / timestamps / fork origin; a bare-UUID and
sbx_-less id match the canonical answer (delete not done early, wait not
not-found); a reconnect inside the final check's window still reads once;
refused mints back off max(hint, back-off); a short-circuit id leaves the
held batch; a malformed item fails only its wait; the final check's read
stops after one partial answer; frames stay ≤ 65,536 bytes; the final-check
mark's jitter; a live terminal event confirmed by one read (raises /
resolves / waits on). Go also: token-bucket flush deferral, the slow stale
sweep, and the final check read's failure keeping the timeout cause.
Earlier: 1,000 waits on a healthy socket → 0 HTTP reads, silent socket → one
reconnect, partial answers, endpoint grouping, byte-limit split, non-2xx
batch → failed read, constants pinned to the contract. - Second review round, each shown failing without its fix, per SDK: a live
destroyedthat is not the target is confirmed by one read (confirmed,
gone, refuted), and so is a held one (onlyrestart()'s held target is
confirmed by a fresh snapshot); a 501
WORKLOAD_PLANE_ELSEWHEREmint selects the batched reads (Python,
TypeScript; Go already did); an id too long for any batch fails with no
request; the final check's window starts when its re-subscribe goes out and
judges the socket that holds the id then; batched reads go on until a new
socket's first frame; each new socket starts with the full subscribe burst;
an unsubscribe never overtakes a subscribe waiting for budget (Python,
TypeScript); a wait on an already-closed client never returns a held state
(TypeScript); a reconnect keeps the whole retry hint; Go: held replays carry
no answered time, new waits read in batches after repeated credential
refusals, a late batch result does not end a spent wait. Test servers now
match the batch-wait path exactly and treat a planned 404 as a failed batch
request (an omitted id is an explicit emptysandboxes). - Third review round, each shown failing without its fix, per SDK: a report
that every snapshot repeats and every read refutes is read on the back-off
(2, 4, 8, 16 s, then every 30 s) rather than on every snapshot; a re-read that finds the report committed
raises; a heldfailed/destroyedgets one plain read; two waits on one
sandbox agree on a refuted report; the final check reads when its snapshot
repeats a refuted report; no two rounds of a batch start less than 1 s
apart; an item naming no id is skipped; a batch 503 is retried and a 400 or
501 ends its waits; a mint 501WORKLOAD_PLANE_ELSEWHEREthen a batch 501
ends the wait after one batched read; an id too long for any request fails before a subscribe; a
server-shaped batch item replacescpuand keeps the fields it omits; a
closed client during the macOS read after the target fails the wait;
TypeScript: a wait joining just after a re-issue is read within about 1 s
(the re-issued request's join callback is no longer cleared by the aborted
one); Go: omitted labels stay unknown, a malformed toolbox URL in a batch
item fails the wait, the stale sweep scales with the watch's age. - Fourth review round, each shown failing without its fix: a per-id
LIMIT
for subscribe #2 followed by #1's snapshot does not confirm #2 (all three
SDKs); a mint 503 withRetry-After: 30leads to batched reads within
about 1 s, and with a short hint the next socket's first frame stops them
(all three SDKs); a confirming read is exactly one plain
GET /sandboxes/{id}and its 404 confirms a reporteddestroyed(Python,
TypeScript; Go already asserted it); a sandbox id without a region tag
learns its region's endpoint (all three SDKs); a batched answer after the
deadline does not settle the wait (Python, TypeScript); Python: a send
queued for a closed connection is not sent on its replacement; TypeScript:
the final check's wait for its re-subscribe follows the id to a socket
created later and is dropped when the waiter settles, and a wait whose
budget is spent at registration subscribes nothing; Go: the final check
waits for its re-subscribe on a send notification from the hub instead of
polling every 10 ms, a merged watch keeps the oldest watch start, the
liveness test synchronizes on the processed pong (200 runs under-race). - Fifth review round, each shown failing without its fix: an unbounded wait
ends when the platform commits a refuted report (it hung before), and a
report refuted for five minutes costs at most about 13 reads shared by its
waits, whose re-reads stop when the stream reports another state (all
three SDKs); a volume id next to 199 untagged sandbox ids fails alone while
the 199 resolve (all three); a batch item'serrorfollows presence (all
three); a confirming read through a closed client fails only that client's
waits (Python, TypeScript; Go's confirmations are per client); the plain
confirming read rebinds a Python handle to a new toolbox URL; TypeScript: a
newcomer to an idle batch is read within about 1 s of the last round; Go:
an older confirming read on the wire never writes into a newer report
(-race), and the confirmations are keyed by sandbox identity. - Sixth review round, each shown failing without its fix: a batch round is
timed from when its request goes out, so a first request that leaves late
(resolving its credential) no longer lets the second follow sooner than
the floor (all three SDKs; this is what a Python 3.13 CI run measured); a
subscribe's send time is recorded only once its frame is written (all
three); a mint 501 with another code is retried like a failed connect (all
three); a spent budget while a terminal report is being confirmed raises
the report in Go too, as in Python and TypeScript; TypeScript: one 429
pause holds two batches; Go: the socket loop arms its timers at absolute
deadlines, which removed a test-only race in the stale-sweep test (200
runs under-race -shuffle=on). - Changelog:
changelog.d/822.changed.md; unreleased fragments that
described the confirmation were updated. scripts/gen-contract-types.sh --checkand the changelog check pass.- Live: this PR's E2E jobs run the Python, TypeScript and Go suites against
the hosted API, which already servesGET /sandboxes/batch-wait.
Merge order
This copies the platform's final contract/sandbox-events-protocol.json
byte for byte, so the next contract refresh keeps it. The SDK code needs no
server deployment to work: every endpoint the new rules use is already
served (GET /sandboxes/batch-wait, which names unreadable endpoints in
X-Daytona-Cells-Failed; the socket's ping / pong; re-subscribe
snapshots). Merging waits on the deployed-contract check, as "Known gates"
says.
Also fixed: an unsubscribe dropped behind a pending re-subscribe
When the last wait for a sandbox left while a re-subscribe of it was still
queued (a confirmation, the final check or the stale-subscription sweep), the
Python and TypeScript hubs dropped the unsubscribe along with the re-subscribe,
as if the id had never been sent, and the server kept the subscription. They
now send the unsubscribe whenever an earlier subscribe of the id went out on
that socket. Go tracks this per entry and was not affected. A final check is
also not scheduled when it would fall at the deadline itself.
Also fixed: a subscribe written across a new run of waits
When the last wait for a sandbox left while its subscribe frame was still being
written, and a new wait then subscribed the id again, the frame's send time was
recorded for the new wait (Go and Python; TypeScript hands a frame to the
socket synchronously and was not affected). The frame now keeps its place in
the snapshot pairing, stamped with a time before the new wait began, and it no
longer counts as that wait's subscribe for the final check: the wait's own
subscribe, sent next, does.
Also in Go: a wait bounded by its caller's context deadline returns
context.DeadlineExceeded when that deadline passes while it waits for
another wait's confirming read, instead of the unconfirmed report. In Python
the caller's cancellation already wins over a report; TypeScript waits take
no cancellation signal (a closed client wins there).
Also fixed: state that outlived a socket or a close
- Go: a watch that routing moves to another socket now follows that socket's
mode at once (the batched reads start or stop with it), and a reconnect no
longer carries a per-idLIMITcooldown from the old socket to the new one. - A close that began as a wait ended now wins in all three SDKs: the wait
ends with the closed-client error, not the result (or, since this round in
TypeScript too, the rejection) it had just received. (Python: fixed again
later, see below; the first fix only fired with a test double.) - A final check whose id moves to another socket starts over there, and a
LIMITrefusal a final check has not handled yet survives a reconnect
(all three SDKs). - Go: a close or a cancellation that is ready together with a result wins
over it at every place a wait takes a result. - The final check's read is unheld (no target, the sandbox as it is now) in
all three SDKs; the waiter's ordinary batched reads still hold. - Go: a batched result the wait has not taken yet is queued, never
overwritten, so a round that answered the target reaches the wait even
when the next round answers first; a confirming batch read that runs out
of the caller's context deadline returnscontext.DeadlineExceeded. - A wait that joins a confirming read while it is on the wire, and the waits
that register after it, take that read's failure too (Python, TypeScript);
an unbounded wait could hang before. A report whose reads all were refused
by their own clients is read again for a later wait. - Moving an id to another socket (Python, TypeScript) and a reconnect
(TypeScript) clear the dropped reports from their waits, so a superseded
report is no longer raised at the deadline; a TypeScript reconnect keeps a
refuted report and its back-off, as Python and Go do. - Go: when a shared confirming read ends because the waits it was made for
ended, it counts as no read, and another wait reads for itself instead of
raising the report (superseded by the member model below). - Go: the stale sweep holds off an id whose snapshot answer is still due
(less than 3 s), as Python and TypeScript do. - Python, TypeScript: the third failed connect in a row waits out the
server's retry hint when it is longer than the 60-72 s fallback window. - All three: a newcomer's batch re-issue is timed from when the read went
out, re-checked when a slow credential delays the send, so the 1 s floor
between two requests of one batch holds. - Merged
main(the contract conflict resolved by keeping this branch's
copy); a batch item's SSH gateway fields reach the handle in Python and Go,
as in TypeScript. - The confirm re-read back-off's jitter is drawn once per collection window,
so a refuted burst stays batched (above). - Go: every wait on a report is a member of its confirming read, which runs
under the client, bounded by the latest deadline among its members, and
ends only when the last one leaves (20 waits cancelled one by one: 1 read). - A confirming read whose response breaks the contract fails every wait on
it with thatBadRequestError(all three SDKs); in TypeScript it is parsed
in full before it is shared, each wait'sobserveis contained, and the
confirming task never leaves a floating rejection. - A batch answer is marked partial for an unrequested item before the item
is validated, so a malformed one never makes an omitted id missing (a
delete does not report success). - An event correcting the held state at the same version is applied while a
snapshot is pending (all three SDKs); in Go a queued correction also wins
over a confirming read. - Python adopts a batch item's toolbox URL when it carries one.
- Python and TypeScript gather the first read of a batch a final check
opened for 5-50 ms, so trickling final checks share requests (Go already
gathered every new batch); in all three the gather never passes half the
budget of the batch's earliest wait. - A 404 of the
GET /sandboxes/batch-waitrequest itself (an API or a
proxy that serves no batched reads) is a 501NOT_IMPLEMENTEDof source
SDKin all three SDKs, never a not-found: adelete()never reports
success and a wait never raises not-found because of it. - Go: a wait that joins after a shared confirming read has finished takes
that read's sandbox into its handle (every field it carried), as Python
and TypeScript already did. - TypeScript tests: the mock server's upgrade socket handles a connection
reset (the hub closing a socket still connecting can reset it, which
escaped as an uncaughtECONNRESETon Node 22); a new test resets the
connection before and after the handshake and checks that the hub keeps
going with nothing escaping. - The confirm re-read back-off (2, 4, 8, 16 s, then every 30 s) is now
lengthened by a random 0-20% and never shortened, drawn once per
collection window and shared by all of that window's requests (which
meets the contract's "drawn once per confirming request, shared by every
id that request read"), so no step is shorter
than stated and "at most one re-read per 30 s per stuck id" holds exactly
in the steady state. - Go: a wait that joins a confirming read whose last member left inside the
20 ms collection window is answered (the read is taken up again, or
answered as not had so the joiner reads), instead of waiting forever. - Tests pin that a frame
version_ruledrops triggers no read and leaves the
back-off alone, and that a permanent mint failure (404, 501
WORKLOAD_PLANE_ELSEWHERE) falls back for that socket only and is never
minted again; every stand-in server's upgrade socket handles a reset. - Python: a close that began now wins with the real transport too. Its close
watcher raises the closed-client error when closing begins, which the
earlier check read as "no close"; the test now drives the transport's own
close. - Python, TypeScript: a confirming request is bounded by the latest budget
among the waits on its ids when the collection window flushes (it was the
first wait's budget), and a wait that joins after the request went out and
outlives it reads again instead of taking the report (Go already did
this): a 10 s wait joining a 0.3 s wait's read no longer fails at 0.3 s. - All three: batched reads count sandboxes, not waits (limits and id bytes
per sandbox identity, released when its last wait leaves): 1,000 waits on
one sandbox are one request carrying one id, where they were 5. - Python, Go: a wait that joins an idle batch wakes it, so its first read
comes 1 s after the batch's previous request rather than after the grown
interval (up to 2.4 s), as TypeScript already did. - Go: a correction that supersedes a report drops the client-wide shared
report too, so the same status reported again is read again; a wait that
reaches a stored or ready confirming read past its budget no longer takes
it as a success. - TypeScript: a confirm window opened before its socket learned its
destination is dropped under the key it was opened with, so none is left
behind. - Tests pin, in all three SDKs, that a wait registering on a held state does
not reset the socket's liveness clock. - Docs: macOS post-target poll spacing, a longer retry hint after three
failed connects, the id-byte encoders, development notes, and two
changelog fragments. - Go: a wait that reaches a stored confirming read of a report it has not
judged after its budget ran out ends with the reported state
(SandboxTerminalStateError), as one whose budget runs out with the read
on the wire does; a re-read of a report it already refuted still ends with
its timeout. - All three: a new wait on a sandbox the held request on the wire already
carries rides that request (its answer reaches the new wait too) instead
of cancelling and re-issuing it, when its budget outlasts the request's
hold: a new wait on the same sandbox every 0.1 s for 1.5 s is one request,
not two or three. - All three: a client's close waits for its confirming reads. Go runs each
confirm collection window as a client worker (soClose()returns only
after its request ended, and a read started on a closed client is answered
at once with the closed-client error); Python's close cancels the
confirming tasks and waits for them; TypeScript's close now also aborts a
confirming request already on the wire. - READMEs: a not-found for a sandbox the stream has never seen
(was_known=false) keeps the wait going on batched reads, while one the
stream knew, or the client already saw, is final; the batched reads after
a failed stream are that stream's waits only; the failed-connect count
starts over on a stream's first frame. Thewait-poll-spacingfragment
scopes its spacing to fallback rounds and its retries to batched reads. - Go: an answer takes the waits it decides out of their batch at once, so a
held answer that took more than 1 s is no longer followed by one more
request carrying sandboxes that already reached their state; a wait still
waiting is read again at once. - Go: when a wait's deadline fires, the frames the stream already delivered
are taken first: a target still succeeds, and a terminal report still
standing ends the wait with that state, as in Python and TypeScript. - All three: a
restart()step, or a wait with a terminal state a lagging
read can show (a pause'sstarted, a joined start'sstopped), never
rides a batched request that went out before it: that answer may predate
its own operation; it re-issues as before. - READMEs: a not-found from a stream the client chose for a sandbox from an
earlier API response is asked again once on the region's stream, whatever
was_knownsays. - TypeScript tests: every socket-only test is bounded above its own inner
waits (a slow runner fails on an assertion, not a bare test timeout). - Go README: the "Durations and waits" summary names both
Startand
Resumefor the macOS read after the target (Startreads the sandbox
before it acts, so it knows the class even by ID;Client.Resumeby ID
knows it only from a read during the wait). - All three: a sandbox id's identity decodes exactly the UUID spellings the
API accepts (32 hex digits, hyphenated, braced, or after a lower-case
urn:uuid:; hex in either case), besides the base58 sandbox id. Go now
matches a wait or delete by a braced or URN spelling to the API's
canonical answer, where it concluded the sandbox missing (a delete
reported done while the sandbox was still deleting); Python and
TypeScript no longer decode spellings the API refuses (an upper-case URN
prefix, braces around 32 digits). - All three: when a batched request carries an id the SDK cannot decode, an
item the request did not name may be its answer, so no omitted id is
concluded missing that round. When every requested id decodes, an
unrequested item is another sandbox, and an omitted id is still missing
(a delete that is done still returns). - Go: a wait that reaches another wait's stored confirming read after its
own budget (on the stored-read path, or when its deadline fires with a
repeat of the report queued) now decides by what that read showed when it
ended before the deadline, as Python and TypeScript judge a stored read
when a wait registers: the target succeeds, a refuting read leaves the
wait to its timeout, and a terminal state no lag can show raises with the
read's state. Only a read still on the wire, or one that ended after the
deadline, ends the wait with the reported state. - Go: a newer state that arrives while a terminal report is being confirmed
supersedes the report, as in Python and TypeScript: the wait goes on with
the newer state instead of raising the report (after a failed read, a
spent budget, or a read that shows the reported state again). - All three: a batched answer reaches only the waits the request read and
the newcomers that rode it. A newcomer that signalled a re-issue (one on
another sandbox, or one that must not ride) no longer takes an answer that
arrives before the re-issue cancels the request: that answer may predate
its own operation. - READMEs: the re-issue rule names its ride exception and the waits that
never ride; the confirming reads' batch size names the 11,000-byte id
limit. - Tests: the Python restart test sends each event once the step it belongs
to is waiting (a slow runner could hold a step back past an event, which
a restart step only takes from a fresh snapshot); the Go joiner-race test
waits for each watch to register before sending. - Python: a shared confirming read or batch item the handle cannot take (a
field that breaks the contract) fails only that wait, with that error;
delivery goes on for the others, where it used to end the shared task, so
unbounded waits on the same read or batch hung. - Python, TypeScript: a learned endpoint's not-found for an untagged id
routed by its region hint retries once on the region's socket, as Go
does, instead of ending the wait (adelete()reported done). - Go: a repeat of a refuted report decides nothing for a wait whose target
it is, as in Python and TypeScript. - All three: a braced or
urn:uuid:UUID carries no region tag, so 500 such
waits share 3 batches instead of 500 one-id requests under bogus regions. - Python, TypeScript: a confirming request carries a sandbox once, whatever
the spellings its waits use (256 spellings of one sandbox: 1 plain read,
was 2 requests). - Go: a confirming request is bounded by the members still waiting when it
goes out (a member that left in the window no longer leaves it
unbounded), and a late wait judges a newer shared read it has not judged. - Python, TypeScript: a subscribe that waited for budget skips the ids
whose waits all left meanwhile (nothing sent, no send time kept). - Docs: the macOS read after a target happens only when the handle knows
the class; the changelog names what supersedes a refuted report, the ride
exception and the idle-batch wake; dead fields and stale comments
removed. - Python, TypeScript: confirmations, refuted reports and their repeats are
keyed by sandbox identity, as in Go: a report under another spelling of a
sandbox joins the read under way or takes the stored one, instead of
starting a read of its own when it arrives after the first spelling's
collection window (the case a slow CI runner hit). - Docs: the changelog names the 11,000-byte id limit next to the 200-sandbox
cap; the READMEs note that a wait joining a confirming read already sent
reads again if that read is cut short at a bound it did not set. - Go: a wait whose target is a refuted report's state (it shares that
report's re-reads through a repeat) is never ended by the report: a re-read
that fails, or is still on the wire when its budget runs out, decides
nothing for it, and it times out, as in Python and TypeScript. At the
deadline, a queued repeat of a refuted report is judged like the report,
not taken as success, and a repeat leaves the handle as the read showed it. - Tests: the spelling tests also deliver the reports more than a collection
window apart, and still see one read per sandbox. - The event-stream final check's one read never rides a batched request already on the
wire (all three SDKs): it reads the sandbox as it is after its re-subscribe
went unanswered. - Go: a
LIMITrefusal that wakes a final check after the watch moved to
another session restarts the check there, as in Python and TypeScript,
instead of reading at once. - Python: sandbox identities are cached, and the waits that judged a
confirming read are kept in a set, so many spellings of one sandbox, or
many frames, no longer slow frame handling. - Python, TypeScript: an older frame under another spelling of a sandbox
(versions are tracked per spelling) no longer stops or replaces the
confirmation of a newer report, which belongs to the sandbox; Go already
compared versions across spellings. - The final check's one read, once sent, is had even if the stream stops
deciding or recovers before its answer, in all three SDKs (before, a
recovery while it was on the wire dropped it, and the wait could run out
with neither the read nor a fresh snapshot); held batched reads follow it
only if no stream can decide then. Go also no longer sends the one read a
second time when its answer takes longer than the batch interval. - Python, TypeScript: a wait that registers on a held state repeating a
report a confirming read refuted is no longer decided by it (a later
wait(until="destroyed")ordelete()could return for a sandbox the read
showed alive); it is judged by that read instead, as Go already did. - A
restart()step that registers while a snapshot of the sandbox is
already on its way (another wait's re-subscribe) re-subscribes too, so that
earlier snapshot can no longer confirm the step (all three SDKs). - Go: a final check whose answer is taken before the notification that its
re-subscribe went out no longer loses that answer (and reads anyway); it
learns of the send first, as Python and TypeScript compare send and answer
times whatever the order. - Go: a state applied under another spelling of a sandbox drops the shared
confirmation by identity, as in Python and TypeScript; a read on the wire
for it then decides nothing. - Go: a snapshot answering a subscribe sent before a
Restartstep no
longer decides the step when it is queued during a confirming read or
drained at the deadline (the frame path already refused it). - Python, TypeScript: a wait on a sandbox id holding a lone surrogate is
refused withBadRequestErrorbefore any request, instead of leaking the
runtime's encoding error (URIError/UnicodeEncodeError). - Go: a newly opened socket reports no received frame until its own first
one (it carried over the previous socket's time; no decision read it). - Tests: the reconnect-during-final-check tests hold the read's answer until
the new socket has subscribed, so a slow runner's reconnect cannot race
the read (Python, TypeScript). - Python, TypeScript: when a region's socket merges into a learned
endpoint's socket, a held report a confirming read refuted is not carried
over (the merge drops the refutation), so a wait that registers before the
new socket's own snapshot is not decided by it. - Python, TypeScript: a wait whose target is a refuted report (an
unboundeddelete()that joined on the repeated report, say) keeps the
shared re-reads going after the wait that refuted it leaves, also after a
failed re-read, so it sees the platform commit the report; before, the
re-reads stopped and the wait could hang. Go already kept them. - Go: a confirming read that shows the target decides nothing when a newer
state arrived while it was on the wire (it already did not for a terminal
read), as Python and TypeScript ignore a read whose confirmation a newer
frame dropped. - A retry hint on a transient batched-read failure (500, 502, 504, …) is
counted from when the failure arrived, not from when the request went out,
so a slow failure no longer spends the hint before it arrives (all three
SDKs). - Go: a watch that routing moves into a session whose endpoint is
permanently unavailable now reads in batches (the session reads for good,
as in Python and TypeScript), and that session's worker no longer mints
again when a watch moves in just before it exits. - A held batched read whose answer arrives once the next round was due (a
read held past its interval, its first renewal included, changed or not)
is renewed after the round's own lengthening, counted from its answer (at
most 0.4 s, no extra request), so clients refused together no longer renew
their held reads in lockstep: 100 clients refused together used to send
their first renewals at one instant (30.000 s) and now spread them over
30.002–30.2 s with the same number of requests (all three SDKs). - Go: a batch keeps only its members' last statuses (as Python and
TypeScript do), so a long-lived batch whose waits come and go no longer
grows its status map without bound. - Python: when a socket's credential is refused and its waits end, its
confirmations, refutations and per-id answer state are dropped too (as in
TypeScript), so a wait after recovery is not judged by a stale refutation
(it waited for a re-read on the back-off, 2 s or more). - A per-id
LIMITnow drops the id's newest outstanding subscribe send time
(it popped nothing): each refused retry used to leave one more stale
entry, so a later final check whose re-subscribe was answered still read,
and arestart()step after a run of refusals waited until its final
check (52.5 s of a 60 s budget, TypeScript, measured) instead of settling
on its own snapshot (all three SDKs). - A re-issue for a wait that joins a held request on the wire, and an idle
batch's round a joining wait brings forward, now wait 1 s lengthened by
the round's 0–20% spread instead of exactly 1 s, so clients that each
gain a wait at once no longer send in step (re-issue: all three SDKs; idle
wake: Python and TypeScript, Go already did). No extra request. - Go: a terminal frame older than a state another wait on the sandbox has
already applied (each Go wait takes its frames in its own time) is no new
report even when no report was pending: it no longer starts a confirming
read, which a lagging answer could have turned into a false failure (Python
and TypeScript apply frames in arrival order, so the newer state drops the
report first). - Go: routing that moves a watch to another session wakes a final check
waiting for its re-subscribe to go out at once (it starts over there), not
when the new session sends its own subscribe. - A refuted report's next re-read is counted from when the read's answer
arrived, shared by every sandbox that request read, instead of from when
each wait resumed: on a loaded client the waits of one answer resumed
apart, so their re-reads drifted past the 20 ms collection window and a
refuted burst split into extra requests and lone plain reads (a 500-sandbox
burst with 0.2 ms of processing per sandbox: 55 batch requests and a
plain read in 5 minutes, scaled; now 33 and none, as with no load). All
three SDKs; no extra request. - PR description: the snapshot-row figures are the measured ones, and
"Merge order" no longer contradicts "Known gates". - Docs: the READMEs, AGENTS.md and the changelog say what a stream ticket
refused with 401 or 403 does (Python and TypeScript end the stream's waits
with that error; Go reads them in batches, where the API's own refusal
decides), and that an id of another kind is refused up front whether or
not a region tag follows. Stale restart, events-config and wait
docstrings are updated. - The final check reads once, inside the budget, when its re-subscribe
cannot go out within its window (min(10 s, half the budget left), counted
from when it was queued) while the socket has no open connection: a socket
that dropped just before the mark and whose reconnect hangs no longer
leaves the wait to time out with no read (all three SDKs). At most one
unheld batched read per bounded wait, and only when the socket could not
carry the re-subscribe. (Narrowed in the round below, "Also fixed: the
unsent read on an open socket": an open connection waits for the send.) - Docs: the changelog fragment and the Python note name the credential
exception and which no-stream cases read for good; TypeScript's docs no
longer mention cancelling a wait, a create or a fork (they take no
signal); the TypeScript note names the lone-sandbox plain read; and a
wait that joins a confirming read in flight is said to be decided by it
unless the bound set when it went out cuts it short. - Docs: every statement of the batch request limits (200 sandboxes, 11,000
URL-encoded id bytes with each id's 3-byte%2Cseparator, the API's
12,288-byte query limit) is complete and the same everywhere; the
fallback's "followed at once" after a held read now names its lengthening;
the cancellation each SDK propagates from a confirming read, the stream
not-found that completes a delete, and Go'sErrClientClosedare named. - Python and TypeScript: a wait that joins on a repeat of a refuted report
after its re-reads stopped restarts them when the report would fail it,
not only when the report is its target, so an unbounded such wait sees a
commit that sends no new frame (Go already scheduled its re-read). - Python and TypeScript: a late wait on a report whose stored read had
decided every earlier wait, and that the read refutes for it, now marks
the report refuted and starts its re-reads, instead of waiting for a frame
that a commit does not send (Go already did). - Go: a confirming window reads a sandbox once, whatever the spellings of
its reads (a newer report's read can share a window with an older one's),
as Python and TypeScript already did; a lone sandbox keeps its plain read.
The DEVELOPMENT notes state the batch request limits and which no-socket
cases read in batches for good. - Python and TypeScript: a refuted report's re-reads stop once only waits
the report is neither a target nor a terminal state of remain, instead of
taking one more read for them after the last wait that depended on it
left (Go never reads for such a wait). - Freshness stamps for a
restart()step are exact: TypeScript orders
subscribe sends and a step's registration with a strictly increasing
stamp (no tie within one millisecond), and Go stamps each subscribe frame
when its own write began, not a whole batch at the end of its last write. - TypeScript: a batch item that carries an empty SSH gateway (a blank host,
port 0) clears the handle's, as in Python and Go. - Go: at the final check, a refuted repeat received at the re-subscribe's
own instant is no answer, as in Python and TypeScript (>=). - Docs: the READMEs say the refuted report's re-reads stop on a frame with
another wire status or a higher version (not any state); the Go README
lists the fallback after three credential refusals. - Merged
main(3cca1f976e), which madeSandboxTerminalStateErrorname
the operation: every terminal-state error this PR's waits raise (a
confirming read, shared, stored or joined late; a batched read; the final
check's read; a spent budget with the report unconfirmed; a restart step;
a refuted report's re-read) now carriesoperationand reads
<operation> did not complete: sandbox <id> is <state>[: <reason>], as
main's existing paths do; tests pin each path in all three SDKs. - Docs: AGENTS.md and the Python and TypeScript READMEs say that three
credential refusals in a row end the socket's waits with
AuthenticationErrorinstead of reading them in batches (Go reads them in
batches, where the API's own refusal ends them, as its README already
said). - A very large retry hint saturates instead of wrapping to an early retry
(Go), and stays finite (Python).
Also fixed: Go socket loop cost at scale (Go only)
-
A cost that predates this PR (the refused-id retry from #693, in
released Go SDKs;mainhas the same two scans, andmain's stale sweep
has the same cap of 1,500 re-subscribes a second, so a healthy socket on
maingets the same stream of answer frames; the numbers below were
measured on this branch before and after the fix): every pass of the Go socket loop (one per incoming
frame, wake or timer) scanned every subscription twice under the hub lock,
inschedule()andnextDeadline(), to find LIMIT-refused ids whose retry
was due. With the stale sweep keeping healthy waits a steady stream of
answers, that was O(subscriptions) per frame. The session now tracks the
earliest refusal retry time (refusedDue): the retry scan runs only once
it is due, re-tracks the ids it leaves refused, andnextDeadline()
considers that one value, so a pass with no refusal retry due costs no
scan. A pass where one is due still scans every subscription, once per
distinct due instant: 1,000 / 5,000 / 10,000 refusals due at staggered
instants cost about 1 M / 25 M / 100 M entry visits (as before this PR;
a follow-up can fold them into the paced flush). Retries, the
maxFrameIDscap per pass and the refusal delay are unchanged. Python and TypeScript have no per-frame scan
(their full scans are the once-a-second stale sweep, reconnects, the
socket-wideLIMITretry, and waiter checks that stop at the first hit). -
A spin this PR introduced: when the subscribe budget deferred ids with
the bucket a hair short of one token, the next flush was rounded down to
the same instant, which accrues nothing, so the loop rescanned every
subscription at one instant forever. The deferral now rounds up to a whole
nanosecond. -
Measured (scale tests under
synctest, real time, same request and row
counts before and after: 0 HTTP reads in every run):Run Before After 10,000 healthy waits, 60 s about 40–55 s about 1.5–3 s 20,000 healthy waits, 10 s about 55 s about 1–2 s 20,000 healthy waits, 60 s about 120–135 s about 2.5–3 s 40,000 healthy waits, 10 s never finished (24 min) about 2.5 s 40,000 healthy waits, 60 s not run about 4–6 s Python and TypeScript take about 4.5 s for 10,000 healthy waits, 60 s.
(Wall-clock times on a shared machine; other runs measured up to 2.7 s for
the first row and up to 5.6 s for the last.)
A counter test pins it for passes with no refusal due: 20,000 answers cost
800,080,000 entry visits before and 80,000 after. One scan remains:session.active()stops at
the first entry with a watch, so it is cheap in steady state, but while
many departed entries wait for their paced unsubscribe it walks them
(10,000 departed and one live entry: about 19.5 M visits per 1,000
passes, against 4,000 after the flush).
Also fixed: the unsent read on an open socket, and the review's other findings
-
The final check's unsent read happens only on a socket with no open
connection (all three SDKs). The read for a re-subscribe that has not
gone out within its window was taken whether or not the socket was open,
so on a healthy socket the client's own pacing (the 50 ms subscribe flush,
longer than the window for budgets under about 0.4 s; the token bucket
shared with the stale sweep; a busy loop) turned into HTTP reads that grew
with the number of waiting sandboxes. Now, while a connection is open, the
check waits for the send and its window runs from it, as before the
hung-reconnect fix. The read happens when the window has passed with the
re-subscribe unsent and the socket has no open connection: at the window's
end, or later, when the connection closes with the re-subscribe still
unsent (so a drop after the window, with a hanging reconnect, still reads
once). Pythonsock.ws is None, woken by_signal_subscribes; TypeScript
isOpen, woken bynotifySubscribes; GoWatchLiveness.Openand
checkUnsent, woken by the Reading channel, which a connection's opening
and closing now close too. A socket stuck in write back-pressure is
replaced by the liveness ping and then has no open connection. -
A final-check re-subscribe whose window is shorter than the 50 ms flush
delay brings the next flush forward (all three SDKs), carrying every id
already queued, but never sooner than 50 ms after the socket's last flush
(paced in the round below, "Also fixed: the short-window flush keeps the
frame pace"). It adds no subscribe rows and changes nothing for windows
of 50 ms or more. -
TypeScript: the send guard is armed again when its timer fires before a
fractional deadline. Node truncatessetTimeoutdelays, and the
window's end is fractional (stamps and half a jittered budget), so the
guard could fire just before it, stop listening and never read. The guard
now usesMath.ceiland re-arms while the deadline is ahead. Python
re-checks in a loop (_subscribe_sent) and Go re-arms on
consider(o.sendBy)(nextTimer), so neither had it. -
TypeScript: a new connection installs its frame handlers before its
resubscribe, which waits for the subscribe budget beyond the 32,000-id
burst: answers that arrived meanwhile were dropped. Python had the same
ordering (_resubscribe_allawaited before_run_ws); it now resubscribes
in a task while the frames are read. Go's socket loop reads frames on its
own goroutine while it sends (readFrames), so it was not affected. -
Python: a per-id
LIMIThandled while that id's subscribe is being
written no longer pops the previous send's stamp: the write being the
newest send, it gets no stamp when it ends (and the refusal counts as
answering it). TypeScript sends synchronously and Go sends from its one
loop, so neither had it. -
Python: no final-check window starts once the budget is spent. The
wait's own timeout can run just after a re-subscribe that went out at the
deadline;_subscribe_sentnow checks the budget before the send, as
TypeScript'swhenSubscribeSentand Go'sonTimeralready did, and the
answer check reads nothing past the deadline. -
Go:
TestWait_aCloseThatBeganWinsOverAWaitThatEndedWithItcloses the
client before sending the frame, as its premise says (1 of 5,000 runs
failed with the old order under-race -cpu 16; 0 of 1,000 now).
TestRefusedSubscribesLeaveNoStaleSendTimes: 0 failures in
-race -cpu 16,4,2 -count=300. -
Docs: the unsent read is for a socket with no open connection; how the
window behaves after a move (Python and TypeScript start a new check once
the re-subscribe goes out on the new socket, Go keeps the firstsendBy;
each reads at most once, inside the budget); a restarted refuted-report
re-read loop counts from the later of the last answer and the restart in
Python and TypeScript, and from the last answer plus the step in Go (each
step at least as long as stated, at most one read per 30 s per stuck id). -
Measured on a healthy socket that answers every subscribe at once, no
state change (HTTP reads; before = the head the review checked, after =
this round):Case Before After Python, 10 waits each at 0.05 / 0.2 / 0.39 / 0.5 s 8–9 / 10 / 5–6 / 0 ids 0 / 0 / 0 / 0 Python, 4,000 waits, scaled bucket, 4 s / 20 s 2,089 / 1,760 ids 0 / 0 Python, 40,000 waits, real bucket and sweep, 20 s 9,693 ids 0 Python, 40,000 waits, 4 s / 6 s 111 / 48 requests 0 / 0 30,000 waits, 3 s Python 46, Go 47 requests 0 / 0 (TypeScript 0) Go, real websocket, 20 s budget, 10,000 / 15,000 / 20,000 waits (the socket-loop cost above plus the unsent read) 1,004–~5,000 / 1,400–2,050 / 1,400–1,864 ids read, p50 20 / 26 / 27–28.7 s 0 / 0 / 0 ids, p50 20.0 s, max 20.05 s TypeScript, hanging reconnect, fractional window ( Math.random0.123), 20 s / 60 s0 reads, timeout 1 read, startedTypeScript, 60 hubs, real timers, hanging reconnect, 2 s 21–35 of 60 with no read 0 of 60 (4 runs) The hung-reconnect cases still read exactly once (Go: 40 of 40 under
-race -count=20; Python and TypeScript: their tests and the review's
drivers), and a final check whose re-subscribe goes unanswered still
reads (10,000 waits: 61 unheld requests in Python and TypeScript, as
before).
Also fixed: Go delivers every events frame to a wait
- Go: a watch now receives every observation, in order (Go only). The
hub kept one pending update per watch and replaced it with the newest, so
a wait busy elsewhere (a confirming read, a loaded process) could miss a
state the stream had sent. ForRestart()this was a real failure: the
stop (and the snapshot answering the final check's re-subscribe) could be
replaced by the start'srunning, and the first step, which waits for the
sandbox to leavestarted, then waited until its timeout. The stream
itself never replaces a status with a repeat of the one it last showed
(it keeps the status in between), and Python and TypeScript judge every
frame as it arrives (_dispatch_state,dispatchState), so Go was the
only SDK that lost it. Updates the consumer has not taken are now held
for it and delivered in order; a watch the hub ends (a not-found, a
permanent endpoint) delivers them before its channel closes, and one the
consumer releases drops them. Tests: a watch that takes nothing while
stopped,bootingandrunningarrive then receives all three
(failed before: onlyrunning); a restart whose first step takes nothing
until all three have reached it completes with no read (failed before:
timed out). - Go: a routing merge wakes the moved watch's refusal wait. When routing
moved a watch into a watch the target already held, the moved entry's
LIMITwait channel was never closed. It is now, and the docs say what
holds: a move starts the final check over on the new session with a
request sent after the move, so a refusal from before it never counts,
and the target's own refusal time stands (carrying the old session's into
it would make the target's own watches read for a refusal of a request
they never sent; Python and TypeScript keep refusals per socket too). - Docs: only a stream ticket refused with 501
WORKLOAD_PLANE_ELSEWHERE
reads for as long as the waits last; any other 501 is a failed connect.
Also fixed: the short-window flush keeps the frame pace, and the review's other findings
- The short-window flush is paced (all three SDKs). The previous round
sent a final-check re-subscribe whose window is shorter than the 50 ms
flush delay at once, with no floor between two such flushes, so many
short-budget waits on one socket (wait(timeout=0.25), restart steps,
start()with little budget left) sent one frame each: 1,000 waits
together sent 1,001 frames in 0.2 s, against the server's 100 inbound
frames a second, which drops the excess with a socket-levelLIMITand
closes the socket past 200. Now such a re-subscribe brings the next flush
forward to now, but never sooner than 50 ms after the socket's last flush
(Pythonlast_flush_at, TypeScriptlastFlushAt, Go
session.lastFlushAt). An isolated short window still goes out at once;
a burst keeps the old cadence.-
The bound: flush starts stay at most one per 50 ms, as before this
change. The frame counts that gives, per SDK and mix, are in "Frame
rates" under "Also: tests and docs from the latest reviews" below,
which corrects the figures first given here. -
Frames against before the immediate flush: never more than one
flush per 50 ms, the same rate bound; a burst can cost one more frame
than before (the first short window goes now, the rest of the burst 50
ms later), so at most twice as many flushes for bursts spaced more than
50 ms apart, and never more than 20 a second. -
Tests per SDK, on the fake clock (Go
TestHealthySocket_shortFinalCheckWindowsKeepTheFlushPace,
Pythontest_*_keep_the_flush_pace, TypeScript "short final-check
windows keep the flush pace"): 1,000 waits with a 300 ms budget
together, 10,000 staggered one a millisecond, and 50 loops of
wait(timeout=0.2), each with no reconnect and no HTTP read:Case Before the immediate flush Previous round Now 1,000 together, subscribe frames (Go / Python / TypeScript) 3 / 2 / 2 1,002 / 1,001 / 2 4 / 3 / 3 10,000 staggered, most subscribe frames in a second 20 / 20 / 20 1,008 / 1,008 / 259 20 / 20 / 20 50 loops, most subscribe frames in a second 11 / 11 / 10 264 / 270 / 13 16 / 16 / 16 HTTP reads (all cases) 1,000–2,494 (Go), 5–41 (Python) 0 0 -
The review's drivers, against a fake socket that enforces the server's
frame bucket: Go 500 waits 2 ms apart with a 200 / 300 ms budget, 0
frames refused and at most 20–21 frames a second (previous round: 102–121
refused, 196–199 a second); Python 50 loops ofwait(timeout=0.2), 14–15
frames a second (previous round 87–107), and 80 loops under the server
limit, 0 refused and 0 reads (previous round 153 refused, 1,514 ids
read); Python and TypeScript short-window scale runs: 1,000 / 10,000 waits
together 3 / 21 frames, staggered 26 / 206 frames, 0 dropped, no close,
0 reads (previous round up to 2,406 frames and a close at 1.29 s).
-
- Go: a wait's deadline takes every update the hub handed it. Since the
previous round a watch's updates beyond the one in its channel wait in a
backlog that a goroutine moves into the channel, and the deadline's
"take what is ready" drain could stop before the later ones arrived: a
busy wait could miss a delivered target and time out. The hub now counts
the updates it hands each watch (WatchLiveness.Delivered, read without
its lock), the wait counts what it received, and the deadline drain
waits for exactly the difference (every handed update reaches the
channel, in order, unless the watch is abandoned, which only the wait's
own release or the client's close does). Test: three updates, the
target last and two still in the backlog, at the deadline decide by the
target with no read (failed before: timeout). - Python and TypeScript: whether a socket has waiters is a count. The
check scanned the socket's subscriptions; a Pythonsetkeeps the slots
of removed ids, so resolving tens of thousands of waits at once was
quadratic: 33,000 waits took about 14.5 s to resolve, 40,000 about 17.4 s;
now 1.3 s and 1.9 s (the review's driver). Each socket now counts its ids
with a live waiter as waiters and subscriptions change. TypeScript'sSet
showed the same growth on a smaller scale (deleting 40,000 ids and
looking for a live one each time took 165 ms), so it counts too. Tests:
resolving 1,000 waits iterates the subscriptions 0 times (failed before:
2,001 in Python, 3,000 in TypeScript); a full-suite run with a check
that the count equals the scan found no difference. - Tests: the TypeScript healthy short-budget test pins the mark's jitter
(with the default random draw it passed at the head before the
fractional-deadline fix for the wrong reason); the four TypeScript tests
that keep the final check off now say why (a socket that never answers,
or a mint held so no connection is open, would read and decide the short
wait: without the opt-out the deadline test failed 3 of 3 runs here and
the handshake test 1 of 3, so both keep it); the
Python busy-budget test asserts its final checks re-subscribed. The
fixedchangelog fragments are named822.fixed.md,
822-learned-endpoint-not-found.fixed.mdand
822-unsubscribe-first.fixed.md. The Go scan counter
says what it is for.
Also fixed: one flush pace on every path, test time, and the review's other findings
- Go: every subscribe flush keeps the 50 ms pace. The previous round
paced the short-window flush, but Go's other flush paths (the subscribe
budget's deferral, the stale sweep, the refused-id retries, reconcile)
could still flush sooner. Fresh ids arriving just under the budget rate
made the deferral's gap shrink geometrically: 2,970 flushes in 3 s, 2,969
of them closer than 50 ms, up to 1,020 frames in a second; 1,000 refused
ids coming due over 5 ms retried in 1,000 flushes. Now one place,
session.flushDue, runs every flush no sooner than 50 ms after the
connection's last (a new connection starts unpaced: the server's bucket
is per connection), and the loop wakes at that time. The same scenes:
59 flushes, none closer than 50 ms, at most 20 frames in a second; the
retries in 2 flushes. Tests:TestFreshIDsArrivingUnderTheBudgetRateKeepTheFlushPace,
TestRefusedIDsComingDueOverAFewMillisecondsKeepTheFlushPace.- Python and TypeScript: flushes queued behind a long budget wait
drain back to back once it frees, each paced only by its own budget
tokens (see "Frame rates" below for the measured figures). - The bound, documented: at most one flush per 50 ms per connection
(in Python and TypeScript, one flush start), each split into frames of
1,000 ids; measured, at most about 85 frames
in a second for the worst mix driven (20,000 leaving waits, 20,000
arriving short waits and 1,500 refused retries; 76–84 before this
change, the same mix), under the server's 100 a second with its
100-frame burst; nothing refused. A new connection sends no
unsubscribes (the server forgot the old connection's ids).
- Python and TypeScript: flushes queued behind a long budget wait
- Go: a wait's goroutine stack stays small. A batched read's result
(a whole sandbox observation, about 1 KB) was received by value in the
wait's select, so every wait goroutine's frame carried it; the previous
round's extra fields pushed the stacks past 8 KB to 16 KB. Results now
reach the wait by pointer: the wait's step frame went from 2.5 KB to
0.6 KB, stack memory at 40,000 waits from about 685 MB to 313 MB (417 MB
before the previous round), peak RSS from about 1.1 GB to 0.8 GB (0.9 GB
before round 57). The per-watch backlog was not the cost: it started no
forwarder in these runs. - Go:
Hub.Closeabandons every forwarder, including one for a watch
the hub already ended (a not-found) whose consumer neither reads nor
releases, whichClosecould wait on (unreachable through the SDK,
whose waits release their watch). Test included. - Python tests: virtual time covers budgets and read timeouts. The
busy-budget test (and every test on the virtual clock) armed each wait's
budget with a realasyncio.wait_for, so on a slow runner the waits
ended before their virtual final-check marks, which failed the test in
CI. The virtual clock now also runswait_for(a wait's budget, the
socket's read timeout), and the busy-budget test pins its jitter and
asserts its exact frames, derived from the scene's arithmetic: 400 ids at
0.533 s, 15 sweep ids at 2 s, and the final checks' 400 at 3.583 s, after
their windows and before the deadline; with the final check off, only
the sweep (15 at 2 s and 15 at 3 s). With a wall-clock stall of 60 or
120 ms per advance it passes (the previous head failed at 60 ms), and so
does every other test on the virtual clock. - Smaller: the TypeScript 50-loop frame-rate test now says it bounds the
pace but is not its guard (it also passed before the pace); a released
Go watch's test pins its two possible deliveries; the gated test source
in the restart test reports its own deliveries; the GoWatchdoc says
the backlog is ordered and dropped on release; the TypeScript notes say
the 50 ms pace is fixed per socket; the READMEs speak of subscribe
flushes, which may carry several frames.
Also: tests and docs from the latest reviews
-
Tests (all three SDKs): an older snapshot that answers a subscribe after a
newer event replays the newer state, as of that subscribe: a final check
answered that way reads nothing, and a newer terminal state in that
position still gets its one confirming read. -
Go: the flush-pace tests also assert the work was done (every due id
subscribed exactly once, every refused id re-subscribed). -
Tests on virtual time: the refused-mint back-off tests (TypeScript and
both Python ones) now run on fake timers with the jitter pinned and
assert the exact gaps, max(retry hint, back-off); the TypeScript tests
that bounded a measured gap from above (the liveness ping, a joining
wait's read, reads while the next connect is far away, a refuted
report's re-reads, an idle batch's pulled-in round, the resubscribe after
a LIMIT cooldown, an abandoned confirming batch) moved to fake timers
too, so a loaded runner cannot fail them. The Python busy-budget tests
assert the final checks' one 400-id frame inside its window instead of
exact frame instants, and the test clock'swait_fortimes out at once
with no time left and keeps a value its operation returns on
cancellation, asasyncio.wait_fordoes. -
Docs: a delete's wait completes on a 404 for the sandbox, never on a
failed batched-read request; the create and fork waits return their
handle where other waits raise the reported state; each SDK's note says
how it ends the waits of a socket that refuses the credential; the
TypeScript note gives the refuted report's re-read schedule; Go's says
what bounds a busy wait step with no deadline. -
Docs: the Python and Go development notes name the errors a confirming
read raises instead of the report; the final check is scoped to waits the
event stream decides (fallback batched reads run none) in the docs, the
docstrings and the changelog. -
Frame rates. In Python and TypeScript the 50 ms pace bounds flush
starts, not frames: a flush sends its unsubscribe frames and then its
subscribe frames back to back (unsubscribes first, as in Go; see below),
and flushes that waited for the
subscribe budget send right after one another once it allows. Measured
against a fake server that enforces its bucket, the busiest second
carried:- about 85 frames for the worst mix driven (20,000 leaving waits, 20,000
arriving 300 ms waits, 1,500 refused retries; Go); - 39 to 52 frames for 40,000 waits followed by 1,000 short waits: about
40 (32 in one 100 ms, the first burst) when the short waits arrive
together (Python and TypeScript), up to 52 when they arrive 1 to 5 ms
apart (Python); - 20 subscribe frames, about 40 with their unsubscribes, for 10,000 short
waits a millisecond apart (all three).
All under the server's 100 a second, nothing refused. The docs now state
the pace as flushes (starts, in Python and TypeScript) and give these
figures instead of "about 40" and "20 frames". - about 85 frames for the worst mix driven (20,000 leaving waits, 20,000
Also fixed: a newer target behind a confirming read (Go), and every sandbox on a stale learned stream (all three)
- Go: a confirming read's answer no longer beats a newer target already
delivered to the wait. Since the per-watch backlog, a wait that took
the frames queued during its confirming read took only the one in the
channel's slot; the frames still being forwarded were missed, so with two
repeats of the report and then a newer target (failed@1,failed@1,
failed@1,running@2) the read'sfailedanswer raised the report
instead of returning onrunning@2. The wait now takes every frame the
hub has counted as delivered (drainDelivered) after a confirming read,
as the deadline path already did; the final check's answer window does
the same before it reads. Tests:TestWait_aNewerTargetDeliveredDuringAConfirmingReadWinsOverItsAnswer
(red 200 of 200 before, green 200 of 200 under-raceafter),
TestWait_theFinalCheckTakesAnAnswerDeliveredBeforeItsWindowEnds; Python
and TypeScript, which settle a target during dispatch, gain the same
scenario as a test. - A not-found from a stream chosen from an earlier API response now
re-routes every sandbox of its region, not only the first. Each SDK
decided "chosen by a learned endpoint" from the region map, which the first
not-found cleared; every later not-found from that stream then took the
was_known/ known-sandbox rule, so a seconddelete()on the stream
returned with the sandbox reporteddestroyedwhile it was still being
deleted (andstart()/wait()raised not-found for a live sandbox).
This was onmaintoo. Now the decision is the socket's own: Python and
TypeScript key sockets by kind and value, as Go'sendpointKeyalready
did, so a learned value equal to a region tag is still its own socket and
a region tag's socket serves only that region. Every not-found from a
learned endpoint's socket is no answer, the region's endpoint is
forgotten if it still names that stream, and every sandbox of that region
waited on there moves to the region's own stream in one subscribe, once
(the region's not-found is decided as usual, also when the learned value
is a region's tag, which no longer loops); other sandboxes on the stream
stay, and later frames of the old stream for a moved sandbox decide
nothing. With plain-string keys, a re-learn could also carry another
region's sandboxes to a stream of the wrong region, and a region retry
could land on a socket that dialled another region: both fixed by the
typed keys, and a region that learns a new endpoint now moves only its own
sandboxes off a stream another region still uses (as Go did). Tests in all three
SDKs: two sandboxes, NOT_FOUND together and the second after the move; a
third region stays put; each fails on the previous head. - TypeScript: the final check's answer window no longer ends up to 1 ms
early on a fractional timer (an answer in its last millisecond now counts),
and a retry hint longer than the longest timer (about 24.8 days) is waited
out whole, as in Python and Go. - Python and TypeScript: a subscribe flush sends its unsubscribes before
its subscribes, as Go does, so a stream at the server's subscription
limit frees the old sandboxes before asking about the new ones (a churn
test at a scaled-down cap: no refusal, every new sandbox subscribed). - Frame figures, bounded by id length. The worst reconcile churn
(20,000 leaving and 20,000 arriving waits just after the 60 s reconcile)
peaks at 60 to 61 frames a second with 33-character ids, 96 to 99 at 87
characters in every SDK, and reaches 100 at 88 (Go): the docs now say the
frames stay under the server's limit for sandbox ids up to 87 characters
(the figures themselves are with 33-character ids). Highest measured per
SDK: about 85 (Go), 61 (Python), 60 (TypeScript). - Tests: Python and TypeScript now guard the older-snapshot replay itself (a
restart step's subscribe answered by an older snapshot completes with no
read; without the replay it stays pending). - Tests: the TypeScript final-check scene (three tests) and the 500-report
confirming burst now run on fake timers with exact values (the LIMIT read
5 ms after the refusal; 3 then 6 requests); the scene's real-time waits
failed once in 51 runs of the load sweep. - Docs: the confirmation errors listed as their own (refused credentials and
a closed client, a 404 except afterdestroyed, the SDK's own 400, a
non-SDK error in Python and TypeScript); a transient batched-read failure
is retried next round; a live event decides a restart step; the final
check's read is not retried; the re-read lengthening is one draw per
confirming request.
Also fixed: every macOS sandbox that comes up started is read once more (all three)
start()that finds the sandboxstoppingorpausing. It first waits
for that operation to settle (targetsstarted,paused,stopped). When
another caller started the sandbox meanwhile, that wait ended the call on
startedfrom a frame or a batched read's item, neither of which carries
the boot mode or the reservation. It now ends through the read after the
target, as a start does; a settledpausedorstoppedis not read (the
resume or start request follows). A failed read keeps the success, and a
close still wins.- The create and fork waits of a macOS sandbox that comes up
started
now make the same read (Python_wait_without_raising_for_its_end,
TypeScriptwaitUntilCreatedand the fork'sreadAfterTarget, Go's
internalwaitwithreadAfterMacOSTarget). - The read follows only
startedin every SDK (it followed any target
butdestroyed). Every public call that can end with a macOS sandbox
started:
| Call | Reads after started | Why |
|---|---|---|
start() (stopped, or joining starting) | yes | the start changes the boot mode and the reservation |
start() settling a stop or pause that ends started | yes (new) | the same: another caller's start |
start() on a sandbox already started | no | its first read is a full read: nothing changed since |
resume() | yes | as start |
create*() wait | yes (new) | the create response predates the boot; a response already started returns as it is |
fork() wait | yes (new) | the fork's detail read predates the boot; one that already shows the target waits for nothing |
restart() | no | the API refuses a restart of a macOS sandbox |
wait() | no | a state wait: other fields stay as of the last read (refresh_data() / refreshData() / Refresh) |
- Python and TypeScript: a wait that re-enters the batched reads keeps its
unheld query. A wait whose last seen state a held read answers at once
(saystoppedfor a wait forstarted) moved to the unheld reads only
when a read answered it. A reconnect that failed again, or the final
check's read handing the wait back, placed it in a held batch again (one
extra request). The choice is now made where every placement starts
(_read_waiter/readWaiter), as Go'sbatchQuerydoes. - Go: frames already delivered decide before the batched reads start.
When the socket switches to batched reads (and when a wait starts on a
socket already reading), the frames the watch has delivered are judged
first, so a target among them ends the wait with no request, as Python
and TypeScript settle such a waiter before their socket reads. - TypeScript and Go: a
start()that finds the sandbox alreadystarted
ends with the client-closed error when the client closed during its
read (it returned success when the read's answer still arrived), as
Python already did. - Go:
markSent, used only by tests, moved to a test file. - Docs: the READMEs and the changelog say no frame was refused by the
server's frame bucket (not "under the server's limit of 100 a second"),
and that a flush sends frames of at most 1,000 ids and 65,536 bytes; the
Python development notes list the fork targets as the TypeScript notes do.
Follow-ups
- Two spellings of one sandbox on one socket. The server keeps one
subscription per sandbox on a socket and answers under the latest
spelling; the SDKs keep one per spelling. Concurrent waits on one sandbox
under two spellings in one process can then resolve one of them only
through the stale sweep. Predates this change; the follow-up keys socket
subscriptions by sandbox identity, as the batched reads already do. - The liveness boundary. After a long retry hint (a 429 with
Retry-After: 30), held batches can renew just before the reconnect,
costing at most one request per batch per reconnect. The follow-up stops
the batched reads one batch interval before the connect. - Go: refused-id retries scan every subscription per distinct due
instant (staggered refusals cost O(N) per instant, see "Go socket loop
cost at scale"). The follow-up folds the retry scan into the paced flush. - Refused-id retries are not jittered. A subscribe refused with
LIMIT
is retried after a fixed 2 s in all three SDKs (as onmain), so clients
refused together retry at one instant. The follow-up lengthens that delay
by a random 0–20% with the existing spread helpers.
Known behaviour kept
- A
NOT_FOUNDframe withwas_known=falseon a healthy socket (an id the
endpoint does not know yet) moves that wait to the batched reads, as the
wait moved to single-sandbox polling before this change. All three SDKs. - Snapshot pairing stays first-in, first-out per id and socket: per the
contract's subscribe semantics a socket answers an id's subscribes in order
and may drop a queued snapshot a newer subscribe superseded, so the oldest
outstanding subscribe is the most recent one a snapshot can be taken to
answer. That can only delay a confirmation (the wait re-subscribes at its
final check), never take a snapshot as fresher than it is. An error frame
without an id drops nothing, for the same reason. - A second wait on an id restarts the stale sweep's young (faster) schedule
for that id; that only re-subscribes the older wait sooner. - A held batch's newcomer waits up to ~1 s for its first read (the request
on the wire is re-issued no sooner than 1 s after it began). - A terminal report costs one read per sandbox and socket, plus the
back-off re-reads while a refuted report keeps repeating (at most one per
30 s once settled), shared by every wait on it and batched with the other
confirming reads due within 20 ms on that socket (at least ceil(N/200)
requests for N reports, more when long ids reach the query-byte budget
first); only a restart's held target is confirmed on the socket. - Go: a wait blocked on the confirming read of one report (version 7, say)
starts the read of a newer terminal report (version 8) only once that read
ends, since the wait reads no frames while it waits for a read; other waits
start its read at once, and the delay is at most one read (bounded by the
request timeout). A newer target frame queued meanwhile is not lost: before
the wait raises on the read, it takes the queued frames, and a newer target
wins (as Python and TypeScript settle a target at once). - An id that does not decode to a sandbox identity is not refused up front:
plain ids are legitimate in the API's id grammar, so such an id is read and
the API answers it.
Known gates
contract changes are deployed(and with itCI passed) stays red until a
maintainer adds thecontract-ahead-of-deploylabel, once the platform
change behind the contract copy is deployed.