@drawbridge/drawbridge-agents 0.1.25 → 0.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,17 +63,31 @@ skill) so it stops living only in tribal memory.
63
63
 
64
64
  ## Billing / metering
65
65
 
66
- - Meter events are **single-writer**: true-ups are `billing.trueup` ledger rows, never meter
67
- events. A true-up written as a meter event in-window corrupts the reflection poll and strands
68
- units unbillable.
69
- - **Upgrade mechanics and the billing path are one contract**: drawbridge-stripe's upgrade
70
- (`subscription.change`) swaps the metered actions price in place, and classic-mode Stripe then
71
- ignores meter events on that closing cycle invoice entirelyso drawbridge-sync's
72
- `settleCycleUsage` bills upgrade-truncated invoices (actions line starts >60s after
73
- `period_start`) as plain invoice items priced from plans.js instead of the meter. Changing the
74
- upgrade mechanic (schedules, cycle-anchor reset, `billing_mode=flexible`) or the metering path
75
- without re-checking the other side silently re-zeroes upgrade-cycle invoices. Detail:
76
- drawbridge-docs `reference/billing.md` § Stripe meter emission.
66
+ - **Actions never touch Stripe's meter.** Every cycle invoice bills the period's ledger count as
67
+ invoice items priced from `plans.js` (drawbridge-sync `settleCycleUsage`). The meter was removed
68
+ after it produced five distinct defects, ending in a 60-second line-window overlap that billed
69
+ one correctly-delivered event twice. Do not reintroduce meter events, and do not "fix" a billing
70
+ discrepancy by reporting usage to Stripe corrections are `billing.trueup` ledger rows.
71
+ - **`items.actions` is the record of what the customer was SOLD** `{ limit,
72
+ overageCentsPerAction }`, written by drawbridge-stripe (≥0.1.44) at create/upgrade/downgrade and
73
+ read by drawbridge-sync at cycle close. plans.js is the default for NEW sales only; editing it
74
+ does not reprice existing customers (that is `repriceActionsSnapshot`, explicit and dry-runnable).
75
+ Anything adding custom/enterprise pricing must gate the plan-change paths and the reprice script
76
+ or negotiated values get silently overwritten. The rate is a NUMBER in cents — the string
77
+ `'2.5'` shape exists only at the Stripe `unit_amount_decimal` boundary.
78
+ - **No Stripe product backs actions (≥0.1.45).** Invoice items carry
79
+ currency/quantity/unit_amount_decimal/tax_behavior/description directly; the account keeps exactly
80
+ one product — the plan product behind `STRIPE_PRICE_*`. Never reintroduce a product-presence guard
81
+ in sync's billing: the old one skipped billing entirely for a productless subscription, which
82
+ would have zeroed every invoice once the products were archived.
83
+ - **The v2 pricing-plan layer (`bpp_*`, billing cadences) is never touched by script.** Canceling a
84
+ billing cadence is terminal and unrecoverable. Dashboard, by hand, only.
85
+ - **A subscription must open with the plan item.** It used to open with the metered actions price
86
+ and attach the plan afterwards with `always_invoice`. With no metered item, Stripe rejects an
87
+ itemless subscription, so the plan goes in at creation — changing the first invoice's shape.
88
+ - **Invoice line descriptions must keep the word "actions":** `isActionsLine` matches `/actions/i`
89
+ to count billed quantity for the billed-vs-ledger reconcile. A copy edit that drops it silently
90
+ breaks the audit. Detail: drawbridge-docs `reference/billing.md`.
77
91
  - Every `$inc` on a `totals.*` counter needs a matching entry in `drawbridge-sync/lib/totals.js`
78
92
  `SOURCES` — that map is the only drift backstop.
79
93
  - The `invoice` collection's **unique partial index on `stripeInvoiceId`** (drawbridge-api
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drawbridge/drawbridge-agents",
3
- "version": "0.1.25",
3
+ "version": "0.1.27",
4
4
  "description": "Shared agent-instruction content (rules, code style, conventions) for the drawbridge-* monorepo.",
5
5
  "license": "UNLICENSED",
6
6
  "publishConfig": {