diff --git a/docs/esp-image.md b/docs/esp-image.md index 8816ea37ba..8456d48d3d 100644 --- a/docs/esp-image.md +++ b/docs/esp-image.md @@ -239,9 +239,11 @@ and a partition table sits where that origin puts `0x8000` (file offset `table_file_offset`, a limitation says to reopen the file with `format: "esp-flash-image"` and that `flash_offset`, and `inspect_artifact` lists the same `open_binary` call as a next probe. `flash_dump` is null for -every other image. Evidence that REA recorded before it reported the field -omits it; REA still reads and compares such Evidence, and the omission says -nothing about where the file was read from. +every other image. An Evidence bundle exported by an earlier release, without +`evidence_format`, is refused; recreate the observation. A standalone Evidence +record from before REA reported the field omits it; REA still reads and +compares such a record, and the omission says nothing about where the file was +read from. ## Limits diff --git a/docs/getting-started/cli.md b/docs/getting-started/cli.md index b26cb4d1b8..1d247677c8 100644 --- a/docs/getting-started/cli.md +++ b/docs/getting-started/cli.md @@ -978,9 +978,10 @@ as `node_modules/`, `dist/`, and `*.log`. Pattern-based exclusions record the matched pattern and whether it came from project, default, caller, or sensitive path policy. Links into excluded paths retain their internal target metadata; the exclusion explains why the target has no inventory entry, and the inventory -remains partial. Exclusions record `entry_kind` when the importer observed it; -older saved exclusions without that field have unknown kind. An excluded -ancestor proves an internal descendant only when its kind is `directory`. +remains partial. Every exclusion records `entry_kind` (`unknown` when the +importer could not observe the kind); a saved graph whose exclusion lacks it is +malformed. An excluded ancestor proves an internal descendant only when its kind +is `directory`. Set `REA_REFERENCE_SECRET_PATTERNS_JSON` to a JSON array of ignore patterns when you want to mark selected paths as sensitive; those patterns are reported separately as configured-secret exclusions. diff --git a/docs/guides/data/sqlite-databases.md b/docs/guides/data/sqlite-databases.md index dfdb311e47..a8bc798247 100644 --- a/docs/guides/data/sqlite-databases.md +++ b/docs/guides/data/sqlite-databases.md @@ -153,8 +153,7 @@ in the MCP client's whole-call deadline; increasing only that deadline does not change the worker budget. No server restart is needed. The result's `worker_timeout_ms` reports the actual parent-supervised budget, -including the default. Historical Evidence without this field has unknown -execution settings, not an inferred default. Explicit input selection is also +including the default, and Evidence without it is malformed. Explicit input selection is also retained in Evidence parameters; omission stays omitted. Completed observations retained under cancellation or cleanup failure keep the same budget facts. Timeout errors name the selected milliseconds, exact CLI/MCP controls, and diff --git a/docs/guides/javascript/javascript-runtime-observation.md b/docs/guides/javascript/javascript-runtime-observation.md index c095cfc37c..86390eb98b 100644 --- a/docs/guides/javascript/javascript-runtime-observation.md +++ b/docs/guides/javascript/javascript-runtime-observation.md @@ -119,7 +119,7 @@ The direct observations are: - `Debugger.scriptFailedToParse`, retained only as a bounded invalid-script count in `scripts.parse_failed_total`. A well-formed parse-failure event is distinct from malformed protocol data and does not make loaded - script coverage unavailable. Older Evidence may omit this count; + script coverage unavailable; - `Runtime.executionContextCreated`, `Runtime.executionContextDestroyed`, and `Runtime.executionContextsCleared`, establishing context lifecycle within diff --git a/docs/guides/managed/managed-code-analysis.md b/docs/guides/managed/managed-code-analysis.md index f6cca08290..7bd3cfad8d 100644 --- a/docs/guides/managed/managed-code-analysis.md +++ b/docs/guides/managed/managed-code-analysis.md @@ -543,17 +543,16 @@ custom modifiers are named too. Valid but unresolved TypeSpecs, invalid scopes, unreadable type names, cycles and nesting beyond the cap keep their raw operand spelling. Invalid or missing metadata coordinates retain the existing malformed signature result and source issue; rendering does not bypass validation. -The attestation is `null` only when member decoding exceeded capacity. When -either observation does not attest resolution, both sides compare raw digests, -which pair only where type rows agree, and the comparison reports that -limitation. The signature is exact whether or +The attestation is `null` only when member decoding exceeded capacity, and then +no members were examined: an inspection with `null` resolution and any field, +method, member reference, call edge or field access is malformed. The signature +is exact whether or not REA decoded it, so undecoded signatures pair by that tuple too, but they never enter structural rounds. An unmatched member is therefore reported as `unknown`, not added or removed, when its own signature was not decoded or when the other side has an unpaired member, one-sided or ambiguous, with the same -declared type and name whose signature was not decoded. When both observations -attest type-name resolution, a decoded signature that still compares by its raw -digest is treated the same way: an unmatched member with one, or beside an +declared type and name whose signature was not decoded. A decoded signature +that still compares by its raw digest is treated the same way: an unmatched member with one, or beside an unpaired same-named member with one, is `unknown`, because its raw bytes name types by build-local row. A matched unresolved signature also remains unknown unless another observed dimension establishes a change; identical row bytes diff --git a/docs/guides/runtime/process-capture.md b/docs/guides/runtime/process-capture.md index 56c3ab00ff..a91d7881ed 100644 --- a/docs/guides/runtime/process-capture.md +++ b/docs/guides/runtime/process-capture.md @@ -373,8 +373,11 @@ The terminal finalizer then freezes PTY input, retains normalized and rendered facts, and releases the renderer. Cleanup retry reuses those completed facts. All new captures commit `terminal_observation_version: "deferred-rendered-journal-v1"`, including when -PID and port normalization are disabled. Historical Evidence remains readable; -recapture both sides with the same observation version before comparison. +PID and port normalization are disabled. An Evidence bundle exported by an +earlier release, without `evidence_format`, is refused; recreate the +observation. A standalone record with an earlier observation version remains +readable; recapture both sides with the same observation version before +comparison. When path normalization is enabled, aliases apply to selected path identities at clear text delimiters. A selected executable path does not alias a longer diff --git a/docs/guides/web/browser-observation.md b/docs/guides/web/browser-observation.md index 66297c43cf..2f1f1003dd 100644 --- a/docs/guides/web/browser-observation.md +++ b/docs/guides/web/browser-observation.md @@ -25,7 +25,7 @@ authority are validated independently before selection and connection. - `inspect_web_page` / `rea inspect-web-page` captures DOM structure, accessibility nodes, scripts, resources, safe response/DOM metadata, attach-window network and console metadata, WebSocket frame sizes, workers, quota, and optionally selected storage key names, redacted storage-content fingerprints, or script sources. - `analyze_web_bundle` / `rea analyze-web-bundle` parses selected script artifacts without execution and derives chunk edges, route and endpoint candidates, vendor fingerprints, static WebMCP declarations, and optionally source-map/original-source evidence. - `observe_web_session` / `rea observe-web-session` arms an observation window of the requested duration for an external user action and records ordered reload, SPA navigation, redirect, failure, lifecycle, and target-termination metadata. -- `discover_webmcp_tools` / `rea discover-webmcp-tools` uses the experimental CDP WebMCP domain to return observed in-scope registrations and their complete observed `input_schema` declaration and canonical `input_schema_sha256` digest inline. Declarations are untrusted JSON data, including declared types, required fields, enums, examples and reference URLs. REA does not resolve schema references. An omitted optional `inputSchema` is a valid parameterless registration, represented by null schema and digest. These fields replace `input_schema_shape`. Registrations with the same name and URL in distinct observed frames retain separate identities. `tool_key` includes the observed frame ID; it is not a stable identity across navigation or browser sessions. Same-frame registration updates replace that owner only, and removal leaves other owners intact. Declared `readOnly`, `untrustedContent`, `consequential`, and `autosubmit` annotation hints are reported per registration: `true`/`false` are declared values, `null` means the declaration did not provide the hint in that capture, and a missing `consequential` key means the hint was not recorded, either in a historical capture or because the observed annotation was invalid. Consult discovery completeness and exclusions to distinguish these cases. Malformed annotation values or registration stacks retain the registration with incomplete coverage and an `invalid_protocol_value` exclusion. Other malformed protocol payloads can fail discovery explicitly. REA never exposes `WebMCP.invokeTool`. +- `discover_webmcp_tools` / `rea discover-webmcp-tools` uses the experimental CDP WebMCP domain to return observed in-scope registrations and their complete observed `input_schema` declaration and canonical `input_schema_sha256` digest inline. Declarations are untrusted JSON data, including declared types, required fields, enums, examples and reference URLs. REA does not resolve schema references. An omitted optional `inputSchema` is a valid parameterless registration, represented by null schema and digest. These fields replace `input_schema_shape`. Registrations with the same name and URL in distinct observed frames retain separate identities. `tool_key` includes the observed frame ID; it is not a stable identity across navigation or browser sessions. Same-frame registration updates replace that owner only, and removal leaves other owners intact. Declared `readOnly`, `untrustedContent`, `consequential`, and `autosubmit` annotation hints are reported per registration: `true`/`false` are declared values, `null` means the declaration did not provide the hint in that capture, and a missing `consequential` key means the observed annotation was invalid, so the hint was not recorded. Consult discovery completeness and exclusions to distinguish these cases. Malformed annotation values or registration stacks retain the registration with incomplete coverage and an `invalid_protocol_value` exclusion. Other malformed protocol payloads can fail discovery explicitly. REA never exposes `WebMCP.invokeTool`. - `compare_web_captures` / `rea compare-web-captures` compares passive captures or exact-step-aligned browser scenarios. Scenario results commit reproducible literal normalization and expose alignment failures plus artifact-level action, screenshot, DOM, accessibility, URL, history, storage, and event differences. Missing or truncated evidence is never treated as equivalence. @@ -47,9 +47,8 @@ properties owner could not be enumerated as an object literal, including explicit non-object values; `not_present` means no effective schema or own `properties` member was present after the `inputSchema ?? input_schema` alias selection. `not_present` describes this projection only: it does not validate a -schema or rule out properties expressed through other schema constructs. Older -observations may omit the coverage field; treat omission as `unknown` rather -than inferring completeness from the array. +schema or rule out properties expressed through other schema constructs. Read +the coverage field rather than inferring completeness from the array. Passive DOM comparison checks complete node inventories and complete frame parent/child structure independently. Node value lengths are comparable only @@ -98,14 +97,10 @@ content. Actual JSON properties with those names remain content. Reference-only objects, unsupported values, and opaque cookie partition identities remain incomplete. Previously exported fingerprints are not recomputed; recapture both sides when comparing captures produced across this decoder change. -IndexedDB schema fingerprints with `projection_version: 2` include the observed -database version and object-store definitions. A missing, malformed, or imprecise -version leaves the schema fingerprint incomplete while retaining observed store -facts. Historical fingerprints without this marker covered object stores only: -matching historical hashes cannot establish unchanged database versions, and a -historical hash is not compared with a version-bearing hash. Recapture both -sides for a complete IndexedDB version comparison; other proven storage changes -remain reportable. +IndexedDB schema fingerprints carry `projection_version: 2` and include the +observed database version and object-store definitions. A missing, malformed, or +imprecise version leaves the schema fingerprint incomplete while retaining +observed store facts. Script comparison groups observations by reported URL and compares unordered content samples. Producer inventory keys include optional metadata, so a changed @@ -468,7 +463,7 @@ agent hint is emitted only when the resolved context matches the response URL before userinfo credentials are removed. Following [RFC 8288](https://www.rfc-editor.org/rfc/rfc8288.html), the `rel`, `anchor`, and `type` parameters use their first occurrence, and quoted-pair escapes are decoded as specified by [RFC 9110 ยง5.6.4](https://www.rfc-editor.org/rfc/rfc9110.html#section-5.6.4). -The context fields are optional when reading older saved captures. Commas +Commas inside URI targets or quoted parameters remain part of those values. Well-known-resource hints require an exact supported pathname; path case is preserved because a case variant may identify a different HTTP resource. @@ -655,13 +650,12 @@ Source maps are not fetched by inspection. Bundle analysis fetches them only whe A fully read response that fails UTF-8, JSON, mapping, or structural validation retains `artifact: null`, empty original-source, module-edge, and mapping arrays, and an explicit failure limitation. Invalid content is `invalid`; -decoder or structural capacity refusal is `fetch_failed`. Its optional -`response_identity` records the complete body's SHA-256 digest, byte count, +decoder or structural capacity refusal is `fetch_failed`. Its +`response_identity`, always present on an `invalid` item, records the complete body's SHA-256 digest, byte count, and `fetch-response-body-bytes` representation without retaining malformed text or charging that text to the 32 MiB output budget. These are bytes delivered by Fetch after HTTP content decoding and before UTF-8 decoding, not -HTTP wire bytes. The identity is absent when the body was not fully read, and -older observations may omit it. A response whose text cannot fit the existing +HTTP wire bytes. A `fetch_failed` item omits the identity when the body was not fully read. A response whose text cannot fit the existing output budget is likewise `fetch_failed` with text omitted and completed-body identity; JSON parsing and source-map decoding are not attempted. Successful and partial maps keep their full text artifacts. Their original text, including an initial BOM or XSSI @@ -691,8 +685,6 @@ Source-map items retain the script's `declared_url` separately from the observed Failed fetches retain the last response URL observed within the approved origins; `effective_url` is `null` when no response was observed. Query parameters are preserved, and both URLs count toward the inline evidence budget. -Current fetches emit a string or null; historical observations may omit -`effective_url` without changing their stored content or Evidence identity. An observed URL must fit before its response body is read. If it cannot fit, remaining map results are explicitly unknown; failed cancellation retains its cleanup context and resource constraint. diff --git a/docs/guides/web/browser-scenario-contract.md b/docs/guides/web/browser-scenario-contract.md index 9c4b58e1af..183402cb50 100644 --- a/docs/guides/web/browser-scenario-contract.md +++ b/docs/guides/web/browser-scenario-contract.md @@ -672,10 +672,9 @@ transaction only when it was observed; a null predecessor does not establish that no earlier hop existed. Request events require both transaction fields; an absent ID is malformed capture data. `redirected_from_transaction_state` records `root` when Playwright observed no predecessor and `unknown` when a -predecessor exists but was outside the capture. A linked predecessor is carried -by `redirected_from_transaction_id` with no state field. Older captures without -the state field retain the conservative meaning that a null predecessor is -unknown. +predecessor exists but was outside the capture. It is required when +`redirected_from_transaction_id` is null and refused when the predecessor is +linked; a request event that breaks either rule is malformed capture data. `scenario.network_content` records the resolved content selection. Comparing captures with different selections reports network evidence as unknown with a diff --git a/docs/guides/web/web-source-location.md b/docs/guides/web/web-source-location.md index 27a83a419e..efd3b9a74a 100644 --- a/docs/guides/web/web-source-location.md +++ b/docs/guides/web/web-source-location.md @@ -248,8 +248,9 @@ profile are preserved. Browser `original_module_edges` carry a `declaration_index` joining each edge to its `original_sources` declaration, including repeated source URLs across indexed -sections. Imports are deduplicated within each declaration. Older observations -may omit the index; their edge declaration identity remains unknown. +sections. Imports are deduplicated within each declaration. Each mapping row +likewise carries its section-local `source_index` and the `declaration_index` +of the original source it maps to. Browser collection defaults to 64 MiB of map responses per inspection and preflights indexed sections, sources, names, generated rows and mapping segments @@ -272,10 +273,11 @@ Malformed UTF-8 map responses are reported as invalid rather than repaired with replacement characters. For browser fetching, an `invalid` map or structural or decoder capacity failure has `artifact: null`, empty decoded arrays, and an explicit limitation. -When its bounded response body was read in full, optional `response_identity` -records that body's SHA-256 digest and byte count after HTTP content decoding -and before UTF-8 decoding. It is not a digest of partial reads or a claim that -the map was valid; historical items may omit it. Malformed text is omitted so +An `invalid` map was always read in full, so it always carries +`response_identity`; a `fetch_failed` item carries it only when its bounded +response body was read in full. It records that body's SHA-256 digest and byte +count after HTTP content decoding and before UTF-8 decoding. It is not a digest +of partial reads or a claim that the map was valid. Malformed text is omitted so it does not consume the 32 MiB inline budget needed by later valid maps. A response whose text cannot fit that budget is refused before JSON parsing and source-map decoding, and retains the same diff --git a/docs/il2cpp-metadata.md b/docs/il2cpp-metadata.md index 591d1474cb..64edabd7b7 100644 --- a/docs/il2cpp-metadata.md +++ b/docs/il2cpp-metadata.md @@ -113,8 +113,9 @@ After finding method indices, parameters can be requested directly: } ``` -Historical Evidence that predates these member collections remains queryable. -A missing collection has an unknown (`null`) summary count, and requesting it +An Evidence bundle exported by an earlier release, without `evidence_format`, +is refused; recreate the observation. A standalone Evidence record that +predates these member collections remains queryable. A missing collection has an unknown (`null`) summary count, and requesting it reports that it was not collected; it is never presented as an empty inventory. The same holds for Evidence that predates binary linking: its summary omits `binary`, and `method_addresses`, `method_address_states`, `return_types`, `field_types` and `parameter_types` counts are `null`. A link retained before diff --git a/docs/javascript-route-inventory.md b/docs/javascript-route-inventory.md index 1a4c30a003..4126be6475 100644 --- a/docs/javascript-route-inventory.md +++ b/docs/javascript-route-inventory.md @@ -34,8 +34,8 @@ reopened with `inspect-evidence-bundle`; its `records` contain the complete Evidence. `inspect_analysis_view`'s `evidence-file` source accepts either one Evidence record or an exported bundle with the selected `evidence_id`. Views do not reopen source files or -reconnect to a browser. Historical Evidence without `route_inventory` is -unmeasured, rather than an empty route set. +reconnect to a browser. A parent without `route_inventory` is unmeasured, +rather than an empty route set. ## Page captured endpoint observations and inferences diff --git a/src/application/BrowserEvidence.ts b/src/application/BrowserEvidence.ts index 570b397893..e1e9efebd1 100644 --- a/src/application/BrowserEvidence.ts +++ b/src/application/BrowserEvidence.ts @@ -245,8 +245,7 @@ const browserResultTargetOrigin = ( typeof result.inspection.target.origin === "string" ) return result.inspection.target.origin; - if ("capture" in result && "target_origin" in result.capture) - return result.capture.target_origin ?? undefined; + if ("capture" in result) return result.capture.target_origin ?? undefined; if (!("target" in result)) return undefined; if ("origin" in result.target) return result.target.origin; if ("initial_url" in result.target) diff --git a/src/application/BrowserObservationContracts.test.ts b/src/application/BrowserObservationContracts.test.ts index 00625391f8..3e1a6f99d4 100644 --- a/src/application/BrowserObservationContracts.test.ts +++ b/src/application/BrowserObservationContracts.test.ts @@ -197,23 +197,15 @@ it("retains own provider metadata separately from admitted browser facts", async expect(reads).toBe(0); }); -it("retains source omission when the browser contract supplies defaults", async () => { +it("refuses a page inspection without the storage fingerprint algorithm", async () => { const { fingerprint_algorithm: _algorithm, ...storage } = inspection.storage; - const source = { ...inspection, storage }; const result = await service.inspectWebPage( - pageProvider(async () => ok(source as typeof inspection)), + pageProvider(async () => + ok({ ...inspection, storage } as typeof inspection), + ), inspectWebPageInputSchema.parse(selected), ); - expect(result.ok).toBe(true); - if (!result.ok) throw result.error; - expect(result.value.normalized_result).toHaveProperty( - "storage.fingerprint_algorithm", - "sha256", - ); - expect(result.value.raw_result).toEqual(source); - expect(result.value.raw_result).not.toHaveProperty( - "storage.fingerprint_algorithm", - ); + expect(result.ok).toBe(false); }); it("avoids a redundant raw browser report when parsed facts retain all own JSON", async () => { diff --git a/src/application/javascript/ElectronActiveEvidence.ts b/src/application/javascript/ElectronActiveEvidence.ts index 602ffe77b2..a05c815e15 100644 --- a/src/application/javascript/ElectronActiveEvidence.ts +++ b/src/application/javascript/ElectronActiveEvidence.ts @@ -14,7 +14,7 @@ export const createElectronActiveEvidence = ( input: ElectronActiveObservationInput, result: ElectronActiveObservationResult, provider: ProviderIdentity, - resolvedInput?: CanonicalElectronActiveObservationInput, + resolvedInput: CanonicalElectronActiveObservationInput, ): Evidence => createEvidence(undefined, provider, { predicateType: "rea.electron-active-scenario", @@ -37,20 +37,16 @@ export const createElectronActiveEvidence = ( const parameters = ( input: ElectronActiveObservationInput, - resolvedInput?: CanonicalElectronActiveObservationInput, + resolvedInput: CanonicalElectronActiveObservationInput, ): EvidenceObservation["parameters"] => { const scenario = jsonObjectSchema.parse(input); return { ...scenario, scenario_sha256: digestCanonicalValue(scenario, "Electron scenario"), - ...(resolvedInput === undefined - ? {} - : { - resolved_paths: { - executable_path: resolvedInput.executable_path, - application_path: resolvedInput.application_path, - application_root: resolvedInput.application_root, - }, - }), + resolved_paths: { + executable_path: resolvedInput.executable_path, + application_path: resolvedInput.application_path, + application_root: resolvedInput.application_root, + }, }; }; diff --git a/src/application/javascript/ElectronBoundaryAnalysis.ts b/src/application/javascript/ElectronBoundaryAnalysis.ts index a60c1f32c9..9f74f2f2a4 100644 --- a/src/application/javascript/ElectronBoundaryAnalysis.ts +++ b/src/application/javascript/ElectronBoundaryAnalysis.ts @@ -2,10 +2,6 @@ import { isPossibleCachedDataCompilation } from "../../domain/javascript/electro import type { JavaScriptJsonDocuments } from "./JavaScriptJsonDocuments.js"; import { compareUnicodeCodePoints } from "../../domain/unicodeCodePointOrder.js"; import type { ElectronIpcFinding } from "../../domain/javascript/electronStaticAnalysisTypes.js"; -import { - ELECTRON_MODULE, - ELECTRON_REFERENCE_KINDS, -} from "../../domain/javascript/javascriptElectronMemberWrites.js"; import type { ElectronBoundarySummary } from "../../domain/javascript/javascriptApplicationAnalysis.js"; import type { AnalyzedJavaScriptArtifactFile, @@ -139,37 +135,11 @@ export const createElectronIpcContext = ( * locates the module, a `worker` URL path, and a specifier that is a recovered * bundle module key. Reading the owned fact here keeps the boundary summary and * the published coverage view from disagreeing. - * - * Historical evidence may predate that field, so the retained references answer - * the same question for those files. */ const electronModuleReferencedBy = ({ javascript, - semantic, -}: AnalyzedJavaScriptArtifactFile): boolean => { - const applicability = javascript?.analysis_coverage?.applicability.electron; - if (applicability !== undefined) return applicability === "observed"; - const links = semantic?.ir.moduleLinks; - if ( - links !== undefined && - links.some( - ({ specifier, kind, loaderAuthority }) => - kind !== "type-import" && - loaderAuthority !== "candidate" && - specifier !== null && - ELECTRON_MODULE.test(specifier), - ) - ) - return true; - return (javascript?.references ?? []).some( - ({ specifier, kind, operation, loader_authority }) => - operation === "load" && - loader_authority !== "candidate" && - ELECTRON_REFERENCE_KINDS.has(kind) && - specifier !== null && - ELECTRON_MODULE.test(specifier), - ); -}; +}: AnalyzedJavaScriptArtifactFile): boolean => + javascript?.analysis_coverage.applicability.electron === "observed"; /** Whether any analyzed source loads an Electron module. */ const electronModuleReferenced = ( @@ -242,12 +212,11 @@ const electronExaminationLimited = ({ javascript, }: AnalyzedJavaScriptArtifactFile): boolean => { if (javascript === null) return false; - const status = javascript.analysis_coverage?.examination.status; - const syntax = javascript.analysis_coverage?.syntax.status; + const { examination, syntax } = javascript.analysis_coverage; return ( javascript.parse_status !== "complete" || - (syntax !== undefined && syntax !== "complete") || - (status !== undefined && status !== "complete") + syntax.status !== "complete" || + examination.status !== "complete" ); }; diff --git a/src/application/javascript/JavaScriptArtifactGraphElectronCoverage.test.ts b/src/application/javascript/JavaScriptArtifactGraphElectronCoverage.test.ts index bfa873624b..68181a2a8d 100644 --- a/src/application/javascript/JavaScriptArtifactGraphElectronCoverage.test.ts +++ b/src/application/javascript/JavaScriptArtifactGraphElectronCoverage.test.ts @@ -283,7 +283,7 @@ it("reports the same Electron applicability as the retained static fact", async const entry = await analyzedEntry( `const worker = new Worker(new URL("electron", import.meta.url));\n`, ); - expect(entry.javascript?.analysis_coverage?.applicability.electron).toBe( + expect(entry.javascript?.analysis_coverage.applicability.electron).toBe( "unknown", ); const graph = await graphFor( @@ -408,7 +408,7 @@ it("reports partial coverage when a successful static pass stopped at a limit", `const electron = require("electron");\nelectron.ipcMain.handle("ping", () => "pong");\n`, (entry) => { const javascript = entry.javascript!; - const coverage = javascript.analysis_coverage!; + const coverage = javascript.analysis_coverage; return { ...entry, javascript: { diff --git a/src/application/javascript/JavaScriptArtifactGraphStructure.test.ts b/src/application/javascript/JavaScriptArtifactGraphStructure.test.ts index 03dc849c6b..b429b88d69 100644 --- a/src/application/javascript/JavaScriptArtifactGraphStructure.test.ts +++ b/src/application/javascript/JavaScriptArtifactGraphStructure.test.ts @@ -179,18 +179,6 @@ describe("skipped JavaScript parse reporting", () => { javascript.analysis_coverage, ); }); - - it("does not reconstruct coverage from a historical overall summary", () => { - const file = skippedFile(); - const { analysis_coverage: _coverage, ...javascript } = - analyzeJavaScriptStaticSource(file.text.included ? file.text.value : ""); - const context = contextFor( - file, - analysisFor([{ file, javascript, semantic: null }]), - ); - addJavaScriptArtifactFiles(context); - expect(fileObservation(context)).not.toHaveProperty("analysis_coverage"); - }); }); it("preserves omitted inventory facts on an unavailable artifact", () => { diff --git a/src/application/javascript/JavaScriptArtifactGraphStructure.ts b/src/application/javascript/JavaScriptArtifactGraphStructure.ts index c1ec6281e3..7a441117f8 100644 --- a/src/application/javascript/JavaScriptArtifactGraphStructure.ts +++ b/src/application/javascript/JavaScriptArtifactGraphStructure.ts @@ -657,7 +657,7 @@ const createFileTarget = ( text_status: file.text.included ? "included" : file.text.reason, parse_status: javascript?.parse_status ?? (skipped ? "skipped" : null), - ...(javascript?.analysis_coverage !== undefined + ...(javascript !== null ? { analysis_coverage: javascript.analysis_coverage } : javascript === null && file.kind === "javascript" ? { diff --git a/src/application/javascript/JavaScriptRuntimeObservationService.test.ts b/src/application/javascript/JavaScriptRuntimeObservationService.test.ts index 6227f907da..a9339d7a92 100644 --- a/src/application/javascript/JavaScriptRuntimeObservationService.test.ts +++ b/src/application/javascript/JavaScriptRuntimeObservationService.test.ts @@ -45,6 +45,7 @@ const runtimeObservation = javascriptRuntimeObservationSchema.parse({ scripts: { items: [], observed_total: 0, + parse_failed_total: 0, excluded: { unsupported_location: 0, invalid_protocol_value: 0 }, }, execution_contexts: [], diff --git a/src/application/javascript/JavaScriptRuntimeReconciliationService.test.ts b/src/application/javascript/JavaScriptRuntimeReconciliationService.test.ts index 429aac3a00..99e0777081 100644 --- a/src/application/javascript/JavaScriptRuntimeReconciliationService.test.ts +++ b/src/application/javascript/JavaScriptRuntimeReconciliationService.test.ts @@ -175,6 +175,7 @@ it("preserves unresolved Inspector target location reason through service Eviden scripts: { items: [], observed_total: 0, + parse_failed_total: 0, excluded: { unsupported_location: 0, invalid_protocol_value: 0 }, }, execution_contexts: [], diff --git a/src/browser/CdpCaptureStorageFingerprints.ts b/src/browser/CdpCaptureStorageFingerprints.ts index 8314854689..bfca80effd 100644 --- a/src/browser/CdpCaptureStorageFingerprints.ts +++ b/src/browser/CdpCaptureStorageFingerprints.ts @@ -197,7 +197,6 @@ const addIndexedDb = async ( version: version ?? null, object_stores: stores.map(indexedDbStoreSchema), }, - projectionVersion: 2, complete: version !== undefined && stores.length === database.objectStores.length && @@ -425,21 +424,22 @@ const addFingerprint = ( readonly identity: unknown; readonly value: unknown; readonly complete: boolean; - readonly projectionVersion?: 2; }, ): void => { - state.items.push({ - scope: input.scope, + const fingerprint = { identity_sha256: digest(input.identity), value_sha256: input.value === undefined ? null : digest(input.value), - ...(input.projectionVersion === undefined - ? {} - : { projection_version: input.projectionVersion }), complete: input.complete && stableValueComplete(input.identity) && stableValueComplete(input.value), - }); + }; + // The IndexedDB schema projection includes the database version. + state.items.push( + input.scope === "indexed_db_schema" + ? { ...fingerprint, scope: input.scope, projection_version: 2 } + : { ...fingerprint, scope: input.scope }, + ); }; const STORAGE_ENTRY_PAGE_SIZE = 1_000; diff --git a/src/browser/PlaywrightBrowserScenarioProvider.test.ts b/src/browser/PlaywrightBrowserScenarioProvider.test.ts index f4b6382932..7e5a363262 100644 --- a/src/browser/PlaywrightBrowserScenarioProvider.test.ts +++ b/src/browser/PlaywrightBrowserScenarioProvider.test.ts @@ -256,6 +256,7 @@ const capturedResponseBodyEvents = (): readonly BrowserScenarioEvent[] => [ kind: "response", transaction_id: "request-1", redirected_from_transaction_id: null, + redirected_from_transaction_state: "root", method: "GET", url: sanitizeBrowserUrl("https://app.example.test/main.js"), resource_type: "script", diff --git a/src/browser/WebSourceMapFetcher.ts b/src/browser/WebSourceMapFetcher.ts index f75e0ac0d7..a88a58fabf 100644 --- a/src/browser/WebSourceMapFetcher.ts +++ b/src/browser/WebSourceMapFetcher.ts @@ -666,9 +666,8 @@ const fetchOne = async ( ); completedResponseIdentity = body.responseIdentity; if (!body.text.ok) - return emptySourceMapItem( + return invalidSourceMapItem( request, - "invalid", body.text.error.message, effectiveUrl, body.responseIdentity, @@ -1040,9 +1039,8 @@ const normalizeSourceMap = ( ); const parsedJson = safeParseJson(sourceMapJsonText(text)); if (!parsedJson.ok) - return emptySourceMapItem( + return invalidSourceMapItem( request, - "invalid", "Source-map JSON is not a version 3 map.", fetchedUrl, responseIdentity, @@ -1211,9 +1209,8 @@ const normalizeSourceMap = ( cause instanceof SourceMapDeadlineError ) throw cause; - return emptySourceMapItem( + return invalidSourceMapItem( request, - "invalid", isSourceMapSectionOverlap(cause) ? cause.message : "Source-map JSON mappings could not be decoded safely.", @@ -1359,24 +1356,37 @@ const sourceMapContext = ( effective_url: effectiveUrl, }); +const failedSourceMapBase = ( + request: WebSourceMapRequest, + limitation: string, + effectiveUrl: string | null, + responseIdentity: ResponseIdentity | undefined, +) => ({ + ...sourceMapContext(request, effectiveUrl), + artifact: null, + original_sources: [], + original_module_edges: [], + mappings: [], + limitation: + responseIdentity === undefined + ? limitation + : `${limitation} Response text was not retained; completed response body identity is available.`, +}); + +/** A map that was filtered or whose complete body may not have been read. */ const emptySourceMapItem = ( request: WebSourceMapRequest, - status: FailedSourceMapStatus, + status: Exclude, limitation: string, effectiveUrl: string | null = null, responseIdentity?: ResponseIdentity, ): WebSourceMapItem => { - const base = { - ...sourceMapContext(request, effectiveUrl), - artifact: null, - original_sources: [], - original_module_edges: [], - mappings: [], - limitation: - responseIdentity === undefined - ? limitation - : `${limitation} Response text was not retained; completed response body identity is available.`, - }; + const base = failedSourceMapBase( + request, + limitation, + effectiveUrl, + responseIdentity, + ); return status === "policy_filtered" ? { ...base, status } : { @@ -1388,6 +1398,18 @@ const emptySourceMapItem = ( }; }; +/** A completely read body that is not a usable map keeps its identity. */ +const invalidSourceMapItem = ( + request: WebSourceMapRequest, + limitation: string, + effectiveUrl: string | null, + responseIdentity: ResponseIdentity, +): WebSourceMapItem => ({ + ...failedSourceMapBase(request, limitation, effectiveUrl, responseIdentity), + status: "invalid", + response_identity: responseIdentity, +}); + const sourceMapTextArtifact = ( text: string, responseIdentity: ResponseIdentity, diff --git a/src/composition/javascriptAnalysisWorkerProcess.ts b/src/composition/javascriptAnalysisWorkerProcess.ts index ac81e41883..7ddf97fe57 100644 --- a/src/composition/javascriptAnalysisWorkerProcess.ts +++ b/src/composition/javascriptAnalysisWorkerProcess.ts @@ -48,9 +48,7 @@ const analyze: JavaScriptSourceWorkerAnalyzer = async ( ...empty, parse_status: facts.parse_status, parse_error_count: facts.parse_error_count, - ...(facts.analysis_coverage === undefined - ? {} - : { analysis_coverage: facts.analysis_coverage }), + analysis_coverage: facts.analysis_coverage, visited_ast_nodes: facts.visited_ast_nodes, limitations: facts.limitations, electron: { diff --git a/src/contracts/managed/managedWorkflowExamples.ts b/src/contracts/managed/managedWorkflowExamples.ts index 6e84e64725..91c515e321 100644 --- a/src/contracts/managed/managedWorkflowExamples.ts +++ b/src/contracts/managed/managedWorkflowExamples.ts @@ -79,6 +79,7 @@ const runtimeMembers = (): ManagedMemberInspection => { ); return { ...result, + signature_resolution: "type-names-v2", method_rows: { offset: 0, count: 1, total: 1 }, methods: [ { diff --git a/src/domain/analysisView/analysisViewResult.ts b/src/domain/analysisView/analysisViewResult.ts index 0f1459b308..706af91ca0 100644 --- a/src/domain/analysisView/analysisViewResult.ts +++ b/src/domain/analysisView/analysisViewResult.ts @@ -847,7 +847,7 @@ export const webBundleSummaryViewResultSchema = z.strictObject({ artifact: artifactSchema.nullable(), parent_operation: z.literal("analyze_web_bundle"), target_url: z.string(), - target_origin: recordedBrowserOriginSchema.nullable().optional(), + target_origin: recordedBrowserOriginSchema.nullable(), source_unknowns: webBundleAnalysisSchema.shape.unknowns, summary: webBundleSummarySchema, }); @@ -858,7 +858,7 @@ export const webBundlePageViewResultSchema = z.strictObject({ kind: z.literal("web-bundle"), parent_operation: z.literal("analyze_web_bundle"), target_url: z.string(), - target_origin: recordedBrowserOriginSchema.nullable().optional(), + target_origin: recordedBrowserOriginSchema.nullable(), source_unknowns: webBundleAnalysisSchema.shape.unknowns, view: webBundleViewRequestSchema, completeness: webBundleAnalysisSchema.shape.completeness, diff --git a/src/domain/analysisView/managedMemberView.test.ts b/src/domain/analysisView/managedMemberView.test.ts index f13d33a916..9347d5557d 100644 --- a/src/domain/analysisView/managedMemberView.test.ts +++ b/src/domain/analysisView/managedMemberView.test.ts @@ -41,6 +41,11 @@ it("keeps unexamined collections unknown while normalizing immutable managed par signature_resolution: null, exported_types: null, user_strings: null, + fields: [], + methods: [], + member_refs: [], + call_edges: [], + field_accesses: [], }; const input = parent(freezeOwnedJsonTreeSnapshot(unexamined)); for (let attempt = 0; attempt < 2; attempt++) { diff --git a/src/domain/analysisView/webBundleView.test.ts b/src/domain/analysisView/webBundleView.test.ts index 599b378b83..401b70adf7 100644 --- a/src/domain/analysisView/webBundleView.test.ts +++ b/src/domain/analysisView/webBundleView.test.ts @@ -32,12 +32,11 @@ const query = ( return result.value; }; -it.each([undefined, null, "https://example.test"])( - "preserves historical omitted and explicit target origins: %s", +it.each([null, "https://example.test"])( + "projects the recorded target origin: %s", (origin) => { const report = sampleWebBundleAnalysis(); - if (origin === undefined) delete report.capture.target_origin; - else report.capture.target_origin = origin; + report.capture.target_origin = origin; const parent = makeParent(report); for (const selection of [ { kind: "summary" }, @@ -45,21 +44,24 @@ it.each([undefined, null, "https://example.test"])( { kind: "web-bundle", collection: "endpoints", fields: ["value"] }, ]) { const view = query(parent, selection); - if (origin === undefined) - expect(view).not.toHaveProperty("target_origin"); - else expect(view).toHaveProperty("target_origin", origin); + expect(view).toHaveProperty("target_origin", origin); if ( view.kind === "summary" || (view.kind === "web-bundle" && view.summary !== null) - ) { - if (origin === undefined) - expect(view.summary).not.toHaveProperty("target_origin"); - else expect(view.summary).toHaveProperty("target_origin", origin); - } + ) + expect(view.summary).toHaveProperty("target_origin", origin); } }, ); +it("refuses a web-bundle report without its target origin", () => { + const report = sampleWebBundleAnalysis(); + Reflect.deleteProperty(report.capture, "target_origin"); + expect(() => + query(makeParent(report), { kind: "web-bundle", collection: "summary" }), + ).toThrow(AnalysisInputError); +}); + it("counts the distinct full parent/report limitation union before bounding", () => { const base = makeParent({ limitations: [ diff --git a/src/domain/analysisView/webBundleView.ts b/src/domain/analysisView/webBundleView.ts index fadf8b78e5..fb12384f73 100644 --- a/src/domain/analysisView/webBundleView.ts +++ b/src/domain/analysisView/webBundleView.ts @@ -69,7 +69,7 @@ export const webBundleViewRequestSchema = z.discriminatedUnion("collection", [ export const webBundleSummarySchema = z.strictObject({ target_url: z.string(), - target_origin: recordedBrowserOriginSchema.nullable().optional(), + target_origin: recordedBrowserOriginSchema.nullable(), scripts_observed: z.number().int().nonnegative(), scripts_analyzed: z.number().int().nonnegative(), counts: z.strictObject({ @@ -151,10 +151,6 @@ export const projectWebBundleView = ( if (!parsed.ok) return parsed; const report: WebBundleAnalysis = parsed.value; - const targetOrigin = - report.capture.target_origin === undefined - ? {} - : { target_origin: report.capture.target_origin }; const sourceLimitations = [ ...new Set([...parent.limitations, ...report.limitations]), ]; @@ -165,7 +161,7 @@ export const projectWebBundleView = ( parent_digest: parent.evidenceId.slice(3), artifact: parent.artifact ?? null, target_url: report.capture.target_url, - ...targetOrigin, + target_origin: report.capture.target_origin, source_unknowns: report.unknowns, limitations: boundedViewMessages( sourceLimitations, @@ -200,7 +196,7 @@ export const projectWebBundleView = ( const buildSummary = (): z.output => ({ target_url: report.capture.target_url, - ...targetOrigin, + target_origin: report.capture.target_origin, scripts_observed: report.capture.scripts_observed, scripts_analyzed: report.capture.scripts_analyzed, counts: { diff --git a/src/domain/browserObservation.test.ts b/src/domain/browserObservation.test.ts index 4ca3ce2042..68470be757 100644 --- a/src/domain/browserObservation.test.ts +++ b/src/domain/browserObservation.test.ts @@ -9,6 +9,8 @@ import { sanitizeEndpointCandidate, sanitizeBrowserUrl, } from "./browserObservation.js"; +import { webPageInspectionSchema } from "./browserObservationSchemas.js"; +import { createWebPageInspection } from "../../tests/support/browser/webPageInspection.js"; describe("browser observation contracts", () => { it.each(["127.0.0.1", "[::1]"])( @@ -285,3 +287,61 @@ describe("browser observation sensitive surfaces and retention", () => { ); }); }); + +describe("page inspection producer facts", () => { + const inspection = () => + createWebPageInspection([ + { + source: "fetch('/api');", + scriptKey: `scr_${"a".repeat(64)}`, + url: "https://app.example.test/main.js", + origin: "https://app.example.test", + cdpHash: "hash", + }, + ]); + const axNode = { + node_id: "root", + parent_id: null, + role: "RootWebArea", + name: null, + description: null, + ignored: false, + states: [], + }; + const worker = { + target_id: "worker-1", + type: "worker", + url: "https://app.example.test/worker.js", + origin: "https://app.example.test", + attached: false, + opener_target_id: null, + parent_frame_id: null, + }; + + it.each([ + ["script frame_id", ["scripts", "items", 0, "frame_id"]], + ["accessibility states", ["accessibility", "nodes", 0, "states"]], + ["worker opener_target_id", ["workers", 0, "opener_target_id"]], + ["worker parent_frame_id", ["workers", 0, "parent_frame_id"]], + ] as const)("refuses an inspection without the %s", (_label, path) => { + const base = inspection(); + const input = structuredClone({ + ...base, + accessibility: { ...base.accessibility, nodes: [axNode] }, + workers: [worker], + }); + expect(webPageInspectionSchema.safeParse(input).success).toBe(true); + const parent = path + .slice(0, -1) + .reduce( + (value, key) => Reflect.get(value as object, key), + input, + ); + Reflect.deleteProperty(parent as object, path.at(-1)!); + const parsed = webPageInspectionSchema.safeParse(input); + expect(parsed.success).toBe(false); + expect(parsed.error?.issues.map((issue) => issue.path)).toContainEqual( + path, + ); + }); +}); diff --git a/src/domain/browserObservationSchemas.ts b/src/domain/browserObservationSchemas.ts index b020db89db..5f055d7474 100644 --- a/src/domain/browserObservationSchemas.ts +++ b/src/domain/browserObservationSchemas.ts @@ -60,14 +60,12 @@ const browserAxNodeSchema = z.object({ name: z.string().nullable(), description: z.string().nullable(), ignored: z.boolean(), - states: z - .array( - z.object({ - name: z.string(), - value: z.union([z.boolean(), z.number(), z.string()]), - }), - ) - .default([]), + states: z.array( + z.object({ + name: z.string(), + value: z.union([z.boolean(), z.number(), z.string()]), + }), + ), }); const browserResourceReconciliationSchema = z.discriminatedUnion("status", [ z.object({ status: z.literal("exact"), resource_key: z.string() }), @@ -82,7 +80,7 @@ const browserResourceReconciliationSchema = z.discriminatedUnion("status", [ ]); const browserScriptSchema = z.object({ script_key: z.string().regex(/^scr_[a-f0-9]{64}(?:_[0-9]+)?$/u), - frame_id: z.string().nullable().default(null), + frame_id: z.string().nullable(), url: z.string(), origin: z.string().nullable(), ...cdpScriptMetadataSchema.shape, @@ -185,8 +183,8 @@ const browserWorkerSchema = z.object({ url: z.string(), origin: z.string().nullable(), attached: z.boolean(), - opener_target_id: z.string().nullable().default(null), - parent_frame_id: z.string().nullable().default(null), + opener_target_id: z.string().nullable(), + parent_frame_id: z.string().nullable(), }); const browserCspSourceSchema = z.object({ kind: z.enum([ @@ -201,10 +199,8 @@ const browserCspSourceSchema = z.object({ const browserLinkMetadataSchema = z.object({ href: z.string().nullable(), destination_scope: z.enum(["approved", "outside_policy", "unsupported"]), - context_url: z.string().nullable().optional(), - context_scope: z - .enum(["approved", "outside_policy", "unsupported"]) - .optional(), + context_url: z.string().nullable(), + context_scope: z.enum(["approved", "outside_policy", "unsupported"]), rel: z.array(z.string()), as: z.string().nullable(), type: z.string().nullable(), @@ -264,6 +260,15 @@ const browserSafeMetadataSchema = z.object({ }); /** Provider-neutral normalized result for one passive web-page observation. */ +const storageFingerprintShape = { + identity_sha256: z.string().regex(/^[a-f0-9]{64}$/u), + value_sha256: z + .string() + .regex(/^[a-f0-9]{64}$/u) + .nullable(), + complete: z.boolean(), +}; + export const webPageInspectionSchema = z.object({ browser: browserVersionSchema, target: browserTargetSchema, @@ -310,34 +315,31 @@ export const webPageInspectionSchema = z.object({ session_storage_keys: z.array(z.string()), indexed_db_names: z.array(z.string()), cache_names: z.array(z.string()), - content_fingerprints: z - .array( + content_fingerprints: z.array( + z.discriminatedUnion("scope", [ z.object({ + ...storageFingerprintShape, scope: z.enum([ "cookie", "local_storage", "session_storage", - "indexed_db_schema", "indexed_db_record", "cache_entry", ]), - identity_sha256: z.string().regex(/^[a-f0-9]{64}$/u), - value_sha256: z - .string() - .regex(/^[a-f0-9]{64}$/u) - .nullable(), + }), + z.object({ + ...storageFingerprintShape, + scope: z.literal("indexed_db_schema"), projection_version: z .literal(2) - .optional() .describe( - "IndexedDB schema projection including database version; absent on historical store-only fingerprints.", + "IndexedDB schema projection including database version.", ), - complete: z.boolean(), }), - ) - .default([]), - fingerprint_algorithm: z.literal("sha256").default("sha256"), - fingerprints_complete: z.boolean().default(false), + ]), + ), + fingerprint_algorithm: z.literal("sha256"), + fingerprints_complete: z.boolean(), values_redacted: z.literal(true), }), limitations: z.array(z.string()), diff --git a/src/domain/browserScenarioCapture.test.ts b/src/domain/browserScenarioCapture.test.ts index 293b7003cc..9dcfec0841 100644 --- a/src/domain/browserScenarioCapture.test.ts +++ b/src/domain/browserScenarioCapture.test.ts @@ -49,6 +49,12 @@ it("requires transaction IDs and explicit unknown redirect predecessors", () => redirected_from_transaction_state: "unknown", }).success, ).toBe(false); + expect( + browserScenarioEventSchema.safeParse({ + ...request, + redirected_from_transaction_state: undefined, + }).success, + ).toBe(false); }); it("parses each network outcome without contradictory status or failure data", () => { diff --git a/src/domain/browserScenarioCaptureValues.ts b/src/domain/browserScenarioCaptureValues.ts index 436c69e53d..89ce6c4bee 100644 --- a/src/domain/browserScenarioCaptureValues.ts +++ b/src/domain/browserScenarioCaptureValues.ts @@ -166,7 +166,7 @@ const networkEventShape = { ...eventBase, transaction_id: z.string().min(1), redirected_from_transaction_id: z.string().min(1).nullable(), - /** Distinguishes a captured root from an unobserved predecessor for null links. */ + /** Present exactly when the predecessor ID is null: a captured root or an unobserved predecessor. */ redirected_from_transaction_state: z.enum(["root", "unknown"]).optional(), method: z.string().min(1), url: sanitizedBrowserUrlSchema, @@ -282,15 +282,15 @@ export const browserScenarioEventSchema = z }), ]) .superRefine((event, context) => { - if ( - "redirected_from_transaction_id" in event && - event.redirected_from_transaction_id !== null && - event.redirected_from_transaction_state !== undefined - ) + if (!("redirected_from_transaction_id" in event)) return; + const linked = event.redirected_from_transaction_id !== null; + const stated = event.redirected_from_transaction_state !== undefined; + if (linked === stated) context.addIssue({ code: "custom", - message: - "Redirect state is valid only when the predecessor transaction ID is null", + message: linked + ? "Redirect state is valid only when the predecessor transaction ID is null" + : "Redirect state is required when the predecessor transaction ID is null", path: ["redirected_from_transaction_state"], }); }); diff --git a/src/domain/browserScenarioDiff.test.ts b/src/domain/browserScenarioDiff.test.ts index bdac324b4f..108a9ad598 100644 --- a/src/domain/browserScenarioDiff.test.ts +++ b/src/domain/browserScenarioDiff.test.ts @@ -501,7 +501,8 @@ describe("browser scenario network event order", () => { ? { ...event, redirected_from_transaction_id: predecessor, - redirected_from_transaction_state: undefined, + redirected_from_transaction_state: + predecessor === null ? ("unknown" as const) : undefined, } : event, ); @@ -610,6 +611,7 @@ describe("browser scenario network comparison stability", () => { kind: "request", transaction_id: "orphan-request", redirected_from_transaction_id: null, + redirected_from_transaction_state: "unknown", method: "GET", url: { url: "https://app.example.test/orphan", diff --git a/src/domain/javascript/electronBundledRequireIdentity.test.ts b/src/domain/javascript/electronBundledRequireIdentity.test.ts index 0e81e70506..307b49b3ff 100644 --- a/src/domain/javascript/electronBundledRequireIdentity.test.ts +++ b/src/domain/javascript/electronBundledRequireIdentity.test.ts @@ -40,7 +40,7 @@ it("does not claim Electron host identity from an unbound require in unknown con loader_authority: "candidate", }), ); - expect(analysis.analysis_coverage?.applicability.electron).toBe("unknown"); + expect(analysis.analysis_coverage.applicability.electron).toBe("unknown"); }); describe("Electron identity through Webpack externals", () => { diff --git a/src/domain/javascript/electronNativeLoaderPaths.test.ts b/src/domain/javascript/electronNativeLoaderPaths.test.ts index d8a19a6ecd..6b04934dda 100644 --- a/src/domain/javascript/electronNativeLoaderPaths.test.ts +++ b/src/domain/javascript/electronNativeLoaderPaths.test.ts @@ -85,9 +85,9 @@ it("does not claim a native re-export from a candidate wrapper with a proven fac specifier: "./addon.node", }), ); - expect( - analysis.analysis_coverage?.semantics.unknown_findings, - ).toBeGreaterThan(0); + expect(analysis.analysis_coverage.semantics.unknown_findings).toBeGreaterThan( + 0, + ); }); describe("native addon loader provenance", () => { diff --git a/src/domain/javascript/electronStaticAnalysisCandidate.test.ts b/src/domain/javascript/electronStaticAnalysisCandidate.test.ts index 0578d68a6c..06cb46e6bd 100644 --- a/src/domain/javascript/electronStaticAnalysisCandidate.test.ts +++ b/src/domain/javascript/electronStaticAnalysisCandidate.test.ts @@ -18,7 +18,7 @@ describe("conditional Electron identities", () => { it("retains alias-derived findings without proving an unknown loader", () => { const result = analyze(source, "main.MJS"); - expect(result.analysis_coverage?.applicability.electron).toBe("unknown"); + expect(result.analysis_coverage.applicability.electron).toBe("unknown"); expect(result.electron.browser_windows).toMatchObject([ { loader_authority: "candidate", @@ -38,7 +38,7 @@ describe("conditional Electron identities", () => { it("retains established CommonJS and ES module observations as proven", () => { const commonjs = analyze(source, "main.cjs"); - expect(commonjs.analysis_coverage?.applicability.electron).toBe("observed"); + expect(commonjs.analysis_coverage.applicability.electron).toBe("observed"); expect( commonjs.electron.browser_windows[0]?.loader_authority, ).toBeUndefined(); @@ -46,7 +46,7 @@ describe("conditional Electron identities", () => { 'import { BrowserWindow } from "electron"; new BrowserWindow({});', "main.mjs", ); - expect(esm.analysis_coverage?.applicability.electron).toBe("observed"); + expect(esm.analysis_coverage.applicability.electron).toBe("observed"); expect(esm.electron.browser_windows[0]?.loader_authority).toBeUndefined(); }); @@ -54,7 +54,7 @@ describe("conditional Electron identities", () => { const optional = 'const {app, BrowserWindow} = require?.("electron"); app.setAppPath("/tmp"); new BrowserWindow();'; const candidate = analyze(optional, "main.MJS"); - expect(candidate.analysis_coverage?.applicability.electron).toBe("unknown"); + expect(candidate.analysis_coverage.applicability.electron).toBe("unknown"); expect(candidate.electron.browser_windows).toMatchObject([ { loader_authority: "candidate" }, ]); diff --git a/src/domain/javascript/electronStaticAnalysisComputedPreferences.test.ts b/src/domain/javascript/electronStaticAnalysisComputedPreferences.test.ts index 605034ec71..ce1058b0c6 100644 --- a/src/domain/javascript/electronStaticAnalysisComputedPreferences.test.ts +++ b/src/domain/javascript/electronStaticAnalysisComputedPreferences.test.ts @@ -15,7 +15,7 @@ describe("computed Electron web preference keys", () => { `); expect(analysis.parse_status).toBe("partial"); - expect(analysis.analysis_coverage?.syntax).toEqual({ + expect(analysis.analysis_coverage.syntax).toEqual({ status: "complete", error_count: 0, }); diff --git a/src/domain/javascript/electronStaticAnalysisOptions.test.ts b/src/domain/javascript/electronStaticAnalysisOptions.test.ts index adb38b459a..882d80f713 100644 --- a/src/domain/javascript/electronStaticAnalysisOptions.test.ts +++ b/src/domain/javascript/electronStaticAnalysisOptions.test.ts @@ -962,7 +962,7 @@ describe("Electron option evidence", () => { `); expect(analysis.parse_status).toBe("partial"); - expect(analysis.analysis_coverage?.syntax).toEqual({ + expect(analysis.analysis_coverage.syntax).toEqual({ status: "complete", error_count: 0, }); @@ -1090,7 +1090,7 @@ describe("Electron empty option keys", () => { expect(analysis.parse_error_count).toBe(0); expect(analysis.parse_status).toBe("partial"); - expect(analysis.analysis_coverage?.syntax).toEqual({ + expect(analysis.analysis_coverage.syntax).toEqual({ status: "complete", error_count: 0, }); @@ -1120,7 +1120,7 @@ describe("Electron empty option keys", () => { expect(analysis.parse_error_count).toBe(0); expect(analysis.parse_status).toBe("partial"); - expect(analysis.analysis_coverage?.syntax).toEqual({ + expect(analysis.analysis_coverage.syntax).toEqual({ status: "complete", error_count: 0, }); @@ -1151,7 +1151,7 @@ describe("Electron empty option keys", () => { expect(analysis.parse_error_count).toBe(0); expect(analysis.parse_status).toBe("partial"); - expect(analysis.analysis_coverage?.syntax).toEqual({ + expect(analysis.analysis_coverage.syntax).toEqual({ status: "complete", error_count: 0, }); diff --git a/src/domain/javascript/electronStaticAnalysisScopedIpc.test.ts b/src/domain/javascript/electronStaticAnalysisScopedIpc.test.ts index c8ca27ca13..d83cc42968 100644 --- a/src/domain/javascript/electronStaticAnalysisScopedIpc.test.ts +++ b/src/domain/javascript/electronStaticAnalysisScopedIpc.test.ts @@ -14,16 +14,16 @@ it("retains an unknown-host Electron request as a candidate without claiming IPC loader_authority: "candidate", }), ]); - expect(analysis.analysis_coverage?.applicability.electron).toBe("unknown"); + expect(analysis.analysis_coverage.applicability.electron).toBe("unknown"); expect(analysis.references).toContainEqual( expect.objectContaining({ specifier: "electron", loader_authority: "candidate", }), ); - expect( - analysis.analysis_coverage?.semantics.unknown_findings, - ).toBeGreaterThan(0); + expect(analysis.analysis_coverage.semantics.unknown_findings).toBeGreaterThan( + 0, + ); }); it.each([ diff --git a/src/domain/javascript/electronStaticAnalysisTypes.ts b/src/domain/javascript/electronStaticAnalysisTypes.ts index c9151f9f48..aa9ce6f781 100644 --- a/src/domain/javascript/electronStaticAnalysisTypes.ts +++ b/src/domain/javascript/electronStaticAnalysisTypes.ts @@ -62,7 +62,7 @@ export type ElectronBrowserWindowFinding = ElectronBrowserWindowPreload & { /** Electron identity is conditional on an unproved loader. */ readonly loader_authority?: "candidate"; readonly module_key: string | null; - /** Recovered factory runtime; absent in older or unbundled findings. */ + /** Recovered factory runtime; absent when no bundler factory runtime was recovered. */ readonly module_runtime?: string; readonly location: JavaScriptSourceRange; }; @@ -84,7 +84,7 @@ export type ElectronContextBridgeFinding = ElectronContextBridgeApiKey & { /** Electron identity is conditional on an unproved loader. */ readonly loader_authority?: "candidate"; readonly module_key: string | null; - /** Recovered factory runtime; absent in older or unbundled findings. */ + /** Recovered factory runtime; absent when no bundler factory runtime was recovered. */ readonly module_runtime?: string; readonly location: JavaScriptSourceRange; }; @@ -150,7 +150,7 @@ interface ElectronIpcFindingContext { /** Electron identity is conditional on an unproved loader. */ readonly loader_authority?: "candidate"; readonly module_key: string | null; - /** Recovered factory runtime; absent in older or unbundled findings. */ + /** Recovered factory runtime; absent when no bundler factory runtime was recovered. */ readonly module_runtime?: string; readonly location: JavaScriptSourceRange; /** Outer syntax invocation when a wrapper produced this underlying IPC call. */ @@ -196,7 +196,7 @@ export interface ElectronSenderValidationFinding { /** Electron identity is conditional on an unproved loader. */ readonly loader_authority?: "candidate"; readonly module_key: string | null; - /** Recovered factory runtime; absent in older or unbundled findings. */ + /** Recovered factory runtime; absent when no bundler factory runtime was recovered. */ readonly module_runtime?: string; readonly location: JavaScriptSourceRange; } @@ -206,7 +206,7 @@ interface ElectronUtilityProcessFindingState { /** Electron identity is conditional on an unproved loader. */ readonly loader_authority?: "candidate"; readonly module_key: string | null; - /** Recovered factory runtime; absent in older or unbundled findings. */ + /** Recovered factory runtime; absent when no bundler factory runtime was recovered. */ readonly module_runtime?: string; readonly location: JavaScriptSourceRange; } @@ -239,7 +239,7 @@ export interface ElectronNativeAddonBindingFinding { /** Electron identity is conditional on an unproved loader. */ readonly loader_authority?: "candidate"; readonly module_key: string | null; - /** Recovered factory runtime; absent in older or unbundled findings. */ + /** Recovered factory runtime; absent when no bundler factory runtime was recovered. */ readonly module_runtime?: string; readonly location: JavaScriptSourceRange; } @@ -271,7 +271,7 @@ export interface ElectronProtocolFinding { /** Electron identity is conditional on an unproved loader. */ readonly loader_authority?: "candidate"; readonly module_key: string | null; - /** Recovered factory runtime; absent in older or unbundled findings. */ + /** Recovered factory runtime; absent when no bundler factory runtime was recovered. */ readonly module_runtime?: string; readonly location: JavaScriptSourceRange; } @@ -311,7 +311,7 @@ export interface ElectronDynamicCodeFinding { */ readonly source_text: ElectronStaticValue; readonly module_key: string | null; - /** Recovered factory runtime; absent in older or unbundled findings. */ + /** Recovered factory runtime; absent when no bundler factory runtime was recovered. */ readonly module_runtime?: string; readonly location: JavaScriptSourceRange; } diff --git a/src/domain/javascript/electronWrappedCallPaths.test.ts b/src/domain/javascript/electronWrappedCallPaths.test.ts index 66cab74c32..a897b95c34 100644 --- a/src/domain/javascript/electronWrappedCallPaths.test.ts +++ b/src/domain/javascript/electronWrappedCallPaths.test.ts @@ -233,8 +233,8 @@ it("preserves every direct observation in a long flat sibling block", () => { expect(result.electron.ipc.map(({ channel }) => channel)).toEqual(channels); expect(result.electron.call_paths ?? []).toEqual([]); expect(result.parse_status).toBe("partial"); - expect(result.analysis_coverage?.syntax.status).toBe("complete"); - expect(result.analysis_coverage?.semantics.unknown_findings).toBeGreaterThan( + expect(result.analysis_coverage.syntax.status).toBe("complete"); + expect(result.analysis_coverage.semantics.unknown_findings).toBeGreaterThan( 0, ); }); @@ -460,8 +460,8 @@ it("preserves an observed empty contextBridge API object", () => { "resolution_basis", ); expect(result.parse_status).toBe("partial"); - expect(result.analysis_coverage?.syntax.status).toBe("complete"); - expect(result.analysis_coverage?.semantics.unknown_findings).toBeGreaterThan( + expect(result.analysis_coverage.syntax.status).toBe("complete"); + expect(result.analysis_coverage.semantics.unknown_findings).toBeGreaterThan( 0, ); }); @@ -887,8 +887,8 @@ it("resolves a site-determined constant channel in place of its dynamic observat ); // The syntax pass's unknown channel is resolved, not left as partial. expect(result.parse_status).toBe("partial"); - expect(result.analysis_coverage?.syntax.status).toBe("complete"); - expect(result.analysis_coverage?.semantics.unknown_findings).toBeGreaterThan( + expect(result.analysis_coverage.syntax.status).toBe("complete"); + expect(result.analysis_coverage.semantics.unknown_findings).toBeGreaterThan( 0, ); }); @@ -908,8 +908,8 @@ it("resolves a site-determined registration whose handler is a named local", () }), ]); expect(result.parse_status).toBe("partial"); - expect(result.analysis_coverage?.syntax.status).toBe("complete"); - expect(result.analysis_coverage?.semantics.unknown_findings).toBeGreaterThan( + expect(result.analysis_coverage.syntax.status).toBe("complete"); + expect(result.analysis_coverage.semantics.unknown_findings).toBeGreaterThan( 0, ); }); @@ -1115,10 +1115,10 @@ it.each(["interface Shape { marker(): void }", "type Shape = typeof marker;"])( ]), ).toEqual([["ch", "wrapper-substitution"]]); expect(result.parse_status).toBe("partial"); - expect(result.analysis_coverage?.syntax.status).toBe("complete"); - expect( - result.analysis_coverage?.semantics.unknown_findings, - ).toBeGreaterThan(0); + expect(result.analysis_coverage.syntax.status).toBe("complete"); + expect(result.analysis_coverage.semantics.unknown_findings).toBeGreaterThan( + 0, + ); }, ); it("resolves a handler a module-level factory call created once in place", () => { @@ -1137,8 +1137,8 @@ it("resolves a handler a module-level factory call created once in place", () => ]), ).toEqual([["ch", "wrapper-substitution"]]); expect(result.parse_status).toBe("partial"); - expect(result.analysis_coverage?.syntax.status).toBe("complete"); - expect(result.analysis_coverage?.semantics.unknown_findings).toBeGreaterThan( + expect(result.analysis_coverage.syntax.status).toBe("complete"); + expect(result.analysis_coverage.semantics.unknown_findings).toBeGreaterThan( 0, ); }); @@ -1199,8 +1199,8 @@ it("resolves a module-level handler in place when the entry binds an unused para }), ]); expect(result.parse_status).toBe("partial"); - expect(result.analysis_coverage?.syntax.status).toBe("complete"); - expect(result.analysis_coverage?.semantics.unknown_findings).toBeGreaterThan( + expect(result.analysis_coverage.syntax.status).toBe("complete"); + expect(result.analysis_coverage.semantics.unknown_findings).toBeGreaterThan( 0, ); }); diff --git a/src/domain/javascript/javascriptFactoryExportRoles.test.ts b/src/domain/javascript/javascriptFactoryExportRoles.test.ts index 844b54e472..5d92ef773d 100644 --- a/src/domain/javascript/javascriptFactoryExportRoles.test.ts +++ b/src/domain/javascript/javascriptFactoryExportRoles.test.ts @@ -136,7 +136,7 @@ it("binds a repeated sloppy parameter name to its last argument", () => { ": function (e, t, e) { e.exports = {ghost: 1}; t.second = 1; }"; const analysis = analyzeJavaScriptStaticSource(webpackChunk(factory)); // Module source is strict, so the parser recovers from the name clash. - expect(analysis.analysis_coverage?.syntax.status).toBe("recovered"); + expect(analysis.analysis_coverage.syntax.status).toBe("recovered"); expect(analysis.bundler_registrations[0]?.modules[0]).toMatchObject({ exports: conventionExports(factory), factory_require_name: "e", @@ -198,7 +198,7 @@ it.each([ const analysis = analyzeJavaScriptStaticSource(webpackChunk(factory)); expect(analysis.bundler_registrations[0]?.modules).toHaveLength(1); expect(analysis.parse_status).toBe("partial"); - expect(analysis.analysis_coverage?.semantics.unknown_findings).toBe(1); + expect(analysis.analysis_coverage.semantics.unknown_findings).toBe(1); }); /** Exports plus every loader call made under Webpack's calling convention. */ diff --git a/src/domain/javascript/javascriptReturnedReferenceCoverage.test.ts b/src/domain/javascript/javascriptReturnedReferenceCoverage.test.ts index fc82b874a0..43c4dcea98 100644 --- a/src/domain/javascript/javascriptReturnedReferenceCoverage.test.ts +++ b/src/domain/javascript/javascriptReturnedReferenceCoverage.test.ts @@ -21,7 +21,7 @@ it("preserves possible ambient effects and discloses projection widening in sour expect(ir.limitations).toContain(RETURNED_REFERENCE_WIDENING_LIMITATION); const facts = analyzeJavaScriptStaticSource(source); expect(facts.limitations).toContain(RETURNED_REFERENCE_WIDENING_LIMITATION); - expect(facts.analysis_coverage?.semantics.uncertainty).toContain( + expect(facts.analysis_coverage.semantics.uncertainty).toContain( "returned-reference-widening", ); expect(facts.endpoints).toEqual( diff --git a/src/domain/javascript/javascriptRuntimeObservation.ts b/src/domain/javascript/javascriptRuntimeObservation.ts index 603ad6fe4c..0814fe4e45 100644 --- a/src/domain/javascript/javascriptRuntimeObservation.ts +++ b/src/domain/javascript/javascriptRuntimeObservation.ts @@ -190,10 +190,7 @@ export const javascriptRuntimeObservationSchema = z.strictObject({ parse_failed_total: z .int() .min(0) - .optional() - .describe( - "Valid scriptFailedToParse events observed; absent in legacy snapshots.", - ), + .describe("Valid scriptFailedToParse events observed."), excluded: z.strictObject({ unsupported_location: z.int().min(0), invalid_protocol_value: z.int().min(0), diff --git a/src/domain/javascript/javascriptRuntimeReconciliationActive.ts b/src/domain/javascript/javascriptRuntimeReconciliationActive.ts index 8baea0ce6d..6f89cad3ad 100644 --- a/src/domain/javascript/javascriptRuntimeReconciliationActive.ts +++ b/src/domain/javascript/javascriptRuntimeReconciliationActive.ts @@ -43,29 +43,22 @@ export const parseActiveElectronCapture = ( const parameters = parseInputAtPath( z .object({ - application_path: absolutePathSchema, - application_root: absolutePathSchema.optional(), - resolved_paths: z - .strictObject({ - executable_path: absolutePathSchema, - application_path: absolutePathSchema, - application_root: absolutePathSchema, - }) - .optional(), + resolved_paths: z.strictObject({ + executable_path: absolutePathSchema, + application_path: absolutePathSchema, + application_root: absolutePathSchema, + }), }) .passthrough(), evidence.parameters, [...path, "parameters"], ); - // Older captures committed canonical paths directly in parameters. New - // captures keep request spelling separate from the admitted execution paths. - const executionPaths = parameters.resolved_paths ?? parameters; + // Request spelling stays in the scenario; the admitted execution paths are + // committed separately and must agree with the observed application. + const executionPaths = parameters.resolved_paths; if ( - executionPaths.application_root === undefined || result.application.application_path !== executionPaths.application_path || - (parameters.resolved_paths !== undefined && - result.application.executable_path !== - parameters.resolved_paths.executable_path) || + result.application.executable_path !== executionPaths.executable_path || !isPathWithinRoot( executionPaths.application_root, result.application.application_path, diff --git a/src/domain/javascript/javascriptSemanticPrecision.test.ts b/src/domain/javascript/javascriptSemanticPrecision.test.ts index cb02475f98..69fff2efa0 100644 --- a/src/domain/javascript/javascriptSemanticPrecision.test.ts +++ b/src/domain/javascript/javascriptSemanticPrecision.test.ts @@ -66,7 +66,7 @@ it("distinguishes wrapper work recovery from unchanged unsupported or cyclic syn const source = `const e = require("electron"); e.ipcMain.on("first", event => event.sender.copy());`; const bounded = analyzeJavaScriptStaticSource(source, { wrapper_visits: 1 }); expect( - bounded.analysis_coverage?.examination.electron_call_paths_limited, + bounded.analysis_coverage.examination.electron_call_paths_limited, ).toBe(true); expect(bounded.limitations).toEqual( expect.arrayContaining([ @@ -77,7 +77,7 @@ it("distinguishes wrapper work recovery from unchanged unsupported or cyclic syn wrapper_visits: 10_000, }); expect( - recovered.analysis_coverage?.examination.electron_call_paths_limited, + recovered.analysis_coverage.examination.electron_call_paths_limited, ).toBe(false); expect((recovered.electron.call_paths ?? []).length).toBeGreaterThan(0); const cycle = analyzeJavaScriptSemantics( diff --git a/src/domain/javascript/javascriptStaticAnalysisAssignedRequire.test.ts b/src/domain/javascript/javascriptStaticAnalysisAssignedRequire.test.ts index 98ba4db6c8..48886e3ee6 100644 --- a/src/domain/javascript/javascriptStaticAnalysisAssignedRequire.test.ts +++ b/src/domain/javascript/javascriptStaticAnalysisAssignedRequire.test.ts @@ -268,7 +268,7 @@ it.each([true, false])( expect.objectContaining({ kind: "require", specifier: null }), ]); expect( - analysis.analysis_coverage?.examination.semantic_resource_limits, + analysis.analysis_coverage.examination.semantic_resource_limits, ).toContain("alias-selections"); }, ); @@ -289,7 +289,7 @@ it.each(["defineProperty", "assign"])( expect.objectContaining({ kind: "require", specifier: null }), ]); expect( - analysis.analysis_coverage?.examination.semantic_resource_limits, + analysis.analysis_coverage.examination.semantic_resource_limits, ).toContain("alias-selections"); }, ); @@ -306,7 +306,7 @@ it.each(["(flag?process.foo:r)", "(flag?r:process.foo)"])( expect.objectContaining({ kind: "require", specifier: null }), ]); expect( - analysis.analysis_coverage?.examination.semantic_resource_limits, + analysis.analysis_coverage.examination.semantic_resource_limits, ).toContain("alias-selections"); }, ); diff --git a/src/domain/javascript/javascriptStaticAnalysisTypes.ts b/src/domain/javascript/javascriptStaticAnalysisTypes.ts index ac1f559554..b249be50f7 100644 --- a/src/domain/javascript/javascriptStaticAnalysisTypes.ts +++ b/src/domain/javascript/javascriptStaticAnalysisTypes.ts @@ -40,7 +40,7 @@ interface JavaScriptStaticReferenceState { | "worker" | "service-worker"; readonly module_key: string | null; - /** Recovered factory runtime; absent in older or unbundled findings. */ + /** Recovered factory runtime; absent when no bundler factory runtime was recovered. */ readonly module_runtime?: string; /** Source-relative filename selected by a proven createRequire factory. */ readonly resolution_base_path?: string; @@ -75,7 +75,7 @@ export interface JavaScriptStaticEndpoint { /** The request target is unresolved source text rather than an exact value. */ readonly resolution?: "partial"; readonly module_key: string | null; - /** Recovered factory runtime; absent in older or unbundled findings. */ + /** Recovered factory runtime; absent when no bundler factory runtime was recovered. */ readonly module_runtime?: string; readonly location: JavaScriptSourceRange; } @@ -92,7 +92,7 @@ export interface JavaScriptStaticStorage { readonly name: string | null; readonly mechanism: string; readonly module_key: string | null; - /** Recovered factory runtime; absent in older or unbundled findings. */ + /** Recovered factory runtime; absent when no bundler factory runtime was recovered. */ readonly module_runtime?: string; readonly location: JavaScriptSourceRange; } @@ -137,7 +137,7 @@ export interface JavaScriptRolePath { readonly path_base?: "source-directory"; readonly mechanism: string; readonly module_key: string | null; - /** Recovered factory runtime; absent in older or unbundled findings. */ + /** Recovered factory runtime; absent when no bundler factory runtime was recovered. */ readonly module_runtime?: string; readonly location: JavaScriptSourceRange; } @@ -146,13 +146,15 @@ export interface JavaScriptRolePath { export interface JavaScriptStaticAnalysis { /** Established overall summary; syntax alone is reported in analysis_coverage. */ readonly parse_status: "complete" | "partial" | "failed"; - /** Historical facts omit this measurement; consumers must not infer it. */ - readonly analysis_coverage?: JavaScriptStaticCoverage; + readonly analysis_coverage: JavaScriptStaticCoverage; readonly parse_error_count: number; readonly visited_ast_nodes: number; readonly references: readonly JavaScriptStaticReference[]; readonly endpoints: readonly JavaScriptStaticEndpoint[]; - /** Missing in historical analyses; absence means unmeasured route coverage. */ + /** + * Absent when a worker checkpoint could not retain the route facts within + * its byte ceiling; absence means unmeasured route coverage. + */ readonly routes?: JavaScriptRouteSourceFacts; readonly storage: readonly JavaScriptStaticStorage[]; readonly bundler_registrations: readonly JavaScriptBundlerRegistration[]; diff --git a/src/domain/javascript/javascriptStaticCoverage.test.ts b/src/domain/javascript/javascriptStaticCoverage.test.ts index d3e1619459..0f77fd74f8 100644 --- a/src/domain/javascript/javascriptStaticCoverage.test.ts +++ b/src/domain/javascript/javascriptStaticCoverage.test.ts @@ -30,7 +30,7 @@ it("separates dynamic semantic uncertainty from completed syntax and examination it("distinguishes recovered syntax from unparseable source without inventing an error total", () => { const recovered = analyzeJavaScriptStaticSource("let value; let value;"); expect(recovered.parse_status).toBe("partial"); - expect(recovered.analysis_coverage?.syntax).toEqual({ + expect(recovered.analysis_coverage.syntax).toEqual({ status: "recovered", error_count: recovered.parse_error_count, }); @@ -46,22 +46,22 @@ it("distinguishes recovered syntax from unparseable source without inventing an it("keeps framework applicability unknown without positive Electron evidence", () => { const ordinary = analyzeJavaScriptStaticSource("export const value = 1;"); expect(ordinary.parse_status).toBe("complete"); - expect(ordinary.analysis_coverage?.applicability.electron).toBe("unknown"); + expect(ordinary.analysis_coverage.applicability.electron).toBe("unknown"); const electron = analyzeCommonJsStaticFixture( "const {ipcMain}=require('electron');", ); - expect(electron.analysis_coverage?.applicability.electron).toBe("observed"); + expect(electron.analysis_coverage.applicability.electron).toBe("observed"); }); it("reports compiler-dependent module side effects independently of complete syntax", () => { const result = analyzeJavaScriptStaticSource( "import { type Config } from './config';", ); - expect(result.analysis_coverage?.syntax).toEqual({ + expect(result.analysis_coverage.syntax).toEqual({ status: "complete", error_count: 0, }); - expect(result.analysis_coverage?.semantics.uncertainty).toContain( + expect(result.analysis_coverage.semantics.uncertainty).toContain( "type-only-module-side-effect", ); }); @@ -81,7 +81,7 @@ it("retains typed examination limits alongside successfully parsed source", () = it("preserves the legacy summary responsibility without relabeling independent limitations", () => { const base = analyzeJavaScriptStaticSource( "export const value = 1;", - ).analysis_coverage!; + ).analysis_coverage; expect( javaScriptStaticParseStatus({ ...base, diff --git a/src/domain/javascript/javascriptStaticPathResolution.test.ts b/src/domain/javascript/javascriptStaticPathResolution.test.ts index 2f13040109..cdb8e6f4f4 100644 --- a/src/domain/javascript/javascriptStaticPathResolution.test.ts +++ b/src/domain/javascript/javascriptStaticPathResolution.test.ts @@ -23,7 +23,7 @@ it.each([ if (path === null) { expect(analysis.role_paths).toEqual([]); expect( - analysis.analysis_coverage?.semantics.unknown_findings, + analysis.analysis_coverage.semantics.unknown_findings, ).toBeGreaterThan(0); } else { expect(analysis.role_paths).toMatchObject([ @@ -42,7 +42,7 @@ it.each(["loadFile", "loadURL"])( ); expect(analysis.role_paths).toEqual([]); expect( - analysis.analysis_coverage?.semantics.unknown_findings, + analysis.analysis_coverage.semantics.unknown_findings, ).toBeGreaterThan(0); expect(analysis.limitations).toContain( "One or more static keys, expressions, or Electron boundary values were dynamic and remain unknown.", diff --git a/src/domain/managed/managedArtifact.ts b/src/domain/managed/managedArtifact.ts index 1025041992..33bd640007 100644 --- a/src/domain/managed/managedArtifact.ts +++ b/src/domain/managed/managedArtifact.ts @@ -507,68 +507,90 @@ export const managedArtifactInspectionSchema = z.object({ limitations: z.array(z.string()), }); +const UNEXAMINED_MEMBER_COLLECTIONS = [ + "fields", + "methods", + "member_refs", + "call_edges", + "field_accesses", +] as const; + /** Provider-neutral, execution-free metadata/signature/IL member inspection. */ -export const managedMemberInspectionSchema = z.object({ - signature_resolution: z - .enum(["type-names-v2"]) - .nullable() - .describe( - "Signature type-name resolution was examined, including unresolved operands, and readable operand names are rendered; null means member decoding exceeded capacity and no members were examined.", - ), - artifact: managedArtifactReferenceSchema, - module: moduleIdentitySchema.nullable(), - assembly: assemblyIdentitySchema.nullable(), - metadata: managedMetadataSummarySchema, - identity_scope: managedTokenIdentityScopeSchema, - types: z.array(managedTypeSchema), - // False means a NestedClass row was unreadable or invalid, not that no - // nested types exist. - nesting_read: z - .boolean() - .describe( - "Whether all NestedClass rows were read and valid; false means nesting is incomplete. Individual name digests can remain unresolved for missing, cyclic or over-deep enclosing chains.", - ), - // Null means the table was not examined (member decoding exceeded capacity), - // not that it was empty. - exported_types: z.array(managedExportedTypeSchema).nullable(), - fields: z.array(managedFieldSchema), - methods: z.array(managedMethodSchema), - member_refs: z.array(managedMemberReferenceSchema), - call_edges: z.array(managedCallEdgeSchema), - field_accesses: z.array(managedFieldAccessSchema), - // Distinct #US literals loaded by ldstr in the inspected method bodies, in - // token order, with their own coverage: #US issues never enter the member - // coverage. null means they were not examined, not that there were none. - user_strings: z - .object({ - state: z.enum(["complete", "partial"]), - literals: z.array(managedUserStringSchema), +export const managedMemberInspectionSchema = z + .object({ + signature_resolution: z + .enum(["type-names-v2"]) + .nullable() + .describe( + "Signature type-name resolution was examined, including unresolved operands, and readable operand names are rendered; null means member decoding exceeded capacity and no members were examined.", + ), + artifact: managedArtifactReferenceSchema, + module: moduleIdentitySchema.nullable(), + assembly: assemblyIdentitySchema.nullable(), + metadata: managedMetadataSummarySchema, + identity_scope: managedTokenIdentityScopeSchema, + types: z.array(managedTypeSchema), + // False means a NestedClass row was unreadable or invalid, not that no + // nested types exist. + nesting_read: z + .boolean() + .describe( + "Whether all NestedClass rows were read and valid; false means nesting is incomplete. Individual name digests can remain unresolved for missing, cyclic or over-deep enclosing chains.", + ), + // Null means the table was not examined (member decoding exceeded capacity), + // not that it was empty. + exported_types: z.array(managedExportedTypeSchema).nullable(), + fields: z.array(managedFieldSchema), + methods: z.array(managedMethodSchema), + member_refs: z.array(managedMemberReferenceSchema), + call_edges: z.array(managedCallEdgeSchema), + field_accesses: z.array(managedFieldAccessSchema), + // Distinct #US literals loaded by ldstr in the inspected method bodies, in + // token order, with their own coverage: #US issues never enter the member + // coverage. null means they were not examined, not that there were none. + user_strings: z + .object({ + state: z.enum(["complete", "partial"]), + literals: z.array(managedUserStringSchema), + issues: z.array(managedParseIssueSchema), + }) + .nullable(), + /** Caller-selected declaring types; null when every type was inspected. */ + selection: z + .object({ + type_names: z.array(z.string().min(1)).min(1), + unmatched_type_names: z.array(z.string().min(1)), + }) + .nullable(), + method_rows: z + .object({ + offset: z.int().nonnegative(), + count: z.int().nonnegative(), + total: z.int().nonnegative(), + }) + .nullable() + .describe( + "Examined zero-based MethodDef row interval before declaring-type selection; null means the row scope was not recorded. Row coordinates are build-local and cannot prove cross-build member absence for a page.", + ), + coverage: z.object({ + state: z.enum(["complete", "partial", "unavailable"]), issues: z.array(managedParseIssueSchema), - }) - .nullable(), - /** Caller-selected declaring types; null when every type was inspected. */ - selection: z - .object({ - type_names: z.array(z.string().min(1)).min(1), - unmatched_type_names: z.array(z.string().min(1)), - }) - .nullable(), - method_rows: z - .object({ - offset: z.int().nonnegative(), - count: z.int().nonnegative(), - total: z.int().nonnegative(), - }) - .nullable() - .describe( - "Examined zero-based MethodDef row interval before declaring-type selection; null means the row scope was not recorded. Row coordinates are build-local and cannot prove cross-build member absence for a page.", - ), - coverage: z.object({ - state: z.enum(["complete", "partial", "unavailable"]), - issues: z.array(managedParseIssueSchema), - }), - limitations: z.array(z.string()), -}); + }), + limitations: z.array(z.string()), + }) + .superRefine((result, context) => { + if (result.signature_resolution !== null) return; + // Null resolution means member decoding exceeded capacity, so no member was + // examined; a member beside it would carry an unattested signature digest. + for (const key of UNEXAMINED_MEMBER_COLLECTIONS) + if (result[key].length > 0) + context.addIssue({ + code: "custom", + path: [key], + message: + "Members require signature_resolution; null resolution means no members were examined.", + }); + }); /** Provider-neutral managed/native boundary observations from PE/CLI metadata. */ export const managedNativeBoundaryInspectionSchema = z.object({ diff --git a/src/domain/managed/managedMemberComparison.ts b/src/domain/managed/managedMemberComparison.ts index bf912435db..ef429a00fb 100644 --- a/src/domain/managed/managedMemberComparison.ts +++ b/src/domain/managed/managedMemberComparison.ts @@ -23,7 +23,6 @@ import { buildMethodItems, } from "./managedMemberComparisonItems.js"; import { keyMembers } from "./managedMemberComparisonMatch.js"; -import { hasSignatureResolution } from "./managedMemberSignatureIdentity.js"; import { digestSchema, prefixedDigestSchema } from "../digests.js"; import { nonEmptyTextSchema } from "../textSchemas.js"; @@ -289,9 +288,6 @@ export const compareManagedMembers = ( right.result.metadata.status === "complete" && hasCompleteMethodRows(right.result), scope, - signatureResolutionExamined: - hasSignatureResolution(left.result) && - hasSignatureResolution(right.result), sameArtifact: left.result.artifact.sha256 === right.result.artifact.sha256, leftAssembly: left.result.assembly, rightAssembly: right.result.assembly, diff --git a/src/domain/managed/managedMemberComparisonCoverage.ts b/src/domain/managed/managedMemberComparisonCoverage.ts index 59afdefb58..d039e012ec 100644 --- a/src/domain/managed/managedMemberComparisonCoverage.ts +++ b/src/domain/managed/managedMemberComparisonCoverage.ts @@ -3,7 +3,6 @@ import type { ManagedMemberComparisonSide, } from "./managedMemberComparison.js"; import type { ManagedMemberInspection } from "./managedArtifact.js"; -import { hasSignatureResolution } from "./managedMemberSignatureIdentity.js"; interface ComparisonCoverageInput { readonly left: ManagedMemberInspection; @@ -240,11 +239,7 @@ export const comparisonLimitations = ( signature.resolved_sha256 !== null && signature.resolved_sha256 !== signature.raw_sha256, ); - if ( - hasSignatureResolution(left) && - hasSignatureResolution(right) && - (namesTypes(left) || namesTypes(right)) - ) + if (namesTypes(left) || namesTypes(right)) limitations.push( "Signature type operands compare by namespace, name, and enclosing names only; defining assemblies and CLR type identity are not established by this comparison.", ); @@ -271,10 +266,6 @@ export const comparisonLimitations = ( limitations.push( "At least one observation lacks a complete MethodDef row inventory; paged or unrecorded method scope cannot establish cross-build method absence. Row intervals are reported in method_rows and describe build-local selections.", ); - if (!hasSignatureResolution(left) || !hasSignatureResolution(right)) - limitations.push( - "At least one managed member observation does not attest signature type-name resolution, so signatures compare by raw bytes, which name types by build-local metadata row.", - ); if (left.exported_types === null || right.exported_types === null) limitations.push( "At least one managed member observation did not examine ExportedType rows; its exported and forwarded types are unknown.", diff --git a/src/domain/managed/managedMemberComparisonItems.ts b/src/domain/managed/managedMemberComparisonItems.ts index 7057b6d68c..cfad03973c 100644 --- a/src/domain/managed/managedMemberComparisonItems.ts +++ b/src/domain/managed/managedMemberComparisonItems.ts @@ -40,8 +40,6 @@ interface ComparisonItemContext { readonly leftMethodsComplete: boolean; readonly rightMethodsComplete: boolean; readonly scope: ManagedComparisonScope; - /** Whether matching keyed signatures by resolved digests, not raw bytes. */ - readonly signatureResolutionExamined: boolean; readonly sameArtifact: boolean; readonly leftAssembly: ManagedMemberInspection["assembly"]; readonly rightAssembly: ManagedMemberInspection["assembly"]; @@ -60,11 +58,9 @@ const inventoryCovers = ( /** * Declared type and name of each unpaired member, per side, whose signature - * was not decoded, or was decoded but not resolved while matching keyed - * resolved signatures. + * was not decoded, or was decoded but not resolved. */ interface UndecodedOneSidedNames { - readonly resolved: boolean; readonly undecoded: Readonly>>; readonly unresolved: Readonly>>; readonly unknownOwners: Readonly< @@ -530,13 +526,13 @@ const absenceLimitations = ( `counterpart-signature-not-decoded: The ${opposite.opposite} ${opposite.inventory} inventory has an unpaired member with the same declared type and name whose signature was not decoded, so it may be this member with a changed signature.`, ] : []), - ...(unresolved(member, opposite.unpaired.resolved) + ...(unresolved(member) ? [ `signature-not-resolved: The member's signature names a type REA could not name, so it was compared by raw bytes, which name types by build-local metadata row; a counterpart whose referenced type moved rows could not be found.`, ] : []), ...(member.signature.parse_status === "decoded" && - !unresolved(member, opposite.unpaired.resolved) && + !unresolved(member) && opposite.unpaired.unresolved[opposite.opposite].has(identity) ? [ `counterpart-signature-not-resolved: The ${opposite.opposite} ${opposite.inventory} inventory has an unpaired member with the same declared type and name whose signature names a type REA could not name, so it may be this member.`, @@ -545,8 +541,7 @@ const absenceLimitations = ( ]; /** A known signature form whose type operands still compare by raw bytes. */ -const unresolved = (member: Method | Field, resolved: boolean): boolean => - resolved && +const unresolved = (member: Method | Field): boolean => member.signature.kind !== "unknown" && member.signature.resolved_sha256 === null; @@ -554,7 +549,6 @@ const unresolved = (member: Method | Field, resolved: boolean): boolean => const pairedSignatureLimitations = ( left: Method | Field, right: Method | Field, - examined: boolean, ): string[] => { if ( left.signature.parse_status === "malformed" || @@ -563,7 +557,7 @@ const pairedSignatureLimitations = ( return [ "signature-malformed: At least one signature is malformed; equal signature bytes do not establish an unchanged member signature.", ]; - return unresolved(left, examined) || unresolved(right, examined) + return unresolved(left) || unresolved(right) ? [ "signature-not-resolved: At least one signature names a type REA could not resolve; equal build-local row bytes do not establish equivalent signature types.", ] @@ -580,17 +574,14 @@ interface Unpaired { readonly identityUnavailable: boolean; } -const undecodedOneSidedNames = ( - members: { - readonly leftOnly: readonly Unpaired[]; - readonly rightOnly: readonly Unpaired[]; - readonly ambiguous: readonly { - readonly left: readonly Unpaired[]; - readonly right: readonly Unpaired[]; - }[]; - }, - resolved: boolean, -): UndecodedOneSidedNames => { +const undecodedOneSidedNames = (members: { + readonly leftOnly: readonly Unpaired[]; + readonly rightOnly: readonly Unpaired[]; + readonly ambiguous: readonly { + readonly left: readonly Unpaired[]; + readonly right: readonly Unpaired[]; + }[]; +}): UndecodedOneSidedNames => { const sides = { left: [ ...members.leftOnly, @@ -610,9 +601,7 @@ const undecodedOneSidedNames = ( ); const undecoded = (item: Method | Field) => item.signature.parse_status !== "decoded"; - const notResolved = (item: Method | Field) => unresolved(item, resolved); return { - resolved, unknownOwners: { left: new Set( sides.left.filter((x) => x.identityUnavailable).map((x) => x.item.name), @@ -628,8 +617,8 @@ const undecodedOneSidedNames = ( right: names(sides.right, undecoded), }, unresolved: { - left: names(sides.left, notResolved), - right: names(sides.right, notResolved), + left: names(sides.left, unresolved), + right: names(sides.right, unresolved), }, }; }; @@ -738,7 +727,6 @@ export const buildMethodItems = ( const signatureLimitations = pairedSignatureLimitations( pair.left.item, pair.right.item, - context.signatureResolutionExamined, ); const locals = compareLocalSignatures( pair.left.item, @@ -871,10 +859,7 @@ export const buildMethodItems = ( ], }); } - const undecoded = undecodedOneSidedNames( - matches, - context.signatureResolutionExamined, - ); + const undecoded = undecodedOneSidedNames(matches); for (const item of matches.leftOnly) items.push( methodOnlyItem( @@ -907,7 +892,6 @@ export const buildFieldItems = ( const signatureLimitations = pairedSignatureLimitations( pair.left.item, pair.right.item, - context.signatureResolutionExamined, ); const changed = signatureIdentity(pair.left.item.signature) !== @@ -968,10 +952,7 @@ export const buildFieldItems = ( ), ], }); - const undecoded = undecodedOneSidedNames( - matches, - context.signatureResolutionExamined, - ); + const undecoded = undecodedOneSidedNames(matches); for (const item of matches.leftOnly) items.push( fieldOnlyItem( diff --git a/src/domain/managed/managedMemberComparisonMatch.ts b/src/domain/managed/managedMemberComparisonMatch.ts index 41d7c09966..fdd65014a6 100644 --- a/src/domain/managed/managedMemberComparisonMatch.ts +++ b/src/domain/managed/managedMemberComparisonMatch.ts @@ -12,10 +12,7 @@ import type { ManagedMemberComparisonResult, ManagedMemberComparisonSide, } from "./managedMemberComparison.js"; -import { - comparableSides, - signatureIdentity, -} from "./managedMemberSignatureIdentity.js"; +import { signatureIdentity } from "./managedMemberSignatureIdentity.js"; type Method = ManagedMemberInspection["methods"][number]; type Field = ManagedMemberInspection["fields"][number]; @@ -506,14 +503,13 @@ const matchObserved = ( }; export const keyMembers = ( - observedLeft: ManagedMemberComparisonSide, - observedRight: ManagedMemberComparisonSide, + left: ManagedMemberComparisonSide, + right: ManagedMemberComparisonSide, scope: ManagedComparisonScope, ): { readonly methodMatches: ReturnType; readonly fieldMatches: ReturnType; } => { - const [left, right] = comparableSides(observedLeft, observedRight); const declared = ( inspection: ManagedMemberInspection, names: ReadonlyMap, diff --git a/src/domain/managed/managedMemberSignatureIdentity.ts b/src/domain/managed/managedMemberSignatureIdentity.ts index f04efb1651..04ed00eee7 100644 --- a/src/domain/managed/managedMemberSignatureIdentity.ts +++ b/src/domain/managed/managedMemberSignatureIdentity.ts @@ -1,5 +1,4 @@ import type { ManagedMemberInspection } from "./managedArtifact.js"; -import type { ManagedMemberComparisonSide } from "./managedMemberComparison.js"; type Method = ManagedMemberInspection["methods"][number]; type Field = ManagedMemberInspection["fields"][number]; @@ -19,46 +18,3 @@ export const signatureIdentity = ({ resolved_sha256 === null ? `raw:${raw_sha256}` : `resolved:${resolved_sha256}`; - -/** - * The producer attests examination independently of whether it could resolve - * any operands. A current inventory of only unresolved types is not legacy. - */ -export const hasSignatureResolution = ( - result: ManagedMemberInspection, -): boolean => - result.signature_resolution !== null || - (result.methods.length === 0 && result.fields.length === 0); - -const withoutResolution = ( - members: readonly Member[], -): Member[] => - members.map((member) => ({ - ...member, - signature: { ...member.signature, resolved_sha256: null }, - })); - -/** - * Compare raw signatures on both sides when either observation does not - * attest resolved digests; a resolved digest never equals a raw one for a signature - * that names a type, so mixing them would lose pairs a raw comparison finds. - */ -export const comparableSides = ( - left: ManagedMemberComparisonSide, - right: ManagedMemberComparisonSide, -): readonly [ManagedMemberComparisonSide, ManagedMemberComparisonSide] => { - if ( - hasSignatureResolution(left.result) && - hasSignatureResolution(right.result) - ) - return [left, right]; - const raw = (side: ManagedMemberComparisonSide) => ({ - ...side, - result: { - ...side.result, - methods: withoutResolution(side.result.methods), - fields: withoutResolution(side.result.fields), - }, - }); - return [raw(left), raw(right)]; -}; diff --git a/src/domain/referenceSourceGraph.test.ts b/src/domain/referenceSourceGraph.test.ts index 80a3c7dc61..3f17a8c10c 100644 --- a/src/domain/referenceSourceGraph.test.ts +++ b/src/domain/referenceSourceGraph.test.ts @@ -166,6 +166,7 @@ const registerSourceCommitmentTests = (): void => { input.exclusions = [ { path: "private.env", + entry_kind: "file", reason: "configured-secret", pattern: ".env", }, @@ -187,7 +188,12 @@ const registerSourceCommitmentTests = (): void => { ...graphInput(), inventory_state: "partial", exclusions: [ - { path: "private.env", reason: "configured-secret", pattern }, + { + path: "private.env", + entry_kind: "file", + reason: "configured-secret", + pattern, + }, ], }); expect(graphWith(".env").root_sha256).not.toBe( @@ -427,6 +433,7 @@ describe("partial historical source graphs", () => { exclusions: [ { path: "secret", + entry_kind: "file" as const, reason: "configured-secret" as const, pattern: "secret", }, @@ -560,10 +567,8 @@ describe("historical source graph excluded symlink targets", () => { path: "secret.txt", reason: "configured-secret", pattern: "secret.txt", - }; - expect(() => createHistoricalSourceGraph(input)).toThrow( - /recorded exclusion/u, - ); + } as (typeof input.exclusions)[number]; + expect(() => createHistoricalSourceGraph(input)).toThrow(/entry_kind/u); }); }); diff --git a/src/domain/referenceSourceGraph.ts b/src/domain/referenceSourceGraph.ts index 6812c2078b..625ac74921 100644 --- a/src/domain/referenceSourceGraph.ts +++ b/src/domain/referenceSourceGraph.ts @@ -135,9 +135,7 @@ const parseFailureSchema = z.strictObject({ const exclusionSchema = z.discriminatedUnion("reason", [ z.strictObject({ path: relativePathSchema, - entry_kind: z - .enum(["file", "directory", "symlink", "other", "unknown"]) - .exactOptional(), + entry_kind: z.enum(["file", "directory", "symlink", "other", "unknown"]), reason: z.enum([ "configured-secret", "project-ignored", @@ -148,9 +146,7 @@ const exclusionSchema = z.discriminatedUnion("reason", [ }), z.strictObject({ path: relativePathSchema, - entry_kind: z - .enum(["file", "directory", "symlink", "other", "unknown"]) - .exactOptional(), + entry_kind: z.enum(["file", "directory", "symlink", "other", "unknown"]), reason: z.enum(["symlink-escape", "unreadable"]), }), ]); @@ -366,7 +362,7 @@ const checkSymlinks = ( ); const excludedKinds = new Map< string, - Set<"file" | "directory" | "symlink" | "other" | "unknown" | undefined> + Set<"file" | "directory" | "symlink" | "other" | "unknown"> >(); for (const { path, entry_kind } of graph.exclusions) { const kinds = excludedKinds.get(path) ?? new Set(); diff --git a/src/domain/webBundleAnalysis.ts b/src/domain/webBundleAnalysis.ts index 29ff270d0e..ca6a1ac541 100644 --- a/src/domain/webBundleAnalysis.ts +++ b/src/domain/webBundleAnalysis.ts @@ -281,8 +281,8 @@ const originalModuleEdgeSchema = z.object({ resolved_source: z.string().nullable(), }); const sourceMapMappingSchema = z.object({ - source_index: z.int().min(0).optional(), - declaration_index: z.int().min(0).optional(), + source_index: z.int().min(0), + declaration_index: z.int().min(0), generated_line: z.int().min(1), generated_column: z.int().min(0), source: z.string().nullable(), @@ -293,8 +293,8 @@ const sourceMapMappingSchema = z.object({ const sourceMapContextShape = { script_key: z.string(), declared_url: z.string(), - // Older saved observations omit this field; current fetches emit string/null. - effective_url: z.string().nullable().optional(), + // Null when no response was observed within the approved origins. + effective_url: z.string().nullable(), }; const parsedSourceMapShape = { artifact: webTextArtifactSchema, @@ -324,15 +324,27 @@ const sourceMapSchema = z.union([ z.object({ ...sourceMapContextShape, ...parsedSourceMapShape, - status: z.enum(["fetch_failed", "invalid"]), + status: z.literal("fetch_failed"), artifact: z.null(), - /** Older observations omit this; completed bytes need it only when text is absent. */ + /** Present only when the complete response body was read. */ response_identity: responseIdentitySchema.exactOptional(), original_sources: emptyArraySchema, original_module_edges: emptyArraySchema, mappings: emptyArraySchema, limitation: z.string(), }), + z.object({ + ...sourceMapContextShape, + ...parsedSourceMapShape, + // A map is judged invalid only after its complete body was read. + status: z.literal("invalid"), + artifact: z.null(), + response_identity: responseIdentitySchema, + original_sources: emptyArraySchema, + original_module_edges: emptyArraySchema, + mappings: emptyArraySchema, + limitation: z.string(), + }), z.object({ ...sourceMapContextShape, status: z.literal("policy_filtered"), @@ -436,9 +448,8 @@ export const webBundleAnalysisSchema = z.object({ route_inventory: javaScriptRouteInventorySchema.exactOptional(), capture: z.object({ target_url: z.string(), - // Older saved observations omit this field; current analyses retain the - // validated HTTP(S) target origin or null when no browser origin exists. - target_origin: recordedBrowserOriginSchema.nullable().optional(), + // The validated HTTP(S) target origin, or null when no browser origin exists. + target_origin: recordedBrowserOriginSchema.nullable(), scripts_observed: z.int().min(0), scripts_analyzed: z.int().min(0), source_artifacts: z.array(webTextArtifactSummarySchema), @@ -481,9 +492,8 @@ export const webBundleAnalysisSchema = z.object({ ), schema_property_names_coverage: z .enum(["complete", "partial", "unknown", "not_present"]) - .optional() .describe( - "Coverage of the schema property-name projection. Missing means unknown for historical observations. Not a schema-validity result.", + "Coverage of the schema property-name projection. Not a schema-validity result.", ), trust: z.literal("page-declared-untrusted"), location: sourceLocationSchema, diff --git a/src/domain/webBundleAnalyzer.test.ts b/src/domain/webBundleAnalyzer.test.ts index a5540116bf..b1912b419f 100644 --- a/src/domain/webBundleAnalyzer.test.ts +++ b/src/domain/webBundleAnalyzer.test.ts @@ -1801,32 +1801,36 @@ describe("web metadata key semantics", () => { }, ]); }); +}); - it("keeps missing coverage absent when parsing historical observations", () => { - const analyzed = analyzeWebBundleFixture( - inspection( - `document.modelContext.registerTool({ name: "legacy", inputSchema: { properties: {} } });`, - ), - ); - const declaration = analyzed.observations.webmcp_declarations[0]; - expect(declaration).toBeDefined(); - if (declaration === undefined) throw new Error("Expected declaration"); - const { schema_property_names_coverage: _coverage, ...legacyDeclaration } = - declaration; - const parsed = webBundleAnalysisSchema.parse({ +it("refuses a declaration without its schema property-name coverage", () => { + const analyzed = analyzeWebBundleFixture( + inspection( + `document.modelContext.registerTool({ name: "uncovered", inputSchema: { properties: {} } });`, + ), + ); + const declaration = analyzed.observations.webmcp_declarations[0]; + if (declaration === undefined) throw new Error("Expected declaration"); + const { schema_property_names_coverage: _coverage, ...withoutCoverage } = + declaration; + expect( + webBundleAnalysisSchema.safeParse({ ...analyzed, observations: { ...analyzed.observations, - webmcp_declarations: [legacyDeclaration], + webmcp_declarations: [withoutCoverage], }, - }); - expect( - Object.hasOwn( - parsed.observations.webmcp_declarations[0] ?? {}, + }).error?.issues, + ).toMatchObject([ + { + path: [ + "observations", + "webmcp_declarations", + 0, "schema_property_names_coverage", - ), - ).toBe(false); - }); + ], + }, + ]); }); it("retains WebMCP declarations through optional member and call chaining", () => { diff --git a/src/domain/webCaptureDiff.ts b/src/domain/webCaptureDiff.ts index e0bb4c087a..9f0663fe6f 100644 --- a/src/domain/webCaptureDiff.ts +++ b/src/domain/webCaptureDiff.ts @@ -173,12 +173,6 @@ const storageDimension = ( before.storage, after.storage, ); - const indexedDbVersionCovered = [before.storage, after.storage].every( - (storage) => - storage.content_fingerprints - .filter(({ scope }) => scope === "indexed_db_schema") - .every(({ projection_version }) => projection_version === 2), - ); return compareDimension( storageMap( before.storage, @@ -194,10 +188,9 @@ const storageDimension = ( ), keysComplete && usageComplete && - indexedDbVersionCovered && before.storage.fingerprints_complete && after.storage.fingerprints_complete, - "Storage fingerprints, inventories, usage, quota, or IndexedDB schema version coverage were unavailable or truncated in at least one observation.", + "Storage fingerprints, inventories, usage, or quota were unavailable or truncated in at least one observation.", keysComplete, ); }; @@ -1660,26 +1653,13 @@ const storageFingerprintIdentities = ( const afterComplete = completeStorageFingerprints(after); const bothComplete = before.fingerprints_complete && after.fingerprints_complete; - const candidates = bothComplete + return bothComplete ? new Set([...beforeComplete.keys(), ...afterComplete.keys()]) : new Set( [...beforeComplete.keys()].filter((identity) => afterComplete.has(identity), ), ); - return new Set( - [...candidates].filter((identity) => { - const beforeSchema = beforeComplete.get(identity); - const afterSchema = afterComplete.get(identity); - if ((beforeSchema ?? afterSchema)?.scope !== "indexed_db_schema") - return true; - return ( - beforeSchema === undefined || - afterSchema === undefined || - beforeSchema.projection_version === afterSchema.projection_version - ); - }), - ); }; const completeStorageFingerprints = ( diff --git a/src/javascript/analysis/JavaScriptAnalysisWorkerSchemas.test.ts b/src/javascript/analysis/JavaScriptAnalysisWorkerSchemas.test.ts index a908f2dce6..aa750aa666 100644 --- a/src/javascript/analysis/JavaScriptAnalysisWorkerSchemas.test.ts +++ b/src/javascript/analysis/JavaScriptAnalysisWorkerSchemas.test.ts @@ -20,17 +20,17 @@ import { analyzeJavaScriptSemantics } from "../../domain/javascript/javascriptSe import { getterExpansionSource } from "../../../tests/fixtures/javascriptGetterExpansion.js"; import { aliasSelectionBudgetSource } from "../../../tests/fixtures/javascriptAliasSelectionBudget.js"; -it("preserves independent static coverage and historical unmeasured facts", () => { +it("preserves independent static coverage and refuses facts without it", () => { const facts = analyzeJavaScriptStaticSource("require(moduleName);"); expect( javaScriptWorkerStaticAnalysisSchema.parse( JSON.parse(JSON.stringify(facts)), ), ).toEqual(facts); - const { analysis_coverage: _coverage, ...historical } = facts; - expect(javaScriptWorkerStaticAnalysisSchema.parse(historical)).toEqual( - historical, - ); + const { analysis_coverage: _coverage, ...unmeasured } = facts; + expect( + javaScriptWorkerStaticAnalysisSchema.safeParse(unmeasured).success, + ).toBe(false); expect( javaScriptWorkerStaticAnalysisSchema.safeParse({ ...facts, diff --git a/src/javascript/analysis/JavaScriptAnalysisWorkerSchemas.ts b/src/javascript/analysis/JavaScriptAnalysisWorkerSchemas.ts index d8e2bb6671..3c8a4bb1a1 100644 --- a/src/javascript/analysis/JavaScriptAnalysisWorkerSchemas.ts +++ b/src/javascript/analysis/JavaScriptAnalysisWorkerSchemas.ts @@ -385,7 +385,7 @@ const referenceShape = { export const javaScriptWorkerStaticAnalysisSchema = z .strictObject({ parse_status: z.enum(["complete", "partial", "failed"]), - analysis_coverage: javaScriptStaticCoverageSchema.exactOptional(), + analysis_coverage: javaScriptStaticCoverageSchema, routes: javaScriptRouteSourceFactsSchema.exactOptional(), parse_error_count: count, visited_ast_nodes: count, diff --git a/tests/boundary/browser/cdpBrowserProvider.sensitive_data.test.ts b/tests/boundary/browser/cdpBrowserProvider.sensitive_data.test.ts index 0df78ae0cd..f8eac03f40 100644 --- a/tests/boundary/browser/cdpBrowserProvider.sensitive_data.test.ts +++ b/tests/boundary/browser/cdpBrowserProvider.sensitive_data.test.ts @@ -216,6 +216,22 @@ describe("CdpBrowserProvider: complete storage fingerprints", () => { ), ).toMatchObject({ complete: true, value_sha256: expect.any(String) }); expect(JSON.stringify(result.value)).not.toContain(body); + // The storage capture always writes its fingerprint facts. + for (const omit of [ + "content_fingerprints", + "fingerprint_algorithm", + "fingerprints_complete", + ]) + expect( + webPageInspectionSchema.safeParse({ + ...result.value, + storage: Object.fromEntries( + Object.entries(result.value.storage).filter( + ([key]) => key !== omit, + ), + ), + }).success, + ).toBe(false); }); }); diff --git a/tests/boundary/browser/cdpJsonShapeComparison.test.ts b/tests/boundary/browser/cdpJsonShapeComparison.test.ts index a700d50718..a56c94518f 100644 --- a/tests/boundary/browser/cdpJsonShapeComparison.test.ts +++ b/tests/boundary/browser/cdpJsonShapeComparison.test.ts @@ -537,6 +537,9 @@ const captureBody = ( session_storage_keys: [], indexed_db_names: [], cache_names: [], + content_fingerprints: [], + fingerprint_algorithm: "sha256", + fingerprints_complete: false, values_redacted: true, }, limitations: [], diff --git a/tests/boundary/browser/webBundleResultCapacity.test.ts b/tests/boundary/browser/webBundleResultCapacity.test.ts index ad5823053a..6dbabc81b6 100644 --- a/tests/boundary/browser/webBundleResultCapacity.test.ts +++ b/tests/boundary/browser/webBundleResultCapacity.test.ts @@ -50,6 +50,7 @@ const buildWideScriptResult = ( name, description: null, schema_property_names: [], + schema_property_names_coverage: "not_present" as const, trust: "page-declared-untrusted" as const, location, }); diff --git a/tests/boundary/browser/webCaptureDiff.test.ts b/tests/boundary/browser/webCaptureDiff.test.ts index 84f6b1a3c2..7db38a7b7a 100644 --- a/tests/boundary/browser/webCaptureDiff.test.ts +++ b/tests/boundary/browser/webCaptureDiff.test.ts @@ -2,7 +2,10 @@ import { afterEach, describe, expect, it } from "vitest"; import { CdpBrowserProvider } from "../../../src/browser/CdpBrowserProvider.js"; import { inspectWebPageInputSchema } from "../../../src/domain/browserObservation.js"; -import type { WebPageInspection } from "../../../src/domain/browserObservationSchemas.js"; +import { + type WebPageInspection, + webPageInspectionSchema, +} from "../../../src/domain/browserObservationSchemas.js"; import { discoverWebMcpToolsInputSchema } from "../../../src/domain/webMcpDiscovery.js"; import { compareWebCaptures } from "../../../src/domain/webCaptureDiff.js"; import { @@ -1412,49 +1415,27 @@ describe("web capture diff semantics and fingerprints", () => { }); }); -it("keeps historical IndexedDB schema projections uncertain while retaining proven changes", async () => { +it("refuses an IndexedDB schema fingerprint without its projection version", async () => { const browser = await startFakeCdpBrowser(); browsers.push(browser); const current = await inspectStorage(browser, true); - const legacy = structuredClone(current); - const oldSchema = legacy.storage.content_fingerprints.find( + const index = current.storage.content_fingerprints.findIndex( ({ scope }) => scope === "indexed_db_schema", ); - if (oldSchema === undefined) + const schema = current.storage.content_fingerprints[index]; + if (schema?.scope !== "indexed_db_schema") throw new Error("Expected an IndexedDB schema fingerprint"); - delete oldSchema.projection_version; - oldSchema.value_sha256 = "0".repeat(64); - for (const [before, after] of [ - [legacy, current], - [current, legacy], - ] as const) - expect(compareStorage(before, after)).toMatchObject({ - status: "unknown", - total_changes: 0, - }); - expect(compareStorage(legacy, structuredClone(legacy))).toMatchObject({ - status: "unknown", - total_changes: 0, - }); - const changedLegacy = structuredClone(legacy); - const changedSchema = changedLegacy.storage.content_fingerprints.find( - ({ scope }) => scope === "indexed_db_schema", - ); - if (changedSchema === undefined) - throw new Error("Expected an IndexedDB schema fingerprint"); - changedSchema.value_sha256 = "1".repeat(64); - expect(compareStorage(legacy, changedLegacy)).toMatchObject({ - status: "changed", - total_changes: 1, - changes: [expect.objectContaining({ change: "modified" })], - }); - const changedKey = structuredClone(current); - changedKey.storage.local_storage_keys.push("new-key"); - expect(compareStorage(legacy, changedKey)).toMatchObject({ - status: "changed", - total_changes: 1, - changes: [expect.objectContaining({ change: "added" })], - }); + expect(schema.projection_version).toBe(2); + const { projection_version: _version, ...withoutVersion } = schema; + const unmarked = structuredClone(current); + (unmarked.storage.content_fingerprints as unknown[])[index] = withoutVersion; + expect( + webPageInspectionSchema.safeParse(unmarked).error?.issues, + ).toMatchObject([ + { + path: ["storage", "content_fingerprints", index, "projection_version"], + }, + ]); }); describe("web capture diff completeness", () => { diff --git a/tests/boundary/browser/webDeadlineBehavior.test.ts b/tests/boundary/browser/webDeadlineBehavior.test.ts index 41af66567a..4717f3b713 100644 --- a/tests/boundary/browser/webDeadlineBehavior.test.ts +++ b/tests/boundary/browser/webDeadlineBehavior.test.ts @@ -26,6 +26,7 @@ const targetList = browserTargetListSchema.parse({ const bundle = webBundleAnalysisSchema.parse({ capture: { target_url: "https://example.test/", + target_origin: "https://example.test", scripts_observed: 0, scripts_analyzed: 0, source_artifacts: [], diff --git a/tests/boundary/browser/webSourceMapFetcher.test.ts b/tests/boundary/browser/webSourceMapFetcher.test.ts index f7e7e96cce..9de0c68aa4 100644 --- a/tests/boundary/browser/webSourceMapFetcher.test.ts +++ b/tests/boundary/browser/webSourceMapFetcher.test.ts @@ -336,6 +336,24 @@ it("parses ECMA-426 HTTP source-map prefixes while retaining exact response evid { artifact: null, mappings: [], original_sources: [] }, { artifact: null, mappings: [], original_sources: [] }, ]); + expect(webSourceMapsSchema.parse(result)).toEqual(result); + const without = (value: object, omit: string) => + Object.fromEntries(Object.entries(value).filter(([key]) => key !== omit)); + for (const omit of ["source_index", "declaration_index"]) + expectInvalidSourceMaps({ + ...result, + items: result.items.map((item) => ({ + ...item, + mappings: item.mappings.map((row) => without(row, omit)), + })), + }); + // An invalid map was read in full, so its body identity is required. + expectInvalidSourceMaps({ + ...result, + items: result.items.map((item) => + item.status === "invalid" ? without(item, "response_identity") : item, + ), + }); } finally { server.closeAllConnections(); if (server.listening) diff --git a/tests/boundary/browser/webSourceMapHttpStatus.test.ts b/tests/boundary/browser/webSourceMapHttpStatus.test.ts index 9339acddab..f0966c496a 100644 --- a/tests/boundary/browser/webSourceMapHttpStatus.test.ts +++ b/tests/boundary/browser/webSourceMapHttpStatus.test.ts @@ -180,13 +180,13 @@ it.each(["invalid JSON", "invalid UTF-8", "HTTP failure", "response limit"])( }); const item = result.items[0]; if (item === undefined) throw new Error("Expected a fetched map result"); - const legacyItem = { ...item }; - delete legacyItem.effective_url; - const legacy = webSourceMapsSchema.parse({ - ...result, - items: [legacyItem], - }); - expect(legacy.items[0]).not.toHaveProperty("effective_url"); + const { effective_url: _effective, ...withoutEffectiveUrl } = item; + expect( + webSourceMapsSchema.safeParse({ + ...result, + items: [withoutEffectiveUrl], + }).success, + ).toBe(false); }, ); diff --git a/tests/boundary/browser/webSourceMapResponseIdentity.test.ts b/tests/boundary/browser/webSourceMapResponseIdentity.test.ts index 31348e93f6..f2f2ac2541 100644 --- a/tests/boundary/browser/webSourceMapResponseIdentity.test.ts +++ b/tests/boundary/browser/webSourceMapResponseIdentity.test.ts @@ -210,24 +210,3 @@ it("refuses oversized text before JSON interpretation while retaining body ident ); expect(calls).toBe(2); }); - -it("keeps historical invalid rows with no response identity admissible", () => { - const historical = { - status: "unavailable", - requested: 1, - processed: 1, - items: [ - { - script_key: request(1).scriptKey, - declared_url: request(1).declaredUrl, - status: "invalid", - artifact: null, - original_sources: [], - original_module_edges: [], - mappings: [], - limitation: "Source-map JSON is not a version 3 map.", - }, - ], - }; - expect(webSourceMapsSchema.parse(historical)).toMatchObject(historical); -}); diff --git a/tests/boundary/filesystem/javascript-applications/javascriptArtifactReconstruction.test.ts b/tests/boundary/filesystem/javascript-applications/javascriptArtifactReconstruction.test.ts index 01109d8c3d..6085784242 100644 --- a/tests/boundary/filesystem/javascript-applications/javascriptArtifactReconstruction.test.ts +++ b/tests/boundary/filesystem/javascript-applications/javascriptArtifactReconstruction.test.ts @@ -576,17 +576,15 @@ it("keeps IPC pairings uncertain when source examination is incomplete", async ( const hiddenSource = analysis.files.find( ({ file }) => file.path === hidden.path, ); - if (hiddenSource?.javascript?.analysis_coverage === undefined) - throw new Error("Missing hidden source coverage"); + if (hiddenSource?.javascript == null) + throw new Error("Missing hidden source analysis"); const hiddenStatic = hiddenSource.javascript; - const { analysis_coverage: _ignoredCoverage, ...historicalStatic } = - hiddenStatic; const limitedStatic = { ...hiddenStatic, analysis_coverage: { - ...hiddenStatic.analysis_coverage!, + ...hiddenStatic.analysis_coverage, examination: { - ...hiddenStatic.analysis_coverage!.examination, + ...hiddenStatic.analysis_coverage.examination, status: "limited" as const, semantic_resource_limits: ["alias-selections" as const], }, @@ -595,19 +593,15 @@ it("keeps IPC pairings uncertain when source examination is incomplete", async ( const wrapperLimitedStatic = { ...hiddenStatic, analysis_coverage: { - ...hiddenStatic.analysis_coverage!, + ...hiddenStatic.analysis_coverage, examination: { - ...hiddenStatic.analysis_coverage!.examination, + ...hiddenStatic.analysis_coverage.examination, status: "limited" as const, electron_call_paths_limited: true, }, }, }; - for (const javascript of [ - historicalStatic, - limitedStatic, - wrapperLimitedStatic, - ]) { + for (const javascript of [limitedStatic, wrapperLimitedStatic]) { const partialAnalysis = { ...analysis, files: analysis.files.map((item) => @@ -649,7 +643,7 @@ it("keeps IPC pairings uncertain when source examination is incomplete", async ( parse_status: "partial" as const, parse_error_count: 1, analysis_coverage: { - ...hiddenStatic.analysis_coverage!, + ...hiddenStatic.analysis_coverage, syntax: { status: "recovered" as const, error_count: 1 }, }, }, @@ -728,7 +722,7 @@ it("does not pair IPC when the Electron wrapper walk hits its depth limit", asyn const limited = analysis.files.find( ({ file }) => file.path === "limited.js", ); - expect(limited?.javascript?.analysis_coverage?.examination).toMatchObject({ + expect(limited?.javascript?.analysis_coverage.examination).toMatchObject({ electron_call_paths_limited: true, semantic_resource_limits: [], }); diff --git a/tests/boundary/filesystem/javascript-applications/javascriptRuntimeReconciliation.test.ts b/tests/boundary/filesystem/javascript-applications/javascriptRuntimeReconciliation.test.ts index 90c57cae33..847ad3a0fb 100644 --- a/tests/boundary/filesystem/javascript-applications/javascriptRuntimeReconciliation.test.ts +++ b/tests/boundary/filesystem/javascript-applications/javascriptRuntimeReconciliation.test.ts @@ -442,7 +442,7 @@ it("preserves unknown Electron frame provenance without linking it to an authori ).toBe(false); }); -it.each(["historical", "selected-paths"] as const)( +it.each(["canonical-paths", "selected-paths"] as const)( "reconciles %s active Electron as a partial target-only runtime capture", async (representation) => { const fixture = await applicationFixture(); @@ -460,7 +460,7 @@ it.each(["historical", "selected-paths"] as const)( const capture = createElectronActiveObservationFixtureResult(applicationPath); let selectedInput: ElectronActiveObservationInput = input; - let resolvedInput: typeof input | undefined; + let resolvedInput: typeof input = input; if (representation === "selected-paths") { const alias = join(fixture, "selected-main.js"); await symlink(applicationPath, alias); @@ -506,6 +506,58 @@ it.each(["historical", "selected-paths"] as const)( }, ); +it("refuses active Electron Evidence without its admitted execution paths", async () => { + const fixture = await applicationFixture(); + const applicationPath = join(fixture, "main.js"); + const input = { + ...electronActiveObservationInputSchema.parse({ + executable_path: process.execPath, + application_path: applicationPath, + application_root: fixture, + actions: [], + }), + application_root: fixture, + }; + const runtime = createElectronActiveEvidence( + input, + createElectronActiveObservationFixtureResult(applicationPath), + { + id: "rea-playwright-electron-active", + name: "REA Playwright active Electron observation provider", + version: "1", + }, + input, + ); + const { resolved_paths: _resolved, ...parameters } = runtime.parameters; + const withoutPaths = createEvidence(undefined, runtime.provider, { + predicateType: runtime.predicate_type, + operation: runtime.operation, + parameters, + result: runtime.normalized_result, + confidence: runtime.confidence, + authority: runtime.authority, + }); + + expect( + reconcileJavaScriptRuntimeEvidence({ + static_layers: [ + { role: "application", analysis: await analyzeFixture(fixture) }, + ], + runtime_observations: [withoutPaths], + }), + ).toMatchObject({ + ok: false, + error: { + _tag: "AnalysisInputError", + issues: [ + { + path: ["runtime_observations", 0, "parameters", "resolved_paths"], + }, + ], + }, + }); +}); + it("commits complete Electron actions independently from selected arguments", async () => { const fixture = await applicationFixture(); const applicationPath = join(fixture, "main.js"); @@ -533,15 +585,19 @@ it("commits complete Electron actions independently from selected arguments", as name: "REA Playwright active Electron observation provider", version: "1", }; + const firstInput = makeInput("first-secret", "#first-secret"); + const secondInput = makeInput("first-secret", "#second-secret"); const first = createElectronActiveEvidence( - makeInput("first-secret", "#first-secret"), + firstInput, createElectronActiveObservationFixtureResult(applicationPath), provider, + firstInput, ); const second = createElectronActiveEvidence( - makeInput("first-secret", "#second-secret"), + secondInput, createElectronActiveObservationFixtureResult(applicationPath), provider, + secondInput, ); expect(first.parameters.scenario_sha256).not.toBe( diff --git a/tests/boundary/inspector/javascriptRuntimeObservation.test.ts b/tests/boundary/inspector/javascriptRuntimeObservation.test.ts index e3dc06e97c..0f47e1b001 100644 --- a/tests/boundary/inspector/javascriptRuntimeObservation.test.ts +++ b/tests/boundary/inspector/javascriptRuntimeObservation.test.ts @@ -920,16 +920,17 @@ test("keeps Inspector parse failures separate and preserves file URL script iden parsedCapture.inspection.completeness.unavailable_sections, ).not.toContain("scripts"); - const legacySnapshot = { + const withoutCount = { ...observed.value, scripts: { ...observed.value.scripts, }, }; - delete legacySnapshot.scripts.parse_failed_total; - const parsedLegacySnapshot = - javascriptRuntimeObservationSchema.parse(legacySnapshot); - expect("parse_failed_total" in parsedLegacySnapshot.scripts).toBe(false); + delete (withoutCount.scripts as { parse_failed_total?: number }) + .parse_failed_total; + expect( + javascriptRuntimeObservationSchema.safeParse(withoutCount).error?.issues, + ).toMatchObject([{ path: ["scripts", "parse_failed_total"] }]); } finally { await fake.close(); } @@ -1025,6 +1026,7 @@ const runtimeObservation = ( }, ], observed_total: 1, + parse_failed_total: 0, excluded: { unsupported_location: 0, invalid_protocol_value: 0, diff --git a/tests/boundary/javascript/asyncChunkCapacity.test.ts b/tests/boundary/javascript/asyncChunkCapacity.test.ts index 1296bd243a..45c9ac9131 100644 --- a/tests/boundary/javascript/asyncChunkCapacity.test.ts +++ b/tests/boundary/javascript/asyncChunkCapacity.test.ts @@ -9,7 +9,7 @@ it("retains a wide factory's async keys before normalizing the registration", () const { source, factory } = javascriptAsyncChunkCapacity(count); const result = analyzeJavaScriptStaticSource(source); expect(result.parse_status).toBe("partial"); - expect(result.analysis_coverage?.syntax).toEqual({ + expect(result.analysis_coverage.syntax).toEqual({ status: "complete", error_count: 0, }); diff --git a/tests/boundary/mcp/browserMcp.test.ts b/tests/boundary/mcp/browserMcp.test.ts index 7ec5149c40..fe15e434e8 100644 --- a/tests/boundary/mcp/browserMcp.test.ts +++ b/tests/boundary/mcp/browserMcp.test.ts @@ -173,21 +173,21 @@ it("preserves Link parameter order and context through the advertised MCP contra `${browser.allowedOrigin}/same-context`, ]); - const legacy = structuredClone(normalized); - for (const response of legacy.metadata.responses) + const contextless = structuredClone(normalized) as unknown as { + metadata: { responses: { links: Record[] }[] }; + }; + for (const response of contextless.metadata.responses) for (const projectedLink of response.links) { delete projectedLink.context_url; delete projectedLink.context_scope; } - expect(webPageInspectionSchema.safeParse(legacy).success).toBe(true); - const legacyStructuredContent = { - ...(inspected.structuredContent as Record), - normalized_result: legacy, - }; + expect(webPageInspectionSchema.safeParse(contextless).success).toBe(false); expect( - ajv.validate(outputSchema, legacyStructuredContent), - JSON.stringify(ajv.errors), - ).toBe(true); + ajv.validate(outputSchema, { + ...(inspected.structuredContent as Record), + normalized_result: contextless, + }), + ).toBe(false); }); cliTest( diff --git a/tests/boundary/mcp/javascriptRuntimeObservationMcp.test.ts b/tests/boundary/mcp/javascriptRuntimeObservationMcp.test.ts index 36c4d736d0..02853783ef 100644 --- a/tests/boundary/mcp/javascriptRuntimeObservationMcp.test.ts +++ b/tests/boundary/mcp/javascriptRuntimeObservationMcp.test.ts @@ -76,6 +76,7 @@ function registerRuntimeParameterContract( scripts: { items: [], observed_total: 0, + parse_failed_total: 0, excluded: { unsupported_location: 0, invalid_protocol_value: 0 }, }, execution_contexts: [], @@ -183,6 +184,7 @@ function registerRuntimeMetadataContract(): void { scripts: { items: [], observed_total: 0, + parse_failed_total: 0, excluded: { unsupported_location: 0, invalid_protocol_value: 0, diff --git a/tests/boundary/mcp/managedMemberSummaryMcp.test.ts b/tests/boundary/mcp/managedMemberSummaryMcp.test.ts index c62b093130..c1a0d96c05 100644 --- a/tests/boundary/mcp/managedMemberSummaryMcp.test.ts +++ b/tests/boundary/mcp/managedMemberSummaryMcp.test.ts @@ -307,7 +307,7 @@ it("summarizes selected members and pages every original collection after the fi }); it("keeps collections that member Evidence never examined unknown", async () => { - const directory = await createTestTempDirectory("rea-member-historical-"); + const directory = await createTestTempDirectory("rea-member-unexamined-"); const path = join(directory, "fixture.dll"); await writeFile(path, buildManagedPeFixture()); const { client } = await createHarness(); @@ -325,8 +325,13 @@ it("keeps collections that member Evidence never examined unknown", async () => user_strings: null, selection: null, signature_resolution: null, + fields: [], + methods: [], + member_refs: [], + call_edges: [], + field_accesses: [], }; - const historical = createEvidence(undefined, parent.provider, { + const unexamined = createEvidence(undefined, parent.provider, { operation: parent.operation, parameters: parent.parameters, result: recorded, @@ -334,7 +339,7 @@ it("keeps collections that member Evidence never examined unknown", async () => authority: parent.authority, }); const summary = await inspectAnalysisView({ - source: { kind: "inline", evidence: historical }, + source: { kind: "inline", evidence: unexamined }, view: { kind: "summary" }, }); if (!summary.ok) throw summary.error; @@ -350,13 +355,13 @@ it("keeps collections that member Evidence never examined unknown", async () => for (const collection of ["exported_types", "user_strings"] as const) expect( await inspectAnalysisView({ - source: { kind: "inline", evidence: historical }, + source: { kind: "inline", evidence: unexamined }, view: { kind: "managed-members", collection, offset: 0, limit: 1 }, }), ).toMatchObject({ ok: false, error: { _tag: "AnalysisInputError" } }); expect( await inspectAnalysisView({ - source: { kind: "inline", evidence: historical }, + source: { kind: "inline", evidence: unexamined }, view: { kind: "managed", collection: "attributes", offset: 0, limit: 1 }, }), ).toMatchObject({ ok: false, error: { _tag: "AnalysisInputError" } }); diff --git a/tests/boundary/providers/managed/managedMemberComparisonFromMetadata.test.ts b/tests/boundary/providers/managed/managedMemberComparisonFromMetadata.test.ts index 7a23d7ed26..0d28eb6aba 100644 --- a/tests/boundary/providers/managed/managedMemberComparisonFromMetadata.test.ts +++ b/tests/boundary/providers/managed/managedMemberComparisonFromMetadata.test.ts @@ -1610,30 +1610,21 @@ it.each([ expect(side.result.fields[0]?.signature.parse_status).toBe("malformed"); expect(side.result.coverage.state).toBe("partial"); - for (const signature_resolution of [ - side.result.signature_resolution, - null, - ]) { - const observation = { - ...side, - result: { ...side.result, signature_resolution }, - }; - const comparison = compareManagedMembers(observation, observation); - expect(comparison.coverage.status).toBe("partial"); - expect(comparison.summary).toMatchObject({ - unchanged: 0, - changed: 0, - added: 0, - removed: 0, - unknown: 2, + const comparison = compareManagedMembers(side, side); + expect(comparison.coverage.status).toBe("partial"); + expect(comparison.summary).toMatchObject({ + unchanged: 0, + changed: 0, + added: 0, + removed: 0, + unknown: 2, + }); + for (const item of [...comparison.methods, ...comparison.fields]) + expect(item).toMatchObject({ + status: "unknown", + match: { status: "matched", confidence: "exact" }, + limitations: [expect.stringMatching(/^signature-malformed:/)], }); - for (const item of [...comparison.methods, ...comparison.fields]) - expect(item).toMatchObject({ - status: "unknown", - match: { status: "matched", confidence: "exact" }, - limitations: [expect.stringMatching(/^signature-malformed:/)], - }); - } }, ); @@ -3035,51 +3026,17 @@ describe("managed member comparison of resolved signatures", () => { ).toEqual([]); }); - it("compares raw signatures against Evidence without resolution attestation", () => { - // Both signatures name Program, TypeDef row 1, in the same build. - const build = () => - buildManagedPeFixture({ - fieldSignature: Buffer.from([0x06, 0x12, leftTypes.program]), - methodSignature: Buffer.from([ - 0x00, - 0x01, - 0x01, - 0x12, - leftTypes.program, - ]), - }); - const left = inspect(build(), "/tmp/left-recorded.dll"); - const right = inspect(build(), "/tmp/right-current.dll"); - const withoutResolution = ( - members: readonly Member[], - ) => - members.map((member) => ({ - ...member, - signature: { ...member.signature, resolved_sha256: null }, - })); - const recorded = managedMemberInspectionSchema.parse({ - ...left.result, - signature_resolution: null, - methods: withoutResolution(left.result.methods), - fields: withoutResolution(left.result.fields), - member_refs: withoutResolution(left.result.member_refs), - }); - expect(recorded.methods[0]?.signature.resolved_sha256).toBeNull(); - - const result = compareManagedMembers( - { evidenceId: left.evidenceId, result: recorded }, - { evidenceId: right.evidenceId, result: right.result }, - ); - - expect(result.methods).toEqual([ - expect.objectContaining({ status: "unchanged" }), - ]); - expect(result.fields).toEqual([ - expect.objectContaining({ status: "unchanged" }), - ]); - expect(result.limitations).toContainEqual( - expect.stringMatching(/signature type.name resolution.*raw bytes/iu), + it("refuses members beside a null signature resolution", () => { + const side = inspect( + buildManagedPeFixture(), + "/tmp/unattested-resolution.dll", ); + expect(side.result.methods.length).toBeGreaterThan(0); + expect( + managedMemberInspectionSchema + .safeParse({ ...side.result, signature_resolution: null }) + .error?.issues.map(({ path }) => path), + ).toEqual(expect.arrayContaining([["methods"], ["fields"]])); }); }); @@ -3238,13 +3195,6 @@ describe("managed member comparison of unresolved signatures", () => { expect( [...result.methods, ...result.fields].map(({ status }) => status), ).toEqual(["unknown", "unknown", "unknown", "unknown"]); - expect(result.limitations).not.toEqual( - expect.arrayContaining([ - expect.stringContaining( - "does not attest signature type-name resolution", - ), - ]), - ); }); it("keeps an unmatched unresolved method unknown in a resolved comparison", () => { @@ -3298,21 +3248,6 @@ describe("managed member comparison of unresolved signatures", () => { }); }); -describe("managed member comparison limitations for resolved signatures", () => { - it("does not report missing resolved digests for observations without signatures", () => { - const base = inspect(buildManagedPeFixture(), "/tmp/no-members.dll"); - const empty = { - ...base, - result: { ...base.result, methods: [], fields: [] }, - }; - const result = compareManagedMembers(empty, empty); - - expect(result.limitations).not.toContainEqual( - expect.stringMatching(/does not attest signature type.name resolution/iu), - ); - }); -}); - describe("managed member comparison of resolved-signature contention", () => { it("contests an ownerless method across builds whose raw signature bytes differ", () => { const base = inspect(buildManagedPeFixture(), "/tmp/ownerless-builds.dll"); diff --git a/tests/fixtures/nodeRuntimeReconciliation.ts b/tests/fixtures/nodeRuntimeReconciliation.ts index a85647f2ea..1084767ed8 100644 --- a/tests/fixtures/nodeRuntimeReconciliation.ts +++ b/tests/fixtures/nodeRuntimeReconciliation.ts @@ -48,6 +48,7 @@ export const nodeReconciliationFixture = (scriptObserved: boolean) => { ] : [], observed_total: scriptObserved ? 1 : 0, + parse_failed_total: 0, excluded: { unsupported_location: 0, invalid_protocol_value: 0 }, }, execution_contexts: [], diff --git a/tests/fixtures/passiveNetworkCapture.ts b/tests/fixtures/passiveNetworkCapture.ts index c2ff254207..f8ac116442 100644 --- a/tests/fixtures/passiveNetworkCapture.ts +++ b/tests/fixtures/passiveNetworkCapture.ts @@ -104,6 +104,9 @@ export const passiveNetworkCapture = (paths: readonly string[] = ["/a"]) => { session_storage_keys: [], indexed_db_names: [], cache_names: [], + content_fingerprints: [], + fingerprint_algorithm: "sha256", + fingerprints_complete: false, values_redacted: true, }, limitations: [ diff --git a/tests/process-global/derivedOperationFailures.test.ts b/tests/process-global/derivedOperationFailures.test.ts index c12e751bdd..227a3bb8c7 100644 --- a/tests/process-global/derivedOperationFailures.test.ts +++ b/tests/process-global/derivedOperationFailures.test.ts @@ -225,21 +225,23 @@ const activeRuntimeFixture = () => { const root = join(process.cwd(), "active-runtime-fixture"); const applicationPath = join(root, "main.js"); const result = createElectronActiveObservationFixtureResult(applicationPath); - const evidence = createElectronActiveEvidence( - { - ...electronActiveObservationInputSchema.parse({ - executable_path: process.execPath, - application_path: applicationPath, - application_root: root, - }), + const input = { + ...electronActiveObservationInputSchema.parse({ + executable_path: process.execPath, + application_path: applicationPath, application_root: root, - }, + }), + application_root: root, + }; + const evidence = createElectronActiveEvidence( + input, result, { id: "rea-playwright-electron-active", name: "REA Playwright active Electron observation provider", version: "1", }, + input, ); return { evidence, result }; }; @@ -305,7 +307,7 @@ describe("runtime reconciliation failure ownership through the public SDK", () = }, { field: "parameters", - path: ["parameters", "application_root"], + path: ["parameters", "resolved_paths", "application_root"], reason: "invalid_type", }, { @@ -325,7 +327,13 @@ describe("runtime reconciliation failure ownership through the public SDK", () = confidence: evidence.confidence, parameters: field === "parameters" - ? { ...evidence.parameters, application_root: 3 } + ? { + ...evidence.parameters, + resolved_paths: { + ...(evidence.parameters.resolved_paths as object), + application_root: 3, + }, + } : evidence.parameters, result: field === "parameters" diff --git a/tests/support/browser/webPageInspection.ts b/tests/support/browser/webPageInspection.ts index 7fd101a3f0..4806f593a3 100644 --- a/tests/support/browser/webPageInspection.ts +++ b/tests/support/browser/webPageInspection.ts @@ -74,6 +74,7 @@ export const createWebPageInspection = ( items: scripts.map( ({ source, scriptKey, url, origin: scriptOrigin, cdpHash }) => ({ script_key: scriptKey, + frame_id: null, url, origin: scriptOrigin, cdp_hash: cdpHash, @@ -120,6 +121,9 @@ export const createWebPageInspection = ( session_storage_keys: [], indexed_db_names: [], cache_names: [], + content_fingerprints: [], + fingerprint_algorithm: "sha256", + fingerprints_complete: false, values_redacted: true, }, limitations: [],