Skip to content

Governance Pipeline

Every AI call wrapped with verify.govern() flows through a 5-stage pipeline:

DEFINE → OBSERVE/PRE-EVALUATE → EXECUTE → POST-EVALUATE → PROVE

Load governance rules from a pack (EU AI Act, HIPAA, custom). Resolve rules, thresholds, and scoring configuration.

Capture the prompt, model, and parameters. Run pre-call governance rules. If a critical rule fails, the pipeline short-circuits — no AI call is made.

Call your AI function, capture the response, timing, and token usage.

Run post-call governance rules on the response. Compute fidelity scores across all scoring dimensions.

Build a Merkle tree from all recorded events. Sign the root with ML-DSA-65 + Ed25519 via @brivora/crypto. Link to previous proof if chaining. Return the complete GovernResult.

interface GovernResult<T> {
output: T; // The AI call's return value (passthrough)
proof: BrivoraProof; // Cryptographic governance proof
valid: boolean; // Did all governance checks pass?
report: ComplianceReport; // Human-readable compliance report
score: FidelityScore; // Composite governance score
events: GovernanceEvent[]; // Full event chain (if audit: true)
timing: {
total: number; // Total ms including governance overhead
aiCall: number; // Ms for the AI call alone
governance: number; // Ms for governance evaluation
proof: number; // Ms for proof generation
};
}

The Merkle tree is the core data structure that makes proofs tamper-evident.

[Root Hash] ← Signed with PQC
/ \
[Hash AB] [Hash CD]
/ \ / \
[Hash A] [Hash B] [Hash C] [Hash D]
| | | |
Event 0 Event 1 Event 2 Event 3
(GOVERN_ (PROMPT_ (MODEL_ (POST_
LOADED) RECEIVED) INVOKE) EVAL)

Each leaf is the SHA-3-256 hash of a serialized event. Internal nodes are SHA3-256(left || right). The root hash is signed. To verify: reconstruct the tree, compute the root, verify the signature. If any event was modified, the root changes, and the signature is invalid.