refactor(core): flatten verify ternary + extract debug_traceCall helper - #162
Merged
Merged
Conversation
Two refactors from the codebase audit: 1. verify/index.ts: Replace 7-level nested ternary in buildReportSources with a flat deriveSimulationVerificationReason() helper. Removes the unreachable dead code branch that tested for "simulation-replay-matched" when success === false (impossible by type definition). 2. fetcher.ts: Extract duplicated stateOverrides plural/singular retry logic into a shared debugTraceCallWithOverrides() helper. Both tryTraceCall (callTracer) and tryRunPrestateTrace (prestateTracer) now delegate to it, eliminating ~50 lines of identical code. No behavioral changes. All 634 tests pass, type-check clean. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two refactors addressing findings from the codebase audit:
buildReportSourceswith a flatderiveSimulationVerificationReason()helper. Removes the unreachable dead code branch that tested for"simulation-replay-matched"whensuccess === false(impossible by theSimulationReplayVerificationResulttype —"simulation-replay-matched"is the success-only reason)stateOverrides(plural) →stateOverride(singular) retry logic into a shareddebugTraceCallWithOverrides()helper. BothtryTraceCall(callTracer) andtryRunPrestateTrace(prestateTracer) now delegate to it, eliminating ~50 lines of identical codeNet: -39 lines (70 added, 109 removed). No behavioral changes.
Test plan
🤖 Generated with Claude Code
Note
Low Risk
Low risk refactor: primarily extracts duplicated logic and replaces a deeply nested ternary with a helper, with minimal behavioral impact. Main risk is subtle changes in edge-case handling of
debug_traceCallparams or simulation replay reason mapping.Overview
Refactors simulation tracing to centralize
debug_traceCallinvocation indebugTraceCallWithOverrides(), reusing the samestateOverrides→stateOverridefallback logic for bothcallTracerandprestateTracerpaths.Simplifies verification source building by extracting the simulation verification reason selection into
deriveSimulationVerificationReason(), removing the prior deeply nested ternary (including an effectively unreachable branch around the replay reason).Written by Cursor Bugbot for commit f5fa235. This will update automatically on new commits. Configure here.