Repository navigation
feat: Added Verifiable Agents - #766
Merged
Merged
Conversation
Collaborator
|
Thanks Abhay, this audit system is really well designed, the RFC 6962 Merkle tree and fail-closed signature checks especially. Merged via #772 with five fixes on top:
Regression tests added for all five, full suite green (4535 passed). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a cryptographically verifiable audit and provenance system to SynapseKit: hash-chained execution traces, batch Merkle signing (Ed25519 by default, pluggable KMS/BYOK), portable signed bundles, an independent verifier with a three-valued
MATCH/DRIFT/UNVERIFIABLEverdict, replay, PII redaction, OTel export, and aVerifiableAgentwrapper — plus a full CLI (synapsekit audit verify|replay) and examples.Closes #738
Type of change
Changes
synapsekit.auditpackage:types.py(AuditRecord,EventKindtaxonomy,Verdict,VerificationResult),serializer.py(deterministic canonical JSON hashing),trace.py(AuditTracer— hash-chained, two-levelpayload_hash→hashcommitment,actor, redaction metadata),merkle.py(RFC 6962 recursive-split tree with domain-separated hashing — avoids the CVE-2012-2459 duplicate-leaf class of bug),signer.py(SigningPolicystrategy: Ed25519 default, BYOK, AWS/Azure/GCP KMS interfaces, encrypted key export),bundle.py(export_audit_bundle/export_selective_bundle, signed manifest metadata, deterministic zip output),verifier.py(standaloneverify()— only needs stdlib +cryptography, supportstrusted_keyspinning for real non-repudiation),replay.py,redact.py(PIIRedactor, redacts before hashing),sink.py(File/S3/Kafka/OTel sinks, sync + asyncawrite),otel.py,metrics.py(wired into signing/export/verify/redact),wrapper.py(VerifiableAgentproxy +instrument_attrsfor capturing an agent's internal sub-component calls,@auditeddecorator).synapsekit audit verify bundle.zip [--trusted-key KEY_ID:BASE64]andsynapsekit audit replay bundle.zip, registered incli/main.py.examples/verifiable_agent.py,examples/audit_verify.py.cryptography>=42promoted to a core dependency (Ed25519 is the default signing algorithm and must work out of the box).synapsekit/__init__.pyexports the curated public API (AuditTracer,EventKind,Verdict,SigningPolicy,VerifiableAgent,verify_audit_bundle, etc.), aliased where names would otherwise collide with existing exports.Testing
uv run pytest tests/ -q)186 new tests in
tests/audit/(with theobserveextra installed for the Prometheus-gated metrics tests), covering: positive verification, all required tamper scenarios (removed/reordered/modified records, bad hash/payload_hash/merkle root/manifest/schema/parent_id/public key), key rotation, selective disclosure, replay (tool/retrieval/policy-hash matching, LLM-determinism-optional), redaction ordering and metadata, async sinks,instrument_attrs, CLI exit codes, andVerdictcategorization (DRIFTvsUNVERIFIABLE). Full repo suite: 4475/4479 passing (4 pre-existing failures unrelated to this change — missing optionalbs4/onnxruntimedeps and an external-binary test).Notes for reviewer
verify()withouttrusted_keysonly proves internal self-consistency (nothing edited after export) — it does not authenticate the signer, since public keys are otherwise read from the bundle's own manifest. Passtrusted_keys={key_id: public_key_bytes}for real non-repudiation.VerificationResult.trust_anchor("none"/"pinned") makes this explicit, and the CLI prints a warning when pinning isn't used.event_id/actor/payload_hash/reserved redaction fields) — bundles produced by earlier schema versions are not compatible with this verifier.AuditRecord.payloadis deep-frozen (MappingProxyType/tuples) to prevent post-hash mutation;AuditRecord.to_dict()unfreezes it back to plain JSON types for serialization.redaction_policy_hash/redaction_statusfields now specifically so those can be added later without another breaking bundle-format change.