Skip to content

feat(schema): add paths for schema types - #449

Merged
rapids-bot[bot] merged 12 commits into
rapidsai:mainfrom
johanpel:schema-type-paths-core
Jul 24, 2026
Merged

feat(schema): add paths for schema types#449
rapids-bot[bot] merged 12 commits into
rapidsai:mainfrom
johanpel:schema-type-paths-core

Conversation

@johanpel

@johanpel johanpel commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Description

Add quent_schema::Path and migrate record and entity types from flat identifiers to paths. Most of the diff mechanically propagates that type change through constraints, FSMs, references, resources, and YAML lowering.

The notable behavioral changes are:

  • Records and entities share one type namespace, enforced by builder validation and the new DuplicateTypePaths base constraint.
  • Schema record/entity maps serialize as entry sequences because paths are arrays.
  • Foo::Memory generates sibling resource records such as Foo::MemoryUsage.
  • instrumentation-build temporarily rejects qualified paths.

YAML syntax remains unchanged and only produces one-segment paths.

A follow-up PR will add namespaced Rust instrumentation generation and simplify the generated runtime API.

Related Issues

Extracted from #448 to make reviewing easier. Part of #442.

Written by Codex.

johanpel added 10 commits July 24, 2026 11:02
Signed-off-by: Johan Peltenburg <johan.peltenburg+code@gmail.com>
Signed-off-by: Johan Peltenburg <johan.peltenburg+code@gmail.com>
Signed-off-by: Johan Peltenburg <johan.peltenburg+code@gmail.com>
Signed-off-by: Johan Peltenburg <johan.peltenburg+code@gmail.com>
Signed-off-by: Johan Peltenburg <johan.peltenburg+code@gmail.com>
Signed-off-by: Johan Peltenburg <johan.peltenburg+code@gmail.com>
Signed-off-by: Johan Peltenburg <johan.peltenburg+code@gmail.com>
Signed-off-by: Johan Peltenburg <johan.peltenburg+code@gmail.com>
Signed-off-by: Johan Peltenburg <johan.peltenburg+code@gmail.com>
Signed-off-by: Johan Peltenburg <johan.peltenburg+code@gmail.com>

@johanpel johanpel left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Self-review to help reviewers

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Records and entities share one type namespace, enforced by builder validation and the new DuplicateTypePaths base constraint.

Comment on lines +32 to +38
#[cfg_attr(feature = "serde", serde(with = "indexmap::map::serde_seq"))]
#[cfg_attr(feature = "ts", ts(as = "Vec<(Path, Entity)>"))]
entities: Map<Path, Entity>,
/// The [`Record`]s of the model.
#[cfg_attr(feature = "ts", ts(as = "indexmap::IndexMap<Identifier, Record>"))]
records: Map<Identifier, Record>,
#[cfg_attr(feature = "serde", serde(with = "indexmap::map::serde_seq"))]
#[cfg_attr(feature = "ts", ts(as = "Vec<(Path, Record)>"))]
records: Map<Path, Record>,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

  • Schema record/entity maps serialize as entry sequences because paths are arrays.

Luckily this was already a feature of indexmap

Comment on lines +201 to +212
fn ensure_unqualified_type_paths(schema: &Schema) -> Result<(), GenerateError> {
let qualified = schema
.records()
.map(|record| record.path())
.chain(schema.entities().map(|entity| entity.path()))
.find(|path| !path.namespace().is_empty());

match qualified {
Some(path) => Err(GenerateError::UnsupportedTypePath { path: path.clone() }),
None => Ok(()),
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

instrumentation-build temporarily rejects qualified paths

This is temporary, follow-up will change this.

Comment on lines +41 to 49
/// Return the default usage record path for `resource`.
pub fn default_usage_record_path(resource: &Path) -> Path {
resource.with_name(suffixed_identifier(resource.name(), "Usage"))
}

/// Return the default bounds record name for `resource`.
pub fn default_bounds_record_name(resource: &Identifier) -> Identifier {
suffixed_identifier(resource, "Bounds")
/// Return the default bounds record path for `resource`.
pub fn default_bounds_record_path(resource: &Path) -> Path {
resource.with_name(suffixed_identifier(resource.name(), "Bounds"))
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

  • Foo::Memory generates sibling resource records such as Foo::MemoryUsage

Comment on lines +277 to +289
#[test]
fn generated_records_are_siblings_of_the_resource() {
let parts = ResourceBuilder::new(path("Foo::Memory"))
.with_capacity(ident("bytes"), Capacity::new(CapacityKind::Occupancy, true))
.build()
.unwrap();

assert_eq!(parts.usage.path().to_string(), "Foo::MemoryUsage");
assert_eq!(
parts.bounds.unwrap().path().to_string(),
"Foo::MemoryBounds"
);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

  • Foo::Memory generates sibling resource records such as Foo::MemoryUsage

@johanpel
johanpel marked this pull request as ready for review July 24, 2026 11:43
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The schema model now uses qualified Path values for entity and record identity. Builders, lookups, references, resources, constraints, FSM diagnostics, code generation, and YAML lowering are updated accordingly. Validation also reports duplicate entity/record paths and supports qualified-path references.

Changes

Path-based schema identity

Layer / File(s) Summary
Schema model and builders
crates/schema/src/schema/*, crates/schema/src/builder/*
Adds validated Path parsing and migrates entities, records, data types, schema indexes, and builders from Identifier names to paths.
Constraints and references
crates/constraints/*, crates/ref-target/*, crates/ref-tree/*
Adds duplicate type-path validation and migrates recursive, unresolved-reference, reference-target, and reference-tree diagnostics to Path.
Resources and downstream integration
crates/resource/*, crates/fsm/*, crates/instrumentation-build/*, crates/yaml/*
Carries paths through resource handling, FSM diagnostics, generated identifiers, code-generation errors, YAML lowering, and related tests.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

  • rapidsai/quent#387: Introduces the resource constraint code later migrated to Path.
  • rapidsai/quent#399: Introduces the FSM builder code whose entity placement API is updated here.
  • rapidsai/quent#426: Introduces the eventless-entity constraint updated here to report paths.

Suggested labels: feature request

Suggested reviewers: dhruv9vats, mbrobbel

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: adding paths for schema types.
Description check ✅ Passed The description covers the PR purpose, key behavior changes, and related issues, though Testing and Screenshots sections are not filled in.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]

This comment was marked as resolved.

Signed-off-by: Johan Peltenburg <johan.peltenburg+code@gmail.com>
coderabbitai[bot]

This comment was marked as spam.

Comment thread crates/schema/src/schema/path.rs Outdated
#[cfg_attr(feature = "serde", serde(try_from = "Vec<Identifier>"))]
#[cfg_attr(feature = "ts", derive(ts_rs::TS))]
#[cfg_attr(feature = "ts", ts(as = "Vec<Identifier>"))]
pub struct Path(Vec<Identifier>);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe for a follow-up; split this into name and namespace (optional). That avoids the invalid empty vec.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That turned out to simplify a few things 👍

b30c841

Signed-off-by: Johan Peltenburg <johan.peltenburg+code@gmail.com>
coderabbitai[bot]

This comment was marked as spam.

@johanpel

Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot
rapids-bot Bot merged commit 263b360 into rapidsai:main Jul 24, 2026
20 checks passed
rapids-bot Bot pushed a commit that referenced this pull request Jul 31, 2026
# Description

Stacked on #466.

Adds qualified schema type path support to `quent-instrumentation-build`. Schema namespaces become Rust modules instead of being flattened:

```rust
Foo::BarBaz → foo::BarBaz
FooBar::Baz → foo_bar::Baz
```

This preserves path boundaries and allows equal leaf names such as Foo::Query and Bar::Query to coexist.

Records, entities, events, references, handles, and observer storage follow the generated module hierarchy. Namespace-local AnyEvent enums compose into their parent namespace, while namespaces without events generate no aggregate.

## Related Issues

Follow-up to #449. Closes #442.

_Written by Codex._

Authors:
  - Johan Peltenburg (https://github.com/johanpel)

Approvers:
  - Dhruv Vats (https://github.com/dhruv9vats)

URL: #468
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.

2 participants