Skip to content

Ariadne: a closed .ari schema every load checks, and ari validate - #1464

Merged
transfix merged 7 commits into
masterfrom
ariadne/schema-validator
Nov 24, 2026
Merged

transfix merged 7 commits into
masterfrom
ariadne/schema-validator

Conversation

@transfix

@transfix transfix commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

The .ari document format gets a formal, closed schema that every load checks, and ari validate (roadmap §15; docs/ARIADNE.md §14).

What changes

  • The schema: src/cvc/ariadne/schema/ari.v1.schema.json, one JSON Schema covering every top-level block (29 built in, plus the host blocks python, wasm, server, relay, world, the fragment's needs, catalog), all 35 built-in widget types, the scene (nodes, sources, materials, volume rendering, transfer functions, clip, shaders, physics bodies, lights, cameras, shadows, worlds, wind), include: and load: sites, data:, assets:, scenes:, args:, keys: and the rest, with a description on each. Every map is closed: an unknown key is an error, except x- keys anywhere, a custom widget's or custom node's own keys, and a top-level block an app registered or the document declares in customs:. A widget's type is its first type key in the loader's order (builtin_widget_types()), as an if/else chain in the schema. It keeps to json-schema-validator's draft-7 subset.
  • Compiled in and installed: CMake embeds the file (CMake/CvcEmbedText.cmake, a byte array; MSVC caps string literals at 16 KB) for ari_schema_json(), and installs it as share/libcvc/ariadne/schema/ari.v1.schema.json for editors.
  • Every load checks (when built with the validator): the document, each import:ed library, each load: fragment, and each include: expansion as a widget (placed at the unit's own file and line). Each problem is a warning (ari: schema: <file>:<line>:<col>: <context>: <pointer>: <message>) and a SchemaIssue in LoadResult::schema_issues. Messages are rewritten from the validator's ("unknown key 'bnd'", "'abc' is the wrong type here"), and an anyOf's per-branch failures collapse to the most specific one. The compiled validators live in a cvc::app slot, built at first use; no process-wide state.
  • validate_string / validate_file: check structure without loading, including each of the document's own units: instantiated with its declared args.
  • ari validate [--structural-only] [--strict] [--json] doc.ari...|- prints compiler-style file:line:col lines, then loads each document without running it and lists the loader's warnings. Exits 0 valid / 1 schema problem / 2 load failure (or a warning with --strict) / 3 bad YAML / 4 built without the validator. ari schema prints the schema.
  • CI: package-linux's configure assertion now also requires "Ariadne: .ari Layer-2 JSON-Schema validation ENABLED", so that lane can't silently lose the validator. macOS and Windows get the validator from the recipe but are not asserted (I did not verify every runner has it).

Behaviour change

A load now warns about keys and values it used to ignore silently, and ari test fails a document that warns. All 184 shipped .ari files are valid (their includes, imports and fragments too). The one fix was src/ari/tests/reopen_refit.ari, which had no meta.min_libcvc. Five loader tests that feed deliberately bad values now count only the loader's own warnings, and also check that the schema flags the same pointer.

A PR that adds a loader key needs a schema entry beside it, or a load warns "unknown key" and EveryShippedDocumentIsValid fails. This branch adds scene: clock: hz from #1441 (a whole number from 10 to 240, as sim_rate_valid takes it), and ClockBlockTakesAWorldsRate checks the schema agrees.

Merge order: this PR lands after the open PRs that add loader keys. Their CI never ran the validator, so if this merged first, the next of them to land would break EveryShippedDocumentIsValid on master. 81b75bb carries their keys ahead of their merge:

Key From
notifications: always, as well as a flag #1450
a tray_icon's icon: and auth: #1450
a color picker's fmt: rgb | hex #1452
a load:'s name: (a key or an expression) #1485
scene: clock: max_lag: (more than 0, at most 10 s), in the scene and in a scene of its own #1475

Master's own new keys need no entry (master merged in as 7ead208, no rebase):

The documents #1450, #1452, #1480 and #1482 add or change (12 files) are valid against this schema. Once they have merged:

Tests

  • New ariadne_schema_test:
    • the embedded schema matches the file;
    • the schema keeps to the draft-7 subset;
    • every built-in widget type and block is in it, in the loader's order;
    • every widget schema is closed over the shared keys;
    • mistakes are found at the right pointer, line and column, and a load warns the same;
    • valid forms are accepted;
    • registered and declared blocks are allowed;
    • units are checked with their declared args;
    • a load checks expansions, libraries and fragments, reporting a template problem once;
    • several apps check apart, including on threads;
    • every shipped document is valid.
  • New ctests for ari validate (examples valid; a deliberately invalid fixture found line by line, in text and JSON) and ari schema.

Not done

  • Schema fragments a host registers for its custom widget and node types: their own keys stay unchecked.
  • meta.schema version selection: the version is in the file name and $id.
  • A Python copy of the file: the installed file serves Python's jsonschema.

Verified locally

Windows, MSVC 14.44, a build with json-schema-validator 2.4.0 (no cvcGL, no pycvc), rebased on f310173:

  • ariadne_schema_test: 13 pass, 1 skipped by design (WithoutTheValidatorNothingIsChecked).
  • ariadne_loader_test: 258 pass.
  • Every ctest matching [Aa]ri (1,190, including the ari validate / ari schema ctests): all pass.
  • Before the rebase, the full suite (8,108 tests): the only failures were a thread-timing test that passes alone and four AriMedia snapshot tests that also failed on that master here.
  • loader.cpp compiles without the validator define.

With master merged in (7ead208) and the open PRs' keys added (81b75bb), on the same build:

Not verified locally: cvcGL tests, pycvc tests, wasm, Linux and macOS. The 95 inline documents in the cvcGL, arigl, arisrv, Python and Ariadne runtime, data, host and world test sources were checked against the schema with Python jsonschema. The three hits are deliberately bad values whose tests are unaffected: a physics body in cvcgl_ariadne_physics (it asserts on realize warnings), a bad.name data entry in ariadne_data_test (it asserts the loader's warning is there), and show_isocontours: maybe in ariadne_runtime_test (it counts reactive warnings, not load warnings).

The .ari document's structure gets a formal definition, roadmap section 15,
now docs/ARIADNE.md section 14:

- src/cvc/ariadne/schema/ari.v1.schema.json: one JSON Schema for every
  top-level block, all 35 built-in widget types, the scene, include: and
  load: sites, with descriptions. Every map is closed: an unknown key is an
  error, except x- keys, a custom widget's or node's own keys, and a block an
  app registered or the document declares in customs:. A widget's type is its
  first type key in the loader's order. It keeps to json-schema-validator's
  draft-7 subset.
- CMake embeds it (CvcEmbedText.cmake) for ari_schema_json() and installs it
  under share/libcvc/ariadne/schema/.
- With the validator built in, every load checks the document, its import:ed
  libraries, its load: fragments and each include: expansion (placed in the
  unit's own file), as warnings and LoadResult::schema_issues with line and
  column. The compiled validators live in a cvc::app slot.
- validate_string / validate_file check without loading, the document's own
  units instantiated with their declared args.
- ari validate [--structural-only] [--strict] [--json] and ari schema.
- ci.yml: package-linux's configure assertion also requires the validator.

All 176 shipped documents are valid; reopen_refit.ari gains its missing
meta.min_libcvc. Five loader tests that feed bad values count the loader's own
warnings and check the schema flags the same pointer. New ariadne_schema_test
and ctests for ari validate and ari schema.
OW8 (#1441) gave the scene's clock an hz key: a whole number of ticks a
second from 10 to 240, as sim_rate_valid takes it. The schema takes it the
same way in both clock entries, and ClockBlockTakesAWorldsRate checks that the
schema accepts hz: 60 and flags each rate the loader warns about.
wasm: takes a guest's path alone and relay: a relay's URL alone, as
their readers do; a bare server: or world: sets nothing, as theirs do.
The schema took a map only, so WasmWasiTest's `wasm: all.wat`, under
min_libcvc 3.7.13, failed its load on Linux.
The closed schema lands after the PRs that add loader keys, so it carries
their keys now:

- notifications: always, as well as a flag (#1450);
- a tray_icon's icon: and auth: (#1450);
- a color picker's fmt: rgb | hex (#1452);
- a load:'s name:, a key or an expression that names the application
  (#1485);
- scene: clock: max_lag:, more than 0 and at most 10 s, in the scene and
  in a scene of its own (#1475).

Master's own new keys need none: #1472's look: wheel:, wheelbase: and
track: sit in world:, which the world rules check, and #1399's region: is
a custom node's own key.

AcceptsWhatTheLoaderTakes takes each new form; FindsEachMistakeWhereItIs
finds fmt: cmyk and notifications: sometimes.
loader.cpp conflicted where master edited the inline schema this branch
replaces (#1450's notifications: always); the closed schema already has it,
so the branch's side stays.

The schema gains the keys master now reads:
- #1495 (merged): a camera's position, target, up, fov, near, far,
  orthographic and height;
- #1491 (open): a scene node's on_pick.
loader.cpp conflicted where both sides add functions after load_file, in the
yaml build and in the stub: this branch's validate_string/validate_file and
master's parse_value (#1477). Both kept.
@transfix
transfix merged commit 8d27f6a into master Nov 24, 2026
29 of 31 checks passed
@transfix
transfix deleted the ariadne/schema-validator branch November 24, 2026 00:10
transfix added a commit that referenced this pull request Nov 24, 2026
loader.cpp conflicted where #1464 turned is_builtin_block into a table
(kBuiltinBlocks): its table kept, with prototypes added to it.

#1464 checks every load against the closed .ari schema, so it gains this
branch's keys:
- a top-level prototypes, a map of name to an object, checked only for its
  args: (a prototype's values may hold {name} tokens its instances fill in,
  as a unit's do);
- use (string) and args (a map of scalars) on node_builtin and node_custom.
docs/ARIADNE.md's Prototypes says what the schema checks.
transfix added a commit that referenced this pull request Nov 24, 2026
The closed schema (#1464, merged into this branch from master) gains a
material's pbr (a flag, or { metallic, roughness, emissive, coat } with coat a
number or { strength, roughness }) and environment in both scene definitions (a
flag, none, or { sky, horizon, ground }). Checked with the validator built in:
ariadne_schema_test 13 (one skip), ariadne_loader_test 263, and
pbr_materials.ari and cvcgl_ariadne_pbr's document validate.
transfix added a commit that referenced this pull request Nov 24, 2026
…ay, region, water_level)

The closed .ari schema (#1464) checks a source: { data } node against
node_builtin. GB3 part 2 reads look, water, underside, texture and sway on
it, and GB2 reads region and water_level, so each was an unknown key.
transfix added a commit that referenced this pull request Nov 24, 2026
… ...) into p9/volume-grid-segment

#1464 checks every load against the closed schema, which already takes a
color picker's fmt: rgb | hex. ColorWidgetFmtHexDrawsTheHexPicker counted
every warning of its fmt: hsv load; it now counts the loader's own, as
#1464's loader tests do, and checks that the schema flags that fmt where
it is when the validator is built in.
transfix added a commit that referenced this pull request Nov 24, 2026
* Ariadne: physically based materials and the scene's environment

A geometry node's `material: { pbr: { metallic, roughness, emissive, coat } }`
shades it with VTK's PBR instead of Phong, and `scene: environment: { sky,
horizon, ground }` lights it from all round (image-based lighting from a
generated gradient). A scene with a pbr: node and no environment: gets a
default one; `environment: false` uses the lights alone. Gap item 5 of the
scene-format plan.

- GeometryNode::setPBR, setMetallic, setRoughness, setEmissive, setCoat
  (state keys pbr, metallic, roughness, emissive_r/g/b, coat, coat_roughness).
  Three post-replacement edits to VTK's PBR shader, on both its poly-data
  mappers: the base colour read as sRGB (made linear) as a Phong surface takes
  it; the lights' sum times pi, so a light lights a PBR surface face on as
  brightly as a Phong one with diffuse 1; emissive without an emissive texture.
- SceneGraph::setImageBasedLighting / setEnvironment / resetEnvironment: an
  8-bit sRGB equirectangular gradient, +z up, following the scene onto a new
  renderer; ViewportManager's mirrors copy it with the lights.
- Loader: SceneNode::pbr_*, Scene::environment_*; realize_scene turns the
  environment on; apply_node_material (and mesh_lab's copy) switch pbr: nodes.
- docs/ARIADNE.md §5.4 "Physically based materials"; example
  examples/ariadne/documents/pbr_materials.ari.
- Tests: cvcgl_pbr_material (pixels against VTK's BRDF in closed form),
  cvcgl_ariadne_pbr, loader PbrMaterialAndEnvironment.

* Ariadne schema: material: pbr: and the scene's environment:

The closed schema (#1464, merged into this branch from master) gains a
material's pbr (a flag, or { metallic, roughness, emissive, coat } with coat a
number or { strength, roughness }) and environment in both scene definitions (a
flag, none, or { sky, horizon, ground }). Checked with the validator built in:
ariadne_schema_test 13 (one skip), ariadne_loader_test 263, and
pbr_materials.ari and cvcgl_ariadne_pbr's document validate.
transfix added a commit that referenced this pull request Nov 24, 2026
* Ariadne: keyframe animation, a scene's animations:

A scene's `animations:` moves its nodes (position, rotation, scale, color,
opacity, visible) or writes state keys along keyframes over the scene clock:
linear, step or smooth (cubic Hermite, Catmull-Rom tangents, flat at the ends)
between keys; once, loop or pingpong at the end; a speed (below 0,
backwards) and autoplay. A node id names every node with it (each repeat:
copy's child), a path a/b one. Each animation's <prefix>.animations.<id>.time,
.playing and .speed are written as it plays and read each frame, so a script
seeks, plays, pauses and changes its speed. An animated scene runs on the
scene clock, as clock: {} would make it. Gap item 7 of the scene-format plan.

- New inc/cvc/ariadne/scene_animation.h / src/cvc/ariadne/scene_animation.cpp:
  SceneAnimation, SceneAnimationTrack, sample_track, advance_animation,
  node_key_width (no renderer).
- Loader: parse_scene_animations; bad tracks left out with a warning.
- Realizer: RealizedScene::animations (SceneAnimationBinding), realize_animations
  (start pose, clock on), tick_scene_animations in tick_scene after physics and
  clip sync.
- docs/ARIADNE.md §5.4 "Animations".
- Tests: ariadne_loader_test AnimationsParsed, AnimationTrackSampling,
  AnimationPlayback; cvcgl_ariadne_animation.

* Ariadne schema: a scene's animations:

The closed schema (#1464, now on master) gains $defs/animation and
$defs/animation_track, and animations: in both scene definitions (scene: and a
scenes: entry). Checked with the validator built in: ariadne_schema_test 13
(one skip), ariadne_loader_test 265, and cvcgl_ariadne_animation's document
validates.
transfix added a commit to cy-pca/nicotina that referenced this pull request Nov 24, 2026
…hint: it never read (#38)

libcvc 4.0.7's ari validate (transfix/libcvc#1464) checks a document against the .ari
schema, whose every map is closed. tests/run.sh now runs it: each file's structure on its own
(--structural-only), then main.ari's load with --strict, which reaches site.ari, nicotina.ari
and the ui/ includes and fails on a loader warning too. An ari without validate (before 4.0.7,
which also has no `ari schema`), or one built without json-schema-validator (exit 4), skips.

It found one: ui/dm.ari's Passphrase input_text had a hint:, a key only message_input reads.
The loader ignored it, so the field never showed it; it goes, and nothing on screen changes.
transfix added a commit that referenced this pull request Nov 24, 2026
…1520)

* Ariadne: keyframe animation, a scene's animations:

A scene's `animations:` moves its nodes (position, rotation, scale, color,
opacity, visible) or writes state keys along keyframes over the scene clock:
linear, step or smooth (cubic Hermite, Catmull-Rom tangents, flat at the ends)
between keys; once, loop or pingpong at the end; a speed (below 0,
backwards) and autoplay. A node id names every node with it (each repeat:
copy's child), a path a/b one. Each animation's <prefix>.animations.<id>.time,
.playing and .speed are written as it plays and read each frame, so a script
seeks, plays, pauses and changes its speed. An animated scene runs on the
scene clock, as clock: {} would make it. Gap item 7 of the scene-format plan.

- New inc/cvc/ariadne/scene_animation.h / src/cvc/ariadne/scene_animation.cpp:
  SceneAnimation, SceneAnimationTrack, sample_track, advance_animation,
  node_key_width (no renderer).
- Loader: parse_scene_animations; bad tracks left out with a warning.
- Realizer: RealizedScene::animations (SceneAnimationBinding), realize_animations
  (start pose, clock on), tick_scene_animations in tick_scene after physics and
  clip sync.
- docs/ARIADNE.md §5.4 "Animations".
- Tests: ariadne_loader_test AnimationsParsed, AnimationTrackSampling,
  AnimationPlayback; cvcgl_ariadne_animation.

* Ariadne schema: a scene's animations:

The closed schema (#1464, now on master) gains $defs/animation and
$defs/animation_track, and animations: in both scene definitions (scene: and a
scenes: entry). Checked with the validator built in: ariadne_schema_test 13
(one skip), ariadne_loader_test 265, and cvcgl_ariadne_animation's document
validates.

* model: a file's clips, skins and morph targets, and posed()

cvc::model reads a file's animations as clips (node channels' translation,
rotation and scale keys in seconds, step or linear/spherical; morph weight
channels), each mesh's skin (bones on their nodes with their offsets, each
vertex's influences, weights summing to 1) and morph targets (position and
normal deltas, rest weights), through assimp. local_transforms(clip, t) and
posed(clip, t) evaluate them: morph targets blended, a skinned mesh placed by
its bones, every other mesh by its node's animated transform, in merged()'s
vertex order. instances() is the same walk over the authored transforms.

Tests: model_test ModelClips (a glTF animation read as a clip; nodes moved
linear, spherical and step, morph weights blended; a two-bone skin; a model
without clips poses as merged).

* Ariadne: a model's own clip in an animation, { node, clip }

An animations: track { node: robot, clip: walk } draws the node's model (the
file its source: names) posed as far into its clip as the animation has run:
the file's node keys, skins and morph weights (cvc::model::posed), on the CPU
each frame, written into the node's mesh in place with its fit: kept. An
animation with no duration: lasts as long as its longest clip. A clip the
model lacks (naming the ones it has), a node with no model file, and a mesh
that is not the model's (an LOD ladder, a model: in its place) are refused.

- scene_animation.h: SceneAnimationTrack::clip; loader parses clip tracks.
- scene_geometry: SceneFit, scene_fit / apply_scene_fit (fit_to_ground is
  built on them, unchanged), read_scene_node_model.
- scene_realize.cpp: bind_clip at realize, pose_clip_track each frame.
- Schema: an animation track's clip.
- docs/ARIADNE.md §5.4 Animations: a model's own clip.
- Tests: cvcgl_ariadne_clip, ariadne_loader_test AnimationClipTracks.
transfix added a commit that referenced this pull request Nov 25, 2026
…derer (GB3 part 2) (#1508)

* world: a data node's world dataset draws with the generated-world renderer (GB3 part 2)

A source: { data } node whose dataset is a world (a city bundle such as
Austin, a saved world, a generate: generated_world dataset) now draws as
the generated_world node draws its own: terrain LOD chunks on the
dataset's ground (ground.png, else satellite.png at its own width and
height), the props' LOD cells, buildings, roads and water.

world_nodes: DataWorldView and DataWorldTask make the drawn world with
world_from_bundle from what the decoder left in the store, off the frame
thread, and put it in through the generated node's install, under the
data node's group. The renderer's parts are found or made through
find_part / make_part, the ground texture has a width and height, and
the per-frame work is one tick_world shared by both nodes.

scene_realize: every data node gets a view and a pending_work probe;
sync_scene_data loads a world dataset into it or clears it; tick_scene
ticks it; finish_scene_data runs the draws to their end. The plain draw
stays for a terrain with a live texture and for non-world datasets.

world_from_bundle draws only items with role_render.

* schema: a data node's world keys (look, water, underside, texture, sway, region, water_level)

The closed .ari schema (#1464) checks a source: { data } node against
node_builtin. GB3 part 2 reads look, water, underside, texture and sway on
it, and GB2 reads region and water_level, so each was an unknown key.

* ari test: give FramesAndTimeout's stuck document 5 s, not 1, so a Debug load can't use it up

The run's clock starts before the document loads. On CI's Debug job (on
master too) the load took over a second, so the 1 s timeout ran out before
test 'waits' began and the message had no "in test 'waits'".
transfix added a commit that referenced this pull request Nov 25, 2026
…ext_menu:)

Master's #1476 gave every backend a built-in context menu on text (Cut,
Copy, Paste, Select text..., ARIADNE.md 5.28) and 5.29 a picture's Save.
SH8's context_menu: now joins that menu instead of running beside it:

- One request opens one menu. Over a widget with entries of its own
  (a field, a text, a picture) those come first, then under a rule the
  items of the innermost context_menu: around it; over anything else
  inside one, its items alone; with none around, #1476's menu as is.
- ImGui: the document's areas live in #1476's ContextMenus. A menu a
  text or field opens remembers the innermost area, which appends its
  items to the same popup; elsewhere the area opens one through the
  same open()/begin() (its long press, Escape, one claim a frame).
- FTXUI: #1476's ctx menu holds the leaf's entries and keeps the
  area's items as rows after them; one Shift+F10 / Menu path, one
  right-click path. The duplicate key decoding is gone (master had it).
- tvision: Options::host_draws_context_menu; hosted_context_menu() and
  pick_context_entry() let the bridge show the menu with popupMenu at
  its place, so a short window no longer cuts it off. That was the
  failing ari_run_context_menu_tvision: a two-row window drew the menu
  as an empty frame.
- The section is ARIADNE.md 5.30; 5.28 points to it. The closed schema
  (ari.v1.schema.json, from #1464) learns context_menu on the document,
  groups, panels, windows, overlays, custom widgets and include sites,
  and kBuiltinBlocks lists it.
- Picks: pick_props takes master's node map (id and node, for a node's
  own on_pick:); CustomEdit keeps both events and context_pick.

The ImGui test for SH8 is cvcgl_imgui_document_menu (master's
cvcgl_imgui_context_menu keeps its name); FTXUI gains
AFieldInACardOffersItsOwnEntriesThenTheCards and
AHostedContextMenuIsAModelForTheHost; the context_menu golden now shows
the text's Copy and Select text... above the card's items.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant