refactor(tools): remove redundant limits and acknowledgements
This commit is contained in:
@@ -57,29 +57,23 @@ describe("browser observation contracts", () => {
|
||||
listBrowserTargetsInputSchema.parse({
|
||||
cdp_endpoint: "http://127.0.0.1:9222",
|
||||
allowed_origins: ["https://app.example.test"],
|
||||
approved: true,
|
||||
}),
|
||||
).toEqual({
|
||||
cdp_endpoint: "http://127.0.0.1:9222",
|
||||
allowed_origins: ["https://app.example.test"],
|
||||
approved: true,
|
||||
});
|
||||
expect(
|
||||
inspectWebPageInputSchema.parse({
|
||||
cdp_endpoint: "http://127.0.0.1:9222",
|
||||
allowed_origins: ["https://app.example.test"],
|
||||
target_id: "page-1",
|
||||
approved: true,
|
||||
}),
|
||||
).toMatchObject({
|
||||
observation_ms: 500,
|
||||
include_accessibility_text: false,
|
||||
include_console_text: false,
|
||||
console_text_approved: false,
|
||||
include_json_body_shapes: false,
|
||||
json_body_schema_approved: false,
|
||||
include_websocket_shapes: false,
|
||||
websocket_shape_approved: false,
|
||||
include_script_sources: false,
|
||||
include_storage_keys: false,
|
||||
limits: {
|
||||
@@ -111,40 +105,35 @@ describe("browser observation contracts", () => {
|
||||
});
|
||||
|
||||
describe("browser observation sensitive surfaces and retention", () => {
|
||||
it("requires independent approval for each sensitive capture surface", () => {
|
||||
it("accepts selected sensitive capture surfaces without extra flags", () => {
|
||||
const base = {
|
||||
cdp_endpoint: "http://127.0.0.1:9222",
|
||||
allowed_origins: ["https://app.example.test"],
|
||||
target_id: "page-1",
|
||||
approved: true,
|
||||
};
|
||||
for (const input of [
|
||||
{ include_console_text: true },
|
||||
{ include_json_body_shapes: true },
|
||||
{ include_websocket_shapes: true },
|
||||
{ include_storage_fingerprints: true },
|
||||
])
|
||||
expect(
|
||||
inspectWebPageInputSchema.safeParse({ ...base, ...input }).success,
|
||||
).toBe(false);
|
||||
).toBe(true);
|
||||
expect(
|
||||
inspectWebPageInputSchema.safeParse({
|
||||
...base,
|
||||
include_storage_fingerprints: true,
|
||||
}).success,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("requires an independent literal approval for screenshot pixels", () => {
|
||||
it("accepts screenshot capture without an extra approval flag", () => {
|
||||
const input = {
|
||||
cdp_endpoint: "http://127.0.0.1:9222",
|
||||
allowed_origins: ["https://app.example.test"],
|
||||
target_id: "page-1",
|
||||
approved: true,
|
||||
};
|
||||
expect(captureWebScreenshotInputSchema.safeParse(input).success).toBe(
|
||||
false,
|
||||
);
|
||||
expect(
|
||||
captureWebScreenshotInputSchema.safeParse({
|
||||
...input,
|
||||
screenshot_approved: true,
|
||||
}).success,
|
||||
).toBe(true);
|
||||
expect(captureWebScreenshotInputSchema.safeParse(input).success).toBe(true);
|
||||
});
|
||||
|
||||
it("removes credentials, query values, and fragments from observed URLs", () => {
|
||||
|
||||
@@ -92,17 +92,14 @@ export const browserAllowedOriginsSchema = z
|
||||
.max(32)
|
||||
.transform((origins) => [...new Set(origins)].sort());
|
||||
|
||||
const approvedBrowserInput = {
|
||||
const browserInput = {
|
||||
cdp_endpoint: browserEndpointSchema,
|
||||
allowed_origins: browserAllowedOriginsSchema,
|
||||
approved: z
|
||||
.literal(true)
|
||||
.describe("Explicit approval for browser observation"),
|
||||
};
|
||||
|
||||
/** Public input for complete discovery of allowed page targets. */
|
||||
export const listBrowserTargetsInputSchema = z.object({
|
||||
...approvedBrowserInput,
|
||||
...browserInput,
|
||||
});
|
||||
|
||||
const browserInspectionLimitsSchema = z.object({
|
||||
@@ -206,16 +203,13 @@ const DEFAULT_BROWSER_INSPECTION_LIMITS = {
|
||||
} as const;
|
||||
|
||||
const inspectWebPageInputFacts = {
|
||||
...approvedBrowserInput,
|
||||
...browserInput,
|
||||
target_id: z.string().trim().min(1).max(256),
|
||||
observation_ms: z.number().int().min(0).max(10_000).default(500),
|
||||
include_accessibility_text: z.boolean().default(false),
|
||||
include_console_text: z.boolean().default(false),
|
||||
console_text_approved: z.boolean().default(false),
|
||||
include_json_body_shapes: z.boolean().default(false),
|
||||
json_body_schema_approved: z.boolean().default(false),
|
||||
include_websocket_shapes: z.boolean().default(false),
|
||||
websocket_shape_approved: z.boolean().default(false),
|
||||
include_storage_keys: z.boolean().default(false),
|
||||
include_storage_fingerprints: z.boolean().default(false),
|
||||
limits: browserInspectionLimitsSchema.default(
|
||||
@@ -226,13 +220,11 @@ const inspectWebPageInputFacts = {
|
||||
const inspectWebPageWithoutSourceSchema = z.strictObject({
|
||||
...inspectWebPageInputFacts,
|
||||
include_script_sources: z.literal(false).default(false),
|
||||
source_capture_approved: z.literal(false).default(false),
|
||||
});
|
||||
|
||||
const inspectWebPageWithSourceShapeSchema = z.strictObject({
|
||||
...inspectWebPageInputFacts,
|
||||
include_script_sources: z.literal(true).default(true),
|
||||
source_capture_approved: z.literal(true),
|
||||
});
|
||||
|
||||
type InspectWebPageShape =
|
||||
@@ -258,28 +250,6 @@ const refineInspectWebPageInput = (
|
||||
path: ["limits", "max_script_source_bytes"],
|
||||
message: "Per-script source limit cannot exceed the total source limit",
|
||||
});
|
||||
for (const [include, approved, path, message] of [
|
||||
[
|
||||
input.include_console_text,
|
||||
input.console_text_approved,
|
||||
"console_text_approved",
|
||||
"Console text capture requires separate approval",
|
||||
],
|
||||
[
|
||||
input.include_json_body_shapes,
|
||||
input.json_body_schema_approved,
|
||||
"json_body_schema_approved",
|
||||
"JSON body schema capture requires separate approval",
|
||||
],
|
||||
[
|
||||
input.include_websocket_shapes,
|
||||
input.websocket_shape_approved,
|
||||
"websocket_shape_approved",
|
||||
"WebSocket shape capture requires separate approval",
|
||||
],
|
||||
] as const)
|
||||
if (include && !approved)
|
||||
context.addIssue({ code: "custom", path: [path], message });
|
||||
if (
|
||||
input.limits.max_console_text_field_bytes >
|
||||
input.limits.max_total_console_text_bytes
|
||||
|
||||
@@ -46,7 +46,6 @@ const scenarioShapeSchema = z.strictObject({
|
||||
redaction: browserScenarioRedactionSchema,
|
||||
capture: browserScenarioCaptureSchema,
|
||||
limits: browserScenarioCaptureLimitsSchema,
|
||||
approved: z.literal(true),
|
||||
});
|
||||
|
||||
type ScenarioShape = z.infer<typeof scenarioShapeSchema>;
|
||||
|
||||
@@ -152,7 +152,6 @@ const locatorSchema = z.discriminatedUnion("kind", [
|
||||
z.strictObject({
|
||||
kind: z.literal("css"),
|
||||
selector: z.string().min(1).max(4_096),
|
||||
approved: z.literal(true),
|
||||
}),
|
||||
]);
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ export const observeWebSessionInputSchema = z.object({
|
||||
cdp_endpoint: browserEndpointSchema,
|
||||
allowed_origins: browserAllowedOriginsSchema,
|
||||
target_id: z.string().trim().min(1).max(256),
|
||||
approved: z.literal(true),
|
||||
observation_ms: z.number().int().min(1).max(60_000).default(10_000),
|
||||
max_timeline_events: z.number().int().min(1).max(20_000).default(2_000),
|
||||
});
|
||||
|
||||
@@ -126,7 +126,6 @@ describe("bundle comparison history", () => {
|
||||
const mutationOne = evidence("mutation-one");
|
||||
const initial = createResidualUnknown(
|
||||
recordUnknownInputSchema.parse({
|
||||
approved: true,
|
||||
question: "Which branch remains unexplained?",
|
||||
severity: "high",
|
||||
domain: "comparison",
|
||||
@@ -145,7 +144,6 @@ describe("bundle comparison history", () => {
|
||||
const advanced = updateResidualUnknown(
|
||||
initial,
|
||||
updateUnknownInputSchema.parse({
|
||||
approved: true,
|
||||
unknown_id: initial.unknown_id,
|
||||
expected_revision: 1,
|
||||
status: "investigating",
|
||||
|
||||
@@ -80,7 +80,6 @@ export const electronActiveObservationInputSchema = z
|
||||
max_processes: 32,
|
||||
max_windows: 32,
|
||||
}),
|
||||
approved: z.literal(true),
|
||||
})
|
||||
.superRefine((input, context) => {
|
||||
if (input.actions.length > input.limits.max_actions)
|
||||
|
||||
@@ -22,7 +22,6 @@ export const electronFileRootsSchema = z
|
||||
const approvedElectronInput = {
|
||||
cdp_endpoint: browserEndpointSchema,
|
||||
allowed_file_roots: electronFileRootsSchema,
|
||||
approved: z.literal(true),
|
||||
};
|
||||
|
||||
/** Input for listing root-confined file:// page targets from Electron CDP. */
|
||||
@@ -73,12 +72,10 @@ export const inspectElectronPageInputSchema = z
|
||||
z.object({
|
||||
...inspectElectronPageFacts,
|
||||
include_script_sources: z.literal(false).default(false),
|
||||
source_capture_approved: z.literal(false).default(false),
|
||||
}),
|
||||
z.object({
|
||||
...inspectElectronPageFacts,
|
||||
include_script_sources: z.literal(true),
|
||||
source_capture_approved: z.literal(true),
|
||||
}),
|
||||
])
|
||||
.superRefine((input, context) => {
|
||||
|
||||
@@ -8,58 +8,6 @@ import { javaScriptSemanticGraphSchema } from "./javascriptSemanticGraph.js";
|
||||
const countSchema = z.number().int().min(0);
|
||||
const digestSchema = z.string().regex(/^[a-f0-9]{64}$/u);
|
||||
|
||||
/** Defaults for one local JavaScript application analysis. */
|
||||
export const JAVASCRIPT_APPLICATION_ANALYSIS_DEFAULT_LIMITS = {
|
||||
max_entries: 8_000,
|
||||
max_total_artifact_bytes: 512 * 1_024 * 1_024,
|
||||
max_artifact_entry_bytes: 128 * 1_024 * 1_024,
|
||||
max_compression_ratio: 1_000,
|
||||
max_depth: 64,
|
||||
max_path_bytes: 4_096,
|
||||
max_text_files: 5_000,
|
||||
max_total_text_bytes: 128 * 1_024 * 1_024,
|
||||
max_text_file_bytes: 8 * 1_024 * 1_024,
|
||||
max_ast_nodes: 2_000_000,
|
||||
max_findings: 8_000,
|
||||
max_modules: 20_000,
|
||||
max_source_map_sources: 5_000,
|
||||
max_parse_milliseconds: 30_000,
|
||||
} as const;
|
||||
|
||||
/** Combined artifact, text, AST, and graph projection bounds. */
|
||||
export const javascriptApplicationAnalysisLimitsSchema = z.strictObject({
|
||||
max_entries: z.number().int().min(1).default(8_000),
|
||||
max_total_artifact_bytes: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.default(512 * 1_024 * 1_024),
|
||||
max_artifact_entry_bytes: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.default(128 * 1_024 * 1_024),
|
||||
max_compression_ratio: z.number().min(1).default(1_000),
|
||||
max_depth: z.number().int().min(1).default(64),
|
||||
max_path_bytes: z.number().int().min(1).default(4_096),
|
||||
max_text_files: z.number().int().min(1).default(5_000),
|
||||
max_total_text_bytes: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.default(128 * 1_024 * 1_024),
|
||||
max_text_file_bytes: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.default(8 * 1_024 * 1_024),
|
||||
max_ast_nodes: z.number().int().min(1).default(2_000_000),
|
||||
max_findings: z.number().int().min(1).default(8_000),
|
||||
max_modules: z.number().int().min(1).default(20_000),
|
||||
max_source_map_sources: z.number().int().min(1).default(5_000),
|
||||
max_parse_milliseconds: z.number().int().min(1).default(30_000),
|
||||
});
|
||||
|
||||
/** Public target-free request for static JavaScript application analysis. */
|
||||
export const analyzeJavaScriptApplicationInputSchema = z.strictObject({
|
||||
input_path: z
|
||||
@@ -67,9 +15,6 @@ export const analyzeJavaScriptApplicationInputSchema = z.strictObject({
|
||||
.min(1)
|
||||
.refine(isAbsolute, "JavaScript application input path must be absolute"),
|
||||
format: z.enum(["auto", "asar", "directory"]).default("auto"),
|
||||
limits: javascriptApplicationAnalysisLimitsSchema.default(
|
||||
JAVASCRIPT_APPLICATION_ANALYSIS_DEFAULT_LIMITS,
|
||||
),
|
||||
});
|
||||
|
||||
/** Compact counts for the high-level Electron architecture/security surface. */
|
||||
|
||||
@@ -8,10 +8,7 @@ import {
|
||||
type ApplicationNode,
|
||||
type JavaScriptApplicationGraph,
|
||||
} from "./javascriptApplicationGraph.js";
|
||||
import type {
|
||||
ApplicationVersionComparisonItem,
|
||||
CompareApplicationVersionsInput,
|
||||
} from "./javascriptApplicationVersionComparisonSchemas.js";
|
||||
import type { ApplicationVersionComparisonItem } from "./javascriptApplicationVersionComparisonSchemas.js";
|
||||
|
||||
interface ChangeGraphInput {
|
||||
readonly left: JavaScriptApplicationGraph;
|
||||
@@ -19,16 +16,11 @@ interface ChangeGraphInput {
|
||||
readonly leftEvidenceId: string;
|
||||
readonly rightEvidenceId: string;
|
||||
readonly items: readonly ApplicationVersionComparisonItem[];
|
||||
readonly omittedComparisonItems: number;
|
||||
readonly limits: CompareApplicationVersionsInput["limits"];
|
||||
}
|
||||
|
||||
/** Bounded cross-version graph and exact projection omission counts. */
|
||||
/** Complete cross-version graph projection. */
|
||||
export interface ApplicationChangeGraphProjection {
|
||||
readonly graph: JavaScriptApplicationGraph;
|
||||
readonly omittedNodes: number;
|
||||
readonly omittedEdges: number;
|
||||
readonly omittedObservations: number;
|
||||
}
|
||||
|
||||
/** Merge compared nodes and add inferred right-to-left changed_from edges. */
|
||||
@@ -47,10 +39,9 @@ export const buildJavaScriptApplicationChangeGraph = (
|
||||
...(left === null ? [] : [left]),
|
||||
]),
|
||||
]);
|
||||
const retainedIds = orderedNodeIds.slice(0, input.limits.max_graph_nodes);
|
||||
const retained = new Set(retainedIds);
|
||||
const merged = mergeNodes(
|
||||
retainedIds.flatMap((nodeId) => allNodes.get(nodeId) ?? []),
|
||||
const retained = new Set(orderedNodeIds);
|
||||
const mergedNodes = mergeNodes(
|
||||
orderedNodeIds.flatMap((nodeId) => allNodes.get(nodeId) ?? []),
|
||||
);
|
||||
const sourceEdges = uniqueEdges([
|
||||
...input.left.edges,
|
||||
@@ -63,15 +54,8 @@ export const buildJavaScriptApplicationChangeGraph = (
|
||||
changedFromEdge(item, input, retained),
|
||||
);
|
||||
const candidateEdges = uniqueEdges([...sourceEdges, ...comparisonEdges]);
|
||||
const edges = candidateEdges.slice(0, input.limits.max_graph_edges);
|
||||
const omittedNodes = Math.max(0, orderedNodeIds.length - retainedIds.length);
|
||||
const omittedEdges = Math.max(0, candidateEdges.length - edges.length);
|
||||
const graphOmissions =
|
||||
omittedNodes + omittedEdges + merged.omittedObservations;
|
||||
const rootNodeIds = preferredRoots
|
||||
.filter((nodeId) => retained.has(nodeId))
|
||||
.slice(0, 1_000);
|
||||
const fallbackRoot = merged.nodes[0]?.node_id;
|
||||
const rootNodeIds = preferredRoots.filter((nodeId) => retained.has(nodeId));
|
||||
const fallbackRoot = mergedNodes[0]?.node_id;
|
||||
const graph = createJavaScriptApplicationGraph({
|
||||
schema: "JavaScriptApplicationGraph",
|
||||
root_node_ids:
|
||||
@@ -80,25 +64,17 @@ export const buildJavaScriptApplicationChangeGraph = (
|
||||
: fallbackRoot === undefined
|
||||
? []
|
||||
: [fallbackRoot],
|
||||
nodes: merged.nodes,
|
||||
edges,
|
||||
coverage: changeGraphCoverage(input, graphOmissions),
|
||||
nodes: mergedNodes,
|
||||
edges: candidateEdges,
|
||||
coverage: changeGraphCoverage(input),
|
||||
limitations: uniqueSorted([
|
||||
...input.left.limitations.map((value) => `Left: ${value}`),
|
||||
...input.right.limitations.map((value) => `Right: ${value}`),
|
||||
"changed_from edges are cross-version inferences and never promote structural or semantic matches to exact identity.",
|
||||
"The change graph contains compared entities and their retained relationships; it is not an executable application.",
|
||||
...(graphOmissions === 0
|
||||
? []
|
||||
: ["The change graph omitted content at explicit caller bounds."]),
|
||||
]),
|
||||
});
|
||||
return {
|
||||
graph,
|
||||
omittedNodes,
|
||||
omittedEdges,
|
||||
omittedObservations: merged.omittedObservations,
|
||||
};
|
||||
return { graph };
|
||||
};
|
||||
|
||||
const nodeCandidates = (
|
||||
@@ -168,8 +144,7 @@ const comparisonEvidence = (
|
||||
right?.observations[0]?.evidence ?? left?.observations[0]?.evidence;
|
||||
const complete =
|
||||
input.left.coverage.status === "complete" &&
|
||||
input.right.coverage.status === "complete" &&
|
||||
input.omittedComparisonItems === 0;
|
||||
input.right.coverage.status === "complete";
|
||||
return {
|
||||
authority: "cross-version-comparison",
|
||||
state: "inferred",
|
||||
@@ -194,21 +169,13 @@ const comparisonEvidence = (
|
||||
? { status: "complete", truncated: false, omitted_count: 0, limits: [] }
|
||||
: {
|
||||
status: "partial",
|
||||
truncated: input.omittedComparisonItems > 0,
|
||||
omitted_count:
|
||||
input.omittedComparisonItems > 0
|
||||
? input.omittedComparisonItems
|
||||
: (source?.coverage.omitted_count ?? null),
|
||||
limits:
|
||||
input.omittedComparisonItems > 0
|
||||
? [
|
||||
{
|
||||
name: "max-comparison-items",
|
||||
value: input.limits.max_comparison_items,
|
||||
unit: "items",
|
||||
},
|
||||
]
|
||||
: [],
|
||||
truncated:
|
||||
input.left.coverage.truncated || input.right.coverage.truncated,
|
||||
omitted_count: combineOmittedCounts(
|
||||
input.left.coverage.omitted_count,
|
||||
input.right.coverage.omitted_count,
|
||||
),
|
||||
limits: sourceCoverageLimits(input),
|
||||
},
|
||||
limitations: [
|
||||
"Cross-version pairing is inferred from the stated match basis; changed_from does not prove runtime reachability.",
|
||||
@@ -220,32 +187,7 @@ const comparisonEvidence = (
|
||||
|
||||
const changeGraphCoverage = (
|
||||
input: ChangeGraphInput,
|
||||
graphOmissions: number,
|
||||
): JavaScriptApplicationGraph["coverage"] => {
|
||||
const outputOmissions = graphOmissions + input.omittedComparisonItems;
|
||||
if (outputOmissions > 0)
|
||||
return {
|
||||
status: "partial",
|
||||
truncated: true,
|
||||
omitted_count: outputOmissions,
|
||||
limits: [
|
||||
{
|
||||
name: "max-comparison-items",
|
||||
value: input.limits.max_comparison_items,
|
||||
unit: "items",
|
||||
},
|
||||
{
|
||||
name: "max-graph-nodes",
|
||||
value: input.limits.max_graph_nodes,
|
||||
unit: "items",
|
||||
},
|
||||
{
|
||||
name: "max-graph-edges",
|
||||
value: input.limits.max_graph_edges,
|
||||
unit: "items",
|
||||
},
|
||||
],
|
||||
};
|
||||
if (
|
||||
input.left.coverage.status === "complete" &&
|
||||
input.right.coverage.status === "complete"
|
||||
@@ -256,30 +198,33 @@ const changeGraphCoverage = (
|
||||
omitted_count: 0,
|
||||
limits: [],
|
||||
};
|
||||
const counts = [
|
||||
input.left.coverage.omitted_count,
|
||||
input.right.coverage.omitted_count,
|
||||
];
|
||||
return {
|
||||
status: "partial",
|
||||
truncated: false,
|
||||
omitted_count: counts.every((value) => value !== null)
|
||||
? counts.reduce<number>((total, value) => total + (value ?? 0), 0)
|
||||
: null,
|
||||
limits: [],
|
||||
truncated: input.left.coverage.truncated || input.right.coverage.truncated,
|
||||
omitted_count: combineOmittedCounts(
|
||||
input.left.coverage.omitted_count,
|
||||
input.right.coverage.omitted_count,
|
||||
),
|
||||
limits: sourceCoverageLimits(input),
|
||||
};
|
||||
};
|
||||
|
||||
const mergeNodes = (
|
||||
nodes: readonly ApplicationNode[],
|
||||
): {
|
||||
readonly nodes: ApplicationNode[];
|
||||
readonly omittedObservations: number;
|
||||
} => {
|
||||
const sourceCoverageLimits = (input: ChangeGraphInput) =>
|
||||
[
|
||||
...new Map(
|
||||
[...input.left.coverage.limits, ...input.right.coverage.limits].map(
|
||||
(limit) => [`${limit.name}\0${limit.value}\0${limit.unit}`, limit],
|
||||
),
|
||||
).values(),
|
||||
].sort((left, right) => compareCodePoints(left.name, right.name));
|
||||
|
||||
const combineOmittedCounts = (left: number | null, right: number | null) =>
|
||||
left === null || right === null ? null : left + right;
|
||||
|
||||
const mergeNodes = (nodes: readonly ApplicationNode[]): ApplicationNode[] => {
|
||||
const groups = new Map<string, ApplicationNode[]>();
|
||||
for (const node of nodes)
|
||||
groups.set(node.node_id, [...(groups.get(node.node_id) ?? []), node]);
|
||||
let omittedObservations = 0;
|
||||
const merged = [...groups.values()].map((group) => {
|
||||
const first = group[0];
|
||||
if (first === undefined)
|
||||
@@ -293,24 +238,18 @@ const mergeNodes = (
|
||||
].sort((left, right) =>
|
||||
compareCodePoints(left.observation_id, right.observation_id),
|
||||
);
|
||||
omittedObservations += Math.max(0, observations.length - 64);
|
||||
return createJavaScriptApplicationNode({
|
||||
kind: first.kind,
|
||||
identity: first.identity,
|
||||
observations: observations
|
||||
.slice(0, 64)
|
||||
.map(
|
||||
({ observation_id: _id, identifier_strategy: _strategy, ...value }) =>
|
||||
value,
|
||||
),
|
||||
observations: observations.map(
|
||||
({ observation_id: _id, identifier_strategy: _strategy, ...value }) =>
|
||||
value,
|
||||
),
|
||||
});
|
||||
});
|
||||
return {
|
||||
nodes: merged.sort((left, right) =>
|
||||
compareCodePoints(left.node_id, right.node_id),
|
||||
),
|
||||
omittedObservations,
|
||||
};
|
||||
return merged.sort((left, right) =>
|
||||
compareCodePoints(left.node_id, right.node_id),
|
||||
);
|
||||
};
|
||||
|
||||
const uniqueEdges = (edges: readonly ApplicationEdge[]): ApplicationEdge[] =>
|
||||
|
||||
@@ -112,7 +112,7 @@ export const applicationNodeObservationSchema =
|
||||
export const applicationNodeInputSchema = z.strictObject({
|
||||
kind: applicationNodeKindSchema,
|
||||
identity: applicationNodeIdentitySchema,
|
||||
observations: z.array(applicationNodeObservationInputSchema).min(1).max(64),
|
||||
observations: z.array(applicationNodeObservationInputSchema).min(1),
|
||||
});
|
||||
|
||||
/** One stable application entity with one or more bounded observations. */
|
||||
@@ -120,7 +120,7 @@ export const applicationNodeSchema = z.strictObject({
|
||||
node_id: z.string().regex(/^jag_node_[a-f0-9]{64}$/u),
|
||||
kind: applicationNodeKindSchema,
|
||||
identity: applicationNodeIdentitySchema,
|
||||
observations: z.array(applicationNodeObservationSchema).min(1).max(64),
|
||||
observations: z.array(applicationNodeObservationSchema).min(1),
|
||||
});
|
||||
|
||||
/** One directed relationship before its semantic identifier is derived. */
|
||||
@@ -148,7 +148,7 @@ export const javascriptApplicationGraphInputSchema = z.strictObject({
|
||||
nodes: z.array(applicationNodeSchema).min(1),
|
||||
edges: z.array(applicationEdgeSchema),
|
||||
coverage: applicationCoverageSchema,
|
||||
limitations: z.array(boundedTextSchema).max(1_000),
|
||||
limitations: z.array(boundedTextSchema),
|
||||
});
|
||||
|
||||
/** Strict stored shape for a JavaScript Application Graph. */
|
||||
|
||||
@@ -7,7 +7,6 @@ import { buildJavaScriptApplicationChangeGraph } from "./javascriptApplicationCh
|
||||
import {
|
||||
applicationVersionComparisonResultSchema,
|
||||
type ApplicationVersionComparisonResult,
|
||||
type CompareApplicationVersionsInput,
|
||||
} from "./javascriptApplicationVersionComparisonSchemas.js";
|
||||
import type { JavaScriptApplicationGraph } from "./javascriptApplicationGraph.js";
|
||||
import { compareCodePoints } from "./javascriptApplicationGraph.js";
|
||||
@@ -28,7 +27,6 @@ export interface ApplicationVersionComparisonProjectionInput {
|
||||
};
|
||||
readonly leftNativeEvidence: readonly Evidence[];
|
||||
readonly rightNativeEvidence: readonly Evidence[];
|
||||
readonly limits: CompareApplicationVersionsInput["limits"];
|
||||
}
|
||||
|
||||
/** Compare application entities with ordered unique-only identity tiers. */
|
||||
@@ -46,28 +44,20 @@ export const compareJavaScriptApplicationVersions = (
|
||||
rightEvidenceId: input.right.evidenceId,
|
||||
leftNativeEvidence: input.leftNativeEvidence,
|
||||
rightNativeEvidence: input.rightNativeEvidence,
|
||||
maxCandidates: input.limits.max_candidate_nodes,
|
||||
});
|
||||
const items = projection.items.slice(0, input.limits.max_comparison_items);
|
||||
const omittedComparisonItems = projection.items.length - items.length;
|
||||
const changeGraph = buildJavaScriptApplicationChangeGraph({
|
||||
left: input.left.graph,
|
||||
right: input.right.graph,
|
||||
leftEvidenceId: input.left.evidenceId,
|
||||
rightEvidenceId: input.right.evidenceId,
|
||||
items,
|
||||
omittedComparisonItems,
|
||||
limits: input.limits,
|
||||
items: projection.items,
|
||||
});
|
||||
const evidenceLinks = uniqueSorted(
|
||||
projection.items.flatMap(({ evidence_links: links }) => links),
|
||||
);
|
||||
const omissions = {
|
||||
omitted_comparison_items: omittedComparisonItems,
|
||||
omitted_candidate_references: projection.omittedCandidateReferences,
|
||||
omitted_graph_nodes: changeGraph.omittedNodes,
|
||||
omitted_graph_edges: changeGraph.omittedEdges,
|
||||
omitted_graph_observations: changeGraph.omittedObservations,
|
||||
left_graph_omitted_count: input.left.graph.coverage.omitted_count,
|
||||
right_graph_omitted_count: input.right.graph.coverage.omitted_count,
|
||||
};
|
||||
const coverage = comparisonCoverage(input, omissions);
|
||||
const semantic = {
|
||||
@@ -83,11 +73,11 @@ export const compareJavaScriptApplicationVersions = (
|
||||
},
|
||||
summary: summary(projection.items),
|
||||
matching: matchingSummary(projection.items),
|
||||
items,
|
||||
items: projection.items,
|
||||
graph: changeGraph.graph,
|
||||
coverage,
|
||||
evidence_links: evidenceLinks,
|
||||
limitations: comparisonLimitations(input, omissions),
|
||||
limitations: comparisonLimitations(input),
|
||||
};
|
||||
return applicationVersionComparisonResultSchema.parse({
|
||||
...semantic,
|
||||
@@ -131,11 +121,7 @@ const countBasis = (
|
||||
type ComparisonOmissions = ApplicationVersionComparisonResult["coverage"];
|
||||
type ComparisonOmissionCounts = Pick<
|
||||
ComparisonOmissions,
|
||||
| "omitted_comparison_items"
|
||||
| "omitted_candidate_references"
|
||||
| "omitted_graph_nodes"
|
||||
| "omitted_graph_edges"
|
||||
| "omitted_graph_observations"
|
||||
"left_graph_omitted_count" | "right_graph_omitted_count"
|
||||
>;
|
||||
|
||||
const comparisonCoverage = (
|
||||
@@ -146,35 +132,24 @@ const comparisonCoverage = (
|
||||
left_graph_status: input.left.graph.coverage.status,
|
||||
right_graph_status: input.right.graph.coverage.status,
|
||||
};
|
||||
if (Object.values(omissions).some((value) => value > 0))
|
||||
return { ...context, ...omissions, status: "truncated" };
|
||||
if (
|
||||
const sourceGraphsComplete =
|
||||
input.left.graph.coverage.status === "complete" &&
|
||||
input.right.graph.coverage.status === "complete"
|
||||
)
|
||||
return {
|
||||
...context,
|
||||
status: "complete-within-inputs",
|
||||
omitted_comparison_items: 0,
|
||||
omitted_candidate_references: 0,
|
||||
omitted_graph_nodes: 0,
|
||||
omitted_graph_edges: 0,
|
||||
omitted_graph_observations: 0,
|
||||
};
|
||||
input.right.graph.coverage.status === "complete";
|
||||
const sourceGraphsTruncated =
|
||||
input.left.graph.coverage.truncated || input.right.graph.coverage.truncated;
|
||||
return {
|
||||
...context,
|
||||
status: "partial",
|
||||
omitted_comparison_items: 0,
|
||||
omitted_candidate_references: 0,
|
||||
omitted_graph_nodes: 0,
|
||||
omitted_graph_edges: 0,
|
||||
omitted_graph_observations: 0,
|
||||
...omissions,
|
||||
status: sourceGraphsComplete
|
||||
? "complete-within-inputs"
|
||||
: sourceGraphsTruncated
|
||||
? "truncated"
|
||||
: "partial",
|
||||
};
|
||||
};
|
||||
|
||||
const comparisonLimitations = (
|
||||
input: ApplicationVersionComparisonProjectionInput,
|
||||
omissions: ComparisonOmissionCounts,
|
||||
): string[] =>
|
||||
uniqueSorted([
|
||||
"Application comparison never uses bundler module ordinals as persistent identity and performs no fuzzy pairing.",
|
||||
@@ -188,9 +163,6 @@ const comparisonLimitations = (
|
||||
: [
|
||||
"At least one source graph is incomplete; unmatched entities on the opposite side remain unknown rather than added or removed.",
|
||||
]),
|
||||
...(Object.values(omissions).some((value) => value > 0)
|
||||
? ["Comparison output was truncated at explicit caller limits."]
|
||||
: []),
|
||||
]);
|
||||
|
||||
const digestCanonical = (value: unknown): string => {
|
||||
|
||||
@@ -8,26 +8,13 @@ const evidenceIdSchema = z.string().regex(/^ev_[a-f0-9]{64}$/u);
|
||||
const nodeIdSchema = z.string().regex(/^jag_node_[a-f0-9]{64}$/u);
|
||||
const boundedTextSchema = z.string().min(1).max(4_096);
|
||||
|
||||
const comparisonLimitsSchema = z.strictObject({
|
||||
max_comparison_items: z.number().int().min(1).max(50_000).default(20_000),
|
||||
max_candidate_nodes: z.number().int().min(1).max(1_000).default(100),
|
||||
max_graph_nodes: z.number().int().min(1).max(100_000).default(20_000),
|
||||
max_graph_edges: z.number().int().min(1).max(200_000).default(40_000),
|
||||
});
|
||||
|
||||
/** Two authenticated application versions and deterministic output bounds. */
|
||||
/** Two authenticated application versions and their native observations. */
|
||||
export const compareApplicationVersionsInputSchema = z
|
||||
.strictObject({
|
||||
left: evidenceSchema,
|
||||
right: evidenceSchema,
|
||||
left_native_observations: z.array(evidenceSchema).max(64).default([]),
|
||||
right_native_observations: z.array(evidenceSchema).max(64).default([]),
|
||||
limits: comparisonLimitsSchema.default({
|
||||
max_comparison_items: 20_000,
|
||||
max_candidate_nodes: 100,
|
||||
max_graph_nodes: 20_000,
|
||||
max_graph_edges: 40_000,
|
||||
}),
|
||||
left_native_observations: z.array(evidenceSchema).default([]),
|
||||
right_native_observations: z.array(evidenceSchema).default([]),
|
||||
unknown_registry_approved: z.literal(true).optional(),
|
||||
})
|
||||
.superRefine((input, context) => {
|
||||
@@ -52,10 +39,7 @@ export const compareApplicationVersionsInputSchema = z
|
||||
});
|
||||
|
||||
const emptyCandidateNodesSchema = z.tuple([]);
|
||||
const candidateNodesSchema = z
|
||||
.tuple([nodeIdSchema])
|
||||
.rest(nodeIdSchema)
|
||||
.check(z.maxLength(1_000));
|
||||
const candidateNodesSchema = z.tuple([nodeIdSchema]).rest(nodeIdSchema);
|
||||
const exactMatchSchema = z.strictObject({
|
||||
status: z.literal("matched"),
|
||||
basis: z.enum([
|
||||
@@ -123,8 +107,8 @@ const comparisonItemContextShape = {
|
||||
]),
|
||||
)
|
||||
.max(6),
|
||||
evidence_links: z.array(evidenceIdSchema).min(2).max(130),
|
||||
limitations: z.array(boundedTextSchema).max(100),
|
||||
evidence_links: z.array(evidenceIdSchema).min(2),
|
||||
limitations: z.array(boundedTextSchema),
|
||||
};
|
||||
|
||||
const comparisonItemSchema = z.union([
|
||||
@@ -165,55 +149,15 @@ const comparisonItemSchema = z.union([
|
||||
}),
|
||||
]);
|
||||
|
||||
const comparisonCoverageContextShape = {
|
||||
const comparisonCoverageSchema = z.strictObject({
|
||||
left_graph_status: z.enum(["complete", "partial", "unknown", "unavailable"]),
|
||||
right_graph_status: z.enum(["complete", "partial", "unknown", "unavailable"]),
|
||||
};
|
||||
const zeroComparisonOmissionsShape = {
|
||||
omitted_comparison_items: z.literal(0),
|
||||
omitted_candidate_references: z.literal(0),
|
||||
omitted_graph_nodes: z.literal(0),
|
||||
omitted_graph_edges: z.literal(0),
|
||||
omitted_graph_observations: z.literal(0),
|
||||
};
|
||||
const comparisonOmissionsShape = {
|
||||
omitted_comparison_items: z.number().int().min(0),
|
||||
omitted_candidate_references: z.number().int().min(0),
|
||||
omitted_graph_nodes: z.number().int().min(0),
|
||||
omitted_graph_edges: z.number().int().min(0),
|
||||
omitted_graph_observations: z.number().int().min(0),
|
||||
};
|
||||
const comparisonCoverageSchema = z.union([
|
||||
z.strictObject({
|
||||
...comparisonCoverageContextShape,
|
||||
...zeroComparisonOmissionsShape,
|
||||
status: z.literal("complete-within-inputs"),
|
||||
}),
|
||||
z.strictObject({
|
||||
...comparisonCoverageContextShape,
|
||||
...zeroComparisonOmissionsShape,
|
||||
status: z.literal("partial"),
|
||||
}),
|
||||
z
|
||||
.strictObject({
|
||||
...comparisonCoverageContextShape,
|
||||
...comparisonOmissionsShape,
|
||||
status: z.literal("truncated"),
|
||||
})
|
||||
.refine(
|
||||
(coverage) =>
|
||||
[
|
||||
coverage.omitted_comparison_items,
|
||||
coverage.omitted_candidate_references,
|
||||
coverage.omitted_graph_nodes,
|
||||
coverage.omitted_graph_edges,
|
||||
coverage.omitted_graph_observations,
|
||||
].some((value) => value > 0),
|
||||
{ message: "Truncated comparison coverage must name an omission" },
|
||||
),
|
||||
]);
|
||||
left_graph_omitted_count: z.number().int().min(0).nullable(),
|
||||
right_graph_omitted_count: z.number().int().min(0).nullable(),
|
||||
status: z.enum(["complete-within-inputs", "partial", "truncated"]),
|
||||
});
|
||||
|
||||
/** Tiered module/entity matching plus a bounded cross-version change graph. */
|
||||
/** Tiered module/entity matching plus its complete cross-version change graph. */
|
||||
export const applicationVersionComparisonResultSchema = z
|
||||
.strictObject({
|
||||
comparison_id: z.string().regex(/^javc_[a-f0-9]{64}$/u),
|
||||
@@ -244,20 +188,19 @@ export const applicationVersionComparisonResultSchema = z
|
||||
ambiguous: z.number().int().min(0),
|
||||
unmatched: z.number().int().min(0),
|
||||
}),
|
||||
items: z.array(comparisonItemSchema).max(50_000),
|
||||
items: z.array(comparisonItemSchema),
|
||||
graph: javascriptApplicationGraphSchema,
|
||||
coverage: comparisonCoverageSchema,
|
||||
evidence_links: z.array(evidenceIdSchema).min(2).max(130),
|
||||
limitations: z.array(boundedTextSchema).max(1_000),
|
||||
evidence_links: z.array(evidenceIdSchema).min(2),
|
||||
limitations: z.array(boundedTextSchema),
|
||||
})
|
||||
.superRefine((result, context) => {
|
||||
const sourceGraphsComplete =
|
||||
result.coverage.left_graph_status === "complete" &&
|
||||
result.coverage.right_graph_status === "complete";
|
||||
if (
|
||||
result.coverage.status !== "truncated" &&
|
||||
(result.coverage.status === "complete-within-inputs") !==
|
||||
sourceGraphsComplete
|
||||
sourceGraphsComplete
|
||||
)
|
||||
context.addIssue({
|
||||
code: "custom",
|
||||
|
||||
@@ -9,19 +9,15 @@ import {
|
||||
type ApplicationNode,
|
||||
type JavaScriptApplicationGraph,
|
||||
} from "./javascriptApplicationGraph.js";
|
||||
import type {
|
||||
ApplicationVersionComparisonItem,
|
||||
CompareApplicationVersionsInput,
|
||||
} from "./javascriptApplicationVersionComparisonSchemas.js";
|
||||
import type { ApplicationVersionComparisonItem } from "./javascriptApplicationVersionComparisonSchemas.js";
|
||||
import type {
|
||||
ApplicationVersionMatchingProjection,
|
||||
ApplicationVersionNodePair,
|
||||
} from "./javascriptApplicationVersionKeys.js";
|
||||
|
||||
/** All classified entities before the caller's item bound is applied. */
|
||||
/** All classified entities and their complete ambiguity candidate sets. */
|
||||
export interface ApplicationVersionItemProjection {
|
||||
readonly items: ApplicationVersionComparisonItem[];
|
||||
readonly omittedCandidateReferences: number;
|
||||
}
|
||||
|
||||
interface ItemContext {
|
||||
@@ -33,7 +29,6 @@ interface ItemContext {
|
||||
readonly rightNativeEvidence: readonly Evidence[];
|
||||
readonly pairByLeft: ReadonlyMap<string, string>;
|
||||
readonly pairByRight: ReadonlyMap<string, string>;
|
||||
readonly maxCandidates: number;
|
||||
}
|
||||
|
||||
type OneSidedNode =
|
||||
@@ -60,9 +55,7 @@ type ComparisonItemSemantic<
|
||||
/** Classify matched, unmatched, and ambiguous nodes without inventing absence. */
|
||||
export const classifyJavaScriptApplicationVersions = (
|
||||
matching: ApplicationVersionMatchingProjection,
|
||||
context: Omit<ItemContext, "pairByLeft" | "pairByRight" | "maxCandidates"> & {
|
||||
readonly maxCandidates: CompareApplicationVersionsInput["limits"]["max_candidate_nodes"];
|
||||
},
|
||||
context: Omit<ItemContext, "pairByLeft" | "pairByRight">,
|
||||
): ApplicationVersionItemProjection => {
|
||||
const pairByLeft = new Map(
|
||||
matching.pairs.map(({ left, right }) => [
|
||||
@@ -77,31 +70,22 @@ export const classifyJavaScriptApplicationVersions = (
|
||||
]),
|
||||
);
|
||||
const fullContext: ItemContext = { ...context, pairByLeft, pairByRight };
|
||||
let omittedCandidateReferences = 0;
|
||||
const leftItems = matching.unmatchedLeft.map((node) => {
|
||||
const candidates = matching.candidatesForLeft.get(node.node_id) ?? [];
|
||||
omittedCandidateReferences += Math.max(
|
||||
0,
|
||||
candidates.length - context.maxCandidates,
|
||||
);
|
||||
return unmatchedItem(
|
||||
{
|
||||
left: node,
|
||||
candidateRightNodeIds: candidates.slice(0, context.maxCandidates),
|
||||
candidateRightNodeIds: candidates,
|
||||
},
|
||||
fullContext,
|
||||
);
|
||||
});
|
||||
const rightItems = matching.unmatchedRight.map((node) => {
|
||||
const candidates = matching.candidatesForRight.get(node.node_id) ?? [];
|
||||
omittedCandidateReferences += Math.max(
|
||||
0,
|
||||
candidates.length - context.maxCandidates,
|
||||
);
|
||||
return unmatchedItem(
|
||||
{
|
||||
right: node,
|
||||
candidateLeftNodeIds: candidates.slice(0, context.maxCandidates),
|
||||
candidateLeftNodeIds: candidates,
|
||||
},
|
||||
fullContext,
|
||||
);
|
||||
@@ -112,7 +96,6 @@ export const classifyJavaScriptApplicationVersions = (
|
||||
...leftItems,
|
||||
...rightItems,
|
||||
].sort((left, right) => compareCodePoints(left.item_id, right.item_id)),
|
||||
omittedCandidateReferences,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -143,7 +143,6 @@ const controlledReplayInputShape = {
|
||||
reproducer_export: z
|
||||
.strictObject({
|
||||
path: absolutePathSchema,
|
||||
approved: z.literal(true),
|
||||
include_sources: z.boolean().default(false),
|
||||
})
|
||||
.optional(),
|
||||
@@ -155,11 +154,10 @@ export const controlledReplayPlanInputSchema = z.strictObject({
|
||||
mode: z.literal("plan"),
|
||||
});
|
||||
|
||||
/** Parse a replay request carrying literal approval for one exact plan. */
|
||||
/** Parse a replay request carrying the digest for one exact plan. */
|
||||
export const controlledReplayExecutionInputSchema = z.strictObject({
|
||||
...controlledReplayInputShape,
|
||||
mode: z.literal("execute"),
|
||||
approved: z.literal(true),
|
||||
plan_digest: digestSchema,
|
||||
});
|
||||
|
||||
|
||||
@@ -28,11 +28,10 @@ const runtimeOriginsSchema = z
|
||||
.overwrite((origins) => [...new Set(origins)].sort())
|
||||
.default([]);
|
||||
|
||||
const approvedRuntimeScope = {
|
||||
const runtimeScope = {
|
||||
inspector_endpoint: browserEndpointSchema,
|
||||
allowed_file_roots: runtimeFileRootsSchema,
|
||||
allowed_origins: runtimeOriginsSchema,
|
||||
approved: z.literal(true),
|
||||
};
|
||||
|
||||
const requireRuntimeScope = (
|
||||
@@ -56,7 +55,7 @@ const requireRuntimeScope = (
|
||||
/** Input for listing approved Node/Electron V8 Inspector targets. */
|
||||
export const listJavaScriptRuntimeTargetsInputSchema = z
|
||||
.strictObject({
|
||||
...approvedRuntimeScope,
|
||||
...runtimeScope,
|
||||
})
|
||||
.superRefine(requireRuntimeScope);
|
||||
export type ListJavaScriptRuntimeTargetsInput = z.infer<
|
||||
@@ -89,7 +88,7 @@ export const javascriptRuntimeObservationLimitsSchema = z.strictObject({
|
||||
/** Input for one bounded, attach-only V8 Inspector observation. */
|
||||
export const observeJavaScriptRuntimeInputSchema = z
|
||||
.strictObject({
|
||||
...approvedRuntimeScope,
|
||||
...runtimeScope,
|
||||
target_id: z.string().trim().min(1).max(256),
|
||||
runtime_kind: javascriptRuntimeKindSchema.optional(),
|
||||
observation_ms: z.number().int().min(0).max(10_000).default(100),
|
||||
|
||||
@@ -26,7 +26,6 @@ export const parseActiveElectronCapture = (
|
||||
);
|
||||
const parameters = z
|
||||
.object({
|
||||
approved: z.literal(true),
|
||||
application_path: absolutePathSchema,
|
||||
application_root: absolutePathSchema,
|
||||
})
|
||||
@@ -40,7 +39,7 @@ export const parseActiveElectronCapture = (
|
||||
)
|
||||
)
|
||||
throw new TypeError(
|
||||
"Active Electron Evidence application path disagrees with its approved root",
|
||||
"Active Electron Evidence application path disagrees with its configured root",
|
||||
);
|
||||
return {
|
||||
kind: "electron-active",
|
||||
|
||||
@@ -432,7 +432,6 @@ const assertRuntimeParameters = (
|
||||
.object({
|
||||
...common,
|
||||
allowed_file_roots: electronFileRootsSchema,
|
||||
source_capture_approved: z.boolean(),
|
||||
})
|
||||
.passthrough()
|
||||
.parse(evidence.parameters);
|
||||
@@ -440,13 +439,9 @@ const assertRuntimeParameters = (
|
||||
throw new TypeError(
|
||||
"Runtime Evidence target disagrees with its captured result",
|
||||
);
|
||||
if (
|
||||
expected.sourceIncluded &&
|
||||
(!parameters.include_script_sources ||
|
||||
parameters.source_capture_approved !== true)
|
||||
)
|
||||
if (expected.sourceIncluded && !parameters.include_script_sources)
|
||||
throw new TypeError(
|
||||
"Runtime Evidence contains source without source-capture approval",
|
||||
"Runtime Evidence contains source without source-capture selection",
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -224,9 +224,7 @@ export const javaScriptSemanticNodeInputSchema = z.strictObject({
|
||||
kind: z.enum(JAVASCRIPT_SEMANTIC_NODE_KINDS),
|
||||
identity: semanticNodeIdentitySchema,
|
||||
function_node_id: semanticNodeIdSchema.nullable(),
|
||||
application_node_ids: z
|
||||
.array(z.string().regex(/^jag_node_[a-f0-9]{64}$/u))
|
||||
.max(64),
|
||||
application_node_ids: z.array(z.string().regex(/^jag_node_[a-f0-9]{64}$/u)),
|
||||
label: z.string().min(1).max(1_024).nullable(),
|
||||
properties: semanticPropertiesSchema,
|
||||
evidence: applicationGraphEvidenceSchema,
|
||||
@@ -281,7 +279,7 @@ export const javaScriptSemanticUnknownInputSchema = z.strictObject({
|
||||
relation_kinds: z.array(z.enum(JAVASCRIPT_SEMANTIC_RELATIONS)).min(1).max(45),
|
||||
reason: z.enum(JAVASCRIPT_SEMANTIC_UNKNOWN_REASONS),
|
||||
detail: boundedTextSchema,
|
||||
candidate_node_ids: z.array(semanticNodeIdSchema).max(1_000),
|
||||
candidate_node_ids: z.array(semanticNodeIdSchema),
|
||||
evidence: applicationGraphEvidenceSchema,
|
||||
});
|
||||
|
||||
@@ -334,7 +332,7 @@ const familyCoverageSchema = z.strictObject({
|
||||
status: z.enum(["complete", "partial", "unknown", "unsupported"]),
|
||||
retained_relations: z.number().int().min(0),
|
||||
omitted_relations: z.number().int().min(0).nullable(),
|
||||
unknown_ids: z.array(semanticUnknownIdSchema).max(100_000),
|
||||
unknown_ids: z.array(semanticUnknownIdSchema),
|
||||
});
|
||||
|
||||
const graphCoverageSchema = z.strictObject({
|
||||
@@ -359,11 +357,11 @@ export const javaScriptSemanticGraphInputSchema = z.strictObject({
|
||||
schema: z.literal("JavaScriptSemanticRelationGraph"),
|
||||
root_artifact_sha256: digestSchema,
|
||||
application_graph_id: z.string().regex(/^jag_[a-f0-9]{64}$/u),
|
||||
root_node_ids: z.array(semanticNodeIdSchema).min(1).max(10_000),
|
||||
nodes: z.array(javaScriptSemanticNodeSchema).min(1).max(100_000),
|
||||
relations: z.array(javaScriptSemanticRelationSchema).max(200_000),
|
||||
fingerprints: z.array(javaScriptSemanticFingerprintSchema).max(20_000),
|
||||
unknowns: z.array(javaScriptSemanticUnknownSchema).max(100_000),
|
||||
root_node_ids: z.array(semanticNodeIdSchema).min(1),
|
||||
nodes: z.array(javaScriptSemanticNodeSchema).min(1),
|
||||
relations: z.array(javaScriptSemanticRelationSchema),
|
||||
fingerprints: z.array(javaScriptSemanticFingerprintSchema),
|
||||
unknowns: z.array(javaScriptSemanticUnknownSchema),
|
||||
coverage: graphCoverageSchema,
|
||||
limitations: z.array(boundedTextSchema).max(1_000),
|
||||
});
|
||||
|
||||
@@ -307,3 +307,36 @@ it("excludes candidate edges unless the caller explicitly opts in", () => {
|
||||
{ relation: "supplies-request-field", resolution: "candidate" },
|
||||
]);
|
||||
});
|
||||
|
||||
it("retains every structural application node linked to one semantic node", () => {
|
||||
const original = node("module", "module");
|
||||
const linked = createJavaScriptSemanticGraphNode({
|
||||
kind: original.kind,
|
||||
identity: original.identity,
|
||||
function_node_id: original.function_node_id,
|
||||
application_node_ids: Array.from(
|
||||
{ length: 65 },
|
||||
(_, index) => `jag_node_${index.toString(16).padStart(64, "0")}`,
|
||||
),
|
||||
label: original.label,
|
||||
properties: original.properties,
|
||||
evidence: original.evidence,
|
||||
});
|
||||
expect(linked.application_node_ids).toHaveLength(65);
|
||||
});
|
||||
|
||||
it("retains all explicit unresolved candidate node identifiers", () => {
|
||||
const unknown = createJavaScriptSemanticGraphUnknown({
|
||||
node_id: null,
|
||||
family: "call-flow",
|
||||
relation_kinds: ["calls"],
|
||||
reason: "ambiguous-target",
|
||||
detail: "All candidate targets are retained.",
|
||||
candidate_node_ids: Array.from(
|
||||
{ length: 1_001 },
|
||||
(_, index) => `jsrg_node_${index.toString(16).padStart(64, "0")}`,
|
||||
),
|
||||
evidence: unknownEvidence(),
|
||||
});
|
||||
expect(unknown.candidate_node_ids).toHaveLength(1_001);
|
||||
});
|
||||
|
||||
@@ -24,7 +24,6 @@ const nodeRuntimeCharacterizationPlanSchema =
|
||||
|
||||
export const nodeCharacterizationPreparationInputSchema = z
|
||||
.strictObject({
|
||||
preparation_approved: z.literal(true),
|
||||
selected_alias: z.string().min(1).max(200),
|
||||
expected_effect: nodeCharacterizationExpectedEffectSchema,
|
||||
instrumentation: javascriptExportInstrumentationInputSchema,
|
||||
@@ -63,7 +62,6 @@ export const nodeCharacterizationPreparationInputSchema = z
|
||||
});
|
||||
|
||||
export const nodeCharacterizationExecutionInputSchema = z.strictObject({
|
||||
execution_approved: z.literal(true),
|
||||
approved_plan_sha256: digestSchema,
|
||||
preparation: nodeCharacterizationPreparationInputSchema,
|
||||
});
|
||||
|
||||
@@ -31,7 +31,6 @@ const sideBindingSchema = z
|
||||
/** Boundary contract for one bounded authority/candidate process experiment. */
|
||||
export const processPairedExperimentSchema = z
|
||||
.object({
|
||||
approved: z.literal(true),
|
||||
shared_scenario: processScenarioSchema,
|
||||
authority: sideBindingSchema,
|
||||
candidate: sideBindingSchema,
|
||||
|
||||
@@ -114,16 +114,11 @@ export const processComparisonContract = (
|
||||
});
|
||||
|
||||
/**
|
||||
* Boundary schema for one explicitly approved, bounded process experiment.
|
||||
* Boundary schema for one bounded process experiment.
|
||||
* Defaults are part of the evidence contract and must remain deterministic.
|
||||
*/
|
||||
export const processScenarioSchema = z
|
||||
.object({
|
||||
approved: z
|
||||
.literal(true)
|
||||
.describe(
|
||||
"Explicit per-call acknowledgement that this operation launches the target",
|
||||
),
|
||||
unknown_registry_approved: z
|
||||
.literal(true)
|
||||
.optional()
|
||||
|
||||
@@ -383,7 +383,6 @@ describe("reconstruction verification integrity", () => {
|
||||
const unknowns = mutations.map((mutation, index) =>
|
||||
createResidualUnknown(
|
||||
{
|
||||
approved: true,
|
||||
question: `Unresolved replay ${index}`,
|
||||
severity: "high",
|
||||
domain: "reconstruction-verification",
|
||||
|
||||
@@ -167,7 +167,6 @@ export const recordUnknownInputSchema = residualUnknownObjectSchema
|
||||
.extend({
|
||||
supporting_evidence_ids: z.array(evidenceIdSchema).max(100).default([]),
|
||||
contradicting_evidence_ids: z.array(evidenceIdSchema).max(100).default([]),
|
||||
approved: z.literal(true),
|
||||
});
|
||||
|
||||
export type RecordUnknownInput = z.infer<typeof recordUnknownInputSchema>;
|
||||
@@ -176,7 +175,6 @@ export type RecordUnknownInput = z.infer<typeof recordUnknownInputSchema>;
|
||||
export const updateUnknownInputSchema = z.object({
|
||||
unknown_id: unknownIdSchema,
|
||||
expected_revision: z.number().int().min(1),
|
||||
approved: z.literal(true),
|
||||
status: residualUnknownObjectSchema.shape.status,
|
||||
severity: residualUnknownObjectSchema.shape.severity,
|
||||
supporting_evidence_ids: z.array(evidenceIdSchema).max(100),
|
||||
|
||||
@@ -3,63 +3,31 @@ import { z } from "zod";
|
||||
import { inspectWebPageWithSourceInputSchema } from "./browserObservation.js";
|
||||
import { webTextArtifactSchema } from "./webContentArtifact.js";
|
||||
|
||||
const webBundleLimitsSchema = z.object({
|
||||
max_findings: z.number().int().min(1).max(10_000).default(1_000),
|
||||
max_ast_nodes: z.number().int().min(1).max(2_000_000).default(250_000),
|
||||
max_source_maps: z.number().int().min(1).max(1_000).default(100),
|
||||
max_source_map_bytes: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(16 * 1_024 * 1_024)
|
||||
.default(4 * 1_024 * 1_024),
|
||||
max_total_source_map_bytes: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(64 * 1_024 * 1_024)
|
||||
.default(16 * 1_024 * 1_024),
|
||||
max_source_map_mappings: z.number().int().min(1).max(100_000).default(10_000),
|
||||
max_original_sources: z.number().int().min(1).max(20_000).default(2_000),
|
||||
});
|
||||
/** Provider-owned parser and network safety bounds, never caller settings. */
|
||||
export const WEB_BUNDLE_ANALYSIS_LIMITS = {
|
||||
max_ast_nodes: 250_000,
|
||||
max_source_maps: 100,
|
||||
max_source_map_bytes: 4 * 1_024 * 1_024,
|
||||
max_total_source_map_bytes: 16 * 1_024 * 1_024,
|
||||
max_source_map_mappings: 10_000,
|
||||
} as const;
|
||||
|
||||
/** Capture-and-analyze input with separate source and source-map approvals. */
|
||||
const analyzeWebBundleFactsSchema =
|
||||
/** Capture-and-analyze input with optional source-map fetching. */
|
||||
export const analyzeWebBundleToolInputSchema =
|
||||
inspectWebPageWithSourceInputSchema.safeExtend({
|
||||
analysis_limits: webBundleLimitsSchema.default({
|
||||
max_findings: 1_000,
|
||||
max_ast_nodes: 250_000,
|
||||
max_source_maps: 100,
|
||||
max_source_map_bytes: 4 * 1_024 * 1_024,
|
||||
max_total_source_map_bytes: 16 * 1_024 * 1_024,
|
||||
max_source_map_mappings: 10_000,
|
||||
max_original_sources: 2_000,
|
||||
}),
|
||||
fetch_source_maps: z.boolean().default(false),
|
||||
});
|
||||
export const analyzeWebBundleInputSchema = z
|
||||
.union([
|
||||
analyzeWebBundleFactsSchema.safeExtend({
|
||||
fetch_source_maps: z.literal(false).default(false),
|
||||
source_map_fetch_approved: z.literal(false).default(false),
|
||||
}),
|
||||
analyzeWebBundleFactsSchema.safeExtend({
|
||||
fetch_source_maps: z.literal(true),
|
||||
source_map_fetch_approved: z.literal(true),
|
||||
}),
|
||||
])
|
||||
.superRefine((input, context) => {
|
||||
if (
|
||||
input.analysis_limits.max_source_map_bytes >
|
||||
input.analysis_limits.max_total_source_map_bytes
|
||||
)
|
||||
context.addIssue({
|
||||
code: "custom",
|
||||
path: ["analysis_limits", "max_source_map_bytes"],
|
||||
message:
|
||||
"Per-map source-map byte limit cannot exceed the aggregate limit",
|
||||
});
|
||||
});
|
||||
export type AnalyzeWebBundleInput = z.infer<typeof analyzeWebBundleInputSchema>;
|
||||
export const analyzeWebBundleInputSchema =
|
||||
analyzeWebBundleToolInputSchema.transform((input) => ({
|
||||
...input,
|
||||
analysis_limits: WEB_BUNDLE_ANALYSIS_LIMITS,
|
||||
})) as z.ZodType<AnalyzeWebBundleInput>;
|
||||
export type AnalyzeWebBundleInput = z.infer<
|
||||
typeof inspectWebPageWithSourceInputSchema
|
||||
> & {
|
||||
readonly fetch_source_maps: boolean;
|
||||
readonly analysis_limits: typeof WEB_BUNDLE_ANALYSIS_LIMITS;
|
||||
};
|
||||
|
||||
const sourceLocationSchema = z.object({
|
||||
script_key: z.string(),
|
||||
@@ -258,7 +226,6 @@ export const webBundleAnalysisSchema = z.object({
|
||||
parsed_scripts: z.number().int().min(0),
|
||||
parse_failures: z.number().int().min(0),
|
||||
visited_ast_nodes: z.number().int().min(0),
|
||||
dropped_findings: z.number().int().min(0),
|
||||
}),
|
||||
limitations: z.array(z.string()),
|
||||
});
|
||||
|
||||
@@ -73,7 +73,7 @@ describe("web bundle analyzer", () => {
|
||||
expect(result.completeness.status).toBe("complete_within_limits");
|
||||
});
|
||||
|
||||
it("reports parser gaps and finding truncation instead of claiming completeness", () => {
|
||||
it("reports parser gaps without imposing a finding cap", () => {
|
||||
const malformed = inspection("function broken( {");
|
||||
const failed = analyzeCapturedWebBundle(malformed, input());
|
||||
expect(failed.completeness).toMatchObject({
|
||||
@@ -82,15 +82,12 @@ describe("web bundle analyzer", () => {
|
||||
});
|
||||
expect(failed.unknowns[0]?.dimension).toBe("javascript_ast");
|
||||
|
||||
const bounded = analyzeCapturedWebBundle(
|
||||
const analyzed = analyzeCapturedWebBundle(
|
||||
inspection("fetch('/one'); fetch('/two'); fetch('/three');"),
|
||||
input({ analysis_limits: { max_findings: 1 } }),
|
||||
input(),
|
||||
);
|
||||
expect(bounded.observations.endpoints).toHaveLength(1);
|
||||
expect(bounded.completeness).toMatchObject({
|
||||
status: "truncated",
|
||||
dropped_findings: 2,
|
||||
});
|
||||
expect(analyzed.observations.endpoints).toHaveLength(3);
|
||||
expect(analyzed.completeness.status).toBe("complete_within_limits");
|
||||
});
|
||||
|
||||
it("propagates source-map truncation into completeness and unknowns", () => {
|
||||
@@ -121,7 +118,7 @@ describe("web bundle analyzer", () => {
|
||||
expect(analysis.completeness.status).toBe("truncated");
|
||||
expect(analysis.unknowns).toContainEqual({
|
||||
dimension: "source_maps",
|
||||
reason: "Source-map evidence was truncated by approved limits",
|
||||
reason: "Source-map evidence was truncated by provider safety limits",
|
||||
affected_script_keys: [`scr_${"1".repeat(64)}`, `scr_${"2".repeat(64)}`],
|
||||
});
|
||||
});
|
||||
@@ -149,9 +146,7 @@ const input = (overrides: Record<string, unknown> = {}) =>
|
||||
cdp_endpoint: "http://127.0.0.1:9222",
|
||||
allowed_origins: [origin],
|
||||
target_id: "page-1",
|
||||
approved: true,
|
||||
include_script_sources: true,
|
||||
source_capture_approved: true,
|
||||
}),
|
||||
...overrides,
|
||||
});
|
||||
|
||||
@@ -40,7 +40,6 @@ export interface AnalysisAccumulator {
|
||||
visitedNodes: number;
|
||||
parsedScripts: number;
|
||||
parseFailures: number;
|
||||
droppedFindings: number;
|
||||
astLimitReached: boolean;
|
||||
}
|
||||
|
||||
@@ -61,18 +60,14 @@ export const analyzeScript = (
|
||||
return;
|
||||
}
|
||||
accumulator.parsedScripts += 1;
|
||||
detectVendorFingerprints(
|
||||
script,
|
||||
accumulator,
|
||||
input.analysis_limits.max_findings,
|
||||
);
|
||||
detectVendorFingerprints(script, accumulator);
|
||||
t.traverseFast(file, (node) => {
|
||||
accumulator.visitedNodes += 1;
|
||||
if (accumulator.visitedNodes > input.analysis_limits.max_ast_nodes) {
|
||||
accumulator.astLimitReached = true;
|
||||
return t.traverseFast.stop;
|
||||
}
|
||||
inspectNode(script, node, accumulator, input.analysis_limits.max_findings);
|
||||
inspectNode(script, node, accumulator);
|
||||
return undefined;
|
||||
});
|
||||
};
|
||||
@@ -81,7 +76,6 @@ const inspectNode = (
|
||||
script: IncludedScript,
|
||||
node: t.Node,
|
||||
accumulator: AnalysisAccumulator,
|
||||
maximumFindings: number,
|
||||
): void => {
|
||||
if (
|
||||
(t.isImportDeclaration(node) || t.isExportAllDeclaration(node)) &&
|
||||
@@ -93,7 +87,6 @@ const inspectNode = (
|
||||
kind: "static_import",
|
||||
node,
|
||||
accumulator,
|
||||
maximumFindings,
|
||||
});
|
||||
else if (t.isExportNamedDeclaration(node) && node.source != null)
|
||||
addEdge({
|
||||
@@ -102,7 +95,6 @@ const inspectNode = (
|
||||
kind: "static_import",
|
||||
node,
|
||||
accumulator,
|
||||
maximumFindings,
|
||||
});
|
||||
else if (t.isImportExpression(node) && t.isStringLiteral(node.source))
|
||||
addEdge({
|
||||
@@ -111,19 +103,16 @@ const inspectNode = (
|
||||
kind: "dynamic_import",
|
||||
node,
|
||||
accumulator,
|
||||
maximumFindings,
|
||||
});
|
||||
if (t.isObjectProperty(node))
|
||||
inspectRouteProperty(script, node, accumulator, maximumFindings);
|
||||
if (t.isObjectProperty(node)) inspectRouteProperty(script, node, accumulator);
|
||||
if (t.isCallExpression(node) || t.isNewExpression(node))
|
||||
inspectCall(script, node, accumulator, maximumFindings);
|
||||
inspectCall(script, node, accumulator);
|
||||
};
|
||||
|
||||
const inspectCall = (
|
||||
script: IncludedScript,
|
||||
node: t.CallExpression | t.NewExpression,
|
||||
accumulator: AnalysisAccumulator,
|
||||
maximumFindings: number,
|
||||
): void => {
|
||||
const name = calleeName(node.callee);
|
||||
const first = stringArgument(node.arguments[0]);
|
||||
@@ -134,7 +123,6 @@ const inspectCall = (
|
||||
kind: "require",
|
||||
node,
|
||||
accumulator,
|
||||
maximumFindings,
|
||||
});
|
||||
if (
|
||||
(name === "importScripts" || name.endsWith(".importScripts")) &&
|
||||
@@ -146,7 +134,6 @@ const inspectCall = (
|
||||
kind: "worker_import",
|
||||
node,
|
||||
accumulator,
|
||||
maximumFindings,
|
||||
});
|
||||
if (
|
||||
routeCallNames.some(
|
||||
@@ -161,14 +148,12 @@ const inspectCall = (
|
||||
mechanism: `call:${name}`,
|
||||
node,
|
||||
accumulator,
|
||||
maximumFindings,
|
||||
});
|
||||
addRouteFrameworkInference({
|
||||
script,
|
||||
name,
|
||||
node,
|
||||
accumulator,
|
||||
maximumFindings,
|
||||
});
|
||||
}
|
||||
const endpoint = endpointArgument(name, node.arguments);
|
||||
@@ -180,20 +165,18 @@ const inspectCall = (
|
||||
mechanism: `call:${name}`,
|
||||
node,
|
||||
accumulator,
|
||||
maximumFindings,
|
||||
});
|
||||
if (
|
||||
name.endsWith("modelContext.registerTool") ||
|
||||
name === "modelContext.registerTool"
|
||||
)
|
||||
addWebMcpDeclaration(script, node, accumulator, maximumFindings);
|
||||
addWebMcpDeclaration(script, node, accumulator);
|
||||
};
|
||||
|
||||
const inspectRouteProperty = (
|
||||
script: IncludedScript,
|
||||
node: t.ObjectProperty,
|
||||
accumulator: AnalysisAccumulator,
|
||||
maximumFindings: number,
|
||||
): void => {
|
||||
const key = propertyName(node.key);
|
||||
if ((key === "path" || key === "route") && t.isStringLiteral(node.value))
|
||||
@@ -204,7 +187,6 @@ const inspectRouteProperty = (
|
||||
mechanism: `property:${key}`,
|
||||
node,
|
||||
accumulator,
|
||||
maximumFindings,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -214,13 +196,12 @@ interface AddEdgeContext {
|
||||
readonly kind: ChunkEdge["kind"];
|
||||
readonly node: t.Node;
|
||||
readonly accumulator: AnalysisAccumulator;
|
||||
readonly maximumFindings: number;
|
||||
}
|
||||
|
||||
const addEdge = (context: AddEdgeContext): void => {
|
||||
const bounded = context.specifier.slice(0, 4_096);
|
||||
const key = `edge\0${context.script.script_key}\0${context.kind}\0${bounded}`;
|
||||
addBounded(context.accumulator, key, context.maximumFindings, () =>
|
||||
addUnique(context.accumulator, key, () =>
|
||||
context.accumulator.edges.push({
|
||||
from_script_key: context.script.script_key,
|
||||
kind: context.kind,
|
||||
@@ -238,13 +219,12 @@ interface AddFindingContext {
|
||||
readonly mechanism: string;
|
||||
readonly node: t.Node;
|
||||
readonly accumulator: AnalysisAccumulator;
|
||||
readonly maximumFindings: number;
|
||||
}
|
||||
|
||||
const addFinding = (context: AddFindingContext): void => {
|
||||
const value = sanitizeEndpointCandidate(context.rawValue);
|
||||
const key = `finding\0${context.mechanism}\0${context.script.script_key}\0${value}`;
|
||||
addBounded(context.accumulator, key, context.maximumFindings, () =>
|
||||
addUnique(context.accumulator, key, () =>
|
||||
context.collection.push({
|
||||
value,
|
||||
mechanism: context.mechanism,
|
||||
@@ -257,7 +237,6 @@ const addWebMcpDeclaration = (
|
||||
script: IncludedScript,
|
||||
node: t.CallExpression | t.NewExpression,
|
||||
accumulator: AnalysisAccumulator,
|
||||
maximumFindings: number,
|
||||
): void => {
|
||||
const declaration = node.arguments[0];
|
||||
if (!t.isObjectExpression(declaration)) return;
|
||||
@@ -280,7 +259,7 @@ const addWebMcpDeclaration = (
|
||||
)
|
||||
: [];
|
||||
const key = `webmcp\0${script.script_key}\0${name ?? ""}\0${schemaPropertyNames.join("\0")}`;
|
||||
addBounded(accumulator, key, maximumFindings, () =>
|
||||
addUnique(accumulator, key, () =>
|
||||
accumulator.webMcp.push({
|
||||
name: name?.slice(0, 256) ?? null,
|
||||
description: description?.slice(0, 2_048) ?? null,
|
||||
@@ -296,13 +275,12 @@ const addWebMcpDeclaration = (
|
||||
const detectVendorFingerprints = (
|
||||
script: IncludedScript,
|
||||
accumulator: AnalysisAccumulator,
|
||||
maximumFindings: number,
|
||||
): void => {
|
||||
const text = script.source.artifact.text;
|
||||
for (const detector of vendorDetectors) {
|
||||
if (!detector.patterns.some((pattern) => text.includes(pattern))) continue;
|
||||
const key = `vendor\0${script.script_key}\0${detector.value}`;
|
||||
addBounded(accumulator, key, maximumFindings, () =>
|
||||
addUnique(accumulator, key, () =>
|
||||
accumulator.inferences.push({
|
||||
kind: detector.kind,
|
||||
value: detector.value,
|
||||
@@ -318,7 +296,6 @@ interface RouteFrameworkContext {
|
||||
readonly name: string;
|
||||
readonly node: t.Node;
|
||||
readonly accumulator: AnalysisAccumulator;
|
||||
readonly maximumFindings: number;
|
||||
}
|
||||
|
||||
const addRouteFrameworkInference = (context: RouteFrameworkContext): void => {
|
||||
@@ -328,7 +305,7 @@ const addRouteFrameworkInference = (context: RouteFrameworkContext): void => {
|
||||
? "React Router-compatible route API"
|
||||
: "Generic route registration API";
|
||||
const key = `route-framework\0${context.script.script_key}\0${value}`;
|
||||
addBounded(context.accumulator, key, context.maximumFindings, () =>
|
||||
addUnique(context.accumulator, key, () =>
|
||||
context.accumulator.inferences.push({
|
||||
kind: "route_framework",
|
||||
value,
|
||||
@@ -343,23 +320,12 @@ const addRouteFrameworkInference = (context: RouteFrameworkContext): void => {
|
||||
);
|
||||
};
|
||||
|
||||
const addBounded = (
|
||||
const addUnique = (
|
||||
accumulator: AnalysisAccumulator,
|
||||
key: string,
|
||||
maximum: number,
|
||||
add: () => void,
|
||||
): void => {
|
||||
if (accumulator.seen.has(key)) return;
|
||||
const findings =
|
||||
accumulator.edges.length +
|
||||
accumulator.routes.length +
|
||||
accumulator.endpoints.length +
|
||||
accumulator.webMcp.length +
|
||||
accumulator.inferences.length;
|
||||
if (findings >= maximum) {
|
||||
accumulator.droppedFindings += 1;
|
||||
return;
|
||||
}
|
||||
accumulator.seen.add(key);
|
||||
add();
|
||||
};
|
||||
@@ -382,7 +348,6 @@ export const emptyAccumulator = (): AnalysisAccumulator => ({
|
||||
visitedNodes: 0,
|
||||
parsedScripts: 0,
|
||||
parseFailures: 0,
|
||||
droppedFindings: 0,
|
||||
astLimitReached: false,
|
||||
});
|
||||
|
||||
|
||||
@@ -24,9 +24,7 @@ export const buildWebBundleAnalysis = (
|
||||
unavailable.length > 0 ||
|
||||
sourceMapIncomplete;
|
||||
const truncated =
|
||||
accumulator.astLimitReached ||
|
||||
accumulator.droppedFindings > 0 ||
|
||||
sourceMaps.status === "truncated";
|
||||
accumulator.astLimitReached || sourceMaps.status === "truncated";
|
||||
return webBundleAnalysisSchema.parse({
|
||||
capture: buildCaptureObservation(inspection, sourceScripts),
|
||||
observations: {
|
||||
@@ -52,7 +50,6 @@ export const buildWebBundleAnalysis = (
|
||||
parsedScripts: accumulator.parsedScripts,
|
||||
parseFailures: accumulator.parseFailures,
|
||||
visitedNodes: accumulator.visitedNodes,
|
||||
droppedFindings: accumulator.droppedFindings,
|
||||
}),
|
||||
limitations: bundleLimitations(),
|
||||
});
|
||||
@@ -97,7 +94,7 @@ const buildUnknowns = (input: UnknownsInput): WebBundleAnalysis["unknowns"] => [
|
||||
: [
|
||||
{
|
||||
dimension: "script_source" as const,
|
||||
reason: "Source artifact was not captured within approved limits",
|
||||
reason: "Source artifact was not captured",
|
||||
affected_script_keys: input.unavailable,
|
||||
},
|
||||
]),
|
||||
@@ -120,7 +117,7 @@ const buildUnknowns = (input: UnknownsInput): WebBundleAnalysis["unknowns"] => [
|
||||
dimension: "source_maps" as const,
|
||||
reason:
|
||||
input.sourceMaps.status === "truncated"
|
||||
? "Source-map evidence was truncated by approved limits"
|
||||
? "Source-map evidence was truncated by provider safety limits"
|
||||
: "One or more requested source maps were unavailable or incomplete",
|
||||
affected_script_keys: [
|
||||
...new Set([
|
||||
@@ -140,7 +137,6 @@ interface CompletenessInput {
|
||||
readonly parsedScripts: number;
|
||||
readonly parseFailures: number;
|
||||
readonly visitedNodes: number;
|
||||
readonly droppedFindings: number;
|
||||
}
|
||||
|
||||
const buildCompleteness = (
|
||||
@@ -154,7 +150,6 @@ const buildCompleteness = (
|
||||
parsed_scripts: input.parsedScripts,
|
||||
parse_failures: input.parseFailures,
|
||||
visited_ast_nodes: input.visitedNodes,
|
||||
dropped_findings: input.droppedFindings,
|
||||
});
|
||||
|
||||
const bundleLimitations = (): WebBundleAnalysis["limitations"] => [
|
||||
|
||||
@@ -12,7 +12,6 @@ export const discoverWebMcpToolsInputSchema = z.object({
|
||||
cdp_endpoint: browserEndpointSchema,
|
||||
allowed_origins: browserAllowedOriginsSchema,
|
||||
target_id: z.string().trim().min(1).max(256),
|
||||
approved: z.literal(true),
|
||||
observation_ms: z.number().int().min(0).max(10_000).default(100),
|
||||
max_tools: z.number().int().min(1).max(5_000).default(500),
|
||||
max_schema_bytes: z
|
||||
|
||||
@@ -43,8 +43,6 @@ export const captureWebScreenshotInputSchema = z.object({
|
||||
cdp_endpoint: browserEndpointSchema,
|
||||
allowed_origins: browserAllowedOriginsSchema,
|
||||
target_id: z.string().trim().min(1).max(256),
|
||||
approved: z.literal(true),
|
||||
screenshot_approved: z.literal(true),
|
||||
maximum_image_bytes: z
|
||||
.number()
|
||||
.int()
|
||||
|
||||
Reference in New Issue
Block a user