GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — docvera/crates/docvera-cli/assets/schema.md at main · a5i/docvera

Expand file tree

/

schema.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
193 lines (138 loc) · 13.4 KB
/

schema.md

Copy path

File metadata and controls

193 lines (138 loc) · 13.4 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

Schema DSL v1

This is a document-schema envelope, not a JSON Schema dialect. frontMatter is a normal JSON Schema value; body, identity, relations and lint are engine extensions. Unknown envelope/DSL fields are rejected rather than silently ignored.

Generated JSON Schemas

docvera schema config > docvera.config.schema.json
docvera schema document > docvera.document.schema.json

These JSON Schema 2020-12 contracts are generated by schemars from the same Rust types used for Serde deserialization. They describe field names, types, defaults, required fields and unknown-field rejection, plus supported version constants. They are not a replacement for semantic Rust checks (regex validity, cross-field cardinality constraints, schema compilation, path confinement and file existence). The CLI still loads configuration with Serde and validates semantics in Rust; it does not run a second validation pass against the generated schema.

Associate the saved files with your editor. For example, in schemas/note.yaml:

# yaml-language-server: $schema=../docvera.document.schema.json
schemaVersion: 1
documentType: note

For TOML editors supporting schema directives, place #:schema ./docvera.config.schema.json at the top of docvera.toml. JSON envelope files can use an editor-side file association. Do not add an envelope $schema property just to select this editor contract: unknown envelope fields are rejected. A Markdown document's front-matter $schema continues to select its document schema, not this generated meta-schema.

docvera schema check-result and diagnostic generate contracts for serialized results. docvera contract --format json includes all five generated schemas under jsonSchemas; docvera guide --format json includes that same contract. schema itself prints a bare schema, without a result envelope, and needs no workspace. The $id URNs identify format versions; they are not hosted download URLs.

Resolution and workspace

docvera.toml is the canonical workspace configuration (docvera init creates it):

version = 1
include = ["docs/**/*.md"]
exclude = ["docs/drafts/**"]

[schemas]
"docs/adr-*.md" = "schemas/adr.yaml"

# Optional: policies are standard SHACL in separate Turtle files.
[validation.shacl]
shapes = ["policies/relations.ttl", "policies/lifecycle.ttl"]

Omit [validation.shacl] to run local/schema/reference checks without SHACL. An enabled section requires a non-empty explicit list of local .ttl paths; no globs or remote downloads. See SHACL policies and RDF vocabulary.

Legacy docvera.yaml remains supported with the equivalent version, include, exclude, schemas, and validation.shacl.shapes structure. Exactly one config may exist: having both docvera.toml and docvera.yaml is an operation error, with no merging or precedence. To migrate, translate the workspace config into TOML and remove docvera.yaml; document schemas remain YAML/JSON and Markdown front matter supports YAML/TOML. Unknown configuration keys and versions are rejected.

Paths are relative to the workspace and normalized to / in results. Directory symlinks are not followed, symlink files are not discovered as documents. .git, .docvera, target and node_modules are always skipped. Includes/excludes use globset semantics, not .gitignore semantics. By default all included files require a schema ([validation] untyped = "error"). Set untyped = "skip" to retain untyped documents as reference targets but omit their diagnostics, including parse/link/SHACL findings. An explicit invalid/missing $schema or ambiguous mappings still produce errors. Multiple matching mappings are an error unless a document provides an explicit selector.

A document's front-matter $schema takes precedence and resolves relative to that document. Schema files must be inside the canonical workspace root; remote selection is unsupported. The selector is a reserved engine field, removed only from the copy of metadata passed to JSON Schema validation. It remains available in the IR.

Front matter is recognized only at the very beginning, after an optional UTF-8 BOM: YAML opens with --- and closes with --- or ...; TOML opens and closes with +++. Delimiter lines must contain exactly the delimiter (LF/CRLF supported). Both formats are enabled by default; [frontMatter] yaml = false / toml = false disables recognition of that format so it remains Markdown. Other positions and delimiters are Markdown. An enabled opener without a closer reports yaml.unclosed / toml.unclosed; malformed content reports yaml.parse / toml.parse, rather than silently becoming Markdown. Values must form a mapping; duplicate keys are errors. BOM and line endings stay unchanged in the source/hash; all spans count bytes in the whole original document. YAML and TOML parser locations supply individual token spans for relations and SHACL (including array items); unlocatable values fall back conservatively to the whole front matter. Front-matter JSON Schema errors currently highlight the whole front matter. See checker.md and shacl.md.

TOML dates/times become ISO-formatted strings in JSON metadata. Non-finite TOML floats (nan, inf) are rejected with toml.parse because they have no JSON value; they never silently become null.

Parser configuration

[parser]
tables = true
strikethrough = true
taskLists = true
footnotes = false
gfm = false                   # includes GFM alert block quotes
math = false
wikilinks = false
smartPunctuation = false
headingAttributes = false
definitionLists = false
superscript = false
subscript = false

[frontMatter]
yaml = true
toml = true

[validation]
untyped = "error"              # or "skip" for editor-oriented workspaces

The values above are the defaults. pulldown-cmark metadata extensions are always off: the engine handles front matter separately. Unknown parser/front-matter fields are rejected. CLI, embedded and WASM checks use the same parser settings, which participate in the workspace fingerprint. The IR still stores selected node kinds, not a complete AST for every enabled extension. Use the same dependency revision and options in other readers; engine heading anchors follow the policy documented below, not renderer-specific slug conventions.

Envelope

Required: schemaVersion: 1, non-empty documentType. Optional: frontMatter, identity, body, relations, lint.

Front-matter JSON Schema supports normal validation/composition, including internal $ref/$defs. External $ref retrieval is disabled (file and network). Do not assume support for $ref between separate document-schema envelopes or for body-schema composition.

identity:

identity:
  field: frontMatter.id
  uniqueWithin: documentType  # workspace | documentType | directory

The field must resolve to a non-empty string. Collisions are reported on every affected document. Internal database keys are relative paths, never declared IDs, so invalid duplicate documents remain visible in SQL. Without an identity rule, the conventional string id is still exposed for link resolution, but uniqueness is not enforced. Directory scope means the same immediate parent directory, not recursive descendants.

Body and section trees

A section starts at its heading and ends before the next heading of the same or higher level. Parent is the nearest preceding lower-level heading. Code fences are parsed as code, never as headings. ATX and Setext headings are supported; heading matching uses parsed visible inline text, not raw Markdown delimiters.

Every body/children container has:

Field Default Meaning
sections [] Rules for immediate child sections
ordered true Matched rule indexes must be nondecreasing
additionalSections false Allow unmatched sections and their subtrees
allowPreamble false At the document root only, allow non-whitespace before first heading

Each section rule requires exactly one heading matcher:

  • title: exact, case-sensitive text.
  • pattern: Rust regex (use ^…$ for a full match).
  • titleEquals: string metadata field, e.g. frontMatter.title.

Other fields:

Field Default Meaning
level parent level + 1; root 1 Required absolute heading level, 1–6
min 1 Minimum occurrences among immediate siblings
max 1 Maximum occurrences; use an explicit finite number for repetition
nonEmpty false Require non-whitespace direct content before the next heading
children closed, empty container Rules for nested sections
content [] Node-count constraints on direct section content

Optional section: min: 0. Repeated section: min: 0, max: 20. If an optional section exists, its content/children still must validate. Missing ancestors do not trigger all missing-descendant diagnostics. Missing sections/cardinality failures point to the parent section, or document span at root.

With strict ordering, repetitions of a rule must remain grouped; A, B, A is invalid when the rule order is A, B. Unknown headings do not advance the rule cursor. If one heading matches multiple rules, the engine emits body.ambiguous and uses the first match for further diagnostics. Avoid overlapping regexes.

The default body is closed and empty: omitting it does not implicitly permit arbitrary headings. To allow any document structure, explicitly use body: { allowPreamble: true, additionalSections: true }.

Content

content:
  - kind: paragraph
    min: 1
  - kind: code
    language: bash
    min: 1
    max: 3

Kinds: paragraph, code, list, table, blockquote. language is only valid for code and matches the first fenced-info token exactly; indented code has no language. min defaults to 1, max is unbounded when omitted. Counts use node start positions in direct section content; nested AST blocks (e.g. paragraphs inside lists) also count. Child sections do not satisfy a parent's content constraints. Unmentioned node kinds are permitted. This prototype does not validate arbitrary block sequences, prohibit node kinds, or inspect table column schemas. nonEmpty checks raw non-whitespace content, not semantic prose.

Relations and links

relations:
  - from: frontMatter.related
    targetType: feature
    min: 1
    max: 5
    mustExist: true

A source field is a string or array of strings; missing field means zero entries. Use either targetType: feature for one allowed type or targetTypes: [feature, requirement] for alternatives. Every target must have one of the allowed types; this does not require every listed type to be represented. Both fields together, an empty targetTypes list, blank names or duplicate names in that list are schema errors. If neither field is specified, any document type is accepted. min defaults to 0, max is unbounded, mustExist defaults to true. Targets may be IDs (FEATURE-0042 or id:FEATURE-0042), paths relative to the source document, and optional #anchor fragments. Typed relations narrow ID candidates by the allowed type or types; multiple candidates remain ambiguous. mustExist: false suppresses only missing-target errors, not wrong types, ambiguous references or invalid anchors. Body Markdown links/images are always checked independently; their edge kind is link.

Reference statuses: resolved, missing, ambiguous, wrong-type, missing-anchor, outside-workspace, invalid-encoding. Files outside the workspace cannot be link targets. Existing non-Markdown assets without an anchor are accepted but not graph nodes. Markdown targets must be included documents. Links with URI schemes other than id: and protocol-relative links are skipped; external availability and URL safety are not validated. HTML <a>/custom anchors are not resolved. Logical ID paths are case-sensitive; filesystem lookup follows OS rules.

Anchor policy: lowercase Unicode letters/numbers, preserve _ and -, replace each whitespace with -, discard other characters. Resolve collisions by appending -1, -2, etc. until unused (including collisions with explicitly suffixed headings). This is an explicit PoC policy, not a guarantee of GitHub/GitLab slug parity. URL percent escapes are decoded before lookup.

Cross-document policies

Cross-document policies use SHACL, not a custom YAML assertion DSL. Configure local Turtle shape files in docvera.toml under [validation.shacl]. The engine projects current documents and resolved references into an in-memory RDF graph, runs pinned Rudof SHACL Native validation, and translates results into Markdown diagnostics. See SHACL policies and the executable design-invariants example. A constraints key in a document schema is not supported.

Lint and diagnostics

lint:
  noSkippedHeadings: true
  noTrailingSpaces: true

Both rules default to false; both emit warnings, separate from schema errors. Trailing-space lint is literal and can flag Markdown hard breaks and code lines; leave it off when those are intentional. No automatic fixes.

Diagnostic fields: path, span, rule, severity, message. Rules are namespaced (yaml.*, schema.*, body.*, identity.*, relation.*, link.*, shacl.*, lint.*). Diagnostics are sorted deterministically. See contracts/v1.json for offset and exit-code conventions.

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.