Skip to main content

SetSpec

Every versioned data contract that crosses an application boundary: benchmark results, capability evidence, event/error envelopes, prompt records.

Status: 0.6.0 — Phases 1–2, 3A, 4, 5, 6 and 7 complete, and the v1.0 contracts are frozen, with two additive minors now published on top of that freeze. Six payload types remain frozen at 1.0 only — model.identity, machine.profile, benchmark.result, benchmark.run_summary, benchmark.goal_pack and benchmark.calibration_report — each with generated JSON Schema and at least three golden payloads shipped as package data. setspec.DRAFT_SCHEMAS is empty, which is where the freeze is readable at runtime rather than only stated here; from now on a new optional field is a minor bump and anything else is a major, enforced by a snapshot diff in CI.

Phase 6 (the adapter arc's LA0 checkpoint) adds three things without touching any of the above: capability.evidence gains an additive 1.1 (an optional adapter field, absent — and byte-identical to 1.0 — on every record with no adapter); model.adapter_manifest 1.0 publishes the operator-reviewed record behind one adapter; and governance.egress_decision 1.0 is the package's first payload under a root other than benchmark/capability/machine/model, carrying a recorded egress verdict for a reader that has Commissioner installed or not. Phase 7 carries that same minor one payload out: benchmark.evidence_bundle gains its own additive 1.1, nesting capability.evidence 1.1 in place of the 1.0 element type its frozen 1.0 still nests, so an exported bundle can now carry adapter-bearing evidence — absent any adapter, byte-identical to 1.0. capability.evidence and benchmark.evidence_bundle are therefore the two payload types with a second published minor; every other payload type remains exactly 1.0.

The schema catalogue lists every payload type, its artifacts, and the cross-field rules the JSON Schema cannot express. Event and error envelopes (Phase 3) are not yet written and are therefore not part of the freeze. Prompt records (setspec.prompts, Phase 5, added in 0.4.0) are shipped: prompt packs with their three content hashes and sandboxed rendering; they carry their own record schema version rather than joining the frozen payload types. See the development plan for what each phase adds.

Part of the Local AI Suite.

Install

pip install setspec

Quickstart

Write a document, then read it back:

from setspec import GeneratorInfo, SchemaVersion, dump_envelope, load_envelope

generator = GeneratorInfo(name="freeweight", version="1.0.0")
document = dump_envelope(
    {"tokens_per_second": 42.0},
    schema="benchmark.result",
    version=SchemaVersion(1, 0),
    generator=generator,
)

envelope = load_envelope(document, expect="benchmark.result", supported=[SchemaVersion(1, 0)])
assert envelope.payload == {"tokens_per_second": 42.0}

dump_envelope returns canonical JSON: byte-identical for equal input, on every platform and Python version, so a document can be hashed and diffed as well as read.

Payload types come in two halves generated from one definition — a strict Out for writers and a preserving In for readers (ADR-0009 rule 4):

from setspec import PayloadDefinition, payload_models
from setspec.serialization import MeasurementField


class ResultFields(PayloadDefinition):
    reading: MeasurementField
    unit: str


ResultOut, ResultIn = payload_models(ResultFields)

# A reader keeps what a newer writer added, so a re-export loses nothing.
received = ResultIn.model_validate({"reading": 1.5, "unit": "ms", "confidence": 0.87})
assert received.extras == {"confidence": 0.87}

A measurement this environment cannot provide is UNSUPPORTED, which serializes as the string "unsupported" — never null, never 0 (ADR-0016).

Phase 2's payload types live in their own versioned modules, not the top-level package, so that a future benchmark.result 2.0 can coexist with v1 rather than racing it for one name (ADR-0009 rule 6):

from setspec.capability.v1 import CapabilityEvidenceOut

evidence = CapabilityEvidenceOut.model_validate(
    {
        "model": {
            "provider_kind": "ollama",
            "provider_model_name": "qwen3.5:9b-q8_0",
            "artifact_digest": None,
            "identity_confidence": "name_only",
            "canonical_id": "ollama/qwen3.5:9b-q8_0@unknown",
            "observed_at": "2026-08-20T09:00:00.000Z",
        },
        "runtime_profile_hash": "a" * 16,
        "machine_fingerprint": "b" * 64,
        "capability_id": "coding.python",  # unenumerated specialization of the known root "coding"
        "score": 0.82,
        "confidence": 0.71,
        "sample_count": 40,
        "excluded_count": 2,
        "dispersion": 0.09,
        "measured_at": "2026-08-20T00:00:00.000Z",
        "computed_at": "2026-08-22T00:00:00.000Z",
        "policy_version": "1.0",
        "vocabulary_version": "1.0",
        "environment": {"provider_kind": "ollama", "provider_version": "0.32.13"},
    }
)
assert evidence.capability_id == "coding.python"

See docs/packages/setspec/spec.md §7 for the full public API and §20 for the acceptance criteria.

Documentation

Project documentation lives under docs/. Start with docs/README.md.

Read this For
docs/packages/setspec/spec.md Purpose, scope, non-goals, public contracts, configuration, acceptance criteria
docs/packages/setspec/development-plan.md The phased build plan: goals, work, tests, acceptance criteria per phase

Development

python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pre-commit install
pytest -m "not live and not performance"

See CONTRIBUTING.md for the full workflow and SECURITY.md for how to report a vulnerability.

License

Apache-2.0 — see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

setspec-0.6.0.tar.gz (266.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

setspec-0.6.0-py3-none-any.whl (191.9 kB view details)

Uploaded Python 3

File details

Details for the file setspec-0.6.0.tar.gz.

File metadata

  • Download URL: setspec-0.6.0.tar.gz
  • Upload date:
  • Size: 266.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for setspec-0.6.0.tar.gz
Algorithm Hash digest
SHA256 1deec1712641cb76c6397a7e0df80baa4acb942bb24cfe9a764d4a0dc7f34530
MD5 6461acd756db3d62fe64c85f5abd7035
BLAKE2b-256 1eaef5ea29115e6053a4b94205232c7f46a39cf06e2028cf12497c746e5de209

See more details on using hashes here.

Provenance

The following attestation bundles were made for setspec-0.6.0.tar.gz:

Publisher: release.yml on JPKell/SetSpec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file setspec-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: setspec-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 191.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for setspec-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9807cf6c321e9b80ef5fbb768ac82c7a4e9e3a8e61c12a7208b5429492a6fcac
MD5 ba2c62114b4ec40638f96fc2945fbcd5
BLAKE2b-256 8d354e81aec3faba58f06992fcc98fed850444d0de968c8eb304e2e2e92a73c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for setspec-0.6.0-py3-none-any.whl:

Publisher: release.yml on JPKell/SetSpec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

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