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

Skip to content

refactor: remove five orphaned modules (768 LOC of dead code) - #578

Closed
ndycode wants to merge 1 commit into
mainfrom
claude/audit-59-remove-dead-modules
Closed

ndycode wants to merge 1 commit into
mainfrom
claude/audit-59-remove-dead-modules

Conversation

@ndycode

@ndycode ndycode commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • Removes five modules that nothing in the repository imports — 768 LOC of dead code, including a 625-line forecast/report monolith that was still being patched in parallel with its live replacement.

What Changed

Each file was verified dead by a whole-repo reference search covering static imports, the scripts' dynamic dist/lib/... imports, the root index.ts plugin-host entry, package.json exports subpaths and files, vendor/, the plugin manifest, and tests — zero references to any of them (the only mentions anywhere are rows in the historical docs/audits/evidence/inventory.txt snapshot, which is preserved untouched per audit policy).

Deleted file LOC Why it's dead
lib/codex-manager/forecast-report-commands.ts 625 Superseded by commands/forecast.ts + commands/report.ts, which codex-manager.ts actually imports. The dead copy was still being patched in parallel with the live one (#502, #506) — exactly the drift hazard an orphaned duplicate creates.
lib/codex-manager/statusline-order.ts 19 Duplicate of reorderStatuslineField in settings-panels.ts (the live, tested copy used by settings-hub/index.ts).
lib/runtime/account-health-check.ts 43 Its clampRuntimeActiveIndices is declared as an injected dependency type in account-check.ts, but the real wiring in index.ts:3126 injects clampActiveIndices from elsewhere; this copy is never used.
lib/runtime/oauth-browser-flow.ts 55 Superseded by runtime/browser-oauth-flow.ts / runtime/manual-oauth-flow.ts (the pair index.ts and lib/AGENTS.md actually use).
lib/runtime/session-affinity.ts 26 ensureRuntimeSessionAffinity has no callers; rotation code constructs SessionAffinityStore from lib/session-affinity.ts directly.

Also drops the now-stale runtime/session-affinity.ts row from the lib/AGENTS.md structure tree (none of the other four appears in any doc).

The candidates came from a local knip run, but each was then hand-verified independently — knip's default config here has known false positives (it flags lib/index.ts, the package main, as unused), so nothing else from its list was acted on. Wiring knip into CI remains tracked in #558 as a maintainer decision; this PR only deletes the hand-confirmed subset.

Validation

  • npm run typecheck clean after deletion (also covers the root index.ts plugin-host entry, which is how the live oauth-flow/account-check modules are reached)
  • npm test -- test/documentation.test.ts test/settings-panels.test.ts test/runtime-account-check.test.ts — the only failure is the pre-existing beta.2 docs-portal drift on main that fix: sync plugin manifest and docs portal to v2.3.0-beta.2 #577 fixes; it fails identically before this change
  • Re-ran knip: all five files gone from its unused-files list; remaining entries are the known false positives / maintainer-decision items
  • npm run lint / npm run build full passes deferred to CI; no source file was modified, only deleted

Docs and Governance Checklist

  • lib/AGENTS.md structure tree updated (only doc that referenced a deleted file)
  • No user-visible behavior changed; no command/setting/path surface touched

Risk and Rollback

  • Risk level: low — pure deletion of modules with zero importers; typecheck proves nothing in the compile graph referenced them. No deleted file had a dedicated test, so no coverage is lost.
  • Rollback plan: git revert the single commit restores all five files verbatim.

Additional Notes

  • scripts/install-codex-auth.js and the remaining knip "unused" entries were deliberately left alone: the installer has dedicated tests and a tsconfig.scripts.json entry (maintainer call), and the rest are entry-point false positives.

https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB

None of these files is imported anywhere in the repo (verified by
whole-repo reference search incl. scripts' dynamic dist imports,
package.json export subpaths, vendor/, and the plugin manifest):

- lib/codex-manager/forecast-report-commands.ts (625 LOC): superseded
  by commands/forecast.ts + commands/report.ts, which the dispatcher
  imports. The dead copy was still being patched in parallel (#502,
  #506) - exactly the drift hazard an orphaned duplicate creates.
- lib/codex-manager/statusline-order.ts: duplicate of
  reorderStatuslineField in settings-panels.ts (the live, tested one).
- lib/runtime/account-health-check.ts: clampRuntimeActiveIndices is
  never wired into account-check.ts's injected deps by any caller.
- lib/runtime/oauth-browser-flow.ts: superseded by
  browser-oauth-flow.ts / manual-oauth-flow.ts.
- lib/runtime/session-affinity.ts: ensureRuntimeSessionAffinity has no
  callers; rotation code constructs SessionAffinityStore directly.

Also drops the stale runtime/session-affinity.ts row from the
lib/AGENTS.md structure tree.

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 39 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: bdabe61d-3370-407e-93d3-781feac1848c

📥 Commits

Reviewing files that changed from the base of the PR and between b566656 and 425ab4b.

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

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 commented Jun 10, 2026

Copy link
Copy Markdown
Owner Author

Closing as a duplicate: an open-PR sweep showed #554 (claude/audit-37-dead-code, from the earlier audit line) already deletes all five of these files plus lib/recovery/index.ts and lib/storage/restore.ts, which this PR had excluded based on grep matches that turned out to be near-name false positives (restore-assessment.js, the root lib/recovery.js facade). Re-verified precisely: nothing on main imports either file, so #554's seven-file set is the correct, complete deletion.

The one thing this PR had that #554 lacked — dropping the stale runtime/session-affinity.ts row from the lib/AGENTS.md structure tree — has been pushed to #554 as 325869c, and #554's branch typechecks clean with it. Please prefer #554.


Generated by Claude Code

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