Skip to content

fix(orchestration): link worker-created sub-Runs - #16784

Closed
brennanb2025 wants to merge 5 commits into
mainfrom
brennanb2025/sta-5378-orchestration-subrun-link-r1
Closed

brennanb2025 wants to merge 5 commits into
mainfrom
brennanb2025/sta-5378-orchestration-subrun-link-r1

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​283 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​283
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​129 $\color{#cf222e}{\Huge{\mathbf{−}}}$​9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​120

Summary

  • record the active worker Dispatch that created a sub-Run
  • expose parent provenance through existing run-list/run-show shapes
  • migrate existing databases with fail-closed lifecycle validation

ELI5

When one agent starts a second group of agents to help with its assignment, Orca used to save that new group without recording which assignment created it. Orca now keeps that link, so the extra work can be traced back to the worker job that started it instead of looking unrelated.

Before / After

  • Before: A worker-created Run appeared in orca orchestration run-list --json and run-show --json without a link to the Dispatch that created it. A supervising coordinator saw a flat list and had to guess from names and timestamps or inspect the worker terminal to find the nested review loop.
  • After: The JSON record carries the active local or remote parent Dispatch ID, so orchestration tooling can associate the Run with the correct worker job. Child messages still stay in the child Run inbox; this PR does not add an in-app hierarchy or change the default non-JSON CLI display.

When you would hit this

Only during nested orchestration: a dispatched worker calls orca orchestration run-create so it can coordinate its own reviewers or other agents. It is most noticeable in multi-round review loops, where the top-level coordinator otherwise sees heartbeats while the nested Runs look unrelated.

Visual evidence

Not applicable. No renderer or visible UI code changed; the observable surface is the --json output of orca orchestration run-list and run-show.

Reliability contract

  • Invariant: active worker-created Runs retain an observable origin Dispatch without changing lifecycle authority.
  • Oracle: focused RPC tests assert local worker links, ordinary roots remain unlinked, and completed origin Dispatches are rejected; schema migration tests pass.
  • Provider coverage: local and federated attachment identity paths covered in code; SSH/WSL/mobile unaffected (no execution or transport changes).
  • Performance: one bounded indexed local lookup, with remote fallback only when attested pane/process identity is present; no polling or subprocesses added.

Closes STA-5378

@coderabbitai

coderabbitai Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

Next included review available in 21 minutes.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8848ef41-32c9-467c-8e06-6906f46511df

📥 Commits

Reviewing files that changed from the base of the PR and between 94e7586 and 1a00cef.

📒 Files selected for processing (10)
  • src/main/runtime/orchestration/db/contract-constants.ts
  • src/main/runtime/orchestration/db/dispatch-context/dispatch-lookup.ts
  • src/main/runtime/orchestration/db/runs/run-create.ts
  • src/main/runtime/orchestration/db/schema/create-core-tables-sql.ts
  • src/main/runtime/orchestration/db/schema/migrate-v13-v30.ts
  • src/main/runtime/orchestration/nested-worker-depth-migration.test.ts
  • src/main/runtime/orchestration/orchestration-schema-version-skew.ts
  • src/main/runtime/orchestration/types.ts
  • src/main/runtime/rpc/methods/orchestration-runs.test.ts
  • src/main/runtime/rpc/methods/orchestration-runs.ts
📝 Walkthrough

Walkthrough

The schema version increases to 31, and runs.parent_dispatch_id is added to the table definition, migration checks, schema skew checks, and RunRow. Dispatch lookup now resolves an unambiguous active local or remote parent using pane key and process incarnation. orchestration.runCreate passes the structured dispatch attestation to createRun. Run creation revalidates local and remote dispatches inside the write transaction before storing the dispatch ID or null. Tests cover local and remote links, stale and revoked origins, completed dispatches, ambiguity, and migration behavior.

Merge Risk: 🟡 Moderate · up to 5acbe

The PR adds worker-to-Run provenance, but the modified test file currently does not parse because of duplicate declarations and closing expressions. The issue should be fixed before merge so the relevant validation can run.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 10 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the main change: linking worker-created sub-Runs to their originating Dispatch.
Description check ✅ Passed The description explains the change, motivation, behavior before and after, issue reference, visual impact, reliability contract, and scope. It does not include the template's explicit Testing, AI Dis…
Full details: Description check

Explanation

The description explains the change, motivation, behavior before and after, issue reference, visual impact, reliability contract, and scope. It does not include the template's explicit Testing, AI Disclosure, Review, Agent skill upstream boundary, Notes, or Checklist sections, but the provided content is sufficiently complete and relevant.

✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

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: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bf96f2ff-b32b-4e2e-9429-b267d167e97e

📥 Commits

Reviewing files that changed from the base of the PR and between 026389a and e17dbe2.

📒 Files selected for processing (9)
  • src/main/runtime/orchestration/db/contract-constants.ts
  • src/main/runtime/orchestration/db/dispatch-context/dispatch-lookup.ts
  • src/main/runtime/orchestration/db/runs/run-create.ts
  • src/main/runtime/orchestration/db/schema/create-core-tables-sql.ts
  • src/main/runtime/orchestration/db/schema/migrate-v13-v30.ts
  • src/main/runtime/orchestration/orchestration-schema-version-skew.ts
  • src/main/runtime/orchestration/types.ts
  • src/main/runtime/rpc/methods/orchestration-runs.test.ts
  • src/main/runtime/rpc/methods/orchestration-runs.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.

@brennanb2025

brennanb2025 commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Review verification (exact head a32bb03): The sole remaining unresolved, non-outdated thread alleged repeated closing casts and duplicate result fields, but each cited site contains exactly one cast and one field; the focused test parses and passes 25/25. Replied with source/test evidence and resolved the thread: #16784 (comment). A baseline review plus an independent same-model three-pass adversarial review found no in-scope issues; performance, schema migration/skew, additive RPC compatibility, SSH/federated lifecycle, mobile backcompat, Windows/Linux, and security were checked. Local gates: orchestration+RPC 2,192 passed / 5 skipped, migration 6/6, pnpm tc:node, pnpm tc, direct oxlint, and oxfmt all pass. Final CI is settled at 47 success, 1 skipped, 0 failing/pending; merge state is CLEAN. Merge verdict: ready to merge.

@brennanb2025

brennanb2025 commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor Author

QA evidence (exact head a32bb03): This change is persistence/RPC-only with no renderable Electron or mobile flow, so Electron/mobile manual UI QA is N/A. Manual source and contract validation covered local and federated parent resolution, stale process identity, local/federated ambiguity, completed/revoked origins, transactional revalidation, v31 migration/skew repair, and additive nullable RPC output; focused tests pass 25/25 and migration tests pass 6/6. The broader orchestration+RPC suite passes 2,192 tests with 5 skipped, and final CI is settled at 47 success, 1 intentional e2e skip, 0 failing/pending. Residual gap: federated/SSH disconnect behavior is covered in-memory rather than by a live network test.

@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

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: dc8f6d9f-9659-4633-8158-3045e788fc3d

📥 Commits

Reviewing files that changed from the base of the PR and between e17dbe2 and 5acbe82.

📒 Files selected for processing (6)
  • src/main/runtime/orchestration/db/dispatch-context/dispatch-lookup.ts
  • src/main/runtime/orchestration/db/runs/run-create.ts
  • src/main/runtime/orchestration/nested-worker-depth-migration.test.ts
  • src/main/runtime/orchestration/types.ts
  • src/main/runtime/rpc/methods/orchestration-runs.test.ts
  • src/main/runtime/rpc/methods/orchestration-runs.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Closing: #29205 has workers start helpers on the Run they already work for, so separate sub-Runs needing a parent link no longer come up.

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