TypeScript
test: exercise guards hidden by ineffective assertions (#21848)
Julius Marminge212811488bf1
diff --git a/apps/desktop/src/wsl/DesktopWslEnvironment.test.ts b/apps/desktop/src/wsl/DesktopWslEnvironment.test.tsindex b3f695daf2d..670dcb89840 100644--- a/apps/desktop/src/wsl/DesktopWslEnvironment.test.ts+++ b/apps/desktop/src/wsl/DesktopWslEnvironment.test.ts@@ -359,23 +359,6 @@ describe("WSL runtime cache", () => {expect(deleted).toBeGreaterThan(kept);});- it("treats a runtime whose executable no longer runs as a cache miss", () => {- const script = buildWslRuntimeInstallScript(- "/mnt/c/Program Files/T3 Code/wsl-runtime.tar.gz",- "1.2.3-x64",- "b".repeat(64),- );-- expect(script).toContain(' [ -x "$1/t3" ] && "$1/t3" --version >/dev/null');-- const entryCheckDefined = script.indexOf("runtime_entry_runs() {");- const readinessDefined = script.indexOf("runtime_is_ready() {");- const readyShortCircuit = script.indexOf("if runtime_is_ready; then");- expect(entryCheckDefined).toBeGreaterThan(-1);- expect(entryCheckDefined).toBeLessThan(readinessDefined);- expect(readinessDefined).toBeLessThan(readyShortCircuit);- });-it("re-hashes the executable against the digest the install recorded", () => {const script = buildWslRuntimeInstallScript("/mnt/c/Program Files/T3 Code/wsl-runtime.tar.gz",@@ -624,6 +607,28 @@ describe.skipIf(posixShellRunner === null)("WSL runtime install script (executedexpect(restored.stdout).toBe(SERVER_ENTRY_SOURCE);});+ it("reinstalls an executable that fails --version despite a matching recorded digest", () => {+ const fixture = createFixture();+ expect(fixture.install().status).toBe(0);+ const brokenEntry = "#!/bin/sh\nexit 42\n";+ const corrupt = runShell(+ [+ "set -eu",+ `printf '%s' ${sh(brokenEntry)} > ${sh(fixture.serverEntry)}`,+ `chmod +x ${sh(fixture.serverEntry)}`,+ `sha256sum ${sh(fixture.serverEntry)} | cut -d ' ' -f 1 > ${sh(`${fixture.runtimeRoot}/.t3code-wsl-runtime-ready`)}`,+ ].join("\n"),+ );+ expect(corrupt.status, corrupt.stderr).toBe(0);+ expect(runShell(`${sh(fixture.serverEntry)} --version`).status).toBe(42);++ const repaired = fixture.install();+ expect(repaired.status, repaired.stderr).toBe(0);+ expect(parseWslRuntimeRoot(repaired.stdout)).toBe(fixture.runtimeRoot);+ expect(runShell(`cat ${sh(fixture.serverEntry)}`).stdout).toBe(SERVER_ENTRY_SOURCE);+ expect(runShell(`${sh(fixture.serverEntry)} --version`).status).toBe(0);+ });+it("falls back instead of launching a corrupted cache it cannot reinstall", () => {const fixture = createFixture();expect(fixture.install().status).toBe(0);diff --git a/apps/mobile/src/features/threads/ThreadDetailScreen.tsx b/apps/mobile/src/features/threads/ThreadDetailScreen.tsxindex 6d354e57c50..ac22a8b7d9e 100644--- a/apps/mobile/src/features/threads/ThreadDetailScreen.tsx+++ b/apps/mobile/src/features/threads/ThreadDetailScreen.tsx@@ -58,7 +58,7 @@ import type { QueuedRunEdit } from "../../state/queued-run-edit";import type { FollowUpBehavior } from "../../lib/followUpBehavior";import type { ActiveTurnComposerAction } from "@t3tools/client-runtime/state/composer-dispatch";import * as Haptics from "expo-haptics";-import { useContext, useEffect, useLayoutEffect, useRef, useState } from "react";+import { useCallback, useContext, useEffect, useLayoutEffect, useRef, useState } from "react";import {AppState,Keyboard,diff --git a/apps/server/src/assets/AssetAccess.test.ts b/apps/server/src/assets/AssetAccess.test.tsindex a327121fd61..ed8ba831146 100644--- a/apps/server/src/assets/AssetAccess.test.ts+++ b/apps/server/src/assets/AssetAccess.test.ts@@ -7,6 +7,7 @@ import {AssetPreviewTypeValidationError,ThreadId,TurnItemId,+ type ToolActivityNativeAppReference,} from "@t3tools/contracts";import { PROJECT_FAVICON_FALLBACK_MARKER } from "@t3tools/shared/projectFavicon";import { MCP_APP_MAX_HTML_BYTES } from "@t3tools/shared/mcpApp";@@ -1082,21 +1083,37 @@ describe("AssetAccess", () => {});}).pipe(Effect.provide(layerTest)),);- it.effect("issues signed native application icon capabilities", () =>- Effect.gen(function* () {- const result = yield* issueAssetUrl({- resource: {- _tag: "native-app-icon",- app: { _tag: "app-id", appId: "com.example.Editor" },- },- });+ it.effect("issues signed native application icon capabilities", () => {+ const resolvedApps: Array<ToolActivityNativeAppReference> = [];+ return Effect.gen(function* () {+ const app = { _tag: "app-id", appId: "com.example.Editor" } as const;+ const result = yield* issueAssetUrl({ resource: { _tag: "native-app-icon", app } });expect(result.relativeUrl).toMatch(new RegExp(`^${ASSET_ROUTE_PREFIX}/[^/]+/native-app-icon\\.png$`, "u"),);- expect(result.expiresAt).toBeGreaterThan(0);- }).pipe(Effect.provide(layerTest)),- );+ const suffix = result.relativeUrl.slice(`${ASSET_ROUTE_PREFIX}/`.length);+ const separator = suffix.indexOf("/");+ const token = suffix.slice(0, separator);+ const name = suffix.slice(separator + 1);+ expect(yield* resolveAsset(token, name)).toEqual({ kind: "file", path: "/icons/editor.png" });+ expect(yield* resolveAsset(`${token}tampered`, name)).toBeNull();+ expect(resolvedApps).toEqual([app]);+ }).pipe(+ Effect.provide(+ Layer.merge(+ layerTest,+ Layer.succeed(NativeAppIconResolver.NativeAppIconResolver, {+ resolve: (app) =>+ Effect.sync(() => {+ resolvedApps.push(app);+ return "/icons/editor.png";+ }),+ }),+ ),+ ),+ );+ });it.effect("serves document attachments inline when a viewer requests it", () =>Effect.gen(function* () {diff --git a/apps/server/src/environmentTheme.test.ts b/apps/server/src/environmentTheme.test.tsindex 998d8cc0acf..7287425c390 100644--- a/apps/server/src/environmentTheme.test.ts+++ b/apps/server/src/environmentTheme.test.ts@@ -142,11 +142,20 @@ it.layer(NodeServices.layer)("environment theme", (it) => {path.join(environmentThemesDir, "shared-light.json"),encodeThemeFile(SHARED_THEME),);- const first = yield* environmentTheme.streamChanges.pipe(Stream.runHead);+ const seen = yield* Queue.unbounded<ReadonlyArray<{ readonly id: string }>>();+ yield* Stream.runForEach(environmentTheme.streamChanges, (themes) =>+ Queue.offer(seen, themes),+ ).pipe(Effect.forkScoped);assert.deepEqual(- Option.getOrNull(first)?.map((theme) => theme.id),+ (yield* Queue.take(seen)).map((theme) => theme.id),["nightfall", "shared-light"],);+ yield* fs.remove(path.join(environmentThemesDir, "nightfall.json"));+ yield* currentThemes;+ assert.deepEqual(+ (yield* Queue.take(seen)).map((theme) => theme.id),+ ["shared-light"],+ );}),),);diff --git a/apps/server/src/keybindings.test.ts b/apps/server/src/keybindings.test.tsindex bef260bf925..e2823551d99 100644--- a/apps/server/src/keybindings.test.ts+++ b/apps/server/src/keybindings.test.ts@@ -602,6 +602,9 @@ it.layer(NodeServices.layer)("keybindings", (it) => {const [first, second] = yield* Effect.gen(function* () {const keybindings = yield* Keybindings.Keybindings;const firstLoad = (yield* keybindings.loadConfigState).keybindings;+ yield* writeKeybindingsConfig(keybindingsConfigPath, [+ { key: "mod+shift+y", command: "script.run-tests.run" },+ ]);const secondLoad = (yield* keybindings.loadConfigState).keybindings;return [firstLoad, secondLoad] as const;});diff --git a/apps/server/src/preview/Manager.test.ts b/apps/server/src/preview/Manager.test.tsindex 50946b7d055..a3bac1941ec 100644--- a/apps/server/src/preview/Manager.test.ts+++ b/apps/server/src/preview/Manager.test.ts@@ -6,6 +6,7 @@ import { PreviewUrlNormalizationError } from "@t3tools/shared/preview";import * as Effect from "effect/Effect";import * as Layer from "effect/Layer";import * as PubSub from "effect/PubSub";+import * as TestClock from "effect/testing/TestClock";import { expect } from "vite-plus/test";import * as ServerConfig from "../config.ts";@@ -459,12 +460,12 @@ it.layer(layer)("PreviewManager", (it) => {const threadId = freshThreadId();const manager = yield* PreviewManager.PreviewManager;const first = yield* manager.open({ threadId, url: "http://localhost:5173" });+ yield* TestClock.adjust("1 second");const second = yield* manager.open({ threadId, url: "http://localhost:3000" });+ yield* TestClock.adjust("1 second");+ yield* manager.navigate({ threadId, tabId: first.tabId, url: "http://localhost:5173/next" });const result = yield* manager.list({ threadId });- expect(result.sessions).toHaveLength(2);- const ids = result.sessions.map((s) => s.tabId);- expect(ids).toContain(first.tabId);- expect(ids).toContain(second.tabId);+ expect(result.sessions.map((s) => s.tabId)).toEqual([second.tabId, first.tabId]);}),);diff --git a/apps/web/src/hooks/useThreadActions.undo.test.ts b/apps/web/src/hooks/useThreadActions.undo.test.tsindex da65bf2ef93..9950911bee3 100644--- a/apps/web/src/hooks/useThreadActions.undo.test.ts+++ b/apps/web/src/hooks/useThreadActions.undo.test.ts@@ -162,9 +162,8 @@ describe("archive Undo", () => {it("shows no Undo when the archive failed", async () => {commands.archive.mockResolvedValue({ _tag: "Failure", cause: new Error("nope") });- const add = vi.spyOn(toastManager, "add").mockReturnValue("toast");await useThreadActions().archiveThread(target);- expect(add).not.toHaveBeenCalled();+ expect(useThreadUndoNotice.getState().notice).toBeNull();});});diff --git a/apps/web/src/onboarding/firstRun.logic.test.ts b/apps/web/src/onboarding/firstRun.logic.test.tsindex 2b5d17e085a..ab6af33c0c5 100644--- a/apps/web/src/onboarding/firstRun.logic.test.ts+++ b/apps/web/src/onboarding/firstRun.logic.test.ts@@ -321,6 +321,17 @@ const bootstrapThread = {runtime: null,};+const freshBootstrap = {+ primaryEnvironmentId,+ serverCwd: "/projects/current",+ bootstrapProjectId: bootstrapProject.id,+ bootstrapThreadId: bootstrapThread.id,+ bootstrapProjectCreated: true,+ bootstrapThreadCreated: true,+ projects: [bootstrapProject],+ threads: [bootstrapThread],+};+describe("isFreshFirstRunWorkspace", () => {it("accepts an empty workspace", () => {expect(@@ -394,8 +405,7 @@ describe("isFreshFirstRunWorkspace", () => {it("rejects projects from another environment even when their paths match", () => {expect(isFreshFirstRunWorkspace({- primaryEnvironmentId,- serverCwd: "/projects/current",+ ...freshBootstrap,projects: [{ ...bootstrapProject, environmentId: "remote-environment" }],threads: [],}),@@ -405,8 +415,7 @@ describe("isFreshFirstRunWorkspace", () => {it("rejects threads from another environment", () => {expect(isFreshFirstRunWorkspace({- primaryEnvironmentId,- serverCwd: "/projects/current",+ ...freshBootstrap,projects: [bootstrapProject],threads: [{ ...bootstrapThread, environmentId: "remote-environment" }],}),@@ -416,8 +425,7 @@ describe("isFreshFirstRunWorkspace", () => {it("rejects a thread that does not belong to the bootstrap project", () => {expect(isFreshFirstRunWorkspace({- primaryEnvironmentId,- serverCwd: "/projects/current",+ ...freshBootstrap,projects: [bootstrapProject],threads: [{ ...bootstrapThread, projectId: "another-project" }],}),@@ -427,8 +435,7 @@ describe("isFreshFirstRunWorkspace", () => {it("rejects a thread when there is no bootstrap project", () => {expect(isFreshFirstRunWorkspace({- primaryEnvironmentId,- serverCwd: "/projects/current",+ ...freshBootstrap,projects: [],threads: [bootstrapThread],}),@@ -438,8 +445,7 @@ describe("isFreshFirstRunWorkspace", () => {it("rejects a bootstrap thread that already has a user message", () => {expect(isFreshFirstRunWorkspace({- primaryEnvironmentId,- serverCwd: "/projects/current",+ ...freshBootstrap,projects: [bootstrapProject],threads: [{@@ -454,8 +460,7 @@ describe("isFreshFirstRunWorkspace", () => {it("rejects a bootstrap thread that has started a turn", () => {expect(isFreshFirstRunWorkspace({- primaryEnvironmentId,- serverCwd: "/projects/current",+ ...freshBootstrap,projects: [bootstrapProject],threads: [{ ...bootstrapThread, latestRun: { id: "first-run" } }],}),@@ -465,8 +470,7 @@ describe("isFreshFirstRunWorkspace", () => {it("rejects a bootstrap thread that has a provider session", () => {expect(isFreshFirstRunWorkspace({- primaryEnvironmentId,- serverCwd: "/projects/current",+ ...freshBootstrap,projects: [bootstrapProject],threads: [{ ...bootstrapThread, runtime: { status: "ready" } }],}),diff --git a/apps/web/src/promptStashStore.test.ts b/apps/web/src/promptStashStore.test.tsindex 2586ebc4d04..97867091385 100644--- a/apps/web/src/promptStashStore.test.ts+++ b/apps/web/src/promptStashStore.test.ts@@ -238,7 +238,12 @@ describe("promptStashStore", () => {environmentId: EnvironmentId.make("environment-1"),};- store.stashEntry({ ...makeEntry({ id: "with-file" }), files: [file] });+ writePromptStashStorageForTest(+ JSON.stringify({+ version: 2,+ state: { entries: [{ ...makeEntry({ id: "with-file" }), files: [file] }] },+ }),+ );store.finalizeEntryImages("with-file", {attachments: [],droppedImageNames: [],@@ -289,8 +294,7 @@ describe("promptStashStore", () => {});describe("prompt stash context records", () => {- it("keeps the records behind a stashed prompt's chips", () => {- const store = usePromptStashStore.getState();+ it("restores the records behind a persisted prompt's chips", () => {const records = [{version: 1 as const,@@ -304,14 +308,23 @@ describe("prompt stash context records", () => {text: "boom",},];- store.stashEntry({- id: "entry-records",- createdAt: "2026-01-01T00:00:00.000Z",- prompt: "see [Terminal 1 line 4](t3-context://v1/terminal/ctx-1)",- attachments: [],- droppedImageNames: [],- records,- });+ writePromptStashStorageForTest(+ JSON.stringify({+ version: 2,+ state: {+ entries: [+ {+ id: "entry-records",+ createdAt: "2026-01-01T00:00:00.000Z",+ prompt: "see [Terminal 1 line 4](t3-context://v1/terminal/ctx-1)",+ attachments: [],+ droppedImageNames: [],+ records,+ },+ ],+ },+ }),+ );const taken = usePromptStashStore.getState().takeEntry("entry-records");expect(taken.entry?.records).toEqual(records);});diff --git a/apps/web/src/providerInstances.test.ts b/apps/web/src/providerInstances.test.tsindex b6aaac5960a..7b6df7cb41e 100644--- a/apps/web/src/providerInstances.test.ts+++ b/apps/web/src/providerInstances.test.ts@@ -1,4 +1,5 @@import {+ DEFAULT_MODEL_BY_PROVIDER,ProjectId,ProviderDriverKind,ProviderInstanceId,@@ -520,8 +521,7 @@ describe("getDefaultProviderInstanceModel", () => {providers,ProviderInstanceId.make("claudeAgent"),);- expect(typeof resolved).toBe("string");- expect(resolved?.length).toBeGreaterThan(0);+ expect(resolved).toBe(DEFAULT_MODEL_BY_PROVIDER[ProviderDriverKind.make("claudeAgent")]);});it("honors the instance's declared default before model-list order", () => {diff --git a/apps/web/src/terminal/ghostty/keyCodes.test.ts b/apps/web/src/terminal/ghostty/keyCodes.test.tsindex 5cc965bf97d..5d530014943 100644--- a/apps/web/src/terminal/ghostty/keyCodes.test.ts+++ b/apps/web/src/terminal/ghostty/keyCodes.test.ts@@ -1,4 +1,5 @@import { describe, expect, it } from "vite-plus/test";+import ghosttyKeyHeader from "../../../../../native/libghostty-vt/include/ghostty/vt/key/event.h?raw";import {ghosttyConsumedMods,@@ -8,11 +9,24 @@ import {} from "./keyCodes";describe("ghosttyKeyForCode", () => {- it("keeps the tail of the pinned Ghostty key enum in order", () => {- expect(ghosttyKeyForCode("F25")).toBe(ghosttyKeyForCode("F24") + 1);- expect(ghosttyKeyForCode("PrintScreen")).toBe(ghosttyKeyForCode("FnLock") + 1);- expect(ghosttyKeyForCode("Pause")).toBe(ghosttyKeyForCode("ScrollLock") + 1);- expect(ghosttyKeyForCode("Paste")).toBe(ghosttyKeyForCode("Cut") + 1);+ it("matches the pinned native key enum after the function keys", () => {+ const enumBody = ghosttyKeyHeader.slice(+ ghosttyKeyHeader.indexOf("GHOSTTY_KEY_UNIDENTIFIED"),+ ghosttyKeyHeader.indexOf("GHOSTTY_KEY_MAX_VALUE"),+ );+ const keys = [...enumBody.matchAll(/GHOSTTY_KEY_([A-Z0-9_]+)/g)].map((match) => match[1]);+ for (const [code, native] of [+ ["F24", "F24"],+ ["F25", "F25"],+ ["FnLock", "FN_LOCK"],+ ["PrintScreen", "PRINT_SCREEN"],+ ["ScrollLock", "SCROLL_LOCK"],+ ["Pause", "PAUSE"],+ ["Paste", "PASTE"],+ ]) {+ expect(keys).toContain(native);+ expect(ghosttyKeyForCode(code!)).toBe(keys.indexOf(native));+ }});});diff --git a/apps/web/src/terminal/ghostty/surface.test.ts b/apps/web/src/terminal/ghostty/surface.test.tsindex c486b3a05a3..550eff2138c 100644--- a/apps/web/src/terminal/ghostty/surface.test.ts+++ b/apps/web/src/terminal/ghostty/surface.test.ts@@ -1,4 +1,5 @@import { afterEach, describe, expect, it, vi } from "vite-plus/test";+import * as appearanceFonts from "../../appearanceFonts";import { GhosttyTerminalCore, type GhosttyCell, type GhosttyRow } from "./core";import {@@ -1594,10 +1595,13 @@ describe("terminal font resolution", () => {});it("ignores proportional families the cell grid cannot lay out", () => {- // Node has no canvas, so the probe answers "monospace" and the- // family is kept; the guard is exercised in the browser instead.- const stack = terminalFontFamily("Helvetica Neue");- expect(stack.endsWith("monospace")).toBe(true);+ const probe = vi.spyOn(appearanceFonts, "isMonospaceFamily").mockReturnValueOnce(false);+ try {+ expect(terminalFontFamily("Helvetica Neue")).toBe(DEFAULT_TERMINAL_FONT_FAMILY);+ expect(probe).toHaveBeenCalledWith('"Helvetica Neue"');+ } finally {+ probe.mockRestore();+ }});it("quotes families the canvas font shorthand would otherwise reject", () => {diff --git a/infra/relay/src/agentActivity/ApnsProviderTokens.test.ts b/infra/relay/src/agentActivity/ApnsProviderTokens.test.tsindex 2a38e578f8d..1e93aab8751 100644--- a/infra/relay/src/agentActivity/ApnsProviderTokens.test.ts+++ b/infra/relay/src/agentActivity/ApnsProviderTokens.test.ts@@ -2,6 +2,8 @@import * as NodeCrypto from "node:crypto";import { describe, expect, it } from "@effect/vitest";+import { vi } from "vite-plus/test";+import { p256 } from "@noble/curves/nist";import * as Effect from "effect/Effect";import * as Redacted from "effect/Redacted";import * as Schema from "effect/Schema";@@ -61,12 +63,17 @@ describe("ApnsProviderTokens", () => {it.effect("serves repeat pushes from the isolate cache without re-signing", () => {ApnsProviderTokens.__resetApnsProviderTokenCacheForTest();+ const sign = vi.spyOn(p256, "sign");return Effect.gen(function* () {const tokens = yield* ApnsProviderTokens.ApnsProviderTokens;const first = yield* tokens.getJwt({ ...signingInput, issuedAtUnixSeconds: WINDOW + 10 });const again = yield* tokens.getJwt({ ...signingInput, issuedAtUnixSeconds: WINDOW + 500 });expect(again).toBe(first);+ expect(sign).toHaveBeenCalledTimes(1);ApnsProviderTokens.__resetApnsProviderTokenCacheForTest();- }).pipe(Effect.provide(ApnsProviderTokens.layer));+ }).pipe(+ Effect.provide(ApnsProviderTokens.layer),+ Effect.ensuring(Effect.sync(() => sign.mockRestore())),+ );});});diff --git a/infra/relay/src/agentActivity/DeliveryAttempts.test.ts b/infra/relay/src/agentActivity/DeliveryAttempts.test.tsindex 2f3d948983d..2f0943884a8 100644--- a/infra/relay/src/agentActivity/DeliveryAttempts.test.ts+++ b/infra/relay/src/agentActivity/DeliveryAttempts.test.ts@@ -1,5 +1,7 @@import * as NodeCryptoLayer from "@effect/platform-node/NodeCrypto";import { describe, expect, it } from "@effect/vitest";+import type { SQL } from "drizzle-orm";+import { PgDialect } from "drizzle-orm/pg-core";import * as Effect from "effect/Effect";import * as Layer from "effect/Layer";@@ -274,7 +276,7 @@ describe("DeliveryAttempts", () => {it.effect("completes a claimed source job with the APNs outcome", () => {const updatedValues: Array<Record<string, unknown>> = [];- const whereClauses: Array<unknown> = [];+ const whereClauses: Array<SQL> = [];const fakeDb = {update: (table: unknown) => {expect(table).toBe(relayDeliveryAttempts);@@ -282,7 +284,7 @@ describe("DeliveryAttempts", () => {set: (values: Record<string, unknown>) => {updatedValues.push(values);return {- where: (clause: unknown) => {+ where: (clause: SQL) => {whereClauses.push(clause);return Effect.void;},@@ -301,7 +303,9 @@ describe("DeliveryAttempts", () => {apnsId: "apns-id",});- expect(whereClauses).toHaveLength(1);+ expect(whereClauses.map((clause) => new PgDialect().sqlToQuery(clause))).toEqual([+ { sql: '"relay_delivery_attempts"."source_job_id" = $1', params: ["job-1"] },+ ]);expect(updatedValues).toEqual([{createdAt: expect.any(String),diff --git a/infra/relay/src/auth/DpopProofs.test.ts b/infra/relay/src/auth/DpopProofs.test.tsindex fba64586e28..0a51034948b 100644--- a/infra/relay/src/auth/DpopProofs.test.ts+++ b/infra/relay/src/auth/DpopProofs.test.ts@@ -1,4 +1,6 @@import { describe, expect, it } from "@effect/vitest";+import type { SQL } from "drizzle-orm";+import { PgDialect } from "drizzle-orm/pg-core";import * as DateTime from "effect/DateTime";import * as Effect from "effect/Effect";import * as Layer from "effect/Layer";@@ -73,15 +75,13 @@ describe("DpopProofReplay", () => {});it.effect("prunes expired proof rows from the maintenance path", () => {- const calls: Array<string> = [];+ const conditions: Array<SQL> = [];const fakeDb = {delete: (table: unknown) => {expect(table).toBe(relayDpopProofs);- calls.push("delete");return {- where: (condition: unknown) => {- expect(condition).toBeDefined();- calls.push("delete.where");+ where: (condition: SQL) => {+ conditions.push(condition);return Effect.void;},};@@ -91,7 +91,10 @@ describe("DpopProofReplay", () => {return Effect.gen(function* () {const replay = yield* DpopProofs.DpopProofReplay;yield* replay.pruneExpired;- expect(calls).toEqual(["delete", "delete.where"]);+ const now = DateTime.formatIso(yield* DateTime.now);+ expect(conditions.map((condition) => new PgDialect().sqlToQuery(condition))).toEqual([+ { sql: '"relay_dpop_proofs"."expires_at" < $1', params: [now] },+ ]);}).pipe(Effect.provide(DpopProofs.layer.pipe(Layer.provide(Layer.succeed(RelayDb.RelayDb, fakeDb)))),);diff --git a/infra/relay/src/environments/ManagedEndpointAllocations.test.ts b/infra/relay/src/environments/ManagedEndpointAllocations.test.tsindex ca1c96de17d..2c8a3f54537 100644--- a/infra/relay/src/environments/ManagedEndpointAllocations.test.ts+++ b/infra/relay/src/environments/ManagedEndpointAllocations.test.ts@@ -3,6 +3,7 @@ import * as Effect from "effect/Effect";import * as Layer from "effect/Layer";import * as Option from "effect/Option";import { PgDialect } from "drizzle-orm/pg-core";+import type { SQL } from "drizzle-orm";import * as RelayDb from "../db.ts";import { relayManagedEndpointAllocations } from "../persistence/schema.ts";@@ -286,15 +287,18 @@ describe("ManagedEndpointAllocations", () => {);it.effect("returns a claim generation only when deprovision wins the allocation CAS", () => {+ const conditions: SQL[] = [];+ const results = [[{ generation: 8 }], []];const fakeDb = {update: (table: unknown) => {expect(table).toBe(relayManagedEndpointAllocations);return {set: (_values: { readonly updatedAt: string }) => {return {- where: () => ({- returning: () => Effect.succeed([{ generation: 8 }]),- }),+ where: (condition: SQL) => {+ conditions.push(condition);+ return { returning: () => Effect.succeed(results.shift() ?? []) };+ },};},};@@ -303,14 +307,14 @@ describe("ManagedEndpointAllocations", () => {return Effect.gen(function* () {const allocations = yield* ManagedEndpointAllocations.ManagedEndpointAllocations;- const generation = yield* allocations.claimDeprovision({- userId: "user-1",- environmentId: "environment-1",- generation: 7,- });+ const input = { userId: "user-1", environmentId: "environment-1", generation: 7 };- expect(generation).toBe(8);- expect(generation).not.toBeNull();+ expect(yield* allocations.claimDeprovision(input)).toBe(8);+ expect(yield* allocations.claimDeprovision(input)).toBeNull();+ expect(new PgDialect().sqlToQuery(conditions[0]!)).toEqual({+ sql: '(((("relay_managed_endpoint_allocations"."user_id" = $1) and ("relay_managed_endpoint_allocations"."environment_id" = $2))) and ("relay_managed_endpoint_allocations"."generation" = $3))',+ params: ["user-1", "environment-1", 7],+ });}).pipe(Effect.provide(layerWithDb(fakeDb)));});diff --git a/packages/contracts/src/terminal.test.ts b/packages/contracts/src/terminal.test.tsindex 066253602a4..8dfaa01ad7d 100644--- a/packages/contracts/src/terminal.test.ts+++ b/packages/contracts/src/terminal.test.ts@@ -125,18 +125,14 @@ describe("TerminalOpenInput", () => {expect(parsed.providerInstanceId).toBe("codex_work");});- it("rejects invalid env keys", () => {- expect(- decodes(TerminalOpenInput, {- threadId: "thread-1",- cwd: "/tmp/project",- cols: 100,- rows: 24,- env: {- "bad-key": "1",- },- }),- ).toBe(false);+ it("drops invalid env keys while retaining valid overrides", () => {+ const parsed = decodeSync(TerminalOpenInput, {+ threadId: "thread-1",+ terminalId: DEFAULT_TERMINAL_ID,+ cwd: "/tmp/project",+ env: { "bad-key": "1", GOOD_KEY: "2" },+ });+ expect(parsed.env).toEqual({ GOOD_KEY: "2" });});it("rejects invalid provider instance ids", () => {