refactor(virtual): share one merge memory budget, part 1/5
Summary
Part 1 of 5 of a stack of merge requests (each targets the previous one; review and merge bottom-up) that bounds the npm virtual metadata merge's memory with a charged parse and a shared merge memory budget, as the Maven virtual merge already does (#1524 (closed)).
No plan file exists for this work: the work item graded as needing a spec amendment first, and the operator chose to ship the S13 (virtual-remote-foundation), S30 (maven-virtual) and S31 (npm-virtual) amendments in this stack instead of a plan MR.
This part moves Maven's merge memory budget into a shared internal/virtual.MergeBudget and wires one process-wide instance. Behavior is unchanged for Maven: the budget is derived once from GOMEMLIMIT as before (the config field moves from the Maven section to the virtual-repositories section, and the boot log names it as the virtual merge budget), and a zero derived budget now logs a boot warning. npm does not use the budget until part 4.
Governing ADRs
ADR 004 (entity-count limits, 20 upstreams per virtual) supplies the limits the merge keeps; read for a conflict, none found. This part changes where the budget lives, not what it admits.
Testing
- The Maven cap suite moves with the type to
internal/virtual, plus a zero-value test; the Maven suites change only in how they construct the budget. - Config derivation tests cover the moved field and the zero-budget warning.
- Build, vet and the unit tests of
internal/virtual,internal/config,internal/format/mavenandcmd/artifact-registrypass at this part. Integration-tagged tests were not run locally; CI runs them. - No e2e row is added or affected: budget exhaustion needs a controlled
GOMEMLIMITthat no black-box scenario can set. Nodocs/userchange: no user page covers virtual merge budgets.
Plan and spec amendments
- S13 (virtual-remote-foundation): new section stating the one process-wide merge memory budget, its derivation from
GOMEMLIMIT, admission, outcomes, what it bounds, and acceptance criteria. - S30 (maven-virtual): the Maven merge cap text now points at S13 instead of owning the budget.
Size
653 reviewable lines as GitLab renders the diff (727 by git diff --numstat, which counts the moved Maven cap test as added and removed): about 208 production, 456 tests, 56 specs, 7 other docs by the numstat count. The slice cannot be smaller: the type, its moved test suite, the Maven call sites and the config move have to land together or Maven would sit on two budgets.
Stacked MRs (review/merge bottom-up)
- refactor(virtual): share one merge memory budge... (!3184 - merged) • David Fernandez • 19.5
👈 - feat(npm): charge the merge parse's retained st... (!3185 - merged) • David Fernandez • 19.5
- feat(npm): hold the merge tail at its encoded s... (!3186 - merged) • David Fernandez • 19.5
- feat(npm): admit the virtual merge against the ... (!3187 - merged) • David Fernandez, Dzmitry (Dima) Meshcharakou • 19.6
- feat(npm): hold the merge budget until the stre... (!3188 - merged) • David Fernandez, Dzmitry (Dima) Meshcharakou • 19.6
Related to #1524 (closed)