perf(electron): build the Next standalone once and hydrate natives per leg (#10321 stage 8/8) - #10390
Conversation
6dfbcaf to
f0e7ae2
Compare
f0e7ae2 to
99b3d58
Compare
a766fe4 to
8856988
Compare
…#9985) (#10396) `check:dead-code` reports 410 dead symbols against a 409 baseline on the pristine `release/v3.8.50` tip, so every PR on the branch is born red on that gate (#10386, #10393, #10390, #10388, #10382 all fail it). Isolated the +1 by diffing knip 6.32 reports between the rebaseline commit 97aac6a (409) and the tip (410): `resolveOpencodeConfigDir` in `src/shared/services/cliRuntime.ts`. #10246 moved the canonical resolvers into `opencodeConfigPath.ts` and left this wrapper behind; the same commit removed its last consumer. The wrapper was not just unused, it was divergent: it returned `path.dirname()` of the canonical value — `~/.config` rather than `~/.config/opencode` — so any future caller reaching for it by name would have written the OpenCode config one directory too high. Removed the wrapper and its now-unused import. A new test pins the canonical resolver's contract and asserts the divergent re-export stays gone; the guard was mutation-validated (re-adding the wrapper fails it). check:dead-code: 409 = baseline, PASS. cliRuntime/opencode suites: 51 pass, 0 fail. New guard: 3 pass, 0 fail. lint / typecheck:core / file-size / complexity-ratchets / test-discovery: green. Co-authored-by: Xiangzhe <bakryun0718@proton.me>
6e5904f to
3fd0d93
Compare
|
Thanks for this — Stage 8 closes out the roadmap nicely and the engineering here is solid. I ran the new test suite independently against your head commit ( One thing worth fixing before merge: Everything else looks ready as-is. Nice work on the deterministic tar/manifest layer — the zip-slip protection and byte-level tamper detection are a genuinely good addition on top of the runner-minute savings. |
3fd0d93 to
bc5bee5
Compare
|
Addressed the requested item in commit bc5bee5: the Linux release matrix now passes x64,arm64 to the hydration verification, covering both architectures packaged by that job. The standalone bundle suite passes 7/7, and the workflow YAML validates with the updated matrix value. Please take another look when you have a chance. |
480c372 to
08c98bd
Compare
…r leg (diegosouzapw#10321 stage 8) The desktop release matrix ran the full Next.js standalone build on all four legs (windows, macos-intel, macos-arm64, linux), duplicating the platform-neutral majority of that work four times and re-exposing every leg to the hosted-runner RAM class of failure that took the linux leg out of v3.8.49. - scripts/build/standaloneTarball.mjs: deterministic, dependency-free tar.gz writer/reader (uid/gid/mtime pinned, sorted entries, symlink + exec-bit preservation; GNU-tar interop covered by tests). - scripts/build/standaloneManifest.mjs: byte-level manifest of .build/next (sha256 + size + symlink target per entry, plus the archive's own digest) catching artifact-transfer corruption before extraction and re-verifying the restored tree byte-for-byte, smuggling included. - scripts/build/standaloneBundle.mjs: pack / restore / hydrate CLI over the two modules above. - scripts/build/hydrateNativeDeps.mjs: swaps install-machine-forked native optionals (@img/sharp-*, @ngrok/ngrok-*, fsevents) from the leg's own npm ci into the restored tree, then verifies the bundled-native closure (koffi triplets, better-sqlite3 prebuilds, wreq-js, onnxruntime with its documented darwin-x64 exemption) services the leg's platform/arch before packaging starts. - .github/workflows/electron-release.yml: new web-build job builds the standalone once on ubuntu with webpack and uploads the bundle; legs download, restore, and hydrate it, skipping the per-leg build. The legacy per-leg build remains as a rollback path via the ELECTRON_SHARED_STANDALONE workflow_dispatch input, and legs fail closed if web-build ran and failed. Regression tests cover archive roundtrip, byte determinism, manifest tamper/smuggle detection, forked-native swaps, and native-closure serviceability.
08c98bd to
b31c629
Compare
|
Validated in local merge-train |
Summary
Stage 8 of the Electron efficiency roadmap (#10321): the desktop release matrix currently runs the full Next.js standalone build on all four legs (windows, macos-intel, macos-arm64, linux), duplicating the platform-neutral majority of that work four times, and re-exposing every leg to the hosted-runner RAM failure class that took the linux leg out of v3.8.49.
This PR builds the standalone once in a new
web-buildjob (ubuntu, webpack — the same RAM escape hatch the linux leg already documents) and has each leg restore + hydrate it:scripts/build/standaloneTarball.mjs— deterministic, dependency-free tar.gz writer/reader (uid/gid/mtime pinned, sorted entries, symlink + exec-bit preservation; GNU-tar interop covered by tests)scripts/build/standaloneManifest.mjs— byte-level manifest of.build/next(sha256 + size + symlink target per entry, plus the archive's own digest); catches artifact-transfer corruption before extraction and re-verifies the restored tree byte-for-byte (unlisted/smuggled files rejected)scripts/build/standaloneBundle.mjs—pack/restore/hydrateCLIscripts/build/hydrateNativeDeps.mjs— swaps install-machine-forked native optionals (@img/sharp-*,@ngrok/ngrok-*,fsevents) from the leg's ownnpm ciinto the restored tree, then asserts the bundled-native closure (koffi triplets, better-sqlite3 prebuilds, wreq-js, onnxruntime — with its documented darwin-x64 exemption) services the leg'smatrix.os/matrix.archbefore packaging starts.github/workflows/electron-release.yml— newweb-buildjob; legs download → restore → hydrate and skip the per-leg buildRollback & failure semantics
ELECTRON_SHARED_STANDALONEworkflow_dispatch input isdisabled(or the shared job was skipped) — a single-input revert to the v-prior behavior.web-buildran and failed, legs do not silently fall back to four per-leg builds; the matrix job condition treats it as a hard failure so the regression the shared job exists to surface stays visible..build/nextexactly as before; restore verifies the tree is byte-identical to whatweb-buildproduced, then hydrate makes it platform-correct.Measurements (issue gate 4 baseline)
Local verification
node --test tests/unit/build/standalone-bundle.test.ts— 7/7 (roundtrip incl. symlinks/exec bits, byte determinism, GNU-tar interop, tamper + smuggle detection, forked-native swap, native-closure serviceability + darwin-x64 exemption)js-yamlandpython3 yaml.safe_loadNotes for reviewers
release/v3.8.50(dead-code gate,open-ssetypecheck,models-catalog-routeunit) is reproduced on cleanf06d5f20ewith zero repo changes and affects every open PR — not introduced here (same triage as perf(electron): prune authoring docs from desktop packages (5/8) #10359).Closes the stage-8 implementation gates of #10321 (runner-minute comparison to be appended after the first release run).