[libgraphql-core-v1] Task 16.6d: Spec notes on all build-level errors#108
Merged
Conversation
Implements Task 16.6d. Task 13 mandated that every validation error carry an ErrorNote::spec, but the rule only landed for the four type validators -- 41 SchemaBuildError construction sites across the type builders (30) and SchemaBuilder (11) carried empty notes and lacked the spec-URL comment convention. Every site now attaches the most precise September 2025 anchor (verified against the spec source; notable corrections: duplicate type/directive definitions cite #sec-Schema's uniqueness rules, and InvalidEnumValueName cites the #sec-Enum-Value grammar production rather than the enum Type-Validation section, which only covers uniqueness). URLs fired from multiple sites live in a new crate-private spec_urls module so they cannot diverge; the literal URL remains in the comment above each site per convention. The TypeValidation wrapper in build() now propagates the inner TypeValidationError's notes onto the outer SchemaBuildError, so notes() surfaces spec notes uniformly regardless of error layer. Two deliberate exceptions, inline-commented: ParseError (grammar level; parser-supplied notes pass through verbatim) and SourceMapLimitExceeded (a u16 implementation limit, not a spec rule). Tests: 8 per-builder spec-note assertions, a note-propagation test, and the meta-test all_build_level_errors_carry_spec_notes -- a kitchen-sink invalid schema triggering 22 distinct error kinds that asserts EVERY returned error carries a Spec note except the two documented exceptions, locking the convention against regression. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TipQtpvuLuHjHmRsVEgwJw
…t, notes doc - Correct the plan completion note's site count (42 = 30 + 12, not 41) - Replace the "permanently locking" claim with an accurate caveat: the meta-test guards kinds reachable from its fixed kitchen-sink source, so new error kinds must extend it alongside their own tests - Document on SchemaBuildError::notes() that TypeValidation errors mirror the inner TypeValidationError notes (read one or the other) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TipQtpvuLuHjHmRsVEgwJw
Contributor
There was a problem hiding this comment.
Pull request overview
This PR standardizes GraphQL spec-references across build-level schema construction errors in libgraphql-core-v1 by attaching ErrorNote::spec(...) notes (and keeping inline URL comments) everywhere SchemaBuildError is created, and by ensuring wrapped TypeValidation errors propagate their notes to the outer build error.
Changes:
- Introduces a crate-private
spec_urlsmodule to centralize spec URL constants used by multiple error sites. - Adds
ErrorNote::spec(...)notes to build-level error construction sites in type builders andSchemaBuilder. - Adds/extends tests to assert spec-note presence and to verify note propagation for wrapped
TypeValidationerrors.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
libgraphql-core-v1-plan.md |
Marks Task 16.6d complete and documents the scope/anchor decisions and tests added. |
crates/libgraphql-core-v1/src/spec_urls.rs |
New centralized spec URL constants for reuse across many error sites. |
crates/libgraphql-core-v1/src/lib.rs |
Exposes spec_urls as a crate-private module. |
crates/libgraphql-core-v1/src/type_builders/object_type_builder.rs |
Adds spec notes to reserved-name and type-validation build errors. |
crates/libgraphql-core-v1/src/type_builders/interface_type_builder.rs |
Adds spec notes to reserved-name and interface type-validation build errors. |
crates/libgraphql-core-v1/src/type_builders/union_type_builder.rs |
Adds spec notes to reserved-name and union type-validation build errors. |
crates/libgraphql-core-v1/src/type_builders/scalar_type_builder.rs |
Adds spec notes to reserved-name build errors. |
crates/libgraphql-core-v1/src/type_builders/input_object_type_builder.rs |
Adds spec notes to reserved-name and input-object type-validation build errors. |
crates/libgraphql-core-v1/src/type_builders/field_def_builder.rs |
Adds spec notes to reserved-name and duplicate-parameter build errors. |
crates/libgraphql-core-v1/src/type_builders/enum_type_builder.rs |
Adds spec notes and corrects anchor selection for invalid enum value names. |
crates/libgraphql-core-v1/src/type_builders/tests/builder_validation_tests.rs |
Adds per-builder tests asserting spec notes are present with expected anchors. |
crates/libgraphql-core-v1/src/schema/schema_builder.rs |
Adds spec notes for schema-build errors and propagates TypeValidationError notes to the wrapping SchemaBuildError. |
crates/libgraphql-core-v1/src/schema/tests/schema_builder_tests.rs |
Adds tests for root-op spec notes, note propagation, and a meta-test enforcing spec-note coverage (with documented exceptions). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
Task 16.6d (fourth of the six schema-hardening PRs): complete the half-landed Task 13 rule — every build-level
SchemaBuildErrornow carries anErrorNote::speclinking the September 2025 rule it enforces. Before this, only the four type validators attached spec notes; 42 construction sites (30 across the type builders'new()/add_*()/from_ast()paths, 12 inSchemaBuilder) returned errors with empty notes.What & why
#sec-Schema's uniqueness rules, andInvalidEnumValueNamecites the#sec-Enum-Valuegrammar production ("Name but nottrue/false/null") instead of the enum Type-Validation section, which only covers uniqueness.spec_urlsmodule holds URL consts for rules fired from multiple sites (Reserved-Names alone fires from 17), so the notes can't diverge; the literal URL stays in the//comment above each site per the plan's convention.notes()surface: theTypeValidationwrapper inbuild()now mirrors the innerTypeValidationError's notes onto the outerSchemaBuildError, so consumers get spec notes without reaching into the inner error (documented on the accessor to avoid double-reading).ParseError(grammar-level; parser-supplied notes — including the parser's own spec notes — flow through verbatim) andSourceMapLimitExceeded(a u16 implementation limit, not a spec rule).Tests (11 new; v1 crate 284 → 295)
Eight per-builder spec-note assertions, a
NoQueryOperationTypeDefinednote test, aTypeValidationnote-propagation test, and the guard-rail:all_build_level_errors_carry_spec_notes— a kitchen-sink invalid schema triggering 22 distinct error kinds, asserting every returned error carries a Spec note except the two documented exceptions. (Caveat recorded in the plan: it guards the kinds its fixed source reaches, so new error kinds must extend the kitchen-sink alongside their own tests.)Verification
cargo test --workspace— 1400 green;cargo clippy --workspace --tests -- -Dwarnings— cleanfb8f396[x]boxes + Completion Notes per the Execution Protocol🤖 Generated with Claude Code
https://claude.ai/code/session_01TipQtpvuLuHjHmRsVEgwJw