Skip to content

feat(rust): read YAML, resolve sources and config, add naming (R3) - #603

Merged
dmealing merged 7 commits into
mainfrom
fm/mo-rust-parity-sources
Nov 18, 2026
Merged

dmealing merged 7 commits into
mainfrom
fm/mo-rust-parity-sources

Conversation

@dmealing

@dmealing dmealing commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

What Changed

  • Rust port (step R3) reads a real project. The loader now reads YAML authoring files into the same node model and canonical output as the JSON loader (ADR-0006 desugar: bare type keys take the default subtype, scalar body is the name, [] suffix is isArray, sigil-free attributes, anchors/aliases, the ERR_YAML_COERCION guard, ERR_MALFORMED_YAML, and a line and column on every error from a YAML file), and the crate resolves a project the way the other ports do: the .metaobjects/config.json reader (same schema and defaults as the TypeScript reader), the four source kinds, directory discovery (symlinks followed, _pending skipped), the embedded iam/ai library sources (build.rs embeds the repo-root library/ deliberately; the crate is publish = false), and naming — strategies, pluralizers and the collection-name collision check. New saphyr dependency.
  • Conformance: source-resolution-conformance (all 28 cases) and naming-conformance pass in full; yaml-conformance passes 15 of 19. The four ledgered fixtures stay ledgered on purpose — error-yaml-coerced-bool-in-int and error-yaml-coerced-num-in-enum expect the attribute-schema pass's ERR_BAD_ATTR_VALUE after the coercion error, and yaml-ref-root-escape and yaml-reporting-via-of-bare need the ADR-0059 reference rules; all four belong to the validation lane (PR 602 stack), as do 11 newer metamodel fixtures that fail unlisted. Ledgers may only shrink.
  • load_bench gained an optional json|yaml|project mode argument (json stays the default, so PR 602's committed 20x baseline comparison is unchanged), and the merge with origin/main keeps lane A's per-phase timing and validate module while timing the YAML parse/desugar as its own phase beside json parse.

Load-time (20x model, release build):

Path Baseline After Peak memory
JSON 15.7–18.4 ms 14.9–18.1 ms 33.5 → 33.6 MB
YAML (new path) — 35.6–40.8 ms (~2.3× JSON) 34.0 MB
Project config read + directory walk — ~21 µs —
File text + library sources — 43–97 µs —

Re-measured on a machine at load average ~50: wall-clock not comparable, peak memory JSON 34.8 MB / YAML 35.7 MB and the phase ratios are the reliable readings.

This branch overlaps merged PR 602 in CHANGELOG.md, examples/load_bench.rs, src/lib.rs and src/loader.rs, so it stays rebasable.

Gate. Two no-mistakes runs. Run 1 found two parity bugs against the TypeScript reference (sibling error indices after an unreadable YAML child; one ERR_YAML_COERCION per bad string-array element), both fixed with tests; its Test step recorded an exception for a first-command cargo fmt --check failure the pipeline fixed before the full affected CI passed. Run 2, after merging PR 602, passed with no findings.

Validation

Risk Assessment

✅ Low: The change is a well-bounded port checked line-for-line against the TypeScript reference and pinned by four conformance corpora plus behavior tests; the two recorded round-1 fixes are correctly applied, the merge with lane A keeps both sides' work (yaml phase beside json phase, bench mode argument with json default), and no concrete failing sequence, intent contradiction, or unrequired component was found.

Testing

Exercised the merged Rust loader end-to-end: the shared yaml-conformance corpus (19 fixtures, 4 lane-A-ledgered) through the real Loader plus the source-resolution and naming corpora and the config/project-load suites all passed; the two run-1 adversarial regressions passed; load_bench ran in json, yaml and project modes with the yaml phase row present and lane A's baseline comparison intact with json still the default. No failures; no UI surface so no screenshots. Broad regression was the already-passing configured command scripts/ci_local.sh --affected --strict-toolchains.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Rust loader reads the shared yaml-conformance corpus (19 fixtures) with only the 4 lane-A-ledgered fixtures failing, and the source-resolution + naming corpora pass ✅ pass live cargo test --test yaml_conformance --test source_resolution_conformance --test naming_conformance all ok; ledger file lists exactly error-yaml-coerced-bool-in-int, error-yaml-coerced-num-in-enum, yaml…
load_bench example accepts json|yaml|project modes: yaml shows its own parse-and-desugar phase row, project times config read + directory walk, json stays the default and the committed 20x baseline co… ✅ pass live load-bench-json.txt / load-bench-yaml.txt / load-bench-project.txt plus the --baseline run showing the baseline delta columns on the json phase table; peak memory 34752 KiB json / 35548 KiB yaml, matc…
Adversarial re-check of the run-1 fixes: an unreadable YAML child keeps later sibling indices stable, and a string-array with multiple non-string elements reports one ERR_YAML_COERCION per bad element ✅ pass live cargo test --test loader_edges -- a_bad_yaml_child_keeps_later_sibling_indices_stable string_array_coercion_reports_every_bad_element: 2 passed
Evidence: load_bench json mode (phase table + baseline-compatible default)
    Finished `release` profile [optimized] target(s) in 0.02s
     Running `{run-worktree}/server/rust/target/release/examples/load_bench 20 5 json`
model: 20 copies of the fitness model, 714 KiB of JSON, 7140 nodes
registry compose: 1.972128ms
load (parse, merge, extends, references), median of 5: 32.088863ms

load phase                    ms
json parse                 4.708
tree build                15.889
merge                      1.493
super resolution           0.477
validation                 0.000
reference resolution       7.271
freeze                     0.167

validation passes: none implemented yet

peak memory: 34764 KiB

resolved reads of every node (children, attrs, is_array), first pass fills the cache, median of 5: 8.573969ms
resolved reads of every node, from the cache, median of 5: 401.27µs
canonical serialize, median of 5: 33.286713ms
Evidence: load_bench yaml mode (yaml parse and desugar phase row)
    Finished `release` profile [optimized] target(s) in 0.01s
     Running `{run-worktree}/server/rust/target/release/examples/load_bench 20 5 yaml`
model: 20 copies of the fitness model, 781 KiB of YAML, 7140 nodes
registry compose: 1.497468ms
load (parse, merge, extends, references), median of 5: 65.294822ms

load phase                      ms
yaml parse and desugar      38.730
tree build                  15.107
merge                        1.354
super resolution             0.353
validation                   0.000
reference resolution         7.131
freeze                       0.168

validation passes: none implemented yet

peak memory: 35588 KiB

resolved reads of every node (children, attrs, is_array), first pass fills the cache, median of 5: 9.852092ms
resolved reads of every node, from the cache, median of 5: 357.578µs
canonical serialize, median of 5: 34.969662ms
Evidence: load_bench project mode (config read + directory walk)
    Finished `release` profile [optimized] target(s) in 0.02s
     Running `{run-worktree}/server/rust/target/release/examples/load_bench 20 5 project`
project: config read + directory walk (20 files), median of 5: 59.212µs
project: read every file's text plus the library sources, median of 5: 103.025µs
peak memory: 4776 KiB
Evidence: Conformance and loader-edge test transcripts
== cargo test --test yaml_conformance --test source_resolution_conformance --test naming_conformance ==
running 7 tests
test already_plural_pluralizer_pair ... ok
test collection_segments ... ok
test a_conflicting_primary_source_pair_is_refused ... ok
test cross_package_collision_is_scoped ... ok
test physical_names ... ok
test collision_cases_are_refused ... ok
test shape_only_cases_are_accepted ... ok
test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.04s
running 1 test
test every_case_resolves_as_pinned ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s
running 1 test
test yaml_corpus ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.08s

== cargo test --test config_reader --test project_load --test loader_edges ==
running 29 tests
test result: ok. 29 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
running 13 tests
test result: ok. 13 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s
running 3 tests
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Rust loader reads the shared yaml-conformance corpus (19 fixtures) with only the 4 lane-A-ledgered fixtures failing, and the source-resolution + naming corpora pass ✅ pass live cargo test --test yaml_conformance --test source_resolution_conformance --test naming_conformance all ok; ledger file lists exactly error-yaml-coerced-bool-in-int, error-yaml-coerced-num-in-enum, yaml…
load_bench example accepts json|yaml|project modes: yaml shows its own parse-and-desugar phase row, project times config read + directory walk, json stays the default and the committed 20x baseline co… ✅ pass live load-bench-json.txt / load-bench-yaml.txt / load-bench-project.txt plus the --baseline run showing the baseline delta columns on the json phase table; peak memory 34752 KiB json / 35548 KiB yaml, matc…
Adversarial re-check of the run-1 fixes: an unreadable YAML child keeps later sibling indices stable, and a string-array with multiple non-string elements reports one ERR_YAML_COERCION per bad element ✅ pass live cargo test --test loader_edges -- a_bad_yaml_child_keeps_later_sibling_indices_stable string_array_coercion_reports_every_bad_element: 2 passed
  • scripts/ci-local.sh --affected --strict-toolchains
  • cargo test --test yaml_conformance --test source_resolution_conformance --test naming_conformance (in server/rust/metaobjects)
  • cargo test --test config_reader --test project_load --test loader_edges
  • cargo test --test loader_edges -- a_bad_yaml_child_keeps_later_sibling_indices_stable string_array_coercion_reports_every_bad_element
  • cargo run --release --example load_bench -- 20 5 json
  • cargo run --release --example load_bench -- 20 5 yaml
  • cargo run --release --example load_bench -- 20 5 project
  • cargo run --release --example load_bench -- 20 3 --baseline baselines/load-20x.json (default mode = json)
  • Broad regression: scripts/ci_local.sh --affected --strict-toolchains already ran and passed at this target commit (baseline run)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…eview)

The Rust loader reads authoring YAML (ADR-0006 desugar, the coercion guard,
line and column on every YAML error), and the crate resolves a project: the
.metaobjects/config.json reader, source kinds, directory discovery, the
embedded iam and ai library sources, and the naming strategies, pluralizers and
collection-name collision check. Passes yaml-conformance 15 of 19, and
source-resolution-conformance and naming-conformance in full.
Keep lane A's per-phase timing and validate module alongside the YAML, source,
config and naming work: the YAML parse and desugar is its own timed phase, and
load_bench keeps its phase tables with json, yaml and project modes.
@dmealing
dmealing merged commit a3a8aba into main Nov 18, 2026
10 checks passed
@dmealing
dmealing deleted the fm/mo-rust-parity-sources branch November 18, 2026 23:38
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