Skip to content

refactor(core): flatten verify ternary + extract debug_traceCall helper - #162

Merged
Th0rgal merged 1 commit into
mainfrom
refactor/verify-ternary-and-trace-dedup
Feb 25, 2026
Merged

refactor(core): flatten verify ternary + extract debug_traceCall helper#162
Th0rgal merged 1 commit into
mainfrom
refactor/verify-ternary-and-trace-dedup

Conversation

@Th0rgal

@Th0rgal Th0rgal commented Feb 25, 2026

Copy link
Copy Markdown
Owner

Summary

Two refactors addressing findings from the codebase audit:

  • 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 the SimulationReplayVerificationResult type — "simulation-replay-matched" is the success-only reason)
  • fetcher.ts: Extract duplicated stateOverrides (plural) → stateOverride (singular) retry logic into a shared debugTraceCallWithOverrides() helper. Both tryTraceCall (callTracer) and tryRunPrestateTrace (prestateTracer) now delegate to it, eliminating ~50 lines of identical code

Net: -39 lines (70 added, 109 removed). No behavioral changes.

Test plan

  • All 634 tests pass
  • TypeScript type-check clean (desktop + generator)
  • Bugbot review clean

🤖 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_traceCall params or simulation replay reason mapping.

Overview
Refactors simulation tracing to centralize debug_traceCall invocation in debugTraceCallWithOverrides(), reusing the same stateOverridesstateOverride fallback logic for both callTracer and prestateTracer paths.

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.

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>
@vercel

vercel Bot commented Feb 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
safe-lens-generator Building Building Preview, Comment Feb 25, 2026 11:30am

Request Review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@Th0rgal
Th0rgal merged commit d4d4c4f into main Feb 25, 2026
4 checks passed
@Th0rgal
Th0rgal deleted the refactor/verify-ternary-and-trace-dedup branch February 25, 2026 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant