mirror of
https://github.com/morluto/rea
synced 2026-10-27 22:45:19 -04:00
fix(javascript): mark resource-skipped files parse_status skipped (#3852)
* fix(javascript): mark resource-skipped files parse_status skipped Files above ~5 MB exhaust the worker heap during static analysis (or exceed the 8 MB static-checkpoint budget with a larger heap). They were inventoried with text included but never parsed, leaving parse_status null and no counter, so the summary read as 'nothing there' instead of 'not analyzed'. Report them as skipped: parse_status 'skipped' on the file observation and a skipped_javascript_files statistics counter. The analysis-failure reason keeps surfacing as a limitation entry. Fixes #3670 * fix(javascript): default skipped_javascript_files when reading old saved evidence Saved analysis evidence written before skipped_javascript_files existed failed validation against the strict reconstruction statistics schema, so users could not reuse old results for comparisons or runtime reconciliation. Accept the field's absence on read (defaulting to 0) while continuing to write it for new results. * fix(javascript): preserve unknown skipped count for legacy evidence The .default(0) gate fix fabricated a measured zero for saved pre-change evidence, so comparisons would receive a definitive "no files skipped" fact the producer never established. Use the codebase's exactOptional idiom instead: legacy reads accept absence and keep omission (unknown), while the producer still always writes the field (required by JavaScriptArtifactReconstructionResult). Tests: legacy payload now asserts the key stays absent/undefined; current-output test keeps asserting the producer-written counter. * fix(javascript): add required failure scope and status to graph fixture --------- Co-authored-by: Saim Shafique <sx4im@users.noreply.github.com>
This commit is contained in:
@@ -324,3 +324,29 @@ describe("graphs transferred to their sealing steps", () => {
|
||||
).toEqual(issuesFrom(() => createJavaScriptApplicationGraph(stale)));
|
||||
});
|
||||
});
|
||||
|
||||
describe("skipped_javascript_files backward compatibility", () => {
|
||||
it("preserves omission for saved evidence that predates the skipped counter", () => {
|
||||
const legacy = structuredClone(
|
||||
JAVASCRIPT_APPLICATION_EVIDENCE_EXAMPLE.normalized_result,
|
||||
) as Record<string, unknown>;
|
||||
const statistics = legacy.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();
|
||||
});
|
||||
|
||||
it("keeps the producer-written skipped count in current evidence", () => {
|
||||
const current = structuredClone(
|
||||
JAVASCRIPT_APPLICATION_EVIDENCE_EXAMPLE.normalized_result,
|
||||
) as Record<string, unknown>;
|
||||
const statistics = current.statistics as Record<string, unknown>;
|
||||
statistics.skipped_javascript_files = 3;
|
||||
const result = javascriptApplicationAnalysisResultSchema.parse(current);
|
||||
expect(result.statistics.skipped_javascript_files).toBe(3);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user