Metadata-Version: 2.5
Name: sm-renewal
Version: 0.4.0
Summary: Extend-only, threshold-attested authority renewal for partitioned agent meshes
Project-URL: Homepage, https://agentclock.ai
Project-URL: Repository, https://github.com/Sharathvc23/sm-renewal
Project-URL: Changelog, https://github.com/Sharathvc23/sm-renewal/blob/main/CHANGELOG.md
Author: stellarminds.ai
License-Expression: MIT
License-File: LICENSE
Keywords: nanda,partition-tolerance,wimse,workload-identity
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: base58>=2.1
Requires-Dist: cryptography>=41.0
Requires-Dist: jcs>=0.2.1
Provides-Extra: dev
Requires-Dist: cbor2>=5.4; extra == 'dev'
Requires-Dist: coverage>=7.0; extra == 'dev'
Requires-Dist: mypy>=1.0; extra == 'dev'
Requires-Dist: pycddl>=0.6; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Description-Content-Type: text/markdown

# sm-renewal

**Extend-only, threshold-attested authority renewal for partitioned agent meshes**

Every workload identity system in deployment today assumes the credential
issuer is reachable — short-lived tokens, fast rotation, timely revocation
are all guarantees about the *connected* case. `sm-renewal` is what a
severed-but-healthy agent does instead of halting or self-renewing: it
collects signed attestations from a two-thirds threshold of peers the
issuer named, who have watched it operate, and extends its existing,
unwidened authority for a bounded, auditable time. This package owns exactly one thing — the
`MeshManifest → RenewalRequest → PeerAttestation → RenewalProof → RenewalChain`
wire format and its verification procedure.

The issuer takes part exactly once, before any partition: it signs a **Mesh
Manifest** naming the members, the ceiling, the clock tolerance and the
widest scope the mesh may ever extend. From then on the quorum of peers is a
limited-authority local issuer the issuer itself appointed — a relying party
outside the mesh verifies a chain from the manifest alone.

## What this package secures (v0.3)

- **Issuer-bounded.** Peer set, ceiling and scope ceiling come from an issuer-signed manifest every object is bound to by hash; a peer cannot widen any of them locally, and nothing made under one manifest verifies under another (G6).
- **No unilateral self-grant.** A requester's own signature never counts toward quorum (`THREATMODEL.md` G1).
- **Threshold `⌈2N/3⌉` of N ≥ 4.** A manifest names at least five members, so every member has at least four peers. A minority — malicious or merely offline — can force fail-closed, never an unauthorized grant; two conflicting proofs for one position need `N/3` equivocators (G2/G3). A threshold, not consensus.
- **Bound to the whole decision.** Every attestation signs the digest of the entire request — scope, requester, timestamps, predecessor — and each round commits to the previous proof's digest, so a chain is hash-linked and a requester cannot swap the request after collecting signatures.
- **Extend-only, structurally.** No field in the wire format can widen scope; scope is fixed, byte-identical, for the life of a chain (G5).
- **Bounded exposure.** A ceiling measured from original issuance, never reset by a later round, terminates peer-attested authority even if the partition never heals (G4).
- **Adversarially tested.** Threshold-not-met, self-attestation, attester-outside-peer-set, request swapped after attestation, broken predecessor link, credential-claims mismatch, manifest splicing, tampered manifest signature, scope widening, scope outside the manifest ceiling, ceiling breach, nonce replay, chain-linkage defects, a full quorum padded with a non-member, a manifest too small for any requester, malformed or mistyped fields, integers outside the I-JSON range, strings with no canonical form, expiries past year 9999, signatures spelled in non-canonical base64, request times running backwards, attestation clocks outside tolerance and incomplete credential claims are all exercised as hostile-path tests and conformance vectors (35 of them), not just asserted. Hostile input is rejected with the failing stage, never raised as an exception. The wire objects are also stated in CDDL ([`conformance/renewal.cddl`](conformance/renewal.cddl)), checked against every vector.

## What this package does NOT do

- **Verify the original credential.** The credential being extended (a WIMSE token, a SPIFFE SVID, or anything else) is treated as an opaque hash. Authenticating it in its own format is the consumer's job — and a mandatory one: `verify_chain`, `evaluate_request` and `evaluate_and_attest` require its claims as `credential=` (every key in `CREDENTIAL_CLAIMS`), refuse without them, and check the root request against all of them. See `SPEC.md` §1.2, §9.2.
- **Claim there is no new trust.** No independent root authority is introduced, but the manifest's provisioning, clock agreement and attesters' health reports are assumptions the connected case did not need. `THREATMODEL.md` lists them.
- **Enforce revocation during a partition.** A revocation issued while the requester is severed cannot take effect until the partition heals — a structural residual, not a defect. See `THREATMODEL.md`.
- **Scope narrowing across rounds.** Not planned; scope is fixed for the life of a chain. See `SPEC.md` §1.2.
- **Provide transport, or decide who the issuer should list.** The manifest is verified, not authored, here.

## Features

- `sm_renewal.identity` — `did:key` Ed25519 identities, shared construction with `sm-arp`.
- `sm_renewal.manifest` — build/sign/verify for the issuer's `MeshManifest`, its hash, and the peer set it yields for a requester.
- `sm_renewal.renewal` — build/sign/verify for `RenewalRequest`, `PeerAttestation`, `RenewalProof`, and `RenewalChain`.
- Canonical serialization via RFC 8785 (JCS) — two independent implementations agree byte-for-byte.
- A deterministic conformance corpus (`conformance/vectors/`) any second implementation can replay to prove interoperability.

## Installation

```bash
pip install sm-renewal
```

Releases are published to PyPI and tagged automatically when the version in
`pyproject.toml` changes on `main` (see `PUBLISHING.md`).

## Quick start

```python
from sm_renewal import (
    Identity,
    build_mesh_manifest,
    build_renewal_request,
    evaluate_and_attest,
    assemble_proof,
    verify_chain,
)

issuer = Identity.generate()
requester = Identity.generate()
peers = [Identity.generate() for _ in range(4)]  # N=4, quorum = ceil(2*4/3) = 3

# Before any partition: the issuer pre-authorizes this mesh.
manifest = build_mesh_manifest(
    issuer,
    members=[p.did for p in peers] + [requester.did],
    ceiling_seconds=12 * 3600,
    scope_ceiling=["read:telemetry"],
    issued_at="2026-07-01T00:00:00Z",
    expires_at="2036-07-01T00:00:00Z",
)

# During the partition: the requester asks its peers for more time.
req = build_renewal_request(
    requester,
    manifest=manifest,
    original_credential_hash="sha256:" + "00" * 32,
    original_scope=["read:telemetry"],
    original_issued_at="2026-07-26T00:00:00Z",
    original_expiry="2026-07-26T04:00:00Z",
    requested_extension_seconds=3600,
)
# Every attester and relying party authenticates the original credential in
# its own format (a WIMSE token, an SVID) and passes its claims. Required.
credential = {
    "original_credential_hash": "sha256:" + "00" * 32,
    "requester_did": requester.did,
    "original_issuer_did": issuer.did,
    "original_scope": ["read:telemetry"],
    "original_issued_at": "2026-07-26T00:00:00Z",
    "original_expiry": "2026-07-26T04:00:00Z",
}
attestations = [
    evaluate_and_attest(
        peer, req, health_evidence="heartbeat_current", manifest=manifest, credential=credential
    )
    for peer in peers
]
proof = assemble_proof(req, attestations, manifest=manifest)

# Anywhere: a relying party verifies the chain under the manifest, against
# the claims of the credential it authenticated itself.
assert verify_chain([proof], manifest=manifest, credential=credential).ok
```

`examples/quick_start.py` is the executed version of this snippet (CI runs it).

## Reference fixtures

`conformance/vectors/*.json` — three valid chains, plus one vector per
hostile path (threshold not met, self-attestation, request swapped after
attestation, ceiling breach, nonce reuse, broken predecessor link,
credential-claims mismatch, manifest-hash mismatch, attester outside the
peer set, requester not a member, scope outside the manifest ceiling,
tampered manifest signature, round out of order, request times running
backwards, an integer outside the I-JSON range, an unpaired surrogate, an
expiry past year 9999, a signature re-spelled in non-canonical base64). Every vector carries the
manifest it is evaluated under and, where relevant, the authenticated
credential claims. Signing
keys in the vectors are fixed, non-secret, documented seeds — never real
keys. Regenerate with `python conformance/_vector_gen.py`; CI fails if the
checkout and the generator disagree.

`conformance/renewal.cddl` states the structure of every wire object in
CDDL (RFC 8610). `tests/test_cddl.py` checks it against every vector: each
well-formed object matches it, and each object malformed in a way CDDL can
state does not.

## Specification

- [`SPEC.md`](./SPEC.md) — normative wire/behaviour, working draft.
- [`WHITEPAPER.md`](./WHITEPAPER.md) — design rationale.
- [`THREATMODEL.md`](./THREATMODEL.md) — what it defends, and what it doesn't.
- [`draft/draft-chandra-wimse-partition-tolerant-renewal-00.txt`](./draft/draft-chandra-wimse-partition-tolerant-renewal-00.txt) — the Internet-Draft this package implements (Experimental, individual submission to the WIMSE working group). Source: `.mkd`; rendered `.xml`/`.txt` via `xml2rfc`.
- [agentclock.ai](https://agentclock.ai) — the paper *Borrowed Time* and its archive.

## Related packages

| Package | Role |
| --- | --- |
| [`sm-arp`](https://github.com/Sharathvc23/sm-arp) | Agency Receipt Protocol — the identity/`did:key` construction this package reuses, and the receipt family a settled `RenewalChain` fits alongside. |
| [`sm-divergence`](https://github.com/Sharathvc23/sm-divergence) / [`sm-resolver`](https://github.com/Sharathvc23/sm-resolver) | Corroborated discovery — a settled `RenewalChain` is a claim a corroboration record can carry alongside a registry's view, so "the registry says expired, the mesh extended" is visible divergence rather than silence. |
| [`sm-conformance`](https://github.com/Sharathvc23/sm-conformance) | Generic signed-badge conformance substrate, if a badge is ever wanted for this primitive. |

## License

[MIT](./LICENSE)

---

*First published: 2026-07-26 | Last modified: 2026-10-30*

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