[libgraphql-core-v1] Task 16.6e: Hygiene, from_str family, Schema::resolve_span#109
Open
jeffmo wants to merge 3 commits into
Open
[libgraphql-core-v1] Task 16.6e: Hygiene, from_str family, Schema::resolve_span#109jeffmo wants to merge 3 commits into
jeffmo wants to merge 3 commits into
Conversation
…span Implements Task 16.6e. Adds the small public APIs the Task 16.5 audit found claimed-but-missing, and clears the stale-doc debt in the validators: - SchemaBuilder::from_str constructs a builder from schema source (the API Disposition ledger named it; only load_str/build_from_str existed). build_from_str now delegates through it. - Source labels for multi-source schemas: new from_str_with_label / load_str_with_label / build_from_str_with_label variants thread an optional label (impl AsRef<Path>) into SchemaSourceMap.file_path, so diagnostics from multi-document schemas can name their source. Unlabeled entry points keep their clean signatures; all variants share a private load_str_impl. Task 19's operation builders will copy this shape. - Schema::resolve_span(Span) -> Option<LineCol> per AD18: indexes the schema's source maps by the span's source_map_id (None when out of range), rustdoc states the schema-originated-span domain per AD18's cross-artifact rule. - Stale rustdoc fixed: validators/mod.rs claimed build() was still todo!(); union_type_validator carried an already-completed TODO. - Dead #[allow(dead_code)] mutation_type_name() accessor removed from SchemaBuilder (build() reads the field directly). - New schema_def_tests.rs covers the previously-untested typed query API: typed lookups, typed iterators, types_implementing, root-op accessors, and resolve_span (hand-computed positions on a multi-line schema; out-of-range -> None; builtin -> 0:0). - Zeroed 9 pre-existing cargo-doc warnings so the doc gate holds. 17 tests + 2 running doctests added. All workspace tests, clippy -Dwarnings, and cargo doc pass clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TipQtpvuLuHjHmRsVEgwJw
…type rationale 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
Implements Task 16.6e for libgraphql-core-v1 by hardening schema-building ergonomics and diagnostics: adds the missing SchemaBuilder::from_str API family (including label-threading variants), implements Schema::resolve_span, and performs hygiene/doc fixes with expanded schema_def test coverage.
Changes:
- Added
SchemaBuilder::from_strplus_with_labelvariants across theload_str/from_str/build_from_strfamily, threading labels intoSchemaSourceMap::file_path. - Implemented
Schema::resolve_span(Span) -> Option<LineCol>using the schema’s stored source maps. - Cleaned up stale docs/dead code and added new
schema_deftests covering typed lookups/iterators, root-op accessors, and span resolution.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| libgraphql-core-v1-plan.md | Marks Task 16.6e complete and documents the API/design outcomes. |
| crates/libgraphql-core-v1/src/validators/union_type_validator.rs | Updates validator docs to reflect current build wiring. |
| crates/libgraphql-core-v1/src/validators/mod.rs | Converts stale item docs to accurate module-level docs with correct link. |
| crates/libgraphql-core-v1/src/types/field_definition.rs | Adjusts rustdoc to avoid broken intra-doc link (but introduces internal-task wording). |
| crates/libgraphql-core-v1/src/span.rs | Fixes rustdoc link for ByteSpan. |
| crates/libgraphql-core-v1/src/schema/tests/schema_def_tests.rs | Adds dedicated typed schema API + resolve_span tests. |
| crates/libgraphql-core-v1/src/schema/tests/schema_builder_tests.rs | Adds tests for from_str and label threading across multi-source schemas. |
| crates/libgraphql-core-v1/src/schema/tests/mod.rs | Wires in the new schema_def_tests module. |
| crates/libgraphql-core-v1/src/schema/schema_def.rs | Adds Schema::resolve_span public API implementation + rustdoc. |
| crates/libgraphql-core-v1/src/schema/schema_builder.rs | Adds from_str and label variants; refactors shared load_str_impl; threads labels into SchemaSourceMap. |
| crates/libgraphql-core-v1/src/schema_source_map.rs | Clarifies docs and links Schema explicitly. |
| crates/libgraphql-core-v1/src/error_note.rs | Fixes intra-doc links and span type reference. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Per PR review: public rustdoc should not reference internal roadmap
items ("planned in Task 18") -- reworded to point at the operation-layer
FieldSelection concept without embedding plan-internal task IDs.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TipQtpvuLuHjHmRsVEgwJw
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.6e (fifth of six schema-hardening PRs): the hygiene sweep + the two small public APIs the Task 16.5 audit found claimed-but-missing.
What & why
SchemaBuilder::from_str— named by the API-Disposition ledger but never implemented (onlyload_str/build_from_strexisted). Inherent method mirroring the other string entry points (FromStrdeliberately avoided — it would force a trait import for a builder convenience);build_from_strnow delegates through it. Error type mirrorsload_str's load-phase shape, documented on the method.SchemaSourceMap::from_source(source, None), so diagnostics from multi-document schemas couldn't name their source (a silent v0 regression: v0'sload_strtookOption<&Path>). Newfrom_str_with_label/load_str_with_label/build_from_str_with_labelvariants (impl AsRef<Path>) thread the label intoSchemaSourceMap.file_path; unlabeled entry points keep their clean signatures; all share a privateload_str_impl. Task 19's operation builders copy this shape.Schema::resolve_span(Span) -> Option<LineCol>— AD18 lists it as public API but nothing implemented it. Indexes the schema's source maps by the span'ssource_map_id(Noneout of range); rustdoc states the schema-originated-span-only domain per AD18's cross-artifact rule, the 0-basedLineColsemantics, the byte-offset column approximation (source maps storeline_startsonly), and builtin→0:0.todo!()" rustdoc invalidators/mod.rsreplaced with accurate module docs; the completed TODO(Task 16) inunion_type_validator.rsremoved; the dead#[allow(dead_code)]mutation_type_name()builder accessor deleted (the field remains;build()reads it directly — removal verified reference-free).schema_deftest coverage — the typed query API had zero dedicated tests; newschema_def_tests.rscovers typed lookups (incl. kind-mismatch →None), typed iterators,types_implementing(), root-op accessors, andresolve_spanwith hand-computed positions on a multi-line schema.cargo docwarnings (broken/wrong-crate intra-doc links, private-item links) — semantic fixes, not silencing.Tests
17 new tests + 2 running doctests (v1 crate 295 → 310 + 10 doctests). Highlights: two-source label-threading test asserting per-source
file_path, per-documentsource_map_id, and cross-document line resolution; hand-verifiedresolve_spanpositions; out-of-range →None; builtin → 0:0.Verification
cargo test --workspace— 1417 green;cargo clippy --workspace --tests -- -Dwarnings— clean;cargo doc --no-deps -p libgraphql-core-v1— 0 warningsresolve_spantest'sline_starts/position math, confirmed thebuild_from_strdelegation is behaviorally identical on error paths, verified all three spot-checked doc-link fixes are semantic, and confirmed the label-threading test exercises real cross-document resolution. Its one worthwhile nit (error-type rationale in rustdoc) applied as the follow-up commit.[x]boxes + Completion Notes per the Execution Protocol🤖 Generated with Claude Code
https://claude.ai/code/session_01TipQtpvuLuHjHmRsVEgwJw
Generated by Claude Code