Skip to content

Remove dead production code and parameters nobody varies - #156

Merged
mstallone merged 2 commits into
mainfrom
cleanup-dead-code
Oct 6, 2026
Merged

mstallone merged 2 commits into
mainfrom
cleanup-dead-code

Conversation

@mstallone

Copy link
Copy Markdown
Owner

TL;DR

First batch from a production cleanup audit (the code-side follow-up to the test-value audit): deletes declarations nothing calls and parameters every caller passes the same way. No behavior changes.

What was happening

  • Leftovers of the switch to read-only credentials (Make Codex and Cursor credentials strictly read-only; delete the Keychain write path #90): CursorUsageError.usageAfterRefreshFailed and CodexAuthError.invalidAuthPayload were thrown by nothing, ProviderAuthRetry.fetch kept a retriedConnectionFailed parameter no caller passed, and both CursorProvider and CodexProvider copied the access token into a currentToken alias "in case it rotated", which a single request with no refresh cannot do.
  • Parameters with one value: SQLiteCLIAccessor.run(readOnly:) (all three callers pass true), resolveDeviceID(allowLegacyInteraction:) (never passed), fetchViewerEnterprises(after:) (always nil), KimiAuthStore.credentialPath defaults (the one caller passes both), and ModelPricingStore.loadCatalog(parse:) (always the same codec).
  • ModelPricingStore.defaultSourceURLs was a dictionary over a three-case enum behind a guard ... else { return false } that could not fail and logged nothing.
  • OpenCodeUsageScan wrapped a single LogUsageScan field since Switch OpenCode Go Meters to the Official Usage API #106 removed its second one.
  • CodexMemoryRow carried four metadata fields that were selected and decoded but never read, and the list query fetched last_usage for nothing.
  • Dead outright: CodexUsagePricing.priorityMultiplier(for:rates:), MuseUsageClient.usageURL, HeaderView.toggle's toggle-back branch (the header only mounts on the dashboard), the unreachable "Refresh failed" fallback in WidgetDataStore, a redundant nil check in DevinProvider, an unused import Security.
  • Test-only: UsageHistoryAggregator.merged(peerDocuments:) and ProviderMetrics.init(provider:metrics:) had no production caller.

What this changes

  • Deletes the dead cases, functions, fields, aliases and parameters above.
  • SourceID gains a url property (a switch), replacing the dictionary and its guard.
  • OpenCodeUsageScanner.scan returns LogUsageScan? directly.
  • CodexMemoryDatabase.loadRow selects only the three columns it returns; the list query drops last_usage.
  • The enterprise-slug GraphQL query drops the cursor variable and the pageInfo selection it never read.
  • merged(peerDocuments:) moves to TestOnlyConveniences.swift; ProviderAccountAssembly.assemble becomes private.

Heads-up

  • Deliberately left: the unreachable defaults at the end of the Claude, Codex and Grok candidate loops (their invariant lives in another file, and removing them would need a force-unwrap or would mislabel a future empty list), CodexTokens.refreshToken (never read, but dropping it changes synthesized equality on a credential type), PricingCatalog.retrievedAt (round-trips into the cache file), and ProviderAccountRecord.removedTombstone and the extra PiProviderMapping entries (both documented as planned work).
  • The enterprise-slug query still reads one page of 100, as before.

Tests

swift test: 1,967 tests, 0 failures locally on macOS 27.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-06T18:01:21.264470Z b0f65e6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@mstallone
mstallone merged commit 9c4aef8 into main Oct 6, 2026
2 checks passed
@mstallone
mstallone deleted the cleanup-dead-code branch October 6, 2026 18:03
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