Skip to content

Make Codex and Claude Code subscriptions go further: a local model router that gives routine agent work to economical models and keeps your strongest model for the hard parts.

fix(release): pin Node in native Linux build images (#175)

澄潭2798b70410b8
diff --git a/docs/release-builds.md b/docs/release-builds.md
index c6431525..fa3514b9 100644
--- a/docs/release-builds.md
+++ b/docs/release-builds.md
@@ -23,6 +23,13 @@ sccache and native build tools. Linux additionally requires Docker: the same
command enters the pinned glibc 2.31 build image and then a separate minimal
runtime image. Host distribution libraries are never used as the release ABI
baseline. The native architecture check applies to the host and both containers.
+Linux frontend preparation uses Node from the pinned build image, not the host.
+The policy pins its version and each native architecture's official archive
+SHA-256 from [Node's published checksums](https://nodejs.org/dist/v22.19.0/SHASUMS256.txt).
+The image verifies the download before extraction and checks Node/npm execution;
+candidate evidence records both versions. Mounting an arbitrary host Node would
+couple the build to that binary's host libc requirements, outside the fixed
+glibc 2.31 environment. Node is a build tool and is not added to the release payload.
The CPA checkout must contain the commit in `vendor/cpa/source.json`; its current
branch does not select the source. Invoke from the clean candidate checkout:
diff --git a/scripts/build-release.py b/scripts/build-release.py
index 28fb848c..73391119 100644
--- a/scripts/build-release.py
+++ b/scripts/build-release.py
@@ -137,6 +137,14 @@ class Candidate:
raise ValueError("external Cargo targets are forbidden")
self.version = json.loads((REPO / "apps/desktop/src-tauri/tauri.conf.json").read_text())["version"]
module("package-desktop").validate_release_versions(self.version)
+ self.result["toolchain"] = {}
+ if not self.target.endswith("-apple-darwin"):
+ npm = "npm.cmd" if self.target.endswith("-pc-windows-msvc") else "npm"
+ try:
+ for name, executable in (("node", "node"), ("npm", npm)):
+ self.result["toolchain"][name] = self.run(executable, "--version")
+ except FileNotFoundError as error:
+ raise ValueError(f"standalone release requires Node.js and npm on PATH; missing: {error.filename}") from error
metadata = json.loads(self.run("cargo", "metadata", "--locked", "--no-deps", "--format-version", "1"))
if Path(metadata["target_directory"]).resolve() != REPO / "target":
raise ValueError("Cargo config must use checkout-local target/")
@@ -147,7 +155,7 @@ class Candidate:
raise ValueError("Linux release must run inside the pinned glibc 2.31 build image")
self.result["linux_baseline"] = baseline
self.result["version"] = self.version
- self.result["toolchain"] = {name: self.run(name, "--version") for name in ("cargo", "rustc")}
+ self.result["toolchain"].update({name: self.run(name, "--version") for name in ("cargo", "rustc")})
def desktop(self):
arch = "arm64" if self.target.startswith("aarch64-") else "x86_64"
diff --git a/scripts/linux-release-baseline.json b/scripts/linux-release-baseline.json
index ba13d652..5be611a8 100644
--- a/scripts/linux-release-baseline.json
+++ b/scripts/linux-release-baseline.json
@@ -5,9 +5,10 @@
"build_image": "python:3.12.11-bullseye@sha256:7cc929040c5e8cf6036c5099d62a83708427c131fb7a7c965b5ba51e995eea1c",
"runtime_image": "python:3.12.11-slim-bullseye@sha256:411fa4dcfdce7e7a3057c45662beba9dcd4fa36b2e50a2bfcd6c9333e59bf0db",
"apt_snapshot": "20250815T000000Z",
+ "node_version": "22.19.0",
"targets": {
- "x86_64-unknown-linux-gnu": {"platform": "linux/amd64", "machine": 62, "interpreter": "/lib64/ld-linux-x86-64.so.2"},
- "aarch64-unknown-linux-gnu": {"platform": "linux/arm64", "machine": 183, "interpreter": "/lib/ld-linux-aarch64.so.1"}
+ "x86_64-unknown-linux-gnu": {"platform": "linux/amd64", "machine": 62, "interpreter": "/lib64/ld-linux-x86-64.so.2", "node_arch": "x64", "node_sha256": "c0649af18e6a24f6fe5535a3e86b341dd49a8e71117c8b68bde973ef834f16f2"},
+ "aarch64-unknown-linux-gnu": {"platform": "linux/arm64", "machine": 183, "interpreter": "/lib/ld-linux-aarch64.so.1", "node_arch": "arm64", "node_sha256": "0b2d9f564b6594222a62c82e1df2efe119dd4a4aff29644f4dd325bf360b6bcc"}
},
"symbol_versions": {"GLIBC": "2.31", "GLIBCXX": "3.4.28", "CXXABI": "1.3.12", "GCC": "4.8.0", "OPENSSL": "1.1.1"},
"system_libraries": ["libc.so.6", "libm.so.6", "libpthread.so.0", "libdl.so.2", "librt.so.1", "libresolv.so.2", "libutil.so.1", "libgcc_s.so.1", "libstdc++.so.6", "libssl.so.1.1", "libcrypto.so.1.1", "ld-linux-x86-64.so.2", "ld-linux-aarch64.so.1"]
diff --git a/scripts/linux-release-container.py b/scripts/linux-release-container.py
index 88f5d9bb..0b8f9cf9 100644
--- a/scripts/linux-release-container.py
+++ b/scripts/linux-release-container.py
@@ -55,7 +55,10 @@ def run(target, source_repo):
docker_build = ['docker', 'build', '--platform', policy['targets'][target]['platform'],
'--provenance=false', '--network', 'host',
'--build-arg', 'BASE_IMAGE=' + policy['build_image'],
- '--build-arg', 'APT_SNAPSHOT=' + policy['apt_snapshot']]
+ '--build-arg', 'APT_SNAPSHOT=' + policy['apt_snapshot'],
+ '--build-arg', 'NODE_VERSION=' + policy['node_version'],
+ '--build-arg', 'NODE_ARCH=' + policy['targets'][target]['node_arch'],
+ '--build-arg', 'NODE_SHA256=' + policy['targets'][target]['node_sha256']]
# Docker resolves each value from its inherited environment. Standard
# proxy build args are excluded from image history/cache provenance.
for name in proxy_names:
diff --git a/scripts/linux-release.Dockerfile b/scripts/linux-release.Dockerfile
index 5b8faeaa..2a2fbe72 100644
--- a/scripts/linux-release.Dockerfile
+++ b/scripts/linux-release.Dockerfile
@@ -6,6 +6,20 @@ RUN printf 'deb [check-valid-until=no] https://snapshot.debian.org/archive/debia
&& printf 'deb [check-valid-until=no] https://snapshot.debian.org/archive/debian-security/%s/ bullseye-security main\n' "$APT_SNAPSHOT" >> /etc/apt/sources.list \
&& rm -f /etc/apt/sources.list.d/* \
&& apt-get update \
- && apt-get install --yes --no-install-recommends cmake clang pkg-config binutils \
+ && apt-get install --yes --no-install-recommends cmake clang pkg-config binutils ca-certificates curl xz-utils \
&& rm -rf /var/lib/apt/lists/* \
&& test "$(getconf GNU_LIBC_VERSION)" = 'glibc 2.31'
+
+# Official checksums: https://nodejs.org/dist/v22.19.0/SHASUMS256.txt
+# The policy selects the native archive; host Node binaries are not mounted.
+ARG NODE_VERSION
+ARG NODE_ARCH
+ARG NODE_SHA256
+RUN curl --fail --location --retry 3 --proto '=https' --tlsv1.2 \
+ "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${NODE_ARCH}.tar.xz" \
+ --output /tmp/node.tar.xz \
+ && printf '%s /tmp/node.tar.xz\n' "$NODE_SHA256" | sha256sum --check --strict \
+ && tar --extract --xz --file /tmp/node.tar.xz --directory /usr/local --strip-components=1 --no-same-owner \
+ && rm /tmp/node.tar.xz \
+ && test "$(node --version)" = "v${NODE_VERSION}" \
+ && npm --version
diff --git a/scripts/test-build-release.py b/scripts/test-build-release.py
index e698038a..15a4eb06 100644
--- a/scripts/test-build-release.py
+++ b/scripts/test-build-release.py
@@ -75,7 +75,7 @@ class CandidateTests(unittest.TestCase):
return ""
if args[:2] == ("cargo", "metadata"):
return json.dumps({"target_directory": str(self.root / "target")})
- if args[0] in ("cargo", "rustc") and args[1] == "--version":
+ if args[0] in ("cargo", "rustc", "node", "npm", "npm.cmd") and args[1] == "--version":
return "fixture toolchain"
if args[0] in ("npm", "npm.cmd"):
if args[1:3] == ("run", "build"):
@@ -134,6 +134,8 @@ class CandidateTests(unittest.TestCase):
store.return_value.locked.return_value = nullcontext()
result = self.candidate.build()
self.assertEqual(result["status"], "awaiting_runtime")
+ self.assertEqual(result["toolchain"]["node"], "fixture toolchain")
+ self.assertEqual(result["toolchain"]["npm"], "fixture toolchain")
self.assertEqual(set(result["linux_abi"]["files"]), {"bin/hiroute", "bin/hirouted", "libexec/cliproxyapi"})
self.assertEqual(result["website_artifact"]["architecture"], "aarch64")
self.assertEqual(sum(args[:3] == ("npm", "run", "build") for args in self.commands), 1)
@@ -156,6 +158,30 @@ class CandidateTests(unittest.TestCase):
archive.write_bytes(b"tampered")
self.assertNotEqual(subprocess.run(command, capture_output=True).returncode, 0)
+ def test_missing_frontend_tools_fail_before_frontend_cpa_or_rust_build(self):
+ for missing in ("node", "npm"):
+ self.commands.clear()
+
+ def command(*args, **kwargs):
+ if args[0] == missing:
+ self.commands.append(args)
+ raise FileNotFoundError(2, "No such file or directory", missing)
+ return self.command(*args, **kwargs)
+
+ with self.subTest(missing=missing), \
+ patch.object(self.candidate, "run", side_effect=command), \
+ patch.object(self.candidate, "script") as script, \
+ patch.object(MODULES["package-desktop"], "ensure_sccache_server") as sccache, \
+ self.assertRaisesRegex(ValueError, "Node.js and npm on PATH; missing: " + missing):
+ self.candidate.build()
+ script.assert_not_called()
+ sccache.assert_not_called()
+ self.assertFalse(any(args[0] == "cargo" for args in self.commands))
+ self.assertFalse(any(args[:2] == ("npm", "ci") for args in self.commands))
+ result = json.loads((self.candidate.output / "result.json").read_text())
+ self.assertEqual(result["status"], "failed")
+ self.assertIn("missing: " + missing, result["error"])
+
def test_archive_with_new_glibc_requirement_cannot_produce_accepted_assets(self):
def newer(*args, **kwargs):
if args[0] == "readelf":
@@ -214,6 +240,8 @@ class CandidateTests(unittest.TestCase):
def test_windows_candidate_is_verified_as_native_pe_and_consumed_by_release_verifier(self):
result = self.build_windows_candidate()
self.assertEqual(result["status"], "awaiting_runtime")
+ self.assertIn(("npm.cmd", "--version"), self.commands)
+ self.assertEqual(result["toolchain"]["npm"], "fixture toolchain")
self.assertNotIn("website_artifact", result)
self.assertNotIn("assets", result)
self.assertEqual(result["publication"], "internal-only")
diff --git a/scripts/test-linux-release.py b/scripts/test-linux-release.py
index 613a6380..4743c17d 100644
--- a/scripts/test-linux-release.py
+++ b/scripts/test-linux-release.py
@@ -127,6 +127,18 @@ Version needs section '.gnu.version_r' contains 1 entry:
for key in ('build_image', 'runtime_image'):
self.assertRegex(policy[key], r'@sha256:[a-f0-9]{64}$')
self.assertEqual(set(policy['targets']), {'x86_64-unknown-linux-gnu', 'aarch64-unknown-linux-gnu'})
+ self.assertEqual(policy['node_version'], '22.19.0')
+ expected = {
+ 'x86_64-unknown-linux-gnu': ('x64', 'c0649af18e6a24f6fe5535a3e86b341dd49a8e71117c8b68bde973ef834f16f2'),
+ 'aarch64-unknown-linux-gnu': ('arm64', '0b2d9f564b6594222a62c82e1df2efe119dd4a4aff29644f4dd325bf360b6bcc'),
+ }
+ for target, values in expected.items():
+ self.assertEqual((policy['targets'][target]['node_arch'], policy['targets'][target]['node_sha256']), values)
+ recipe = (ROOT / 'linux-release.Dockerfile').read_text()
+ self.assertIn('node-v${NODE_VERSION}-linux-${NODE_ARCH}.tar.xz', recipe)
+ self.assertIn('"$NODE_SHA256" | sha256sum --check --strict', recipe)
+ self.assertIn('test "$(node --version)" = "v${NODE_VERSION}"', recipe)
+ self.assertIn('&& npm --version', recipe)
@unittest.skipUnless(platform.system() == 'Linux', 'Linux runtime fixture')
@@ -302,7 +314,7 @@ class ContainerTests(unittest.TestCase):
def setUp(self):
temporary = tempfile.TemporaryDirectory()
self.addCleanup(temporary.cleanup)
- self.root = Path(temporary.name)
+ self.root = Path(temporary.name).resolve()
scripts = self.root / 'scripts'
scripts.mkdir()
for name in ('linux-release-baseline.json', 'linux-release.Dockerfile',
@@ -388,6 +400,29 @@ class ContainerTests(unittest.TestCase):
'linux-release-baseline.json', 'candidate.tar.gz', 'candidate.tar.gz.json', 'linux-abi.json',
})
+ def assert_node_build_arguments(self, arch):
+ policy = abi.baseline()
+ args = self.commands[0]
+ arguments = [args[i + 1] for i, value in enumerate(args) if value == '--build-arg']
+ self.assertIn('NODE_VERSION=' + policy['node_version'], arguments)
+ self.assertIn('NODE_ARCH=' + arch, arguments)
+ self.assertIn('NODE_SHA256=' + policy['targets'][self.target]['node_sha256'], arguments)
+ compiler = next(args for args in self.commands if 'scripts/build-release.py' in args)
+ environment = [compiler[i + 1] for i, value in enumerate(compiler) if value == '-e']
+ self.assertIn('PATH=/usr/local/bin:/opt/cargo/bin:/opt/go/bin:/usr/bin:/bin', environment)
+ mounts = [compiler[i + 1] for i, value in enumerate(compiler) if value == '-v']
+ self.assertFalse(any('/node:' in value or '/npm:' in value for value in mounts))
+
+ def test_x64_build_uses_its_pinned_node_inside_the_image(self):
+ container.run(self.target, self.source)
+ self.assert_node_build_arguments('x64')
+
+ def test_arm64_build_selects_its_own_node_archive(self):
+ self.target = 'aarch64-unknown-linux-gnu'
+ with patch.object(container.platform, 'machine', return_value='aarch64'):
+ container.run(self.target, self.source)
+ self.assert_node_build_arguments('arm64')
+
def test_non_green_runtime_keeps_failed_result_and_awaiting_package(self):
self.runtime_state = 'red'
with self.assertRaisesRegex(ValueError, 'minimum runtime'):