Skip to content

refactor: move quantity snapshotting to line engine#4746

Merged
turip merged 1 commit into
feat/legacy-split-line-enginefrom
feat/move-quantity-snapshot-to-lineengine
Jul 19, 2026
Merged

refactor: move quantity snapshotting to line engine#4746
turip merged 1 commit into
feat/legacy-split-line-enginefrom
feat/move-quantity-snapshot-to-lineengine

Conversation

@turip

@turip turip commented Jul 18, 2026

Copy link
Copy Markdown
Member

Summary

  • move quantity snapshotting from the billing service into the legacy invoicing line engine
  • construct and inject one legacy line engine instance into billing and subscription sync
  • give the legacy invoice updater a narrow, local QuantitySnapshotter dependency

Motivation

Snapshotting is owned by line engines themselves. Keeping quantity snapshotting with the legacy invoicing line engine makes that ownership explicit and prepares later split-line-group refactors without routing snapshot behavior through the billing service.

Stacked on #4745.

Validation

  • nix develop --impure .#ci -c make test-nocache — 6,156 tests passed, 9 skipped
  • fast Go lint on all changed package trees — 0 issues

Greptile Summary

This PR moves quantity snapshotting into the legacy billing line engine. The main changes are:

  • Adds snapshotting dependencies and methods to the legacy line engine.
  • Shares one legacy line engine between billing and subscription sync.
  • Gives the invoice updater a narrow quantity snapshotter interface.
  • Updates application and test wiring for the new constructors.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.
  • The moved snapshotting logic preserves the previous dependencies, validation, error mapping, and concurrency behavior.
  • Production and test constructors consistently provide the new engine dependency.

Important Files Changed

Filename Overview
openmeter/billing/lineengine/quantitysnapshot.go Moves quantity snapshotting from the billing service to the legacy line engine while preserving validation, metering, and error handling.
openmeter/billing/lineengine/engine.go Adds the feature, streaming, and concurrency dependencies required for engine-owned snapshotting.
openmeter/billing/service/service.go Accepts and registers a preconstructed legacy line engine instead of constructing one around the billing service.
openmeter/billing/worker/subscriptionsync/service/reconciler/invoiceupdater/invoiceupdate.go Replaces the broad billing-service snapshot call with a local quantity snapshotter dependency.
app/common/billing.go Constructs one legacy line engine and injects it into billing and subscription synchronization.

Reviews (1): Last reviewed commit: "refactor: move quantity snapshotting to ..." | Re-trigger Greptile

Context used:

  • Context used - CLAUDE.md (source)
  • Context used - AGENTS.md (source)

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e5a835e8-6c8b-448a-8347-ad0c50177860

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/move-quantity-snapshot-to-lineengine

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@turip
turip merged commit ef935d3 into feat/legacy-split-line-engine Jul 19, 2026
22 of 23 checks passed
@turip
turip deleted the feat/move-quantity-snapshot-to-lineengine branch July 19, 2026 17:27
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