Skip to content

feat(runtime): the host refuses a request meant for another runtime - #27224

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/d4-d4-cl2
Oct 10, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/d4-d4-cl2

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​328 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​325
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​103 $\color{#cf222e}{\Huge{\mathbf{−}}}$​15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​88

ELI5

An orca command 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:

  • Every request the CLI sends from a stamped terminal carries a new optional field, expectedRuntimeSource: the launching profile's id plus the id of the exact running Orca the CLI just checked.
  • The host checks that field first, before reading params or running anything. If the profile or the running Orca differs, it refuses with runtime_source_mismatch and "Nothing was run." A host that does not know its own profile id refuses with runtime_source_unverifiable. A malformed field is refused with bad_request. The check covers both the one-shot socket transport and the streaming transport, because it sits in the shared request admission step.
  • Hosts advertise runtime-source-fence.v1 in their status capabilities.
  • No change for anything else: requests with no field (an old CLI, a CLI started outside an Orca terminal, status.get probes, paired-server calls) run exactly as before.

Why

  • The host must make the final call. A check on the client before sending always leaves a gap before the request arrives. Only the receiving side can refuse at the moment the request would take effect.
  • Check the exact running Orca as well as the profile. The CLI has already accepted a restarted Orca of the same profile, and it sends that Orca's id. Requiring the host to be that same Orca means even a second Orca on the same profile cannot pick up the request. This mirrors the response check the CLI already did, but before any effect instead of after.
  • A separate field, not part of the orchestration envelope. Federation forwards that envelope to other servers, which would then refuse it wrongly.
  • Optional field, no new method. Following the remote compatibility rules: an old host ignores the field (the CLI's pre-send probe from fix(cli): check the runtime source before sending #27206 is still the fence there), and a new host treats a missing field as before. The capability is there so clients can tell whether the host-side guarantee holds. Nothing requires it, so mixed versions keep working.

Design adaptation: the design calls the field _meta.expectedRuntimeSource. Requests have no _meta object (only responses do), so it is a top-level request field, like the existing orchestrationContractVersion.

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 (real RpcDispatcher): 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 on origin/main because 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 the status.get probe. These fail on origin/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, focused pnpm test (all of src/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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

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

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

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.
@coderabbitai

coderabbitai Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2f56be7d-eb8a-42d1-87f8-f72abb88b37f

📥 Commits

Reviewing files that changed from the base of the PR and between 7aa91f7 and 18f351e.


📒 Files selected for processing (11)
  • src/cli/runtime/client.ts
  • src/cli/runtime/runtime-source-fence.test.ts
  • src/cli/runtime/runtime-source-fence.ts
  • src/cli/runtime/transport.ts
  • src/main/runtime/rpc/core.ts
  • src/main/runtime/rpc/rpc-request-admission-prologue.ts
  • src/main/runtime/rpc/runtime-source-admission.test.ts
  • src/main/runtime/rpc/runtime-source-admission.ts
  • src/shared/protocol-version.ts
  • src/shared/runtime-rpc-envelope.ts
  • tests/e2e/cross-version-wire/runtime-source-fence-downgrade.unit.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.



📝 Walkthrough

Walkthrough

The CLI runtime source fence now returns a verified source ID and runtime ID for local requests. The transport includes that expectation in the RPC payload. The host validates supplied expectations during request admission and rejects malformed, unverifiable, or mismatched values before handler invocation. Tests cover CLI request expectations, host admission results, and wire behavior between current and released hosts.


Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 18f35

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 | Passed 3 | Failed 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check Warning The PR implements a local request field and a host admission fence for matching runtime IDs. It does not satisfy the full source-binding requirements in #17642. In runtime-source-fence.ts, a changed… Implement source-specific bootstrap records and an ownership-verified, atomic restart/adoption handoff. Keep a source-bound caller unavailable when only the profile matches or the runtime epoch changes. Capability-gate or fail closed before…
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 11 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: the host rejects requests intended for a different runtime.
Description check Passed The description is detailed and covers the required sections, including the user impact, implementation, rationale, linked issue, testing, compatibility, and checklist. Manual testing and full validat…
Out of Scope Changes check Passed The changed production files define, transport, enforce, and advertise the runtime-source fence. The added tests cover CLI propagation, shared admission, streaming admission, and wire compatibility. T…

Full details: Linked Issues check

Explanation

The PR implements a local request field and a host admission fence for matching runtime IDs. It does not satisfy the full source-binding requirements in #17642. In runtime-source-fence.ts, a changed runtime ID is accepted after a status probe when installationId matches. This permits a same-profile restart without an authoritative adoption handoff, which #17642 explicitly forbids. The PR also sends the field to older hosts that ignore it, so the source-bound mutation can silently downgrade to the pre-send check. RuntimeClient.call() bypasses this fence for remotePairing. The required paired/headless source binding is therefore not established.

Resolution

Implement source-specific bootstrap records and an ownership-verified, atomic restart/adoption handoff. Keep a source-bound caller unavailable when only the profile matches or the runtime epoch changes. Capability-gate or fail closed before source-bound mutations when the host ignores expectedRuntimeSource. Apply equivalent source binding to paired and headless paths, and add tests for these cases.


  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@OrcaWin
OrcaWin merged commit fff0bb0 into main Oct 10, 2026
38 checks passed
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.

[Bug]: Managed Agent CLI can target a different live Runtime than its launch source

1 participant