feat: first-class DAG workflow engine #311
Labels
No labels
backend
bug
chore
duplication
effort:complex
effort:medium
effort:trivial
enhancement
frontend
fullstack
priority:high
ready-for-agent
refactor
security
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dries/ocman#311
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem Statement
Ocman can launch child sessions, isolate work in worktrees, and repeatedly trigger a single action through Agent Loops. It cannot yet coordinate a large, durable multi-agent workflow such as the Bun Zig-to-Rust migration described in the reference video: discover thousands of work items, fan them out, run implementers and adversarial reviewers in parallel, fan findings back into fixers, serialize commits, gate progress on builds/tests, and resume safely after interruption.
Today a lead agent can approximate parts of this by creating many sessions and loops, but correctness lives in prompts and agent memory. Ocman has no persisted graph, deterministic dependency scheduling, artifact contracts, workspace ownership, fan-in semantics, or workflow-level recovery. At high concurrency this leads to agents fighting over Git state, repeated expensive commands, unclear progress, and unsafe retries of uncertain side effects.
Solution
Add a first-class, versioned DAG workflow engine to ocman. Users and agents define workflows declaratively as YAML or JSON. A workflow version contains triggers, typed nodes, dependency edges, CEL conditions, artifacts, resource requirements, repeat policies, and workspace policies. Each trigger firing or manual start creates an immutable, separately auditable Workflow Run pinned to one workflow version.
The engine executes agent, command, approval, subworkflow, map, and join nodes. Dynamic map nodes expand a JSON work-item list into pinned subworkflow runs, while join nodes aggregate ordered results and statuses. Named resource pools and a required run concurrency cap bound machine load. Worktree shards and exclusive/path-scoped leases prevent concurrent writers from corrupting shared state. Immutable artifacts connect nodes without shared mutable scratch state.
Existing Agent Loops become compatibility views over triggered one-node workflows. Existing cron, schedule, PR, child-completion, and turn-completion behavior moves into the workflow trigger layer. Current loop APIs, MCP tools, and UI remain as wrappers for one release while persisted loops are migrated.
The first reusable template demonstrates the target capability: discover migration units, map each through implement -> two parallel adversarial reviews -> join -> fix -> validate -> serialized commit, then run subsequent compile/test campaigns from captured diagnostic artifacts.
User Stories
Implementation Decisions
Testing Decisions
Out of Scope
Further Notes
The reference workflow succeeded because a human designed a translation pipeline around agents: shared guidance, stable work units, adversarial review, centralized fixing, controlled Git behavior, captured diagnostics, validation, and aggressive parallelism. The workflow engine should encode those coordination guarantees while leaving implementation judgments to agents.
This is intentionally a general DAG engine rather than a hard-coded migration campaign. The first migration template is the tracer example and acceptance proof, not a privileged execution path.
The implementation should be delivered as tracer-bullet tickets rather than one large change. A useful first vertical slice is: persist and validate a two-node definition, start a run, execute a fake agent followed by a fake command, stream state, and render the read-only run graph. Dynamic map/join, workspace leasing, triggers/loop migration, and the full migration template can then extend the same run seam.
Resolved by merged PR #338, which delivered the first-class workflow engine and its tracer-bullet scope.