Principle:A5c ai Babysitter Argument Canonicalization
| Knowledge Sources | |
|---|---|
| Domains | Cryptography, Canonicalization, Policy_Enforcement |
| Last Updated | 2026-10-23 00:00 GMT |
Overview
A method for producing a single, loss-preserving canonical serialization of arguments and commands for consistent hashing across trust boundaries.
Description
Argument Canonicalization is the principle of ensuring that the same logical value always produces the same bytes, regardless of key order or formatting. The canonicalizer:
- Deep-sorts object keys so key order does not matter
- Preserves array order (position is significant)
- Preserves value types (no coercion)
- Fails closed on non-representable values (NaN, ±Infinity, bigint, function, symbol) — never silently coerces
The canonical string is hashed (SHA-256) to produce argsHash and commandHash used in policy enforcement gates. The same canonicalizer is used byte-for-byte by both the proxy producer and every verification gate, ensuring hash consistency.
Usage
Use this principle when building systems that hash arguments or commands across trust boundaries where hash mismatches would cause false denials or false approvals.
Theoretical Basis
The canonicalization is a recursive normalization:
canonicalize(value):
null/undefined -> null
number -> value (throw if non-finite)
string/boolean -> value
array -> [canonicalize(e) for e in array] // preserve order
object -> { sorted_keys: canonicalize(values) } // deep-sort keys
other -> throw (fail closed)
argsHash = sha256(canonicalizeArgs(value))
commandHash = sha256(canonicalizeArgv(command).join('|'))
Key property: The canonicalizer is shared byte-for-byte between the producer (proxy) and the verifier (gate). This eliminates hash drift — the same arguments always produce the same hash on both sides.
TOCTOU prevention: The gate recomputes the hash from the actual runtime arguments and compares to the authorization's hash, preventing time-of-check-to-time-of-use attacks.