Skip to content

chore: remove unused backend code - #5

Merged
skrishnan22 merged 1 commit into
mainfrom
codex/backend-spring-clean
Jul 16, 2026
Merged

skrishnan22 merged 1 commit into
mainfrom
codex/backend-spring-clean

Conversation

@skrishnan22

Copy link
Copy Markdown
Owner

Summary

  • remove zero-reference backend declarations, stale compatibility wrappers, deprecated aliases, and compiler-detectable residue
  • consolidate repeated record checks, admin console output helpers, and Worker SQL statement types
  • update shared projection and sandbox preview consumers to use the canonical APIs
  • remove stale CLI guard flags from help output and add regression coverage

Why

A backend-wide spring-clean audit found unused exports, test-only compatibility APIs, duplicated helpers, and stale command documentation. Removing them reduces maintenance surface without changing supported runtime behavior. Cleanup already covered by PR #2 was intentionally excluded.

Impact

This removes 196 net lines across the backend and related consumer tests. Private compatibility exports are removed in favor of their existing canonical replacements.

Validation

  • pnpm typecheck
  • pnpm test - 972 tests passed
  • git diff --cached --check

@skrishnan22
skrishnan22 marked this pull request as ready for review July 16, 2026 13:51
@greptile-apps

greptile-apps Bot commented Jul 16, 2026

Copy link
Copy Markdown

Greptile Summary

This PR is a backend-wide cleanup that removes 196 net lines of dead code: unused exports, duplicated helpers, deprecated type aliases, and test-only compatibility wrappers. All consumer call sites are updated to use the canonical APIs.

  • Consolidation: Output/createConsoleOutput/safeErrorMessage are extracted to a new console-output.ts; the duplicated SqlStatement interface across memberships.ts, session-directory.ts, and workspace-cache.ts is consolidated into a new sql.ts; three local isRecord helpers are replaced with the shared canonical version from @codevil/shared.
  • Dead code removal: mapAgentEventToChat (always returned []), projectEvent/projectEvents (superseded by applyToChatActivity), deprecated EmittedSpan/EmittedLog type aliases, setParseFailureSink, detectPreviewCommand (compat wrapper over detectPreviewApps), fakePreviewServer (test helper), and the always-empty workspaceBackupExcludes are removed; the unused token parameter is dropped from validatePreviewAccess.
  • Tests: Regression coverage added for the CLI usage string, and existing tests migrated to the canonical applyToChatActivity and detectPreviewApps APIs.

Confidence Score: 5/5

Every removed function was either dead code, a compatibility re-export, or a duplicated helper replaced by an identical canonical version. No runtime behavior changes in production paths.

The cleanup is narrow and mechanical: new canonical files replace exact duplicates, mapAgentEventToChat was provably always returning [], validatePreviewAccess never read its token argument, and the shared isRecord matches the stricter local variant it replaced. The typecheck and 972 passing tests leave no suspicious gap.

No files require special attention. The projection and preview-manager changes are the most structurally significant but are fully covered by updated tests.

Important Files Changed

Filename Overview
packages/admin-cli/src/console-output.ts New file that centralizes the Output interface, createConsoleOutput factory, and safeErrorMessage helper, eliminating two duplicate definitions.
packages/worker/src/sql.ts New canonical home for SqlStatement interface, previously duplicated in three files; all consumer files updated to import from here.
packages/shared/src/projections.ts Removes ProjectedSessionView, projectEvent, and projectEvents batch helpers; all call sites migrated to applyToChatActivity.
packages/shared/src/projection-chat.ts Removes mapAgentEventToChat (every branch returned []) and inlines return [] — semantically identical.
packages/shared/src/wire-parsing.ts Removes setParseFailureSink and makes failureSink const; no caller was overriding it.
packages/shared/src/observability.ts Removes deprecated EmittedSpan/EmittedLog aliases and the never-read _kind private field; span_kind is still emitted via _builder.
packages/sandbox-image/src/preview-manager.ts Removes detectPreviewCommand compat wrapper and fakePreviewServer test helper; Next.js readinessTimeoutMs is preserved in appToCommand.
packages/worker/src/orchestrator/preview.ts Drops unused token parameter from validatePreviewAccess; token hash validation still occurs in proxyPreviewRequest.
packages/worker/src/workspace-cache.ts Removes workspaceBackupExcludes (always returned []) and restoreLatestWorkspaceCacheForSandbox.
packages/sandbox-image/test/runtime.test.mjs Migrates detectPreviewCommand tests to detectPreviewApps with correct PreviewApp shape assertions.
packages/cli/src/args.ts Removes parsePositiveInteger and strips --max-cost/--max-steps from usage string; new test confirms absence.
packages/worker/src/integrations/slack/actions.ts Replaces local isRecord (excluded arrays) with canonical shared version which also excludes arrays — semantically identical.

Reviews (1): Last reviewed commit: "chore: remove unused backend code" | Re-trigger Greptile

@skrishnan22
skrishnan22 merged commit cc5aafd into main Jul 16, 2026
3 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.

1 participant