Skip to content

Commit f44c0a7

Browse files
Switch Effect imports to explicit subpaths
- Replace barrel imports across server and test code - Add diagnostics overrides for Node-only scripts and probes - Tighten auth/session encoding and deterministic test fixtures
1 parent aa219be commit f44c0a7

396 files changed

Lines changed: 2694 additions & 1708 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/desktop/tsconfig.json‎

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,7 @@
33
"compilerOptions": {
44
"composite": true,
55
"types": ["node", "electron"],
6-
"lib": ["ESNext", "DOM", "esnext.disposable"],
7-
"plugins": [
8-
{
9-
"name": "@effect/language-service",
10-
"namespaceImportPackages": ["@effect/platform-node", "effect"],
11-
"diagnosticSeverity": {
12-
"importFromBarrel": "error",
13-
"anyUnknownInErrorContext": "error",
14-
"instanceOfSchema": "warning",
15-
"deterministicKeys": "warning"
16-
}
17-
}
18-
]
6+
"lib": ["ESNext", "DOM", "esnext.disposable"]
197
},
208
"include": ["src", "tsdown.config.ts"]
219
}

‎apps/server/integration/OrchestrationEngineHarness.integration.ts‎

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @effect-diagnostics nodeBuiltinImport:off
12
import { execFileSync } from "node:child_process";
23

34
import * as NodeServices from "@effect/platform-node/NodeServices";
@@ -8,20 +9,18 @@ import {
89
type OrchestrationEvent,
910
type OrchestrationThread,
1011
} from "@t3tools/contracts";
11-
import {
12-
Effect,
13-
Exit,
14-
FileSystem,
15-
Layer,
16-
ManagedRuntime,
17-
Option,
18-
Path,
19-
Ref,
20-
Schedule,
21-
Schema,
22-
Scope,
23-
Stream,
24-
} from "effect";
12+
import * as Effect from "effect/Effect";
13+
import * as Exit from "effect/Exit";
14+
import * as FileSystem from "effect/FileSystem";
15+
import * as Layer from "effect/Layer";
16+
import * as ManagedRuntime from "effect/ManagedRuntime";
17+
import * as Option from "effect/Option";
18+
import * as Path from "effect/Path";
19+
import * as Ref from "effect/Ref";
20+
import * as Schedule from "effect/Schedule";
21+
import * as Schema from "effect/Schema";
22+
import * as Scope from "effect/Scope";
23+
import * as Stream from "effect/Stream";
2524

2625
import { CheckpointStoreLive } from "../src/checkpointing/Layers/CheckpointStore.ts";
2726
import { CheckpointStore } from "../src/checkpointing/Services/CheckpointStore.ts";

‎apps/server/integration/TestProviderAdapter.integration.ts‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { randomUUID } from "node:crypto";
2-
31
import {
42
ApprovalRequestId,
53
EventId,
@@ -12,7 +10,10 @@ import {
1210
TurnId,
1311
ProviderDriverKind,
1412
} from "@t3tools/contracts";
15-
import { Effect, Queue, Stream } from "effect";
13+
import * as Effect from "effect/Effect";
14+
import * as Queue from "effect/Queue";
15+
import * as Random from "effect/Random";
16+
import * as Stream from "effect/Stream";
1617

1718
import {
1819
ProviderAdapterSessionNotFoundError,
@@ -202,7 +203,7 @@ interface MakeTestProviderAdapterHarnessOptions {
202203
}
203204

204205
function nowIso(): string {
205-
return new Date().toISOString();
206+
return "2026-01-01T00:00:00.000Z";
206207
}
207208

208209
function sessionNotFound(
@@ -308,10 +309,9 @@ export const makeTestProviderAdapterHarness = (options?: MakeTestProviderAdapter
308309
for (const fixtureEvent of response.events) {
309310
const rawEvent: Record<string, unknown> = {
310311
...(fixtureEvent as Record<string, unknown>),
311-
eventId: randomUUID(),
312+
eventId: yield* Random.nextUUIDv4,
312313
provider,
313314
sessionId: RuntimeSessionId.make(String(input.threadId)),
314-
createdAt: nowIso(),
315315
};
316316
rawEvent.threadId = state.snapshot.threadId;
317317
if (Object.hasOwn(rawEvent, "turnId")) {
@@ -366,7 +366,7 @@ export const makeTestProviderAdapterHarness = (options?: MakeTestProviderAdapter
366366
if (deferredTurnCompletedEvents.length === 0) {
367367
yield* emit({
368368
type: "turn.completed",
369-
eventId: EventId.make(randomUUID()),
369+
eventId: EventId.make(yield* Random.nextUUIDv4),
370370
provider,
371371
createdAt: nowIso(),
372372
threadId: state.snapshot.threadId,

‎apps/server/integration/orchestrationEngine.integration.test.ts‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @effect-diagnostics nodeBuiltinImport:off
12
import fs from "node:fs";
23
import path from "node:path";
34

@@ -17,7 +18,10 @@ import {
1718
ProviderInstanceId,
1819
} from "@t3tools/contracts";
1920
import { assert, it } from "@effect/vitest";
20-
import { Effect, Option, Schema } from "effect";
21+
import * as Clock from "effect/Clock";
22+
import * as Effect from "effect/Effect";
23+
import * as Option from "effect/Option";
24+
import * as Schema from "effect/Schema";
2125

2226
import type { TestTurnResponse } from "./TestProviderAdapter.integration.ts";
2327
import {
@@ -47,7 +51,7 @@ const CODEX_PROVIDER = ProviderDriverKind.make("codex");
4751
const CLAUDE_AGENT_PROVIDER = ProviderDriverKind.make("claudeAgent");
4852

4953
function nowIso() {
50-
return new Date().toISOString();
54+
return "2026-05-01T00:00:00.000Z";
5155
}
5256

5357
class IntegrationWaitTimeoutError extends Schema.TaggedErrorClass<IntegrationWaitTimeoutError>()(
@@ -64,14 +68,14 @@ function waitForSync<A>(
6468
timeoutMs = 10_000,
6569
): Effect.Effect<A, never> {
6670
return Effect.gen(function* () {
67-
const deadline = Date.now() + timeoutMs;
71+
const deadline = (yield* Clock.currentTimeMillis) + timeoutMs;
6872

6973
while (true) {
7074
const value = read();
7175
if (predicate(value)) {
7276
return value;
7377
}
74-
if (Date.now() >= deadline) {
78+
if ((yield* Clock.currentTimeMillis) >= deadline) {
7579
return yield* Effect.die(new IntegrationWaitTimeoutError({ description }));
7680
}
7781
yield* Effect.sleep(10);
@@ -156,6 +160,7 @@ const startTurn = (input: {
156160
readonly messageId: string;
157161
readonly text: string;
158162
readonly modelSelection?: ModelSelection;
163+
readonly createdAt?: string;
159164
}) =>
160165
input.harness.engine.dispatch({
161166
type: "thread.turn.start",
@@ -174,7 +179,7 @@ const startTurn = (input: {
174179
: {}),
175180
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
176181
runtimeMode: "approval-required",
177-
createdAt: nowIso(),
182+
createdAt: input.createdAt ?? nowIso(),
178183
});
179184

180185
it.live("runs a single turn end-to-end and persists checkpoint state in sqlite + git", () =>
@@ -755,6 +760,7 @@ it.live("reverts to an earlier checkpoint and trims checkpoint projections + git
755760
commandId: "cmd-turn-start-revert-1",
756761
messageId: "msg-user-revert-1",
757762
text: "First edit",
763+
createdAt: "2026-02-24T10:04:59.900Z",
758764
});
759765

760766
yield* harness.waitForThread(
@@ -813,6 +819,7 @@ it.live("reverts to an earlier checkpoint and trims checkpoint projections + git
813819
commandId: "cmd-turn-start-revert-2",
814820
messageId: "msg-user-revert-2",
815821
text: "Second edit",
822+
createdAt: "2026-02-24T10:05:00.900Z",
816823
});
817824

818825
yield* harness.waitForThread(

‎apps/server/integration/providerService.integration.test.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ import { ProviderDriverKind, ProviderInstanceId, ThreadId } from "@t3tools/contr
33
import { DEFAULT_SERVER_SETTINGS } from "@t3tools/contracts/settings";
44
import * as NodeServices from "@effect/platform-node/NodeServices";
55
import { it, assert } from "@effect/vitest";
6-
import { Effect, FileSystem, Layer, Path, Queue, Stream } from "effect";
6+
import * as Effect from "effect/Effect";
7+
import * as FileSystem from "effect/FileSystem";
8+
import * as Layer from "effect/Layer";
9+
import * as Path from "effect/Path";
10+
import * as Queue from "effect/Queue";
11+
import * as Stream from "effect/Stream";
712

813
import { ProviderAdapterRegistry } from "../src/provider/Services/ProviderAdapterRegistry.ts";
914
import { makeAdapterRegistryMock } from "../src/provider/testUtils/providerAdapterRegistryMock.ts";

‎apps/server/scripts/acp-mock-agent.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env bun
2+
// @effect-diagnostics nodeBuiltinImport:off
23
import { appendFileSync } from "node:fs";
34

45
import * as Effect from "effect/Effect";

‎apps/server/scripts/cli.ts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
#!/usr/bin/env node
2-
32
import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
43
import * as NodeServices from "@effect/platform-node/NodeServices";
5-
import { Data, Effect, FileSystem, Logger, Option, Path } from "effect";
4+
import * as Data from "effect/Data";
5+
import * as Effect from "effect/Effect";
6+
import * as FileSystem from "effect/FileSystem";
7+
import * as Logger from "effect/Logger";
8+
import * as Option from "effect/Option";
9+
import * as Path from "effect/Path";
10+
import * as Schema from "effect/Schema";
611
import { Command, Flag } from "effect/unstable/cli";
712
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
813

@@ -228,7 +233,10 @@ const publishCmd = Command.make(
228233

229234
const original = yield* fs.readFileString(packageJsonPath);
230235
yield* fs.writeFileString(backupPath, original);
231-
yield* fs.writeFileString(packageJsonPath, `${JSON.stringify(pkg, null, 2)}\n`);
236+
yield* fs.writeFileString(
237+
packageJsonPath,
238+
`${Schema.encodeUnknownSync(Schema.UnknownFromJsonString)(pkg)}\n`,
239+
);
232240
yield* Effect.log("[cli] Prepared package.json for publish");
233241

234242
const iconBackups = yield* applyPublishIconOverrides(repoRoot, serverDir);

‎apps/server/scripts/cursor-acp-model-mismatch-probe.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
// @effect-diagnostics nodeBuiltinImport:off
12
import { spawn, type ChildProcessWithoutNullStreams } from "node:child_process";
23
import process from "node:process";
34
import readline from "node:readline";
5+
import * as NodeTimers from "node:timers";
46

57
type JsonPrimitive = null | boolean | number | string;
68
type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue };
@@ -114,7 +116,8 @@ function matchesKeyword(option: SessionConfigOption, keyword: string): boolean {
114116

115117
function sleep(ms: number) {
116118
return new Promise<void>((resolve) => {
117-
setTimeout(resolve, ms);
119+
// @effect-diagnostics-next-line globalTimers:off - Standalone Node probe script, not an Effect runtime test.
120+
NodeTimers.setTimeout(resolve, ms);
118121
});
119122
}
120123

@@ -177,19 +180,20 @@ class JsonRpcChild {
177180
const id = this.nextId++;
178181

179182
const responsePromise = new Promise<JsonValue | undefined>((resolve, reject) => {
180-
const timeout = setTimeout(() => {
183+
// @effect-diagnostics-next-line globalTimers:off - Standalone Node probe script request timeout.
184+
const timeout = NodeTimers.setTimeout(() => {
181185
this.pending.delete(id);
182186
reject(new Error(`Timed out waiting for ${method} response after ${timeoutMs}ms.`));
183187
}, timeoutMs);
184188

185189
this.pending.set(id, {
186190
method,
187191
resolve: (value) => {
188-
clearTimeout(timeout);
192+
NodeTimers.clearTimeout(timeout);
189193
resolve(value);
190194
},
191195
reject: (error) => {
192-
clearTimeout(timeout);
196+
NodeTimers.clearTimeout(timeout);
193197
reject(error);
194198
},
195199
});

‎apps/server/src/atomicWrite.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { Effect, FileSystem, Path } from "effect";
1+
import * as Effect from "effect/Effect";
2+
import * as FileSystem from "effect/FileSystem";
3+
import * as Path from "effect/Path";
24
import * as Random from "effect/Random";
35

46
export const writeFileStringAtomically = (input: {

‎apps/server/src/attachmentPaths.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import path from "node:path";
1+
// @effect-diagnostics nodeBuiltinImport:off
2+
import NodePath from "node:path";
23

34
export const ATTACHMENTS_ROUTE_PREFIX = "/attachments";
45

56
export function normalizeAttachmentRelativePath(rawRelativePath: string): string | null {
6-
const normalized = path.normalize(rawRelativePath).replace(/^[/\\]+/, "");
7+
const normalized = NodePath.normalize(rawRelativePath).replace(/^[/\\]+/, "");
78
if (normalized.length === 0 || normalized.startsWith("..") || normalized.includes("\0")) {
89
return null;
910
}
@@ -19,9 +20,9 @@ export function resolveAttachmentRelativePath(input: {
1920
return null;
2021
}
2122

22-
const attachmentsRoot = path.resolve(input.attachmentsDir);
23-
const filePath = path.resolve(path.join(attachmentsRoot, normalizedRelativePath));
24-
if (!filePath.startsWith(`${attachmentsRoot}${path.sep}`)) {
23+
const attachmentsRoot = NodePath.resolve(input.attachmentsDir);
24+
const filePath = NodePath.resolve(NodePath.join(attachmentsRoot, normalizedRelativePath));
25+
if (!filePath.startsWith(`${attachmentsRoot}${NodePath.sep}`)) {
2526
return null;
2627
}
2728
return filePath;

0 commit comments

Comments
 (0)