Repository navigation
Effect Service Conventions: 3 issues found
Three convention violations found, all in apps/server/src/provider/Layers/GrokAdapter.ts (inline comments posted):
GrokAdapter.ts:1036—Date.now()is used inside an Effect service for the tool-update throttle gate. It is the only imperative clock read inapps/server/src; every other service reads time viaClock(yield* Clock.currentTimeMillis), which keeps the gate testable withTestClock.GrokAdapter.ts:242-247—selectPermissionOptionIdis a redundant pass-through wrapper with the same signature as the newly exportedselectGrokPermissionOptionId; call the exported function directly and delete the wrapper.GrokAdapter.ts:1747—detail: executed?.errorcopies arbitrary text from the_x.ai/rewind/executewire payload into a caller-visible error message. Keepdetaila stable structural string and preserve the raw value ascause.
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/scripts/acp-mock-agent.ts, apps/server/src/provider/Layers/GrokAdapter.ts, GrokProvider.ts, apps/server/src/provider/acp/{AcpSessionRuntime,GrokAcpSupport,GrokAcpToolUpdates,GrokAcpWorkflow,XAiAcpExtension}.ts and their tests, plus packages/contracts/src/model.ts.
Items checked and found compliant:
- Imports: all touched modules use namespace subpath imports (
import * as Effect from "effect/Effect",effect/FileSystem,effect/Path); no consolidated named imports from"effect"were introduced. Named imports from@t3tools/contractsand pure-helper modules are correct per the conventions. - Dependency acquisition:
grokHasLocalAuthMaterialacquiresFileSystem/Pathfrom the environment withyield*, andcheckGrokProviderStatuscorrectly widens its requirement type to include them. ThePath.Path["Service"]parameter ongrokAuthFileCandidatesis a pure local helper, not injected service ownership. - No
ManagedRuntime.make,runPromise, orrunPromiseExitwas introduced; the only newLayer.succeed/Layer.buildusage is pre-existing ACP runtime wiring. - New modules
GrokAcpWorkflow.tsandGrokAcpToolUpdates.tsare pure mapping/predicate modules with no service definitions, so the service-layout rules do not apply. - Errors: no new
Schema.TaggedErrorClassdefinitions, nocatchTag/catchIfmisuse, and no single-use error factory helpers were added; the existingProviderAdapterRequestErrorshape is reused.
🔍 Agent activity — 1 tool call
💭 I'm checking the Effect service imports across these files to see if there are any convention violations—looking at whether they're using namespace subpath imports versus consolidated named imports from the main "effect" package. Looking at the imports and the
grokAuthFileCandidatesfunction signature, I'm checking whether thePath.Path["Service"]parameter follows the right convention for service dependencies. The function is a pure helper that uses the path service to join paths, so I need to verify this is the correct pattern for how it's being called. Now I'm scanning through the changed files to see what's being imported from the "effect" library. These are pre-existing patterns, so the PR is mainly adding thereasoningEffortconfig option. The AcpSessionRuntime change looks fine with theoptions?._metaaddition to setSessionModel. Now I'm checking GrokAdapter.ts for new code — it's constructing error objects with detail strings, which follows the existing pattern in that file, though I need to verify whether the new detail fields are properly copying the error message. Looking at the specific detail field that copiesexecuted?.error ?? "ok rewind did not succeed."— this takes an error string from the Grok agent's wire payload and puts it into detail, which technically violates the convention against copying raw wire payloads into detail fields. The tricky part is whether an error message from the agent counts as "raw wire payload" or just a legitimate error string. I also notice there's no cause field being preserved, though I should check if ProviderAdapterRequestError even supports a cause field. Let me look at the error class definitions to understand what's allowed. The existing error class uses static detail strings throughout the file, which is the established pattern. The tricky part is this new case where I'm passing throughexecuted?.error ?? "..."— pulling the agent's error text directly. It's remote wire data, which normally I'd avoid putting into detail fields, but this particular error message is meant for display and feels more like a normalized message than arbitrary defect text. It's borderline whether this violates the convention. Now I'm checking the GrokAdapter code for service layer conventions — looking at whether new code properly threads FileSystem and Path dependencies through the effect signatures. ThegrokHasLocalAuthMaterialfunction is a pure effect that correctly requires those dependencies, andcheckGrokProviderStatushas been updated to include them in its signature. What I need to verify is whether all the call sites actually provide these dependencies through the providers layer. The driver supplies Crypto and ChildProcessSpawner through provideService, while FileSystem and Path come from the ambient environment via NodeServices in the driver's requirements—that's consistent with the convention as long as the driver layer includes them. Looking at lines 118-119, the Crypto service is being provided by yielding from Crypto.Crypto earlier in the setup. Now examining GrokAdapter.ts, I see a new selectGrokPermissionOptionId function that's being wrapped by a private selectPermissionOptionId function with an identical signature—this is just delegating to the public function. It's the same pattern as the redundant wrapper convention we flag: a helper that exists only to forward its arguments unchanged, which adds unnecessary indirection without providing value. I'm noting thatGrokAdapterShapeis a pre-existing type convention in the codebase that's outside the scope of this PR, then moving on to examine theselectPermissionOptionIdandrollbackThreadregions. Looking at this finding,selectPermissionOptionIdis indeed a straightforward pass-through wrapper that just forwards its arguments to an underlying schema predicate—it's a textbook example of the redundant wrapper pattern the convention explicitly calls out. This is a concrete violation worth flagging. For the other issues I'm considering:Date.now()in the ToolCallUpdated handler bypasses Effect's Clock system, which is a runtime boundary concern, but the conventions don't specifically address Clock usage—they focus on Layer.succeed and module-level dependencies. I'll hold off on flagging that since it doesn't cleanly fit the stated rules. Let me examine the rollback and cancellation code next. Theexecuted?.errorfield is the Grok agent's rewind error string — a remote-provided arbitrary string that gets embedded in detail and exposed to callers. It's borderline whether this violates the convention about not copying raw wire payloads, but since it's the provider's own error explanation (similar to how other adapters handle remote payloads), I think it's defensible. I'm noticing the repository has inconsistent patterns around error handling. There's a case where provider-supplied error text gets copied directly into the detail field, which violates the convention against including raw wire payloads in error messages. The fix would be to keep the detail as a stable, consistent message while storing the raw provider error elsewhere—possibly in acausefield if the schema supports it. I'm also scanning through the new code for other error-handling issues: checkingemitGrokTaskSpecsand the notification handler for patterns likeEffect.ignorethat might be swallowing failures, and looking at howisGrokAcpAuthFailureworks—it's using regex on stringified error text rather than catching statically-tagged failures, which the convention discourages. I'm looking at whetherisGrokAcpAuthFailureshould use tag-based matching instead of string pattern matching on the stringified cause. The current approach is a heuristic that works but doesn't align with the convention of using catchTags for error classification. Since ACP errors are already tagged with EffectAcpErrors.AcpError, I could leverage that structural information rather than relying on regex matching against the error text. Now I need to decide on the review findings. I'm leaning toward flagging the redundantselectPermissionOptionIdwrapper as a minor violation — it's a same-signature wrapper that adds no value since internal callers could just use the exported function directly. For thedetail: executed?.errorfield, I'm checking how the parse function normalizes the error value. The convention is explicit: don't copy raw wire payloads or arbitrary defect text into detail fields; preserve the exact underlying value only as cause. The rewind error here is a structured string from Grok's extension, so putting it directly into detail violates that principle. I'll flag both issues but keep it to two comments max, phrased as suggestions rather than hard failures. Since I have findings, the check should fail, but I need to be careful about the final response format — the guidance says "All clear" for no findings, but the schema requires JSON output. Now I'm reviewing whether these findings are substantive enough to warrant failure. I should look more closely at the service-injection patterns in the new GrokProvider and adapter code, particularly howLayer.succeedis used and whether GrokAdapter accepts service instances. TheemitGrokTaskSpecsfunction uses closures overofferRuntimeEvent, which is internal. I've confirmed thatmakeGrokAdaptersignature is pre-existing and thatGrokAdapterproperly acquiresfileSystemvia yield*. One more thing to check: the newToolCallUpdatedgate inGrokAdapter.tsusesDate.now()directly inside an Effect, but the codebase might have a convention of usingDateTime.nowor Clock instead. Let me see ifDate.now()appears elsewhere in the server code. I'm noticing thatDate.now()is being used directly in this provider, which is unusual since the rest of the codebase relies on DateTime.now or Clock abstractions. This bypasses the Effect Clock system entirely, which is why the test had to useTestClock.withLiveto work around it. The pattern here violates the convention about not hiding dependencies in module globals or singleton services — imperative runtime APIs should flow through proper Effect layers rather than being called directly. I'm noticing this pattern only appears once in the server source, which breaks the repo conventions. The effect would be equivalent to getting the current time, and there's already anowIsohelper available in the adapter. I need to check the line context to see if we're actually inside anEffect.genblock where I can useyield. I'm thinking about getting the current time in milliseconds within an Effect generator—I could useClock.currentTimeMillisif the Clock module exists in this version of effect, but the repo seems to be usingDateTimeinstead, so I might need to get the current DateTime and convert it to epoch milliseconds. Let me verify whether Clock is available in this effect version first. I've identified a clear violation:Date.now()is being used directly in an Effect service at line 1036 of GrokAdapter.ts, but the codebase consistently usesClock.currentTimeMillisinstead. This is a legitimate finding around imperative APIs crossing runtime boundaries. I'm now going through the file to add inline comments marking where this needs to be replaced. For the first fix, I'll need to add the Clock import and provide a unified diff since the change isn't self-contained. The second issue is a redundant wrapper at lines 242-247. For the third finding at line 1747, there's a detail field being populated with raw wire error text, which violates the bounded attributes rule — I should suggest preserving the cause field instead while keeping the detail stable, though I'm weighing whether this is concrete enough to include given the noise threshold. Let me verify the exact line numbers in the diff to ensure they're part of the context that GitHub will accept for review comments. I'm posting the review with a failure state and three issues found. The first comment flags thatDate.now()is being used for time reading when Effect services should useClockinstead, making it testable withTestClock— I'm suggesting the replacement with the proper import. For the second comment, there's a redundant wrapper function that could be inlined, but since the callers would need to change across multiple locations, I can't provide a diff suggestion and will just describe the issue. The third comment addresses how the error detail is being constructed in the wire payload — I'm weighing whether to spread conditional keys in the object literal or use a simpler approach with the optional cause field.
1. modify_pr — Reviewed the Grok ACP changes against the Effect service conventions. Three findings in apps/server/src/provider/Layers/GrokAdapter.ts; the new pure modules (GrokAcpWorkflow.ts, GrokAcpToolUpdates.ts, XAiAcpExtension.ts) and the new FileSystem/Path acquisition in GrokProvider.ts follow the conventions (namespace subpath imports, dependencies acquired from the environment, requirements surfaced in the signature).
Agent Credits: 184 credits