Skip to content

feat(rust): make Rust a full language with generator config, publishable crates and the rules gate - #627

Merged
dmealing merged 6 commits into
mainfrom
fm/mo-130-lane-rust
Nov 21, 2026
Merged

dmealing merged 6 commits into
mainfrom
fm/mo-130-lane-rust

Conversation

@dmealing

Copy link
Copy Markdown
Member

What Changed

  • Rust cargo meta gains a generator config and a portable eject. cargo meta init writes { "generators": [...] } into metaobjects.config.json, so a project drops a generator by config instead of ejecting. cargo meta gen --list reports each generator as configured or not, using the new generator_list.rs and a registry fixture update. cargo meta eject no longer writes the build machine's path into codegen/Cargo.toml. The owned crate pins the crates.io release by default, and --engine <directory | git-url[#rev]> points it at a checkout or git revision.
  • Rust cargo meta verify now runs the business-rules gate (ADR-0066). The new metaobjects::rules_check module reports the same five findings, severities and message text as the other ports. It honours the four rules.* settings and verify.lifecycle.unreachable. The new rules_check_conformance test runs it against fixtures/rules-check-conformance/, and validate/rules.rs and the conformance ledger were adjusted to match.
  • The three Rust crates become publishable, and the "preview" label is retired. publish = false is removed. Each crate gains packaging metadata, a README and a LICENSE. The rust lane in scripts/ci-local.sh now runs cargo publish --dry-run --workspace --locked; nothing is published. ADR-0065 Amendment 3, CHANGELOG, docs/ports/rust.md, CONFORMANCE, the stability labels and the fit-assessment skill docs are updated to describe Rust as a full port.
Validation

Risk Assessment

✅ Low: The Rust lane work is well-bounded: crate packaging metadata, a strict generator-list parser, an engine-source abstraction for eject, and a rules gate ported from the reference. The only issue found is stale preview wording in an ADR. The rules gate is covered by the shared conformance corpus, but this pass did not run any tests.

Testing

I built the CLI and drove it in a disposable project. Bare verify ran the rules gate and exited 0 on a clean model. On the unreachable-state-error fixture it printed the two expected errors and exited 1. verify --codegen skipped the rules gate, so the review-4 concern is not present in the current code. Generator selection, eject, undo, listing and unknown-generator refusal all behaved correctly. The rules-check conformance test also passed. Two limits: ejected-crate builds could not run because the engine crate is not on crates.io, and I wrote no source or test files, so I did not re-run broad regression.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Bare cargo meta verify runs the business-rules gate: a clean model exits 0 with a rules summary, and an unreachable-state model at unreachable: error reports 2 errors and exits 1; --codegen skip… ✅ pass live s2-verify-rules.txt, s2b-rules-conformance.txt
Generator list lives in metaobjects.config.json: init scaffolds it, gen --list reports configured generators, and an unknown generator name is refused by gen ✅ pass live s1-init.txt, s3-generators-eject.txt, s3b-unknown-generator.txt
Eject a generator and undo it: eject writes the owned copy with no absolute machine path, a repeat eject is refused without --force, --undo removes the copy, and an unknown generator is rejected ✅ pass live s3-generators-eject.txt
Evidence: init transcript
$ cargo meta init
wrote .metaobjects/config.json
wrote .metaobjects/.gitignore
wrote metaobjects/meta.app.yaml
wrote metaobjects.config.json
next: declare your objects in metaobjects/ (JSON or YAML), then run `cargo meta gen`.
Choose the generators `gen` runs by editing metaobjects.config.json.
Commit .metaobjects/.gen-state/.hashes/ with the generated crates.
Schema migrations are the Node `meta` command's (`meta migrate`), for every server language.
exit=0
./.metaobjects/config.json
./metaobjects.config.json
./.metaobjects/.gitignore
./metaobjects/meta.app.yaml
{
  "schema_version": 1,
  "migrate": {
    "foreignKeyIndexes": true
  },
  "verify": {
    "handEdits": "fail"
  },
  "api": {
    "pagination": {
      "defaultLimit": 50,
      "maxLimit": 1000
    },
    "unknownFields": "reject"
  }
}
{
  "generators": [
    "entity",
    "client",
    "commands"
  ]
}
Evidence: verify rules gate transcript
## clean-default-settings: gen + bare verify
  created generated/meta_client/src/lib.rs
  created generated/acme_purchasing_cli/src/purchase_request.rs
  created generated/acme_purchasing_cli/Cargo.toml
  ... and 5 more
changed crates: acme_purchasing, acme_purchasing_cli, acme_purchasing_client, meta_cli, meta_client, meta_support (cargo check -p acme_purchasing -p acme_purchasing_cli -p acme_purchasing_client -p meta_cli -p meta_client -p meta_support)
gen exit=0
cargo meta verify: in sync (the model and every recorded file are unchanged since the last gen; pass --full to render and compare).
cargo meta verify — rules: 4 operation(s), 1 lifecycle(s) with 5 transition(s).
verify exit=0

## unreachable-state-error: bare verify (expect rules error, exit 1)
error: generated code is out of sync with metadata.
  drifted: generated/acme_purchasing/src/purchase_request.rs
  drifted: generated/acme_purchasing/src/lib.rs
  extra:   generated/acme_purchasing/src/decision_input.rs (no generator emits it any more; gen deletes it)
regenerate (cargo meta gen) and commit the result.
cargo meta verify — rules: 0 operation(s), 1 lifecycle(s) with 4 transition(s).
  WARN_LIFECYCLE_UNREACHABLE_STATE [acme::purchasing::PurchaseRequest.status]: states "archived", "legacy" of "status" cannot be reached from the initial state "draft" by any transition. Add the transition that leads there, or set verify.lifecycle.unreachable if only seeded data uses them.
  WARN_TRANSITION_UNREACHABLE [acme::purchasing::PurchaseRequest.status.restore]: transition "restore" starts only from "archived", "legacy", which no transition reaches from the initial state "draft", so it can never be made.
cargo meta verify — rules: 2 error(s).
verify exit=1

## same, verify --codegen
error: generated code is out of sync with metadata.
  drifted: generated/acme_purchasing/src/purchase_request.rs
  drifted: generated/acme_purchasing/src/lib.rs
  extra:   generated/acme_purchasing/src/decision_input.rs (no generator emits it any more; gen deletes it)
regenerate (cargo meta gen) and commit the result.
verify --codegen exit=1

## --templates
cargo meta: `cargo meta verify --templates` does not exist yet: the Rust port ships no prompt or template generator, so it has no template gate. `cargo meta verify --codegen` is the generated-code gate.

Run `cargo meta --help` for the commands and their flags.
exit=2

## unreachable: off
error: generated code is out of sync with metadata.
  drifted: generated/acme_purchasing/src/purchase_request.rs
  drifted: generated/acme_purchasing/src/lib.rs
  extra:   generated/acme_purchasing/src/decision_input.rs (no generator emits it any more; gen deletes it)
regenerate (cargo meta gen) and commit the result.
cargo meta verify — rules: 0 operation(s), 1 lifecycle(s) with 4 transition(s).
exit=1
Evidence: rules conformance test
    Finished `test` profile [unoptimized + debuginfo] target(s) in 6.29s
     Running tests/rules_check_conformance.rs (/mnt/scratch/rust-target-mo/debug/deps/rules_check_conformance-74833fef9969b190)

running 1 test
test every_rules_check_case_reports_what_the_corpus_expects ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.07s
Evidence: generators and eject transcript
## gen --list
metaobjects.config.json runs: entity, client, commands
entity - model crates, one per metadata package: serde structs, enums, value objects, create and patch inputs, validate() (layer: model) [configured]
client - client crates, one per package with served entities: a typed HTTP client and list query per entity (needs entity) (layer: client) [configured]
commands - command crates, one per package with served entities: clap commands over the client (needs entity and client; Rust only) (layer: client) [configured]
exit=0

## eject --list
metaobjects.config.json runs: entity, client, commands
entity - model crates, one per metadata package: serde structs, enums, value objects, create and patch inputs, validate() (layer: model) [configured]
client - client crates, one per package with served entities: a typed HTTP client and list query per entity (needs entity) (layer: client) [configured]
commands - command crates, one per package with served entities: clap commands over the client (needs entity and client; Rust only) (layer: client) [configured]
exit=0

## eject entity
ejected entity -> codegen/generators/entity.rs [created]
  wrote codegen/Cargo.toml (the engine is crates.io, exactly 0.1.0)
  wrote codegen/main.rs (the generator list)
The copies are yours: edit them freely. `cargo meta gen` and `cargo meta verify` now build and run the codegen/ crate; `cargo meta gen --list` reports how far an owned copy has drifted from the reference.
exit=0
codegen/Cargo.toml
codegen/generators/entity.rs
codegen/main.rs
(abs-path grep done)
{
  "generators": [
    "entity",
    "client",
    "commands"
  ]
}

## gen --list after eject
metaobjects.config.json runs: entity, client, commands
entity - model crates, one per metadata package: serde structs, enums, value objects, create and patch inputs, validate() (layer: model) [configured] [owned: identical]
client - client crates, one per package with served entities: a typed HTTP client and list query per entity (needs entity) (layer: client) [configured]
commands - command crates, one per package with served entities: clap commands over the client (needs entity and client; Rust only) (layer: client) [configured]

## eject unknown
cargo meta: unknown or non-ejectable generator(s): nosuch; ejectable: entity, client, commands

Run `cargo meta --help` for the commands and their flags.
exit=2

## eject again without --force
cargo meta eject: already owned: codegen/generators/entity.rs. Eject never overwrites your copy; pass --force to replace it (and discard any edits) with the reference.
exit=1

## eject --undo
removed codegen/generators/entity.rs
codegen/main.rs is yours: undo never edits it. In it (the crate does not build until you do):
  remove `pub mod entity;`
  replace `Box::new(generators::entity::EntityGenerator)` with `Box::new(metaobjects_codegen::EntityGenerator)`
No owned generator is left. Delete the codegen/ directory to go back to running the shipped generators directly.
exit=0
Cargo.toml
main.rs
{
  "generators": [
    "entity",
    "client",
    "commands"
  ]
}

## config: unknown generator
cargo meta: unknown flag --dry-run for `cargo meta gen`. Valid flags: --force, --generators, --list, --out, --project, --strict, --timings (also accepted everywhere: --help)

Run `cargo meta --help` for the commands and their flags.
exit=2
Evidence: unknown generator transcript
## unknown generator in config, via gen --list
metaobjects.config.json runs: entity, bogus
entity - model crates, one per metadata package: serde structs, enums, value objects, create and patch inputs, validate() (layer: model) [configured]
client - client crates, one per package with served entities: a typed HTTP client and list query per entity (needs entity) (layer: client) [not configured]
commands - command crates, one per package with served entities: clap commands over the client (needs entity and client; Rust only) (layer: client) [not configured]
exit=0
error: no matching package named `metaobjects` found
location searched: crates.io index
required by package `codegen v0.0.0 (/mnt/scratch/mo-rust-scn/p/codegen)`
verify exit=1
cargo meta gen failed:
metaobjects.config.json lists the generator "bogus", which is not available; available: entity, client, commands. (`cargo meta gen --list` shows them)
exit=1

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 4 infos
  • ℹ️ server/rust/metaobjects-cli/src/lib.rs:75 - Stale help text after this change. verify --codegen help still says "It is the only gate this port ships, so a bare verify runs it", and the --templates refusal says "verify --codegen is the gate it ships." A bare verify now also runs the business-rules gate, and docs/ports/rust.md was updated to say so. Reword both strings, e.g. "the generated-code gate; a bare verify runs it and the business-rules gate".
  • ℹ️ docs/ports/rust.md:3 - docs/ports/rust.md still opens "Rust port (preview)" and says "in preview" at lines 1, 3, 253, 265, 299 and 385. ADR-0065 Amendment 3 and the CHANGELOG now describe Rust as a full, publishable language in 1.3.0, so the page contradicts them. The cross-language-porting rule file also still says "Rust in preview". If preview status is deliberately kept until the first publish, no action is needed. Otherwise the wording should be reconciled.

🔧 Fix applied.
4 infos still open:

  • ℹ️ server/rust/metaobjects-cli/src/lib.rs:75 - Stale help text after this change. verify --codegen help still says "It is the only gate this port ships, so a bare verify runs it", and the --templates refusal says "verify --codegen is the gate it ships." A bare verify now also runs the business-rules gate, and docs/ports/rust.md was updated to say so. Reword both strings, e.g. "the generated-code gate; a bare verify runs it and the business-rules gate".
  • ℹ️ docs/CONFORMANCE.md:94 - Fix round left a stale sentence: "The column joins this table when the port leaves preview." The same round removed the preview label (ADR-0065 Amendment 4), so the condition no longer names anything. docs/ports/rust.md:299 was reworded to the tautology "joins when the port has a column". Both should state a real condition, e.g. when the port runs the render, persistence and API-contract corpora. Same class: docs/features/stability-labels.md:45 still says "A port's preview status is on its page"; and the new Rust row at line 26 uses "supported", which is not one of the three labels the page defines (stable, preview, experimental, lines 10-14), so the row has no defined meaning.
  • ℹ️ CHANGELOG.md:421 - The [1.3.0] section (starts line 79) still labels the Rust port "in preview" at lines 410, 421, 430, 441, 449, 478, 490 and 520. Line 430 describes the unlisted-failure warning as applying "while the port is in preview", which Amendment 4 reframes as "until the owner turns the warning off". A reader of the 1.3.0 notes gets a Rust port that is both preview and a full language. Unreleased entries can be reworded; line 1432 is a released section and should stay. agent-context/ capability-sheet.md:66 and SKILL.md:335 also still say preview, left deliberately (golden regen rule).
  • ℹ️ server/rust/metaobjects-cli/src/lib.rs:591 - cmd_verify never reads --codegen, so verify --codegen also runs the business-rules gate and exits 1 on a rules error. The help text and docs/ports/rust.md say a bare verify runs it and the generated-code gate, which implies --codegen alone is codegen-only (as in the TS reference). An adopter CI step pinned to verify --codegen will now fail on a verify.lifecycle.unreachable: error or rules.permissions.names: require finding. Either gate the rules lines/exit code on --codegen being absent, or reword help and docs to say both gates always run. The remedy decides product behavior, so it needs the author's choice. The earlier help-text rewording round did not cover this sibling.

🔧 Fix applied.
📝 4 wording or comment-placement notes left for the author (no fix round spent):

  • ℹ️ CHANGELOG.md:421 - The [1.3.0] section (starts line 79) still labels the Rust port "in preview" at lines 410, 421, 430, 441, 449, 478, 490 and 520. Line 430 describes the unlisted-failure warning as applying "while the port is in preview", which Amendment 4 reframes as "until the owner turns the warning off". A reader of the 1.3.0 notes gets a Rust port that is both preview and a full language. Unreleased entries can be reworded; line 1432 is a released section and should stay. agent-context/ capability-sheet.md:66 and SKILL.md:335 also still say preview, left deliberately (golden regen rule).
  • ℹ️ scripts/ci-local.sh:72 - Stale 'preview' wording about the Rust port survives the preview cleanup. scripts/ci-local.sh:72 says 'rust → the Rust port (preview): cargo fmt ...' and scripts/ci-lane-map.txt:44 says 'the Rust port (preview, ADR-0065)'. ADR-0065 Amendment 4 retired the label and the intent is 'Rust as a full language'. The earlier fix round grepped only docs/, spec/ and agent-context/, so scripts/ was left behind. Reword both comments (ci-lane-map.txt is outside the listed changed files but is the same class). Comment-only, no behavior change.
  • ℹ️ CHANGELOG.md:410 - The 1.3.0 entry still says of the Rust port 'It has no verify, so the rules gate does not run there.' The same changelog now says cargo meta verify exists (line ~487 verify --codegen) and, in the new Amendment 3 entry (line ~75), that it runs the business-rules gate. The sentence contradicts the release notes. Reword to say the rules gate runs in cargo meta verify (see the Amendment 3 entry) or drop the sentence.
  • ℹ️ spec/decisions/ADR-0065-rust-is-the-sixth-port.md:138 - Stale preview wording left after the Amendment 4 cleanup. Owner ruling 2 still says the engine's Rust API "carries no stability promise while the port is in preview". Line 107 still says the CONFORMANCE.md column is deferred "until it leaves preview". Both contradict Amendment 4, which retires the label. eject.rs's doc comment was already reworded to "between releases", so ruling 2 should match. Reword line 138 to "between releases". Give line 107 a real condition, e.g. until the port runs the render, persistence and API-contract corpora.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Bare cargo meta verify runs the business-rules gate: a clean model exits 0 with a rules summary, and an unreachable-state model at unreachable: error reports 2 errors and exits 1; --codegen skip… ✅ pass live s2-verify-rules.txt, s2b-rules-conformance.txt
Generator list lives in metaobjects.config.json: init scaffolds it, gen --list reports configured generators, and an unknown generator name is refused by gen ✅ pass live s1-init.txt, s3-generators-eject.txt, s3b-unknown-generator.txt
Eject a generator and undo it: eject writes the owned copy with no absolute machine path, a repeat eject is refused without --force, --undo removes the copy, and an unknown generator is rejected ✅ pass live s3-generators-eject.txt
  • scripts/ci-local.sh --affected --strict-toolchains
  • Baseline: scripts/ci-local.sh --affected --strict-toolchains passed (ran before this step, not re-run)
  • cargo build -p metaobjects-cli, then drove cargo-meta meta init|gen|verify|eject in a throwaway project built from fixtures/rules-check-conformance cases
  • cargo test -p metaobjects --test rules_check_conformance
  • cargo meta gen --list, eject --list, eject entity, repeat eject, eject --undo, unknown generator in metaobjects.config.json
🔧 **Document** - 1 issue found → auto-fixed ✅
  • ℹ️ agent-context/skills/metaobjects-fit-assessment/references/capability-sheet.md:66 - The capability sheet and SKILL.md:335 still call Rust "a sixth port in preview, unpublished". They are left as is on purpose: an earlier round recorded that they are golden-regenerated. Reword them in the next golden regen. Also still saying preview: the notes string in server/rust/metaobjects/tests/conformance-expected-failures.json, and the $comment in fixtures/generator-registry-conformance/registry.json. Both are test data or a canonical manifest, so I did not touch them.

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…s no machine path, crates ready to publish

B1: the project's generator list is metaobjects.config.json (cargo meta init writes it,
gen --list shows configured against available); no eject needed to drop a generator.
B2: eject names the exact crates.io release by default and takes --engine for a checkout
or git revision; the crates drop publish = false, gain packaging metadata, and the rust
lane runs cargo publish --dry-run. ADR-0065 Amendment 3 records it. Nothing is published.
@dmealing
dmealing merged commit b62f743 into main Nov 21, 2026
10 checks passed
@dmealing
dmealing deleted the fm/mo-130-lane-rust branch November 21, 2026 11:25
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