Skip to content

feat(rust): add the sixth port's loader core, in preview (ADR-0065) - #597

Merged
dmealing merged 10 commits into
mainfrom
fm/mo-rust-phase1-core
Nov 18, 2026
Merged

dmealing merged 10 commits into
mainfrom
fm/mo-rust-phase1-core

Conversation

@dmealing

Copy link
Copy Markdown
Member

What Changed

  • Adds server/rust/ as a Cargo workspace (pinned toolchain, publish = false) with the first crate, metaobjects: the node model, type registry with the built-in strict/sealed providers, JSON loader (packages, children, subtypes, attrs, extends, references) and the canonical serializer. The tree freezes at load end and memoizes its resolved reads (effective children/attrs, array-ness) for concurrent readers, matching the other ports' cache design; nothing is published and there is no codegen or cargo meta command yet.
  • Gates the port on the shared corpora: registry-conformance passes byte-identical, and the metamodel corpus runs with an expected-failures ledger (256/510 passing) that can only shrink — a ledgered fixture that starts passing fails the run, a regressing fixture fails it via a recorded minPassing count, and an unlisted failure only warns while the port is in preview.
  • Wires a rust CI lane into ci-local.sh, pr-ci and local-ci (fmt --check, clippy with warnings denied, crate tests), teaches the port/lane selection scripts a sixth port, and documents the decision in ADR-0065 plus updates to docs/CONFORMANCE.md, the porting rules and the CHANGELOG.
Validation

Risk Assessment

✅ Low: A well-bounded, additive preview port: byte-identical registry conformance, a shrink-only 254-fixture ledger with a minPassing regression floor, CI wiring covered by the existing lane-selection tests, both prior review-round decisions implemented, and the freeze-then-memoize change carrying strong invariant and concurrency tests; no substantiated defect found across the full pass.

Testing

Baseline broad regression was the already-passing configured run of scripts/ci-local.sh --affected --strict-toolchains at this commit; no source files were changed in this turn, so it was not re-run. I drove three live scenarios against the real Rust port: the exact gate_conf_rust test command is green with the corpus summary line visible (proving the review-round-2 --nocapture fix); two adversarial probes confirmed the preview-port ledger policy — an unlisted failing fixture prints a visible warning and stays green, while dropping a passing fixture fails the run on the minPassing floor; and the load_bench example loaded 1785 nodes of the real fitness model clean with cached reads ~48x faster than the cache-filling pass, demonstrating the frozen-tree memoization the intent asked to add to the Rust node model. All transient fixture probes and the release build dir were removed; the worktree is clean.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Rust metamodel corpus gate is green and its per-run summary is visible under the gate's -- --nocapture invocation ✅ pass live rust_gate.log — exit 0, all 5 test binaries ok, line 'metamodel corpus: 256 of 510 fixtures pass; 254 on the expected-failures ledger; 0 unlisted failures' printed by the passing test
Adversarial: a fixture that fails in Rust and is not on the ledger prints a warning instead of failing the run ✅ pass live probe_unlisted.log — copied ledgered fixture error-agg-all-non-boolean to unlisted name zz-unlisted-probe; run exited 0 with 'warning: fixture fails in Rust and is not on the ledger (preview port, not…
Adversarial: a fixture that used to pass regressing fails the run via the ledger's minPassing floor ✅ pass live probe_regression2.log — temporarily removed passing fixture abstract-template-prompt-hoists-payloadref from the corpus; run exited 101 with '255 fixtures pass but the ledger's minPassing is 256: a fix…
Live loader loads the real fitness model clean and memoizes resolving reads on the frozen tree ✅ pass live load_bench output — cargo run --release --locked --example load_bench -- 5 7: 178 KiB / 1785 nodes loaded with zero errors (asserted in the example), cold read pass 449µs vs cached read pass 9.3µs (~4…
Evidence: Rust gate run (cargo test --locked -q -- --nocapture)

metamodel corpus: 256 of 510 fixtures pass; 254 on the expected-failures ledger; 0 unlisted failures — all 5 test binaries ok, exit 0


running 12 tests

thread 'node::tests::a_frozen_tree_refuses_mutation' (951037) panicked at metaobjects/src/node.rs:163:9:
cannot mutate a frozen metadata tree
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
............
test result: ok. 12 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s


running 9 tests
.........
test result: ok. 9 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s


running 1 test
metamodel corpus: 256 of 510 fixtures pass; 254 on the expected-failures ledger; 0 unlisted failures
.
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.04s


running 1 test
.
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s


running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Evidence: Adversarial probe: unlisted failing fixture warns, run stays green

warning: fixture fails in Rust and is not on the ledger (preview port, not a gate failure): zz-unlisted-probe: errors: want ["ERR_INVALID_ORIGIN"] got [] — exit 0


running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 12 filtered out; finished in 0.00s


running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 9 filtered out; finished in 0.00s


running 1 test
metamodel corpus: 256 of 511 fixtures pass; 254 on the expected-failures ledger; 1 unlisted failures
warning: fixture fails in Rust and is not on the ledger (preview port, not a gate failure): zz-unlisted-probe: errors: want ["ERR_INVALID_ORIGIN"] got []; envelope length mismatch: expected 1, got 0
.
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.13s


running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out; finished in 0.00s
Evidence: Adversarial probe: dropped passing fixture fails the run (minPassing guard)

255 fixtures pass but the ledger's minPassing is 256: a fixture that passed has regressed — exit 101


running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 12 filtered out; finished in 0.00s


running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 9 filtered out; finished in 0.00s


running 1 test
metamodel corpus: 255 of 509 fixtures pass; 254 on the expected-failures ledger; 0 unlisted failures

thread 'metamodel_corpus' (1009409) panicked at metaobjects/tests/metamodel_conformance.rs:412:9:
255 fixtures pass but the ledger's minPassing is 256: a fixture that passed has regressed (see the warnings above)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
metamodel_corpus --- FAILED

failures:

failures:
    metamodel_corpus

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.98s

error: test failed, to rerun pass `--test metamodel_conformance`
Evidence: load_bench: 5 copies of the real fitness model through the Rust loader, frozen-tree memoization
model: 5 copies of the fitness model, 178 KiB of JSON, 1785 nodes
registry compose: 1.042326ms
load (parse, merge, extends, references), median of 7: 4.212139ms
resolved reads of every node, first pass fills the cache, median of 7: 449.262µs
resolved reads of every node, from the cache, median of 7: 9.288µs
canonical serialize, median of 7: 2.109631ms

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 2 infos
  • ℹ️ server/rust/metaobjects/src/errors.rs:83 - Misplaced doc comment: the line 'An ERR_UNKNOWN with no source: a registry or provider definition problem.' describes unknown(), but both comment lines were attached above unknown() while at() sat undocumented, so the ERR_UNKNOWN sentence read as if it documented at(). Moved the sentence onto unknown() and gave at() the 'An error located in a document.' line.
  • ℹ️ server/rust/metaobjects/src/registry.rs:109 - Simplification-pass note: ReferenceDescriptor and TypeDefinition::references (populated in providers.rs:493-510) are write-only in this change — no code reads them yet. Judged intentional forward plumbing, not an unrequired component: it mirrors the reference ports' registry shape that the chartered next phase (reference validation, ADR-0065 'every later phase … held to the same corpora') reads, and its own comment states that. No action; do not remove without also diverging the registry shape from the other five ports.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Rust metamodel corpus gate is green and its per-run summary is visible under the gate's -- --nocapture invocation ✅ pass live rust_gate.log — exit 0, all 5 test binaries ok, line 'metamodel corpus: 256 of 510 fixtures pass; 254 on the expected-failures ledger; 0 unlisted failures' printed by the passing test
Adversarial: a fixture that fails in Rust and is not on the ledger prints a warning instead of failing the run ✅ pass live probe_unlisted.log — copied ledgered fixture error-agg-all-non-boolean to unlisted name zz-unlisted-probe; run exited 0 with 'warning: fixture fails in Rust and is not on the ledger (preview port, not…
Adversarial: a fixture that used to pass regressing fails the run via the ledger's minPassing floor ✅ pass live probe_regression2.log — temporarily removed passing fixture abstract-template-prompt-hoists-payloadref from the corpus; run exited 101 with '255 fixtures pass but the ledger's minPassing is 256: a fix…
Live loader loads the real fitness model clean and memoizes resolving reads on the frozen tree ✅ pass live load_bench output — cargo run --release --locked --example load_bench -- 5 7: 178 KiB / 1785 nodes loaded with zero errors (asserted in the example), cold read pass 449µs vs cached read pass 9.3µs (~4…
  • scripts/ci-local.sh --affected --strict-toolchains
  • cargo test --locked -q -- --nocapture in server/rust (the gate_conf_rust test invocation from scripts/ci-local.sh:828)
  • Adversarial probe: unlisted failing fixture copied into fixtures/conformance, gate test re-run, warning visibility and exit 0 verified, probe removed
  • Adversarial probe: passing fixture temporarily removed from corpus, gate test re-run, minPassing regression guard verified to fail the run (exit 101), fixture restored
  • cargo run --release --locked --example load_bench -- 5 7 (real loader on 5 copies of the persistence-conformance fitness model)
  • git status --porcelain after cleanup — worktree clean
⚠️ **Document** - 1 info
  • ℹ️ Judgment call, recorded for visibility: README's port/install table, docs/ports/ (no rust.md), and the many "all five ports" claims in docs/features/* were left unchanged. Under ADR-0065's deliberate preview posture (unpublished, no codegen/CLI; joins matrices when it leaves preview) these are accurate as written, not stale. docs/ports/rust.md becomes warranted when the port gains a user-facing surface (cargo meta), not before.
✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

A Cargo workspace under server/rust/ with a pinned toolchain and one crate,
`metaobjects`: the node model, the type registry and the built-in providers
(strict, sealed after bootstrap, the shared ERR_* codes), a JSON loader for
packages, children, subtypes, attributes, extends and references, and the
canonical serializer.

- registry-conformance passes byte for byte.
- The metamodel corpus: 256 of 510 fixtures pass. The other 254 are on a
  shrink-only expected-failures ledger (validation passes, merge warnings and
  script.json fixtures, none built yet).
- examples/load_bench.rs times a load of 20 copies of the public fitness model.
- A `rust` CI lane: ci-local.sh --only rust (fmt --check, clippy -D warnings,
  cargo test), a job in pr-ci and local-ci, and server/rust/** selecting it in
  the affected-ports and ports-to-run selectors (tests updated for six ports).
- The metamodel-version gate writes and checks the Rust constant too.
- ADR-0063 (proposed), a CHANGELOG entry and a CONFORMANCE.md note.

Nothing is published; no codegen or `cargo meta` yet.
Main took ADR-0063 and ADR-0064, so the Rust ADR is now ADR-0065. The rust
lane is rewired into main's shared lane map (scripts/ci-lane-map.txt and
ci-select-lanes.sh) instead of the per-script case tables.
The loader freezes the tree at its terminal phase, as the other ports do at
REGISTERED. A frozen tree refuses mutation and memoizes effective children,
effective attrs (attr reads through that map) and resolved_is_array, one
OnceLock per node and accessor, so concurrent readers share one computation
and a cached read is a borrow. Nothing is cached before the freeze.

Tests hold cached reads equal to the uncached walks on a hand-built chain and
the public fitness model, show a read before the freeze does not survive a
later mutation, and read one frozen tree from eight threads. load_bench times
a cold and a warm read pass. ADR-0065 records the design (decision 8).
- The metamodel corpus fails when a fixture that passed regresses: the
  ledger records minPassing (256, may only rise), and a ledger name with no
  fixture directory fails the run. New unlisted failures still only warn.
- The ledger notes name every gap it covers, including the unknown-attr
  check and the reporting short-name rule.
- A frozen attr() on a node that extends nothing borrows its own map
  instead of building the cache; the serializer iterates the cached reads
  instead of copying them.
- metadata_files walks a symlinked directory once, so a cycle terminates.
- Drop a home-path mention from a local-ci.yml comment.
- One js_display in json.rs (was duplicated in parser and manifest) and
  MetaError::unknown (was two private wrappers).
- The loader builds its top-level index once; super resolution and
  reference resolution share it instead of building the same map twice.
- Extends errors build the node's fqn and source only on the error path.
- builtin_provider reads core_providers instead of repeating the table.
- The corpus test normalizes numbers with json::safe_whole_i64.
@dmealing
dmealing merged commit 05a245d into main Nov 18, 2026
10 checks passed
@dmealing
dmealing deleted the fm/mo-rust-phase1-core branch November 18, 2026 16:03
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