Skip to content

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

fix: close the review gaps in the Node floor check — symlinked invocation, 22.0-22.11 shell gates, major-only CI drift assertion (#3863)

[._.]/ Adam Eivy2b7b0c67e45f
diff --git a/README.md b/README.md
index ce0efb3283..a68354f64f 100644
--- a/README.md
+++ b/README.md
@@ -291,7 +291,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)
+- 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.
- 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/scripts/checkNodeVersion.js b/scripts/checkNodeVersion.js
index 6ccd9b8dad..7ec80af191 100644
--- a/scripts/checkNodeVersion.js
+++ b/scripts/checkNodeVersion.js
@@ -23,7 +23,8 @@
* and is asserted to be >= this floor, not equal to it.
*/
-import { pathToFileURL } from 'url';
+import { realpathSync } from 'fs';
+import { fileURLToPath } from 'url';
/** The hard floor. Changing the version means changing exactly this string. */
export const MIN_NODE = '22.12.0';
@@ -76,9 +77,25 @@ export function assertNodeVersion({
return false;
}
-// Runnable directly: `node scripts/checkNodeVersion.js`. pathToFileURL rather
-// than a `file://` template so a repo path containing a space or a non-ASCII
-// character still matches (it percent-encodes; the template does not).
-if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
- assertNodeVersion();
+// Runnable directly: `node scripts/checkNodeVersion.js`.
+//
+// Both sides are realpath'd before comparing. Node's ESM loader resolves
+// symlinks when it builds `import.meta.url`, but `process.argv[1]` is whatever
+// the caller typed — so a repo reached through a symlinked parent (a checkout
+// under a symlinked home, /tmp → /private/tmp on macOS, a symlinked worktree)
+// makes the two spellings differ and the gate would silently no-op, exiting 0
+// on an unsupported Node. fileURLToPath/realpathSync also handle paths with
+// spaces or non-ASCII characters, which a `file://` string template does not.
+const invokedPath = process.argv[1];
+if (invokedPath) {
+ const resolve = (p) => {
+ try {
+ return realpathSync(p);
+ } catch {
+ return p;
+ }
+ };
+ if (resolve(fileURLToPath(import.meta.url)) === resolve(invokedPath)) {
+ assertNodeVersion();
+ }
}
diff --git a/scripts/node-version-drift.test.js b/scripts/node-version-drift.test.js
index eb953d56a7..b02f529424 100644
--- a/scripts/node-version-drift.test.js
+++ b/scripts/node-version-drift.test.js
@@ -30,6 +30,20 @@ const ENGINES_RANGE = `>=${MIN_NODE}`;
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.
+ */
+function pinSatisfiesFloor(pin) {
+ const raw = String(pin).trim();
+ 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;
+}
+
const MANIFESTS = ['package.json', 'client/package.json', 'server/package.json', 'autofixer/package.json'];
const NPMRCS = ['.npmrc', 'client/.npmrc', 'server/.npmrc', 'autofixer/.npmrc'];
@@ -38,17 +52,39 @@ describe('Node version floor has exactly one owner (issue #3863)', () => {
expect(MIN_NODE).toMatch(/^\d+\.\d+\.\d+$/);
});
+ // 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('20.19.0')).toBe(false);
+ expect(pinSatisfiesFloor('18')).toBe(false);
+ });
+
describe('floor sites equal MIN_NODE', () => {
- it('setup.sh gates on the MIN_NODE major', () => {
- const match = read('setup.sh').match(/"\$NODE_VERSION"\s+-lt\s+(\d+)/);
- expect(match, 'setup.sh no longer contains a `-lt <major>` Node gate').toBeTruthy();
- expect(Number(match[1])).toBe(MIN_MAJOR);
+ // 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.
+ it('setup.sh gates on the full MIN_NODE floor', () => {
+ const sh = read('setup.sh');
+ const major = sh.match(/"\$NODE_MAJOR"\s+-lt\s+(\d+)/);
+ const minor = sh.match(/"\$NODE_MINOR"\s+-lt\s+(\d+)/);
+ expect(major, 'setup.sh no longer contains a `$NODE_MAJOR -lt <n>` gate').toBeTruthy();
+ expect(minor, 'setup.sh no longer contains a `$NODE_MINOR -lt <n>` gate').toBeTruthy();
+ expect([Number(major[1]), Number(minor[1])]).toEqual([MIN_MAJOR, MIN_MINOR]);
});
- it('setup.ps1 gates on the MIN_NODE major', () => {
- const match = read('setup.ps1').match(/\$majorVersion\s+-lt\s+(\d+)/);
- expect(match, 'setup.ps1 no longer contains a `-lt <major>` Node gate').toBeTruthy();
- expect(Number(match[1])).toBe(MIN_MAJOR);
+ it('setup.ps1 gates on the full MIN_NODE floor', () => {
+ const ps1 = read('setup.ps1');
+ const major = ps1.match(/\$majorVersion\s+-lt\s+(\d+)/);
+ const minor = ps1.match(/\$minorVersion\s+-lt\s+(\d+)/);
+ expect(major, 'setup.ps1 no longer contains a `$majorVersion -lt <n>` gate').toBeTruthy();
+ expect(minor, 'setup.ps1 no longer contains a `$minorVersion -lt <n>` gate').toBeTruthy();
+ expect([Number(major[1]), Number(minor[1])]).toEqual([MIN_MAJOR, MIN_MINOR]);
});
it.each(MANIFESTS)('%s declares engines.node = the floor', (rel) => {
@@ -64,12 +100,7 @@ describe('Node version floor has exactly one owner (issue #3863)', () => {
it('.nvmrc is >= MIN_NODE', () => {
const nvmrc = read('.nvmrc').trim();
expect(nvmrc).toMatch(/^\d+(\.\d+)*$/);
- expect(compareVersions(nvmrc, `${MIN_MAJOR}`)).toBeGreaterThanOrEqual(0);
- // A bare major in .nvmrc ("24") resolves to that line's latest release, so
- // compare majors when it omits a minor rather than reading "24" as 24.0.0.
- if (parseVersion(nvmrc)[0] === MIN_MAJOR) {
- expect(compareVersions(nvmrc, MIN_NODE)).toBeGreaterThanOrEqual(0);
- }
+ expect(pinSatisfiesFloor(nvmrc), `.nvmrc (${nvmrc}) is below the floor`).toBe(true);
});
it('every CI job pins a node-version >= MIN_NODE', () => {
@@ -80,15 +111,17 @@ describe('Node version floor has exactly one owner (issue #3863)', () => {
.split('\0')
.filter(Boolean);
const pins = workflows.flatMap((rel) =>
- [...read(rel).matchAll(/node-version:\s*['"]?(\d+)(?:\.[\dx]+)*/g)].map((m) => ({
+ [...read(rel).matchAll(/node-version:\s*['"]?(\d+(?:\.[\dx]+)*)/g)].map((m) => ({
rel,
- major: Number(m[1]),
+ pin: m[1],
}))
);
- // Sanity: without this the .each below would pass vacuously.
+ // Sanity: without this the loop below would pass vacuously.
expect(pins.length).toBeGreaterThan(0);
- for (const { rel, major } of pins) {
- expect(major, `${rel} pins node-version below the floor`).toBeGreaterThanOrEqual(MIN_MAJOR);
+ 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);
}
});
});
diff --git a/setup.ps1 b/setup.ps1
index 9d172e223d..43c534e07b 100644
--- a/setup.ps1
+++ b/setup.ps1
@@ -17,13 +17,16 @@ if (-not $nodeCommand) {
exit 1
}
-# Check Node.js version. Vite 8 (client build) requires ^20.19 || >=22.12, so a
-# v18 install fails at `npm run build` rather than here. Gate on 22 — what
-# .nvmrc and CI actually use.
+# 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])
-if ($majorVersion -lt 22) {
- Write-Host "Node.js 22+ required (found v$nodeVersion) - see .nvmrc" -ForegroundColor Red
+$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
exit 1
}
Write-Host "Found Node.js v$nodeVersion" -ForegroundColor Green
diff --git a/setup.sh b/setup.sh
index 65f5cdc9f0..5be831211c 100755
--- a/setup.sh
+++ b/setup.sh
@@ -18,11 +18,16 @@ if ! command -v node &> /dev/null; then
exit 1
fi
-# Vite 8 (client build) requires ^20.19 || >=22.12, so a v18 install fails at
-# `npm run build` rather than here. Gate on 22 — what .nvmrc and CI actually use.
-NODE_VERSION=$(node -v | cut -d'v' -f2 | cut -d'.' -f1)
-if [ "$NODE_VERSION" -lt 22 ]; then
- echo "Node.js 22+ required (found v$NODE_VERSION) — see .nvmrc"
+# 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.
+NODE_MAJOR=$(node -v | cut -d'v' -f2 | cut -d'.' -f1)
+NODE_MINOR=$(node -v | cut -d'v' -f2 | cut -d'.' -f2)
+if [ "$NODE_MAJOR" -lt 22 ] || { [ "$NODE_MAJOR" -eq 22 ] && [ "$NODE_MINOR" -lt 12 ]; }; then
+ echo "Node.js 22.12+ required (found $(node -v)) — see .nvmrc"
exit 1
fi