Title: memory_heal has no orphan-facet sweep, and facets/remove needs the full targetId+dimension+value triple · Issue #1614 · rohitg00/agentmemory · GitHub
Open Graph Title: memory_heal has no orphan-facet sweep, and facets/remove needs the full targetId+dimension+value triple · Issue #1614 · rohitg00/agentmemory
X Title: memory_heal has no orphan-facet sweep, and facets/remove needs the full targetId+dimension+value triple · Issue #1614 · rohitg00/agentmemory
Description: Summary #1589 was closed by #1591 for the new deletion paths, which is the important half — thanks for that. This tracks the two follow-ups that PR body explicitly left out: "The memory_heal orphan sweep and targetId-only facets/remove a...
Open Graph Description: Summary #1589 was closed by #1591 for the new deletion paths, which is the important half — thanks for that. This tracks the two follow-ups that PR body explicitly left out: "The memory_heal orphan...
X Description: Summary #1589 was closed by #1591 for the new deletion paths, which is the important half — thanks for that. This tracks the two follow-ups that PR body explicitly left out: "The memory_heal o...
Opengraph URL: https://github.com/rohitg00/agentmemory/issues/1614
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"memory_heal has no orphan-facet sweep, and facets/remove needs the full targetId+dimension+value triple","articleBody":"## Summary\n\n#1589 was closed by #1591 for the *new deletion* paths, which is the important half — thanks for that. This tracks the two follow-ups that PR body explicitly left out:\n\n> \"The `memory_heal` orphan sweep and `targetId`-only `facets/remove` are separate changes.\" — #1591\n\nBoth matter for existing stores, because a cascade fix cannot clean rows that were already orphaned before it landed.\n\n## 1. `memory_heal` cannot see facets\n\n`src/functions/diagnostics.ts` on `main` has **zero** occurrences of `facet`. The heal categories are actions / leases / sentinels / sketches / signals / sessions / memories / lessons / summaries / semantic / procedural / crystals / insights / mesh — facets are not among them, so there is no supported way to reclaim orphan facet rows.\n\nMeasured on 0.9.30 with 4 orphan rows present:\n\n```\nPOST /agentmemory/diagnostics/heal {\"dryRun\":true}\n -> {\"details\":[],\"fixed\":0,\"skipped\":0,\"success\":true}\nPOST /agentmemory/diagnostics/heal\n -> {\"details\":[],\"fixed\":0,\"skipped\":0,\"success\":true}\n```\n\nBoth runs report success while the orphans survive.\n\n## 2. `facets/remove` requires the full triple, unlike the query side\n\n```\nPOST /agentmemory/facets/query {\"matchAll\":[\"tool:\u003cname>\"],\"targetType\":\"memory\"}\n -> 200, returns the facet + targetId\n\nPOST /agentmemory/facets/remove {\"targetId\":\"\u003cid>\"}\n -> 400 {\"error\":\"targetId and dimension are required\"}\n\nPOST /agentmemory/facets/remove {\"targetId\":\"\u003cid>\",\"dimension\":\"tool\",\"value\":\"\u003cname>\"}\n -> 200 {\"removed\":1,\"success\":true}\n```\n\nSo the query API identifies a target by id alone, while removal needs you to already know every `(dimension, value)` pair it carries. For a target with N facets that is N calls, each of which has to be discovered from a query first.\n\n## Reproduction of the residue\n\n1. create a memory, tag it with two facets, confirm `facets/query` returns it\n2. delete the memory *before* #1591 landed → `{\"deleted\":1,...}`\n3. later, try to delete it again: `{\"deleted\":0,\"notFound\":[\"\u003cid>\"],\"success\":true}` — the body is gone\n4. `facets/query` for either facet value **still returns that targetId**\n5. `diagnostics/heal` dry-run and real both report `fixed:0`\n6. only per-facet `facets/remove` calls with the full triple clear them\n\n## Why it matters beyond hygiene\n\nA dedupe step that queries facets before writing (`xtool:true`, `tool:\u003cname>`) sees the orphan and concludes the entry already exists, so the real entry is never written. That is exactly how we hit it: an orphan made a compliant re-write look like a duplicate.\n\n## Proposed\n\n1. Add an orphan-facet sweep to `memory_heal`: scan `mem:facets`, drop rows whose `targetId` no longer resolves in the memories (and semantic) store. #1591 already ships the \"resolve first, then delete\" helper (`deleteFacetsForTargets`), so the sweep can reuse it.\n2. Either accept `targetId` alone on `facets/remove` (removing every facet for that target), or document the required triple next to the query API — the current asymmetry is easy to trip over.\n\nAlso worth folding in while it is open: #1591 notes observation, action and `mem:core` targets orphan the same way on their delete paths.\n\nHappy to test a patch against a store that has pre-existing orphans (we can produce them deterministically).","author":{"url":"https://github.com/7889545","@type":"Person","name":"7889545"},"datePublished":"2026-10-25T20:03:55Z","url":"https://github.com/rohitg00/agentmemory/issues/1614"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:fa98cae5-e019-4f03-84f6-53a070b64880 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9D96:2B1900:B7E81:EE928:6AEBDF9E |
| html-safe-nonce | 62b0133999a8171b4f95823184f3a5758de33091d96c3828478a94480520bed0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RDk2OjJCMTkwMDpCN0U4MTpFRTkyODo2QUVCREY5RSIsInZpc2l0b3JfaWQiOiI4MTM2Mzk0MjI0OTUzOTc0Njg2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 0dc248e71655cd7d6f0e18c18c94b3f3b372b3242158c66ceec6ec7e1ca0a040 |
| hovercard-subject-tag | issue:6028693138 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/rohitg00/agentmemory/1614/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2dc2fe40b3b90e158d25fa0b5837f90591219ac6eb163f1ddee61ce081a06ab9/rohitg00/agentmemory/issues/1614 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2dc2fe40b3b90e158d25fa0b5837f90591219ac6eb163f1ddee61ce081a06ab9/rohitg00/agentmemory/issues/1614 |
| og:image:alt | Summary #1589 was closed by #1591 for the new deletion paths, which is the important half — thanks for that. This tracks the two follow-ups that PR body explicitly left out: "The memory_heal orphan... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | 7889545 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 701f7e3aecc56e7594e73fa7b7e1483af74322a67f7038be453d0feb05e86e77 |
| turbo-cache-control | no-preview |
| go-import | github.com/rohitg00/agentmemory git https://github.com/rohitg00/agentmemory.git |
| octolytics-dimension-user_id | 48523873 |
| octolytics-dimension-user_login | rohitg00 |
| octolytics-dimension-repository_id | 1166408297 |
| octolytics-dimension-repository_nwo | rohitg00/agentmemory |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1166408297 |
| octolytics-dimension-repository_network_root_nwo | rohitg00/agentmemory |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 12d1048a3491dd63e4193b2937cf72f1c24a2a52 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width