Files
Dragan Spiridonov ce1222a7c4 fix(learning): stop brain-export hook leak + harden DB backups on virtiofs mount
Real-time hook learning-capture was failing on this macOS Docker bind mount
with `Failed to initialize UnifiedMemoryManager: database is locked`, and a
brain-checkpoint hook was leaking deadlocked `brain export` subprocesses
(4 found, ~1.5GB RSS). Root cause is SQLite concurrency on a WAL-hostile
virtiofs mount, NOT a native-binary mismatch (better-sqlite3 loads fine).

- brain-checkpoint.cjs: add AQE_DISABLE_BRAIN_CHECKPOINT env / marker-file kill
  switch (opt-in; shipped installs unaffected). The export spawns a native RVF
  writer that deadlocks in a futex and ignores the SIGTERM the timeout sends,
  so orphaned exporters piled up. Disabling stops the leak at the source.
- aqe-hook.cjs: make the FATAL health-log fix-hint conditional. Only suggest
  `npm rebuild better-sqlite3` for real native markers; lock-contention
  failures now point at the actual cause instead of sending users down the
  wrong path.
- feature-flags.ts: add the missing RUVECTOR_USE_RVF_PATTERN_STORE env override
  (the only RuVector flag lacking one) so an RVF FsyncFailed can fall back to
  the SQLite HNSW PatternStore. Activates after build.
- scripts/aqe-db-backup.sh: consistent VACUUM INTO snapshots (safe with
  concurrent writers), integrity-verified before promotion, rotating + daily,
  to the host mount so they survive container loss. Restore round-trip tested.
- devcontainer.json: auto-restart the backup loop (postStartCommand) and set
  bind-mount env mitigations (remoteEnv: AQE_DISABLE_WAL,
  RUVECTOR_USE_RVF_PATTERN_STORE=false, AQE_DISABLE_BRAIN_CHECKPOINT).
- learning-config.json: clear the stale rebuildMode flag (no src reader; on
  since 2025-12).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 15:22:43 +00:00

66 lines
2.6 KiB
JSON

{
"name": "Basic Development DevPod",
"image": "mcr.microsoft.com/devcontainers/base:debian12",
"runArgs": [
"--privileged",
"--memory=8g",
"--memory-swap=12g",
"--memory-reservation=4g",
"--cpus=3",
"--oom-kill-disable=false",
"--memory-swappiness=60"
],
"remoteUser": "vscode",
// Environment mitigations for this macOS virtiofs bind mount (see the
// postStartCommand backup loop and .agentic-qe/DISABLE_BRAIN_CHECKPOINT):
// - AQE_DISABLE_WAL: rollback-journal instead of WAL (WAL mmap corrupts here).
// - RUVECTOR_USE_RVF_PATTERN_STORE=false: RVF native init FsyncFails on this
// mount; fall back to SQLite HNSW. (Takes effect after `npm run build`.)
// - AQE_DISABLE_BRAIN_CHECKPOINT: stop the leaking `brain export` hook.
"remoteEnv": {
"AQE_DISABLE_WAL": "1",
"RUVECTOR_USE_RVF_PATTERN_STORE": "false",
"AQE_DISABLE_BRAIN_CHECKPOINT": "1"
},
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/devcontainers/features/python:1": {}
},
"hostRequirements": {
"memory": "8gb",
"cpus": 3,
"storage": "64gb"
},
"customizations": {
"vscode": {
"extensions": [
"rooveterinaryinc.roo-cline",
"vsls-contrib.gistfs",
"github.copilot",
"anthropic.claude-code",
"codeflow-studio.claude-code-extension",
"suzuki0430.ccusage-vscode"
]
}
},
// node_modules lives in a named volume so the container installs its own
// (Linux) native binaries instead of seeing the host's (e.g. macOS) ones
// via the workspace bind mount. The host's node_modules is untouched.
// The volume is root-owned on first creation, hence the chown before npm ci.
"postCreateCommand": "sudo chown vscode:vscode node_modules && bash .devcontainer/install-tools.sh && npm ci",
// Auto-restart the verified learning-DB backup loop on every container start.
// memory.db lives on the macOS virtiofs bind mount (WAL-corruption prone), so
// scripts/aqe-db-backup.sh takes consistent, integrity-checked snapshots to
// .agentic-qe/backups/verified/ every 30 min — durable if the container dies.
// Idempotent: skips if a loop is already running.
"postStartCommand": "pgrep -f 'aqe-db-backup.sh loop' >/dev/null || (nohup bash scripts/aqe-db-backup.sh loop 1800 >/dev/null 2>&1 &)",
"shutdownAction": "none",
"mounts": [
"source=agentic-qe-node-modules,target=${containerWorkspaceFolder}/node_modules,type=volume"
],
"capAdd": [
"SYS_ADMIN",
"SYS_PTRACE"
]
}