> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anonalabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# What was true back then

> Every memory carries two clocks. Filter on when things happened, not just when you stored them.

[← All use cases](/use-cases/overview)

<div className="uc-examples"><a href="https://github.com/anonalabs/Anona-Memory-SDK/blob/main/examples/time_travel.py">time\_travel.py</a></div>

## The scenario

You import a year of history on a Tuesday. Every one of those memories was
*recorded* on Tuesday and *happened* months apart, and almost every interesting
question is about the second clock.

Three controls use the two clocks, and mixing them up is the usual bug.

## Step 1 — Write with the event's own time

```python theme={null}
client.record_batch(space_id=space, items=[
    {"content": "The June offsite settled on the pricing overhaul.", "timestamp": "2026-06-10T09:00:00Z"},
    {"content": "The December board meeting approved the London office.", "timestamp": "2025-12-04T15:00:00Z"},
])
```

`timestamp` is yours to set and means *when it happened*. The record time is the
system's and you cannot set it.

## Step 2 — Filter on event time

```python theme={null}
client.retrieve(
    space_id=space,
    query="what was decided?",
    occurred_after="2026-06-01T00:00:00Z",
    occurred_before="2026-07-01T00:00:00Z",
)
```

## Step 3 — Replay what the space knew

```python theme={null}
client.retrieve(space_id=space, query="what was decided?", as_of="2025-01-01T00:00:00Z")
```

`as_of` is **record** time, not event time. Both rows above were written today,
so a year ago the space knew nothing — and returning nothing is correct. This is
the control people expect to filter by event date, and it does not.

## Step 4 — Move "now"

```python theme={null}
client.retrieve(space_id=space, query="recent decisions", query_timestamp="2026-06-15T00:00:00Z")
```

`query_timestamp` re-ranks rather than filters: it moves the "now" that recency,
and phrases like *last quarter*, resolve against.

## Evals

1. Write two memories with event dates months apart, both today.
2. Window to one month. Assert only one returns.
3. `as_of` a date before you wrote them. Assert **nothing** returns — if
   something does, you are filtering on the wrong clock.
4. Move `query_timestamp` and check the ordering changes while the set does not.

## Guardrails

<Warning>
  **`as_of` and `occurred_before` answer different questions and look identical
  at the call site.** "What did we know then" is `as_of`; "what happened then" is
  `occurred_*`. Choosing wrong returns a plausible, wrong answer rather than an
  error.
</Warning>

* **Undated writes collapse to their write time**, so a backfill without
  `timestamp` makes every temporal question unanswerable and there is no bulk fix.
* **An event-time filter narrows hard.** If a window returns less than you
  expect, check the memories actually carry event time before tuning recall.

## The script

Complete and runnable:
[`time_travel.py`](https://github.com/anonalabs/Anona-Memory-SDK/blob/main/examples/time_travel.py).
