chore(app-api): remove dead sessions/services/metadata.py duplicate - #1092
Merged
Conversation
Left over from #200. Every runtime consumer already imports apis.shared.sessions.metadata; the copy still wrote the legacy rotating S#ACTIVE# session sort key that the SessionRecencyIndex (GSI4) listing cannot see. Repoint test_cache_savings.py and three spec citations. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Summary
backend/src/apis/app_api/sessions/services/metadata.pywas a 1060-line near-verbatim copy ofbackend/src/apis/shared/sessions/metadata.py, left behind by #200. This PR verifies it is unreachable and deletes it.Why it matters beyond tidiness: the duplicate still wrote the legacy rotating session sort key (
S#ACTIVE#{last_message_at}#{session_id}/S#DELETED#…), which the shared module migrated away from in #175. Any code path that reached it would have written rows invisible to theSessionRecencyIndex(GSI4) listing.docs/specs/session-metadata-static-sort-key.mdalready called it a dead duplicate.Verification that it was dead
app_api.sessions.services.metadata,services.metadata,from .metadata,services/metadata→ only the five call sites intest_cache_savings.py.stream_coordinator.py,quota/checker.py,display_text.py, chat/admin/session routes all importapis.shared.sessions.metadata.importlib/import_module/__import__hit in the repo (incl.backend/src/lambdas/,backend/scripts/, workflows, Dockerfiles) is unrelated. No string-path reference anywhere.sessions/services/__init__.pyis empty;sessions/__init__.pyexports onlyrouter._update_cost_summary_asynchas an identical signature; the shared version additionally has the_coerce_cost_totalhelper andor 0guards forNonecache pricing.Changes
backend/src/apis/app_api/sessions/services/metadata.pybackend/src/apis/app_api/sessions/tests/test_cache_savings.pyatapis.shared.sessions.metadata. The existingpatch('apis.shared.storage.get_metadata_storage')needed no change since both copies import the storage factory lazily inside the function.agent-marketplace.mdhad a real relative link to the deleted file;gpt-5-6-prompt-caching.mdandquota-cooldown-windows.mdcited line numbers). Repointed to the shared module.Test plan
uv run pytest src/apis/app_api/sessions/tests/ tests/costs/→ 220 passeduv run pytest tests/(the CI command) → 8345 passed, 3 skippedpython -c "import apis.app_api.sessions.services.metadata"→ModuleNotFoundErrorNote for reviewers
test_cache_savings.pylives undersrc/, and bothpytest.iniandpyproject.tomlsettestpaths = tests, so it is not collected in CI today (nor are the other in-src/test dirs). It passes locally by explicit path. Moving it tobackend/tests/costs/would get it into CI now that it exercises the shared module; left out of this PR as a scope expansion.🤖 Generated with Claude Code