Skip to content

refactor(inference): remove auto-impression recording, switch to client-side manual submission#67

Merged
marevol merged 1 commit intomainfrom
refactor/remove-inference-auto-impression
Feb 23, 2026
Merged

refactor(inference): remove auto-impression recording, switch to client-side manual submission#67
marevol merged 1 commit intomainfrom
refactor/remove-inference-auto-impression

Conversation

@marevol
Copy link
Collaborator

@marevol marevol commented Feb 23, 2026

Summary

Removes the automatic impression recording that was added in #56. Impression events are now the responsibility of the client, which sends them explicitly via POST /api/v1/conversion_event/ using the request_id returned in the inference response.

Changes Made

Inference service:

  • Deleted inference/inference/impressions.py — entire background recording module
  • Deleted inference/tests/test_impressions.py
  • Removed BackgroundTasks parameter and record_impression call from routes/project.py; request_id generation and response field are preserved
  • Removed inference_auto_record_impressions config setting from config.py
  • Removed ConversionEvent SQLAlchemy model from models.py (inference no longer writes to DB)
  • Removed unused UUID import from models.py

Backend:

  • Updated deduplication comment in ab_test.py view (removed "auto-recorded" wording; dedup logic itself is kept — clients may still send duplicate requests)
  • Added test_create_impression_with_request_id to test_event_views.py
  • Added TestABTestImpressionDeduplication class to test_ab_test_views.py with two cases: same request_id counted once, null request_id each counted individually
  • Added missing _use_locmem_cache fixture to test_ab_test_views.py (pre-existing issue that caused the tests to fail without Redis)

Docs & config (10 files):

  • Updated all descriptions of inference DB access to "read-only"
  • Removed INFERENCE_AUTO_RECORD_IMPRESSIONS from env var docs, .env.example, Helm configmap/values, and CLAUDE.md
  • Rewrote impression recording guidance in docs/guide/ab-testing.md and docs/guide/inference.md

Testing

  • ruff check backend/ inference/ — all passed
  • inference test suite: 24/24 passed
  • backend test suites (event views + A/B test views): 32/32 passed

Breaking Changes

  • INFERENCE_AUTO_RECORD_IMPRESSIONS env var is removed. Clients that relied on auto-recorded impressions must now send them explicitly.

Additional Notes

The request_id is still generated and returned in every /inference/predict/project/{id} response, so clients have everything they need to record impressions with proper deduplication via recommendation_request_id.

…nt-side manual submission

Reverts the auto-impression recording introduced in commit 356a2e9. Instead
of automatically recording impression events in the background on every
project-level prediction, clients are now responsible for explicitly sending
impression events via POST /api/v1/conversion_event/ using the request_id
returned in the inference response.

- Delete inference/inference/impressions.py and its tests
- Remove BackgroundTasks wiring from routes/project.py
- Remove inference_auto_record_impressions config setting
- Remove ConversionEvent SQLAlchemy model (no longer written by inference)
- Update deduplication comment in ab_test.py view
- Add test_create_impression_with_request_id to test_event_views.py
- Add TestABTestImpressionDeduplication tests (same/null request_id cases)
- Add missing _use_locmem_cache fixture to test_ab_test_views.py
- Update all docs and Helm config to reflect read-only inference DB access

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@marevol marevol merged commit c094703 into main Feb 23, 2026
9 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