read method

Future<UsageLedger?> read(
  1. String dir
)

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).

Implementation

Future<UsageLedger?> read(String dir) async {
  final read = await env.readTextFile('$dir/$artifactFileName');
  if (read.isErr) return null;
  try {
    final parsed = jsonDecode(read.valueOrNull!);
    if (parsed is! Map) return null;
    return UsageLedger.fromJson(parsed.cast<String, dynamic>());
  } on Object {
    return null;
  }
}