The local Rust policy-gate demonstration · Chapter 4 of 9

Gate

The agent accepts the stored row when all three checks hold:

  1. The decoded policy bytes rehash to policy_hash.
  2. policy_hash equals SHA-256 of the canonical body.policy.
  3. validate_policy_gate(request_hash) returns Y = 1 and 12 bearings for that same request_hash.

The agent then matches the action to the policy. Default is deny. The executable must be listed. The endpoint must be listed as both an upstream endpoint and a downstream endpoint. The region must be mutable. Immutable region text in the signed prompt must still match the document. The replacement length must be within max_patch_bytes.

A passing action writes exhibit_summary, marks the nonce SPENT, and stamps accept. A rule failure marks the nonce SPENT, leaves the document unchanged, and stamps reject. A policy or prompt mismatch stamps reject and leaves the nonce RESERVED. A second submit of a SPENT nonce stamps reject and does not apply the patch again.

There is no HMAC. Each scripted reply is a fixed proposal in the case list. cargo run --bin serve sends the submitted policy and prompt to the xAI Chat Completions API, then runs the same checks on the returned proposal. request_hash covers the policy and the prompt. The model reply stays outside that hash.