Repository navigation
Effect Service Conventions: 1 issue found
1 finding
apps/server/src/serverSettings.ts(lines 452-459): the new provider-history SQL query maps its failure toServerSettingsErrorwithoperation: "read-file"andsettingsPath, producing the caller-visible messageServer settings read-file failed at <settingsPath>.This misidentifies a database read as a settings-file read and collides with the existing file-read failure. Suggested fix: add a dedicatedServerSettingsOperationliteral (e.g."read-provider-history") inpackages/contracts/src/settings.tsand use it at this wrapping site, keeping the SQL error ascause.
An inline review comment was posted for this finding.
Details
Note
Your check run agent prompt is: .macroscope/check-run-agents/effect-service-conventions.md
More information about how Check Run Agents work can be found in our Help Center.
Scope reviewed
apps/server/src/serverSettings.tsapps/server/src/serverSettings.test.tsapps/server/src/server.ts
Checks that passed
- Imports:
import * as SqlClient from "effect/unstable/sql/SqlClient"follows the subpath-namespace convention in both the service and the test; named imports from@t3tools/contractsare explicitly allowed. - Service definition: module keeps the canonical order (errors/schemas,
Context.Servicetag with inline interface,make,export const layer); noFooShapetype was introduced, andServerSettingsService["Service"]is still used for the returned object. - Dependency acquisition: the new SQL dependency is acquired from the environment via
yield* SqlClient.SqlClientinsidemake, so it is reflected inlayer's requirement type;server.tssatisfies it withLayer.provideMerge(SqlitePersistenceLayerLive)(the same layer value already used byPersistenceLayerLive, so it is memoized rather than duplicated). NoManagedRuntime.make,runPromise/runPromiseExit, service-instance parameters, or newLayer.succeedimplementations were introduced. - Change discipline: this is a behavior change (provider enablement now derives from persisted session history and explicit disables are persisted), and it is covered by focused tests in
serverSettings.test.tsusing an in-memory SQLite layer rather than mocked business logic. DirectSqlClientuse inside tests to seed rows is an acceptable test seam. - File layout: no service/layer files moved, no compatibility shims added.
Rationale for the finding
ServerSettingsError.message is derived from operation + settingsPath, so operation is a caller-visible structural discriminator. Reusing "read-file" for a projection_thread_sessions / provider_session_runtime query means the error no longer identifies the failing stage and reports a filesystem path that was not involved in the failure, which conflicts with the convention to capture stable structural context (operation/stage plus the correct resource identifier) at the wrapping site.
🔍 Agent activity — 9 tool calls
💭 I'm checking the changed files to evaluate them—looking at how serverSettings.ts acquires the SqlClient from the environment and wraps errors into ServerSettingsError at the failure boundary, which seems reasonable, but I want to check the actual file for more context.
1. git_tools — import|SqlClient|ServerSettingsError — rejected: repo.url: required parameter is missing or empty;repo: required parameter is missing or empty
2. browse_code — apps/server/src/serverSettings.ts
💭 I'm checking the changed regions around lines 234-470 and 620-660.
3. browse_code — apps/server/src/serverSettings.ts
💭 Checking the imports and dependency wiring look correct—SqlClient is pulled in via
make, and the layer requirement flows through to where server.ts provides the persistence layer. Now I'm double-checking whetherServerSettings.layerproperly exposes that requirement. I'm also flagging that using "read-file" as the operation label for a SQL query failure seems like a mislabeling — the convention calls for the operation discriminator to accurately capture the failure context, so reusing a file-read label for a database query misrepresents what actually happened. I want to check the ServerSettingsError definition in contracts to see what operation values are actually available and whether Effect.mapError wrapping here is appropriate.
4. browse_code — Show the definition of ServerSettingsError in @t3tools/contracts (packages/contracts), including the full operation literal union and how message is derived.
5. browse_code — apps/server/src/serverSettings.ts
💭 I'm noticing the SQL provider-history query failure is being mislabeled with
operation: "read-file"at the settings path, when it's actually a database error, not a file read—the error message would misleadingly claim a settings file read failed. A distinct operation literal is needed to correctly capture this domain context. I'll flag that as a concrete finding, then check other things: the ServerSettings layer now requiring SqlClient (need to verify consumers/tests supply it), whetherLayer.provideMergecauses any duplication issues (likely fine due to memoization), and a minor redundant nested check that's more a code-quality nit than a convention violation. Let me look at the layer definition at the end of the file to confirm.
6. git_tools — export const layer
7. git_tools — ServerSettings(Module)?.layer|serverSettings.layer
💭 That looks fine. Now I'm checking server.ts for layering issues around merging SqlitePersistenceLayerLive into ServerSettingsLayerLive—wondering if SqlitePersistenceLayerLive gets provided elsewhere too, which could spin up duplicate sqlite clients since layer memoization only works within the same composed graph.
8. git_tools — SqlitePersistenceLayerLive
💭 Same layer instance confirmed, memoized fine. Now I'm questioning whether ServerSettings issuing raw SQL against projection tables directly violates convention — is there supposed to be a dedicated repository/persistence service owning those tables instead of domain services querying SQL directly? That said, I don't see this explicitly covered in the listed conventions, so I shouldn't invent a violation there. Better to focus on something concrete: the error mislabeling issue, where reusing a "read-file" operation label for what's actually a SQL query produces a misleading caller-facing error message. This does seem like a legitimate finding worth flagging — the operation context should be accurate and distinct rather than reused across unrelated failure paths. I'm also scanning the test file for issues, but the layer setup and SqlClient usage there look fine, and adding tests for a behavior change is appropriate rather than excessive. There's a minor style note about using string literals instead of ProviderDriverKind for driver comparisons, but nothing else stands out as a clear violation. I'm now weighing whether the read-file mislabeling issue is significant enough to fail the check outright or just merits an inline comment. I need to check whether the mapError block, around lines 452-459, actually falls within the diff's added lines so I can post an inline comment there — line 456 for the "read-file" operation label looks like the right anchor. I'm also noting that wrapping the SQL failure with settingsPath context is reasonable, though I should reconsider how strongly to phrase the finding given the convention about capturing stable, known context rather than wrapping an entire multi-step pipeline. I've confirmed line 456 in the new file is where
operation: "read-file"appears, so I can anchor the comment there. Since fixing this would require adding a new operation literal in the contracts file, it's a cross-file change and no direct diff suggestion is possible.
9. modify_pr — One finding on error modeling for the new provider-history query. Import namespaces, Context.Service/make/layer shape, and dependency acquisition (yield* SqlClient.SqlClient with SqlClient surfaced in layer's requirements and provided in server.ts) all look consistent with the conventions.
Agent Credits: 91 credits