Skip to content

feat: Implements the multi-step execution chain engine for the Galaxy DevKit automation system#329

Open
sotoJ24 wants to merge 5 commits into
Galaxy-KJ:mainfrom
sotoJ24:issue/304
Open

feat: Implements the multi-step execution chain engine for the Galaxy DevKit automation system#329
sotoJ24 wants to merge 5 commits into
Galaxy-KJ:mainfrom
sotoJ24:issue/304

Conversation

@sotoJ24

@sotoJ24 sotoJ24 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the multi-step execution chain engine for the Galaxy DevKit
automation system (roadmap item #50, issue #304).

Closes #304.

Files

  • packages/core/automation/src/execution-chain/index.ts — engine + types
  • packages/core/automation/src/test/execution.chain.test.ts — unit tests
  • packages/core/automation/jest.config.cjs — Jest configuration
  • packages/core/automation/tsconfig.test.json — test-only TypeScript config

Design

API surface (matches issue spec)

export interface ExecutionStep {
  type: string;
  params: Record<string, unknown>;
  label?: string;           // key in context.outputs; defaults to type
  retryAttempts?: number;   // per-step override
  retryDelayMs?: number;    // per-step override
}

export class ExecutionChain {
  constructor(
    executors: Record<string, StepExecutor>,
    options?: ExecutionChainOptions,
  );
  async executeSteps(steps: ExecutionStep[]): Promise<boolean>;
  async execute(steps: ExecutionStep[]): Promise<ChainResult>;
  registerExecutor(type: string, executor: StepExecutor): void;
}

executeSteps returns boolean as specified. execute returns the full
ChainResult with per-step diagnostics for callers that need observability.
Both share the same internal loop.

Sequential execution and halt on failure

Steps run in order. On any failure the loop returns immediately — subsequent
steps are never called. A console.warn lists the already-completed steps so
the caller knows what may need compensating. Rollback is intentionally the
caller's responsibility: the engine has no knowledge of what each step did,
so it cannot safely undo it.

Context threading

A mutable ExecutionContext.outputs object is passed to every executor.
Each step's return value is stored under its label (or type when no
label is given), making it available to all subsequent steps:

// Step 1 produces a value
blend_withdraw: async (step, ctx) => ({ amount: '100', asset: 'USDC' })

// Step 2 reads it
soroswap_swap: async (step, ctx) => {
  const { amount } = ctx.outputs['blend_withdraw'] as { amount: string };
  // ...
}

Retry

Per-step and chain-level retry with configurable delay. retriesUsed is
reported in StepResult for observability.

Protocol-agnostic

ExecutionChain has zero imports of Blend, Soroswap, or vault code.
Executors are plain async (step, context) => unknown functions registered
by type string, making every protocol integration independently mockable and
swappable.

Tests

Screenshot from 2026-06-30 19-51-54

Acceptance criteria

  • Execution continues sequentially on success
  • Execution halts and warns on step failure — subsequent steps are not
    called; completed steps are listed in a console.warn for rollback
    guidance
  • Unit tests covering mock execution chain (23 tests, all passing)
  • Per-step and chain-level retry with configurable attempts and delay
  • Context threads outputs between steps for real pipeline composition
  • Protocol-agnostic — no hard dependency on any DeFi protocol

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@sotoJ24, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 52 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: cab94b06-f2e7-4bd8-8611-b3310be101c7

📥 Commits

Reviewing files that changed from the base of the PR and between deb9ad9 and bf7e8af.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (8)
  • packages/contracts/governance/Cargo.toml
  • packages/contracts/governance/src/lib.rs
  • packages/core/automation/jest.config.cjs
  • packages/core/automation/package.json
  • packages/core/automation/src/execution-chain/index.ts
  • packages/core/automation/src/test/execution.chain.test.ts
  • packages/core/automation/tsconfig.json
  • packages/core/automation/tsconfig.test.json
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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.

[FEATURE] Automation: Multi-step action execution chain engine (#50)

1 participant