Framework.SchemaRegistry (Framework v0.5.0)
View SourceSchema registry + digesting + append-time size/PII enforcement.
Implementation per wire-contracts-ci-gates.md:
- JSON Schema is single source of truth
- Schema registry with $id, x_schema_version, x_schema_digest, x_max_bytes, x_pii_tags
- Append-time enforcement BEFORE ExJsonSchema validation
- Transaction rollback on violations
- Boot loader reads schemas into ETS with digest verification
Enforcement order (binding):
- Check x_max_bytes size limit
- Check x_pii_tags violations
- Then validate JSON with ExJsonSchema
- Record schema markers for replay verification
Summary
Functions
Compute SHA256 digest of schema content.
Get schema information by schema_id.
Register a schema in the registry with full validation.
Validate payload against schema with append-time enforcement.
Verify schema digest matches current registry. Used during replay to detect schema drift.
Types
Functions
Compute SHA256 digest of schema content.
Digest is computed over the canonical JSON representation excluding the x_schema_digest field itself to avoid circular dependency.
Get schema information by schema_id.
Register a schema in the registry with full validation.
Schema must include:
- $id: Unique schema identifier
- x_schema_id: Same as $id for consistency
- x_schema_version: Integer version
- x_schema_digest: SHA256 digest of schema content
- x_max_bytes: Size limit (default 64 KiB, max 256 KiB)
- x_pii_tags: List of fields containing PII
@spec validate_payload(String.t(), map()) :: {:ok, %{ schema_id: String.t(), schema_version: integer(), schema_digest: String.t() }} | {:error, validation_error()}
Validate payload against schema with append-time enforcement.
Enforcement order per wire-contracts-ci-gates.md:
- Check x_max_bytes size limit
- Check x_pii_tags violations
- Validate JSON with ExJsonSchema
Returns {:ok, schema_markers} or {:error, validation_error()}
Verify schema digest matches current registry. Used during replay to detect schema drift.