Skip to content

chore(app-api): remove dead sessions/services/metadata.py duplicate - #1092

Merged
philmerrell merged 1 commit into
developfrom
chore/remove-dead-app-api-metadata
Sep 13, 2026
Merged

chore(app-api): remove dead sessions/services/metadata.py duplicate#1092
philmerrell merged 1 commit into
developfrom
chore/remove-dead-app-api-metadata

Conversation

@philmerrell

Copy link
Copy Markdown
Contributor

Summary

backend/src/apis/app_api/sessions/services/metadata.py was a 1060-line near-verbatim copy of backend/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 the SessionRecencyIndex (GSI4) listing. docs/specs/session-metadata-static-sort-key.md already called it a dead duplicate.

Verification that it was dead

  • Importers: repo-wide grep for app_api.sessions.services.metadata, services.metadata, from .metadata, services/metadata → only the five call sites in test_cache_savings.py. stream_coordinator.py, quota/checker.py, display_text.py, chat/admin/session routes all import apis.shared.sessions.metadata.
  • Dynamic imports: every importlib / import_module / __import__ hit in the repo (incl. backend/src/lambdas/, backend/scripts/, workflows, Dockerfiles) is unrelated. No string-path reference anywhere.
  • Re-exports: sessions/services/__init__.py is empty; sessions/__init__.py exports only router.
  • Symbols: every top-level def in the app_api copy has a same-named counterpart in the shared copy. _update_cost_summary_async has an identical signature; the shared version additionally has the _coerce_cost_total helper and or 0 guards for None cache pricing.

Changes

  • Delete backend/src/apis/app_api/sessions/services/metadata.py
  • Repoint the five imports in backend/src/apis/app_api/sessions/tests/test_cache_savings.py at apis.shared.sessions.metadata. The existing patch('apis.shared.storage.get_metadata_storage') needed no change since both copies import the storage factory lazily inside the function.
  • Fix three spec citations that would have dangled (agent-marketplace.md had a real relative link to the deleted file; gpt-5-6-prompt-caching.md and quota-cooldown-windows.md cited line numbers). Repointed to the shared module.

Test plan

  • uv run pytest src/apis/app_api/sessions/tests/ tests/costs/ → 220 passed
  • uv run pytest tests/ (the CI command) → 8345 passed, 3 skipped
  • python -c "import apis.app_api.sessions.services.metadata"ModuleNotFoundError

Note for reviewers

test_cache_savings.py lives under src/, and both pytest.ini and pyproject.toml set testpaths = 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 to backend/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

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>
@philmerrell
philmerrell merged commit f7be395 into develop Sep 13, 2026
6 checks passed
@philmerrell
philmerrell deleted the chore/remove-dead-app-api-metadata branch September 13, 2026 19:05
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