mirror of
https://github.com/morluto/rea.git
synced 2026-11-21 06:04:03 +00:00
fix(native): preserve caller-selected paths in binary sessions (#12102)
* fix(mcp): preserve caller-selected binary session paths * test(mcp): verify caller paths across snapshot replay * test(mcp): separate session alias and snapshot replay coverage * fix(evidence): preserve selected paths across binary workflows * fix(evidence): retain authentication admission for caller aliases
This commit is contained in:
1 parent
c3531b9f1c
commit
e09d6273a1
17 files changed
+469
-109
No files matched your search
@@ -382,6 +382,9 @@ export class BinarySession
|
||||
const imported = this.importAnalysisSnapshot(options.snapshot);
|
||||
if (!imported.ok) return imported;
|
||||
}
|
||||
// The same bytes can be selected through a different spelling without retiring the engine.
|
||||
if (retained.target.callerInputPath !== target.callerInputPath)
|
||||
this.#active = { ...retained, target };
|
||||
return ok(target);
|
||||
}
|
||||
|
||||
@@ -541,6 +544,9 @@ export class BinarySession
|
||||
kind: "binary",
|
||||
path: this.#active.target.path,
|
||||
sha256: this.#active.target.sha256,
|
||||
...(this.#active.target.callerInputPath === undefined
|
||||
? {}
|
||||
: { caller_input_path: this.#active.target.callerInputPath }),
|
||||
};
|
||||
if (this.#activeBundleResources !== undefined)
|
||||
return {
|
||||
@@ -1468,12 +1474,13 @@ export class BinarySession
|
||||
const execution = { ...result.value, subject: null };
|
||||
return ok(execution);
|
||||
}
|
||||
const sessionBinding = this.#active;
|
||||
const prepared = prepareSessionExecution({
|
||||
active: this.#active,
|
||||
active: sessionBinding,
|
||||
operation: name,
|
||||
parameters: arguments_,
|
||||
snapshotContext: options?.snapshotContext,
|
||||
nativeSourceAdmitted: this.#active?.nativeSourceAdmitted === true,
|
||||
nativeSourceAdmitted: sessionBinding?.nativeSourceAdmitted === true,
|
||||
isOperationAvailable: (operation) => this.#currentlyAvailable(operation),
|
||||
isOperationAdvertised: options?.isOperationAdvertised,
|
||||
unboundOperationError: (operation, route) =>
|
||||
@@ -1510,12 +1517,14 @@ export class BinarySession
|
||||
: profiled;
|
||||
// A successful Ghidra operation proves this client's native source snapshot
|
||||
// was admitted; a composite health response and parsed path do not.
|
||||
const currentBinding = this.#active;
|
||||
if (
|
||||
execution.ok &&
|
||||
capability.provider.id === "ghidra" &&
|
||||
this.#active === active
|
||||
currentBinding !== undefined &&
|
||||
currentBinding.runId === sessionBinding?.runId
|
||||
)
|
||||
this.#active.nativeSourceAdmitted = true;
|
||||
currentBinding.nativeSourceAdmitted = true;
|
||||
if (
|
||||
this.#runtimeAvailability.observe(
|
||||
dispatch,
|
||||
@@ -1571,7 +1580,10 @@ export class BinarySession
|
||||
name,
|
||||
arguments_,
|
||||
evidenceExecution,
|
||||
this.admitRecoveryObservation.bind(this),
|
||||
{
|
||||
callerTarget: active.target,
|
||||
admit: this.admitRecoveryObservation.bind(this),
|
||||
},
|
||||
);
|
||||
if (!admitted.ok) return admitted;
|
||||
const evidence = createAnalysisExecutionEvidence(
|
||||
@@ -1579,6 +1591,7 @@ export class BinarySession
|
||||
arguments_,
|
||||
evidenceExecution,
|
||||
"observed",
|
||||
{ callerTarget: active.target },
|
||||
);
|
||||
const recorded = this.recordEvidence(evidence);
|
||||
if (!recorded.ok) {
|
||||
@@ -1593,6 +1606,7 @@ export class BinarySession
|
||||
: bindSessionEvidenceExecution(
|
||||
{ ...execution.value, evidenceId: evidence.evidence_id },
|
||||
authenticated,
|
||||
active.target.callerInputPath,
|
||||
);
|
||||
if (cacheable && execution.value.cachePolicy !== "live")
|
||||
this.recordSnapshot({
|
||||
|
||||
@@ -33,7 +33,12 @@ import type { SavedAnalysisSnapshot } from "../../domain/savedAnalysisSnapshot.j
|
||||
|
||||
/** Selection observed at the end of one serialized open attempt. */
|
||||
export type OpenSelectionReceipt =
|
||||
| { readonly kind: "binary"; readonly path: string; readonly sha256: string }
|
||||
| {
|
||||
readonly kind: "binary";
|
||||
readonly path: string;
|
||||
readonly sha256: string;
|
||||
readonly caller_input_path?: string;
|
||||
}
|
||||
| {
|
||||
readonly kind: "resources";
|
||||
readonly path: string;
|
||||
|
||||
@@ -6,6 +6,9 @@ import { liveBinaryTargetSummarySchema } from "../../domain/liveBinaryTargetSumm
|
||||
export const binaryTargetSummary = (target: BinaryTarget) =>
|
||||
liveBinaryTargetSummarySchema.parse({
|
||||
path: target.path,
|
||||
...(target.callerInputPath === undefined
|
||||
? {}
|
||||
: { caller_input_path: target.callerInputPath }),
|
||||
format: target.format,
|
||||
kind: target.kind,
|
||||
sha256: target.sha256,
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { evidenceSubjectDisplay } from "../../domain/evidence.js";
|
||||
import {
|
||||
evidenceSubjectDisplay,
|
||||
type Evidence,
|
||||
} from "../../domain/evidence.js";
|
||||
import { basename } from "node:path";
|
||||
import type { AnalysisExecution } from "../../ports/AnalysisProvider.js";
|
||||
import type { Evidence } from "../../domain/evidence.js";
|
||||
import type { JsonValue } from "../../domain/jsonValue.js";
|
||||
import { equalJsonText } from "../../domain/jsonSerialization.js";
|
||||
import type { AnalysisError } from "../../domain/analysisErrorBase.js";
|
||||
@@ -18,11 +20,12 @@ const issued = new WeakMap<AnalysisExecution, Evidence>();
|
||||
export const bindSessionEvidenceExecution = (
|
||||
execution: AnalysisExecution,
|
||||
evidence: Evidence,
|
||||
callerInputPath: string | undefined,
|
||||
): AnalysisExecution => {
|
||||
if (
|
||||
(execution.sourceEvidence !== undefined &&
|
||||
execution.sourceEvidence.length > 0) ||
|
||||
evidence.caller_input_path !== undefined
|
||||
evidence.caller_input_path !== callerInputPath
|
||||
)
|
||||
return execution;
|
||||
// Semantic IDs intentionally omit display paths and names. A duplicate in
|
||||
@@ -113,12 +116,10 @@ export const completedOperationEvidence = (
|
||||
subject:
|
||||
execution.subject === undefined ? options.target : execution.subject,
|
||||
};
|
||||
const admitted = admitCompletedAnalysis(
|
||||
operation,
|
||||
parameters,
|
||||
observation,
|
||||
options.admitRecovery,
|
||||
);
|
||||
const admitted = admitCompletedAnalysis(operation, parameters, observation, {
|
||||
callerTarget: options.target,
|
||||
admit: options.admitRecovery,
|
||||
});
|
||||
if (!admitted.ok) return admitted;
|
||||
return ok(
|
||||
createAnalysisExecutionEvidence(
|
||||
@@ -126,6 +127,7 @@ export const completedOperationEvidence = (
|
||||
parameters,
|
||||
observation,
|
||||
"observed",
|
||||
{ callerTarget: options.target },
|
||||
),
|
||||
);
|
||||
};
|
||||
Reference in new issue
Block a user