mirror of
https://github.com/morluto/rea
synced 2026-10-26 06:16:17 -04:00
49e67aa1d9
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
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { vi } from "vitest";
|
|
import type { ProcessOwnershipHost } from "./ProcessOwnership.js";
|
|
import { ProcessOwnershipEvidenceOwner } from "./ProcessOwnershipEvidence.js";
|
|
|
|
export const createOwnership = () => ({
|
|
runId: "run-token",
|
|
leaderPid: 100,
|
|
processGroupId: 100,
|
|
evidenceOwner: new ProcessOwnershipEvidenceOwner(),
|
|
});
|
|
|
|
export const host = (
|
|
environments: Readonly<Record<number, Readonly<Record<string, string>>>>,
|
|
): {
|
|
readonly adapter: ProcessOwnershipHost;
|
|
readonly signalGroup: ReturnType<typeof vi.fn>;
|
|
} => {
|
|
const livePids = new Set(Object.keys(environments).map(Number));
|
|
const signalGroup = vi.fn((processGroupId: number) => {
|
|
if (processGroupId === 100) livePids.clear();
|
|
});
|
|
return {
|
|
adapter: {
|
|
listProcesses: () =>
|
|
Promise.resolve(
|
|
[...livePids].map((pid) => ({
|
|
pid,
|
|
parentPid: pid === 100 ? 1 : 100,
|
|
processGroupId: 100,
|
|
state: "S",
|
|
command: "fixture",
|
|
})),
|
|
),
|
|
environment: (pid) => Promise.resolve(environments[pid] ?? {}),
|
|
signalGroup,
|
|
},
|
|
signalGroup,
|
|
};
|
|
};
|