Effect Service Conventions: 1 issue found
1 issue found
apps/server/src/provider/piRuntime.ts(lines 590–601): the newPiRuntimeEffect service declares its interface as a standalonePiRuntimeShapetype instead of defining it inline in theContext.Servicedeclaration. Define the interface inline and refer to the inferred shape asPiRuntime["Service"](including in themakeinternals, thesatisfiesclause, and the new test doubles that importPiRuntimeShape).
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.
Convention checked
Service definition — Define the service interface inline in the
Context.Servicedeclaration. Do not retain a standaloneFooShapeorFooServiceShapeinterface/type. Refer to the inferred service interface asFoo["Service"], including in tests and integration harnesses.
Finding
apps/server/src/provider/piRuntime.ts introduces a new Context.Service named PiRuntime (line 644) whose interface is defined as a separate exported PiRuntimeShape interface (lines 590–601). The standalone shape is then used to type the make internals (PiRuntimeShape["runCommand"], PiRuntimeShape["spawnSession"], satisfies PiRuntimeShape) and is imported as a type by the new test doubles (PiAdapter.test.ts, PiProvider.test.ts, PiTextGeneration.test.ts).
This mirrors the older sibling opencodeRuntime.ts (OpenCodeRuntimeShape), but the conventions are authoritative when older code differs, and this is newly-authored service code in the PR's changed scope. The fix is to inline the interface in the Context.Service<PiRuntime, {...}>() declaration and reference the shape as PiRuntime["Service"] (the pattern already used elsewhere, e.g. TextGeneration.TextGeneration["Service"]).
Reviewed but not flagged
PiRuntimeError(Data.TaggedErrorwithoperation/detail/causeplus astatic ispredicate) carries structured attributes and preservescause, matching the existing runtime-module error pattern.makePiRuntime/PiRuntimeLivenaming andLayer.effectusage follow the established*Runtime/*Livesibling pattern.- Effect subpath namespace imports,
@t3tools/contractsnamed imports, and thePiDriver/PiAdapter/PiProvider/PiTextGenerationmodules otherwise conform to the conventions.
🔍 Agent activity — 1 tool call
💭 I'm checking the diff for violations of Effect service conventions, particularly the rule about defining service interfaces inline within
Context.Servicedeclarations rather than as separate standalone types. Looking at the new files like piRuntime.ts, I need to see if they're following this pattern correctly. The issue is thatPiRuntimeShapeis defined as a standalone interface and then used in theContext.Servicedeclaration, which violates the convention. The convention also says to refer to the inferred service interface asFoo["Service"]rather than using external type references likePiRuntimeShapein test doubles and other places. SincePiRuntimeShapeis newly introduced in this pull request, it's a violation that should be flagged. I need to verify whetherPiRuntimeShapeis purely the service interface or if it serves some other purpose that might justify keeping it separate. Looking at themake/layerconventions, the code exportsPiRuntimeLiveinstead of the canonicallayername, which also appears to be a violation of the established pattern. ThePiRuntimeShapeinterface is the real issue here—the check instructions explicitly say not to keep standalone shape interfaces, but the repo already hasProviderAdapterShapeand similar patterns, so I need to decide whether this is an established convention I should respect or a violation I should flag. The instructions treat the check as authoritative when there's a conflict, so the shape interface probably needs to go. Looking at wherePiRuntimeShapeis actually used, it shows up across multiple test files as the type annotation for test doubles, which confirms it's being referenced externally and would need to be addressed if I'm flagging this as a violation. The convention states that service interfaces should be accessed viaPiRuntime["Service"]rather than using a standalone shape type. I need to verify whetherContext.Serviceactually supports that bracket notation for accessing the service type, since that's the crux of whether this is truly a violation or if the convention applies differently to this pattern. Looking atPiAdapterShapeusage in PiAdapter.ts — it's consuming the existingProviderAdapterShaperather than defining a new service, so that's out of scope. ThemakePiAdapterfunction returns an object satisfyingPiAdapterShapeand gets provided as aContext.Servicein tests, but I need to determine if it's actually functioning as a service or just a factory. Now checking the error conventions againstPiRuntimeError, which usesData.TaggedErrorinstead of the recommendedSchema.TaggedErrorClass— that might be a convention deviation, thoughData.TaggedErrorcould be widely used in the codebase. Thedetailfield also needs scrutiny to ensure it's not just duplicatingcause.message. I'm noticing that the detail field is constructing an error message that includes the full command with its arguments, which could leak sensitive information like prompt text. That's a potential security issue worth flagging. There's also some redundancy in howPiRuntimeErroruses both anoperationfield and adetailfield to encode similar distinctions. Looking at the message derivation,PiRuntimeErrorrelies onData.TaggedErrorwhich doesn't auto-derive messages from attributes the way the convention expects. UsingSchema.TaggedErrorClasswould be more aligned with that pattern. The staticismethod usingP.isTaggedis a bit borderline—it's not redundantly wrapped, but exporting direct schema predicates would be cleaner. The clearest violation though is the standalonePiRuntimeShapeinterface for the newPiRuntimeservice. Let me verify that by checking the actual file to confirm it hasn't already been addressed and to get the exact line numbers. I also need to look at how errors are defined elsewhere in the repo—specifically whetherSchema.TaggedErrorClassis the established pattern—to determine ifPiRuntimeErrorusingData.TaggedErroris a genuine deviation worth reporting. I need to restructure how the repository is passed—it should be an object containing the URL rather than just a string. I'll use the head commit SHA. I'm seeing the repo's error handling pattern now — errors useSchema.TaggedErrorClasswith structured attributes and amessagegetter, plus an optionalcausefield for defects. TheProviderAdapterShape<TError>is a generic adapter contract rather than a Context.Service, which works fine since it's parametrized and meant as an interface for adapters rather than a service tag. The newPiRuntimeservice definesPiRuntimeShapeas a standalone interface, which breaks the repo convention of defining service interfaces inline within the Context.Service declaration. I need to check howOpenCodeRuntimehandles this — if it's an established local pattern, the violation becomes less clear, but since the instructions say to treat new code as in-scope, I should still flag it. Also,PiRuntimeErrorusesData.TaggedErrorwhile the repo's error convention usesSchema.TaggedErrorClass, which is another deviation I need to verify against the existing runtime service definitions. I need to check howOpenCodeRuntimeis structured as a Context.Service and verify it usesOpenCodeRuntimeShape, while also confirming thatOpenCodeRuntimeErrorextends the tagged error pattern with itsoperation,cause, anddetailfields. I'm setting upPiRuntimeto follow the same pattern asOpenCodeRuntime, defining the service interface, creating a tagged error type with metadata fields and a type guard, establishing the live layer implementation, and starting to build the factory function. Now I'm weighing whether to flag this pattern as a violation. The guidelines say not to demand unrelated cleanup, but they're also explicit about avoiding standaloneFooShapeinterfaces. SincePiRuntimeis newly introduced and mirrors the established sibling pattern, flagging it would force a divergence from what's already in the codebase. The check allows for not failing on optional style preferences or legacy code, and this seems like a case where consistency with the existing module takes precedence over the stricter guideline. The conventions explicitly state "when older code differs," which suggests new code should follow the updated patterns regardless of what existing sibling services do. InliningPiRuntimeShapeinto theContext.Servicedefinition is a concrete, contained fix—I'd need to update the type references throughout the make internals and tests, but that's manageable. The real question is whetherPiRuntimeShapeserves a legitimate purpose beyond just following the old pattern, or if it's genuinely necessary for the implementation. ured about whether this is actually the intended violation to flag, or if the code is acceptable as-is. The PR introducesPiRuntimeShapeas a new standalone type that mirrors the olderOpenCodeRuntimepattern, and the conventions are explicit: define the service interface inline and don't keep a separateFooShape. This looks like a textbook case the conventions describe. But I'm weighing whether flagging it violates the principle of not demanding unrelated cleanup—exceptPiRuntimeShapeisn't legacy code, it's newly written in this PR, so it's fair game to address. There's alsoPiRuntimeErrorusingData.TaggedErrorwhen the repo convention calls forSchema.TaggedErrorClass, which I see in the Errors.ts file. The conventions are authoritative over older patterns, so even thoughOpenCodeRuntimeErroruses the older approach, that shouldn't stop me from flagging the new code. The real question is whether I should flag both issues or focus on the clearest one given how closely the new service mirrors the existing sibling. The error handling pattern in PiRuntimeError mirrors OpenCodeRuntimeError closely enough—both use structured attributes and preserve cause chains—so the real question is whether the deviation fromSchema.TaggedErrorClassis significant enough to flag. Since neither implementation defines a custom message getter and the semantic requirements around structured attributes and cause preservation are met, I'm reconsidering whether to raise this as a finding at all. The convention is explicit: don't keep a standalonePiRuntimeShapewhen the service interface should be defined inline inContext.Service. The codebase already follows this pattern withTextGeneration["Service"], so this is a clear violation I should flag. I'm also considering whether to flag the consumers importingPiRuntimeShape, but that depends on whether they're part of the same violation or separate concerns. Let me locate the exact line numbers forPiRuntimeShapeand the class declaration in piRuntime.ts so I can pinpoint the issue precisely. I'm checking the specific line range to see the exact structure of the code. I've identified that PiRuntime is a new Context.Service with a standalone PiRuntimeShape interface, mirroring the OpenCodeRuntime pattern. Now I'm weighing whether to flag this against the convention that requires service interfaces to be defined inline rather than as separate standalone types, especially since this is a newly introduced pattern in this PR. The authoritative-override clause in the conventions tips me toward flagging it—the "Effect Service Conventions" check specifically targets this exact scenario. However, I'm also considering whether to flag PiRuntimeError, which uses Data.TaggedError instead of Schema.TaggedErrorClass. This is more ambiguous since the codebase has two established patterns: Errors.ts uses Schema.TaggedErrorClass while the runtime modules use Data.TaggedError, so I'm less certain about flagging that one. I'm also noticing line 627 copies command arguments into the detail field, which mirrors what OpenCodeRuntime does and doesn't expose sensitive information—the args are just CLI flags like provider and model settings, not secrets. Given that this pattern is consistent with the sibling module and the arguments aren't sensitive, I'm inclined not to flag this either. So I'm settling on one clear finding: the standalone PiRuntimeShape interface on the new PiRuntime service, though I'm still weighing whether to flag it at all given how strongly the established pattern pulls toward accepting it. I'll flag the standalonePiRuntimeShapeas a violation of the service-definition convention, targeting the interface declaration with guidance to inline it within theContext.Servicedeclaration instead. The comment will be concise and reference the established pattern. Now I'm setting up the GitHub PR review with the inline comment positioned at lines 590-601 on the right side, along with a brief summary in the review body.
1. modify_pr — Effect service conventions review: one finding on the new PiRuntime service definition.
💭 The review is in, so I need to finalize the JSON output. I had a small formatting issue with the provider path that I'm correcting now, and I'll make sure the summary paths are properly structured.
Agent Credits: 176 credits