Align GTS entity validation with strict schema resolution#104
Conversation
- Rely on strict pre-resolution before compiling schemas for validation. - Restrict best-effort schema reference resolution to crate internals and silence dead-code warnings. Signed-off-by: Aviator 5 <ai.agent.tor@gmail.com>
|
Warning Review limit reached
More reviews will be available in 39 minutes. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe PR makes schema ChangesStrict resolution and compatibility validation
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- Replace the lenient schema reference resolver surface with strict resolution that reports unresolved refs and cycles. - Let validate-entity rely on schema validation for trait completeness instead of enforcing additional closedness policy. Signed-off-by: Aviator 5 <ai.agent.tor@gmail.com>
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
- Route entity validation through GtsId parsing before schema or instance checks. - Stop reporting type status for wildcard ID validation and parsing results. - Remove instance modifier rejection outside schema validation. Signed-off-by: Aviator 5 <ai.agent.tor@gmail.com>
d60e132 to
ddfbf08
Compare
- Reject descendant schemas that set additionalProperties: false while orphaning ancestor properties under allOf composition. - Validate x-gts-traits-schema compatibility across ancestor prefixes so abstract schemas fail on structural conflicts even without values. - Add regression coverage for nested schema and trait-schema compatibility cases. Signed-off-by: Aviator 5 <ai.agent.tor@gmail.com>
Signed-off-by: Aviator 5 <ai.agent.tor@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@gts/src/ops.rs`:
- Around line 644-654: Preserve anonymous-instance handling in validate_entity
by not immediately returning on GtsId::try_new failure; instead, let
add_entity/validate_instance-style raw instance IDs continue through instance
validation and only use parsed_id when parsing succeeds. Update the
validate_entity flow around GtsId::try_new and the subsequent store lookup so
anonymous IDs are validated via the existing instance path rather than rejected
as invalid upfront.
In `@gts/src/schema_compat.rs`:
- Around line 232-234: The depth guard in the recursive compatibility check
currently returns silently in the validation path, which can let deeply nested
descendants bypass orphan-property validation. Update the recursion in
schema_compat.rs around the depth check in the compatibility traversal to fail
closed by reporting a validation error when MAX_RECURSION_DEPTH is hit instead
of treating the truncated subtree as compatible, using the same validation flow
that handles other incompatibilities.
- Around line 242-247: The orphaned-property check in
validate_closed_descendant_branches only looks at descendant properties and
misses valid matches from patternProperties. Update the filter around the
ancestor.properties iteration to treat an ancestor property as satisfied when it
is either explicitly present in descendant_props or matched by any pattern in
descendant_obj.get("patternProperties"). Preserve the existing
additionalProperties=false logic, but extend the compatibility check so schema
names like userId aren’t falsely flagged when a matching patternProperties entry
allows them.
In `@gts/src/schema_resolver_test.rs`:
- Around line 3-5: The module docs in schema_resolver_test are stale: they still
refer to SchemaResolver::try_resolve even though the tests now cover
SchemaResolver::resolve. Update the wording in the test module comment to match
the current method name so the documentation stays accurate and points to the
correct resolver API.
In `@gts/src/schema_resolver.rs`:
- Line 10: Update the module-level doc comment in schema_resolver so it refers
to the current store wrapper name, GtsStore::resolve_schema_refs, instead of
try_resolve_schema_refs; keep the wording aligned with the existing thin-wrapper
description and make sure the doc points readers to the symbol used by the
current call sites.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b80e055b-1ac5-40ef-bd38-0562f4596db5
📒 Files selected for processing (12)
.gts-spec-versiongts-macros/tests/inheritance_tests.rsgts-macros/tests/integration_tests.rsgts/src/ops.rsgts/src/schema_compat.rsgts/src/schema_modifiers.rsgts/src/schema_refs.rsgts/src/schema_resolver.rsgts/src/schema_resolver_test.rsgts/src/schema_traits.rsgts/src/store.rsgts/src/store_test.rs
💤 Files with no reviewable changes (1)
- gts/src/schema_modifiers.rs
✅ Files skipped from review due to trivial changes (2)
- .gts-spec-version
- gts/src/schema_refs.rs
- Report an error when closed-descendant branch validation reaches the recursion limit. - Cover the depth guard path so overly nested schemas cannot silently pass compatibility checks. - Update resolver comments to match the current resolve_schema_refs naming. Signed-off-by: Aviator 5 <ai.agent.tor@gmail.com>
|
I think there’s a medium-risk correctness issue in When resolving a ref like That means a remote fragment can be inlined while still containing Concretely, a remote schema like: {
"$defs": { "Name": { "type": "string" } },
"properties": {
"name": { "$ref": "#/$defs/Name" }
}
}referenced as I think the resolver should either:
A regression test covering this case would be useful. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@gts/src/schema_resolver.rs`:
- Around line 96-124: Handle the root self-reference case in
schema_resolver::resolve_inner by treating the exact "$ref" value "#" as a local
root pointer, not as an external reference. Update the branch that currently
matches only references starting with "`#/`" so it also includes "#", then resolve
it through local_root.pointer and the existing visited/cycle_found path to keep
circular reference detection consistent with other local refs.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9d8a1e3f-6b0d-437e-a32f-d1d38102a74e
📒 Files selected for processing (3)
gts/src/schema_resolver.rsgts/src/schema_resolver_test.rsgts/src/store.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- gts/src/store.rs
- Track the active local root while resolving GTS pointer fragments. - Resolve supported local JSON Pointer refs strictly and preserve sibling handling through allOf. - Add regression coverage for remote fragment roots, nested remote refs, missing local targets, and caller-root siblings. Signed-off-by: Aviator 5 <ai.agent.tor@gmail.com>
3751a8c to
fdcbc0a
Compare
good catch, fixed |
adds regression coverage for closed descendant schemas and x-gts-traits-schema compatibility across ancestor branches.
Summary by CodeRabbit
Summary of Release Updates
Bug Fixes / Behavior Changes
$refresolution is now strict: unresolved external references and circular references fail validation.resolve_schema_refsis now fallible and removedtry_*helpers.x-gts-*keywords no longer accepted on instances; validation now routes by type vs instance IDs).Bug Fixes / Compatibility Improvements
additionalProperties: false) with orphaning detection and depth guard; added trait-schema inheritance compatibility.Documentation
Chores / Tests
$refresolution) and bumped spec version to v0.12.1.