⚙️ ToolGraph Workflow Engine

Resolved 💬 0 comments Opened Sep 26, 2025 by haasonsaas Closed Sep 26, 2025

Overview

Implement a typed, declarative workflow engine that enables tool composition, DAG execution, and policy enforcement.

Problem

Current tools are isolated function calls without composition, dependencies, or workflow orchestration. No support for complex multi-step operations with retries, timeouts, and rollbacks.

Solution

Build a comprehensive workflow engine with:

Core Components

  • Tool Trait with strongly typed input/output schemas
  • WorkflowEngine for DAG execution with policies
  • ExecutionContext for identity, secrets, and capabilities
  • PolicyGuard for security and sandboxing enforcement

Tool Trait Design

#[async_trait]
trait Tool: Send + Sync {
    fn name(&self) -> &'static str;
    fn input_schema(&self) -> Value;
    fn output_schema(&self) -> Value;
    fn is_deterministic(&self) -> bool;
    fn side_effect_level(&self) -> SideEffectLevel;
    async fn execute(&self, ctx: &ExecutionContext, input: Value) -> Result<Value>;
}

Built-in Tools

  • code_edit: Apply diffs with rollback capability
  • run_tests: Execute tests in sandboxed environment
  • run_lints: Code quality checks with auto-fix
  • search_code: Query the project index
  • git_operations: Branch, commit, PR creation
  • file_operations: Read/write with path sandboxing

Workflow Definition (TOML)

[workflow]
name = "implement-feature"
description = "Plan, implement, test, and review a feature"

[[steps]]
name = "plan"
tool = "planner_agent"
inputs = { task = ".task" }

[[steps]]
name = "implement"
tool = "code_edit"
depends_on = ["plan"]
inputs = { files = ".files", changes = ".changes" }

[[steps]]
name = "test"
tool = "run_tests"
depends_on = ["implement"]
inputs = { test_pattern = ".test_pattern" }

[policies]
max_duration = "10m"
max_cost = ".00"
allowed_paths = ["src/", "tests/"]

ExecutionContext

  • Identity management: User, role, permissions
  • Resource limits: Time, cost, token budgets
  • Capabilities: File access, network, git operations
  • Security: Secret management, path sandboxing

Implementation Plan

  1. Define Tool trait and basic tools (file ops, git, tests)
  2. Build WorkflowEngine with DAG execution
  3. Add PolicyGuard with sandboxing
  4. Create TOML workflow definition format
  5. Add CLI support for workflow execution

Success Criteria

  • Execute 10-step workflows reliably
  • Policy enforcement prevents unauthorized access
  • Rollback works for failed operations
  • Performance: <100ms overhead per tool call

Timeline

4-6 weeks for core engine, 8-10 weeks with full tool suite

View original on GitHub ↗