refactor: prune the unused-export backlog knip recorded
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 (onlywithQueuedRetryis 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-retrytuning constants, the settings-hub option tables, bench-format helpers, and three property-test arbitraries. Perlib/AGENTS.md, public API flows throughlib/index.tsor the documented subpaths — none of these are reachable from any entry. - Stale compatibility re-exports trimmed:
forecast-report-shared'sisRetryableStorageWriteError(its "historical import surface" has no remaining importers; the trim then revealed the underlyingsave-retry.tsexport was also externally unused — un-exported too),file-paths'getAccountsBackupPathAtIndex, androtation.ts's routing-mutex value re-export block (every consumer importsrouting-mutex.jsdirectly; the type re-exports stay). - Dead code deleted (~120 lines):
createRuntimeEventHandler(an unused generic factory —index.tsand the test use onlyhandleRuntimeEvent), the never-readDASHBOARD_DISPLAY_SETTINGS_VERSION,CODEX_HOST_BRIDGE_META+ its interface (benchmark notes encoded as an unused constant), the unusedresetRuntimeObservabilitySnapshotForTests, and 11 unused fast-check arbitraries intest/property/helpers.ts. - Kept on purpose:
PersistedSwitchReasonSchemastays exported — the const exists solely to feedz.infer, and un-exporting it tripsno-unused-vars(value used only in a type position). The single remaining knip warning documents it.
Validation
- [x]
npm run typecheckclean - [x]
npx eslint <all 28 changed files> --max-warnings=0 - [x]
npx knip: export warnings 94 → 1 (the documented keeper); zero error-level findings - [x] Full
npx vitest run: 4,531 passed / 58 failed / 6 skipped — identical totals to the documented environment-only baseline on unmodifiedmain(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:
createRuntimeEventHandlergeneric 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:
isRetryableStorageWriteErrorfromforecast-report-shared,getAccountsBackupPathAtIndexfromfile-paths, and routing-mutex value re-exports fromrotation.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]
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
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.
[!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 reviewcommand 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 7363dfb21cfd059b253117b6c831fc07be664568 and 00b060c490670aa1cd05e65b5b2f2c244a4a0af6.
📒 Files selected for processing (29)
lib/auth/device-auth.tslib/codex-manager/backend-settings-helpers.tslib/codex-manager/commands/uninstall.tslib/codex-manager/forecast-report-shared.tslib/codex-manager/formatters/quota-formatters.tslib/codex-manager/repair-commands.tslib/codex-manager/settings-hub/backend.tslib/codex-manager/settings-hub/dashboard.tslib/codex-manager/settings-hub/shared.tslib/codex-manager/settings-preview.tslib/codex-manager/settings-write-queue.tslib/dashboard-settings.tslib/fs-retry.tslib/prompts/codex-host-bridge.tslib/prompts/fetch-utils.tslib/rotation.tslib/runtime/config-toml.tslib/runtime/event-handler.tslib/runtime/first-run.tslib/runtime/quota-headers.tslib/runtime/runtime-current-account.tslib/runtime/runtime-observability.tslib/schemas.tslib/storage/file-paths.tslib/storage/save-retry.tsscripts/bench-format/hashline-v2.mjsscripts/bench-format/models.mjsscripts/bench-format/stats.mjstest/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.
Comment @coderabbitai help to get the list of available commands and usage tips.
Closing as superseded — the substance of this stack is already on main:
knip.jsoncis present onmain(byte-identical to what #555 proposed).@fast-check/vitesthas already been removed fromdevDependencies.- The unused-export / unused-type backlog that #556 and #557 pruned is already clean on current
main(verified by running knip against today's tree — no unused files, no unused deps; only a handful of intentional warn-level export/type/enum keepers remain).
Because the bases were ~159 commits behind main, replaying the original deletions would risk removing code that has since become live, with no net benefit. The one genuinely still-valid finding from reviewing this stack — a broken dashboard-settings.js import in test/settings-preview.test.ts that knip surfaced — has been split out into #616. Thanks!