lib.metering
Usage metering and billing core module for ContractSpec applications
domainslibraryv5.0.5stableservernode
@lssm-tech/lib.meteringbun add @lssm-tech/lib.meteringManifest declarations describe the current workspace; they do not verify registry publication or runtime execution.
Package guide
Website: https://contractspec.io
Usage metering and billing core module for ContractSpec applications.
What It Provides
- Layer: lib.
- Consumers: bundles.
src/contracts/contains contract specs, operations, entities, and registry exports.src/docs/contains docblocks and documentation-facing exports.src/contracts/contains contract specs, operations, entities, and registry exports.src/docs/contains docblocks and documentation-facing exports.
Installation
npm install @lssm-tech/lib.metering
or
bun add @lssm-tech/lib.metering
Usage
Import the root entrypoint from @lssm-tech/lib.metering, or choose a documented subpath when you only need one part of the package surface.
Architecture
src/aggregationis part of the package's public or composition surface.src/analyticsis part of the package's public or composition surface.src/contracts/contains contract specs, operations, entities, and registry exports.src/docs/contains docblocks and documentation-facing exports.src/entities/contains domain entities and value objects.src/events.tsis package-level event definitions.src/economic-usage-ledger.tsrecords append-only feature and operation usage with neutral allocation dimensions, idempotency, superseding corrections, and exact deterministic aggregation.src/index.tsis the root public barrel and package entrypoint.
Public Entry Points
- Export
.resolves through./src/index.ts. - Export
./aggregationresolves through./src/aggregation/index.ts. - Export
./analytics/posthog-meteringresolves through./src/analytics/posthog-metering.ts. - Export
./analytics/posthog-metering-readerresolves through./src/analytics/posthog-metering-reader.ts. - Export
./contractsresolves through./src/contracts/index.ts. - Export
./docsresolves through./src/docs/index.ts. - Export
./docs/metering.docblockresolves through./src/docs/metering.docblock.ts. - Export
./entitiesresolves through./src/entities/index.ts. - Export
./economic-usage-ledgerresolves through./src/economic-usage-ledger.ts. - Export
./eventsresolves through./src/events.ts. - Export
./metering.capabilityresolves through./src/metering.capability.ts. - The package publishes 11 total export subpaths; keep docs aligned with
package.json.
Local Commands
bun run dev— contractspec-bun-build devbun run build— contractspec-bun-build buildbun run lint— bun lint:fixbun run lint:check— biome check .bun run lint:fix— biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .bun run typecheck— tsgo --noEmitbun run publish:pkg— bun publish --tolerate-republish --ignore-scripts --verbosebun run publish:pkg:canary— bun publish:pkg --tag canarybun run clean— rimraf dist .turbobun run build:bundle— contractspec-bun-build transpilebun run build:types— contractspec-bun-build typesbun run prebuild— contractspec-bun-build prebuild
Recent Updates
- Replace eslint+prettier by biomejs to optimize speed.
- Stability.
- Resolve lint, build, and type errors across nine packages.
- Add AI provider ranking system with ranking-driven model selection.
Notes
- Aggregation logic must stay deterministic — non-determinism causes billing discrepancies.
- New economic usage should use decimal-string or integer quantities. Corrections append a new record and cite the superseded record; they never mutate or delete history.
- Billing-related schemas are compliance-sensitive; changes require review.
- Capability contract (
metering.capability) is public API — treat as a breaking-change surface.
Relationships
THIS PACKAGElib.metering13 import paths
Arrows point from a package to its direct dependency. Counts are derived from captured workspace manifests.
7 declarations
@lssm-tech/lib.economic-evidenceworkspace:^
Read the package manual ↗@lssm-tech/lib.schemaworkspace:^
Read the package manual ↗@lssm-tech/lib.orchestration-specworkspace:^
Read the package manual ↗@lssm-tech/lib.contracts-spec-coreworkspace:^
Read the package manual ↗@lssm-tech/lib.contracts-integrationsworkspace:^
Read the package manual ↗@lssm-tech/lib.surface-runtimeworkspace:^
Read the package manual ↗
Declared capabilities
Lib Metering
Usage metering and billing core module for ContractSpec applications
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 --unsafe --only=nursery/useSortedClasses . && node ../../../../scripts/biome.cjs check --write .lint:checknode ../../../../scripts/biome.cjs check .prebuildcontractspec-bun-build prebuildtypechecktsgo --noEmit