-
Notifications
You must be signed in to change notification settings - Fork 0
[libgraphql-core-v1] Task 16.6e: Hygiene, from_str family, Schema::resolve_span #109
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
Open
jeffmo
wants to merge
5
commits into
main
Choose a base branch
from
lgcore_v1_task16.6e
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1beccf2
[libgraphql-core-v1] Hygiene fixes, from_str family, Schema::resolve_…
claude 42a7f6a
[libgraphql-core-v1] 16.6e review follow-up: document from_str error-…
claude b9f10fc
[libgraphql-core-v1] Drop internal task ID from FieldDefinition rustdoc
claude 2a1888c
[libgraphql-core-v1] Rename label -> source_path across string entry …
claude 5a62618
Fix clippy 1.97 lints in pre-existing v0-core and parser code
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| mod schema_build_error_tests; | ||
| mod schema_builder_extension_tests; | ||
| mod schema_builder_tests; | ||
| mod schema_def_tests; | ||
| mod schema_errors_tests; | ||
| mod type_validation_error_tests; |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the answer is probably no, but I'm curious if there are any clever tricks we might employ to help ensure -- at the type level -- that a given
Spanis correctly associated with a givenSchema? Not the end of the world if not (or if such a trick would impose overhead on the API and/or error message story or would otherwise have unworthy trade-offs), but I'd like you to think about it and tell me what you can come up with (if anything).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought about this a fair bit. There ARE tricks; I think none of the instance-level ones are worth their cost here, but there's a domain-level middle ground worth considering for Task 18. The menu:
1. Lifetime branding / generativity (the only true type-level instance guarantee). GhostCell-style:
Schemaconstruction introduces a fresh invariant lifetime'brand(via a closure:SchemaBuilder::build_with(|schema: Schema<'brand>| ...)), spans it hands out becomeSpan<'brand>, andresolve_span(Span<'brand>)only accepts same-brand spans. Two differentSchemas can never exchange spans — the compiler proves it. Why I'd reject it here:GraphQLType<'brand>,FieldDefinition<'brand>, every error type… the entire crate surface.Schemain a plain struct or return it up the stack without the brand infecting the container. That kills the "build a schema, keep it around, serve requests" usage pattern that is this crate's whole point.Schemamust be'static+ serde for bincode embedding. Brands don't survive serialization — a deserializedSpan<'brand>is meaningless, so the macro path can't exist under branding.2. Per-schema runtime identity tag. Stamp each
Schemawith a unique id atbuild(), widenSpanto carry it,resolve_spanreturnsNoneon mismatch. Honest assessment: it only upgrades "wrong position" to "None", costs 4–8 bytes on aCopytype that's stored everywhere, and muddies serde/PartialEqdeterminism (bincode round-trip equality would need the id excluded or regenerated). Not worth it.3. Domain-level newtypes (the one I'd actually consider). The realistic misuse class per AD18 isn't schema-A-vs-schema-B (one schema per process is overwhelmingly the norm) — it's schema-span vs operation-span, once Task 18 introduces operation documents whose spans use the same dense id space. That confusion CAN be caught at compile time cheaply: keep
Spanas the raw representation, but have operation-side types store/expose aDocSpan(Span)newtype (or a ZST-marker generic) soSchema::resolve_spansimply won't accept an operation span and vice versa. Zero runtime cost, no serde impact (schema-sideSpanunchanged), and the churn lands entirely in operation types that don't exist yet — free if we decide before 18, expensive after.Recommendation: keep
resolve_spanas-is for instance-level (theOption+ documented span-domain contract), and if you like #3 I'll amend Task 18's spec to make operation spans a distinct type at API boundaries. Happy to do that as part of this PR's plan-doc or as a one-liner in the next one — say the word.Generated by Claude Code