You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(orchestration): mail an agent on a paired server with send --on; its reply comes back by itself - #40106
An agent on one computer can now mail an agent that is already running on a paired Orca server, and get the answer back. You write send --on <server>; your own Orca carries the mail there and later fetches the reply. The agent on the server just answers with a normal reply, and the reply shows up in your own check, waking you like local mail.
Files
Added
Deleted
Net
Test
4
$\color{#1a7f37}{\Huge{\mathbf{+}}}$595
0
$\color{#1a7f37}{\Huge{\mathbf{+}}}$595
Prod
38
$\color{#1a7f37}{\Huge{\mathbf{+}}}$1353
$\color{#cf222e}{\Huge{\mathbf{−}}}$46
$\color{#1a7f37}{\Huge{\mathbf{+}}}$1307
What Changed
Before
# A chat agent on this computer:
$ orca orchestration send --environment devB --to term_9f3c --subject "Is main green?"
error: session_caller_host_boundary: This request reached Orca from a paired client, and an Orca session ID identifies a caller only on the host that runs that session.
# A terminal agent: accepted, but the reply can never come back.
$ orca orchestration send --environment devB --to term_9f3c --subject "Is main green?"
messageId=msg_f9dd4e316405
# ...on devB the agent replies, and it is refused: terminal_not_found
After
# Any agent (terminal or chat) on this computer:
$ orca orchestration send --on devB --to term_9f3c --subject "Is main green?" --body "reply when you know"
messageId=msg_f20f98cf3571
# On devB, the agent's check shows who it came from, and the reply takes no flag:
msg_f20f98cf3571 [status] from=term_bae1… on Jinwoo's MacBook Pro
$ orca orchestration reply --id msg_f20f98cf3571 --body "Green."
# Back on this computer, check --wait wakes with the answer:
msg_a306f85a4534 [status] from=term_9f3c on devB-machine
Re: Is main green?
Green.
Recipients can be a terminal agent (term_…) or a chat agent (orca_session_id:…) on the server. Either side can keep replying in that conversation. The server can only answer conversations this computer started; it never starts new ones or connects back.
Refusals, all before anything is sent:
# The server runs an older Orca:
error: server_mail_unsupported: Server oldB runs an older Orca that cannot receive agent mail from another server. Update Orca on oldB, then send again. Nothing was sent.
# An agent points mail or work at a server with --environment (or an inherited ORCA_ENVIRONMENT):
error: agent_server_route_refused: send with --environment devB runs on devB and nothing comes back to you. To message an agent on devB, use: orca orchestration send --on devB --to term_9f3c --subject 'Is main green?'
error: agent_server_route_refused: worker-start with --environment devB runs on devB and nothing comes back to you. To start a worker on devB, use: orca orchestration worker-start --on devB ...
error: mailbox_is_local: Your mailbox is on this Orca; replies from devB arrive here. Drop --environment devB.
A person's own shell keeps today's --environment behaviour (run the command on that server). Only agents that their own Orca verifies (a chat by its session, a terminal agent by its launch) get these refusals. A chat agent's read-only commands against a server (inbox, worker-list, run-list --environment devB) now run there like a shell's instead of being refused.
Mechanism
send --on <server> uses the same server names and resolver as worker-start --on. The caller's own Orca checks the server can receive peer mail, then hands the message over (orchestration.peerMailDeliver). The server stores it with its usual mail code, labelled <sender> on <server name>. Mail between servers is only accepted from a paired computer, not a phone.
A reply to mail that came from another server goes back by its message id. The server queues it in the existing durable federation relay. This computer's Orca pulls it with a waiting pull (peerMailPull, about 20 s per wait), stores it once, wakes the caller, then acknowledges it (peerMailAck). The pull loop starts again whenever the orchestration database opens, so a reply waiting during a restart of either side still arrives, once.
The mail lands in the caller's mailbox. That is the Run it coordinates when it has one, so check and chat mail delivery work as for local mail. A terminal caller is found again by its pane after a restart.
One CLI rule keeps send, reply and worker-start with --on on the caller's own Orca, even with an inherited ORCA_ENVIRONMENT, so the --on command in an agent refusal works as printed. It refuses --on together with --environment, and refuses it when the Orca carrying the mail is too old to support it. reply --on is refused on both sides ("Drop --on").
A conversation belongs to one pairing: after a server is re-paired, the next send or reply opens a new one. The server accepts only peerconv_ conversation ids, so mail cannot name another Orca's dispatch in the relay.
The orchestration guide (placement and remote, messaging) teaches send --on, the flagless reply, and that --environment runs a command there.
Why
Agents coordinate across computers today only by starting workers with worker-start --on. Mail to an agent that already runs elsewhere either fails for chat agents or loses the reply for terminal agents. The caller's own Orca already knows who the caller is and already has a durable pull-only channel to its paired servers. Reusing both is the smallest change that works for both agent kinds. It also keeps pairing one-way: the server never connects back. We didn't let --environment silently turn into mail routing for agents, because that would change what an existing flag means. Agents get an exact --on command instead.
Linked Issue
Internal (maintainer).
Visual Proof
N/A: CLI and runtime behaviour only. The before and after output is above, and the live results are below.
Testing
Live, on head 1f51d95: two isolated dev Orcas built from this branch (own profiles, paired with each other in both directions), plus two Orcas built from main (as the older server and home, and for the before-run). Real Claude terminal agents, Claude chats and an OpenCode chat.
Check
Result
before-run on main: terminal send --environment, then the reply
terminal_not_found on reply; chat: session_caller_host_boundary; --on unknown
the same, B→A: terminal→terminal, terminal→chat, chat→terminal, chat→chat
pass, all 4
a 7-message back-and-forth between two terminal agents
pass, each message stored once
this Orca stopped, two replies (terminal and chat) sent meanwhile, then restarted
pass: both arrived, once; nothing left queued
server stopped with a reply queued, restarted, then this Orca
pass: arrived once; the conversation went on after both restarts
older server (main build)
server_mail_unsupported, nothing stored there
older home: its own CLI / this CLI on that Orca / its send --environment to the new server
--on unknown / refused, nothing sent / unchanged
agent send, worker-start, check with --environment and with inherited ORCA_ENVIRONMENT (terminal and chat)
refused with the exact --on command / mailbox_is_local
the worker-start --on command from that refusal, run with ORCA_ENVIRONMENT still set
pass: worker started on the server, finished on this Orca
reply --on, on either side
refused, "Drop --on"
chat agent inbox, worker-list, run-list with --environment
ran on the server
a person's shell send --environment
unchanged
Automated: a two-runtime contract suite. It covers both agent kinds' reply routes, delivery that survives restarting both sides, older-server refusal with nothing sent, phone-pairing refusal, a retried delivery acknowledged after its recipient closed, and refusals for payload fields and for workers another Orca coordinates. Also CLI tests for the agent-only --environment refusal and the older-Orca gate, and a test that chat reads to a server drop the session id. Every added test fails without the change. Ran on macOS.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Risk
Level: Medium
New mail path between paired Orcas. Older servers are refused before anything is sent. An older Orca running this CLI is refused by the CLI, because it would otherwise drop --on and mail a local agent. An older computer talking to a newer server is unchanged.
Each paired server that a conversation was opened with gets one waiting pull at a time. Idle, that is about three requests a minute per server, and each retry waits up to 30 s while the server is unreachable.
Agents that used send/worker-start/check --environment <B> now get a refusal naming the --on command. A person's shell is unaffected.
worker-start --on now always runs on the caller's own Orca. Before, an inherited ORCA_ENVIRONMENT sent it to that server, where the server name did not resolve.
Stored data: two new tables (peer_mail_conversations, peer_mail_messages), created if missing. Replies reuse the existing relay table. A revert leaves those tables unused and harmless.
Back out with a plain revert.
Review
Adversarial review found four issues, all fixed in the second commit: the CLI gate on an older carrying Orca, a retried delivery after its recipient closed, payload fields that were silently dropped, and workers another Orca coordinates.
A second, fresh review of the whole diff (Codex and Claude) found more, fixed with a test each that fails on revert: a server accepted any conversation id, so a paired computer could read another Orca's queued relay items; a reply replayed after a mail reset jammed the pull loop; reset tasks dropped replies still waiting to be pulled; a re-paired server refused every later send and reply; a registry read error stopped the pull loop; the worker-start --on hint did not work with an inherited ORCA_ENVIRONMENT; and the opening side still took reply --on. Declined: a forged sender label (a paired computer already has workspace control of the server), more replies within a conversation this Orca opened (conversations are two-way), retention for the new tables and the idle pull (follow-up), and a person's shell inside an agent's shell counting as that agent (launch evidence cannot tell them apart).
Landing order
This PR lands first, on --environment, the flag main has today. The later CLI rename (#40097) rebases onto it and converts these reads and this copy to its new flag name.
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
Cross-platform: no platform-specific code; the CLI and runtime paths are shared. Remote SSH and WSL panes are unchanged. Mobile: phone pairings can't send mail between servers. Folder workspaces work (nothing assumes git).
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)
I stated the risk: what could break, for whom, and how to back it out
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
This change adds paired-server agent mail through the optional --on flag. It adds peer-mail RPC contracts, database storage, delivery and reply handling, and relay loops that pull queued replies into the originating server’s mailbox. CLI checks distinguish mail routing from remote command execution. The guides describe the send and reply flow, capability requirements, and related command behavior.
Merge Risk: Low · up to 3514a
Cross-server agent mail works as described. In an edge case, the refusal message for an agent using --environment can show a malformed suggested command. This does not affect message delivery, so the change is mergeable with minor follow-up.
Pre-merge checks: 5
Check name
Status
Explanation
Title check
The title clearly identifies the main change: sending mail to an agent on a paired server with send --on.
Docstring Coverage
Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentati…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description check
The description is complete and follows the template. It explains the user-facing change, mechanism, rationale, testing, risk, rollback, and cross-platform considerations. It marks visual proof as N/A…
Full details: Docstring Coverage
Explanation
Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 20 functions across 37 files.
Full details: Description check
Explanation
The description is complete and follows the template. It explains the user-facing change, mechanism, rationale, testing, risk, rollback, and cross-platform considerations. It marks visual proof as N/A with a reason and identifies the author as an internal maintainer, for whom the AI Disclosure section does not apply.
Finishing Touches
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
⚠️ Outside diff range comments (4)
Major · Keep conversations bound to their original peer · peer-mail-store.ts:24-57
src/main/runtime/orchestration/db/federation/peer-mail-store.ts:24-57 Major · Data Integrity & Integration · Heavy lift
Keep conversations bound to their original peer
If a resumed VM gets a new host key but retains its mail database, the same local agent reuses the old conversation ID with a fresh pairing credential. The server can reject the new send because that conversation belongs to the old credential. Preserve the old conversation and open a separate one for the new peer.
Major · Reject replies when the conversation’s peer has changed · peer-mail-reply.ts:91-92
src/main/runtime/rpc/methods/orchestration/messaging/peer-mail-reply.ts:91-92 Major · Security & Privacy · Quick win
Reject replies when the conversation’s peer has changed
After a VM resume replaces the host key, a reply to an imported message can send its body to the replacement server. The server receives the body even if it later rejects the recipient or conversation. Compare the current fingerprint with the saved fingerprint before delivery.
Suggested fix
const server = await requirePeerMailServer(runtime, environmentId)
+ if (server.peerFingerprint !== conversation.peer_fingerprint) {+ throw new OrchestrationError(+ 'peer_changed',+ `Server ${server.name} now identifies a different Orca server. No reply was sent.`,+ NOTHING_SENT+ )+ }
await deliverPeerMail(runtime, server, conversation, {
Major · Bind pulled replies to the conversation’s peer fingerprint. · peer-mail-relay.ts:136-142
src/main/runtime/orchestration/federation/peer-mail/peer-mail-relay.ts:136-142 Major · Security & Privacy · Heavy lift
Bind pulled replies to the conversation’s peer fingerprint.
After re-pairing, a replacement server with access to the old peer database can return an old conversation ID in a crafted pull response. The relay accepts the reply under the old conversation and delivers it to the local agent.
Resolve the server before pulling, pin the pull and acknowledgment to that pairing revision, and compare its fingerprint with each conversation before importing the reply.
Minor · Use --environment for remote reads · bundled-skill-guides.ts:4155-4158
src/cli/bundled-skill-guides.ts:4155-4158 Minor · Functional Correctness · Quick win
Use --environment for remote reads
The CLI rejects --server as an unknown flag for both inbox and worker-list. Use --environment in the source guide and regenerate the bundled guide.
Suggested fix
-`--server <server>` runs one command on that server and delivers nothing back+`--environment <server>` runs one command on that server and delivers nothing back
to you, so an agent never mails with it. Your mailbox stays on your own Orca:
`check` takes no server flag. Read-only commands such as `inbox` or
-`worker-list` with `--server` show that server's records. A server whose Orca+`worker-list` with `--environment` show that server's records. A server whose Orca
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 6c5e42a9-4545-405c-81f2-a13c468238ac
Commits
Reviewing files that changed from the base of the PR and between ab87c59 and 3ab7707.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
25-25: Trivial · Maintainability & Code Quality · Low value
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Remove or fix the unused ast-grep-ignore directive.
ast-grep reports this suppression as unused. The rule name orchestration-agent-kind-branch may not match the line below it. A lint step that denies unused suppressions would fail. Remove the directive, or move it to the line the rule flags.
Source: Linters/SAST tools
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 89768e1b-ff9b-471c-810b-6fc2bcb9791f
Commits
Reviewing files that changed from the base of the PR and between 9db1806 and 43600cf.
Files ignored due to path filters: 1
src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Guard the findIndex result in withOn.
withOn calls kept.findIndex(...) and then kept.splice(at + 1, ...). When neither send nor worker-start appears in kept, at is -1. The splice call then inserts --on <server> at index 0, before the orchestration token. The suggested command in the refusal message is then malformed.
This case is reachable when rawArgs is undefined. ctx.rawArgs is optional in HandlerContext, so args becomes empty and the message shows a bare --on <server>. It is also reachable when a prefix of the argv contains an alias that is not matched.
Fall back to a message without a rewritten command when the subcommand is not found.
Proposed fix
--- "a/src/cli/handlers/orchestration/agent-server-route.ts"+++ "b/src/cli/handlers/orchestration/agent-server-route.ts"@@ -50,9 +50,12 @@
}
kept.push(arg)
}
- const at = kept.findIndex((arg) => arg === 'send' || arg === 'worker-start')- kept.splice(at + 1, 0, '--on', server)- return renderOrchestrationArgv(kept) ?? ''+ const at = kept.findIndex((arg) => arg === 'send' || arg === 'worker-start')+ if (at === -1) {+ return `the same command with --on ${server} instead of --environment ${server}`+ }+ kept.splice(at + 1, 0, '--on', server)+ return renderOrchestrationArgv(kept) ?? ''
}
/** An agent's mail and workers live on its own Orca; pointing them at another server reaches nobody. */
Committable suggestion
IMPORTANT
Review the replacement and indentation, then test before committing.
If neither send nor worker-start appears in kept, at is -1. splice(0, 0, '--on', server) then puts --on before the other tokens. This happens when ctx.rawArgs is undefined, because HandlerContext.rawArgs is optional. The refusal message then suggests a malformed command. Fall back to a generic hint when no subcommand is found.
Proposed fix
const at = kept.findIndex((arg) => arg === 'send' || arg === 'worker-start')
+ if (at === -1) {+ return `the same command with --on ${server} instead of --environment ${server}`+ }
kept.splice(at + 1, 0, '--on', server)
Replace the per-conversation query loop in pendingReplies with one bounded query.
pendingReplies calls db.listPeerConversationIds(peerFingerprint). It then runs one listPendingFederationRelay query per conversation. listPeerConversationIds returns every conversation the peer has ever opened. The query count grows with conversation history, not with the number of pending replies.
The relay calls peerMailPull in a loop, and each pull runs this scan twice: once before the wait and once after the wake. A long-lived pairing therefore issues many SQLite reads on every cycle, even when no reply is queued.
Add a store method that selects pending to_home rows for all role = 'peer' conversations of one peer_fingerprint. Use a JOIN, order by creation, and apply LIMIT PULL_PAGE_SIZE. The scan then costs one query per call.
The loop also always scans conversations in the same order. A conversation early in that order can fill the 50-item page and delay later conversations until it is acknowledged. A single ordered query removes that bias.
86-86: Trivial · Maintainability & Code Quality · Low value
Remove the unused ast-grep-ignore directive.
ast-grep reports this directive as an unused suppression for orchestration-agent-kind-branch. The rule does not match mayNameSession(to) here. Delete the directive so lint:ast-grep stays clean and the comment does not hide a future rule match.
🧹 Proposed fix
- // ast-grep-ignore: orchestration-agent-kind-branch -- peer mail may name a chat session on this Orca
if (mayNameSession(to)) {
Source: Linters/SAST tools
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 07089669-68fd-47c3-bcbb-57c7fd287921
Commits
Reviewing files that changed from the base of the PR and between 9db1806 and 3514af5.
Files ignored due to path filters: 1
src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
…ts and re-pairs, keep pulling on a registry error
- A server takes only peerconv_ conversation ids, so a paired computer cannot name another Orca's dispatch in the relay.
- A replayed reply after a mail reset is acknowledged, not retried forever; reset tasks keeps replies waiting to be pulled.
- A re-paired server starts a new conversation instead of refusing every later send and reply.
- A failed registry read keeps the pull loop retrying.
- Drop the two ast-grep-ignore lines that only #40193's rule needed.
…like send --on
An inherited ORCA_ENVIRONMENT sent worker-start --on to that server, so the
--on command the agent refusal suggests did not work. One rule now keeps
send, reply and worker-start with --on on the caller's own Orca.
… between servers
The side that opened the conversation still took --on when it named the right
server; the reply usage says --on is accepted only to refuse it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
An agent on one computer can now mail an agent that is already running on a paired Orca server, and get the answer back. You write
send --on <server>; your own Orca carries the mail there and later fetches the reply. The agent on the server just answers with a normalreply, and the reply shows up in your owncheck, waking you like local mail.What Changed
Before
After
Recipients can be a terminal agent (
term_…) or a chat agent (orca_session_id:…) on the server. Either side can keep replying in that conversation. The server can only answer conversations this computer started; it never starts new ones or connects back.Refusals, all before anything is sent:
A person's own shell keeps today's
--environmentbehaviour (run the command on that server). Only agents that their own Orca verifies (a chat by its session, a terminal agent by its launch) get these refusals. A chat agent's read-only commands against a server (inbox,worker-list,run-list --environment devB) now run there like a shell's instead of being refused.Mechanism
send --on <server>uses the same server names and resolver asworker-start --on. The caller's own Orca checks the server can receive peer mail, then hands the message over (orchestration.peerMailDeliver). The server stores it with its usual mail code, labelled<sender> on <server name>. Mail between servers is only accepted from a paired computer, not a phone.peerMailPull, about 20 s per wait), stores it once, wakes the caller, then acknowledges it (peerMailAck). The pull loop starts again whenever the orchestration database opens, so a reply waiting during a restart of either side still arrives, once.checkand chat mail delivery work as for local mail. A terminal caller is found again by its pane after a restart.send,replyandworker-startwith--onon the caller's own Orca, even with an inheritedORCA_ENVIRONMENT, so the--oncommand in an agent refusal works as printed. It refuses--ontogether with--environment, and refuses it when the Orca carrying the mail is too old to support it.reply --onis refused on both sides ("Drop --on").peerconv_conversation ids, so mail cannot name another Orca's dispatch in the relay.send --on, the flagless reply, and that--environmentruns a command there.Why
Agents coordinate across computers today only by starting workers with
worker-start --on. Mail to an agent that already runs elsewhere either fails for chat agents or loses the reply for terminal agents. The caller's own Orca already knows who the caller is and already has a durable pull-only channel to its paired servers. Reusing both is the smallest change that works for both agent kinds. It also keeps pairing one-way: the server never connects back. We didn't let--environmentsilently turn into mail routing for agents, because that would change what an existing flag means. Agents get an exact--oncommand instead.Linked Issue
Internal (maintainer).
Visual Proof
N/A: CLI and runtime behaviour only. The before and after output is above, and the live results are below.
Testing
Live, on head 1f51d95: two isolated dev Orcas built from this branch (own profiles, paired with each other in both directions), plus two Orcas built from main (as the older server and home, and for the before-run). Real Claude terminal agents, Claude chats and an OpenCode chat.
send --environment, then the replyterminal_not_foundon reply; chat:session_caller_host_boundary;--onunknownsend --on+ flagless reply, A→B: terminal→terminal, terminal→chat, chat→terminal, chat→chat, chat→OpenCode chatserver_mail_unsupported, nothing stored theresend --environmentto the new server--onunknown / refused, nothing sent / unchangedsend,worker-start,checkwith--environmentand with inheritedORCA_ENVIRONMENT(terminal and chat)--oncommand /mailbox_is_localworker-start --oncommand from that refusal, run withORCA_ENVIRONMENTstill setreply --on, on either sideinbox,worker-list,run-listwith--environmentsend --environmentAutomated: a two-runtime contract suite. It covers both agent kinds' reply routes, delivery that survives restarting both sides, older-server refusal with nothing sent, phone-pairing refusal, a retried delivery acknowledged after its recipient closed, and refusals for payload fields and for workers another Orca coordinates. Also CLI tests for the agent-only
--environmentrefusal and the older-Orca gate, and a test that chat reads to a server drop the session id. Every added test fails without the change. Ran on macOS.Risk
Level: Medium
--onand mail a local agent. An older computer talking to a newer server is unchanged.send/worker-start/check --environment <B>now get a refusal naming the--oncommand. A person's shell is unaffected.worker-start --onnow always runs on the caller's own Orca. Before, an inheritedORCA_ENVIRONMENTsent it to that server, where the server name did not resolve.peer_mail_conversations,peer_mail_messages), created if missing. Replies reuse the existing relay table. A revert leaves those tables unused and harmless.Review
Adversarial review found four issues, all fixed in the second commit: the CLI gate on an older carrying Orca, a retried delivery after its recipient closed, payload fields that were silently dropped, and workers another Orca coordinates.
A second, fresh review of the whole diff (Codex and Claude) found more, fixed with a test each that fails on revert: a server accepted any conversation id, so a paired computer could read another Orca's queued relay items; a reply replayed after a mail reset jammed the pull loop; reset tasks dropped replies still waiting to be pulled; a re-paired server refused every later send and reply; a registry read error stopped the pull loop; the
worker-start --onhint did not work with an inheritedORCA_ENVIRONMENT; and the opening side still tookreply --on. Declined: a forged sender label (a paired computer already has workspace control of the server), more replies within a conversation this Orca opened (conversations are two-way), retention for the new tables and the idle pull (follow-up), and a person's shell inside an agent's shell counting as that agent (launch evidence cannot tell them apart).Landing order
This PR lands first, on
--environment, the flag main has today. The later CLI rename (#40097) rebases onto it and converts these reads and this copy to its new flag name.Agent skill upstream boundary
Notes
Cross-platform: no platform-specific code; the CLI and runtime paths are shared. Remote SSH and WSL panes are unchanged. Mobile: phone pairings can't send mail between servers. Folder workspaces work (nothing assumes git).
Checklist