Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
4de50d5
test(raw): pin raw-binary admission and identity
Entrpi Oct 27, 2026
893a023
refactor(raw): carry the raw load selection as one admitted value
Entrpi Oct 27, 2026
56f27b3
feat(raw): state the M-profile raw load contract
Entrpi Oct 27, 2026
f7b4496
feat(raw): admit M-profile loads at a separate base
Entrpi Oct 27, 2026
74b4a2c
feat(raw): give M-profile loads a versioned identity
Entrpi Oct 27, 2026
e1271f9
feat(ghidra): open M-profile loads at their base in Thumb state
Entrpi Oct 27, 2026
5962d2a
test(raw): check saved raw snapshots and schemas stay compatible
Entrpi Oct 27, 2026
6565d11
test(ghidra): verify M-profile raw loads against real Ghidra
Entrpi Oct 27, 2026
ea8ac34
feat(raw): add the armv8.1-m.main variant
Entrpi Oct 28, 2026
8bd006e
fix(ghidra): report Ghidra's ARMv8.1-M loop flow for armv8.1-m.main
Entrpi Oct 28, 2026
b45a7d4
test(ghidra): verify an ARMv8.1-M image against real Ghidra
Entrpi Oct 28, 2026
8d9e15a
refactor: name the variant vocabulary after architecture_variant
Entrpi Oct 28, 2026
63f2552
refactor(ghidra): keep variant decoder limitations beside the languages
Entrpi Oct 28, 2026
56a0587
fix(raw): require base_address with every architecture_variant
Entrpi Oct 28, 2026
808240d
fix(raw): align vector tables as VTOR does and refuse Reset inside them
Entrpi Oct 28, 2026
3bded52
fix(ghidra): key variant coordinates by base, not entry
Entrpi Oct 28, 2026
8315acc
refactor(raw): discriminate the segments load image by layout
Entrpi Oct 28, 2026
a2decdd
docs(raw): record why vector-table words keep their full width
Entrpi Oct 28, 2026
404b60f
docs(raw): record why the seeded entry function is named entry
Entrpi Oct 28, 2026
b381a01
fix(raw): name the refused load input in error details
Entrpi Oct 28, 2026
58ab75f
docs(raw): state that results keep no caller spellings yet
Entrpi Oct 28, 2026
3c4e4f5
docs(raw): explain why reused sessions cannot report stale vector words
Entrpi Oct 28, 2026
891a731
docs(raw): scope architecture_variant to the ARM M profiles
Entrpi Oct 28, 2026
3bc15c9
docs(raw): state each load pairing rule once in open_binary
Entrpi Oct 28, 2026
26cac3d
refactor(ghidra): let session limitations own the variant load facts
Entrpi Oct 28, 2026
33f1d13
refactor(ghidra): launch with the label policy the profile committed
Entrpi Oct 28, 2026
58c7e88
refactor(raw): let the vector-table read carry its length
Entrpi Oct 28, 2026
d7622e8
test(raw): compare saved raw images by their facts, not their prose
Entrpi Oct 28, 2026
36e0908
Merge upstream main into feat-ghidra-mprofile-raw
Entrpi Oct 28, 2026
d708eb4
test(ghidra): expect not-in-listing where the Cortex-M lane stops
Entrpi Oct 28, 2026
beaa182
test(raw): pin raw identity to main after its instruction-status revi…
Entrpi Oct 28, 2026
1b55c3a
test(ghidra): own the Cortex-M lane's LLVM and CLI commands
Entrpi Oct 29, 2026
a7451a0
test(raw): derive the Reset fixtures from one Thumb image
Entrpi Oct 29, 2026
bd985a4
docs(raw-binary): say that recording load spellings would not be addi…
Entrpi Oct 29, 2026
4731755
docs(raw-binary): tell callers how to keep their load spellings
Entrpi Oct 29, 2026
c943559
Merge upstream main into feat-ghidra-mprofile-raw
Entrpi Oct 29, 2026
13906c5
Merge upstream main into feat-ghidra-mprofile-raw
Entrpi Oct 29, 2026
a1c564e
Merge upstream main into feat-ghidra-mprofile-raw
Entrpi Oct 31, 2026
8745130
Merge upstream main into feat-ghidra-mprofile-raw
Entrpi Nov 1, 2026
93cde07
Merge upstream main into feat-ghidra-mprofile-raw
Entrpi Nov 1, 2026
54d4d33
Merge upstream main into feat-ghidra-mprofile-raw
Entrpi Nov 1, 2026
b250be1
Merge upstream main into feat-ghidra-mprofile-raw
Entrpi Nov 4, 2026
18c8965
Merge upstream main into feat-ghidra-mprofile-raw
Entrpi Nov 5, 2026
8aec915
test(ghidra): keep raw digests at main's byte-search and data-type re…
Entrpi Nov 5, 2026
8b78936
Merge upstream main into feat-ghidra-mprofile-raw
Entrpi Nov 5, 2026
a0717a6
Merge upstream main into feat-ghidra-mprofile-raw
Entrpi Nov 5, 2026
f45a6ca
Merge upstream main into feat-ghidra-mprofile-raw
Entrpi Nov 7, 2026
63b4fc8
Merge main into feat-ghidra-mprofile-raw
Entrpi Nov 7, 2026
46a8db4
test(domain): check raw-binary refusal facts, not sentences
Entrpi Nov 7, 2026
1238961
Merge main into feat-ghidra-mprofile-raw
Entrpi Nov 7, 2026
b82751a
Merge main into feat-ghidra-mprofile-raw
Entrpi Nov 7, 2026
7b4d25e
docs(adr): move the M-profile raw load decision into an ADR
Entrpi Nov 7, 2026
9251826
Merge main into feat-ghidra-mprofile-raw
Entrpi Nov 8, 2026
7c9d321
Merge main into feat-ghidra-mprofile-raw
Entrpi Nov 8, 2026
79ae54d
Merge main into feat-ghidra-mprofile-raw
Entrpi Nov 9, 2026
526c456
Merge main into feat-ghidra-mprofile-raw
Entrpi Nov 9, 2026
f0c95ab
test(ghidra): repin digests and replay for main's call-coverage revision
Entrpi Nov 9, 2026
ec36dc9
Merge branch 'main' into feat-ghidra-mprofile-raw
Entrpi Nov 10, 2026
68fa04d
Merge branch 'main' into feat-ghidra-mprofile-raw
Entrpi Nov 10, 2026
8ae3b4e
Merge branch 'main' into feat-ghidra-mprofile-raw
Entrpi Nov 10, 2026
ca775e7
Merge remote-tracking branch 'origin/main' into feat-ghidra-mprofile-raw
Entrpi Nov 11, 2026
69fb296
Merge remote-tracking branch 'origin/main' into feat-ghidra-mprofile-raw
Entrpi Nov 11, 2026
3760d36
chore(plugin): regenerate the skill bundle from the authored skill
Entrpi Nov 11, 2026
f032197
Merge remote-tracking branch 'origin/main' into feat-ghidra-mprofile-raw
Entrpi Nov 14, 2026
da137b0
Merge remote-tracking branch 'origin/main' into feat-ghidra-mprofile-raw
Entrpi Nov 14, 2026
cf445aa
Merge remote-tracking branch 'origin/main' into feat-ghidra-mprofile-raw
Entrpi Nov 21, 2026
9d7ab2c
test(raw): keep the target route diagnostics within the function leng…
Entrpi Nov 22, 2026
dd59ab0
docs(raw): record the M-profile lane on Ghidra 12.2
Entrpi Nov 22, 2026
583ecb7
refactor(raw): read vector words and own the Cortex-M workspace throu…
Entrpi Nov 22, 2026
0edf352
fix(raw): name raw-binary as the format of vector-table read failures
Entrpi Nov 22, 2026
207631c
fix(verify): remove the Cortex-M workspace after a verified run
Entrpi Nov 22, 2026
35fbcb8
chore(verify): record open_binary's input schema with the M-profile l…
Entrpi Nov 22, 2026
3d8e5c3
Merge remote-tracking branch 'origin/main' into feat-ghidra-mprofile-raw
Entrpi Nov 22, 2026
f6415fe
test(cli): expect open_binary's M-profile load flags in the CLI comma…
Entrpi Nov 22, 2026
c8a68a4
test(cli): record the CLI help goldens with the M-profile load flags
Entrpi Nov 22, 2026
0a66d7c
Merge remote-tracking branch 'origin/main' into feat-ghidra-mprofile-raw
Entrpi Nov 22, 2026
14bce8e
docs(raw-binary): qualify snapshot replay under the producer rule
Entrpi Nov 22, 2026
b660ef4
Merge remote-tracking branch 'origin/main' into feat-ghidra-mprofile-raw
Entrpi Nov 22, 2026
77d14bd
test(ghidra): report why Cortex-M verifier cleanup could not be checked
Entrpi Nov 22, 2026
5ecb56d
Merge remote-tracking branch 'origin/main' into feat-ghidra-mprofile-raw
Entrpi Nov 23, 2026
db9bc1d
Merge remote-tracking branch 'origin/main' into feat-ghidra-mprofile-raw
Entrpi Nov 23, 2026
07f639c
Merge remote-tracking branch 'origin/main' into feat-ghidra-mprofile-raw
Entrpi Nov 23, 2026
4f29527
fix(domain): compare raw-load functions by coordinates, not entry pro…
Entrpi Nov 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(raw): carry the raw load selection as one admitted value
The caller's raw load selection (format, architecture and entry_point)
travelled as three loose optional fields through about ten layers:
CLI flags, MCP open, direct analysis (five call sites), the session
port and open options, and target resolution. Every new load input had
to be threaded through each of them. The CLI and MCP boundaries now
build one NativeLoadSelection, and target admission is its only reader.

Admission now returns one RawBinaryLoad, carried on the raw target as
rawLoad. It names the base address of file offset 0 and the entry
separately. Before, the provider client, the load-image attestation,
the analysis profile and the snapshot target each read the entry and
assumed it was also the base. Admission still sets the base to the
entry, so nothing a caller sees changes.

No contract or behaviour change. The tests pinned in the previous
commit pass unchanged: the admission and pairing result grids, the
per-family profile digests, the raw snapshot target and query id, and
the complete raw load image. Tests that build raw targets use the new
rawLoadAtEntry fixture.
  • Loading branch information
Entrpi committed Oct 27, 2026
commit 893a02391c5539f955e906316fcbf6343b6aa576
2 changes: 1 addition & 1 deletion scripts/verify-real-ghidra-dol.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ try {
fixture,
);
const resolved = await parseBinaryTarget(fixture.path, {
formatHint: "gamecube-dol",
loadSelection: { format: "gamecube-dol" },
});
if (!resolved.ok) throw resolved.error;
assert.equal(resolved.value.format, "gamecube-dol");
Expand Down
29 changes: 10 additions & 19 deletions src/application/BinaryTargetResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import {
import { AnalysisCancelledError } from "../domain/analysisErrorCore.js";
import type {
BinaryTarget,
BinaryArchitecture,
PeCodeViewRecord,
UniversalMachOSlice,
} from "../domain/binaryTargetTypes.js";
Expand All @@ -50,13 +49,11 @@ import {
resolveAppBundleExecutable,
type ResolvedAppBundle,
} from "./AppBundleExecutable.js";
import {
validateDosComLength,
type ExecutableFormatHint,
} from "../domain/dosCom.js";
import { validateDosComLength } from "../domain/dosCom.js";
import {
admitRawBinary,
rawBinarySelectionError,
type NativeLoadSelection,
} from "../domain/rawBinary.js";
import { admitGamecubeDol } from "../domain/gamecubeDolAdmission.js";
import { DOL_HEADER_SIZE } from "../domain/gamecubeDol.js";
Expand Down Expand Up @@ -120,9 +117,7 @@ export interface BinaryTargetResolverOptions {
readonly cwd?: string;
readonly hostArchitecture?: NodeJS.Architecture;
readonly targetKind?: BinaryTarget["kind"];
readonly formatHint?: ExecutableFormatHint;
readonly architecture?: BinaryArchitecture;
readonly entryPoint?: string;
readonly loadSelection?: NativeLoadSelection;
readonly signal?: AbortSignal;
readonly resources?: ArtifactResourceScope;
}
Expand Down Expand Up @@ -258,7 +253,8 @@ const readOpenedBinaryTarget = async (
const { path, sourcePath, selectedPath, bundleInfoPlist } = selected;
const bundle = bundleInfoPlist === undefined ? {} : { bundleInfoPlist };
const hostArchitecture = options.hostArchitecture ?? process.arch;
const { targetKind, formatHint, signal, architecture, entryPoint } = options;
const { targetKind, signal, loadSelection = {} } = options;
const formatHint = loadSelection.format;
throwIfTargetResolutionCancelled(signal);
if (formatHint === "raw-binary") {
if (targetKind !== undefined && targetKind !== "executable")
Expand All @@ -270,8 +266,8 @@ const readOpenedBinaryTarget = async (
),
);
const admitted = admitRawBinary({
architecture,
entryPoint,
architecture: loadSelection.architecture,
entryPoint: loadSelection.entryPoint,
fileBytes: metadata.size,
});
if (!admitted.ok)
Expand All @@ -289,15 +285,10 @@ const readOpenedBinaryTarget = async (
format: "raw-binary",
architecture: admitted.value.architecture,
availableArchitectures: [admitted.value.architecture],
entryPoint: admitted.value.entryPoint,
entryPointSource: admitted.value.entryPointSource,
rawLoad: admitted.value.load,
});
}
const pairing = rawBinarySelectionError({
...(formatHint === undefined ? {} : { format: formatHint }),
architecture,
entryPoint,
});
const pairing = rawBinarySelectionError(loadSelection);
if (pairing !== undefined)
return err(
new BinaryTargetError(path, pairing, {
Expand All @@ -323,7 +314,7 @@ const readOpenedBinaryTarget = async (
const admitted = admitGamecubeDol({
bytes: headerBytes,
fileSize: metadata.size,
entryPoint,
entryPoint: loadSelection.entryPoint,
});
if (!admitted.ok)
return err(
Expand Down
69 changes: 15 additions & 54 deletions src/application/DirectAnalysis.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import type { ExecutableFormatHint } from "../domain/dosCom.js";
import { dispatchQueuedInterrupts } from "../process/queuedInterrupts.js";
import type {
BinaryArchitecture,
BinaryTarget,
} from "../domain/binaryTargetTypes.js";
import type { BinaryTarget } from "../domain/binaryTargetTypes.js";
import type { NativeLoadSelection } from "../domain/rawBinary.js";
import type { JsonValue } from "../domain/jsonValue.js";
import type { DirectAnalysisDependencies } from "./DirectAnalysisDependencies.js";
import type { BinarySession } from "./binary/BinarySession.js";
Expand Down Expand Up @@ -129,25 +126,17 @@ export const runDirectAnalysis = async (
readonly snapshotPath?: string | undefined;
readonly signal?: AbortSignal;
readonly providerId?: AnalysisProviderSelector;
readonly formatHint?: ExecutableFormatHint;
readonly architecture?: BinaryArchitecture;
readonly entryPoint?: string;
readonly loadSelection?: NativeLoadSelection;
} = {},
): Promise<Result<Evidence, JsonValue>> =>
withProcessCancellation(options.signal, (signal) =>
runAnalysis(dependencies, path, tool, arguments_, {
logger: options.logger ?? silentLogger,
snapshotPath: options.snapshotPath,
signal,
...(options.formatHint === undefined
? {}
: { formatHint: options.formatHint }),
...(options.architecture === undefined
? {}
: { architecture: options.architecture }),
...(options.entryPoint === undefined
...(options.loadSelection === undefined
? {}
: { entryPoint: options.entryPoint }),
: { loadSelection: options.loadSelection }),
...(options.providerId === undefined
? {}
: { providerId: options.providerId }),
Expand Down Expand Up @@ -324,9 +313,7 @@ const runAnalysis = async (
readonly evidenceParameters?: Readonly<Record<string, JsonValue>>;
readonly createSession?: () => BinarySession | Promise<BinarySession>;
readonly providerId?: AnalysisProviderSelector;
readonly formatHint?: ExecutableFormatHint;
readonly architecture?: BinaryArchitecture;
readonly entryPoint?: string;
readonly loadSelection?: NativeLoadSelection;
},
): Promise<Result<Evidence, JsonValue>> => {
const { logger, signal, snapshotPath } = options;
Expand Down Expand Up @@ -373,15 +360,9 @@ const runAnalysis = async (
path,
snapshotPath,
signal,
...(options.formatHint === undefined
...(options.loadSelection === undefined
? {}
: { formatHint: options.formatHint }),
...(options.architecture === undefined
? {}
: { architecture: options.architecture }),
...(options.entryPoint === undefined
? {}
: { entryPoint: options.entryPoint }),
: { loadSelection: options.loadSelection }),
});
if (!prepared.ok) return err(prepared.error);
const { snapshot } = prepared.value;
Expand All @@ -390,15 +371,9 @@ const runAnalysis = async (
const preview = await session.previewTarget(prepared.value.target, {
signal,
snapshot,
...(options.formatHint === undefined
? {}
: { formatHint: options.formatHint }),
...(options.architecture === undefined
...(options.loadSelection === undefined
? {}
: { architecture: options.architecture }),
...(options.entryPoint === undefined
? {}
: { entryPoint: options.entryPoint }),
: { loadSelection: options.loadSelection }),
...(options.providerId === undefined
? {}
: { providerId: options.providerId }),
Expand Down Expand Up @@ -437,15 +412,9 @@ const runAnalysis = async (
}
const openOptions = {
signal,
...(options.formatHint === undefined
? {}
: { formatHint: options.formatHint }),
...(options.architecture === undefined
? {}
: { architecture: options.architecture }),
...(options.entryPoint === undefined
...(options.loadSelection === undefined
? {}
: { entryPoint: options.entryPoint }),
: { loadSelection: options.loadSelection }),
...(snapshot === undefined ? {} : { snapshot }),
...(options.providerId === undefined
? {}
Expand Down Expand Up @@ -700,9 +669,7 @@ const prepareSnapshot = async (options: {
"readAnalysisSnapshot" | "resolveTarget"
>;
readonly path: string;
readonly formatHint?: ExecutableFormatHint;
readonly architecture?: BinaryArchitecture;
readonly entryPoint?: string;
readonly loadSelection?: NativeLoadSelection;
readonly snapshotPath: string | undefined;
readonly signal: AbortSignal;
}): Promise<
Expand All @@ -721,15 +688,9 @@ const prepareSnapshot = async (options: {
if (!loaded.ok) return loaded;
const target = await session.resolveTarget(path, {
signal: options.signal,
...(options.formatHint === undefined
? {}
: { formatHint: options.formatHint }),
...(options.architecture === undefined
? {}
: { architecture: options.architecture }),
...(options.entryPoint === undefined
...(options.loadSelection === undefined
? {}
: { entryPoint: options.entryPoint }),
: { loadSelection: options.loadSelection }),
});
if (!target.ok) return target;
if (!snapshotMatchesTarget(loaded.value.target, target.value))
Expand Down
21 changes: 5 additions & 16 deletions src/application/binary/BinarySessionOpen.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import type { ExecutableFormatHint } from "../../domain/dosCom.js";
import type {
BinaryArchitecture,
BinaryTarget,
} from "../../domain/binaryTargetTypes.js";
import type { BinaryTarget } from "../../domain/binaryTargetTypes.js";
import type { NativeLoadSelection } from "../../domain/rawBinary.js";
import { artifactTargetSelectedPath } from "../../domain/binaryTargetTypes.js";
import type { AnalysisProviderSelector } from "../../domain/providerSelection.js";
import type { AnalysisProfileCommitment } from "../../domain/analysisProfile.js";
Expand Down Expand Up @@ -35,9 +32,7 @@ export type AnalysisSnapshotLoader = () => Promise<
export interface BinarySessionOpenOptions {
readonly signal?: AbortSignal;
readonly targetKind?: BinaryTarget["kind"];
readonly formatHint?: ExecutableFormatHint;
readonly architecture?: BinaryArchitecture;
readonly entryPoint?: string;
readonly loadSelection?: NativeLoadSelection;
readonly snapshot?: AnalysisSnapshot;
/**
* Load the snapshot inside the open's turn instead of before it, so calls
Expand Down Expand Up @@ -92,15 +87,9 @@ export const resolveSessionOpen = async (
...(options.targetKind === undefined
? {}
: { targetKind: options.targetKind }),
...(options.formatHint === undefined
...(options.loadSelection === undefined
? {}
: { formatHint: options.formatHint }),
...(options.architecture === undefined
? {}
: { architecture: options.architecture }),
...(options.entryPoint === undefined
? {}
: { entryPoint: options.entryPoint }),
: { loadSelection: options.loadSelection }),
...(options.signal === undefined ? {} : { signal: options.signal }),
});
if (!parsed.ok) return parsed;
Expand Down
11 changes: 3 additions & 8 deletions src/application/binary/BinarySessionPort.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import type { InvestigationRecordPort } from "../investigation/InvestigationRecordPort.js";
import type { ExecutableFormatHint } from "../../domain/dosCom.js";
import type {
BinaryArchitecture,
BinaryTarget,
} from "../../domain/binaryTargetTypes.js";
import type { BinaryTarget } from "../../domain/binaryTargetTypes.js";
import type { NativeLoadSelection } from "../../domain/rawBinary.js";
import type { JsonValue } from "../../domain/jsonValue.js";
import type { AnalysisSnapshot } from "../../domain/analysisSnapshot.js";
import type { AnalysisProfileCommitment } from "../../domain/analysisProfile.js";
Expand Down Expand Up @@ -61,9 +58,7 @@ export interface BinarySessionPort
options?: {
readonly signal?: AbortSignal;
readonly targetKind?: BinaryTarget["kind"];
readonly formatHint?: ExecutableFormatHint;
readonly architecture?: BinaryArchitecture;
readonly entryPoint?: string;
readonly loadSelection?: NativeLoadSelection;
readonly snapshot?: AnalysisSnapshot;
readonly loadSnapshot?: AnalysisSnapshotLoader;
readonly providerId?: AnalysisProviderSelector;
Expand Down
8 changes: 5 additions & 3 deletions src/application/binary/BinaryTargetSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export const binaryTargetSummary = (target: BinaryTarget) =>
kind: target.kind,
sha256: target.sha256,
architecture: target.architecture ?? null,
...(target.format === "raw-binary" || target.format === "gamecube-dol"
? { entry_point: target.entryPoint }
: {}),
...(target.format === "raw-binary"
? { entry_point: target.rawLoad.entryPoint }
: target.format === "gamecube-dol"
? { entry_point: target.entryPoint }
: {}),
});
22 changes: 15 additions & 7 deletions src/cli/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { BinaryArchitecture } from "../domain/binaryTargetTypes.js";
import {
binaryArchitectureSchema,
rawBinaryEntryPointSchema,
type NativeLoadSelection,
} from "../domain/rawBinary.js";
import { analysisProviderSelectorSchema } from "../domain/providerSelection.js";
import type { AnalysisProviderSelector } from "../domain/providerSelection.js";
Expand Down Expand Up @@ -69,21 +70,28 @@ export interface NativeOpenCliFlags {
readonly "entry-point"?: string | undefined;
}

/** Map native CLI flags onto the shared one-shot analysis options. */
export const directAnalysisOptionsFromCli = (
logger: Logger,
/** Collect the native load flags into the selection that target admission owns. */
const nativeLoadSelectionFromCli = (
options: NativeOpenCliFlags,
) => ({
logger,
snapshotPath: options.snapshot,
): NativeLoadSelection => ({
...(options["target-format"] === undefined
? {}
: { formatHint: options["target-format"] }),
: { format: options["target-format"] }),
...(options.architecture === undefined
? {}
: { architecture: options.architecture }),
...(options["entry-point"] === undefined
? {}
: { entryPoint: options["entry-point"] }),
});

/** Map native CLI flags onto the shared one-shot analysis options. */
export const directAnalysisOptionsFromCli = (
logger: Logger,
options: NativeOpenCliFlags,
) => ({
logger,
snapshotPath: options.snapshot,
loadSelection: nativeLoadSelectionFromCli(options),
...(options.provider === undefined ? {} : { providerId: options.provider }),
});
29 changes: 19 additions & 10 deletions src/contracts/sessionLifecycleInputs.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { executableFormatHintSchema } from "../domain/dosCom.js";
import {
executableFormatHintSchema,
type ExecutableFormatHint,
} from "../domain/dosCom.js";
import { absoluteLocalPathStringSchema } from "../domain/localPath.js";
import {
binaryArchitectureSchema,
rawBinaryEntryPointSchema,
rawBinarySelectionError,
type NativeLoadSelection,
} from "../domain/rawBinary.js";
import { z } from "zod";
import { analysisProviderSelectorSchema } from "../domain/providerSelection.js";
Expand All @@ -18,6 +22,19 @@ const binaryTargetPathSchema = absoluteLocalPathStringSchema.describe(
"Absolute local filesystem path for the analysis target; relative paths are rejected.",
);

/** Collect the open_binary load fields into the selection that target admission owns. */
export const openBinaryLoadSelection = (input: {
readonly format?: ExecutableFormatHint | undefined;
readonly architecture?: NativeLoadSelection["architecture"] | undefined;
readonly entry_point?: string | undefined;
}): NativeLoadSelection => ({
...(input.format === undefined ? {} : { format: input.format }),
...(input.architecture === undefined
? {}
: { architecture: input.architecture }),
...(input.entry_point === undefined ? {} : { entryPoint: input.entry_point }),
});

/** Input contract for opening a target with an optional staged snapshot. */
export const openBinaryInputSchema = z
.strictObject({
Expand All @@ -41,15 +58,7 @@ export const openBinaryInputSchema = z
snapshot_path: snapshotPathSchema.optional(),
})
.superRefine((value, context) => {
const pairing = rawBinarySelectionError({
...(value.format === undefined ? {} : { format: value.format }),
...(value.architecture === undefined
? {}
: { architecture: value.architecture }),
...(value.entry_point === undefined
? {}
: { entryPoint: value.entry_point }),
});
const pairing = rawBinarySelectionError(openBinaryLoadSelection(value));
if (pairing === undefined) return;
context.addIssue({
code: "custom",
Expand Down
Loading