chore: delete dead code unreachable from production#1775
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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/andinternal/entireclient/repocreds/) and various unreferenced helpers acrossstrategy,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 integrationby moving a helper out of a_test.gofile 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
marked this pull request as ready for review
July 20, 2026 08:54
pjbgf
approved these changes
Jul 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 frommain), cross-checked with-testand-tags e2e/-tags integrationruns 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 importersinternal/entireclient/repocreds/— onlySafetyMarginwas consumed; moved intocmd/git-remote-entire(its sole consumer) astokenSafetyMarginNever-wired plumbing
logging/context.gosession/parent/toolcall context helpers — values were set nowhere in prod and the accessors were unused (the logger reads keys directly); kept prod-usedWithComponent/WithAgentand simplifiedattrsFromContextstrategy.ListOrphanedSessionStates+ grace period — orphan filtering thatentire cleannever runs (it usesListAllItems)strategy.PromptOverwriteNewerLogs/StatusToText— resume's overwrite prompt flow, superseded by keep-by-default +--forceLegacy siblings of canonical APIs
discovery.SaveCache,settings.SaveClonePreferences— non-atomic siblings of theModify*APIs; tests migrated toModify*paths.CheckpointPath— already-deprecated wrapper ofid.CheckpointID.Path()No callers anywhere (not even tests)
httputil.BufferRequestBody/BodyReader,tokenstore.ClusterKeyringService/KeyringServiceForIssuerKey,e2e/testutil.AssertCheckpointsOnRemoteMisc test-only-alive
strategy:HardResetWithProtection,IsAncestorOf,ExtractInProgressTodo,sessionStateFilecli:ExtractTodoContentFromToolInput,resumeSingleSessionwrapper (test now targetsrestoreSingleSessiondirectly),runGitHubBootstrapWithmoved into its test filetrailers.FormatMetadata,execx.Interactive,investigate.StateStore.ClearBonus fixes
go build -tags integrationwas broken:integration_test/backend.go(non-test file) calledfileExistsOnRemoteBranchdefined in a_test.gofile. Helper moved intobackend.go.HardResetWithProtectionandhard_reset_test.goupdated.Kept deliberately
*ForTest/*ForTestingseams and cache-reset helpers (test isolation),checkpoint.Register+fsstore(documented reference backend for the pluggable seam),contexts.Saveandtrailers.FormatCheckpoint(fixture primitives with 30+/10+ test call sites),String()methods (fmtreaches them via reflection — deadcode false-positive class),MermaidDiagram(used by thego:generatediagram script).Test plan
golangci-lint run ./...(v2.11.3): 0 issuesmise run test: 8,014 tests — 13 failures are pre-existing (TestExplainCmd_SummaryTimeoutSecondsValidationfails identically on clean main; tokenstoreTestLoosePermsWarnWriter_DefaultsToStderris parallel-pollution, passes in isolation)mise run test:integration: 436 passmise run test:e2e:canary(Vogon): 117 passgo build -tags integration ./...now compiles (was broken on main)deadcodererun: 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/andinternal/entireclient/repocreds/;git-remote-entirenow defines its owntokenSafetyMargininstead of importingrepocreds.SafetyMargin.CLI/strategy cleanup: Drops unused resume helpers (
resumeSingleSession,PromptOverwriteNewerLogs/StatusToText), orphan-session listing (ListOrphanedSessionStates+ grace period),HardResetWithProtection/IsAncestorOf, todo/trailer helpers, and non-atomicSaveClonePreferences/discovery.SaveCache(tests useModify*).Logging & exec: Strips session/parent/tool-call context helpers from
logging(keeps component/agent); removesexecx.Interactive.Tests & docs: Moves or deletes matching tests; fixes integration build by moving
fileExistsOnRemoteBranchintointegration_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.