Skip to content

refactor(charges): remove legacy intent override wiring - #4563

Merged
turip merged 1 commit into
mainfrom
feat/remove-legacy-charge-overrides
Jun 24, 2026
Merged

turip merged 1 commit into
mainfrom
feat/remove-legacy-charge-overrides

Conversation

@turip

@turip turip commented Jun 24, 2026 •

Copy link
Copy Markdown
Member

What

Removes the legacy embedded charge intent override runtime wiring from flat-fee and usage-based charges.

This deletes the old domain IntentOverride fields, adapter update/hydration paths, reusable embedded-column override helpers, and tests that asserted the old inline-column behavior.

It also marks the remaining legacy inline override columns as deprecated in Ent while keeping the physical columns in place for compatibility.

Why

The follow-up implementation moves charge intent overrides to type-owned override rows. This PR keeps the compatibility columns physically present, but removes the old runtime API surface first so the replacement PR can focus on the new storage and adapter semantics.

Validation

  • direnv exec . env POSTGRES_HOST=127.0.0.1 go test -count=1 -tags=dynamic ./openmeter/billing/charges/flatfee/... ./openmeter/billing/charges/usagebased/... ./openmeter/billing/charges/models/intentoverride/...
  • direnv exec . env GO_LINT_PATH='./openmeter/billing/charges/flatfee/... ./openmeter/billing/charges/usagebased/... ./openmeter/billing/charges/models/intentoverride/...' make lint-go-fast

@coderabbitai

coderabbitai Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Removes the IntentOverride concept from billing charges entirely. The IntentOverride field is dropped from ChargeBase in both flat-fee and usage-based models; the exported domain types, interfaces, and helper functions are removed from the intentoverride package; adapter/mapper code no longer persists or reads overrides; and all legacy inline override DB columns in the Ent schema mixins are marked as deprecated.

Changes

IntentOverride removal from billing charges

Layer / File(s) Summary
ChargeBase struct and validation cleanup
openmeter/billing/charges/flatfee/charge.go, openmeter/billing/charges/usagebased/charge.go
Removes the IntentOverride field from ChargeBase in both flatfee and usagebased models and drops the corresponding validation branches from Validate().
intentoverride package: remove exported types and deprecate DB columns
openmeter/billing/charges/models/intentoverride/mixin.go, openmeter/billing/charges/models/intentoverride/flatfee.go, openmeter/billing/charges/models/intentoverride/usagebased.go
Removes exported FlatFee and UsageBased structs, generic creator/updater/getter interfaces, and all Create/Update/Map helpers. Introduces legacyInlineOverrideColumnDeprecation and marks all legacy inline override Ent schema columns as deprecated in base, flatfee, and usagebased mixins. Deletes associated integration test suites in flatfee/adapter/intentoverride_test.go and usagebased/adapter/intentoverride_test.go.
Adapter and mapper: stop persisting and reading IntentOverride
openmeter/billing/charges/flatfee/adapter/charge.go, openmeter/billing/charges/flatfee/adapter/mapper.go, openmeter/billing/charges/usagebased/adapter/charge.go, openmeter/billing/charges/usagebased/adapter/mapper.go
Removes intentoverride.UpdateFlatFee/UpdateUsageBased calls from UpdateCharge adapters and strips MapFlatFeeFromDB/MapUsageBasedFromDB calls plus IntentOverride field assignments from both MapChargeBaseFromDB mappers.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • openmeterio/openmeter#4542: Directly conflicts at the code level — this PR adds the flat-fee/usage-based intent override plumbing (fields, mapping, and UpdateCharge calls) in the same adapter/mapper/charge files that the current PR removes.

Suggested labels

release-note/misc, area/billing, kind/refactor

Suggested reviewers

  • tothandras
  • borbelyr-kong
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: removing legacy intent override wiring from charge handling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/remove-legacy-charge-overrides

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 force-pushed the feat/remove-legacy-charge-overrides branch from 5de2f2c to 156e06f Compare June 24, 2026 12:04
@turip
turip marked this pull request as ready for review June 24, 2026 12:04
@turip
turip requested a review from a team as a code owner June 24, 2026 12:04
@turip turip added release-note/misc Miscellaneous changes area/billing labels Jun 24, 2026
@greptile-apps

greptile-apps Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR removes the legacy embedded-column intent override runtime wiring from flat-fee and usage-based charges as an intermediate step before a follow-up PR introduces type-owned override rows.

  • Deletes the IntentOverride fields from both flatfee.ChargeBase and usagebased.ChargeBase, along with all associated OverrideBase, FlatFee, and UsageBased domain structs, their creator/updater/getter interfaces, and the generic helper functions (CreateBase, UpdateBase, MapBaseFromDB, etc.) in the intentoverride package.
  • Removes intentoverride.UpdateFlatFee and intentoverride.UpdateUsageBased calls from UpdateCharge, and removes MapFlatFeeFromDB/MapUsageBasedFromDB calls from the mapper functions, so the override_* DB columns are no longer read or written at runtime. The columns are marked Deprecated in the ent schema and removed from the default Columns list (but kept in ValidColumn), keeping the physical columns intact for the follow-up migration.

Confidence Score: 5/5

Safe to merge; the changes are a clean, intentional removal of an API surface with no new logic introduced.

All changes are deletions of the old inline-column override path. The adapter no longer writes or reads the override_* columns, the domain structs no longer carry the IntentOverride field, and the ent schema marks those columns as deprecated while keeping them physically present. Any existing override data in the DB columns is left frozen (neither read nor overwritten), which is the stated intent before the follow-up PR introduces type-owned override rows. The generated ent/db files correctly move the deprecated field names out of the default Columns list while keeping them in ValidColumn. The deleted test suites covered exactly the behavior being removed. No new logic paths are introduced.

No files require special attention. The ent/db generated files are consistent with the schema changes, and the adapter/mapper removals are symmetric between flat-fee and usage-based charge types.

Important Files Changed

Filename Overview
openmeter/billing/charges/models/intentoverride/mixin.go Removes all domain types (OverrideBase, BaseCreator/Updater/Getter, helper functions) and adds Deprecated annotations + legacyInlineOverrideColumnDeprecation constant to all remaining ent schema fields.
openmeter/billing/charges/models/intentoverride/flatfee.go Removes FlatFee struct and all FlatFeeCreator/Updater/Getter interfaces and helpers; adds Deprecated annotation to remaining mixin fields. PercentageDiscountsOverride is retained as it is still referenced by the ent DB struct.
openmeter/billing/charges/models/intentoverride/usagebased.go Removes UsageBased struct and all UsageBasedCreator/Updater/Getter interfaces and helpers; adds Deprecated annotations to remaining mixin fields.
openmeter/billing/charges/flatfee/charge.go Removes IntentOverride *intentoverride.FlatFee field from ChargeBase and its Validate() guard; clean removal with no lingering references.
openmeter/billing/charges/usagebased/charge.go Removes IntentOverride *intentoverride.UsageBased field from ChargeBase and its Validate() guard; mirrors the flat-fee change symmetrically.
openmeter/billing/charges/flatfee/adapter/charge.go Removes intentoverride.UpdateFlatFee call from UpdateCharge; override columns are now left untouched in the DB on every update.
openmeter/billing/charges/usagebased/adapter/charge.go Removes intentoverride.UpdateUsageBased call from UpdateCharge; mirrors the flat-fee adapter change.
openmeter/billing/charges/flatfee/adapter/mapper.go Removes MapFlatFeeFromDB call and IntentOverride field assignment from MapChargeBaseFromDB; override data in DB columns is now silently ignored on reads.
openmeter/billing/charges/usagebased/adapter/mapper.go Removes MapUsageBasedFromDB call and IntentOverride field assignment from MapChargeBaseFromDB; mirrors the flat-fee mapper change.
openmeter/ent/db/chargeflatfee/chargeflatfee.go Generated: removes 17 override fields from default Columns slice; adds them to ValidColumn via a separate loop, keeping them recognizable for predicate/ordering use without including them in default SELECTs.
openmeter/ent/db/chargeusagebased/chargeusagebased.go Generated: removes 15 override fields from default Columns slice; adds them to ValidColumn via a separate loop, mirroring the flat-fee change.
openmeter/ent/db/chargeflatfee.go Generated: adds Deprecated doc comments to all 17 override struct fields; fields remain in place for DB compatibility.
openmeter/ent/db/chargeusagebased.go Generated: adds Deprecated doc comments to all 15 override struct fields; mirrors the flat-fee entity change.
openmeter/billing/charges/flatfee/adapter/intentoverride_test.go Deleted: 342-line integration test suite covering inline-column override read/write/clear behavior; removal is consistent with the removed adapter code.
openmeter/billing/charges/usagebased/adapter/intentoverride_test.go Deleted: 343-line integration test suite for usage-based inline-column overrides; removal mirrors the flat-fee test deletion.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    subgraph Before["Before (removed by this PR)"]
        A1[UpdateCharge / CreateCharge] --> B1[intentoverride.UpdateFlatFee / UpdateUsageBased]
        B1 --> C1[Write override_* columns in DB]
        D1[GetByID / GetByIDs] --> E1[MapFlatFeeFromDB / MapUsageBasedFromDB]
        E1 --> F1[ChargeBase.IntentOverride populated]
    end

    subgraph After["After"]
        A2[UpdateCharge / CreateCharge] --> B2[chargemeta update only]
        B2 --> C2[override_* columns untouched in DB]
        D2[GetByID / GetByIDs] --> E2[MapChargeBaseFromDB - no override mapping]
        E2 --> F2[ChargeBase has no IntentOverride field]
    end

    subgraph Schema["DB Schema - unchanged"]
        G[override_* columns physically present\nMarked Deprecated in ent schema\nRemoved from default Columns list\nStill valid in ValidColumn]
    end

    C2 -.->|columns frozen| G
    Before -.->|replaced by| After
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    subgraph Before["Before (removed by this PR)"]
        A1[UpdateCharge / CreateCharge] --> B1[intentoverride.UpdateFlatFee / UpdateUsageBased]
        B1 --> C1[Write override_* columns in DB]
        D1[GetByID / GetByIDs] --> E1[MapFlatFeeFromDB / MapUsageBasedFromDB]
        E1 --> F1[ChargeBase.IntentOverride populated]
    end

    subgraph After["After"]
        A2[UpdateCharge / CreateCharge] --> B2[chargemeta update only]
        B2 --> C2[override_* columns untouched in DB]
        D2[GetByID / GetByIDs] --> E2[MapChargeBaseFromDB - no override mapping]
        E2 --> F2[ChargeBase has no IntentOverride field]
    end

    subgraph Schema["DB Schema - unchanged"]
        G[override_* columns physically present\nMarked Deprecated in ent schema\nRemoved from default Columns list\nStill valid in ValidColumn]
    end

    C2 -.->|columns frozen| G
    Before -.->|replaced by| After
Loading

Reviews (1): Last reviewed commit: "refactor(charges): remove legacy intent ..." | Re-trigger Greptile

@turip
turip merged commit e134c32 into main Jun 24, 2026
26 of 30 checks passed
@turip
turip deleted the feat/remove-legacy-charge-overrides branch June 24, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants