Skip to main content

Module parse

Module parse 

Source
Expand description

TOOLSET.md parse pipeline.

The public entry point is parse_toolset. It reads TOOLSET.md from the given toolset directory, splits the YAML frontmatter, drives the bounded iterative-event parse, validates all fields, and returns a typed Toolset.

§Parse pipeline

  1. Read TOOLSET.md (256 KiB size cap before parse).
  2. UTF-8 decode (non-UTF-8 → NotUtf8; never a panic).
  3. Split the leading ----fenced frontmatter.
  4. Drive the yaml-rust2 ITERATIVE event pull loop over the frontmatter string.
    • Each event is pulled one at a time via Parser::next_token() — the parser’s state machine uses an explicit heap stack; there is no C-stack recursion on the pull path (only Parser::load is C-stack recursive; we do not call it).
    • Reject YAML anchors/aliases at the event level (pre-expansion).
    • Track nesting depth (both BLOCK and FLOW); exceed 8 → FrontmatterTooDeep. Because we stop pulling events the instant depth > MAX_DEPTH, C-stack depth stays O(1) for any nesting; scanner heap is bounded by the 256 KiB file cap (a single-line flow document may buffer up to the capped input as tokens — finite, no OOM/overflow — before the depth bound fires).
    • Track keys at each mapping level; duplicate → DuplicateKey.
  5. Map the event stream to a Frontmatter struct.
  6. Validate name / description / compatibility.
  7. Extract and parse the capability manifest.
  8. Return Toolset or the first ToolsetFormatError.

Structs§

Toolset
A parsed and validated toolset.

Functions§

parse_toolset
Parse and validate a toolset directory.