You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .agents/skills/charges/SKILL.md
+35Lines changed: 35 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,8 @@ Primary packages:
32
32
33
33
`openmeter/billing/charges` is the root facade for charge operations.
34
34
35
+
Charge-backed invoicing no longer relies on a charges-side `InvoicePendingLines(...)` wrapper. Billing owns invoice creation and dispatches gathering lines by `billing.LineEngineType`, while charge packages provide charge-specific line engines where needed.
36
+
35
37
Important layers:
36
38
37
39
-`charges.Service`
@@ -70,6 +72,34 @@ Important types:
70
72
-`MeterValue`
71
73
-`Totals`
72
74
75
+
## Billing Line Engines
76
+
77
+
Charge-backed gathering lines must carry the correct billing line engine when they are created.
78
+
79
+
Current engine values:
80
+
81
+
-`billing.LineEngineTypeChargeFlatFee`
82
+
-`billing.LineEngineTypeChargeUsageBased`
83
+
-`billing.LineEngineTypeChargeCreditPurchase`
84
+
85
+
Current implementations:
86
+
87
+
- flat fee line engine: `openmeter/billing/charges/flatfee/lineengine`
88
+
- credit purchase line engine: `openmeter/billing/charges/creditpurchase/lineengine`
89
+
90
+
Important rules:
91
+
92
+
- do not rely on billing to infer a charge-backed engine from `ChargeID`
93
+
-`billing/service.CreatePendingInvoiceLines(...)` rejects charge-backed gathering lines with empty `Engine`
94
+
- production wiring must register charge line engines through `billing.Service.RegisterLineEngine(...)`
95
+
- charge test setups must also register those engines explicitly; keep this in `openmeter/billing/charges/testutils`
96
+
- if a charge create path stamps a new `LineEngineType`, app wiring and charge test wiring must register a matching implementation in the same change
97
+
98
+
Operational consequence:
99
+
100
+
- adding a new charge engine enum without a registered implementation causes invoice collection to fail when billing resolves the line engine
101
+
- a schema migration defaulting old persisted rows to `invoicing` is not enough for charge-backed lines; existing persisted gathering lines may need a backfill if they should route to a charge engine after rollout
102
+
73
103
## Timestamp Normalization
74
104
75
105
Charge persistence assumes timestamp precision is bounded by streaming aggregation precision.
@@ -159,6 +189,11 @@ Placement guidance:
159
189
160
190
This means a newly created credit-only charge (usage-based or flat fee) that is eligible for immediate activation will be returned as `active` (or `final`) from `Create(...)` itself.
161
191
192
+
For invoice-settled charges:
193
+
194
+
- flat fee and credit purchase creation now stamp the gathering line engine in their type-specific `Create(...)` flows
195
+
- usage-based charge creation also stamps `LineEngineTypeChargeUsageBased`; do not introduce this discriminator unless a corresponding billing engine exists or the path is intentionally blocked
0 commit comments