Skip to content

Concepts

Six architectural invariants govern every API route, browser script, and generated notice in PolicyGrain.

View .mdOpen llms.txt

API keys, scopes and account claiming

Every authenticated route accepts Authorization: Bearer with either a pgk_ API key or a 15-minute pgs_ web session token. Four scopes gate access: documents, sites:write, evidence:read (requires a verified account), and keys.

When a coding agent creates an unverified account via POST /v1/keys and the human owner later signs in via WorkOS, every pre-claim key becomes suspended (403 key_suspended) until the owner explicitly keeps or revokes it on /keys.

Questions, tiers and visibility

Tier 1 questions capture the core data-processing facts shown in the web app. Tier 2 questions refine optional clauses through the API and carry shows_if conditions evaluated deterministically against earlier answers.

Cited documents, provenance and material_version

Documents are assembled deterministically from pinned policygrain/legal-sources templates—never hallucinated per customer. Identical answer digests reuse content-addressed versions, and every clause retains its statutory register citation (such as DPDP Act s.5(1) or DPDP Rules r.3).

Owner answers vs agent-inferred answers

Answers submitted by coding agents are tagged source: 'agent_inferred' and hold generated documents in draft state until the human account owner confirms them via PATCH /v1/profiles/{id} with confirm.

Sites, verified domains and versioned banner configs

Each site verifies domain ownership via DNS TXT or HTTPS well-known challenge before live browser verification runs. Banner configurations are immutable numbered versions published to the CDN; incrementing material_version prompts returning visitors to re-confirm.

Consent receipts, trust classes and Merkle seals

Visitor choices arrive at POST /v1/receipts, are classified by origin and config match (origin_ok, origin_unexpected, config_mismatch, rate_flagged), written by an insert-only PostgreSQL role into a per-site SHA-256 chain, and sealed daily with Ed25519 Merkle roots.