Skip to main content

Module descriptor_json

Module descriptor_json 

Source
Expand description

Descriptors as data (impl plan §4 step 7), in the tr-grammar §7 conventions — internally tagged sums, records — as if descriptors were already Soil values. Named shapes serialize by name (ids are per-instance); loading is two-pass (declare all, then define all), which handles recursive types for free.

This format feeds the fixtures corpus and the C ABI’s registration entry point, and seeds plan 02’s --types env.json contract — but it is not frozen here; plan 02 freezes it in docs/soil0-cli.md.

[{"name": "SummaryRow",
  "strategy": {"tag": "Structural"},
  "body": {"tag": "Record", "value": [
    {"name": "count", "shape": {"tag": "U64"}, "ignored": null},
    {"name": "mean",  "shape": {"tag": "F64"}, "ignored": null}]}}]

Shapes: {"tag": "I64"} …, {"tag": "List", "value": <shape>}, {"tag": "Map", "value": {"key": <shape>, "value": <shape>}}, {"tag": "Named", "value": "Tree"}, {"tag": "Closure"}. Ignored defaults: null, {"tag": "Const", "value": <scalar>}, or {"tag": "CopyField", "value": "field_name"} (the serializable vocabulary; Native thunks cannot round-trip through data).

Functions§

descriptors_to_json
Serialize registered types back to the descriptor JSON format. Fails on Native ignored-defaults, which are code, not data.
load_descriptors
Load a JSON array of descriptors into the registry. Returns the new TypeIds in array order.
parse_shape_json
Parse one shape in the descriptor-JSON encoding ({"tag": "I64"}, {"tag": "Named", "value": "Doc"}, …) against the runtime’s registry. The entry point used by the fixtures harness.