Skip to content

feat(orchestration): report current coordinator in run-show - #49160

Open
TuanNancy wants to merge 1 commit into
stablyai:mainfrom
TuanNancy:feat/run-show-coordinator
Open

TuanNancy wants to merge 1 commit into
stablyai:mainfrom
TuanNancy:feat/run-show-coordinator

Conversation

@TuanNancy

Copy link
Copy Markdown
Contributor

ELI5

When one chat took over a run, another participant asking orca orchestration run-show saw coordinator_handle: null and could not tell who owned the run now. The response now names the current coordinator (a chat session address or a terminal handle), the run id, the generation and the runtime, so a second participant can check ownership before acting on a decision.

Files Added Deleted Net

What Changed

Before: exposeRun() deliberately removed the coordinator's Orca session id from every run receipt, and a chat-owned run has no terminal handle, so run-show returned coordinator_handle: null with no replacement. Runtime id was only available in the RPC envelope (_meta), not in the result.

After: orchestration.runShow adds a top-level coordinator object with four values: run_id, actor, consumer_generation and runtime_id.

  • actor is the run's current coordinator: orca_session_id:<id> for a chat, or the terminal handle. It uses the existing generation fence, so a session id left behind by an older handover is not reported as current; in that case actor is null (explicit unknown).
  • runtime_id comes from the runtime that answered.
  • The CLI prints the actor in both default JSON and --full views, and adds an actor line to --full text.
  • The internal session id remains hidden; only its established mailbox address is exposed.

Why

The host already has the authoritative binding in the run row. Deriving the actor there avoids a second RPC, a chat wake, or trusting a caller-supplied identity, and keeps the existing read-only access check (access.kind: 'reads', permission: 'workspace') untouched. Reporting the generation alongside the actor makes it unambiguous which handover the answer belongs to.

Linked Issue

Fixes #48312

Visual Proof

N/A: this changes a CLI/RPC response, not rendered UI. The output shape is covered by the receipt tests below.

Testing

  • pnpm test src/main/runtime/rpc/methods/orchestration/runs/run-coordinator-receipt.test.ts --maxWorkers=2: 3/3 pass.

    • A chat coordinator is reported as its orca_session_id: address with the run id, generation and runtime id.
    • A terminal coordinator is reported by handle.
    • A stale generation yields an explicit null actor and the new generation value.
  • pnpm check:changed --base=HEAD: 28/28 checks pass.

  • Tests use a real in-memory OrchestrationDb and the same row the RPC reads; the stale-generation case bumps the row directly, so it fails if the generation fence is removed.

  • Platform: macOS, unit level. No platform-specific code.

  • 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

Performance

None. The handler derives one address from fields already loaded with the run; no new query, message or wake. Runtime id was already available on the runtime object.

Risk

Level: Low

Worst case is a stale actor address for one generation after a handover: the generation fence and the existing handover bump keep that from happening, and null is returned when the host cannot tell. The change adds a field to a read response; older clients ignore unknown JSON fields. A plain revert removes the field and restores the previous output.

AI Disclosure

Implemented with the help of an AI coding agent (OpenCode, Hy4 flash model).

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

No SSH/remote, mobile, cross-platform or permission changes; the RPC stays read-only and uses the same workspace permission as before.

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
  • 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)

Reported by @taka0024brainbit

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

orchestration.runShow now returns a coordinator receipt with the run ID, actor, consumer generation, and runtime ID. The actor is derived from the coordinator key and is null when the chat session belongs to an older consumer generation. The CLI displays coordinator metadata in compact and full output.

Severity of issue fixed: Low

Merge Risk: Low · up to 7dea2

The run-show --full text view can crash when the CLI talks to an older Orca host that does not return coordinator details. Other output modes keep working. A small guard in the formatter fixes it, and the rest of the change looks safe.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat(orchestration): report current coordinator in run-show" matches the main change. The PR adds a top-level coordinator object to the orchestration run-show response, with the current act…
Description check Passed The description follows the repository template. It has ELI5, What Changed (before and after, plus mechanism), Why, a linked issue (Fixes #48312), Visual Proof marked N/A with a reason, Testing with t…
Linked Issues check Passed Issue #48312 asks that callers allowed to inspect a run receive run ID, current coordinator actor (including chat coordinators), consumer generation, and runtime ID in the normal run-show response, wi…
Out of Scope Changes check Passed All changes support the coordinator-reporting objective of #48312. The changes are: a new RunCoordinatorReceipt type and exposeRunCoordinator function; a coordinator field added to the runShow respons…
Full details: Title check

Explanation

The title "feat(orchestration): report current coordinator in run-show" matches the main change. The PR adds a top-level coordinator object to the orchestration run-show response, with the current actor, generation, and runtime ID. The title is short, specific, and follows a conventional-commit style.

Full details: Description check

Explanation

The description follows the repository template. It has ELI5, What Changed (before and after, plus mechanism), Why, a linked issue (Fixes #48312), Visual Proof marked N/A with a reason, Testing with the commands run, a Performance statement, a Risk section with level and revert plan, AI Disclosure, the upstream boundary checkbox, Notes, and a checklist. Minor gaps: the Risk level is set, but the Review section is empty and the lint/typecheck/test/build checklist item is unchecked, which the template allows when CI covers it. The Testing section also leaves the manual-test box unchecked without explanation.

Full details: Linked Issues check

Explanation

Issue #48312 asks that callers allowed to inspect a run receive run ID, current coordinator actor (including chat coordinators), consumer generation, and runtime ID in the normal run-show response, with an explicit unknown when the host cannot establish the actor. At head, orchestration.runShow in src/main/runtime/rpc/methods/orchestration/runs/runs.ts always returns a coordinator field built by exposeRunCoordinator(run, runtime.getRuntimeId()). run-coordinator-receipt.ts returns run_id, actor, consumer_generation, and runtime_id. The actor comes from mailboxAddressOf(runCoordinatorKey(run)). runCoordinatorKey (src/main/runtime/orchestration/addressing/orchestration-caller-identity.ts) takes the Orca session id from currentRunCoordinatorOrcaSessionId(run), which the code comments describe as excluding session ids left by older bindings. A chat coordinator therefore yields orca_session_id:<id>, a terminal coordinator yields its handle, and a stale binding yields null. The handler adds no query, message, or wake, and the diff leaves the existing access check untouched. Limitation: I did not open currentRunCoordinatorOrcaSessionId in src/main/runtime/orchestration/db/runs/run-coordinator-orca-session.ts, so the generation-fence behavior rests on its name and the documented comment. The reported tests for the stale-generation case were not re-run.

Full details: Out of Scope Changes check

Explanation

All changes support the coordinator-reporting objective of #48312. The changes are: a new RunCoordinatorReceipt type and exposeRunCoordinator function; a coordinator field added to the runShow response in runs.ts, with removedWork still conditional; CLI output of the actor in run-show views (run-handlers.ts); and unit tests for chat, terminal, and stale-generation actors (run-coordinator-receipt.test.ts). The runs.ts diff contains no unrelated edits. The PR description reports no changes to permissions, remote behavior, or UI. The CLI hunks were taken from the summary and were not diffed directly.

  • 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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

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: a05ef1af-1dfb-4762-8cde-0bc02b8cf79a
Commits

Reviewing files that changed from the base of the PR and between 44b21e0 and 7dea2fb.

Files selected for processing: 4

  • src/cli/orchestration/runs/run-handlers.ts
  • src/main/runtime/rpc/methods/orchestration/runs/run-coordinator-receipt.test.ts
  • src/main/runtime/rpc/methods/orchestration/runs/run-coordinator-receipt.ts
  • src/main/runtime/rpc/methods/orchestration/runs/runs.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.

? formatRemovedWorkListing(r.run.id, r.removedWork, cursor)
: `${r.run.id}${r.run.legacy ? ' [legacy, inspect only]' : ''} ${r.run.objective}\n` +
`consumer generation ${r.run.consumer_generation}; created ${r.run.created_at}` +
`consumer generation ${r.run.consumer_generation}; runtime ${r.coordinator.runtime_id}; created ${r.run.created_at}` +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Guard coordinator in run-show --full for runtimes that omit it.

The --full text formatter reads r.coordinator.runtime_id, r.coordinator.actor, r.coordinator.run_id, and r.coordinator.consumer_generation with no check. A runtime that predates this change returns no coordinator. The CLI can still reach such a runtime, because the compatibility gate accepts protocol version 2 or later. The formatter then throws a TypeError before it prints the run. Default text output and --json output do not read these fields.

Declare coordinator as optional, and print unknown when it is absent:

Suggested fix

     run: {
       id: string
       objective: string
       consumer_generation: number
       legacy: number
       created_at: string
     }
-    coordinator: {
+    coordinator?: {
       run_id: string
       actor: string | null
       consumer_generation: number
       runtime_id: string
     }
-          `consumer generation ${r.run.consumer_generation}; runtime ${r.coordinator.runtime_id}; created ${r.run.created_at}` +
-          `\ncoordinator ${r.coordinator.actor ?? 'unknown'} (run ${r.coordinator.run_id}, generation ${r.coordinator.consumer_generation})` +
+          `consumer generation ${r.run.consumer_generation}; runtime ${r.coordinator?.runtime_id ?? 'unknown'}; created ${r.run.created_at}` +
+          (r.coordinator
+            ? `\ncoordinator ${r.coordinator.actor ?? 'unknown'} (run ${r.coordinator.run_id}, generation ${r.coordinator.consumer_generation})`
+            : '\ncoordinator unknown') +

This branch has not been deployed

No deployments
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.

[Feature]: Show the current coordinator actor for chat-owned runs in run-show

1 participant