feat(ghidra): checkpoint owned Programs across sessions

Add opt-in REA_GHIDRA_CHECKPOINT_DIR for owned Ghidra Program persistence through the shared CLI/MCP provider. Save completed initial analysis and metadata changes on normal close; verify and restore the last successful packed Program without auto-analysis.

Preserve generation identity, exclusive ownership, typed cancellation and cleanup retry. Refresh checkpoint-dependent profiles after retirement, including failed-switch restoration, while retaining caller selection provenance. Keep source executables and caller projects unchanged.

Validated with 720 focused tests (3 platform skips), 13 real Ghidra CLI/MCP scenarios, static/docs checks and CI. Review findings addressed. No version bump or release publication.

Refs #8165.
This commit is contained in:
gensokyo-dev authored and GitHub committed 2026-11-07 14:52:39 +08:00
1 parent 99db80a13e
commit c07ab4b994
32 files changed
+2711 -111

No files matched your search

@@ -25,6 +25,7 @@ export interface SessionProviderRoute {
readonly identity: ProviderIdentity;
readonly capabilities: ReadonlyMap<string, CapabilityDescriptor>;
readonly profile: AnalysisProfileCommitment | null;
readonly refreshAfterRetirement?: true;
readonly binding: AnalysisProviderBinding | null;
readonly selection: AnalysisProviderSelection | undefined;
createClient(
@@ -97,6 +98,37 @@ export class SessionProviderRouter {
: selected;
}
/** Refresh only provider selections whose state can be published by close. */
async refreshAfterRetirement(
route: SessionProviderRoute,
target: BinaryTarget,
signal?: AbortSignal,
): Promise<Result<SessionProviderRoute, AnalysisError>> {
if (route.refreshAfterRetirement !== true || route.binding === null)
return ok(route);
const refreshed = await this.registry.select(
target,
route.binding.identity.id,
signal === undefined ? {} : { signal },
);
if (!refreshed.ok) return refreshed;
return ok(
selectableRoute(this.auxiliaryProviders, {
...refreshed.value,
requestedProviderId:
route.selection?.requestedProviderId ??
refreshed.value.requestedProviderId,
binding:
refreshed.value.binding === null
? null
: {
...refreshed.value.binding,
selectionSource: route.binding.selectionSource,
},
}),
);
}
/** Candidate status authoritative for the active or target-free route. */
async candidateStatuses(
route: SessionProviderRoute,
@@ -156,6 +188,9 @@ const selectableRoute = (
identity,
capabilities,
profile: binding?.profile ?? null,
...(binding?.refreshAfterRetirement === undefined
? {}
: { refreshAfterRetirement: binding.refreshAfterRetirement }),
binding,
selection,
createClient: (target, context) =>