Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: align supported Node range with dependencies (#7928)
[._.]/ Adam Eivy30019a6e53dd
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 5b97e68349..cf82ec27de 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -790,10 +790,42 @@ jobs:GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}run: node scripts/cancel-current-ci-run.js+ node-minimum:+ name: Node minimum compatibility+ runs-on: ubuntu-latest+ permissions:+ contents: read+ steps:+ - uses: actions/checkout@v7+ with:+ persist-credentials: false++ - name: Use the minimum supported Node.js+ uses: actions/setup-node@v7+ with:+ node-version: 22.22.2++ - name: Verify the runtime gate+ run: node scripts/checkNodeVersion.js++ # Resolve every committed npm lockfile on the minimum runtime. The+ # workspace-level contract test below is the fail-closed engine check;+ # installs stay script-free so native rebuilds cannot turn this contract+ # job into a second application test suite.+ - name: Install all workspaces+ run: |+ npm ci --ignore-scripts+ npm ci --ignore-scripts --prefix client+ npm ci --ignore-scripts --prefix server+ npm ci --ignore-scripts --prefix autofixer++ - name: Run the Node compatibility contract+ run: npm run test:fast --prefix server -- ../scripts/checkNodeVersion.test.js ../scripts/node-version-drift.test.js+gate:name: CI Gateif: always()- needs: [impact, server, client, lint, database, windows-server]+ needs: [impact, server, client, lint, database, windows-server, node-minimum]runs-on: ubuntu-latest# READ, not write: the reporter only lists this run's jobs, to name the one# whose STEP failed when the fail-fast cancel beat GitHub to writing the job@@ -830,6 +862,7 @@ jobs:CI_GATE_RESULT_LINT: ${{ needs.lint.result }}CI_GATE_RESULT_DATABASE: ${{ needs.database.result }}CI_GATE_RESULT_WINDOWS_SERVER: ${{ needs.windows-server.result }}+ CI_GATE_RESULT_NODE_MINIMUM: ${{ needs.node-minimum.result }}run: node scripts/ci-gate-report.jsfull-gate:diff --git a/PRD.md b/PRD.mdindex 8dd82b272e..610ce12b7d 100644--- a/PRD.md+++ b/PRD.md@@ -241,7 +241,7 @@ CoS MUST assess the actual behavior proposed by external GitHub issues, comments## Assumptions & Constraints-- Runs on Node.js ≥22.12.0; PostgreSQL (system `:5432` or Docker `:5561`) is a mandatory runtime dependency for every install.+- Runs on Node.js `^22.22.2 || ^24.15.0 || >=26.0.0`; PostgreSQL (system `:5432` or Docker `:5561`) is a mandatory runtime dependency for every install.- The user operates on a private Tailscale network. A compromised network peer remains a host-access risk, so PortOS strongly recommends the optional instance password and requires explicit acknowledgement when it is absent.- The user maintains an arbitrary, unbounded number of federated PortOS installs (including local-inference machines) as sync peers and, where enabled, spare generation capacity — not a single fixed primary/secondary pair.- AI provider costs are assumed to run primarily through flat-rate subscriptions (Claude Max, Codex, Google AI Pro, SuperGrok) plus local Ollama/LM Studio inference, not metered per-call billing — this shapes the "no cold-bootstrap LLM calls" policy.diff --git a/README.md b/README.mdindex 97671d6ad3..aadb1c8dd3 100644--- a/README.md+++ b/README.md@@ -300,7 +300,7 @@ Track your biological self alongside your digital one.### Requirements-- Node.js 22.12 or later (24 is what CI and `.nvmrc` use; Vite 8 requires ≥20.19). `npm run setup`, `npm start` and `npm run dev` check this first and stop immediately on an older Node — a bare `npm install` only warns, so use the commands below.+- Node.js `^22.22.2 || ^24.15.0 || >=26.0.0` (24 is the preferred LTS used by CI and `.nvmrc`; the supported Node 22 line starts at 22.22.2). `npm run setup`, `npm start` and `npm run dev` check this first and stop immediately on an unsupported release line or patch — a bare `npm install` only warns, so use the commands below.- npm 11.11.0 or later for dependency authoring (`npm install -g [email protected]` provides the verified minimum and supports the PortOS Node floor). Its Arborist 9.4.0 lockfile writer preserves `libc` metadata; npm 11.10.1 and earlier omit it. See the [npm 11.11.0 writer](https://github.com/npm/cli/blob/v11.11.0/workspaces/arborist/lib/shrinkwrap.js). npm 12 is not required. PortOS-managed setup, update, and dependency-repair installs preserve committed lockfiles with `--no-save`; do not commit metadata-only churn from older npm. Every workspace declares `engines.npm`, and setup/start/dev print an advisory below that floor. These are warnings, never runtime failures. Check `node -v`, `npm -v`, and executable resolution in the environment running PortOS as well as your shell: a Node version manager can select a different toolchain for agent shells. Avoid blindly upgrading to `npm@latest`, whose own Node requirement may exceed PortOS's.- Git- PostgreSQL, either installed locally or available through Docker. PortOS requires a healthy database; the setup command provisions the supported local or Docker-backed instance.diff --git a/autofixer/package-lock.json b/autofixer/package-lock.jsonindex 8a879522df..6118744dfc 100644--- a/autofixer/package-lock.json+++ b/autofixer/package-lock.json@@ -11,7 +11,7 @@"express": "5.2.1"},"engines": {- "node": ">=22.12.0",+ "node": "^22.22.2 || ^24.15.0 || >=26.0.0","npm": ">=11.11.0"}},diff --git a/autofixer/package.json b/autofixer/package.jsonindex c361cdbbfe..8e4a20ada7 100644--- a/autofixer/package.json+++ b/autofixer/package.json@@ -4,7 +4,7 @@"private": true,"type": "module","engines": {- "node": ">=22.12.0",+ "node": "^22.22.2 || ^24.15.0 || >=26.0.0","npm": ">=11.11.0"},"dependencies": {diff --git a/client/package-lock.json b/client/package-lock.jsonindex 489669f84b..976a7b917a 100644--- a/client/package-lock.json+++ b/client/package-lock.json@@ -36,7 +36,7 @@"vitest": "5.0.1"},"engines": {- "node": ">=22.12.0",+ "node": "^22.22.2 || ^24.15.0 || >=26.0.0","npm": ">=11.11.0"}},diff --git a/client/package.json b/client/package.jsonindex f5a599ef32..cf0175936e 100644--- a/client/package.json+++ b/client/package.json@@ -4,7 +4,7 @@"private": true,"type": "module","engines": {- "node": ">=22.12.0",+ "node": "^22.22.2 || ^24.15.0 || >=26.0.0","npm": ">=11.11.0"},"scripts": {diff --git a/package-lock.json b/package-lock.jsonindex 4a3a87b50a..c05f12bcd6 100644--- a/package-lock.json+++ b/package-lock.json@@ -12,7 +12,7 @@"pm2": "7.0.4"},"engines": {- "node": ">=22.12.0",+ "node": "^22.22.2 || ^24.15.0 || >=26.0.0","npm": ">=11.11.0"}},diff --git a/package.json b/package.jsonindex b4b6bc4bb5..27fb1dd6da 100644--- a/package.json+++ b/package.json@@ -8,7 +8,7 @@"type": "module","engines": {- "node": ">=22.12.0",+ "node": "^22.22.2 || ^24.15.0 || >=26.0.0","npm": ">=11.11.0"},"scripts": {diff --git a/scripts/checkNodeVersion.js b/scripts/checkNodeVersion.jsindex 4f94545ef6..1c482cde1a 100644--- a/scripts/checkNodeVersion.js+++ b/scripts/checkNodeVersion.js@@ -1,5 +1,5 @@/**- * Single source of truth for the Node.js version floor (issue #3863).+ * Single source of truth for the supported Node.js runtime range (issue #3863).** The floor used to be copied into five places that could drift independently* (setup.sh, setup.ps1, .nvmrc, the CI workflows, README prose) while the@@ -8,7 +8,8 @@* succeed, several minutes would pass, and the run would die inside Vite with* an error that never names the cause.*- * MIN_NODE below is now the only place the floor is written down:+ * The supported range below is now the only place the runtime contract is+ * written down:* - the four `engines` fields declare it machine-readably (npm warns on a* mismatch; `engine-strict` is deliberately NOT set — see the .npmrc note,* it would make one dependency's narrow range break every install),@@ -17,16 +18,24 @@* - scripts/node-version-drift.test.js fails if any of the other sites is* left behind when MIN_NODE moves.*- * Why 22.12 and not Vite's own `^20.19 || >=22.12`: nothing here is tested on- * 20 (.nvmrc and every CI job are 24), so advertising 20 would promise a- * configuration that never actually runs. `.nvmrc`/CI at 24 is a *preference*- * and is asserted to be >= this floor, not equal to it.+ * The current dependency intersection is `^22.22.2 || ^24.15.0 || >=26.0.0`:+ * react-router requires Node 22.22, while the Babel toolchain and the+ * dependency graph's supported Node 24 line require later patches. Node 23 and+ * 25 are intentionally excluded by dependencies with even-major ranges.+ * `.nvmrc`/CI at 24 remains the preferred LTS, while the minimum CI job proves+ * the lower supported Node 22 line.*/import { isDirectlyInvoked } from './lib/directInvocation.js';-/** The hard floor. Changing the version means changing exactly this string. */-export const MIN_NODE = '22.12.0';+/** The lowest supported Node 22 patch. */+export const MIN_NODE = '22.22.2';++/** The lowest supported Node 24 patch. */+export const MIN_NODE_24 = '24.15.0';++/** The supported runtime range shared by manifests, setup, and CI. */+export const SUPPORTED_NODE_RANGE = `^${MIN_NODE} || ^${MIN_NODE_24} || >=26.0.0`;/** Parse `v22.12.0` / `22.12` / `22` into a [major, minor, patch] tuple. */export function parseVersion(version) {@@ -49,19 +58,83 @@ export function compareVersions(a, b) {return 0;}-/** True when `version` is at or above the floor. */+/**+ * Compare a tool version against the small, portable subset of npm engine+ * ranges used by PortOS manifests. Unsupported syntax returns null so callers+ * can fail closed instead of treating an unknown requirement as compatible.+ */+export function satisfiesVersionRequirement(version, requirement) {+ if (typeof version !== 'string' || !version.trim() || typeof requirement !== 'string' || !requirement.trim()) {+ return null;+ }+ if (!/^v?\d+(?:\.\d+){0,2}(?:-[0-9A-Za-z.-]+)?$/.test(version.trim())) return null;+ const alternatives = requirement.split('||').map((part) => part.trim()).filter(Boolean);+ if (!alternatives.length) return null;++ const satisfiesComparator = (candidate, comparator) => {+ const token = comparator.trim();+ if (!token || token === '*' || /^x$/i.test(token)) return true;+ const match = token.match(/^(>=|<=|>|<|=|\^|~)?\s*(v?\d+(?:\.\d+){0,2})(?:\.[xX*])?$/);+ if (!match) return null;+ const operator = match[1] || '=';+ const target = match[2];+ const comparison = compareVersions(candidate, target);+ const numericParts = target.replace(/^v/, '').split('.').map((part) => Number(part));+ const major = numericParts[0];+ const minor = numericParts[1] || 0;+ const patch = numericParts[2] || 0;+ const isPartial = numericParts.length < 3 || /(?:^|\.)[xX*]$/.test(token);+ const partialUpper = numericParts.length < 2+ ? `${major + 1}.0.0`+ : `${major}.${minor + 1}.0`;+ if (operator === '=' && isPartial) {+ return comparison >= 0 && compareVersions(candidate, partialUpper) < 0;+ }+ if (operator === '>=') return comparison >= 0;+ if (operator === '<=') return isPartial+ ? compareVersions(candidate, partialUpper) < 0+ : comparison <= 0;+ if (operator === '>') return isPartial+ ? compareVersions(candidate, partialUpper) >= 0+ : comparison > 0;+ if (operator === '<') return comparison < 0;+ if (operator === '^') {+ const upper = major > 0+ ? `${major + 1}.0.0`+ : minor > 0+ ? `0.${minor + 1}.0`+ : numericParts.length < 3 ? '0.1.0' : `0.0.${patch + 1}`;+ return comparison >= 0 && compareVersions(candidate, upper) < 0;+ }+ if (operator === '=') return comparison === 0;+ const upper = numericParts.length < 2 ? `${major + 1}.0.0` : `${major}.${minor + 1}.0`;+ return comparison >= 0 && compareVersions(candidate, upper) < 0;+ };++ const results = alternatives.map((alternative) => {+ const comparators = alternative.replaceAll(',', ' ').split(/\s+/).filter(Boolean);+ const values = comparators.map((comparator) => satisfiesComparator(version, comparator));+ if (values.some((value) => value === null)) return null;+ return values.every(Boolean);+ });+ if (results.some(Boolean)) return true;+ if (results.every((value) => value === false)) return false;+ return null;+}++/** True when `version` is in the supported runtime range. */export function satisfiesMinNode(version = process.versions.node) {- return compareVersions(version, MIN_NODE) >= 0;+ return satisfiesVersionRequirement(version, SUPPORTED_NODE_RANGE) === true;}-/** The one-line failure message, mirroring the shape the shell gates print. */+/** The one-line failure message, shared by the Node and shell gates. */export function unsupportedNodeMessage(version = process.versions.node) {- return `Node.js ${MIN_NODE}+ required (found v${String(version).trim().replace(/^v/, '')}) — see .nvmrc`;+ return `Node.js ${SUPPORTED_NODE_RANGE} required (found v${String(version).trim().replace(/^v/, '')}) — see .nvmrc`;}/**- * Exit non-zero with `unsupportedNodeMessage` when the running Node is below- * the floor. Injectable so the test can exercise both branches without+ * Exit non-zero with `unsupportedNodeMessage` when the running Node is outside+ * the supported range. Injectable so the test can exercise both branches without* spawning a second interpreter or tearing down the runner.*/export function assertNodeVersion({diff --git a/scripts/checkNodeVersion.test.js b/scripts/checkNodeVersion.test.jsindex 5ba313a369..e41cdf64bf 100644--- a/scripts/checkNodeVersion.test.js+++ b/scripts/checkNodeVersion.test.js@@ -1,29 +1,32 @@/**- * Unit tests for the Node floor gate (issue #3863). The drift test next door+ * Unit tests for the Node runtime gate (issue #3863). The drift test next door* checks that every *site* agrees with MIN_NODE; this one checks that the gate- * itself accepts and rejects the right versions — in particular that a v22.0- * machine (which the coarse `-lt 22` shell gates wave through) is still+ * itself accepts and rejects the right versions — in particular that excluded+ * Node release lines do not pass a coarse major-only gate.* rejected by the precise check that `npm run setup` / `npm start` run.*/import { describe, it, expect, vi } from 'vitest';import {MIN_NODE,+ MIN_NODE_24,+ SUPPORTED_NODE_RANGE,assertNodeVersion,compareVersions,parseVersion,+ satisfiesVersionRequirement,satisfiesMinNode,unsupportedNodeMessage,} from './checkNodeVersion.js';describe('parseVersion', () => {it.each([- ['v22.12.0', [22, 12, 0]],- ['22.12.0', [22, 12, 0]],- ['22.12', [22, 12, 0]],+ ['v22.22.2', [22, 22, 2]],+ ['22.22.2', [22, 22, 2]],+ ['22.22', [22, 22, 0]],['24', [24, 0, 0]],[' 24.1.2\n', [24, 1, 2]],- ['22.12.0-nightly20240101', [22, 12, 0]],+ ['22.22.2-nightly20240101', [22, 22, 2]],])('parses %s', (input, expected) => {expect(parseVersion(input)).toEqual(expected);});@@ -31,11 +34,11 @@ describe('parseVersion', () => {describe('compareVersions', () => {it.each([- ['22.12.0', '22.12.0', 0],- ['22.11.9', '22.12.0', -1],- ['22.12.1', '22.12.0', 1],- ['20.19.0', '22.12.0', -1],- ['24.0.0', '22.12.0', 1],+ ['22.22.2', '22.22.2', 0],+ ['22.22.1', '22.22.2', -1],+ ['22.22.3', '22.22.2', 1],+ ['20.19.0', '22.22.2', -1],+ ['24.0.0', '22.22.2', 1],// Numeric, not lexical: "9" > "10" as strings, but not as versions.['22.9.0', '22.10.0', -1],])('compares %s to %s', (a, b, expected) => {@@ -43,25 +46,36 @@ describe('compareVersions', () => {});});-describe('satisfiesMinNode', () => {- it('rejects the versions the coarse shell gates would let through', () => {- // Major 22 clears `-lt 22`, but 22.0/22.11 are below the real Vite floor.- expect(satisfiesMinNode('22.0.0')).toBe(false);- expect(satisfiesMinNode('22.11.0')).toBe(false);- });-- it('rejects the versions the README used to advertise', () => {- expect(satisfiesMinNode('18.20.0')).toBe(false);- expect(satisfiesMinNode('20.19.0')).toBe(false);+describe('satisfiesVersionRequirement', () => {+ it('supports the engine-range syntax used by the manifests', () => {+ expect(satisfiesVersionRequirement('22.22.2', SUPPORTED_NODE_RANGE)).toBe(true);+ expect(satisfiesVersionRequirement('24.15.0', SUPPORTED_NODE_RANGE)).toBe(true);+ expect(satisfiesVersionRequirement('26.0.0', SUPPORTED_NODE_RANGE)).toBe(true);+ expect(satisfiesVersionRequirement('23.0.0', SUPPORTED_NODE_RANGE)).toBe(false);+ expect(satisfiesVersionRequirement('not-a-version', SUPPORTED_NODE_RANGE)).toBe(null);});+});- it('accepts the floor and everything above it', () => {- expect(satisfiesMinNode(MIN_NODE)).toBe(true);- expect(satisfiesMinNode('22.12.1')).toBe(true);- expect(satisfiesMinNode('v24.0.0')).toBe(true);+describe('satisfiesMinNode', () => {+ it.each([+ ['22.0.0', false],+ ['22.22.1', false],+ ['23.0.0', false],+ ['24.0.0', false],+ ['24.14.0', false],+ ['25.0.0', false],+ ['18.20.0', false],+ ['20.19.0', false],+ [MIN_NODE, true],+ [MIN_NODE_24, true],+ ['22.23.0', true],+ ['24.20.0', true],+ ['v26.0.0', true],+ ])('returns %s -> %s', (version, expected) => {+ expect(satisfiesMinNode(version)).toBe(expected);});- it('defaults to the running interpreter, which must itself satisfy the floor', () => {+ it('defaults to the running interpreter, which must itself satisfy the range', () => {expect(satisfiesMinNode()).toBe(true);});});@@ -69,7 +83,7 @@ describe('satisfiesMinNode', () => {describe('assertNodeVersion', () => {it('passes without invoking the failure path on a supported Node', () => {const onFail = vi.fn();- expect(assertNodeVersion({ version: '24.1.0', onFail })).toBe(true);+ expect(assertNodeVersion({ version: '24.15.0', onFail })).toBe(true);expect(onFail).not.toHaveBeenCalled();});diff --git a/scripts/doctor.js b/scripts/doctor.jsindex e1165c3a27..3f845cb8e6 100644--- a/scripts/doctor.js+++ b/scripts/doctor.js@@ -51,7 +51,7 @@ import { certPaths } from '../lib/certPaths.js';import { commandExists } from '../server/lib/commandExists.js';import { isStaleGitLock } from '../server/lib/gitStaleLock.js';import { scrubHomePath } from '../server/lib/homePath.js';-import { MIN_NODE, compareVersions, satisfiesMinNode } from './checkNodeVersion.js';+import { SUPPORTED_NODE_RANGE, compareVersions, satisfiesMinNode } from './checkNodeVersion.js';import { MIN_NPM, parseNpmUserAgent, readBundledNpmVersion } from './checkNpmVersion.js';import { isDirectlyInvoked } from './lib/directInvocation.js';import { listPendingMigrations } from './run-migrations.js';@@ -188,8 +188,8 @@ function probePath(root, relativePath, { presentDetail, missingDetail }) {async function probeNode() {const version = process.versions.node;return satisfiesMinNode(version)- ? { available: true, detail: `v${version} (floor ${MIN_NODE})` }- : { available: false, detail: `v${version} is below the ${MIN_NODE} floor — see .nvmrc` };+ ? { available: true, detail: `v${version} (supported ${SUPPORTED_NODE_RANGE})` }+ : { available: false, detail: `v${version} is outside ${SUPPORTED_NODE_RANGE} — see .nvmrc` };}/**diff --git a/scripts/node-version-drift.test.js b/scripts/node-version-drift.test.jsindex c015736938..3e966d0729 100644--- a/scripts/node-version-drift.test.js+++ b/scripts/node-version-drift.test.js@@ -1,138 +1,118 @@/**- * Drift guard for the Node.js version floor (issue #3863).+ * Drift guard for the supported Node.js runtime range (issue #3863).*- * The floor used to be written out longhand in five independent places —- * setup.sh, setup.ps1, .nvmrc, the CI workflows, and README prose — with- * nothing keeping them in agreement, and none of them on the primary- * `npm run setup` / `npm start` path. scripts/checkNodeVersion.js now owns the- * number; this test is what makes the other sites follow it.- *- * Two different assertions, deliberately:- * - the *floor* sites (shell gates, `engines`, README prose) must EQUAL- * MIN_NODE — they promise what the project supports;- * - the *preference* sites (.nvmrc, CI `node-version`) must be >= MIN_NODE —- * running CI on 24 while supporting 22.12 is correct, not drift.+ * The supported range is owned by scripts/checkNodeVersion.js. This test keeps+ * manifests, setup entrypoints, README, CI, and the committed dependency graph+ * aligned with that owner. CI still runs the preferred Node 24 line, while a+ * dedicated minimum job exercises the lower supported Node 22 line.*/import { describe, it, expect } from 'vitest';import { execFileSync } from 'child_process';import { readFileSync } from 'fs';-import { dirname, join } from 'path';+import { join } from 'path';import { fileURLToPath } from 'url';-import { MIN_NODE, compareVersions, parseVersion } from './checkNodeVersion.js';--const REPO_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');-const [MIN_MAJOR, MIN_MINOR] = parseVersion(MIN_NODE);-/** The README states the floor without its patch component ("22.12"). */-const MIN_NODE_SHORT = `${MIN_MAJOR}.${MIN_MINOR}`;-const ENGINES_RANGE = `>=${MIN_NODE}`;+import {+ MIN_NODE,+ MIN_NODE_24,+ SUPPORTED_NODE_RANGE,+ parseVersion,+ satisfiesMinNode,+ satisfiesVersionRequirement,+} from './checkNodeVersion.js';+const REPO_ROOT = join(fileURLToPath(new URL('..', import.meta.url)));const read = (rel) => readFileSync(join(REPO_ROOT, rel), 'utf8');const readJson = (rel) => JSON.parse(read(rel));/**- * True when a version *pin* — which may be partial (`24`, `24.x`, `22.12.0`) —- * is at or above the floor. A pin without an explicit numeric minor names a- * release line, not a point release, so `22`/`22.x` resolves to the latest 22- * and clears a 22.12 floor; `22.10.0` names a real version and does not.+ * True when a version pin — which may be partial (`24`, `24.x`) — names a+ * supported release line or a supported concrete version. A partial release+ * line resolves to its current patch, so it is checked by major rather than by+ * the current patch number.*/-function pinSatisfiesFloor(pin) {- // Strip a leading `v` before the shape test below, or `v22.10.0` would read- // as "no explicit minor" and be waved through as a release-line pin.+function pinSatisfiesSupportedRange(pin) {const raw = String(pin).trim().replace(/^v/, '');const [major] = parseVersion(raw);- if (major !== MIN_MAJOR) return major > MIN_MAJOR;- if (!/^\d+\.\d/.test(raw)) return true;- return compareVersions(raw, MIN_NODE) >= 0;+ if (/^\d+(?:\.x)?$/i.test(raw)) return major === 22 || major === 24 || major >= 26;+ if (!/^\d+\.\d/.test(raw)) return false;+ return satisfiesMinNode(raw);}const MANIFESTS = ['package.json', 'client/package.json', 'server/package.json', 'autofixer/package.json'];+const LOCKFILES = ['package-lock.json', 'client/package-lock.json', 'server/package-lock.json', 'autofixer/package-lock.json'];const NPMRCS = ['.npmrc', 'client/.npmrc', 'server/.npmrc', 'autofixer/.npmrc'];--describe('Node version floor has exactly one owner (issue #3863)', () => {- it('MIN_NODE is a concrete three-part version', () => {+const SUPPORTED_NODE_POINTS = [MIN_NODE, MIN_NODE_24, '26.0.0'];+const REQUIRED_DEPENDENCIES = [+ ['server/package-lock.json', 'node_modules/undici'],+ ['server/package-lock.json', 'node_modules/@babel/parser'],+ ['client/package-lock.json', 'node_modules/react-router'],+];++describe('Node version contract has exactly one owner (issue #3863)', () => {+ it('exports a concrete lower bound and a supported range', () => {expect(MIN_NODE).toMatch(/^\d+\.\d+\.\d+$/);+ expect(MIN_NODE_24).toMatch(/^\d+\.\d+\.\d+$/);+ expect(SUPPORTED_NODE_RANGE).toBe('^22.22.2 || ^24.15.0 || >=26.0.0');});// The pin comparison decides whether the .nvmrc / CI assertions below pass,// so it is verified against literals rather than trusted.- it('pinSatisfiesFloor reads partial and point pins correctly', () => {- expect(MIN_NODE).toBe('22.12.0'); // the literals below assume this floor- expect(pinSatisfiesFloor('24')).toBe(true);- expect(pinSatisfiesFloor('24.x')).toBe(true);- expect(pinSatisfiesFloor('22')).toBe(true); // the 22 line resolves above 22.12- expect(pinSatisfiesFloor('22.12.0')).toBe(true);- expect(pinSatisfiesFloor('22.10.0')).toBe(false);- expect(pinSatisfiesFloor('v22.10.0')).toBe(false);- expect(pinSatisfiesFloor('20.19.0')).toBe(false);- expect(pinSatisfiesFloor('18')).toBe(false);+ it('pinSatisfiesSupportedRange reads release-line and point pins correctly', () => {+ expect(pinSatisfiesSupportedRange('24')).toBe(true);+ expect(pinSatisfiesSupportedRange('24.x')).toBe(true);+ expect(pinSatisfiesSupportedRange('22')).toBe(true);+ expect(pinSatisfiesSupportedRange('22.22.2')).toBe(true);+ expect(pinSatisfiesSupportedRange('22.22.1')).toBe(false);+ expect(pinSatisfiesSupportedRange('23')).toBe(false);+ expect(pinSatisfiesSupportedRange('24.14.0')).toBe(false);+ expect(pinSatisfiesSupportedRange('25.x')).toBe(false);+ expect(pinSatisfiesSupportedRange('20.19.0')).toBe(false);+ expect(pinSatisfiesSupportedRange('18')).toBe(false);});- describe('floor sites equal MIN_NODE', () => {- // Both shell gates check major AND minor: a bare `-lt 22` would wave through- // 22.0–22.11, which is below the real floor. They run before any Node script- // in the `./setup.sh` path, so their literals must track MIN_NODE exactly.- // A floor whose minor is 0 needs no minor comparison — the major one already- // covers it — so that half is only required when MIN_MINOR is non-zero.- const assertShellGate = (body, label, majorRe, minorRe) => {- const major = body.match(majorRe);- expect(major, `${label} no longer contains its major Node gate`).toBeTruthy();- expect(Number(major[1])).toBe(MIN_MAJOR);- const minor = body.match(minorRe);- if (MIN_MINOR === 0) return;- expect(minor, `${label} no longer contains its minor Node gate`).toBeTruthy();- expect(Number(minor[1])).toBe(MIN_MINOR);- };-- it('setup.sh gates on the full MIN_NODE floor', () => {- assertShellGate(- read('setup.sh'),- 'setup.sh',- /"\$NODE_MAJOR"\s+-lt\s+(\d+)/,- /"\$NODE_MINOR"\s+-lt\s+(\d+)/- );+ describe('floor sites equal SUPPORTED_NODE_RANGE', () => {+ it.each(MANIFESTS)('%s declares engines.node = the supported range', (rel) => {+ expect(readJson(rel).engines?.node).toBe(SUPPORTED_NODE_RANGE);});- it('setup.ps1 gates on the full MIN_NODE floor', () => {- assertShellGate(- read('setup.ps1'),- 'setup.ps1',- /\$majorVersion\s+-lt\s+(\d+)/,- /\$minorVersion\s+-lt\s+(\d+)/- );+ it.each(LOCKFILES)('%s records the supported range in its root package', (rel) => {+ expect(readJson(rel).packages?.['']?.engines?.node).toBe(SUPPORTED_NODE_RANGE);});- it.each(MANIFESTS)('%s declares engines.node = the floor', (rel) => {- expect(readJson(rel).engines?.node).toBe(ENGINES_RANGE);+ it('setup.sh delegates the pre-install gate to the owner', () => {+ expect(read('setup.sh')).toMatch(/node scripts\/checkNodeVersion\.js/);+ expect(read('setup.sh')).not.toMatch(/22\.12/);});- it('README states the floor', () => {- expect(read('README.md')).toContain(`Node.js ${MIN_NODE_SHORT} or later`);+ it('setup.ps1 delegates the pre-install gate to the owner', () => {+ expect(read('setup.ps1')).toMatch(/node scripts\/checkNodeVersion\.js/);+ expect(read('setup.ps1')).not.toMatch(/22\.12/);+ });++ it('README states the supported range', () => {+ expect(read('README.md')).toContain(SUPPORTED_NODE_RANGE);});});- describe('preference sites stay at or above the floor', () => {- it('.nvmrc is >= MIN_NODE', () => {+ describe('preference sites stay on supported release lines', () => {+ it('.nvmrc is a supported release line', () => {const nvmrc = read('.nvmrc').trim();- expect(nvmrc).toMatch(/^\d+(\.\d+)*$/);- expect(pinSatisfiesFloor(nvmrc), `.nvmrc (${nvmrc}) is below the floor`).toBe(true);+ expect(nvmrc).toMatch(/^\d+(?:\.\d+)*$/);+ expect(pinSatisfiesSupportedRange(nvmrc), `.nvmrc (${nvmrc}) is outside the supported range`).toBe(true);});- it('every CI job pins a node-version >= MIN_NODE', () => {+ it('every CI setup-node pin is supported', () => {const workflows = execFileSync('git', ['ls-files', '-z', '.github/workflows'], {cwd: REPO_ROOT,encoding: 'utf8',}).split('\0').filter(Boolean);- // `v?` so a `node-version: 'v24'` spelling is read, not skipped — an- // unparsed pin would drop out of the loop instead of failing it.const pinsIn = (body) =>[...body.matchAll(/node-version:\s*['"]?v?(\d+(?:\.[\dx]+)*)/g)].map((m) => m[1]);const pins = workflows.flatMap((rel) => pinsIn(read(rel)).map((pin) => ({ rel, pin })));- // Sanity: without these the loop below could pass vacuously — globally if- // nothing parsed at all, per-file if one workflow's pins stopped parsing.expect(pins.length).toBeGreaterThan(0);for (const rel of workflows) {const body = read(rel);@@ -141,21 +121,32 @@ describe('Node version floor has exactly one owner (issue #3863)', () => {.toBeGreaterThan(0);}for (const { rel, pin } of pins) {- // Compare the whole pin, not just its major: `22.10.0` shares MIN_NODE's- // major and is still below the floor.- expect(pinSatisfiesFloor(pin), `${rel} pins node-version ${pin}, below the floor`).toBe(true);+ expect(pinSatisfiesSupportedRange(pin), `${rel} pins node-version ${pin}, outside the supported range`)+ .toBe(true);+ }+ });++ it('CI explicitly exercises the lowest supported Node 22 point', () => {+ const workflow = read('.github/workflows/ci.yml');+ expect(workflow).toContain(`node-version: ${MIN_NODE}`);+ expect(workflow).toContain('name: Node minimum compatibility');+ });+ });++ describe('the advertised range covers required dependency engines', () => {+ it.each(REQUIRED_DEPENDENCIES)('%s %s accepts every supported runtime point', (rel, packagePath) => {+ const dependency = readJson(rel).packages?.[packagePath];+ expect(dependency?.engines?.node, `${rel} ${packagePath} has no node engine`).toBeTruthy();+ for (const version of SUPPORTED_NODE_POINTS) {+ expect(+ satisfiesVersionRequirement(version, dependency.engines.node),+ `${packagePath} rejects supported Node ${version} with ${dependency.engines.node}`,+ ).toBe(true);}});});- describe('the floor is actually enforced', () => {- // Regression guard for the fix that #3863 originally proposed and this- // change deliberately reversed: `engine-strict=true` makes npm treat- // EBADENGINE as fatal for *dependencies* as well as for this project, so a- // single transitive package with a narrow range breaks `npm install` on a- // Node PortOS fully supports (jsdom@30 wants `^22.22.2 || ^24.15.0 || >=26`- // — a supported Node 24.14 fails it). Enforcement lives in the script chain- // below instead. Re-adding this line breaks every install, so it is guarded.+ describe('the range is actually enforced', () => {it.each(NPMRCS)('%s does not set engine-strict', (rel) => {expect(read(rel)).not.toMatch(/^\s*engine-strict\s*=\s*true/m);});diff --git a/server/lib/ollamaContext.js b/server/lib/ollamaContext.jsindex 5df05c60e7..639b4585bb 100644--- a/server/lib/ollamaContext.js+++ b/server/lib/ollamaContext.js@@ -136,7 +136,7 @@ function hostOf(baseUrl) {? `http://localhost${raw}`: `http://${raw}`// `URL.parse` returns null on invalid input instead of throwing (Node ≥22.1;- // the repo's engine floor is 22.12), so no try/catch is needed here.+ // every supported PortOS runtime is newer), so no try/catch is needed here.const url = URL.parse(withScheme)if (!url) return nulldiff --git a/server/package-lock.json b/server/package-lock.jsonindex 63ed3effae..b4112cea1c 100644--- a/server/package-lock.json+++ b/server/package-lock.json@@ -31,7 +31,7 @@"vitest": "5.0.1"},"engines": {- "node": ">=22.12.0",+ "node": "^22.22.2 || ^24.15.0 || >=26.0.0","npm": ">=11.11.0"}},diff --git a/server/package.json b/server/package.jsonindex 2ffa25baac..38640b57bd 100644--- a/server/package.json+++ b/server/package.json@@ -4,7 +4,7 @@"private": true,"type": "module","engines": {- "node": ">=22.12.0",+ "node": "^22.22.2 || ^24.15.0 || >=26.0.0","npm": ">=11.11.0"},"scripts": {diff --git a/server/services/persistentMindWorkspacePreflight.js b/server/services/persistentMindWorkspacePreflight.jsindex 3b8755f135..63b4f1b56b 100644--- a/server/services/persistentMindWorkspacePreflight.js+++ b/server/services/persistentMindWorkspacePreflight.js@@ -22,7 +22,8 @@ import {isCliReviewer,isReviewer,} from '../lib/validation.js';-import { compareVersions } from '../../scripts/checkNodeVersion.js';+import { compareVersions, satisfiesVersionRequirement } from '../../scripts/checkNodeVersion.js';+export { satisfiesVersionRequirement } from '../../scripts/checkNodeVersion.js';import * as codeReview from './codeReview.js';const execFileAsync = promisify(execFile);@@ -273,68 +274,6 @@ const engineRequirements = (manifest) => {};};-/**- * Compare a tool version against the small, portable subset of npm engine- * ranges used by PortOS manifests. It intentionally does not pretend to be a- * complete semver implementation; unsupported syntax is unknown to callers.- */-export function satisfiesVersionRequirement(version, requirement) {- if (typeof version !== 'string' || !version.trim() || typeof requirement !== 'string' || !requirement.trim()) return null;- if (!/^v?\d+(?:\.\d+){0,2}(?:-[0-9A-Za-z.-]+)?$/.test(version.trim())) return null;- const alternatives = requirement.split('||').map((part) => part.trim()).filter(Boolean);- if (!alternatives.length) return null;-- const satisfiesComparator = (candidate, comparator) => {- const token = comparator.trim();- if (!token || token === '*' || /^x$/i.test(token)) return true;- const match = token.match(/^(>=|<=|>|<|=|\^|~)?\s*(v?\d+(?:\.\d+){0,2})(?:\.[xX*])?$/);- if (!match) return null;- const operator = match[1] || '=';- const target = match[2];- const comparison = compareVersions(candidate, target);- const numericParts = target.replace(/^v/, '').split('.').map((part) => Number(part));- const major = numericParts[0];- const minor = numericParts[1] || 0;- const patch = numericParts[2] || 0;- const isPartial = numericParts.length < 3 || /(?:^|\.)[xX*]$/.test(token);- const partialUpper = numericParts.length < 2- ? `${major + 1}.0.0`- : `${major}.${minor + 1}.0`;- if (operator === '=' && isPartial) {- return comparison >= 0 && compareVersions(candidate, partialUpper) < 0;- }- if (operator === '>=') return comparison >= 0;- if (operator === '<=') return isPartial- ? compareVersions(candidate, partialUpper) < 0- : comparison <= 0;- if (operator === '>') return isPartial- ? compareVersions(candidate, partialUpper) >= 0- : comparison > 0;- if (operator === '<') return comparison < 0;- if (operator === '^') {- const upper = major > 0- ? `${major + 1}.0.0`- : minor > 0- ? `0.${minor + 1}.0`- : numericParts.length < 3 ? '0.1.0' : `0.0.${patch + 1}`;- return comparison >= 0 && compareVersions(candidate, upper) < 0;- }- if (operator === '=') return comparison === 0;- const upper = numericParts.length < 2 ? `${major + 1}.0.0` : `${major}.${minor + 1}.0`;- return comparison >= 0 && compareVersions(candidate, upper) < 0;- };-- const results = alternatives.map((alternative) => {- const comparators = alternative.replaceAll(',', ' ').split(/\s+/).filter(Boolean);- const values = comparators.map((comparator) => satisfiesComparator(version, comparator));- if (values.some((value) => value === null)) return null;- return values.every(Boolean);- });- if (results.some(Boolean)) return true;- if (results.every((value) => value === false)) return false;- return null;-}-const normalizeVersion = (value) => {const match = String(value || '').trim().match(/^v?\d+(?:\.\d+){0,2}(?:-[0-9A-Za-z.-]+)?$/);return match ? match[0].replace(/^v/, '') : null;diff --git a/server/services/persistentMindWorkspacePreflight.test.js b/server/services/persistentMindWorkspacePreflight.test.jsindex 0ce3733629..cd0566a8d6 100644--- a/server/services/persistentMindWorkspacePreflight.test.js+++ b/server/services/persistentMindWorkspacePreflight.test.js@@ -95,7 +95,7 @@ describe('persistent mind workspace preflight', () => {await writeManifest(repoPath, 'package.json', { engines });const dependencies = createDependencies();for (const [nodeVersion, npmVersion, blocked] of [- ['24.14.1', '11.11.0', false],+ ['24.15.0', '11.11.0', false],['26.0.0', '11.12.1', false],['26.0.0', '11.10.1', true],['22.11.0', '11.11.0', true],diff --git a/setup.ps1 b/setup.ps1index 314073c65b..dae892eb62 100644--- a/setup.ps1+++ b/setup.ps1@@ -17,16 +17,14 @@ if (-not $nodeCommand) {exit 1}-# Check Node.js version. Vite 8 (client build) requires ^20.19 || >=22.12, so an-# older install fails at `npm run build` rather than here. This mirrors MIN_NODE-# in scripts/checkNodeVersion.js, which owns the floor and re-checks it at the-# head of `npm run setup` below; scripts/node-version-drift.test.js keeps the two-# literals in sync.-$nodeVersion = (node -v) -replace 'v', ''-$majorVersion = [int]($nodeVersion.Split('.')[0])-$minorVersion = [int]($nodeVersion.Split('.')[1])-if ($majorVersion -lt 22 -or ($majorVersion -eq 22 -and $minorVersion -lt 12)) {- Write-Host "Node.js 22.12+ required (found v$nodeVersion) - see .nvmrc" -ForegroundColor Red+# Keep the pre-install check on the same owner as npm run setup/start/dev.+# The Node script handles excluded release lines (23/25) as well as patch+# floors, without a second semver implementation in PowerShell.+node scripts/checkNodeVersion.js+if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }+$nodeVersion = (node -v) -replace '^v', ''+if (-not $nodeVersion) {+ Write-Host "Unable to read the Node.js version after the compatibility check." -ForegroundColor Redexit 1}Write-Host "Found Node.js v$nodeVersion" -ForegroundColor Greendiff --git a/setup.sh b/setup.shindex 973f439569..f079e9c14b 100755--- a/setup.sh+++ b/setup.sh@@ -18,21 +18,10 @@ if ! command -v node &> /dev/null; thenexit 1fi-# Vite 8 (client build) requires ^20.19 || >=22.12, so an older install fails at-# `npm run build` rather than here. This mirrors MIN_NODE in-# scripts/checkNodeVersion.js, which owns the floor and re-checks it at the head-# of `npm run setup` below; scripts/node-version-drift.test.js keeps the two-# literals in sync. The duplication buys a clear message before any Node script-# runs at all.-# Strip the leading `v` by parameter expansion rather than `cut -d'v'`, which-# would yield an empty field (and an "integer expression expected" error below)-# on a build whose `node -v` omits it.-NODE_RAW=$(node -v)-NODE_VER=${NODE_RAW#v}-NODE_MAJOR=$(echo "$NODE_VER" | cut -d'.' -f1)-NODE_MINOR=$(echo "$NODE_VER" | cut -d'.' -f2)-if [ "$NODE_MAJOR" -lt 22 ] || { [ "$NODE_MAJOR" -eq 22 ] && [ "$NODE_MINOR" -lt 12 ]; }; then- echo "Node.js 22.12+ required (found v$NODE_VER) — see .nvmrc"+# Keep the pre-install check on the same owner as npm run setup/start/dev.+# Running the Node script here handles excluded release lines (23/25) as well+# as patch floors, without a second semver implementation in shell.+if ! node scripts/checkNodeVersion.js; thenexit 1fi