This guide is for contributors changing Ravage internals. For operator commands, start with How To Use. For the system flow, read Architecture.
Most Ravage changes should preserve these rules:
Core runtime:
packages/ravage/src/ravage/__main__.py: CLI parser and command dispatch.packages/ravage/src/ravage/agent_core/ai_agent.py: evaluated local ai-web
runtime loop.packages/ravage/src/ravage/agent_core/autonomous_graph/: bounded graph
coordinator, workers, budgets, scoped HTTP, evidence, and durable state.packages/ravage/src/ravage/dast_scan.py: deterministic scan runtime.packages/ravage/src/ravage/benchmark.py: local benchmark harness.packages/ravage/src/ravage/xben_parts/: XBEN runner implementation.packages/ravage/src/ravage/run_data/audit.py: audit store and hash-chain
verification.packages/ravage/src/ravage/run_data/workspace.py: workspace paths and
artifacts.packages/ravage/src/ravage/runtime.py: external tool execution modes.packages/ravage/src/ravage/web_core/scope_policy.py: same-origin and
explicit-scope enforcement.Agent internals:
agent_core/action_parser.py: current model-action parsing.agent_core/action_executor.py: scoped local action execution and evidence
recording.agent_core/agent_state.py: evaluated-base working state.agent_core/autonomous_route_selection.py: explicit post-base route
selection.agent_core/autonomous_graph/model_bridge.py: graph model routing and
accounting.agent_core/autonomous_graph/scoped_http.py: remote structured-HTTP
enforcement.probe_suite.py and probes/: deterministic specialist catalog and proof
closure.Benchmark and evaluation:
ravage xben: command-line wrapper for XBEN.scripts/run_memory_eval.py: memory A/B runner.scripts/grade_xben_failures.py: failure taxonomy report generator.proof_bundle*.py: proof bundle candidate, verifier, and evaluation logic.trace_quality.py: trace-quality diagnostics.failure_taxonomy.py: failure grouping and markdown rendering.overfit_guard.py: benchmark-overfit checks.coverage_ledger.py: attempted-candidate tracking.ravage attack is the canonical model-agent entry point:
audit.db, workspace/, and optional report paths.ai-web loop with the selected model, mode, and tool runtime.ravage scan follows the same run-shape pattern but calls deterministic DAST
instead of the model loop.
The ravage xben ... path manages target Docker projects, case selection,
timeouts, per-case outputs, flag matching, and benchmark modes. For each case
it generates a normal engagement brief and invokes the same public
ravage attack command. XBEN owns provisioning and scoring; exploit behavior
stays in the attack engine. The old top-level ravage --benchmark ...
examples are not the current public benchmark interface.
The model must return exactly one JSON action with:
actionkill_chain_stageargsrationaleThe parser accepts fenced JSON or a JSON object embedded in text, but invalid model output is recorded and corrected through the next observation.
Observations are wrapped with:
This prevents target HTML, JavaScript, error pages, or API responses from pretending to be agent instructions.
New tools should follow these rules:
Typed probes should distinguish:
When adding a probe, also update:
Source-guided workflows must not become one-off benchmark shortcuts. They should be based on reusable source signals and dynamic proof patterns.
Good workflow shape:
Avoid:
Ravage accepts findings only after tool-backed evidence. SQLi still has a
specialized report_sqli path. Other classes use generic findings with
evidence details.
For IDOR/SSTI and similar multi-step cases, proof-bundle verification can be enabled:
--proof-bundle-verifier --require-proof-bundle-findings
Use this when candidate signals are noisy and findings should require semantic proof before promotion.
Memory is local and advisory.
Safe memory behavior:
Memory must not:
XBEN supports explicit context modes:
black-box: benchmark description is available; source code, case names, and
difficulty levels are withheld.white-box: source files and benchmark description may guide candidates, but
live proof is still required.source-aware: compatibility alias for white-box.Do not compare runs unless mode, target set, model route, turn budget, memory mode, tool runtime, and Docker architecture are the same.
Use focused tests for the touched subsystem:
.venv/bin/python -m pytest packages/ravage/tests/test_ai_agent.py
.venv/bin/python -m pytest packages/ravage/tests/test_xben_runner.py
.venv/bin/python -m pytest packages/ravage/tests/test_source_guided_runtime.py
Broad validation:
.venv/bin/python -m pytest packages/schemas packages/ravage/tests tests
.venv/bin/python -m ruff check .
.venv/bin/python -m mypy packages scripts
If the virtualenv console script is stale, use:
PYTHONPATH=packages/ravage/src:packages/schemas/src \
.venv/bin/python -m ravage --help
Keep docs tied to current code:
ravage --help and source files over old plans.docs/.