Skip to main content

Module time

Module time 

Source
Expand description

Time — one generation point for every persisted timestamp.

Three canonical forms exist in the wild (see docs/TIMESTAMP_CONVENTIONS.md for the full per-surface registry):

  • Epoch milliseconds (now_unix_millis) — the default for new persisted event records (sessions, friction JSONL, the opencode corpus). Sub-second ordering matters for parallel sessions, and the opencode corpus we correlate against (Phase 4 archaeology) is millis.
  • Epoch seconds (now_unix_secs) — legacy schemas already fixed to seconds (karma chain, write-audit journal, sangha locks). Do not migrate casually: readers exist.
  • RFC 3339 (now_rfc3339) — human-facing coordination surfaces (lease ledgers, drill reports) where an agent reads the value with a bare eye.

Rules:

  1. Never hand-roll SystemTime::now() or Utc::now().timestamp*() at a write site — go through this module so the convention has one implementation.
  2. A persisted timestamp field’s doc comment names its unit.
  3. Cross-surface correlation converts through typed chrono::DateTime, never by comparing raw integers (the 1000× ambiguity class).

Functions§

new_operation_id
Generate a monotonic, time-ordered operation ID (UUIDv7 format) for end-to-end multi-step write sequence correlation and crash barrier detection (U6).
now_rfc3339
Current time as RFC 3339 with second precision and Z offset — human-facing coordination surfaces (lease ledgers, drill reports).
now_unix_millis
Current Unix time in milliseconds — the default for new persisted event records.
now_unix_secs
Current Unix time in seconds — legacy schemas fixed to seconds (karma chain, write-audit journal, sangha locks).