Skip to content

Resolve dynamic anchors in nested schema resources - #171

Open
jihtsan wants to merge 2 commits into
opis:masterfrom
jihtsan:codex/163-resolve-nested-dynamic-anchors
Open

jihtsan wants to merge 2 commits into
opis:masterfrom
jihtsan:codex/163-resolve-nested-dynamic-anchors

Conversation

@jihtsan

@jihtsan jihtsan commented Oct 21, 2026

Copy link
Copy Markdown

Fixes #163.

A $dynamicRef to an anchor below a schema resource root currently validates against the resource root instead. The issue example wrongly inherits the root's additionalProperties: false; other nested targets can recurse until PHP exhausts memory.

Register $dynamicAnchor alongside $anchor and resolve the initial reference URI before searching the dynamic evaluation path for its outermost matching dynamic anchor. Track schemas entered through ordinary applicators as well as references. Static targets, JSON Pointer/boolean targets, and 2019-09 recursive references retain their own behavior. This is independent of the evaluated-annotation issue in #167/#170.

Validation (PHP 8.4.26, PHPUnit 9.6.38):

  • 20 new regression cases pass, including the reported nested recursion, both anchor keywords, embedded resources, static fallback, boolean targets, and scope entered through properties. Against the base, 14 of the original 18 cases fail/error (some exhaust memory); the remaining four pass. Each baseline case ran in an isolated process.
  • composer run tests: 6,297 tests, 6,347 assertions pass.
  • Current JSON-Schema-Test-Suite dynamicRef tests: 44/44 pass with their remote fixtures loaded locally.
  • PHP syntax and git diff --check pass. Independent Codex Standards and Spec reviews pass after a missing applicator-scope edge case was corrected and regression-tested.

Other PHP versions and upstream CI have not been run locally. AI assistance: OpenAI GPT-6 (Codex) performed implementation, tests, drafting, and independent agent reviews at the account owner's request.

Fixes opis#163. Register dynamic anchors and resolve their initial URI before searching the outer dynamic scope; leave recursive references unchanged.

AI assistance: OpenAI GPT-6 (Codex), authorized by the account owner. Prompt summary: reproduce issue 163, implement resource-scoped dynamic anchors, and verify regression and official JSON Schema tests.

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.

additionalProperties scope into $dynamicRefs

1 participant