fix(soul): ratio guard against genesis seeding over a populated engram #21
Reference in New Issue
Block a user
Delete Branch "feat/connectors-soul"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Data-safety guard for the genesis boot path (2026-06-15 engram-clobber work).
Problem
Genesis boot seeds a fresh identity and saves it over snapshot.json whenever the
in-memory graph looks empty. A fixed node-count threshold (50) missed partial
loads, letting a sparse boot clobber the populated 47MB engram down to ~63 nodes.
This change
Replace the fixed threshold with a ratio guard: refuse to seed when the on-disk
snapshot is large (>200KB) but the loaded graph is sparse (< disk/16000 nodes).
Known limitation (read before merging)
This gates only the seed / pre-serve-save path. Root cause is deeper: engram_save
in el_runtime.c is non-atomic — fopen(p,"wb") truncates the file to 0 before
writing 47MB, so a concurrent load can read an empty file → genesis → and if the
guard reads guard_disk in that same window it also sees empty and passes. The real
fix is an ATOMIC engram_save (temp + fsync + rename) in el_runtime.c, which I have
diagnosed and proposed to Will but not yet implemented (held pending his review).
Until that lands, the live founder engram is protected by: this guard + the
neuron-daemons.sh TRIPWIRE (restore-from-golden) + a read-only snapshot stopgap +
a locked golden lifeline.
🤖 Generated with Claude Code
Adds the soul side of the connectors feature (spec: docs/research/ mcp-connectors-adoption-spec.md). The soul thin-proxies the neuron-connectd bridge on 127.0.0.1:7771 so the UI talks to one origin and never reaches the bridge directly. routes.el: - handle_connectors + connectd_get/connectd_post helpers (POST bodies go via a temp file + curl -d @file, so model/UI input can't reach the shell). - GET /api/connectors and POST /api/connectors/{add,toggle,auto-approve, remove,secret,oauth/start} registered in both GET and POST routers. chat.el: - tool_auto_approved(): an mcp__* tool skips the approval card only when its server is explicitly opted in (off by default; built-in tools unaffected; bridge down -> false). Wired into the agentic approval gate so an auto-approved connector tool flows straight to execution. Regenerated dist/chat.c and dist/routes.c. Verified live on :7770: real chat, recall, and /api/connectors all work after promotion. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.