Metadata-Version: 2.5
Name: sm-revocation
Version: 0.1.1
Summary: Freshness-bounded revocation feeds for agent meshes on intermittent links: REVOKED, NOT_REVOKED(as_of) or UNKNOWN, from signed feeds any carrier can forward.
Project-URL: Homepage, https://agentclock.ai
Project-URL: Documentation, https://pypi.org/project/sm-revocation/#files
Author-email: StellarMinds <hello@stellarminds.ai>
License-Expression: MIT
License-File: LICENSE
Keywords: ai-agents,delay-tolerant,did,nanda,partition,revocation,verifiable
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: jcs>=0.2.1
Requires-Dist: sm-arp>=0.3.0
Requires-Dist: sm-feed>=0.2.1
Provides-Extra: dev
Requires-Dist: coverage>=7.0; extra == 'dev'
Requires-Dist: mypy>=1.0; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: ruff==0.15.13; extra == 'dev'
Description-Content-Type: text/markdown

# sm-revocation

**Freshness-bounded revocation feeds for agent meshes on intermittent links**

Revocation assumes a reachable issuer. A CRL or an OCSP responder tells a relying
party that a credential is revoked only if the relying party can reach it, and a
mesh cut off from its issuer either keeps acting on old information without
knowing how old it is, or stops. `sm-revocation` is the third option: the issuer
publishes revocations on a signed, hash-chained [`sm-feed`](https://pypi.org/project/sm-feed/)
feed and re-signs the feed's head on a declared cadence; anyone who met the issuer
— a member, a relay, a vehicle, a store-and-forward bundle — can carry entries,
heads and pages onward; and a holder's view answers one of three things about a
subject at a time:

- **`REVOKED(effective_at, reason)`** — an issuer-signed revocation it holds;
- **`NOT_REVOKED(as_of)`** — it holds every revocation the issuer had signed up to a
  head the issuer itself dated `as_of`, and none names the subject;
- **`UNKNOWN(reason)`** — `behind`, `stale`, `not_covered`, `before_anchor` or
  `feed_misbehaved`, each a statement of what the view cannot rule out.

The caller bounds how old `as_of` may be. Past the bound the answer is `UNKNOWN`,
so a partitioned mesh knows how old its revocation information is and refuses past
the bound, instead of acting on it blind. This package owns the revocation payload
profile on `sm-feed`, the issuer's time obligations, the view, its conflict
evidence, and the adapters for [`sm-renewal`](https://pypi.org/project/sm-renewal/)
and [`sm-dat`](https://pypi.org/project/sm-dat/).

## What it does (0.1)

- **A revocation counts as soon as it is seen.** A single signed revoke entry,
  flooded through any carrier on its own, makes every holder that receives it
  answer `REVOKED`, without the rest of the chain (SPEC §6.3).
- **`NOT_REVOKED` only from a complete chain and a matching head.** Entries extend
  the view's chain one at a time, in any order and from any carrier; a missing,
  reordered or corrupt entry stops the chain at the gap and the view answers
  `UNKNOWN(behind)`, never `NOT_REVOKED` (§6.4).
- **Monotone state.** Nothing a carrier sends, in any order, moves the view's
  cursor, frontier, revocations or evidence backwards. A replayed old page or head
  changes nothing; there is no un-revoke (§4.5, §6.1).
- **Freshness from the issuer's own signatures.** `as_of` is the `generated_at` of
  the newest head the chain is complete to. The view reads no clock, so equal
  inputs give equal answers anywhere (§6.7).
- **Issuer misbehaviour becomes transferable evidence.** The issuer's signed times
  must never decrease (§5.3). Two signed objects that bind one position to two
  hashes (a fork), or whose times run backwards along the feed (an order
  conflict), form a `revocation-conflict/0.1` proof anyone can re-check. An order
  conflict is what exposes an issuer that keeps heartbeating a holder while hiding
  a later entry from it, as soon as the hidden entry and a heartbeat meet at any
  holder (§7).
- **Late joiners.** A `revocation-snapshot/0.1` lets a view start from a signed
  checkpoint, whose state digest every view walking through it recomputes (§8).
- **Adversarially tested.** 28 deterministic conformance vectors and a hostile-path
  suite: forged, tampered, mistyped and non-canonical objects, profile violations,
  chain-rule breaks, out-of-order and partial carriage, replays, forks of every
  kind, order conflicts at either holder, tampered proofs, snapshot refusals and
  false checkpoint digests. Hostile values are substituted into every field of
  every object; the view names the failing stage and never raises.

## What it does not do

- **Deliver a revocation to a node nothing can reach.** A mesh with no path to the
  issuer, direct or carried, learns nothing new. Its answers go `stale` on
  schedule. That is the inherited revocation residual, made visible, not removed.
- **Catch a freeze at a holder that meets no one.** A holder that hears only from
  the issuer cannot tell "nothing was revoked" from "nothing is being shown to me".
  Freeze detection needs contact between holders; witness co-signing is not in
  `0.1`.
- **Check the issuer's word.** `effective_at`, `reason`, `prune_after` and every
  signed time are the issuer's statements. A caller that wants to cap future-dated
  heads does so against its own clock, outside the view.
- **Transport, scheduling or the decision to revoke.** Those are the consumer's.

`THREATMODEL.md` states every boundary.

## Installation

```bash
pip install sm-revocation
```

Requires Python 3.11+ and `sm-feed` 0.2.1 or later.

## Quick start

```python
from sm_arp import Identity
from sm_revocation import RENEWAL_KINDS, FeedView, RevocationIssuer, revoked_set

issuer = RevocationIssuer(
    Identity.generate(),
    heartbeat_seconds=60,
    subject_kinds=["credential_hash", "manifest_hash"],
    issued_at="2026-11-01T09:00:00Z",
)
issuer.revoke(
    subject_kind="credential_hash",
    subject="sha256:" + "a1" * 32,
    effective_at="2026-11-01T09:02:00Z",
    issued_at="2026-11-01T09:02:00Z",
    reason="key_compromise",
)

# Any carrier forwards the page; the holder verifies everything itself.
view = FeedView(issuer.feed_id)
view.ingest_page(issuer.page(None, generated_at="2026-11-01T09:05:00Z"))

view.status("credential_hash", "sha256:" + "a1" * 32, "2026-11-01T09:06:00Z", 300)
# Status(outcome='REVOKED', effective_at='2026-11-01T09:02:00Z', reason='key_compromise', ...)

# For sm-renewal: the set to pass as revoked_credential_hashes, or None.
revoked = revoked_set(view, RENEWAL_KINDS, "2026-11-01T09:06:00Z", 300)
if revoked is None:
    ...  # decline to attest. Never substitute an empty set.
```

A `Status` deliberately has no truth value: test `.revoked`, `.not_revoked` or
`.unknown`. `examples/quick_start.py` runs a fuller version, including a freeze
being caught.

## Using it with sm-renewal and sm-dat

- **`revoked_set(view, kinds, at, max_staleness_seconds)`** returns the
  `frozenset` `sm-renewal` takes as `revoked_credential_hashes`, or `None` when the
  view cannot vouch for completeness and freshness. An attester that gets `None`
  declines; a relying party fails its revocation step. **Never pass an empty set in
  place of `None`**: `sm-renewal` reads an empty set as "complete, fresh, and
  nothing revoked" (SPEC §9.1).
- **`dat_checker(resolve)`** returns the `revocation_checker` `sm-dat` takes.
  `sm-dat` calls one checker for every grant in a chain, ancestors included, so
  `resolve(grant_id)` returns that grant's own feed views and its
  `max_revocation_age_seconds`. `REVOKED` → `True`, `NOT_REVOKED` → `False`,
  anything else → `None` (SPEC §9.2).

## Reference fixtures

`conformance/vectors/*.json` — 28 deterministic scenarios from fixed, non-secret
seeds, each a script of ingests and queries with the answer the SPEC requires at
every step. `conformance/_vector_gen.py` regenerates them byte for byte, and checks
each hand-written expectation against the implementation while it writes.

## Specification

- [`SPEC.md`](./SPEC.md) — normative wire format and behaviour, working draft.
- [`WHITEPAPER.md`](./WHITEPAPER.md) — design rationale.
- [`THREATMODEL.md`](./THREATMODEL.md) — what it defends, and what it does not.

## Related packages

| Package | Role |
| --- | --- |
| [`sm-feed`](https://pypi.org/project/sm-feed/) | The substrate: signed, hash-chained, cursor-based feed |
| [`sm-renewal`](https://pypi.org/project/sm-renewal/) | Partition-tolerant renewal; consumes `revoked_set` |
| [`sm-dat`](https://pypi.org/project/sm-dat/) | Delegated authority tokens; consumes `dat_checker` |
| [`sm-arp`](https://pypi.org/project/sm-arp/) | Ed25519, JCS and `did:key`, shared across the family |

## License

[MIT](./LICENSE)

---

*First published: 2026-11-28 | Last modified: 2026-11-28*

*Personal research contributions aligned with [Project NANDA](https://projectnanda.org) standards. [Stellarminds.ai](https://stellarminds.ai)*
