UsageLedgerWriter class final

Writes and validates usage.json artifacts.

Constructors

UsageLedgerWriter(ExecutionEnv env)
Creates a UsageLedgerWriter over env's filesystem.

Properties

env → ExecutionEnv
The filesystem abstraction (never dart:io — hosts vary).
final
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
read(String dir) → Future<UsageLedger?>
Reads and parses the artifact at <dir>/usage.json without the chain fingerprint check — the display path (/usage) shows whatever is on disk; readIfValid is the gate for write decisions (E3).
readIfValid(String dir, {required int expectedRecords, required String expectedHash}) → Future<UsageLedger?>
Reads the artifact at <dir>/usage.json and returns it when it is parseable AND its chain fingerprint matches expectedRecords/ expectedHash (a fresh scan's numbers). Returns null for a missing file, a parse failure, or a fingerprint mismatch — the caller then REBUILDS from the chain instead of merging into garbage (E3).
toString() → String
A string representation of this object.
inherited
write(String dir, UsageLedger ledger, {String? tmpSuffix, Iterable<String> forbiddenSecrets = const [], Iterable<String> forbiddenContent = const []}) → Future<void>
Writes ledger to <dir>/usage.json atomically: full bytes to a unique tmp file, then rename over the target. A crash mid-write leaves at most a tmp file — the artifact is never partial (E3).

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

usageDirFor({required String sessionsRoot, required String sessionId}) → String
Resolves the per-session usage directory: <sessionsRoot>/<sessionId> (gh-1241 surface 1 — the sessions root IS the .fah/sessions tree; session ids are uuidv7 and never collide with the --cwd-slug-- workspace directories).

Constants

artifactFileName → const String
The artifact file name inside a session's usage directory.