mirror of
https://github.com/morluto/rea
synced 2026-10-26 22:28:27 -04:00
71ae02c6ef
Retain original parent/child scope and prior native-generation proof across exit settlement and token retries. Keep historical scope separate from signal authority, count each supplied snapshot once, and share one existing native-exit deadline throughout cleanup. Validated 387 affected tests (one Darwin-only skip), five controls repeated three times, and 30 synced-main integration tests (one platform skip). Synced-head static, architecture, docs and discovery checks pass; real GDB qualification passes 44 CLI/MCP cases. Native-observer edge controls are simulated. Assisted-by: Reimu (gensokyo-skills:reimu-incident-triage) Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing)
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import type { ProcessIdentityObservation } from "./ProcessOwnership.js";
|
|
|
|
/** Native lifecycle is independent of ownership, token readability and ps text. */
|
|
export type ProcessLifecycle = "non-zombie" | "exiting" | "zombie" | "dead";
|
|
|
|
export type ProcessLifecycleObservation =
|
|
| { readonly state: "observed"; readonly lifecycle: ProcessLifecycle }
|
|
| { readonly state: "unavailable"; readonly reason: string };
|
|
|
|
export const PROCESS_CLEANUP_VERIFICATION_GRACE_MS = 1_000;
|
|
export const PROCESS_CLEANUP_VERIFICATION_INTERVAL_MS = 25;
|
|
|
|
/** One operation owns a lazily started native-exit waiting window. */
|
|
export interface ProcessExitSettlementBudget {
|
|
deadline: number | undefined;
|
|
}
|
|
|
|
export const processIdentityHasExited = (
|
|
identity: ProcessIdentityObservation | undefined,
|
|
): boolean =>
|
|
identity?.state === "absent" ||
|
|
(identity?.state === "readable" &&
|
|
identity.lifecycle?.state === "observed" &&
|
|
(identity.lifecycle.lifecycle === "zombie" ||
|
|
identity.lifecycle.lifecycle === "dead"));
|
|
|
|
export const processIdentityIsExiting = (
|
|
identity: ProcessIdentityObservation | undefined,
|
|
): boolean =>
|
|
identity?.state === "readable" &&
|
|
identity.lifecycle?.state === "observed" &&
|
|
identity.lifecycle.lifecycle === "exiting";
|