closedhumanPR #104Auth
hackathon/Implement delegatable capability tokens and scenario doctor
This PR contains the implementation of Delegatable Capability Tokens with Cascading Revocation (Phase 1) and the Scenario Doctor FastAPI validation service (Phase 2).
Author
@tanishaacodes
github profile →- Status
- Closed without merging
- Opened on
- Jul 8
- Branch
- hackathon/versioned-comms
Description
The pitch.
# Nanda Town Hackathon Submission: Phase 1 & Phase 2
This PR contains the implementation of **Delegatable Capability Tokens with Cascading Revocation** (Phase 1) and the **Scenario Doctor FastAPI validation service** (Phase 2).
---
## 1. File Changes & Architecture
### Phase 1: Auth Plugin & Verification
* [packages/nest-plugins-reference/nest_plugins_reference/auth/delegatable.py](file:///Users/tani/nandatown/packages/nest-plugins-reference/nest_plugins_reference/auth/delegatable.py):
- Class `DelegatableAuth` implementing the `Auth` interface protocol.
- Implements Macaroon-style HMAC chaining signature derivation for offline delegation.
- Recursively checks the delegation chain during `verify()` and raises `RevokedAncestorError` if any parent/ancestor JTI is marked revoked.
- Generates deterministic `jti` values using SHA-256 hashes of the payload to preserve simulation determinism.
* [packages/nest-core/nest_core/scenarios_builtin/delegated_auth.py](file:///Users/tani/nandatown/packages/nest-core/nest_core/scenarios_builtin/delegated_auth.py):
- Simulation scenario setup containing scope escalation, stale parent, and audience confusion attacks.
- Integrates a `VirtualClock` driven by the simulator's tick-based clock (`ctx.time`) for trace reproducibility across random seeds.
- Dynamically patches standard `jwt` auth at runtime to mock delegation layouts while omitting security checks.
* [packages/nest-core/nest_core/validators.py](file:///Users/tani/nandatown/packages/nest-core/nest_core/validators.py):
- Implements adversarial checks `validate_auth_no_scope_escalation`, `validate_auth_no_stale_parent`, and `validate_auth_no_audience_confusion`.
- Correlates trace events using `(jti, presenter)` tuples to prevent collision of stolen tokens.
* [scenarios/delegated_auth.yaml](file:///Users/tani/nandatown/scenarios/delegated_auth.yaml):
- Scenario configuration file using `auth: delegatable`.
### Phase 2: Scenario Doctor Service
* [apps/scenario-doctor/main.py](file:///Users/tani/nandatown/apps/scenario-doctor/main.py):
- Standalone FastAPI application.
- Endpoint `GET /health`: Basic health state check.
- Endpoint `GET /layers`: Lists the 12 system layers and valid reference plugins (including `delegatable`).
- Endpoint `POST /validate-scenario`: YAML structure checker validation.
- Endpoint `POST /lint`: Verifies config layers and plugins against known entries.
* [apps/scenario-doctor/Dockerfile](file:///Users/tani/nandatown/apps/scenario-doctor/Dockerfile):
- Multi-stage containerized setup using `python:3.12-slim` base image.
* [apps/scenario-doctor/railway.json](file:///Users/tani/nandatown/apps/scenario-doctor/railway.json):
- Configures the builder to run under the `DOCKERFILE` driver.
* [docs/hackathon/solutions/scenario-doctor-skill.md](file:///Users/tani/nandatown/docs/hackathon/solutions/scenario-doctor-skill.md):
- OpenClaw-compatible `SKILL.md` documenting curl invocation formats and schemas.
---
## 2. API Endpoints (Scenario Doctor)
### `GET /health`
* **Response**: `{"status": "ok"}`
### `GET /layers`
* **Response**: Dictionary mapping of NANDA Town's 12 layers and plugins.
### `POST /validate-scenario`
* **Input Content-Type**: `text/yaml`
* **Input Example**:
```yaml
name: test_scenario
duration: 100Try it
Open PR on GitHubView diffCheckout locally
git fetch origin pull/104/head:pr-104
git checkout pr-104