Repository navigation
feat(orchestration): let a structured chat run orchestration as itself - #22568
Conversation
There was a problem hiding this comment.
ℹ️ No critical issues — one minor correctness edge inline.
Reviewed changes
- Session id injected into every structured child.
structuredWorkerChildIdentityEnvbecomesstructuredSessionChildIdentityEnv, settingORCA_AGENT_SESSION_IDplus the CLI PATH entry for chats and workers alike; both native providers (Claude resolver, Codex builder) build their child env here. - Terminal view carries the same id.
ensureAgentSessionpasses the id in spawn env viawithStructuredSessionTerminalViewEnv, deliberately not in the persistedlaunchConfig.agentEnv. - CLI acts as the session. The shared resolver returns
undefinedwhen the injected id names the caller and refuses a conflicting caller flag withconsumer_fencedbefore any request; all 16 caller-naming verbs inherit the rule, with a per-verb and a 30-verb enumerated test. - Envelope and stripping. The id rides
orchestrationCompatibilityEvidence.agentSessionId; SSH host-CLI passthrough, inherited PTY env (local/daemon/relay), and WSL are handled, and the sharedstructworker_handle helpers move tosrc/shared. - Tests. Per-verb and enumerated CLI coverage plus env-propagation tests spanning native Claude/Codex (including a spawned real child), terminal view, WSL, PTY inheritance, and SSH.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No new issues in this delta. The run-scoped caller-flag gap for
gate-list/task-listis closed cleanly, with tests that fail against the previous code. The one open thread from the prior review —injectedSessionAddress()for a worker in terminal view — is untouched by these commits and remains open.
Reviewed changes
- Added
refuseConflictingSessionCallertoterminal-identity.ts. A session still validates the caller flag on a--run-scoped listing: it throwsconsumer_fencedbefore any RPC when--fromnames another actor, and returnsundefinedotherwise. - Routed
gate-list --runandtask-list --runthrough it. Both previously short-circuited toundefinedwhen--runwas present, so a conflicting--fromon the run-scoped path was silently dropped instead of refused. They now match every other caller-naming verb. - Pinned the run-scoped rule. A per-command test asserts the flagless path sends no caller param, that another actor's handle is refused with
consumer_fencedand zero RPCs, and that the session's ownsession:<id>spelling is accepted.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Important
The new structured-session-cli-login-shell.test.ts hardcodes /bin/zsh, which the default Linux unit-test shards do not have installed, so it will fail the required Unit-tests check. Verified locally: 2 of its 3 cases exit with spawn /bin/zsh ENOENT.
Reviewed changes
- Named this app's CLI by absolute path.
prependOrcaCliDirToChildPathnow returns the launcher, andstructuredSessionChildIdentityEnvsetsORCA_CLI_COMMANDto it (devorca-dev, packagedresources/bin/orca/orca.exe, packaged Linux shim) instead of the literal'orca', falling back only when there is no app environment. - Added a real-login-shell test.
structured-session-cli-login-shell.test.tssets a tempHOMEwhose profile prepends a stand-in globalorca, then asserts bareorcaresolves to the global and"$ORCA_CLI_COMMAND"resolves to this app forzsh -lcandbash -lc. - Updated env expectations. Claude, Codex, and identity-env tests now expect the absolute dev launcher.
The ORCA_CLI_COMMAND value is intentionally kept to the bare-name union when sent on the wire (resolveCompatibilityCliCommand, schema in orchestration-params.ts:45,125), while the locally printed resume commands use the absolute path and are quoted by renderCommand — both correct. The prior review's open injectedSessionAddress() thread is untouched by this commit.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Split the login-shell suite by shell. The zsh arm moved to a new
structured-session-cli-login-shell.live-shell.test.ts;structured-session-cli-login-shell.test.tskeeps only the bash arm, so it no longer spawns a shell the ordinary unit lane lacks. - Extracted the shared setup.
structured-session-login-shell-test-harness.tsholds the tempHOME, the stand-in globalorcastubs, and thestructuredSessionChildIdentityEnvwiring, consumed by both suites. - Wired the zsh arm into the real-shell lane.
pr.ymladds the new file to the shell-contracts job andunit-tests.ymladds it to the shard--excludelist, so the required Unit-tests check no longer runs it. - Taught the lane guard to see a
program-field zsh.realZshUsageinconfig/scripts/pr-workflow-parallelism.test.mjsgained aprogram:\s*['"](?:\/(?:usr\/)?bin\/)?zsh['"]alternative, and the new file joinedshellContractFiles— the mechanism that let the test escape the zsh-install lane.
Verified locally on the zsh-less runner: the lane guard passes (19/19), the bash arm passes (2/2), and the new live-shell file fails only when run directly outside the exclude.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
22f54f2 to
3ace023
Compare
2d9dc67 to
fef6854
Compare
3ace023 to
f771efd
Compare
fef6854 to
3af56b1
Compare
f771efd to
6746bb5
Compare
There was a problem hiding this comment.
ℹ️ No new issues in this delta. One low-impact edge raised by the prior review —
injectedSessionAddress()returningsession:<id>for a structured worker in terminal view — is unchanged by these commits, so this is informational rather than an approval.
Reviewed changes
- Refusal moved to a spec-declared, single CLI-entry check. Every
CommandSpecnow carriesidentityFlagRoles, andmain()refuses a session'scallerflag naming another actor once, after flag validation;targetflags (inbox --terminal,dispatch-show --from,worker-start --terminal) still pass through.namesInjectedSessioncompares plain strings so the check stays off the actor codec's module graph. - Session CLI handoff. A current CLI reached through a different install re-runs the command once through the launcher the session named (
ORCA_CLI_COMMAND), bounded byORCA_CLI_REEXEC, then exits with its status. The packaged macOS/Linux launchers, the Linux bare-orcashim/dispatcher, and the Windows launcher now exportORCA_CLI_SELF; a dev launcher exports none on purpose. - Absolute launcher in every local terminal.
buildPtyHostEnvnames this app's CLI by absolute path for all non-WSL terminals, not just structured sessions;resolvePackagedWindowsCompatibilityCommandnow maps an absolute value toorca/orca-ideinstead of throwing. - Omit rather than guess, and pin the instance.
applyThisAppClidrops an inheritedORCA_CLI_COMMANDand omits it (with a warning) when no launcher resolves, rather than falling back to bareorca, and setsORCA_USER_DATA_PATHbeside the identity.
Verified locally: tc:cli is clean and the new/changed suites pass (166 passed, 4 skipped across session-cli-reexec, orchestration-session-caller-cli, index-orchestration, structured-session-child-identity-env, cli-self-export, windows-launcher-asset, linux-terminal-orca-cli-shim). The declared flag roles match each handler's actual use, and the new plain-string acceptance set matches the old normalizeOrchestrationActor-based one.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
6746bb5 to
8dac986
Compare
0ef7f31 to
3f5f798
Compare
8dac986 to
a77c7a4
Compare
3f5f798 to
00f4525
Compare
a77c7a4 to
abe5c3d
Compare
9d02ccc to
52774a0
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since prior pullfrog review 5309964149 (0ef7f31623):
- Dropped the terminal-view session-id spawn.
52774a0337deleteswithStructuredSessionTerminalViewEnv, revertsensureAgentSessionto base, removes the WSLWSLENVid entry and the terminal-view PTY/daemon tests, and makes the inherited-stamp strip unconditional, since #22783 on the base removed the handoff that path served. - Moved
injectedSessionAddressinto shared.f8ab17a21brelocates it tosrc/shared/agent-session-caller-env.ts, backed by the import-free leafsrc/shared/orca-session-address-prefix.ts;orca-session-address.tsre-exports the prefix and reuses the leafSTRUCTURED_WORKER_HANDLE_PREFIX. - Kept the entry check off the codec graph.
f87111d528compares the session's spellings as plain strings (id,session:<id>, own handle) sorefuseConflictingSessionCallerFlagsstays off the actor codec's module graph. - Added a CLI-vs-host address cross-check.
orchestration-party-cli-address.test.tsassertsinjectedSessionAddresslands onresolveOrcaSessionParty(...).addressfor a chat (with an inherited pane handle) and a registered worker.
This also retires the prior open worker-in-terminal-view thread: with no terminal view presenting as a session, injectedSessionAddress can no longer mis-name a worker. tc:cli/tc:node are clean and the touched suites pass.
ℹ️ The PR description still documents the removed terminal-view path
The body's ELI5, sections 1/4/5, and the ablation table still describe the id being injected into a terminal view's spawn env and carried into WSL via WSLENV. 52774a0337 removed that path, so the description now maps a change that is not in the diff.
Technical details
# Stale PR description after the terminal-view removal
## Affected sites
- PR body, ELI5 and "What Changed" §1/§4/§5 — describe `withStructuredSessionTerminalViewEnv` and the WSL `ORCA_AGENT_SESSION_ID/u` passthrough as active.
- PR body, "Ported from #19648" and the ablations table — list the terminal-view spawn and its ablation as live mechanisms.
## Required outcome
- The description should state that only a native structured child (Claude/Codex) carries the id; a terminal view now carries neither the id nor the marker.
## Open questions for the human
- None.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
52774a0 to
df8b939
Compare
df8b939 to
7a0b037
Compare
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between a66627e7c2b7d52de06cc004249597fdb963e0ba and 97cfa1b280279b3e1736a4a8dda2504c71c276c7. 📒 Files selected for processing (11)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughStructured-session children now receive session identity and app CLI settings. The executable CLI can hand off to a session launcher, and orchestration commands validate caller identity flags. PTY and SSH subprocess environments remove inherited session markers. New tests cover child environments, CLI handoff, orchestration identity, and Bash and zsh command resolution. Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to Ordinary structured chats can attribute activity to a parent terminal or pane. Clear inherited identity before merging; the remaining test and CI-selection gaps also need owner attention. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to Structured chats can now run orchestration commands as themselves, with checks that reject conflicting caller names and nonlocal session claims. The remaining design risk is that a local process may be able to claim another active chat’s identity by changing its environment. That boundary needs confirmation before the risk can be treated as minimal. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 2e856898-d7b8-40a6-8df3-591ab34378a9
📒 Files selected for processing (66)
.github/workflows/pr.yml.github/workflows/unit-tests.ymlconfig/scripts/pr-workflow-parallelism.test.mjsconfig/scripts/vitest-caller-identity-env-setup.tsconfig/tsconfig.node.jsonconfig/vitest.config.tsnative/windows-cli-launcher/OrcaCliLauncher.csresources/darwin/bin/orcaresources/linux/bin/orca-idesrc/cli/command-spec.tssrc/cli/handlers/orchestration-windows-ask-cli.test.tssrc/cli/handlers/orchestration/dispatch-handlers.tssrc/cli/handlers/orchestration/message-check-handler.tssrc/cli/handlers/orchestration/message-send-handler.tssrc/cli/handlers/orchestration/question-handler.tssrc/cli/handlers/orchestration/run-handlers.tssrc/cli/handlers/orchestration/runtime-compatibility.tssrc/cli/handlers/orchestration/terminal-identity.tssrc/cli/index-orchestration.test.tssrc/cli/index.tssrc/cli/orchestration-session-caller-cli.test.tssrc/cli/runtime/orchestration-compatibility-envelope.tssrc/cli/session-caller-flags.tssrc/cli/session-cli-reexec.test.tssrc/cli/session-cli-reexec.tssrc/cli/specs/orchestration-worker-specs.tssrc/cli/specs/orchestration.tssrc/main/claude/claude-stream-json-connection.test.tssrc/main/claude/claude-structured-launch-resolution.test.tssrc/main/claude/claude-structured-launch-resolution.tssrc/main/cli/cli-self-export.test.tssrc/main/cli/cli-self-export.tssrc/main/cli/linux-bare-orca-dispatcher.tssrc/main/cli/linux-terminal-orca-cli-shim.test.tssrc/main/cli/linux-terminal-orca-cli-shim.tssrc/main/cli/orca-cli-child-path.tssrc/main/cli/windows-launcher-asset.test.tssrc/main/codex/codex-structured-child-environment.test.tssrc/main/codex/codex-structured-child-environment.tssrc/main/codex/codex-structured-session-adapter.test.tssrc/main/ipc/pty-daemon-spawn-agent-home-env.test.tssrc/main/ipc/pty-spawn-env-terminal-basics.test.tssrc/main/ipc/pty/host-env/assembly.tssrc/main/ipc/pty/host-env/pi-agent.tssrc/main/ipc/pty/host-env/spawn-env-keys.tssrc/main/ipc/pty/ipc/spawn-options.tssrc/main/ipc/pty/runtime/spawn-options.tssrc/main/providers/provider-dispatch.test.tssrc/main/runtime/orchestration/orchestration-party-cli-address.test.tssrc/main/runtime/rpc/methods/orchestration-structured-worker-session.test.tssrc/main/runtime/structured-session-child-identity-env.test.tssrc/main/runtime/structured-session-child-identity-env.tssrc/main/runtime/structured-session-cli-login-shell.live-shell.test.tssrc/main/runtime/structured-session-cli-login-shell.test.tssrc/main/runtime/structured-session-login-shell-test-harness.tssrc/main/runtime/structured-worker-child-identity-env.test.tssrc/main/runtime/structured-worker-child-identity-env.tssrc/main/runtime/structured-worker-identity.test.tssrc/main/runtime/structured-worker-identity.tssrc/main/ssh/ssh-remote-cli-host-passthrough.test.tssrc/main/ssh/ssh-remote-cli-host-passthrough.tssrc/shared/agent-session-caller-env.tssrc/shared/orca-session-address-prefix.tssrc/shared/orca-session-address.tssrc/shared/structured-session-marker.tssrc/shared/structured-worker-handle.ts
💤 Files with no reviewable changes (2)
- src/main/runtime/structured-worker-child-identity-env.test.ts
- src/main/runtime/structured-worker-child-identity-env.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
| --exclude=src/main/zsh-scoped-histfile.live-shell.test.ts \ | ||
| --exclude=src/main/zsh-startup-hook-user-config-equivalence.live-shell.test.ts \ | ||
| --exclude=src/main/zsh-wrapper-version-mismatch.live-shell.test.ts \ | ||
| --exclude=src/main/runtime/structured-session-cli-login-shell.live-shell.test.ts \ |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
rg -n 'SHELL_PREFIXES|shell-contract|shell_contract|structured-session-cli-login-shell|pr-code-change-scope' config/scripts/pr-code-change-scope.mjs .github/workflows/pr.yml .github/workflows/unit-tests.ymlRepository: stablyai/orca
Length of output: 1796
🏁 Script executed:
set -eu
printf '%s\n' '--- current scope detector ---'
sed -n '1,120p' config/scripts/pr-code-change-scope.mjs
sed -n '380,430p' config/scripts/pr-code-change-scope.mjs
printf '%s\n' '--- workflow shell-contracts job and final gating ---'
sed -n '450,610p' .github/workflows/pr.yml
sed -n '680,730p' .github/workflows/pr.yml
sed -n '1080,1195p' .github/workflows/pr.yml
printf '%s\n' '--- unit exclusion context ---'
sed -n '45,72p' .github/workflows/unit-tests.yml
printf '%s\n' '--- relevant paths in current and base revisions ---'
git show 7a0b03752a8e5d72f670bbeb8949155c9de0745b:config/scripts/pr-code-change-scope.mjs | sed -n '70,115p'
git show 77829142acac3358e28954099b9beb67534b7a81:config/scripts/pr-code-change-scope.mjs | sed -n '70,115p'Repository: stablyai/orca
Length of output: 28900
🏁 Script executed:
set -eu
printf '%s\n' '--- runtime test and related files ---'
git ls-files 'src/main/runtime/*structured-session*' 'src/main/runtime/*shell*' | sort
rg -n --glob '*.ts' --glob '*.tsx' 'structured-session-cli-login-shell|structured session|login shell' src/main/runtime src/main | head -120
printf '%s\n' '--- prefix matching and scope computation ---'
rg -n 'function matchesPrefix|matchesPrefix|function compute|const shouldRun|shouldRun|GLOBAL_FORCE_PREFIXES|ALWAYS_ON_CODE_JOBS' config/scripts/pr-code-change-scope.mjs
sed -n '115,220p' config/scripts/pr-code-change-scope.mjs
sed -n '300,385p' config/scripts/pr-code-change-scope.mjsRepository: stablyai/orca
Length of output: 28306
🏁 Script executed:
set -eu
sed -n '465,485p' config/scripts/pr-code-change-scope.mjs
printf '%s\n' '--- test and harness headers ---'
sed -n '1,45p' src/main/runtime/structured-session-cli-login-shell.live-shell.test.ts
sed -n '1,35p' src/main/runtime/structured-session-login-shell-test-harness.tsRepository: stablyai/orca
Length of output: 3676
Route the excluded test through shell contracts.
A change to src/main/runtime/structured-session-cli-login-shell.live-shell.test.ts or src/main/runtime/structured-session-login-shell-test-harness.ts does not match SHELL_PREFIXES. The shell-contracts job is skipped, while the unit shards exclude the live test.
Add both paths to SHELL_PREFIXES.
Suggested fix
const SHELL_PREFIXES = [
+ 'src/main/runtime/structured-session-cli-login-shell.live-shell.test.ts',
+ 'src/main/runtime/structured-session-login-shell-test-harness.ts',
'src/main/daemon/repro-13767-shell-ready-marker-lost-to-exec',| const DEV_CLI_BIN_FIRST = /^[^:;]*[\\/]cli[\\/]bin[:;]/ | ||
| // The dev launcher by absolute path: a login shell's profile cannot reorder it behind a global. | ||
| const DEV_CLI_LAUNCHER = /^[^:;]*[\\/]cli[\\/]bin[\\/]orca-dev$/ |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,115p' src/main/codex/codex-structured-child-environment.test.ts
sed -n '155,180p' src/main/claude/claude-structured-launch-resolution.test.ts
sed -n '26,48p' src/main/codex/codex-structured-session-adapter.test.ts
sed -n '40,58p' src/main/cli/orca-cli-child-path.tsRepository: stablyai/orca
Length of output: 8147
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- cited test files and imports ---'
sed -n '1,125p' src/main/codex/codex-structured-child-environment.test.ts
sed -n '145,185p' src/main/claude/claude-structured-launch-resolution.test.ts
sed -n '1,65p' src/main/codex/codex-structured-session-adapter.test.ts
printf '%s\n' '--- implementation bindings and platform helpers ---'
rg -n -C 4 'DEV_COMMAND_NAME|buildCodexStructuredChildEnvironment|orca-dev|process\\.platform|platform.*win32|isPackaged' src/main/codex src/main/claude src/main/cli src/main/runtime src/main -g '*.ts' | head -260
printf '%s\n' '--- workflow/platform support ---'
rg -n -C 3 'windows|win32|vitest|test' .github package.json pnpm-workspace.yaml 2>/dev/null | head -220Repository: stablyai/orca
Length of output: 41364
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- Windows workflow declarations ---'
find .github -maxdepth 3 -type f -print | sort
for f in $(find .github -maxdepth 3 -type f \( -name '*.yml' -o -name '*.yaml' \) -print | sort); do
if rg -q -i 'windows|win32|pnpm test|vitest run|test:' "$f"; then
printf '%s\n' "--- $f ---"
rg -n -C 5 -i 'windows|win32|pnpm test|vitest run|test:' "$f"
fi
done
printf '%s\n' '--- cited-file platform guards ---'
rg -n -C 2 'skipIf|process\\.platform|platform|win32|win' \
src/main/codex/codex-structured-child-environment.test.ts \
src/main/claude/claude-structured-launch-resolution.test.ts \
src/main/codex/codex-structured-session-adapter.test.ts || trueRepository: stablyai/orca
Length of output: 41736
🏁 Script executed:
#!/bin/bash
set -e
for f in .github/workflows/pr.yml .github/workflows/unit-tests.yml .github/workflows/computer-e2e.yml; do
printf '%s\n' "--- $f ---"
rg -n -C 8 'runs-on:.*windows|windows-2022|matrix\\.os|vitest run|pnpm test|src/main/codex|src/main/claude|structured-child|structured-launch|structured-session' "$f" || true
doneRepository: stablyai/orca
Length of output: 17568
Make the development launcher assertions platform-aware.
When these tests run on Windows, the unpackaged launcher is orca-dev.cmd, and its absolute path is drive-qualified. The current regexes reject the .cmd suffix and the drive letter. Reuse one helper across all three tests that uses path.basename for the launcher name and PATH.split(path.delimiter)[0] for the first PATH entry.
| ...childEnv, | ||
| ...(identity ? { ORCA_TERMINAL_HANDLE: identity.handle } : {}), |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,115p' src/main/runtime/structured-session-child-identity-env.ts
sed -n '55,105p' src/main/runtime/structured-session-child-identity-env.test.ts
sed -n '270,300p' src/main/claude/claude-structured-launch-resolution.ts
sed -n '1,85p' src/main/codex/codex-structured-child-environment.tsRepository: stablyai/orca
Length of output: 9850
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- exact environment identifier references ---'
rg -n --glob '*.ts' --glob '*.tsx' --glob '*.js' --glob '*.json' 'ORCA_TERMINAL_HANDLE|ORCA_PANE_KEY|injectedSessionAddress|structuredSessionChildIdentityEnv|resolveClaudeStructuredInvocation|buildCodexStructuredChildEnvironment' src test 2>/dev/null | head -240
printf '%s\n' '--- candidate Claude/Codex environment construction ---'
rg -n --glob '*.ts' 'childEnv|baseEnv|launch\.env|process\.env|environment|env:' src/main/claude src/main/codex src/main/runtime 2>/dev/null | head -240
printf '%s\n' '--- relevant files ---'
git ls-files | rg 'structured|identity|claude|codex|terminal|pane|caller|orchestration' | head -240Repository: stablyai/orca
Length of output: 41982
🤖 get_repo_knowledge executed:
get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions
Length of output: 44144
🏁 Script executed:
rg -n --glob '*.ts' --glob '*.tsx' 'ORCA_TERMINAL_HANDLE|ORCA_PANE_KEY|injectedSessionAddress|structuredSessionChildIdentityEnv|resolveClaudeStructuredInvocation|buildCodexStructuredChildEnvironment|launch\.env|childEnv' src | head -300Repository: stablyai/orca
Length of output: 33263
🏁 Script executed:
rg -n --glob '*.ts' --glob '*.tsx' 'ORCA_TERMINAL_HANDLE|ORCA_PANE_KEY|injectedSessionAddress|structuredSessionChildIdentityEnv|resolveClaudeStructuredInvocation|buildCodexStructuredChildEnvironment|launch\.env|childEnv' srcRepository: stablyai/orca
Length of output: 41979
Clear inherited terminal context before building the structured child environment.
Claude starts from process.env, and this helper spreads that environment. A chat without a registered worker can therefore retain inherited ORCA_TERMINAL_HANDLE and ORCA_PANE_KEY. The session ID still wins for orchestration caller resolution, so the inherited handle does not change injectedSessionAddress there. Hook and handle-based consumers can still attribute activity to the parent.
Suggested fix
const env: Record<string, string> = {
...childEnv,
- ...(identity ? { ORCA_TERMINAL_HANDLE: identity.handle } : {}),
[ORCA_AGENT_SESSION_ID_ENV]: sessionId,
[ORCA_STRUCTURED_SESSION_ENV]: '1'
}
+ delete env.ORCA_TERMINAL_HANDLE
+ delete env.ORCA_PANE_KEY
+ if (identity) {
+ env.ORCA_TERMINAL_HANDLE = identity.handle
+ }…ve Codex, the terminal view, WSL, PTY inheritance and SSH
…verb that names its caller Adds the per-verb table (flagless acts as the session; a conflicting --from or --terminal is refused before any request; the session's own spellings are accepted), the enumerated guess population with its positive control, the structured worker's own handle, the identity-less refusal for an older child, the unchanged terminal agent, and the envelope. dispatch-show's --from only fills preview text, so it passes through unfenced and a session's flagless preview names the address the real dispatch writes.
…marker; the id is checked first
…verbatim from the CLI
…LIs that predate it A CLI older than the id, reached through a global install when a shell rc resets PATH, would otherwise guess a sibling's terminal in a chat that no longer carries the marker. It refuses on the marker instead; a current CLI checks the id first, so the marker never makes a session with an id identity-less.
…-list scoped by --run A --run listing needs no caller, so both handlers skipped the resolver and a --from naming another actor was dropped silently under a session. The conflict check now runs on that branch too; terminal callers are unchanged.
…ured session's login shells A provider can run each command in a login shell: Codex runs zsh -lc, and the profile rebuilds PATH, putting a global install (possibly an older Orca) ahead of the directory Orca prepended. ORCA_CLI_COMMAND, which an agent resolves the CLI from first, is now the absolute launcher in that directory (the native launcher on Windows), so no shell's startup files can swap it. The PATH prepend stays for shells that read no profile. Found by the live coordinator run of the next PR.
…p's absolute launcher
…ne that installs zsh The ordinary Linux unit lane has no /bin/zsh, so the zsh arm failed there with ENOENT. It moves to a live-shell file registered in the shell-contracts lane; the bash arm keeps running in every lane. The lane guard's detector now also sees a zsh spawned through the ProcessSpec program field, which is how this test escaped it.
…ncher resolves, and pin its instance A bare `orca` fallback named GNOME's screen reader on packaged Linux, and an inherited value named another app's CLI. The builder now deletes any inherited value, sets the absolute launcher only when one resolved, and pins ORCA_USER_DATA_PATH so a current CLI dials the instance that minted the id. Renames the marker reader to hasStructuredSessionMarker and records why the terminal view carries the id without the marker.
… local terminal ORCA_CLI_COMMAND meant three things by lane: an absolute launcher for a structured session, a bare name for WSL, and nothing for any other terminal, so a structured session's terminal view lost it. Local terminals now get the same absolute launcher the structured lane gets; WSL keeps its guest command name, and a terminal whose launcher does not resolve still gets none.
…CLI was invoked A login shell can reorder PATH behind a global install, and an agent or its helper script can run bare `orca`, so the binary that answered depended on the agent following instructions. Orca's packaged launchers and bare-orca shims now export ORCA_CLI_SELF (outermost wins). At the CLI entry, when it names a different launcher than ORCA_CLI_COMMAND, the command re-runs once through the named launcher with ORCA_CLI_REEXEC=1 and exits with its status; both variables are consumed so no child inherits them. Dev launchers export no self on purpose, WSL and SSH names never qualify, and a launcher that cannot start leaves the command to run here. The Windows launcher no longer rewrites ORCA_CLI_COMMAND; the legacy ask protocol normalizes its resume command itself.
…spec and refuse at the CLI entry Each handler hand-classified its --from/--terminal as the caller or a target, and the refusal of a conflicting caller flag ran inside the caller resolver plus two standalone calls for --run listings, so a new verb that read its flag raw would pass a sibling's handle to a pre-session host. Specs now declare identityFlagRoles, the CLI entry refuses a conflicting caller flag once from the spec, the resolver only applies the id-wins rule, and a test fails any orchestration verb that accepts --from or --terminal without classifying it.
… graph The check runs at the CLI entry for every command, and the actor codec pulls zod through the session record. Compare the session's own spellings as plain strings instead.
…, off the codec's module graph The Orca session address prefix moves to a leaf module with no imports, re-exported by the address codec, so the CLI entry check derives `session:<id>` from that constant instead of re-typing it and still stays off the codec's zod graph. Prose and test names say caller or Orca session id, not actor.
…w that the handoff is gone The terminal handoff was removed, so no terminal is ever a structured session: - delete the terminal-view identity env and its WSL passthrough, and their tests; - strip the session caller keys from every terminal's env unconditionally; - the CLI's own-address spelling moves beside the injected id in src/shared, with a test pinning it to the address the host's party resolver gives that session.
…minal names Packaged Linux names the userData shim in ORCA_CLI_COMMAND, while the preflight ran the bundled launcher behind it. The CLI saw a different launcher and handed the preflight off to the shim, booting Electron twice before every codex launch.
… preflight Only a structured session needs an absolute ORCA_CLI_COMMAND; local terminals go back to naming none (WSL keeps its guest command), and the Codex launch preflight goes back to the bundled launcher. The CLI handoff is scoped to sessions, so a terminal's preflight can no longer be handed off and start Electron twice. This reverts commit d2cefb6 and commit dd2853a.
The handoff ran whenever an Orca launcher's ORCA_CLI_SELF differed from an absolute ORCA_CLI_COMMAND, so any process with both - a terminal, a script - ran another install's CLI instead of the one invoked: a beta's --version lied, and an AppImage command from a terminal that outlived its Orca failed. It now requires the injected session id, the identity it exists to deliver. The launcher variables are still consumed in every process.
The launcher stopped writing orca/orca-ide over ORCA_CLI_COMMAND so the handoff could see a session's absolute launcher, which also changed what every Windows terminal's CLI read. The CLI entry now applies the launcher's rule itself once the handoff is decided, so terminals and the legacy ask resume command see exactly what they saw before, and the resume-command reader goes back to its original form.
…ot a launcher export Every packaged launcher, shim and dispatcher exported ORCA_CLI_SELF so the CLI could tell which launcher ran it, and compared that with the session's ORCA_CLI_COMMAND. Two launchers of the same app are different files, so a session that reached its own app through a global orca-ide on Linux still handed off and started Electron twice, and the export rode artifacts every terminal uses. A structured session now also names the JS entry its launcher runs (ORCA_SESSION_CLI_ENTRY), and the CLI compares its own argv entry with it: any launcher of the same app stays, another install hands off. The launcher scripts, Linux shim and dispatcher go back to main; the Windows launcher keeps only leaving ORCA_CLI_COMMAND for the CLI to name after the handoff decision.
…injected id already bind any current CLI Every current Orca CLI dials the instance ORCA_USER_DATA_PATH names and sends the injected session id in the orchestration envelope, so a bare `orca` that reaches another install's current CLI already acts as the session. An older CLI has no handoff code and refuses on the marker. The handoff only lined up versions between two current CLIs, and comparing two separately derived paths kept misfiring (an AppImage's mount against its registered extraction started the CLI twice on every call). Removes the re-exec, ORCA_SESSION_CLI_ENTRY and ORCA_CLI_REEXEC, and the CLI-side Windows command naming; the packaged Windows launcher rewrites ORCA_CLI_COMMAND again, as on main, inside its own process only. resolveHostCliEntryPath goes back to the SSH passthrough.
…le, now that every session's env is populated
ed61356 to
ccb4b95
Compare

ELI5
A native chat can now run Orca orchestration commands as itself. Orca already gives every native chat an id. This PR puts that id, and this app's own
orcaCLI, into the environment of every command the chat runs. So when a chat runsorca orchestration run-create,checkorworker-start, it acts as that chat. Before, it either refused or, worse, guessed a nearby terminal and read that terminal's messages. Terminals are not changed at all.What Changed
Before: a native (structured) Claude or Codex chat that ran
orca orchestration ...had no identity of its own. The CLI either refused, or picked a sibling terminal pane in the same worktree and acted as it, which could consume that pane's messages (#21097).After: the chat acts as
session:<id>. It can create a run, start workers, and receive theirworker_done. It never touches another pane's messages, and a flag that tries to act as someone else is refused before anything is sent. Verified live with real Claude and Codex chats (screenshots below).Mechanism
structuredSessionChildIdentityEnv, used by both the Claude and the Codex native launch). It now sets:ORCA_AGENT_SESSION_ID: the Orca-minted session id, not the provider's, which rotates on/clear.ORCA_CLI_COMMAND: this app's CLI launcher by absolute path, plus the samePATHprepend terminals get. The absolute path matters because Codex runs every command aszsh -lc, and a login profile can put a globalorcaahead onPATH. When no launcher resolves, the key is left out rather than set to a bareorca, which on Linux is GNOME's screen reader.ORCA_USER_DATA_PATH: pinned to this instance, so any current CLI talks to the Orca that minted the id.ORCA_STRUCTURED_SESSION: kept next to the id, so a CLI that predates the id refuses instead of guessing a terminal.resolveOrchestrationTerminalHandle) checks the id first. When it is present, the CLI sends it in the orchestration envelope and resolves no terminal. The host (refactor(orchestration): resolve every caller and target to one orchestration party, keyed by the Orca session id #22555) binds it. All 16 commands that name a caller get this from the one resolver.--from/--terminalnames the caller or a target (identityFlagRoles). The CLI checks once, before any request, that a caller flag restates the session. Otherwise it refuses with "This command runs as agent session<id>, so --terminal<x>would act as a different caller. Drop --terminal … No request was sent." This also protects an older host reached over a pairing, which would honor the flag and ignore the id.STRUCTURED_WORKER_HANDLE_PREFIXnow lives insrc/shared/structured-worker-handle.ts, so the CLI and main share one definition.session:<id>without loading the address codec.Why
Why bare
orcaworks with no new instructions for agents: agents keep the same commands and skill text as terminal agents; only the address differs. A chat's bareorcaresolves in one of three ways:ORCA_CLI_COMMANDlets an agent that follows the existing skill reach this app's CLI even when a login shell reordersPATH.Alternatives considered:
shell_environment_policy.set.PATH. Rejected. Codex only re-applies it when a command reuses its shell snapshot, and a login profile reordersPATHagain otherwise.Known limits, follow-ups:
shell_environment_policy.inherit = "core"or"none", Codex strips the id and the marker from commands. That is already true on main for the marker. Carrying the identity keys through Codex's per-threadshell_environment_policy.setas well as the process environment would survive that. Follow-up.--from/--terminalnaming another caller, including to drive a paired remote runtime as some other terminal. That is the point of the refusal. A chat acts only as itself.ORCA_CLI_COMMANDis…\resources\bin\orca.exe, which contains a space when the Windows username does. Agents in the live QA referenced the variable ("$ORCA_CLI_COMMAND") rather than pasting its value, and bareorcaalso resolves through thePATHprepend. Not yet verified live on Windows.Linked Issue
Supersedes #19648. Part of the structured-chat orchestration stack after #22555.
Visual Proof
Live on a dev build of this branch (macOS, M4 MacBook Air), real Claude Code and real Codex native chats.
Before (main): a native chat has no id, and orchestration refuses it as identity-less.
After: each chat's commands carry its own id, this app's CLI and the pinned instance (Claude, Codex).
After: a native Claude chat and a native Codex chat each coordinate a terminal worker to
worker_done.After: asked to check another terminal's inbox, the chat is refused before sending, and it reads the refusal correctly. That terminal's message is still there afterwards.
After: a plain terminal's environment is the same as on main (its handle, no session id, no
ORCA_CLI_COMMAND).Testing
Live QA (macOS dev build, real agents).
zsh -lctoo. A chat'schecknever consumes a sibling terminal's pending message.--terminal <other handle>is refused, and both agents recovered by dropping the flag.session:<id>, started a terminal worker and received itsworker_done.orcathat reached an older global CLI refused safely and did not touch the live app.Automated.
pnpm tcpasses. All changed test files and the CLI, PTY and main CLI suites pass (282 files).Not tested live: Windows, Linux (including AppImage) and packaged builds are covered by unit tests only.
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
orca-dev/orca-dev.cmd, macOSresources/bin/orca, Windowsorca.exe, Linux shim).agentSessionIdis an optional envelope field.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)