Skip to content

test(runtime): pin transport error code/message classification agreement - #12676

Merged
Jinwoo-H merged 1 commit into
mainfrom
test/transport-error-classification-agreement
Aug 5, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
test/transport-error-classification-agreement

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

What this pins

Since #12667, isRecoverableRemoteRuntimeConnectionError and isRuntimeRpcQueueOverloadError treat a present error code as authoritative and consult RECOVERABLE_MESSAGE_FRAGMENTS only 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 from RECOVERABLE_CODES now 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:

  • RemoteRuntimeClientError construction sites across remote-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) and remote-runtime-prepared-request-admission.ts
  • RuntimeRpcCallQueueOverloadError (all three scopes share one message)
  • both wrapped close-message formatters, at close codes 1006, 1011, and 1011-with-reason
  • host-forwarded codes reconstructed by RuntimeRpcCallError, covering both RUNTIME_PASSTHROUGH_CODES (message equals the code) and STRUCTURED_RUNTIME_PASSTHROUGH_CODES (message is the host's), plus the runtime_error fallthrough
  • Tailscale-hinted variants, since main rewrites error.message on an already-coded error before it crosses IPC
  • code-less producers in web-runtime-client.ts and remote-runtime-terminal-multiplexer.ts, plus the untyped ipcMain.handle rejection shape

Where 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 its file: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 (reconnecting is 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:

NON-VACUITY PROBE: code "runtime_error" classifies fatal but its message matches
recoverable fragment "remote orca runtime closed the connection" — either add
"runtime_error" to RECOVERABLE_CODES in remote-runtime-client-error-classification.ts,
or change the message so it no longer reads as a transient connection failure.

What it deliberately does not catch

  • A transient code whose message matches no fragment. There is nothing for the code to disagree with, so the pair looks consistent. remote_runtime_busy is 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.
  • The reverse direction (recoverable code, fatal-reading message) is allowed on purpose: that is the code doing its job. 'Refreshing remote runtime control transport.' carries remote_runtime_unavailable and no fragment would have rescued it.
  • Open-ended host messages. The runtime_error fallthrough in mapRuntimeError forwards whatever the host threw, so only representative messages are pinned. Worth noting the one dangerous instance is not reachable: runtime_rpc_queue_overloaded would be flattened to runtime_error while keeping its "queue is full" message, but the queue pool is client-local (src/main/ipc/runtime-environment-call-queue.ts and 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.

Injected defect Result
{code:'runtime_error', message:'Remote Orca runtime closed the connection.'} 1 failed / 5 passed
{code:'runtime_error', message:'Remote runtime call queue is full; …'} 2 failed / 4 passed (trips the overload guard too)
removed 'remote terminal stream is not connected' from the fragment list 1 failed / 6 passed
added an unproduced code to RECOVERABLE_CODES 1 failed / 6 passed
none 7 passed

Production change

Only two consts become export 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

vitest on 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

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.
@Jinwoo-H
Jinwoo-H merged commit 2ec36a9 into main Aug 5, 2026
43 checks passed
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The 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 remote_runtime_busy exception.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change and verification in detail, but omits the required Summary, Screenshots, Testing, AI Review Report, Security Audit, and Notes sections. Add the required template headings, state “No visual change,” record testing results, and include AI review, cross-platform, security audit, and follow-up notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding tests that verify transport error code and message classification agreement.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
src/shared/remote-runtime-transport-error-agreement.test.ts (2)

52-55: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Fail loudly when an RPC frame changes shape.

frameError currently falls back to a parsed type: 'response' frame if parseRemoteRuntimeRpcFrame stops 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 the type === 'error' branch before using parsed.error.


62-183: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Ensure 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

📥 Commits

Reviewing files that changed from the base of the PR and between 2496458 and 34ede00.

📒 Files selected for processing (2)
  • src/shared/remote-runtime-client-error-classification.ts
  • src/shared/remote-runtime-transport-error-agreement.test.ts

enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant