oc_chat
Loading...
Searching...
No Matches
oc_chat.registry.clock Namespace Reference

Classes

class  Clock
class  RealClock
class  FakeClock

Functions

str _rfc3339_from_time_ns (int value)
str wall_plus_seconds (str wall, int seconds)

Detailed Description

Injectable clock service for registry code.

Purpose
-------
Centralize all wall-clock and monotonic reads used by the registry so
tests can pin time and production code never reads time directly.

Responsibilities
----------------
- Define the two-read :class:`Clock` contract.
- Provide :class:`RealClock` backed by Python timers.
- Provide :class:`FakeClock` for deterministic tests.
- Provide wall-time arithmetic helpers so other registry modules do not
  import time or datetime directly.

Diagnostics
-----------
Domain: OC_CHAT.MAIN
Levels:
    L2 - lifecycle events
    L3 - semantic details
    L4 - deep tracing

Contracts
---------
- This is the only module under ``oc_chat.registry`` allowed to import
  ``time`` or ``datetime``.
- ``now_wall`` returns explicit RFC3339 UTC ending in ``Z``.
- ``state_version`` ordering is an integer counter; monotonic timing is
  available for timeout logic and wall time is only stored as text.

Dependencies
------------
- oc_diagnostics (structured debug logging via _dbg)
- time (wall-clock and monotonic nanosecond reads for RealClock)
- datetime (RFC3339 UTC formatting, parsing and wall-time arithmetic)

Function Documentation

◆ _rfc3339_from_time_ns()

str oc_chat.registry.clock._rfc3339_from_time_ns ( int value)
protected

Definition at line 69 of file clock.py.

Here is the caller graph for this function:

◆ wall_plus_seconds()

str oc_chat.registry.clock.wall_plus_seconds ( str wall,
int seconds )
Return ``wall`` plus ``seconds`` as RFC3339 UTC.

Definition at line 77 of file clock.py.