Skip to content

Memory search excludes chunks whose known parent is not served - #924

Closed
zlareb1 wants to merge 12 commits into
mainfrom
fix/chunk-parent-serving-state
Closed

zlareb1 wants to merge 12 commits into
mainfrom
fix/chunk-parent-serving-state

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in a release)

Changelog entry

Memory search excludes conversation chunks whose known parent is rejected, superseded, proposed or otherwise outside the read's served states. Explicit inclusion flags and historical reads use the same status and time rules as facts.

Why

The chunk leg checked parent state only for hard tags or historical reads. An ordinary search could therefore return a retired fact's text through its conversation chunk.

Scope and risk

Candidate selection, final reads and neighbour windows share a parent-state predicate over canonical memory heads. The match includes agent, user, session and key within the org and namespace; a different writer or session cannot hide a passage. Session-only evidence remains eligible. Anonymous user and session spellings match the same parent identity. Blank-session ingests retain their independent generated session ids. Projections without a matching canonical parent remain session evidence; this change does not infer or repair those parent identities. Point-write chunks retain their existing current-value check in the pool.

The parent-state check adds a scoped metadata subquery to each chunk statement. It changes eligibility, without changing ranking weights. Populated integration cases cover live neighbours, rejected and retired parents, inclusion flags, historical reads, hard tags and identity collisions.

Compatibility, rollout and rollback

  • Wire: no operations or fields change.
  • Operator steps: none. No migration or re-index is required.
  • Rollback: reverting restores the earlier chunk eligibility; stored rows are unchanged.

Tests

  • Focused chunk, identity-projection, two-stage retrieval, search-service, point-write chunk, provenance, timestamp and SQL-snapshot tests: The focused retrieval and SQL-snapshot checks pass all 119 non-producer cases. All six producer-identity cases pass with the unchanged writer, including distinct and readable identities for independent blank-session ingests.
  • Regression tests failed before the implementation. The neighbour-window assertion checks its own bound predicates; an anonymous-identity comparison inside the independent parent subquery is valid.
  • Changed-file Ruff checks and the function-length gate pass.
  • Nine populated ClickHouse integration cases and analyzer validation run in CI. Their vector fixtures supply the stored codecs' 3,072 dimensions for value and key embeddings. No local server or ClickHouse was started.
  • The SQL-shape snapshot was regenerated after resource capacity recovered. Its diff contains only chunk statements; all corpus cases render and every tested axis changes a statement shape.
  • Broad local suites were left to CI at the owner's request.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated: Codex wrote the implementation and tests. Independent review and full CI qualify the submitted head.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed.
  • SQL-shape snapshot regenerated and its diff verified.
  • No migration is added.
  • No plugin behaviour changes.
  • No frontend changes.
  • Docs describe the implemented parent-state filter.
  • Repository text contains no internal deployment details.
  • Commits are signed off.

@zlareb1
zlareb1 marked this pull request as ready for review November 18, 2026 21:17
@zlareb1 zlareb1 mentioned this pull request Nov 18, 2026
6 tasks done
@zlareb1 zlareb1 closed this Nov 20, 2026
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.

1 participant