# codexstar69/bug-hunter architecture

> Architecture diagram of the GitHub repository codexstar69/bug-hunter, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/codexstar69/bug-hunter
- Repository: https://github.com/codexstar69/bug-hunter

## Overview

Bug Hunter is an AI-agent skill for evidence-backed code auditing, with scan-only, single-pass behavior by default. The documented workflow triages risk, plans and retrieves bounded context, runs adversarial review, validates findings, and reports results; optional branches cover verification, benchmark measurement, and approved fixes. The runner’s dependencies are supported by the SOURCE INDEX, while some stage links are documented only in the README. Unsampled subsystems are represented by their exact paths from the tree; their internal calls are not inferred.

Main entry points: [`scripts/run-bug-hunter.cjs`](https://github.com/codexstar69/bug-hunter/blob/main/scripts/run-bug-hunter.cjs) (Audit runner), [`scripts/schema-runtime.cjs`](https://github.com/codexstar69/bug-hunter/blob/main/scripts/schema-runtime.cjs) (Schema validation), [`scripts/bug-hunter-state.cjs`](https://github.com/codexstar69/bug-hunter/blob/main/scripts/bug-hunter-state.cjs) (Audit state), [`scripts/triage.cjs`](https://github.com/codexstar69/bug-hunter/blob/main/scripts/triage.cjs) (Risk triage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Run orchestration"]
  node_runner["Audit runner<br/>[run-bug-hunter.cjs]"]
  node_triage["Risk triage<br/>[triage.cjs]"]
  node_adaptive["Adaptive profiles"]
  node_scheduler["Chunk scheduler"]
  node_worktree["Source harvesting"]
end

subgraph group_analysis["Audit analysis"]
  node_indexing["Architecture recon<br/>[code-index.cjs]"]
  node_retrieval["Hypothesis retrieval"]
  node_hunter["Hunter findings<br/>[run-bug-hunter.cjs]"]
  node_docs["Documentation checks<br/>[doc-lookup.cjs]"]
  node_skeptic["Skeptic challenges<br/>[run-bug-hunter.cjs]"]
  node_referee["Referee verdicts<br/>[run-bug-hunter.cjs]"]
end

subgraph group_artifacts["Artifacts and state"]
  node_artifacts["Artifact planning"]
  node_schemas["Schema validation<br/>[schema-runtime.cjs]"]
  node_validators["Generated validators"]
  node_state[("Audit state")]
  node_stateio["State storage<br/>[state-store.cjs]"]
  node_cache[("Evidence cache<br/>[evidence-cache.cjs]")]
  node_report["Audit report<br/>[render-report.cjs]"]
end

subgraph group_verification["Verification and quality"]
  node_verifier["Hybrid verification"]
  node_process["Process runner<br/>[process-runner.cjs]"]
  node_benchmark["Benchmark quality"]
  node_loop["Coverage loop"]
  node_fixer["Approved fixes<br/>[fix-lock.cjs]"]
end

node_user(("Agent user"))

node_user -->|"requests scan"| node_runner
node_runner -->|"invokes"| node_triage
node_runner -->|"selects profile"| node_adaptive
node_runner -->|"schedules chunks"| node_scheduler
node_runner -->|"plans context"| node_retrieval
node_runner -->|"runs checks"| node_verifier
node_runner -->|"uses state storage"| node_stateio
node_runner -->|"plans artifacts"| node_artifacts
node_runner -->|"manages run state"| node_state
node_triage -.->|"informs profile"| node_adaptive
node_worktree -.->|"supplies source"| node_runner
node_runner -.->|"performs recon"| node_indexing
node_runner -->|"collects findings"| node_hunter
node_runner -->|"checks documentation"| node_docs
node_runner -->|"challenges claims"| node_skeptic
node_runner -->|"resolves evidence"| node_referee
node_runner -.->|"reuses evidence"| node_cache
node_runner -.->|"renders report"| node_report
node_schemas -->|"validates with"| node_validators
node_state -->|"validates artifacts"| node_schemas
node_stateio -->|"uses state commands"| node_state
node_verifier -->|"runs processes"| node_process
node_benchmark -->|"uses schema runtime"| node_schemas
node_runner -.->|"extends coverage"| node_loop
node_runner -.->|"authorizes fixes"| node_fixer

click node_runner "https://github.com/codexstar69/bug-hunter/blob/main/scripts/run-bug-hunter.cjs"
click node_triage "https://github.com/codexstar69/bug-hunter/blob/main/scripts/triage.cjs"
click node_adaptive "https://github.com/codexstar69/bug-hunter/blob/main/scripts/adaptive-policy.cjs"
click node_scheduler "https://github.com/codexstar69/bug-hunter/blob/main/scripts/chunk-scheduler.cjs"
click node_worktree "https://github.com/codexstar69/bug-hunter/blob/main/scripts/worktree-harvest.cjs"
click node_indexing "https://github.com/codexstar69/bug-hunter/blob/main/scripts/code-index.cjs"
click node_retrieval "https://github.com/codexstar69/bug-hunter/blob/main/scripts/retrieval-planner.cjs"
click node_hunter "https://github.com/codexstar69/bug-hunter/blob/main/scripts/run-bug-hunter.cjs"
click node_docs "https://github.com/codexstar69/bug-hunter/blob/main/scripts/doc-lookup.cjs"
click node_skeptic "https://github.com/codexstar69/bug-hunter/blob/main/scripts/run-bug-hunter.cjs"
click node_referee "https://github.com/codexstar69/bug-hunter/blob/main/scripts/run-bug-hunter.cjs"
click node_artifacts "https://github.com/codexstar69/bug-hunter/blob/main/scripts/artifact-planner.cjs"
click node_schemas "https://github.com/codexstar69/bug-hunter/blob/main/scripts/schema-runtime.cjs"
click node_validators "https://github.com/codexstar69/bug-hunter/blob/main/scripts/generated-schema-validators.cjs"
click node_state "https://github.com/codexstar69/bug-hunter/blob/main/scripts/bug-hunter-state.cjs"
click node_stateio "https://github.com/codexstar69/bug-hunter/blob/main/scripts/state-store.cjs"
click node_cache "https://github.com/codexstar69/bug-hunter/blob/main/scripts/evidence-cache.cjs"
click node_report "https://github.com/codexstar69/bug-hunter/blob/main/scripts/render-report.cjs"
click node_verifier "https://github.com/codexstar69/bug-hunter/blob/main/scripts/hybrid-verifier.cjs"
click node_process "https://github.com/codexstar69/bug-hunter/blob/main/scripts/process-runner.cjs"
click node_benchmark "https://github.com/codexstar69/bug-hunter/blob/main/scripts/benchmark-suite.cjs"
click node_loop "https://github.com/codexstar69/bug-hunter/blob/main/scripts/experiment-loop.cjs"
click node_fixer "https://github.com/codexstar69/bug-hunter/blob/main/scripts/fix-lock.cjs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_runner,node_triage,node_adaptive,node_scheduler,node_worktree,node_user toneBlue
class node_indexing,node_retrieval,node_hunter,node_docs,node_skeptic,node_referee toneAmber
class node_artifacts,node_schemas,node_validators,node_state,node_stateio,node_cache,node_report toneMint
class node_verifier,node_process,node_benchmark,node_loop,node_fixer toneRose
```

## Components

### Run orchestration

- [Audit runner](https://github.com/codexstar69/bug-hunter/blob/main/scripts/run-bug-hunter.cjs): `scripts/run-bug-hunter.cjs`
- [Risk triage](https://github.com/codexstar69/bug-hunter/blob/main/scripts/triage.cjs): `scripts/triage.cjs`
- [Adaptive profiles](https://github.com/codexstar69/bug-hunter/blob/main/scripts/adaptive-policy.cjs): `scripts/adaptive-policy.cjs`
- [Chunk scheduler](https://github.com/codexstar69/bug-hunter/blob/main/scripts/chunk-scheduler.cjs): `scripts/chunk-scheduler.cjs`
- [Source harvesting](https://github.com/codexstar69/bug-hunter/blob/main/scripts/worktree-harvest.cjs): `scripts/worktree-harvest.cjs`

### Audit analysis

- [Architecture recon](https://github.com/codexstar69/bug-hunter/blob/main/scripts/code-index.cjs): `scripts/code-index.cjs`
- [Hypothesis retrieval](https://github.com/codexstar69/bug-hunter/blob/main/scripts/retrieval-planner.cjs): `scripts/retrieval-planner.cjs`
- [Hunter findings](https://github.com/codexstar69/bug-hunter/blob/main/scripts/run-bug-hunter.cjs): `scripts/run-bug-hunter.cjs`
- [Documentation checks](https://github.com/codexstar69/bug-hunter/blob/main/scripts/doc-lookup.cjs): `scripts/doc-lookup.cjs`
- [Skeptic challenges](https://github.com/codexstar69/bug-hunter/blob/main/scripts/run-bug-hunter.cjs): `scripts/run-bug-hunter.cjs`
- [Referee verdicts](https://github.com/codexstar69/bug-hunter/blob/main/scripts/run-bug-hunter.cjs): `scripts/run-bug-hunter.cjs`

### Artifacts and state

- [Artifact planning](https://github.com/codexstar69/bug-hunter/blob/main/scripts/artifact-planner.cjs): `scripts/artifact-planner.cjs`
- [Schema validation](https://github.com/codexstar69/bug-hunter/blob/main/scripts/schema-runtime.cjs): `scripts/schema-runtime.cjs`
- [Generated validators](https://github.com/codexstar69/bug-hunter/blob/main/scripts/generated-schema-validators.cjs): `scripts/generated-schema-validators.cjs`
- [Audit state](https://github.com/codexstar69/bug-hunter/blob/main/scripts/bug-hunter-state.cjs): `scripts/bug-hunter-state.cjs`
- [State storage](https://github.com/codexstar69/bug-hunter/blob/main/scripts/state-store.cjs): `scripts/state-store.cjs`
- [Evidence cache](https://github.com/codexstar69/bug-hunter/blob/main/scripts/evidence-cache.cjs): `scripts/evidence-cache.cjs`
- [Audit report](https://github.com/codexstar69/bug-hunter/blob/main/scripts/render-report.cjs): `scripts/render-report.cjs`

### Verification and quality

- [Hybrid verification](https://github.com/codexstar69/bug-hunter/blob/main/scripts/hybrid-verifier.cjs): `scripts/hybrid-verifier.cjs`
- [Process runner](https://github.com/codexstar69/bug-hunter/blob/main/scripts/process-runner.cjs): `scripts/process-runner.cjs`
- [Benchmark quality](https://github.com/codexstar69/bug-hunter/blob/main/scripts/benchmark-suite.cjs): `scripts/benchmark-suite.cjs`
- [Coverage loop](https://github.com/codexstar69/bug-hunter/blob/main/scripts/experiment-loop.cjs): `scripts/experiment-loop.cjs`
- [Approved fixes](https://github.com/codexstar69/bug-hunter/blob/main/scripts/fix-lock.cjs): `scripts/fix-lock.cjs`

### Other components

- **Agent user**

## Connections

- Agent user → Audit runner: requests scan (evidence: `README.md`)
- Audit runner → Risk triage: invokes (evidence: `scripts/run-bug-hunter.cjs`)
- Audit runner → Adaptive profiles: selects profile (evidence: `scripts/run-bug-hunter.cjs`)
- Audit runner → Chunk scheduler: schedules chunks (evidence: `scripts/run-bug-hunter.cjs`)
- Audit runner → Hypothesis retrieval: plans context (evidence: `scripts/run-bug-hunter.cjs`)
- Audit runner → Hybrid verification: runs checks (evidence: `scripts/run-bug-hunter.cjs`)
- Audit runner → State storage: uses state storage (evidence: `scripts/run-bug-hunter.cjs`)
- Audit runner → Artifact planning: plans artifacts (evidence: `scripts/run-bug-hunter.cjs`)
- Audit runner → Audit state: manages run state (evidence: `scripts/run-bug-hunter.cjs`)
- Risk triage → Adaptive profiles: informs profile (evidence: `README.md`)
- Source harvesting → Audit runner: supplies source
- Audit runner → Architecture recon: performs recon (evidence: `README.md`)
- Audit runner → Hunter findings: collects findings (evidence: `README.md`)
- Audit runner → Documentation checks: checks documentation (evidence: `README.md`)
- Audit runner → Skeptic challenges: challenges claims (evidence: `README.md`)
- Audit runner → Referee verdicts: resolves evidence (evidence: `README.md`)
- Audit runner → Evidence cache: reuses evidence (evidence: `README.md`)
- Audit runner → Audit report: renders report (evidence: `README.md`)
- Schema validation → Generated validators: validates with (evidence: `scripts/schema-runtime.cjs`)
- Audit state → Schema validation: validates artifacts (evidence: `scripts/bug-hunter-state.cjs`)
- State storage → Audit state: uses state commands (evidence: `scripts/state-store.cjs`)
- Hybrid verification → Process runner: runs processes (evidence: `scripts/hybrid-verifier.cjs`)
- Benchmark quality → Schema validation: uses schema runtime (evidence: `scripts/benchmark-suite.cjs`)
- Audit runner → Coverage loop: extends coverage (evidence: `README.md`)
- Audit runner → Approved fixes: authorizes fixes (evidence: `README.md`)
