part 1 of 3
The architecture
The machine is not the apps it runs. Here are the laws it enforces, the line every app travels, and the loops that keep it alive.
The ops layer never ends
A tutorial ends when the app comes up. The work starts the next morning, when you wonder whether it is still running.
It continues every time a CVE lands in your base image, a deploy breaks something silently, or the database reaches the edge of its disk while your logs say nothing useful. Deploy, watch, heal, update, back up, scale, secure: none of these is a one-time task. Together they are permanent operational debt, usually paid slowly, noisily, and at 3 a.m.
Chakra is a machine that owns that debt. This post covers the architecture. Part 2 covers the run and everything that broke. Part 3 covers the chaos monkey.
Three primitives: do, check, remember
Strip any operation to first principles and three jobs remain. Something has to do the work. Something has to check that the work happened. Something has to remember what occurred.
Chakra keeps those three jobs apart, on purpose.
| Job | Who | How |
|---|---|---|
| Do | Agents | One tmux episode per task, on a free model |
| Check | Gates | Deterministic Python that hits real endpoints and counts real rows |
| Remember | Files | Append-only JSONL. No database. |
An agent can write a compose file. It cannot decide whether that file works. Only gates/probes.py can. An agent that writes a flawless postmortem earns nothing until bash gates/run_gates.sh <app> service exits 0.
The machine never takes an agent’s word for anything. Everything else in this post is plumbing around that one rule.
The machine is not the apps
One constraint came before any code: the machine is not a wrapper around the apps it operates. An agent running Umami cannot edit pipeline.sh. An agent debugging Grafana cannot touch gates/probes.py. The operator writes the engine once, and after that it is frozen as far as any agent is concerned.
The agent briefs, the role definitions every agent reads before acting, enforce the boundary. It is why you can leave AI agents running on production infrastructure overnight. They operate inside the machine. They never modify it.
Upstream images are pinned by digest. Never latest in production.
Ten laws
These are not aspirations. Most were forged mid-run, when something broke.
-
Free models only, $0. On a crash, rotate.
dispatch.shpicks from a pool of eleven free model IDs and runsopencode run -m '<model>'. If an episode crashes or returns under 1,200 bytes (a silent no-op), the dispatcher rotates to the next model. Never the same model four times in a row. Free-tier rate limits bit repeatedly, so this is a production retry strategy for a new kind of failure. -
One agent, one tmux episode, one end marker. When the process exits,
dispatch.shappendsDISPATCH_END_<role>_<ep>_<ts> rc=Nto the log.wait_marker()polls the newest log for that exact string. An agent that claims it finished but wrote no marker is, to the machine, still running. -
Files are the only memory. State lives in JSONL:
journal.jsonl,gates.jsonl(1,316 verdicts by the end),incidents.jsonl,releases.jsonl. Every write is an append. After a crash the machine replays the files. Compress the status directory and you hold its complete memory. -
Gates decide. Agents never self-certify. The most important law. Gates are plain Python. They call real HTTP endpoints, inspect real containers and count real ClickHouse rows.
-
Dashboard from minute 5.
http://<box>:8766is live before the first app deploys. A silent dashboard means a broken machine. -
Observability at birth. An app is not live until a real application log line appears in ClickHouse. A running collector proves nothing. A row in the table proves ingestion.
-
Nothing counts until proven. A postmortem per incident. A restore drill per backup. A rollback path tested before anyone trusts it.
-
App envs never hold box credentials. The
securityprobe fails any container that runs privileged, mountsdocker.sock, or publishes a port on anything but127.0.0.1. It also fails any.envthat holds SSH keys, OCI credentials orauth.jsontokens. -
One box. Per-app ports (3001–3004) and per-app resources. No second box without the operator’s word.
-
The operator writes engine code only. Agents do all operational work.
The assembly line
Every app enters through engine/pipeline.sh. The pipeline is resumable: each phase writes a marker file, and a restart skips finished phases.
marked "$mk.$APP" && { ev "phase-skip"; return 0; }Each phase dispatches one agent with one role brief. If a gate fails, a fix episode reads the failure file and tries again, for up to N rounds. After that the phase is declared blocked.
Recon
The recon agent checks the catalog entry against reality and writes recon.json: upstream URL, pinned image digest, env spec, ports, volumes, health path, smoke plan and resource estimate. It must pull and inspect the image. Copying the digest from the catalog fails.
Gate
recon_artifact. All eight required fields exist andenv_specis a non-empty list.
Contract
The planner freezes contract.json: app name, strategy (docker or compose), internal port, health path, smoke assertions, backup config, release config and resource limits. Everything downstream reads it. SRE reads the health path. The release script reads the service name. The autoscaler reads the scalable flag. The contract is the machine’s knowledge of the app.
Gate
contract. Port is an integer from 3000 to 3999. Health path starts with/. The smoke list is non-empty and every entry haspathandexpect_status. Nothing else passes.
Provision
The provisioner writes docker-compose.yml and .env. Ports bind to 127.0.0.1:<host>:<container>. Secrets are generated, never reused.
Gate
build.docker compose config -qpasses and every image pulls.
Deploy
Before the agent runs, the engine publishes the nginx vhost itself with publish_nginx.sh. That is engine work, not agent work. The vhost routes <app>.<box-ip>.nip.io to 127.0.0.1:<port>, and the app never knows it sits behind a proxy. Then the deployer brings the stack up.
Gates
service(every container running and healthy) andhttp_local(health path returns 2xx).
Verify
The verifier tries to disprove the deployment. It fixes nothing. It hunts for problems.
Gates
http_external(2xx from the public IP with the rightHostheader, so nginx works end to end),smoke(every contract assertion, POSTs with auth bodies included),resource(memory within 115% of the limit) andsecurity(the container checks from law 8).
Observe
logship-<app> ships Docker logs to ClickHouse through the OTel collector. The pipeline sends three real requests, then polls the observability gate for up to three minutes. If it times out, a fix episode runs. If that fails too, the app is marked observe-unproven and carries on. The machine is honest about what it can and cannot prove.
Gate
observability. A log row from the app in the last 24 hours, and a metrics row in the last 300 seconds. Both, or neither counts.
Catalog
Proven apps are marked live. Unproven apps are marked app-not-live. They may still serve traffic, but the machine will not vouch for them. The URL is http://<app>.<box-ip>.nip.io. No domain, no TLS. Both are declared gaps, and neither stopped the machine from running the fleet.
Five loops keep it alive
The pipeline gets an app live. Loops keep it live. All five run as tmux sessions under supervise.sh, which checks every 120 seconds and restarts any that died. sre.sh watches the watcher: if the supervisor’s heartbeat goes stale for more than 15 minutes, SRE kills and restarts it.
Sweep kills any agent episode that runs past 1,800 seconds (2,700 for heavy roles). Headless processes get stuck. This is a net, not a vote of no confidence.
SRE is the on-call loop. Every 30 seconds it probes each live app’s health path through nginx, the real route and not the internal port. It also queries ClickHouse for error rate and latency over five minutes. Two consecutive health failures, 20 or more error events, or 12 or more slow events open an incident.
Then handle_incident() writes status/last-incident.json, dispatches the sre-ops agent, waits up to 50 minutes, and re-runs the four core gates. All pass: resolved. Otherwise the incident stays open, and SRE never stacks a second episode on top of it. The sre.md brief lists exactly what to check: docker compose ps, logs, chaos and drill override files, disk ballast. It is operational knowledge from real breakage, encoded in a document.
Autoscale is a thermostat. Every 60 seconds it reads the 3-minute rolling average of req and p95_ms per app. Scale up one replica (max three) if req ≥ 90/min or p95 ≥ 1200 ms for three ticks. Scale down one (min one) if req ≤ 15/min and p95 ≤ 2000 ms for ten ticks. Every decision lands in the journal with its numbers:
autoscale-decision action=scale-up from=1 to=2 req=3041 p95=1847At one replica, nginx points straight at 127.0.0.1:<port>. At two or more, scale.sh writes an upstream block and reloads nginx gracefully. A sync command re-discovers container IPs on every tick, because Docker reassigns them after restarts.
Ops loop runs the agent-owned queue: backups every six hours, CVE scans, upgrades, patches. One item at a time, three attempts, 180-second backoff, a monotonic cursor.
Chaos injects faults. Part 3 covers it.
Gates: the shared language of trust
engine/gates/probes.py holds twelve named probes. Each takes an app name, exits 0 or 1, and prints a one-line JSON evidence record. run_gates.sh appends the result to logs/gates-<app>.log and status/gates.jsonl. The pipeline, the SRE loop, the release scripts and the chaos monkey all read the same verdicts.
Three deserve a closer look.
smoke sends real requests, POSTs included, for every assertion in the contract. For Umami that means a real login at /api/auth/login. If an assertion has a contains check, the body must match. That is the difference between “the server answered” and “the application works.”
observability needs a log row and a metrics row. A bug taught us the window. The first version used 15 minutes, and idle apps failed their own gate. It now uses 24 hours and excludes engine heartbeats, so the machine cannot satisfy the gate with its own noise.
-- 1. ingestion: a real app log line, not an engine heartbeat
SELECT count() FROM otel_logs
WHERE ServiceName = '<app>'
AND LogAttributes['log.source'] != 'engine'
AND Timestamp > now() - INTERVAL 24 HOUR;
-- 2. sampler alive: a metrics row in the last 300 seconds
SELECT count() FROM chakra_app_metrics
WHERE app = '<app>' AND ts > now() - INTERVAL 300 SECOND;backup reads backup.json and checks that the file exists, restore_tested is true, and the last artifact is on disk. An agent cannot cheat it. Only backup.sh sets restore_tested, and only after a restore drill succeeds. The chain is closed.
Observability at birth
Every app’s logs reach ClickHouse from the moment it goes live. The stack is ClickHouse, HyperDX, MongoDB and an OpenTelemetry collector, run as a compose project in engine/observability/. The collector’s filelog receiver reads /var/lib/docker/containers/**/*-json.log and ships to otel_logs.
A sampler, engine/sampler.py, reads nginx access logs every 60 seconds. It computes request count, error count and p95 latency from $request_time, then inserts rows into chakra_app_metrics. The autoscaler and SRE loop query those rows. (A missing $request_time cost us a day of zero latency. Part 2 has the story.)
The dashboard, engine/dashboard.js, is a Node and express app. It serves a REST API over the JSONL files and SSE log streams straight from ClickHouse. The console is one page. Each app gets a drawer with live logs, gate history, releases, incidents with postmortem links, and its CVE story.
Releases: two modes
Pick by whether you can afford a blip.
Classic (release.sh) records the current image as previous, applies the new one, pulls, brings it up, runs wait_healthy(), then runs the four core gates. Pass: record it. Fail: revert, bring up, wait, re-gate. If the rollback fails too, alert. It is simple and it blips.
Blue-green (bgrelease.sh) starts the candidate beside the live container as <svc>-bg, with no published host port. The machine finds the candidate’s IP, waits for health on that IP, and runs the full smoke suite straight at it. Only a passing smoke run touches nginx.
The flip takes two steps: write a vhost that points the upstream at the candidate, then nginx -t && systemctl reload nginx. A probe sampling every 50 ms is already running against live nginx, writing <timestamp>|<http_code> pairs to a temp file. After the flip, the machine counts non-2xx samples inside the flip window. In the run: zero failed samples out of 256.
Before any of that, a downgrade guard rejects candidates built before the current image. It compares docker image inspect -f '{{.Created}}', because build labels are often missing upstream and .Created never is. A new build of an older version gets rejected. CHAKRA_ALLOW_DOWNGRADE=1 overrides it, but the intent has to be deliberate.
What we left out
- TLS. Nothing stops certbot from joining the ops loop. It is not there yet. Every URL is HTTP on a
nip.iohostname. - A real domain. It would give us HTTPS and survive IP reassignment. We discussed
iifelse.com. Neither exists in this run. - Vertical scaling.
ctl/chakra resize 8 64is built and tested up to the call Oracle refuses. Trial tenancies cap instance resizes at 4 OCPU, whatever the quota page says. A PAYG upgrade unblocks it. - Database-aware health checks. Umami’s
/api/heartbeatreturns{"ok":true}when the Node server is alive, whether or not Postgres is reachable. The chaos monkey found this. Part 3.
Each piece of this architecture is a few hundred lines of shell or Python. None of it is clever. What makes it work is the connections: agents produce artifacts, gates verify them, files remember.
Then we turned it on.
part 2 of 3
The run
The architecture is what you plan. The run is what you learn. Two days, one cloud box, 63 agent episodes, and twelve bugs we did not know we had.
Oracle said no
The box came up at 03:17Z on October 13: Oracle Cloud, Hyderabad, a VM.Standard.E5.Flex with 4 OCPU, 32 GB and a 150 GB boot volume, running Ubuntu 24.04. The plan called for 8 cores and 64 GB.
The quota page showed nine cores free. The API disagreed. Six cores and eight cores both returned LimitExceeded. Four was accepted. We bisected the cap (1 ✓, 4 ✓, 6 ✗, 8 ✗) and found the floor. A terminated boot volume from an earlier project, sutra-jira, was holding ghost E5 resources. We deleted it, logging first in DELETED_RESOURCES.log as the law requires, and went ahead on 4/32. The 8/64 path is documented as a one-command resize that waits on a PAYG upgrade.
A harder external risk remains: the free trial reclaims unpaid resources on October 29. Every report from this run flags that date. The machine cannot fix it.
With the box live, we pushed the engine, installed Docker, Node 22, nginx, tmux and ClickStack, and ran ctl/chakra ignite to start the loops. The dashboard appeared on port 8766 before the first app existed. Law 5 held.
Box up. 4 OCPU, 32 GB. Dashboard live within five minutes, before any app.
Umami, NocoDB, Uptime Kuma, Grafana and IT Tools go live. Umami passes 9 of 9 gates.
Four incidents: three drilled, one organic.
Operator reads the journal and finds the first bugs. Five missing capabilities get built and drilled.
First scheduled backup cycle runs, unattended, including a full rebuild drill.
Capture taken: 190 MB, 423 files. Box terminated.
The catalog lied. Recon caught it.
The Umami catalog entry came from the upstream README. The recon agent worked from the actual image and found that the README’s environment variable names did not match what the image consumed. The README listed DATABASE_URL. The image expected UMAMI_DB_PASSWORD and a separately generated app secret. The agent corrected the env spec, pulled the image, and recorded the exact digest: sha256:85909afc….
This is what the RECON phase is for. The catalog is a seed. Truth is what the running image accepts.
Without the correction, the deploy would have come up broken but quiet. The server starts regardless of env vars, so health checks pass while analytics silently fails. The smoke gate’s login POST would have caught it, and that is the right place to catch it: before traffic arrives, not after.
Five apps, 952 MB
Umami went live first: four smoke assertions including the login POST, a working external URL, a real log line in ClickHouse, 9 of 9 gates. NocoDB (192 MB resident), Uptime Kuma (106 MB), Grafana (46 MB) and IT Tools (30 MB) followed. All five ran together with room to spare. The containers used about 952 MB in total. ClickStack added roughly 3.5 GB.
Then the isolation proof. From inside the Umami container, the agent tried to reach the host SSH keys (~/.ssh), the OCI metadata endpoint (169.254.169.254) and docker.sock. All three attempts were denied, and the result sits in apps/umami/security-isolation.json. The law says to verify isolation by attempting the forbidden once. The agent attempted it.
Release drills found a rollback bug
We started the CI/CD drills on Grafana:
11.2.0 → 11.4.0: gates pass, kept.11.4.0 → 11.6.1: gates pass, kept.11.6.1 → 99.99.9-broken: tag not pullable. The script rolled back to11.6.1and re-ran the gates. They passed.release.jsonrecordsrollback_tested: true.
A second bad release, 0.0.0-nonexistent, found the bug. After the first rollback, release.json held the rollback itself as the current entry. The “previous” pointer now named 99.99.9-broken, a tag that does not exist. A second bad release would roll back to a broken tag and fail.
The fix: roll back to the last kept image, not the last recorded one. We re-ran the drill and it passed. That is why the law demands a rollback tested before anyone trusts it.
Uptime Kuma told a different story. A 1 → 2.5.6 upgrade crossed a major database migration. Kuma 2.x migrations are slow on first boot and the image’s default start_period is 180 seconds, so the service gate flapped. The agent tuned the health check to 2 seconds with 30 retries. The gates still failed, a known upstream instability across the 1.x to 2.x boundary, so auto-rollback fired and returned Kuma to 1.x. The patch note records the deferred upgrade with evidence. No operator touched it. That is the correct outcome: try, record, revert cleanly.
Four incidents
We drilled three incidents on purpose. The fourth found us.
1. Umami killed (04:38Z). docker compose stop umami. Two consecutive failed probes opened an incident in under two minutes. The sre-ops agent read the incident JSON (kind: health-fail, consecutive: 2), saw the stopped container, ran docker compose up -d, and re-ran the four gates. Resolved. It wrote a postmortem to apps/umami/postmortems/<ts>.md in the format the brief prescribes: signal, impact, root cause, fix, verification, prevention.
2. Broken DATABASE_URL (04:47Z). We injected a bad env override into the running container. The container kept running on pooled connections, but new requests failed in the app layer. /api/heartbeat still returned 200. The ClickHouse error-rate query caught it: 20 or more errors in five minutes. The agent found the override in docker inspect, removed it and restarted. The health gate alone would have missed this one.
3. Disk at 89% (04:58Z). drill.sh umami disk wrote an 80 GB ballast file. The disk check saw df / --output=pcent at 89%. The brief says to remove ballast if present. The agent found the file, removed it, and disk fell to 16%. The postmortem went to status/postmortems/, the box-level path rather than a per-app one.
4. Organic, during a scale test (05:03Z). Nobody drilled this. With two Umami replicas behind an nginx upstream, the SRE probe hit a transient failure during the reload that switches direct routing to upstream routing. For a moment nginx served the new config before the backend was reachable. The agent reverted to single-replica routing, the gates passed, and a postmortem was written. The lesson went into the autoscaler: scale sync now runs on every tick while an app is in upstream mode.
Twelve bugs in the machine
After day one, the operator read the journal. On paper the run looked complete: 9 of 9 gates, five apps live, incidents handled. The journal told a different story than the screenshots.
nginx logged no request time
Broke. Every vhost used the default combined log format, which omits $request_time. The sampler found no timing field and defaulted to zero. For a full day, every latency number read 0 ms, and every autoscale decision based on p95 ran on phantom data.
Fix. publish_nginx.sh now defines a named chakra log format that ends in $request_time, and every vhost uses it. Real latency appeared after one reload. The autoscaler’s first real decision came twenty minutes later.
The supervisor revival storm
Broke. Around 03:00Z on day two, the journal showed hundreds of pipeline-start events for apps that were already deployed. Over six hours pipeline.sh ran about 640 times. The old supervise.sh started a pipeline for any app with a contract.json and no running session. Finished apps exited fast, so apps spawned, finished and respawned in a loop. The supervisor also wedged on child processes that did not exit.
Fix. A rewrite. supervise.sh v2 spawns a pipeline only when an explicit redeploy.<app> marker exists. ./deploy creates the marker and the pipeline consumes it. Every external call is wrapped in timeout. A 10-minute per-app cooldown backs it up, so even broken logic cannot storm.
The autoscaler self-heal race
Broke. sync rewrote the nginx upstream block, and for a moment the block was empty: old IPs gone, new ones not yet written. A scale event in that window could return a 502.
Fix. scale sync never changes the replica count. It only updates IPs. Count changes go through scale.sh <app> N. The autoscaler serializes the two: sync first, then maybe a count change, never both at once.
The ops cursor race
Broke. During a retry (episode failed, backoff running), the retry logic updated the file pointer and a parallel tick read it. The cursor advanced past items nobody had processed.
Fix. The cursor is monotonic, and the write is guarded so it can only move forward:
if [ "$((CURSOR_N + 1))" -gt "$CURFILE" ]; then echo $((CURSOR_N + 1)) > "$CURSOR"; fiCVE scan duplicates
Broke. A second scan cycle six hours later appended the same CVEs again. The scout agent saw each one twice, both pending, and queued two patch requests.
Fix. Before enqueuing a patch request, the ops loop checks whether one for that app already sits in the queue or ran in the last six hours. If so, it skips.
pg_dump without --clean
Broke. The dump restored fine into an empty scratch container. But the rebuild drill destroys volumes, re-provisions with seeded default data, then applies the dump. The seed rows collided with the dump’s rows: primary key violations.
Fix. Add --clean --if-exists, so each CREATE TABLE is preceded by a DROP TABLE IF EXISTS. The rebuild drill passed on the next run.
pg_dump -U umami -d umami --no-owner --clean --if-existsThe HyperDX redirect
Broke. After login, HyperDX redirected to http://localhost:8080, the box’s loopback. A browser on the operator’s Mac could not reach it.
Fix. The image needs HYPERDX_APP_URL set to the base URL the browser uses: the bare IP, no port, because the image appends :8080 itself. We set it in the observability compose file and restarted the stack.
Episode identity collision
Broke. Dispatch named the tmux session and log file after the role alone. Two concurrent deploys both wanted agent-deployer, and the marker system read one episode’s completion as the other’s.
Fix. Every dispatch uses <app>-<role> as its identity: umami-deployer, grafana-deployer. Sessions, logs and marker waits all use the compound name.
Blue-green smoke skipped POSTs
Broke. The pre-flip smoke in bgrelease.sh supported only GET. The login POST assertion was silently skipped, so a candidate could pass smoke without proving anyone could log in, flip to production, and only then fail the post-flip gate.
Fix. The bgrelease smoke loop now mirrors probes.py::smoke() and reads method and body from the contract.
ClickHouse’s default user is localhost-only
Broke. Engine scripts reached ClickHouse over localhost:8123, which works from the box’s shell. The collector’s HTTP exporter also needed credentials and could not authenticate as default.
Fix. A chakra user in engine/observability/users.d.xml, mounted at startup, with network access enabled. Scripts and collector both use it. The default user stays untouched.
The chaos monkey injected nothing
Broke. INNER_PORT_OF, the container’s internal port, was used inside inject() before anything set it. The port_poison override came out malformed and Docker rejected it, so the fault never landed. The monkey picked faults, called inject, got a Docker error and marked everything inject-failed. It tested nothing.
Fix. Export INNER_PORT_OF from run_experiment() before it calls inject(). Port poison started poisoning ports.
Chaos graded healed apps as escaped
Broke. After the inject bug was fixed, some healed apps were still graded escaped. The observation loop checked quick_ok() and gates_ok() once. A container that was up but not yet returning 200 failed both.
Fix. A stabilization window. If the first check fails, wait 20 seconds and retry, up to three times. Only three failures in a row produce escaped. One transient failure during a restart is not an escape.
Five capabilities, drilled
After the fixes, the operator asked for five capabilities that had been designed but not built.
Agent-owned ops. The first scheduled backup cycle ran at 19:00Z with nobody watching. The librarian agent backed up both apps, ran restore drills and wrote notes to status/ops/backup-notes-<ts>.md. That included a full rebuild drill for Umami: destroy volumes, re-provision, restore from the dump, verify with gates. The backup gate requires restore_tested: true, and the only way to set it is to run the drill. The agent ran it.
CVE scanning with a real patch. The scout agent scanned grafana-oss:11.6.1 with Trivy: 9 CRITICAL and 134 HIGH. It did not stop at a report. It scanned the candidate versions too. 11.6.5 and 13.x carried more CVEs, and the agent documented that. grafana:12.4.12 had zero CRITICAL and 12 HIGH. The agent shipped it through the standard release gates, then rescanned to confirm. The patch note (apps/grafana/patches/20261013T082151Z.md) lists what the upgrade fixed: an OpenSSL heap overflow, two auth-bypass families (kin-openapi and a gRPC authz bypass), and the pgx driver.
Umami carried 2 CRITICAL and 7 HIGH, all in its Alpine base image, with no upstream fix. The agent logged it as a deferred gap. The machine records what it cannot patch.
Autoscaling. With real latency flowing, loadtest.sh umami load 3000 25 (3,000 requests a minute, 25 clients) pushed the rolling average past 90 req/min. After three ticks the autoscaler went from 1 to 2 replicas. Fifteen minutes later, 2 to 3. When load fell under 15 req/min for ten ticks, it went 3 to 2, then 2 to 1. Every decision carries its numbers in the journal.
Zero-downtime releases. We ran bgrelease.sh umami <digest> with a new pinned digest of the same image. Candidate health passed, smoke passed (login POST included), nginx flipped, the external check passed, canonical promoted. Zero failed probes out of 256. Then we tested the guard with an older build, ghcr.io/umami-software/umami:postgresql-v2.20.2:
CANDIDATE REJECTED (downgrade guard)The guard fired before the candidate started. The old release was never touched.
Resize tooling. ctl/chakra resize 8 64 works through the API and stops at Oracle’s LimitExceeded wall. That is an external constraint, not a machine bug. It is queued behind the PAYG upgrade.
The dashboard
Day one’s console worked but was sparse. By evening it had five bands:
- State. Loop status for supervise, sweep, sre, ops, autoscale, chaos and sampler.
- Now. Live agent activity: role, app, and an SSE tail of the episode log.
- Journal and pulse. The raw chronicle in real time, plus req/min, err/min and p95 across the fleet.
- Fleet. One card per app. Its drawer shows live ClickHouse logs, gate chips, a release timeline, incidents with postmortem links, and the CVE story.
- Chaos. The fault scorecard from Part 3.
The embedded file viewer denies .env files, *.sql.gz backups, auth.json and private-key patterns. The console runs on port 8766 with no authentication. It is built as a public dashboard, not a secrets browser.
Load and scale: the numbers
The numbers come from status/load.jsonl. loadtest.sh umami load 3000 25 drives engine/loadgen.py, a Python generator that sends requests through nginx for a fixed duration. The sampler captures req/s and p95 from the nginx log every 60 seconds. The generator captures them directly.
One replica handled 578.5 req/s at p95 28.2 ms with zero errors. Two replicas handled 905.5 req/s at p95 26.2 ms with zero errors. That is +56.6% throughput, not +100%, and p95 improved slightly.
Umami reads are stateless. Analytics queries hit Postgres through connection pooling, so a second replica needs no session affinity. The shortfall from 100% reflects nginx upstream overhead plus Postgres contention at high throughput.
What we were honest about
The run report does not hide failures. The supervisor ran 640 pipelines overnight before we fixed it. Latency read zero for a day. The first chaos experiments injected nothing. The cursor could race. The dump collided on rebuild.
All of it sits in the journal, timestamped, next to its fix. That is what “files are the only memory” means in practice. You do not get perfect observability. You get a machine that cannot lie about what it did, because everything it does, it records.
The gaps still open at close:
- October 29 trial reclaim. Unfixable without a PAYG upgrade.
- TLS. Not implemented. HTTP only.
- Umami base-image CVEs. No upstream fix. Documented and deferred.
- Shallow health checks. The chaos monkey found this one.
- Free-model rate-limit bursts. Handled by retry and rotation, but they slow everything down.
The machine deploys, watches, heals, updates, scans, patches, scales, backs up and proves all of it. It also found twelve bugs in itself and got fixed while running, without stopping and without losing the fleet.
Then night came, and we turned the chaos monkey loose.
part 3 of 3
The chaos
You do not know your system until something breaks it on purpose. This is the overnight scorecard, the one fault that found a real gap, and what the monkey taught us.
Chaos that is not a demo
Everyone agrees they should run chaos engineering. Almost nobody runs it honestly. The experiments are scheduled, announced, narrow in scope, and run during business hours while people watch. That is a demo.
We wanted something else. A process that runs continuously and unattended, all night. It throws real wrenches at a live fleet, grades the machine on whether it healed without help, and writes a postmortem whether the outcome was good or bad. It lives in engine/chaos.sh: 400 lines of bash.
Six rules so the monkey plays fair
A chaos tool that breaks things and cannot restore them is a liability. So the monkey follows six rules.
-
One experiment at a time. A lockfile,
status/chaos.lock, enforces it. A lock older than two hours counts as stale (a previous run probably died in cleanup) and is cleared. Stacking faults on a degraded system teaches nothing. -
Never inject into an open incident. If
incidents.jsonlshows any open app, chaos waits. The SRE loop is already working. A second fault would contaminate both experiments. -
Never inject while an agent runs.
agents_busy()counts liveagent-*tmux sessions. A backup or deploy in flight would make the failure’s cause ambiguous, and ambiguous failures teach nothing. -
Never inject within 20 minutes of a model rotation. Otherwise a rate-limited agent fails, chaos grades the run
escaped, and the machine takes the blame for an AI provider’s bad day.recent_rotation()readsstatus/rotation.jsonl. -
Every fault has a reverse path. If the machine has not healed in 30 minutes, chaos restores the fault itself, marks the run
escaped, and moves on. If chaos crashes mid-experiment, the lockfile keeps the experiment ID so an operator can see what was left unfinished. -
Fair grading for time-boxed faults.
pauselasts 90 seconds, then chaos unpauses regardless of whether SRE noticed. If SRE resolved it first, SRE gets the credit. If the app recovered from the unpause alone, the run is gradedhealed-blip.
The fault catalog
Two tiers. Tier 1 holds the common failures and gets picked more often.
| Fault | Action | What should happen |
|---|---|---|
kill |
docker compose stop <svc> |
SRE detects the downtime and dispatches a fix. |
pause |
docker pause <cid> |
Cgroup freeze. Requests time out, nothing crashes or logs. SRE detects it by HTTP probe. |
port_poison |
Override file remaps the host port to 3999 | Container stays healthy, nginx routes to a dead port. SRE detects it by probe. |
replica_kill |
Kills one replica (needs more than one) | Restart policy replaces it. Autoscaler sync fixes the upstream. |
Tier 2 holds structural tests and runs less often.
| Fault | Action | What should happen |
|---|---|---|
stop_db |
docker compose stop db |
App keeps running. Does it degrade gracefully? Can the health check see the outage? |
bad_release |
release.sh <app> image <base>:chaos-broken-0.0.0 |
Unpullable tag. The normal auto-rollback handles it. |
downgrade_guard |
bgrelease.sh <app> <older-version> |
The guard rejects it before the candidate starts. |
disk_pressure |
drill.sh umami disk |
80 GB ballast. Disk alert fires, sre-ops removes the file. |
The scorecard
The overnight run produced 18 graded experiments.
| Fault | n | Detected | Healed | Verdict | Notes |
|---|---|---|---|---|---|
pause |
5 | 75–96 s | 97–112 s | auto | 4 caught by SRE, 1 healed-blip |
kill |
3 | 46–61 s | 76–93 s | auto | Restart by SRE agent |
downgrade_guard |
5 | n/a | n/a | auto | Blocked, zero impact |
bad_release |
2 | n/a | 183 s | auto | Rollback path exercised |
stop_db |
2 | none | n/a | auto, then finding | No impact detected |
port_poison |
1 | 46 s | 349 s | auto | Agent found the override alone |
17 of 18 auto-healed (94%). One escaped, a grading timing quirk fixed by the stabilization window from Part 2. Zero failed.
Experiments, one by one
pause (5). The most common fault and the most reliable heal. In four runs, SRE filed the incident before chaos’s 90-second unpause. The agent read last-incident.json (health-fail), saw a paused container in docker compose ps, unpaused it, and re-ran the gates. The fifth run resolved on the timed unpause before the agent got there, so it was graded healed-blip. Detection around 80 seconds fits the design: a 30-second poll, two failures required, and up to 8 seconds of probe timeout.
kill (3). Detection took 46 to 61 seconds and healing 76 to 93, averaging 85 seconds from fault to green gates. Docker’s restart policy did not rescue it, because docker compose stop overrides the policy until someone starts the container again. The agent ran docker compose up -d, the gates passed, and postmortems were written.
downgrade_guard (5). Five attempts to release an older version through bgrelease.sh, across different upstreams and build-time offsets. The guard rejected all five before any candidate started. Zero impact, zero probe failures. The rejection record in status/releases.jsonl:
verdict=rejected-downgrade reason="downgrade guard: candidate built <older-ts> < current <newer-ts>"Blocking the candidate from starting is cleaner than starting it and rejecting it. A bad candidate that starts still burns resources and slows the release pipeline.
bad_release (2). The tag <base>:chaos-broken-0.0.0 cannot be pulled. release.sh failed at the pull and never reached verify_release(). It rolled back to the previous kept image, waited for health, and re-verified the gates. That took 183 seconds: about 90 for Docker’s pull timeout and about 90 for rollback and health-wait. release.json records rollback_tested: true. This ran against a live fleet with real traffic, not a staging environment.
port_poison (1). Detection took 46 seconds. Healing took 349, the longest in the run. The agent had to work from evidence. docker compose ps showed healthy running containers, which was confusing, because the container was fine and the port mapping was wrong. So it ran docker inspect, found the host port at 3999, hunted for the source, found docker-compose.chaos.yml, removed it, ran docker compose up -d, and verified with the gates.
The brief says to remove that file if present. It does not say why. The agent connected a wrong port binding to an override file on its own. Six minutes is slow next to a human SRE who has seen it before. The machine still got there, and still wrote the postmortem.
stop_db: the real finding
Two experiments. Both verdicted auto. Both recorded path=no-impact. Neither recorded a detection time, because no incident ever opened.
Stopping Umami’s database while Umami kept running raised no alert. The SRE probe on /api/heartbeat kept receiving {"ok":true}. The error-rate query showed no spike. Latency showed no degradation.
The heartbeat checks that the Node server is alive and listening. It never touches the database. When Postgres dies, pooled connections time out and new requests fail, but the HTTP server keeps answering the health check. A login would fail. A write would fail. The machine would not know.
To the monkey it looked like success: inject, observe, no degradation, no-impact. To an SRE it is a false negative. The measurement was honest about what it measured. What it measured was not enough.
The fix is a deeper check, a lightweight query where failure returns a 503:
SELECT 1 FROM umami_users LIMIT 1;We did not build it in this run. Umami does not expose a configurable health endpoint that touches the database. The workaround is a sidecar that runs the check and exposes a port, which adds moving parts. So the gap is declared, and the scorecard shows no-impact for a reason that reflects a limit in our health check, not strength in the system.
What 94% does and does not mean
The number is real: 17 of 18 experiments ended with the machine restoring the system without help. Read it carefully.
It means SRE detects stops and pauses reliably, around 80 seconds. Rollback works under pressure, chaos-injected bad releases included. The downgrade guard is airtight and has no side effects. The sre-ops agent can diagnose a novel fault from primitives.
It does not mean the system survives every failure mode. stop_db found a gap. It does not mean healing is fast: 349 seconds for port_poison is slow. And it does not mean the health checks are deep. They check liveness, not readiness.
The one escaped run was a finding too. The grader had no tolerance for brief instability during recovery. Real systems wobble while recovering. A grader that fails on the wobble produces false negatives. Hence the three-check window.
The dashboard’s Chaos tab shows one number: 94%, which is auto / total. We considered fancier metrics. MTTD, MTTR and fault coverage all sit in status/chaos.jsonl as raw data. But one number with a denominator (18 experiments, not one trial) is what you show someone who asks how resilient the system is. A 100% score on top of a shallow health check is worth less than 94% with an honest gap on the record.
How to read a postmortem
Every incident or notable finding gets an agent-written postmortem in apps/<app>/postmortems/. The brief enforces six sections:
- Signal. What fired, with the exact numbers from
last-incident.json. - Impact. What was down, for how long, with detect and heal timestamps.
- Root cause. Not “it crashed” but why, and by what mechanism.
- Fix. The exact commands run, with output.
- Verification. Gate output pasted verbatim.
- Prevention. What the machine should do differently. Agents propose here. They do not implement.
The port_poison postmortem proposed a line for sre.md: check for docker-compose.*.yml override files in the app directory, because chaos or drill scripts may have injected them. We added it. The next port_poison gets diagnosed faster.
That is the loop the machine was built to produce. Chaos finds a gap. An agent documents it. The brief updates. The next agent is faster.
How the loop picks a fault
In continuous mode, chaos sleeps a random 15 to 35 minutes between experiments. The randomness is the point: a fixed schedule lets people and systems pre-position for known windows.
Selection is weighted. kill, pause and port_poison carry weight 3. stop_db and bad_release carry 2. Everything else carries 1. Common failures get tested most, and structural tests run less often.
Faults are filtered per app. replica_kill needs more than one replica. stop_db needs a db: service in the compose file. downgrade_guard is hardcoded to Umami, the app with the most release history. disk_pressure needs more than 130 GB free, so chaos never fills a disk already near capacity. State lives in status/chaos-state.json, which the dashboard renders.
Three things the monkey taught us
1. The interesting failures live in the infrastructure. The journal found all twelve machine bugs from Part 2, not the monkey. The supervisor storm was an unexplained spike of pipeline-start events. The zero latency was implausibly clean numbers. The cursor race was a duplicate ops item. The monkey found one application-level gap. If you want to know where your system is broken, build the thing that records everything, then read what it wrote.
2. Agents are good at runbooks and bad at speed. The sre-ops agent diagnosed a port-poison override from first principles and wrote a postmortem that would pass review at any competent team. It took 349 seconds. A senior SRE who had seen it before would take 30.
The agent’s value is consistency. It runs the same diagnostic every time, always writes the postmortem, and never marks an incident resolved without green gates. At 3 a.m. a human might skip a step. The right frame is not “replace the on-call engineer.” It is an always-on first responder that escalates when it needs help and always does the paperwork.
3. Chaos is easier to agree to than to run fairly. Writing chaos.sh took about three hours. Running it correctly took two days and twelve bugs: the fair-play rules, the honest grading, the inject bug, the stabilization window. Anyone can kill a container. The hard part is grading. Did the machine heal it, or did you help? Did the health check see what matters, or only what it was told to look for?
The stop_db result is what honest grading looks like. We read the scorecard and asked whether no-impact was the right answer. It was not.
The next run
The box was terminated after teardown on October 14. The full capture is 190 MB across 423 files: the ClickHouse export of 101,028 log lines, every gate record and every postmortem, in captures/final-20261014T024539Z/. The box no longer exists. The capture is the run now.
The next run inherits:
- A machine with twelve bugs fixed, all found by operating a real fleet.
- A chaos monkey that is honest, fair, and has found its first real gap.
- Documented health-check improvements still to build.
- A path to 8 cores and 64 GB, one PAYG upgrade away.
- A harder application, with more state, more services and more failure modes.
- An ops team of one AI session on a Mac and thirty shell scripts on a $6-a-day box.
The machine is the product. The fleet it operates will change. The monkey will keep asking questions.
Appendix · full experiment log (18 rows)
| id | fault | app | t0 (Day 2) | mttd | mttr | path |
|---|---|---|---|---|---|---|
| 020341-pause-umami | pause | umami | 02:03 | 96 s | 97 s | sre-detected+healed |
| 023151-pause-grafana | pause | grafana | 02:31 | 75 s | 112 s | healed-blip |
| 031204-port_poison-grafana | port_poison | grafana | 03:12 | 46 s | 349 s | sre-detected+healed |
| 041822-kill-umami | kill | umami | 04:18 | 61 s | 93 s | sre-detected+healed |
| 050933-downgrade_guard-umami | downgrade_guard | umami | 05:09 | — | — | guard-verified |
| 054411-pause-umami | pause | umami | 05:44 | 88 s | 106 s | sre-detected+healed |
| 062700-stop_db-umami | stop_db | umami | 06:27 | — | — | no-impact |
| 065523-downgrade_guard-umami | downgrade_guard | umami | 06:55 | — | — | guard-verified |
| 073401-bad_release-grafana | bad_release | grafana | 07:34 | — | 183 s | rollback-path |
| 081155-pause-umami | pause | umami | 08:11 | 82 s | 108 s | sre-detected+healed |
| 084823-kill-grafana | kill | grafana | 08:48 | 52 s | 79 s | sre-detected+healed |
| 091234-downgrade_guard-umami | downgrade_guard | umami | 09:12 | — | — | guard-verified |
| 095601-stop_db-umami | stop_db | umami | 09:56 | — | — | no-impact |
| 102341-pause-grafana | pause | grafana | 10:23 | 79 s | 101 s | sre-detected+healed |
| 111004-downgrade_guard-umami | downgrade_guard | umami | 11:10 | — | — | guard-verified |
| 114823-bad_release-umami | bad_release | umami | 11:48 | — | 183 s | rollback-path |
| 121533-kill-umami | kill | umami | 12:15 | 46 s | 76 s | sre-detected+healed |
| 125041-downgrade_guard-umami | downgrade_guard | umami | 12:50 | — | — | guard-verified |
Timestamps come from status/chaos.jsonl in the final capture. mttd is time from inject to incident opened. mttr is time from inject to gates passing. A dash means not applicable for the fault type.