Skip to content

Scope evaluated annotations to their instance location - #170

Open
jihtsan wants to merge 1 commit into
opis:masterfrom
jihtsan:codex/167-scope-evaluated-properties
Open

jihtsan wants to merge 1 commit into
opis:masterfrom
jihtsan:codex/167-scope-evaluated-properties

Conversation

@jihtsan

@jihtsan jihtsan commented Oct 21, 2026

Copy link
Copy Markdown

Fixes #167.

Evaluated property names from a child object currently reach the parent schema's shared state. This lets an otherwise forbidden root property pass unevaluatedProperties: false when its name was validated inside a child.

Record the instance path for each shared schema frame and merge evaluated annotations only between frames describing the same data location. This retains same-location allOf and $ref propagation while keeping child property names and array indices local. The change follows JSON Schema Core's instance-location rules for annotations and unevaluated applicators: https://json-schema.org/draft/2020-12/json-schema-core#name-unevaluatedproperties.

The new cases cover draft 2019-09 and 2020-12, multiple nesting levels, references, valid controls, and the array counterpart of the same shared-state problem. This does not address the separate dynamic-anchor resolution issue in #163.

Validation on macOS with PHP 8.4.26 and PHPUnit 9.6.38:

  • New regression provider on the base: 22 tests, 10 failures. With this change: all 22 pass.
  • Existing base suite excluding the new provider: 6,277 tests, 6,327 assertions, all pass.
  • composer run tests: 6,299 tests, 6,349 assertions, all pass.
  • php -l for both changed files and git diff --check: pass.

Dependencies were resolved with composer update --no-interaction --no-progress, matching CI. Generated vendor files and the lock file are excluded. Other PHP versions and Linux were not tested locally; upstream CI is separate.

AI assistance: OpenAI GPT-6 (Codex) investigated, implemented, tested, and drafted this PR. Independent automated Standards/Spec reviews found no outstanding issues; no human review is claimed.

Fixes opis#167. Record the instance path on shared schema frames and merge evaluated properties/items only when frames describe the same data location. Preserve same-location allOf and reference annotation propagation.

AI assistance: OpenAI GPT-6 (Codex) investigated the issue and JSON Schema specification, implemented the scoped fix, and ran 22 new regression cases plus all 6299 tests locally. No human review is claimed.

This branch has not been deployed

No deployments
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.

Evaluated properties are incorrectly scoped

1 participant