record method

Future<void> record({
  1. required NativeStepFingerprint fingerprint,
  2. List<String> outputPaths = const [],
  3. List<Map<String, Object?>> artifactDeclarations = const [],
})

Record a completed step in the cache.

fingerprint is the step's fingerprint. outputPaths are the absolute paths to files produced by this step. artifactDeclarations are JSON-serializable artifact declarations produced by this step, used to reconstruct artifacts on cache hit.

Implementation

Future<void> record({
  required NativeStepFingerprint fingerprint,
  List<String> outputPaths = const [],
  List<Map<String, Object?>> artifactDeclarations = const [],
}) async {
  final metaFile = _metaFile(fingerprint);
  metaFile.parent.createSync(recursive: true);

  final metadata = <String, dynamic>{
    'stepId': fingerprint.id,
    'hash': fingerprint.hash,
    'outputs': outputPaths,
    'artifactDeclarations': artifactDeclarations,
    'recordedAt': DateTime.now().toIso8601String(),
  };

  await metaFile.writeAsString(
    const JsonEncoder.withIndent('  ').convert(metadata),
  );

  logger?.fine(
    'Cached ${fingerprint.id} with ${outputPaths.length} output(s)',
  );
}