Skip to content

Conversation

@jba
Copy link
Contributor

@jba jba commented Jul 2, 2025

Move schema state that depends on resolution into the Resolved struct.
The remaining unexported schema fields are dependent only on the schema itself and its sub-schemas.

Now a schema can be resolved multiple times, as itself or as part of other schemas.

Fixes #84.

@jba jba requested a review from findleyr July 2, 2025 13:49
@jba
Copy link
Contributor Author

jba commented Jul 2, 2025

@findleyr: @adonovan should review. Having trouble getting his username to show up.

// s.base.uri != nil.
// s.base == s <=> s.uri != nil
uri *url.URL
// These fields are independent of arguments to Schema.Resolved,
Copy link

Choose a reason for hiding this comment

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

I don't understand how there can be any computed fields in a Schema if it is to be stateless, and a valid operand of many independent calls to Resolve.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The unexported fields are the outputs of functions on the other fields. They are cached computations.
For example, pattern is always the result of compiling Pattern.
I am assuming a Schema is not changed after Resolve, as documented.
(How to thread-protect the setting of these cached fields will be the topic of another PR.)
However, thinking about this, path is not in fact a function of the schema, but its ancestors as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved everything into resolvedInfo.

I am trying to take advantage of the fact that a GitHub PR consists of multiple commits, by structuring the work like a stack of CLs. Of the two new commits, the first makes this change, and the second is just a rename. You can view them separately via the "Changes from..." dropdown on the "Files changed" tab.

@jba jba requested a review from adonovan July 4, 2025 14:13
@jba jba requested review from adonovan and removed request for adonovan and findleyr July 14, 2025 12:31
@jba jba requested a review from samthanawalla July 18, 2025 19:21
@jba jba merged commit 3bbe74f into modelcontextprotocol:main Jul 21, 2025
3 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.

jsonschema: remove Schema resolution fields

3 participants