feat(covenant): signed evidence, capability attenuation, accountable-intermediary modules - #26
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR. |
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughAdds three Covenant modules: signed execution evidence with agent chains, signed intermediary receipts, and attenuated capability delegation. Each module includes verification logic and focused Vitest coverage for tampering, expiry, denial, revocation, and retrieval behavior. ChangesEvidence standard
Capability attenuation
Accountable intermediary
Estimated code review effort: 5 (Critical) | ~90 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant EvidenceGenerator
participant AgentEvidenceChain
participant EvidenceStorage
Caller->>EvidenceGenerator: submit execution evidence
EvidenceGenerator->>AgentEvidenceChain: record envelope hash
AgentEvidenceChain-->>EvidenceGenerator: return chain metadata
EvidenceGenerator->>EvidenceStorage: store signed evidence
EvidenceStorage-->>Caller: return evidence
sequenceDiagram
participant DelegationRegistry
participant validateAttenuation
participant Ed25519
DelegationRegistry->>validateAttenuation: validate delegated capabilities
validateAttenuation-->>DelegationRegistry: return validation result
DelegationRegistry->>Ed25519: sign delegation
Ed25519-->>DelegationRegistry: return signature
DelegationRegistry->>Ed25519: verify delegation signature
sequenceDiagram
participant Client
participant ManagedIntermediary
participant DownstreamServer
participant ReceiptStorage
Client->>ManagedIntermediary: process request
ManagedIntermediary->>DownstreamServer: forward eligible request
DownstreamServer-->>ManagedIntermediary: return response
ManagedIntermediary->>ReceiptStorage: store signed receipt
ReceiptStorage-->>Client: return receipt and response
Possibly related PRs
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
src/lib/covenant/accountable-intermediary.test.tsOops! Something went wrong! :( ESLint: 10.8.0 TypeError [ERR_IMPORT_ATTRIBUTE_MISSING]: Module "file:///.eslintrc.json?mtime=1785801415162" needs an import attribute of "type: json" src/lib/covenant/accountable-intermediary.tsOops! Something went wrong! :( ESLint: 10.8.0 TypeError [ERR_IMPORT_ATTRIBUTE_MISSING]: Module "file:///.eslintrc.json?mtime=1785801415162" needs an import attribute of "type: json" src/lib/covenant/capability-attenuation.test.tsOops! Something went wrong! :( ESLint: 10.8.0 TypeError [ERR_IMPORT_ATTRIBUTE_MISSING]: Module "file:///.eslintrc.json?mtime=1785801415162" needs an import attribute of "type: json"
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Uh oh!
There was an error while loading. Please reload this page.
Summary
Adds three additive, standards-hardened Covenant modules under
src/lib/covenant/— extracted/hardened from reference drafts — plus vitest suites. This is Phase 1: land + prove the primitives. Nothing in the live 9-phase runtime (runtime.ts), routes,governance.ts,safety.ts, ortypes.tsis touched, so/api/requestis unchanged. Wiring these into the pipeline (and any trust-score model change) is a deliberate, design-gated Phase 2.Each reference draft had a real Ed25519 bug —
crypto.createSign('sha256')/key.export({format:'hex'}), which Node rejects for Ed25519. All three modules now reuse the existing./cryptoprimitives (generateKeyPair,signMessage,verifyMessage,sha256) with base64-DER keys/signatures, and share one recursive canonical encoder.evidence-standard.tsServer-signed, per-agent evidence envelopes (the current runtime uses HMAC/SHA-256 with a single global
lastEvidenceHash).canonicalEncode()— recursive, lexicographically key-sorted, whitespace-free JSON (the existinghmacHashObjectonly sorts top-level keys); rejects non-finite numbers, normalizes-0.EvidenceGeneratorsigns each envelope hash with an Ed25519 server key fromCOVENANT_EVIDENCE_SIGNING_KEY. Fail-closed:AgentEvidenceChain— one independent chain head per agent (removes the global-head race), plusverifyEvidence,getEvidenceChain,queryEvidenceByAgent/ByTime.capability-attenuation.tsDeterministic, signed delegation as an explicit
Capability {resource, action, constraints}model — offered alongside the existing trust-score delegation, not replacing it.validateAttenuation()proves delegatee ⊆ delegator (and can't loosenmax_amount);hasCapability()enforces grant/exclude/constraint/expiry/revocation.DelegationRegistrysigns delegations (signMessageovercanonicalEncode) and does cascading revocation (guards against re-processing already-revoked to terminate cycles).accountable-intermediary.tsSigned gateway/proxy decision receipts (new capability — no equivalent today).
ManagedIntermediary.processRequest()emits a signedIntermediaryReceiptforforwarded | cached | denied(429/403) | queued, committing to the request hash + decision;verifyReceipt()recomputes hash and checks the Ed25519 signature (any field tamper ⇒ invalid).Testing
npm test: 42 passed (was 29 on main) — 13 new tests, no new failures. Covers deterministic canonicalization, verify-true, prod fail-closed, tamper-every-section, per-agent chains, attenuation escalation rejection, denial codes, cascade revocation, receipt tamper detection.tsc --noEmit,npm run build,npm run lint: the only failures (route-context typegen error; ESLint 10 vs legacynext lintconfig) reproduce identically on cleanmain— pre-existing, not introduced here.Follow-up (Phase 2, not in this PR)
Wire
EvidenceGeneratorinto Phase 7 sealing +forwardEvidence; decide whether capability attenuation supersedes trust-score delegation (data migration); sourceCOVENANT_EVIDENCE_SIGNING_KEYvia Coolify. These need design sign-off before touching the live path.Link to Devin session: https://app.devin.ai/sessions/325c5e1802984dcd9189080f1493b466
Requested by: @reprewindai-dev
Summary by CodeRabbit