Repository navigation
fix(javascript): refuse member-mutation work beyond a fixed allowance - #11144
Merged
Merged
Conversation
Member-mutation indexing retained every scheduled alias state until its query finished, with no bound on the phase. Conditional self-selections before one member write (#8294) multiplied those states until the worker heap was exhausted. Charge each scheduled alias state to a per-phase work meter. Past 524,288 states the phase is refused with a resource_constraint that names the fixed work allowance. The application and web bundle workers carry the reported limit to the parent, which rebuilds the refusal with that allowance instead of heap advice. Refs #8294 #6127 #6344 #7170 #7510 #8298
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Contributor
[Medium impact] The PR appears safe to merge, with the previous coverage gap addressed. SummaryThis PR caps member-mutation work and carries the fixed-allowance refusal through both worker paths.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Schedule an alias state] --> B[Charge the source's meter]
B --> C{Allowance exceeded?}
C -->|No| D[Retain the state]
C -->|Yes| E[Throw typed resource refusal]
E --> F[Worker forwards reason and limits]
F --> G[Parent restores fixed work allowance]
Reviews (2) · Last reviewed commit: "test(javascript): prove the member-mutat..." · Reviewed by Greptile |
13 tasks
morluto
added a commit
that referenced
this pull request
Nov 15, 2026
…etting The member-mutation alias-state allowance from #11144 was a fixed constant, so a refused source could not be admitted without a code change. Register javascript.member_mutation_alias_states (default 524288, 1 to 8388608 alias states) with the launch seed REA_JAVASCRIPT_MEMBER_MUTATION_ALIAS_STATES. The application, web bundle and reference-source boundaries resolve it from the accepted operation snapshot and launch environment, refuse a malformed seed before analysis, and send it to the workers with each source. A refusal names the setting, its effective value, source and range, and the recovery; worker parents rebuild it from the allowance they sent. Refs #8294
morluto
added a commit
that referenced
this pull request
Nov 15, 2026
…etting (#11181) * feat(javascript): make the member-mutation work allowance a runtime setting The member-mutation alias-state allowance from #11144 was a fixed constant, so a refused source could not be admitted without a code change. Register javascript.member_mutation_alias_states (default 524288, 1 to 8388608 alias states) with the launch seed REA_JAVASCRIPT_MEMBER_MUTATION_ALIAS_STATES. The application, web bundle and reference-source boundaries resolve it from the accepted operation snapshot and launch environment, refuse a malformed seed before analysis, and send it to the workers with each source. A refusal names the setting, its effective value, source and range, and the recovery; worker parents rebuild it from the allowance they sent. Refs #8294 * fix(javascript): keep the setting and recovery of a refused web script A web bundle script refused by the member-mutation allowance kept only its reason and reported limits, so the public unknown lost the setting, value, source and recovery. Carry the refusal's structured limit and remediation on the per-script result and its javascript_analysis unknown, grouping scripts only when that recovery agrees. Assert structured limit facts and the owning formatter's recovery instead of fixed wording. * fix(browser): keep only registered setting limits on a refused web script * feat(javascript): keep syntax facts for a source whose member-mutation phase is refused (#11187) * feat(javascript): keep syntax facts for a source whose member-mutation phase is refused A source refused by the member-mutation work allowance during static analysis lost every fact, so the application graph counted it as skipped. Reference-source import failed outright on such a file. Checkpoint the parser, comment and text facts the static owner can still state, with parse status partial, examination not-examined and refused_phase member-mutations, before reporting the refusal; the semantic phase is not started because it indexes the same mutations. Reference-source import keeps the file's declaration-level imports and records that its CommonJS require calls were not examined. Refs #8294 * test(javascript): compare the reference-source refusal with its owning formatter * feat(javascript): keep a refused web script's parse and text facts A captured script whose member-mutation phase was refused lost every fact in analyze_web_bundle, so it was neither counted as parsed nor kept its vendor markers. The analyzer now returns the script as unavailable with partial facts: refused phase, parse status and the inferences read from script text alone. Findings gathered before the refusal are dropped, because they may have read an incomplete mutation index. The worker parent states the refusal and its setting recovery from the allowance it sent, through the same helper the isolated analyzer uses for every unavailable script. The bundle counts the script as parsed, keeps its text inferences, and its javascript_analysis unknown carries refused_phase. Refs #8294 * chore(mcp): record the member-mutation setting in the advertised summary * fix(javascript): rebuild a parked source worker when the member-mutation allowance changes A worker parked on a resource scope was reused when heap, timeout and precision matched, but its requests carry the allowance it was built with. After update_analysis_settings accepted a new allowance, the next analysis on that scope kept the old one. The reuse check now compares the allowance's value and source, so a changed setting gets a worker built with it. The web bundle worker already takes the allowance per script.
This was referenced Nov 24, 2026
2 of 20 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Member-mutation indexing in the JavaScript semantic engine had no bound on the work one source could take. A short alias history (#8294) made it keep scheduling alias states until the worker heap ran out, so the file was skipped after tens of seconds with heap advice that does not help. This PR adds a per-phase work meter. When a source passes a fixed allowance, the phase stops with a typed
resource_constraintthat names the allowance. This is step 5 of plan W10 (per-phase work meter with a fixed-ceiling refusal), applied first to the member-mutation phase, where the reports point.Refs #8294 #6127 #6344 #7170 #7510 #8298. None of them is fully fixed: each still loses that source's facts. They now get a bounded typed refusal instead of heap exhaustion or a timeout.
Problem and expected behavior
Smallest trigger: eight conditional self-selections before one member write (351 bytes, from the #8294 thread):
markValueincollectSemanticMemberMutationsStepskeeps every scheduled alias state until its query finishes. After the existingalias-selectionswidening, scheduling continues and grows about 8× per added selection. Measured onmain(in-processanalyzeJavaScriptSemantics, Node 24.22.1,--max-old-space-size=1024):[email protected]umd/react-dom.production.min.js(sha25635f4f974…6f0d) exhausts a 2 GiB heap the same way. At 1,000,000 processed states its worklist held 484,415 pending states and 1.16 GiB of heap.Expected: the phase stays bounded and the refusal says which deterministic allowance was exceeded. Raising heap or timeout does not admit the same source.
Change and scope
src/domain/javascript/javascriptSemanticWorkAllowance.ts:JavaScriptSemanticWorkMeter(one per phase run) andJAVASCRIPT_MEMBER_MUTATION_WORK_ALLOWANCE = 524_288alias states per source. Charging past it throwsAnalysisResourceConstraintError(resourcecpu, reported limitjavascript_member_mutation_alias_state_limit, fixed allowance kindwork, not retryable).javaScriptSemanticWorkAllowance(limits)rebuilds the fixed-allowance recovery from reported limits, so each process boundary derives it from one place.javascriptSemanticMemberMutations.ts: eachmarkValueschedules through oneschedulehelper that charges the phase meter before retaining the state. Charging happens at scheduling, not processing, because scheduling outruns processing (react-dom above).JavaScriptAnalysisWorker#protocolFailure): a reported work limit becomes the fixed-allowance recovery, not the heap or result-budget remediation. The worker server already forwardsAnalysisResourceConstraintErrorresource and limits.output), and the parent reported every resource frame as measured memory exhaustion. Now the server forwards the refusal asresourcewith its reportedlimits(new optional field on the failure frame). The parent maps it through the same owner to resourcecpuwith the fixed allowance. Other resource frames are unchanged.javascript-artifact-reconstruction.mddescribes the allowance next tosemantic_precision.Why a refusal and not partial results: a member-mutation index that stops partway leaves later reads with stale literals. Making every affected binding, ambient path and required-module export unknown would have to reach each index those reads consult. That is the pushed-havoc redesign (audit C1 step 3), not this bound.
Why fixed and not a
semantic_precisionfield: the plan asks for a fixed ceiling, and adding a field changes the advertised input schema. Making it caller-selectable is a follow-up decision. The value is sized from measurements, below.Not included:
alias_selections) is complementary: it narrows one query, and this PR bounds the phase. They touch the same function. This PR does not include fix(javascript): stop widened alias joins from exhausting the worker heap #8392's change.Contract and boundary impact
javascriptSemanticWorkAllowance.tsowns the allowance, meter and recovery. Consumers: member-mutation indexing (producer), the application worker parent, and the web bundle worker server and parent. No superseded path remains. The web bundle parent's two duplicated resource-frame constructions now share one helper.resource_constraint(resourcecpu, fixed work allowance) instead of a worker heap exhaustion or timeout.limitsfield. Parent and worker ship together.Expected effects:
Evidence and regression coverage
Tests added or updated:
src/domain/javascript/javascriptSemanticWorkAllowance.test.ts: the 8-selection fixture is refused with the fixed allowance (about 2 s, about 700 MiB RSS for the test process, which is the cost of reaching the allowance). The 4-selection control completes.src/domain/javascript/javascriptSemanticWorkAllowance.phase.test.ts: three write queries in one source charge one meter, and each source gets a fresh meter (fails if the meter moves intomarkValue).tests/boundary/javascript/javascriptSourceAnalysisWorker.test.ts: a worker failure frame that reports the work limit becomes resourcecpu,retryable: false, a fixedworkallowance and no remediation sentence.src/browser/WebBundleAnalysisWorkerServer.test.ts: the real worker server, with an analyzer that hits the meter, sendsreason: "resource"with the reported limit and canonical reason.src/browser/WebBundleAnalysisWorker.test.ts: the parent maps that frame to resourcecpuwith the fixed allowance.Base reproduction: with
JavaScriptAnalysisWorker.tsandWebBundleAnalysisWorker.tsrestored frommain, both parent tests fail (1 failed | 16 passedand1 failed | 34 passed). Onmainthe 8-selection fixture exhausts a 1 GiB heap (standalone run above). The server test would get anoutputframe from the old wrapper.Measurements (executed; in-process
analyzeJavaScriptSemantics, one coldtsxprocess per input, Node 24.22.1, macOS arm64, shared machine with load average 7–11, so times are noisy):Corpus within the allowance: the same 14 published bundles from
node_modulesthat fix(javascript): expose operands of unmodelled implicit execution #10631 used. Alias states scheduled per source (largest first): openpgp 122,568, rxjs 121,353, isomorphic-git 102,163, pako 66,229, docsearch 54,988, vue 33,075, zip.js 24,092, vueuse 18,880, algoliasearch 10,991, handlebars 10,397, js-yaml 6,744, preact 5,799, diff 4,798, underscore 4,237. The largest is 23% of the allowance; the largest single query (rxjs) scheduled 28,377 states, and every other query stayed at or below 307. Every value status was compared by JSON path betweenmainand this branch: 0 changes across 81,312 values, and no refusals. The semantic IR is unchanged for these sources, so agent tokens are unchanged; they were not measured separately.Sizing: retained states cost about 1.1–1.6 KiB each (react-dom: 1.16 GiB heap at 1,084,531 scheduled; 7 selections: 642 MiB RSS at 400,807). 524,288 keeps a refused source below the default 1 GiB worker heap on both fixtures. 262,144 would leave 2.1× headroom over the corpus maximum.
User-visible CLI/MCP output: not captured from a built CLI run. The refusal reason is
JavaScript member-mutation analysis scheduled more than 524288 alias states for one source. Recovery names "The JavaScript member-mutation work allowance" as a fixed work allowance.Remaining proof gaps: no end-to-end
rea analyze-javascript-applicationoranalyze-web-bundlerun on react-dom. Elapsed-time numbers are single cold runs on a loaded machine. Large real bundles from analyze-javascript-application: semantic phase never completes on a 6.5 MB minified Electron main.js (3 timeouts, incl. reduced semantic limits) #7170 (6.5 MB) and [Bug] analyze-javascript-application never completes on a 20 MB Expo Router web bundle, even with semantic limits at 1 #7510 (20 MB) are unavailable locally. They may now be refused instead of running until the deadline, which loses no facts they currently return but is unmeasured.Observed, derived, and inferred claims remain distinguishable.
Artifact identity, source provenance, and failed attempts remain preserved.
Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.
Validation performed
npm run test:local -- src/domain/javascript/javascriptSemanticWorkAllowance.test.ts src/browser/WebBundleAnalysisWorkerServer.test.ts— 8 passed.npm run test:local -- src/domain/javascript/javascriptSemanticWorkAllowance.phase.test.ts— 2 passed (2 failed with the meter moved intomarkValue).npm run test:local -- src/browser/WebBundleAnalysisWorker.test.ts— 35 passed (1 failed with the parent change reverted).npm run test:focused -- tests/boundary/javascript/javascriptSourceAnalysisWorker.test.ts— 17 passed (1 failed with the parent change reverted).npm run test:local -- src/domain/javascript/javascriptMemberMutationCoverage.test.ts src/domain/javascript/javascriptSemanticAnalysis.execution_points.test.ts src/domain/javascript/javascriptSemanticExecutionPoints.test.ts— 78 passed.npm run check:fast— passed.npm run docs:check— passed.node scripts/verify/architecture-guards.mjs— passed.npx oxfmt --checkon changed files — passed.Compatibility, safety, and release
Author readiness
Human owner:
Before merge
type(scope): outcome.