feat(foundry): memory investigation tooling and VFS pool spec

Add memory monitoring instrumentation, investigation findings, and
SQLite VFS pool design spec for addressing WASM SQLite memory spikes.

- Add /debug/memory endpoint and periodic memory logging (dev only)
- Add mem-monitor.sh script for continuous memory profiling with
  automatic heap snapshot capture on spike detection
- Add configureRunnerPool to registry setup for engine driver support
- Document memory investigation findings (per-actor cost, spike behavior)
- Write SQLite VFS pool spec for bin-packing actors onto shared WASM instances
- Add foundry-mem-monitor and foundry-dev-engine justfile recipes
- Add compose.dev.yaml engine driver and platform support

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nathan Flurry 2026-03-17 23:46:03 -07:00
parent 7b23e519c2
commit ee99d0b318
18 changed files with 888 additions and 496 deletions

View file

@ -2,6 +2,9 @@ name: foundry
services:
backend:
# Use linux/amd64 when RIVET_RUN_ENGINE=1 since the engine binary only
# ships for x86_64 Linux. Falls back to native platform otherwise.
platform: ${FOUNDRY_BACKEND_PLATFORM:-}
build:
context: ..
dockerfile: foundry/docker/backend.dev.Dockerfile
@ -11,6 +14,7 @@ services:
- path: .env
required: false
environment:
NODE_ENV: "development"
HF_BACKEND_HOST: "0.0.0.0"
HF_BACKEND_PORT: "7741"
RIVETKIT_STORAGE_PATH: "/root/.local/share/foundry/rivetkit"
@ -18,6 +22,10 @@ services:
RIVET_LOG_LEVEL: "${RIVET_LOG_LEVEL:-debug}"
RIVET_LOG_TIMESTAMP: "${RIVET_LOG_TIMESTAMP:-1}"
FOUNDRY_LOG_LEVEL: "${FOUNDRY_LOG_LEVEL:-debug}"
# Set RIVET_RUN_ENGINE=1 in .env or environment to use the Rust engine
# instead of the file-system driver. Eliminates native bun:sqlite KV
# overhead but WASM SQLite per-actor cost remains.
RIVET_RUN_ENGINE: "${RIVET_RUN_ENGINE:-}"
# Pass through credentials needed for agent execution + PR creation in dev/e2e.
# Do not hardcode secrets; set these in your environment when starting compose.
ANTHROPIC_API_KEY: "${ANTHROPIC_API_KEY:-}"