feat minor bridge feat/phase-2g-bundle
AI Agent git-import/068377df · 112 days ago · Apr 5, 2026 · Diff

feat(bridge): Netlify Blobs-backed memory events + cost tracking for hosted

The bridge was crashing with ENOENT /var/task/data/consolidation because saveConsolidationCost() tried to mkdir on the read-only Lambda filesystem. Beyond the crash, all memory events were lost between Lambda invocations (ephemeral /tmp) so consolidation always saw 0 events.

Full Blobs-backed hosted path:

- blobsGetMemoryEvents / blobsSetMemoryEvents / blobsAppendMemoryEvent: store memory events as a JSON array in Netlify Blobs under memory/{uid}/{vaultId}/events — capped at 500, durable across cold starts

- loadConsolidationCost / saveConsolidationCost: use Blobs when __netlify_blob_store is set, file fallback for self-hosted — no more mkdir crash on /var/task/data/consolidation

- fireBridgeCaptureEvent: appends to Blobs on hosted (durable), falls back to FileMemoryProvider on self-hosted

- POST /api/v1/memory/consolidate: loads Blobs events into a temp FileMemoryProvider, runs consolidateMemory against it, syncs remaining (post-consolidation) events back to Blobs — complete round-trip

- GET /api/v1/memory: reads from Blobs on hosted, file on self-hosted

- consolidationConfig.data_dir: uses os.tmpdir() on hosted path (writable)

Detection: globalThis.__netlify_blob_store (set by netlify/functions/bridge.mjs before each invocation) — 100% reliable, no env var guessing needed.

sha256:40af1b2eaeefe5ad8fa949db0a41e26f492702d82d0547078a033687b40e2628 sha
sha256:5f397e0c51340bd006e8642bb2a08d7492ff726f03e5592a297730ada2f3fbcf snapshot
← Older Oldest on feat/phase-2g-bundle
All commits
Newer → Latest on feat/phase-2g-bundle

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:40af1b2eaeefe5ad8fa949db0a41e26f492702d82d0547078a033687b40e2628 --body "your comment"