# KeygraphHQ/shannon

> TypeScript web-app pentester on Temporal; fixed recon, analysis, exploit and report phases run by LLM agents using source code and a live URL.

- Category: [Open-source AI pentest and offensive-security agents](https://llms-technical-reviews.com/offensive-security-agents/)
- Repository: https://github.com/KeygraphHQ/shannon (reviewed at commit `b9744f6cecc5429333873b86a6762f1d70c54fc2`, 2026-10-27)
- Stars: 50938 · Language: TypeScript · License: AGPL-3.0
- Canonical page: https://llms-technical-reviews.com/p/shannon/

## Overview

Shannon is a white-box pentester for web applications. It needs two inputs: a running URL and the application's source repository. One command (`npx @keygraph/shannon start -u <url> -r <repo>`) starts a local Temporal server and a disposable worker container. Inside it, a fixed sequence of LLM agents reads the code, maps the live app in a browser, hunts for five OWASP-style vulnerability classes, tries to prove each candidate against the running target, and writes a report. The output is a workspace folder holding a Markdown and PDF report, `report.json`, and SARIF for exploit-mode runs.

Code orchestrates and the model works. The phases, the agents, which ones run in parallel, what each must deliver, retries and resume are all defined in a Temporal workflow. The LLM decides what to read, what to run in the shell and what to submit within each agent session. Agents run on the pi coding-agent harness (`@earendil-works/pi-coding-agent`) with one model for the whole scan, by default `anthropic:claude-sonnet-4-6`.

Its findings policy is strict: in exploit mode, a finding reaches the report only if an exploit agent marks it `exploited` (with impact, steps and evidence) or `blocked`. Its scope control for network targets, though, is prompt-only.

## Architecture

```mermaid
flowchart TD
  CLI["shannon CLI"] --> TMP["Temporal server (compose)"]
  CLI --> WRK["Worker container (docker run --rm)"]
  WRK --> WF["pentestPipeline workflow"]
  WF --> PRE["Preflight + auth validation"]
  WF --> PR["pre-recon (code)"]
  PR --> RC["recon (code + browser)"]
  RC --> V["5 vuln agents"]
  WF --> CAP["Capella SAST (optional child)"]
  V --> REC["Reconciliation per class"]
  CAP --> REC
  REC --> EX["Exploit agents + misc lane"]
  EX --> REP["Report agent -> report.json"]
  REP --> OUT["Markdown / PDF / SARIF renderer"]
```

| Component | Path | Role |
|---|---|---|
| CLI | `apps/cli/src/` | Setup wizard, `start`/`stop`, Temporal infra, worker container launch |
| Workflow | `apps/worker/src/temporal/workflows.ts` | Phase ordering, parallel class lanes, retries, resume, terminal status |
| Activities | `apps/worker/src/temporal/activities.ts` | Temporal activity wrappers for every agent and deterministic step |
| Agent registry | `apps/worker/src/session-manager.ts` | Agent names, prompt templates, deliverables, prerequisites, browser sessions |
| Agent execution | `apps/worker/src/services/agent-execution.ts` | Config, prompt, git checkpoint, pi session, validate, render, commit |
| pi executor | `apps/worker/src/ai/pi/` | Session creation, tool allowlist, `task` sub-agents, permission extension |
| Collectors | `apps/worker/src/collectors/` | Typed submit tools for recon, vuln queues, exploit verdicts, report findings |
| Reconciliation | `apps/worker/src/ai/reconciliation/` | Prepare, enrich, form, materialize and publish exploitation tasks per class |
| Capella | `apps/worker/src/ai/sast/capella/` | Optional agentic static analysis that feeds SARIF into reconciliation |
| Prompts | `apps/worker/prompts/` | Per-agent templates plus shared scope, rules and target partials |

## How a request flows

1. **Launch.** `spawnWorker` runs the worker image with `--rm` on the `shannon-net` network. It mounts the repository read-only, with writable overlays for `.shannon/deliverables`, the scratchpad and Playwright state, and drops Docker's seccomp profile so Chromium can sandbox itself ([docker.ts](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/cli/src/docker.ts#L424-L500)).
2. **Preflight.** The workflow runs `runPreflightChecks`: repository, config schema, `code_path` rules, a credential probe and target reachability ([preflight.ts](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/services/preflight.ts#L534-L579)). For Anthropic and OpenAI it also checks that the account is cleared for security workloads, so the scan does not fail halfway on a provider refusal ([cyber-access-verification.ts](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/services/cyber-access-verification.ts#L7-L17)).
3. **Auth validation.** If the config has an `authentication` block, a `validate-authentication` agent logs in with the browser to prove that the login flow works before any analysis spend.
4. **Recon.** `pre-recon` (code analysis) and `recon` run in sequence. Agentic SAST (Capella) starts alongside them as a Temporal child workflow when it is enabled ([workflows.ts](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/temporal/workflows.ts#L1344-L1442)).
5. **Class lanes.** Five lanes (injection, XSS, auth, authz, SSRF) run with at most five at once, and a miscellaneous exploit lane runs beside them. Each lane runs its vuln agent, waits for the Capella result, reconciles, checks the exploitation queue, and runs the exploit agent only if the queue is non-empty and exploit mode is on ([workflows.ts](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/temporal/workflows.ts#L746-L796)).
6. **One agent run.** `AgentExecutionService.execute` loads the config and prompt, takes a git checkpoint of the deliverables repo, runs `runPiPrompt` with a typed submit tool, then validates, renders and commits under a repo lock ([agent-execution.ts](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/services/agent-execution.ts#L192-L263)).
7. **Report.** The report agent fills a structured `report.json` through collector tools. A deterministic renderer turns it into Markdown, PDF (Typst) and SARIF. The run ends `completed`, or `partial` if any degradation reason was recorded.

## Key components

### Temporal workflow

`pentestPipeline` is the control plane. Activities get long timeouts and up to 50 attempts with 5- to 30-minute backoff. Configuration, credential, target and provider-refusal errors are marked non-retryable ([workflows.ts](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/temporal/workflows.ts#L92-L106)). Resume reads `session.json`, restores the git checkpoint and runs only incomplete agents. A cancel from the CLI aborts the in-flight pi session through the activity's cancellation signal.

### Agent harness

Every agent gets pi's built-in `read`, `bash`, `edit`, `write`, `grep`, `find` and `ls`. Browser agents also get a `playwright-cli` skill ([pi-executor.ts](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/ai/pi/pi-executor.ts#L59-L77)). Custom tools add `todo_write`, `glob`, a `task` tool for child sessions and the phase's submit tool. Sessions run in memory with pi's retry settings and context compaction ([pi-executor.ts](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/ai/pi/pi-executor.ts#L300-L353)). Child `task` sessions get only file tools and `bash`. They cannot spawn further children or submit structured output ([task-tool.ts](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/ai/pi/task-tool.ts#L44-L47)). Security tooling is whatever the model runs through `bash`, plus the browser.

### Findings: queues, reconciliation, verdicts

Vuln agents must call `submit_exploitation_queue`, which is validated against per-class TypeBox schemas. Reconciliation then merges producer observations, optional SAST provenance and a model-driven **task formation** pass that groups observations into exploitation tasks. Task formation runs with read-only tools and is always denied `.git`, `.shannon` and `.pi` ([task-formation-executor.ts](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/ai/pi/task-formation-executor.ts#L41-L44)). When the model's output is rejected in an accepted way, it falls back to one task per observation. Exploit agents return verdicts through a typed collector: `exploited` requires severity, impact, ordered reproduction steps and evidence, and `blocked` requires a confidence rating. The exploit prompt's rule is "Only EXPLOITED and BLOCKED_BY_SECURITY should be reported as findings" ([_exploit-scope.txt](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/prompts/shared/_exploit-scope.txt#L1-L18)). The verdict is still the exploit agent's own claim. No separate step replays it. With `exploit: false`, queue entries are rendered straight into findings files, so that mode reports unproven candidates.

### Scope and safety controls

- **Code scope is enforced.** `code_path` avoid rules become deny entries in the `pi-permission-system` extension. These block file tools and recognised shell file operations, including in child sessions ([permission-system.ts](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/ai/pi/permission-system.ts#L77-L127)).
- **Network scope is not.** The other rule types (`url_path`, `subdomain`, `domain`, `method`, `header`, `parameter`; see the [example config](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/configs/example-config.yaml#L60-L73)) and the free-text `rules_of_engagement` are rendered into prompts only. The exploit prompt confines testing to the target URL, forbids out-of-band callbacks and internal-network pivots, and asks for in-band proof. Nothing in the container or the tool layer blocks other hosts.
- **Preflight guards are one-shot.** The target URL check rejects link-local (cloud metadata) addresses and pins DNS for that check, but loopback and RFC 1918 targets are explicitly allowed ([preflight.ts](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/services/preflight.ts#L65-L79)). Agents' later traffic is not filtered.
- **Container posture.** The repository is read-only, the container is removed after the run, and provider keys come in as environment variables and are held in an in-memory credential store ([models.ts](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/ai/models.ts#L160-L170)). Against that, the worker runs with `seccomp=unconfined` for the whole container, and agents have unrestricted `bash`. There is no human approval step during a run.
- **Responsible-use framing.** The README warns that Shannon "actively executes exploits" and should run only against systems you own or are authorised to test, never production. That is guidance, not a control.

## Extending it

- **Prompts.** Templates in `apps/worker/prompts/` (per agent plus `shared/` partials) can be live-mounted from a source checkout.
- **Config.** YAML validated by a closed JSON Schema: `authentication` (form, SSO, API or basic login, TOTP, mailbox for magic links), `rules.avoid`/`rules.focus`, `rules_of_engagement`, `exploit`, `agentic_sast`, and report filters (`min_severity`, `min_confidence`, `guidance`, `sarif`).
- **Models.** `SHANNON_AI_MODEL=<provider>:<model>`. Anthropic, OpenAI, xAI and Bedrock are curated ([models.ts](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/ai/models.ts#L54-L84)). Any other pi-catalogue provider works through `SHANNON_AI_API_KEY`, and `--models-config` defines custom models or gateways.
- **New classes.** Adding one means a new agent entry, prompt templates, a queue schema, a reconciliation class and a workflow lane. The pipeline is not plugin-shaped.

## Running it

- Requirements are Docker, Node 18+ and a provider key. `npx @keygraph/shannon setup` stores credentials, and `start -u <url> -r <repo> [--config file]` runs a scan. `--validate-auth` and `--validate-model` run only those checks. `-w <name>` names a workspace and resumes it if it exists. `status`, `logs` and `stop` manage running scans.
- The CLI brings up Temporal through Docker Compose and launches one worker container per scan with its own task queue.
- Use it in CI with SARIF upload. Results stay in a local workspace (`workspaces/<host>_<session>/`), with internals under `.shannon/`.

## Strengths and caveats

- **Strength: deterministic orchestration.** Phase order, parallelism, retries and resume live in Temporal, not in a model's plan, so runs are reproducible in shape and survive crashes.
- **Strength: proof-oriented reporting.** In exploit mode, typed verdicts with required evidence and a deterministic renderer keep speculative findings out of the report.
- **Strength: source plus runtime.** Recon and analysis read the code, and the optional Capella SAST feeds SARIF provenance into exploitation tasks.
- **Caveat: network scope is honour-system.** URL and host avoid rules, rules of engagement and the in-band-only constraint are prompts. Enforce egress yourself if the target sits near anything sensitive.
- **Caveat: narrow coverage by design.** Exactly five classes plus a miscellaneous lane, web apps only, and a source repository is required.
- **Caveat: one model for everything, no spend cap.** Every agent, including task formation and Capella, uses the same model, and there is no budget limit. Long retry windows (up to 50 attempts) can stretch a failing run.
- **Caveat: AGPL-3.0.** Embedding Shannon in a hosted service carries copyleft obligations.

*Sources: code at b9744f6, verified Q&A.*

## How KeygraphHQ/shannon answers the Open-source AI pentest and offensive-security agents questions

### How is the agent loop and planning implemented? (answered)

Shannon uses a **multi-agent, single-model, phase-based** pipeline orchestrated by **Temporal workflows** (`apps/worker/src/temporal/workflows.ts`), not a dynamic model-driven loop. The `pentestPipeline` function runs five sequential phases: pre-recon, recon, vulnerability analysis (5 parallel agents: injection, xss, auth, authz, ssrf), exploitation (5 parallel agents + 1 miscellaneous), and reporting. Agents are defined declaratively in `apps/worker/src/session-manager.ts` with prompt templates, deliverables, and prerequisites — the workflow's explicit code structure enforces ordering and concurrency, not a model-authored plan. Each agent runs a single-turn-or-until-complete session via the **pi-coding-agent** harness (`apps/worker/src/ai/pi/pi-executor.ts:runPiPrompt`), which uses built-in tools (read, bash, edit, write, grep, find, ls) plus per-phase custom collectors. There is no iterative planning loop: the workflow calls activities (wrappers around `AgentExecutionService.execute()`) which handle the full lifecycle — load config, load prompt, git checkpoint, pi session, output validation, render deliverable, git commit (`apps/worker/src/services/agent-execution.ts:151-401`). Retry is owned by Temporal's activity retry policy: up to 50 attempts with exponential backoff (5 min initial, 30 min max) in production, with specific non-retryable error types (`apps/worker/src/temporal/workflows.ts:92-106`). Cancellation is handled via Temporal's cancellation scope with `WAIT_CANCELLATION_COMPLETED` for report operations, `TRY_CANCEL` for agents. Stop conditions: completed (all agents successful), partial (some degradation), failed (hard error), or cancelled (user-initiated). Capella (agentic SAST) runs as a Temporal child workflow overlapping the pentest, and its result is joined per-class before reconciliation. The miscellaneous exploitation lane runs concurrently with the five fixed classes. Resume is supported: detected via `session.json`, restoring git checkpoints and only running incomplete agents (`apps/worker/src/temporal/workflows.ts:1296-1342`).


Citations: [apps/worker/src/temporal/workflows.ts:361-381](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/temporal/workflows.ts#L361-L381) · [apps/worker/src/session-manager.ts:21-123](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/session-manager.ts#L21-L123) · [apps/worker/src/services/agent-execution.ts:151-276](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/services/agent-execution.ts#L151-L276) · [apps/worker/src/ai/pi/pi-executor.ts:233-476](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/ai/pi/pi-executor.ts#L233-L476) · [apps/worker/src/temporal/workflows.ts:1296-1342](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/temporal/workflows.ts#L1296-L1342)

### How are security tools integrated and executed? (answered)

Security tools are integrated through pi's **custom tool system** and the `tool` call mechanism from the pi-coding-agent harness. Every agent gets a standard set of built-in pi tools: `read`, `bash`, `edit`, `write`, `grep`, `find`, `ls` (`apps/worker/src/ai/pi/pi-executor.ts:60`). Three custom tools are added universally: `todo_write` (full-state-replace planning scratchpad for agent task tracking), `glob` (file pattern matching via zx's `globby`), and `task` (child-session delegation — spawns an independent sub-agent with its own tools for parallel sub-tasks, constrained to `CHILD_TOOLS = ['read', 'grep', 'find', 'ls', 'write', 'bash']` with no recursive task or collector tools) (`apps/worker/src/ai/pi/task-tool.ts:47`, `apps/worker/src/ai/pi/session-tools.ts:25-104`). Per-phase collector tools are injected by the activity: vulnerability agents get `submit_exploitation_queue` which captures structured findings via TypeBox validation (`apps/worker/src/ai/queue-schemas.ts:295-348`), plus `set_findings_summary`, `set_strategic_intelligence`, `set_safe_vectors`, and `set_blind_spots` for the analysis deliverable (`apps/worker/src/collectors/vuln-collector.ts:365-474`). Recon and pre-recon phases have their own collector tools with TypeBox schemas in their respective `apps/worker/src/collectors/` files. **Browser automation** is integrated for auth agents via the `playwright-cli` Skill (`apps/worker/src/ai/pi/pi-executor.ts:62-77`), injected only for browser-using agents (determined by `apps/worker/src/utils/browser-agents.ts`). Each agent is assigned to one of 6 isolated Playwright sessions via `PLAYWRIGHT_SESSION_MAPPING` to share browser state without interfering (`apps/worker/src/session-manager.ts:177-206`). **Bash commands** are bounded via a timeout extension (`BASH_TIMEOUT_EXTENSION_DIR`). Commands are built within the pi session environment; tools like `save-deliverable` and `generate-totp` are exposed as CLI scripts on the `PATH`. Output is parsed by the model as tool results, and structured payloads (exploitation queues, analysis sections) are captured via the collector tool's in-memory state before being written to disk by `AgentExecutionService`.


Citations: [apps/worker/src/ai/pi/pi-executor.ts:59-77](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/ai/pi/pi-executor.ts#L59-L77) · [apps/worker/src/ai/pi/task-tool.ts:44-48](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/ai/pi/task-tool.ts#L44-L48) · [apps/worker/src/ai/pi/session-tools.ts:25-104](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/ai/pi/session-tools.ts#L25-L104) · [apps/worker/src/ai/queue-schemas.ts:294-348](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/ai/queue-schemas.ts#L294-L348) · [apps/worker/src/collectors/vuln-collector.ts:364-474](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/collectors/vuln-collector.ts#L364-L474) · [apps/worker/src/session-manager.ts:177-206](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/session-manager.ts#L177-L206)

### How are scope, authorization and dangerous actions controlled? (answered)

Scope, authorization, and dangerous actions are controlled through **five layers of defense**:

**1. Preflight Validation** (`apps/worker/src/services/preflight.ts:534-579`): Five sequential checks run before any agent starts: repo path existence and type, config file validation against a closed JSON Schema (`additionalProperties: false`), code_path rules matching real filesystem entries, credential validation via a minimal pi session probe, and target URL reachability (DNS + HTTP HEAD with pinned lookup to prevent DNS rebinding). The target URL check includes a **link-local metadata blocklist** (`169.254.0.0/16`, `apps/worker/src/services/preflight.ts:67-79`) to prevent scanning cloud metadata services.

**2. Config-level Scoping** (`code_path` avoid/focus rules): The YAML config supports `rules.avoid` and `rules.focus` with type `code_path`, which are glob patterns scoped to the target repository. Avoid rules are enforced via the **`@gotgenes/pi-permission-system`** extension (`apps/worker/src/ai/pi/permission-system.ts`): each avoid pattern is translated into a cross-cutting `path` deny entry that blocks file access (`read/edit/write/grep/find/ls`) AND recognized bash file operations (`cat/grep/sed/…`) on matching paths, across every tool and child `task` session. `external_directory: allow` keeps legitimate access outside the mounted working directory unblocked (`apps/worker/src/ai/pi/permission-system.ts:78-93`). Config values are also sanitized against dangerous patterns (path traversal, HTML/JS/data/file URLs, `apps/worker/src/config-parser.ts:55-61`).

**3. Task Formation Boundaries** (`apps/worker/src/ai/pi/task-formation-executor.ts:43-44`): Always-denied paths (`.git`, `.shannon`, `.pi`) block access to git history, scan internals, and credentials. Task formation agents are confined to `read`, `grep`, `find`, `ls`, `glob`, `submit_result` tools only — no bash or write access.

**4. Container Isolation**: Each scan runs in an ephemeral `docker run --rm` container with a per-invocation task queue, ensuring repo isolation and preventing cross-scan interference. The target repo is mounted read-only where appropriate.

**5. Cancellation Signals**: Temporal cancellation signals are threaded through agent sessions (`apps/worker/src/ai/pi/pi-executor.ts:322-328`), allowing UI/CLI cancel to abort in-flight agent sessions rather than waiting for timeouts.

> **Editor's note.** Correction: only `code_path` avoid rules are enforced (via pi-permission-system); URL/subdomain/domain/method/header/parameter rules and rules_of_engagement are prompt text only, the 169.254/16 block applies just to the preflight target check, and the worker runs with seccomp=unconfined on an unfiltered bridge network.

Citations: [apps/worker/src/services/preflight.ts:534-579](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/services/preflight.ts#L534-L579) · [apps/worker/src/services/preflight.ts:67-79](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/services/preflight.ts#L67-L79) · [apps/worker/src/ai/pi/permission-system.ts:78-93](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/ai/pi/permission-system.ts#L78-L93) · [apps/worker/src/ai/pi/permission-system.ts:114-127](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/ai/pi/permission-system.ts#L114-L127) · [apps/worker/src/ai/pi/task-formation-executor.ts:38-44](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/ai/pi/task-formation-executor.ts#L38-L44) · [apps/worker/src/config-parser.ts:51-61](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/config-parser.ts#L51-L61)

### How are findings validated and reported? (answered)

Findings flow through a **deterministic pipeline with no LLM involvement in validation or deduplication**.

**Capture**: Vulnerability agents produce structured exploitation queues via the `submit_exploitation_queue` custom tool, which validates each entry against a TypeBox schema with per-class fields (injection, xss, auth, authz, ssrf, miscellaneous). The tool rejects out-of-namespace IDs and duplicate producer IDs before the data leaves the agent session (`apps/worker/src/ai/queue-schemas.ts:313-348`). Per-agent validators in `session-manager.ts` (`createVulnValidator`, `createExploitValidator`) check that the queue JSON file exists on disk.

**Reconciliation** (`apps/worker/src/temporal/workflows.ts:619-702`): After vuln analysis, each class undergoes a five-stage reconciliation pipeline: prepare (read durable producer observations), enrich (enrich observations with SAST provenance if available), form (Pass 1 model-based task formation — groups observations into exploitation tasks via a dedicated pi session; falls back to a singleton fallback when the model fails in an accepted way), materialize (merges enrichment into tasks), and publish (writes the reconciled queue as durable state). The form stage applies a `FORBIDDEN_MODEL_KEYS` blocklist to prevent internal IDs from leaking into published tasks (`apps/worker/src/ai/reconciliation/form.ts:46-54`).

**Confirmation**: Shannon does not use a second-agent review for confirmation. Instead, the exploitation phase runs a separate agent that independently attempts to exploit each finding from the reconciled queue. The exploitation agent produces `*_exploitation_evidence.md` files with proof-of-concept steps. The exploitation decision is based on whether the reconciled queue has vulnerabilities (`apps/worker/src/temporal/workflows.ts:776-778`).

**Report Assembly** (`apps/worker/src/services/reporting.ts`, `apps/worker/src/services/report-renderer.ts`): The report agent produces a structured `report.json`, which is then deterministically rendered (no LLM) into: Markdown (`Security-Assessment-Report.md`), PDF (via Typst from `apps/worker/templates/typst/report.typ`), and SARIF 2.1.0 (`report.sarif`, exploit runs only). Degradation is tracked via closed `PartialReasonCode`s (`apps/worker/src/types/run-state.ts:30-39`). When `exploit=false`, the findings renderer (`apps/worker/src/services/findings-renderer.ts`) deterministically converts each `*_exploitation_queue.json` into `*_findings.md` with no LLM in the loop. The final status is `partial` if any partial reasons were recorded, `completed` otherwise.

> **Editor's note.** Correction: validation is not LLM-free — reconciliation's form stage is a model-driven task-formation session that groups (de-duplicates) observations into exploitation tasks, and an `exploited` verdict is the exploit agent's own schema-validated claim with no independent replay; only the final report rendering is deterministic.

Citations: [apps/worker/src/ai/queue-schemas.ts:294-348](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/ai/queue-schemas.ts#L294-L348) · [apps/worker/src/temporal/workflows.ts:619-702](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/temporal/workflows.ts#L619-L702) · [apps/worker/src/ai/reconciliation/form.ts:38-54](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/ai/reconciliation/form.ts#L38-L54) · [apps/worker/src/services/report-renderer.ts:1-99](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/services/report-renderer.ts#L1-L99) · [apps/worker/src/services/findings-renderer.ts:1-38](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/services/findings-renderer.ts#L1-L38) · [apps/worker/src/types/run-state.ts:28-39](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/types/run-state.ts#L28-L39)

### How is engagement state and knowledge kept across a long run? (answered)

Engagement state is persisted through a **file-based audit and checkpoint system**, not an in-memory knowledge graph or database.

**Run Directory Structure**: Each scan writes to a workspace directory (`workspaces/{hostname}_{sessionId}/`). The top level holds the customer-facing report (PDF and Markdown); all internals — checkpoints, logs, prompts, agent deliverables, `session.json`, browser artifacts — live under a hidden `.shannon/` subdirectory (`apps/worker/src/audit/utils.ts:52-54`).

**Session State**: `session.json` records the canonical workflow state including completed agents, expected agents, participating classes, report progress (stage, partial reasons, model checkpoint), and the miscellaneous exploitation outcome (`apps/worker/src/audit/utils.ts:59-62`). This is the file resume reads to determine which agents to skip.

**Workflow Logger** (`apps/worker/src/audit/workflow-logger.ts`): A combined `workflow.log` provides human-readable per-workflow logs backed by `LogStream` (`apps/worker/src/audit/log-stream.ts`). Every combined-log line is also projected into per-agent files under `.shannon/agents/<slug>.log` via `actor-projection.ts`. Capella stages get their own per-stage trace queues drained before the activity returns.

**Git Checkpoints**: After each agent completes successfully, its deliverable is git-committed to a deliverables repo within the workspace. On resume, the workflow restores the git checkpoint, removes incomplete agent deliverables, and only re-routes missing agents (`apps/worker/src/temporal/workflows.ts:1318-1342`). Rollback is handled by `rollbackGitWorkspace` in `apps/worker/src/services/agent-execution.ts:410-415`.

**Reconciliation Artifact Store** (`apps/worker/src/ai/reconciliation/artifact-store.ts`): A file-based store for reconciliation observations and tasks, referenced by opaque artifact refs passed between reconciliation stages. Each stage (prepare, enrich, form, materialize, publish) writes its output as a durable artifact.

**No summarization or compaction of long sessions** beyond pi's built-in **context compaction** (`compaction: { enabled: true }` in `apps/worker/src/ai/pi/pi-executor.ts:344`), which compresses the transcript when it approaches the context window. There is no knowledge graph, semantic memory store, or cross-session learning. Each task `child session` accumulates its usage separately; the parent totals its own plus child spend.


Citations: [apps/worker/src/audit/utils.ts:42-80](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/audit/utils.ts#L42-L80) · [apps/worker/src/temporal/workflows.ts:1296-1342](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/temporal/workflows.ts#L1296-L1342) · [apps/worker/src/services/agent-execution.ts:295-340](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/services/agent-execution.ts#L295-L340) · [apps/worker/src/ai/pi/pi-executor.ts:332-346](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/ai/pi/pi-executor.ts#L332-L346) · [apps/worker/src/temporal/workflows.ts:480-504](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/temporal/workflows.ts#L480-L504)

### Which models are supported and how are cost and context managed? (answered)

**One model runs the entire workflow**, set via `SHANNON_AI_MODEL=<provider>:<model-id>`, defaulting to `anthropic:claude-sonnet-4-6` (`apps/worker/src/ai/models.ts:84`). There is no per-role or per-phase model selection — every agent (pre-recon, recon, 5 vuln agents, 5+1 exploit agents, report agent) and the Capella SAST child workflow use the same model.

**Supported Providers**: Four curated providers with dedicated credential variables — `anthropic` (`ANTHROPIC_API_KEY`), `openai` (`OPENAI_API_KEY`), `xai` (`XAI_API_KEY`), `amazon-bedrock` (`AWS_BEARER_TOKEN_BEDROCK` + `AWS_REGION`). Any other pi-ai provider ID works via the generic `SHANNON_AI_API_KEY` env var. Bedrock is the only exception — it authenticates through AWS_ variables, not the generic key (`apps/worker/src/ai/models.ts:54-81`).

**Model Resolution**: Resolution happens at scan start via `resolveModelSelection()` (`apps/worker/src/ai/models.ts:285-313`), which parses the spec (splitting on the **first** colon only to preserve Bedrock IDs), collects credentials from env vars, creates a `ModelRuntime` via pi with network catalogue refresh (10s timeout, falls back to static), and looks up the model. A `--models-config` file overlays custom model definitions onto pi's catalogue via `models.json`. Custom definitions and the generic `SHANNON_AI_BASE_URL` for endpoint overrides are both supported. Credentials stay in an in-memory `RuntimeCredentialStore` — never written to disk (`apps/worker/src/ai/models.ts:163-195`). Pi auth.json reuse is supported via `SHANNON_USE_PI_AUTH=1`.

**Thinking Level**: Set to `'high'` globally (`apps/worker/src/ai/pi/thinking-level.ts`), passed to every `createAgentSession` call for deeper analysis than pi's default (`medium`). The preflight credential probe and structured generation calls run without reasoning.

**Cost and Context Management**: pi's **context compaction** is enabled (`compaction: { enabled: true }`, `apps/worker/src/ai/pi/pi-executor.ts:344`) to guard against context window overflow on long agent runs. Usage (tokens, cost, cache hits) is tracked per agent and aggregated into `OperationalMetrics` for the final summary (`apps/worker/src/temporal/workflows.ts:313-325`). The `task` child-session tool accumulates its own usage and reports it back to the parent for accurate total spend (`apps/worker/src/ai/pi/task-tool.ts:183-191`). There is no user-configurable token or cost budget — the only cost control is Temporal's activity retry and the pipeline's stop conditions. pi's retry settings absorb provider-level transport faults (`apps/worker/src/ai/pi/retry-settings.ts`).


Citations: [apps/worker/src/ai/models.ts:54-84](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/ai/models.ts#L54-L84) · [apps/worker/src/ai/models.ts:99-123](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/ai/models.ts#L99-L123) · [apps/worker/src/ai/models.ts:137-154](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/ai/models.ts#L137-L154) · [apps/worker/src/ai/models.ts:238-313](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/ai/models.ts#L238-L313) · [apps/worker/src/ai/pi/pi-executor.ts:332-346](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/ai/pi/pi-executor.ts#L332-L346) · [apps/worker/src/ai/pi/task-tool.ts:183-191](https://github.com/KeygraphHQ/shannon/blob/b9744f6cecc5429333873b86a6762f1d70c54fc2/apps/worker/src/ai/pi/task-tool.ts#L183-L191)
