Skip to content

refactor(schema): align the SchemaBuilder API with the builder conventions - #360

Merged
rapids-bot[bot] merged 6 commits into
rapidsai:mainfrom
johanpel:schema-builder-api
Jul 13, 2026
Merged

refactor(schema): align the SchemaBuilder API with the builder conventions#360
rapids-bot[bot] merged 6 commits into
rapidsai:mainfrom
johanpel:schema-builder-api

Conversation

@johanpel

@johanpel johanpel commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Description

Aligns all five schema builders (AnnotationsBuilder, RecordBuilder, EventBuilder, EntityBuilder, SchemaBuilder) with one API convention: bare-noun getters returning references, set_* replacing and returning the previous entry, try_insert_* erroring on duplicate or empty names, try_with_* for construction chains, try_new accepting plain strings, and each builder holding an AnnotationsBuilder (annotations_mut to amend, with_annotations to replace). Call sites updated mechanically.

Related Issues

Part of #352

🤖 Generated with Claude Code

johanpel and others added 6 commits July 10, 2026 12:10
The builder mirrors the built type's accessors and std map conventions:
bare-noun getters returning references (docs, constraint, metadata),
set_* upserting and returning the displaced entry, and try_insert_*
erroring on a duplicate or empty name while returning &mut Self for
chaining. Entries are stored as Constraint/Metadata values directly, and
from_annotations lifts existing annotations back into a builder.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…data

Consuming counterparts of try_insert_* so annotations build in one
expression; call sites folded onto the chain form.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ntions

RecordBuilder follows the AnnotationsBuilder conventions: try_new
accepting plain strings, a bare-noun field getter, set_field replacing
and returning the previous field, try_insert_field for in-place adds,
and try_with_field(s) for construction chains. The builder now holds an
AnnotationsBuilder, amendable through annotations_mut and replaceable
through with_annotations.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…tions

EventBuilder follows the same conventions as RecordBuilder: try_new
accepting plain strings, bare-noun getters, set_field and
set_cardinality replacing and returning the previous value,
try_insert_field for in-place adds, try_with_field(s) for construction
chains, and an AnnotationsBuilder inside.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ntions

EntityBuilder follows the same conventions as the other builders:
try_new accepting plain strings, bare-noun getters, set_event replacing
and returning the previous event, try_insert_event for in-place adds,
try_with_event(s) for construction chains, and an AnnotationsBuilder
inside.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…tions

SchemaBuilder completes the convention pass: try_new accepting plain
strings, bare-noun entity and record getters, set_* replacing and
returning the previous element, try_insert_* for in-place adds,
try_with_* for construction chains, and an AnnotationsBuilder inside.
All five builders now share one uniform API.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@johanpel
johanpel marked this pull request as ready for review July 13, 2026 07:26
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: QUIET

Plan: Enterprise

Run ID: 93781c37-940c-4f94-8014-97763dd7c730

📥 Commits

Reviewing files that changed from the base of the PR and between 02944dd and b1b2c8a.

📒 Files selected for processing (14)
  • crates/constraints/tests/validator.rs
  • crates/fsm/tests/fsm-constraint.rs
  • crates/instrumentation-build/example/build.rs
  • crates/instrumentation-build/src/events.rs
  • crates/instrumentation-build/src/runtime/mod.rs
  • crates/ref-target/tests/ref-target-constraint.rs
  • crates/ref-tree/tests/ref-tree-constraint.rs
  • crates/schema/src/builder/annotations.rs
  • crates/schema/src/builder/entity.rs
  • crates/schema/src/builder/event.rs
  • crates/schema/src/builder/mod.rs
  • crates/schema/src/builder/record.rs
  • crates/schema/src/test_utils.rs
  • crates/schema/src/visitor.rs

📝 Walkthrough

Walkthrough

Refactors schema builders to retain typed annotation state, adds validated constructors and fallible insertion APIs, and updates examples and tests to use the new builder methods.

Changes

Schema builder refactor

Layer / File(s) Summary
Typed annotation storage
crates/schema/src/builder/annotations.rs
AnnotationsBuilder stores typed constraints and metadata, supports getters, setters, fallible insertion, conversion from existing annotations, and direct finalization.
Event and entity builder APIs
crates/schema/src/builder/event.rs, crates/schema/src/builder/entity.rs
Event and entity builders now use annotation builders, validated constructors, mutable accessors, and try_with_* insertion methods.
Record and schema composition
crates/schema/src/builder/record.rs, crates/schema/src/builder/mod.rs
Record and schema builders gain the corresponding validated construction, lookup, replacement, annotation, and fallible composition APIs.
Caller and test migration
crates/schema/src/test_utils.rs, crates/constraints/tests/validator.rs, crates/fsm/tests/fsm-constraint.rs, crates/ref-*/tests/*, crates/instrumentation-build/..., crates/schema/src/visitor.rs
Examples and tests replace legacy builder calls and inline annotation construction with the new APIs.
Estimated code review effort: 4 (Complex) ~45 minutes

Possibly related PRs

  • rapidsai/quent#354: Touches the same schema builder files and precedes the annotation and try_with_* API refactoring.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: standardizing the SchemaBuilder API to match builder conventions.
Description check ✅ Passed It covers the refactor goal and related issue, but it omits the Testing and Screenshots sections from the template.
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.

@johanpel

Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot
rapids-bot Bot merged commit 5727013 into rapidsai:main Jul 13, 2026
13 checks passed
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