fix(ghidra): recover stale clients on same-target reopen (#2014)
* fix(ghidra): recover stale clients on same-target reopen * test(ghidra): allow supervised shutdown in health regression * fix(ghidra): read process exit without diagnostic snapshots Health and startup exit checks called the supervisor snapshot, which concatenates retained launcher output only to read the exit code. * test(adb): align fixtures with literal output and directory commands --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
co-authored by
Cursor Agent
morluto
parent
69e097a8ca
commit
4573e8cf35
@@ -7,6 +7,10 @@ import type { ProgressReporter } from "../application/ProgressReporter.js";
|
||||
import { AnalysisError } from "../domain/analysisErrorBase.js";
|
||||
import type { JsonValue } from "../domain/jsonValue.js";
|
||||
import { ProviderCleanupError } from "../domain/providerCleanupError.js";
|
||||
import {
|
||||
providerRetryAction,
|
||||
type ProviderOperationHealth,
|
||||
} from "../domain/providerOperationHealth.js";
|
||||
import { err, ok, type Result } from "../domain/result.js";
|
||||
import { silentLogger } from "../logger.js";
|
||||
import type { Logger } from "pino";
|
||||
@@ -477,6 +481,32 @@ export class GhidraClient {
|
||||
});
|
||||
}
|
||||
|
||||
/** Observed failures that prevent a retained session from being reused. */
|
||||
operationHealthSnapshot(): ProviderOperationHealth | undefined {
|
||||
const exit = this.#process?.observedExit();
|
||||
const state =
|
||||
exit !== undefined
|
||||
? "exited"
|
||||
: this.#socket?.destroyed === true
|
||||
? "unreachable"
|
||||
: this.#startPromise === undefined &&
|
||||
(this.#process !== undefined ||
|
||||
this.#socket !== undefined ||
|
||||
this.#runtimeRoot !== undefined ||
|
||||
this.#socketRoot !== undefined ||
|
||||
this.#snapshotOwners.size > 0)
|
||||
? "unknown"
|
||||
: undefined;
|
||||
if (state === undefined) return undefined;
|
||||
return {
|
||||
state,
|
||||
stage: null,
|
||||
retryAction: providerRetryAction(state),
|
||||
exitCode: exit?.code ?? null,
|
||||
requests: [],
|
||||
};
|
||||
}
|
||||
|
||||
/** Latest bounded local diagnostics, with bearer material redacted. */
|
||||
diagnostics(): Readonly<Record<string, JsonValue>> {
|
||||
return structuredClone(this.#diagnostics());
|
||||
@@ -633,7 +663,7 @@ export class GhidraClient {
|
||||
deadline,
|
||||
failure: this.#failure,
|
||||
isClosed: () => this.#closing,
|
||||
processExited: () => this.#process?.snapshot().exitCode !== undefined,
|
||||
processExited: () => this.#process?.observedExit() !== undefined,
|
||||
startupTimeoutMs: this.#options.startupTimeoutMs,
|
||||
handlers: {
|
||||
data: this.#onSocketData,
|
||||
|
||||
@@ -108,7 +108,10 @@ export type GhidraProviderClientFactory = (
|
||||
Partial<
|
||||
Pick<
|
||||
GhidraClient,
|
||||
"runtimeLineage" | "readTargetSnapshot" | "hashTargetSnapshot"
|
||||
| "operationHealthSnapshot"
|
||||
| "runtimeLineage"
|
||||
| "readTargetSnapshot"
|
||||
| "hashTargetSnapshot"
|
||||
>
|
||||
>;
|
||||
|
||||
@@ -840,6 +843,7 @@ export const createGhidraProviderClient = (input: {
|
||||
}),
|
||||
);
|
||||
},
|
||||
operationHealthSnapshot: () => client.operationHealthSnapshot?.(),
|
||||
runtimeLineageSnapshots: () => {
|
||||
const observation = client.runtimeLineage?.() ?? null;
|
||||
return observation === null
|
||||
|
||||
Reference in New Issue
Block a user