Skip to content

refactor: prune the unused-export backlog knip recorded#556

Open
ndycode wants to merge 1 commit into
claude/audit-38-knip-configfrom
claude/audit-39-export-prune
Open

refactor: prune the unused-export backlog knip recorded#556
ndycode wants to merge 1 commit into
claude/audit-38-knip-configfrom
claude/audit-39-export-prune

Conversation

@ndycode

@ndycode ndycode commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Summary

Clears the unused-export backlog that #555's knip config recorded as warnings: 93 of 94 resolved across 28 files (−165 net lines), with the one remaining warning kept deliberately and documented.

Stacked on #555#554. Merge in order; this PR then shows only the prune commit.

What was done, by category

  • 77 symbols un-exported — used inside their own module only: settings-write-queue's retry internals (only withQueuedRetry is consumed externally), config-toml's six TOML helpers, quota-headers' parsers/formatters, the device-auth constants, repair-commands' usage/arg-parse helpers, nine zod sub-schemas, fs-retry tuning constants, the settings-hub option tables, bench-format helpers, and three property-test arbitraries. Per lib/AGENTS.md, public API flows through lib/index.ts or the documented subpaths — none of these are reachable from any entry.
  • Stale compatibility re-exports trimmed: forecast-report-shared's isRetryableStorageWriteError (its "historical import surface" has no remaining importers; the trim then revealed the underlying save-retry.ts export was also externally unused — un-exported too), file-paths' getAccountsBackupPathAtIndex, and rotation.ts's routing-mutex value re-export block (every consumer imports routing-mutex.js directly; the type re-exports stay).
  • Dead code deleted (~120 lines): createRuntimeEventHandler (an unused generic factory — index.ts and the test use only handleRuntimeEvent), the never-read DASHBOARD_DISPLAY_SETTINGS_VERSION, CODEX_HOST_BRIDGE_META + its interface (benchmark notes encoded as an unused constant), the unused resetRuntimeObservabilitySnapshotForTests, and 11 unused fast-check arbitraries in test/property/helpers.ts.
  • Kept on purpose: PersistedSwitchReasonSchema stays exported — the const exists solely to feed z.infer, and un-exporting it trips no-unused-vars (value used only in a type position). The single remaining knip warning documents it.

Validation

  • npm run typecheck clean
  • npx eslint <all 28 changed files> --max-warnings=0
  • npx knip: export warnings 94 → 1 (the documented keeper); zero error-level findings
  • Full npx vitest run: 4,531 passed / 58 failed / 6 skipped — identical totals to the documented environment-only baseline on unmodified main (sandbox EACCES, IPv6 ::1, Windows-path sims)

Risk / Rollback

No behavior changes — visibility reductions and deletions of unreferenced code only; the full-suite baseline parity is the gate. Revert the single commit.

https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB


Generated by Claude Code

note: greptile review for oc-chatgpt-multi-auth. cite files like lib/foo.ts:123. confirm regression tests + windows concurrency/token redaction coverage.

Greptile Summary

visibility-only refactor clearing 93 of 94 knip unused-export warnings across 28 files: 77 symbols un-exported (now module-private), stale compatibility re-exports trimmed, and ~120 lines of dead code deleted. no behavioral changes — all public api still flows through lib/index.ts or documented subpaths, and full-suite vitest parity with unmodified main is confirmed.

  • 77 symbols narrowed to module scope across settings-write-queue, config-toml, quota-headers, device-auth, repair-commands, schemas, fs-retry, and bench-format helpers — none reachable from any package entry.
  • dead code deleted: createRuntimeEventHandler generic factory (~55 lines), DASHBOARD_DISPLAY_SETTINGS_VERSION, CODEX_HOST_BRIDGE_META+interface (benchmark notes as an unused constant), resetRuntimeObservabilitySnapshotForTests, and 11 fast-check arbitraries.
  • stale compatibility re-exports dropped: isRetryableStorageWriteError from forecast-report-shared, getAccountsBackupPathAtIndex from file-paths, and routing-mutex value re-exports from rotation.ts — all confirmed import-less before removal.

Confidence Score: 4/5

safe to merge — pure visibility reductions and dead-code deletions with no behavioral changes; the one rough edge is cosmetic.

every removed export was verified to have no remaining callers: routing-mutex consumers already import from routing-mutex.js directly, schema sub-schemas are only used as building blocks within schemas.ts, and the deleted functions (createRuntimeEventHandler, resetRuntimeObservabilitySnapshotForTests) have zero test or library references. the only loose end is test/property/helpers.ts, where arbTimestamp, arbMessageContent, and arbInputItem were un-exported but not deleted after their sole consumers were removed — they're inert dead declarations rather than a runtime risk.

test/property/helpers.ts — three dead private declarations (arbTimestamp, arbMessageContent, arbInputItem) should be deleted rather than left as unexported module-level noise.

Important Files Changed

Filename Overview
test/property/helpers.ts removed 11 unused arbitraries; three dead private declarations (arbTimestamp, arbMessageContent, arbInputItem) left behind after arbRequestBody deletion
lib/runtime/event-handler.ts deleted unused createRuntimeEventHandler generic factory (~55 lines); handleRuntimeEvent remains as the sole export
lib/rotation.ts removed value re-exports (createAsyncMutex, getRoutingMutex, withRoutingMutex) from routing-mutex.js; all callers confirmed to import from routing-mutex.js directly; type re-exports kept
lib/runtime/runtime-observability.ts deleted resetRuntimeObservabilitySnapshotForTests — no callers found in test tree
lib/codex-manager/settings-write-queue.ts un-exported all retry internals (EBUSY/EPERM/EAGAIN constants, backoff helpers); withQueuedRetry remains the sole public API and is covered by settings-hub-utils.test.ts
lib/schemas.ts un-exported 8 internal Zod sub-schemas; no external importers of these symbols found; PersistedSwitchReasonSchema stays exported per documented knip exception
lib/codex-manager/forecast-report-shared.ts dropped isRetryableStorageWriteError from the compatibility re-export surface; no callers import it from this path
lib/runtime/config-toml.ts six TOML helper functions un-exported; tested indirectly through public API in config-toml-restore.test.ts and app-bind.test.ts
lib/auth/device-auth.ts un-exported DEVICE_AUTH_BASE_URL, DEVICE_AUTH_API_BASE_URL, DEVICE_AUTH_TIMEOUT_MS, DEVICE_AUTH_DEFAULT_INTERVAL_MS, printDeviceAuthorizationPrompt; all module-internal
lib/storage/save-retry.ts isRetryableStorageWriteError made private; also dropped from forecast-report-shared compatibility re-export; no remaining external callers

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[knip scan #555] -->|94 warnings| B{prune decision}
    B -->|77 symbols| C[un-export: make module-private]
    B -->|stale re-exports| D[trim compatibility surface]
    B -->|truly dead| E[delete dead code]
    B -->|1 keeper| F[PersistedSwitchReasonSchema\ndocumented knip exception]

    C --> C1[settings-write-queue internals]
    C --> C2[config-toml helpers]
    C --> C3[quota-headers parsers]
    C --> C4[device-auth constants]
    C --> C5[9 Zod sub-schemas]
    C --> C6[fs-retry tuning constants]
    C --> C7[bench-format helpers]

    D --> D1[isRetryableStorageWriteError\nforecast-report-shared → save-retry]
    D --> D2[getAccountsBackupPathAtIndex\nfile-paths → backup-paths direct]
    D --> D3[routing-mutex values\nrotation.ts → routing-mutex.js direct]

    E --> E1[createRuntimeEventHandler ~55 lines]
    E --> E2[DASHBOARD_DISPLAY_SETTINGS_VERSION]
    E --> E3[CODEX_HOST_BRIDGE_META + interface]
    E --> E4[resetRuntimeObservabilitySnapshotForTests]
    E --> E5[11 fast-check arbitraries]
Loading

Fix All in Codex

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
test/property/helpers.ts:7-51
**Dead private declarations not deleted**

`arbTimestamp` (line 7), `arbMessageContent` (line 35), and `arbInputItem` (line 46) are all now unreachable: `arbRequestBody` — the only consumer of `arbInputItem` — was deleted, and `arbTokenBucketState` / `arbHealthEntry` — the only consumers of `arbTimestamp` — were also deleted. `arbMessageContent` is kept only by the now-dead `arbInputItem`. All three should be removed rather than left as unexported dead declarations; they will likely trigger `no-unused-vars` under stricter configs and add noise to the module.

Reviews (1): Last reviewed commit: "refactor: prune the unused-export backlo..." | Re-trigger Greptile

93 of the 94 export-level warnings resolved across 28 files:

- 77 symbols un-exported: used inside their module only (settings-write
  -queue's retry internals, config-toml's TOML helpers, quota-headers'
  parsers, device-auth constants, repair-commands' usage/arg helpers,
  zod sub-schemas, fs-retry tuning constants, bench-format helpers, ...)
  — per lib/AGENTS.md, public API flows through lib/index.ts or the
  documented subpaths, and none of these are reachable from any entry.
- Two stale compatibility re-exports trimmed (forecast-report-shared's
  isRetryableStorageWriteError, file-paths' getAccountsBackupPathAtIndex)
  plus the rotation.ts routing-mutex value re-export block whose three
  names every consumer now imports from routing-mutex directly.
- Dead code deleted: createRuntimeEventHandler (an unused generic
  factory superseded by handleRuntimeEvent), the never-read
  DASHBOARD_DISPLAY_SETTINGS_VERSION, CODEX_HOST_BRIDGE_META and its
  interface (benchmark notes-as-code), the unused
  resetRuntimeObservabilitySnapshotForTests, and 11 unused fast-check
  arbitraries in test/property/helpers.ts.
- PersistedSwitchReasonSchema stays exported on purpose: the const only
  feeds z.infer, and un-exporting it trips no-unused-vars (value used
  only as a type); the single remaining knip warning documents it.

Verified: typecheck clean, eslint --max-warnings=0 on all 28 changed
files, full vitest run 4531 passed / 58 failed — identical totals to the
documented environment-only baseline on unmodified main.

https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@ndycode, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 19 minutes and 21 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: d4d7aa13-9a58-48fb-bf5c-e09d2e4835b8

📥 Commits

Reviewing files that changed from the base of the PR and between 7363dfb and 00b060c.

📒 Files selected for processing (29)
  • lib/auth/device-auth.ts
  • lib/codex-manager/backend-settings-helpers.ts
  • lib/codex-manager/commands/uninstall.ts
  • lib/codex-manager/forecast-report-shared.ts
  • lib/codex-manager/formatters/quota-formatters.ts
  • lib/codex-manager/repair-commands.ts
  • lib/codex-manager/settings-hub/backend.ts
  • lib/codex-manager/settings-hub/dashboard.ts
  • lib/codex-manager/settings-hub/shared.ts
  • lib/codex-manager/settings-preview.ts
  • lib/codex-manager/settings-write-queue.ts
  • lib/dashboard-settings.ts
  • lib/fs-retry.ts
  • lib/prompts/codex-host-bridge.ts
  • lib/prompts/fetch-utils.ts
  • lib/rotation.ts
  • lib/runtime/config-toml.ts
  • lib/runtime/event-handler.ts
  • lib/runtime/first-run.ts
  • lib/runtime/quota-headers.ts
  • lib/runtime/runtime-current-account.ts
  • lib/runtime/runtime-observability.ts
  • lib/schemas.ts
  • lib/storage/file-paths.ts
  • lib/storage/save-retry.ts
  • scripts/bench-format/hashline-v2.mjs
  • scripts/bench-format/models.mjs
  • scripts/bench-format/stats.mjs
  • test/property/helpers.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/audit-39-export-prune
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch claude/audit-39-export-prune

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

ndycode added a commit that referenced this pull request Jun 11, 2026
refactor: prune the unused-export backlog knip recorded
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.

2 participants