Repository navigation
Effect Service Conventions: 2 issues found
Two convention violations were found in the new GitHub GraphQL budget path.
apps/server/src/sourceControl/githubGraphQlBudget.ts(lines 90-94): the budget is a process-wide mutable singleton (Mapstate +Date.now()) imported directly intoGitHubPullRequestCli.make, hiding a dependency in a module global instead of exposing it as an Effect service acquired from the environment.make/layertypes do not reflect the requirement, and tests reset the global inafterEach.apps/server/src/pullRequest/GitHubPullRequestCli.ts(lines 931-938): the paused-budget failure reusesGitHubCli.GitHubCliRateLimitErrorwith a manufacturednew Error(...)ascause, puttingresetAtinto an unstructured string and reporting the misleading messageGitHub CLI failed in executewhen no command ran.
Both findings were posted as inline review comments.
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.
Methodology: reviewed the full merge-base..head diff, then read apps/server/src/sourceControl/githubGraphQlBudget.ts, apps/server/src/pullRequest/GitHubPullRequestCli.ts (graphqlRead and make), apps/server/src/sourceControl/GitHubCli.ts (error definitions and service shape), and grepped for all uses of githubGraphQlBudget. Also confirmed via codebase research that the house style for cross-request state in apps/server/src is Context.Service plus Ref/SynchronizedRef created inside make (e.g. McpSessionRegistry.ts, serverLifecycleEvents.ts, ProviderInstanceRegistryLive.ts), so the new module-level singleton is not an established pattern.
Not flagged: the web-side changes (PullRequestCodeTab.tsx, PullRequestReviewAnnotation.tsx, pullRequestDetail.logic.ts, useLiveRefresh.ts) are React/pure-helper code with no Effect service concerns; the new contract schemas, RPC method, optional getReviewThreadComments provider method, and PullRequestService.threadComments follow existing patterns (namespace Effect imports, Service["Service"] typing, existing PullRequestOperationError usage).
🔍 Agent activity — 1 tool call
💭 I'm spotting a violation in the new GitHub GraphQL budget module—it's using a mutable singleton Map at the module level that gets imported directly into a service's
makefunction, which hides dependencies instead of declaring them properly through Effect. The code also suppresses diagnostics aroundDate.now()calls, mixing imperative state mutations with what should be pure service construction.… I'm identifying the main issues with the code structure. ThegithubGraphQlBudgetis a module-level mutable singleton being used insideGitHubPullRequestCli.make, which violates the principle of not hiding dependencies in module globals or closures. Additionally, the code relies onDate.now()instead of using the Effect Clock service, and this should be refactored as a proper Effect service using Context.Service with appropriate make and layer implementations. The test file compounds this problem by resetting the global state in afterEach, which exposes the coupling between tests and shared mutable state. Beyond that, the code manufactures an Error just to populate thecausefield — since this failure is a locally-decided pause rather than an underlying error, creating a synthetic Error erases the actual structure. I should flag that reusingGitHubCliRateLimitErrorwith a manufactured Error is misleading (the message claims "GitHub CLI failed" when no CLI actually ran), and a dedicated error class likeGitHubGraphQlBudgetPausedErrorwould better represent what's actually happening. TheresetAtcontext is also buried inside a string message instead of being captured as a structured field, which loses the stable serializable domain context. The interfaceGitHubGraphQlBudgetitself… The new module violates dependency injection principles since it's a process-wide mutable singleton with hidden state that gets consumed directly in the… I'm seeing two code violations here. First, there's a hidden dependency in the module global—a mutable state withDate.nowbeing consumed inside a service, which directly contradicts the convention about composing resources in an application-owned layer and passing context to runtimes. Second, the code is manufacturing anErrorobject just to populate a cause field, and cramming structured context like host and resetAt into the message string instead of following proper error construction patterns. Looking at the rest of the codebase, the React components and pure helpers check out fine. The test imports are correct, but I notice the new module import style uses a named import of a singleton value—if this gets converted to a service, it should switch to a namespace import, which ties back to the first finding. I'm also scanning through the other files likews.tsand checking the PullRequestProvider for any similar issues. Now I need to identify the exact line numbers for inline comments on the PR diff. The first finding should targetgithubGraphQlBudget.tslines 90-94 where the singleton is exported, and the second finding goes onGitHubPullRequestCli.tslines 930-938, specifically around line 935 where the new Error is created. Both of these are in the added lines of the diff, so I can place comments there. I'm drafting the first comment now to explain how the process-wide mutable state becomes a hidden dependency of the service'smake` method.…
1. modify_pr — Two Effect service convention issues in the new GraphQL budget path. Details inline.
Agent Credits: 92 credits