Idempotent debit + per-key ATTRIBUTION — the money primitive a per-item bulk charge needs (debitOnceIfCovers
itself does NOT attribute). On a FRESH debited it records the spend against keyId (the row id is the stable nonce);
a replayed/insufficient attributes nothing.
OptionalkeyId: string | null
@suluk/credits— a metered credit ledger (C046, extracted verbatim). The package OWNS the schema (credit_transactioncredit_amount/credit_keysidecars); the app injects a Drizzle handle (D1 in prod, bun:sqlite in tests). The money-correctness core: the ATOMICdebitIfCovers(a conditional INSERT that can't drive the ledger negative under concurrency) + the idempotentdebitOnceIfCovers(the partial-refund double-spend guard) + per-key spend + the activity-log query. App-specific payment-alert kinds + the user-table count stay in the app.