Skip to content

fix(memory): apply eligibility filters before injection limits - #451

Merged
EyJunge1 merged 2 commits into
tickernelz:mainfrom
Phototonic:codex/fix-memory-eligibility-limit
Oct 28, 2026
Merged

EyJunge1 merged 2 commits into
tickernelz:mainfrom
Phototonic:codex/fix-memory-eligibility-limit

Conversation

@Phototonic

Copy link
Copy Markdown
Contributor

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

  • Exercised the change locally (or N/A for docs/meta-only)
  • Noted any follow-up or known limitations

Validated with Bun 1.3.14:

  • The original regression failed on the base implementation: both V1 and V2-loader assertions expected three eligible memories and received none.
  • 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, and bun run build: passed.
  • After building, 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. Its Bun.build call reports unresolved relative imports, including ../services/logger.js from dist/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 with bunx tsc. Running bun test tests/plugin-bundle-boundary.test.ts there gives 2 passed, 1 failed with the same unresolved-import errors. No bundle-boundary code or tests are changed in this PR.

Checklist

  • Branch is based on main (do not open PRs from commits already on main)
  • bun test passes (or N/A)
  • bun run typecheck passes (or N/A)
  • bun run check passes (format + lint + typecheck; or N/A)
  • Docs / README updated when behavior or contribution process changes

Phototonic and others added 2 commits October 28, 2026 17:15
Use the indexed session_id column (with metadata fallback) for session
exclusion, and keep pinned rows when merging per-shard limits.
@EyJunge1
EyJunge1 merged commit c1809c1 into tickernelz:main Oct 28, 2026
6 of 7 checks passed
@EyJunge1 EyJunge1 mentioned this pull request Oct 28, 2026
7 tasks done
@Phototonic
Phototonic deleted the codex/fix-memory-eligibility-limit branch October 28, 2026 23:10
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.

2 participants