Description
Specification section
Throughout the Draft 2020-12, but particularly:
Evaluating an instance against a schema involves processing all of the keywords in the schema against the appropriate locations within the instance. Typically, applicator keywords are processed until a schema object with no applicators (and therefore no subschemas) is reached. The appropriate location in the instance is evaluated against the assertion and annotation keywords in the schema object, and their results are gathered into the parent schema according to the rules of the applicator.
11. A Vocabulary for Unevaluated Locations
[Unevaluated] instance items or properties may have been unsuccessfully evaluated against one or more adjacent keyword subschemas, such as when an assertion in a branch of an "anyOf" fails. Such failed evaluations are not considered to contribute to whether or not the item or property has been evaluated. Only successful evaluations are considered.
What is unclear?
The usages of "evaluated" and "unevaluated" are not antonyms - and "evaluated" is open to some interpretation.
Results
Just for context - I use the term "results" as defined in the spec - a boolean validity that may have with additional information attached by annotations. The JSON Schema recommended output schema provides an example.
Evaluated/Evaluation
The current usage of "evaluate" seems to mean "process all keywords and gather the results". This interpretation means "evaluation" is successfully completed once all keywords are processed and results gathered - regardless of the boolean value of the result. This would also mean that if keywords are processed but their results are not gathered, the keyword is not "evaluated".
I think this is a good definition, but it's not given explicitly. See the discussion in python-jsonschema #1365 (⚠ disclosure: my own issue), where the unevaluatedProperties
validator does process it's dependent subschemas for it's own internal use then discards the results and does not gather them for the validator - but considered the subschemas "evaluated". It is not clear from the spec itself which interpretation is correct.
Unevaluated
From the above definition of "evaluated" as "processed to produce a result", "unevaluated" should be it's mutually-exclusive antonym - "not evaluated", that is "not processed to produce a result". Note that the value of the result is not part of the definition; an evaluation with a falsy result is still an evaluation.
However, in section 11, "unevaluated" does not mean "not evaluated", it means "not validated". Properties that are "evaluated" can also be "unevaluated" at the same time if the result is falsy! Further, the term "failed evaluations" also seems wrong; an evaluation that successfully produces a falsy result didn't fail, it succeeded!
Proposal
Definitions of Evaluated/Unevaluated
I propose to change the phrasing in section 7 to clearly define "evaluated" as "processed and results gathered". I can do this myself if is a desired clarification.
The phrasing and defined keyword behavior in section 11 is more tricky. If we were starting fresh, I think "unevaluated" should be defined as "not evaluated" in the spec, and unevaluated*
keywords would change to follow the definition. Depending on the collection of subschemas, this might be able to produce the same results as before without significant breaking changes (see below).
If these definitions cannot be used, I think the docs need to be painfully explicit that "unevaluated" does not mean "not evaluated".
Specification for how applicators apply subschemas and gather their results
I think the intent of current unevaluated*
behavior could largely be preserved if the applicator spec were more clear on how it applies subschemas and gathers their results. It seems like we have to treat falsy evaluations as unevaluated only because the falsy value indicates a subschema that should not have been applied. This may be wrong, or become a bigger topic, so I will open a new issue and cross-link them.
Do you think this work might require an [Architectural Decision Record (ADR)]? (significant or noteworthy)
Yes