Repository navigation
feat(runtime): the host refuses a request meant for another runtime - #27224
Conversation
A CLI launched from an Orca terminal now sends, with each request, the runtime it verified before sending (expectedRuntimeSource: the launching profile's installation id plus the verified runtime id). The host checks it before parsing params or running any handler and refuses a mismatch with runtime_source_mismatch, so a runtime that took over the endpoint between the CLI's check and its send cannot apply the request. Optional field: an old CLI sends none and an old host ignores it (the CLI's pre-send probe stays the fence there). Hosts advertise runtime-source-fence.v1.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The request fence adds protection for source-bound calls without changing older requests. No concrete merge-blocking issue is established; normal validation remains appropriate. Pre-merge checks |
|
ELI5
An
orcacommand typed in an Orca terminal now tells the running Orca which Orca it is meant for. If a different Orca answers, it says "not for me" and does nothing, instead of carrying the command out.What Changed
Before: the previous change (#27206) made the CLI check, before sending, that the running Orca is the one that launched its terminal. But the check and the send are two separate steps. The Orca that received the request had no way to tell whether the request was meant for it, so if another Orca took over the socket in between, it would just run it.
After:
expectedRuntimeSource: the launching profile's id plus the id of the exact running Orca the CLI just checked.runtime_source_mismatchand "Nothing was run." A host that does not know its own profile id refuses withruntime_source_unverifiable. A malformed field is refused withbad_request. The check covers both the one-shot socket transport and the streaming transport, because it sits in the shared request admission step.runtime-source-fence.v1in their status capabilities.status.getprobes, paired-server calls) run exactly as before.Why
Design adaptation: the design calls the field
_meta.expectedRuntimeSource. Requests have no_metaobject (only responses do), so it is a top-level request field, like the existingorchestrationContractVersion.Linked Issue
Fixes #17642 (together with #27206: the CLI refuses another runtime before sending, and now the host refuses a request meant for another runtime before running it).
Visual Proof
N/A. This is a CLI and RPC change with no UI.
Testing
src/main/runtime/rpc/runtime-source-admission.test.ts(realRpcDispatcher): another profile is refused before the handler runs, and so is another running Orca of the same profile. A matching request runs, and a request with no field runs as before. A host without a profile id refuses, malformed values are refused, and the streaming transport is fenced too. The refusal cases fail onorigin/mainbecause the handler ran.src/cli/runtime/runtime-source-fence.test.ts: the CLI sends the expectation with the runtime it verified (after a restart probe, and on the no-probe path). It sends none from an unstamped terminal, and none on thestatus.getprobe. These fail onorigin/main.tests/e2e/cross-version-wire/runtime-source-fence-downgrade.unit.test.ts: over a real socket and against the newest release's dispatcher, the newest release's host ignores the field and runs the request. A new host runs a request with no field, refuses a mismatch and runs a match.pnpm tc, focusedpnpm test(all ofsrc/cli/runtime/plus the dispatcher admission suites),oxlint,pnpm run check:code-quality:changed.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
Notes
Security: the field only lets a caller ask to be refused. Profile ids and runtime ids already appear in
status.get, and the check runs after authentication. SSH: the SSH bridge stamps the bridging runtime (#27206), so bridged commands carry this host's own ids and pass. WSL: the stamp crosses through WSLENV, so a WSL CLI sends the same field. Windows: the cross-version test uses a named pipe there. Folder workspaces: nothing here depends on Git. Mobile and paired clients send no field and are unchanged. Performance: one in-memory lookup per request that carries the field.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)