mirror of
https://github.com/morluto/rea.git
synced 2026-10-26 17:35:11 +00:00
Retain native-only dispatch workflows without requiring a deep provider profile. Validate exact target, operation, and current reader bindings during open, import, recording, and export; preserve selected deep bindings and caller limits. Validated public CLI and stdio MCP save/reopen, exact CLI replay, changed-limit cache partitioning, baseline failure and candidate success on an Apple-clang fixture, snapshot lifecycle regressions, typecheck and lint. No target or deep engine execution. Fixes #5529.
60 lines
2.2 KiB
TypeScript
60 lines
2.2 KiB
TypeScript
import { analysisProfilesEqual } from "../../domain/analysisProfile.js";
|
|
import type { AnalysisProfileCommitment } from "../../domain/analysisProfile.js";
|
|
import {
|
|
snapshotMatchesBinding,
|
|
type AnalysisSnapshot,
|
|
} from "../../domain/analysisSnapshot.js";
|
|
import type { BinaryTarget } from "../../domain/binaryTargetTypes.js";
|
|
import { workflowAnalysisProfile } from "../InvestigationProviders.js";
|
|
import type { SessionProviderRoute } from "./SessionProviderRouter.js";
|
|
|
|
/** Return the exact currently declared native dispatch reader profile, if any. */
|
|
export const profilelessNativeDispatchProfile = (
|
|
route: SessionProviderRoute,
|
|
): AnalysisProfileCommitment | undefined => {
|
|
const descriptor = route.capabilities.get("inspect_native_dispatch_metadata");
|
|
const profile = descriptor?.analysisProfile;
|
|
if (
|
|
descriptor === undefined ||
|
|
descriptor.operation !== "inspect_native_dispatch_metadata" ||
|
|
!descriptor.available ||
|
|
descriptor.provider.id !== "native-macos" ||
|
|
profile === undefined ||
|
|
profile.provider.id !== descriptor.provider.id ||
|
|
profile.provider.name !== descriptor.provider.name ||
|
|
profile.provider.version.length === 0
|
|
)
|
|
return undefined;
|
|
return structuredClone(profile);
|
|
};
|
|
|
|
/** Require only exact native dispatch workflow observations for this target/profile. */
|
|
export const isProfilelessNativeDispatchSnapshot = (
|
|
snapshot: AnalysisSnapshot,
|
|
target: BinaryTarget,
|
|
profile: AnalysisProfileCommitment,
|
|
): boolean =>
|
|
snapshotMatchesBinding(snapshot, target, profile) &&
|
|
snapshot.entries.length === 0 &&
|
|
hasOnlyProfilelessNativeDispatchEntries(snapshot.workflow_entries, profile);
|
|
|
|
/** Reject mixed operations and entries derived from a different source profile. */
|
|
export const hasOnlyProfilelessNativeDispatchEntries = (
|
|
entries: readonly {
|
|
readonly operation: string;
|
|
readonly execution: {
|
|
readonly analysis_profile: AnalysisProfileCommitment;
|
|
};
|
|
}[],
|
|
profile: AnalysisProfileCommitment,
|
|
): boolean =>
|
|
entries.length > 0 &&
|
|
entries.every(
|
|
(entry) =>
|
|
entry.operation === "inspect_native_dispatch_metadata" &&
|
|
analysisProfilesEqual(
|
|
entry.execution.analysis_profile,
|
|
workflowAnalysisProfile(profile, entry.operation),
|
|
),
|
|
);
|