Expand description
TC.3 — the config schema / value boundary: arena on the wire, tree in the host.
Design: docs/dev/architecture/typed-configuration.md.
WIT has no recursive types. A schema and a value are both trees, and the
obvious spelling — a variant whose arm holds another variant — does not
parse: “type config-schema depends on itself”. So both cross as an arena:
a flat list of nodes plus the index of the root, children referenced by
index. This module is where that arena becomes a tree and back.
§What the boundary has to defend against
An arena is guest-controlled input in a shape that invites two failures no other boundary in this crate has:
- an index that points nowhere — trivially rejected, and
- an index that points back up the tree, i.e. a cycle. Following one naively is unbounded recursion on the host’s stack, from a value a plugin chose. The tree-building walk therefore carries the set of nodes currently on its own path and refuses a node it is already inside.
Both are typed errors, never a trap and never a panic: a malformed
declaration registers nothing and the plugin is told so, the same contract
register-option has for a default that does not parse.
Enums§
- Arena
Error - What went wrong turning an arena into a tree. Rendered into the
false/ warn paths the config seam already uses — a guest never traps over one.
Functions§
- schema_
from_ wit - A guest’s schema arena as a
ConfigSchema. - schema_
to_ wit - A
ConfigSchemaas an arena for the guest. The mirror ofschema_from_wit, for:describe-option-shaped reads from a plugin. - value_
from_ wit - A guest’s value arena as a
ConfigValue. - value_
to_ wit - A
ConfigValueas an arena for the guest.