Skip to content

Verify: facets outlive the records they tag #465

Closed

Description

@possiblyneal

Part of #448

Question

Do Memory, Lesson and Observation deletes leave facet rows that facet queries still return, and is there no orphan sweep? Upstream: rohitg00#1589, rohitg00#1614, rohitg00#1624.

Activity

  1. self-assigned this
    on Nov 18, 2026
  2. possiblyneal commented on Nov 18, 2026

    @possiblyneal
    OwnerAuthor

    #465 verdict (worktree tmp/wt/verify-465, branch verify/465-facets, base fdc3d45)

    1589 Memory delete leaves facets

    • APPLY. Only facets.ts touched KV.facets (and export-import replace); governance-delete/bulk, forget, evict, retention-evict, auto-forget, observe cap-eviction never did, and facet-query/get/stats read raw rows.
    • Repro: test/facet-orphans.test.ts, 6 tests, fails 6/6 on base (governance-delete, forget by memoryId).
    • Fix: deleteFacetsForTargets(kv, ids) in facets.ts (by targetId, any targetType), called beside every existing evictGraphForSources site (governance x2, retention, auto-forget, evict, observe, remember/forget).

    1624 lesson delete / observation forget leave facets

    • APPLY, narrower than claimed. Lesson tombstones no longer exist here (decay sweep and tombstone purge hard-delete), so the soft-delete half is stale; mem::lesson-delete and purgeLessons did leave facets: now call the helper. Observation per-id and whole-Session forget are covered by the same call (tests "forget by observationIds", "forget of a whole Session", "lesson-delete").
    • Not done: a lesson targetType (public API; lessons are still tagged as "memory"). Retry if: the Operator wants Lesson tags labelled as such.

    1614 orphan sweep in memory_heal, facets/remove by targetId only

    • NOT APPLIED. Reach: live store copy has 0 facet rows (nothing auto-tags; only the manual memory_facet_tag tool writes them), so there is nothing pre-existing to sweep. facets/remove by targetId is an API change with no user. Retry if: a live store shows orphan facet rows from before this cascade (count with select count(*) from kv where scope='mem:facets').

    Class 2: no. Deletes only facet rows of already-deleted targets; Recall, Injection and Summaries do not read facets. eval:suite not needed.
    Cost: one extra kv.list(KV.facets) per delete batch (empty scope in the Operator's store).
    Verification: facet-orphans 6/6 pass; lessons, governance, forget, evict, retention, auto-forget, observe, facets tests pass (203 total in run; the one failure was my own test, fixed); typecheck 0 errors. Patch: tmp/verify/465/fix.patch.

    Bar (tmp/verify/465-verify.log; a duplicate run collided once and was discarded, the clean suite is tmp/wt/verify-465/tmp/eval-suite/fix465-fast): typecheck 0 errors; npm test Tests 3122 passed | 1 skipped (3123); eval:gate and eval:gate:rules pass; eval:suite fast vs base-fdc3d459: every metric Δ 0.000. Branch verify/465-facets (uncommitted, worktree tmp/wt/verify-465).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions