fix(orchestration): worker-start --on runs on the caller's own Orca, 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.
This commit is contained in:
Jinwoo-H
2026-11-09 14:40:15 -05:00
parent 225b4c8194
commit ef8314f712
2 changed files with 32 additions and 7 deletions
+23
View File
@@ -103,6 +103,29 @@ describe('--environment local and workspace addresses', () => {
}
})
it('runs worker-start --on on this Orca despite an inherited ORCA_ENVIRONMENT', async () => {
const args = [
'orchestration',
'worker-start',
'--on',
'build-box',
'--spec',
'Go',
'--agent',
'claude'
]
vi.stubEnv('ORCA_ENVIRONMENT', 'srv-b')
runtimeClientConstructorMock.mockClear()
listEnvironmentsMock.mockReturnValue(SAVED)
callMock.mockRejectedValue(new RuntimeClientError('runtime_unavailable', 'stop here'))
await run([...args, '--json'])
expect(runtimeClientConstructorMock).toHaveBeenCalled()
expect(
runtimeClientConstructorMock.mock.calls.every(([, environment]) => environment === null)
).toBe(true)
vi.unstubAllEnvs()
})
it('refuses current against another environment with an inspection command', async () => {
listEnvironmentsMock.mockReturnValue(SAVED)
const { exitCode, output } = await run([
+9 -7
View File
@@ -105,20 +105,20 @@ export async function main(
refuseConflictingSessionCallerFlags(commandSpec, parsed.flags)
await refuseLocalManagementSelector(parsed.commandPath, parsed.flags)
const RuntimeClientClass = await loadRuntimeClientClass()
// `--on` mail is carried by the caller's own Orca; an inherited server selection never reroutes it.
const peerMail = isPeerMailCommand(parsed.commandPath, parsed.flags)
// `--on` runs on the caller's own Orca, which reaches that server; an inherited selection never reroutes it.
const onCallersOrca = runsOnCallersOrca(parsed.commandPath, parsed.flags)
if (
peerMail &&
onCallersOrca &&
(parsed.flags.has('pairing-code') ||
(parsed.flags.has('environment') &&
!isLocalEnvironmentSelector(parsed.flags.get('environment'))))
) {
throw new RuntimeClientError(
'invalid_argument',
'--on already names the server the mail goes to; drop --environment. Your own Orca carries it.'
'--on already names the server; drop --environment. Your own Orca reaches it.'
)
}
const ignoreRemoteSelection = peerMail || ignoresRemoteSelection(parsed.commandPath)
const ignoreRemoteSelection = onCallersOrca || ignoresRemoteSelection(parsed.commandPath)
const pairingCode = ignoreRemoteSelection ? null : parsed.flags.get('pairing-code')
const environmentSelector = ignoreRemoteSelection ? null : parsed.flags.get('environment')
// An explicit local route suppresses ambient ORCA_ENVIRONMENT and pairing codes.
@@ -205,13 +205,15 @@ export async function main(
}
}
function isPeerMailCommand(
const ON_CALLERS_ORCA_COMMANDS: ReadonlySet<string> = new Set(['send', 'reply', 'worker-start'])
function runsOnCallersOrca(
commandPath: readonly string[],
flags: ReadonlyMap<string, string | boolean>
): boolean {
return (
commandPath[0] === 'orchestration' &&
(commandPath[1] === 'send' || commandPath[1] === 'reply') &&
ON_CALLERS_ORCA_COMMANDS.has(commandPath[1] ?? '') &&
flags.has('on')
)
}