Skip to content

fix(core): track deprecated_at for correct time-travel recall (#1086) - #1100

Merged
ajianaz merged 3 commits into
developfrom
fix/deprecated-at-schema
Aug 26, 2026
Merged

ajianaz merged 3 commits into
developfrom
fix/deprecated-at-schema

Conversation

@ajianaz

@ajianaz ajianaz commented Aug 26, 2026 •

Copy link
Copy Markdown
Collaborator

What (description of the change)

Fixes #1086 — time-travel recall (recall_at_time / memory_exists_at) incorrectly excluded any deprecated memory regardless of when it was deprecated. A memory deprecated after the point-in-time did exist at that moment and must still appear in historical recall.

  • Schema v17 — new deprecated_at TEXT column (schema.rs, store.rs): ALTER TABLE + backfill of legacy deprecated rows (deprecated_at = updated_at).
  • All deprecate paths now stamp deprecated_at = now (bulk.rs, edges.rs); restore clears it.
  • Memory type — new deprecated_at: Option<DateTime<Utc>> field, persisted in INSERT/SELECT row mapping.
  • Temporal predicate (core recall_at_time + server memory_exists_at): deprecated before pit → excluded; deprecated after pit → included; NULL treated as "after" (unreachable post-migration), identical in core and server.
  • recall_inner(include_deprecated) — internal variant so the temporal path fetches deprecated candidates and applies the time predicate itself; normal recall keeps filtering deprecated rows (unchanged).

Why (the problem you're solving)

The deprecation flag (deprecated = 1) is a boolean with no timestamp, so temporal predicates could not distinguish "deprecated before the pit" from "deprecated after the pit". Both were excluded — making time-travel recall return wrong history for any memory that was deprecated after the queried moment.

Testing (how you verified this works)

  • New regression test test_recall_at_time_deprecated_after_pit (core, no ONNX needed) — passes.
  • New server test at_time_includes_deprecated_after_pit; legacy at_time_excludes_deprecated updated to the new semantics — all pass.
  • cargo test --workspace — all pass (516 core + server + mcp).
  • cargo clippy --workspace --all-targets — clean; cargo fmt --all — clean.
  • Cora pre-commit review flagged NULL semantics twice — manually verified as false positive (v17 backfill guarantees no NULL+deprecated rows; core and server aligned).
Scenario Before After
Recall at pit, deprecated before pit excluded excluded ✅
Recall at pit, deprecated after pit excluded ❌ included ✅
Normal recall (deprecated rows) excluded excluded (unchanged)

Closes #1086

- Schema v17: add deprecated_at column, backfill legacy deprecated rows
- Set deprecated_at on all deprecate paths, clear on restore
- recall_at_time: memory deprecated AFTER the point-in-time now appears
  (previously any deprecated flag excluded it); deprecated BEFORE is excluded
- memory_exists_at handler: same temporal predicate
- recall_inner(include_deprecated) so temporal path sees deprecated rows
- Regression test (no ONNX dependency)
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 17e2f91 into develop Aug 26, 2026
14 checks passed
@ajianaz
ajianaz deleted the fix/deprecated-at-schema branch August 26, 2026 04:56
ajianaz added a commit that referenced this pull request Sep 6, 2026