Dependency Graph (DAG) and Conditional Schedules

A control pattern representing task prerequisites as a directed graph to defer execution until all conditions are satisfied, keeping autonomous loops moving forward in correct order.

General Meaning

A dependency graph models tasks and data workflows as a Directed Acyclic Graph (DAG), ensuring that downstream operations execute only after their upstream prerequisites have completed successfully. It forms the foundation of modern data engineering and distributed workflow orchestration.

When paired with conditional schedules—such as waiting for a wall-clock time, external API event, or resource release—the scheduler manages complex temporal dependencies automatically. This enables autonomous systems to queue tasks safely without requiring manual intervention to sequence operations.

Why It Matters

  • Preventing ordering failures: Stops downstream build and deployment jobs from firing prematurely before upstream data ingestion and design work finish.
  • Eliminating wasteful polling loops: Keeps unready work parked in dormant states, ensuring that queues only dispatch genuinely actionable tasks to worker agents.
  • Maintaining continuous parallel throughput: Holds blocked tasks in reserve while allowing completely independent work streams to proceed unimpeded.

How the Site Factory Uses It

In the Site Factory, task coordination in tools/work.py is backed by Cloudflare D1 as the source of truth, organizing jobs using parent dependencies (depends_on) and conditional schedules (state: "scheduled", condition). Downstream tasks are strictly blocked from execution until every parent task reaches the done state.

For scheduled tasks, agents are strictly forbidden from clearing conditions based on guesswork. Instead, periodic patrol routines check external conditions—such as elapsed dates, merged PRs, or public release notes—against physical files or API logs before transitioning tasks from scheduled to ready, adhering to docs/architecture.md.

Caveats & Operational Rules

  • Never clear conditions by speculative assumption: Unmet prerequisites must never be treated as satisfied without verified observation logs or physical evidence.
  • Do not mistake scheduled queues for stalled systems: Having numerous tasks in scheduled status reflects healthy deferred work rather than a frozen pipeline, and should not trigger false alarms.
  • Maintain clear separation across waiting states: Do not conflate review waits, deploy waits, dependency waits, and schedule waits into a single catch-all status.

Related Terms

References

  • Book: Martin Kleppmann, *Designing Data-Intensive Applications*, Chapter 10 (Batch Processing: Workflows and DAGs)

Verified: 2026-11-08