mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 05:02:40 +00:00
* fix(process): preserve producer-owned inspection cancellation Prototype the explicit inspection origin and retained file/batch owner protocol. Downstream adapter migration and lease binding remain required before integration. * fix(process): type inspection ownership handoffs precisely * fix(process): retain plain inspection preparation cancellation * fix(process): retain explicit inspection cleanup and cancellation facts * fix(process): require explicit inspection facts and cleanup scope * refactor(process): remove redundant cleanup forwarding wrapper * fix(firmware): retain inspection cancellation and cleanup ownership * fix(wakaru): retain typed inspection outcomes and caller scope * fix(ghidra): preserve inspection facts and launch cleanup scope * fix(providers): preserve typed process inspection outcomes * refactor(process): remove obsolete inspection cancellation re-export * fix(native): preserve inspection preparation cleanup and cancellation * fix(registration): retain typed inspection cleanup during Git discovery * fix(process): preserve inspection deadline origin in adapter handoff * fix(process): consume the canonical inspection selector in binding * fix(native): preserve inspection deadlines and cleanup retry completion * test(process): narrow the retained Darwin preparation owner * fix(providers): preserve preparation ownership and timeout policy Narrow preparation facts through their canonical owner, preserve actual cleanup capabilities and recorded cancellation, and keep enclosing command deadlines authoritative. Retain raw inspection records through Java refusal and configuration projections without changing availability fallback policy. * refactor(process): use one inspection failure type owner * fix(providers): retain recorded secondary failures when rebinding * fix(ghidra): preserve normalized inspection facts through public projection * fix(process): normalize native process listing cancellation * docs(development): clarify failure provenance and cleanup verification * fix(process): preserve direct inspection cancellation facts * fix(process): retain inspection owners through termination * fix(process): preserve command inspection cleanup provenance * fix(desktop): preserve inspection facts after cleanup retry * refactor(process)!: migrate desktop capture with inspection producers * fix(desktop)!: preserve capture failure origins and cleanup owners (#10115) * fix(desktop): preserve capture failure origins and cleanup * fix(desktop): type keyring cleanup cancellation * fix(kuna)!: retain copy cleanup before retiring workspaces (#10114) * fix(kuna): own copy cancellation and descriptor cleanup * fix(kuna): close copy descriptors before workspace removal * test(kuna): type copy lifecycle gates for project library * docs(kuna): explain retained copy-file cleanup and staging ownership * docs(kuna): separate cache publication, integrity and cleanup guidance * fix(desktop): retain sampling inspection owners before release * fix(process): preserve capture file read cancellation origin * fix(process): retain capture inspection cancellation and cleanup owners * fix(process): retain sampling inspection failures in capture scope * fix(process): retain inspection failures through mandatory cleanup * fix(process): distinguish sampler shutdown from capture cancellation * fix(browser): retain startup EOF before later cancellation * fix(process): bind capture inspection cleanup to the owning run * test(process): migrate cancellation fixtures to typed owners Record explicit preparation and command cancellation facts, retain exact opaque reasons and physical causes, and guard the mocked version probe from native preparation. Keep the live Wakaru command control while adding a recording equivalent for bounded source verification. * fix(process): own sampling reads and settle inspection peers * fix(errors): retain authored recovery through cleanup composition * fix(process): retain all sampling inspection leaves for final cleanup * test(browser): report recording cleanup signal outcome * fix(process): keep inspection error context out of implicit JSON * fix(desktop): retain normalized sampling cleanup ownership * test(process): assert tagged startup cancellation
108 lines
3.9 KiB
TypeScript
108 lines
3.9 KiB
TypeScript
import type { AnalysisCleanupLease } from "../artifacts/AnalysisCleanupLease.js";
|
|
import {
|
|
RegularFileCleanupFailure,
|
|
regularFileCancellation,
|
|
} from "../filesystem/OwnedRegularFile.js";
|
|
import { DarwinProcessOwnershipInspectionError } from "./DarwinProcessRunTokenReader.js";
|
|
import {
|
|
ProcessOwnershipInspectionCancelled,
|
|
ProcessOwnershipIdentityBatchFailure,
|
|
rethrowProcessOwnershipInspectionFailure,
|
|
} from "./ProcessInspectionCancellation.js";
|
|
|
|
export type ProcessInspectionFailure =
|
|
| ProcessOwnershipInspectionCancelled
|
|
| ProcessOwnershipIdentityBatchFailure
|
|
| RegularFileCleanupFailure
|
|
| DarwinProcessOwnershipInspectionError;
|
|
|
|
export type ProcessInspectionCleanupFailure =
|
|
| DarwinProcessOwnershipInspectionError
|
|
| RegularFileCleanupFailure;
|
|
|
|
/** One inspection fact paired with the exact lease its normalizer already owns. */
|
|
export interface ProcessInspectionCleanupLease {
|
|
readonly failure: ProcessInspectionCleanupFailure;
|
|
readonly lease: AnalysisCleanupLease;
|
|
}
|
|
|
|
/** Collect only the exact owners explicitly transferred by inspection preparation. */
|
|
export const processInspectionCleanupFailures = (
|
|
cause: unknown,
|
|
): readonly ProcessInspectionCleanupFailure[] => {
|
|
const failures: ProcessInspectionCleanupFailure[] = [];
|
|
const visited = new Set<unknown>();
|
|
const owners = new Set<unknown>();
|
|
const visit = (failure: unknown): void => {
|
|
if (visited.has(failure)) return;
|
|
visited.add(failure);
|
|
if (failure instanceof ProcessOwnershipIdentityBatchFailure) {
|
|
for (const entry of failure.failures) visit(entry.cause);
|
|
for (const entry of failure.physicalFailures) visit(entry.cause);
|
|
return;
|
|
}
|
|
if (failure instanceof RegularFileCleanupFailure) {
|
|
if (!owners.has(failure.owner)) {
|
|
owners.add(failure.owner);
|
|
failures.push(failure);
|
|
}
|
|
return;
|
|
}
|
|
if (!(failure instanceof DarwinProcessOwnershipInspectionError)) return;
|
|
const owner = failure.cleanupOwner;
|
|
if (owner === undefined) {
|
|
if (failure.cleanupFailure !== undefined) failures.push(failure);
|
|
} else if (!owners.has(owner)) {
|
|
owners.add(owner);
|
|
failures.push(failure);
|
|
}
|
|
};
|
|
visit(cause);
|
|
return failures;
|
|
};
|
|
|
|
/** Only recorded owner cancellation facts; caller reasons and Error.cause stay opaque. */
|
|
export const processInspectionCancellations = (
|
|
cause: unknown,
|
|
): readonly { readonly reason: unknown }[] => {
|
|
const facts: { readonly reason: unknown }[] = [];
|
|
const visited = new Set<unknown>();
|
|
const add = (fact: { readonly reason: unknown } | undefined): void => {
|
|
if (
|
|
fact !== undefined &&
|
|
!facts.some((existing) => Object.is(existing.reason, fact.reason))
|
|
)
|
|
facts.push(fact);
|
|
};
|
|
const visit = (failure: unknown): void => {
|
|
if (visited.has(failure)) return;
|
|
visited.add(failure);
|
|
if (failure instanceof ProcessOwnershipIdentityBatchFailure) {
|
|
for (const entry of failure.cancellations) visit(entry.cancellation);
|
|
for (const entry of failure.physicalFailures) visit(entry.cause);
|
|
} else if (failure instanceof DarwinProcessOwnershipInspectionError)
|
|
add(failure.cancellation);
|
|
else if (failure instanceof RegularFileCleanupFailure) {
|
|
add(regularFileCancellation(failure));
|
|
if (
|
|
failure.operationFailure === undefined &&
|
|
failure.outcome.kind === "failed"
|
|
)
|
|
add(ProcessOwnershipInspectionCancelled.from(failure.outcome.cause));
|
|
} else if (failure instanceof ProcessOwnershipInspectionCancelled)
|
|
add(failure);
|
|
};
|
|
visit(cause);
|
|
return facts;
|
|
};
|
|
|
|
/** Mandatory cleanup cannot replace transferred inspection facts with an uncertainty row. */
|
|
export const rethrowProcessInspectionFailure = (cause: unknown): void => {
|
|
if (
|
|
processInspectionCleanupFailures(cause).length > 0 ||
|
|
processInspectionCancellations(cause).length > 0
|
|
)
|
|
throw cause;
|
|
rethrowProcessOwnershipInspectionFailure(cause);
|
|
};
|