Skip to content

[codex] Fix search date filters to use event dates#2192

Draft
TheLordArgus wants to merge 1 commit into
garrytan:masterfrom
TheLordArgus:codex/fix-temporal-search-filters
Draft

[codex] Fix search date filters to use event dates#2192
TheLordArgus wants to merge 1 commit into
garrytan:masterfrom
TheLordArgus:codex/fix-temporal-search-filters

Conversation

@TheLordArgus

Copy link
Copy Markdown

Summary

Fixes temporal search filtering so since / until operate on page event time first, using effective_date before falling back to updated_at / created_at. It also makes the lower bound inclusive and normalizes plain YYYY-MM-DD until values to the next day for the existing exclusive upper-bound comparison.

Root Cause

The Postgres search paths were filtering dates against COALESCE(p.updated_at, p.created_at), so recently reimported or refreshed pages could appear in a recent-event query even when their actual effective_date was old. PGLite already used effective_date, but its lower bound was exclusive.

Impact

Temporal queries such as "what happened since May 20" can otherwise include old pages that were merely touched recently, or miss events that fall exactly on the lower-bound date.

Changes

  • Use COALESCE(p.effective_date, p.updated_at, p.created_at) in Postgres search date filters.
  • Make lower bounds inclusive in Postgres and PGLite.
  • Normalize plain-date until values to the next-day timestamp before passing them to the exclusive upper-bound engine filter.
  • Add a regression that inserts an old event refreshed during the test and verifies it is excluded by a May afterDate, while the boundary date is included.

Validation

  • bun test test/chunk-grain-fts.test.ts

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.

1 participant