lib.billing-spec
Country-neutral BillingOS quote-to-cash contracts, invariants, and agent action governance types.
@lssm-tech/lib.billing-specbun add @lssm-tech/lib.billing-specManifest declarations describe the current workspace; they do not verify registry publication or runtime execution.
Package guide
Country-neutral BillingOS contracts for quote-to-cash primitives, lifecycle evidence, policy metadata, and agent-facing operation descriptions.
This package is the canonical core contract surface. It intentionally does not contain France-only readiness, PA routing, provider credentials, production submission APIs, persistence adapters, UI, or runtime side effects.
Scope
Use this package to model reusable BillingOS concepts before choosing a country pack or runtime implementation:
- commercial parties, billing accounts, seller/buyer/vendor/customer roles, and fiscal references;
- catalog, price book, offer, quote, order/commitment, invoice, credit-note, payment, reconciliation, and tax-treatment references;
- workflow/event/audit/source metadata for quote-to-cash replay;
- accounting-export, revenue-memory, connector-profile, financial-data-vault, and product-surface projection contracts when they are country-neutral;
- agent operation catalog and safety metadata for read/draft/recommend/approval-only billing actions;
- role-aware quote-to-cash cockpit packets, persona-to-managed-role bindings, action availability, and evidence references for downstream bundle/app seams.
Invoice-issuance contracts (additive)
The following additive operation/event contracts describe the France-ready issuance path. They sit alongside the original eight billing contract keys, which are unchanged:
billing.invoice.issue— issue an invoice from a quote/order, producing the canonical invoice record.billing.invoice.submit— submit an issued invoice to a PDP (Plateforme de Dématérialisation Partenaire) / e-reporting target.billing.invoice.submitted— event emitted once submission is accepted.billing.creditNote.issue— issue a credit note (avoir) derived from a prior invoice.
These contracts stay country-neutral: France legal behavior (TVA, mandatory mentions, gapless numbering, NF203, avoir immutability) lives in @lssm-tech/lib.billing-france, and Factur-X/EN16931 generation plus PDP submission live in @lssm-tech/integration.provider-einvoicing.
Payment-provider evidence
BillingOS keeps provider-neutral payment state while retaining redacted evidence needed for reconciliation. BillingProviderReference can identify the provider object, connected merchant account, webhook event, idempotency key, and evidence references without embedding credentials or provider SDK objects. Connector profiles advertise checkout, payment-method, subscription, invoice, dispute, payout, marketplace, and webhook capabilities explicitly.
Provider network calls remain in integration packages. BillingSpec only models their normalized lifecycle and evidence.
Boundary
BillingOS core remains country-neutral. France e-invoicing/e-reporting readiness lives in @lssm-tech/lib.billing-france; deterministic helper behavior lives in @lssm-tech/lib.billing-runtime; CompanyOS/operator composition belongs in examples or an explicit module surface.
Core contracts may describe high-impact operations, but they must carry authority/autonomy and operator-approval metadata. They must not represent silent authorized execution.
Public entrypoints
@lssm-tech/lib.billing-spec— root barrel@lssm-tech/lib.billing-spec/types— country-neutral BillingOS contract types@lssm-tech/lib.billing-spec/validation— contract validation helpers@lssm-tech/lib.billing-spec/fixtures— safe synthetic quote-to-cash cockpit fixtures@lssm-tech/lib.billing-spec/billing-os— additive versioned catalog, exact-money, usage-truth, correction, and FinanceOS posting-handoff schemas@lssm-tech/lib.billing-spec/service-agreement— bounded managed-workflow agreements, usage and approval-gated operation contracts@lssm-tech/lib.billing-spec/subscriptions— subscription plan versions (weekly, monthly, quarterly, yearly intervals; explicit tier and trial), subscription state events, provider snapshots, entitlement grants and access decisions, with the fivesubscriptionContractsoperations (billing.subscription.plan.publish,.state.apply,.reconcile,.entitlement.settle,.entitlement.check)@lssm-tech/lib.billing-spec/billing-os/docs— owner-module BillingOS semantic-contract DocBlock@lssm-tech/lib.billing-spec/plans— brand-neutral subscription plan template, catalog schema, override, instantiation (career plan data lives in the lssm-os-spec catalog)
BillingOS economic truth lifecycle
The additive billing-os surface models estimate → reservation → execution usage → provider actual → rating → invoice/import correction. Provider payloads and credentials remain outside core; only stable redacted evidence references are accepted. Unknown or stale hard-budget knowledge requires review. Reservations, invoice issuance, payment effects, collection effects, and authorized finance posting handoffs require stable ContractSpec Connect authorization references.
Billing-to-finance integration is reference-only: BillingOS emits a balanced posting handoff, while FinanceOS owns ledger acceptance and returns a receipt. Neither package imports the other.
Production-readiness safety boundaries
- No France-specific fields, readiness schedules, PA claims, or provider routing in core.
- No provider credentials, API keys, network calls, filesystem/database adapters, or production billing processor behavior.
- No production PA submission, e-reporting submission, invoice send, mark-paid, refund, write-off, or VAT/tax-treatment mutation without an explicit approval packet.
- No legal advice, tax advice, PA accreditation claim, or full accounting/general-ledger claim.
See docs/billingos-production-readiness.md and docs/billingos-v0-release-verification.md for prompt coverage, release gates, and remaining non-goals.
Canonical contract suppliers
Billing operation factories and DocBlock metadata consume the existing Core contract declarations. Complete billing spec objects, authority requirements, validation defaults and test assertions are preserved. Usage evidence types consume the complete pure Observability Spec declarations from /evidence-record and /signal-spec. Original derivation, defaults and test assertions remain unchanged. Clean declarations and affected consumers still require qualification before integration.
Service agreements (./service-agreement, additive)
Contracts for a bounded managed workflow sold as fixed setup + subscription + metered usage:
ServiceAgreementSchema— immutable agreement versions binding a workflow edition, installation, selected meter editions (each naming its qualifying receipt class), frozen price editions applied per whole half-open period, budget/exhaustion policy, late-arrival rule and terms. Automatic collection requires qualification evidence.ServiceUsageEventSchema— strict, content-free usage facts across the estimate → reservation → usage → provider actual → invoice correction chain, with full-scope idempotency identity and reasoned exclusions.OnPremUsageBatchSchema— signed, digest-only on-prem usage export.ServicePriceVersionSchema,ServiceUsageRatingSchema,MeteredServiceUsageSchemaandMeteredServiceUsageReceiptSchema— a versioned platform price table whose versions are explicitlyunpricedorpriced(ISO currency, integer micros, owner decision ref), and the strict, content-free record of one metered service call with its rating (unpricedwithprice_not_setorno_price_version, orpricedwith the exact amount). There is no default price.ServicePilotAcceptanceRecordSchemaandServiceTerminationRequestSchema.- Operations:
billing.service.usage.record|correct|summary|meter,billing.service.invoiceDraft.compute,billing.service.budget.reserve,billing.service.onprem.batch.import,billing.service.agreement.terminate, and approval-gatedbilling.service.invoice.submit|issue(execution.approval.required) (serviceAgreementContracts).
The subpath is not re-exported from the root barrel.
Distribution build contract
The existing ./service-agreement export must be available from an installed package under each advertised condition:
- Bun/default:
dist/service-agreement/index.js - Node:
dist/node/service-agreement/index.js - Browser:
dist/browser/service-agreement/index.js - Types:
dist/service-agreement/index.d.ts
The explicit entry list in tsdown.config.js must include src/service-agreement/index.ts. The canonical direct-entry build bundles its reachable local modules while keeping declared package dependencies external. Keep the existing source/export contracts and the ten serviceAgreementContracts operation keys intact.
Run the package's canonical prebuild/build and published-pack workflow before qualifying this subpath. Verification must load the actual installed artifact outside the workspace, inspect all ten operation keys and their meta.key values, and exercise the declared runtime, browser-bundler and type-consumer paths. A source-checkout import alone does not establish distribution readiness.
Relationships
Arrows point from a package to its direct dependency. Counts are derived from captured workspace manifests.
3 declarations
@lssm-tech/lib.schemaworkspace:^
Read the package manual ↗@lssm-tech/lib.contracts-spec-coreworkspace:^
Read the package manual ↗zodcatalog:
Declared capabilities
Country-neutral BillingOS quote-to-cash contracts, invariants, and agent action governance types.
Scripts
publish:pkgbun publish --tolerate-republish --ignore-scripts --verbosepublish:pkg:canarybun publish:pkg --tag canarybuildcontractspec-bun-build buildbuild:bundlecontractspec-bun-build transpilebuild:typescontractspec-bun-build typesdevcontractspec-bun-build devcleanrimraf dist .turbolintbun lint:fixlint:fixnode ../../../../scripts/biome.cjs check --write .lint:checknode ../../../../scripts/biome.cjs check .testbun testprebuildcontractspec-bun-build prebuildtypechecktsgo --noEmit