Repository navigation
Effect Service Conventions: 1 issue found
apps/server/src/provider/Layers/ClaudeAdapter.ts — Backend behavior change to completeTurn's token-usage snapshot precedence (contextUsageSnapshot ?? updatedLastGood ?? resultIterationSnapshot) lands without a focused test. The newly changed path (prior lastKnownTokenUsage present and result.usage reporting active input/output tokens) is not covered by existing tests, so the #8594 regression could silently return.
No violations found for imports/namespaces, service definition (Context.Service, make, layer), dependency acquisition, runtime boundaries, or error modeling — the diff does not touch those aspects.
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/provider/Layers/ClaudeAdapter.ts(only file changed; matches include patternapps/**/*.ts).
Convention checks performed
- Imports/namespaces: no import lines changed; no consolidated
from "effect"named imports introduced. - Service definition / layout: no
Context.Servicetag,make, orlayerdeclarations touched; no new shape interfaces, re-export shims, or file moves. - Dependency acquisition / runtime boundaries: no new service-instance parameters,
Layer.succeed,ManagedRuntime.make,runPromise, orrunPromiseExitin the diff. - Errors and predicates: no error classes,
Schema.TaggedErrorClassdefinitions, predicates, orcatchTag(s)usage in the diff. - Change discipline: flagged — behavior change without focused test coverage.
Basis for the test finding
Old precedence: contextUsageSnapshot ?? (resultTotalOnly && lastGoodUsage ? patchedLastGood : resultIterationSnapshot) ?? patchedLastGood.
New precedence: contextUsageSnapshot ?? updatedLastGood ?? resultIterationSnapshot.
The only semantic delta is when lastGoodUsage exists and result.usage has non-zero input/output (i.e. resultHasActiveUsage): the result-derived snapshot used to win, and now the last-known per-request snapshot wins. Existing tests in apps/server/src/provider/Layers/ClaudeAdapter.test.ts (≈ lines 2708, 2775, 2838) either have no prior lastKnownTokenUsage or send a total_tokens-only result, which took the resultTotalOnly branch before this change — so all of them pass under both the old and new code. An inline comment was posted requesting a case that seeds lastKnownTokenUsage and then delivers a result with active per-model usage.
🔍 Agent activity — 5 tool calls
💭 I'm looking at the diff in ClaudeAdapter.ts, which changes token usage snapshot logic rather than an Effect service definition. The change drops some computations and adds a new one, which could leave variables like
resultUsageRecordorclaudeUsageInputTokensunused, though that's more a lint concern than a convention violation—I want to check the surrounding file to confirm.
1. browse_code — apps/server/src/provider/Layers/ClaudeAdapter.ts
2. git_tools — claudeTotalProcessedTokens|claudeUsageInputTokens|resultUsageRecord|lastClaudeUsageIteration
💭 This isn't really about Effect service conventions—it's a backend behavior change to token usage metering. I'm checking whether the PR includes tests for this, since the diff only touches ClaudeAdapter.ts and the discipline guidelines call for focused tests when backend behavior changes.
3. browse_code — Are there existing tests covering completeTurn token usage snapshot behavior in apps/server (ClaudeAdapter usage snapshot / thread token usage / normalizeClaudeActiveTokenUsage)? List test file paths and what they assert about result.usage vs lastKnownTokenUsage.
💭 I'm checking whether the existing test at line 2838 already covers the priority change, since it verifies "lastKnownTokenUsage wins" -- the removed branching logic previously let resultIterationSnapshot override lastGood when the result had active usage, but the simplified fallback chain no longer does that. Given the "Change discipline" guideline for Effect services, this looks like it needs a new focused test specifically for the case where result has active usage but lastGood is present, since that precedence flip is the actual behavior change worth verifying. Checking whether test 2838 actually exercises the new path—if total_tokens is used without input/output tokens set, that would mean resultHasActiveUsage is false, so it falls into the same old path rather than the new precedence, meaning the true behavior change might still be untested. I confirmed the diff only touches ClaudeAdapter.ts with no test additions, and there's no other obvious convention issue like unused imports or error handling gaps. Since this is a genuine backend behavior change in token metering with no focused coverage, I'll flag it as a missing-test finding and request a focused test in ClaudeAdapter.test for this precedence fix.
4. browse_code — apps/server/src/provider/Layers/ClaudeAdapter.ts
💭 I've confirmed the precedence change alters behavior specifically when lastGoodUsage exists alongside active input/output tokens in result.usage—previously the result snapshot would win, but now lastGood takes priority, and none of the existing tests actually exercise this scenario. I'll leave an inline comment flagging this untested case around the changed lines. Since this is a genuine behavior change lacking test coverage, I'll mark the check as failure rather than passing it cleanly, while keeping the review comment measured rather than alarmist.
5. modify_pr — Effect service conventions: imports, service/tag/make/layer shape, dependency acquisition, and error modeling are unchanged and compliant in this diff. One change-discipline finding: the token-usage precedence change alters backend behavior without a focused test.
Agent Credits: 161 credits
Token usage: 24 uncached input · 451,657 cache-read input · 154,737 cache-write input · 13,409 output
Agent Credits may also include non-token charges from external tools such as web research.