Skip to content

API Reference parrot_tools.legal.boe.hashing

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_tools.legal.boe.hashing

View source

Content-hash sealing for BOE article versions (FEAT-449 R3/R11).

The span existence gate (FEAT-449 span verifier) can only be deterministic if every stored articulo.versions[] entry carries a sealed content_hash computed over the exact text that is stored — hash what you store, slice what you stored.

HASH_NORM_VERSION MUST only be bumped alongside a migration plan: changing the normalization contract invalidates every previously stored span (recomputed hashes would no longer match, and existing span offsets would no longer index the same normalized text).

Attribute HASH_NORM_VERSION

Normalization contract version. Bump ONLY with a migration plan — changing this invalidates every stored span.

Function normalize_for_hash

Normalize text before hashing and storage.

Applies Unicode NFC composition and newline normalization (\r\n or \r -> \n). NOTHING else — no whitespace collapse, no stripping. Offsets derived later must index text identical to what the lawyer is shown (R11).

normalize_for_hash(text: str) -> str

Parameter Type Default Description
text str Raw extracted text.

Returns: str — NFC-normalized text with newlines normalized to \n.

Function seal_hash

Compute the sealed content hash over already-normalized text.

seal_hash(normalized_text: str) -> str

Parameter Type Default Description
normalized_text str Text that has already been passed through normalize_for_hash (or is otherwise known to already be in normalized form).

Returns: str — sha256 hex digest over the UTF-8 encoding of normalized_text.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally