Skip to content

fix(storage): delete_neuron cascades to the fibers that list it - #236

Merged
acidkill merged 1 commit into
mainfrom
fix/delete-neuron-fiber-cascade
Sep 7, 2026
Merged

acidkill merged 1 commit into
mainfrom
fix/delete-neuron-fiber-cascade

Conversation

@acidkill

@acidkill acidkill commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • delete_neuron (SurrealDB + InMemory; delete_neurons_batch delegates; the HTTP route and shared_store go through the SurrealDB path) sheds the deleted id from every fiber.neuron_ids.
  • A fiber losing its ANCHOR is soft-forgotten the same way smem_forget does it — the typed_memory row's expires_at is set to now so it leaves recall immediately — and carries an _anchor_deleted metadata tombstone; graph-only fibers keep at least the marker.
  • find_cross_cluster_links drops anchors that no longer resolve before minting RELATED_TO edges.
  • New 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 format clean; mypy — only the pre-existing google.genai noise.
  • Storage-parity meta-test green (repair method on both backends).

Verified by

@acidkill

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
@acidkill
acidkill merged commit 1bd9a12 into main Sep 7, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

delete_neuron leaves the neuron in every fiber that lists it

1 participant