Runtime architecture
One page on how a scan actually runs: the lead/worker loop, the HITL gates,
what’s durable, and what --resume can and can’t recover. Code citations are
file.go:line in internal/agent unless noted.
Lead loop
Section titled “Lead loop”LeadLoop (lead_loop.go) drives Eino’s adk.TurnLoop for the lead agent.
Run/Resume are single-use on the library side, so LeadLoop recreates a
fresh adk.TurnLoop on every call, wired to the same checkpoint store and
run name (newTurnLoop); the LeadLoop object itself persists across that
swap and carries in-memory history plus the pending-interrupt correlation
map. There is no separate “TurnLoop” type in this repo — it is the vendored
eino/adk loop that LeadLoop owns and restarts.
A checkpoint is written whenever the loop pauses on an approval or decision
interrupt (fileCheckPointStore, checkpoint_store.go — one gob file per
run under .state/checkpoints/<run>.ckpt, atomic temp+rename, 32 MiB cap).
A clean finish_scan deletes it (adk.WithSkipCheckpoint()); otherwise it
survives for --resume.
Workers as tools
Section titled “Workers as tools”Workers are registered with the lead via adk.NewAgentTool (WorkerRegistry .Spawn, worker_registry.go), not spawned as background goroutines. A
worker only exists, and only counts as “active”, while the lead is blocked
inside the tool call that invokes it — finish_scan refuses while any such
call is in flight (activeChildren, wired to WorkerRegistry.InFlight).
Naming is the stable identity: the first worker of a role gets the bare role
name (recon), later ones get recon-2, recon-3, … (reserveNameLocked).
Names for a whole spawn_agents batch are reserved up front so a mid-batch
failure can’t leave half-registered names; lead is reserved from the start
so no worker can collide with it.
Parallel tool calls, serial lifecycle (adapter.go): every tool call in
one assistant message runs concurrently (ExecuteSequentially: false on the
Eino ToolsNode). The lifecycle tools
(record_finding, record_lead, confirm_finding, drop_lead,
record_impact, record_coverage, delete_finding, finish_scan, and a
worker’s agent_finish) are each wrapped in a mutex shared across one
NewChatAgent build (serialTool/serialLifecycleTools), so a batch of
lifecycle calls issued in one message still completes one at a time per
agent — a readability/ordering aid, not a correctness requirement, since
lifecycle.mu already makes each call atomic regardless of order.
Background workers (worker_registry.go Start): a lead call to a worker
(or pursue_finding) starts that worker on its own goroutine and runner and
returns at once. Finished results queue in the registry; the lead collects
them with wait_for_workers, which blocks until at least one worker finishes
and returns every result ready so far, so the lead acts on a fast worker while
a slow one is still running. The [RUN STATE] block shows running workers and
uncollected results; finish_scan is refused until both are empty. A worker
that hits an approval/decision parks on its own checkpoint (giving back its
concurrency slot) and resumes when the operator’s decision is routed to it
(ResolveDecision); with no operator connected it ends as
ErrWorkerNeedsOperator. Workers started by a worker stay synchronous. A run
that ends cancels and joins every worker (Shutdown). A worker running when
the process dies is not resumed on --resume; the lead calls it again, and
it continues from its persisted history. Linked todos (todo_id on the
worker spec) are set in_progress on start and done/blocked on finish by
the engine.
PARRIER_PROVIDER_CONCURRENCY (default 1) serializes outbound model
requests per provider, process-wide, to stay inside small plan concurrency
allowances. At 1, background workers overlap their tool execution but take
turns on model calls; raise it if your provider plan allows more in-flight
requests.
Streaming (PARRIER_STREAM, default on; 0 restores one blocking call per
reply): the gate asks the provider for a stream and concatenates the chunks
into the same message a blocking call returns, so guards, metering, history
and the full agent_message / agent_thought events are unchanged. While the
chunks arrive, their text is also sent as coalesced agent_message_delta /
agent_thought_delta events (see docs/EVENTS.md); the lead and reviewer
stream answers, workers stream only their reasoning. A stream that fails
mid-way emits agent_stream_reset and falls back to one blocking call. Deltas
trail the provider by up to one flush interval. The eino-ext OpenAI adapter
always asks for usage in the stream (stream_options.include_usage), so the
meter still counts streamed tokens; a provider that ignores the option leaves
them uncounted (PARRIER_STREAM=0 then restores exact metering). The
provider slot now spans the whole stream, not just the open: with
PARRIER_PROVIDER_CONCURRENCY=1 one agent’s reply finishes reading before the
next request starts.
Continuable history: WorkerAgent.history (worker_agent.go) survives
across separate invocations of the same worker-as-tool. Each Run prepends
the carried history (minus any stray System message) to the new input,
then refreshes it from the model gate’s settled transcript afterward. Calling
a worker by name a second time continues its own transcript — this is what
pursue_finding relies on to hand a finding back to the worker that already
touched it. This is distinct from the steer inbox (steerInbox,
worker_factory.go): mid-run operator steer text delivered into a running
worker’s own next model call, not a parent→worker invocation.
Lead tool partition (tools.Config.LeadPartition, leadDrop/maskLead in
internal/tools/build.go): under standard/deep effort the lead’s tool set has
every execution tool removed (exec_command, browser, http_request,
sessions, recon/probe/identity/caido-replay/captcha) — tools.Build constructs
the full set then filters it by a name table, so a worker’s build (any other
AgentName) is never affected. The lead keeps planning/consolidation tools
(todo, notes, record_finding, spawn_agents, validate_finding, …)
and must delegate every execution track to a spawned worker; prompt.go’s
systemPrompt and the run-start seed query both carry a partitioned variant
that names spawn_agents as the only path to testing. Lite effort leaves the
lead unpartitioned (spawn overhead dominates a quick scan). PARRIER_LEAD_PARTITION
(1/0) overrides the effort-based default either way; run.go emits a
control agent_message at startup stating which mode is active. In the TUI,
the depth setting is the switch: standard/deep hints carry a “lead delegates”
marker, the depth popup’s footer states the rule, and the running header shows
full auto / cov:<profile> badges for the non-default launch choices.
HITL: approval and decision
Section titled “HITL: approval and decision”Every lead and worker tool call is wrapped by ApprovalTool (approval.go),
which classifies the call by risk via a policy matrix (policy_matrix.go):
| Risk | Meaning |
|---|---|
L0 |
Auto-allowed. Most recon/probe/lifecycle tools, GET http_request. |
L1 |
Needs operator approval in supervised/manual mode. Write-ish tools: exec_command, proxy_repeat_request, session_start, session_send, identity_replay, compare_identities, validate_finding, recon_graphql, most probe_*. http_request/proxy_repeat_request escalate L0→L1 dynamically on POST/PUT/PATCH/DELETE. |
L2/L3 |
Exist in the type system for operator overrides; frida_attach/frida_spawn_hook/frida_enumerate ship as L2 (dynamic instrumentation). |
FORBIDDEN |
Always refused, never prompts — destructive shell patterns on exec_command (rm -rf /, mkfs, fork bombs, shutdown/reboot, …). |
PARRIER_APPROVAL_POLICY (JSON {"mode":...,"tools":{...}}) picks the mode.
Default is auto headless, supervised when PARRIER_INTERACTIVE=1.
The TUI defaults to full auto and lets the operator switch to interactive
for one engagement (/runmode, the run mode settings row’s [full auto] · interactive toggle, or ctrl+l): full auto
launches the child with PARRIER_INTERACTIVE=0 and
PARRIER_APPROVAL_POLICY={"mode":"auto"}, so no approvals or request_decision
prompts are produced; interactive launches with PARRIER_INTERACTIVE=1 and the
supervised default. The control pipe still supports pause/seize, steer,
stop_agent and extend in auto; only the HITL channel is off. The choice is per
launch and is not persisted. manual gates every non-L0 call; auto only
blocks FORBIDDEN.
request_decision (free-form HITL ask, not tied to a specific tool call) is
only added to the lead’s tool list when PARRIER_INTERACTIVE=1.
An approval/decision interrupt parks the adk.TurnLoop and checkpoints. The
request-id ↔ Eino-interrupt-id correlation needed to answer it after a cold
process restart lives in .state/pending_interrupts.json — this is the
“pending decision sidecar.” It is loaded unconditionally on LeadLoop
construction, independent of the current process’s PARRIER_INTERACTIVE
setting (see Migration below). Session-scoped “approve, don’t ask again this
run” decisions (decisionStore, approval.go) are memory-only in the
shipped wiring — they do not survive a process restart even though the store
type supports a JSON path.
Recall gates: leads, impact, coverage profile
Section titled “Recall gates: leads, impact, coverage profile”- Leads vs. confirmed:
record_leadfiles a finding withStatus=="lead"— it is excluded fromvulnerabilities.json/CSV/the executive report and tracked only inleads.jsonuntilconfirm_findingpromotes it (needs non-empty evidence) ordrop_leadrejects it. - Impact gate: a confirmed medium+ finding gets
ImpactStatusset tounprovenon confirm.record_impactresolves it toprovenornot_exploitable, both requiring evidence.pursue_findingautomates this: it hands the finding to the worker that owns it (or a freshvalidateworker) and asks it to callrecord_impact; a successful outcome also firesimpact_proven. - Coverage profile (
PARRIER_COVERAGE_PROFILE, defaultlight):lightis a no-op — no gate onfinish_scan, identical to pre-feature behavior.web-default,api-default,androideach name a subset of vulnerability classes; the gate requires at least onerecord_coveragerow (any outcome, includingnot_applicablewith evidence) for every surface already touched × every class the profile names. It is a coverage-row gate, not a depth or identity-matrix requirement — it does not by itself forcecompare_identitiesor probe-tool usage, only a recorded coverage entry per surface/class pair. Valid values are exactlylight,web-default,api-default,android(case-insensitive); anything else, including plausible-looking names likemobile, is a config error — useandroidfor mobile engagements. The TUI selects it per launch with thecoveragesettings row or/coverage [profile]; the child env is set explicitly, so a stray hostPARRIER_COVERAGE_PROFILEdoes not gate alightrun. - Reviewer gaps: the reviewer’s class-aware gap finder
(
canonicalVulnClasses,reviewer_eino.go) is the same class vocabulary the coverage profiles draw from.
Identity / recon / probe / validate / chain
Section titled “Identity / recon / probe / validate / chain”- Identity matrix (
internal/tools/identity.go):identity_add,identity_list(secrets never echoed),identity_replay(L1),compare_identities(L1) — replay one request as ≥2 stored identities and diff status/length/hash. The core authz/IDOR/BOLA check. - Recon (
internal/tools/recon.go):recon_crawl(L0, same-origin GET crawl),recon_js(L0, extract endpoint/secret-shaped strings from one JS file),recon_openapi(L0, fetch/parse an OpenAPI doc),recon_graphql(L1, the one write —__schemaintrospection POST). - Probes (
internal/tools/probe.go,probe_b.go):probe_sqli,probe_xss,probe_idor(tranche A, all L1);probe_ssrf,probe_upload,probe_jwt(L0, decode-only),probe_graphql(L1, introspection + at most one extra query),probe_race,probe_business_logic(L0, no-network manual-test checklist, not a scan or a verdict) (tranche B). All are deterministic detection/checklist tools, not exploit chains. - Validator (
internal/agent/validate.go):validate_finding, lead-only, L1 — one deterministic HTTP request reproducing a finding’s claim, records a transcript, never changes a finding’s status itself.confirm_findingis the actual status-changing tool (lifecycle_tools.go). - Chain planner (
internal/agent/chain.go):chain_propose, lead-only, L0, read-only, no network. Reasons over confirmed findings and open leads using a capability vocabulary —READ,WRITE,EXEC,SSRF,AUTHZ,CRED,INFO— either taken from a finding’s recordedCapabilitiesor conservatively inferred from title/description/CWE. Every proposed chain names the existing tools (required_tests) that would actually need to run to prove it;chain_proposeproves nothing by itself. - Browser (
internal/tools/browser.go,browser_session.go): thebrowsertool drivesagent-browserthrough one persistent per-run sandbox session (a broker container within.log/out, started withStartSession). Page state, cookies, localStorage and the daemon survive across separate tool calls.exec_command agent-browser ...is different: each exec call is a freshdocker run --rmcontainer, so multi-step browser state dies there; use thebrowsertool for flows.
Benchmark class metrics
Section titled “Benchmark class metrics”internal/bench/class.go adds class-level recall/precision/cost metrics on
top of the existing scoreboard, additively (old scoreboards load with zero
values). Per fixture run it computes lead count (from leads.json; leads
never count toward TP/FP/precision/recall), impact-eligible/impact-proven
counts and rate for medium+ confirmed findings, cost-per-confirmed, and a
per-class table (truth/matched/found/recall/precision) derived from each
fixture’s CWE or explicit class label. cmd/parrier-bench renders it as a
markdown table appended after the standard summary.
Durable vs. in-memory
Section titled “Durable vs. in-memory”Written under parrier_runs/<run-name>/:
| File | Contents |
|---|---|
run.json |
Run record: target, model, settings, agent roster, LLM usage totals. |
vulnerabilities.json / .csv |
Confirmed findings only. |
leads.json |
Open (unconfirmed) findings — audit trail, not a customer artifact. |
coverage.json |
Coverage rows. |
events.ndjson |
Append-only event log; resume validates it starts with run_started for this run id. |
penetration_test_report.md |
Executive report. |
Written under .state/ (resume/checkpoint plumbing):
| File | Contents |
|---|---|
checkpoints/<run>.ckpt |
Eino gob checkpoint at an approval/decision pause; deleted on clean finish. |
pending_interrupts.json |
Request-id ↔ interrupt-id correlation for in-flight approval/decision prompts. |
resume.json |
Objective, next-finding counter, budget/turns/coverage-profile settings for --resume. |
messages.json |
Pending operator instruction queue per agent. |
lead.history.json, <worker-name>.history.json |
Per-agent settled transcript, the write-ahead a resumed agent continues from. |
identities.json |
Stored test identities — kept out of the shared sandbox workspace deliberately. |
Every lifecycle-mutating tool call (record_finding, record_lead,
confirm_finding, record_impact, record_coverage, delete_finding,
drop_lead) persists to disk before the tool call returns, so there is no
meaningful in-memory-only window for findings/coverage. The run meter’s
running spend totals are in-memory between those persist points and are only
flushed into run.json at the same points — a crash between two persists can
lose at most a few turns of spend accounting, never a finding.
A worker invocation that is mid-flight when the process dies has no separate
durable state beyond its last completed turn in .state/<name>.history.json
— workers are tool calls, not background processes, so there is nothing
titled “an interrupted worker” to resume; the lead simply decides on resume
whether to call that worker again, and it continues from whatever history was
last flushed.
--resume and migration from an older run directory
Section titled “--resume and migration from an older run directory”--resume <run-dir> refuses a run that still looks live (pid + creation
token check) and refuses one already marked completed. Otherwise:
- No checkpoint for this run name — falls back to a fresh first turn
(
lead.Run, notlead.Resume) on top of whatever findings/coverage/history were restored from disk. This is the expected path for any run directory from before checkpointing existed, or one that finished its last turn cleanly without ever pausing on an interrupt. Not an error. - No
leads.json— treated as “no open leads,” not an error (same missing-file-is-empty handling asvulnerabilities.json/coverage.json). This is the expected path for a run directory from before the leads/impact recall work; it resumes with zero leads and all prior findings read as already-confirmed. - Coverage profile on resume —
.state/resume.jsonrestores thePARRIER_COVERAGE_PROFILEthe run started with; changing the environment variable before--resumedoes not change an in-progress run’s gate. To resume under a different profile, note that the gate only checks for the presence of coverage rows, so widening the profile after the fact may immediately report new gaps on the nextfinish_scanattempt — this is intended, not a bug. - Approval policy change across a restart — a pending approval/decision
interrupt resumes correctly against an operator’s answer regardless of
whether
PARRIER_APPROVAL_POLICY’s mode changed between the original run and the--resumeprocess, because.state/pending_interrupts.jsonis loaded and matched before the policy matrix’s current mode is consulted. What does matter is whether the resuming process has a control channel at all (opts.Stdin != nil, correlated with but not identical toPARRIER_INTERACTIVE=1): resuming headless against a run that’s sitting on a pending decision does not hang — it ends the run immediately with statusstopped, reasoninterrupted, exit code 3, and an explicit message that the decision never arrived before the control channel closed. Resume withparrier chat(or any--resumeinvocation that keeps stdin open and setsPARRIER_INTERACTIVE=1) to actually answer it. - A pending-interrupt sidecar from a run made before interactive mode
existed simply won’t exist —
.state/pending_interrupts.jsonis read as empty if missing, same missing-is-empty pattern as the artifact files.
Extend semantics
Section titled “Extend semantics”extend raises one worker’s runtime turn ceiling (gateModel.turnLimit) and/or
per-agent spend cap (meter.agentCaps) while the run is live. The turn check
happens after prepare increments the turn counter and before the provider call,
so an exhausted worker does not pay for one more request; a budget extension
bases on the greater of the current cap and what the worker already spent, so it
always buys at least the requested amount.
Limits: the control is runtime-only (not persisted; a restart forgets it), lead
is rejected, and Eino’s MaxIterations fixed at spawn remains an absolute
ceiling. Default workers use MaxInt32, so the runtime limit is the effective one;
a worker explicitly spawned with a lower child-turn cap cannot be extended past
that Eino limit without a rebuild. TUI alias: /extend-worker <agent> <turns> [budget]; the finished-run /extend <instruction> flow is separate.