How rqm reads YAML
How rqm reads YAML
Every requirement, the configuration and the baseline are read through one module, crates/rqm/src/yaml/, with the same options. This page lists them, and a test fails when the numbers below drift from the parser.
The pins
| Option | Setting | What it means for an author |
|---|---|---|
| Duplicate keys | error | Two equal keys in one mapping are E-YAML-DUPLICATE-KEY, at the second key. Keys that differ in case are different keys. |
| Merge keys | error | << is E-YAML-MERGE-KEY. |
| Legacy octal | off | 0755 is not an integer. Write 0o755, or 755 for the decimal number. |
| Booleans | strict | Only true, True, TRUE and the false forms are booleans. yes, no, on, off and y are plain strings. |
| Non-finite floats | rejected | .nan, .inf, -.inf and numbers such as 1e999 are E-YAML-NON-FINITE. |
| Tags | core tags only | !!str, !!int, !!float, !!bool, !!null and !!binary mean what YAML says. Any other tag is E-YAML-TAG. |
| Documents | exactly one | A second document is E-YAML-MULTIPLE-DOCUMENTS at its start, and an empty file is E-YAML-EMPTY. |
| Encoding | UTF-8 | Other bytes are E-YAML-ENCODING at the first bad byte. A byte order mark and CRLF line endings are accepted. |
Anchors and aliases are not specially handled. The parser accepts them within its limits, hashes are computed over the parsed model, and a document that relies on them is outside the contract.
rqm reads every scalar without asking the parser for a specific type, because a field typed as a float in the parser does not apply the non-finite rule: the text .nan arrives as a number. The typing of scalars is done by rqm itself, after the parse.
The limits
rqm sets no limit of its own on requirement YAML. The parser’s default limits apply, and a document that goes over one is E-YAML-LIMIT with the position of the breach. These are the values of the pinned version (serde-saphyr 2.0.0):
| Limit | Value | Meaning |
|---|---|---|
max_depth |
64 | nesting of sequences and mappings |
flow_nesting_limit |
255 | nesting of [ and { in one flow collection |
max_nodes |
250000 | nodes in one document, aliases counted when they are expanded |
max_events |
1000000 | parser events in one document |
max_total_scalar_bytes |
67108864 | bytes of all scalars together |
max_aliases |
50000 | alias uses |
max_anchors |
50000 | anchors |
max_documents |
1024 | documents in a stream (rqm accepts one) |
Rust source files that the later source scan reads have no size or depth limit of rqm’s own either.
The parse thread
The parser is recursive, so each document is parsed on a thread with a stack of 64 MiB (PARSE_STACK_BYTES). The memory is reserved and not used, and it is released when the parse ends. With it, a document that is nested exactly as deep as the limits allow parses in debug and release builds, and a document one level deeper is a diagnostic.