Skip to main content

sm-divergence — catch a cheating registry by corroboration

Integrity for the sources agents resolve through. A registry (or a name service, or a DID method) can lie by omission, tampering, or equivocation; signing an artifact closes only tampering. This asks several sources the same questions and makes any disagreement loud.

Agents reach each other through middlemen — registries, indexes, DID methods — and a middleman can lie:

  • tamper — serve a false endpoint (or key) for an agent,
  • omit — hide an agent that is actually registered,
  • equivocate — tell different clients different things.

A self-certifying artifact (a signed AgentFacts-style record, a did:key) defeats tampering — it can't be altered without breaking its signature. But no signature can prove what a source chose not to serve. Omission and equivocation are invisible to a single source.

The cheap, robust defense is one decentralized discovery already hands you: corroboration. If an agent is reachable through two or more sources, ask all of them the same question and treat any disagreement as a signal. That is all this library does — enough to turn a silently cheating source into a loudly diverging one. See the whitepaper for the argument and the spec for the normative procedure.

This is the reference implementation of the IETF Internet-Draft Multi-Source Corroboration for AI Agent Discovery: the sm-resolver kernel is the claim model and diff, and this package is the signing layer — the agent self-description and the signed Corroboration Record — plus the reference discovery and identity layers.

-02 is the published revision (submitted 30 October 2026) and is what this release implements: it adds the claim-outcome vocabulary, requires a record to name its signature algorithm, and aligns corroboration with registry-assisted resolution of known subjects — the DAWN-aligned profile under which a registry resolves a Known Subject (an agent name, an email, a DID) to a terminal target in one hop, as a renewable lease with a sequence. This release reads that sequence: a registry one step behind is attributed as stale_binding, never accused of tampering, and two registries agreeing on an address but not on its targetDigest are reported as digest — substitution at the host, which an endpoint comparison cannot see. Both revisions and the diff between them are on the datatracker, and the text of each is committed under draft/, byte-identical to what the IETF serves.

Requires Python 3.11 or later. The core has no cryptography dependency; signing and verification live in the attestation extra, so you pull it only when you use it.

The registry points; corroboration proves. Resolution is one registry's answer for one known subject: a target, its authority evidence, its lease position. Corroboration is what a verifier does when it holds two such answers. This library never evaluates authority evidence — whether a target's authority is acceptable is local policy, and a sweeper that let it move the verdict would be doing trust evaluation. The issuer is carried as provenance and as the scope a sequence counts in. The sweeper is an auditor over a bounded, explicitly configured source set, and every lookup is exact: no enumeration, no fan-out beyond that set, no registry-to-registry forwarding.

Records carry their algorithm, bound to the key. From corroboration/0.3 a record names its signature algorithm, and a verifier derives the algorithm from the key type the sweeper's did:key encodes rather than trusting the record. Records issued at earlier versions carry no such member and remain verifiable.

Not a transparency log. Corroboration catches a source that disagrees with its peers; it does not stop a single source lying consistently to a first-time caller. That last mile is transparency-log territory (WHITEPAPER §7).

Where it fits

A DNS/CA-pillar primitive in the Project NANDA four-pillar model (DNS / CA / Orchestration / Attestation): it protects the integrity of discovery and identity resolution themselves. NANDA's discovery is multi-source by design — a lean Index delegating to a quilt of registries — and corroboration is only possible because of it: the redundancy built for resilience doubles as an integrity check. This library turns that latent property into an active one, the concrete mechanism behind accountable discovery — a federated registry that is not merely decentralized but auditable.

Install

pip install sm-divergence                 # omission + endpoint/key checks (httpx only)
pip install "sm-divergence[attestation]"  # + verified-DID checks (Ed25519/did:key)
pip install "sm-divergence[dns]"          # + a DNS zone as a source (SVCB / TXT)
pip install "sm-divergence[ans]"          # + a registration log, with receipt verification

Quick start

import asyncio
from sm_divergence import check_once

results = asyncio.run(
    check_once(
        ["https://registry-a.example", "https://registry-b.example"],
        ["agent-1", "agent-2"],
    )
)
for r in results:
    print(r.agent_id, r.verdict)  # agent-1 DIVERGENT   (AGREE / DIVERGENT / INSUFFICIENT)
    for f in r.findings:
        print(" ", f.kind, f.confirmation, f.detail)
        # endpoint suspected {'field': 'endpoint',
        #                     'values': {'https://registry-a.example': 'https://real.example/',
        #                                'https://registry-b.example': 'https://attacker.example/'}}

Each check returns one SweepResult per subject — a verdict (AGREE, DIVERGENT, or INSUFFICIENT when fewer than two sources answered decisively), the claims, and the findings. A finding is suspected when first seen and confirmed once re-observed past the detector's staleness_window_s (so legitimate propagation lag isn't mistaken for tampering).

Long-running? Keep a detector and route new findings to your alert sink — it deduplicates, so a persisting divergence fires your callback once:

from sm_divergence import DivergenceDetector

detector = DivergenceDetector(
    ["https://registry-a.example", "https://registry-b.example"],
    on_finding=lambda f: alert(f.kind, f.agent_id, f.detail),
    staleness_window_s=300,
)
await detector.check(watch_ids=my_agent_ids)  # call each poll cycle

The Corroboration Record

Every sweep can be sealed into a signed, content-addressed Corroboration Record (draft §9) — the auditable proof that the checks ran, emitted for every subject whatever the verdict (the AGREE record is the positive attestation, not just the DIVERGENT ones):

from sm_divergence import sign_sweep, verify_corroboration_record

records = sign_sweep(results, sweeper_private_key=my_ed25519_key)  # needs [attestation]
# record_id = SHA-256(JCS(body)); signed by the sweeper's did:key
assert all(verify_corroboration_record(r) for r in records)  # verifies offline

CLI

python -m sm_divergence check \
    --resolution-registry https://registry-a.example \
    --resolution-registry https://registry-b.example \
    --watch orders@moon-bakery.example

Exit 0 when the sources agree, 2 when any divergence is found (so a cron or CI step fails loudly), 1 on a usage error. --resolution-registry URL is a Resolution Registry implementing the known-subject-resolution-02 profile (POST /resolve; --identity-type sets the Subject Identity type, default agent-name); --registry URL a NEST-style by-id registry; --nanda-index URL the legacy two-hop Index. They mix freely. Add --json for machine output, --attestation to also compare verified DIDs.

What it compares

Every finding is omission (present on one source, positively absent on another) or the name of a view field whose values disagree. The detail is uniform: {"field": <name>, "values": {source: value}} (or {"present_on", "missing_from"} for omission), so a consumer parses findings the same way at every layer.

Kind Meaning
omission One source serves the id; another positively reports it absent (404 / soft-404). An unreachable source is excluded — a timeout is not a claim.
endpoint Discovery sources disagree on an agent's endpoint.
digest Discovery sources agree on the endpoint but disagree on the integrity digest of what it serves (targetDigest) — the same host serving two documents. Compared only when both sides carry one.
stale_binding A registry serves a subject-to-target binding whose lease sequence is below the current one in the same authority scope. Attributed to that source and withheld from the field comparison: being behind is not disagreeing.
did Discovery sources with a verified attestation disagree on the key. One valid record + one forged one is not a disagreement — only proven DIDs count.
key Identity sources (DID methods) disagree on the agent's verification key.
source_equivocation One source, observed from several vantages, disagrees with itself on a field — equivocation by that source, distinct from disagreement between sources.
agent_equivocation The agent's own key signed two different self-descriptions at the same seq — key compromise or a lying agent (the one finding about the agent, not a source).
stale_description A source serves a self-description behind the highest seq (replay / lag).

Architecture — a kernel and its layers

The primitive factors into a source-agnostic kernel and a layer per thing a middleman can be asked. Each layer supplies its own view and thin resolvers; the kernel is untouched.

sm-resolver  (dependency)  the source-agnostic kernel — Resolver[T], the View
                           contract, Claim, diff_claims, Corroborator, SweepResult
sm_divergence/
  discovery/   registry-integrity layer — RecordView + KnownSubjectResolver
               + HttpByIdResolver (NEST) + NandaIndexV2Resolver + AnsV2Resolver
               + AnsLogResolver (a registration log's public badge)
               + CatalogResolver (a published AI Catalog document)
               + DnsSvcbResolver / DnsTxtResolver (a DNS zone as a source)
  identity/    key-consistency layer — DidView + DidKeyResolver / DidWebResolver
               / UniversalResolverResolver + signed self-description
  record.py    the signed Corroboration Record (draft §9)

The kernel now lives in its own package, sm-resolver — sm-divergence is the reference set of layers built on it. Everything below is re-exported from the top level, so from sm_divergence import Corroborator, Finding, … is unchanged.

Sources of different formats mix in one run. A Resolver hides one source's wire format and normalizes its answer to the same view the diff understands:

from sm_divergence import DivergenceDetector, HttpByIdResolver, NandaIndexV2Resolver

await DivergenceDetector(
    [
        HttpByIdResolver("https://nest.example"),  # GET /api/agents/{id}
        NandaIndexV2Resolver("https://index.example"),  # two-hop resolve → record
    ]
).check(["agent-1"])

A DNS zone is a source too. DnsSvcbResolver reads the SVCB rows at the agent's FQDN and DnsTxtResolver the v=ans1 TXT rows at _ans.{fqdn}, so what a zone publishes can be corroborated against what a registry answers:

from sm_divergence import DivergenceDetector, DnsSvcbResolver, KnownSubjectResolver

await DivergenceDetector(
    [
        KnownSubjectResolver("https://registry.example"),  # POST /resolve
        DnsSvcbResolver(protocol="a2a"),  # SVCB at the agent's FQDN
        # the same zone through a second recursive resolver: a zone that answers
        # differently by vantage is reported as source_equivocation
        DnsSvcbResolver(protocol="a2a", nameservers=["192.0.2.53"], vantage="resolver-b"),
    ]
).check(["agent.example.com"])

DnsZoneResolver is the two as one source — SVCB first, TXT only when the zone publishes no SVCB row — so a zone that uses one record shape is not reported as an omission by the other. DohQuery(url) reaches a recursive resolver by DNS over HTTPS: pass it as query= where UDP port 53 is filtered, or to observe a zone through a second, independent resolver.

By default the zone's claim is the descriptor it names (compared with a registry's terminal target) and that descriptor's digest; pass target="service" to compare the service endpoint instead. The agent-specific SvcParamKeys have no assigned code point, so SvcParamKeyMap says which key plays which role. require_dnssec=True turns an answer — or a denial — the recursive resolver did not authenticate into an error, never an absent. The adapter makes no HTTP request: it does not fetch the descriptor or check the digest against it. Needs the dns extra.

A registration log is a source too. AnsLogResolver reads a transparency log's public badge for an agent — no credential — and reduces the DNS records that badge attests by the same rules as the DNS resolvers, so the log and the live zone are read alike:

from sm_divergence import AnsLogResolver, DivergenceDetector, DnsSvcbResolver

await DivergenceDetector(
    [
        AnsLogResolver("https://log.example", protocol="a2a"),  # located via _ans-badge.{fqdn}
        DnsSvcbResolver(protocol="a2a"),  # what the zone publishes now
    ]
).check(["agent.example.com"])

A zone record changed after it was sealed is an endpoint or digest finding. A revoked or expired registration is an error claim with that outcome, never an absent; so is a name with no badge row, since the log was never asked. Needs the dns extra.

Give it the log's verification keys and nothing unsigned is used: the event is read from the log's signed receipt (signature and Merkle inclusion proof checked) and the status from its signed, short-lived status token. Anything that does not verify is error/unverifiable.

AnsLogResolver("https://log.example", root_keys=open("pinned-root-keys.txt").read())

Pin the keys out of band: keys fetched from the log being read show only that it is self-consistent. A verified receipt proves inclusion under the root it states, not that the root is current or that no later event supersedes it. Needs the cose extra (pip install "sm-divergence[ans]" brings both).

AnsV2Resolver reads a by-id record route instead. Because such a route may answer 404 for an agent the caller is not allowed to see, a 404 there is no claim by default, never a false absent; pass not_found_is_absent=True only where a 404 can mean nothing but "does not exist". It reads the record's endpoints[] list — protocol= picks the entry, target= the descriptor or the service endpoint.

A published catalog is a source too. CatalogResolver reads a publisher's AI Catalog document (by default /.well-known/ai-catalog.json) and takes the entry whose identifier names the subject: its url is the descriptor and its digest the descriptor's digest.

from sm_divergence import CatalogResolver, DivergenceDetector, DnsSvcbResolver

await DivergenceDetector(
    [
        CatalogResolver("https://agent.example.com", artifact_type="application/a2a-agent-card+json"),
        DnsSvcbResolver(protocol="a2a", owner_for=lambda agent_id: "agent.example.com"),
    ]
).check(["urn:air:agent.example.com:support"])

No catalog at all is an error — the publisher said nothing — and so is a subject not found while part of the listing sits in a nested catalog that was not read (follow_nested=True reads them, within bounds). Only a catalog read in full that lists no such identifier is absent. A redirect is not followed unless follow_redirects=True. Artifacts are never fetched.

Some directories give every revision of an agent a new, content-addressed identifier and carry the agent card inline. match_on="displayName" compares another entry member instead, the latest revision is taken, and inline_endpoint=a2a_interface_url("JSONRPC") reads the agent's service endpoint out of the inline card.

One subject, many names. A zone knows an agent by FQDN, a log by an entry id, a catalog by an identifier. SubjectMap holds those names and hands each resolver its mapping:

subjects = SubjectMap({"support-agent": {"fqdn": "agent.example.com", "catalog": "urn:air:example.com:support"}})
DnsZoneResolver(owner_for=subjects.name("fqdn"))
CatalogResolver("https://example.com", identifier_for=subjects.name("catalog"))

A subject with no name for a source is an error claim from that source — excluded, never absent — so a gap in the mapping cannot show up as an omission.

examples/live_sweep.py runs any of these against live sources from the command line: python examples/live_sweep.py agent.example.com --zone --doh <resolver> --log <log> --log-keys <file>.

Digests are canonicalized before they are compared (digest-normalization/0.1), so one SHA-256 served as hex by a registry and as base64url by a zone is not a false digest divergence.

Identity layer — catches a did:web (or a Universal Resolver) serving a different verification key than the agent's self-certifying did:key root, a key divergence (the identity analogue of a tampered endpoint):

from sm_divergence import Corroborator, DidKeyResolver, DidWebResolver

await Corroborator(
    [
        DidKeyResolver(did_for=lambda a: agent_did_key[a]),  # offline root of truth
        DidWebResolver(did_for=lambda a: agent_did_web[a]),  # fetched, may be hijacked
    ]
).check(agent_ids)

A new format or layer is a thin adapter — a view with a comparable() and a Resolver that returns it; the generic Corroborator + diff_views do the rest:

from collections.abc import Mapping
from dataclasses import dataclass
from sm_divergence import Corroborator


@dataclass(frozen=True)
class MyView:
    field: str | None = None

    def comparable(self) -> Mapping[str, str | None]:
        return {"field": self.field}


class MyResolver:
    label = "src-a"

    async def resolve(self, agent_id): ...  # -> (Status, MyView | None)


await Corroborator([MyResolver(), ...]).check(agent_ids)

Signed correspondence — the same agent is a bare id on one registry, a URN locator on an Index, a did:web on a domain, and corroboration can't infer that these are the same agent. Instead of trusting a caller-supplied mapping, let the agent sign its own aliases + endpoints; verify offline and drive the resolvers from the verified names, so a source that disagrees is contradicting the agent's own signature:

from sm_divergence import (
    build_self_description,
    HttpDescriptionResolver,
    corroborate_descriptions,
    signed_alias_for,
    DidWebResolver,
    AliasClosureResolver,
    binds_by_key,
)

# the agent signs (bumping seq on every re-issue), with its did:key's private key.
# The bundle is the draft §8 shape: {version, subject, seq, aliases, endpoints, signature}.
bundle = build_self_description(
    aliases={"web": "did:web:acme.org", "nanda": "urn:ai:…:acme"},
    endpoints=["https://acme.example/agents/acme"],
    private_key=agent_ed25519_private_bytes,
    seq=5,
)

# a consumer fetches the description from EVERY source and reconciles it —
# omission / replay / agent-equivocation on the description itself become findings:
recs = await corroborate_descriptions(
    [HttpDescriptionResolver(s) for s in source_urls],
    ["acme"],
)
canonical = recs["acme"].canonical  # None if the agent equivocates
sds = {"acme": canonical} if canonical else {}

# drive resolvers from the PROVEN aliases, with closure so a claimed alias that
# doesn't bind back to the did:key contributes no claim (never a false divergence):
web = DidWebResolver(did_for=signed_alias_for(sds, "web"))
web = AliasClosureResolver(web, lambda a: sds[a].subject if a in sds else None, binds_by_key)

The kernel lives in sm-resolver; sm-divergence is the reference layers built on it. The top-level public API is unchanged.

For verified-DID comparison over signed records shaped {"record": {..., "did": "did:key:z…", "endpoint": …}, "sig": "<b64 ed25519 over JCS(record)>"}, use the built-in adapter (needs the attestation extra):

from sm_divergence import DivergenceDetector, signed_record_adapter

DivergenceDetector(registries, adapter=signed_record_adapter())
Package Role
sm-bridge NANDA-compatible registry endpoints + Quilt-style deltas — produces the multi-source surface this corroborates across.
sm-chapter Minimal registry/discovery server — a natural consumer that runs a divergence check each cycle.
sm-conformance The shared Ed25519 / JCS signing convention this library's optional DID check verifies.

Develop

make ci-local   # uv: sync → ruff → format → mypy --strict → pytest

License

MIT


First published: 2026-07-04 | Last modified: 2026-10-30

Published by Stellarminds.ai under the MIT licence. Aligned with Project NANDA standards.

Metadata

Release files for sm-divergence 0.13.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 sm-divergence 0.13.0
File Size Uploaded Provenance Actions
sm_divergence-0.13.0.tar.gz 414.9 kB With provenance Details for sm_divergence-0.13.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sm-divergence 0.13.0
File Interpreter ABI Platform Actions
sm_divergence-0.13.0-py3-none-any.whl Python 3 none any Details for sm_divergence-0.13.0-py3-none-any.whl

Total release size: 504.8 kB

Release files / sm_divergence-0.13.0.tar.gz

Download URL sm_divergence-0.13.0.tar.gz
Size 414.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7e63a536729279621ed334a3b8b59f30dc3a97c5cc8efcfe4fcbed7b2a26cceb
BLAKE2b-256 checksum
How to use checksums
bb2d663da592dee06ea335fd15ef0f9809b28b9d5c70a497925d983d44cc7fd2
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 20, 2026.

Transparency log

Release files / sm_divergence-0.13.0-py3-none-any.whl

Download URL sm_divergence-0.13.0-py3-none-any.whl
Size 89.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c13a5d119f84234074321dea6fd9777cb350c1499ae73daa498d8516162a80fd
BLAKE2b-256 checksum
How to use checksums
162fbc188c359bca84b10ed718216a90519376493e1996c6e54bdd55abb659eb
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 20, 2026.

Transparency log

Security for sm-divergence 0.13.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 sm_divergence-0.13.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 20, 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