Build a Continuous Software Engine

Chapter 06 • Production Fleet & Adversarial Proof

Fleet Operations, Observability & Proof

Day-one demos rarely reveal what breaks when one engine runtime operates several repositories around the clock. Keep observability strictly non-blocking behind an explicit event stream interface, make fleet self-upgrades fail closed behind an external supervisor, and judge your engine by an adversarial proof suite rather than happy-path unit tests.

Non-Blocking Event Stream & Observability Interface

Running multiple autonomous repositories requires a single place to watch live progress, inspect raw attempt traces, triage capped Needs You decisions, and notice drift (for example, documentation commits crowding out product code). Put live monitoring and telemetry behind an Event Stream & Observability interface:

  • Monotonic, cursor-resumable event projection. Emit structured domain events (attempt started, gate failed, review verdict, landed, rolled back, escalated, budget shed, upgrade readiness) with strictly increasing sequence cursors so any consumer can disconnect and resume without losing or reordering events.
  • Suggested default adapter vs. alternatives. A local HTTP dashboard streaming over Server-Sent Events (SSE) paired with JSONL logs and read-only CLI/MCP telemetry tools is a zero-infrastructure adapter. WebSockets, Kafka or NATS topics, OpenTelemetry exporters, webhooks, or a terminal UI can implement the exact same interface without changing a line of orchestrator logic.
  • Separate opt-in steering controls. Keep monitoring read-only by default. If your dashboard offers steering actions (retry, dismiss eligible untracked escalations, approve or reject a parked candidate, or save config), put them behind explicit opt-in flags, require authentication, and revalidate every mutation against authoritative state before acting.
MANAGED PROJECT LOOPS (ISOLATED PER REPO)Repo ALocal ledgerRepo BPost-land hookRepo CBranch-pinnedEVENT STREAM & TELEMETRY INTERFACECursor-Resumable, Never Blocking• Default: local SSE dashboard + read-only CLI/MCP• Alternatives: WebSockets, Kafka/NATS, OTel, TUI• Async remote probes; fast degraded local statusSUPERVISION & UPGRADE INTERFACE (E.G. LAUNCHD / SYSTEMD / K8S; NEVER SELF-RESTARTING)1. Drain All ReposBlock if unconfirmed2. Install & SelfcheckThrowaway repo proof3. Reload SupervisorVerify live version4. Fail-Closed ReadyNew land or roll backADVERSARIAL PROOF SUITE (REQUIRED BEFORE TRUSTING UNATTENDED RUNS)Abrupt process-group exit • Crash failpoints at commit/land/rollback • Finite-state scheduler livenessFail-closed review parsing & backtest corpus • Culprit-only rollback • CAS lease races • End-to-end selfcheck
Production fleets isolate observability from workers and keep process upgrades fail-closed behind an external supervision interface, grounded in an adversarial proof suite that tests crashes, abrupt exits, and deadlocks directly.

Failure Mode Prevented: Observability Causing the Outage It Reports

Putting synchronous remote network or VCS queries (such as git ls-remote) inside a frequently polled status or dashboard endpoint causes latency spikes, starves liveness probes, and displays false “0 live” states while workers are healthy. Strictly isolate local read-only ledger status from asynchronous, cached remote probes, enforce per-project fault isolation, and never let telemetry contend with worker dispatch.

Read-Only Telemetry & Development Story

Expose read-only telemetry tools (CLI or stdio MCP) that serve bounded attempt evidence, friction summaries, and a development story breaking down effort, landings, first-try rates, retries, and failures by work category (feature, fix, refactor, docs, harness). Both humans and read-only planners benefit from seeing where time actually goes without granting mutation access.

Fleet Supervision & Fail-Closed Upgrade Interlocks

When your engine improves itself while managing multiple repositories under one shared binary or checkout, upgrading that runtime live is one of the easiest ways to corrupt active work. Separate concerns behind a Fleet Supervision & Upgrade interface (suggested default adapter: an OS service manager like launchd or systemd plus an upgrade CLI; alternatives: Kubernetes, Nomad, or container fleet controllers):

  1. Declare and drain every project sharing the runtime. Guard all declared checkouts before switching code, wait for active attempts to drain cleanly, and keep upgrades blocked if any engine’s shutdown cannot be confirmed.
  2. Install and verify with selfcheck. Run the candidate runtime’s self-contained smoke proof (landing a real change end-to-end in a throwaway repository) before switching live traffic. If it fails, roll back immediately and verify the restored runtime.
  3. Reload supervisor definitions deliberately. Stale loaded service files cause quiet drift where a daemon keeps running old flags or paths after restart.
  4. Enforce fail-closed post-restart readiness. Require every restarted checkout to report the exact target version, a verified branch tip, and post-baseline landing progress before marking the rollout complete.

Engineering Discipline for Building Your Own Engine

Comparing multiple independent implementations built from the same brief makes one pattern unmistakable: passing initial happy-path tests does not separate a trustworthy engine from a brittle one. Build the smallest version of each milestone that can pass its proof, and lean on four habits that keep that proof runnable as the engine grows:

Minimal Dependencies & Small Modules

Lean on your runtime’s built-in standard library (for example, an embedded database, test runner, and subprocess APIs) and keep modules small and single-purpose. Add a third-party dependency only when local code would be large or security-fragile.

Real Repository Tools for Builders

Artificial tool-less single-shot patch loops break down on real codebases. A tool-less executor can help with a fixture or a tiny edit, while the tool-using builder proof requires reading, editing, and running the project’s real linter, typechecker, and tests inside the attempt boundary.

Executable Rules Over Giant Prompts

Keep agent instruction files focused. Whenever a rule can be verified mechanically (module size, doc links, prohibited local paths, skipped tests, lockfile integrity), enforce it in a fast linter rather than relying on prose alone, while keeping brief explanation where it helps humans understand why the rule exists.

One-Command End-to-End selfcheck

Build a fast selfcheck command that runs the real engine path on a throwaway repository with fixture agents and real Git, proving an accepted change lands once, a rejection leaves the ref unchanged, and replay works after a ledger wipe. Wire selfcheck into the engine’s own health checks, using fixture health commands inside selfcheck so it never recurses.

The Adversarial Proof Matrix

Before trusting any continuous software engine unattended overnight, prove every failure boundary directly with automated fault-injection tests. These rows are requirements to prove rather than results from an engine already built from this guide. Use real processes, storage, and Git for integration faults and the declared finite model for scheduler enumeration; the first-run fixture is not a substitute.

Failure BoundaryAdversarial Test ScenarioRequired Proof
Abrupt Process & Group ExitSIGKILL the orchestrator (and separately its process group) while a check and its spawned subprocesses are stuck; also test dangling SDK handles on shutdownZero leftover child or nested subprocesses; clean-exit backstop terminates orchestrator cleanly
Crash FailpointsCrash before commit or after ref advance but before ledger update. Separately land then engine-roll back with Rollback-Of stamped before health, and land then human-revert without it. Wipe the ledger and restart in both casesNo duplicate landings or rollback charges; still-current engine-rolled-back work requeues within its budget; human-reverted work stays done with no requeue or rollback charge; live work is skipped and revoked attempts cannot resume
Contracts & FencingEdit behavior or priority, or delete an active goal; submit writes and promotions with a stale fence and, after a wipe, with the old generation but the current numeric fenceDeletion frees the slot; behavioral edits supersede old work and feedback; priority edits preserve healthy work; both stale tuples are rejected atomically without changing ledger or ref
Fail-Closed VerificationWeaken tests; crash or time out the reviewer; return {"accept":true} without a reason, conflicting verdicts, a valid rejection, or a confirmed review outageGates catch weakened tests; no promotion without a valid accept; only the confirmed outage parks uncharged among reviewer failures; reviewer meets the approved error limits
Landing & RollbackAdvance tip or change trusted policy during verification; touch mixed-policy paths; cause a rebase conflict and attempt an unauthorized reversal; land a broken engine change then an innocent one after a human commitCurrent strictest policy wins; rebase conflict charges a retry with bounded backoff; unauthorized reversal blocks promotion and immediately goes to needs-human; promoted SHA equals the checked SHA; rollback charges only removed engine work
Stuckness & FlakesInject livelock, A → B → A oscillation, a worker crash, unexplained lease expiry, unknown provider error, confirmed host interruption/outage, and a shared check failureStuck work stops; unexplained failures charge and escalate within budget; confirmed interruption/outage is uncharged; one repair requeues affected tasks; triage stays bounded and read-only
Scheduler LivenessEnumerate every reachable state and successor in the declared finite model; test real missing and cyclic dependencies separatelyNon-terminal states act or name a wake that changes eligibility; parked tasks cannot hide independent work; stale plans are discarded
Distributed LeasesRace two peers; inject transient renewal and ambiguous push timeouts; wake an expired peer after a landing; test stale sibling artifactsOne landing; transient renewal retries within TTL; late peer deduplicates; post-land, pull and rollback refresh artifacts
Observability & UpgradesStall local VCS and remote probes while dashboard polls; run fleet upgrade with an unconfirmed engine stop or failing selfcheckLocal status does not block workers; upgrade stays blocked or verifies the restored runtime; readiness requires target version, healthy tip and new landing

How to Know Your Engine Is Ready for Unattended Runs

  • Every row in the Adversarial Proof Matrix passes deterministically in your automated suite under realistic host load.
  • The engine self-hosts on its own repository, landing real changes through its own gates, independent reviewer, and selfcheck health check.
  • A multi-hour hands-off soak across multiple repositories runs with native self-stewardship handling flakes, cascades, triage, and post-land rebuilds without manual babysitting.