Atlas incident investigation with Flow

A plan to run the Flow agent harness inside Atlas. Atlas gives the agent a set of deterministic, scrubbed tools. Central hands off an issue to Atlas and gets back a summary. Central never connects to a host.

Status page. Started 28 October 2026. The progress table in section 9 is the live tracker.

1. Problem

Atlas is the regional control plane. It already has dashboards and alerts in Insights. The data comes from Datum, which stores metrics and logs in ClickHouse. When an alert fires, an operator reads the charts, then connects to hosts over SSH to find the cause. This takes time, and the steps are similar each time.

Flow is the agent harness in the Frappe framework. It can run a model in a loop with tools, skills and a knowledge base. We want Flow to do the first part of an investigation.

There are three constraints:

2. Design: where the agent runs

We considered two options.

OptionHow it worksResult
A. Agent in Central, Atlas exposes raw read APIsCentral's agent calls many Atlas routes and reads raw output.Rejected. Central sees raw host data. Each new tool needs a new public route.
B. Agent in Atlas, Central hands off an issueEach region runs its own investigator. Central sends an issue and reads back a scrubbed summary.Chosen. Raw data stays in the region. The contract is two or three routes.

In option B, the Central agent uses the Atlas investigator like a subagent: it gives a task and gets a report back.

Boundaries. Raw output stays inside the region. Only the issue and a scrubbed summary cross to Central.

3. What Flow gives us today

Flow is in frappe/flow. A daemon (flow_harness) runs the agent loop for the bench. Frappe holds the configuration, the transcript and the HTTP API. We checked these facts in the code:

Gaps that affect this plan:

4. The tool set

Each tool is small and deterministic. The agent cannot send free SQL to the database or free shell to a host without a gate. Tools live in a new Atlas module, atlas/investigation/, grouped by subject. Every tool returns scrubbed text or JSON.

4.1 Inventory (read only)

ToolReturns
find_resourcesHosts, VMs and service VMs that match a name, IP, tenant or status.
get_hostMetal Server state, disks, metald version, recent actions.
get_virtual_machineVM state, host, tenant, network, recent actions and migrations.
list_recent_tasksRecent SSH Tasks, console logs and failed background jobs for a resource.
list_error_logsRecent Atlas Error Log rows, grouped by method.

4.2 Telemetry (read only)

ToolReturns
list_alert_checksThe checks in the existing Insights alerts (P1, P2 Hosts, P2 Platform, P3) and which ones fail now.
list_saved_queriesThe queries of the Atlas Insights workbook, with key and title.
run_saved_queryThe result of one workbook query, with an optional time range.
query_telemetryThe result of a SELECT on Datum. It connects as a read-only ClickHouse user (readonly=1), with a row limit and a time limit.
get_telemetry_freshnessThe time of the last metric and the last log line from each host. Old values mean that telemetry is blind for that host.

The saved queries come first. They are tested and fast. The skill tells the agent to use them before it writes its own SQL.

Telemetry first, host second

Vector already sends most logs to Datum. So the agent reads Datum first. It goes to a host only for data that Datum does not have.

DataIn Datum
metald journal (metal.service), all levelsYes
Other host journal lines, warning and above (includes metal-vm@<id> units)Yes
Service VM journal, warning and above; proxy nginx errorsYes
Host and VM metricsYes
firecracker.log; journal lines below warning; live state (processes, sockets, WireGuard, disk)No

The agent also goes to the host when get_telemetry_freshness shows old data. Then Vector or the network has failed, and Datum cannot show the problem.

4.3 Host and VM diagnostics (fixed commands)

These tools run a fixed script through SSH Task in background mode. Atlas connects to the host over SSH, not through the metald API, so the tools work when metald is down. Each run is a record, so there is an audit trail. The agent chooses only the target and the size.

ToolCommand on the host
get_firecracker_logtail -c of /var/lib/metal/machines/<id>/firecracker/<id>/root/firecracker.log
get_vm_unit_journaljournalctl -u metal-vm@<id>.service --since
get_metald_journaljournalctl -u metal.service --since. Only for hosts with stale telemetry; otherwise the agent reads this journal from Datum.
get_host_healthLoad, memory, disk, failed units, kernel messages (dmesg tail), WireGuard handshakes

The same scripts become buttons for operators. Fetch Firecracker Log and Fetch VM Journal go on Virtual Machine. Fetch metald Journal goes on Metal Server. This fills a gap: today no action fetches these logs.

4.4 Commands and actions (gated)

These tools exist only in the engineer agent (see section 5). The Central investigation agent does not have them.

ToolTargetGate
run_commandHost or tenant-0 VMApproval for each call.
run_tenant_vm_commandVM of a customer tenantApproval for each call. The prompt names the tenant.
run_actionMetal Server, Virtual Machine, service recordApproval for each call. Allow list of actions; termination is not in the list.

A third command tool, run_readonly_command, is in both agents. It needs no approval, because a parser refuses every command that is not on a read-only allow list (see section 5).

Commands run through the Metal Server Console, which already logs each run in Metal Server Console Log. Tenant-0 VMs are reached with the existing proxy command through the host network namespace.

5. Permission policy

Flow sets approval per tool, not per argument. So we split the tools by risk, and we use two agents with different tool sets. The model cannot change the policy, because it is fixed by which tools an agent has.

ActionCentral investigationEngineer in Atlas
Read inventory, telemetry, logs, docsAllowedAllowed
Read-only command on a host or tenant-0 VM (allow list)Allowed, loggedAllowed, logged
Other command on a host or tenant-0 VMNot availableEngineer approves
Any SSH to a VM of a customer tenantNot availableEngineer approves
Change actions (restart, stop, migrate, reboot, resize, firewall, upgrade)Not availableEngineer approves
terminate, archive_server, delete of any recordNot availableNot available

The read-only allow list is a parser, not a prompt. It splits the command on ;, &&, || and |. It refuses redirection, command substitution and backticks. Each part must start with an allowed program, for example journalctl, systemctl status, cat, tail, head, grep, ls, df, free, ss, ip, wg show, ps, top -b -n 1, uptime, dmesg. Reads of secret paths, such as /etc/shadow and private keys, are refused.

Central investigations run as a dedicated Atlas user with an Atlas Investigator role. Each read-only tool checks this role. Gated tools also require System Manager, so the investigator user cannot use them even if a session gets them by mistake. Engineer sessions run as the engineer, so the existing console logs and action records name the person who approved.

6. Scrubbing output

A scrubber is a function that replaces sensitive text with a fixed marker. It is deterministic: the same input always gives the same output, and no model is involved. It lives in one place, atlas/core/scrub.py, and every tool calls it on its return value.

It masks credentials only. IP addresses, host names, emails and record names stay, because they are needed to investigate. It replaces, in order:

  1. PEM blocks (private keys, certificates).
  2. Known token formats: JWT, Bearer values, cloud access keys, sk- API keys, GitHub tokens, WireGuard keys.
  3. Values of secret-like keys in key=value, key: value and JSON, for example password, secret, token, api_key.
  4. Credentials in URLs (user info and signed query strings).
  5. High-entropy words. A word of 20 or more characters from a base64 or hex alphabet, with Shannon entropy above a limit, becomes [REDACTED:entropy]. UUIDs and Atlas record names are kept, because the agent needs them.
password=hunter2 token: eyJhbGciOi...   →   password=[REDACTED] token: [REDACTED:jwt]

The Metal Server Console gets a Scrub Output check, on by default. With the check on, the stored output is scrubbed. An operator can turn it off for one run. Agent tools always scrub and cannot turn it off.

A second layer is possible: Flow's daemon has an extension point for a tool_call hook, with a redact_secrets example. We do not need it at first.

7. Central to Atlas handoff

A new DocType Atlas Investigation owns the state of one handoff. Fields: issue, context JSON, requested by, status (Queued, Running, Completed, Failed), Flow Session and summary. The run uses the read-only agent, so it never waits for approval.

Route (under /api/atlas)CallerDoes
POST /investigationsCentral, tenant 0 onlyCreates the record and starts a Flow run. Returns the ID.
GET /investigations/{id}CentralStatus, summary and the full transcript: each tool call, its arguments and its scrubbed result.

Atlas sends a webhook event on each status change, through the webhook that Central already configures. Central can also poll. Authentication uses the existing Central JWT and require_central_identity. No new token type is needed.

Central gets two Flow tools: start_region_investigation and get_region_investigation. Central gets the whole investigation, with credentials masked. If the cause needs a change, the summary says so. An Atlas engineer then does the change in the Atlas desk.

One investigation. There is no approval step, because the investigator has only read-only tools.

Knowledge and skill

An incident-investigation skill in atlas/skills/ gives the method: read the failing alert checks, run the saved queries, find the affected resources, read logs, form a hypothesis, check it, then report. It lists the tools to prefer at each step. A short report template sets the output: symptom, evidence, cause, confidence, and suggested next step.

The Atlas knowledge base uses openai/text-embedding-3-small through OpenRouter (0.02 USD per million tokens). It takes the Atlas docs/ folder, the module SPEC.md files and the incident postmortems. A second source takes Frappe Cloud platform docs. A setup command loads them, so a new region gets the same base.

8. Phases

Each phase has a check. A phase is done only when its check passes on atlas.localhost with the development region.

#PhaseDepends onCheck
0Flow daemon on the Atlas bench. OpenRouter provider and two models on atlas.localhost.Nonetest_connection passes for both models. A plain chat answers.
1Scrubber module and tests. Scrub Output check on the Metal Server Console.NoneTests with real secret shapes pass. A console run that prints a key stores [REDACTED].
2Log fetch scripts and buttons over SSH: Firecracker log, VM journal, metald journal.1Each button on a development host gives an SSH Task with scrubbed output.
3Read-only ClickHouse user on Datum. Read-only tools: inventory, telemetry, freshness, alert checks, saved queries.1Each tool runs from a Flow chat and returns scrubbed output. An INSERT through query_telemetry fails in ClickHouse.
4Read-only command parser and gated tools (run_command, run_tenant_vm_command, run_action).1, 2Parser tests pass. In an engineer session, a gated call pauses the run; Approve runs it, Deny stops it. terminate is refused.
5Investigator role and user. Two agents (investigator, engineer assistant), skill and knowledge base.3, 4The investigator finds the cause of a staged fault on a development VM (for example, a stopped metald or a full disk). It has no gated tool.
6Atlas Investigation DocType, two API routes and webhook event.5A curl call with a Central token starts a run and reads the summary and transcript.
7Central client methods and Flow tools.6Central's agent hands off an issue and shows the Atlas summary.
8Evaluation: replay the causes of past postmortems as staged faults. Record time to cause, tool calls and cost per model.7A table of measured results for both models. No targets yet.

Phases 1 to 4 are useful without the agent. The scrubber and the log buttons help operators today.

9. Progress

Updated 28 October 2026, night. All work is on the development region (atlas.localhost). Nothing is committed.

#PhaseStatusNotes
PlanSurvey of Flow, Atlas and CentralDoneThis page.
0Flow on Atlas bench, modelsDoneOpenRouter provider, DeepSeek V4.1 Flash and GLM 5.3 Flash. Embeddings: openai/text-embedding-3-small.
1Scrubber, console flagDoneatlas/core/scrub.py. It works line by line, so streamed console output stays stable. Scrub Output is on by default.
2Log fetch actionsDoneNew Diagnostics menu: Firecracker Log and VM Journal on a VM; metald Journal and Host Health on a host. Each is a scrubbed console log. Tested on a real host.
3Read-only toolsDone15 tools. A read-only ClickHouse user for Datum. The saved queries come from the workbook scripts, so Atlas does not need Insights.
4Gated tools, command parserDoneApproval pause, Approve and run tested. The investigator user cannot call a change tool.
5Agent, skill, knowledge baseDoneTwo agents, the incident-investigation skill, and 127 documents in the knowledge base.
6Investigation DocType and APIDonePOST and GET /api/atlas/investigations. Central polls; there is no webhook. Engineers save a chat with save_investigation.
7Central toolsDonestart_region_investigation and get_region_investigation. Tested from Central with a real token.
8EvaluationStartedTwo real findings (see below). No model comparison yet.

First real result

The first investigation used the P1 alert "waw-1 has an unavailable VM". The agent found that a VM on that host has been stuck since 14 October. Its Firecracker API no longer answers, but the process is still alive. Because of this, metald still sees the VM as running and does not restart it. The agent gave medium confidence and listed the next checks.

RunTool callsModel iterationsCostResult
First tryabout 11060 (limit)0.14 USDNo report: it kept exploring.
After the fix42250.016 USDFull report with evidence.

A second investigation started from Central, through the new API with a real Central token. It used the P2 alert "NIC errors on wg0". The agent found that the alert is false: the error counters did not grow. A manual check found the exact cause. The alert query groups the samples by labels but not by metric. Two metrics with the same labels then look like one counter that went from 0 to 3. This is a bug in the alert scripts, not in the agent. It is not fixed yet.

The fix had two parts. The instructions now give a budget of 30 tool calls. If a run reaches the iteration limit, Atlas asks once for the report.

Problems found and fixed on the way

Next

  1. Review the diff and split it into commits.
  2. Compare DeepSeek and GLM on the same problems.
  3. Decide whether Central needs its own agent, or only the two tools on its assistant.

10. Decisions

  1. Who can change things. Only an Atlas engineer, in an Atlas desk session, and only after approving the call. Central investigations never get gated tools.
  2. What Central receives. The whole investigation: summary and full transcript, with credentials masked.
  3. What the scrubber masks. Credentials only. IP addresses and host names stay.
  4. Read-only commands. Allowed without approval in both agents, through the allow-list parser.
  5. Embedding model. openai/text-embedding-3-small through OpenRouter.
  6. Telemetry access. A read-only ClickHouse user on Datum for query_telemetry.
  7. Log access. SSH from Atlas for data not in Datum. A metald log route can come later if needed.

Sources