Skip to main content

Cometric

CI

Commercial Intelligence Engine. Cometric models the commercial arrangements behind service engagements, simulates their economics month by month, and searches for structures that balance profitability, risk, and client value.

  1. Model. Arrangements are compositions, not a single "pricing model": billing bases, rate schedules, allowances, minimums, adjustments, delivery costs, and capacity, each typed and validated.
  2. Simulate. A deterministic decimal engine computes contractual fees, costs by margin layer, contribution, client effective unit price, capacity use, and who absorbs each deviation from plan.
  3. Optimize. A grid search over the parameters you declare returns the trade-off frontier. Nothing is ranked unless you supply an objective, and every recommendation is marked for human review.

It is built for any service relationship priced through a composite arrangement: consulting, outsourcing, managed services, and alternative legal services. Sector knowledge ships as data-only packs.

Guarantees

  • No model arithmetic. Every amount is computed by decimal code. Floating-point input is rejected.
  • Reproducible. Each result carries a SHA-256 fingerprint of its canonical inputs, engine version, and policies.
  • Traceable. Every fee line records its evaluation step, formula, quantity, and contract version.
  • Explicit policy. Cost layering, capacity ceilings, recognition rules, and risk tolerances are inputs. Missing economic policy is an error, never a silent default.
  • Labeled knowledge. Pack concepts and claims carry evidence classes. Inference and proposals are always labeled as such.

Install

pip install "cometric[mcp]"           # or: uv pip install "cometric[mcp]"
uv sync --all-extras                  # from a checkout

PyPI

Python 3.11 or later.

Quickstart

cometric validate src/cometric/examples/spec_example.json
cometric calculate src/cometric/examples/case_a.json --scenario base --cost-policy reference
cometric explain src/cometric/examples/spec_example.json --period 2027-01
cometric break-even src/cometric/examples/case_b.json --driver contracts --scenario base --cost-policy reference
cometric floor src/cometric/examples/case_b.json --cost-policy reference --target-margin 0.20
cometric template base_plus_overage
cometric template phased_fixed_fee --pack consulting
cometric template tiered_units_annual_minimum --pack alsp
cometric reconcile engagement.json --scenarios actual-quantities.json --actuals actuals.json --cost-policy reference --summary-only
cometric lookup PM-023
import json

import cometric

case = json.load(open("src/cometric/examples/case_a.json"))
result = cometric.calculate_periods(case["engagement"], case["scenarios"][1], "reference", detail="periods")
print(result["term"]["contribution_margin"], result["input_fingerprint"])

MCP server

Cometric ships a read-only, stateless MCP server: 20 tools (start with quickstart; for a new deal, propose_structures), schema and template discovery, resources for the glossary, schemas, concept schemes, rules, coverage, templates, and worked examples, and seven guided prompts.

cometric mcp                                   # stdio
COMETRIC_ALLOWED_ROOT=/path/to/models cometric mcp   # stdio, may read input files under that root
cometric mcp --transport http --port 8765      # stateless streamable HTTP at POST /mcp

Claude Code:

claude mcp add cometric -- uvx --from "cometric[mcp]" cometric mcp

The HTTP transport keeps no session state, answers GET /mcp with 405, keeps DNS-rebinding protection on (set COMETRIC_ALLOWED_HOSTS for your hostname), and checks a bearer token when COMETRIC_MCP_TOKEN is set.

Concepts

Concept Meaning
Engagement Parties, units, services, effective-dated arrangement versions, delivery plan
Fee component One charge computed by one method: fixed recurring, time, dedicated resource, unit output, weighted unit output, allowance plus overage, fixed project, outcome adjustment (gain-share, success fee, percent of outcome)
Realization Contractual fee against hours worked at a standard rate card, with write-down and effective billing rate
Accumulation period Allowances, minimums, tiers, and capacity accumulate over a declared period independent of the monthly grain
Evaluation order Resolve, measure, consume allowances, price, collar, discount, minimum, performance, cap
Cost policy Maps each cost category to exactly one margin layer; reference is shipped and must be named
Scenario Immutable, origin-labeled assumptions spread to months by exact allocation
Derived risk Who absorbs a deviation: provider contribution versus client unit price
Dominance A candidate is dominated when another is at least as good on every metric and better on one

Packs

Packs are YAML only, with no executable code. base holds domain-neutral commercial knowledge: billing bases, 34 pricing models, 70 levers, 16 commercial dimensions, 49 metrics and indicators, cost categories, compatibility and reasoning rules, selection heuristics, mechanisms, and negotiation exchanges. alsp extends it for alternative legal services with service categories, unit templates, provider types, regulatory review rules, sector prevalence overlays, and evidence. consulting extends it for advisory work with realization and staffing concepts, outcome-fee review rules, and five templates: role-based time and materials, capped time and materials, phased fixed fee, hours-drawdown retainer, and fixed fee plus success fee.

cometric packs
cometric validate-pack alsp
cometric validate-pack consulting

Proposing structures

propose_structures takes a short deal profile (unit of work and complexity tiers, volume certainty and figures, cost shape, one to three client priorities, the provider's limit on volume risk, term) and lists candidate structures, each a base pricing model plus levers. Candidates are grouped by who absorbs a volume shortfall and never ranked; each shows its risk allocation, which priorities it serves and where it falls short, what its labels assume, trade-offs, evidence strength, and the inputs to supply. It proposes no figures: expanded candidates are skeleton engagements with labelled placeholders and shared scenarios, ready for compare_arrangements once filled.

cometric propose request.json                 # {packs, deal_profile, options}
cometric propose request.json --expand PM-011+CL-R01+CL-V07

quickstart("propose_structures") returns a runnable request; the full contract is docs/PROPOSE_STRUCTURES_SPEC_v0.2.md.

Ontology

The ontology is published in docs/ontology/: diagrams of the core model, every field and controlled vocabulary, and a page per pack with each concept's definition, evidence class, relations, rules, claims, and sources. cometric.ttl holds the same content in Turtle (OWL classes for the core model, SKOS concept schemes for vocabularies and packs), for Protégé, rdflib, or any SPARQL store. Both are generated from the package, and a test fails when the committed copy is out of date.

cometric ontology > cometric.ttl          # Turtle to stdout
cometric ontology --out docs/ontology     # regenerate the reference

Development

uv sync --all-extras
uv run pytest
uv run ruff check src tests scripts && uv run ruff format --check src tests scripts
uv run python scripts/build_fixtures.py   # regenerate casebook fixtures

The specification is docs/COMETRIC_SPEC_v0.3.md; the ontology reference is docs/ontology/. Implementation status is in docs/STATUS.md; worked commercial patterns (tiered minimums, transition credits, partial billing, cost from hours, early termination) are in docs/PATTERNS.md; reconciling a real engagement is described in docs/RECONCILIATION.md.

License

Apache License 2.0. See LICENSE.

Metadata

Release files for cometric 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cometric 0.6.0
File Size Uploaded Provenance Actions
cometric-0.6.0.tar.gz 710.4 kB With provenance Details for cometric-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cometric 0.6.0
File Interpreter ABI Platform Actions
cometric-0.6.0-py3-none-any.whl Python 3 none any Details for cometric-0.6.0-py3-none-any.whl

Total release size: 961.0 kB

Release files / cometric-0.6.0.tar.gz

Download URL cometric-0.6.0.tar.gz
Size 710.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4ed1ce0fd7fd31c6aa3392a9c5c716e2d1f4d1a61984b2af91304a0d7e982614
BLAKE2b-256 checksum
How to use checksums
7e898a05d99e9ebfd7d13a79e5364ce6ddbc228e0900144959dcfc07d743c26d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / cometric-0.6.0-py3-none-any.whl

Download URL cometric-0.6.0-py3-none-any.whl
Size 250.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
40fd447bbd6558cb89d8c714e0cfd873e485af69b00db48532e3f419c3e506b6
BLAKE2b-256 checksum
How to use checksums
5646e00d8d7e4118cc8cecb88fa058892e1ab57d10d67105f2f8f40556056888
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Security for cometric 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cometric-0.6.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page