2 Commits

Author SHA1 Message Date
yoniebans
f7ed1995c7 feat(persistence): add the prompt-cache clock to the usage contract
SessionRecord gains prompt_cache_clock and SESSION_ROW_COLUMNS ends with it after transcript_revision, as main's sessions table does. UsageDelta gains prompt_cache_clock: a delta carrying one replaces the stored clock, one without leaves it, and the queue_usage contract states that deltas with different clocks apply in order and never merge, so the last applied clock is the stored one.

UsageRepository gains two reads with main's semantics: prompt_cache_clock(session_id) returns a PromptCacheClockRecord (the stored clock, the resume fallback last_assistant_at, which is the newest active assistant row time only while cache read plus write tokens are above zero, and the generation), None for an unknown session as the other usage reads answer; prompt_cache_generation(session_id) counts the session's compaction-archived rows, 0 for an unknown session.

WorkerMainUsage gains prompt_cache_clock, and record_usage documents the owner-side stamp: a clock that decodes to a JSON object is stored with its generation set to the owner's count at commit, any other text as sent, and the receipt digest covers the clock as sent.

The reference backend implements the field, both reads and the stamp; contract cases cover the round trip, ordering, the fallback gate, the generation count, scope isolation and the worker receipt.
2026-11-17 13:01:56 +01:00
yoniebans
d333146d3f feat(persistence): worker execution and delegation ledger operations 2026-11-17 13:01:55 +01:00