Cometric
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.
- Model. Arrangements are compositions, not a single "pricing model": billing bases, rate schedules, allowances, minimums, adjustments, delivery costs, and capacity, each typed and validated.
- 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.
- 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
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: 19 tools (start with quickstart), schema and template discovery, resources for the glossary, schemas, concept schemes, rules, coverage, templates, and worked examples, and six 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
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.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cometric-0.5.0.tar.gz | 654.4 kB | With provenance | Details for cometric-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cometric-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for cometric-0.5.0-py3-none-any.whl |
Total release size: 877.2 kB
Release files / cometric-0.5.0.tar.gz
| Download URL | cometric-0.5.0.tar.gz |
|---|---|
| Size | 654.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4434e058f214892109bebc0add5b2fb957846fbd59b9e3c1c69cba3c62319f37
|
|
BLAKE2b-256 checksum How to use checksums |
6eef991d619997cf84dd2743516ec68112424e10917fe1bf4a7bf9b5b2181021
|
| 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 logRelease files / cometric-0.5.0-py3-none-any.whl
| Download URL | cometric-0.5.0-py3-none-any.whl |
|---|---|
| Size | 222.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5ab4740e144efbf1340c92ac9053299a1555d635bc097382ca2bb5da6f9ab5b8
|
|
BLAKE2b-256 checksum How to use checksums |
60d545402e89ca190ab38339eeb0c1a24f67b4fb75b8adef0b39a756fc8e5520
|
| 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 logSecurity for cometric 0.5.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.
Attestation for cometric-0.5.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 logA 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.