fix: consolidate boundary ownership and cleanup failure paths (#477)
This commit is contained in:
@@ -2,6 +2,7 @@ import type { BinarySessionPort } from "../application/BinarySession.js";
|
||||
import {
|
||||
EvidenceIntegrityError,
|
||||
EvidenceReferenceError,
|
||||
type EvidenceLimitError,
|
||||
} from "../domain/errors.js";
|
||||
import type { Evidence } from "../domain/evidence.js";
|
||||
import { err, ok, type Result } from "../domain/result.js";
|
||||
@@ -48,3 +49,15 @@ export const resolveSessionEvidenceIds = (
|
||||
}
|
||||
return ok(records);
|
||||
};
|
||||
|
||||
/** Record source evidence in order, stopping at the first session rejection. */
|
||||
export const recordSessionEvidenceSources = (
|
||||
recordEvidence: BinarySessionPort["recordEvidence"] | undefined,
|
||||
sources: readonly Evidence[],
|
||||
): Result<null, EvidenceIntegrityError | EvidenceLimitError> => {
|
||||
for (const source of sources) {
|
||||
const recorded = recordEvidence?.(source);
|
||||
if (recorded !== undefined && !recorded.ok) return recorded;
|
||||
}
|
||||
return ok(null);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user