Repository navigation
test(runtime): pin transport error code/message classification agreement - #12676
Conversation
Since #12667 a present error code is authoritative in `isRecoverableRemoteRuntimeConnectionError`, so a genuinely transient code that is missing from `RECOVERABLE_CODES` now classifies as fatal even when its own message reads as a transient connection failure. Fatal is the classification that dead-ends a terminal pane (#12650), and nothing prevented a future code from landing without a matching entry. This adds a differential guard over the reachable (code, message) corpus: 57 coded pairs plus 8 code-less ones, derived from the real producers wherever a unit test can call them. It fails if any pair is fatal-by-code while its message matches a recoverable fragment, and names the producer, the code and the fragment with the fix to apply. `RECOVERABLE_CODES` and `RECOVERABLE_MESSAGE_FRAGMENTS` are exported so the failure text can name the offending entry instead of duplicating the lists.
📝 WalkthroughWalkthroughThe change exports typed recoverable error-code and message-fragment collections. It adds a transport error agreement test suite that covers error producers, classification consistency, queue-overload handling, message-only fallback, recoverable coverage, and the 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/shared/remote-runtime-transport-error-agreement.test.ts (2)
52-55: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winFail loudly when an RPC frame changes shape.
frameErrorcurrently falls back to a parsedtype: 'response'frame ifparseRemoteRuntimeRpcFramestops returning an error. That drops a non-error object into the error corpus and can make the coded-error assertion fail without naming the producer. Assert thetype === 'error'branch before usingparsed.error.
62-183: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winEnsure hand-copied producer messages are derived or validated.
The static corpus duplicates producer error messages, so a producer message edit can leave a stale pair in the differential guard. Add a derived-entry helper for messages that do not need special frame parsing, or assert that this test still lists the current message in the producer module.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 46f6d777-cd4a-4537-bbdd-7e283abaf032
📒 Files selected for processing (2)
src/shared/remote-runtime-client-error-classification.tssrc/shared/remote-runtime-transport-error-agreement.test.ts
…ent (stablyai#12676) Since stablyai#12667, a present error code short-circuits classification: a code that is genuinely transient but missing from `RECOVERABLE_CODES` classifies as FATAL. That is the shape that dead-ends terminal panes — stablyai#12650 fixed exactly that for a different error, where a transient failure misclassified as fatal unmounted the Reconnect banner and left recreating the session as the only escape. Today the code and fragment sets agree. Nothing prevented a future code from being added without a matching entry, and the failure would have been silent. This pins that agreement: for every reachable transport error, a code that classifies fatal must not carry a message that would have classified recoverable. 57 coded pairs plus 8 code-less ones, derived by invoking the producers where possible so a reworded message updates the corpus instead of leaving a stale copy silently passing. The failure message names the offending fragment and says what to do about it. Enumeration turned up producers beyond the obvious ones — notably the Tailscale-hinted variants, where `runtime-environment-transport-routing.ts` mutates the message on an already-coded error before it crosses IPC, making those distinct corpus members. Also documented (not asserted, because it is unreachable today): `runtime_rpc_queue_overloaded` is absent from both host passthrough allowlists, so if it ever crossed `mapRuntimeError` it would flatten to `runtime_error` while keeping its "queue is full" message — precisely the dangerous shape. The queue pool is never instantiated on the server dispatcher, so it cannot happen now. The known exception is pinned rather than silently exempted: a dedicated test records WHY the guard cannot see `remote_runtime_busy` (fatal by code, matching no fragment, so the two sides have nothing to disagree about). If someone rewords a busy message into connection wording, that test fails and points at STA-3479. Proven non-vacuous by four separate injections. The only production change is two `const` to `export const`.
What this pins
Since #12667,
isRecoverableRemoteRuntimeConnectionErrorandisRuntimeRpcQueueOverloadErrortreat a present error code as authoritative and consultRECOVERABLE_MESSAGE_FRAGMENTSonly when there is no code. That is the right design — English substring matching was never a contract — but it introduces a new failure mode: a genuinely transient code that is missing fromRECOVERABLE_CODESnow classifies as fatal, even when its own message plainly reads as a transient connection failure that the fragment list would have rescued before.Fatal is the classification that dead-ends a terminal pane. #12650 fixed exactly that shape for a different error: a transient failure misclassified as fatal called
recovery.cancel(), which unmounted the Reconnect banner and left the user no escape but recreating the session. The sets agree today; nothing prevented the next code from landing without a matching entry, and the regression would have been silent — no crash, no log, just a pane the user cannot recover.This adds a differential guard over the corpus of reachable transport errors: for every producer that can reach the two classifiers, it asserts that the pair's code classification never says fatal while its message classification says recoverable.
The corpus
57 coded pairs and 8 code-less ones, enumerated from the producers rather than from the code sets:
RemoteRuntimeClientErrorconstruction sites acrossremote-runtime-client.ts,remote-runtime-request-frames.ts,remote-runtime-request-websocket.ts,remote-runtime-memory-limits.ts, the shared-control modules (-open,-connection,-ready,-admission,-subscription-start,-protocol) andremote-runtime-prepared-request-admission.tsRuntimeRpcCallQueueOverloadError(all three scopes share one message)RuntimeRpcCallError, covering bothRUNTIME_PASSTHROUGH_CODES(message equals the code) andSTRUCTURED_RUNTIME_PASSTHROUGH_CODES(message is the host's), plus theruntime_errorfallthrougherror.messageon an already-coded error before it crosses IPCweb-runtime-client.tsandremote-runtime-terminal-multiplexer.ts, plus the untypedipcMain.handlerejection shapeWhere a producer is callable from a unit test the pair is derived by invoking it (
parseAuthenticatedFrame,remoteRuntimeUnavailableError,formatSharedControlCloseMessage,withRemoteRuntimeTailscaleHint, …), so editing a message updates the corpus with it instead of leaving a stale copy behind. Only the pairs behind socket callbacks and module-private helpers are literals, each tagged with itsfile:line.Two coverage assertions keep the corpus from rotting in the other direction: every recoverable fragment and every recoverable code must be backed by a producer in the corpus, or explicitly declared producer-less (
reconnectingis the one such entry — it is status-state vocabulary that no error raises).Failure output
The guard is written to hand the next person an instruction, not a puzzle:
What it deliberately does not catch
remote_runtime_busyis exactly that today: four producers whose messages say "retry after…" but match no fragment, so they classify fatal and this guard stays silent. Tracked as STA-3479. Rather than exempt it quietly, the corpus includes those four pairs and a test pins why they are invisible — if someone later reworks a busy message into connection wording, that test fails and points at STA-3479 instead of letting the change look harmless.'Refreshing remote runtime control transport.'carriesremote_runtime_unavailableand no fragment would have rescued it.runtime_errorfallthrough inmapRuntimeErrorforwards whatever the host threw, so only representative messages are pinned. Worth noting the one dangerous instance is not reachable:runtime_rpc_queue_overloadedwould be flattened toruntime_errorwhile keeping its "queue is full" message, but the queue pool is client-local (src/main/ipc/runtime-environment-call-queue.tsand the web preload) and never sits on the server dispatch path.Non-vacuity
Each assertion was verified to fail before landing green — a guard that cannot fail is worse than none.
{code:'runtime_error', message:'Remote Orca runtime closed the connection.'}{code:'runtime_error', message:'Remote runtime call queue is full; …'}'remote terminal stream is not connected'from the fragment listRECOVERABLE_CODESProduction change
Only two
consts becomeexport const(RECOVERABLE_CODES,RECOVERABLE_MESSAGE_FRAGMENTS) so the failure text can name the offending entry rather than duplicating the lists in a copy that would drift. No behavior change.Verification
viteston the new guard plus the classification,runtime-environments, shared remote-runtime transport (20 files / 223 tests) and pty-transport (108 tests) suites;pnpm run typecheck;oxlint(default, native-plugin and type-aware configs);oxfmt --check; max-lines ratchet and reliability gates.🤖 Generated with Claude Code