export function summarizeRunResult(resultText, snapshots = []) {
  return {
    canonicalEventCount: resultText.split("\n").filter((line) => line.startsWith("canon_event=")).length,
    motionSnapshotCount: snapshots.length,
  };
}

export function createRunSummary(program, runtime = {}, snapshot = null) {
  const metadata = snapshot?.metadata ?? {};
  return {
    runStatus: runtime.runStatus ?? "ok",
    programSource: program.source,
    snapshotLabel: runtime.snapshotLabel ?? metadata.snapshotLabel ?? null,
    workflow: metadata.workflow ?? null,
    programOpfsPath: program.opfsPath,
    programWasmPath: program.wasmPath,
    iniWasmPath: runtime.iniWasmPath ?? null,
    canonicalEventCount: runtime.canonicalEventCount ?? 0,
    motionSnapshotCount: runtime.motionSnapshotCount ?? 0,
  };
}
