api/
FastAPI backend. Serves the built React bundle at / and the Marimo notebook at /notebook (when installed). All routers mounted under /api/*, plus a WebSocket at /ws/tasks/{task_id}.
Routers
Prefix |
Responsibility |
|---|---|
|
Scan, list protocols, list phases. |
|
Run, consensus, verify-key, auto-export. |
|
Hex, entropy, strings, structure overlay, VAS, module / process / connection / handle tables. |
|
Heap allocator analysis: allocator detection ( |
|
|
|
Background-task status + cancellation. A pipeline task record ( |
|
Multipart upload → MSL convert. |
|
Packet-capture upload ( |
|
Browse and discover files. |
|
Probe images, select a profile, open a kernel or process view, and extract processes. |
|
Run Volatility plugins, manage case source and versions, and register a reviewed synthesis result. |
|
Structure library + Kaitai import/export. |
|
Static check, pattern generate, export (YARA / JSON / Vol3). |
|
Incremental Welford consensus sessions. |
|
|
|
BYO-oracle registry: bundled examples ( |
|
Phase-25 pipeline orchestration. |
|
SPA experiment runner — spawn target, dump, analyze per tool, verify, emit Volatility3 plugins. |
|
Run an emitted YARA rule over dumps ( |
|
User-chosen server settings persisted in |
|
Serves the repo’s |
|
WebSocket progress stream (ring buffer + HTTP fallback). The terminal frame for a task that ended in an earlier server life carries the record’s |
|
HTTP backfill endpoint registered by the same WS router; returns buffered events when the WebSocket ring has rolled past a client’s last-seen sequence. |
|
Top-level status probe reporting whether the Marimo notebook mount at |
Progress bus
Background tasks run in a shared ProcessPoolExecutor with an asyncio.Semaphore(1) gating outer runs. Progress events (stage_start, progress, stage_end, funnel, nsweep_point, oracle_tick, oracle_hit, artifact, done, error) flow through a ProgressBus with per-task 512-event ring buffers.
Memory-budget guard
Consensus-building routes estimate their peak memory and refuse when it exceeds the budget (MEMDIVER_MEMORY_BUDGET_MB, see Configuration and environment variables). The refusal is a CapabilityError with code: "memory_budget_exceeded", which the global handler in api/main.py maps to HTTP 507 with a flat body (api/memory_budget_errors.py):
{"error": "...", "code": "memory_budget_exceeded", "category": "PRECONDITION",
"message": "...", "estimate_bytes": 123, "budget_bytes": 45, "details": {"operation": "...", "breakdown": {}, "source": "..."}}
Routes that translate other CapabilityErrors to {"detail"} locally re-raise this one so it always stays a 507. To run anyway, re-send the same request with force_memory: true (the MemoryOverrideFields mixin). It is accepted by /api/analysis/consensus, /consensus/aligned-window, /consensus/regions, /candidates, /auto-export, /run, /api/pipeline/run, /api/experiment/run and /api/consensus/begin, where force remains an alias. Background tasks get force_memory in their params. A task that fails on the guard records error (the message) plus error_info: {code, estimate_bytes, budget_bytes, details} on its task record, and its terminal error event carries the same dict as extra.
Persistence
Task records are atomically persisted to <task_root>/<id>/record.json; orphan PENDING / RUNNING records are reset to FAILED on app restart.
Uploaded oracles are persisted as <oracle_dir>/<uuid>.py plus a <uuid>.json metadata sidecar, and are restored on restart (re-hashed against the stored sha256, and always restored unarmed). .py files without a sidecar are reported as orphans by GET /api/oracles/status and removed only on request (DELETE /api/oracles/orphans).
Shutdown
memdiver web bounds uvicorn’s graceful shutdown with MEMDIVER_WEB_GRACEFUL_TIMEOUT_S (default 10 s); the lifespan then closes the task manager, the oracle registry and the cached dump readers. The task manager’s process-pool workers and multiprocessing manager child run a parent-death watchdog (core/process_guard.py), so they exit even if the server is killed with SIGKILL. Details: Shutdown and child processes.
Middleware
CORS —
CORSMiddlewarewithallow_origins=settings.cors_origins(default["http://localhost:5173"]; a literal"*"is dropped), credentials allowed, methodsGET/POST/PUT/DELETE/OPTIONS(PUTis used byPUT /api/settings/last-dir;PATCHis not allowed), headersContent-Type/Authorization/X-API-Key.GZip —
GZipMiddlewarewithminimum_size=1000.Host allow-list —
HostAllowListMiddleware(pure ASGI, HTTP + WebSocket, always on) refuses anyHostthat is not127.0.0.1/localhost/::1(any port),MEMDIVER_ALLOWED_HOSTS, or a guarded non-loopback bind host, with421(DNS-rebinding defence).Cross-site guard —
CrossSiteRequestGuard(pure ASGI, always on) refuses non-safe requests and WebSocket handshakes withSec-Fetch-Site: cross-siteor anOriginthat is not same-origin withHost, not incors_originsand not the Vite dev origin (localhost/127.0.0.1onMEMDIVER_FRONTEND_PORT/FRONTEND_PORT/5173) — loopback origins on other ports are refused (403), and non-empty bodies typedtext/plain/form-urlencoded/missing (415). Both run outermost. See Security model.Read-path sandbox — opt-in (
MEMDIVER_ALLOWED_ROOTS); a router-level dependency (api/path_policy.enforce_request_read_paths) on every router taking read paths.Token auth —
ApiTokenAuthMiddlewareis a no-op unlessMEMDIVER_API_TOKENis set; then every/api,/wsand/notebookroute requires the token (Authorization: Bearer …orX-API-Key: …; WebSockets may pass?token=…)./health,/docs,/redoc,/openapi.jsonand the static bundle stay open.memdiver webrefuses a non-loopbackMEMDIVER_HOSTwithout a token unlessMEMDIVER_ALLOW_INSECUREis set (api/security.py).
Configuration
All settings come from api/config.py (MEMDIVER_* environment variables or .env). The full list, with defaults and effects, is in Configuration and environment variables.
OpenAPI
/docs (Swagger), /redoc (ReDoc), /openapi.json.