fix(ci): reconcile lifecycle checks with current main

Preserve failed event finalization across retries and current capture ownership checks. Retain Git unreadable-ref and bounded-heap Evidence coverage, pinned maintenance destinations, and explicit native binding facts.
This commit is contained in:
N0zoM1z0
2026-10-11 01:08:09 +08:00
12 changed files with 133 additions and 85 deletions
@@ -2,7 +2,6 @@ import { writeFile } from "node:fs/promises";
import { join } from "node:path";
import { expect, it } from "vitest";
import { z } from "zod";
import { createTestTempDirectory } from "../../../tests/fixtures/temporaryDirectory.js";
import { javascriptApplicationAnalysisResultSchema } from "../../domain/javascript/javascriptApplicationAnalysis.js";
@@ -32,15 +31,16 @@ const graphIdentities = async (source: string) => {
...(identity.strategy === "artifact-local-key"
? {
namespace: identity.namespace,
// Module-export identity is a JSON tuple whose first entry
// binds the whole container; only that digest changes here.
key:
identity.namespace === "module-export"
? JSON.stringify(
z
.array(z.string())
.parse(JSON.parse(identity.key))
.slice(1),
(JSON.parse(identity.key) as unknown[]).slice(1),
)
: identity.key.replace(/^[0-9a-f]{64}:/u, ""),
: identity.namespace === "source-module"
? identity.key.replace(/^[0-9a-f]{64}:/u, "")
: identity.key,
}
: {}),
}))
+2
View File
@@ -69,6 +69,8 @@ export const closeCdpTargetSession = async (
}
}
}
// Cancellation skips optional domain shutdown but still releases the
// attached session using its independent, bounded cleanup signal.
if (!cleanup.signal.aborted && sessionId !== undefined)
try {
await connection.send(
@@ -553,7 +553,7 @@ it("shares concurrent close and retries browser cleanup after failure", async ()
expect(cleanupSettlements).toEqual([false, true]);
});
it("reports event finalization failure before allowing settled cleanup retries", async () => {
it("keeps failed event finalization failed across cleanup retries", async () => {
const finishEvents = vi
.fn<() => Promise<void>>()
.mockRejectedValue(new Error("event finalization failed"));
@@ -567,9 +567,10 @@ it("reports event finalization failure before allowing settled cleanup retries",
await expect(cleanup.close(finishEvents)).rejects.toMatchObject({
reason: "cleanup_failed",
cleanup: { reason: "event finalization failed" },
});
await expect(cleanup.close(finishEvents)).resolves.toBeUndefined();
await expect(cleanup.close(finishEvents)).rejects.toMatchObject({
reason: "cleanup_failed",
});
expect(finishEvents).toHaveBeenCalledTimes(1);
expect(closeBrowser).toHaveBeenCalledTimes(1);
});
+4 -5
View File
@@ -42,7 +42,6 @@ export class PlaywrightScenarioBrowserCleanupOwner {
#profileRemoved: boolean;
#closePromise: Promise<void> | undefined;
#eventFinalizationPromise: Promise<void> | undefined;
#eventFinalizationFailureReported = false;
/** Keep the narrow provider actions needed to release one opened browser. */
constructor(private readonly resources: PlaywrightScenarioCleanupResources) {
@@ -98,10 +97,10 @@ export class PlaywrightScenarioBrowserCleanupOwner {
try {
await eventFinalization;
} catch (cause: unknown) {
if (!this.#eventFinalizationFailureReported) {
failures.push(cause);
this.#eventFinalizationFailureReported = true;
}
// A failed finalization stays failed: the memoized attempt rejects on
// every retry so cleanup can never report success for unfinalized
// events.
failures.push(cause);
}
if (!this.#browserClosed) {
try {
@@ -22,9 +22,13 @@ it("preserves a 12,000-member native import through both analyzers", () => {
const staticAnalysis = analyzeParsedJavaScriptStaticSource("", parsed);
const ir = analyzeParsedJavaScriptSemantics(parsed);
expect(staticAnalysis.parse_status).toBe("complete");
// The addon exports `next`; `last` belongs to an object reached from it.
expect(staticAnalysis.electron.native_addon_bindings).toEqual([
expect.objectContaining({ specifier: "./addon.node", members: ["next"] }),
expect.objectContaining({
specifier: "./addon.node",
members: ["next"],
namespace_access: false,
dynamic_member_access: false,
}),
]);
expect(ir.coverage).toEqual({ status: "complete", omittedCount: 0 });
const path = origin(onlyBinding(ir, "value"));
+21 -15
View File
@@ -16,35 +16,41 @@ import { classifyFilesystemEffects } from "./ProcessFilesystemEffects.js";
it.each(["after", "before"] as const)(
"keeps absence unknown when the %s snapshot omits an existing file",
async (partialSide) => {
// Enumeration order is filesystem-dependent. Choose a genuinely omitted
// entry by comparing a complete snapshot with a capacity-limited one.
const root = await createTestTempDirectory("rea-fs-partial-absence-");
const names = ["a.txt", "z.txt"];
for (const name of names) await writeFile(join(root, name), "unchanged");
await writeFile(join(root, "a1.txt"), "first");
await writeFile(join(root, "a2.txt"), "second");
await writeFile(join(root, "z.txt"), "target");
const scenario = parseProcessScenario({
executable: process.execPath,
working_directory: root,
filesystem_observation_paths: [root],
limits: { files: 2 },
});
const complete = await snapshotRoots({
...scenario,
limits: { ...scenario.limits, files: 4 },
});
const partial = await snapshotRoots(scenario);
const omitted = names.find(
(name) => !partial.files.some(({ path }) => path === `root_0:${name}`),
expect(complete.completeRoots).toEqual(["root_0"]);
expect(partial.truncated).toBe(true);
const omitted = complete.files.find(
(file) => !partial.files.some(({ path }) => path === file.path),
);
if (omitted === undefined)
throw new Error("Expected an omitted fixture file");
for (const name of names) if (name !== omitted) await rm(join(root, name));
const complete = await snapshotRoots(scenario);
if (omitted === undefined) throw new Error("Expected an omitted entry");
const before = partialSide === "before" ? partial : complete;
const after = partialSide === "after" ? partial : complete;
expect(await readFile(join(root, omitted), "utf8")).toBe("unchanged");
const effect = classifyFilesystemEffects(before, after).find(
({ path }) => path === `root_0:${omitted}`,
({ path }) => path === omitted.path,
);
expect(effect?.status).toBe("unknown");
expect(effect).toMatchObject(
partialSide === "after"
? { before: { path: `root_0:${omitted}` }, after: null }
: { before: null, after: { path: `root_0:${omitted}` } },
);
expect(effect).toMatchObject({
...(partialSide === "after"
? { before: omitted, after: null }
: { before: null, after: omitted }),
reason: expect.stringContaining("did not exhaust path enumeration"),
});
},
);
+18 -5
View File
@@ -18,6 +18,7 @@ import {
} from "./ProcessCaptureError.js";
import {
releaseProcessResources,
ProcessCaptureResourceScope,
createProcessCaptureObservationBuffer,
prepareProcessCapture,
resolveProcessResult,
@@ -291,26 +292,31 @@ it("keeps empty cleanup exception messages actionable in the report", async () =
});
it.each(["termination", "verification"] as const)(
"retains observations and the temporary root when process %s throws",
"retains observations and retries the temporary root when process %s throws",
async (stage) => {
const cleanupFailure = new Error(`${stage} inspection failed`);
const removeTemporaryRoot = vi.fn(async () => undefined);
let failing = true;
const scope = new ProcessCaptureResourceScope();
const host: ProcessCaptureCleanupHost = {
platform: "linux",
cleanupProcessGroup: async () => {
if (stage === "termination") throw cleanupFailure;
if (failing && stage === "termination") throw cleanupFailure;
return {
cleaned: true,
signaled: true,
unverified: [{ pid: 900, diagnostic: "environment unavailable" }],
unverified: failing
? [{ pid: 900, diagnostic: "environment unavailable" }]
: [],
};
},
verifyTokenOwnedProcesses: async () => {
throw cleanupFailure;
if (failing) throw cleanupFailure;
return { cleaned: true, signaled: false };
},
removeTemporaryRoot,
};
const cleanup = await releaseProcessResources({
const cleanup = await scope.release({
timers: new Set(),
terminal: { pid: 321 },
renderer: undefined,
@@ -360,6 +366,13 @@ it.each(["termination", "verification"] as const)(
},
});
}
failing = false;
await scope.retryCleanup();
expect(removeTemporaryRoot).toHaveBeenCalledExactlyOnceWith(
"/fixture/root",
);
await scope.close();
expect(removeTemporaryRoot).toHaveBeenCalledTimes(1);
},
);