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

test: guard docs/DEPS.md against dependency drift (#5708)

[._.]/ Adam Eivy2ca70196d9f7
diff --git a/docs/DEPS.md b/docs/DEPS.md
index 5289af9971..66f96b35e0 100644
--- a/docs/DEPS.md
+++ b/docs/DEPS.md
@@ -2,7 +2,9 @@
Living reference of every third-party dependency in PortOS, why it's kept, and what the current verdict is. Updated by `/do:depfree` runs.
-**Last audited:** 2026-09-02 (scoped: `pdf-lib` → `@cantoo/pdf-lib`, issue #5672); prior 2026-08-04 (scoped audit of the `keyv`/`cacheable` supply-chain compromise); prior follow-up 2026-07-14 (issue #2547), prior full audit 2026-04-28 (default mode), tables corrected 2026-07-01 during a docs audit.
+That "every dependency" claim is enforced by `docs/deps-doc.test.js` (run by `cd server && npm test`): adding a dependency to any workspace manifest without a row here fails the suite, and a Quick Reference row naming a package no manifest declares fails too unless its verdict records the removal (`REMOVED` / `REPLACED`).
+
+**Last audited:** 2026-09-02 (scoped: `pdf-lib` → `@cantoo/pdf-lib`, issue #5672; parity sweep that added the missing `playwright-core` row and put this document under test — `docs/deps-doc.test.js`, issue #5708); prior 2026-08-04 (scoped audit of the `keyv`/`cacheable` supply-chain compromise); prior follow-up 2026-07-14 (issue #2547), prior full audit 2026-04-28 (default mode), tables corrected 2026-07-01 during a docs audit.
**Verdict:** All dependencies justified. The 2026-08-04 audit replaced the entire `eslint` stack with `@biomejs/biome`, dropping 110 net client packages including the `file-entry-cache → flat-cache → keyv` chain named in the August 2026 Shai-Hulud npm compromise (PortOS held safe versions throughout — see the detailed finding below). The same pass closed a latent hole where `ignore-scripts=true` was only active for repo-root installs, not for any workspace install or CI. Since the last full audit: `sax` was removed (replaced with an owned parser, issue #1824), `portos-ai-toolkit` was vendored in-tree (`server/lib/aiToolkit/`), and monolithic `googleapis` was replaced with scoped `@googleapis/*` packages. The 2026-07-14 follow-up bumped `kokoro-js` to its latest patch `1.2.1` (still on maintenance watch — no publish since 2025-05) and aligned the dual `pm2` pins (root + server both `7.0.4`). The 2026-09-02 follow-up replaced abandoned `pdf-lib` (no publish since 2022-05) with the maintained MIT fork `@cantoo/[email protected]` — a same-public-API swap across the four export paths, done while `npm audit` was still clean rather than under advisory pressure.
## Audit Methodology
@@ -33,6 +35,7 @@ Before removing a Tier 3 candidate, run a transitive-dep check (`npm ls <pkg>`).
| `kokoro-js` | 2 | KEEP | `server/services/voice/tts-kokoro.js` | Only pure-JS in-process TTS; replacement = Python subprocess + pooling |
| `node-pty` | 1 | KEEP | shell/terminal services | Native PTY binding (N-API) |
| `pg` | 1 | KEEP | Postgres access | Official `pg` driver |
+| `playwright-core` | 1 | KEEP | `server/services/fableLoom/falVideoAutomation.js` — fal.ai scene video automation | Drives the PortOS-managed browser over CDP (`chromium.connectOverCDP`). `-core` rather than the full `playwright` package deliberately: the browser is provisioned separately by `npm run setup:browser`, so the bundled browser download would be dead weight |
| `pm2` | 1 | KEEP | app lifecycle | Process manager. Pinned `7.0.4` (aligned with root pin) |
| `sharp` | 1 | KEEP | image processing | Native, widely-audited |
| `socket.io` | 1 | KEEP | realtime | Foundational |
@@ -124,7 +127,7 @@ Before removing a Tier 3 candidate, run a transitive-dep check (`npm ls <pkg>`).
- **Trigger**: the August 2026 Shai-Hulud npm compromise hit `keyv`, `flat-cache`, and `file-entry-cache` (among ~430 packages). PortOS was **never exposed** — it held `[email protected]`, `[email protected]`, `[email protected]`, while the malicious releases were the *next major* in each line (`6.0.0` / `6.1.24` / `11.1.6`), unreachable from the `^4` / `^4.0.0` / `^8.0.0` ranges. npm has since unpublished all three, and no install hook ever existed in the tree.
- **Why they were here at all**: not direct dependencies. A single chain under one root — `eslint → file-entry-cache → flat-cache → keyv` — client workspace, devDependencies only. `[email protected]` (latest) hard-requires `file-entry-cache@^8.0.0`; no eslint release drops it. So the only way to shed them was to stop using eslint.
- **Semver headroom was already zero**: the highest published `[email protected]` *is* `8.0.0`, `[email protected]` *is* `4.0.1`, `[email protected]` *is* `4.5.4`. An `overrides` pin would have been a no-op — there was nowhere to float. Removal was therefore a **maintenance** win, not a security fix.
-- **Resolution**: replaced eslint with `@biomejs/[email protected]`. Client lockfile **447 → 337 packages** (−110; the eslint tree out, 9 Biome entries in, only 1 platform binary installed). All four eslint-chain packages now report 0 occurrences in `client/package-lock.json`.
+- **Resolution**: replaced eslint with `@biomejs/biome` (the Quick Reference row and `client/package.json` are the version's home — naming a pin here only drifts). Client lockfile **447 → 337 packages** (−110; the eslint tree out, 9 Biome entries in, only 1 platform binary installed). All four eslint-chain packages now report 0 occurrences in `client/package-lock.json`.
- **`typescript` went with it.** It was a client devDependency solely to satisfy `@eslint-react/eslint-plugin`'s peer dep — the client has no `tsconfig`, zero `.ts`/`.tsx` sources, no `tsc` script, and nothing peer-depends on it. Removing it also retires the `.github/dependabot.yml` ignore rule that pinned it below TS7 (and issue #3351, which tracked waiting on typescript-eslint for TS7 support — now moot).
- **Rule parity was proven with fixtures, not inferred from a clean run** — a linter with no rules also reports "0 problems". Every rule the old config enforced fires under Biome; `npm run lint` covers the same **1859 files** with 0 problems. `exhaustive-deps` was already `off` (documented, deliberate), which is what made this a half-day swap instead of a risky one.
- **The `crypto.randomUUID` ban survives as a GritQL plugin** (`client/lint-no-random-uuid.grit`). This rule is load-bearing: `crypto.randomUUID` is undefined on insecure origins, and PortOS is routinely reached over plain HTTP via Tailscale. It matches on the CST node kind rather than code snippets, so it catches `crypto.`, `globalThis.crypto.`, `window.`, `self.`, optional chaining, bare `typeof` references, and assignment targets — and, matching the old ESLint rule exactly, *not* `crypto['randomUUID']`. Exemptions for `src/lib/uuid.js` and `src/**/*.test.{js,jsx}` are expressed as **negated globs**, because a Biome override's `plugins` list is *additive*: `plugins: []` does NOT disable an inherited plugin. Do not "simplify" that back.
diff --git a/docs/deps-doc.test.js b/docs/deps-doc.test.js
new file mode 100644
index 0000000000..841322a1a9
--- /dev/null
+++ b/docs/deps-doc.test.js
@@ -0,0 +1,89 @@
+/**
+ * Parity guard for docs/DEPS.md.
+ *
+ * DEPS.md calls itself a "living reference of every third-party dependency in
+ * PortOS" and is the artifact a reviewer consults to answer "why is this package
+ * here, and is it still justified?". Nothing enforced that claim, and it drifted:
+ * `playwright-core` landed as a server runtime dependency 27 days after the
+ * document's stated last-audit date and had no row at all, so the newest
+ * dependency in the tree was the one with no recorded justification.
+ *
+ * These assertions move that failure from "the next audit, months later" to the
+ * commit that introduces it. They deliberately check *names*, not versions —
+ * DEPS.md carries no version for most rows, and asserting on the few that do
+ * would turn every Dependabot bump into a doc-edit chore.
+ *
+ * The test is colocated with the document it guards; `server/vitest.config.js`
+ * globs `../docs/**` so `cd server && npm test` picks it up.
+ */
+import { readFileSync } from 'fs';
+import { dirname, join } from 'path';
+import { fileURLToPath } from 'url';
+import { describe, expect, it } from 'vitest';
+import { discoverWorkspaces, workspaceDir } from '../scripts/trusted-rebuilds.js';
+
+const DOC = readFileSync(join(dirname(fileURLToPath(import.meta.url)), 'DEPS.md'), 'utf8');
+
+/**
+ * Every direct dependency name in every workspace manifest, mapped to the
+ * workspaces declaring it. Workspaces are discovered rather than hardcoded
+ * (`discoverWorkspaces()` is the repo's existing single source for "what is a
+ * workspace"), so a fifth workspace is covered without editing a list here.
+ *
+ * Manifests are read and JSON-parsed as files rather than resolved as modules:
+ * CI never installs root `node_modules`, so anything reached through an
+ * installed package would be green locally and red in CI.
+ */
+const WORKSPACES = discoverWorkspaces();
+const DECLARED = new Map();
+for (const label of WORKSPACES) {
+ const pkg = JSON.parse(readFileSync(join(workspaceDir(label), 'package.json'), 'utf8'));
+ for (const name of [...Object.keys(pkg.dependencies ?? {}), ...Object.keys(pkg.devDependencies ?? {})]) {
+ DECLARED.set(name, [...(DECLARED.get(name) ?? []), label]);
+ }
+}
+
+/**
+ * Rows of the Quick Reference table, as `{ name, verdict }`. Scoped to that one
+ * section so a table added to the prose below can't be mistaken for the roster.
+ * Cells are split rather than pattern-matched so padding changes are invisible;
+ * section headings (`**Server deps**`) and the browser workspace's `_(none)_`
+ * placeholder carry no backticked package and drop out.
+ */
+function quickReferenceRows() {
+ const afterHeading = DOC.slice(DOC.indexOf('## Quick Reference Table') + 1);
+ const end = afterHeading.indexOf('\n## ');
+ const section = end === -1 ? afterHeading : afterHeading.slice(0, end);
+ return section
+ .split('\n')
+ .map((line) => line.split('|').map((cell) => cell.trim()))
+ .map(([, name, , verdict]) => ({ name: /^`([^`]+)`$/.exec(name ?? '')?.[1], verdict: verdict ?? '' }))
+ .filter(({ name }) => name);
+}
+
+describe('docs/DEPS.md', () => {
+ it('documents every dependency declared in every workspace manifest', () => {
+ // A Quick Reference row, not merely a backticked mention anywhere in the
+ // file: prose elsewhere (a "Last audited" note, a detailed finding) names
+ // packages in passing, and accepting that would let a deleted row pass.
+ const documented = new Set(quickReferenceRows().map(({ name }) => name));
+ const undocumented = [...DECLARED.entries()]
+ .filter(([name]) => !documented.has(name))
+ .map(([name, labels]) => `${name} (${labels.join(', ')})`);
+ expect(undocumented).toEqual([]);
+ });
+
+ it('names no package that no manifest declares, unless the row records a removal', () => {
+ const stale = quickReferenceRows()
+ .filter(({ name, verdict }) => !DECLARED.has(name) && !/REMOVED|REPLACED/.test(verdict))
+ .map(({ name }) => name);
+ expect(stale).toEqual([]);
+ });
+
+ it('scans a non-empty set of manifests and table rows', () => {
+ // Without this, a broken discovery path or a table-format change lets both
+ // assertions above pass over nothing at all.
+ expect(WORKSPACES.length).toBeGreaterThanOrEqual(4);
+ expect(quickReferenceRows().length).toBeGreaterThanOrEqual(40);
+ });
+});
diff --git a/server/vitest.config.js b/server/vitest.config.js
index 42d4fdd957..411d7b2af1 100644
--- a/server/vitest.config.js
+++ b/server/vitest.config.js
@@ -61,6 +61,9 @@ export default defineConfig({
// (sandbox.js isolation/promotion primitives) whose adversarial tests run
// under this node runner.
'../autofixer/**/*.test.js',
+ // docs/deps-doc.test.js guards DEPS.md against dependency drift; it lives
+ // next to the document it checks rather than in server/.
+ '../docs/**/*.test.js',
],
// The slashdo submodule ships its own node:test suites; vitest can't
// parse them and the broad `../lib/**` glob would otherwise pick them up