Repository navigation
fix(memory): apply eligibility filters before injection limits - #451
Merged
EyJunge1 merged 2 commits intoOct 28, 2026
Merged
Conversation
Use the indexed session_id column (with metadata fallback) for session exclusion, and keep pinned rows when merging per-shard limits.
7 tasks done
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
Memory injection currently applies session and age exclusions after limiting the candidate list. With
maxMemories: 3, three current-session memories can consume every slot and leave the injected project context empty even when older eligible memories exist.Pass optional eligibility filters through the memory client into the Turso query before each shard's limit. Preserve the existing project scope, strict age cutoff, pinned candidate selection, merged ordering, final cap, and profile-only injection. Ordinary memory listing remains unchanged.
Add native-database regression coverage for V1 and the shared V2 context loader, and document the behavior in the README and its five translations.
Test plan
Validated with Bun 1.3.14:
bun test tests/memory-injection-eligibility.test.ts tests/v2-memory-context.test.ts tests/profile-inject-empty-memories.test.ts tests/client-scope-traversal.test.ts: 24 passed, 0 failed. Covers session/age exclusions before limits, multiple shards, project isolation, bounded candidate counts, pins, legacy/malformed metadata, disabled filters, short results, and zero/empty profile-only context.bun run typecheck,bun run check, andbun run build: passed.bun test: 957 passed, 4 skipped, 1 failed. The suite is not fully green.Pre-existing failure:
tests/plugin-bundle-boundary.test.ts→does not pull local embedding transformer internals into the plugin-loader bundle. ItsBun.buildcall reports unresolved relative imports, including../services/logger.jsfromdist/v2/adapter.js.The same failure was reproduced on a pristine copy of upstream base
83c386bc6b048220a2e7d9309733e1acd6c608cb, using the same Bun version and locked dependencies, after compiling its distribution files withbunx tsc. Runningbun test tests/plugin-bundle-boundary.test.tsthere gives 2 passed, 1 failed with the same unresolved-import errors. No bundle-boundary code or tests are changed in this PR.Checklist
main(do not open PRs from commits already onmain)bun testpasses (or N/A)bun run typecheckpasses (or N/A)bun run checkpasses (format + lint + typecheck; or N/A)