closedhumanPR #207Auth
bounded_delegation: cap chain depth, let the revocation set forget
delegatable and mesh_revocable get the crypto right. They just never stop growing — in two directions — and neither growth breaks an invariant, which is why the existing validators wave it all through.
Author
@sobingt
github profile →- Status
- Closed without merging
- Opened on
- Jul 26
- Branch
- hackathon/sobingt-bounded-delegation
Description
The pitch.
`delegatable` and `mesh_revocable` get the crypto right. They just never stop growing — in two directions — and neither growth breaks an invariant, which is why the existing validators wave it all through. **Depth.** `delegate` appends a segment and re-signs, unbounded, offline. 2000 delegations make a 215 KB token whose `verify` runs ~400x slower than a root's. The verifier pays, so one holder slows down every agent it presents to. **Revocations.** The G-Set never forgets. An expired entry is already unforgeable — expiry rejects the token before `_revoked` is even consulted — so keeping it buys nothing and costs every replica memory and every gossip round bytes. `BoundedDelegationAuth` subclasses `MeshRevocableAuth`: token format, HMAC chain, attenuation, and CRDT replication all inherited, with `TestInheritedBehaviour` pinning that nothing regressed. It adds: - `max_depth`, checked at `delegate` *and* at `verify` — a strict verifier must refuse a chain a laxer minter allowed (`test_stricter_verifier_rejects_laxer_mint`) - expiry-based pruning behind `prune_grace` — pruning a G-Set is only safe for entries past expiry, and the grace window keeps a stale peer from resurrecting one while it could still matter. Entries merged from peers carry no known expiry and are never pruned. Four validators, all FAIL against `jwt` / `delegatable` / `mesh_revocable`, all PASS here. One of them, `check_depth_attack_refused`, exists so a scenario can't pass just by never provoking the bound. ```bash uv sync && uv run ruff check . && uv run ruff format --check . && uv run pyright && uv run pytest -v uv run nest run scenarios/bounded_delegation.yaml ``` 1365 passed, ruff and pyright clean, 54 new tests. The scenario (14 agents, 100 ticks) is seed-invariant: audit digests are byte-identical under seeds 42, 7, and 1337. Swap `auth:` to any of the three merged plugins and the checks flip to FAIL. `DEFAULT_MAX_DEPTH = 8` is a judgement call — the shipped trees are depth 3, so 8 leaves room. Happy to change it, or make `prune_grace` an explicit deployment decision rather than a default.
Try it
Open PR on GitHubView diffCheckout locally
git fetch origin pull/207/head:pr-207
git checkout pr-207