Keep legacy normalized receipt ownership on replay

This commit is contained in:
Michael D'Angelo
2026-11-04 22:08:31 +00:00
parent cb6142dab5
commit cd0a07ad83
3 changed files with 17 additions and 4 deletions
@@ -26,9 +26,10 @@ export function workerCoverageReceiptLocation(
const workerPrefix = `artifacts/deep_discovery/workers/${basename(worker)}/`;
const normalized = components.join("/");
const outputPrefix = `${workerPrefix}output/`;
const shared =
isObject(surface.provenance) &&
(surface.provenance.scanReceiptRefs as string[] | undefined)?.includes(ref);
const recorded = isObject(surface.provenance)
? (surface.provenance.scanReceiptRefs as string[] | undefined)
: undefined;
const shared = recorded?.includes(ref) || recorded?.includes(normalized);
if (archived && !shared && normalized.startsWith(outputPrefix)) {
return {
context,
@@ -281,7 +281,8 @@ export function scanCoverage(
const ref = posix.normalize(receipt);
return ref.startsWith(archivePrefix) ||
ref.startsWith(`${artifactPrefix}/`) ||
scanRefs?.has(receipt)
scanRefs?.has(receipt) ||
scanRefs?.has(ref)
? ref
: `${artifactPrefix}/${ref}`;
};
@@ -806,6 +806,17 @@ async function testCoveragePublicationParity(root: string) {
path.join(output, "artifacts/review.md"),
"Review evidence.\n",
);
// Older retained coverage recorded the normalized scan-owned receipt.
const historical = structuredClone(original);
historical.reviewState.surfaces[0].receiptRefs = ["artifacts/./review.md"];
historical.reviewState.surfaces[0].provenance = {
scanReceiptRefs: ["artifacts/review.md"],
};
const projected = scanCoverage(
{ ...worker, result: historical },
worker.artifacts.scanDir,
);
assert.deepEqual(projected.surfaces[0].receiptRefs, ["artifacts/review.md"]);
for (const ref of [
"artifacts/review.md",
"artifacts/./review.md",