|
| 1 | +# `predicate-authorityd` Operations Guide |
| 2 | + |
| 3 | +This guide shows how to run the local sidecar daemon, provide a policy file, and verify health/status endpoints. |
| 4 | + |
| 5 | +## 1) Sample `policy.json` |
| 6 | + |
| 7 | +Create `examples/authorityd/policy.json`: |
| 8 | + |
| 9 | +```json |
| 10 | +{ |
| 11 | + "rules": [ |
| 12 | + { |
| 13 | + "name": "allow-orders-http-post", |
| 14 | + "effect": "allow", |
| 15 | + "principals": ["agent:orders-*"], |
| 16 | + "actions": ["http.post"], |
| 17 | + "resources": ["https://api.vendor.com/orders"], |
| 18 | + "required_labels": [] |
| 19 | + }, |
| 20 | + { |
| 21 | + "name": "deny-admin-delete", |
| 22 | + "effect": "deny", |
| 23 | + "principals": ["agent:*"], |
| 24 | + "actions": ["http.delete"], |
| 25 | + "resources": ["https://api.vendor.com/admin/*"], |
| 26 | + "required_labels": [] |
| 27 | + } |
| 28 | + ] |
| 29 | +} |
| 30 | +``` |
| 31 | + |
| 32 | +## 2) Start the daemon |
| 33 | + |
| 34 | +Run from repo root: |
| 35 | + |
| 36 | +```bash |
| 37 | +PYTHONPATH=. predicate-authorityd \ |
| 38 | + --host 127.0.0.1 \ |
| 39 | + --port 8787 \ |
| 40 | + --mode local_only \ |
| 41 | + --policy-file examples/authorityd/policy.json \ |
| 42 | + --policy-poll-interval-s 2.0 \ |
| 43 | + --credential-store-file ./.predicate-authorityd/credentials.json |
| 44 | +``` |
| 45 | + |
| 46 | +### Optional: enable control-plane shipping |
| 47 | + |
| 48 | +To automatically ship proof events and usage records to |
| 49 | +`predicate-authority-control-plane`, set: |
| 50 | + |
| 51 | +```bash |
| 52 | +export CONTROL_PLANE_URL="http://127.0.0.1:8080" |
| 53 | +export CONTROL_PLANE_TENANT_ID="dev-tenant" |
| 54 | +export CONTROL_PLANE_PROJECT_ID="dev-project" |
| 55 | +export CONTROL_PLANE_AUTH_TOKEN="<bearer-token>" |
| 56 | + |
| 57 | +PYTHONPATH=. predicate-authorityd \ |
| 58 | + --host 127.0.0.1 \ |
| 59 | + --port 8787 \ |
| 60 | + --mode local_only \ |
| 61 | + --policy-file examples/authorityd/policy.json \ |
| 62 | + --control-plane-enabled \ |
| 63 | + --control-plane-fail-open |
| 64 | +``` |
| 65 | + |
| 66 | +When enabled, daemon bootstrap auto-attaches `ControlPlaneTraceEmitter` so each |
| 67 | +authority decision pushes: |
| 68 | + |
| 69 | +- audit events -> `/v1/audit/events:batch` |
| 70 | +- usage credits -> `/v1/metering/usage:batch` |
| 71 | + |
| 72 | +## 3b) Optional local identity registry (ephemeral task identities) |
| 73 | + |
| 74 | +Enable local identity support: |
| 75 | + |
| 76 | +```bash |
| 77 | +PYTHONPATH=. predicate-authorityd \ |
| 78 | + --host 127.0.0.1 \ |
| 79 | + --port 8787 \ |
| 80 | + --mode local_only \ |
| 81 | + --policy-file examples/authorityd/policy.json \ |
| 82 | + --identity-mode local-idp \ |
| 83 | + --local-identity-enabled \ |
| 84 | + --local-identity-registry-file ./.predicate-authorityd/local-identities.json \ |
| 85 | + --local-identity-default-ttl-s 900 \ |
| 86 | + --flush-worker-enabled \ |
| 87 | + --flush-worker-interval-s 2.0 \ |
| 88 | + --flush-worker-max-batch-size 50 \ |
| 89 | + --flush-worker-dead-letter-max-attempts 5 |
| 90 | +``` |
| 91 | + |
| 92 | +Issue an ephemeral identity: |
| 93 | + |
| 94 | +```bash |
| 95 | +curl -s -X POST http://127.0.0.1:8787/identity/task \ |
| 96 | + -H "Content-Type: application/json" \ |
| 97 | + -d '{"principal_id":"agent:backend","task_id":"refactor-pr-102","ttl_seconds":120}' |
| 98 | +``` |
| 99 | + |
| 100 | +Inspect pending local ledger flush queue: |
| 101 | + |
| 102 | +```bash |
| 103 | +curl -s http://127.0.0.1:8787/ledger/flush-queue | jq |
| 104 | +``` |
| 105 | + |
| 106 | +List quarantined dead-letter items only: |
| 107 | + |
| 108 | +```bash |
| 109 | +curl -s http://127.0.0.1:8787/ledger/dead-letter | jq |
| 110 | +``` |
| 111 | + |
| 112 | +Manually trigger an immediate flush cycle: |
| 113 | + |
| 114 | +```bash |
| 115 | +curl -s -X POST http://127.0.0.1:8787/ledger/flush-now \ |
| 116 | + -H "Content-Type: application/json" \ |
| 117 | + -d '{"max_items":50}' | jq |
| 118 | +``` |
| 119 | + |
| 120 | +Requeue a quarantined item for retry: |
| 121 | + |
| 122 | +```bash |
| 123 | +curl -s -X POST http://127.0.0.1:8787/ledger/requeue \ |
| 124 | + -H "Content-Type: application/json" \ |
| 125 | + -d '{"queue_item_id":"q_abc123"}' | jq |
| 126 | +``` |
| 127 | + |
| 128 | +Flush worker behavior: |
| 129 | + |
| 130 | +- reuses control-plane client retry policy (`--control-plane-max-retries`, `--control-plane-backoff-initial-s`), |
| 131 | +- drains up to `--flush-worker-max-batch-size` queue items per cycle, |
| 132 | +- quarantines entries after `--flush-worker-dead-letter-max-attempts` failed sends, |
| 133 | +- sleeps `--flush-worker-interval-s` between flush cycles. |
| 134 | + |
| 135 | +Expected startup output: |
| 136 | + |
| 137 | +```text |
| 138 | +predicate-authorityd listening on http://127.0.0.1:8787 (mode=local_only) |
| 139 | +``` |
| 140 | + |
| 141 | +## 3) Endpoint checks |
| 142 | + |
| 143 | +### Health |
| 144 | + |
| 145 | +```bash |
| 146 | +curl -s http://127.0.0.1:8787/health | jq |
| 147 | +``` |
| 148 | + |
| 149 | +Example response: |
| 150 | + |
| 151 | +```json |
| 152 | +{ |
| 153 | + "status": "ok", |
| 154 | + "mode": "local_only", |
| 155 | + "uptime_s": 12 |
| 156 | +} |
| 157 | +``` |
| 158 | + |
| 159 | +### Status |
| 160 | + |
| 161 | +```bash |
| 162 | +curl -s http://127.0.0.1:8787/status | jq |
| 163 | +``` |
| 164 | + |
| 165 | +Example response: |
| 166 | + |
| 167 | +```json |
| 168 | +{ |
| 169 | + "mode": "local_only", |
| 170 | + "policy_hot_reload_enabled": true, |
| 171 | + "revoked_principal_count": 0, |
| 172 | + "revoked_intent_count": 0, |
| 173 | + "revoked_mandate_count": 0, |
| 174 | + "proof_event_count": 0, |
| 175 | + "daemon_running": true, |
| 176 | + "policy_reload_count": 1, |
| 177 | + "policy_poll_error_count": 0, |
| 178 | + "last_policy_reload_epoch_s": 1700000000.0, |
| 179 | + "last_policy_poll_error": null |
| 180 | +} |
| 181 | +``` |
| 182 | + |
| 183 | +## 4) Verify policy hot-reload |
| 184 | + |
| 185 | +1. Update `examples/authorityd/policy.json`. |
| 186 | +2. Wait for at most `--policy-poll-interval-s`. |
| 187 | +3. Check `/status` and confirm `policy_reload_count` increases. |
| 188 | + |
| 189 | +## 5) Stop daemon |
| 190 | + |
| 191 | +Press `Ctrl+C` in the daemon terminal. |
0 commit comments