Repository navigation
fix(cli): hash linked generator packages in the gen skip key - #651
Merged
Merged
Conversation
…Script, Rust) TypeScript: the ADR-0064 key dropped every @metaobjectsdev/* import of the config on the assumption that the CLI aliases it onto its engine, while the engine half hashes only the CLI's own dependencies. A package the CLI does not depend on (an independent pack) was then hashed by nothing. Only the packages the CLI actually aliases (CLI_ALIASED_PACKAGES) are left out now. Rust: a crate the owned codegen crate depends on by path is now an input, followed through its own path dependencies; the engine crates its source hash covers are left out. Java (plugin and project classpath content), C# (project references by content, packages by version) and Python (every named module's package by content) had no such gap.
Rust: follow workspace-inherited path dependencies, [patch]/[replace] tables, single-quoted paths and trailing comments. TypeScript: leave the CLI-aliased packages out of a generator package's closure too. Both ports bump their fingerprint format. The linked-package test runs in scratch.
One packageNameOf for the CLI; one quote-aware TOML line scanner in Rust; each manifest read once; engine crates matched by the directories build.rs hashed rather than by name, so another checkout named like one is hashed.
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
meta genskip key (gen-fingerprint.ts) now hashes any config-imported@metaobjectsdev/*package that is not in the newCLI_ALIASED_PACKAGESset (exported fromload-metaobjects-config.ts). Such packages, for example@metaobjectsdev/pack-config, are hashed like third-party generator packages: by content when linked, by version when installed. Previously every@metaobjectsdev/*import was skipped, so editing a linked pack's generator code left the key unchanged andgenskipped stale output.FINGERPRINT_FORMATbumps to 4, so the firstgenafter upgrading renders once.packageNameOfmoves to its own module (lib/package-name.ts) and is shared bygen-fingerprint.ts,load-metaobjects-config.tsandruntime-eject.ts.cargo meta genskip key (metaobjects-codegen): apathdependency of the ownedcodegen/crate (in a build table or[patch]) is now hashed, following its own path dependencies and inherited workspace. Themetaobjectsandmetaobjects-codegenengine crates are excluded by directory, sincebuild.rsalready hashes them into the engine source hash.FINGERPRINT_FORMATbumps to 2.docs/features/cli.mdanddocs/ports/rust.mddescribe the new skip-key inputs; adds changelog fragmentchangelog.d/gen-skip-key-linked-generator-packages.md.Why Rust is in this change, and the other ports
The task was to fix the TypeScript blind spot and to check every other port's skip key for the same one, fixing any that had it in the same PR.
codegen/crate reaches bypath. Nothing hashed it, so editing its generator code left the key unchanged andcargo meta genskipped over stale output. TheCargo.tomlreader handles multi-line inline tables,[dependencies.<name>],target.*,[patch]/[replace]and workspace inheritance, and adds no dependency (tomlis not in the workspace tree).Known follow-up (safe direction, output never stale): the review round cap left one Rust note open. A path dependency whose directory contains the project's
.metaobjects/(an owned crate depending on..) makes the key change on every run, socargo meta gennever skips in that layout.This took one no-mistakes run (four review fixes and one documentation fix folded into it).
Validation
Risk Assessment
@metaobjectsdev/*config import is now hashed, and the round-3 narrowing is correct. The Rust path-dependency scan can defeat the skip key when a dependency covers the project root, but that fails safe: it re-renders and never leaves output stale.Testing
Intent is that a linked
@metaobjectsdev/*pack's generator code counts toward the ADR-0064 skip key. Two scenarios ran live through the realmeta genCLI on a disposable project. Editing only the pack's generator made the nextgenoverwrite its output. Runninggenwith nothing changed skipped and wrote nothing. Both pass. The focused test file passes 4/4, covering the engine-alias guard and a pack's own dependency on an aliased package. Both are unit-level only, not live, and the alias-guard boundary is not required by the intent. The base-code failure was not reproduced live, so the pre-fix regression claim rests on the test's own reasoning. The Rust path-dependency part of the change is outside the TypeScript intent and was not driven live. Overall: the two live scenarios pass; the alias-guard boundary is untested live.meta genre-render (local CLI, synthetic disposable project)meta genwith nothing changed skips rendering and writes nothing (no spurious re-render from the new pack hashing)Evidence: Live meta gen transcript: linked pack edit re-renders, unchanged project skips
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
📌 **Review** - 1 warning left as notes at the round cap
server/rust/metaobjects-codegen/src/engine.rs:299- Scope exceeds the stated intent. The intent is TypeScript-only: stopconfigGraphEntriesfrom dropping non-engine@metaobjectsdev/*imports. The change also adds a Rust-port feature that no intent requirement needs: ~190 lines inengine.rs(path_dependency_entries, a hand-rolled line-scan TOML reader withmanifest_dependencies,toml_key_value,toml_key_string,unquoted,strip_toml_comment,workspace_root_manifest), a newMETAOBJECTS_ENGINE_CRATE_DIRSenv emitted bybuild.rs, aFINGERPRINT_FORMATbump to 2 infingerprint.rs, new tests inrun_engine.rs, and thedocs/ports/rust.mdparagraph. The Rust port has no@metaobjectsdev/*-import-dropping path to fix, so this is a separate defect class (path dependencies of the owned crate) plus a new parser to maintain. Smallest honest remedy: remove the Rust part from this change and land it separately if wanted. Confirm with the author whether Rust parity was deliberately in scope. If it stays, a line scan will miss multi-line inline tables (dep = {\n path = ... }), whichcargoaccepts. The doc says the forms 'one-line' are supported, so that limit is known.🔧 Fix applied.
2 warnings still open:
server/rust/metaobjects-codegen/src/engine.rs:299- Scope exceeds the stated intent. The intent is TypeScript-only: stopconfigGraphEntriesfrom dropping non-engine@metaobjectsdev/*imports. The change also adds a Rust-port feature that no intent requirement needs: ~190 lines inengine.rs(path_dependency_entries, a hand-rolled line-scan TOML reader withmanifest_dependencies,toml_key_value,toml_key_string,unquoted,strip_toml_comment,workspace_root_manifest), a newMETAOBJECTS_ENGINE_CRATE_DIRSenv emitted bybuild.rs, aFINGERPRINT_FORMATbump to 2 infingerprint.rs, new tests inrun_engine.rs, and thedocs/ports/rust.mdparagraph. The Rust port has no@metaobjectsdev/*-import-dropping path to fix, so this is a separate defect class (path dependencies of the owned crate) plus a new parser to maintain. Smallest honest remedy: remove the Rust part from this change and land it separately if wanted. Confirm with the author whether Rust parity was deliberately in scope. If it stays, a line scan will miss multi-line inline tables (dep = {\n path = ... }), whichcargoaccepts. The doc says the forms 'one-line' are supported, so that limit is known.server/rust/metaobjects-codegen/src/engine.rs:345- Path dependency silently goes unhashed when its manifest was already queued as a workspace root.enqueuededupes by manifest path and means both "scanned this manifest" and "hashed this crate". At line 337 aworkspace = truedependency queues the workspace root manifest before thepathsloop runs. If a path dependency then points at that same root directory, line 345 getsNonefromenqueueandcontinues, so nopath-dependency:entry is pushed. Example: the project root is a workspace with its own[package],codegen/Cargo.tomlhasserde.workspace = trueandmyapp = { path = ".." }. The root crate'ssrc/is then hashed by nothing, and editing it regenerates nothing, which is the stale-output failure this change exists to fix. Fix: track hashed crate directories in a separate set from scanned manifests, and push the entry whenever the crate dir is not yet hashed. The engine andqueueddedupe then only guard re-scanning. Add a run_engine.rs case with a workspace-inheriting owned crate that path-depends on its workspace root. This is new code from the original change, not from the fix round. The fix round'slogical_linesrewrite does not touch it.🔧 Fix applied.
2 issues (1 warning, 1 info) still open:
server/typescript/packages/cli/src/lib/gen-fingerprint.ts:190- The newskipparameter ofpackageClosureEntries(if (skip.has(dep)) continue;, passedCLI_ALIASED_PACKAGESfromconfigGraphEntries) is not required by the intent and drops coverage. The intent only requires that a non-engine@metaobjectsdev/*config import be hashed like any other generator package. The closure walk already deduped engine copies through the sharedseenset. The skip also changes what is hashed under a linked pack: any dependency inCLI_ALIASED_PACKAGES(@metaobjectsdev/codegen-ts,metadata,migrate-ts,cli, and barets-poet) is now left out of the closure. Before this change a third-party generator package'sts-poetdependency, and a linked pack's@metaobjectsdev/codegen-tsdependency, were hashed. The rationale 'never runs, so only the engine copy counts' holds only for the config file, whichloadMetaobjectsConfigrewrites onto the CLI's copies.load-metaobjects-config.tsstates that under Bun jiti's alias map is not applied and 'only the config file is pre-processed'. A module inside the pack that imports@metaobjectsdev/codegen-tstherefore resolves through the project'snode_modules. In that case a different physical copy runs from the CLI's own, and nothing hashes it now. Smallest honest remedy: remove theskipparameter and theCLI_ALIASED_PACKAGESargument at thepackageClosureEntriescall site, keepingCLI_ALIASED_PACKAGESonly for the top-level config-import skip. The extra entries then only over-approximate, which at worst causes a spurious regen. The third test (an import the CLI aliases onto its engine is not hashed) pins this narrower behaviour for the linked pack's dependency. It would need its fixture's expectation reconsidered if the skip goes.changelog.d/gen-skip-key-linked-generator-packages.md:9- Changelog line 9 runs far past the wrapped width. 'Both ports bump their fingerprint format, so the firstgenafter upgrading renders once. Before this change, ...' sits on one overlong line after 'bump'. Rewrap for consistency with the surrounding lines.🔧 Fix applied.
📌 Review round cap reached: 1 warning left unresolved as notes (no further fix round):
server/rust/metaobjects-codegen/src/engine.rs:333- A path dependency that contains the project's own.metaobjects/.gen-statemakes the Rust skip key unstable, socargo meta gennever skips. The round-2 fix explicitly supports the case where the owned crate path-depends on the project or workspace root (app = { path = ".." }, the second unit test).hash_tree_except(&dir, PATH_DEPENDENCY_NOT_INPUTS)skips only the top-level namestargetand.git(seefingerprint.rshash_tree_except: the skip list applies only to the root's direct entries)..metaobjects/.gen-state/fingerprintlives underproject_root(engine.rsgen_state) and holds the previous key. Trace: run 1 computes K1 and stores it. Run 2 hashes a tree containing the file holding K1, so the key is K2 != K1; it regenerates and stores K2. Run 3 hashes a tree containing K2, so the key is K3 != K2, and so on. The.hashes/manifest, which is rewritten on each gen, is also hashed. Output is never stale. The cost is that the skip optimisation is permanently defeated for exactly the layout the round-2 fix targets. Round 2 added the case but left this sibling behind. The unit test only compares hashes before and after an edit and never runsgentwice, so it cannot see it. When the dependency is a strict ancestor (monorepo root),.metaobjectsis not a top-level entry, so a top-level skip would not catch it either. Smallest fix: exclude any.metaobjectsdirectory (and the ownedcodegen/dir, already hashed on its own) from the path-dependency tree walk, then add arun_engine.rscase where the owned crate path-depends on..and a secondgenisOutcome::Skipped.✅ **Test** - passed
✅ No issues found.
meta genre-render (local CLI, synthetic disposable project)meta genwith nothing changed skips rendering and writes nothing (no spurious re-render from the new pack hashing)scripts/ci-local.sh --affected --strict-toolchainscd server/typescript && bun test packages/cli/test/gen-fingerprint-linked-package.test.ts(4 pass, 0 fail; unit level)Live: disposable project under $DEV_SCRATCH withmetaobjects.config.tsimporting@metaobjectsdev/pack-fixture, a source-checkout pack symlinked intonode_modules; driven withbun server/typescript/packages/cli/bin/meta.ts genfour times (first gen, no change, pack generator edited, no change again)Evidence log kept in the local pipeline evidence store; disposable project removed afterwardsBaseline configured commandscripts/ci-local.sh --affected --strict-toolchainsalready passed at target commit; no source or test files changed in this turn, so not re-run🔧 **Document** - 1 issue found → auto-fixed ✅
spec/decisions/ADR-0064-skip-codegen-when-nothing-changed.md:42- ADR-0064 §3 lists generator identity 'in practice' as the engine package and its MetaObjects dependencies, plus codegen config, owned generators and template roots. It does not name third-party or pack generator packages the config imports. The change now hashes a non-engine @metaobjectsdev/* pack like any other generator package. I left the ADR unchanged: the decision already says a generator's identity is the hash of its built code, and the pack case falls under that rule. Judgment call: add a short Amendment if the ADR's list is meant to be exhaustive.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.