fix(ida): retain private input after ambiguous open (#1845)

fix(ida): retain private input after unverified open
This commit is contained in:
jhuang-tw
2026-10-13 20:58:51 +08:00
committed by GitHub
parent 2a61deafc6
commit 4ea24f9767
4 changed files with 103 additions and 18 deletions
+13
View File
@@ -43,6 +43,7 @@ import {
legacyMetadataSchema,
modernHealthSchema,
openDatabaseSchema,
rejectedOpenDatabaseSchema,
} from "./IdaProtocolValues.js";
import {
idaFileDigest,
@@ -122,6 +123,7 @@ export class IdaSessionClient implements AnalysisClient {
#databaseCloseCompleted = false;
#openAttempted = false;
#openCompleted = false;
#openRejected = false;
#callGraphAdvertised = false;
#surveyAdvertised = false;
#initialIdentity: string | undefined;
@@ -469,6 +471,9 @@ export class IdaSessionClient implements AnalysisClient {
preferred_session_id: this.#workspace.sessionId,
});
this.#openCompleted = true;
// A completed but malformed/positive open may still own a live Worker.
// Only an explicit producer rejection keeps the old no-worker branch.
this.#openRejected = rejectedOpenDatabaseSchema.safeParse(raw).success;
this.#lifecycle.push(raw);
const opened = openDatabaseSchema.parse(raw);
if (
@@ -633,6 +638,14 @@ export class IdaSessionClient implements AnalysisClient {
throw new AnalysisProtocolError(
"An unowned worker still uses the private workspace; it was retained.",
);
if (
this.#database === undefined &&
this.#openCompleted &&
!this.#openRejected
)
throw new AnalysisProtocolError(
"IDA open returned without a verified private worker binding. An empty session inventory does not prove that its Worker exited; the private workspace was retained.",
);
}
if (this.#database !== undefined) {
if (!this.#databaseCloseCompleted) {