feat(javascript)!: require JavaScript application and source-map fields that were optional only for historical Evidence (#10958)

* feat(managed)!: require managed Evidence fields that were defaulted only for historical Evidence

Member inspections, comparisons, verification results and application graphs
require every field their producers write. nesting_read is boolean and the
bare-name comparison mode for historical observations is deleted;
signature_resolution loses type-names-v1. The unavailable-metadata member
result now writes assembly: null instead of relying on a default.

BREAKING CHANGE: managed records missing these fields are refused as
malformed; recreate the observation.

* docs(managed): drop the remaining historical-omission claims for member Evidence

* docs(process): describe process capture omissions by their current meaning

raw_data is omitted when it equals data and residual_unknowns when a failure
retained none; neither omission describes historical Evidence.

* feat(javascript)!: require JavaScript application and source-map fields that were optional only for historical Evidence

skipped_javascript_files, protocol_registrations and the original-source and
module-edge source_index/declaration_index links are always written by their
producers and are now required.

BREAKING CHANGE: results missing these fields are refused as malformed;
recreate the observation.

* test(browser): refuse original-source rows without their source or declaration index
This commit is contained in:
morluto authored and GitHub committed 2026-11-15 18:23:32 +08:00
1 parent 536c54ca1f
commit 659772952d
4 files changed
+38 -32

No files matched your search

@@ -56,8 +56,7 @@ const electronBoundarySummarySchema = z.strictObject({
resolved_utility_entrypoints: countSchema,
native_addon_bindings: countSchema,
resolved_native_addon_bindings: countSchema,
/** Absent in evidence produced before protocol registrations were reported. */
protocol_registrations: countSchema.exactOptional(),
protocol_registrations: countSchema,
/** `node:vm` compilations whose logic may live in an opaque bytecode cache. */
v8_cached_data_compilations: countSchema.exactOptional(),
/**
@@ -82,10 +81,7 @@ const reconstructionStatisticsSchema = z.strictObject({
text_bytes_read: countSchema,
invalid_utf8_files: countSchema,
parsed_javascript_files: countSchema,
// Old saved evidence predates this field: absence must stay unknown, not
// become a measured zero. The producer always writes it (required by the
// application-layer result type); readers treat a missing value as unknown.
skipped_javascript_files: countSchema.exactOptional(),
skipped_javascript_files: countSchema,
visited_ast_nodes: countSchema,
findings: countSchema,
modules: countSchema,
@@ -102,7 +102,6 @@ describe("immutable JavaScript result reuse", () => {
it("borrows imported immutable results only after complete format validation", () => {
const input = example();
delete input.statistics.skipped_javascript_files;
freezeJsonSnapshot(input);
const result = complete(
parseOwnedJavaScriptApplicationAnalysisSteps(input),
@@ -111,7 +110,6 @@ describe("immutable JavaScript result reuse", () => {
expect(result).toEqual(
javascriptApplicationAnalysisResultSchema.parse(input),
);
expect(result.statistics).not.toHaveProperty("skipped_javascript_files");
expect(complete(parseOwnedJavaScriptApplicationAnalysisSteps(input))).toBe(
input,
);
@@ -426,19 +424,17 @@ describe("graphs transferred to their sealing steps", () => {
});
});
describe("skipped_javascript_files backward compatibility", () => {
it("preserves omission for saved evidence that predates the skipped counter", () => {
const legacy = structuredClone(
describe("skipped_javascript_files", () => {
it("refuses a result without the skipped counter", () => {
const withoutCounter = structuredClone(
JAVASCRIPT_APPLICATION_EVIDENCE_EXAMPLE.normalized_result,
) as Record<string, unknown>;
const statistics = legacy.statistics as Record<string, unknown>;
const statistics = withoutCounter.statistics as Record<string, unknown>;
delete statistics.skipped_javascript_files;
const result = javascriptApplicationAnalysisResultSchema.parse(legacy);
// A pre-change result can contain the very resource-skipped files this
// field reports, but it has no counter: unknown must not become a
// measured zero that comparisons would treat as "nothing skipped".
expect("skipped_javascript_files" in result.statistics).toBe(false);
expect(result.statistics.skipped_javascript_files).toBeUndefined();
expect(
javascriptApplicationAnalysisResultSchema.safeParse(withoutCounter).error
?.issues[0]?.path,
).toEqual(["statistics", "skipped_javascript_files"]);
});
it("keeps the producer-written skipped count in current evidence", () => {
@@ -452,14 +448,15 @@ describe("skipped_javascript_files backward compatibility", () => {
});
});
describe("Electron boundary summary compatibility", () => {
it("reads results produced before protocol registrations were counted", () => {
describe("Electron boundary summary", () => {
it("refuses a summary without the protocol registration count", () => {
const current = example();
const { protocol_registrations: _count, ...summary } = current.summary;
const parsed = javascriptApplicationAnalysisResultSchema.parse({
...current,
summary,
});
expect(parsed.summary).not.toHaveProperty("protocol_registrations");
expect(
javascriptApplicationAnalysisResultSchema.safeParse({
...current,
summary,
}).error?.issues[0]?.path,
).toEqual(["summary", "protocol_registrations"]);
});
});