fix(process): identify unknown live processes in cleanup diagnostics

This commit is contained in:
morluto
2026-10-09 00:49:31 +08:00
parent bfb7776006
commit eb89a16d9b
6 changed files with 49 additions and 6 deletions
+25
View File
@@ -15,6 +15,7 @@ import {
projectProcessCliError,
} from "../../../src/application/process/ProcessCli.js";
import { createEvidence } from "../../../src/domain/evidence.js";
import { ProcessCaptureError } from "../../../src/process/capture/ProcessCaptureError.js";
import { PROCESS_PROVIDER } from "../../../src/application/process/ProcessEvidence.js";
import { INVESTIGATION_EXAMPLES } from "../../../src/contracts/investigationExamples.js";
@@ -229,6 +230,30 @@ describe("process CLI environment key diagnostics", () => {
});
describe("process CLI evidence validation", () => {
it("preserves sanitized unknown-process IDs and reasons through CLI projection", () => {
const reason =
"process ownership token could not be read for 1 live process(es): environment_unavailable=1; live candidates 900=environment_unavailable";
const projected = projectProcessCliError(
new ProcessCaptureError("cleanup incomplete", {
reason: "cleanup_incomplete",
cleanupResources: ["owned_process_group"],
cleanupReport: {
owned_process_group: { state: "unverified", reason },
terminal_renderer: { state: "cleaned", reason: null },
temporary_root: { state: "cleaned", reason: null },
},
}),
);
expect(projected).toMatchObject({
code: "cleanup_incomplete",
details: {
cleanup_report: {
owned_process_group: { reason },
},
},
});
});
it("captures the minimal executable-and-arguments scenario", async () => {
const root = await fixture();
const scenario = join(root, "scenario.json");