engram: add /api/nodes/reseed so a node body can be repaired at its own id #92
Reference in New Issue
Block a user
Delete Branch "feat/engram-reseed-route"
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?
What
Adds
POST /api/nodes/reseed— the only way to put a body on a node id that already exists.Why
Two write paths could put a node in the graph and neither could repair one.
POST /api/nodesmints a fresh id viaengram_node_full.POST /api/load-mergehonors a declared id but skips anything already present. Correct for the additive case; it leaves a hole.Forge's genesis seed sits in that hole. Two of Neuron's identity nodes are resident carrying only their own label as content — 30 and 22 bytes against 4263 and 2590 declared. Their ids are load-bearing:
is_protected_node()keys on exact ids and 214 declared edges reference them. Recreating them under a new id is not a repair, it is a second break.How
Engram has no in-place node update, so a replace is forget-then-merge.
engram_forgetalso drops every incident edge — 85 and 93 on those two nodes, nearly all tag edges and accumulated hebbian associations the seed does not declare and could not restore.preserve_edges(defaulttrue) therefore snapshots before the forget and re-merges after: the replaced node is back by then so it is skipped, and every dropped edge returns through the(from_id, to_id, relation)dedup. The same re-merge is the failure path — if the seed merge does not produce the node, the backup puts the original back. Rollback, not data loss.With no
replacelist the route is exactly/api/load-merge.Classification stays in the caller — the route is mechanism, not policy. Ids in
replacethat are not resident are no-ops, so a typo cannot produce a silent partial run.Verification
Sandbox engram (throwaway port, throwaway data dir) seeded to mirror the live graph's state for this seed — 15 resident declared nodes including the 2 hollow ones, and all 694 of their real incident edges:
nodes_added: 0, edges_added: 0Also compiled and smoke-tested from this branch's base (
origin/main), not just from the working tree it was written in.No prod or stage writes.
Branch note
Branched from
origin/mainrather than the local engram working branch, which is 19 commits ahead of its remote and 27 behind main. That divergence is pre-existing and untouched here; this PR is one file so it can land independently of it.