Skip to content

refactor(scheduled_action): split agent executor into automations crate#4167

Open
ehayes2000 wants to merge 1 commit into
mainfrom
eric.hayes/split-automations-crate
Open

refactor(scheduled_action): split agent executor into automations crate#4167
ehayes2000 wants to merge 1 commit into
mainfrom
eric.hayes/split-automations-crate

Conversation

@ehayes2000

Copy link
Copy Markdown
Contributor

No description provided.

@ehayes2000 ehayes2000 requested a review from a team as a code owner June 17, 2026 19:58
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a10299fc-32eb-4b24-8ee2-c7cdac511087

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

A new automations Rust crate is extracted from scheduled_action to host the service binary and agent-execution logic. A new ActionRunner trait is added to scheduled_action/src/domain/ports.rs, and InProcessExecutor is refactored to be generic over this trait, removing its direct dependency on PgPool, ToolServiceContext, and SQS types. AgentActionRunner implementing this trait is introduced in automations/src/runner.rs, delegating to existing agent_task functions. Domain model imports in agent_task.rs and notify.rs are redirected to scheduled_action::domain::models. Workspace, flake, infra stack logging, CI service paths, and dependency closure files are all updated to reference the new crate.

Suggested reviewers

  • synoet

Poem

🐇 A crate was born on a cloudy day,
automations hopped into the fray.
ActionRunner trait—decoupled and bright,
No more big deps holding on tight.
The scheduler schedules, the runner just runs,
Separate crates now, two bunnies, not one! 🎉

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess whether a description exists and relates to the changeset. Add a pull request description explaining the motivation, approach, and impact of splitting the agent executor into a separate automations crate.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: refactoring the scheduled_action crate by extracting the agent executor logic into a separate automations crate.
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.


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 `@rust/cloud-storage/automations/src/lib.rs`:
- Line 1: Add the `#![deny(missing_docs)]` attribute to the crate root in lib.rs
to enforce documentation requirements on all public items. This attribute should
be placed at the top of the file alongside the existing `#![recursion_limit =
"256"]` directive. This is a workspace coding guideline for new crates that
ensures all public items have proper documentation.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 430c784d-ca48-4e6f-868a-4ab0f95705d1

📥 Commits

Reviewing files that changed from the base of the PR and between ab09751 and 9c7b914.

⛔ Files ignored due to path filters (1)
  • rust/cloud-storage/Cargo.lock is excluded by !**/*.lock, !**/Cargo.lock
📒 Files selected for processing (14)
  • .github/services-config.json
  • .github/workspace-dep-closures.json
  • flake.nix
  • infra/stacks/agent-schedule-service/index.ts
  • rust/cloud-storage/Cargo.toml
  • rust/cloud-storage/automations/Cargo.toml
  • rust/cloud-storage/automations/src/bins/service.rs
  • rust/cloud-storage/automations/src/inprocess_executor/agent_task.rs
  • rust/cloud-storage/automations/src/inprocess_executor/mod.rs
  • rust/cloud-storage/automations/src/inprocess_executor/notify.rs
  • rust/cloud-storage/automations/src/lib.rs
  • rust/cloud-storage/scheduled_action/Cargo.toml
  • rust/cloud-storage/scheduled_action/src/outbound.rs
  • rust/cloud-storage/workspace-hack/Cargo.toml
💤 Files with no reviewable changes (2)
  • rust/cloud-storage/scheduled_action/src/outbound.rs
  • rust/cloud-storage/scheduled_action/Cargo.toml

@@ -0,0 +1,18 @@
#![recursion_limit = "256"]

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add missing docs enforcement in the new crate root.

Line 1 is missing #![deny(missing_docs)], which is required for new lib.rs files in this workspace.

Suggested patch
 #![recursion_limit = "256"]
+#![deny(missing_docs)]

As per coding guidelines, “Add #![deny(missing_docs)] to lib.rs in new crates to enforce documentation on all public items.”

🤖 Prompt for 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.

In `@rust/cloud-storage/automations/src/lib.rs` at line 1, Add the
`#![deny(missing_docs)]` attribute to the crate root in lib.rs to enforce
documentation requirements on all public items. This attribute should be placed
at the top of the file alongside the existing `#![recursion_limit = "256"]`
directive. This is a workspace coding guideline for new crates that ensures all
public items have proper documentation.

Source: Coding guidelines

@ehayes2000 ehayes2000 force-pushed the eric.hayes/split-automations-crate branch from 9c7b914 to 87b1278 Compare June 17, 2026 20:29

@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 `@rust/cloud-storage/scheduled_action/src/outbound/inprocess_executor.rs`:
- Around line 60-65: The action claimed via self.repo.claim_action(&id) on line
60 is not released if the subsequent self.runner.create_resource(&action) call
fails on line 64, since the question mark operator causes an early return
without cleanup. Wrap the create_resource call in error handling or use a
pattern that ensures self.repo.release_action(&id) is called to release the
claim whenever create_resource fails, preventing the action from being blocked
indefinitely until the claim times out.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: 13c573ac-e2b2-44b7-a733-1f8bfe850236

📥 Commits

Reviewing files that changed from the base of the PR and between 9c7b914 and 87b1278.

⛔ Files ignored due to path filters (1)
  • rust/cloud-storage/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (15)
  • .github/services-config.json
  • .github/workspace-dep-closures.json
  • flake.nix
  • infra/stacks/agent-schedule-service/index.ts
  • rust/cloud-storage/Cargo.toml
  • rust/cloud-storage/automations/Cargo.toml
  • rust/cloud-storage/automations/src/agent_task.rs
  • rust/cloud-storage/automations/src/bins/service.rs
  • rust/cloud-storage/automations/src/lib.rs
  • rust/cloud-storage/automations/src/notify.rs
  • rust/cloud-storage/automations/src/runner.rs
  • rust/cloud-storage/scheduled_action/Cargo.toml
  • rust/cloud-storage/scheduled_action/src/domain/ports.rs
  • rust/cloud-storage/scheduled_action/src/outbound/inprocess_executor.rs
  • rust/cloud-storage/workspace-hack/Cargo.toml
💤 Files with no reviewable changes (1)
  • rust/cloud-storage/scheduled_action/Cargo.toml

Comment on lines 60 to 65
self.repo.claim_action(&id).await?;

// Create the chat up front so the caller gets a chat_id synchronously
// and the eventual execution record can link back to it.
let chat_id = match action.kind {
ActionKind::Agent => agent_task::create_run_chat(&self.db, &action).await?,
};
// Create the run resource up front so the caller gets a resource id
// synchronously and the eventual execution record can link back to it.
let resource_id = self.runner.create_resource(&action).await?;

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Release the action claim if resource creation fails.

On Line 60 the action is claimed, but on Line 64 a create_resource failure returns early and skips release_action, leaving the action blocked until claim timeout.

Suggested patch
-        let resource_id = self.runner.create_resource(&action).await?;
+        let resource_id = match self.runner.create_resource(&action).await {
+            Ok(resource_id) => resource_id,
+            Err(e) => {
+                if let Err(release_err) = self.repo.release_action(&id).await {
+                    tracing::error!(
+                        error=?release_err,
+                        action_id=?id,
+                        "failed to release action claim after resource creation failure",
+                    );
+                }
+                return Err(e);
+            }
+        };
🤖 Prompt for 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.

In `@rust/cloud-storage/scheduled_action/src/outbound/inprocess_executor.rs`
around lines 60 - 65, The action claimed via self.repo.claim_action(&id) on line
60 is not released if the subsequent self.runner.create_resource(&action) call
fails on line 64, since the question mark operator causes an early return
without cleanup. Wrap the create_resource call in error handling or use a
pattern that ensures self.repo.release_action(&id) is called to release the
claim whenever create_resource fails, preventing the action from being blocked
indefinitely until the claim times out.

@ehayes2000 ehayes2000 force-pushed the eric.hayes/split-automations-crate branch 2 times, most recently from cac7d80 to 3e745c2 Compare June 17, 2026 20:48
@ehayes2000 ehayes2000 force-pushed the eric.hayes/split-automations-crate branch from 3e745c2 to 2532598 Compare June 17, 2026 20:55
scheduled_action becomes a pure scheduling library (cron schedule, repo,
polling/tokio dispatchers, HTTP router, live updates). The concrete agent
executor and the deployable service binary move to a new automations crate
that depends on scheduled_action + memory + ai_tools.

This breaks the scheduled_action -> memory edge out of the core library so
memory can depend on scheduled_action (for upcoming composed-memory work)
without a cargo cycle.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ehayes2000 ehayes2000 force-pushed the eric.hayes/split-automations-crate branch from 2532598 to f2ff1a8 Compare June 17, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant