Skip to content

Implement 2020-12 $dynamicRef dynamic scope semantics - #159

Open
jnbdz wants to merge 2 commits into
eclipse-vertx:masterfrom
SiteNetSoft:fix-dynamicref-scope
Open

Implement 2020-12 $dynamicRef dynamic scope semantics#159
jnbdz wants to merge 2 commits into
eclipse-vertx:masterfrom
SiteNetSoft:fix-dynamicref-scope

Conversation

@jnbdz

@jnbdz jnbdz commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #158

Motivation

Seven core draft2020-12/dynamicRef tests from the official test suite have been skipped via unsupported-tck-tests.properties since 2022. Unlike the rest of that file (genuinely optional features), they mask three real conformance gaps in $dynamicRef:

  1. anchors pushed into the dynamic context were not popped on the early-return paths, so schemas from already-left scopes stayed resolvable;
  2. a $dynamicRef with no matching $dynamicAnchor (e.g. targeting a plain $anchor) was silently ignored instead of behaving like a normal $ref;
  3. resolution considered only anchors whose subschema had been visited, while the spec resolves to the first schema resource in the dynamic scope that defines a matching $dynamicAnchor.

Changes

  • validate is now a thin wrapper that tracks the dynamic scope — entered schema resources and $dynamicAnchors — and pops it in a finally, so every return path leaves scope correctly.
  • $dynamicRef (2019-09/2020-12 path) resolves per spec: initial resolution like $ref (unresolvable → SchemaException); only when the initial target carries a matching $dynamicAnchor is it re-resolved to the first (outermost) resource in the dynamic scope defining that anchor. An ownership check excludes anchor lookup entries registered under the parent resource URI during dereferencing.
  • Draft-4/7 keeps the legacy encounter-based behavior (that path early-returns as before).
  • The seven draft2020-12/dynamicRef entries are removed from unsupported-tck-tests.properties — the whole TCK now runs them and passes.

Full suite: 4797 tests, 0 failures (skips down from 152 to 145).

jnbdz added 2 commits August 11, 2026 22:08
The $dynamicRef implementation resolved through the first encountered
$dynamicAnchor with the same name, which diverges from the 2020-12
specification in three ways: anchors pushed into the dynamic context
were not popped on the early-return paths, so schemas from left scopes
stayed resolvable; a $dynamicRef without a matching $dynamicAnchor was
silently ignored instead of behaving like a normal $ref; and
resolution only considered anchors whose subschema had been visited
instead of resources entered by evaluation.

Track the dynamic scope (entered schema resources and anchors) in a
validate wrapper that pops in a finally block, and resolve $dynamicRef
per specification: initial resolution like $ref, then, only when the
target carries a matching $dynamicAnchor, re-resolution to the first
resource in the dynamic scope defining that anchor. Anchors registered
under their parent resource uri during dereferencing are excluded by an
ownership check. The legacy behavior is preserved for draft-4/7.

Un-skips the seven core draft2020-12/dynamicRef TCK tests listed as
unsupported since 2022.

Fixes eclipse-vertx#158
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.

$dynamicRef does not implement 2020-12 dynamic scope semantics (7 core TCK tests skipped)

1 participant