Thanks to visit codestin.com
Credit goes to github.com

Skip to content

refactor(lib): delete seven orphaned modules (852 dead lines) - #554

Merged
ndycode merged 3 commits into
mainfrom
claude/audit-37-dead-code
Jun 11, 2026
Merged

ndycode merged 3 commits into
mainfrom
claude/audit-37-dead-code

Conversation

@ndycode

@ndycode ndycode commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Summary

Deletes seven fully orphaned modules — 852 dead lines — found by a knip pass and then verified by hand, since raw knip output here has known false positives (it flags lib/index.ts itself because the repo has no knip config for the package entry/subpath exports). Each deletion was confirmed to have zero importers across lib/, scripts/, test/, and index.ts, no facade re-exports, no package.json subpath/bin references, and no dynamic imports. Also drops the now-stale runtime/session-affinity.ts row from the lib/AGENTS.md structure tree.

This PR absorbed #559-wave duplicate #578 (closed): that PR had independently re-verified five of these files and contributed the lib/AGENTS.md fix.

Deleted

Module Lines Why dead
lib/codex-manager/forecast-report-commands.ts 625 Orphaned by the command-registry extraction — forecast-report-shared.ts + the registry replaced it
lib/storage/restore.ts 71 Superseded by storage/backup-restore.ts (restoreAccountsFromBackupPath is what lib/storage.ts actually uses)
lib/runtime/oauth-browser-flow.ts 55 Pre-existing dead code (untouched since the 2.1.x era); live flows are browser-oauth-flow.ts/manual-oauth-flow.ts
lib/runtime/account-health-check.ts 43 Same — index.ts wires clampActiveIndices from elsewhere, never this copy
lib/runtime/session-affinity.ts 26 ensureRuntimeSessionAffinity has no callers; rotation constructs SessionAffinityStore directly
lib/codex-manager/statusline-order.ts 19 Duplicate of reorderStatuslineField in settings-panels.ts (the live, tested copy)
lib/recovery/index.ts 12 Unused barrel; unlike auth/, request/, codex-cli/, recovery has no package subpath export backed by an index file

Deliberately kept

  • lib/recovery/{constants,types,storage}.tsnot orphaned despite the barrel deletion: the root facade lib/recovery.ts (used by lib/runtime/session-recovery.ts) imports recovery/storage.js and recovery/types.js directly, and recovery/constants.ts has a dedicated suite (test/recovery-constants.test.ts). Only the barrel was dead.
  • lib/ui/index.ts — knip flags it, but it's the barrel added on purpose by the merged ui-cohesion refactor as intended surface.
  • scripts/install-codex-auth.js — dev tooling with its own dedicated test suite (test/install-codex-auth.test.ts).

Validation

  • npm run typecheck clean (the strongest guarantee for pure deletions — any remaining static reference would fail), re-run after each of the three commits
  • Canary suites (storage, runtime-rotation-proxy, codex-manager-cli): failure lists byte-identical to unmodified main (the known environment-baseline failures — sandbox EACCES + IPv6 ::1 — same test names both sides; 201/201 on the CLI suite)

Risk / Rollback

Pure deletions of unreferenced files plus one doc line; revert the commits restores them.

https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB

A knip pass followed by hand verification (zero importers across lib/,
scripts/, test/, index.ts; no facade re-exports; no package.json subpath
or bin references; no dynamic imports) found six fully dead modules:

- lib/codex-manager/forecast-report-commands.ts (625 lines) — orphaned
  by the command-registry extraction; forecast-report-shared.ts and the
  registry replaced it
- lib/storage/restore.ts (71) — superseded by storage/backup-restore.ts
- lib/runtime/oauth-browser-flow.ts (55)
- lib/runtime/account-health-check.ts (43)
- lib/codex-manager/statusline-order.ts (19)
- lib/recovery/index.ts (12) — unused barrel; not a package subpath
  (unlike auth/, request/, codex-cli/ whose index files back exports)

Deliberately kept: lib/ui/index.ts (the barrel added on purpose by the
ui-cohesion refactor as intended surface) and
scripts/install-codex-auth.js (dev tooling with its own test suite).

Verified: typecheck clean; storage + rotation-proxy + manager-cli suites
show failure lists identical to unmodified main (the 25 known
environment-baseline failures only, byte-identical test names).

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 14 minutes and 50 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: 7db67cee-4582-4d53-9ad7-173511e7e822

📥 Commits

Reviewing files that changed from the base of the PR and between e453111 and 325869c.

📒 Files selected for processing (8)
  • lib/AGENTS.md
  • lib/codex-manager/forecast-report-commands.ts
  • lib/codex-manager/statusline-order.ts
  • lib/recovery/index.ts
  • lib/runtime/account-health-check.ts
  • lib/runtime/oauth-browser-flow.ts
  • lib/runtime/session-affinity.ts
  • lib/storage/restore.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/audit-37-dead-code
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch claude/audit-37-dead-code

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.

Found by the knip config follow-up: lib/runtime/session-affinity.ts (26
lines, ensureRuntimeSessionAffinity) has zero importers — superseded by
runtime/session-affinity-entry.ts. It is distinct from the very-alive
lib/session-affinity.ts, which the first sweep's basename grep conflated
it with. Typecheck clean; both session-affinity suites pass (17/17).

https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
@ndycode ndycode changed the title refactor(lib): delete six orphaned modules (825 dead lines) refactor(lib): delete seven orphaned modules (852 dead lines) Jun 10, 2026

ndycode commented Jun 10, 2026

Copy link
Copy Markdown
Owner Author

Both review findings dispositioned:

  1. Off-by-one title/table — fixed: title and body now say seven modules / 852 lines, with lib/runtime/session-affinity.ts as its own table row and the lib/AGENTS.md tree fix noted.
  2. "Orphaned recovery sub-modules" follow-up — declined: lib/recovery/{constants,types,storage}.ts are not orphaned. The root facade lib/recovery.ts (consumed by lib/runtime/session-recovery.ts) imports recovery/storage.js and recovery/types.js directly (lib/recovery.ts:11,19), storage.ts pulls in constants.ts, and test/recovery-constants.test.ts exercises the constants module dedicatedly. Only the recovery/index.ts barrel was dead — the review's grep appears to have missed the root-facade import path. The "Deliberately kept" section now records this so the next sweep doesn't re-flag them.

Generated by Claude Code

@ndycode
ndycode merged commit 2009353 into main Jun 11, 2026
2 checks passed
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