Files
reverse-engineering-anything/tests/fixtures/javascriptRuntimeReconciliation.ts
T
morluto 3afd8a16ee feat(evidence)!: give Evidence bundles a format revision owned by one module (#10861)
* feat(evidence)!: give Evidence bundles a format revision owned by one module

`src/domain/evidenceFormat.ts` owns Evidence format evolution. Bundles now
carry `evidence_format: 1`; every bundle reader admits only the current
revision and refuses an unmarked or other-revision bundle once, with the
single recreate-observations guidance, instead of admitting earlier shapes
one optional field at a time.

The 6.7-era artifact inventory summary identities are no longer rebuilt:
compare_artifacts checks the current projection only and reports a mismatch
with the owner's guidance. The pre-6.6 identity diagnosis uses the same
guidance. SQLite `worker_timeout_ms` and Dart AOT `string_pool.policy`,
optional only for historical Evidence, are now required.

BREAKING CHANGE: Evidence bundles written by REA 6.x (no `evidence_format`)
are refused by import, comparison, reconstruction and analysis-snapshot
readers as an integrity mismatch telling the caller to recreate the
observations; re-exporting an earlier bundle does not update its format or
identities. Bundles constructed by hand must include `"evidence_format": 1`.
6.7-era artifact summaries are refused by compare_artifacts, and SQLite and
Dart AOT Evidence without the newly required fields fails validation.

* fix(evidence): let the ledger application admit its bundle's format

build_reconstruction_obligation_ledger registered the full bundle schema with the SDK, so an unmarked or other-revision bundle was refused as invalid_request before the format owner ran. Register it like coverage: the application parses the request envelope and admits the bundle.

* feat(pcap)!: read capture Evidence through the current result schema only (#10879)

Delete the pcap read-compatibility schema that defaulted executable identity for historical capture Evidence, and require query_labels_hex (null when unknown) now that every producer writes it. Evidence from an earlier format is refused at the bundle format owner; a record that omits these fields is reported as malformed instead of defaulted.

BREAKING CHANGE: inspect_pcap_capture results always carry query_labels_hex, and analysis views no longer default missing tshark/capinfos identity fields.

* feat(desktop)!: require the effective view policy in desktop state Evidence (#10886)

inspect_desktop_application_state always records the complete policy it used, including sqlite_view_bytes. Drop the optional historical shape and the task draft's absent-policy branch.

BREAKING CHANGE: desktop application state results without effective_view_policy, or with a policy missing sqlite_view_bytes, are refused as malformed.

* feat(android)!: require component declaration facets and reference aggregates in Android Evidence (#10904)

* feat(android)!: require component declaration facets and reference aggregates in Android Evidence

The JADX producers always write the manifest component projection with every declaration facet, target_definition and direct_invokes_coverage. Require them, delete the duplicate observed component schema, drop the unknown declaration coverage that only described historical omission, and give manifest view results their explicit facet.

BREAKING CHANGE: Android package, component and reference results missing these fields are refused as malformed; component declaration_coverage and its summary counts no longer include unknown; manifest view results always carry facet manifest.

* refactor(android): parse package results with the domain schema directly

* feat(browser)!: require the DOM length unit and redirect-scoped prior-hop facts (#10897)

* feat(browser)!: require the DOM length unit and redirect-scoped prior-hop facts

Both CDP producers always declare node_value_length_unit, and the observation session writes redirect_response on every redirect event and no other. Require the unit, drop the diff's absent-unit branch, and admit redirect_response exactly on redirect rows.

BREAKING CHANGE: DOM snapshots without node_value_length_unit and redirect timeline rows without redirect_response are refused as malformed, including inline inspections passed to compare_web_captures.

* docs(browser): drop the historical redirect_response omission note

* feat(native)!: require native Evidence fields that were optional only for historical Evidence (#10946)

Mach-O encryption, slice malformed cause, symbol runtime names and import
facts; ELF export encoding facts and visibility; value-flow limits; load-image
permissions and relocation symbols; Swift type-reference kind and GPU AMD
target metadata are required. Legacy enum values (unrecorded, unknown
visibility, undecodable, modinfo_field_exceeds_limit) and the retained
schemas, view defaults and reinterpretations that served historical Evidence
are deleted.

BREAKING CHANGE: native records missing these fields are refused as
malformed; recreate the observation.
2026-11-15 17:25:31 +08:00

177 lines
5.3 KiB
TypeScript

import { jsonValueSchema } from "../../src/domain/jsonValue.js";
import type { ElectronPageInspection } from "../../src/domain/javascript/electronObservation.js";
import { writeFile } from "node:fs/promises";
import { join } from "node:path";
import { createElectronEvidence } from "../../src/application/javascript/ElectronEvidence.js";
import { inspectElectronPageInputSchema } from "../../src/domain/javascript/electronObservation.js";
import { createWebTextArtifact } from "../../src/domain/webContentArtifact.js";
import { analyzeJavaScriptApplication } from "../support/javascriptApplicationScope.js";
import { createTestTempDirectory } from "./temporaryDirectory.js";
export const SOURCE = `const worker = new Worker(new URL("./worker.js", import.meta.url));\nexport const observed = worker;\n`;
export const applicationFixture = async (): Promise<string> => {
const root = await createTestTempDirectory("rea-runtime-reconciliation-");
await Promise.all([
writeFile(
join(root, "package.json"),
JSON.stringify({
name: "rea-runtime-reconciliation-fixture",
version: "1.0.0",
renderer: "index.html",
}),
),
writeFile(join(root, "index.html"), "<script src='./app.js'></script>"),
writeFile(join(root, "app.js"), SOURCE),
writeFile(join(root, "worker.js"), "self.onmessage = () => undefined;\n"),
]);
return root;
};
export const analyzeFixture = async (root: string) => {
const result = await analyzeJavaScriptApplication({
input_path: root,
});
if (!result.ok) throw result.error;
return result.value;
};
export const electronRuntimeEvidence = (
root: string,
source: string,
options: {
readonly scriptFile?: string;
readonly includeWorker?: boolean;
readonly targetId?: string;
readonly sourceIncluded?: boolean;
readonly workersUnavailable?: boolean;
readonly scriptsUnavailable?: boolean;
} = {},
) => {
const scriptFile = options.scriptFile ?? "app.js";
const includeWorker = options.includeWorker ?? true;
const targetId = options.targetId ?? "target-main";
const sourceIncluded = options.sourceIncluded ?? true;
const input = inspectElectronPageInputSchema.parse({
cdp_endpoint: "http://127.0.0.1:9223",
target_id: targetId,
observation_ms: 100,
include_script_sources: sourceIncluded,
});
const report = {
browser: {
product: "Electron/fixture",
protocol_version: "1.3",
revision: "fixture",
user_agent: "Electron fixture",
js_version: "13",
},
target: {
target_id: targetId,
type: "page",
title: "Fixture",
file_path: join(root, "index.html"),
attached: false,
},
capture_window: {
started_at: "2026-07-15T00:00:00.000Z",
ended_at: "2026-07-15T00:00:00.100Z",
observation_ms: 100,
},
completeness: captureCompleteness(options),
frames: [
{
frame_id: "frame-main",
parent_frame_id: null,
file_path: join(root, "index.html"),
},
],
dom: {
total_nodes: 0,
node_value_length_unit: "utf8-bytes",
nodes: [],
},
scripts: {
total: 1,
items: [
{
script_key: `electron_script_${"1".repeat(64)}`,
frame_id: "frame-main",
file_path: join(root, scriptFile),
cdp_hash: "fixture",
length: Buffer.byteLength(source),
is_module: true,
language: "JavaScript",
source: {
included: true as const,
artifact: createWebTextArtifact(source, "text/javascript"),
},
},
],
},
resources: [],
workers: includeWorker
? [
{
target_id: "worker-main",
type: "worker",
file_path: join(root, "worker.js"),
attached: false,
opener_target_id: targetId,
parent_frame_id: "frame-main",
},
]
: [],
limitations: ["Synthetic passive capture fixture."],
} satisfies ElectronPageInspection;
return createElectronEvidence(
"inspect_electron_page",
input,
{ source: jsonValueSchema.parse(report), facts: report },
{
id: "rea-cdp-electron",
name: "REA Electron file-page CDP observation provider",
version: "1",
},
);
};
const completeCapture = () => ({
status: "complete_within_window" as const,
conditions: ["complete_within_window" as const],
policy_filtered_sections: [],
attach_limited_sections: [],
truncated_sections: [],
unavailable_sections: [],
excluded: [],
dropped_events: {
scripts: 0,
network_requests: 0,
console_events: 0,
websocket_connections: 0,
websocket_frames: 0,
webmcp_tools: 0,
timeline_events: 0,
total: 0,
},
});
const captureCompleteness = (options: {
readonly workersUnavailable?: boolean;
readonly scriptsUnavailable?: boolean;
}) => {
const unavailableSections = [
...(options.scriptsUnavailable ? (["scripts"] as const) : []),
...(options.workersUnavailable ? (["workers"] as const) : []),
];
if (unavailableSections.length === 0) return completeCapture();
return {
...completeCapture(),
status: "attach_limited" as const,
conditions: ["attach_limited" as const],
attach_limited_sections: unavailableSections,
unavailable_sections: unavailableSections,
};
};