The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
test(e2ee): budget the password-lockout suites for their scrypt cost
Dev jacobfef78a5c31cd
diff --git a/cli/src/lib/e2ee/manager.test.ts b/cli/src/lib/e2ee/manager.test.tsindex bfd529d3a..78b1bbfa2 100644--- a/cli/src/lib/e2ee/manager.test.ts+++ b/cli/src/lib/e2ee/manager.test.ts@@ -3,6 +3,12 @@ import { mkdtempSync, rmSync } from 'fs'import { tmpdir } from 'os'import { join } from 'path'+// The one module here imported statically rather than in beforeAll: a test timeout is needed when+// `it()` is DEFINED, long before beforeAll runs. Safe because passwordPake.js is pure crypto —+// noble plus core.js — and reaches config/env.js by no path, which is the only thing the deferral+// above exists to keep out until ADAPTER_DATA_DIR is set.+import { PW_SCRYPT_TEST_TIMEOUT_MS } from './passwordPake.js'+// The manager transitively imports config/env (validated at load) + writes the paired store to disk,// so point ADAPTER_DATA_DIR at a temp dir BEFORE importing it (dynamic import in beforeAll).type Frame = Record<string, unknown>@@ -463,7 +469,8 @@ describe('E2eeManager persistent remote-password pairing', () => {const result = takeLast('e2e_pw_pair_result').payload as Record<string, unknown>expect(result).toMatchObject({ ok: false, error: 'RATE_LIMITED' })expect(typeof result.retryAt).toBe('number')- })+ // One scrypt per wrong-password attempt — see PW_SCRYPT_TEST_TIMEOUT_MS.+ }, PW_SCRYPT_TEST_TIMEOUT_MS)it('setting a new password clears an existing lockout', async () => {const { mgr, takeLast } = machine()@@ -488,7 +495,8 @@ describe('E2eeManager persistent remote-password pairing', () => {const r4 = joiner.onPake(takeLast('e2e_pw_pake'))!mgr.handleFrame(conn, r4)expect(takeLast('e2e_pw_pake').payload).toMatchObject({ round: 5, ok: true })- })+ // One scrypt per wrong-password attempt — see PW_SCRYPT_TEST_TIMEOUT_MS.+ }, PW_SCRYPT_TEST_TIMEOUT_MS)it('clearRemotePassword removes it — a subsequent intent gets NO_REMOTE_PASSWORD again', async () => {const { mgr, takeLast } = machine()diff --git a/cli/src/lib/e2ee/passwordPake.ts b/cli/src/lib/e2ee/passwordPake.tsindex 7c71d724c..d045a5f9d 100644--- a/cli/src/lib/e2ee/passwordPake.ts+++ b/cli/src/lib/e2ee/passwordPake.ts@@ -41,6 +41,14 @@ const SCRYPT_R = 8const SCRYPT_P = 1const SCRYPT_DKLEN = 32+/** Budget for a TEST that spends several `stretchPassword` calls back to back — the lockout suites+ * in manager.test.ts and relayLink.spec.ts burn one per wrong-password attempt. Five attempts plus+ * a rotation measure ~3s on an M-series laptop, i.e. 61% of vitest's 5s default before CI is even+ * involved, and a 4-core runner is roughly half that speed. The cost parameters above are a+ * security control and are never lowered to fit a test budget, so the budget moves instead. This+ * is a hang detector, not a performance assertion. */+export const PW_SCRYPT_TEST_TIMEOUT_MS = 30_000+/** Slow-hash a persistent remote password into a 32-byte verifier/key-material seed, salted per* machineId so the same password chosen on two different machines derives unrelated verifiers (and* therefore unrelated CPace generators). Deterministic for a given (password, machineId) pair. */diff --git a/cli/src/lib/e2ee/relayLink.spec.ts b/cli/src/lib/e2ee/relayLink.spec.tsindex 482b225b7..35f28972a 100644--- a/cli/src/lib/e2ee/relayLink.spec.ts+++ b/cli/src/lib/e2ee/relayLink.spec.ts@@ -5,6 +5,12 @@ import { join } from 'path'import { WebSocketServer } from 'ws'import type { AddressInfo } from 'net'+// The one module here imported statically rather than in beforeAll: a test timeout is needed when+// `it()` is DEFINED, long before beforeAll runs. Safe because passwordPake.js is pure crypto —+// noble plus core.js — and reaches config/env.js by no path, which is the only thing the deferral+// above exists to keep out until ADAPTER_DATA_DIR is set.+import { PW_SCRYPT_TEST_TIMEOUT_MS } from './passwordPake.js'+// Same reason as manager.test.ts: ADAPTER_DATA_DIR must be set before any transitive import of// config/env.js, so every module under test is dynamically imported after the temp dir is set.type Frame = Record<string, unknown>@@ -278,7 +284,8 @@ describe('remote-password link + relay session crypto (interop with the real E2e} finally {await close()}- })+ // One scrypt per wrong-password attempt — see PW_SCRYPT_TEST_TIMEOUT_MS.+ }, PW_SCRYPT_TEST_TIMEOUT_MS)it('setting a new password clears an existing lockout', async () => {const { manager, wsBase, close } = fakeMachine()@@ -313,7 +320,8 @@ describe('remote-password link + relay session crypto (interop with the real E2e} finally {await close()}- })+ // One scrypt per wrong-password attempt — see PW_SCRYPT_TEST_TIMEOUT_MS.+ }, PW_SCRYPT_TEST_TIMEOUT_MS)})describe('RemoteRelayPool drops a peer the responder no longer trusts', () => {