fix(audit): match export ownership and inventory receipts in browser
This commit is contained in:
+10
-4
@@ -475,8 +475,12 @@ export function effectiveSessionExport(step) {
|
||||
const id = String(step?.session_id || recorded?.session_id || "");
|
||||
const original = recorded?.session_id && id && recorded.session_id !== id ? null : recorded;
|
||||
const repairs = [...(step?.session_export_repairs ?? [])].reverse()
|
||||
.filter((entry) => id !== "" && entry?.session_id === id);
|
||||
const hasFile = (entry) => Boolean(entry?.html) && (step?.artifacts ?? []).some((file) => file?.name === entry.html && file.size_bytes > 0);
|
||||
.filter((entry) => id !== "" && entry?.session_id === id &&
|
||||
(!original?.backend || entry.backend === original.backend) &&
|
||||
(!original?.directory || entry.directory === original.directory));
|
||||
const hasFile = (entry) => Boolean(entry?.html) && (step?.artifacts ?? []).some((file) =>
|
||||
file?.name === entry.html && file.size_bytes > 0 &&
|
||||
(!(entry.html_bytes > 0) || file.size_bytes === entry.html_bytes));
|
||||
// A failed later attempt must not hide an earlier, verified full repair.
|
||||
const isComplete = (entry) => entry?.status === "complete" && entry.messages > 0 &&
|
||||
entry.html_bytes > 0 && !entry.truncated && !entry.diagnostic && hasFile(entry);
|
||||
@@ -484,9 +488,11 @@ export function effectiveSessionExport(step) {
|
||||
}
|
||||
|
||||
export function sessionExportArtifact(step) {
|
||||
const html = effectiveSessionExport(step)?.html;
|
||||
const evidence = effectiveSessionExport(step);
|
||||
const html = evidence?.html;
|
||||
if (typeof html !== "string" || html.trim() === "") return null;
|
||||
return (step?.artifacts ?? []).find((artifact) => artifact?.name === html) ?? null;
|
||||
return (step?.artifacts ?? []).find((artifact) => artifact?.name === html &&
|
||||
(!(evidence.html_bytes > 0) || artifact.size_bytes === evidence.html_bytes)) ?? null;
|
||||
}
|
||||
|
||||
/** A recorded ID and an exported document are different facts. Never call a
|
||||
|
||||
Reference in New Issue
Block a user