R320 · Agent principles and patterns › Harness building blocks

Two graphs and a fail-open judge: the state model inside an autonomous security agent

Read the original

agent-stateknowledge-graphtool-gatingagent-securitymulti-agentverification

Source: the ARTEX repository (github.com/BaaRai/ARTEX) — README, docs/ARCHITECTURE.md, SECURITY.md, CHANGELOG.md, CONTRIBUTING.md and .github/workflows/ci.yml. AGPL-3.0. Every mechanism below is the documentation's own account, not confirmed against the Go source.

ARTEX is a self-hosted multi-agent offensive-security platform: a planner decomposes a goal, worker agents run real recon and exploitation tools, and findings accumulate until a goal is proven. The security application is not the interesting part. What is worth an engineer's attention is its answer to a problem every long-running agent system has and most solve badly — what the agents remember, and who is allowed to decide it — together with an unusually candid account of where its own safety controls stop.

The repository describes itself as a fork and English translation of an upstream Chinese project, whose engine it still runs. Its main branch is explicitly "not considered a stable release" and is "maintained on a best-effort basis". Read it as a design to learn from, not a dependency.

Two graphs, not one memory

The system splits durable state along the only axis that matters for an exploratory agent: what the world contains, versus what we have done to it.

Both are table families in one PostgreSQL database — two graphs in the logical sense, one store. A third table, exploration_anchors(node_id, asset_id), joins them, tying every intent, fact and finding back to the asset it concerned.

That anchor table is the move to steal. Because every attempt is anchored to a thing, coverage becomes a query rather than a judgement: which assets have had intents run against them, which produced facts, which produced nothing. An agent system without this equivalent has to ask a model whether it has finished, which is the least reliable way to find out.

The second structural decision is just as portable. Parent-child links and dedup keys in the asset graph are computed by the program; agents submit raw observations only. The identity of a thing is not a model's opinion. This is the same instinct as keeping idempotency keys out of generated code: the parts of state that must stay consistent across many writers do not belong to the writers.

Findings that carry their own proof — with the honest qualifier

Each finding records severity, class, confidence, asset references and a status workflow, and can be linked to a stored request/response snapshot from captured traffic. Capture comes from an MITM recording proxy (bound to 127.0.0.1 by default) or a browser extension that skips binary bodies and truncates at 256 KiB.

The README's wording is worth quoting precisely because it is weaker than how the design is usually described second-hand: "Every finding can carry the captured request and response that justify it." The link is optional and exists only where traffic was actually captured. The design intent — an artefact that is self-justifying, so a reviewer needs no replay to believe it — is right. The implementation is a can, and the gap between those two is exactly where a reader forms a false impression of how much evidence a system really holds.

A release note says "proof-basis gates, measured impact, adversarial verification and dedup rules decide what a finding must contain before it is reported". The documents do not say whether that adversarial verification is deterministic or a model judging a model, nor what the dedup key is. Treat both as unknown.

Three brakes, and what each is worth

The project's own pitch is "autonomy with brakes": human approval gates, scope rules, token and turn budgets, and a per-host noise governor. The documentation is specific enough to grade them, which is rarer than it should be.

Pre-dispatch scope checks. Scope is evaluated at add_intent and insert_assets — before an intent is dispatched or an asset inserted. Order is intercept first (a global blacklist of exact and fuzzy domains, IPs, URLs and CIDR ranges, with built-in blocks for .gov, .gov.cn, .edu, .edu.cn), then a per-task allow-list. Platform HTTP clients re-check at dial time against a fresh DNS lookup, which closes the classic rebinding window. Two honest limits: with a proxy in the path the pin is "name-only" and no IP binding is claimed; and the allow-list is optional.

That last point is the whole story, and SECURITY.md says it under the heading "Accepted gap": with no allow-list configured, "any host carried on an in-scope event that is not blocked enters the graph as an asset", and the upstream scanner's own scope verdict is trusted as-is. A default-deny control that defaults to absent is a default-allow control. Cross-checking the scanner's notion of scope against the platform's own is filed as "a deliberate design question".

A hook at the tool boundary. Shell tools pass through a PreToolUse hook combining a judge, an argv grammar, a target gate, pins and risk scoring, plus built-in deny rules for delete-style endpoint paths. The structural property is the one that matters: the check runs before the tool executes, so it is not advice the model can decline. Whether the target gate extracts hosts from arbitrary tool argv is not documented, and that is the load-bearing question for any argv-level gate.

A model judge that fails open. There is a "model fallback approval" path, and a changelog entry describes an unparseable verdict being "allowed per the model-failure policy (fail-open)". For a system whose actions are network attacks, a judge that admits what it cannot parse is the control most likely to be mistaken for a guarantee. The lesson generalises past security: any approval layer whose failure mode is "allow" should be documented as noise reduction, not enforcement. The noise governor has the same shape — a per-host token bucket with jitter, concurrency caps and 429/503 backoff, whose "default profile is strict passthrough".

The one control with no asterisk is plumbing: tool results are wrapped in a nonce-tagged untrusted-output boundary (an ADR of its own), disableable by environment variable.

Coordination by shared log, not by messages

One planner loop plus N worker goroutines per task, default three. Workers claim one intent, run tools through the guard hooks, write facts, assets and findings back, and stop. They never message each other. Cross-worker information flows through searches over other intents' execution traces — search_all_worker_traces(q), list_worker_traces, get_worker_trace.

That is a deliberate trade: no inbox, no protocol, no ordering problem, at the cost of discovery being a search the worker has to think to run. The planner is woken by graph changes behind a debounce, treats each wake-up as a fresh session, and most wake-ups dispatch zero intents — a "quiet mode" skips planning when the fingerprint of open goals has not changed. Writing the no-op as the common case is the right instinct for any event-driven planner; the usual failure is a loop that must produce an action because it was invoked.

The planner can also queue a course correction into a steerBox that the worker's PreToolUse hook drains on its next call. Mid-flight steering delivered through the same gate that enforces policy is a tidy reuse of one interception point. A changelog note that worker messages live only in memory with no crash recovery is the obvious counterweight.

Retest as a separate agent

A finding can be retested by starting an independent agent session — not by restarting the original task — optionally against a stated fixed version, with its own role, budget and limits. It concludes "Still reproducible", "Fixed" or "Cannot confirm", and a status only auto-advances to Fixed on a successful retest with that conclusion. Original evidence is preserved.

The three-valued conclusion is the detail to copy. "Cannot confirm" is the verdict most verification systems lack, and its absence is what turns an inconclusive check into a false green. The current gaps are named: retest history is not in report exports or task archives, and is not automatically linked to traffic captures.

Engineering shape

Go backend with roughly 270 HTTP routes, JWT and SSE; a Next.js 16 / React 19 frontend embedded via go:embed behind an embedui build tag, built CGO_ENABLED=0. PostgreSQL is required — the "one binary" framing covers the UI, not the datastore — with a separate SQLite traffic index. Secrets are sealed with AES-256-GCM with the AAD bound to table.column, and schema migrations are numbered and recorded with their SHA-256. Providers are Anthropic, OpenAI, OpenAI-responses and Ollama, with profile failover and per-intent rotation; Ollama support is listed as unreleased.

CI runs gofmt, build, vet, tests against Postgres 16, a race run on a package list, govulncheck, shellcheck, a TypeScript no-emit check and npm tests. Two caveats a reader should note rather than be told: one job is advisory (continue-on-error: true), and two tests that fail on unmodified upstream code are skipped under a tracked issue. Both are ordinary, and both mean the green badge covers less than it appears to.

The repository states that it is for systems you own or are explicitly authorised in writing to test, requires a terms-and-disclaimer consent step at login, keeps a demo mode that generates only labelled simulated records, and declares reports that it "can be used to attack systems" out of scope. Enforcement of that is policy and consent; the technical part is the optional allow-list discussed above.

What to take

  1. Split durable agent state by what exists versus what was tried, and join them with an anchor table so coverage is a query.

  2. Keep identity and dedup in program code. Agents submit observations; the system decides what is the same thing.

  3. Make findings carry their proof — and describe the result with the qualifier the implementation earns.

  4. Grade your own brakes by failure mode. A pre-dispatch check and a pre-execution hook enforce; an optional allow-list and a fail-open judge reduce noise. Say which is which in the documents.

  5. Let the planner return nothing. A fingerprint of open goals, a debounce, and zero dispatched actions as the normal outcome.

  6. Give verification a third verdict. "Cannot confirm" is what keeps an inconclusive check from reading as a pass.

Part of the Research notes on nowucca.com. Figures and claims are the source's own unless the summary says otherwise.