Repository navigation
fix: keep retaining a source after an earlier memory's page moved - #244
Merged
Merged
Conversation
Comparing a new revision with earlier memories from the same source read every page those memories were first written to, beside the page each lives on now. The support slug deliberately records the original placement, so after a move, a fold into a folder or a removal that page no longer exists, and read threw not_found. Retain caught it as retain_apply_failed and held the whole revision, and every later revision of the source failed the same way. A page that no longer exists now contributes no lines. The earlier memory is compared where it lives now, one that no page carries any more is skipped as before, and any other read failure still fails the revision. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
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.
Summary
Before writing a new revision of a source, automatic retention compares it with the earlier memories from the same source group (
assessEarlierSupport). For each earlier memory it reads the page the memory lives on now, from themanaged_memory_entriesprojection, and also everyretain_supports.slug. That slug records where the memory was first written.retention-source-frame.tsnotes that it deliberately survives a page move.So after maintenance or a person moves that page, folds it into a folder of the same name, or removes it,
readthrowsnot_found. Nothing in that loop catches it, so the error reaches the catch-all inretain():degraded: ['retain_apply_failed'],reason_code: 'apply_failed', and the notesource apply failed: no page at <original slug>;This showed up in production as a conversation whose digests stopped saving anything after its earlier memories were reorganised.
Change
A
not_foundfrom that read now stands for a page that carries no lines:retain_supports.slugis left as the original placement on purpose. Rewriting it on move would change whatretention-source-frame.tsrelies on.Not changed
stageRetractionsalso locates a retraction target bysupport.slug. It does not throw. For a moved memory it holds the correction assource_unavailable("owned page is unavailable") instead of retracting at the new location. That is a separate limitation and is left for its own change.Tests
packages/core/test/retain.test.ts: retain a memory into a conversation group, move its page, then retain an extracted revision of the same group. It checks that the revision isokwith nodegradedreasons, and that the earlier memory is compared where it lives now. Before the fix it reproduced the production note exactly.pnpm typecheck,pnpm lint,pnpm check:repositoryand prettier pass.retain.test.tspasses 65/65.pnpm test: 5022 passed, 6 failed. All 6 were document-ingest/OCR tests that timed out at 30 s under full-suite load (ingest.test.ts,extractor-contract.test.ts). Run alone they pass 76/76.🤖 Generated with Claude Code