Repository navigation
feat: add Rust docs explorer generation and metadata endpoint - #673
Merged
Merged
Conversation
…Node The Rust port builds the port-neutral docs view from its loaded model (metaobjects::docs_view), byte-identical to TypeScript on every fixtures/explorer-conformance case, and a new opt-in docs-site generator writes explorer.json, the explorer app, explorer-model.js and explorer-stamp.js. The app is a canonical copy in metaobjects-codegen (synced by scripts/sync-explorer-app.sh, held by the explorer app copies gate) and ships in the published crate. Rust codegen now records generatedBy/sourceNode provenance in the hash manifest per the shared provenance vector, and the engine runs a run-output reader (docs-site) after every other generator, so gen and verify list the same files. The docs-site builder is engine, as the shared registry rules: eject refuses it and gen --list marks it [package-only]; an owned theme in codegen/docs-site/ replaces the shipped one. metaobjects::meta_endpoint adds the framework-free /_meta and /_meta/docs bodies (ETag and If-None-Match as TypeScript's).
# Conflicts: # docs/features/docs-view.md # docs/features/explorer-data.md # docs/features/explorer-site.md # docs/features/metadata-api.md # fixtures/generator-registry-conformance/registry.json
…ORMANCE explorer row and paragraph; --transport question left open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
server/rust/metaobjects/src/docs_view.rs,meta_endpoint.rs) and writesexplorer.jsonplus a stamp file. A newdocs-sitegenerator (server/rust/metaobjects-codegen/src/docs_site.rs) copies the shared explorer app fromserver/rust/metaobjects-codegen/explorer-app/, so a Rust project gets the explorer without Node. Thedocs-sitegenerator is package-only in Rust and opt-in. Thereads_run_output()engine hook lets it see this run's generated files./_metathrough an opt-in endpoint, with an FNV-1a ETag and 304 support. The host mounts it explicitly.generatedBy/sourceNodeprovenance, matchingfixtures/codegen-skip-conformance/manifests.json.examples/rust-servicemanifest is rewritten once with these fields.scripts/sync-explorer-app.shandgate_explorer_app_driftinscripts/ci-local.shcover the Rust app copy. Docs and the changelog entry are updated.Validation
Risk Assessment
✅ Low: The remaining files are docs, test wiring, a vendored app copy that is byte-identical to the C# canonical copy, and a docs view builder that the shared explorer corpus checks byte for byte against an independent oracle; only one cosmetic test cleanup was found.
Testing
Baseline configured command passed. Drove three scenarios live on a disposable copy of examples/rust-service with the real cargo-meta binary: explorer output generation with verify, skip-on-unchanged and regenerate-on-edit, and eject refusal for package-only docs-site. All three passed with live evidence. The docs view conformance check ran as a committed cargo test, which is not a live run, so it is recorded as untested for live purposes. The running-application /_meta-beside endpoint was not driven live. Scratch project removed and worktree left clean.
Evidence: explorer.json generated by cargo-meta gen on rust-service copy
Evidence: explorer-stamp.js generated by cargo-meta gen
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
📌 **Review** - 1 info left as notes at the round cap
server/rust/metaobjects-codegen/src/eject.rs:255- The intent says "docs-site is opt-in (runs only when listed), like metamodel-docs;cargo meta initdoes not add it."cargo meta init --transportdoes add it. That command callsgenerator_list::scaffold(true)(generator_list.rs:204-208), which lists every reference withopt_in: true, and the new docs-site entry is one of them. So the flag documented as "lists the opt-in axum transport (service-routes) too" (cli lib.rs:50-51) now also turns on the model explorer, about 1.3 MB of app files under generated/site/. metamodel-docs already behaved this way before this change. The testthe_scaffold_parses_...(generator_list.rs:240) assertsscaffold(true) == shipped_names(), so it locks this in. The USAGE text at cli lib.rs:96-98 is also stale: it says only service-routes is skipped when there is no list. Please decide: either--transportadds only the transport (filter on service-routes, or add a separate transport marker), or the intent and help text accept that--transportadds every opt-in generator.server/rust/metaobjects-codegen/src/docs_site.rs:191- Prompt text the explorer embeds is not part of the skip key, sogencan skip and leave a stale site.generatereads prompt.mustachefiles from the model's source roots and the project'stemplates/(prompt_dirs, lines 287-307), and writes them into explorer-model.js and its stamp.extra_inputslists only the owned theme dir,prompts,verifyFileandroutesFile. The model fingerprint hashes the model tree, not the files beside it. Failing sequence: list only docs-site, or put the prompt beside the metadata. Runcargo meta gen, then edittemplates/shop/order-note.mustacheand runcargo meta genagain. The second run reports Skipped because the key and recorded outputs are unchanged, so explorer-model.js keeps the old text. A localcargo meta verify(no CI, no --full) also says in sync, and only a CI render shows the drift. The doc comment at 188-190 claims every read input regenerates. Fix: addtemplatestoextra_inputs, and hash the metadata source roots the prompts are read from (or the project-relative directories of the resolved.mustachefiles). The C# (DocsSiteGenerator.cs:54) and Python (docs_site_generator.py:189) generators have the same gap. They are outside this change.server/rust/metaobjects-codegen/src/docs_site.rs:90- The engine hash in the skip key does not cover the new explorer app files. ADR-0064 says a build with different content must never reuse a stored key. The app is compiled in withinclude_str!("../explorer-app/..."), but build.rs (roots at lines ~36-43, extension filterrs|toml|mustache|json) never hashesexplorer-app/. Itsrerun-if-changeddoes not name that directory either, so METAOBJECTS_ENGINE_SOURCE_HASH stays the same whenscripts/sync-explorer-app.shbrings in a rebuilt app. Failing sequence: with a local or path-dependency engine at the same version, sync a new app, rebuild, and runcargo meta genon an unchanged project. The run skips, the site keeps the old index.html/assets, and a localverifyreports clean. Fix in build.rs: addmanifest.join("explorer-app")to the roots and acceptjs,cssandhtmlincollect(or hash every file under that root).server/rust/metaobjects/src/docs_view.rs:108- Simplification: the new publicdocs_view::build_model(tree, root)has no caller anywhere in the workspace. The endpoint, the generator and the tests all callbuildormeta_endpoint::docs. No intent requirement needs a second public entry point, so the recommended remedy is to remove it.🔧 Fix applied.
3 issues (2 warnings, 1 info) still open:
server/rust/metaobjects-codegen/src/eject.rs:255- The intent says "docs-site is opt-in (runs only when listed), like metamodel-docs;cargo meta initdoes not add it."cargo meta init --transportdoes add it. That command callsgenerator_list::scaffold(true)(generator_list.rs:204-208), which lists every reference withopt_in: true, and the new docs-site entry is one of them. So the flag documented as "lists the opt-in axum transport (service-routes) too" (cli lib.rs:50-51) now also turns on the model explorer, about 1.3 MB of app files under generated/site/. metamodel-docs already behaved this way before this change. The testthe_scaffold_parses_...(generator_list.rs:240) assertsscaffold(true) == shipped_names(), so it locks this in. The USAGE text at cli lib.rs:96-98 is also stale: it says only service-routes is skipped when there is no list. Please decide: either--transportadds only the transport (filter on service-routes, or add a separate transport marker), or the intent and help text accept that--transportadds every opt-in generator.server/rust/metaobjects-codegen/src/engine.rs:731- The round-1 fix for F2 makes a metadata directory part of the skip key, and it hashes that directory whole. That breaks the skip when the directory is the project root.source_dirs(generator.rs:~190) maps a source root that is a file to its parent. A project with"sources": [{ "path": "model.json" }]at the root, or{ "path": "." }, therefore hashes the whole project withhash_tree(project_root). That tree includes.metaobjects/.gen-state/(the stored fingerprint itself), the generated output,.git/and the adopter'starget/. Failing sequence: list docs-site in such a project, runcargo meta gen, then run it again. Eachpreparehashes the fingerprint file the previous run wrote, so the key differs from the stored key on every run.gennever skips, and the localverifyfast path never answers. Every run also walkstarget/and.git/, which can be gigabytes. The round-1 fix put the same pattern in its sibling sites: C#KeyExtrasaddsmeta.Directorywhole (server/csharp/MetaObjects.Codegen/CodegenCli.cs:715, hashed viaFilesUnderwith no exclusions in GenFingerprint.cs:227-231), and Python addsconfig.metadata_dir()whole (server/python/src/metaobjects/cli.py:1848-1854). Narrower fix that still closes F2: key only the prompt inputs. Hash the*.mustachefiles under each source dir, or better, the exact candidate paths each@textRefresolves to (present or absent). Do this in all three ports.server/python/tests/test_gen_skip_conformance.py:450- The Python regression test added in round 1 covers only a prompt intemplates/. The newreads_metadata_dirbranch in cli.py:1848-1854 has no test. That branch handles a prompt beside the metadata, the primary F2 case, and contains its ownrelative_tologic. Removing the branch, or computing the wrong directory, would still pass. The Rust test (docs_site.rs:222) runs both locations, and the C# test covers the metadata directory. Add themetaobjects/case to the Python test, matching Rust, so it fails without thereads_metadata_dirkey.🔧 Fix applied.
1 warning still open:
server/rust/metaobjects-codegen/src/eject.rs:255- The intent says "docs-site is opt-in (runs only when listed), like metamodel-docs;cargo meta initdoes not add it."cargo meta init --transportdoes add it. That command callsgenerator_list::scaffold(true)(generator_list.rs:204-208), which lists every reference withopt_in: true, and the new docs-site entry is one of them. So the flag documented as "lists the opt-in axum transport (service-routes) too" (cli lib.rs:50-51) now also turns on the model explorer, about 1.3 MB of app files under generated/site/. metamodel-docs already behaved this way before this change. The testthe_scaffold_parses_...(generator_list.rs:240) assertsscaffold(true) == shipped_names(), so it locks this in. The USAGE text at cli lib.rs:96-98 is also stale: it says only service-routes is skipped when there is no list. Please decide: either--transportadds only the transport (filter on service-routes, or add a separate transport marker), or the intent and help text accept that--transportadds every opt-in generator.🔧 No changes applied.
✅ Re-checked - no issues remain.
📌 Review round cap reached: 1 info left unresolved as notes (no further fix round):
server/rust/metaobjects-codegen/tests/hash_manifest.rs:192- Inprovenance_follows_the_vectors, the firstlet mut expect = serde_json::to_string_pretty(&want[name])pluspush('\n')is used only to re-parse intoparsed. It is then shadowed by the key-sortedexpect.want[name].clone()could be used directly, so the first serialize-and-parse round trip is dead weight. The comment also says field order inside an entry is part of the contract, but the code re-sorts only the top-level path keys. Inner entry order is kept through preserve_order. Dropping the round trip and saying the sort is of paths would make the test clearer. Assertions are unchanged.✅ **Test** - passed
✅ No issues found.
scripts/ci-local.sh --affected --strict-toolchainscargo test -p metaobjects --test docs_view_conformancein server/rust (3 passed, includes every_fixture_reproduces_its_expected_view against fixtures/explorer-conformance)cargo buildof server/rust/metaobjects-cli (cargo-meta binary)Scratch copy of examples/rust-service with docs-site added to metaobjects.config.json:cargo-meta meta gen --list,cargo-meta meta gen,cargo-meta meta verifyReruncargo-meta meta genon unchanged project: reports gen skippedEdit metaobjects/meta.app.yaml description marker, rerun gen: did not skip, updated explorer.json, explorer-model.js, explorer-stamp.js; marker appears in outputs; verify reports in synccargo-meta meta eject docs-site: refused with package-only reason, exit 2cargo test -qin server/rust/metaobjects-codegen (all suites passed)Broad regression from the configured test commandscripts/ci-local.sh --affected --strict-toolchains(passing outcome at target commit, not re-run)docs/ports/rust.md:73- docs/ports/rust.md:60 and :73 describecargo meta init --transportas adding only the transport, with the two docs generators opt-in. The code (eject.rs / generator_list::scaffold(true)) also lists docs-site, so the docs are stale or the behavior is wrong. Pending Doug's decision on F1; docs must follow that decision.✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
Validated in one no-mistakes run. Review took three fix rounds plus a coverage pass. Test, document and lint passed. CI is local.