Repository navigation
Conversation
Vidoc security reviewTip Good to merge — no security issues found. Reviewed 150 of 155 changed files. 5 deleted files have no code to review. 💬 Have questions? Tag @vidoc in a comment and I'll answer. |
There was a problem hiding this comment.
All reported issues were addressed across 105 files
This PR moves logic across many files. Ultrareviews find 2.4x more serious bugs than standard reviews. Comment @cubic-dev-ai ultrareview to run one.
View guided diff | Turn on auto-fix | Re-trigger cubic
|
@cubic-dev-ai review |
@MDzaja I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 5 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 105 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
|
@cubic-dev-ai review |
@MDzaja I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 106 files
Requires human review: Auto-approval blocked because this review re-detected 8 unresolved issues already reported by Cubic.
View guided diff | Turn on auto-fix | Re-trigger cubic
|
@cubic-dev-ai review |
@MDzaja I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 56 files (changes from recent commits).
Requires human review: Auto-approval blocked because this review re-detected 2 unresolved issues already reported by Cubic.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 108 files
Requires human review: Auto-approval blocked because this review re-detected 10 unresolved issues already reported by Cubic.
View guided diff | Turn on auto-fix | Re-trigger cubic
|
@cubic-dev-ai review |
@MDzaja I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 110 files
Requires human review: Auto-approval blocked because this review re-detected 2 unresolved issues already reported by Cubic.
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.
View guided diff | Turn on auto-fix | Re-trigger cubic
|
@cubic-dev-ai review |
@MDzaja I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 113 files
Requires human review: Auto-approval blocked because this review re-detected 3 unresolved issues already reported by Cubic.
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.
View guided diff | Turn on auto-fix | Re-trigger cubic
|
@cubic-dev-ai review |
@MDzaja I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 112 files
Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 32 files (changes from recent commits).
Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.
View guided diff | Turn on auto-fix | Re-trigger cubic
|
@cubic-dev-ai review |
@MDzaja I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 119 files
Requires human review: Auto-approval blocked because this review re-detected 2 unresolved issues already reported by Cubic.
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.
View guided diff | Turn on auto-fix | Re-trigger cubic
|
@cubic-dev-ai review |
@MDzaja I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 119 files
Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.
View guided diff | Turn on auto-fix | Re-trigger cubic
Signed-off-by: MDzaja <mirkodzaja0@gmail.com>
…te or fork sees it reach started, and only then; a start on a started sandbox honours a close; re-entered batched reads keep an unheld query Signed-off-by: MDzaja <mirkodzaja0@gmail.com>
…ost 1,000 ids and 65,536 bytes with none refused by the frame bucket, the fork targets in the Python notes Signed-off-by: MDzaja <mirkodzaja0@gmail.com>
|
@cubic-dev-ai review |
@MDzaja I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 155 files
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.
View guided diff | Turn on auto-fix | Re-trigger cubic
…n when its read after the target spends the budget; tests for the macOS create route and a failed confirming read's reason Signed-off-by: MDzaja <mirkodzaja0@gmail.com>
…ther status, or the same status at a higher version; credential refusals in the fallback batching note Signed-off-by: MDzaja <mirkodzaja0@gmail.com>
…report when it shows a lag-free terminal state; fork() refuses an unusable id before reading its source (Python, TypeScript) Signed-off-by: MDzaja <mirkodzaja0@gmail.com>
…on ready with its first read; tests for a close or cancellation during the settling read after started Signed-off-by: MDzaja <mirkodzaja0@gmail.com>
…te, Go's worst measured frame mixes Signed-off-by: MDzaja <mirkodzaja0@gmail.com>
|
@cubic-dev-ai review |
@MDzaja I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 155 files
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.
View guided diff | Turn on auto-fix | Re-trigger cubic
… kind or one too long for any request) before it reads its source, in all three SDKs; the Go settling test delivers a late answer and a late 503 Signed-off-by: MDzaja <mirkodzaja0@gmail.com>
…t and its resets, the failed-connect and refused-mint resets, a completed delete wait leaves the handle destroyed Signed-off-by: MDzaja <mirkodzaja0@gmail.com>
…ellation wins a wait's race, so asyncio never logs it as never retrieved Signed-off-by: MDzaja <mirkodzaja0@gmail.com>
…racter ids), the surrogate refusal as existing behaviour Signed-off-by: MDzaja <mirkodzaja0@gmail.com>
|
@cubic-dev-ai review |
@MDzaja I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 155 files
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.
View guided diff | Turn on auto-fix | Re-trigger cubic
… the report, the 4401 count resets in AGENTS.md, the macOS read-after-started sentence Signed-off-by: MDzaja <mirkodzaja0@gmail.com>
… it is Signed-off-by: MDzaja <mirkodzaja0@gmail.com>
|
@cubic-dev-ai review |
@MDzaja I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 155 files
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.
View guided diff | Turn on auto-fix | Re-trigger cubic
…s SDK source, the raw state field per language Signed-off-by: MDzaja <mirkodzaja0@gmail.com>
|
@cubic-dev-ai review |
@MDzaja I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
No issues found across 155 files
You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.
View guided diff | Turn on auto-fix | Re-trigger cubic
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 bytefrom 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):
pingafter 5 s ofsilence; no frame within 10 s of it closes the socket and reconnects
(backoff, resubscribe). Its waiters stay registered.
removed (Python
_run_early_probe, TypeScriptrunEarlyProbe, GowaitProbe), and so is the "final reserve" of single reads.destroyedincluded, whether a live frame reports it or the hub alreadyheld 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 unheld
GET /sandboxes/batch-wait?ids=…with no wait target, at most200 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 atonce from the same view as the single read; a window holding one id uses
the plain
GET /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 plain
GET(it needs fields batch items lack). Cost: 500 sandboxesfailing 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 reported
destroyed, which it confirms; the SDK's own 400for 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 ofrestart()is confirmed by re-subscribing the id: the held target, or asnapshot 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-id
NOT_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 apartfrom the snapshots with no order (subscribe chore(deps): bump the github-actions group with 5 updates #2's
LIMITcan arrive beforesubscribe chore(deps): bump the github-actions group in /.github/actions/setup-toolchain with 5 updates #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. A
MALFORMED, or aLIMITwithout an id, drops nothing.
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 with
LIMIT(then at once), is the sandbox read once, inside thebudget (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 503SERVICE_UNAVAILABLEfrom the SDK, becomes the timeout's cause, as does anordinary round's partial answer), and any other failure ends the wait
with that error.
WORKLOAD_PLANE_ELSEWHERE; any other 501 is a failed connect and isretried; three failed connects, or
DAYTONA_SANDBOX_EVENTS=0; and after a reconnect, until the new socket'sfirst frame proves it; events off and a permanently refused mint (404,
501
WORKLOAD_PLANE_ELSEWHERE, and in Go 401 / 403) read this way for aslong 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 with
GET /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 sandboxesand 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.
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.
answers a held read at once on (loose
waitonstopping/stopped/deleting/deleted/failed/lost,
wait_exactonfailed/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.
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.
policy. A transient failure (no response, a client timeout, a 429, a 5xx
other than 501; batch-wait never answers
LIMIT_EXCEEDED) is retried nextround 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.
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.
does not decide it (all three SDKs).
UUID, base58 of its 16 bytes, with or without
sbx_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 theresponse carries
X-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's
NoWaitandStart's first read included), and so is a well-formed id of anotherkind (
vol_,img_,snap_,fn_plus base58 of a UUID, optionallyfollowed by
-and a non-empty region tag), whether or not the tag isthere: 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).
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 changed
cpu, for example); anomitted or null field keeps the handle's value. A toolbox URL is validated and adopted only when
present. The macOS
start()/resume()read after the target alsofollows a batch-decided target.
a random 0–20%.
connect is more than 1 s (the batches' minimum interval) away, for a retry
hint (a 503 with
Retry-After, say), a refused mint or the reconnectback-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.
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 thereconnect 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.
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.
(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()'swait_exact, the fork wait targets, processwaits, the token-refresh pause, the reconcile timer, wait errors and timeouts.
Waits on a closed client now raise
ClientClosedErrorin every SDK (thePython 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.
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).
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).
(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's12,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 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
pytest -n 8 -m "not timing"and-m timing) on 3.15and 3.11, ruff, mypy;
_syncregenerated.go test -race -shuffle=on ./...,go vet(with and without-tags e2e),golangci-lint.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 itsfix: 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 notnot-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.
destroyedthat is not the target is confirmed by one read (confirmed,gone, refuted), and so is a held one (only
restart()'s held target isconfirmed 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 empty
sandboxes).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 held
failed/destroyedgets one plain read; two waits on onesandbox 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 501
WORKLOAD_PLANE_ELSEWHEREthen a batch 501ends the wait after one batched read; an id too long for any request fails before a subscribe; a
server-shaped batch item replaces
cpuand keeps the fields it omits; aclosed 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.
LIMITfor subscribe chore(deps): bump the github-actions group with 5 updates #2 followed by chore(deps): bump the github-actions group in /.github/actions/setup-toolchain with 5 updates #1's snapshot does not confirm chore(deps): bump the github-actions group with 5 updates #2 (all three
SDKs); a mint 503 with
Retry-After: 30leads to batched reads withinabout 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).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's
errorfollows presence (allthree); 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.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.d/822.changed.md; unreleased fragments thatdescribed the confirmation were updated.
scripts/gen-contract-types.sh --checkand the changelog check pass.the hosted API, which already serves
GET /sandboxes/batch-wait.Merge order
This copies the platform's final
contract/sandbox-events-protocol.jsonbyte 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 inX-Daytona-Cells-Failed; the socket'sping/pong; re-subscribesnapshots). 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.DeadlineExceededwhen that deadline passes while it waits foranother 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
mode at once (the batched reads start or stop with it), and a reconnect no
longer carries a per-id
LIMITcooldown from the old socket to the new one.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.)
LIMITrefusal a final check has not handled yet survives a reconnect(all three SDKs).
over it at every place a wait takes a result.
all three SDKs; the waiter's ordinary batched reads still hold.
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 returns
context.DeadlineExceeded.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.
(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.
ended, it counts as no read, and another wait reads for itself instead of
raising the report (superseded by the member model below).
(less than 3 s), as Python and TypeScript do.
server's retry hint when it is longer than the 60-72 s fallback window.
out, re-checked when a slow credential delays the send, so the 1 s floor
between two requests of one batch holds.
main(the contract conflict resolved by keeping this branch'scopy); a batch item's SSH gateway fields reach the handle in Python and Go,
as in TypeScript.
so a refuted burst stays batched (above).
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).
it with that
BadRequestError(all three SDKs); in TypeScript it is parsedin full before it is shared, each wait's
observeis contained, and theconfirming task never leaves a floating rejection.
is validated, so a malformed one never makes an omitted id missing (a
delete does not report success).
snapshot is pending (all three SDKs); in Go a queued correction also wins
over a confirming read.
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.
GET /sandboxes/batch-waitrequest itself (an API or aproxy that serves no batched reads) is a 501
NOT_IMPLEMENTEDof sourceSDKin all three SDKs, never a not-found: adelete()never reportssuccess and a wait never raises not-found because of it.
that read's sandbox into its handle (every field it carried), as Python
and TypeScript already did.
reset (the hub closing a socket still connecting can reset it, which
escaped as an uncaught
ECONNRESETon Node 22); a new test resets theconnection before and after the handshake and checks that the hub keeps
going with nothing escaping.
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.
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.
version_ruledrops triggers no read and leaves theback-off alone, and that a permanent mint failure (404, 501
WORKLOAD_PLANE_ELSEWHERE) falls back for that socket only and is neverminted again; every stand-in server's upgrade socket handles a reset.
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.
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.
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.
comes 1 s after the batch's previous request rather than after the grown
interval (up to 2.4 s), as TypeScript already did.
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.
destination is dropped under the key it was opened with, so none is left
behind.
not reset the socket's liveness clock.
failed connects, the id-byte encoders, development notes, and two
changelog fragments.
judged after its budget ran out ends with the reported state
(
SandboxTerminalStateError), as one whose budget runs out with the readon the wire does; a re-read of a report it already refuted still ends with
its timeout.
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.
confirm collection window as a client worker (so
Close()returns onlyafter 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.
(
was_known=false) keeps the wait going on batched reads, while one thestream 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. The
wait-poll-spacingfragmentscopes its spacing to fallback rounds and its retries to batched reads.
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.
are taken first: a target still succeeds, and a terminal report still
standing ends the wait with that state, as in Python and TypeScript.
restart()step, or a wait with a terminal state a laggingread can show (a pause's
started, a joined start'sstopped), neverrides a batched request that went out before it: that answer may predate
its own operation; it re-issues as before.
earlier API response is asked again once on the region's stream, whatever
was_knownsays.waits (a slow runner fails on an assertion, not a bare test timeout).
StartandResumefor the macOS read after the target (Startreads the sandboxbefore it acts, so it knows the class even by ID;
Client.Resumeby IDknows it only from a read during the wait).
API accepts (32 hex digits, hyphenated, braced, or after a lower-case
urn:uuid:; hex in either case), besides the base58 sandbox id. Go nowmatches 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).
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).
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.
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).
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.
never ride; the confirming reads' batch size names the 11,000-byte id
limit.
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.
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.
routed by its region hint retries once on the region's socket, as Go
does, instead of ending the wait (a
delete()reported done).it is, as in Python and TypeScript.
urn:uuid:UUID carries no region tag, so 500 suchwaits share 3 batches instead of 500 one-id requests under bogus regions.
the spellings its waits use (256 spellings of one sandbox: 1 plain read,
was 2 requests).
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.
whose waits all left meanwhile (nothing sent, no send time kept).
the class; the changelog names what supersedes a refuted report, the ride
exception and the idle-batch wake; dead fields and stale comments
removed.
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).
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.
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.
window apart, and still see one read per sandbox.
wire (all three SDKs): it reads the sandbox as it is after its re-subscribe
went unanswered.
LIMITrefusal that wakes a final check after the watch moved toanother session restarts the check there, as in Python and TypeScript,
instead of reading at once.
confirming read are kept in a set, so many spellings of one sandbox, or
many frames, no longer slow frame handling.
(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.
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.
report a confirming read refuted is no longer decided by it (a later
wait(until="destroyed")ordelete()could return for a sandbox the readshowed alive); it is judged by that read instead, as Go already did.
restart()step that registers while a snapshot of the sandbox isalready on its way (another wait's re-subscribe) re-subscribes too, so that
earlier snapshot can no longer confirm the step (all three SDKs).
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.
confirmation by identity, as in Python and TypeScript; a read on the wire
for it then decides nothing.
Restartstep nolonger decides the step when it is queued during a confirming read or
drained at the deadline (the frame path already refused it).
refused with
BadRequestErrorbefore any request, instead of leaking theruntime's encoding error (
URIError/UnicodeEncodeError).one (it carried over the previous socket's time; no decision read it).
the new socket has subscribed, so a slow runner's reconnect cannot race
the read (Python, TypeScript).
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.
unbounded
delete()that joined on the repeated report, say) keeps theshared 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.
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.
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).
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.
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).
TypeScript do), so a long-lived batch whose waits come and go no longer
grows its status map without bound.
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).
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 a
restart()step after a run of refusals waited until its finalcheck (52.5 s of a 60 s budget, TypeScript, measured) instead of settling
on its own snapshot (all three SDKs).
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.
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).
waiting for its re-subscribe to go out at once (it starts over there), not
when the new session sends its own subscribe.
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.
"Merge order" no longer contradicts "Known gates".
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.
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.)
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.
URL-encoded id bytes with each id's 3-byte
%2Cseparator, the API's12,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's
ErrClientClosedare named.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).
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).
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.
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).
restart()step are exact: TypeScript orderssubscribe 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.
port 0) clears the handle's, as in Python and Go.
own instant is no answer, as in Python and TypeScript (
>=).another wire status or a higher version (not any state); the Go README
lists the fallback after three credential refusals.
main(3cca1f9), which madeSandboxTerminalStateErrornamethe 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 carries
operationand reads<operation> did not complete: sandbox <id> is <state>[: <reason>], asmain's existing paths do; tests pin each path in all three SDKs.
credential refusals in a row end the socket's waits with
AuthenticationErrorinstead of reading them in batches (Go reads them inbatches, where the API's own refusal ends them, as its README already
said).
(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 feat(sdk-go): add the Go SDK, go.daytona.com/sdk/v2 #693, in
released Go SDKs;
mainhas the same two scans, andmain's stale sweephas 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 weremeasured 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,
in
schedule()andnextDeadline(), to find LIMIT-refused ids whose retrywas 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 onceit is due, re-tracks the ids it leaves refused, and
nextDeadline()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-wide
LIMITretry, 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 rowcounts before and after: 0 HTTP reads in every run):
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 atthe 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). Python
sock.ws is None, woken by_signal_subscribes; TypeScriptisOpen, woken bynotifySubscribes; GoWatchLiveness.OpenandcheckUnsent, woken by the Reading channel, which a connection's openingand 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 truncates
setTimeoutdelays, and thewindow'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 uses
Math.ceiland re-arms while the deadline is ahead. Pythonre-checks in a loop (
_subscribe_sent) and Go re-arms onconsider(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 resubscribesin 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 beingwritten 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, asTypeScript's
whenSubscribeSentand Go'sonTimeralready did, and theanswer check reads nothing past the deadline.
Go:
TestWait_aCloseThatBeganWinsOverAWaitThatEndedWithItcloses theclient 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 first
sendBy;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):
Math.random0.123), 20 s / 60 sstartedThe hung-reconnect cases still read exactly once (Go: 40 of 40 under
-race -count=20; Python and TypeScript: their tests and the review'sdrivers), 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
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. For
Restart()this was a real failure: thestop (and the snapshot answering the final check's re-subscribe) could be
replaced by the start's
running, and the first step, which waits for thesandbox to leave
started, then waited until its timeout. The streamitself 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 theonly 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: only
running); a restart whose first step takes nothinguntil all three have reached it completes with no read (failed before:
timed out).
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 whatholds: 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).
WORKLOAD_PLANE_ELSEWHEREreads 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
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 waitstogether sent 1,001 frames in 0.2 s, against the server's 100 inbound
frames a second, which drops the excess with a socket-level
LIMITandcloses 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
(Python
last_flush_at, TypeScriptlastFlushAt, Gosession.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,Python
test_*_keep_the_flush_pace, TypeScript "short final-checkwindows 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: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 of
wait(timeout=0.2), 14–15frames 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).
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 withoutits 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).
check scanned the socket's subscriptions; a Python
setkeeps the slotsof 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's
Setshowed 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.
(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.mdand822-unsubscribe-first.fixed.md. The Go scan countersays what it is for.
Also fixed: one flush pace on every path, test time, and the review's other findings
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 theconnection'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.drain back to back once it frees, each paced only by its own budget
tokens (see "Frame rates" below for the measured figures).
(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).
(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.
Hub.Closeabandons every forwarder, including one for a watchthe hub already ended (a not-found) whose consumer neither reads nor
releases, which
Closecould wait on (unreachable through the SDK,whose waits release their watch). Test included.
busy-budget test (and every test on the virtual clock) armed each wait's
budget with a real
asyncio.wait_for, so on a slow runner the waitsended before their virtual final-check marks, which failed the test in
CI. The virtual clock now also runs
wait_for(a wait's budget, thesocket'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.
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 Go
Watchdoc saysthe 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's
wait_fortimes out at oncewith no time left and keeps a value its operation returns on
cancellation, as
asyncio.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:
arriving 300 ms waits, 1,500 refused retries; Go);
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);
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".
Also fixed: a newer target behind a confirming read (Go), and every sandbox on a stale learned stream (all three)
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 reportinstead of returning on
running@2. The wait now takes every frame thehub 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; Pythonand TypeScript, which settle a target during dispatch, gain the same
scenario as a test.
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 streamreturned with the sandbox reported
destroyedwhile it was still beingdeleted (and
start()/wait()raised not-found for a live sandbox).This was on
maintoo. Now the decision is the socket's own: Python andTypeScript key sockets by kind and value, as Go's
endpointKeyalreadydid, 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.
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.
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).
(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).
restart step's subscribe answered by an older snapshot completes with no
read; without the replay it stays pending).
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.
a closed client, a 404 except after
destroyed, the SDK's own 400, anon-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 waitsfor that operation to settle (targets
started,paused,stopped). Whenanother caller started the sandbox meanwhile, that wait ended the call on
startedfrom a frame or a batched read's item, neither of which carriesthe boot mode or the reservation. It now ends through the read after the
target, as a start does; a settled
pausedorstoppedis not read (theresume or start request follows). A failed read keeps the success, and a
close still wins.
startednow make the same read (Python
_wait_without_raising_for_its_end,TypeScript
waitUntilCreatedand the fork'sreadAfterTarget, Go'sinternal
waitwithreadAfterMacOSTarget).startedin every SDK (it followed any targetbut
destroyed). Every public call that can end with a macOS sandboxstarted:startedstart()(stopped, or joiningstarting)start()settling a stop or pause that endsstartedstart()on a sandbox alreadystartedresume()create*()waitstartedreturns as it isfork()waitrestart()wait()refresh_data()/refreshData()/Refresh)unheld query. A wait whose last seen state a held read answers at once
(say
stoppedfor a wait forstarted) moved to the unheld reads onlywhen 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.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.
start()that finds the sandbox alreadystartedends 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.
markSent, used only by tests, moved to a test file.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
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.
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.
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.
LIMITis retried after a fixed 2 s in all three SDKs (as on
main), so clientsrefused together retry at one instant. The follow-up lengthens that delay
by a random 0–20% with the existing spread helpers.
Known behaviour kept
NOT_FOUNDframe withwas_known=falseon a healthy socket (an id theendpoint 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.
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.
for that id; that only re-subscribes the older wait sooner.
on the wire is re-issued no sooner than 1 s after it began).
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.
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).
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 amaintainer adds the
contract-ahead-of-deploylabel, once the platformchange behind the contract copy is deployed.