Skip to content

fix: fix injection filter in object properties #1013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 12, 2025

Conversation

Natoandro
Copy link
Contributor

@Natoandro Natoandro commented May 8, 2025

  • Only filter out leaf nodes of the injection tree.
  • Type the selection and output type for nested functions (part of MET-862).
  • Support conservative expansion; needed for FDK handlers that take the original type.
  • Improve logging:
    • Disable tracing instrumentations unless the tracing-instrument feature is enabled (CLI). This will make the output more readable by default.
    • Enable logging on crates other than meta (CLI): typegraph, tg_schema, metagen.

Migration notes

N/A


  • The change comes with new or modified tests
  • Hard-to-understand functions have explanatory comments
  • End-user documentation is updated to reflect the change

Summary by CodeRabbit

  • New Features

    • Added advanced typegraph expansion capabilities with configurable duplication and naming engines.
    • Introduced support for disconnected types in typegraphs.
    • Added optional tracing instrumentation in the CLI, enabled via a feature flag.
  • Improvements

    • Enhanced manifest rendering for TypeScript, Python, and Rust clients with better type caching and logging.
    • Improved policy handling and expansion logic for richer typegraph processing.
    • Updated synchronization primitives for lazy initialization, improving thread safety.
  • Bug Fixes

    • Prevented potential runtime errors in filter utilities by adding null checks.
  • Refactor

    • Major internal restructuring of typegraph expansion, duplication, and naming systems for extensibility and maintainability.
    • Simplified and unified module imports and type definitions.
  • Chores

    • Updated tests and fixtures to align with new typegraph schema handling and expansion logic.
    • Added a new optional CLI feature for conditional tracing instrumentation.

Copy link
Contributor

coderabbitai bot commented May 8, 2025

📝 Walkthrough

Walkthrough

This set of changes introduces a new, modular, and extensible typegraph expansion system, replacing the previous monolithic conversion logic. The refactor introduces configurable duplication and naming engines, restructures type linking and conversion steps, and updates synchronization primitives to use OnceLock. Public APIs, trait bounds, and type signatures are updated to reflect these new abstractions. Conditional tracing instrumentation is added across CLI modules, and logging is improved. Typegraph expansion is now explicitly applied in all client and FDK code generation paths.

Changes

File(s) Change Summary
src/typegraph/graph/src/conv/mod.rs Removed old conversion function; introduced TypegraphExpansionConfig and TypegraphExpansion structs for modular, configurable expansion.
src/typegraph/graph/src/expansion/mod.rs, src/typegraph/graph/src/expansion/map.rs, src/typegraph/graph/src/expansion/step.rs New expansion system: Registry, ExpansionConfig, TypegraphExpansion, ConversionStep, ConversionMap, and related logic for multi-pass, engine-driven typegraph expansion.
src/typegraph/graph/src/engines/duplication.rs, src/typegraph/graph/src/engines/naming.rs, src/typegraph/graph/src/engines/mod.rs Refactored duplication/naming engines: new traits (DuplicationEngine, DuplicationEngineFactory, NamingEngineFactory), updated method names, and new default engine structs.
src/typegraph/graph/src/key.rs Added TypeKey::original() method; updated import path for DupKey.
src/typegraph/graph/src/path.rs Removed branch field from ValueTypePath and all related logic.
src/typegraph/graph/src/type_registry.rs Updated to use new DuplicationEngine trait bound and new import paths for expansion types.
src/typegraph/graph/src/types/mod.rs Introduced interlude module for common imports; changed TypeBase::name from Once to OnceLock.
src/typegraph/graph/src/types/object.rs, src/typegraph/graph/src/types/list.rs, src/typegraph/graph/src/types/optional.rs, src/typegraph/graph/src/types/union.rs, src/typegraph/graph/src/types/function.rs Updated imports to use interlude; changed lazy fields from Once to OnceLock; updated trait bounds and method signatures to use new engine traits and expansion types.
src/typegraph/graph/src/types/boolean.rs, src/typegraph/graph/src/types/file.rs, src/typegraph/graph/src/types/float.rs, src/typegraph/graph/src/types/integer.rs, src/typegraph/graph/src/types/string.rs Simplified imports using interlude.
src/typegraph/graph/src/lib.rs Removed old conversion/naming modules from public API; added new internal modules; added disconnected_types to Typegraph; removed TryFrom implementation.
src/typegraph/graph/src/policies.rs Added PolicySpec::new() for constructing policy specs from registry and schema.
src/typegraph/graph/tests/expanded.rs Test updated to use new expansion system (ExpansionConfig::with_default_engines().expand).
src/metagen/src/client_ts/selections.rs Introduced TsSelectionExtras; updated manifest page logic and references; updated function signatures.
src/metagen/src/client_ts/mod.rs, src/metagen/src/client_py/mod.rs, src/metagen/src/client_rs/mod.rs, src/metagen/src/fdk_ts/mod.rs, src/metagen/src/fdk_py/mod.rs, src/metagen/src/fdk_rs/mod.rs All code generation now applies explicit typegraph expansion before manifest construction; added logging for manifest building and rendering.
src/metagen/src/fdk_ts/types.rs Updated type key derivation for function properties; TsTypesPage::new now accepts fdk argument and ensures inclusion of original input types.
src/metagen/src/fdk_rs/types.rs Test updated to expand typegraph before building manifest.
src/metagen/src/fdk_rs/stubs.rs Removed redundant typegraph conversion.
src/metagen/src/lib.rs, src/metagen/src/tests/fixtures.rs, src/metagen/src/tests/mod.rs Updated all references and signatures to use tg_schema::Typegraph for clarity and consistency.
src/typegraph/core/src/utils/metagen_utils.rs Simplified construction of generator input resolved variant, removing unnecessary conversion/wrapping.
src/meta-cli/Cargo.toml Added optional tracing-instrument feature.
src/meta-cli/src/cli/*.rs, src/meta-cli/src/config.rs, src/meta-cli/src/deploy/actors/typegate.rs, src/meta-cli/src/main.rs Conditional tracing instrumentation (#[cfg_attr(feature = "tracing-instrument", tracing::instrument)]); improved logging and info output.

Sequence Diagram(s)

sequenceDiagram
    participant Schema as tg_schema::Typegraph
    participant ExpansionConfig
    participant DupEngine as DuplicationEngine
    participant NamingEngine
    participant TypegraphExpansion
    participant ConversionMap
    participant Registry
    participant Typegraph

    Schema->>ExpansionConfig: expand(schema)
    ExpansionConfig->>DupEngine: create from schema
    ExpansionConfig->>NamingEngine: create from schema
    ExpansionConfig->>TypegraphExpansion: new(config, schema, engines)
    TypegraphExpansion->>Registry: extract runtimes, materializers, policies
    loop until all steps done
        TypegraphExpansion->>ConversionMap: run_conversion_steps()
        TypegraphExpansion->>TypegraphExpansion: run_link_steps()
    end
    TypegraphExpansion->>Typegraph: build expanded Typegraph (with registry, types, names, disconnected_types)
    Typegraph->>ExpansionConfig: return Arc<Typegraph>
Loading
sequenceDiagram
    participant Generator
    participant Typegraph
    participant ExpansionConfig
    participant ManifestBuilder
    participant Renderer

    Generator->>Typegraph: receive (raw or from input)
    Generator->>ExpansionConfig: expand(typegraph)
    ExpansionConfig->>Typegraph: produce expanded typegraph
    Generator->>ManifestBuilder: build manifest (with expanded typegraph)
    ManifestBuilder->>Renderer: render output files
Loading
sequenceDiagram
    participant CLI
    participant Tracing
    participant ExpansionConfig
    participant Generator

    CLI->>Tracing: (if feature enabled) instrument functions
    CLI->>Generator: run (with config, args)
    Generator->>ExpansionConfig: expand typegraph
    Generator->>...: proceed with manifest building and rendering
Loading

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/typegraph/graph/src/types/object.rs (1)

24-28: Focused correction to filter only leaf injections

This change modifies the is_injected method to only return true when the injection is a leaf node, correctly matching the PR objective to filter out only leaf nodes of the injection tree.

Consider adding a doc comment to explain the concept of injection and the significance of filtering only leaf nodes, which would help future developers understand the reasoning behind this specific implementation.

 impl ObjectProperty {
+    /// Returns true if this property has a leaf injection.
+    /// Only leaf nodes are considered "injected" as they contain the actual injection value.
     pub fn is_injected(&self) -> bool {
         self.injection
             .as_ref()
             .filter(|inj| matches!(inj.as_ref(), InjectionNode::Leaf { .. }))
             .is_some()
     }
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f29f202 and 076ace2.

📒 Files selected for processing (1)
  • src/typegraph/graph/src/types/object.rs (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/typegraph/graph/src/types/object.rs (1)
src/typegate/src/typegraph/types.ts (1)
  • InjectionNode (84-86)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: test-full
  • GitHub Check: lint-compat (macos-13, x86_64-apple-darwin, false)
  • GitHub Check: lint-compat (macos-14, aarch64-apple-darwin, false)
  • GitHub Check: pre-commit

Copy link

codecov bot commented May 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.15%. Comparing base (f29f202) to head (d8db584).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1013   +/-   ##
=======================================
  Coverage   81.15%   81.15%           
=======================================
  Files         143      143           
  Lines       18045    18046    +1     
  Branches     1970     1970           
=======================================
+ Hits        14645    14646    +1     
  Misses       3382     3382           
  Partials       18       18           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

linear bot commented May 9, 2025

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🔭 Outside diff range comments (1)
src/metagen/src/tests/fixtures.rs (1)

122-132: ⚠️ Potential issue

Avoid potential panic on empty CLI output
tg.pop().unwrap() will panic if the CLI returns zero typegraphs (e.g., compilation error, wrong path).
Return an error instead to keep tests from aborting unexpectedly:

-    let tg = Arc::new(tg.pop().unwrap());
-    Ok(tg)
+    let tg = tg
+        .pop()
+        .map(Arc::new)
+        .ok_or_else(|| eyre!("no typegraph returned by meta-cli"))?;
+    Ok(tg)
🧹 Nitpick comments (9)
src/metagen/src/fdk_rs/types.rs (1)

1026-1028: Avoid shadowing the tg variable to improve readability

tg first refers to the schema graph (Arc<tg_schema::Typegraph>) and is immediately re-used for the expanded graph (Arc<typegraph::Typegraph>). Shadowing with two different concrete types makes the code harder to skim and can trip up future refactors.

-let tg = create_typegraph(name.into(), nodes)?;
-let tg = TypegraphExpansionConfig::default().expand_with_default_params(tg)?;
+let tg_schema = create_typegraph(name.into(), nodes)?;
+let tg = TypegraphExpansionConfig::default().expand_with_default_params(tg_schema)?;

Explicit names make it obvious which instance is which and prevent accidental type mix-ups.

src/metagen/src/client_py/mod.rs (1)

85-91: Eliminate the extra Arc clone and unify the matching arms

Each match arm clones the raw Arc only to pass it immediately to expand_with_default_params. You can avoid the duplication and the extra reference increment with a single binding:

-        let tg = match inputs
-            .get(Self::INPUT_TG)
-            .context("missing generator input")?
-        {
-            GeneratorInputResolved::TypegraphFromTypegate { raw } => raw.clone(),
-            GeneratorInputResolved::TypegraphFromPath { raw } => raw.clone(),
-            _ => bail!("unexpected input type"),
-        };
+        let raw_schema = match inputs
+            .get(Self::INPUT_TG)
+            .context("missing generator input")?
+        {
+            GeneratorInputResolved::TypegraphFromTypegate { raw }
+            | GeneratorInputResolved::TypegraphFromPath { raw } => raw,
+            _ => bail!("unexpected input type"),
+        };
+
+        // Expand once
+        let tg = TypegraphExpansionConfig::default().expand_with_default_params(raw_schema.clone())?;

The intent stays the same and we avoid an unnecessary clone on an Arc.

src/typegraph/graph/tests/expanded.rs (1)

22-25: Print stderr only on failure to keep CI output clean

The unconditional eprintln! floods CI logs even when the test passes. Consider gating it behind the status check (or an env flag) so it only aids debugging when something actually fails:

-if !output.stderr.is_empty() {
-    eprintln!("---stderr-start---\n{}\n---stderr-end---",
-        String::from_utf8(output.stderr)?);
-}
+if !output.status.success() && !output.stderr.is_empty() {
+    eprintln!("---stderr-start---\n{}\n---stderr-end---",
+        String::from_utf8(output.stderr)?);
+}

This keeps the happy-path quiet while still surfacing useful diagnostics on failure.

src/typegraph/graph/src/lib.rs (2)

70-76: Consider documenting and validating disconnected_types
The new disconnected_types field is a public collection but there is no accompanying documentation or helper API.

  • Why does the key use the raw schema index (u32) instead of the internal TypeKey abstraction used elsewhere?
  • Under which conditions can this map be empty vs. partially-populated?
    A short comment or accessor that clarifies the intended life-cycle would avoid misuse and future refactors.

52-55: Re-export is handy, but expose through prelude as well?
TypegraphExpansionConfig is now public-re-exported here, but most downstream code seems to rely on prelude::*.
If that is the common import path, consider also adding the type to pub mod prelude for consistency.

src/typegraph/graph/src/conv/step.rs (2)

552-565: Expose StepResult::new publicly or add From<Type> implementation
Several conversion helpers now call StepResult::<G>::new(ty.clone()), which is readable but slightly noisy.
Implementing impl<G: DupKeyGen> From<Type> for StepResult<G> (or making new pub) would let callers write StepResult::from(ty.clone()), improving ergonomics and reducing boiler-plate.


206-233: Minor optimisation: avoid an extra clone of ty
StepResult::new(ty.clone()) immediately clones ty, and a second clone happens inside MapItem::new.
You can move the MapItem::new call before constructing StepResult and reuse the original value, e.g.:

-        let ty = Type::Optional(ty_inner.clone());
-        let mut result = StepResult::<G>::new(ty.clone());
+        let ty = Type::Optional(ty_inner.clone());
+        let map_item = MapItem::new(&ty, self.rpath.clone(), self.dkey.clone())?;
+        let mut result = StepResult::<G>::new(ty);

This shaves one Arc clone per node.

src/typegraph/graph/src/conv/mod.rs (2)

144-156: Left-over eprintln! debug output
eprintln!("another round needed for #{idx}"); will print on every expansion when always_convert_original is enabled, polluting stdout/stderr of libraries and larger CLI tools.
Recommend gating behind cfg!(debug_assertions) or using the tracing crate with an appropriate log level.


193-211: converting_disconnected_types flag never reset
After the first “original” round the flag remains true, so every subsequent call to run_conversion_steps (even if no steps are added) will keep inserting converted types into self.disconnected_types.
Although harmless right now, resetting the flag to false after the round completes would avoid surprises if the loop ever iterates again for other reasons.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b3429c1 and 08e3485.

📒 Files selected for processing (20)
  • src/meta-cli/src/cli/gen.rs (2 hunks)
  • src/metagen/src/client_py/mod.rs (2 hunks)
  • src/metagen/src/client_rs/mod.rs (2 hunks)
  • src/metagen/src/client_ts/mod.rs (4 hunks)
  • src/metagen/src/fdk_py/mod.rs (2 hunks)
  • src/metagen/src/fdk_rs/mod.rs (2 hunks)
  • src/metagen/src/fdk_rs/stubs.rs (0 hunks)
  • src/metagen/src/fdk_rs/types.rs (2 hunks)
  • src/metagen/src/fdk_ts/mod.rs (4 hunks)
  • src/metagen/src/fdk_ts/types.rs (2 hunks)
  • src/metagen/src/lib.rs (1 hunks)
  • src/metagen/src/tests/fixtures.rs (5 hunks)
  • src/metagen/src/tests/mod.rs (2 hunks)
  • src/typegraph/core/src/utils/metagen_utils.rs (1 hunks)
  • src/typegraph/graph/src/conv/key.rs (1 hunks)
  • src/typegraph/graph/src/conv/map.rs (1 hunks)
  • src/typegraph/graph/src/conv/mod.rs (2 hunks)
  • src/typegraph/graph/src/conv/step.rs (13 hunks)
  • src/typegraph/graph/src/lib.rs (2 hunks)
  • src/typegraph/graph/tests/expanded.rs (1 hunks)
💤 Files with no reviewable changes (1)
  • src/metagen/src/fdk_rs/stubs.rs
✅ Files skipped from review due to trivial changes (5)
  • src/typegraph/core/src/utils/metagen_utils.rs
  • src/typegraph/graph/src/conv/map.rs
  • src/typegraph/graph/src/conv/key.rs
  • src/metagen/src/lib.rs
  • src/metagen/src/tests/mod.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/metagen/src/fdk_ts/types.rs
  • src/metagen/src/client_ts/mod.rs
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: test-full
  • GitHub Check: lint-compat (macos-14, aarch64-apple-darwin, false)
  • GitHub Check: lint-compat (macos-13, x86_64-apple-darwin, false)
  • GitHub Check: pre-commit
🔇 Additional comments (11)
src/meta-cli/src/cli/gen.rs (2)

174-174: Simplified typegraph handling.

The code now directly uses the raw typegraph without unnecessary conversions.


196-196: Fixed inconsistent return type.

This change correctly returns a TypegraphFromTypegate variant for typegraphs loaded from path, maintaining consistency with the broader codebase changes that now consistently use Arc<tg_schema::Typegraph> directly.

src/metagen/src/fdk_rs/mod.rs (2)

20-20: Added import for typegraph expansion.

The import of TypegraphExpansionConfig is necessary for the expansion functionality added below.


144-147: Added typegraph expansion to process the injection tree properly.

This change adds the explicit expansion of the typegraph before further processing. The always_convert_original() configuration ensures that the original typegraph is converted regardless of any caching mechanisms.

This expansion step is crucial for correctly filtering injection nodes, as it ensures that the typegraph structure is fully expanded with default parameters, which helps address the injection filtering issue mentioned in the PR objectives.

src/metagen/src/client_rs/mod.rs (2)

15-15: Added import for typegraph expansion.

The import of TypegraphExpansionConfig is necessary for the expansion functionality added below.


158-160: Added cloning and expansion of the typegraph for consistent processing.

The code now explicitly clones the raw typegraph and applies expansion with default parameters. This ensures consistent preprocessing across different generators and properly handles the injection tree.

This expansion is important for correctly handling nested function types, addressing part of the MET-862 issue mentioned in the PR objectives.

Also applies to: 162-163

src/metagen/src/fdk_py/mod.rs (2)

12-12: Added import for typegraph expansion.

The import of TypegraphExpansionConfig is necessary for the expansion functionality added below.


205-208: Added typegraph expansion for consistent processing across generators.

This addition ensures the typegraph is properly expanded with default parameters, adding the always_convert_original() option to ensure consistent conversion regardless of caching.

This change aligns with similar modifications in other generator modules, ensuring consistent handling of the injection tree and properly typing nested functions.

src/metagen/src/fdk_ts/mod.rs (1)

118-120: Handle missing cached-type look-ups gracefully

map.get(&fun.input().key().original()).unwrap() will panic if the original input type was not cached—e.g., if always_convert_original() is removed in the future or if the cache is filtered. Prefer an explicit error to avoid hiding this edge case behind a hard-to-trace panic:

-let inp_ty = map.get(&fun.input().key().original()).unwrap();
+let inp_ty = map
+    .get(&fun.input().key().original())
+    .expect("cached type for materializer input not found");

The expect message documents the invariant and yields a clearer error in the unlikely event it is violated.

src/typegraph/graph/src/conv/step.rs (1)

38-53: disconnected path segment is hard-coded to Input
For truly disconnected nodes we cannot assume they always belong to the input branch; some may be outputs or other value kinds in the future.
Consider parameterising ValueTypeKind or inferring it from context instead of fixing it to Input, or at least add a TODO explaining the limitation.

src/metagen/src/tests/fixtures.rs (1)

80-106: create_typegraph helper: missing validation for test_types indices
The function blindly assigns indices idx + 4 for the additional test_types.
If any of the supplied nodes internally reference indices ≥ types.len() this will produce an invalid schema.
Consider validating references or documenting the expectation to callers.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/typegraph/graph/src/conv/mod.rs (1)

138-203: Missing error handling for potential unwrap failure

The run method contains an unwrap at line 161 that could panic if the conversion map's first item is unexpectedly missing.

Consider adding a fallback or proper error handling:

-            let map_item = self.conversion_map.direct.first().unwrap();
-            match map_item {
-                MapItem::Namespace(root, _) => root.clone(),
-                _ => unreachable!(),
+            self.conversion_map.direct.first()
+                .and_then(|map_item| match map_item {
+                    MapItem::Namespace(root, _) => Some(root.clone()),
+                    _ => None,
+                })
+                .ok_or_else(|| anyhow::anyhow!("Missing root namespace in conversion map"))?
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 08e3485 and edfb2b2.

📒 Files selected for processing (23)
  • src/meta-cli/Cargo.toml (1 hunks)
  • src/meta-cli/src/cli/completion.rs (1 hunks)
  • src/meta-cli/src/cli/deploy.rs (3 hunks)
  • src/meta-cli/src/cli/dev.rs (1 hunks)
  • src/meta-cli/src/cli/doctor.rs (1 hunks)
  • src/meta-cli/src/cli/fdk_template.rs (1 hunks)
  • src/meta-cli/src/cli/gen.rs (6 hunks)
  • src/meta-cli/src/cli/list.rs (1 hunks)
  • src/meta-cli/src/cli/new.rs (1 hunks)
  • src/meta-cli/src/cli/serialize.rs (1 hunks)
  • src/meta-cli/src/cli/undeploy.rs (1 hunks)
  • src/meta-cli/src/cli/upgrade.rs (2 hunks)
  • src/meta-cli/src/config.rs (2 hunks)
  • src/meta-cli/src/deploy/actors/typegate.rs (1 hunks)
  • src/meta-cli/src/main.rs (2 hunks)
  • src/metagen/src/client_py/mod.rs (2 hunks)
  • src/metagen/src/client_rs/mod.rs (2 hunks)
  • src/metagen/src/client_ts/mod.rs (4 hunks)
  • src/metagen/src/fdk_py/mod.rs (3 hunks)
  • src/metagen/src/fdk_rs/mod.rs (4 hunks)
  • src/metagen/src/fdk_ts/mod.rs (4 hunks)
  • src/typegraph/graph/src/conv/mod.rs (2 hunks)
  • src/typegraph/graph/src/lib.rs (2 hunks)
✅ Files skipped from review due to trivial changes (10)
  • src/meta-cli/Cargo.toml
  • src/meta-cli/src/cli/fdk_template.rs
  • src/meta-cli/src/cli/list.rs
  • src/meta-cli/src/cli/doctor.rs
  • src/meta-cli/src/cli/undeploy.rs
  • src/meta-cli/src/cli/upgrade.rs
  • src/meta-cli/src/cli/serialize.rs
  • src/meta-cli/src/config.rs
  • src/meta-cli/src/cli/deploy.rs
  • src/meta-cli/src/deploy/actors/typegate.rs
🚧 Files skipped from review as they are similar to previous changes (7)
  • src/metagen/src/client_rs/mod.rs
  • src/metagen/src/client_py/mod.rs
  • src/metagen/src/fdk_py/mod.rs
  • src/metagen/src/fdk_rs/mod.rs
  • src/typegraph/graph/src/lib.rs
  • src/metagen/src/fdk_ts/mod.rs
  • src/meta-cli/src/cli/gen.rs
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: test-full
  • GitHub Check: lint-compat (macos-14, aarch64-apple-darwin, false)
  • GitHub Check: lint-compat (macos-13, x86_64-apple-darwin, false)
  • GitHub Check: pre-commit
🔇 Additional comments (16)
src/meta-cli/src/cli/dev.rs (1)

51-51: Improved build configuration with conditional tracing instrumentation

The change from direct #[tracing::instrument] to conditional #[cfg_attr(feature = "tracing-instrument", tracing::instrument)] is a good improvement that makes tracing instrumentation optional based on feature flags.

src/meta-cli/src/cli/completion.rs (1)

25-25: Conditional tracing based on feature flag

Making the tracing instrumentation conditional via #[cfg_attr(feature = "tracing-instrument", tracing::instrument)] is consistent with the approach applied across the codebase, allowing for more flexible build configurations.

src/meta-cli/src/cli/new.rs (2)

45-45: Conditional tracing based on feature flag

Applying #[cfg_attr(feature = "tracing-instrument", tracing::instrument)] makes tracing instrumentation optional, which is consistent with changes elsewhere in the codebase.


53-53: Improved logging with semantic level macros

The changes from println! to proper logging macros (debug! and info!) improve the code by:

  1. Using appropriate log levels for different messages
  2. Making logs filterable in production
  3. Ensuring consistent logging patterns across the codebase

Also applies to: 59-59

src/meta-cli/src/main.rs (2)

60-60: Conditional tracing instrumentation

Making the tracing instrumentation conditional using #[cfg_attr(feature = "tracing-instrument", tracing::instrument)] is a good practice that allows for more flexible build configurations.


85-92: Enhanced logging configuration

The improved RUST_LOG environment variable configuration now properly covers additional modules (meta, metagen, tg_schema, typegraph) for consistent logging levels across related components.

src/typegraph/graph/src/conv/mod.rs (4)

58-97: Well-designed configuration API for typegraph expansion

The new TypegraphExpansionConfig struct provides a clean, fluent interface for configuring typegraph expansion with sensible defaults. The documentation explains the purpose of each option clearly.


99-110: Good separation of configuration from implementation

The TypegraphExpansion struct properly separates configuration from implementation details. The fields are well-organized with clear responsibilities, including tracking of disconnected types.


205-231: Well implemented recursive conversion steps

The implementation handles conversion steps recursively while maintaining state in a clean way. The conditional logic for disconnected types is correctly implemented.


233-239: Good use of memory optimization with std::mem::take

The run_link_steps method efficiently uses std::mem::take to avoid unnecessary cloning when processing link steps.

src/metagen/src/client_ts/mod.rs (6)

11-15: Imports updated to accommodate new architecture

The imports have been properly updated to reference the new modules and types, including TypegraphExpansionConfig.


45-46: Improved memory management with Arc-wrapped IndexMap

Converting the types field from a plain IndexMap to an Arc<IndexMap> allows for more efficient sharing of the type cache without unnecessary cloning.


59-63: Added FDK parameter for conditional behavior

The TsClientManifest::new method now accepts an fdk parameter that's passed to TsTypesPage::new, allowing for conditional behavior during type page creation. The types are now correctly wrapped in an Arc for shared ownership.


68-68: Updated function call to pass shared type references

The call to selections::manifest_page now correctly passes the Arc-wrapped types memo, ensuring the selection manifest can efficiently share type references.


128-134: Explicit typegraph expansion using new API

The code now properly clones the raw typegraph and expands it using the new TypegraphExpansionConfig API before passing it to manifest creation. This ensures consistent expansion behavior across different code generators.


135-141: Added helpful logging around manifest building and rendering

The added log statements provide useful information about the progress of manifest building and rendering, which will help with debugging and monitoring.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/typegraph/graph/src/conv/mod.rs (1)

142-162: Consider adding more detailed logging for conservative expansion

The run method includes good high-level logging for the expansion process, but consider adding more detailed logging when processing disconnected types in conservative mode to aid debugging.

 if self.config.conservative {
+    tracing::debug!("adding disconnected types for conservative expansion");
     for (idx, map_item) in self.conversion_map.direct.iter().enumerate() {
         if let MapItem::Value(vtype) = map_item {
             if vtype.default.is_none() {
+                tracing::trace!("adding disconnected type at index {}", idx);
                 self.conversion_steps
                     .push_back(ConversionStep::disconnected(idx as u32))
             }
         }
     }
     self.converting_disconnected_types = true;
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between edfb2b2 and 437af5f.

📒 Files selected for processing (4)
  • src/metagen/src/fdk_py/mod.rs (3 hunks)
  • src/metagen/src/fdk_rs/mod.rs (4 hunks)
  • src/metagen/src/fdk_ts/mod.rs (4 hunks)
  • src/typegraph/graph/src/conv/mod.rs (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/metagen/src/fdk_rs/mod.rs
  • src/metagen/src/fdk_py/mod.rs
  • src/metagen/src/fdk_ts/mod.rs
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: test-full
  • GitHub Check: lint-compat (macos-14, aarch64-apple-darwin, false)
  • GitHub Check: lint-compat (macos-13, x86_64-apple-darwin, false)
  • GitHub Check: pre-commit
🔇 Additional comments (10)
src/typegraph/graph/src/conv/mod.rs (10)

58-65: Well-documented configuration struct

The new TypegraphExpansionConfig provides clear documentation for the conservative flag, explaining its purpose for converting original types even when unreachable. This is crucial for understanding the expansion behavior.


67-74: Good builder pattern implementation

The implementation of conservative() follows a proper builder pattern by returning self, allowing for method chaining. The documentation clearly explains what "original types" means in this context.


75-84: Convenient default parameters expansion method

The expand_with_default_params method provides a convenient way to expand a typegraph with default parameters, simplifying the API for common use cases.


85-101: Well-designed generic expansion method

The expand method is well-designed with appropriate generic type constraints, allowing for customization of duplication key generation and naming engine while maintaining type safety.


103-114: Clear struct fields for expansion state

The TypegraphExpansion struct has a well-organized set of fields to track the state of the expansion process. The inclusion of converting_disconnected_types flag helps manage the conservative expansion mode.


120-140: Well-implemented constructor

The new method properly initializes all fields with sensible defaults and takes all necessary dependencies as parameters.


164-191: Good performance tracking

The code includes performance tracking that's conditionally compiled only in debug builds, which is a good practice to avoid overhead in production.


193-207: Efficient resource management for final Typegraph assembly

The code efficiently manages memory by using std::mem::take to move resources when assembling the final Typegraph structure.


209-235: Well-structured conversion steps execution

The run_conversion_steps method has a good structure with clear control flow and proper error handling. The approach of returning a boolean to indicate whether more work is needed is clean and effective.


237-243: Efficient link steps execution

The run_link_steps method efficiently takes the accumulated link steps and processes them, providing clean error handling.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🔭 Outside diff range comments (1)
src/typegraph/graph/src/expansion/step.rs (1)

489-491: 🛠️ Refactor suggestion

TODO outjection is still unresolved

Outjection support for function outputs is acknowledged but not implemented:

injection: None, // TODO outjection

Because outjection can modify output typing, leaving this unhandled may yield an incorrect duplication key and an incomplete expansion.
Either implement outjection propagation now or add a tracking issue so the gap is not forgotten.

🧹 Nitpick comments (7)
src/typegraph/graph/src/types/list.rs (1)

4-5: Avoid * imports to preserve API clarity

Wildcard imports (use super::interlude::*) hide the concrete dependencies of this module and make it harder to track the public surface when reading or reviewing the code. Re-export “interlude” items explicitly or keep them grouped in a prelude if you want ergonomic shorthand, but still list the identifiers.

src/typegraph/graph/src/types/union.rs (1)

4-5: Prefer explicit imports over wildcards

Same comment as for list.rs: hiding dependencies via * imports makes grepping and IDE “find usages” less effective. Consider enumerating the symbols or creating a small prelude module with only what you actually need.

src/typegraph/graph/src/expansion/map.rs (1)

7-11: Import list can be trimmed

NameRegistry is only used in assign_names; if that method moves behind a feature-gate, the import becomes dead code. Optional: add #[cfg(feature = "naming")] around both the import and the function to avoid unconditional pulls.

src/typegraph/graph/src/types/function.rs (2)

4-5: Wild-card imports hide dependencies

Repeated here for completeness: replacing * imports with explicit names helps maintenance (rust-analyzer, grep, docs). Consider splitting interlude into a curated prelude with only the handful of items every file needs.

Also applies to: 7-8


60-96: Factor out duplicated OnceLock::set + error dance

The same pattern (map.get_exOnceLock::set → custom error) appears in every link implementation. You could DRY this up with a tiny helper:

fn set_once_lock<T>(
    lock: &OnceLock<T>,
    value: T,
    ctx: impl std::fmt::Display,
) -> Result<()> {
    lock.set(value).map_err(|_| eyre!("OnceLock: {ctx} already set"))
}

Which makes the critical path clearer and reduces boilerplate:

set_once_lock(&self.ty.input, obj.clone(), format!("function input; key={:?}", self.ty.key()))?;

Not blocking, but saves ~15 lines per type node.

src/typegraph/graph/src/engines/duplication.rs (1)

78-80: key_for_fn_output always returns the default key – outjections ignored

Currently:

fn key_for_fn_output(&self, _fn_type: &FunctionType) -> Self::Key {
    Self::Key { injection: None }
}

If/when outjection support is added (see TODO in step.rs), the duplication engine will need to honour output-level injections as well.
Placing a FIXME here or wiring the future outjection field now will prevent silent bugs later.

src/typegraph/graph/src/expansion/mod.rs (1)

203-214: Potential quadratic growth when conservative expansion is enabled

Inside the outer while loop we keep re-scanning the whole conversion_map and push a ConversionStep::disconnected for every type whose default is None, every iteration:

for (idx, map_item) in self.conversion_map.direct.iter().enumerate() {self.conversion_steps.push_back(ConversionStep::disconnected(idx as u32))
}

Although plan() will skip duplicates, we still:

  • allocate identical ConversionSteps repeatedly,
  • pay hashing / look-ups, and
  • keep run_conversion_steps returning true even when nothing new is actually produced.

A simple guard (if !self.converting_disconnected_types) around the push loop or retaining a HashSet<u32> of already-queued indices would cap the complexity.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 437af5f and d8db584.

📒 Files selected for processing (31)
  • src/metagen/src/client_py/mod.rs (2 hunks)
  • src/metagen/src/client_rs/mod.rs (2 hunks)
  • src/metagen/src/client_ts/mod.rs (4 hunks)
  • src/metagen/src/fdk_py/mod.rs (3 hunks)
  • src/metagen/src/fdk_rs/mod.rs (4 hunks)
  • src/metagen/src/fdk_rs/types.rs (2 hunks)
  • src/metagen/src/fdk_ts/mod.rs (4 hunks)
  • src/typegate/src/runtimes/substantial/filter_utils.ts (2 hunks)
  • src/typegraph/graph/src/engines/duplication.rs (4 hunks)
  • src/typegraph/graph/src/engines/mod.rs (1 hunks)
  • src/typegraph/graph/src/engines/naming.rs (4 hunks)
  • src/typegraph/graph/src/expansion/map.rs (2 hunks)
  • src/typegraph/graph/src/expansion/mod.rs (1 hunks)
  • src/typegraph/graph/src/expansion/step.rs (18 hunks)
  • src/typegraph/graph/src/key.rs (1 hunks)
  • src/typegraph/graph/src/lib.rs (3 hunks)
  • src/typegraph/graph/src/path.rs (3 hunks)
  • src/typegraph/graph/src/policies.rs (2 hunks)
  • src/typegraph/graph/src/type_registry.rs (4 hunks)
  • src/typegraph/graph/src/types/boolean.rs (1 hunks)
  • src/typegraph/graph/src/types/file.rs (1 hunks)
  • src/typegraph/graph/src/types/float.rs (1 hunks)
  • src/typegraph/graph/src/types/function.rs (2 hunks)
  • src/typegraph/graph/src/types/integer.rs (1 hunks)
  • src/typegraph/graph/src/types/list.rs (2 hunks)
  • src/typegraph/graph/src/types/mod.rs (2 hunks)
  • src/typegraph/graph/src/types/object.rs (3 hunks)
  • src/typegraph/graph/src/types/optional.rs (2 hunks)
  • src/typegraph/graph/src/types/string.rs (1 hunks)
  • src/typegraph/graph/src/types/union.rs (2 hunks)
  • src/typegraph/graph/tests/expanded.rs (1 hunks)
✅ Files skipped from review due to trivial changes (6)
  • src/typegraph/graph/src/types/file.rs
  • src/typegraph/graph/src/types/string.rs
  • src/typegraph/graph/src/types/boolean.rs
  • src/typegraph/graph/src/type_registry.rs
  • src/typegraph/graph/src/engines/mod.rs
  • src/typegraph/graph/src/types/mod.rs
🚧 Files skipped from review as they are similar to previous changes (9)
  • src/metagen/src/fdk_rs/types.rs
  • src/typegraph/graph/tests/expanded.rs
  • src/metagen/src/client_py/mod.rs
  • src/typegraph/graph/src/lib.rs
  • src/metagen/src/fdk_py/mod.rs
  • src/metagen/src/client_rs/mod.rs
  • src/metagen/src/fdk_ts/mod.rs
  • src/metagen/src/fdk_rs/mod.rs
  • src/typegraph/graph/src/types/object.rs
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/typegate/src/runtimes/substantial/filter_utils.ts (1)
src/typegate/src/runtimes/substantial/deno_context.ts (1)
  • result (254-286)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: build-docker (linux/amd64, custom-ubuntu-large)
  • GitHub Check: build-docker (linux/arm64, ubuntu-22.04-arm)
  • GitHub Check: test-full
  • GitHub Check: lint-compat (macos-13, x86_64-apple-darwin, false)
🔇 Additional comments (28)
src/typegraph/graph/src/types/float.rs (1)

4-4: Improved import organization.

The import has been simplified by using the new centralized interlude module. This change aligns with the broader pattern across type modules and improves consistency without affecting any functionality.

src/typegraph/graph/src/types/integer.rs (1)

4-4: Import consolidation looks good.

The change to use super::interlude::* simplifies imports and aligns with the broader refactoring effort across type modules. This improves consistency without changing functionality.

src/typegate/src/runtimes/substantial/filter_utils.ts (2)

73-73: Good defensive programming.

Adding the nullish check on result prevents potential runtime errors when accessing properties on undefined/null values. This increases the robustness of the code.


131-131: Syntax cleanup looks good.

Removing the trailing comma improves code consistency and follows best practices.

src/typegraph/graph/src/key.rs (2)

4-4: Import path update looks good.

Changing from a relative import to an absolute crate import for DupKey aligns with the module restructuring in the codebase.


9-13: Well-implemented TypeKey.original method.

This new method correctly creates a TypeKey with the same type index but resets the variant/duplicate ID to zero. This supports the injection filter fix by allowing access to the original type key without variant offsets, which is essential for filtering only leaf nodes in the injection tree.

src/typegraph/graph/src/engines/naming.rs (4)

6-6: Import path update is correct.

The import path change from crate::conv to crate::expansion properly reflects the new module structure after the expansion system refactoring.


29-29: Clone trait bound addition is appropriate.

Adding the Clone trait bound to NamingEngineFactory ensures consistency with other engine factories in the codebase and supports the new expansion system architecture.


46-47: Derive Clone implementation is consistent.

Adding Clone to the derive list for DefaultNamingEngineFactory properly implements the new trait bound requirement. This change is aligned with similar updates to other engine factories.


97-98: Import ordering looks good.

Moving the DupKey import after the public exports maintains a clean separation between public API and internal implementation details.

src/typegraph/graph/src/policies.rs (1)

28-52: Well-implemented policy mapping functionality!

The PolicySpec::new implementation provides a clean and efficient way to construct policy specifications from indices using the registry. It handles both simple and conditional policies appropriately while maintaining good performance with pre-allocated capacity.

src/typegraph/graph/src/path.rs (3)

181-182: Good simplification of path equality check.

Removing the branch field comparison simplifies the equality check, making it more maintainable while preserving the essential comparison logic.


271-272: Clean simplification of ValueTypePath construction.

The simplified constructor for input path improves readability by removing the unnecessary branch field.


275-276: Clean simplification of ValueTypePath construction.

Similar to the input path, the output path construction is now more concise without the branch field.

src/typegraph/graph/src/types/optional.rs (2)

11-11: Improved synchronization with OnceLock.

Replacing Once with OnceLock is a good modernization that provides better thread-safe lazy initialization capabilities.


51-51: Updated trait bound to use the new DuplicationEngine.

Changing from DupKeyGen to DuplicationEngine aligns with the broader refactoring of the duplication system, providing more flexibility and control over the duplication process.

src/metagen/src/client_ts/mod.rs (5)

45-46: Improved type sharing with Arc.

Using Arc<IndexMap> instead of just IndexMap for the types enables efficient sharing of the type mapping across different components, reducing memory usage and potentially improving performance.


59-63: Added support for FDK-specific type generation.

The new fdk parameter allows the client manifest to behave differently when generating code for FDK vs. client usage, addressing part of the PR objective to support conservative expansion for FDK handlers.


68-68: Enhanced type sharing in manifest page.

Passing the shared types_memo to the selections manifest page improves consistency and reduces redundant type mapping operations.


133-133: Explicit typegraph expansion with the new system.

Using the new ExpansionConfig::with_default_engines().expand(tg) approach ensures the typegraph is properly expanded with the modular expansion system before generating client code.


135-140: Improved logging for better debugging.

Adding informational logging statements before and after key processing stages improves observability and aligns with the PR objective to enhance logging clarity.

src/typegraph/graph/src/types/list.rs (2)

11-11: Confirm MSRV ≥ 1.70 now that OnceLock is used

std::sync::OnceLock is only stable starting with Rust 1.70. If the project has an MSRV lower than that, builds will break.
Action items

  1. Add/adjust the rust-version field in the root Cargo.toml.
  2. Mention the new MSRV in the CHANGELOG / release notes.

29-32: 👍 Clean trait migration to DuplicationEngine

The new signature is concise and keeps the link-time API symmetrical with the rest of the expansion machinery. Nothing to change here.

src/typegraph/graph/src/types/union.rs (2)

11-11: MSRV check for OnceLock

UnionType::variants moved to OnceLock, which requires Rust ≥ 1.70. Please ensure the crate’s stated MSRV reflects this.


29-32: Good consistency with the new DuplicationEngine abstraction

The refactor keeps the linking API uniform across all type nodes.

src/typegraph/graph/src/types/function.rs (1)

14-15: MSRV reminder for OnceLock

Follow-up from other files: ensure MSRV is bumped and documented.

src/typegraph/graph/src/expansion/step.rs (2)

40-52: Check semantic correctness of RelativePath::Input for disconnected types

disconnected() fabricates a step with

rpath: RelativePath::Input(ValueTypePath {
    owner: Default::default(),
    path: vec![],
}),

Disconnected types are not necessarily related to function inputs, yet we hard-wire them to the Input variant.
Down-stream code (e.g. ConversionMap::next_key and name assignment) relies on the RelativePath variant to decide into which bucket (value/function/namespace) the converted type is stored. Mis-categorising the path could:

  • cause the type to be inserted in the wrong map entry, breaking look-ups,
  • give the type an “input”-style canonical name although it is not a function argument.

Please double-check whether Input is really the intended category here.
If the goal is merely “some value type”, consider introducing a dedicated RelativePath::Detached (or reuse NsObject/Value) to avoid overloading semantics.


470-492: MapItem::new gets a fresh RelativePath::Function(self.idx) – is that valid?

Unlike other convert_* helpers that pass self.rpath.clone(), convert_function builds a brand new path:

MapItem::new(&ty, RelativePath::Function(self.idx),)

If the current ConversionStep is not the root (e.g. a function nested inside an object property), self.rpath already tracks the full path.
Replacing it with RelativePath::Function(self.idx) might:

  • lose the surrounding context,
  • create two distinct map keys for the very same type, and
  • make deduplication/naming inconsistent.

Unless this was intentional, consider keeping the accumulated path:

- MapItem::new(&ty, RelativePath::Function(self.idx), self.dkey.clone())?
+ MapItem::new(&ty, self.rpath.clone(), self.dkey.clone())?

Please verify with a nested-function test case.

@Natoandro Natoandro merged commit 58c4f25 into main May 12, 2025
13 checks passed
@Natoandro Natoandro deleted the fix-metagen-with-injection branch May 12, 2025 18:36
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.

3 participants