Skip to main content

Metadata Schemas

A declaration of what a resource's metadata must satisfy: one JSON Schema per resource type and selector, enforced by the resource's own write path.

Overview​

A document filed under a governed directory must carry metadata the directory's schema accepts. The check sits in the document's own write path, so it holds for every route a write can come through: create, update, restore and a formation apply alike. A write that violates it is refused with 400 VALIDATION_FAILED, and nothing is stored.

Documents are the only governed resource type. A path_prefix matches on a path boundary: /reports governs /reports/q1.txt and never /reports-archive/q1.txt. The reserved /.system root cannot be governed.

This module is a verbatim mirror of the runtime: every field, method, status code and error shape is the runtime's own, re-rooted under the project in the path.

See the OpenAPI spec for the full endpoint and schema reference, or browse it rendered under API Reference → Metadata Schemas.

Data Model​

MetadataSchema​

FieldTypeDescription
idstringPublic ID (mdschema_ prefix).
project_idstringThe project the declaration governs.
resource_typestringThe governed resource: document. Fixed at creation.
path_prefixstringThe directory a document declaration governs.
schemaobjectThe declared JSON Schema, stored as written.
created_atstring (date-time)
updated_atstring (date-time)

Key Concepts​

A declaration governs writes, not rows​

The schema is compiled when declared, so one that cannot compile is refused rather than stored. One selector has one schema per resource type; declaring a second is 409 NAME_CONFLICT.

Documents already stored are not re-judged. A declaration applies to a document the next time its path or metadata is written. Deleting a declaration leaves every stored document's metadata as it is.

resource_type cannot be changed by an update, because it decides which write path reads the declaration. To govern a different type, delete the declaration and declare again.

Checking before writing​

POST /v1/projects/{project_id}/metadata-schemas/validate answers what a write at a path would be told, without writing: valid, the refusing declaration's metadata_schema_id and path_prefix, and the violation in error. It reports and never enforces; the refusal is the write path's.

Who may do what​

Every route needs any project member.

Examples​

Declare a schema for a directory​

naturali create-metadata-schema \
--project-id proj_V1StGXR8Z5jdHi6B \
--resource-type document \
--path-prefix /reports \
--schema '{ "type": "object", "required": ["quarter"], "properties": { "quarter": { "enum": ["Q1", "Q2", "Q3", "Q4"] } } }'

Check metadata before a write​

naturali validate-metadata \
--project-id proj_V1StGXR8Z5jdHi6B \
--path /reports/q1.txt \
--metadata '{ "quarter": "Q5" }'

List the declarations in a project​

naturali list-metadata-schemas \
--project-id proj_V1StGXR8Z5jdHi6B \
--resource-type document