Skip to content

feat: injectable clock for stored timestamps and expiry - #4

Merged
apresmoi merged 4 commits into
mainfrom
feat/task-clock
Oct 11, 2026
Merged

apresmoi merged 4 commits into
mainfrom
feat/task-clock

Conversation

@apresmoi

Copy link
Copy Markdown
Collaborator

Adds an injectable epoch-millisecond clock so callers replaying a historical moment (training trials) can make Mneme observe task time instead of wall time.

  • MemoryClock, createOffsetClock({ origin, anchorMs }) and resolveClock exported from the package root.
  • Every data/visibility time read uses the clock: event createdAt, TTL expiry, causal recorded_at, authority expiry and consumed_at, MCP expiresAt, envelope nonce/expiry. Latency timing stays on real time.
  • mneme mcp --clock-origin <ISO> --clock-anchor-ms <ms> (env MNEME_CLOCK_ORIGIN / MNEME_CLOCK_ANCHOR_MS): advancing clock origin + (realNow - anchor); invalid values refuse startup.
  • One clock per composition: mixed custom clocks across supplied dependencies are refused; legacy clockless compositions are unchanged. Every sample is validated to stay within years 0000-9999.
  • Generated nonces now carry a random component, so they stay unique under a frozen clock.

No clock configured means behavior identical to before. Mneme stays independent of other repos (no runtime-specific names).

Consumers: Daimon (feat/task-clock) feature-detects createOffsetClock; it needs a release of this change.

@apresmoi
apresmoi merged commit 7f30dd8 into main Oct 11, 2026
1 check passed
@apresmoi apresmoi mentioned this pull request Oct 11, 2026
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