Heuristic:24kchengYe MemoMind Temporal Offset Uniqueness
| Knowledge Sources | |
|---|---|
| Domains | Retain_Pipeline, Temporal_Modeling |
| Last Updated | 2026-10-28 14:45 GMT |
Overview
Each extracted fact receives a 10ms temporal offset to preserve fact ordering and ensure unique timestamps across documents and within conversations.
Description
When facts are extracted from text, multiple facts from the same document or conversation share the same base `event_date`. Without disambiguation, temporal retrieval cannot distinguish between facts that occurred at "the same time." The `SECONDS_PER_FACT = 0.01` constant applies a monotonically increasing offset (by absolute position across all facts in a batch) to all temporal fields (`occurred_start`, `occurred_end`, `mentioned_at`). This preserves the original ordering of facts within and across documents while keeping timestamps unique.
Usage
Use this heuristic when processing retain batches — it is applied automatically by `_add_temporal_offsets()` after fact extraction. Relevant when debugging temporal retrieval ordering issues or when facts from the same conversation have identical timestamps.
The Insight (Rule of Thumb)
- Action: Apply a per-fact temporal offset of 0.01 seconds (10ms) to all temporal fields.
- Value: `SECONDS_PER_FACT = 0.01` — each fact gets `i * 0.01` seconds offset, where `i` is the absolute position across all facts in the batch.
- Trade-off: Timestamps are no longer exactly the LLM-extracted value but are shifted by up to a few seconds for large batches (e.g., 300 facts = 3s offset). This is negligible for real-world temporal queries.
- Compatibility: Applied to all fact types; offset uses absolute position across all contents in a retain batch for cross-document uniqueness.
Reasoning
LLM fact extraction returns multiple facts with the same `event_date` (e.g., all facts from a single conversation share one timestamp). Without unique timestamps, temporal retrieval (`ORDER BY occurred_start DESC`) returns facts in arbitrary order for identical timestamps, making it impossible to reconstruct conversation flow. The 10ms offset is small enough to be imperceptible for real-world temporal queries (which operate at day/week granularity) but large enough to ensure unique sort order. Using absolute position (not per-content position) ensures uniqueness across multiple documents in the same retain batch.
Code Evidence
Constant definition from `fact_extraction.py:1440-1441`:
# Each fact gets 10ms offset to preserve ordering within a document
SECONDS_PER_FACT = 0.01
Offset application from `fact_extraction.py:2052-2077`:
def _add_temporal_offsets(facts, contents):
"""Add time offsets to preserve fact ordering across all contents.
Uses absolute position across all facts to ensure unique timestamps.
"""
for i, fact in enumerate(facts):
offset = timedelta(seconds=i * SECONDS_PER_FACT)
if fact.occurred_start:
fact.occurred_start = parse_datetime_flexible(fact.occurred_start) + offset
if fact.occurred_end:
fact.occurred_end = parse_datetime_flexible(fact.occurred_end) + offset
if fact.mentioned_at:
fact.mentioned_at = parse_datetime_flexible(fact.mentioned_at) + offset