fix(process): report denied inspection as typed cleanup failures (#9261)

* fix(process): report denied inspection as typed cleanup failures

Preserve the native ps diagnostic through owned-worker cleanup and finalize one-shot JavaScript analysis before Evidence delivery. Retain mandatory inspection and existing cleanup authority.

Preserve the inspector diagnostic when the initial process-table read succeeds but pre-signal revalidation fails, and remove the unreachable typed-error branch so retained artifact retry failures project through the existing cleanup contract.

* fix(resources): preserve independent close failure ownership

* fix(cli): retain cleanup recovery and nested close evidence

* refactor(providers): classify rejected closes at the shared boundary

* test(cli): preserve bundle metadata and physical inspection failures

* fix(cli): preserve the JavaScript failure envelope after finalization

* test(cli): validate the JavaScript error envelope at its boundary

* fix(providers): preserve unnamed close failure resources

* fix(cli): retain invocation owners through outer cleanup

* test(cli): distinguish reported cleanup failures from uncaught errors

* fix(cli): compose each runtime’s declared cleanup owners

* test(cli): preserve the original cleanup rejection

* test(cli): allow cleanup retry recovery after a reported failure

* fix(cli): report final cleanup after returned results

* fix(cli): preserve launcher executable mode

* test(cli): retain invocation cleanup in file sessions

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
This commit is contained in:
SandivandVincent Koc authored and GitHub committed 2026-11-30 19:38:45 +08:00
1 parent 891a999a12
commit f5055cd2ed
33 files changed
+1501 -111

No files matched your search

@@ -60,6 +60,7 @@ import {
} from "../../domain/analysisErrorCore.js";
import { ProviderAdapterError } from "../../domain/providerAdapterError.js";
import { ProviderCleanupError } from "../../domain/providerCleanupError.js";
import type { ProcessInspectionDiagnostic } from "../../process/ProcessOwnership.js";
import { ok, err, type Result } from "../../domain/result.js";
import { javaScriptRuntime } from "../../domain/runtimeVersion.js";
import {
@@ -751,6 +752,7 @@ export class JavaScriptAnalysisWorker {
this.#lastFailure,
cause.cleanupResources,
cause.processId,
cause.inspection,
);
cause.bindCleanupFailure(error);
throw error;
@@ -1431,6 +1433,7 @@ export class JavaScriptAnalysisWorker {
this.#lastFailure,
cause.cleanupResources,
cause.processId,
cause.inspection,
);
cause.bindCleanupFailure(error);
return error;
@@ -1502,6 +1505,7 @@ export class JavaScriptAnalysisWorker {
],
processId: number | null = this.#runtime.supervisor?.launch.process.pid ??
null,
inspection?: ProcessInspectionDiagnostic,
): ProviderCleanupError {
return new ProviderCleanupError(
PROVIDER,
@@ -1509,6 +1513,14 @@ export class JavaScriptAnalysisWorker {
{
reason,
worker_pid: processId,
...(inspection === undefined
? {}
: {
inspection: {
...inspection,
arguments: [...inspection.arguments],
},
}),
...(original === undefined
? {}
: {
@@ -1525,6 +1537,9 @@ export class JavaScriptAnalysisWorker {
},
{
operation: OPERATION,
...(inspection === undefined
? {}
: { remediationAction: inspection.remediation_action }),
...(original === undefined ? {} : { cleanupPrimary: original }),
cause: new Error(
reason,
@@ -1539,7 +1554,13 @@ export class JavaScriptAnalysisWorker {
const stopped = await this.#runtime.stop();
if (stopped.status === "incomplete") {
this.#resetState();
const error = this.#cleanupError(stopped.reason, original);
const error = this.#cleanupError(
stopped.reason,
original,
undefined,
undefined,
stopped.cleanupResult?.inspection,
);
this.#runtime.bindCleanupFailure(error);
return error;
}