refactor(providers)!: await owned readiness observations
Carry asynchronous readiness through provider selection, session status, CLI and MCP. Join observations during cancellation and shutdown, keep status readable during finalization, and retain mixed provider errors and exact cleanup dependencies through the shared inspection failure owner. Validation: 255 focused tests across 18 files; 21 registry tests rerun with primary restoration assertion; check:fast; docs:check and 5 README conformance tests. Registered MCP and SDK schema checks use controlled providers; no real Ghidra/JVM verification. This is a prerequisite for #4561. The synchronous Ghidra Java producer and its doctor/client ownership migration remain unfinished. BREAKING CHANGE: binary_session candidate availability can be unknown during owner finalization. Consumers must handle this state; the internal session status API is now asynchronous. Refs: #4561
This commit is contained in:
1 parent
4087048270
commit
150e996a86
25 files changed
+643
-132
No files matched your search
@@ -146,11 +146,14 @@ const completionInventoryLookup = async (
|
||||
return signal?.aborted === true ? undefined : result;
|
||||
};
|
||||
|
||||
const providerCandidates = (
|
||||
const providerCandidates = async (
|
||||
session: BinarySessionPort | undefined,
|
||||
): readonly string[] => {
|
||||
): Promise<readonly string[]> => {
|
||||
if (session === undefined) return [];
|
||||
const parsed = providerStatusSchema.safeParse(session.status());
|
||||
const signal = currentMcpRequestSignal();
|
||||
const parsed = providerStatusSchema.safeParse(
|
||||
await session.status(signal === undefined ? {} : { signal }),
|
||||
);
|
||||
if (!parsed.success) return [];
|
||||
const candidates = parsed.data.analysis_provider_candidates.map(
|
||||
({ provider }) => provider.id,
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { EvidenceMcpServer } from "./EvidenceMcpServer.js";
|
||||
import type { BinarySessionPort } from "../application/binary/BinarySessionPort.js";
|
||||
import type { ProviderAvailability } from "../application/AnalysisProvider.js";
|
||||
import type { JebAnalysisAvailability } from "../application/jeb/JebAnalysisPort.js";
|
||||
import { AnalysisCancelledError } from "../domain/analysisErrorCore.js";
|
||||
import { AnalysisError } from "../domain/analysisErrorBase.js";
|
||||
import {
|
||||
buildCapabilityInventory,
|
||||
compactToolAvailability,
|
||||
@@ -13,7 +13,7 @@ import type {
|
||||
ClientFeatureAvailability,
|
||||
ToolAvailability,
|
||||
} from "../contracts/toolOutputSchemaPrimitives.js";
|
||||
import { jsonObjectSchema } from "../domain/jsonValue.js";
|
||||
import { jsonObjectSchema, type JsonValue } from "../domain/jsonValue.js";
|
||||
import { createServerIdentity } from "../serverIdentity.js";
|
||||
import { mcpClientMetadata } from "./mcpClientMetadata.js";
|
||||
import type { AvailabilityPolicy } from "../application/CapabilityInventory.js";
|
||||
@@ -73,6 +73,7 @@ export const registerSessionStatusTool = (
|
||||
let adbAvailability: ProviderAvailability | undefined;
|
||||
let apktoolAvailability: ProviderAvailability | undefined;
|
||||
let jebAvailability: JebAnalysisAvailability | undefined;
|
||||
let status: JsonValue;
|
||||
try {
|
||||
const [android, adb, apktool, jeb] = await Promise.all([
|
||||
androidAnalysisAvailability(context.mcpReq.signal),
|
||||
@@ -84,14 +85,11 @@ export const registerSessionStatusTool = (
|
||||
adbAvailability = adb;
|
||||
apktoolAvailability = apktool;
|
||||
jebAvailability = jeb;
|
||||
status = await session.status({ signal: context.mcpReq.signal });
|
||||
} catch (cause) {
|
||||
if (!context.mcpReq.signal.aborted) throw cause;
|
||||
return server.delivery.toCallToolResult(
|
||||
err(new AnalysisCancelledError("binary_session")),
|
||||
contract,
|
||||
);
|
||||
if (!(cause instanceof AnalysisError)) throw cause;
|
||||
return server.delivery.toCallToolResult(err(cause), contract);
|
||||
}
|
||||
const status = session.status();
|
||||
const statusObject = jsonObjectSchema.parse(status);
|
||||
const toolAvailability = buildCapabilityInventory(
|
||||
status,
|
||||
|
||||
Reference in new issue
Block a user