UsageSegment class final
One closed-or-open segment of a session's usage: the fold of every provider request between two resume boundaries (gh-1241 I1/I2).
Constructors
-
UsageSegment({required int index, required UsageModelTotals totals, required Map<
String, UsageModelTotals> byModel, required UsageSource source, String? model, DateTime? openedAt, DateTime? closedAt}) -
Creates a UsageSegment.
const
-
UsageSegment.fromJson(Map<
String, dynamic> json) -
Deserializes from a JSON map; unknown fields are ignored
(forward-compat, UT-1).
factory
Properties
-
byModel
→ Map<
String, UsageModelTotals> -
Per-model split of totals (I5); model ids are provider-controlled
strings — schema-validated data, never shell-interpolated.
final
- closedAt → DateTime?
-
When the segment last carried usage (the last contributing record's
chain timestamp).
nullwhile the segment is open and empty.final - hashCode → int
-
The hash code for this object.
no setterinherited
- index → int
-
0-based position in the session's segment sequence (chain order — a
resume APPENDS, never reorders, E4).
final
- model → String?
-
The segment's LAST-SEEN model id (gh-1460): the model that served the
segment's final request — the id stamped into the
fa-tokens:segment-close line so downstream consumers can price the row.nullon segments that never observed a model (legacy chains, or only zero-filled fallbacks) — the log line then keeps its legacy shape. Deliberately NOT part of the usage.json schema: it is rebuildable from the chain and consumed by the log line only.final - openedAt → DateTime?
-
When the segment opened (the
usage_segment_startmarker's chain timestamp, or the first contributing record's). Informational only — ordering never derives from timestamps (E4).final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- source → UsageSource
-
Provenance marker for this segment (I3).
final
- totals → UsageModelTotals
-
Request/token sums over the segment.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> - Serializes to a JSON map (schema order fixed for byte-determinism).
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited