closedhumanPR #141Auth

auth-safety-engineer: DelegatableAuth with scoped delegation, cascading revocation, and deterministic validators

Persona: auth-safety-engineer

Author

Status
Closed without merging
Opened on
Jul 9
Branch
hackathon/niruuu20-delegatable-auth

Description

The pitch.

## Layer picked: **Auth (#5)** — Problem 04

**Persona:** `auth-safety-engineer`

## Summary

Implements Problem 04: Delegatable capability tokens with cascading revocation.

This update addresses reviewer feedback by tightening DelegatableAuth behavior, splitting stale-parent and transitive-revocation attacks, enforcing audience binding, making delegation scope-gated, and removing nondeterminism from the jwt contrast path.

## What changed

- Merged latest `main` and resolved shared-file conflicts.
- Added documented auth plugin entry point in `packages/nest-plugins-reference/pyproject.toml`.
- Preserved `verify(token, presenter=None)` compatibility with the base Auth protocol.
- Changed delegated token verification to fail closed when `presenter` is omitted.
- Enforced audience binding for delegated tokens.
- Enforced `"delegate"` scope before a token can mint child tokens.
- Added adversarial leaf sub-delegation rejection.
- Split `stale_parent` from `transitive_revocation` in the scenario trace.
- Tightened validators to check event ordering and specific error reasons.
- Made YAML `root_scopes` and `delegation_tree` load-bearing in scenario construction.
- Fixed deterministic clock injection for `JwtAuth`.
- Reworked jwt contrast test to resolve paths from `__file__`, write traces to `tmp_path`, and swap layers with `model_copy`.
- Added property-style coverage for delegation validity and cascading revocation.

## Why this is distinct

Unlike baseline entries with hardcoded topology, this scenario makes `root_scopes` and `delegation_tree` load-bearing. The trace therefore proves configurable delegation behavior instead of only proving one fixed hardcoded path.

## Validation

```bash
uv sync
uv run ruff check .
uv run ruff format --check .
uv run pyright
uv run pytest -v
```

Optional local scenario validation:

```bash
nest run delegated_auth -o /tmp/delegated_auth.jsonl
python -c "
from pathlib import Path
from nest_core.validators import validate_trace
for r in validate_trace(Path('/tmp/delegated_auth.jsonl'), 'delegated_auth'):
    print(('PASS' if r.passed else 'FAIL'), r.name, r.detail)
"
```

## Reviewer feedback addressed

* Branch conflicts resolved and CI-equivalent checks run locally.
* `stale_parent` now revokes the direct parent, while `transitive_revocation` revokes the grandparent/root ancestor.
* Delegated token verification now fails closed when presenter is missing.
* Delegation now requires the parent token to hold `"delegate"` scope.
* YAML config now drives root scopes and delegation tree.
* Jwt contrast path now uses deterministic clock injection.
* Contrast test no longer depends on current working directory and no longer writes into repo `./traces`.

## Tradeoffs

* Keeps the delegation model tree-shaped rather than DAG-shaped for deterministic trace validation.
* Uses local deterministic token lineage rather than network introspection.

Try it

Open PR on GitHubView diff

Checkout locally

git fetch origin pull/141/head:pr-141
git checkout pr-141