TypedMark Schema Boundary
The schema/json-schema/ directory contains machine-readable JSON Schemas (draft
2020-12) for the governed TypedMark artifacts. They validate document shape so
that tools, editors, CI pipelines, and agents can catch authoring errors early
without re-deriving the artifact contracts from prose.
The prose specification is the single source of truth. The schemas complement it and never override it: where a schema and the specification disagree, the specification wins and the schema has a bug.
Artifact map#
| Governed artifact | JSON Schema |
|---|---|
typedmark.md |
typedmark.schema.json |
<metadata_directory>/schemas/<note_type>.md |
note-type.schema.json |
<metadata_directory>/property-sets/<property_set>.md |
property-set.schema.json |
<metadata_directory>/history.md |
history.schema.json |
marketplace.json (marketplace repository root; plain JSON, not Markdown) |
marketplace.schema.json |
| shared blocks (field definitions, storage, relationships, headings, …) | defs.schema.json |
Managed notes are deliberately not covered: their frontmatter is validated against the collection's effective note-type schemas, which only exist after the semantic layer composes property sets and inheritance. A document schema cannot express them.
What the schemas enforce#
- required and allowed keys per artifact, with
additionalProperties: falsewherever the specification closes the key set - scalar types, identifier grammars (
name, slugs, field names), and enums (kind, property types, formats, severities, archive policies, history ops) - local conditional rules:
type: listrequiresitems,type: link/timerequire a matchingformat,const_value/value_from_schemaexclusivity, per-type constraint applicability (not_blank,regex,min/max,allowed_values,unique,computed), abstract types not declaring composition references, archive-policy-dependent required keys,versionrequiringscaffold, field operations declaring exactly one ofnote_type/property_set - the core-defined field contracts for
note_type,id,deleted, andarchivedwhere schemas or property sets declare them
What stays in the semantic layer#
These rules are normative but cannot (or should not) be expressed in JSON Schema:
- filesystem checks: file basename equals
note_type/property_set, template files exist under<metadata_directory>/templates/, artifact locations derive frommetadata_directory - cross-file resolution:
extendschains and cycle detection, property-set references,exclude_property_setsmembership indefault_property_sets,frontmatter_removetargeting inherited fields, relationship and fieldtargetsresolving to note types, composition source resolution - effective-schema computation: the evaluation pipeline, block merge rules, and the required effective keys for concrete note types
- value semantics:
default_value/const_value/allowed_valuesconformance to the declared type,min <= max, regex dialect, storage placeholder resolution, generation-strategy value production, shared expression-language syntax, consumer-specific reference resolution, transform validity, null handling, and stored-value agreement (all tool / validator-time behaviors) - managed-note conformance: note-type association, canonical field materialization, note-link syntax and resolution, allowed unresolved placeholder links, relationship instance counting and cardinality, heading rules, storage-path conformance including archived state
- system evolution: history version ordering and uniqueness, the replay invariant, migration impact computation, composition determinism and the canonical serialization
- conformance modes: valid system definition and valid instantiated collection
Fixtures#
schema/fixtures/ contains three buckets:
valid/— artifacts that MUST pass their schemainvalid-shape/— artifacts that MUST fail their schema; each file's body names the violated ruleinvalid-semantic/— artifacts that MUST pass their schema but are invalid under the semantic layer; see the README in that folder
Run the expectations with:
bun run validate-fixtures
Fixtures are mapped to artifact schemas by filename prefix (typedmark-*,
note-type-*, property-set-*, history*, marketplace*). Markdown fixtures
are validated through their extracted frontmatter; .json fixtures, the
marketplace catalog, are validated directly.
Recommended validation workflow for implementations#
- extract the governed artifact's frontmatter per the Frontmatter Block Grammar and parse it as YAML
- validate document shape with the matching JSON Schema
- build effective models (composition, inheritance, property sets)
- run semantic validation against the prose rules
- report shape failures separately from semantic failures, using the severity
model of
validation_defaults
Maintenance rules#
- every normative change to a governed artifact's shape MUST update the JSON Schemas and the fixtures in the same change
- every schema change MUST keep
bun run validate-fixturespassing - rules the schemas cannot express MUST be listed in this document
- schemas MUST NOT silently redefine or extend normative prose behavior