Skip to content

Commit cc4372a

Browse files
refactor(usage): usage readers use Effect FileSystem and SqlClient
The Antigravity, OpenCode and Cursor account usage readers were Node code wrapped in Effect.promise: node:fs/promises, node:sqlite DatabaseSync, setImmediate yields every 256 rows, and a file-wide nodeBuiltinImport:off. They are now Effect functions. - Discovery, reads and walks go through FileSystem and Path. Symlinks are detected with readLink, so they are still never followed. - Databases open through @t3tools/shared/nodeSqliteClient with readonly: true, one scoped client per file, and keep the busy_timeout = 100 pragma. Antigravity still reads in one transaction. - Yields use Effect.yieldNow at the same points. - Cursor reads credentials with FileSystem, hashes with effect/Crypto, and decodes the JWT with Base64Url. Pages read ahead run as scoped fibers, so interruption replaces the AbortController. Each page and the whole read keep their 10 s and 60 s budgets. CursorAccountReader passes the Keychain as an Effect instead of a promise callback. - The tests are it.effect with scoped temp dirs and seed SQLite through the shared client. One Node import remains in the Antigravity reader and its test: node:fs/promises stat, because Effect's File.Info has no ctime, and the cache fingerprint (size:mtimeMs:ctimeMs) depends on it. apps/server/src/usage/usageTranscriptReader.ts, the stream-json engine that predates this stack, is still Node-based. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent f99db8a commit cc4372a

8 files changed

Lines changed: 1214 additions & 970 deletions

File tree

‎apps/server/src/provider/Drivers/AntigravityUsage.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ const make = Effect.gen(function* () {
106106
: resolvedRoot;
107107
conversationDirs.add(yield* fileSystem.realPath(dir).pipe(Effect.orElseSucceed(() => dir)));
108108
}
109-
const result = yield* Effect.promise(() =>
110-
readAntigravityUsage([...conversationDirs], windowStartMs, cache),
109+
const result = yield* readAntigravityUsage([...conversationDirs], windowStartMs, cache).pipe(
110+
Effect.provideService(FileSystem.FileSystem, fileSystem),
111+
Effect.provideService(Path.Path, path),
111112
);
112113
const scanned: ProviderUsageScan[] = [];
113114
for (const dir of conversationDirs) {

0 commit comments

Comments
 (0)