Skip to content

TASK-0000: ✨ Add durable ingestion billing outbox - #13

Closed
finnp wants to merge 1 commit into
interloom:mainfrom
finnp:task-0000-r2r-billing-outbox
Closed

finnp wants to merge 1 commit into
interloom:mainfrom
finnp:task-0000-r2r-billing-outbox

Conversation

@finnp

@finnp finnp commented Aug 19, 2026

Copy link
Copy Markdown

Summary

  • accept an Interloom billing context containing a stable ingestion ID, organization, and file or note attribution
  • persist a pending billing event before each asynchronous LiteLLM completion, embedding, or transcription request and complete it with normalized token usage
  • propagate billing identifiers into LiteLLM spend-log metadata for reconciliation
  • deliver completed events at least once through a leased, retrying Postgres outbox using a service-authenticated callback
  • preserve billing context through both simple and Hatchet ingestion workflows

Callback contract

Set R2R_BILLING_CALLBACK_URL and R2R_BILLING_CALLBACK_SERVICE_TOKEN. Delivery uses POST with the il-service-token header. Events are versioned with schema_version: 1 and deduplicated by billing_event_id on the receiver.

Verification

  • pytest tests/unit/test_billing.py tests/unit/app/test_routes.py -q --no-cov (34 passed)
  • ruff check core tests/unit/test_billing.py
  • ruff format --check core tests/unit/test_billing.py
  • scoped mypy with --follow-imports=skip (8 changed source files)

The repository-wide unit run reaches existing database-backed tests that require a local test Postgres; targeted route and billing suites are green.

@finnp finnp closed this by deleting the head repository Aug 31, 2026
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