fix(storage): delete_neuron cascades to the fibers that list it - #236
Merged
Merged
Conversation
A deleted neuron left its id in every fiber.neuron_ids: fiber counts drifted, prune's orphan-protection set grew monotonically, and each enrichment pass minted fresh RELATED_TO edges pointing at the missing anchor. The delete path now sheds the id everywhere; a fiber whose ANCHOR was deleted is soft-forgotten exactly the way smem_forget does it (the typed_memory row's expires_at plus an _anchor_deleted metadata tombstone) instead of being left claiming a member that no longer exists. Enrichment additionally refuses to link anchors that do not resolve, and repair_fiber_member_drift() converges databases that accumulated drift before the cascade existed — implemented on both persistent backends (the storage-parity meta-test keeps them symmetrical). Closes #194
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
delete_neuron(SurrealDB + InMemory;delete_neurons_batchdelegates; the HTTP route and shared_store go through the SurrealDB path) sheds the deleted id from everyfiber.neuron_ids.smem_forgetdoes it — the typed_memory row'sexpires_atis set to now so it leaves recall immediately — and carries an_anchor_deletedmetadata tombstone; graph-only fibers keep at least the marker.find_cross_cluster_linksdrops anchors that no longer resolve before minting RELATED_TO edges.repair_fiber_member_drift()on BOTH persistent backends (parity meta-test enforced) converges databases that accumulated dangling members before this fix — planned to run against production during the next deploy.Why
Closes #194. Consequences ranked by the reporter: counts drift (
len(fiber.neuron_ids)overstates), prune's protected-set bloats monotonically, and enrichment manufactures stale references — each pass re-created persistent edges at deleted anchors. Cleanup belongs on the delete path because consumers cannot distinguish a deleted id from a failed read.Test plan
pytest tests/ -m "not stress" -n auto— 7348 passed (4 unit: member-shed keeps fiber, anchor-delete soft-forgets + tombstones, synapse/state cascade intact, enrichment never links dead anchors; plus a live SurrealDB test registered in the cleanup set, exercised by the Integration job).ruff check/ruff formatclean;mypy— only the pre-existing google.genai noise.Verified by
@acidkill