mirror of
https://github.com/morluto/rea.git
synced 2026-11-03 13:26:10 +00:00
fix(process): retain native ownership evidence through cleanup
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
This commit is contained in:
1 parent
0fc8462be1
commit
49e67aa1d9
47 files changed
+5262
-1173
No files matched your search
@@ -29,6 +29,8 @@ const fixture = vi.hoisted(() => ({
|
||||
readonly read: number;
|
||||
readonly pid?: number;
|
||||
readonly parent?: number;
|
||||
readonly processGroupId?: number;
|
||||
readonly sessionId?: number;
|
||||
readonly start?: number;
|
||||
}
|
||||
>(),
|
||||
@@ -165,6 +167,7 @@ vi.mock("../ExecFileOutput.js", () => ({
|
||||
}));
|
||||
|
||||
import { startProcessSampler } from "./ProcessSampling.js";
|
||||
import { readLinuxProcessStat } from "./LinuxProcessSampling.js";
|
||||
import type { ProcessSample } from "../../domain/process/processCapture.js";
|
||||
|
||||
const platformDescriptor = Object.getOwnPropertyDescriptor(process, "platform");
|
||||
@@ -195,8 +198,8 @@ const statLine = (pid: number, read: number): string => {
|
||||
String(
|
||||
mutation?.read === read ? (mutation.parent ?? row.parent) : row.parent,
|
||||
),
|
||||
"100",
|
||||
"100",
|
||||
String(mutation?.read === read ? (mutation.processGroupId ?? 100) : 100),
|
||||
String(mutation?.read === read ? (mutation.sessionId ?? 100) : 100),
|
||||
];
|
||||
while (fields.length < 19) fields.push("0");
|
||||
fields.push(
|
||||
@@ -269,6 +272,28 @@ const waitFor = async (condition: () => boolean): Promise<void> => {
|
||||
}
|
||||
};
|
||||
|
||||
it("rejects a mismatched stat PID and zero process-group/session IDs at sampling admission", async () => {
|
||||
setUpFixture();
|
||||
fixture.statMutations.set(100, { read: 1, pid: 200 });
|
||||
const wrongPid = await readLinuxProcessStat(
|
||||
100,
|
||||
new AbortController().signal,
|
||||
);
|
||||
expect(wrongPid.value).toBeUndefined();
|
||||
|
||||
setUpFixture();
|
||||
fixture.statMutations.set(100, {
|
||||
read: 1,
|
||||
processGroupId: 0,
|
||||
sessionId: 0,
|
||||
});
|
||||
const zeroGroups = await readLinuxProcessStat(
|
||||
100,
|
||||
new AbortController().signal,
|
||||
);
|
||||
expect(zeroGroups.value).toBeUndefined();
|
||||
});
|
||||
|
||||
const flushImmediateProcPass = async (): Promise<void> => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
await Promise.resolve();
|
||||
|
||||
Reference in new issue
Block a user