Commit a76636e
fix(temporal): review findings — pure-read temporal recall + hardened valid-period writes (#363)
Finding 1 (#356-class value inversion): handle_recall applied the valid-time
filter AFTER db.recall(), whose fts5 path (and dense/hybrid with reinforce)
reinforces every matched row — so `recall {query, valid_at:T}` bumped
retrieval_count/decay/layer on entities the filter then hid, making invisible
entities immortal under repeated temporal queries. The inner recall is now
forced to a pure read whenever a valid-time filter is present, and the
deferred side-effects are applied to the SURVIVING hits only (fts5 always,
dense/hybrid only with reinforce:true), mirroring the expansion path.
Unfiltered calls keep the original behavior byte-for-byte.
Finding 2 (inverted/extended valid periods):
- mimir_correct now rejects valid_to <= valid_from (same error shape as
remember) — an inverted period would shadow older versions in bitemporal_at
while never matching itself, making the fact unanswerable.
- mimir_supersede validates an explicit valid_to against the old fact's
stored period BEFORE any mutation: rejects valid_to <= valid_from and
rejects extending an already-closed period (tighten-only).
- db.set_valid_to is now conservative by construction: errors on inversion,
never extends an already-bounded valid_to (keeps the earlier close and
reports it), allows tightening. The default supersede close is bumped
strictly past valid_from so a same-millisecond supersede stays coherent.
Review nits: valid_op is validated against the closed enum (unknown strings
rejected instead of silently meaning overlaps); the misplaced entity_from_row
doc comment is restored (it had attached to TemporalVersion).
Tests: 203 -> 208 — hidden-entity non-reinforcement, unfiltered-recall
behavior identity (side-effects + result set), unknown valid_op rejection,
inverted-period rejection on correct, and the full supersede matrix
(invert-reject pre-mutation, extend-reject, default keeps earlier close,
tighten allowed). Temporal gate still 100% (20/20, identical signature).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 6205151 commit a76636e
3 files changed
Lines changed: 329 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3482 | 3482 | | |
3483 | 3483 | | |
3484 | 3484 | | |
3485 | | - | |
| 3485 | + | |
| 3486 | + | |
| 3487 | + | |
| 3488 | + | |
| 3489 | + | |
| 3490 | + | |
| 3491 | + | |
| 3492 | + | |
| 3493 | + | |
| 3494 | + | |
| 3495 | + | |
| 3496 | + | |
| 3497 | + | |
3486 | 3498 | | |
| 3499 | + | |
| 3500 | + | |
| 3501 | + | |
| 3502 | + | |
| 3503 | + | |
| 3504 | + | |
| 3505 | + | |
| 3506 | + | |
| 3507 | + | |
| 3508 | + | |
| 3509 | + | |
| 3510 | + | |
| 3511 | + | |
| 3512 | + | |
| 3513 | + | |
| 3514 | + | |
| 3515 | + | |
| 3516 | + | |
| 3517 | + | |
| 3518 | + | |
| 3519 | + | |
3487 | 3520 | | |
3488 | 3521 | | |
3489 | 3522 | | |
3490 | 3523 | | |
3491 | | - | |
| 3524 | + | |
3492 | 3525 | | |
3493 | 3526 | | |
3494 | 3527 | | |
| |||
6827 | 6860 | | |
6828 | 6861 | | |
6829 | 6862 | | |
6830 | | - | |
6831 | 6863 | | |
6832 | 6864 | | |
6833 | 6865 | | |
| |||
6886 | 6918 | | |
6887 | 6919 | | |
6888 | 6920 | | |
| 6921 | + | |
6889 | 6922 | | |
6890 | 6923 | | |
6891 | 6924 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3119 | 3119 | | |
3120 | 3120 | | |
3121 | 3121 | | |
3122 | | - | |
| 3122 | + | |
3123 | 3123 | | |
3124 | 3124 | | |
3125 | 3125 | | |
| |||
0 commit comments