2026-10-07 12:10:45 +08:00
|
|
|
import type { EvidenceWriter } from "../application/investigation/InvestigationRecordPort.js";
|
2026-10-06 05:57:38 +08:00
|
|
|
import { EvidenceIntegrityError } from "../domain/evidenceErrors.js";
|
2026-07-16 18:49:35 +08:00
|
|
|
import type { Evidence } from "../domain/evidence.js";
|
2026-09-29 19:24:05 +08:00
|
|
|
import { ok, type Result } from "../domain/result.js";
|
2026-07-12 21:45:26 +00:00
|
|
|
|
2026-09-08 10:59:13 +08:00
|
|
|
/** Record source evidence in order, stopping at the first session rejection. */
|
|
|
|
|
export const recordSessionEvidenceSources = (
|
2026-10-07 12:10:45 +08:00
|
|
|
recordEvidence: EvidenceWriter["recordEvidence"] | undefined,
|
2026-09-08 10:59:13 +08:00
|
|
|
sources: readonly Evidence[],
|
2026-09-29 10:53:17 +08:00
|
|
|
): Result<null, EvidenceIntegrityError> => {
|
2026-09-08 10:59:13 +08:00
|
|
|
for (const source of sources) {
|
|
|
|
|
const recorded = recordEvidence?.(source);
|
|
|
|
|
if (recorded !== undefined && !recorded.ok) return recorded;
|
|
|
|
|
}
|
|
|
|
|
return ok(null);
|
|
|
|
|
};
|