Skip to content

feat(orchestration): Phase 1 — TaskGraph core types, DAG operations, persistence #1236

@bug-ops

Description

@bug-ops

Parent: #1235

Summary

Implement core type system, DAG algorithms, and SQLite persistence for task orchestration.

Branch: feat/m33/orchestration-types
Feature flag: orchestration (optional, not default)

Deliverables

New files

  • crates/zeph-core/src/orchestration/mod.rs — module declaration, feature-gated
  • crates/zeph-core/src/orchestration/graph.rsTaskGraph, TaskNode, TaskId, TaskStatus, GraphStatus, TaskResult, FailureStrategy, GraphId, GraphStore trait
  • crates/zeph-core/src/orchestration/dag.rsvalidate, toposort, ready_tasks, propagate_failure
  • crates/zeph-core/src/orchestration/error.rsOrchestrationError enum
  • crates/zeph-core/src/orchestration/config.rsOrchestrationConfig
  • crates/zeph-memory/src/sqlite/graph_store.rsSqliteGraphStore impl
  • crates/zeph-memory/migrations/021_task_graphs.sql — SQLite schema

Modified files

  • crates/zeph-core/src/lib.rs#[cfg(feature = "orchestration")] pub mod orchestration
  • crates/zeph-core/src/config/types.rs — add orchestration field to Config
  • crates/zeph-core/Cargo.toml — add orchestration feature
  • Cargo.toml root — feature propagation
  • crates/zeph-memory/src/sqlite/mod.rspub mod graph_store (feature-gated)
  • crates/zeph-memory/Cargo.tomlorchestration feature

Key design decisions

  • ADR-021: Persistence in zeph-memory, trait in zeph-core (zeph-core never depends on sqlx)
  • TaskId(u32) indexes into Vec<TaskNode> (not HashMap — O(1) access, max_tasks=20)
  • Edges implicit in TaskNode.depends_on (no separate edge list)
  • Only Completed unblocks downstream; Skipped triggers transitive skip propagation
  • GraphStore trait: save_graph, load_graph, list_graphs, delete_graph

DAG algorithms

  1. Cycle detection: Kahn's algorithm — simultaneously validates acyclicity and produces topological sort
  2. Ready tasks: scan for Pending tasks with all deps Completed
  3. Failure propagation: Abort (cancel all), Skip (transitive), Retry (reset to Ready), Ask (pause)
  4. Validation: valid TaskId refs, no self-references, cycle-free, at least one root

Tests (~35)

  • Cycle detection: single cycle, multi-node cycle, no cycle, self-reference
  • Topological sort: linear chain, diamond, wide parallel, single node, empty graph
  • Ready tasks: initial roots, after completion, skipped does NOT unblock
  • Failure propagation: abort cascades, skip cascades transitively, retry resets status
  • Validation: invalid TaskId references, empty graph, single task
  • Serialization round-trip for all types (serde JSON)
  • Persistence: save/load round-trip, list, delete (test SQLite)
  • Display impls for user-facing types

Dependencies

None — first phase.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestorchestrationTask orchestration / DAG scheduling

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions