Vape / docs /ARCHITECTURE.md
DetVape's picture
Sync from GitHub via hub-sync
2ad8e85 verified
|
Raw History Blame Contribute Delete
14.5 kB
# V.A.P.E. Architecture
> Status legend: [OK] implemented & running Β· [WIP] partial/scaffolded Β· [TBD] planned
V.A.P.E. is an autonomous on-chain security & intelligence operation. It runs as
**two cooperating runtimes** plus a **self-improving skill ecosystem**, all on free
tiers (Groq + GitHub Actions + open-source tooling).
## High-level flow
```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ DATA SOURCES (real) β”‚
β”‚ Base RPC Β· Etherscan V2 Β· DexScreener β”‚
β”‚ GoPlus Β· CoinGecko Β· DeFiLlama Β· CVEs β”‚
β”‚ Immunefi/Code4rena Β· X/@based_vape β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ β”‚ β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ PYTHON ENGINE β”‚ β”‚ SKILLFORGE β”‚ β”‚ ACP MONITOR β”‚
β”‚ (CI, hourly) β”‚ β”‚ (GitHub Actions) β”‚ β”‚ (job lifecycle) β”‚
β”‚ agents/*.py β”‚ β”‚ skillforge/* β”‚ β”‚ scripts/acp-* β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ β”‚ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ intel/ β”‚ β”‚ Virtuals ACP β”‚
│ reports/audits/ │ │ events→triage→ │
β”‚ broadcasts/ β”‚ β”‚ negotiate/fund/ β”‚
β”‚ bounty-radar/ β”‚ β”‚ complete jobs β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ GitHub Pages β”‚ β”‚ USDC escrow on β”‚
β”‚ (docs/) β€” UI β”‚ β”‚ Base β€” payment β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```
Component-level status detail (see the legend above) lives in the table
below, not inside the diagram β€” a diagram should show structure, a table
should show status, so neither has to be hand-re-aligned every time a
component's state changes.
| Component | Status | Notes |
|---|---|---|
| `agents/run.py` | [OK] | Hourly bounty-cycle orchestration |
| `agents/investigate.py` | [OK] | Deep-investigation engine, real recon+scoring |
| Groq LLM tier | [OK] | Frontier-model fallback chain, see `agents/llm.py` |
| `skillforge/tools/static/slither.sh` | [OK] | Static analysis wrapper |
| `agents/acp_fulfill.py` / wallet | [WIP] | ACP job fulfillment + wallet scaffolding |
| `skillforge/harvest.py` | [OK] | Hourly CVE/tool harvest |
| `skillforge/toolcheck.py` | [OK] | 6x/day tool smoke-test |
| `skillforge/synthesize.py` | [OK] | Daily skill distillation β†’ PR |
| Security tool tiers | [OK] | 13 tools registered across static/fuzzing/ai-redteam/recon |
| `skillforge/memory/` | [OK] | Shared append-only memory base |
## Components
### 1. Python engine β€” `agents/` [OK] (the CI workhorse)
Runs hourly in GitHub Actions (`.github/workflows/bounty-cycle.yml`).
- **`run.py`** β€” single-pass orchestrator. `ask_llm()` (Groq `llama-3.1-8b-instant`,
3-retry rate-limit backoff) + `run_slither()` (30s timeout). Dual mode via
`--review-repo` β†’ bounty reports vs. self-review reports.
- **`main.py`** β€” `VAPE` (investigator) + `HACK` (red-team auditor) over fetched bounties.
- **`vape.py` / `hack.py`** β€” persona engines with `vape_system.md` / `hack_system.md` prompts.
- **`tools.py`** β€” `fetch_bounties()`, `log_report()`.
- **`acp_fulfill.py` / `wallet.py`** [WIP] β€” ACP job fulfillment + wallet scaffolding (signing via ACP CLI).
- **`investigate.py`** [OK] β€” deep-investigation engine, CertiK-style scoring (risk is the default,
not the exception β€” see README's table for the full check list). Every real verdict is
permanent in `intel/investigations/ledger.json`; auto mode never re-investigates an address
already on record, `--address` always forces a re-check (hired job / deliberate deep-dive).
`fail-list.md`/`caution-list.md`/`pass-list.md` regenerate from the ledger every run.
- **`review_ledger.py`** [OK] β€” self-review: re-checks the oldest-reviewed addresses per list
against fresh data (pass/caution weekly, fail monthly, `review-ledger.yml`), logs a real
finding when a past verdict drifts. This is VAPE auditing its own track record, not just
producing new ones.
- **`token_scan.py`** [OK] β€” free Hunt console + paid x402 quick-check, same keyless checks as
`investigate.py` minus the ones needing an optional Etherscan key. Ported field-for-field to
`worker/src/scan.ts` and `docs/assets/app.js`, kept honest by `scan-parity.yml`.
- **`scout.py`** [OK] β€” bounty-radar triage, rule-based fit scoring (no LLM), hourly via `scout.yml`.
- **`intel_common.py` / `security_sweep.py` / `base_sweep.py` / `sentiment_sweep.py` /
`virtuals_sweep.py` / `macro_sweep.py` / `mainnet_patch_check.py` / `bug_bounty_intel.py`**
[OK] β€” revives the intel/reports/{security,base,sentiment,virtuals,macro,mainnet-patch-check,
bug-bounty-intel}-*.md sweeps, which used to run as ad hoc Claude Code sessions (never
committed code) until they all silently stopped 2026-07-01 with zero trace in git history.
Same design rule as `scout.py`: the headline verdict/score is computed deterministically
from real data (`data_fetchers.py` + `skillforge/research.py`'s live web search), the LLM
only narrates what the real data means. Scheduled via `intel-sweeps.yml` β€” security/base/
virtuals 4x/day, sentiment 2x/day, macro daily, the two follow-up checks weekly.
`security_sweep.py` also writes `data/attack-feed.json` (real, dated incidents over a
rolling 56-day/8-week window from the same hacks feed, powering the site's homepage
ticker + "Threat Ledger" section β€” see `docs/assets/attackfeed.js`) and, for any new
Base-chain incident it can resolve a real on-chain address for via web search, runs
`investigate.py`'s actual forensics pipeline against it (`attempt_incident_forensics()`)
β€” never a fabricated address, honestly skipped when one can't be found.
`investigate.py::hack_correlation()` was also fixed to genuinely cross-reference a
target's risk traits against real incidents in the same feed (citing the specific
matching incident by name/date/amount) instead of returning generic canned text
regardless of what the real data showed.
`security_sweep.py::learn_from_incidents()` closes the loop from "reports/investigates"
to "learns": every incident within the same 14-day actionable window is run through a
deterministic keyword classifier (`ATTACK_PATTERNS`) mapping its real `technique` string
to a known vulnerability class, a concrete prevention measure, and β€” honestly β€” whether
`investigate.py`'s `score()` already has a named check for it or whether this is an
admitted coverage gap. Where forensics resolved a real Base address, it also backtests
VAPE's own scoring model against the actual verdict (`PROCEED`/`CAUTION`/`REJECT`) on
that contract β€” a `PROCEED` verdict on something that then got exploited is logged as a
real model miss, not smoothed over. Every lesson is logged once (idempotent via
`attack_lessons_state.json`) to `skillforge/memory/findings.jsonl`, surfaced in the
report's "Lessons Learned" section and per-incident in `data/attack-feed.json`/the
Threat Ledger UI. Nothing here is LLM-guessed β€” see this module's design law above.
- **`self_improve.py`** [OK] β€” finds one real, evidence-backed issue, priority order: (1)
unaddressed CRITICAL/HIGH findings from the AI red-team tools below β€” closes the loop
from "VAPE discovers it's vulnerable" to "VAPE proposes to fix itself" β€” then (2) pyflakes
bugs, then (3) tool-registry gaps (never an open-ended LLM guess). Has `builder.py`
propose a fix grounded in the actual target file, opens a real PR via `skillforge/mcp.py`'s
`GitHubMCPWrapper` for human review (never auto-merges), and logs a "lesson" to
`skillforge/memory/lessons.jsonl` every cycle β€” the missing link that now feeds
self-improvement's own real work into the same Memory `skillforge/synthesize.py` distills
from. `skillforge/memory/self_improve_state.json` tracks which findings already got a PR
so the same one isn't re-targeted forever.
- **`build_request.py`** [OK] β€” the concrete "VAPE can build tools/apps/anything needed"
capability: label a GitHub issue `vape-build` (real-time via `build-request.yml`'s
`issues: labeled` trigger, not polled) and `builder.py`'s new `generate_project()`
attempts a real multi-file implementation (parses `### FILE: path` blocks, rejects path
traversal/absolute paths, caps file count/size). Files land in an isolated
`build-requests/issue-<N>-<slug>/` directory via a PR β€” never applied to the real codebase
automatically. Same two gates as `self_improve.py`: Builder's security validation, then
human PR review.
- **`redteam.py`** [OK] β€” real prompt-injection test against VAPE's own report pipeline: crafts
a malicious token symbol, runs it through the real `investigate.py -> run.py` grounding
path and a real LLM call, judges the actual output, and logs a real finding if it's
hijacked (daily via `redteam.yml`). See `agents/run.py::_build_grounding()` for the
untrusted-data framing this test verifies.
- **`skillforge/tools/ai-redteam/`** [OK] β€” garak (native `groq` generator), promptfoo (native
`groq:` provider, config generated from the real `VAPE_REPORT_SYSTEM`), and deepteam
(`vape_deepeval_model.py` wraps `agents/llm.py` as the simulator+judge β€” zero new
cost/secrets) all wired against VAPE's real production model, daily via
`redteam-deep.yml`. See `skillforge/skills/ai-agent-redteam.md`.
### 2. SKILLFORGE β€” `skillforge/` [OK] (self-improving skill+tool ecosystem)
Zero-local-compute skill growth via GitHub Actions. See `skillforge/MANIFEST.md`.
- **harvest** (hourly) β€” real CVE + tool-release intel, no LLM.
- **toolcheck** (6Γ—/day) β€” installs & verifies 13 security tools on runners, no LLM.
- **synthesize** (daily) β€” Groq distills harvested data β†’ opens a PR.
- **Tool tiers:** static (slither/aderyn/mythril) Β· fuzzing (echidna/foundry) Β·
ai-redteam (garak/promptfoo/deepteam) Β· recon (token_safety/contract_recon/wallet_trace/base_rpc/market_data).
- **Memory:** append-only `memory/` (tools-registry.json, findings/skills/lessons.jsonl, INDEX.md).
- **Skills:** playbooks in `skillforge/skills/` (sc-static-analysis, ai-agent-redteam, onchain-recon-forensics).
### 3. intel/ pipeline [OK] (the audit trail)
Timestamped real-data outputs committed continuously: `reports/`, `audits/poc-reports/`,
`broadcasts/`, `bounty-radar/`, `engagements/`, `catalog/`. Synced to the HF Space via
`sync-to-hub.yml`.
### 4. ACP job monitor [OK] (autonomous revenue)
Catches incoming ACP jobs and negotiates β†’ funds β†’ completes at near-zero compute.
3 layers: persistent `acp events listen` daemon (zero LLM) β†’ drain+triage loop (zero LLM)
β†’ reasoning handler that fires only on a real funded job. 14 live offerings; USDC escrow on Base.
*(Operational layer; runs on the host alongside the repo.)*
### 5. UI β€” `app.py` / `docs/` [OK]
Gradio app (`app.py`, `requirements.txt: gradio`) for the HF Space; `docs/index.html` is
VAPE's public site β€” narrative case-file pages over the same real data (investigations,
reputation, TVL, Intel Explorer), wallet connect + a wallet profile β€” portfolio, 24h P&L,
an Alchemy+CoinGecko-backed cost-basis estimate, and case history
(`docs/assets/wallet.js`/`profile.js`) β€” and hiring surfaces for both payment rails: an
x402 pay-per-call panel backed by `worker/` (Cloudflare Worker/Deno Deploy, see
`docs/DEPLOYMENT.md` section E) and an ACP panel surfacing the real job lifecycle in
`docs/ACP_PROTOCOL.md`.
Still zero-build β€” `docs/assets/*.js` are plain files, no bundler.
## Data-flow summary
Real sources β†’ engines analyze β†’ findings written to `intel/` (audit trail) and
SKILLFORGE memory (learning) β†’ surfaced via UI/broadcasts β†’ monetized via ACP jobs.
Every loop is grounded in **real data only** β€” no simulated or hypothetical output.
## Runtime map
| Runtime | Trigger | Compute | State |
|---|---|---|---|
| Python engine | GH Actions hourly | free runner | reports/ commits |
| SKILLFORGE | GH Actions (hourly/6x/daily) | free runner | skillforge/memory |
| ACP monitor | persistent daemon | ~zero idle | acp-monitor/state.json |
## Current vs. future
**Now:** autonomous hourly LLM+slither reports, SKILLFORGE 13-tool verification, intel
audit trail, ACP job monetization, self-review PRs.
**Next:** richer UI, external-target auditing (beyond self-repo), persistent
cross-run agent memory, full ACP deliverable automation.