mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 13:12:26 +00:00
fix(runtime): bind Inspector evidence to the selected request (#10039)
This commit is contained in:
1 parent
dd522bf9a7
commit
81d4f6b42a
2 files changed
+142
-34
No files matched your search
@@ -11,6 +11,7 @@ import type { AnalysisError } from "../../domain/analysisErrorBase.js";
|
||||
import type {
|
||||
ListJavaScriptRuntimeTargetsInput,
|
||||
ObserveJavaScriptRuntimeInput,
|
||||
JavaScriptRuntimeObservation,
|
||||
} from "../../domain/javascript/javascriptRuntimeObservation.js";
|
||||
import { err, ok, type Result } from "../../domain/result.js";
|
||||
import {
|
||||
@@ -80,6 +81,17 @@ export const observeJavaScriptRuntime = async (
|
||||
) {
|
||||
const report = javascriptRuntimeObservationSchema.safeParse(partial);
|
||||
if (report.success) {
|
||||
const mismatch = runtimeSelectionFailure(input, report.data);
|
||||
if (mismatch !== undefined) {
|
||||
result.error.retainSecondaryFailure(mismatch);
|
||||
return err(
|
||||
keepIncompleteObservation(
|
||||
result.error,
|
||||
"observe_javascript_runtime",
|
||||
"Inspector retained a non-JSON incomplete observation.",
|
||||
),
|
||||
);
|
||||
}
|
||||
result.error.partialObservation =
|
||||
createJavaScriptRuntimeObservationEvidence(
|
||||
"observe_javascript_runtime",
|
||||
@@ -107,6 +119,9 @@ export const observeJavaScriptRuntime = async (
|
||||
{ cause: report.error },
|
||||
),
|
||||
);
|
||||
const mismatch = runtimeSelectionFailure(input, report.data);
|
||||
if (mismatch !== undefined)
|
||||
return err(mismatch.retainPartialObservation(report.data));
|
||||
return runtimeEvidence(
|
||||
"observe_javascript_runtime",
|
||||
input,
|
||||
@@ -116,6 +131,24 @@ export const observeJavaScriptRuntime = async (
|
||||
);
|
||||
};
|
||||
|
||||
/** Shape-valid observations still must identify the caller-selected request. */
|
||||
const runtimeSelectionFailure = (
|
||||
input: ObserveJavaScriptRuntimeInput,
|
||||
report: JavaScriptRuntimeObservation,
|
||||
): AnalysisOutputError | undefined =>
|
||||
report.target.target_id !== input.target_id ||
|
||||
report.capture.observation_ms !== input.observation_ms ||
|
||||
report.target.runtime_kind !== (input.runtime_kind ?? "unknown") ||
|
||||
report.target.runtime_kind_authority !==
|
||||
(input.runtime_kind === undefined
|
||||
? "not-declared"
|
||||
: "caller-declared-unverified")
|
||||
? new AnalysisOutputError(
|
||||
"observe_javascript_runtime",
|
||||
"Inspector changed the selected target, observation window, or caller-declared runtime kind.",
|
||||
)
|
||||
: undefined;
|
||||
|
||||
const requireProvider = (
|
||||
provider: JavaScriptRuntimeObservationPort | undefined,
|
||||
operation: "list_javascript_runtime_targets" | "observe_javascript_runtime",
|
||||
|
||||
Reference in new issue
Block a user