fix(ci): repair boundary regressions and evidence assertions
Detach cancelled CDP sessions within the cleanup budget and retain event-finalization failures across retries. Honor Git filesystem encodings and exclude the promise-API probe from source-read failures. Align existing integration regressions with retained process resources, filesystem-order-independent truncation, owned skill files, explicit native access facts and streamed JSON errors. Validation: 132 acceptance tests passed (2 skipped), 83 affected boundary tests passed, Git/JSON/CLI boundary regressions passed, check:ci, docs:check and test discovery passed. Local verification used Node 24.18.0 on macOS; cross-platform CI remains pending.
This commit is contained in:
@@ -53,9 +53,24 @@ const resolveSourceHead = async (
|
||||
...fs.promises,
|
||||
// isomorphic-git treats every read failure as absence. Preserve real
|
||||
// failures so a readable packed ref cannot hide an unreadable loose ref.
|
||||
readFile: async (path: string) => {
|
||||
readFile: async (
|
||||
path: string | undefined,
|
||||
options:
|
||||
| BufferEncoding
|
||||
| { readonly encoding?: BufferEncoding | null }
|
||||
| null = null,
|
||||
) => {
|
||||
// The library probes readFile() without a path to detect promise APIs.
|
||||
// Reject that invocation without attributing it to a source read.
|
||||
if (path === undefined)
|
||||
throw new TypeError("Git filesystem read requires a path");
|
||||
try {
|
||||
return await readRegularFile(path, { signal });
|
||||
const bytes = await readRegularFile(path, { signal });
|
||||
const encoding =
|
||||
typeof options === "string" ? options : options?.encoding;
|
||||
return encoding === undefined || encoding === null
|
||||
? bytes
|
||||
: bytes.toString(encoding);
|
||||
} catch (cause: unknown) {
|
||||
if (errorCode(cause) !== "ENOENT") failedRead ??= { cause };
|
||||
throw cause;
|
||||
|
||||
@@ -31,7 +31,16 @@ const graphIdentities = async (source: string) => {
|
||||
...(identity.strategy === "artifact-local-key"
|
||||
? {
|
||||
namespace: identity.namespace,
|
||||
key: identity.key.replace(/^[0-9a-f]{64}:/u, ""),
|
||||
// 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(
|
||||
(JSON.parse(identity.key) as unknown[]).slice(1),
|
||||
)
|
||||
: identity.namespace === "source-module"
|
||||
? identity.key.replace(/^[0-9a-f]{64}:/u, "")
|
||||
: identity.key,
|
||||
}
|
||||
: {}),
|
||||
}))
|
||||
|
||||
@@ -68,18 +68,20 @@ export const closeCdpTargetSession = async (
|
||||
// Best-effort domain cleanup; transport close is the definitive boundary.
|
||||
}
|
||||
}
|
||||
if (!cleanup.signal.aborted && sessionId !== undefined)
|
||||
try {
|
||||
await connection.send(
|
||||
"Target.detachFromTarget",
|
||||
{ sessionId },
|
||||
undefined,
|
||||
cleanup.signal,
|
||||
);
|
||||
} catch {
|
||||
// Best-effort detach; transport close is the definitive boundary.
|
||||
}
|
||||
}
|
||||
// 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(
|
||||
"Target.detachFromTarget",
|
||||
{ sessionId },
|
||||
undefined,
|
||||
cleanup.signal,
|
||||
);
|
||||
} catch {
|
||||
// Best-effort detach; transport close is the definitive boundary.
|
||||
}
|
||||
} finally {
|
||||
clearTimeout(timeout);
|
||||
cleanup.abort();
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -23,7 +23,12 @@ it("preserves a 12,000-member native import through both analyzers", () => {
|
||||
const ir = analyzeParsedJavaScriptSemantics(parsed);
|
||||
expect(staticAnalysis.parse_status).toBe("complete");
|
||||
expect(staticAnalysis.electron.native_addon_bindings).toEqual([
|
||||
expect.objectContaining({ specifier: "./addon.node", members: ["last"] }),
|
||||
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"));
|
||||
|
||||
@@ -16,29 +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-");
|
||||
await writeFile(join(root, "z.txt"), "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 },
|
||||
});
|
||||
if (partialSide === "before") await writeFile(join(root, "a.txt"), "other");
|
||||
const before = await snapshotRoots(scenario);
|
||||
if (partialSide === "after") await writeFile(join(root, "a.txt"), "other");
|
||||
else await rm(join(root, "a.txt"));
|
||||
const after = await snapshotRoots(scenario);
|
||||
expect(await readFile(join(root, "z.txt"), "utf8")).toBe("unchanged");
|
||||
const complete = await snapshotRoots({
|
||||
...scenario,
|
||||
limits: { ...scenario.limits, files: 4 },
|
||||
});
|
||||
const partial = await snapshotRoots(scenario);
|
||||
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 entry");
|
||||
const before = partialSide === "before" ? partial : complete;
|
||||
const after = partialSide === "after" ? partial : complete;
|
||||
const effect = classifyFilesystemEffects(before, after).find(
|
||||
({ path }) => path === "root_0:z.txt",
|
||||
({ path }) => path === omitted.path,
|
||||
);
|
||||
expect(effect?.status).toBe("unknown");
|
||||
expect(effect).toMatchObject(
|
||||
partialSide === "after"
|
||||
? { before: { path: "root_0:z.txt" }, after: null }
|
||||
: { before: null, after: { path: "root_0:z.txt" } },
|
||||
);
|
||||
expect(effect).toMatchObject({
|
||||
...(partialSide === "after"
|
||||
? { before: omitted, after: null }
|
||||
: { before: null, after: omitted }),
|
||||
reason: expect.stringContaining("did not exhaust path enumeration"),
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -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 releases 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,
|
||||
@@ -319,8 +325,11 @@ it.each(["termination", "verification"] as const)(
|
||||
host,
|
||||
});
|
||||
|
||||
expect(removeTemporaryRoot).toHaveBeenCalledWith("/fixture/root");
|
||||
expect(cleanup.temporary_root).toEqual({ state: "cleaned", reason: null });
|
||||
expect(removeTemporaryRoot).not.toHaveBeenCalled();
|
||||
expect(cleanup.temporary_root).toEqual({
|
||||
state: "unverified",
|
||||
reason: `temporary root retained because owned process cleanup is failed: ${cleanupFailure.message}`,
|
||||
});
|
||||
expect(cleanup.owned_process_group).toMatchObject({
|
||||
state: "failed",
|
||||
reason: cleanupFailure.message,
|
||||
@@ -357,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);
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user