Skip to content

feat: extract local runtime provider - #453

Merged
delete-cloud merged 1 commit into
mainfrom
dogfood/local-runtime-provider
Jun 2, 2026
Merged

delete-cloud merged 1 commit into
mainfrom
dogfood/local-runtime-provider

Conversation

@delete-cloud

@delete-cloud delete-cloud commented Jun 2, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • add LocalDaemonSessionRuntimeProvider to own normal local daemon runtime preparation
  • delegate SessionManager._prepare_local_daemon_runtime() to the provider while preserving the public run path
  • cover cached runtime reuse and changed-workspace rebuild behavior in local daemon executor tests
  • refresh ADR-0058 runtime ownership status

Tests

  • uv run pytest tests/coding_agent/test_local_daemon_executor.py -v
  • uv run pytest tests/ui/test_session_manager_runtime.py -k "local_daemon_executor or coordinator_integration or default_run_target_workspace or rebuilds_live_runtime_when_default_run_target_changes" -v
  • uv run ruff check src/coding_agent/executors src/coding_agent/server/session_manager.py tests/ui/test_session_manager_runtime.py tests/coding_agent/test_local_daemon_executor.py
  • uv run ruff format --check src/coding_agent/executors src/coding_agent/server/session_manager.py tests/coding_agent/test_local_daemon_executor.py
  • git diff --check

Summary by CodeRabbit

  • Refactor

    • Refactored local daemon runtime preparation logic into a dedicated provider component for improved separation of concerns and maintainability.
  • Tests

    • Added comprehensive test coverage for runtime provider functionality, including cached runtime reuse and workspace change scenarios.
  • Documentation

    • Updated architecture decision records and added task specifications documenting the runtime preparation refactor.

@coderabbitai

coderabbitai Bot commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR refactors local daemon runtime preparation from inline SessionManager logic into a dedicated LocalDaemonSessionRuntimeProvider class, consolidating environment resolution, workspace caching, agent creation, tape restoration, and session state wiring into a reusable provider boundary while preserving existing run behavior.

Changes

Local Daemon Runtime Provider Extraction

Layer / File(s) Summary
Architecture and planning documentation
.opencode/prompts/tasks/local-daemon-pr30-local-runtime-provider.md, docs/adr/0058-local-daemon-control-plane-executor-architecture.md
Task specification and ADR document the refactor scope: extracting runtime preparation into LocalDaemonSessionRuntimeProvider, enumerating scope/out-of-scope boundaries, and recording completed/remaining work (runtime execution through RunCoordinator/LocalDaemonExecutor, preparation delegation, and remaining lifecycle bookkeeping in SessionManager).
LocalDaemonSessionRuntimeProvider implementation
src/coding_agent/executors/local_daemon.py
New runtime provider class with type aliases for environment/workspace resolution, runtime lifecycle hooks, and factories; async prepare_runtime method resolves targets, conditionally closes/invalidates cached state when workspace changes, otherwise creates agents with approval-policy mapping, restores tape, persists session state, wires message bus/config, updates LLM provider overrides, and returns a bound runtime adapter.
Module API exports
src/coding_agent/executors/__init__.py
Imports and exports LocalDaemonRuntimeSession and LocalDaemonSessionRuntimeProvider to extend the public API surface.
SessionManager integration
src/coding_agent/server/session_manager.py
Delegates _prepare_local_daemon_runtime to LocalDaemonSessionRuntimeProvider, passing closures for environment resolution, workspace computation, runtime close, agent creation, tape/session operations, and an adapter factory that binds the _WireConsumer.
Test coverage for provider behavior
tests/coding_agent/test_local_daemon_executor.py
New FakeRuntimeSession fixture and two async tests validate cached runtime reuse (when workspace unchanged) and session rebuild (on workspace change), with assertions around runtime closure, tape restoration, session persistence, and binding contents; minor formatting updates to existing test return-type annotations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • delete-cloud/Coding-Agent-Loop#439: Refactors local-daemon runtime preparation by routing through LocalDaemonExecutor.prepare_runtime(...) instead of the new LocalDaemonSessionRuntimeProvider boundary used here.
  • delete-cloud/Coding-Agent-Loop#427: Refactors SessionManager local-daemon handling by routing runtime execution through LocalDaemonExecutor.execute_runtime, while this PR moves preparation into LocalDaemonSessionRuntimeProvider.
  • delete-cloud/Coding-Agent-Loop#423: Refactors session_manager.py by extracting process-local runtime state into SessionRuntimeHandle via SessionRecord; both PRs modify session runtime-state machinery.

Poem

🐰 A rabbit hops through preparation's maze,

Runtime roots now bundled in a provider's blaze,

SessionManager's burden eased with care,

Cached and restored, the logic squared to square! ✨

🚥 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 'feat: extract local runtime provider' directly and clearly summarizes the main change: extracting a new LocalDaemonSessionRuntimeProvider class to encapsulate runtime preparation logic.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dogfood/local-runtime-provider

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 and usage tips.

@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

🤖 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 `@coding-agent/src/coding_agent/executors/local_daemon.py`:
- Around line 160-163: The adapter returned by adapter_factory is being cached
to session.runtime_adapter without being initialized; call
adapter.initialize(...) (or the adapter's appropriate init method) immediately
after creating adapter = self.adapter_factory(pipeline, ctx) and before
assigning session.runtime_adapter (and before setting
session.runtime_pipeline/session.runtime_ctx) so the cached PipelineAdapter is
fully initialized like the direct builders used in SessionManager.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bbe551a6-bf17-4501-b7cd-e6aa8df5119b

📥 Commits

Reviewing files that changed from the base of the PR and between 55defc1 and 05e8911.

📒 Files selected for processing (6)
  • coding-agent/.opencode/prompts/tasks/local-daemon-pr30-local-runtime-provider.md
  • coding-agent/docs/adr/0058-local-daemon-control-plane-executor-architecture.md
  • coding-agent/src/coding_agent/executors/__init__.py
  • coding-agent/src/coding_agent/executors/local_daemon.py
  • coding-agent/src/coding_agent/server/session_manager.py
  • coding-agent/tests/coding_agent/test_local_daemon_executor.py

@delete-cloud
delete-cloud merged commit dc91b04 into main Jun 2, 2026
1 check passed
@delete-cloud
delete-cloud deleted the dogfood/local-runtime-provider branch June 2, 2026 21:22
@delete-cloud

Copy link
Copy Markdown
Owner Author

Retroactive review evidence: CodeRabbit completed this PR review with one actionable comment. The comment was verified against pre-refactor behavior and answered as intentionally unchanged for this behavior-preserving slice. Local fallback reviewer Darwin also inspected the PR for P1/P2 correctness/scope issues. Result: no P1/P2 findings; no fixes were required.

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