feat: add greplica graph gc to prune stale knowledge-graph memory - #108
Open
burrows99 wants to merge 2 commits into
Open
feat: add greplica graph gc to prune stale knowledge-graph memory#108burrows99 wants to merge 2 commits into
greplica graph gc to prune stale knowledge-graph memory#108burrows99 wants to merge 2 commits into
Conversation
Adds a `graph gc [--dry-run]` command that removes memory a repo no longer supports: - stale anchors — components/claims whose `code_anchor` file was deleted (reuses the existing code-anchor audit for claims; adds the same check for component anchors) - orphaned claims/flows — no edge references them - dangling edges — an endpoint object no longer exists Pruning a subject cascades to every edge that touches it and runs in a single transaction. Object rows are global across repos (Autoloops#103), so gc only unlinks this repo's `graph_memberships` + repo-scoped `graph_object_embeddings` and deletes the shared row only when no membership anywhere still references it. `--dry-run` reports the plan without touching the database. Adds `scripts/check-graph-gc.js` (wired into `npm test`) covering all three defect classes, cascade cleanup, healthy-object safety, and idempotency. Closes Autoloops#24 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Author
|
Full gc-full.mp4 |
This was referenced Jul 22, 2026
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.
Closes #24.
greplica graph gc [--dry-run]prunes memory a repo no longer supports.What it detects
code_anchorfile no longer exists on disk. Reuses the existing code-anchor audit (auditClaimCodeAnchors, already behindgraph audit anchors) for claims, and adds the same file check for component anchors.Prune semantics
about/evidenced_byedges go with it), all in a single transaction.graph_memberships+ repo-scopedgraph_object_embeddings, and deletes the shared object row only when no membership anywhere still references it. No cross-repo damage.--dry-runreports the plan and touches nothing.Design note (the open question from the thread)
The issue says "permanently prunes," and #103 makes a naive global
DELETEdangerous. This PR reconciles both: hard-delete, but gated on no remaining references, so it reclaims rows without affecting other repos. Happy to switch to a pure retire-via-supersession model if maintainers prefer.Tests
scripts/check-graph-gc.js(wired intonpm test) seeds a temp DB with one of each defect class plus healthy objects, then asserts: dry-run counts + zero mutation, real run prunes exactly the defects with cascaded edges/memberships/embeddings, healthy objects untouched, and a second pass is a no-op.npm testandnpm run typecheckboth pass.Demo
Recording being attached in a comment.