fix(javascript): recover webpack chunks with array module tables #13829
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.52) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #13829"
general
weight: 0.35
thejesh23
Summary
analyze-javascript-applicationrecovered no modules from webpack chunks whose module table is a sparse array, and from webpack 4 chunks registered onwebpackJsonp. The files'candidate_enumerationstill readcomplete. Webpack writes a sparse array whenever numeric module ids are dense. That is the normal output of webpack 4 production builds, and of webpack 5 withoptimization.moduleIds: "natural"or"size". The docs say chunk registrations "represented as AST literals" are recovered.Chunk registration now reads object, sparse-array and
Array(n).concat([...])tables, and treatswebpackJsonpas a chunk runtime.No linked issue. This came out of an audit and is a small fix within the existing recovery boundary, so the write-up is here rather than in a separate issue.
Problem and expected behavior
concatenateModules: false, once withmoduleIds: "deterministic"and once with"natural". The natural build's chunk is(self.webpackChunk=self.webpackChunk||[]).push([[1],[,,(e,n,r)=>{…},(e,n,r)=>{…}]]). A webpack 4 chunk is(window.webpackJsonp=window.webpackJsonp||[]).push([[0],[function(e,t,n){…},…]]).inspectBundlerRegistrationreturned early unless the table was anObjectExpression.findChunkRuntimematched only/(?:webpack|rspack)Chunk/. The chunk gave no registration and no unknown finding.Array(n).concatoffset, is its module id. Holes are absent ids. Elements that aren't function literals are skipped, as non-factory object properties already are. Arrays containing spreads stay unrecognised, because their indexes aren't literal.Change and scope
javascriptStaticAnalysisHelpers.ts: amoduleTableEntrieshelper yields{ key, factory }slots for an object table (via the existingmodulePropertyName/moduleFactory) or an array table.CHUNK_RUNTIME_NAMEaddswebpackJsonp, and the webpack vendor markers addwebpackJsonptoo. Without that, a minified webpack 4 chunk returnedbundler: "webpack"registrations whilevendors(and the artifact graph'svendor_markers) stayed empty.javascriptStaticAnalysisBundler.ts:recoverBundlerModulestakes those slots. Object tables produce the same keys and factories in the same order as before, so the bootstrap and esbuild paths are unchanged.var r=[,e=>{…}]in a natural-id entry bundle). That table also feedsjavascriptBootstrapIntegrity,javascriptBundledRequireOriginandjavascriptSymbolicBindings, which read.properties. Widening it touches those proofs and is left for a follow-up. The guide line says bootstrap tables are recovered only in object form.Array(n).concatis recovered only when the existing semantic model proves the native binding, unchanged concat behavior and valid array lengths. Shadowing, reassignment and visible inherited-slot mutations remain unresolved.Contract and boundary impact
inspectBundlerRegistration). Downstream consumers see morebundler_registrations[].modulesand module ranges.Evidence and regression coverage
src/domain/javascript/javascriptStaticAnalysisArrayModuleTables.test.tscovers:- a natural-id chunk;
- webpack 4
webpackJsonpchunks with array and object tables, and theirwebpackvendor marker;- an
Array(7).concat([…,,…])offset table;- an array of non-functions, which registers the chunk keys with no modules.
All 4 fail on the base revision
d979c1849(expected [] to deeply equal [ [ '2', '3' ] ], …) and pass with the change.- Before = built CLI at
9560457.- After = this branch on
d979c1849.- Node 24.22.1, macOS arm64.
- Command:
rea analyze-javascript-application <dir> --json | jq -c '.normalized_result.statistics|{modules,findings}'| Input | Before | After |
|---|---|---|
|
moduleIds: "deterministic"(object tables) |{"modules":3,"findings":6}|{"modules":3,"findings":6}||
moduleIds: "natural"(array chunk + array bootstrap) |{"modules":0,"findings":3}|{"modules":2,"findings":5}. The bootstrap's own module is the follow-up above. || webpack 4
webpackJsonparray + object chunks, webpack 5 array + object chunks |{"modules":2,"findings":1}|{"modules":8,"findings":6}|- Standalone bootstrap tables in array form are not covered.
- Not run against a large real-world webpack 4 application.
Validation performed
All on Node 24.22.1, macOS arm64.
npx vitest run src/domain/javascript- Base: 200 files / 6180 tests passed.
- With the change: 6183 passed and 1 failed, a 30 s timeout under machine load (load average about 7).
- A second run timed out in
electronWrappedCallPaths.test.tsandjavascriptSemanticAnalysis.builtin_defaults.test.ts.- Both files pass when run alone with the change: 382/382, the slow test in 1.8 s. Neither is touched by this change.
npx vitest run tests/boundary/filesystem/javascript-applications/javascriptBundlerAdapters.test.ts tests/boundary/filesystem/javascript-applications/javascriptRuntimeReconciliation.test.ts— 22 passed.npm run build:cached, thennpx vitest run tests/boundary/cli/javascriptBundlerRuntimeScopes.test.ts tests/boundary/cli/javascriptBundlerSelfReferences.test.ts tests/acceptance/applications/webpackLoaderReturnsCli.test.ts tests/acceptance/applications/webpackRenamedExportsCli.test.ts— 21 passed.npm run check:fast— passed (typecheck, lint, architecture guards).vendorsassertion failed on 0633dfa (expected [] to deeply equal [ 'webpack' ]) and passes now.npx vitest run src/domain/javascriptpassed (201 files / 6184 tests), andcheck:fast,format:check,metadata:check,knip:productionanddocs:checkall passed.lint:typed(3 errors) andknipfail only in files this PR doesn't touch.npm run format:check,npm run metadata:check,npm run knip:production,npm run docs:check— passed.npm run knip— fails onUefiLzmaStreamRequest(src/uefi/UefiLzmaProtocol.ts:21). It reports the same on an unmodifiedd979c1849checkout, so this change didn't cause it.npm run lint:typed— 1 error, insrc/domain/webModuleImports.ts(switch-exhaustiveness-check). That file is untouched here. No new diagnostics in the changed files.Compatibility, safety, and release
Maintainer validation
Array offsets now require the native Array binding, unchanged concat semantics and valid uint32 array lengths. Visible inherited-index mutations use the existing array-iteration uncertainty owner. Holes remain absent and no leading-hole array is allocated.
Author readiness
Human owner: @thejesh23
Before merge
type(scope): outcome.🤖 Generated with Claude Code