# deonmenezes/mantishack architecture

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

- Interactive diagram: https://gitdiagram.com/deonmenezes/mantishack
- Repository: https://github.com/deonmenezes/mantishack

## Overview

1. **Top-level shape**
   This is a monorepo for an autonomous offensive-security framework, not a single app. The runtime is predominantly Python, with command wrappers in `bin/`, `mantishack.py`, `mantishack_agentic.py`, and many executable shims in `libexec/`. The repo also contains large data sets, rule packs, and test corpora that are part of the architecture, not just fixtures.

2. **Two control planes**
   The README’s key architectural split is between the **Python execution layer** and the **Claude Code decision layer**.  
   - The Python layer (`core/`, `packages/`, `engine/`) runs scans, analysis, validation, reporting, and artifact management.  
   - The Claude layer (`.claude/`, `tiers/`, `CLAUDE.md`) supplies the human/agent workflow: slash commands, skills, specialist agents, and persona-driven reasoning.

3. **Command surface and workflow entrypoints**
   The primary user-facing entrypoints are the `/mantis-*` commands defined under `.claude/commands/`, with supporting skills and agents under `.claude/skills/` and `.claude/agents/`. These commands route into the Python packages through `libexec/*` wrappers, so the architecture is “command-driven orchestration over shared analysis engines,” not a single monolithic CLI.

4. **Core orchestration layer**
   `core/orchestration/`, `core/run/`, `core/project/`, and `core/reporting/` form the backbone for turning a target into structured findings.  
   - `core/run/` tracks provenance, identity, metadata, and safe output handling.  
   - `core/project/` manages named workspaces, merges/diffs, exports, and finding correlation.  
   - `core/reporting/` renders findings and witness data into console/report formats.

5. **Static analysis pipeline**
   Static code analysis is centered around **Semgrep** and **CodeQL**, but the repo wraps them in substantial orchestration.  
   - `packages/semgrep/` and `packages/codeql/` provide scanners, model adapters, and evidence validators.  
   - `engine/semgrep/rules/` and `engine/codeql/suites/` hold the actual rule/query packs.  
   - `core/sarif/` parses SARIF output into the internal finding model.  
   The data flow is: source tree → scanner(s) → SARIF/JSON findings → validation/correlation → reports.

6. **Dataflow and exploitability validation**
   `core/dataflow/` and `packages/hypothesis_validation/` are the main “is this real?” layer. They consume findings from scanners, augment them with path/constraint evidence, and decide whether a result is reachable, meaningful, and worth escalation. This layer also bridges to LLM extraction and barrier synthesis, so it is the boundary between raw tool output and attackable hypotheses.

7. **Agentic analysis and LLM dispatch**
   `core/llm/`, `packages/llm_analysis/`, `packages/code_understanding/`, `packages/autonomous/`, and `packages/strategy_eval/` coordinate model usage and prompt-driven analysis. The repo supports multiple providers and model roles, with dispatch, routing, scorecards, tool-use loops, and response validation. This is where “analysis” gets converted into structured judgments, but the architecture keeps the model layer separated from the execution and scanning layers.

8. **Binary, crash, fuzzing, and exploit paths**
   The repo has a parallel binary-analysis branch: `packages/fuzzing/`, `packages/binary_analysis/`, `core/binary/`, `core/sandbox/`, `core/smt_solver/`, and `core/witness/`.  
   - Fuzzing generates corpora, harnesses, telemetry, and crash artifacts.  
   - Sandbox modules constrain or observe untrusted execution.  
   - Crash analysis and SMT components turn crashes into feasibility checks and candidate exploit constraints.  
   - Witness storage captures evidence that links crashes, traces, and exploitability claims.

9. **Software composition analysis and supply-chain risk**
   `packages/sca/` is a major subsystem on its own. It scans dependency manifests, lockfiles, container/image metadata, registries, and reachability evidence to produce supply-chain risk judgments. It includes parsers for many ecosystems, resolvers, registries, reachability analysis, version handling, SBOM import/export, suppression logic, and calibration data. This is the repo’s dependency-risk and update-impact pipeline, separate from source-code vulnerability hunting.

10. **Historical / forensic / CVE-diff tooling**
   `packages/cve_diff/` and `core/cve/` compare known CVE fixes against code and release artifacts. `core/coverage/`, `core/inventory/`, `core/ast/`, `core/verified_outcome/`, and `core/oss-forensics`-related tooling support evidence-backed reconstruction of changes, call graphs, and historical states. The architecture supports “before/after” and “what changed?” workflows, not just point-in-time scanning.

11. **Security boundary and containment layers**
   A lot of the repo is dedicated to keeping the framework safe while it analyzes hostile code. `core/security/` contains prompt envelope defenses, redaction, environment sanitization, response schema checks, and trust rules. `core/sandbox/` adds OS-level isolation, profiling, tracing, seccomp/Landlock/Seatbelt-style controls, and observation modes. These layers sit between external code/binaries and the analysis pipeline.

12. **Artifacts, caches, and persistent state**
   The main data interchange formats are SARIF, JSON, YAML, and project-specific store formats. Persistent and semi-persistent state lives in project workspaces, witness stores, annotation stores, coverage stores, fingerprint caches, and SCA calibration data. The repo also ships large internal corpora under `core/dataflow/corpus/`, `packages/cve_diff/data/`, `packages/sca/data/`, and `test/data/`, which are used both for regression tests and for validating the analysis methods.

13. **External service and tooling dependencies that shape the architecture**
   The repo integrates with Claude Code, Semgrep, CodeQL, GitHub/GH Archive/Wayback, OCI registries, OSV/NVD, and GitHub Actions. These are not incidental: they define acquisition paths, offline caches, CI workflows, and how findings and vulnerability evidence are sourced. The repo is designed to keep much of this offline once packs/data are cached.

14. **Repository boundary as a product platform**
   Overall, this is a platform with multiple specialized pipelines sharing a common execution substrate. The shared substrate is the Python/core model layer and the command/runtime wrappers; the specialized pipelines are source-code analysis, binary exploitation, supply-chain analysis, forensic reconstruction, and LLM-assisted validation. An architecture diagram should therefore show a central orchestration/runtime backbone feeding several loosely coupled analysis domains, all mediated by security/sandbox controls and converging into a common findings/reporting/project store.

Main entry points: [`packages/llm_analysis`](https://github.com/deonmenezes/mantishack/tree/main/packages/llm_analysis) (LLM analysis), [`packages/hypothesis_validation`](https://github.com/deonmenezes/mantishack/tree/main/packages/hypothesis_validation) (Dataflow validation), [`core/run`](https://github.com/deonmenezes/mantishack/tree/main/core/run) (Runtime core), [`core/orchestration`](https://github.com/deonmenezes/mantishack/tree/main/core/orchestration) (Orchestration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control_plane["Control plane"]
  node_claude_commands["Slash commands<br/>workflow commands<br/>[commands]"]
  node_claude_skills_agents["Skills & agents<br/>agent playbooks<br/>[skills]"]
  node_claude_personas["Personas<br/>reasoning roles"]
end

subgraph group_python_core["Python core"]
  node_mantishack_entry["CLI entry<br/>python launcher<br/>[mantishack.py]"]
  node_libexec_wrappers["Wrappers<br/>exec shims"]
  node_runtime_core["Runtime core<br/>orchestration runtime"]
  node_orchestration["Orchestration<br/>workflow coordinator"]
  node_project_store[("Project store<br/>workspace model")]
  node_reporting["Reporting<br/>rendering layer"]
  node_security_boundary["Security boundary<br/>defense layer"]
  node_sandbox["Sandbox<br/>containment"]
end

subgraph group_analysis_domains["Analysis domains"]
  node_scanner_layer["Scanner layer<br/>static scanners"]
  node_source_analysis["Source analysis<br/>source-intel pipeline"]
  node_dataflow_validation["Dataflow validation<br/>finding validation"]
  node_llm_analysis["LLM analysis<br/>model dispatch"]
  node_binary_paths["Binary paths<br/>crash/fuzz pipeline"]
  node_exploit_feasibility["Exploit feasibility<br/>constraint solver"]
  node_sca_pipeline["SCA pipeline<br/>dependency risk"]
  node_cve_diff["CVE diff<br/>historical analysis"]
end

subgraph group_policy_data["Policy & data"]
  node_evidence_stores[("Evidence stores<br/>persistent artifacts")]
  node_rules_and_corpora["Rules & corpora<br/>packs and datasets"]
end

node_claude_commands -->|"invoke"| node_libexec_wrappers
node_claude_skills_agents -->|"guide"| node_llm_analysis
node_claude_personas -->|"shape"| node_llm_analysis
node_mantishack_entry -->|"boot"| node_runtime_core
node_libexec_wrappers -->|"route"| node_orchestration
node_orchestration -->|"persist"| node_project_store
node_orchestration -->|"handoff"| node_dataflow_validation
node_runtime_core -->|"enforce"| node_security_boundary
node_runtime_core -->|"contain"| node_sandbox
node_scanner_layer -->|"consume"| node_rules_and_corpora
node_scanner_layer -->|"emit"| node_dataflow_validation
node_source_analysis -->|"build on"| node_scanner_layer
node_source_analysis -->|"consult"| node_llm_analysis
node_dataflow_validation -->|"refine"| node_exploit_feasibility
node_llm_analysis -->|"guarded by"| node_security_boundary
node_binary_paths -->|"run in"| node_sandbox
node_binary_paths -->|"check"| node_exploit_feasibility
node_sca_pipeline -->|"calibrate"| node_rules_and_corpora
node_sca_pipeline -->|"triage"| node_llm_analysis
node_cve_diff -->|"compare"| node_rules_and_corpora
node_reporting -->|"summarize"| node_project_store
node_evidence_stores -->|"source"| node_reporting
node_evidence_stores -->|"support"| node_dataflow_validation

click node_claude_commands "https://github.com/deonmenezes/mantishack/blob/main/.claude/commands"
click node_claude_skills_agents "https://github.com/deonmenezes/mantishack/blob/main/.claude/skills"
click node_claude_personas "https://github.com/deonmenezes/mantishack/tree/main/tiers"
click node_mantishack_entry "https://github.com/deonmenezes/mantishack/blob/main/mantishack.py"
click node_libexec_wrappers "https://github.com/deonmenezes/mantishack/tree/main/libexec"
click node_runtime_core "https://github.com/deonmenezes/mantishack/tree/main/core/run"
click node_orchestration "https://github.com/deonmenezes/mantishack/tree/main/core/orchestration"
click node_project_store "https://github.com/deonmenezes/mantishack/tree/main/core/project"
click node_reporting "https://github.com/deonmenezes/mantishack/tree/main/core/reporting"
click node_security_boundary "https://github.com/deonmenezes/mantishack/tree/main/core/security"
click node_sandbox "https://github.com/deonmenezes/mantishack/tree/main/core/sandbox"
click node_scanner_layer "https://github.com/deonmenezes/mantishack/tree/main/packages/static-analysis"
click node_source_analysis "https://github.com/deonmenezes/mantishack/tree/main/packages/source_intel"
click node_dataflow_validation "https://github.com/deonmenezes/mantishack/tree/main/packages/hypothesis_validation"
click node_llm_analysis "https://github.com/deonmenezes/mantishack/tree/main/packages/llm_analysis"
click node_binary_paths "https://github.com/deonmenezes/mantishack/tree/main/packages/fuzzing"
click node_exploit_feasibility "https://github.com/deonmenezes/mantishack/tree/main/packages/exploit_feasibility"
click node_sca_pipeline "https://github.com/deonmenezes/mantishack/tree/main/packages/sca"
click node_cve_diff "https://github.com/deonmenezes/mantishack/tree/main/packages/cve_diff"
click node_evidence_stores "https://github.com/deonmenezes/mantishack/tree/main/core/witness"
click node_rules_and_corpora "https://github.com/deonmenezes/mantishack/tree/main/engine/semgrep/rules"

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_claude_commands,node_claude_skills_agents,node_claude_personas toneBlue
class node_mantishack_entry,node_libexec_wrappers,node_runtime_core,node_orchestration,node_project_store,node_reporting,node_security_boundary,node_sandbox toneAmber
class node_scanner_layer,node_source_analysis,node_dataflow_validation,node_llm_analysis,node_binary_paths,node_exploit_feasibility,node_sca_pipeline,node_cve_diff toneMint
class node_evidence_stores,node_rules_and_corpora toneRose
```

## Components

### Control plane

Claude Code commands, skills, agents, and personas that drive the agentic workflow.

- [Slash commands](https://github.com/deonmenezes/mantishack/blob/main/.claude/commands): workflow commands · Primary user-facing command surface for mantis workflows. · `.claude/commands`
- [Skills & agents](https://github.com/deonmenezes/mantishack/blob/main/.claude/skills): agent playbooks · Specialist skills and agent prompts for analysis, validation, and reporting. · `.claude/skills`
- [Personas](https://github.com/deonmenezes/mantishack/tree/main/tiers): reasoning roles · Tiered personas and guidance that shape Claude-driven decisions. · `tiers`

### Python core

Shared execution substrate for orchestration, project state, runtime safety, and reporting.

- [CLI entry](https://github.com/deonmenezes/mantishack/blob/main/mantishack.py): python launcher · Top-level Python launchers and wrappers for the framework. · `mantishack.py`
- [Wrappers](https://github.com/deonmenezes/mantishack/tree/main/libexec): exec shims · Executable shims that route commands into Python packages and tools. · `libexec`
- [Runtime core](https://github.com/deonmenezes/mantishack/tree/main/core/run): orchestration runtime · Core execution backbone for run identity, provenance, safe IO, and orchestration. · `core/run`
- [Orchestration](https://github.com/deonmenezes/mantishack/tree/main/core/orchestration): workflow coordinator · Coordinates analysis passes, reachability enrichment, and understand/validate handoffs. · `core/orchestration`
- [Project store](https://github.com/deonmenezes/mantishack/tree/main/core/project): workspace model · Manages workspaces, merges, diffs, exports, correlations, and project reports. · `core/project`
- [Reporting](https://github.com/deonmenezes/mantishack/tree/main/core/reporting): rendering layer · Console and report rendering for findings and witness evidence. · `core/reporting`
- [Security boundary](https://github.com/deonmenezes/mantishack/tree/main/core/security): defense layer · Prompt, environment, redaction, and trust controls around model and tool use. · `core/security`
- [Sandbox](https://github.com/deonmenezes/mantishack/tree/main/core/sandbox): containment · Isolation, observation, and platform-specific execution controls. · `core/sandbox`

### Analysis domains

Specialized pipelines for source, binary, supply-chain, and exploit workflows.

- [Scanner layer](https://github.com/deonmenezes/mantishack/tree/main/packages/static-analysis): static scanners · Shared scanner orchestration and result normalization for Semgrep, CodeQL, and Coccinelle. · `packages/static-analysis`
- [Source analysis](https://github.com/deonmenezes/mantishack/tree/main/packages/source_intel): source-intel pipeline · Source-intel discovery, measurement, rendering, and rule-based reasoning for code smells and hazards. · `packages/source_intel`
- [Dataflow validation](https://github.com/deonmenezes/mantishack/tree/main/packages/hypothesis_validation): finding validation · Findings, barriers, path evidence, and hypothesis validation across scanner outputs. · `packages/hypothesis_validation`
- [LLM analysis](https://github.com/deonmenezes/mantishack/tree/main/packages/llm_analysis): model dispatch · Model routing, prompts, scorecards, validation, and agentic reasoning loops. · `packages/llm_analysis`
- [Binary paths](https://github.com/deonmenezes/mantishack/tree/main/packages/fuzzing): crash/fuzz pipeline · Fuzzing, crash analysis, binary understanding, and exploitability support. · `packages/fuzzing`
- [Exploit feasibility](https://github.com/deonmenezes/mantishack/tree/main/packages/exploit_feasibility): constraint solver · SMT- and graph-based feasibility checks, mitigations, and exploit constraints. · `packages/exploit_feasibility`
- [SCA pipeline](https://github.com/deonmenezes/mantishack/tree/main/packages/sca): dependency risk · Supply-chain scanning, reachability, registries, SBOMs, and calibration-driven risk scoring. · `packages/sca`
- [CVE diff](https://github.com/deonmenezes/mantishack/tree/main/packages/cve_diff): historical analysis · Compares fixes, releases, and advisories to reconstruct vulnerability change history. · `packages/cve_diff`

### Policy & data

Rule packs, corpora, calibration data, and persistent evidence stores.

- [Evidence stores](https://github.com/deonmenezes/mantishack/tree/main/core/witness): persistent artifacts · Annotations, witnesses, coverage, fingerprints, and cached corpus-like evidence. · `core/witness`
- [Rules & corpora](https://github.com/deonmenezes/mantishack/tree/main/engine/semgrep/rules): packs and datasets · Rule packs, query packs, calibration data, and repository corpora used for validation and regression. · `engine/semgrep/rules`

## Connections

- Slash commands → Wrappers: invoke · Slash commands dispatch through executable shims into the runtime.
- Skills & agents → LLM analysis: guide · Specialist agents and skills steer LLM-backed analysis and review loops.
- Personas → LLM analysis: shape · Personas define reasoning style, escalation posture, and review behavior.
- CLI entry → Runtime core: boot · Top-level launchers initialize the shared runtime substrate.
- Wrappers → Orchestration: route · Wrappers route command-specific flows into orchestration passes.
- Orchestration → Project store: persist · Workflow passes write workspaces, diffs, correlations, and exports.
- Orchestration → Dataflow validation: handoff · Findings move from orchestration into evidence-backed validation.
- Runtime core → Security boundary: enforce · Runtime operations are filtered through trust, redaction, and schema defenses.
- Runtime core → Sandbox: contain · Untrusted execution and observation run inside containment layers.
- Scanner layer → Rules & corpora: consume · Scanner behavior is driven by rule packs and cached corpora.
- Scanner layer → Dataflow validation: emit · Scanner outputs are normalized into findings for validation.
- Source analysis → Scanner layer: build on · Source-intel analysis uses scanner results and rule-based context.
- Source analysis → LLM analysis: consult · Some source-intel workflows use model-assisted interpretation and bridging.
- Dataflow validation → Exploit feasibility: refine · Validated findings can be transformed into feasibility and constraint problems.
- LLM analysis → Security boundary: guarded by · Model dispatch and prompt handling are protected by response and envelope controls.
- Binary paths → Sandbox: run in · Fuzzing and crash workflows execute under containment and observation.
- Binary paths → Exploit feasibility: check · Crashes and traces feed exploitability and constraint checks.
- SCA pipeline → Rules & corpora: calibrate · SCA depends on offline data, calibration sets, and ecosystem maps.
- SCA pipeline → LLM analysis: triage · Selected SCA judgments use LLM-assisted review and explanation.
- CVE diff → Rules & corpora: compare · Historical diff workflows rely on corpora, advisories, and fix samples.
- Reporting → Project store: summarize · Reports are assembled from project state and correlated findings.
- Evidence stores → Reporting: source · Witnesses, annotations, and coverage records back rendered reports.
- Evidence stores → Dataflow validation: support · Validation consumes persistent evidence and witness data.
