diff --git a/.github/workflows/runtime-matrix.yml b/.github/workflows/runtime-matrix.yml new file mode 100644 index 000000000..22cc927af --- /dev/null +++ b/.github/workflows/runtime-matrix.yml @@ -0,0 +1,64 @@ +--- +name: Runtime Matrix + +# #1165: compatibility validation across the supported Node.js LTS lines. +# Primary CI runtime is Node 22 (ci-and-labels.yml); this workflow adds the +# wider matrix on a schedule so per-PR CI time stays bounded while every +# supported runtime gets install/lint/typecheck/unit/build evidence weekly +# (and on demand, and on every change to its own definition). +'on': + schedule: + # Weekly, Monday 04:07 UTC — off the hour to reduce runner contention. + - cron: '7 4 * * 1' + workflow_dispatch: + pull_request: + paths: + - '.github/workflows/runtime-matrix.yml' + - 'pnpm-lock.yaml' + - 'package.json' + - 'pnpm-workspace.yaml' + +permissions: + contents: read + +concurrency: + group: runtime-matrix-${{ github.ref }} + cancel-in-progress: true + +jobs: + matrix: + name: Node ${{ matrix.node }} + runs-on: ubuntu-latest + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + node: ['22', '24', '26'] + steps: + - name: Checkout repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - name: Setup pnpm + uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1 + - name: Setup Node.js ${{ matrix.node }} + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: ${{ matrix.node }} + cache: 'pnpm' + - name: Frozen install + run: pnpm install --frozen-lockfile + - name: Lint + run: pnpm run lint + - name: Typecheck + run: pnpm run typecheck + - name: Unit tests + run: pnpm run test + - name: Production build + run: pnpm run build + - name: Runtime summary + if: always() + run: | + { + echo "## Runtime matrix — Node ${{ matrix.node }}" + echo "- engines.node: $(node -p 'require("./package.json").engines.node')" + echo "- Install, lint, typecheck, unit tests, and build are configured above." + } >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/security-scan.yml b/.github/workflows/security-scan.yml index 5ef59d20c..868a1d3d6 100644 --- a/.github/workflows/security-scan.yml +++ b/.github/workflows/security-scan.yml @@ -192,16 +192,14 @@ jobs: with: node-version: '22' - # Fails on high/critical only. Lower severities are still listed on - # failure output but must not gate a PR on an unpatched transitive - # advisory the project cannot change. + # Fails on high/critical advisories after applying the reviewed, + # GHSA-scoped exception configured in pnpm-workspace.yaml. - name: Audit lockfile for high/critical advisories - # CVE-2026-93687 (GHSA-vfj7-8cjw-p6xm, braces stack-exhaustion DoS) is - # HIGH with NO patched release (<0.0.0, disclosed 2026-10-03) and is a - # transitive dep of eslint-config-next -> fast-glob -> micromatch. - # Ignored by CVE until upstream ships a fix; every other high/critical - # advisory still fails this job. - run: pnpm audit --audit-level=high --ignore CVE-2026-93687 + # GHSA-vfj7-8cjw-p6xm (braces) was withdrawn on 2026-10-23 as not + # practically exploitable. pnpm audit requires GHSA identifiers; + # CVE identifiers are not valid entries in its ignore configuration. + # All other high/critical advisories remain blocking. + run: pnpm audit --audit-level=high # ============================================================================ # INFRASTRUCTURE AS CODE SCAN diff --git a/.npmrc b/.npmrc deleted file mode 100644 index b6f27f135..000000000 --- a/.npmrc +++ /dev/null @@ -1 +0,0 @@ -engine-strict=true diff --git a/README.md b/README.md index 2a0250bba..f47894523 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ Your notes stay in this browser (IndexedDB + a small localStorage envelope). No ### Prerequisites - **Node.js**: $\ge 22$ (pinned by `.nvmrc` and permitted by `package.json` `engines`) -- **pnpm**: `10.30.3` (pinned by `package.json` `packageManager`) +- **pnpm**: `12.17.0` (pinned by `package.json` `packageManager`) ### Installation & Development diff --git a/agents-docs/DEPLOYMENT.md b/agents-docs/DEPLOYMENT.md index c3f0b97f2..306612552 100644 --- a/agents-docs/DEPLOYMENT.md +++ b/agents-docs/DEPLOYMENT.md @@ -23,10 +23,10 @@ , an override makes Vercel use the *oldest* version of the named package manager in the build image — for pnpm that is **v6**, which cannot read this repo's `lockfileVersion: '9.0'` or its -`pnpm.overrides`. With no override, Vercel infers pnpm from `pnpm-lock.yaml` +`pnpm-workspace.yaml` `overrides`. With no override, Vercel infers pnpm from `pnpm-lock.yaml` and picks the right major. -The `packageManager: "pnpm@10.30.3"` field only takes effect when Corepack is +The `packageManager: "pnpm@12.17.0"` field only takes effect when Corepack is enabled on the Vercel project (`ENABLE_EXPERIMENTAL_COREPACK=1`). Do not assume it is active. diff --git a/agents-docs/RUNTIME_TOOLCHAIN.md b/agents-docs/RUNTIME_TOOLCHAIN.md new file mode 100644 index 000000000..7bd2d2c37 --- /dev/null +++ b/agents-docs/RUNTIME_TOOLCHAIN.md @@ -0,0 +1,52 @@ +# Runtime & Toolchain + +Authoritative decisions: `plans/219-runtime-toolchain-1165-1166-2026-11-19.md` +(#1165 Node matrix, #1166 pnpm 12). This page is the operator-facing summary. + +## Node.js + +| Runtime | Status | Where validated | +|---------|--------|-----------------| +| Node 22 LTS | **Primary runtime** — `engines.node` floor is `>=22.12.0` | Per-PR CI (`ci-and-labels.yml`), `setup-node` pinned to `'22'` | +| Node 24 LTS | Supported — inside `engines.node` `>=22.12.0 <27.0.0` | Scheduled weekly matrix (`.github/workflows/runtime-matrix.yml`) | +| Node 26 LTS | Supported — same range, same schedule | Same matrix | +| Node 27+ | **Not supported** (untested future line) — engine-strict refuses it | — | + +- The matrix runs frozen install, lint, typecheck, unit tests, and the + production build on every listed runtime (weekly + on demand + on any + change to the workflow, lockfile, or root manifests). +- A red matrix run is a supported-runtime blocker: record the concrete + failure (and the upstream issue) in plan 219, narrow `engines.node`, and + note the exclusion — no runtime is advertised merely because install + worked. + +## pnpm + +- Pinned **`pnpm@12.17.0`** by `packageManager` (lockfile vendors the pinned + manager: integrity-checked `@pnpm/exe.*` artifacts in the lockfile's + manager document, so CI and local installs are reproducible even before + `pnpm/action-setup` runs). +- All pnpm settings live in `pnpm-workspace.yaml` (`engineStrict`, + `peerDependencyRules`, `overrides`, `allowBuilds`, `auditConfig`). There is + **no `.npmrc`** and no `pnpm` field in `package.json` — pnpm 12 ignores the + latter and the validator (`scripts/validate-package-manager.sh`) fails the + gate if settings drift back. +- Build scripts of pinned deps are **denied by default** (`allowBuilds: + pkg: false` — core-js, esbuild, onnxruntime-node, protobufjs, + unrs-resolver). To approve a new dep's postinstall, run + `pnpm approve-builds ` and review the resulting `allowBuilds` diff — + never run `--all`. +- Rollback pnpm: `git revert` the plan-219 commit, then + `pnpm install --frozen-lockfile` (details in plan 219). + +## Upgrading the toolchain (next time) + +1. `npm view pnpm versions` + release notes; test with + `npm_config_manage_package_manager_versions=false npx -y pnpm@ + install --frozen-lockfile` first — expect a settings migration, never + regenerate blindly. +2. `pnpm approve-builds` for new build-script deps (deny form to preserve the + default). +3. Full gate under the candidate (`pnpm --version` must print the candidate), + lockfile churn diff (target: zero dep-graph changes), docs + plan record, + then pin. diff --git a/package.json b/package.json index 23dd23dd8..8198663e7 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,9 @@ "version": "0.2.0", "private": true, "type": "module", - "packageManager": "pnpm@10.30.3", + "packageManager": "pnpm@12.17.0", "engines": { - "node": ">=22.0.0 <25.0.0" + "node": ">=22.12.0 <27.0.0" }, "scripts": { "prepare": "./scripts/install-hooks.sh", @@ -124,40 +124,5 @@ "typescript-eslint": "^8.67.0", "vite": "^8.2.4", "vitest": "4.1.11" - }, - "pnpm": { - "peerDependencyRules": { - "allowedVersions": { - "eslint": "10" - } - }, - "overrides": { - "postcss": "^8.5.23", - "source-map-js": "^1.2.2", - "brace-expansion@<1.1.18": "1.1.21", - "brace-expansion@>=5": "^5.0.12", - "picomatch": "^4.0.4", - "browserslist": "^4.28.7", - "js-yaml": "^4.3.2", - "adm-zip": "npm:adm-zip@0.6.1", - "dompurify": "^3.4.18", - "undici": "^7.29.1", - "nanoid@3": "3.3.18", - "postcss-selector-parser": "^7.1.6", - "smol-toml": "^1.9.1", - "katex": "^0.19.0" - }, - "ignoredBuiltDependencies": [ - "core-js", - "esbuild", - "onnxruntime-node", - "protobufjs", - "unrs-resolver" - ], - "auditConfig": { - "ignoreCves": [ - "CVE-2026-93687" - ] - } } } diff --git a/plans/218-csp-reassessment-1167-2026-11-19.md b/plans/218-csp-reassessment-1167-2026-11-19.md new file mode 100644 index 000000000..c547924ef --- /dev/null +++ b/plans/218-csp-reassessment-1167-2026-11-19.md @@ -0,0 +1,57 @@ +# Plan 218 — CSP reassessment for #1167 (2026-11-19) + +Periodic reassessment of the Content-Security-Policy required by #1167. +**Outcome: the least-privilege posture is confirmed; every exception is +measured and carries a revisit trigger; no policy change ships in plan 217.** + +Baseline: `packages` of evidence from #1051 / plan 191 — implementation in +`src/lib/security/csp.ts` (+ `next.config.ts`) with the unit invariant pins +in `src/lib/security/csp.test.ts` and production-Chromium violation capture +in `e2e/csp-violations.spec.ts`. + +## Directive inventory (each source → why it exists → evidence) + +| Directive | Included sources | Required by | Evidence / revisit trigger | +|-----------|------------------|-------------|----------------------------| +| `default-src` | `'self'` | Everything else falls back to self; frame/object/base are separately tightened | Static site; no third-party frame/object/base use. Revisit on any new embedding feature. | +| `script-src` | `'self' 'unsafe-inline' 'unsafe-eval' 'wasm-unsafe-eval' blob:` | - `self`: app bundles. - `unsafe-eval`: `onnxruntime-web` compiles with `eval` — production Chromium drive recorded a real `script-src → eval` violation without it (plan 191). Removing it ships a permanent lexical fallback behind a working-looking toggle. - `wasm-unsafe-eval`: WebAssembly compile of the ONNX runtime (additive, never a substitute). - `blob:`: onnxruntime imports its WASM loader as a blob module — measured `script-src-elem → blob` + "no available backend found" without it. - `unsafe-inline`: Next.js does not emit nonce-bearing inline scripts in a static export; removing it breaks hydration (**#1051** tracks the nonce pipeline). | Re-run the production drive whenever: Next.js major upgrades; transformers.js/onnxruntime-web upgrades (watch for a no-eval build); any CSP violation appears in the e2e log. | +| `style-src` | `'self' 'unsafe-inline'` | Next.js inlines critical CSS `