Keep a run-scoped evidence owner from acquisition through settlement and cleanup retry. Bind token observations to native generations and retain related generations and unresolved identity lookups across table omissions, reparenting and process-group changes without treating PID hints as authority. Use native effective UID facts for withholding decisions, corroborate Linux procfs absence, and share the Linux stat parser with sampling and debugger identity checks. Signal only after current token and group revalidation. Complete swept cleanup across all groups with one bounded final family check; retain unresolved owners and successful-peer completion across retries. Validation: npm run check, docs:check and test discovery passed. Focused ownership/consumer coverage totals 513 passed and 1 skipped across 35 files, including the corrected Electron cancellation test rerun independently. Darwin helper compilation, real owned Node child cleanup, CLI/MCP capture and retained cleanup retries ran. Real Electron applications, native Linux races/PID reuse and Windows cleanup were not qualified. The original Linux reports remain open for that work. Fixes #5238 Refs #4322, #5206
73 lines
2.3 KiB
TypeScript
73 lines
2.3 KiB
TypeScript
import { ProcessOwnershipEvidenceOwner } from "../../../src/process/ProcessOwnershipEvidence.js";
|
|
import { expect, it } from "vitest";
|
|
|
|
import { emptyUnverifiedProcessCapture } from "../../../src/domain/process/processCapture.fixture.js";
|
|
import { parseProcessCapture } from "../../../src/domain/process/processCaptureParsing.js";
|
|
import { parseProcessScenario } from "../../../src/domain/process/processScenario.js";
|
|
import { createProcessCaptureEvidence } from "../../../src/application/process/ProcessEvidence.js";
|
|
import { observeSettlement } from "../../../src/process/capture/ProcessCaptureLifecycle.js";
|
|
|
|
it.each([
|
|
["win32", "program.exe"],
|
|
["linux", "directory\\program.exe"],
|
|
["darwin", "directory\\program.exe"],
|
|
] as const)(
|
|
"interprets the executable name using the captured %s host",
|
|
(platform, expectedName) => {
|
|
const scenario = parseProcessScenario({
|
|
executable: "/fixtures/directory\\program.exe",
|
|
working_directory: process.cwd(),
|
|
events: [],
|
|
});
|
|
const base = emptyUnverifiedProcessCapture();
|
|
const capture = parseProcessCapture({
|
|
...base,
|
|
manifest: { ...base.manifest, platform },
|
|
});
|
|
expect(
|
|
createProcessCaptureEvidence(scenario, capture).parameters
|
|
.executable_name,
|
|
).toBe(expectedName);
|
|
},
|
|
);
|
|
|
|
it("stamps process Evidence from the capture manifest host", () => {
|
|
const scenario = parseProcessScenario({
|
|
executable: process.execPath,
|
|
working_directory: process.cwd(),
|
|
events: [],
|
|
});
|
|
const base = emptyUnverifiedProcessCapture();
|
|
const capture = parseProcessCapture({
|
|
...base,
|
|
manifest: {
|
|
...base.manifest,
|
|
platform: "linux",
|
|
architecture: "arm64",
|
|
},
|
|
});
|
|
|
|
expect(
|
|
createProcessCaptureEvidence(scenario, capture).environment,
|
|
).toMatchObject({
|
|
id: "linux-arm64",
|
|
platform: "linux",
|
|
architecture: "arm64",
|
|
});
|
|
});
|
|
|
|
it("uses the selected host platform for process settlement behavior", async () => {
|
|
const events: string[] = [];
|
|
const result = await observeSettlement({
|
|
runId: "run",
|
|
processGroupIds: [],
|
|
settleMs: 0,
|
|
recordEvent: (event) => events.push(event),
|
|
platform: "win32",
|
|
ownershipEvidence: new ProcessOwnershipEvidenceOwner(),
|
|
});
|
|
|
|
expect(result).toEqual({ state: "unverifiable", elapsed_ms: 0 });
|
|
expect(events).toEqual(["lifecycle"]);
|
|
});
|