Skip to main content

Module jsonl

Module jsonl 

Source
Expand description

JSONL transcript aggregator — terminal fallback for the rate-limit data pipeline.

Canonical spec: docs/specs/jsonl-aggregation.md. Ports the billing-block math from ryoppippi/ccusage’s _session-blocks.ts (MIT). Produces raw token counts and block boundaries only; mapping to UsageBucket without tier detection is the orchestrator’s problem.

v0.1 exposes only the currently-active 5h block. Historical blocks are deferred per spec §Open questions — extending JsonlAggregate with completed_blocks is a non-breaking change under #[non_exhaustive].

Structs§

FiveHourBlock
Active 5-hour billing block. start is the UTC-floor-to-hour of the block’s first entry; actual_last_activity lets the caller distinguish a block where the user stopped typing 10 seconds ago from one where they stopped 4 hours ago. The block’s end time is a derivation from start — see Self::end.
JsonlAggregate
Output of the aggregator. five_hour is None when no entry falls within the last [BLOCK_DURATION_HOURS] hours; seven_day is always present (zero-valued on an empty transcript).
SevenDayWindow
Rolling 7-day window. window_start is now - 7d at the time the aggregator ran.
TokenCounts
Per-category token counts aggregated from the transcript.

Enums§

JsonlError

Functions§

aggregate_jsonl
Discover project roots, scan every *.jsonl under them, dedupe, aggregate. Memoization is the caller’s responsibility; each call re-scans from offset zero.