Skip to content

feat(orchestration): start a worker in one step; worker-start creates the coordinator's Run - #34900

Closed
Jinwoo-H wants to merge 3 commits into
mainfrom
orch-one-step-dispatch
Closed

Jinwoo-H wants to merge 3 commits into
mainfrom
orch-one-step-dispatch

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​35 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​35
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​135 $\color{#cf222e}{\Huge{\mathbf{−}}}$​65 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​70

Summary

A coordinator can start a worker with one command. When worker-start --spec finds no Run bound to its caller, it creates one and binds it to that caller, so the coordinator's terminal or chat is still the one woken by worker_done. run-create stays for Task graphs and for starting a new goal.

  • Shared path: the Run is created by createBoundRun, which run-create now uses too. It makes the same binding and cancels the same waiters.
  • Coordinators only: the Run is created only for a caller at root depth (resolveCreatorDepth === ROOT_DISPATCH_DEPTH) that passed --spec without --run. A worker on an active Dispatch still starts helpers in its own Run. Nesting and depth rules are unchanged.
  • Receipt: every receipt now carries run: { id, objective, created }, and the CLI prints Created and bound Run … or In Run …. A reused Run left over from an earlier goal is therefore visible. Nothing guesses whether a Run is stale.
  • Objective: the new Run's objective is the title the first Task gets, from --task-title or the spec's first line, built by the existing buildOrchestrationTaskDisplayMetadata.
  • Checks first: the spec budget check runs before a Run can be created.
  • Docs: the skill guide and CLI help now lead with the one-step form, and the bundled guides were regenerated.

Mixed versions

  • Old CLI → new server: works. The receipt only gains an optional field.

  • New CLI → older server: keeps today's refusal; the guide says to run-create first there. An earlier commit on this branch tried a CLI-side catch-and-retry fallback. Review found it could not work safely:

    • the client decorates the refusal text it matched on;
    • an older server's refusal cannot prove the caller is a root coordinator (remote and legacy workers get the same text);
    • recovery of its inner run-create would have been reported under the worker-start command.

    So it was removed.

Known trade-off

If a deeper launch check fails (agent preflight, placement, remote capability) after a Run was created, that Run stays bound. That is the same state as running run-create and then a failed worker-start today, and the next receipt names it.

Testing

  • pnpm check:changed --maxWorkers=2: 21 checks passed.
  • New RPC tests:
    • an unbound coordinator gets a created and bound Run, then reuses it with created: false;
    • --task with no bound Run still refuses and creates no Run.
  • Real dev app (background launch), with a Claude coordinator in a folder workspace:
    • Before (main): worker-start --spec … --agent claude → consumer_fenced, no worker.
    • After: the same single command → receipt run.created: true; the worker sent worker_done and Orca woke the coordinator with it.

… the coordinator's Run when none is bound

worker-start --spec now creates and binds a Run for a root coordinator with
no bound Run, through the same path run-create uses, and names the Run it
created or joined in every receipt. Workers on a Dispatch keep starting
helpers in their own Run and never get a new one. A new CLI against an older
runtime runs run-create and retries; old CLIs need no change.
…efore a Run is created

The CLI fallback matched a refusal text the client decorates, could not
prove the caller was a root coordinator on an older runtime, and recovered
an inner run-create under the worker-start command. Older runtimes keep
their refusal and the guide says to run-create first there. The prompt
budget check now runs before worker-start can create a Run.
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

Worker start can now create and bind a Run for an eligible unbound coordinator. Receipts include the Run ID, objective, and creation status. The changes also update Run creation helper logic, worker-start validation, tests, and CLI guidance for independent waves and planned Task graphs.

Priority: Normal

Merge Risk: Moderate · up to 926ba

Workers can join an earlier goal, and the retry instructions can create the wrong Task or fail. Correct the guidance before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title names the feature (one-step worker start, with worker-start creating the coordinator's Run), which matches the main change in the changeset: worker-start --spec creates and binds a Run for r…
Description check Passed The description covers the required sections: an ELI5-style Summary, what changed (shared createBoundRun path, coordinator-only creation, receipt fields, objective source, check ordering, docs), the r…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the feature (one-step worker start, with worker-start creating the coordinator's Run), which matches the main change in the changeset: worker-start --spec creates and binds a Run for root coordinators, plus the shared createBoundRun helper, receipt changes, and docs. The title is specific and concise, so it passes.

Full details: Description check

Explanation

The description covers the required sections: an ELI5-style Summary, what changed (shared createBoundRun path, coordinator-only creation, receipt fields, objective source, check ordering, docs), the rationale and trade-offs, mixed-version compatibility, and testing with commands and a before/after real-app report. Several template sections are missing or unfilled: the ELI5 heading and 'Why' section are not labeled as in the template, the Linked Issue section has no 'Fixes #' issue reference, the Visual Proof section is absent or lacks a before/after attachment for a behavior change, the AI Disclosure section is blank, the Agent skill upstream boundary checkbox is not ticked, and the testing checklist items are not checked. Because the description is mostly complete, the check passes, but the author should add the linked issue, a visual before/after or the N/A reason, the AI disclosure, and the checklist state.

Full details: Docstring Coverage

Explanation

Docstring coverage is 66.67% which is insufficient. 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 3 functions across 8 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

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.

@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: 3


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: e0b68538-b93d-4161-87a1-34f0045983f2
Commits

Reviewing files that changed from the base of the PR and between bd4702f and bc3ad67.

Files selected for processing: 9
  • skill-guides/orchestration.md
  • src/cli/bundled-skill-guides.ts
  • src/cli/handlers/orchestration/worker-output.ts
  • src/cli/specs/orchestration-worker-specs.ts
  • src/cli/specs/orchestration.ts
  • src/main/runtime/rpc/methods/orchestration/runs/runs.ts
  • src/main/runtime/rpc/methods/orchestration/worker/composed-workers.test.ts
  • src/main/runtime/rpc/methods/orchestration/worker/worker-start-authority.ts
  • src/main/runtime/rpc/methods/orchestration/worker/workers.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.

Comment on lines +105 to +109
Confirm the runtime and start the full independent wave before waiting.
`worker-start --spec` creates the Task and its attempt in one call; with no Run
bound, it also creates one bound to you (an older Orca refuses instead; then
`run-create` first). Its receipt's `run` names the Run it created or joined; if
that is an earlier goal's Run, `run-create` first:

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.

Major · Data Integrity & Integration · Quick win

Check the bound Run before starting the wave.

If the coordinator is bound to an earlier Run, the first worker-start --spec creates the Task and Dispatch in that Run. The receipt arrives after this mutation. Running run-create afterward does not move the first Dispatch, so the later bound check --wait can miss its worker_done. Run run-current --json first and create the intended Run before the first worker start. (raw.githubusercontent.com)

Comment on lines +128 to +130
Use `run-create --objective "<objective>"`, then `task-create` plus
`worker-start --task <task_id>`, for planned fan-out with dependencies or a
retry of a known Task. Use dependencies only for real ordering

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.

Major · Functional Correctness · Quick win

Do not create a new Run when retrying an existing Task.

worker-start --task <task_id> requires the resolved Run to match the Task's Run. After run-create, the new binding differs, so the retry fails with task_not_found. Use run-create only for new planned fan-out. For a known Task, use its owning Run and pass --retry-of <dispatch_id>. (raw.githubusercontent.com)

],
identityFlagRoles: { from: 'caller', terminal: 'target' },
notes: [
'With --spec and no bound Run, a coordinator gets a new Run bound to it, named after the Task title; the receipt names the Run it created or joined.',

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

Document the older-runtime refusal.

worker-start --spec does not always create a Run. This revision calls orchestration.workerStart directly, so an older runtime can return its refusal and require run-create first. Add this caveat here and in the matching note at src/cli/specs/orchestration.ts:13. (raw.githubusercontent.com)

@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: 3


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: 0e063cb9-4f4c-423d-a136-9090ce7a1d4a
Commits

Reviewing files that changed from the base of the PR and between bc3ad67 and 926ba06.

Files selected for processing: 1
  • src/cli/bundled-skill-guides.ts

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

Comment on lines +2441 to +2443
"`worker-start --spec` creates the Task and its attempt in one call; with no Run",
"bound, it also creates one bound to you (an older Orca refuses instead; then",
"`run-create` first). Its receipt's `run` names the Run it created or joined; if",

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

Supported by static analysis

Script executed:

sed -n '1,130p' src/main/runtime/rpc/methods/orchestration/worker/worker-start-authority.ts
sed -n '1,120p' config/scripts/generate-bundled-skill-guides.mjs

Repository: stablyai/orca

Length of output: 7688


Limit the Run-creation rule to a root coordinator in the canonical guide.

worker-start --spec creates a Run only for a coordinator at root dispatch depth, with --spec and without --run. A worker on an active Dispatch starts helpers in that Dispatch's Run and cannot create one. Other unbound callers are fenced with consumer_fenced.

Change skill-guides/orchestration.md, then regenerate the bundle. Do not edit only src/cli/bundled-skill-guides.ts, because regeneration overwrites direct edits.

Canonical guide wording
-`worker-start --spec` creates the Task and its attempt in one call; with no Run
-bound, it also creates one bound to you (an older Orca refuses instead; then
+`worker-start --spec` creates the Task and its attempt in one call; for a root
+coordinator with no bound Run and no `--run`, it also creates one (an older Orca
+refuses instead; then
 `run-create` first). Its receipt's `run` names the Run it created or joined; if

Then run pnpm generate:bundled-skill-guides to update the generated bundle.

"`worker-start --spec` creates the Task and its attempt in one call; with no Run",
"bound, it also creates one bound to you (an older Orca refuses instead; then",
"`run-create` first). Its receipt's `run` names the Run it created or joined; if",
"that is an earlier goal's Run, `run-create` first:",

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.

Major · Data Integrity & Integration · Quick win

Supported by static analysis

Script executed:

sed -n '95,120p' skill-guides/orchestration.md
sed -n '2435,2452p' src/cli/bundled-skill-guides.ts
git diff 49695f37b18760dc42898e681cc49c4b733019e4 926ba06eb80be2e632f644fb69fa2b4e27c8f7f1 -- skill-guides/orchestration.md src/cli/bundled-skill-guides.ts

Repository: stablyai/orca

Length of output: 6595


Script executed:

set -o pipefail
printf '%s\n' '--- worker-start definitions and references ---'
rg -n -F --glob '!node_modules' --glob '!dist' --glob '!build' \
  -e 'worker-start' -e 'createBoundRun' -e 'run-create' \
  src skill-guides test tests 2>/dev/null | head -n 240 || true
printf '%s\n' '--- changed guide context ---'
nl -ba skill-guides/orchestration.md | sed -n '96,142p'
printf '%s\n' '--- candidate orchestration RPC/CLI files ---'
rg --files src | rg 'orchestration|worker|run' | head -n 160

Repository: stablyai/orca

Length of output: 44704


Script executed:

set -o pipefail
printf '%s\n' '--- worker-start handler and RPC bindings ---'
rg -n -F --glob '*.ts' \
  -e "'orchestration worker-start'" \
  -e 'workerStart' \
  -e 'worker_start' \
  -e 'createStartingWorkerDispatch' \
  -e 'createBoundRun' \
  src/cli/handlers src/main/runtime/rpc src/main/runtime/orchestration/db | head -n 320 || true
printf '%s\n' '--- implicit coordinator test ---'
nl -ba src/cli/handlers/orchestration/worker-start-implicit-coordinator.test.ts
printf '%s\n' '--- worker-start-related changed files ---'
git diff --name-only 49695f37b18760dc42898e681cc49c4b733019e4 926ba06eb80be2e632f644fb69fa2b4e27c8f7f1 -- \
  'src/**' 'skill-guides/**' | rg -i 'orchestration|worker|run|bundled' | head -n 240

Repository: stablyai/orca

Length of output: 24514


Script executed:

set -o pipefail
printf '%s\n' '--- worker-start authority ---'
nl -ba src/main/runtime/rpc/methods/orchestration/worker/worker-start-authority.ts
printf '%s\n' '--- worker-start registration ---'
nl -ba src/main/runtime/rpc/methods/orchestration/worker/workers.ts
printf '%s\n' '--- local worker start ---'
nl -ba src/main/runtime/rpc/methods/orchestration/worker/local-worker-start.ts | sed -n '1,230p'
printf '%s\n' '--- run creation ---'
nl -ba src/main/runtime/rpc/methods/orchestration/runs/runs.ts
printf '%s\n' '--- changed composed-worker tests ---'
git diff 49695f37b18760dc42898e681cc49c4b733019e4 926ba06eb80be2e632f644fb69fa2b4e27c8f7f1 -- src/main/runtime/rpc/methods/orchestration/worker/composed-workers.test.ts src/main/runtime/rpc/methods/orchestration/worker/worker-start-authority.ts src/main/runtime/rpc/methods/orchestration/worker/workers.ts src/main/runtime/rpc/methods/orchestration/runs/runs.ts

Repository: stablyai/orca

Length of output: 44019


Script executed:

set -o pipefail
printf '%s\n' '--- orchestration CLI specs ---'
nl -ba src/cli/specs/orchestration.ts | sed -n '1,75p'
printf '%s\n' '--- existing run-current documentation ---'
rg -n -F --glob '*.md' --glob '*.ts' \
  -e 'run-current' -e 'runCurrent' -e 'run-use --id' \
  skill-guides src/cli src/main/runtime/rpc/methods/orchestration | head -n 160 || true

Repository: stablyai/orca

Length of output: 8208


Check the bound Run before launching a worker.

worker-start resolves an existing coordinator Run before it creates the Task and Dispatch. The current guide checks the receipt only after the launch commands. If that Run belongs to an earlier goal, the first worker is created in the stale Run, and run-create only affects later workers. Add a run-current check before the first launch in both guide copies.

Suggested fix
-Confirm the runtime and start the full independent wave before waiting.
-`worker-start --spec` creates the Task and its attempt in one call; with no Run
-bound, it also creates one bound to you (an older Orca refuses instead; then
-`run-create` first). Its receipt's `run` names the Run it created or joined; if
-that is an earlier goal's Run, `run-create` first:
+Confirm the runtime and inspect the bound Run before starting any worker.
+Run `run-current --json`. If it names an earlier goal's Run, run
+`run-create --objective "<objective>" --json` before any `worker-start`.
+If no Run is bound, `worker-start --spec` creates one bound to you (an older
+Orca refuses instead; then `run-create` first). Its receipt's `run` identifies
+the Run it created or joined:
 
 ```text
 ORCA status --json
+ORCA orchestration run-current --json
 ORCA orchestration worker-start --spec "<worker A task>" --worktree current --agent codex --json

Comment on lines +2463 to +2465
"Use `run-create --objective \"<objective>\"`, then `task-create` plus",
"`worker-start --task <task_id>`, for planned fan-out with dependencies or a",
"retry of a known Task. Use dependencies only for real ordering",

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.

Major · Data Integrity & Integration · Quick win

Separate planned fan-out from Task retry instructions.

A retry must use the Run that owns the existing Task. Creating a new Run makes worker-start --task reject the Task because its run_id differs from the selected Run. A retry also requires --retry-of <dispatch_id>. (raw.githubusercontent.com)

Do not run task-create for a known Task. Instruct users to resume or bind the existing Run, then run worker-start --task <task_id> --retry-of <dispatch_id>.

Proposed wording
-  "Use `run-create --objective \"<objective>\"`, then `task-create` plus",
-  "`worker-start --task <task_id>`, for planned fan-out with dependencies or a",
-  "retry of a known Task. Use dependencies only for real ordering",
+  "For planned fan-out with dependencies, use `run-create --objective \"<objective>\"`,",
+  "then `task-create` and `worker-start --task <task_id>`. To retry a known Task,",
+  "bind its existing Run with `run-use --id <run_id>`, then use",
+  "`worker-start --task <task_id> --retry-of <dispatch_id>`. Use dependencies only",
+  "for real ordering",
Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"Use `run-create --objective \"<objective>\"`, then `task-create` plus",
"`worker-start --task <task_id>`, for planned fan-out with dependencies or a",
"retry of a known Task. Use dependencies only for real ordering",
"For planned fan-out with dependencies, use `run-create --objective \"<objective>\"`,",
"then `task-create` and `worker-start --task <task_id>`. To retry a known Task,",
"bind its existing Run with `run-use --id <run_id>`, then use",
"`worker-start --task <task_id> --retry-of <dispatch_id>`. Use dependencies only",
"for real ordering",

@Jinwoo-H

Copy link
Copy Markdown
Contributor Author

Superseded by #36137, which combines the orchestration v3 changes into one PR.

@Jinwoo-H Jinwoo-H closed this Oct 29, 2026
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.

1 participant