fix(audit): reserve recovery evidence outside user deliverables

This commit is contained in:
2026-10-20 21:26:48 +01:00
parent 860615acb5
commit b56d6af180
5 changed files with 69 additions and 17 deletions
+4 -2
View File
@@ -165,12 +165,14 @@ export function isSystemArtifact(artifact) {
/** A visit's stage-produced artifacts: everything except the system files. */
export function stageArtifacts(step) {
return presentedArtifacts(step).filter((artifact) => !isSystemArtifact(artifact));
const repairs = new Set((step?.session_export_repairs ?? []).map((entry) => entry?.html).filter(Boolean));
return presentedArtifacts(step).filter((artifact) => !isSystemArtifact(artifact) && !repairs.has(artifact?.name));
}
/** A visit's system files, newest-listing order preserved. */
export function systemArtifacts(step) {
return presentedArtifacts(step).filter(isSystemArtifact);
const repairs = new Set((step?.session_export_repairs ?? []).map((entry) => entry?.html).filter(Boolean));
return presentedArtifacts(step).filter((artifact) => isSystemArtifact(artifact) || repairs.has(artifact?.name));
}
/** How many files the capture excluded for `step` (absent means none). */
+30 -14
View File
@@ -116,25 +116,41 @@ export function createRunDetailView(rt) {
const sessionRepairs = new Set();
function sessionExportRetry(step) {
const run=state.runDetail;
const run = state.runDetail;
if (!run?.id || !step?.sequence || !(step.session_id || step.session_export?.session_id)) return null;
const key=`${run.id}:${step.sequence}`;
const running=step.agent_active || ["running","queued"].includes(run.status) ||
(run.status==="waiting" && run.export_pending_sequence!==step.sequence);
const button=h("button",{class:"ghost session-export-retry",type:"button",disabled:running || sessionRepairs.has(key),
text:sessionRepairs.has(key)?"Exporting…":"Retry export only",
title:"Read the exact recorded session again. Does not rerun the stage or its tools."});
button.addEventListener("click",async()=>{
const key = `${run.id}:${step.sequence}`;
const running = step.agent_active || ["running", "queued"].includes(run.status) ||
(run.status === "waiting" && run.export_pending_sequence !== step.sequence);
const button = h("button", {
class: "ghost session-export-retry",
type: "button",
disabled: running || sessionRepairs.has(key),
text: sessionRepairs.has(key) ? "Exporting…" : "Retry export only",
title: "Read the exact recorded session again. Does not rerun the stage or its tools.",
});
button.addEventListener("click", async () => {
if (sessionRepairs.has(key)) return;
sessionRepairs.add(key);button.disabled=true;button.textContent="Exporting…";
sessionRepairs.add(key);
button.disabled = true;
button.textContent = "Exporting…";
try {
const detail=await repo.repairSessionExport(run.id,step.sequence);
if (state.runDetail?.id===run.id) {
const detail = await repo.repairSessionExport(run.id, step.sequence);
if (state.runDetail?.id === run.id) {
if (rt.refreshRunDetail) rt.refreshRunDetail(run.id);
else {state.runDetail=detail;renderContent();}
else {
state.runDetail = detail;
renderContent();
}
}
} catch(error) {state.actionError=describeError(error);renderContent();}
finally {sessionRepairs.delete(key);button.disabled=Boolean(running);button.textContent="Retry export only";rt.views.dialogs.refreshStageAudit?.();}
} catch (error) {
state.actionError = describeError(error);
renderContent();
} finally {
sessionRepairs.delete(key);
button.disabled = Boolean(running);
button.textContent = "Retry export only";
rt.views.dialogs.refreshStageAudit?.();
}
});
return button;
}