Skip to content

feat(orchestration): manage detached task runtimes#75

Merged
senamakel merged 5 commits into
tinyhumansai:mainfrom
senamakel:feat/detached-task-lifecycle
Jul 23, 2026
Merged

feat(orchestration): manage detached task runtimes#75
senamakel merged 5 commits into
tinyhumansai:mainfrom
senamakel:feat/detached-task-lifecycle

Conversation

@senamakel

@senamakel senamakel commented Jul 23, 2026

Copy link
Copy Markdown
Member

Summary

  • add a generic DetachedTaskRegistry<Metadata, Status> beside the durable orchestration TaskStore
  • centralize owner-checked wait/timeout, cooperative-cancel-before-abort, shared steering lookup, and soft-cap terminal cleanup
  • document the process-local runtime boundary and add focused async lifecycle coverage

The registry intentionally does not duplicate durable state. Applications continue to transition the matching TaskStore record and reconcile store records with no live runtime after restart.

Validation

  • cargo fmt --check
  • cargo test graph::orchestration::test::detached_registry (4 passed)
  • cargo clippy --all-targets --all-features -- -D warnings

Summary by CodeRabbit

  • New Features

    • Added runtime management for detached tasks, including status tracking, waiting, steering, cancellation, and ownership checks.
    • Added task snapshots and clear outcomes for completed or timed-out waits.
    • Added automatic cleanup of completed tasks with bounded runtime storage.
  • Documentation

    • Documented detached task runtime management, cancellation behavior, ownership safeguards, and restart reconciliation.
    • Updated the SDK gaps documentation to reflect the available detached task controls.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 37 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 94f74c85-2ead-4a87-82f1-7fca4de274b1

📥 Commits

Reviewing files that changed from the base of the PR and between 1e6a639 and 7a35454.

📒 Files selected for processing (5)
  • src/graph/mod.rs
  • src/graph/orchestration/runtime.rs
  • src/graph/orchestration/test.rs
  • src/graph/orchestration/types.rs
  • src/lib.rs
📝 Walkthrough

Walkthrough

Adds DetachedTaskRegistry, public runtime state types, ownership-aware waiting and steering, cooperative cancellation, terminal cleanup, shared steering integration, tests, and documentation.

Changes

Detached task runtime

Layer / File(s) Summary
Runtime contracts and registration
src/graph/orchestration/types.rs, src/graph/orchestration/mod.rs, src/graph/orchestration/runtime.rs
Defines public snapshots, wait outcomes, cancellation results, and registry errors; exposes the registry with registration, snapshots, and steering APIs.
Waiting, cancellation, and cleanup
src/graph/orchestration/runtime.rs
Implements terminal waits, timeout retention, cooperative cancellation followed by abort, bulk cancellation, terminal sweeping, and steering deregistration.
Behavior validation and documentation
src/graph/orchestration/test.rs, docs/modules/graph/subagents-recursion.md, docs/sdk-gaps.md
Tests ownership, waits, timeouts, cancellation, steering, and soft-cap cleanup; documents registry responsibilities and lifecycle behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant DetachedTaskRegistry
  participant DetachedTaskExecutor
  participant SteeringRegistry
  Caller->>DetachedTaskRegistry: register detached task
  DetachedTaskRegistry->>DetachedTaskExecutor: retain runtime handles
  Caller->>DetachedTaskRegistry: wait or request steering
  DetachedTaskRegistry->>SteeringRegistry: resolve or deregister steering
  DetachedTaskExecutor-->>DetachedTaskRegistry: publish status
  Caller->>DetachedTaskRegistry: cancel task
  DetachedTaskRegistry->>DetachedTaskExecutor: cancel token then abort
  DetachedTaskRegistry-->>Caller: return status or cancellation metadata
Loading

Poem

A rabbit hops through runtime’s door,
Registers tasks and tracks some more.
Waits may pause, or time may flee,
Soft caps sweep terminals free.
“Cancel, then abort!” I cheer—
Clean task trails for every ear.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding orchestration support for managing detached task runtimes.
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.

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1e6a63952b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/graph/orchestration/mod.rs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/graph/orchestration/runtime.rs`:
- Around line 170-182: Propagate a distinct lock-poisoned error consistently
across DetachedTaskRegistry instead of mapping it to Unknown or silently
returning empty/zero results. Reuse the existing self.lock() helper from
register() in wait(), ensure_live_owned, ensure_live, take_and_cancel, len,
snapshots, sweep_terminal, and cancel_where, preserving each method’s normal
behavior when the mutex is healthy.
- Around line 162-211: Update the `wait` method’s `Ok(Err(error))` branch to
remove the task entry via `self.remove(task_id)` before returning
`StatusChannelClosed`. Preserve the existing error propagation and
terminal/timeout behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9b63bcd7-59af-46d5-9a6a-7f3885326ebe

📥 Commits

Reviewing files that changed from the base of the PR and between 2583fcc and 1e6a639.

📒 Files selected for processing (6)
  • docs/modules/graph/subagents-recursion.md
  • docs/sdk-gaps.md
  • src/graph/orchestration/mod.rs
  • src/graph/orchestration/runtime.rs
  • src/graph/orchestration/test.rs
  • src/graph/orchestration/types.rs

Comment thread src/graph/orchestration/runtime.rs
Comment thread src/graph/orchestration/runtime.rs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f0915e678a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/lib.rs Outdated
@senamakel
senamakel merged commit d548657 into tinyhumansai:main Jul 23, 2026
2 checks passed
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