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
|
||||
|
||||
@@ -274,8 +274,9 @@ function openAuditFor(d, step, stageKey, visitIndex) {
|
||||
const current = currentStep();
|
||||
if (tab === "session") {
|
||||
const capture = sessionCaptureState(current);
|
||||
const retrying = capture.artifact && capture.evidence?.status === "complete" ? false : sessionRepairs.has(`${d.id}:${step.sequence}`);
|
||||
return JSON.stringify([capture.sessionId,capture.artifact,capture.evidence?.status,capture.evidence?.messages,capture.evidence?.truncated,capture.evidence?.diagnostic,capture.message,retrying]);
|
||||
const complete = capture.artifact && capture.evidence?.status === "complete" && !capture.evidence.truncated;
|
||||
const retryState = complete ? null : [sessionRepairs.has(`${d.id}:${step.sequence}`), current.agent_active, state.runDetail?.status, state.runDetail?.export_pending_sequence];
|
||||
return JSON.stringify([capture.sessionId,capture.artifact,capture.evidence?.status,capture.evidence?.messages,capture.evidence?.truncated,capture.evidence?.diagnostic,capture.message,retryState]);
|
||||
}
|
||||
if (["input","output","memory"].includes(tab)) return JSON.stringify(systemArtifacts(current).find((entry)=>entry.name===`${tab}.md`) ?? null);
|
||||
return `${d.pipeline_id}:${d.version}:${stageKey}`;
|
||||
|
||||
Reference in New Issue
Block a user