Skip to content

chore: delete dead code unreachable from production#1775

Merged
gtrrz-victor merged 2 commits into
mainfrom
chore/delete-dead-code
Jul 20, 2026
Merged

chore: delete dead code unreachable from production#1775
gtrrz-victor merged 2 commits into
mainfrom
chore/delete-dead-code

Conversation

@gtrrz-victor

@gtrrz-victor gtrrz-victor commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

https://entire.io/gh/entireio/cli/trails/900

Summary

Deletes code with no production callers — 2,340 lines removed across 51 files. Found via golang.org/x/tools/cmd/deadcode (whole-program reachability from main), cross-checked with -test and -tags e2e/-tags integration runs plus per-symbol greps, so test-only-alive code is included per the "used only by tests = dead" rule.

Deleted

Whole packages

  • cmd/entire/cli/lockfile/ — zero production importers
  • internal/entireclient/repocreds/ — only SafetyMargin was consumed; moved into cmd/git-remote-entire (its sole consumer) as tokenSafetyMargin

Never-wired plumbing

  • logging/context.go session/parent/toolcall context helpers — values were set nowhere in prod and the accessors were unused (the logger reads keys directly); kept prod-used WithComponent/WithAgent and simplified attrsFromContext
  • strategy.ListOrphanedSessionStates + grace period — orphan filtering that entire clean never runs (it uses ListAllItems)
  • strategy.PromptOverwriteNewerLogs / StatusToText — resume's overwrite prompt flow, superseded by keep-by-default + --force

Legacy siblings of canonical APIs

  • discovery.SaveCache, settings.SaveClonePreferences — non-atomic siblings of the Modify* APIs; tests migrated to Modify*
  • paths.CheckpointPath — already-deprecated wrapper of id.CheckpointID.Path()

No callers anywhere (not even tests)

  • httputil.BufferRequestBody/BodyReader, tokenstore.ClusterKeyringService/KeyringServiceForIssuerKey, e2e/testutil.AssertCheckpointsOnRemote

Misc test-only-alive

  • strategy: HardResetWithProtection, IsAncestorOf, ExtractInProgressTodo, sessionStateFile
  • cli: ExtractTodoContentFromToolInput, resumeSingleSession wrapper (test now targets restoreSingleSession directly), runGitHubBootstrapWith moved into its test file
  • trailers.FormatMetadata, execx.Interactive, investigate.StateStore.Clear

Bonus fixes

  • go build -tags integration was broken: integration_test/backend.go (non-test file) called fileExistsOnRemoteBranch defined in a _test.go file. Helper moved into backend.go.
  • CLAUDE.md / agent-guide.md references to the deleted HardResetWithProtection and hard_reset_test.go updated.

Kept deliberately

*ForTest/*ForTesting seams and cache-reset helpers (test isolation), checkpoint.Register + fsstore (documented reference backend for the pluggable seam), contexts.Save and trailers.FormatCheckpoint (fixture primitives with 30+/10+ test call sites), String() methods (fmt reaches them via reflection — deadcode false-positive class), MermaidDiagram (used by the go:generate diagram script).

Test plan

  • golangci-lint run ./... (v2.11.3): 0 issues
  • mise run test: 8,014 tests — 13 failures are pre-existing (TestExplainCmd_SummaryTimeoutSecondsValidation fails identically on clean main; tokenstore TestLoosePermsWarnWriter_DefaultsToStderr is parallel-pollution, passes in isolation)
  • mise run test:integration: 436 pass
  • mise run test:e2e:canary (Vogon): 117 pass
  • go build -tags integration ./... now compiles (was broken on main)
  • deadcode rerun: 234 → 193 findings; remainder is the intentional keeps above

🤖 Generated with Claude Code


Note

Medium Risk
Large deletion surface could hide a false-positive deadcode cut; integration build fix and settings migration reduce but do not eliminate that risk.

Overview
This PR removes ~2,300 lines of dead code identified via whole-program reachability (including symbols only kept alive by tests).

Whole packages and auth plumbing: Deletes lockfile/ and internal/entireclient/repocreds/; git-remote-entire now defines its own tokenSafetyMargin instead of importing repocreds.SafetyMargin.

CLI/strategy cleanup: Drops unused resume helpers (resumeSingleSession, PromptOverwriteNewerLogs / StatusToText), orphan-session listing (ListOrphanedSessionStates + grace period), HardResetWithProtection / IsAncestorOf, todo/trailer helpers, and non-atomic SaveClonePreferences / discovery.SaveCache (tests use Modify*).

Logging & exec: Strips session/parent/tool-call context helpers from logging (keeps component/agent); removes execx.Interactive.

Tests & docs: Moves or deletes matching tests; fixes integration build by moving fileExistsOnRemoteBranch into integration_test/backend.go; updates CLAUDE.md / agent-guide to drop references to deleted hard-reset helpers.

Reviewed by Cursor Bugbot for commit 8bfb18f. Configure here.

Remove code with no production callers, found via golang.org/x/tools/cmd/deadcode
(reachability from main, cross-checked with -test and -tags e2e/integration runs):

- lockfile package: no production importer
- repocreds package: only SafetyMargin was used; moved it into
  git-remote-entire (its sole consumer) as tokenSafetyMargin
- logging/context.go: session/parent/toolcall context plumbing never wired
  into production logging; kept WithComponent/WithAgent which are used
- httputil: BufferRequestBody, BodyReader (no callers anywhere)
- tokenstore: ClusterKeyringService, KeyringServiceForIssuerKey (no callers)
- discovery.SaveCache, settings.SaveClonePreferences: legacy non-atomic
  siblings of the Modify* APIs; tests migrated to Modify*
- strategy: HardResetWithProtection, IsAncestorOf,
  ListOrphanedSessionStates (+ grace period), StatusToText,
  PromptOverwriteNewerLogs, ExtractInProgressTodo, sessionStateFile
- cli: ExtractTodoContentFromToolInput, resumeSingleSession wrapper,
  runGitHubBootstrapWith moved into its test file
- trailers.FormatMetadata, paths.CheckpointPath (deprecated wrapper),
  execx.Interactive, investigate StateStore.Clear
- e2e/testutil: AssertCheckpointsOnRemote (no callers under any tag)

Also fixes 'go build -tags integration': fileExistsOnRemoteBranch moved
from a _test.go file into backend.go, which referenced it from non-test code.

Kept deliberately: *ForTest/*ForTesting seams, cache-reset helpers,
checkpoint.Register + fsstore (documented reference backend for the
pluggable seam), contexts.Save and trailers.FormatCheckpoint (widely used
test fixture primitives), String() methods (fmt reflection), and
MermaidDiagram (go:generate).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 16, 2026 12:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes dead/unreachable Go code across the CLI and supporting packages, based on whole-program reachability from main, and updates the remaining code/tests/docs to align with the deletions (including an integration build fix in the test harness).

Changes:

  • Deletes unused packages/APIs (notably lockfile/ and internal/entireclient/repocreds/) and various unreferenced helpers across strategy, logging, httputil, and test utilities.
  • Migrates callers/tests off legacy “Save*” helpers to the atomic Modify* APIs (discovery.ModifyCache, settings.ModifyClonePreferences) and removes deprecated wrappers (e.g., paths.CheckpointPath).
  • Fixes go build -tags integration by moving a helper out of a _test.go file into the integration test backend support code.

Reviewed changes

Copilot reviewed 51 out of 51 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/entireclient/tokenstore/tokenstore.go Removes unused keyring service helper(s).
internal/entireclient/repocreds/repocreds.go Deletes unused repo-credential exchange/cache package.
internal/entireclient/repocreds/repocreds_test.go Removes tests for deleted repocreds package.
internal/entireclient/httputil/oauth.go Drops unused request-body buffering helpers.
internal/entireclient/discovery/cache.go Removes SaveCache; keeps atomic ModifyCache as the supported path.
internal/entireclient/discovery/cache_test.go Migrates tests to ModifyCache.
e2e/testutil/repo.go Removes unused remote checkpoint assertion helper.
docs/architecture/agent-guide.md Updates docs to remove references to deleted hard-reset regression tests.
cmd/git-remote-entire/jurisdictionauth.go Inlines safety margin constant previously sourced from repocreds.
cmd/entire/cli/trailers/trailers.go Removes unused FormatMetadata helper.
cmd/entire/cli/trailers/trailers_test.go Removes tests for deleted FormatMetadata.
cmd/entire/cli/trail_cmd_test.go Migrates tests from SaveClonePreferences to ModifyClonePreferences.
cmd/entire/cli/strategy/session_state.go Removes unused session-state path helper.
cmd/entire/cli/strategy/session_state_test.go Adjusts tests to construct session-state paths directly.
cmd/entire/cli/strategy/rewind_test.go Removes tests for deleted overwrite-prompt flow.
cmd/entire/cli/strategy/messages.go Removes unused todo extraction helper.
cmd/entire/cli/strategy/messages_test.go Removes tests for deleted todo extraction helper.
cmd/entire/cli/strategy/manual_commit_rewind.go Removes unused interactive overwrite prompt/status formatting helpers.
cmd/entire/cli/strategy/imported_session_test.go Removes orphan-session assertions tied to deleted orphan discovery API.
cmd/entire/cli/strategy/hard_reset_test.go Removes regression tests for deleted HardResetWithProtection.
cmd/entire/cli/strategy/common.go Removes unused git ancestry + hard reset helpers.
cmd/entire/cli/strategy/cleanup.go Removes unused orphan-session listing logic (and grace period).
cmd/entire/cli/strategy/clean_test.go Removes tests tied to deleted orphan-session listing.
cmd/entire/cli/setup_github.go Removes a test-only wrapper from production code.
cmd/entire/cli/setup_github_test.go Moves runGitHubBootstrapWith helper into the test file.
cmd/entire/cli/settings/settings.go Removes SaveClonePreferences legacy API.
cmd/entire/cli/review/cmd_test.go Migrates review tests to ModifyClonePreferences.
cmd/entire/cli/resume.go Removes unused resumeSingleSession wrapper.
cmd/entire/cli/resume_test.go Updates tests to target restoreSingleSession directly.
cmd/entire/cli/paths/paths.go Removes deprecated CheckpointPath wrapper.
cmd/entire/cli/logging/logger.go Simplifies context-attr extraction to component/agent only.
cmd/entire/cli/logging/logger_test.go Updates tests for removed logging context keys (tool/session/parent).
cmd/entire/cli/logging/context.go Deletes unused session/toolcall context helpers; keeps component/agent.
cmd/entire/cli/logging/context_test.go Removes tests for deleted context helpers; keeps attrsFromContext coverage.
cmd/entire/cli/lockfile/lockfile.go Deletes unused lockfile package (portable lock helpers).
cmd/entire/cli/lockfile/lockfile_windows.go Deletes Windows-specific lockfile implementation.
cmd/entire/cli/lockfile/lockfile_unix.go Deletes Unix-specific lockfile implementation.
cmd/entire/cli/lockfile/lockfile_unix_test.go Removes Unix-only lockfile tests.
cmd/entire/cli/lockfile/lockfile_test.go Removes lockfile tests.
cmd/entire/cli/investigate/state.go Removes unused StateStore.Clear.
cmd/entire/cli/investigate/state_test.go Removes tests/coverage for deleted Clear.
cmd/entire/cli/integration_test/remote_operations_test.go Removes helper that was incorrectly referenced from non-test code.
cmd/entire/cli/integration_test/last_checkpoint_id_test.go Updates tests to use CheckpointID.Path() directly.
cmd/entire/cli/integration_test/backend.go Adds fileExistsOnRemoteBranch helper into non-test integration build.
cmd/entire/cli/hooks.go Removes unused todo extraction helper wrapper.
cmd/entire/cli/hooks_test.go Removes tests for deleted todo extraction helper wrapper.
cmd/entire/cli/explain_test.go Inlines FormatMetadata formatting in tests after helper deletion.
cmd/entire/cli/execx/execx.go Removes unused execx.Interactive constructor.
cmd/entire/cli/execx/execx_test.go Removes tests for deleted Interactive helper.
cmd/entire/cli/attach_test.go Migrates test seeding from SaveClonePreferences to ModifyClonePreferences.
CLAUDE.md Updates docs to remove references to deleted hard-reset helpers/tests.

@gtrrz-victor
gtrrz-victor marked this pull request as ready for review July 20, 2026 08:54
@gtrrz-victor
gtrrz-victor requested a review from a team as a code owner July 20, 2026 08:54
@gtrrz-victor
gtrrz-victor merged commit 5c81e13 into main Jul 20, 2026
10 checks passed
@gtrrz-victor
gtrrz-victor deleted the chore/delete-dead-code branch July 20, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants