Context Poliscopic is a civic-document project: it collects local government agendas and supporting documents, extracts their text and structure, and turns them into a weekly newsletter. The newsletter is generated by a scheduled pipeline, and this note is about that pipeline rather than the coverage. Poliscopic project page.
For several weeks, five scheduled jobs ran every weekday at 5 a.m. and reported failure. Each one was supposed to produce a weekly civic newsletter for a different topic: boards and commissions, housing, public safety, water, transportation. Each one was marked as failing with the same message — a timeout during a model call — six to nine times in a row.
The newsletters were, in many cases, arriving. This is the part worth sitting with. The thing that reported failure and the thing that did the work were not the same process, and only one of them was being measured.
Three generations of the same pipeline
The workflow had been rebuilt twice before it worked.
The first version was a shell pipeline: a sequence of scripts, each calling the next. That is easy to read and hard to resume. If step four fails, the run is over, and the only record of what happened is the terminal scrollback.
The second version was a YAML runner. YAML is a plain-text configuration format; here it described an ordered list of steps. A long-running Python process read that file, then looped: sleep five seconds, check whether each step had written a state file, and start whatever step was ready. A state file is just a small record on disk saying whether a step is pending, running, succeeded, or failed. The idea was that any step could be retried without rerunning the whole pipeline, because the runner could see where it had stopped.
That version worked, in the sense that newsletters went out. It also depended on one process staying alive for fifteen to sixty minutes, and on a poll interval as the only way to notice that a step had finished.
The extra call
The specific failure was one layer up. Each step's model work was delegated through a separate scheduled agent call — a second job that existed only to invoke the model and report back. So a single newsletter was not one job; it was a launcher, a polling runner, and then a series of short-lived jobs, one per model step.
Every one of those calls had its own timeout. The launcher's timeout was the shortest. It could expire while the runner was still healthy and the steps were still completing, and when it did, the scheduler recorded a failure for the whole topic. Raising the timeout from 60 seconds to 300 seconds made the error less frequent without changing anything about the cause. It moved the boundary, not the design.
There is a general lesson in this that has nothing to do with newsletters. A supervisor's report is a statement about the supervisor. If the supervisor is a wrapper around the actual work, its timeout is a fact about the wrapper.
What replaced the loop
The redesign removed the long-lived process and the delegated call. It kept the state files, because they were the useful part.
Now the scheduled job starts a runner that creates a run directory, writes the first step's job file, launches a step executor as a detached process, and exits. The whole launcher lifetime is under a second. The step executor calls the model directly, writes the step's outcome, and then invokes the runner again in a mode that advances the run exactly one pass: check the gate, run any deterministic steps inline, prepare the next model step, launch it detached, exit.
No process outlives the step it is working on. Nothing sleeps and checks. The chain is the state: each step ends by recording what happened and starting the next decision.
Retries are bounded per step. When a step fails, the advance pass applies the retry policy; when retries are exhausted, the run is marked failed, an alert email goes out, and no further step starts. That last clause matters more than it sounds. A pipeline that keeps going after a failed verification step is not more resilient; it is less honest.
The verification gate stayed where it was, before send. A separate model checks each claim in the draft against the source material, and the run either continues to delivery or sends the draft back for correction. The redesign changed how the work was scheduled, not what counted as acceptable output.
What two clean runs establish
Two end-to-end runs — housing and public safety — completed after the change on the same day. Both advanced through classification, enrichment, summarization, verification, and send. Both recorded a delivered email, a populated week-in-review section, and no data-gap section. The Python files compiled cleanly, which is a low bar but a real one for a pipeline assembled from scripts.
Two runs are enough to show that the chain executes. They are not enough to show that it recovers.
The known gap is specific. If a step executor is killed — a reboot, a crashed machine, a process reaped by the operating system — the chain stops. Nothing is left to launch the next advance pass. The run remains marked running, and the daily digest's workflow-health section surfaces it, but no process is watching for that state. A stall-recovery job could close this, and it has not been built.
That is the honest state of the system: reliable in the normal path, visible when it stalls, and not yet self-healing. The difference between those three claims is the whole point of writing them down separately.
The design rule that came out of it
The useful rule is not "use a queue" or "avoid polling." It is that a scheduled job should be a trigger, not a container. If the job's lifetime has to span the work, then the job's timeout becomes a limit on the work, and every failure of the scheduler gets reported as a failure of the pipeline.
The corollary is about observability. A pipeline that reports only success or failure at the top cannot distinguish "the newsletter was not produced" from "the wrapper gave up waiting." Those are different incidents with different fixes, and they were being collapsed into one line in a log for weeks.