1. Envelope parsing
Caller sends: { capability, credential?, request: { method, path, headers, body } }
2. Capability lookup
Broker finds the capability definition (registry or user-created)
3. Credential resolution
Determines which credential to use:
├─ Explicit: caller specifies --credential
├─ Scoped: workspace/group match
└─ Default: first credential for the capability's provider
4. Policy validation
├─ Request method in allow.methods?
├─ Request path starts with allow.pathPrefixes?
├─ Request host in credential's hosts list?
└─ Advanced policy (rate limits, body size, response blocklist)?
5. Auth injection
├─ Decrypt secret from vault
├─ Render auth template (Bearer {{secret}}, query param, path prefix, etc.)
└─ Inject into outgoing request headers/query/path
6. Request building
├─ Host derived from capability policy (not caller)
├─ Scheme always HTTPS
└─ Caller-supplied auth headers rejected
7. Upstream execution
Send request via HTTP client (reqwest + TLS)
8. Response sanitization
├─ Strip auth-class response headers
├─ Apply response body blocklist
└─ Return to caller