Metadata-Version: 2.5
Name: sm-renewal
Version: 0.2.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: coverage>=7.0; extra == 'dev'
Requires-Dist: mypy>=1.0; 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 Byzantine supermajority of peers 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.2)

- **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).
- **Byzantine quorum, `⌈2N/3⌉` of N ≥ 4.** A minority — malicious or merely offline — can force fail-closed, never an unauthorized grant (G2/G3).
- **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, manifest splicing, tampered manifest signature, scope-widening attempts, scope outside the manifest ceiling, ceiling breach, nonce replay, and chain-linkage defects are all exercised as hostile-path tests and conformance vectors (17 of them), not just asserted.

## 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 — the consumer's responsibility. See `SPEC.md` §1.2.
- **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,
)
attestations = [
    evaluate_and_attest(peer, req, health_evidence="heartbeat_current", manifest=manifest)
    for peer in peers
]
proof = assemble_proof(req, attestations, manifest=manifest)

# Anywhere: a relying party verifies the chain under the manifest.
assert verify_chain([proof], req, manifest=manifest).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, widened scope, ceiling
breach, nonce reuse, broken chain linkage, manifest-hash mismatch, attester
outside the peer set, scope outside the manifest ceiling, tampered manifest
signature). Every vector carries the manifest it is evaluated under. 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.

## 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)*
