# Graph engineering when the graph never sleeps

> Most graph engineering advice assumes a graph that starts when you prompt it and ends when it answers. A Cue pipeline runs all night with nobody watching. That changes which failures hurt, and the fixes come out close to inverted.

31 Jul 2026 · Engineering · cue, graph-engineering, pipelines, observability, automation · The Conductor
Source: https://runmaestro.ai/blog/graph-engineering-the-graph-never-sleeps/

---

Anatoli Kopadze published [a good explainer on graph engineering](https://x.com/anatolikopadze/status/2080668775796314331). We have been doing this in [Maestro Cue](https://docs.runmaestro.ai/maestro-cue) for months, so this post describes how.

The short version of his piece: a node is one job with a defined input and output. An edge is a real data dependency. Most workflows are a straight chain where three quarters of the arrows are imaginary. Cut the fake arrows and the line becomes something wide.

All of that is correct, and it is written about a graph you invoke. You ask for a workflow, a fleet of agents spawns, one report lands, and everything disappears. The graph exists for the length of your question.

A Cue pipeline is the other kind. Our own graph has sixteen nodes that fire on schedules and heartbeats whether or not anyone is awake. Some have fired every few minutes since May.

Persistence does not change the vocabulary. It changes which failures hurt you, and the answers come out close to inverted.

Our graph tends an internal knowledge base, which is fine to run and dull to read about. So this post draws the same topology pointed at a code repository.

## The graph

First, the reactive half. Everything in the top box fires on a timer and almost always exits without doing anything. Nothing in the bottom box runs except when one of the watchers hands it work:

```mermaid fig="The reactive half" title="Cheap watchers, costly agents" caption="The watchers fire on a timer and almost always exit. The agents run only when a watcher hands them work."
flowchart TD
  subgraph WATCH["Watchers: cheap gates"]
    PRW["PR Watcher<br/>every 2 min"]
    CIW["CI Watcher<br/>every 3 min"]
    ALR["Alert Spool<br/>every 60 sec"]
  end
  subgraph WORK["Agents: only on a hit"]
    RVW["Review Fan-Out, 4 lenses"]
    TRI["Failure Triage"]
    REP["Repro Builder"]
    PAT["Patch Author"]
    INC["Incident Scribe"]
  end
  PRW -->|"new head SHA"| RVW
  CIW -->|"red build + log"| TRI
  ALR -->|"open incident"| INC
  TRI -->|"suspect commit"| REP
  REP -->|"a red test"| PAT
  class PRW,CIW,ALR gate
```

The scheduled half is six jobs on a clock. We do not draw it as a graph, because it is not one. Five of the six have no relationship to each other, and a picture of six unconnected boxes tells you less than a table:

| Job                 | Fires       | Produces                           |
| ------------------- | ----------- | ---------------------------------- |
| Dependency Audit    | 02:00 daily | advisory report per manifest       |
| Flake Detector      | 03:00 daily | tests that failed under rerun      |
| Flake Quarantine PR | 03:20 daily | a PR that skips exactly that list  |
| Doc Drift           | 04:00 daily | docs whose code moved without them |
| Architecture Drift  | Fri 17:00   | import-boundary violations         |
| Dead Code Sweep     | Sun 09:00   | unreferenced symbols               |

One arrow lives in that table. Two operations nodes sit above it:

```mermaid fig="The scheduled half" title="Two operations nodes above the clock"
flowchart TD
  HC["Fleet Health Check<br/>06:00"]
  HEAL["Self-Heal<br/>every 30 min"]
  subgraph NIGHT["The six scheduled jobs"]
    FLK["Flake Detector"] -->|"flake list"| QUA["Flake Quarantine PR"]
  end
  HC -.->|"probes"| NIGHT
  HEAL e1@-.->|"heals"| NIGHT
  class e1 loop
```

That is six real edges across sixteen nodes. This is the fake-edge test applied honestly, and the answer keeps coming back: these jobs have nothing to do with each other. The Sunday dead code sweep does not need Friday's architecture report. People chain them anyway, because a list looks like a sequence.

Three of the six edges are dispatch edges: a watcher notices something and hands an expensive node its input. The other three are data edges, and one of them carries the whole design.

**Repro feeds Patch.** The patch author never starts from a description of the bug. It gets a test that is currently red. That is the difference between a fix and a plausible-looking diff. If Repro cannot produce a red test, the chain stops and a human gets a short note instead of a pull request. That is correct behaviour.

## Time is the edge you cannot delete

Kopadze's third failure mode is false independence. Two nodes look parallel because their prompts never mention each other, but they write the same file or call the same rate-limited API. His fix is one git worktree per worker.

Worktrees fix one kind of contention: the filesystem. Point a persistent graph at a real engineering environment and count what else there is only one of. One staging deploy. One seeded test database. One pool of CI runners. One org-wide model quota.

There is no worktree for a staging environment. Patch and Repro can each have their own checkout and still collide on the same database.

So the `settings` block in our `cue.yaml` says this:

```yaml
settings:
  max_concurrent: 1
  timeout_on_fail: break
  queue_size: 512
```

These happen to be Cue's defaults. We keep them on purpose. `max_concurrent: 1` means sixteen nodes, one run at a time. A graph engineering article would call that the worst possible topology.

When every node competes for the same scarce resources, parallel runs work only until two agents force-push the same branch, or a quota limit trips at 03:00 and the night is lost. With one slot, extra events wait in the queue (up to `queue_size`) instead of running on top of each other.

Our real isolation mechanism is **time**. Audit at 02:00, flakes at 03:00, quarantine at 03:20, doc drift at 04:00. That column looks like a chain. It is a contention schedule: it serializes shared resources in the only vocabulary the scheduler has.

An invoked graph optimizes wall-clock time because you are sitting there waiting. Nobody waits on the night shift. A slow audit at 02:00 costs nothing when the first person opens a laptop at eight. Two nodes colliding at 03:00 with nobody watching costs a lot.

Trade the parallelism you do not need for the determinism you need when something breaks at 03:00.

## The cheapest node is not an agent

**No scheduled node is an agent. Every agent sits behind a deterministic gate.**

Eleven of the sixteen nodes are plain shell commands: the three watchers, the six scheduled jobs, and the two operations nodes. In Cue that is `action: command` with `mode: shell`. The five agent nodes live in the dispatch layer, and no clock trigger reaches them directly.

Many of those shell commands call a model internally. There is an LLM inside them. But **Cue does not know that**. The node's contract with the scheduler is "run this command, get an exit code." The model lives inside the node, not on the edge.

The first benefit is robustness. A dispatcher bug once took out every agent node we had, for weeks. The shell nodes kept running, because their failure surface was an exit code, not a dispatch protocol. Over months, the node type with fewer moving parts wins on availability alone.

The second benefit is cost, and the fan-out literature skips it because an invoked graph never runs long enough to care. **Put a cheap deterministic gate in front of every expensive node.**

The PR watcher fires every two minutes, indefinitely. It calls `gh api`, compares each pull request's head SHA against a stored high-water mark, and exits. Almost always there is nothing new, and it exits having spent zero tokens. When a SHA moves, it dispatches the review fan-out.

In Cue the wiring looks like this:

```yaml
subscriptions:
  - name: PR Watcher
    event: time.heartbeat
    interval_minutes: 2
    action: command
    command:
      mode: shell
      shell: ./scripts/pr-watcher.sh

  - name: Review Fan-Out
    event: cli.trigger
    fan_out: [Review Security, Review Tests, Review API, Review Style]
    prompt: |
      Review this pull request through your lens.
      {{CUE_CLI_PROMPT}}
```

The watcher script does the comparison. Only on a hit does it call:

```bash
maestro-cli cue trigger "Review Fan-Out" --prompt "PR #$PR moved to $SHA"
```

The text after `--prompt` arrives in the reviewers' prompt as `{{CUE_CLI_PROMPT}}`.

> [!NOTE] Why not the built-in GitHub trigger?
> Cue's `github.pull_request` trigger fires once for each new pull request. It does not fire when someone pushes new commits to an open one. A watcher that tracks head SHAs catches both.

That is about 720 firings a day, and nearly all of them cost one API call and a comparison. The graph is very wide in time and nearly free, because the wide part is deterministic and the expensive part waits behind it. Make the watcher an agent that "checks whether anything interesting happened," and you have a machine that pays a model to find nothing 700 times a day. Sometimes it talks itself into a finding to justify the trip.

**The node that decides whether to work should never be the node that does the work.** In a fleet you start on demand, you are the gate. In a graph that runs alone, something else must be, and a shell script is the best choice: cheap, deterministic, and it has no opinions.

When the decision really needs judgment, Cue has a middle step. `maestro-cli cue gate "<name>" --set "<condition>"` makes a local model check a plain-language condition before a run starts. That is much cheaper than a full agent run. A string comparison in a shell script is cheaper still, so use it wherever it is enough.

## The checker is the whole trick

Here we push back on the source article instead of agreeing with it.

The article is right that a worker should never grade its own work. It is also right that topology does not buy truth, so a graph needs anchors: things that cannot be argued with, like tests that ran or revenue that landed.

Both points assume a human reads the output within the hour. If the verifier is wrong, you notice, because you are right there.

Nobody reads the night shift. That is the point of it, and also the trap. The failure to fear is not a bad answer. It is a node that reports success while doing nothing, indefinitely, with every light green.

Three real examples from our graph:

**Five weeks.** A recurring messaging job attaches an image to each message it sends. The attachment code broke. The text kept sending, on schedule, correctly worded. The probe asked "has the output file changed recently?" and reported green the entire time.

**Thirty-seven days.** Our semantic search index failed on every run because of a native module version mismatch. The probe watched the log file. The log gets a new line on every run, including total failures. Hundreds of logged failures, zero alerts, and a frozen index we kept querying and trusting.

**Fourteen days.** An ingestion job ran hourly for two weeks. It deferred the same item every time, exited zero, and logged nothing alarming. Green the whole way.

None of these is a reasoning failure. No model hallucinated. No verifier agreed too easily with a worker. Every node did one bounded job. They failed where topology has nothing to say: **the signal that said a node was healthy was not connected to whether the node did its job.**

Freshness is not health. We have learned that lesson in four separate places, and it is the most expensive one we know.

## Two layers of anchor

The fix treats "did it run?" and "did it work?" as two separate questions. Our health check is an ordinary script; nothing here is special to Cue except that Cue runs it.

The first layer is liveness. Every node registers an artifact that only real work can produce:

```python
PROBES: dict[str, dict] = {
    "Dependency Audit": {"output_glob": "reports/deps/*.md"},
    "Flake Detector":   {"output_glob": "reports/flakes/*.json"},
    "PR Watcher":       {"state_file": "state/pr_watermark.json"},
    # Probe the INDEX, never the log. The log gets a line on every run, including
    # total failure, which is how log freshness reported GREEN for 37 days while
    # the index sat frozen. The artifact's mtime is the honest signal here.
    "Semantic Index":   {"state_file": "~/.cache/search/index.sqlite"},
}
```

**Probe the product, never the process.** A log proves the process ran. An index proves it produced something. Watch the artifact that could not exist unless the work happened.

The second layer exists because the first is not enough:

```python
# A PROBE asks "did this job run and touch its artifact?", which is not the same
# question as "did the job do its job?". A DEEP_CHECK opens the artifact and
# inspects the payload. Its verdict overrides a green probe.
DEEP_CHECKS: dict[str, callable] = {
    "Review Fan-Out":   review_health.check,   # comment cites >=1 file in the diff?
    "Dependency Audit": deps_health.check,     # every configured registry reported?
}
```

Does the review comment name a file that appears in the diff, or is it four paragraphs of generic praise? Did every registry report, or did one stop while the others keep the file's timestamp moving?

That is the anchor idea made specific for unattended work. An anchor is not just "a number that cannot argue back." It is a signal **that cannot exist without the work**. A log line fails that test. A timestamp usually fails it. The bytes of the thing the node was supposed to make usually pass.

The third piece: a node with no probe does not pass. It reports `UNKNOWN`, with a hint about what probe to add. Unmonitored is a state, and it is not healthy. A graph that treats "no opinion about this node" as "this node is fine" will fail on the node you forgot to instrument. A known gap is better than a false green.

## Heal, do not nag

When an invoked graph fails, it tells you, and you are already there. When the night shift fails at 03:00 on a Tuesday, telling someone gives them a chore before coffee.

Our watchdog started as an alerter, so every failure became a task on the operator's list. Now it regenerates the missing artifact itself and escalates only when regeneration fails.

Cue already covers one part of this. If the machine sleeps through a `time.scheduled` slot, Cue fires one catch-up run for the most recent missed slot when it wakes. `time.heartbeat` subscriptions get one catch-up too. What Cue cannot know is whether a run that did fire produced anything. That is the self-heal node's job. It runs every thirty minutes and looks for any artifact whose time has passed without it appearing, then generates it. The generator is idempotent and time-gated, so a 09:00 tick heals the 02:00 audit and leaves Friday's report alone.

> [!TIP] No desktop app required
> If the night shift should not depend on a laptop lid, `maestro-cli cue engine check` lists anything the standalone engine is missing, and `maestro-cli cue engine start` runs Cue without the desktop app.

The heal loop is not finished. Deduplication is per artifact per day, so a bad night still produces several notifications instead of one. A self-healing node that pings you four times about the same failure has a notification bug.

## What to take from this

1. **Run the fake-edge test and count your real edges.** Sixteen nodes, six edges, and half of those are dispatch, not data.
2. **Give downstream nodes anchors, not descriptions.** The patch author gets a red test. If the upstream node cannot produce the anchor, stopping is correct.
3. **Use time as your isolation mechanism when nothing else works.** Worktrees fix the filesystem and nothing else.
4. **Gate every expensive node behind a cheap one.** The node that decides should not be the node that does.
5. **Prefer shell nodes at the scheduler boundary.** Keep the model inside the node.
6. **Probe the product, never the process.** Log lines and timestamps that change either way are how you get thirty-seven days of confident nothing.
7. **Add a payload check on top of the liveness check.** The gap between "it ran" and "it worked" is where five weeks of broken attachments hid.
8. **Make unmonitored visible.** `UNKNOWN` beats a false green.
9. **Heal instead of alerting.** An alert that becomes a chore moves work back onto the person the graph was built to help.

Kopadze's anchors are things that cannot argue back: tests that ran, revenue that landed. Ours are more mundane, because this graph's job is not to be smart. Its job is to be there. Our anchors are bytes on disk that could not exist unless the work happened.

Topology does not buy truth. It does not buy uptime either. You earn both separately, and a persistent graph makes you earn uptime every night.

To build one, start with [Maestro](https://runmaestro.ai) and the [Cue docs](https://docs.runmaestro.ai/maestro-cue). If you are new to Cue, [Maestro Cue: agents that pick up work on their own](https://runmaestro.ai/blog/maestro-cue-agents-pick-up-work/) shows how to build a pipeline by describing it to an agent instead of writing YAML. The whole graph above is sixteen entries in one `cue.yaml` file.
