Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
build: the Electron fuses ride the flip-preparation release
review744c0eacce95
diff --git a/docs/project-limit.md b/docs/project-limit.mdindex d230350df..5b99bab3d 100644--- a/docs/project-limit.md+++ b/docs/project-limit.md@@ -260,14 +260,23 @@ with "Up to N open projects", lists "Unlimited open projects" under Pro, and the5. Keep both constants in their literal one-line form —`export const PROJECT_LIMIT_DEADLINE_MS = Date.parse('<ISO instant>')` and`export const PROJECT_LIMIT_DEADLINE_FROZEN = true | false` — because the guard reads the source.+6. **The Electron fuses ship with the flip-preparation release, not before.** `package.json` carries+ no `build.electronFuses` while the limit is dormant: the fuses would be the one change a user of+ a dormant release could notice (they unset `NODE_EXTRA_CA_CERTS`, see below). After the owner's+ NODE_EXTRA_CA_CERTS decision and device Run 1, the flip-preparation release sets+ `build.electronFuses` to exactly `scripts/electron-fuses.json` — the one definition, read by both+ `src/main/electron-fuses.test.ts` (the decision record; it accepts absent or exactly that object)+ and the guard, which refuses a **frozen** release whose `build.electronFuses` is absent or differs+ from it. An unfrozen release is not checked.**The guard**: `scripts/check-project-limit-deadline.mjs` is the first step that runs in each buildjob of `.github/workflows/release.yml` — `release-mac`, `release-linux` and `release-win` — rightafter checkout and setup-node, before `npm ci` (plain node). It exits 1 when the deadline is lessthan 30 days away and not frozen, or when it cannot read the constants; and for a **frozen** (flip)release also when `PROJECT_ALLOWANCE_PUBLIC_KEY` (`src/core/project-allowance-key.ts`) is empty,-unreadable, not an Ed25519 public-key PEM, or a private key. An unfrozen release never looks at the-key. The three jobs run in+unreadable, not an Ed25519 public-key PEM, or a private key, and when `package.json`'s+`build.electronFuses` is not exactly `scripts/electron-fuses.json` (item 6). An unfrozen release+never looks at the key or the fuses. The three jobs run inparallel and each creates the release on its first upload, so a refused tag fails all three beforeanything is built or uploaded: no release, not even a prerelease, and `publish` never runs. Bump thedeadline, then move the tag to that commit (or tag the next version) and rerun.@@ -275,7 +284,7 @@ deadline, then move the tag to that commit (or tag the next version) and rerun.so a change of literal form fails on the PR, not on release day, and pins the step's place in allthree jobs. It never guards a frozen deadline's DATE — that is item 2's hazard.-## Before Release B ships — owner decisions+## Owner decisions before the limit can ship### O1: the allowance key pair@@ -308,10 +317,14 @@ the installs the limit will never reach until they update (Accepted gaps). The gkey only at the flip release, because refusing every release before O1 would block unrelatedreleases; doing O1 early is the owner's call.-### NODE_EXTRA_CA_CERTS / NODE_OPTIONS (owner's call before Release B)+### NODE_EXTRA_CA_CERTS / NODE_OPTIONS (owner's call before the fuses ship)-The hardening fuse `enableNodeOptionsEnvironmentVariable: false` (`package.json`-`build.electronFuses`, the Release B hardening) makes Electron **unset** `NODE_OPTIONS` **and**+The fuses ship with the flip-preparation release (Release checklist, item 6), so this decision is+due before that release, not before Release B — which ships no fuses.++The hardening fuse `enableNodeOptionsEnvironmentVariable: false` (`scripts/electron-fuses.json`,+set as `package.json` `build.electronFuses` from the flip-preparation release on) makes Electron+**unset** `NODE_OPTIONS` **and**`NODE_EXTRA_CA_CERTS` at process start, in GUI and RunAsNode mode alike (measured on Electron42.11.16). Consequences:@@ -330,7 +343,7 @@ The hardening fuse `enableNodeOptionsEnvironmentVariable: false` (`package.json`main process (measured against an unfused control) — a one-line bypass of the gate on macOS andWindows.-Options before Release B ships:+Options before the flip-preparation release ships:- **(a)** Ship with the cost and say so in the release notes.- **(b)** First build child re-supply: read the values from the login-shell probe@@ -357,9 +370,12 @@ The decision is enes's. Device check 10 below gathers the evidence.client — with the O1 public key pasted, or its installs stay unlimited even after the flip.Every later release before the flip bumps `PROJECT_LIMIT_DEADLINE_MS` (the release workflowrefuses otherwise).+- **Flip preparation — a release before O4:** after the NODE_EXTRA_CA_CERTS decision and device+ Run 1, set `package.json` `build.electronFuses` to exactly `scripts/electron-fuses.json`+ (Release checklist, item 6). The flip release is refused without them.- **O4 — flip day:**- 1. In the release that accompanies the flip (or the first one after it), set- `PROJECT_LIMIT_DEADLINE_FROZEN = true` and the deadline to the flip date. If the flip slips past+ 1. In the release that accompanies the flip (or the first one after it — it must carry the fuses),+ set `PROJECT_LIMIT_DEADLINE_FROZEN = true` and the deadline to the flip date. If the flip slips pasta deadline a shipped release has already frozen, nothing warns you: ship a release that sets`FROZEN = false` and bumps the deadline before that date passes (Release checklist, item 2).2. Set the cutoff in the admin console's Project limit card (an ISO instant with an offset).@@ -423,8 +439,9 @@ The decision is enes's. Device check 10 below gathers the evidence.3. Hand-editing `workspace.json` to un-close projects bypasses the gate; never clamped. The sameclass: a hand-edited future `offAt` in `project-limit.json` suppresses the deadline.4. A patched build (easy on Linux — Electron has no asar integrity there — re-signing needed on- macOS/Windows). After the license change (#1317) this is a license breach for production use,- not something the code prevents.+ macOS/Windows once the fuses ship; before the flip-preparation release, easy everywhere). After+ the license change (#1317) this is a license breach for production use, not something the code+ prevents.5. Both legacy counts are client-reported and only capped at CAP. Before the cutoff anyone who readsthe public Release A change can mint a legacy device id with a CAP-sized allowance by calling`/v1/check` by hand. This ends at the cutoff; the date is not announced in advance.@@ -462,6 +479,10 @@ verification and reads as "Couldn't check your free allowance".**Run 1 — packaged builds, no server needed**+No release carries the fuses before the flip-preparation release, so Run 1 runs on packaged test+builds made with `build.electronFuses` set to exactly `scripts/electron-fuses.json`; its results+(with check 10's) are what that release waits for.+1. macOS arm64 and x64, signed: the app launches; `npx @electron/fuses read --app <path>` shows`EnableEmbeddedAsarIntegrityValidation` and `OnlyLoadAppFromAsar` enabled, RunAsNode enabled,NodeOptions and NodeCliInspect disabled; `Info.plist` carries `ElectronAsarIntegrity`.diff --git a/package.json b/package.jsonindex 144e950c5..db69ac9d0 100644--- a/package.json+++ b/package.json@@ -61,13 +61,6 @@"**/node_modules/sharp/**","**/node_modules/@img/**"],- "electronFuses": {- "runAsNode": true,- "enableNodeOptionsEnvironmentVariable": false,- "enableNodeCliInspectArguments": false,- "enableEmbeddedAsarIntegrityValidation": true,- "onlyLoadAppFromAsar": true- },"extraResources": [{"from": "build/icon.png",diff --git a/scripts/check-project-limit-deadline.mjs b/scripts/check-project-limit-deadline.mjsindex d1931d3ce..cc80911fd 100644--- a/scripts/check-project-limit-deadline.mjs+++ b/scripts/check-project-limit-deadline.mjs@@ -16,6 +16,12 @@// So a frozen release is refused while the key is empty, unreadable, not an Ed25519 public-key PEM,// or a PRIVATE key. An unfrozen release does not look at the key at all.//+// The flip release also ships the Electron hardening fuses (src/main/electron-fuses.test.ts holds the+// decision record): `package.json` `build.electronFuses` stays absent while the limit is dormant and+// is added in the flip-preparation release, set to exactly `scripts/electron-fuses.json` — the one+// definition both that test and this guard read. A frozen release is refused unless package.json+// carries exactly that object; an unfrozen release does not look at the fuses either.+//// It reads the SOURCE TEXT, not the compiled constant, so it runs before `npm ci` with node alone.// That is why the constants must keep their literal forms on one line:// export const PROJECT_LIMIT_DEADLINE_MS = Date.parse('<ISO instant>')@@ -23,7 +29,7 @@// Anything else is reported as unreadable — never waved through. The test pins these readings to the// values the app actually compiles.//-// Usage: node scripts/check-project-limit-deadline.mjs [path/to/project-limit.ts [path/to/project-allowance-key.ts]]+// Usage: node scripts/check-project-limit-deadline.mjs [path/to/project-limit.ts [path/to/project-allowance-key.ts [path/to/package.json]]]import crypto from 'node:crypto'import fs from 'node:fs'import path from 'node:path'@@ -32,6 +38,7 @@ import { fileURLToPath } from 'node:url'const MIN_LEAD_MS = 30 * 24 * 60 * 60 * 1000const SOURCE = 'src/shared/project-limit.ts'const KEY_SOURCE = 'src/core/project-allowance-key.ts'+const FUSES_SOURCE = 'scripts/electron-fuses.json'const DEADLINE_RE = /^export const PROJECT_LIMIT_DEADLINE_MS = Date\.parse\('([^']*)'\)\s*$/mconst FROZEN_RE = /^export const PROJECT_LIMIT_DEADLINE_FROZEN = (true|false)\s*$/m@@ -93,14 +100,94 @@ export function readAllowanceKey(source) {}/**- * Why this pair of sources must not be released at `now`, or null when it may: the deadline first- * (`deadlineProblem`), then — only for a frozen (flip) release — the allowance key.+ * The fuses the flip release must ship (`scripts/electron-fuses.json`, next to this script), or null+ * when that file cannot be read or is not a JSON object.+ * @returns {Record<string, unknown> | null}+ */+export function readExpectedFuses() {+ try {+ const v = JSON.parse(fs.readFileSync(fileURLToPath(new URL('./electron-fuses.json', import.meta.url)), 'utf8'))+ return isPlainObject(v) ? v : null+ } catch {+ return null+ }+}++/** @param {unknown} v */+function isPlainObject(v) {+ return typeof v === 'object' && v !== null && !Array.isArray(v)+}++/**+ * JSON deep equality; key order is not a difference.+ * @param {unknown} a+ * @param {unknown} b+ * @returns {boolean}+ */+function jsonEqual(a, b) {+ if (Array.isArray(a) || Array.isArray(b)) {+ return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((v, i) => jsonEqual(v, b[i]))+ }+ if (isPlainObject(a) && isPlainObject(b)) {+ const ka = Object.keys(a)+ const kb = Object.keys(b)+ return ka.length === kb.length && ka.every((k) => Object.hasOwn(b, k) && jsonEqual(a[k], b[k]))+ }+ return Object.is(a, b)+}++/**+ * Why this package.json's `build.electronFuses` is not the flip release's, or null when it is exactly+ * `expected`.+ * @param {string | null | undefined} packageSource the text of package.json; null/undefined = unreadable+ * @param {Record<string, unknown> | null} expected `readExpectedFuses()`; null = unreadable+ * @returns {string | null}+ */+export function fusesProblem(packageSource, expected) {+ if (!expected) {+ return `could not read ${FUSES_SOURCE} — the flip release ships exactly those fuses (docs/project-limit.md, Release checklist)`+ }+ let build+ try {+ const pkg = JSON.parse(packageSource ?? '')+ if (!isPlainObject(pkg)) throw new Error('not an object')+ build = pkg.build+ } catch {+ build = undefined+ }+ if (!isPlainObject(build)) {+ return (+ 'could not read build.electronFuses from package.json — the flip release ships the hardening fuses ' ++ '(docs/project-limit.md, Release checklist)'+ )+ }+ if (!Object.hasOwn(build, 'electronFuses')) {+ return (+ 'package.json has no build.electronFuses — the flip release ships the hardening fuses: set it to exactly ' ++ `${FUSES_SOURCE} (docs/project-limit.md, Release checklist)`+ )+ }+ if (!jsonEqual(build.electronFuses, expected)) {+ return (+ `package.json build.electronFuses differs from ${FUSES_SOURCE} — the flip release ships exactly those ` ++ 'fuses; a change to them is a decision for src/main/electron-fuses.test.ts (docs/project-limit.md, Release checklist)'+ )+ }+ return null+}++/**+ * Why these sources must not be released at `now`, or null when they may: the deadline first+ * (`deadlineProblem`), then — only for a frozen (flip) release — the allowance key, then the fuses.* @param {string} source the text of src/shared/project-limit.ts* @param {string | null} keySource the text of src/core/project-allowance-key.ts; null = unreadable* @param {Date} now+ * @param {string | null} [packageSource] the text of package.json; null/absent = unreadable+ * @param {Record<string, unknown> | null} [expectedFuses] defaults to `readExpectedFuses()`, read only+ * for a frozen release* @returns {string | null}*/-export function releaseProblem(source, keySource, now) {+export function releaseProblem(source, keySource, now, packageSource, expectedFuses) {const deadline = deadlineProblem(source, now)if (deadline) return deadlineif (!readDeadline(source).frozen) return null@@ -137,7 +224,7 @@ export function releaseProblem(source, keySource, now) {'public half of PROJECT_ALLOWANCE_PRIVATE_KEY before the flip release (docs/project-limit.md, O1)')}- return null+ return fusesProblem(packageSource, expectedFuses === undefined ? readExpectedFuses() : expectedFuses)}function fail(message) {@@ -161,6 +248,7 @@ if (isMain) {const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')const file = process.argv[2] ?? path.join(root, SOURCE)const keyFile = process.argv[3] ?? path.join(root, KEY_SOURCE)+ const pkgFile = process.argv[4] ?? path.join(root, 'package.json')let sourcetry {source = fs.readFileSync(file, 'utf8')@@ -174,7 +262,14 @@ if (isMain) {} catch {keySource = null}- const problem = releaseProblem(source, keySource, new Date())+ // Likewise: only a frozen release needs the fuses.+ let packageSource = null+ try {+ packageSource = fs.readFileSync(pkgFile, 'utf8')+ } catch {+ packageSource = null+ }+ const problem = releaseProblem(source, keySource, new Date(), packageSource)if (problem) fail(problem)const { deadlineMs, frozen } = readDeadline(source)console.log(diff --git a/scripts/check-project-limit-deadline.test.ts b/scripts/check-project-limit-deadline.test.tsindex b672c7939..bf08598e1 100644--- a/scripts/check-project-limit-deadline.test.ts+++ b/scripts/check-project-limit-deadline.test.ts@@ -6,8 +6,10 @@ import path from 'path'import { testTmpDir } from '../src/core/test-tmp'import { PROJECT_LIMIT_DEADLINE_FROZEN, PROJECT_LIMIT_DEADLINE_MS } from '../src/shared/project-limit'import { PROJECT_ALLOWANCE_PUBLIC_KEY } from '../src/core/project-allowance-key'+import EXPECTED_FUSES from './electron-fuses.json'import {deadlineProblem,+ fusesProblem,readAllowanceKey,readDeadline,releaseProblem@@ -36,6 +38,16 @@ function keySource(value: string): string {const EMPTY_KEY ='PROJECT_ALLOWANCE_PUBLIC_KEY is empty — paste the public half of PROJECT_ALLOWANCE_PRIVATE_KEY into src/core/project-allowance-key.ts before the flip release (docs/project-limit.md, O1)'+/** A package.json whose `build` block carries `fuses` (`undefined` = no `electronFuses` key at all). */+function pkgSource(fuses?: unknown): string {+ const build: Record<string, unknown> = { appId: 'com.nodeterm.app', asar: true }+ if (fuses !== undefined) build.electronFuses = fuses+ return JSON.stringify({ name: 'node-terminal', build }, null, 2)+}+const FUSED = pkgSource(EXPECTED_FUSES)+const NO_FUSES =+ 'package.json has no build.electronFuses — the flip release ships the hardening fuses: set it to exactly scripts/electron-fuses.json (docs/project-limit.md, Release checklist)'+/** The two lines the guard reads, in the shape src/shared/project-limit.ts writes them, wrapped in* the same kind of doc comment (which itself quotes the literal form — it must not be matched). */function source(iso: string, frozen: boolean): string {@@ -112,13 +124,13 @@ describe('releaseProblem: the flip release also needs the allowance key (owner sconst FROZEN = source('2026-01-01T00:00:00Z', true)it('refuses a frozen (flip) release while the key is empty', () => {- expect(releaseProblem(FROZEN, keySource(''), NOW)).toBe(EMPTY_KEY)+ expect(releaseProblem(FROZEN, keySource(''), NOW, FUSED)).toBe(EMPTY_KEY)})it('passes a frozen release with an Ed25519 public key, as a template literal or a quoted string', () => {- expect(releaseProblem(FROZEN, keySource(PUBLIC_PEM), NOW)).toBeNull()+ expect(releaseProblem(FROZEN, keySource(PUBLIC_PEM), NOW, FUSED)).toBeNull()const quoted = `export const PROJECT_ALLOWANCE_PUBLIC_KEY = '${PUBLIC_PEM.replace(/\n/g, '\\n')}'\n`- expect(releaseProblem(FROZEN, quoted, NOW)).toBeNull()+ expect(releaseProblem(FROZEN, quoted, NOW, FUSED)).toBeNull()})it('does not check the key while the deadline is not frozen — not even an unreadable key file', () => {@@ -151,6 +163,55 @@ describe('releaseProblem: the flip release also needs the allowance key (owner s})})+describe('releaseProblem: the flip release also ships the Electron fuses', () => {+ const FAR = source('2027-01-31T00:00:00Z', false)+ const FROZEN = source('2026-01-01T00:00:00Z', true)+ const KEY = keySource(PUBLIC_PEM)++ it('refuses a frozen release whose package.json carries no fuses', () => {+ expect(releaseProblem(FROZEN, KEY, NOW, pkgSource())).toBe(NO_FUSES)+ })++ it('passes a frozen release whose package.json carries exactly scripts/electron-fuses.json', () => {+ expect(releaseProblem(FROZEN, KEY, NOW, FUSED)).toBeNull()+ // Key order is not a difference.+ const reversed = Object.fromEntries(Object.entries(EXPECTED_FUSES).reverse())+ expect(releaseProblem(FROZEN, KEY, NOW, pkgSource(reversed))).toBeNull()+ })++ it('refuses a frozen release whose fuses differ in any way', () => {+ const inverted = { ...EXPECTED_FUSES, enableNodeOptionsEnvironmentVariable: true }+ const dropped: Record<string, unknown> = { ...EXPECTED_FUSES }+ delete dropped.onlyLoadAppFromAsar+ const added = { ...EXPECTED_FUSES, grantFileProtocolExtraPrivileges: false }+ for (const fuses of [inverted, dropped, added, {}, null, true, 'yes']) {+ expect(releaseProblem(FROZEN, KEY, NOW, pkgSource(fuses))).toMatch(+ /^package\.json build\.electronFuses differs from scripts\/electron-fuses\.json/+ )+ }+ })++ it('fails closed on a frozen release whose package.json is unreadable or not JSON', () => {+ for (const pkg of [null, undefined, '', 'not json', '[]']) {+ expect(releaseProblem(FROZEN, KEY, NOW, pkg)).toMatch(/^could not read build\.electronFuses from package\.json/)+ }+ })++ it('fails closed when the expected fuses cannot be read', () => {+ expect(fusesProblem(FUSED, null)).toMatch(/^could not read scripts\/electron-fuses\.json/)+ })++ it('never looks at the fuses of an unfrozen release', () => {+ for (const pkg of [pkgSource(), pkgSource({ runAsNode: false }), null, 'not json']) {+ expect(releaseProblem(FAR, KEY, NOW, pkg)).toBeNull()+ }+ })++ it('reports the key before the fuses', () => {+ expect(releaseProblem(FROZEN, keySource(''), NOW, pkgSource())).toBe(EMPTY_KEY)+ })+})+describe('the real src/shared/project-limit.ts', () => {// Pins the guard to the compiled constants, so a change of literal form fails on the PR that makes// it, not on release day.@@ -164,17 +225,31 @@ describe('the real src/shared/project-limit.ts', () => {it('and the real src/core/project-allowance-key.ts reads as the key the app compiles', () => {expect(readAllowanceKey(REAL_KEY_SOURCE)).toBe(PROJECT_ALLOWANCE_PUBLIC_KEY)})++ it('and the real package.json carries no fuses or exactly the expected ones (src/main/electron-fuses.test.ts)', () => {+ const real = fs.readFileSync(path.resolve(__dirname, '../package.json'), 'utf8')+ const build = JSON.parse(real).build ?? {}+ if (Object.hasOwn(build, 'electronFuses')) expect(fusesProblem(real, EXPECTED_FUSES)).toBeNull()+ else expect(fusesProblem(real, EXPECTED_FUSES)).toBe(NO_FUSES)+ })})describe('the CLI the release workflow runs', () => {- /** Run the CLI on a limit source and a key source (`null` = point it at a key file that is not there). */- function run(src: string, key: string | null = keySource(PUBLIC_PEM)): { status: number | null; stderr: string } {+ /** Run the CLI on a limit source, a key source and a package.json (`null` = point it at a file+ * that is not there). */+ function run(+ src: string,+ key: string | null = keySource(PUBLIC_PEM),+ pkg: string | null = FUSED+ ): { status: number | null; stderr: string } {const dir = testTmpDir('nt-limit-deadline-')const file = path.join(dir, 'project-limit.ts')const keyFile = path.join(dir, 'project-allowance-key.ts')+ const pkgFile = path.join(dir, 'package.json')fs.writeFileSync(file, src)if (key !== null) fs.writeFileSync(keyFile, key)- const r = spawnSync(process.execPath, [SCRIPT, file, keyFile], { encoding: 'utf8' })+ if (pkg !== null) fs.writeFileSync(pkgFile, pkg)+ const r = spawnSync(process.execPath, [SCRIPT, file, keyFile, pkgFile], { encoding: 'utf8' })return { status: r.status, stderr: r.stderr }}@@ -193,13 +268,28 @@ describe('the CLI the release workflow runs', () => {expect(r.stderr).toContain('missing.ts')})- it('exits 0 for a far deadline (key unchecked) and for a frozen one with a real key', () => {+ it('exits 0 for a far deadline (key and fuses unchecked) and for a frozen one with a real key and the fuses', () => {const far = source(new Date(Date.now() + 90 * DAY_MS).toISOString(), false)expect(run(far, keySource('')).status).toBe(0)expect(run(far, null).status).toBe(0)+ expect(run(far, keySource(PUBLIC_PEM), pkgSource()).status).toBe(0)+ expect(run(far, keySource(PUBLIC_PEM), null).status).toBe(0)expect(run(source('2026-01-01T00:00:00Z', true)).status).toBe(0)})+ it('exits 1 for a frozen release whose package.json has no fuses, other fuses, or is missing', () => {+ const frozen = source('2026-01-01T00:00:00Z', true)+ const absent = run(frozen, keySource(PUBLIC_PEM), pkgSource())+ expect(absent.status).toBe(1)+ expect(absent.stderr).toContain(NO_FUSES)+ const other = run(frozen, keySource(PUBLIC_PEM), pkgSource({ ...EXPECTED_FUSES, runAsNode: false }))+ expect(other.status).toBe(1)+ expect(other.stderr).toContain('differs from scripts/electron-fuses.json')+ const missing = run(frozen, keySource(PUBLIC_PEM), null)+ expect(missing.status).toBe(1)+ expect(missing.stderr).toContain('could not read build.electronFuses from package.json')+ })+it('exits 1 for a frozen release with an empty or missing key file', () => {const frozen = source('2026-01-01T00:00:00Z', true)const empty = run(frozen, keySource(''))diff --git a/scripts/electron-fuses.json b/scripts/electron-fuses.jsonnew file mode 100644index 000000000..a8ef60e91--- /dev/null+++ b/scripts/electron-fuses.json@@ -0,0 +1,7 @@+{+ "runAsNode": true,+ "enableNodeOptionsEnvironmentVariable": false,+ "enableNodeCliInspectArguments": false,+ "enableEmbeddedAsarIntegrityValidation": true,+ "onlyLoadAppFromAsar": true+}diff --git a/src/main/electron-fuses.test.ts b/src/main/electron-fuses.test.tsindex 64051c018..f93cb0c05 100644--- a/src/main/electron-fuses.test.ts+++ b/src/main/electron-fuses.test.ts@@ -2,19 +2,29 @@ import { describe, it, expect } from 'vitest'import fs from 'fs'import path from 'path'import type { Configuration } from 'electron-builder'+import expectedFuses from '../../scripts/electron-fuses.json'/**- * Release guard for the Electron fuses the packaged binary is flipped with (package.json+ * The decision record for the Electron fuses the packaged binary is flipped with (package.json* `build.electronFuses`; electron-builder 26 hands them to `@electron/fuses` after packing and- * right before signing). Spec §12 (free-tier project limit, Release B): the limit is enforced by- * the code inside `app.asar`, so the shipped binary must refuse to run anything else.+ * right before signing). The free-tier project limit (docs/project-limit.md) is enforced by the+ * code inside `app.asar`, so once it can switch on the shipped binary must refuse to run anything+ * else.+ *+ * WHEN THEY SHIP: not yet. Release B ships the limit dormant, and the fuses would be its one change a+ * user could notice (NODE_EXTRA_CA_CERTS below), so `build.electronFuses` is ABSENT until the+ * flip-preparation release — applied there after the owner's NODE_EXTRA_CA_CERTS decision and device+ * Run 1 (docs/project-limit.md). The object they ship as is `scripts/electron-fuses.json`, the ONE+ * definition: this test pins package.json to absent-or-exactly-it, and the release guard+ * (`scripts/check-project-limit-deadline.mjs`) refuses a frozen (flip) release unless package.json+ * carries exactly it.** - `enableEmbeddedAsarIntegrityValidation: true` + `onlyLoadAppFromAsar: true` — the app loads* only from `app.asar`, and on macOS/Windows only an asar whose header hash matches the one* electron-builder embedded at package time (Info.plist `ElectronAsarIntegrity` / the Windows* integrity resource). An unpacked `resources/app/` beside it is never searched. Linux has no- * asar integrity support in Electron — accepted in §12, and §13 lists a patched Linux build as- * a known gap.+ * asar integrity support in Electron — accepted, and docs/project-limit.md lists a patched+ * Linux build among the accepted gaps.* - `enableNodeOptionsEnvironmentVariable: false` — Electron UNSETS `NODE_OPTIONS` and* `NODE_EXTRA_CA_CERTS` at process start, in GUI and in RunAsNode mode alike, so neither the* app nor ANY process it spawns sees them (measured: an `sh` child reads both as unset).@@ -62,28 +72,36 @@ import type { Configuration } from 'electron-builder'* relay shared by every local Codex node.** Flipping a fuse cannot be undone by the app at runtime and is only observable on a PACKAGED- * build, so this object is pinned exactly: a fuse added, dropped or inverted must be a decision+ * build, so the object is pinned exactly: a fuse added, dropped or inverted must be a decision* someone reads this comment for, not a drive-by edit.*/type FuseOptions = NonNullable<Configuration['electronFuses']>-// `satisfies` makes a misspelled key a typecheck error here, before electron-builder's own schema-// rejects it at package time.-const EXPECTED_FUSES = {- runAsNode: true,- enableNodeOptionsEnvironmentVariable: false,- enableNodeCliInspectArguments: false,- enableEmbeddedAsarIntegrityValidation: true,- onlyLoadAppFromAsar: true-} satisfies FuseOptions+// A key of the JSON that is not a fuse electron-builder knows is a typecheck error here, before+// electron-builder's own schema rejects it at package time (and `satisfies` checks every value).+type UnknownFuse = Exclude<keyof typeof expectedFuses, keyof FuseOptions>+const noUnknownFuse: [UnknownFuse] extends [never] ? true : UnknownFuse = true+const EXPECTED_FUSES = expectedFuses satisfies FuseOptionsconst PKG = path.resolve(__dirname, '../../package.json')describe('Electron fuses (package.json build.electronFuses)', () => {const build = JSON.parse(fs.readFileSync(PKG, 'utf8')).build ?? {}- it('flips exactly the hardening fuses of spec §12, RunAsNode kept on', () => {- expect(build.electronFuses).toEqual(EXPECTED_FUSES)+ it('the shipped object flips exactly the hardening fuses, RunAsNode kept on', () => {+ expect(noUnknownFuse).toBe(true)+ expect(EXPECTED_FUSES).toEqual({+ runAsNode: true,+ enableNodeOptionsEnvironmentVariable: false,+ enableNodeCliInspectArguments: false,+ enableEmbeddedAsarIntegrityValidation: true,+ onlyLoadAppFromAsar: true+ })+ })++ it('package.json carries no fuses yet, or exactly that object', () => {+ // Absent until the flip-preparation release (header); never a partial, edited or null set.+ expect(Object.hasOwn(build, 'electronFuses') ? build.electronFuses : EXPECTED_FUSES).toEqual(EXPECTED_FUSES)})it('packages the app into an asar, which onlyLoadAppFromAsar requires', () => {