# Inside ARTEX: How an AI Hacker Thinks for Eight Hours Straight

ARTEX is not one AI hacker staring at a gigantic prompt. It is a small organization: a planner chooses where to look, parallel workers touch the target, PostgreSQL remembers what happened, and server code decides whether the evidence is real.

That separation is the entire trick. It is what lets ARTEX attempt work that usually breaks a single agent: an open-ended security campaign that runs for hours and is worthless unless it can prove its result.

Consider a deceptively simple task:

> Find and prove an exploitable vulnerability somewhere across these 40 endpoints.

Give it to one AI agent in a loop and the first few minutes may look excellent. It enumerates the surface, calls tools, reads results, and follows the loudest lead. Then the job gets longer than the agent's working memory.

By endpoint twenty, old turns are being summarized to make room. The exact request that made endpoint seven interesting becomes a paraphrase. A half-finished chain is buried under fresh output. The agent begins repeating work or tunnel-visioning on whatever remains most vivid in its context. And when it finally says, “I found SQL injection,” the proof may be a confident sentence rather than a reproducible receipt.

That is not necessarily a model failure. It is a **systems-design failure**.

One agent, one context window, one serial line of thought: that shape is excellent for bounded, interactive work. It is a poor fit for work that is long, open-ended, parallelizable, and worthless unless it proves its own result.

What makes ARTEX interesting is not that it can call security tools. Many agents can do that. The interesting part is the machinery around the model: durable shared state, disposable workers, event-driven planning, captured network evidence, and a verifier the model cannot simply talk past.

This article follows the machine from `./artex` to a verified report, then asks the more useful question: **what can any long-running agent system learn from it?**

> **Scope and safety:** this is an architectural study of public, open-source code. ARTEX has high capability and weak default containment. Use security tooling only on systems you own or are explicitly authorized to test.

## [1\. The eight-hour problem](https://github.com/jaiswalakshansh/curious/blob/main/artex/docs/00-overview.md)

Most agent harnesses have the same basic rhythm:

1. Put the goal in a prompt.
2. Let the model reason.
3. Let it call a tool.
4. Put the result back into the same context.
5. Repeat until the agent returns an answer.

This loop is elegant because all nuance stays in one place. But its memory is also its execution trace. Every scan result, dead end, error message, request, response, plan change, and tool output competes for space inside one finite window.

When that window fills, the harness has only a few choices: discard, summarize, or spill information somewhere else and hope the agent remembers to retrieve it. All three introduce a new failure mode. A summary can preserve the conclusion while losing the byte, parameter, or header that made the conclusion defensible.

Pentesting makes the weakness painfully visible because it combines four hard properties:

- **It is open-ended.** There is no fixed sequence that guarantees a result.
- **It branches.** One response can create several mechanistically different paths.
- **It benefits from real parallelism.** Reconnaissance, authentication, API behavior, and input handling can be explored independently.
- **It is evidence-bound.** “Probably vulnerable” is not a deliverable.

ARTEX treats those properties as architecture requirements. Its answer is not a longer system prompt. Its answer is to stop making one context own the whole job.

## [2\. The shape: an organization, not an individual](https://github.com/jaiswalakshansh/curious/blob/main/artex/docs/01-architecture-reference.md)

A single-loop harness is a brilliant individual holding the assignment in its head. ARTEX behaves more like an organization: it has strategy, operators, institutional memory, and an auditor.

![Two system shapes: a single-loop agent with one context window versus ARTEX with a planner, parallel workers, a PostgreSQL graph, and a server verifier](https://cdn.hashnode.com/uploads/covers/68754c3daa8fe2f8716fc53f/68e814a2-7851-4ac9-894b-52b1da9feb1b.png align="center")

Its four owners are deliberately separate:

| Job | Owner | What it is allowed to do |
| --- | --- | --- |
| **Plan** | Planner | Read the current situation and create exploration intents. It does not touch the target. |
| **Act** | Worker pool | Claim one intent, execute tools against the target, write discoveries back, then stop. |
| **Remember** | PostgreSQL graphs | Store assets, goals, intents, facts, findings, lineage, scope, and coverage outside any model context. |
| **Verify** | Server | Re-check captured evidence and decide whether a finding may prove a goal. |

This is a **blackboard multi-agent architecture**. The database is the shared board in the middle of the room. The planner writes directions to it. Workers take directions from it and add observations. The planner wakes when the board changes. The verifier refuses unsupported conclusions.

There is no master script saying, “run scanner A, then scanner B, then test endpoint C.” The next action is recomputed from the latest shared state. That matters: a credential discovered by one worker can change the next intent assigned to another without either worker having to merge a transcript back into one parent conversation.

The design principle is simple:

> If a job can outlive one context, the truth of the job cannot live only in that context.

## [3\. Before the first request: the architecture gives itself away](https://github.com/jaiswalakshansh/curious/blob/main/artex/docs/02-boot-and-launch.md)

Boot code sounds like plumbing. In ARTEX, it reveals the product's deepest assumptions before a single agent runs: the process may die, the campaign must survive; evidence must be captured by default; and an online service is not the same thing as an active attack.

ARTEX builds to a single Go binary with a Next.js/shadcn interface embedded using `go:embed`. PostgreSQL is the external state dependency. Running the product is therefore closer to launching a service than assembling a frontend, an API, and a collection of scripts.

![ARTEX boot sequence from the binary through configuration, schema migration, capture proxy, HTTP server, embedded UI, and dormant state](https://cdn.hashnode.com/uploads/covers/68754c3daa8fe2f8716fc53f/c720e550-a85c-4e87-b435-298dee096c5c.png align="center")

The startup path exposes several important design choices.

### The process is disposable; the state is not

`main()` maps the result of `run()` to a process exit code. A supervisor can use that code to relaunch the binary, including after a self-update. The engagement survives because goals, intents, facts, evidence references, and usage accounting live outside the process.

On every launch, ARTEX applies its schema and numbered migrations idempotently. An upgrade becomes: replace the binary, restart it, and let the service assert the database shape it expects. That is a practical detail, but it is also part of long-running autonomy: recovery cannot depend on someone manually reconstructing in-memory state.

### Port 8787 is the control plane

The HTTP service exposes the JSON API and the embedded interface with JWT authentication. Server-Sent Events feed live activity into the console. Tasks, sessions, findings, assets, coverage, traffic, settings, and human steering are different projections of the same underlying system—not separate sources of truth.

### Port 8788 is the evidence plane

Before any agent is allowed to work, ARTEX starts an embedded recording MITM proxy. Workers are later given proxy environment variables and the generated CA across common toolchains. HTTP traffic from `curl`, Python, Node, and other tools can therefore pass through one capture bus.

This ordering is the important bit: **evidence capture is a platform property, not a behavior the agent must remember.**

### Boot does not mean attack

After the database, proxy, API, and UI are live, the engine is dormant. No planner or worker goroutine exists until an operator creates a task. The daemon can be online while the attack engine remains asleep.

That clean boundary—service ready, engagement absent—is the first safety-relevant separation in the design.

## [4\. The heartbeat: plan → act → write back → wake](https://github.com/jaiswalakshansh/curious/blob/main/artex/docs/01-architecture-reference.md#2-the-shared-engine--the-blackboard-loop)

When a task begins, ARTEX starts one planner loop, a configurable pool of workers, and—in the hardened mainline—a janitor that recovers abandoned claims.

![The ARTEX feedback loop: graph change, debounced planner round, open intent frontier, atomic worker claim, tool execution through the capture proxy, and write-back](https://cdn.hashnode.com/uploads/covers/68754c3daa8fe2f8716fc53f/7a72e59a-a4a8-405d-827d-cee51ed50f8f.png align="center")

The loop has five important mechanics.

### 1\. Planning is event-driven, not constantly polling an LLM

The planner sleeps until the task is stopped, a graph change posts a notification, or a long heartbeat timer fires. When several workers finish close together, an **800 ms debounce** folds the notification burst into one planning round. Cheap programmatic guards run before any model call: paused, deleting, terminal, settling, or already complete.

So the LLM is not the scheduler. Go code owns lifecycle and wake-up policy; the model is invoked only for the judgment-heavy planning turn.

### 2\. The planner produces intents, not commands

An intent is a target-anchored direction such as “investigate this authentication boundary,” not a rigid list of shell steps. In the hardened fork, one planning round may add up to four high-value intents, each connected to target assets and parent reasoning nodes.

A hard invariant prevents a silent stall: **if a goal is still open and no work is in flight, the planner must emit at least one intent.** The model is free to choose the next direction, but it is not free to quietly end an unfinished task.

### 3\. Workers coordinate with one SQL predicate

Open intents form a frontier ordered by priority. Every worker tries to claim one with an atomic compare-and-set:

```sql
UPDATE exploration_nodes
SET state = 'running', owner = $1
WHERE id = $2 AND state = 'open';
```

If two workers race, only one update still sees `state='open'`. `RowsAffected() == 1` means the claim succeeded. No global lock and no central coordinator are needed.

The BaaRai mainline strengthens this with a heartbeat, lease, and fencing token. If a worker hangs or dies, the claim-sweep loop can return the intent to `open` without pretending it was completed.

### 4\. Completion has more than one meaning

A worker does not merely return “finished.” The engine distinguishes:

- `done`: the direction was covered;
- `exhausted`: the worker hit a time or turn budget while the direction may still be useful;
- `blocked`: an external failure prevented progress;
- `paused` or `stopped`: execution was interrupted.

These states are feedback for the next planning round. A covered path can be dropped. An exhausted path can be re-dispatched. A blocked path can wait for an environmental change.

### 5\. A write-back is the next planning event

Workers add assets, facts, findings, and traceable lineage to the graph as they discover them. When a worker terminates, `NotifyDone(intent)` wakes the planner. The board is richer, so the next plan can be different.

The loop is not `plan → execute → answer`. It is `plan → execute → change shared truth → plan again`.

## [5\. Input → proof: one engagement, end to end](https://github.com/jaiswalakshansh/curious/blob/main/artex/docs/03-input-to-findings-flow.md)

The architecture becomes easier to understand if we follow one objective all the way through the machine.

![Hero sequence diagram showing an ARTEX engagement from operator objective and goals agent through planner, graph, worker, capture proxy, server proof gates, and reporter](https://cdn.hashnode.com/uploads/covers/68754c3daa8fe2f8716fc53f/f66b0e3c-4b15-4877-86c4-e8c55ff78ee3.png align="center")

### Stage 1 — the operator supplies intent and scope

The input is free-form language plus an authorized target boundary: for example, a domain and an objective to find a demonstrably exploitable issue. Creating the task spawns the per-task planner, workers, and claim recovery machinery.

The operator owns the goal and the boundary. The engine owns the loop inside that boundary.

### Stage 2 — a goals agent converts prose into durable structure

Before attack planning, a dedicated goals agent calls structured tools:

- `set_goals` creates final-outcome nodes, not procedural steps;
- `set_constraints` stores allow/deny rules that are injected as high-priority red lines every round;
- scope registration starts deliberately narrow rather than silently widening a named subdomain to an entire root domain.

That last point is more than bookkeeping. Scope becomes the denominator for coverage later. If the denominator is vague, “we tested everything” can never be measured honestly.

### Stage 3 — the planner opens several different routes

The new goal nodes wake the planner. It reads a rendered overview of the graph and creates target-anchored intents. The prompt doctrine favors depth on a promising route while keeping a few **mechanistically different** routes in flight, reducing the chance that every worker repeats the same assumption.

An intent enters the graph as `open`. It is now durable work, not a thought that exists only in a model response.

### Stage 4 — one worker claims one intent

The pool races on the frontier; the database grants one claim. The selected worker receives a deliberately narrow mandate: complete this intent, write back discoveries, then stop.

Disposable workers are a feature. Each context stays focused. The shared graph—not a long-lived worker transcript—carries continuity across the campaign.

### Stage 5 — real tools run through the evidence bus

Workers may invoke the actual toolbox available to the installation: network discovery, HTTP enumeration, content discovery, request replay, database testing, custom scripts, or integrated tools. HTTP-capable traffic is routed through the recording proxy.

The worker can also search other workers' raw traces. That creates a shared sensorium: a hidden parameter, error string, or authentication clue observed elsewhere does not have to survive a lossy summary to become reusable.

### Stage 6 — “only what is in the graph counts”

Discoveries are written immediately:

- a host, service, or endpoint becomes an asset;
- an observation becomes a fact tied to its producing activity;
- a candidate vulnerability becomes a finding bound to captured traffic;
- edges record what spawned, yielded, derived, covered, or proved what.

This rule prevents an important class of ghost knowledge. If a detail exists only in one dying worker's context, the rest of the organization does not know it.

### Stage 7 — the planner re-plans from the changed world

The worker exits with a meaningful terminal state and wakes the planner. A new credential can create an authenticated route. A negative result can close one branch. A newly discovered endpoint expands the authorized surface ledger. The next intent is computed from current truth rather than a fixed playbook.

### Stage 8 — negative evidence counts too

The coverage ledger records outcomes such as `reported`, `no_issue_found`, `ruled_out`, or `needs_follow_up`. An absent finding is not automatically treated as a clean target. The planner can ask for untested assets and push toward untouched surface instead of circling the same exciting endpoint.

### Stage 9 — the server decides whether the goal is proved

When the planner calls `prove_goal`, program code checks the finding against live capture, response content, and provenance. Failure leaves the goal open. Success can mark the last goal met and cancel remaining work.

The model proposes closure. The host application grants it.

### Stage 10 — reporting and retesting are separate jobs

A reporter receives the finding, bound evidence, and execution trace and produces Markdown under a strict traceability rule. A retester can later classify the issue as reproduced, fixed, or inconclusive.

This is the complete division of labor:

> **Operator → goals → planner → intents → workers → captured traffic → graph write-back → server proof → report.**

## [6\. The memory: two graphs, not one giant prompt](https://github.com/jaiswalakshansh/curious/blob/main/artex/docs/01-architecture-reference.md#3-the-dual-graph-data-model--state-outside-the-context-window)

ARTEX's most reusable design decision is that memory lives in PostgreSQL, while the context window is treated as a temporary view over that memory.

![The global asset graph and per-task exploration graph connected by anchors and a coverage ledger](https://cdn.hashnode.com/uploads/covers/68754c3daa8fe2f8716fc53f/bd0b73ba-714b-4bd8-953c-da5bc115b871.png align="center")

### Graph A — the global asset map

The asset graph stores typed objects such as root domains, subdomains, IPs, services, applications, and endpoints. It is shared across tasks, so one engagement can enrich the inventory used by the next.

Agents submit raw observations; database constraints preserve order. Partial unique indexes and `ON CONFLICT` upserts deduplicate assets. Inserting a service or endpoint can cause its host hierarchy to materialize automatically. The model observes; the database maintains identity.

The trade-off is real: global memory improves continuity, but it also demands strong company and scope isolation when an installation serves multiple clients.

### Graph B — the per-task reasoning trail

The exploration graph stores nodes such as `goal`, `intent`, `fact`, `finding`, `hint`, and `digest`. Typed edges make the lineage readable:

- a goal **spawns** an intent;
- an intent **yields** a fact or finding;
- a fact is **derived from** the work that produced it;
- a finding **proves** a goal;
- a digest **covers** folded detail.

Node kinds have explicit state machines. That gives the planner more than a pile of notes—it gets a queryable model of open work, active work, completed work, failed work, and evidence lineage.

### Anchors connect reasoning to reality

An intent about “the upload chain” is abstract until it points to the concrete endpoint or service it concerns. `exploration_anchors(node_id, asset_id)` bridges the per-task reasoning graph to the global asset graph.

Those anchors also power coverage. Scope is the denominator; anchored, tested surface is the numerator. “Explore something we have not touched” becomes a database query instead of a suggestion in a prompt.

### Compaction shrinks the view, not the history

Long campaigns still cannot place the whole graph into every planner call. ARTEX identifies quiet branches and folds them into `digest` nodes. If a branch becomes relevant again, the planner can expand it.

This is different from ordinary context summarization. The digest is an index over retained structure; it is not the only surviving copy of the past. The working view stays bounded while the campaign history remains durable.

## [7\. The auditor: why a finding can earn trust](https://github.com/jaiswalakshansh/curious/blob/main/artex/docs/01-architecture-reference.md#4-evidence-binding--why-the-findings-are-true-not-merely-plausible)

Most agent demos spend their energy on tool use and almost none on the verdict. ARTEX's strongest idea is to treat **verification as a separate trust boundary**.

![Three fail-closed proof gates: host-matched live capture, proof level plus verbatim quote, and provenance](https://cdn.hashnode.com/uploads/covers/68754c3daa8fe2f8716fc53f/54871f70-99fd-4866-b1e7-87a1d6a60cd9.png align="center")

First, HTTP exchanges are recorded by the proxy. When a finding references traffic, host-owned code creates an immutable, content-addressed evidence snapshot. The agent supplies references and claims; it does not get to author the evidence body that will prove them.

Then `prove_goal` faces three server-side gates in the hardened mainline:

1. **Host-matched live capture.** The bound exchange must still exist and its host must match in-scope assets. Missing verification infrastructure fails closed.
2. **Verbatim receipt.** The finding needs a sufficiently strong Proof-of-Exploit level, and a meaningful evidence quote must appear verbatim in the actual response body. The server reads and gzip/deflate-decodes the response itself before comparing.
3. **Provenance.** Bytes that merely came back from the target are not automatically trustworthy evidence of the agent's conclusion. Target-authored material is demoted and cannot self-prove a goal.

If any gate fails, the goal remains open.

This design intentionally favors precision over recall. A real out-of-band, timing-only, or binary-response issue may not produce the clean quote these gates require and can be left `not_assessed`. That is not a free win; it is an explicit product choice: **better to miss an awkward-to-prove issue than confidently close a goal on a hallucinated one.**

The larger lesson is broader than security:

> Never let the component that proposes success be the only component that judges success.

For a coding agent, the auditor may be tests and a compiler. For a data agent, it may be schema checks and reconciled totals. For ARTEX, it is captured network traffic and deterministic proof gates.

## [8\. So why is this better than a harness?](https://github.com/jaiswalakshansh/curious/blob/main/artex/docs/04-harness-comparison.md)

Put the two designs side by side and the differences are structural, not cosmetic.

![Comparison of the four jobs collapsed into one harness context versus four owners in ARTEX](https://cdn.hashnode.com/uploads/covers/68754c3daa8fe2f8716fc53f/9a4d2357-e0db-43e9-82d4-f11a9e27231c.png align="center")

| Concern | Single-loop harness | ARTEX blackboard engine |
| --- | --- | --- |
| Memory | Context and summaries | Durable asset and exploration graphs |
| Planning and action | Interleaved in one actor | Planner decides; workers execute |
| Parallelism | One main loop; subagents report back | Workers write directly to shared state |
| Work claiming | Implicit in the next model turn | Explicit frontier plus atomic CAS |
| Completion | Inferred from the transcript | Typed terminal states and coverage |
| Verification | Agent assertion or human review | Server re-checks captured bytes |
| Recovery | Reconstruct the prior context | Reclaim intent; read state from the DB |
| Human control | Often permission-gated | Auto-execution by default; operator sets scope and brakes |

ARTEX wins when the task outlasts one context, needs several independent hands, must resume after failure, and requires a machine-checkable verdict.

But the harness wins in two important cases.

**First, bounded interactive work.** Coding, debugging, research, and “help me do this now” often benefit from one coherent conversation with a human steering every turn. A database-backed organization adds latency and loses some nuance when rich context is flattened into graph nodes.

**Second, engineering simplicity.** ARTEX is a Go service, PostgreSQL schema, agent SDK, proxy, evidence store, verification layer, UI, provider pool, and operational policy. That is a lot of machine to build and debug. If the task does not require durable state, true parallelism, or independent proof, the machinery is unnecessary.

The practical rule is:

> **Use a harness when the task fits one head and you want to stay in the loop. Build a blackboard when the task outlasts one context, needs many hands, and must prove its own result.**

## [9\. The trade-off triangle: trust, reach, or simplicity](https://github.com/jaiswalakshansh/curious/blob/main/artex/docs/06-three-forks-compared.md)

ARTEX is not one frozen design. Three related repositories share an ancestor but invest in different edges of the system, exposing the trade-offs that the clean architecture diagram hides.

![Fork tree from the upstream ARTEX engine to the BaaRai reliability and evidence fork and the artex-ymh reach and stealth fork](https://cdn.hashnode.com/uploads/covers/68754c3daa8fe2f8716fc53f/5b8e2e4f-7617-48b6-980e-a489ad9cd0de.png align="center")

### Upstream: make the loop legible

The original ARTEX is the clearest teacher. It contains the essential organism: planner, workers, dual graph, real tools, capture, and reactive write-back. Its simplicity exposes why the design works, but some guarantees still lean heavily on prompt discipline.

### BaaRai/ARTEX: make unattended results trustworthy

The mainline hardens the engine around failure and evidence: leases for worker claims, stronger proof gates, provider failover, budgets, a prompt-injection boundary, richer coverage, authenticated browser capture, and a larger skill library.

Every improvement carries a price. Strict evidence gates can reject valid but awkward findings. Provider rotation can create quality variance between intents. Budgets are useful only when configured. The injection boundary is a framing defense, not a type system.

### artex-ymh: extend reach and operational control

The internal-network fork focuses on external-to-internal handoff, topology, sessions, tunnels, pinned tooling, honeypot awareness, and rules-of-engagement modes.

That reach makes it the sharpest branch and the most sensitive one. More phases mean more state, more failure modes, and a larger blast radius if scope control is wrong.

The comparison reveals a general truth: **trust, reach, and simplicity pull in different directions.** Upstream is easiest to understand. The hardened mainline is easier to trust. The internal-network fork can go further. None gets the other two properties for free.

## [10\. The honest caveat: capability is high; containment is opt-in](https://github.com/jaiswalakshansh/curious/blob/main/artex/docs/06-three-forks-compared.md#12-safety--authorization-posture-the-big-one)

The uncomfortable part is also the most important part.

Workers run in a bypass-style permission mode: tools auto-execute without a person approving each command. The upstream authorization-scope guard was deliberately removed. Remaining controls are largely database rules or operator configuration, and several hardened guardrails are not safe-by-default.

That explains both the system's effectiveness and its risk. Autonomy without constant interruption is exactly what makes an eight-hour campaign possible. It is also what turns a scope mistake, prompt failure, or bad intent into a high-blast-radius event.

The forks respond differently:

- the BaaRai line adds an untrusted-data boundary, target gates, intercept rules, budgets, and operational controls, but several require explicit configuration;
- the ymh line reintroduces `off`, `warn`, and `strict` rules-of-engagement modes plus scope-expansion approval;
- none changes the operator's responsibility to define and enforce authorization.

So the rule is non-negotiable: **point the real system only at assets you own or have explicit permission to test.** Put scope enforcement outside the model, prefer fail-closed controls, set budgets, and treat the capture/evidence plane as sensitive data.

This caveat is not legal boilerplate after the interesting engineering. It is part of the architecture review. An autonomous system is defined as much by where it must stop as by how cleverly it continues.

## [11\. The takeaway: four ideas worth stealing](https://github.com/jaiswalakshansh/curious/blob/main/artex/docs/00-overview.md)

ARTEX is interesting because it turns a fragile long prompt into a durable operating system for a goal.

Four ideas generalize well beyond security:

1. **Externalize memory.** Let model context be a working view, not the canonical record.
2. **Parallelize hands, not truth.** Give workers narrow contexts, but make them write into one shared state model.
3. **Re-plan on state change.** Let discoveries change the next action instead of committing to one script at the start.
4. **Separate assertion from verification.** Let agents propose success; let deterministic systems grant it.

The deepest shift is organizational. A single-loop agent asks one mind to plan, act, remember, and grade itself. ARTEX assigns those jobs to different components and makes the database the meeting place.

That is why it can stay coherent when the task becomes too large, too long, or too consequential for one context window to hold.

---

**Read the complete code-grounded teardown:** [github.com/jaiswalakshansh/curious](https://github.com/jaiswalakshansh/curious/tree/main/artex)

The repository includes the boot path, architecture reference, full input-to-findings flow, harness comparison, UI walkthrough, three-fork comparison, and vendored source with `file:line` citations.
