Skip to content

feat(databind): add parser validation for required fields and collection types#593

Merged
david-waltermire merged 10 commits intometaschema-framework:developfrom
david-waltermire:feature/parser-required-validation
Dec 28, 2025
Merged

feat(databind): add parser validation for required fields and collection types#593
david-waltermire merged 10 commits intometaschema-framework:developfrom
david-waltermire:feature/parser-required-validation

Conversation

@david-waltermire
Copy link
Contributor

@david-waltermire david-waltermire commented Dec 27, 2025

Summary

Add validation during deserialization to provide meaningful errors when:

  • Required fields are missing (flags with required="true", model instances with min-occurs > 0)
  • Binding configuration specifies invalid collection class types

Required field validation:

  • Validates required flags and model instances are present during parsing
  • Respects default values - fields with defaults are not considered missing
  • Reports clear error messages listing all missing required fields by name
  • Controlled via DESERIALIZE_VALIDATE_REQUIRED_FIELDS feature flag
  • Enabled by default now that choice validation works correctly

Choice instance support (issue #594):

  • Add @BoundChoice annotation to mark fields as mutually exclusive choice alternatives
  • Add BoundInstanceModelChoice implementing IChoiceInstance interface
  • Update AssemblyModelGenerator to detect and create choice instances during introspection
  • Fix AbstractProblemHandler.isChoiceSatisfied() to properly handle choice instances
  • Regenerate Metaschema binding classes with @BoundChoice annotations
  • Remove CLI workarounds that disabled validation (no longer needed)

Collection class type validation:

  • Validates that collection-class in binding configuration implements Collection or Map
  • Throws BindingException with clear message for invalid types (e.g., String)
  • Validates at configuration load time for early error detection

Related Issues

Test plan

  • Valid XML/JSON documents parse successfully
  • Missing required flag throws IOException with field name in message
  • Missing required field throws IOException with field name in message
  • Missing required assembly throws IOException with field name in message
  • Fields with default values do not trigger validation errors
  • Validation can be toggled via feature flag
  • Invalid collection class (e.g., String) throws BindingException
  • Non-existent collection class throws BindingException
  • Valid collection classes (List, Set, Map implementations) are accepted
  • Choice alternatives properly detected via @BoundChoice annotation
  • Choice validation correctly checks if at least one alternative is set
  • All tests pass
  • Full CI build passes (mvn clean install -PCI -Prelease)

Summary by CodeRabbit

  • New Features

    • Required-field validation during deserialization (enabled by default).
    • Annotation-based choice group support for mutually exclusive fields.
    • Binding configuration now validates collection-class declarations.
  • Improvements

    • Clearer error messages when required fields or assemblies are missing.
    • Improved handling to disable required-field checks during schema validation.
  • Tests

    • New and extended tests and fixtures covering required-field validation, choice handling, and binding config errors.
  • Configuration

    • New feature flag "validate-required-fields" (default: true).

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 27, 2025

📝 Walkthrough

Walkthrough

Adds required-field validation during deserialization (feature flag DESERIALIZE_VALIDATE_REQUIRED_FIELDS), propagates BindingException in binding config parsing and tests, and implements annotation-based choice support via a new @BoundChoice annotation and runtime/model-level choice instance handling for annotation-generated bindings.

Changes

Cohort / File(s) Summary
Binding configuration & exception propagation
databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java
Added BindingException propagation to public load(...) methods and internal processing; added validateCollectionClass(...) to verify collection-class entries.
Deserialization feature flag
databind/src/main/java/gov/nist/secauto/metaschema/databind/io/DeserializationFeature.java
New public feature DESERIALIZE_VALIDATE_REQUIRED_FIELDS (Boolean, default true) to control required-field validation.
Required-field validation core
databind/src/main/java/gov/nist/secauto/metaschema/databind/io/AbstractProblemHandler.java
New constructors to enable/disable validation, added validateRequiredFields(...) and helpers to map choice relationships and detect missing required fields.
Format problem handlers
databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/DefaultJsonProblemHandler.java, databind/src/main/java/gov/nist/secauto/metaschema/databind/io/xml/DefaultXmlProblemHandler.java
Exposed public constructors (no-arg and boolean) to control required-field validation behavior.
Deserializer integration
databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/DefaultJsonDeserializer.java, databind/src/main/java/gov/nist/secauto/metaschema/databind/io/xml/DefaultXmlDeserializer.java
Use problem handlers constructed with the DESERIALIZE_VALIDATE_REQUIRED_FIELDS flag when creating Metaschema readers.
Choice annotation
databind/src/main/java/gov/nist/secauto/metaschema/databind/model/annotations/BoundChoice.java
New runtime-retained annotation @BoundChoice(choiceId()) to mark fields/methods that participate in a Metaschema choice.
Choice model support
databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/BoundInstanceModelChoice.java
New class implementing choice-instance behavior for annotation-based bindings (choiceId, model container, minOccurs etc.).
Codegen + typeinfo changes
databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/AbstractNamedModelInstanceTypeInfo.java, .../INamedModelInstanceTypeInfo.java, .../AssemblyDefinitionTypeInfoImpl.java
Track choiceId in typeinfo; emitter injects @BoundChoice on generated fields; AssemblyDefinitionTypeInfoImpl supports passing choiceId.
Assembly model generator
databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/AssemblyModelGenerator.java
Group named instances by @BoundChoice, validate adjacency (fields must be consecutive), and append choice instances via a BoundAssemblyModelBuilder.
Model API implementations
databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/DefinitionAssemblyGlobal.java, databind/src/main/java/gov/nist/secauto/metaschema/databind/model/IBoundDefinitionModelAssembly.java
Added/required getChoiceInstances() on DefinitionAssemblyGlobal and removed default no-op implementation from interface (implementations now must supply choices).
Metaschema binding classes (annotations applied)
databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/...
Added @BoundChoice annotations to specific binding fields (e.g., json-value-key and related fields) to encode choice grouping in binding classes.
Validator configuration / feature disabling
databind/src/main/java/gov/nist/secauto/metaschema/databind/IBindingContext.java
Adjusted newValidator/validateWithConstraints to disable DESERIALIZE_VALIDATE_REQUIRED_FIELDS when schema validation or constraint validation is being used.
Tests — exception propagation & new tests
databind/src/test/java/... (many files)
Propagated BindingException through test method throws; added tests for invalid/nonexistent collection-class parsing and extensive RequiredFieldValidationTest; added BoundChoiceTest for adjacency and choice behavior.
Test resources
databind/src/test/resources/metaschema/required-fields/*, .../binding-config-invalid-collection-class.xml, .../binding-config-nonexistent-class.xml, .../recursive-imports/*
New metaschema fixtures for required-field validation, collection-class error cases, and recursive-import testing.
Maven plugin & infra docs
metaschema-maven-plugin/.../GenerateSourcesMojo.java, .claude/*, PRDs/...
Minor exception-handling update to catch BindingException in the plugin, and documentation/plan updates describing choice/validation work.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

Suggested reviewers

  • aj-stein

Poem

🐰 Hop-hop, the bindings sing tonight,

Choices grouped and fields set right,
Validators check with gentle care,
No missing flags will catch us unaware,
Codegen hops forward, bounding bright.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 32.20% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(databind): add parser validation for required fields and collection types' accurately reflects the main feature additions in this PR: required field validation, collection class type validation, and choice instance support.
Linked Issues check ✅ Passed The PR fully addresses all acceptance criteria from linked issue #594: @BoundChoice annotation created, BoundInstanceModelChoice implements IChoiceInstance, AssemblyModelGenerator groups by choice with adjacency validation, code generator emits annotations, DefinitionAssembly.getChoiceInstances() updated, and required field validation enabled by default with choice support.
Out of Scope Changes check ✅ Passed All changes directly support the stated objectives: required field validation, choice instance support, collection class validation, and supporting test infrastructure. Documentation updates, test resources, and binding class regenerations are within scope. No unrelated changes detected.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2f21ad8 and 5dde295.

📒 Files selected for processing (2)
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/AbstractNamedModelInstanceTypeInfo.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/BoundInstanceModelChoice.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/AbstractNamedModelInstanceTypeInfo.java
🧰 Additional context used
📓 Path-based instructions (1)
**/*.java

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.java: All code changes must follow the Javadoc style guide (docs/javadoc-style-guide.md). New code requires 100% Javadoc coverage on public/protected members. Modified code must add/update Javadoc on any members touched. All Javadoc must include @param, @return, @throws tags in the correct order (BLOCKING)
Java target version must be Java 11. Use SpotBugs annotations (@nonnull, @nullable) for null safety in code.
Follow package naming convention gov.nist.secauto.metaschema.* for all Java packages
Follow Test-Driven Development (TDD) principles: write tests first before implementing functionality, verify tests fail with current implementation, implement minimal code to pass tests, then refactor while keeping tests green

Files:

  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/BoundInstanceModelChoice.java
🧠 Learnings (2)
📚 Learning: 2025-12-19T04:01:37.408Z
Learnt from: david-waltermire
Repo: metaschema-framework/metaschema-java PR: 550
File: core/src/main/java/gov/nist/secauto/metaschema/core/metapath/format/JsonPointerFormatter.java:56-100
Timestamp: 2025-12-19T04:01:37.408Z
Learning: When overriding Java interface methods, rely on inherited Javadoc from the interface. Do not duplicate documentation in the implementing class unless there is implementation-specific behavior that warrants additional notes beyond the interface contract.

Applied to files:

  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/BoundInstanceModelChoice.java
📚 Learning: 2025-12-27T16:52:04.509Z
Learnt from: david-waltermire
Repo: metaschema-framework/metaschema-java PR: 590
File: core/src/main/java/gov/nist/secauto/metaschema/core/metapath/DynamicContext.java:482-492
Timestamp: 2025-12-27T16:52:04.509Z
Learning: In Java, UncheckedIOException.getCause() is declared to return IOException. In methods that declare throws IOException, you can rethrow the underlying cause with throw e.getCause() where e is an UncheckedIOException, without a cast. Ensure the surrounding method signature includes throws IOException. This does not apply to other unchecked exceptions; verify that e is actually an UncheckedIOException before using this pattern.

Applied to files:

  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/BoundInstanceModelChoice.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Website
  • GitHub Check: Code
🔇 Additional comments (4)
databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/BoundInstanceModelChoice.java (4)

1-26: LGTM!

Package declaration follows the required naming convention, and imports are well-organized.


27-69: Well-structured immutable design.

The class declaration, Javadoc, and constructor follow best practices. The immutable design (final fields, no setters) ensures thread safety, and null-safety annotations are properly applied.


99-140: LGTM!

The public methods are well-implemented with appropriate documentation. The getMinOccurs() override includes helpful implementation-specific Javadoc explaining why annotation-based bindings return 0 (optional by default), while other overrides correctly rely on inherited documentation.


71-97: The type safety concerns in this review comment are unfounded. Both IBoundInstanceModelField and IBoundInstanceModelAssembly explicitly extend IFieldInstanceAbsolute and IAssemblyInstanceAbsolute respectively (confirmed in their interface definitions). The casts are guaranteed safe by the type system, and the instanceof checks, while redundant, are not problematic.

Additionally, the silent skipping concern does not apply here. IBoundInstanceModelNamed has exactly two implementations—IBoundInstanceModelField and IBoundInstanceModelAssembly—both of which are explicitly handled in the method. All possible types are covered; there is no scenario where an unrecognized instance type would be silently skipped. The DefaultChoiceModelBuilder.buildChoice() method correctly handles the empty case by returning IContainerModelSupport.empty().

The code is correct as written and does not require changes.

Likely an incorrect or invalid review comment.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 PMD (7.19.0)
databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/BoundInstanceModelChoice.java

[ERROR] Cannot load ruleset pmd/category/java/custom.xml: Cannot resolve rule/ruleset reference 'pmd/category/java/custom.xml'. Make sure the resource is a valid file or URL and is on the CLASSPATH. Use --debug (or a fine log level) to see the current classpath.
[WARN] Progressbar rendering conflicts with reporting to STDOUT. No progressbar will be shown. Try running with argument -r to output the report to a file instead.

databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/AbstractNamedModelInstanceTypeInfo.java

[ERROR] Cannot load ruleset pmd/category/java/custom.xml: Cannot resolve rule/ruleset reference 'pmd/category/java/custom.xml'. Make sure the resource is a valid file or URL and is on the CLASSPATH. Use --debug (or a fine log level) to see the current classpath.
[WARN] Progressbar rendering conflicts with reporting to STDOUT. No progressbar will be shown. Try running with argument -r to output the report to a file instead.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
databind/src/test/resources/metaschema/required-fields/missing-required-flag.xml (1)

1-6: LGTM! Test resource correctly structured with helpful comment.

The XML structure appropriately includes required-field and required-assembly while intentionally omitting the required-flag attribute to test validation behavior. The inline comment at line 2 clearly documents the test scenario.

Consider adding similar explanatory comments to the JSON test resources (e.g., missing-required-field.json, missing-required-flag.json) for consistency and improved test documentation.

databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/BindingConfigurationLoaderTest.java (1)

57-62: LGTM! Exception declaration is correct.

The addition of BindingException to the throws clause correctly reflects the exception propagation from binding configuration loading.

💡 Optional: Consider a more descriptive test method name

The method name test() is generic. Per coding guidelines, @test methods using descriptive names don't require Javadoc. Consider renaming to something like testLoadOscalBindingConfiguration() to better describe what the test validates.

-  void test() throws MalformedURLException, IOException, BindingException {
+  void testLoadOscalBindingConfiguration() throws MalformedURLException, IOException, BindingException {
databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/DefaultJsonDeserializer.java (1)

106-127: LGTM! Helper method is well-implemented.

The new helper method correctly encapsulates the reader creation logic with feature-driven problem handler configuration. The implementation aligns with the parallel changes in the XML deserializer.

💡 Optional: Add @throws tag to Javadoc

The method declares throws IOException, so per Javadoc guidelines, consider adding a @throws tag:

   * @param documentUri
   *          the URI of the document being parsed
   * @return the new reader
+  * @throws IOException
+  *           if an error occurred creating the reader
   */
databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfigurationTest.java (1)

403-436: LGTM! Good coverage for collection class validation errors.

The new tests properly verify that invalid and non-existent collection classes throw BindingException with meaningful messages.

Minor style note: These tests use fully qualified org.junit.jupiter.api.Assertions.assertThrows and assertTrue instead of the static imports used elsewhere in this file. Consider using the static imports for consistency.

🔎 Optional: Use static imports for consistency
   @Test
   void testInvalidCollectionClassThrowsError() {
     // Test that specifying a class that doesn't implement List for a List field
     // throws an error
     File bindingConfigFile = new File("src/test/resources/metaschema/binding-config-invalid-collection-class.xml");

     DefaultBindingConfiguration config = new DefaultBindingConfiguration();

-    BindingException exception = org.junit.jupiter.api.Assertions.assertThrows(
+    BindingException exception = assertThrows(
         BindingException.class,
         () -> config.load(bindingConfigFile));

     String message = exception.getMessage();
-    org.junit.jupiter.api.Assertions.assertTrue(
+    assertTrue(
         message != null && (message.contains("Collection") || message.contains("collection")),
         "Error message should indicate type incompatibility: " + message);
   }

   @Test
   void testNonExistentCollectionClassThrowsError() {
     // Test that specifying a non-existent class throws an error
     File bindingConfigFile = new File("src/test/resources/metaschema/binding-config-nonexistent-class.xml");

     DefaultBindingConfiguration config = new DefaultBindingConfiguration();

-    BindingException exception = org.junit.jupiter.api.Assertions.assertThrows(
+    BindingException exception = assertThrows(
         BindingException.class,
         () -> config.load(bindingConfigFile));

     String message = exception.getMessage();
-    org.junit.jupiter.api.Assertions.assertTrue(
+    assertTrue(
         message != null && (message.contains("class") || message.contains("ClassNotFound")),
         "Error message should indicate class not found: " + message);
   }

You'll also need to add the static imports at the top:

import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

(Note: assertTrue is already statically imported at line 12, and assertThrows is available but not currently used in the static imports.)

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 953f1e3 and d103f9f.

📒 Files selected for processing (25)
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/AbstractProblemHandler.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/DeserializationFeature.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/DefaultJsonDeserializer.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/DefaultJsonProblemHandler.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/xml/DefaultXmlDeserializer.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/xml/DefaultXmlProblemHandler.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/BindingModuleLoader.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/AbstractMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/BindingConfigurationLoaderTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfigurationTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultChoiceGroupBindingConfigurationTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/RequiredFieldValidationTest.java
  • databind/src/test/resources/metaschema/binding-config-invalid-collection-class.xml
  • databind/src/test/resources/metaschema/binding-config-nonexistent-class.xml
  • databind/src/test/resources/metaschema/required-fields/metaschema.xml
  • databind/src/test/resources/metaschema/required-fields/missing-required-assembly.xml
  • databind/src/test/resources/metaschema/required-fields/missing-required-field.json
  • databind/src/test/resources/metaschema/required-fields/missing-required-field.xml
  • databind/src/test/resources/metaschema/required-fields/missing-required-flag.json
  • databind/src/test/resources/metaschema/required-fields/missing-required-flag.xml
  • databind/src/test/resources/metaschema/required-fields/valid-example.json
  • databind/src/test/resources/metaschema/required-fields/valid-example.xml
  • metaschema-maven-plugin/src/main/java/gov/nist/secauto/metaschema/maven/plugin/GenerateSourcesMojo.java
🧰 Additional context used
📓 Path-based instructions (2)
**/*.java

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.java: All code changes must follow the Javadoc style guide (docs/javadoc-style-guide.md). New code requires 100% Javadoc coverage on public/protected members. Modified code must add/update Javadoc on any members touched. All Javadoc must include @param, @return, @throws tags in the correct order (BLOCKING)
Java target version must be Java 11. Use SpotBugs annotations (@nonnull, @nullable) for null safety in code.
Follow package naming convention gov.nist.secauto.metaschema.* for all Java packages
Follow Test-Driven Development (TDD) principles: write tests first before implementing functionality, verify tests fail with current implementation, implement minimal code to pass tests, then refactor while keeping tests green

Files:

  • metaschema-maven-plugin/src/main/java/gov/nist/secauto/metaschema/maven/plugin/GenerateSourcesMojo.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/BindingModuleLoader.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/BindingConfigurationLoaderTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/DeserializationFeature.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/DefaultJsonProblemHandler.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/DefaultJsonDeserializer.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/xml/DefaultXmlProblemHandler.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/AbstractMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/RequiredFieldValidationTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultChoiceGroupBindingConfigurationTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/AbstractProblemHandler.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfigurationTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/xml/DefaultXmlDeserializer.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java
**/*Test.java

📄 CodeRabbit inference engine (CLAUDE.md)

@test methods do not require Javadoc if they use descriptive method names. Use JUnit 5 for testing with parallel execution enabled.

Files:

  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/BindingConfigurationLoaderTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/AbstractMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/RequiredFieldValidationTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultChoiceGroupBindingConfigurationTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfigurationTest.java
🧠 Learnings (7)
📚 Learning: 2025-12-24T21:22:07.082Z
Learnt from: david-waltermire
Repo: metaschema-framework/metaschema-java PR: 567
File: metaschema-testing/src/main/java/gov/nist/secauto/metaschema/model/testing/testsuite/GenerationCase.java:74-80
Timestamp: 2025-12-24T21:22:07.082Z
Learning: Files in the package gov.nist.secauto.metaschema.model.testing.testsuite in metaschema-testing are generated binding classes created from Metaschema definitions. Documentation and style improvements for these files should be made at the code generator level (metaschema-maven-plugin) rather than by manually editing the generated code.

Applied to files:

  • databind/src/test/resources/metaschema/required-fields/valid-example.xml
  • metaschema-maven-plugin/src/main/java/gov/nist/secauto/metaschema/maven/plugin/GenerateSourcesMojo.java
  • databind/src/test/resources/metaschema/required-fields/missing-required-field.xml
  • databind/src/test/resources/metaschema/required-fields/valid-example.json
  • databind/src/test/resources/metaschema/binding-config-invalid-collection-class.xml
  • databind/src/test/resources/metaschema/required-fields/missing-required-flag.json
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/BindingConfigurationLoaderTest.java
  • databind/src/test/resources/metaschema/required-fields/missing-required-assembly.xml
  • databind/src/test/resources/metaschema/required-fields/missing-required-flag.xml
  • databind/src/test/resources/metaschema/required-fields/missing-required-field.json
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/AbstractMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/RequiredFieldValidationTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultChoiceGroupBindingConfigurationTest.java
  • databind/src/test/resources/metaschema/binding-config-nonexistent-class.xml
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfigurationTest.java
  • databind/src/test/resources/metaschema/required-fields/metaschema.xml
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java
📚 Learning: 2025-12-24T21:21:40.208Z
Learnt from: david-waltermire
Repo: metaschema-framework/metaschema-java PR: 567
File: metaschema-testing/src/main/java/gov/nist/csrc/ns/metaschema/test_suite/_1_0/Metaschema.java:41-47
Timestamp: 2025-12-24T21:21:40.208Z
Learning: In metaschema-framework/metaschema-java, generated binding classes in package gov.nist.csrc.ns.metaschema.test_suite._1_0 (and similar generated binding packages) are pre-generated by metaschema-maven-plugin and checked into source control. Javadoc coverage issues in these generated classes should be tracked as code generator improvements rather than file-level issues, and improvements are deferred to generator enhancements.

Applied to files:

  • databind/src/test/resources/metaschema/required-fields/valid-example.xml
  • metaschema-maven-plugin/src/main/java/gov/nist/secauto/metaschema/maven/plugin/GenerateSourcesMojo.java
  • databind/src/test/resources/metaschema/required-fields/missing-required-field.xml
  • databind/src/test/resources/metaschema/required-fields/valid-example.json
  • databind/src/test/resources/metaschema/binding-config-invalid-collection-class.xml
  • databind/src/test/resources/metaschema/required-fields/missing-required-flag.json
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/BindingConfigurationLoaderTest.java
  • databind/src/test/resources/metaschema/required-fields/missing-required-assembly.xml
  • databind/src/test/resources/metaschema/required-fields/missing-required-flag.xml
  • databind/src/test/resources/metaschema/required-fields/missing-required-field.json
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/AbstractMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/RequiredFieldValidationTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultChoiceGroupBindingConfigurationTest.java
  • databind/src/test/resources/metaschema/binding-config-nonexistent-class.xml
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfigurationTest.java
  • databind/src/test/resources/metaschema/required-fields/metaschema.xml
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java
📚 Learning: 2025-12-24T21:21:56.361Z
Learnt from: david-waltermire
Repo: metaschema-framework/metaschema-java PR: 567
File: metaschema-testing/src/main/java/gov/nist/secauto/metaschema/model/testing/testsuite/Metaschema.java:41-47
Timestamp: 2025-12-24T21:21:56.361Z
Learning: In metaschema-testing, generated binding classes under gov.nist.secauto.metaschema.model.testing.testsuite are produced by metaschema-maven-plugin from YAML metaschema definitions. Javadoc issues in these generated classes should not be flagged for manual fixes; improvements are tracked and handled through code generator enhancements rather than manual edits to the generated source.

Applied to files:

  • databind/src/test/resources/metaschema/required-fields/valid-example.xml
  • metaschema-maven-plugin/src/main/java/gov/nist/secauto/metaschema/maven/plugin/GenerateSourcesMojo.java
  • databind/src/test/resources/metaschema/required-fields/missing-required-field.xml
  • databind/src/test/resources/metaschema/required-fields/valid-example.json
  • databind/src/test/resources/metaschema/binding-config-invalid-collection-class.xml
  • databind/src/test/resources/metaschema/required-fields/missing-required-flag.json
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/BindingConfigurationLoaderTest.java
  • databind/src/test/resources/metaschema/required-fields/missing-required-assembly.xml
  • databind/src/test/resources/metaschema/required-fields/missing-required-flag.xml
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/DefaultJsonDeserializer.java
  • databind/src/test/resources/metaschema/required-fields/missing-required-field.json
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/AbstractMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/RequiredFieldValidationTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultChoiceGroupBindingConfigurationTest.java
  • databind/src/test/resources/metaschema/binding-config-nonexistent-class.xml
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfigurationTest.java
  • databind/src/test/resources/metaschema/required-fields/metaschema.xml
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java
📚 Learning: 2025-12-17T13:27:43.679Z
Learnt from: CR
Repo: metaschema-framework/metaschema-java PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T13:27:43.679Z
Learning: Applies to core/metaschema/schema/xml/** : XMLBeans code is generated from XSD schemas in core/metaschema/schema/xml during Maven build. Generated sources are placed in target/generated-sources/

Applied to files:

  • databind/src/test/resources/metaschema/required-fields/valid-example.xml
  • metaschema-maven-plugin/src/main/java/gov/nist/secauto/metaschema/maven/plugin/GenerateSourcesMojo.java
  • databind/src/test/resources/metaschema/required-fields/missing-required-assembly.xml
📚 Learning: 2025-12-19T04:01:37.408Z
Learnt from: david-waltermire
Repo: metaschema-framework/metaschema-java PR: 550
File: core/src/main/java/gov/nist/secauto/metaschema/core/metapath/format/JsonPointerFormatter.java:56-100
Timestamp: 2025-12-19T04:01:37.408Z
Learning: When overriding Java interface methods, rely on inherited Javadoc from the interface. Do not duplicate documentation in the implementing class unless there is implementation-specific behavior that warrants additional notes beyond the interface contract.

Applied to files:

  • metaschema-maven-plugin/src/main/java/gov/nist/secauto/metaschema/maven/plugin/GenerateSourcesMojo.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/BindingModuleLoader.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/BindingConfigurationLoaderTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/DeserializationFeature.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/DefaultJsonProblemHandler.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/DefaultJsonDeserializer.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/xml/DefaultXmlProblemHandler.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/AbstractMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/RequiredFieldValidationTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultChoiceGroupBindingConfigurationTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/AbstractProblemHandler.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfigurationTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/xml/DefaultXmlDeserializer.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java
📚 Learning: 2025-12-27T16:52:04.509Z
Learnt from: david-waltermire
Repo: metaschema-framework/metaschema-java PR: 590
File: core/src/main/java/gov/nist/secauto/metaschema/core/metapath/DynamicContext.java:482-492
Timestamp: 2025-12-27T16:52:04.509Z
Learning: In Java, UncheckedIOException.getCause() is declared to return IOException. In methods that declare throws IOException, you can rethrow the underlying cause with throw e.getCause() where e is an UncheckedIOException, without a cast. Ensure the surrounding method signature includes throws IOException. This does not apply to other unchecked exceptions; verify that e is actually an UncheckedIOException before using this pattern.

Applied to files:

  • metaschema-maven-plugin/src/main/java/gov/nist/secauto/metaschema/maven/plugin/GenerateSourcesMojo.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/BindingModuleLoader.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/BindingConfigurationLoaderTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/DeserializationFeature.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/DefaultJsonProblemHandler.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/DefaultJsonDeserializer.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/xml/DefaultXmlProblemHandler.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/AbstractMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/RequiredFieldValidationTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultChoiceGroupBindingConfigurationTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/AbstractProblemHandler.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfigurationTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/xml/DefaultXmlDeserializer.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java
📚 Learning: 2024-11-14T17:07:03.586Z
Learnt from: david-waltermire
Repo: metaschema-framework/metaschema-java PR: 245
File: core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IIPv4AddressItem.java:66-73
Timestamp: 2024-11-14T17:07:03.586Z
Learning: In the Metaschema Java codebase, differences in casting patterns across atomic type implementations are intentional and required; any differences in approach are significant and necessary.

Applied to files:

  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java
🧬 Code graph analysis (7)
metaschema-maven-plugin/src/main/java/gov/nist/secauto/metaschema/maven/plugin/GenerateSourcesMojo.java (1)
databind/src/main/java/gov/nist/secauto/metaschema/databind/io/BindingException.java (1)
  • BindingException (11-56)
databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/BindingConfigurationLoaderTest.java (1)
databind/src/main/java/gov/nist/secauto/metaschema/databind/io/BindingException.java (1)
  • BindingException (11-56)
databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java (1)
databind/src/main/java/gov/nist/secauto/metaschema/databind/io/BindingException.java (1)
  • BindingException (11-56)
databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/AbstractMetaschemaTest.java (1)
databind/src/main/java/gov/nist/secauto/metaschema/databind/io/BindingException.java (1)
  • BindingException (11-56)
databind/src/test/java/gov/nist/secauto/metaschema/databind/io/RequiredFieldValidationTest.java (2)
core/src/main/java/gov/nist/secauto/metaschema/core/model/MetaschemaException.java (1)
  • MetaschemaException (11-70)
core/src/main/java/gov/nist/secauto/metaschema/core/util/ObjectUtils.java (1)
  • ObjectUtils (18-135)
databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfigurationTest.java (1)
databind/src/main/java/gov/nist/secauto/metaschema/databind/io/BindingException.java (1)
  • BindingException (11-56)
databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java (1)
databind/src/main/java/gov/nist/secauto/metaschema/databind/io/BindingException.java (1)
  • BindingException (11-56)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Website
  • GitHub Check: Code
🔇 Additional comments (41)
databind/src/test/resources/metaschema/required-fields/missing-required-assembly.xml (1)

1-6: Well-structured test resource for missing required-assembly validation.

This test resource correctly demonstrates the scenario where a required assembly element is missing while other required elements (required-flag and required-field) are present. The XML is well-formed, the comment clearly documents the intent, and the file appropriately isolates the test case to validate that the new validation logic detects missing required assemblies.

databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/BindingModuleLoader.java (1)

65-65: Functionally equivalent change – consider clarifying the motivation.

The shift from a method reference bindingContext::newBoundLoader to an explicit lambda () -> bindingContext.newBoundLoader() appears functionally equivalent. Both forms capture the bindingContext reference and lazily invoke newBoundLoader() when the Lazy is evaluated. Exception propagation and null-safety behavior remain unchanged.

If this change addresses a specific tool warning, exception-handling edge case, or coding standard preference, consider documenting the rationale in the commit message or PR comments for future reference.

databind/src/test/resources/metaschema/required-fields/missing-required-field.json (1)

1-8: LGTM! Test resource correctly structured for missing required-field scenario.

The JSON structure appropriately includes required-flag and required-assembly while intentionally omitting required-field to test the validation behavior when a required field (min-occurs="1") is missing.

databind/src/test/resources/metaschema/binding-config-nonexistent-class.xml (1)

1-15: LGTM! Test resource correctly structured for collection-class validation.

The binding configuration appropriately references a non-existent class (com.nonexistent.FakeCollection) to test the validation behavior introduced in this PR that ensures collection-class entries implement java.util.Collection or java.util.Map. The inline comment clearly documents the test scenario.

databind/src/test/resources/metaschema/required-fields/metaschema.xml (1)

1-59: LGTM! Well-structured metaschema definition for required-fields testing.

The metaschema definition appropriately establishes a test schema with a comprehensive mix of required and optional elements:

  • Required flag (required="yes")
  • Required field and assembly (min-occurs="1")
  • Nested required flag within assembly (required-assembly has required id flag)
  • Optional counterparts for each type

This provides excellent coverage for testing the new required-field validation feature across different element types.

databind/src/test/resources/metaschema/required-fields/missing-required-flag.json (1)

1-8: LGTM! Test resource correctly structured for missing required-flag scenario.

The JSON structure appropriately includes required-field and required-assembly while intentionally omitting required-flag to test the validation behavior when a required flag (required="yes") is missing. This complements the XML variant (missing-required-flag.xml) for cross-format testing.

databind/src/test/resources/metaschema/required-fields/valid-example.xml (1)

1-6: LGTM! Valid test resource with all required elements present.

The XML structure correctly includes all required elements as defined in the metaschema:

  • required-flag attribute
  • required-field element
  • required-assembly element with required id flag

This provides the positive test case to verify that valid documents parse successfully with the new validation feature enabled.

databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultChoiceGroupBindingConfigurationTest.java (2)

19-19: LGTM! Import added for exception propagation.

The BindingException import is necessary to support the updated throws clause in the setUp method, aligning with the broader PR changes that propagate BindingException through configuration loading workflows.


57-57: LGTM! Exception propagation correctly updated.

The addition of BindingException to the throws clause is appropriate, as bindingConfig.load(BINDING_CONFIG_FILE) now throws this exception as part of the collection-class validation feature introduced in this PR.

databind/src/test/resources/metaschema/required-fields/valid-example.json (1)

1-9: LGTM! Valid test resource with complete required elements.

The JSON structure correctly includes all required elements as defined in the metaschema:

  • required-flag
  • required-field
  • required-assembly with required id

This provides the positive test case for JSON format to verify that valid documents parse successfully with the new validation feature enabled, complementing the XML variant (valid-example.xml).

databind/src/test/resources/metaschema/binding-config-invalid-collection-class.xml (1)

1-16: LGTM! Test resource is well-structured.

This test resource properly exercises the invalid collection-class validation scenario. The XML structure is valid, and the comments clearly document the intent (testing that String does not implement Collection or Map).

databind/src/test/resources/metaschema/required-fields/missing-required-field.xml (1)

1-6: LGTM! Test resource is appropriate.

This test resource correctly sets up a scenario with a missing required-field element, which is clearly indicated by the comment. The XML structure is valid and aligns with the required-field validation testing objectives.

databind/src/main/java/gov/nist/secauto/metaschema/databind/io/xml/DefaultXmlDeserializer.java (1)

165-169: LGTM! Feature flag integration is correct.

The changes correctly read the DESERIALIZE_VALIDATE_REQUIRED_FIELDS feature flag and pass it to the problem handler constructor. This aligns with the parallel implementation in the JSON deserializer path.

databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/BindingConfigurationLoaderTest.java (1)

12-12: LGTM! Import addition is correct.

The import for BindingException is necessary to support the updated method signature.

metaschema-maven-plugin/src/main/java/gov/nist/secauto/metaschema/maven/plugin/GenerateSourcesMojo.java (2)

13-13: LGTM! Import addition is correct.

The import for BindingException is necessary to support the updated exception handling in the generate() method.


86-95: LGTM! Exception handling is correct.

The catch clause properly handles both IOException and BindingException that can be thrown during binding configuration loading. The error message is appropriately generic for both exception types.

databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/DefaultJsonDeserializer.java (2)

134-134: LGTM! Helper method usage is correct.

The helper method is properly invoked to create the reader with the appropriate problem handler configuration.


159-159: LGTM! Helper method usage is correct.

The helper method is properly invoked, ensuring consistent reader creation across both deserialization paths.

databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/DefaultJsonProblemHandler.java (2)

39-48: LGTM! Constructor is well-documented.

The parameterized constructor has complete Javadoc with a proper @param tag and correctly delegates to the superclass constructor.


32-37: Javadoc is accurate—no changes required.

The Javadoc correctly describes the behavior. When super() is called without arguments, it invokes AbstractProblemHandler()'s protected no-arg constructor (line 33-34), which in turn calls this(true), enabling required field validation by default. The statement "with required field validation enabled" is accurate.

databind/src/main/java/gov/nist/secauto/metaschema/databind/io/DeserializationFeature.java (1)

58-68: LGTM! Feature flag is well-documented.

The new feature flag has comprehensive Javadoc that clearly describes its behavior, default state (disabled), and the rationale for being disabled by default. The implementation correctly sets the default value to false.

databind/src/main/java/gov/nist/secauto/metaschema/databind/io/xml/DefaultXmlProblemHandler.java (1)

35-51: LGTM! Constructors correctly delegate to superclass.

The new constructors properly delegate to AbstractProblemHandler for required-field validation configuration. The Javadoc is complete with @param documentation for the parameterized constructor.

databind/src/main/java/gov/nist/secauto/metaschema/databind/io/AbstractProblemHandler.java (3)

21-56: LGTM! Well-structured validation configuration.

The class-level Javadoc, field, constructors, and accessor are properly documented and follow the expected pattern for optional validation behavior. The default of true in the no-arg constructor aligns with the documented behavior.


58-97: LGTM! Validation logic is sound.

The handleMissingInstances method correctly validates before applying defaults. The error message provides clear context with the parent definition name and lists all missing required fields, which aids debugging.


106-135: LGTM! Helper methods are well-designed.

The isRequiredAndMissingDefault correctly prioritizes checking for default values before evaluating required status, and safely handles unknown instance types. Using getJsonName() provides a consistent identifier across formats.

databind/src/test/java/gov/nist/secauto/metaschema/databind/io/RequiredFieldValidationTest.java (4)

31-63: LGTM! Well-structured test setup.

The test class properly extends AbstractMetaschemaTest and uses @BeforeAll to compile the module once for all tests. The static paths are clearly organized for different test scenarios.


65-98: LGTM! Valid input and missing flag tests are well-designed.

The tests properly verify successful parsing of valid inputs and correct error behavior for missing required flags, with appropriate use of assertDoesNotThrow and assertThrows.


100-158: LGTM! Comprehensive coverage for missing field/assembly scenarios.

The tests cover missing required fields and assemblies for both XML and JSON formats, ensuring consistent validation behavior across formats.


160-196: LGTM! Feature flag toggle test and parameterized field name verification.

The feature flag test correctly validates both disabled (default) and enabled states. The parameterized test efficiently covers both XML and JSON formats for field name inclusion in error messages.

databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java (2)

26-26: LGTM! Import added for BindingException propagation.


50-51: LGTM! Test method signatures updated for BindingException propagation.

The throws clauses are correctly updated to include BindingException, aligning with the changes in DefaultBindingConfiguration.load() which is invoked through runTests.

Also applies to: 64-65, 80-81, 93-94, 164-165, 180-181

databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfigurationTest.java (2)

18-18: LGTM! Import added for BindingException.


51-51: LGTM! Test method signatures updated for BindingException propagation.

The throws clauses are correctly updated to include BindingException, consistent with the changes in DefaultBindingConfiguration.load().

Also applies to: 79-79, 155-155, 194-194, 227-227, 262-262, 299-299, 365-365

databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/AbstractMetaschemaTest.java (2)

18-18: LGTM! Import added for BindingException.


62-68: LGTM! Method signatures correctly updated for BindingException propagation.

The throws clauses are appropriately updated on methods that invoke compileModule, which calls DefaultBindingConfiguration.load(). The runTests(Path, Class, Consumer) overload correctly omits BindingException since it doesn't use the binding configuration loading path.

Also applies to: 112-113, 117-122, 132-139

databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java (6)

18-18: LGTM! Imports added for BindingException and Collection.

Also applies to: 29-29


293-306: LGTM! Load methods properly propagate BindingException.

The load method overloads are correctly updated with @throws BindingException documentation and proper exception propagation through the call chain.

Also applies to: 308-320, 322-360


374-427: LGTM! Metaschema binding processing propagates BindingException.

The processMetaschemaBindingConfig method signature correctly includes BindingException to propagate validation errors from property binding processing.


455-487: LGTM! Property binding processing integrates collection class validation.

The processPropertyBindings method now validates collection classes before creating configurations, providing early failure detection at configuration load time.


489-523: LGTM! Collection class validation is well-implemented.

The validateCollectionClass method correctly:

  1. Attempts to load the class using Class.forName
  2. Wraps ClassNotFoundException in a meaningful BindingException
  3. Verifies the class implements Collection or Map
  4. Provides clear error messages with context (class name, property name, definition name)

This validation at configuration load time prevents runtime surprises from invalid collection class configurations.


525-575: LGTM! Assembly and field property binding methods propagate BindingException.

Both processAssemblyPropertyBindings and processFieldPropertyBindings correctly delegate to processPropertyBindings and propagate BindingException in their signatures.

…ion types

Add validation during deserialization to provide meaningful errors:

Required field validation:
- Validate that required flags (isRequired=true) are present
- Validate that required model instances (minOccurs > 0) are present
- Respect default values - fields with defaults are not considered missing
- Report clear error messages listing all missing required fields
- Controlled via DESERIALIZE_VALIDATE_REQUIRED_FIELDS feature flag
- Enabled by default for user data parsing
- Choice group support: only errors if ALL options in a choice are missing
- Automatically disabled for module loading and CLI validators

Collection class type validation:
- Validate collection-class in binding configuration implements Collection or Map
- Throw BindingException with clear message for invalid types
- Validate at configuration load time for early error detection

Resolves validation gap where missing required fields silently resulted
in null values rather than helpful error messages.
@david-waltermire david-waltermire force-pushed the feature/parser-required-validation branch from d103f9f to af6fb60 Compare December 28, 2025 01:13
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
databind/src/main/java/gov/nist/secauto/metaschema/databind/io/AbstractProblemHandler.java (2)

168-180: Consider edge case: empty choice groups.

The isChoiceSatisfied method iterates over choice.getNamedModelInstances(). If a choice has no named model instances (empty collection), the method returns false, which would incorrectly mark instances as missing.

While this is likely an edge case that shouldn't occur with valid metaschema definitions, you may want to add a defensive check or document this assumption.


214-218: Instance naming uses JSON name consistently.

Using getJsonName() for instance identification is consistent throughout the handler. This approach works for both JSON and XML since bound properties have a JSON name, though for error messages in XML-only scenarios, users might find the JSON name less intuitive.

Consider whether the error message should adapt based on the parsing context (e.g., use XML element names for XML parsing errors). This is a nice-to-have improvement for future consideration.

databind/src/test/java/gov/nist/secauto/metaschema/databind/io/MetaschemaModuleMetaschemaTest.java (1)

68-86: Consider extracting a helper to reduce repetition.

Each deserializer (XML, JSON, YAML) requires the same pattern: create deserializer, disable required-field validation, then deserialize. A small helper method could consolidate this:

private <T extends IBoundObject> T deserializeWithoutRequiredFieldValidation(
    IBindingContext context, Format format, Class<T> clazz, Path path) throws IOException {
  IDeserializer<T> deserializer = context.newDeserializer(format, clazz);
  deserializer.disableFeature(DeserializationFeature.DESERIALIZE_VALIDATE_REQUIRED_FIELDS);
  return deserializer.deserialize(path);
}

This is a minor improvement for maintainability.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d103f9f and af6fb60.

📒 Files selected for processing (30)
  • PRDs/20251224-codegen-quality/implementation-plan.md
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/IBindingContext.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/AbstractProblemHandler.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/DeserializationFeature.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/DefaultJsonDeserializer.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/DefaultJsonProblemHandler.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/xml/DefaultXmlDeserializer.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/xml/DefaultXmlProblemHandler.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/BindingModuleLoader.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/DefinitionAssemblyGlobal.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/AbstractMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/BindingConfigurationLoaderTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfigurationTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultChoiceGroupBindingConfigurationTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/MetaschemaModuleMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/RequiredFieldValidationTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/json/JsonParserTest.java
  • databind/src/test/resources/metaschema/binding-config-invalid-collection-class.xml
  • databind/src/test/resources/metaschema/binding-config-nonexistent-class.xml
  • databind/src/test/resources/metaschema/required-fields/metaschema.xml
  • databind/src/test/resources/metaschema/required-fields/missing-required-assembly.xml
  • databind/src/test/resources/metaschema/required-fields/missing-required-field.json
  • databind/src/test/resources/metaschema/required-fields/missing-required-field.xml
  • databind/src/test/resources/metaschema/required-fields/missing-required-flag.json
  • databind/src/test/resources/metaschema/required-fields/missing-required-flag.xml
  • databind/src/test/resources/metaschema/required-fields/valid-example.json
  • databind/src/test/resources/metaschema/required-fields/valid-example.xml
  • metaschema-maven-plugin/src/main/java/gov/nist/secauto/metaschema/maven/plugin/GenerateSourcesMojo.java
✅ Files skipped from review due to trivial changes (2)
  • databind/src/test/resources/metaschema/required-fields/missing-required-assembly.xml
  • databind/src/test/resources/metaschema/required-fields/valid-example.json
🚧 Files skipped from review as they are similar to previous changes (13)
  • databind/src/test/resources/metaschema/binding-config-invalid-collection-class.xml
  • databind/src/test/resources/metaschema/binding-config-nonexistent-class.xml
  • databind/src/test/resources/metaschema/required-fields/missing-required-flag.xml
  • databind/src/test/resources/metaschema/required-fields/missing-required-field.xml
  • databind/src/test/resources/metaschema/required-fields/missing-required-field.json
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/DefaultJsonDeserializer.java
  • metaschema-maven-plugin/src/main/java/gov/nist/secauto/metaschema/maven/plugin/GenerateSourcesMojo.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/xml/DefaultXmlDeserializer.java
  • databind/src/test/resources/metaschema/required-fields/missing-required-flag.json
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/json/DefaultJsonProblemHandler.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfigurationTest.java
  • databind/src/test/resources/metaschema/required-fields/metaschema.xml
  • databind/src/test/resources/metaschema/required-fields/valid-example.xml
🧰 Additional context used
📓 Path-based instructions (2)
**/*.java

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.java: All code changes must follow the Javadoc style guide (docs/javadoc-style-guide.md). New code requires 100% Javadoc coverage on public/protected members. Modified code must add/update Javadoc on any members touched. All Javadoc must include @param, @return, @throws tags in the correct order (BLOCKING)
Java target version must be Java 11. Use SpotBugs annotations (@nonnull, @nullable) for null safety in code.
Follow package naming convention gov.nist.secauto.metaschema.* for all Java packages
Follow Test-Driven Development (TDD) principles: write tests first before implementing functionality, verify tests fail with current implementation, implement minimal code to pass tests, then refactor while keeping tests green

Files:

  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/DeserializationFeature.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/IBindingContext.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/AbstractMetaschemaTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/xml/DefaultXmlProblemHandler.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/MetaschemaModuleMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/json/JsonParserTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/BindingConfigurationLoaderTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/DefinitionAssemblyGlobal.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/RequiredFieldValidationTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultChoiceGroupBindingConfigurationTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/AbstractProblemHandler.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/BindingModuleLoader.java
**/*Test.java

📄 CodeRabbit inference engine (CLAUDE.md)

@test methods do not require Javadoc if they use descriptive method names. Use JUnit 5 for testing with parallel execution enabled.

Files:

  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/AbstractMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/MetaschemaModuleMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/json/JsonParserTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/BindingConfigurationLoaderTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/RequiredFieldValidationTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultChoiceGroupBindingConfigurationTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java
🧠 Learnings (6)
📚 Learning: 2025-12-19T04:01:37.408Z
Learnt from: david-waltermire
Repo: metaschema-framework/metaschema-java PR: 550
File: core/src/main/java/gov/nist/secauto/metaschema/core/metapath/format/JsonPointerFormatter.java:56-100
Timestamp: 2025-12-19T04:01:37.408Z
Learning: When overriding Java interface methods, rely on inherited Javadoc from the interface. Do not duplicate documentation in the implementing class unless there is implementation-specific behavior that warrants additional notes beyond the interface contract.

Applied to files:

  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/DeserializationFeature.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/IBindingContext.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/AbstractMetaschemaTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/xml/DefaultXmlProblemHandler.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/MetaschemaModuleMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/json/JsonParserTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/BindingConfigurationLoaderTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/DefinitionAssemblyGlobal.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/RequiredFieldValidationTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultChoiceGroupBindingConfigurationTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/AbstractProblemHandler.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/BindingModuleLoader.java
📚 Learning: 2025-12-27T16:52:04.509Z
Learnt from: david-waltermire
Repo: metaschema-framework/metaschema-java PR: 590
File: core/src/main/java/gov/nist/secauto/metaschema/core/metapath/DynamicContext.java:482-492
Timestamp: 2025-12-27T16:52:04.509Z
Learning: In Java, UncheckedIOException.getCause() is declared to return IOException. In methods that declare throws IOException, you can rethrow the underlying cause with throw e.getCause() where e is an UncheckedIOException, without a cast. Ensure the surrounding method signature includes throws IOException. This does not apply to other unchecked exceptions; verify that e is actually an UncheckedIOException before using this pattern.

Applied to files:

  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/DeserializationFeature.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/IBindingContext.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/AbstractMetaschemaTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/xml/DefaultXmlProblemHandler.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/MetaschemaModuleMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/json/JsonParserTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/BindingConfigurationLoaderTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/DefinitionAssemblyGlobal.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/RequiredFieldValidationTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultChoiceGroupBindingConfigurationTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/AbstractProblemHandler.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/BindingModuleLoader.java
📚 Learning: 2025-12-24T21:21:40.208Z
Learnt from: david-waltermire
Repo: metaschema-framework/metaschema-java PR: 567
File: metaschema-testing/src/main/java/gov/nist/csrc/ns/metaschema/test_suite/_1_0/Metaschema.java:41-47
Timestamp: 2025-12-24T21:21:40.208Z
Learning: In metaschema-framework/metaschema-java, generated binding classes in package gov.nist.csrc.ns.metaschema.test_suite._1_0 (and similar generated binding packages) are pre-generated by metaschema-maven-plugin and checked into source control. Javadoc coverage issues in these generated classes should be tracked as code generator improvements rather than file-level issues, and improvements are deferred to generator enhancements.

Applied to files:

  • databind/src/main/java/gov/nist/secauto/metaschema/databind/IBindingContext.java
  • PRDs/20251224-codegen-quality/implementation-plan.md
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/AbstractMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/MetaschemaModuleMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/json/JsonParserTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/BindingConfigurationLoaderTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/DefinitionAssemblyGlobal.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/RequiredFieldValidationTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultChoiceGroupBindingConfigurationTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/BindingModuleLoader.java
📚 Learning: 2025-12-24T21:21:56.361Z
Learnt from: david-waltermire
Repo: metaschema-framework/metaschema-java PR: 567
File: metaschema-testing/src/main/java/gov/nist/secauto/metaschema/model/testing/testsuite/Metaschema.java:41-47
Timestamp: 2025-12-24T21:21:56.361Z
Learning: In metaschema-testing, generated binding classes under gov.nist.secauto.metaschema.model.testing.testsuite are produced by metaschema-maven-plugin from YAML metaschema definitions. Javadoc issues in these generated classes should not be flagged for manual fixes; improvements are tracked and handled through code generator enhancements rather than manual edits to the generated source.

Applied to files:

  • PRDs/20251224-codegen-quality/implementation-plan.md
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/AbstractMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/MetaschemaModuleMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/json/JsonParserTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/BindingConfigurationLoaderTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/DefinitionAssemblyGlobal.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/RequiredFieldValidationTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultChoiceGroupBindingConfigurationTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java
📚 Learning: 2025-12-24T21:22:07.082Z
Learnt from: david-waltermire
Repo: metaschema-framework/metaschema-java PR: 567
File: metaschema-testing/src/main/java/gov/nist/secauto/metaschema/model/testing/testsuite/GenerationCase.java:74-80
Timestamp: 2025-12-24T21:22:07.082Z
Learning: Files in the package gov.nist.secauto.metaschema.model.testing.testsuite in metaschema-testing are generated binding classes created from Metaschema definitions. Documentation and style improvements for these files should be made at the code generator level (metaschema-maven-plugin) rather than by manually editing the generated code.

Applied to files:

  • PRDs/20251224-codegen-quality/implementation-plan.md
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/AbstractMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/MetaschemaModuleMetaschemaTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/json/JsonParserTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/BindingConfigurationLoaderTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/DefinitionAssemblyGlobal.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/io/RequiredFieldValidationTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultChoiceGroupBindingConfigurationTest.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java
📚 Learning: 2024-11-14T17:07:03.586Z
Learnt from: david-waltermire
Repo: metaschema-framework/metaschema-java PR: 245
File: core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IIPv4AddressItem.java:66-73
Timestamp: 2024-11-14T17:07:03.586Z
Learning: In the Metaschema Java codebase, differences in casting patterns across atomic type implementations are intentional and required; any differences in approach are significant and necessary.

Applied to files:

  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java
🧬 Code graph analysis (6)
databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/AbstractMetaschemaTest.java (1)
databind/src/main/java/gov/nist/secauto/metaschema/databind/io/BindingException.java (1)
  • BindingException (11-56)
databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/BindingConfigurationLoaderTest.java (1)
databind/src/main/java/gov/nist/secauto/metaschema/databind/io/BindingException.java (1)
  • BindingException (11-56)
databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java (1)
databind/src/main/java/gov/nist/secauto/metaschema/databind/io/BindingException.java (1)
  • BindingException (11-56)
databind/src/test/java/gov/nist/secauto/metaschema/databind/io/RequiredFieldValidationTest.java (2)
core/src/main/java/gov/nist/secauto/metaschema/core/model/MetaschemaException.java (1)
  • MetaschemaException (11-70)
core/src/main/java/gov/nist/secauto/metaschema/core/util/ObjectUtils.java (1)
  • ObjectUtils (18-135)
databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultChoiceGroupBindingConfigurationTest.java (1)
databind/src/main/java/gov/nist/secauto/metaschema/databind/io/BindingException.java (1)
  • BindingException (11-56)
databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java (1)
databind/src/main/java/gov/nist/secauto/metaschema/databind/io/BindingException.java (1)
  • BindingException (11-56)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Code
  • GitHub Check: Website
🔇 Additional comments (26)
PRDs/20251224-codegen-quality/implementation-plan.md (1)

304-305: Verify feature flag default value—potential inconsistency with PR objectives.

Line 304 states the acceptance criterion "[x] Required field validation enabled by default", but the PR objectives specify the feature is "disabled by default" (controlled via DESERIALIZE_VALIDATE_REQUIRED_FIELDS). These statements are contradictory—the feature flag cannot both default to enabled and disabled.

Additionally, line 301 marks choice group support as completed, yet the PR objectives note that "choice-group 'only one required' semantics are not yet handled," creating ambiguity about what level of choice group support was delivered.

Please verify:

  1. What is the actual default value of the DESERIALIZE_VALIDATE_REQUIRED_FIELDS feature flag in the implementation?
  2. What scope of choice group handling was implemented—does basic choice group validation work, or only a subset?
  3. Update acceptance criteria (lines 297–308) to accurately reflect the implemented behavior.
databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/impl/DefinitionAssemblyGlobal.java (1)

36-36: LGTM! Import added for new method.

The java.util.List import is correctly added to support the return type of the new getChoiceInstances() method.

databind/src/main/java/gov/nist/secauto/metaschema/databind/io/AbstractProblemHandler.java (3)

28-63: LGTM!

The class documentation and constructors are well-structured. The constructor chaining pattern with sensible defaults (validation enabled) is appropriate, and the Javadoc coverage meets the coding guidelines requirements with proper @param and @return tags.


70-73: LGTM!

The conditional validation before applying defaults is the correct ordering - validation should fail-fast before attempting to apply default values to the target object.


90-131: LGTM!

The validation logic correctly handles choice groups: an instance belonging to a choice is only reported as missing if all siblings in that choice are also missing. The error message formatting with singular/plural handling is a nice touch.

databind/src/test/java/gov/nist/secauto/metaschema/databind/io/json/JsonParserTest.java (1)

33-36: LGTM!

The comment clearly documents why required field validation is disabled for this specific regression test. The limitation around dynamically compiled binding classes not preserving choice group information is a reasonable technical constraint.

This suggests that the default value for DESERIALIZE_VALIDATE_REQUIRED_FIELDS should perhaps be false (as stated in the PR description) to avoid breaking dynamically compiled scenarios by default.

databind/src/main/java/gov/nist/secauto/metaschema/databind/IBindingContext.java (2)

450-451: LGTM!

Disabling required-field validation in the validator is correct since schema validation already handles required field checks. The comment clearly documents the rationale.


575-576: LGTM!

Consistent with the newValidator method - required-field validation is disabled when schema validation is in play. This prevents redundant validation and potential false positives.

databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/BindingConfigurationLoaderTest.java (2)

12-12: LGTM!

Import added for BindingException to support the updated method signature.


56-61: LGTM!

The test method signature correctly declares BindingException to align with the updated DefaultBindingConfiguration.load() API that now throws this exception for invalid binding configurations.

databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultChoiceGroupBindingConfigurationTest.java (2)

19-19: LGTM!

Import added for BindingException to support the updated method signature.


56-60: LGTM!

The @BeforeEach setup method correctly declares BindingException since it invokes bindingConfig.load(), which now throws this exception for invalid binding configurations.

databind/src/test/java/gov/nist/secauto/metaschema/databind/io/MetaschemaModuleMetaschemaTest.java (1)

46-50: LGTM!

The comment clearly explains why required-field validation is disabled: pre-generated binding classes don't preserve choice group information. Creating the deserializer explicitly to configure the feature before use is the correct approach.

databind/src/main/java/gov/nist/secauto/metaschema/databind/io/xml/DefaultXmlProblemHandler.java (1)

35-51: LGTM!

The new constructors provide a clean public API for configuring required-field validation behavior. The Javadoc is complete with proper @param tags, and the implementation correctly delegates to the parent class constructors.

databind/src/main/java/gov/nist/secauto/metaschema/databind/io/DeserializationFeature.java (1)

58-72: No changes needed. The default value of true (enabled) is correct and matches the implementation's usage patterns. The feature is properly disabled in contexts where schema validation or choice-group handling requires it, as documented in the Javadoc.

databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/BindingModuleLoader.java (1)

65-72: LGTM!

The lazy initialization correctly disables required-field validation for module loading. The inline comments clearly explain the rationale—metaschema modules have their own schema validation, and this is an internal operation with trusted input.

databind/src/test/java/gov/nist/secauto/metaschema/databind/io/RequiredFieldValidationTest.java (3)

28-32: LGTM!

Well-structured test class with clear organization and comprehensive coverage of required-field validation scenarios across both XML and JSON formats.


160-177: Verify default state of the feature flag.

The test comment at line 164 states "validation is enabled by default," but the PR description says the feature is "disabled by default." If the feature is disabled by default, the first assertion (lines 166-168) would fail because it expects an IOException to be thrown without explicitly enabling the feature.

Please verify the intended default state and update either the test or the PR description accordingly.


55-63: LGTM!

The @BeforeAll setup correctly compiles the test metaschema module once before all tests run.

databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/config/DefaultBindingConfiguration.java (3)

300-306: LGTM!

The Javadoc correctly documents the new BindingException that can be thrown during binding configuration processing.


503-523: LGTM!

The validateCollectionClass method provides clear fail-fast validation at configuration load time. The implementation correctly validates that the specified class exists and implements either java.util.Collection or java.util.Map, with informative error messages.


478-484: LGTM!

Validation is correctly placed before the configuration is created and stored, ensuring fail-fast behavior for invalid collection class specifications.

databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/BasicMetaschemaTest.java (2)

26-26: LGTM!

The import addition and corresponding throws clause updates are consistent with the BindingException propagation through the test infrastructure.


50-51: LGTM!

Test method signatures correctly updated to propagate BindingException from the underlying runTests calls.

databind/src/test/java/gov/nist/secauto/metaschema/databind/codegen/AbstractMetaschemaTest.java (2)

18-18: LGTM!

The import and corresponding throws clause updates correctly propagate BindingException from DefaultBindingConfiguration.load() through the test utility methods.


63-83: LGTM!

The compileModule method correctly declares BindingException since it calls bindingConfiguration.load(bindingFile) which can now throw this exception.

Add PR 5 section documenting the plan to support IChoiceInstance in
annotation-based bindings. This addresses the limitation discovered
during PR 4 where dynamically compiled bindings don't preserve choice
group information.

References: metaschema-framework#594, metaschema-framework#262
…n workaround docs

- Add Javadoc to getChoiceInstances() in DefinitionAssemblyGlobal
- Rename test method in BindingConfigurationLoaderTest per naming convention
- Use static imports for assertThrows/assertTrue in DefaultBindingConfigurationTest
- Update CLAUDE.md with guidance on @OverRide Javadoc and automated review feedback
- Fix comments about disabling required field validation to reference issue metaschema-framework#594
  (choice group limitation in pre-generated binding classes, not schema validation)
- Updated comments in BindingModuleLoader, MetaschemaModuleMetaschemaTest, JsonParserTest
Replace remote OSCAL metaschema fetch in testExistsWithVariable with
local test resources to avoid CI flakiness due to network issues.

Created recursive-imports/ test directory with:
- parent.xml - imports child-a and child-b
- child-a.xml - imports grandchild
- child-b.xml - leaf module
- grandchild.xml - leaf module with root-name

This structure tests the same recurse-depth functionality without
requiring network access to external resources.
@david-waltermire david-waltermire linked an issue Dec 28, 2025 that may be closed by this pull request
12 tasks
Disable required field validation in CLI bound loaders because
pre-generated binding classes don't preserve choice group information.

Affected commands:
- AbstractConvertSubcommand (convert)
- AbstractValidateContentCommand (validate-content)
- EvaluateMetapathCommand (metapath eval)

See issue metaschema-framework#594. TODO: Remove when metaschema-framework#594 is implemented.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/AbstractValidateContentCommand.java (1)

247-250: LGTM: Consistent temporary workaround applied.

The workaround is correctly placed after loader creation and before use, with clear documentation referencing issue #594. The implementation is consistent with the other CLI commands in this PR.

Optional: Consider extracting the workaround to reduce duplication

Since this identical workaround appears in three CLI commands, consider extracting it to a helper method to ensure all instances are updated together when #594 is resolved:

/**
 * Apply temporary workaround for issue #594.
 * TODO: Remove this method when #594 is implemented.
 */
private static void applyIssue594Workaround(@NonNull IBoundLoader loader) {
  // Disable required field validation because pre-generated binding classes
  // don't preserve choice group information. See issue #594.
  loader.disableFeature(DeserializationFeature.DESERIALIZE_VALIDATE_REQUIRED_FIELDS);
}

This would make it easier to remove the workaround consistently across all locations when the issue is resolved.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d85a9e9 and 00eccf1.

📒 Files selected for processing (3)
  • metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/AbstractConvertSubcommand.java
  • metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/AbstractValidateContentCommand.java
  • metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/metapath/EvaluateMetapathCommand.java
🧰 Additional context used
📓 Path-based instructions (2)
**/*.java

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.java: All code changes must follow the Javadoc style guide (docs/javadoc-style-guide.md). New code requires 100% Javadoc coverage on public/protected members. Modified code must add/update Javadoc on any members touched. All Javadoc must include @param, @return, @throws tags in the correct order (BLOCKING)
Java target version must be Java 11. Use SpotBugs annotations (@nonnull, @nullable) for null safety in code.
Follow package naming convention gov.nist.secauto.metaschema.* for all Java packages
Follow Test-Driven Development (TDD) principles: write tests first before implementing functionality, verify tests fail with current implementation, implement minimal code to pass tests, then refactor while keeping tests green

Files:

  • metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/metapath/EvaluateMetapathCommand.java
  • metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/AbstractValidateContentCommand.java
  • metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/AbstractConvertSubcommand.java
**/metapath/**/*.java

📄 CodeRabbit inference engine (CLAUDE.md)

Metapath is an implementation of XPath 3.1. Use the XPath 3.1 specification (https://www.w3.org/TR/xpath-31/) and XPath Functions 3.1 (https://www.w3.org/TR/xpath-functions-31/) as authoritative reference when implementing new functions, fixing bugs, or understanding error handling. Raise clarification before making changes if implementation differs from spec.

Files:

  • metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/metapath/EvaluateMetapathCommand.java
🧠 Learnings (6)
📚 Learning: 2025-12-17T13:27:43.679Z
Learnt from: CR
Repo: metaschema-framework/metaschema-java PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T13:27:43.679Z
Learning: Applies to **/metapath/**/*.java : Metapath is an implementation of XPath 3.1. Use the XPath 3.1 specification (https://www.w3.org/TR/xpath-31/) and XPath Functions 3.1 (https://www.w3.org/TR/xpath-functions-31/) as authoritative reference when implementing new functions, fixing bugs, or understanding error handling. Raise clarification before making changes if implementation differs from spec.

Applied to files:

  • metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/metapath/EvaluateMetapathCommand.java
📚 Learning: 2025-12-24T21:21:40.208Z
Learnt from: david-waltermire
Repo: metaschema-framework/metaschema-java PR: 567
File: metaschema-testing/src/main/java/gov/nist/csrc/ns/metaschema/test_suite/_1_0/Metaschema.java:41-47
Timestamp: 2025-12-24T21:21:40.208Z
Learning: In metaschema-framework/metaschema-java, generated binding classes in package gov.nist.csrc.ns.metaschema.test_suite._1_0 (and similar generated binding packages) are pre-generated by metaschema-maven-plugin and checked into source control. Javadoc coverage issues in these generated classes should be tracked as code generator improvements rather than file-level issues, and improvements are deferred to generator enhancements.

Applied to files:

  • metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/metapath/EvaluateMetapathCommand.java
  • metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/AbstractValidateContentCommand.java
📚 Learning: 2025-12-24T21:21:56.361Z
Learnt from: david-waltermire
Repo: metaschema-framework/metaschema-java PR: 567
File: metaschema-testing/src/main/java/gov/nist/secauto/metaschema/model/testing/testsuite/Metaschema.java:41-47
Timestamp: 2025-12-24T21:21:56.361Z
Learning: In metaschema-testing, generated binding classes under gov.nist.secauto.metaschema.model.testing.testsuite are produced by metaschema-maven-plugin from YAML metaschema definitions. Javadoc issues in these generated classes should not be flagged for manual fixes; improvements are tracked and handled through code generator enhancements rather than manual edits to the generated source.

Applied to files:

  • metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/metapath/EvaluateMetapathCommand.java
  • metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/AbstractValidateContentCommand.java
📚 Learning: 2025-12-24T21:22:07.082Z
Learnt from: david-waltermire
Repo: metaschema-framework/metaschema-java PR: 567
File: metaschema-testing/src/main/java/gov/nist/secauto/metaschema/model/testing/testsuite/GenerationCase.java:74-80
Timestamp: 2025-12-24T21:22:07.082Z
Learning: Files in the package gov.nist.secauto.metaschema.model.testing.testsuite in metaschema-testing are generated binding classes created from Metaschema definitions. Documentation and style improvements for these files should be made at the code generator level (metaschema-maven-plugin) rather than by manually editing the generated code.

Applied to files:

  • metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/metapath/EvaluateMetapathCommand.java
  • metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/AbstractValidateContentCommand.java
📚 Learning: 2025-12-19T04:01:37.408Z
Learnt from: david-waltermire
Repo: metaschema-framework/metaschema-java PR: 550
File: core/src/main/java/gov/nist/secauto/metaschema/core/metapath/format/JsonPointerFormatter.java:56-100
Timestamp: 2025-12-19T04:01:37.408Z
Learning: When overriding Java interface methods, rely on inherited Javadoc from the interface. Do not duplicate documentation in the implementing class unless there is implementation-specific behavior that warrants additional notes beyond the interface contract.

Applied to files:

  • metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/metapath/EvaluateMetapathCommand.java
  • metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/AbstractValidateContentCommand.java
  • metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/AbstractConvertSubcommand.java
📚 Learning: 2025-12-27T16:52:04.509Z
Learnt from: david-waltermire
Repo: metaschema-framework/metaschema-java PR: 590
File: core/src/main/java/gov/nist/secauto/metaschema/core/metapath/DynamicContext.java:482-492
Timestamp: 2025-12-27T16:52:04.509Z
Learning: In Java, UncheckedIOException.getCause() is declared to return IOException. In methods that declare throws IOException, you can rethrow the underlying cause with throw e.getCause() where e is an UncheckedIOException, without a cast. Ensure the surrounding method signature includes throws IOException. This does not apply to other unchecked exceptions; verify that e is actually an UncheckedIOException before using this pattern.

Applied to files:

  • metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/metapath/EvaluateMetapathCommand.java
  • metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/AbstractValidateContentCommand.java
  • metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/AbstractConvertSubcommand.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Code
  • GitHub Check: Website
🔇 Additional comments (5)
metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/AbstractValidateContentCommand.java (1)

32-32: LGTM: Import added for temporary workaround.

The import supports the temporary workaround applied later in the file.

metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/AbstractConvertSubcommand.java (2)

18-18: LGTM: Import added for temporary workaround.

The import supports the temporary workaround applied later in the file.


132-135: LGTM: Consistent temporary workaround applied.

The workaround is correctly placed after loader creation and before use, with clear documentation referencing issue #594. The implementation is identical to the pattern used in AbstractValidateContentCommand and EvaluateMetapathCommand.

metaschema-cli/src/main/java/gov/nist/secauto/metaschema/cli/commands/metapath/EvaluateMetapathCommand.java (2)

28-28: LGTM: Import added for temporary workaround.

The import supports the temporary workaround applied later in the file.


148-151: LGTM: Consistent temporary workaround applied.

The workaround is correctly placed after loader creation and before content loading, with clear documentation referencing issue #594. The implementation is identical to the pattern used in the other CLI commands.

@david-waltermire david-waltermire linked an issue Dec 28, 2025 that may be closed by this pull request
5 tasks
…hema-framework#594)

Add annotation-based binding support for choice instances, enabling proper
validation of mutually exclusive alternatives in generated binding classes.

Core changes:
- Add @BoundChoice annotation to mark fields as choice alternatives
- Add BoundInstanceModelChoice implementing IChoiceInstance interface
- Update AssemblyModelGenerator to handle @BoundChoice during introspection
- Add INamedModelInstanceTypeInfo.hasChoiceAnnotation() for code generation

Validation improvements:
- Fix AbstractProblemHandler.isChoiceSatisfied() to handle choice instances
- Remove DESERIALIZE_VALIDATE_REQUIRED_FIELDS workarounds from CLI commands
  since choice validation now works correctly

Regenerated binding classes:
- METASCHEMA.java, AssemblyModel.java, InlineDefineField.java now have
  @BoundChoice annotations on their choice alternative fields

Documentation:
- Update metaschema-java-library.md skill with binding model documentation
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (5)
PRDs/20251224-codegen-quality/implementation-plan.md (1)

372-376: Confirm adjacency validation requirement is in scope for PR 5.

Lines 372–376 introduce an adjacency validation constraint for choice fields (they must be consecutive in serialization order). While this is a good defensive check, it adds complexity and potential failure modes. Confirm this is a hard requirement vs. a nice-to-have, and ensure it's covered by unit tests per the acceptance criteria.

databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/INamedModelInstanceTypeInfo.java (1)

16-31: Choice ID setter on type info interface looks good

Adding setChoiceId(@Nullable String choiceId) with clear Javadoc and nullability annotation cleanly exposes choice metadata for named instances. This aligns with the new choice support without impacting existing callers.

If you expect callers to query the choice later via the interface (not just through concrete subclasses), consider adding a matching @Nullable String getChoiceId() to INamedModelInstanceTypeInfo for symmetry.

databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/AbstractNamedModelInstanceTypeInfo.java (1)

42-72: Choice ID handling and BoundChoice emission look correct (add @OverRide on setter)

Storing the optional choiceId and conditionally emitting a @BoundChoice annotation in buildField cleanly wires choice metadata into generated bindings and respects the nullability contract.

One small improvement: setChoiceId(@Nullable String choiceId) implements the interface method but is not annotated with @Override. Adding @Override will help catch signature drift during refactors and is consistent with the rest of the codebase’s style.

Proposed tweak
-  public void setChoiceId(@Nullable String choiceId) {
+  @Override
+  public void setChoiceId(@Nullable String choiceId) {
     this.choiceId = choiceId;
   }

Also applies to: 118-124

databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/AssemblyModelGenerator.java (1)

218-236: Consider adding @NonNull annotation to constructor parameter.

For consistency with the field annotation, the constructor parameter should also be annotated. As per coding guidelines, use SpotBugs annotations for null safety.

🔎 Proposed fix
-    ChoiceInstanceEntry(int index, @NonNull IBoundInstanceModelNamed<?> instance) {
+    ChoiceInstanceEntry(int index, @edu.umd.cs.findbugs.annotations.NonNull IBoundInstanceModelNamed<?> instance) {
       this.index = index;
       this.instance = instance;
     }
databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/BoundInstanceModelChoice.java (1)

134-138: Consider adding @Nullable annotation to getRemarks() return.

Since this method explicitly returns null, adding the @Nullable annotation would align with the coding guidelines for SpotBugs null safety annotations.

🔎 Proposed fix
   @Override
+  @edu.umd.cs.findbugs.annotations.Nullable
   public MarkupMultiline getRemarks() {
     // no remarks for annotation-based bindings
     return null;
   }
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 00eccf1 and 2f21ad8.

📒 Files selected for processing (15)
  • .claude/skills/metaschema-java-library.md
  • PRDs/20251224-codegen-quality/implementation-plan.md
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/AbstractNamedModelInstanceTypeInfo.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/INamedModelInstanceTypeInfo.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/def/AssemblyDefinitionTypeInfoImpl.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/AbstractProblemHandler.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/IBoundDefinitionModelAssembly.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/annotations/BoundChoice.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/AssemblyModelGenerator.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/BoundInstanceModelChoice.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/BindingModuleLoader.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/AssemblyModel.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/InlineDefineField.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/METASCHEMA.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/model/impl/BoundChoiceTest.java
💤 Files with no reviewable changes (1)
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/IBoundDefinitionModelAssembly.java
🧰 Additional context used
📓 Path-based instructions (2)
**/*.java

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.java: All code changes must follow the Javadoc style guide (docs/javadoc-style-guide.md). New code requires 100% Javadoc coverage on public/protected members. Modified code must add/update Javadoc on any members touched. All Javadoc must include @param, @return, @throws tags in the correct order (BLOCKING)
Java target version must be Java 11. Use SpotBugs annotations (@nonnull, @nullable) for null safety in code.
Follow package naming convention gov.nist.secauto.metaschema.* for all Java packages
Follow Test-Driven Development (TDD) principles: write tests first before implementing functionality, verify tests fail with current implementation, implement minimal code to pass tests, then refactor while keeping tests green

Files:

  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/annotations/BoundChoice.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/InlineDefineField.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/AbstractProblemHandler.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/BoundInstanceModelChoice.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/AbstractNamedModelInstanceTypeInfo.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/model/impl/BoundChoiceTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/def/AssemblyDefinitionTypeInfoImpl.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/AssemblyModelGenerator.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/METASCHEMA.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/AssemblyModel.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/INamedModelInstanceTypeInfo.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/BindingModuleLoader.java
**/*Test.java

📄 CodeRabbit inference engine (CLAUDE.md)

@test methods do not require Javadoc if they use descriptive method names. Use JUnit 5 for testing with parallel execution enabled.

Files:

  • databind/src/test/java/gov/nist/secauto/metaschema/databind/model/impl/BoundChoiceTest.java
🧠 Learnings (14)
📚 Learning: 2025-12-19T04:01:37.408Z
Learnt from: david-waltermire
Repo: metaschema-framework/metaschema-java PR: 550
File: core/src/main/java/gov/nist/secauto/metaschema/core/metapath/format/JsonPointerFormatter.java:56-100
Timestamp: 2025-12-19T04:01:37.408Z
Learning: When overriding Java interface methods, rely on inherited Javadoc from the interface. Do not duplicate documentation in the implementing class unless there is implementation-specific behavior that warrants additional notes beyond the interface contract.

Applied to files:

  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/annotations/BoundChoice.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/InlineDefineField.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/AbstractProblemHandler.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/BoundInstanceModelChoice.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/AbstractNamedModelInstanceTypeInfo.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/model/impl/BoundChoiceTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/def/AssemblyDefinitionTypeInfoImpl.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/AssemblyModelGenerator.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/METASCHEMA.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/AssemblyModel.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/INamedModelInstanceTypeInfo.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/BindingModuleLoader.java
📚 Learning: 2025-12-27T16:52:04.509Z
Learnt from: david-waltermire
Repo: metaschema-framework/metaschema-java PR: 590
File: core/src/main/java/gov/nist/secauto/metaschema/core/metapath/DynamicContext.java:482-492
Timestamp: 2025-12-27T16:52:04.509Z
Learning: In Java, UncheckedIOException.getCause() is declared to return IOException. In methods that declare throws IOException, you can rethrow the underlying cause with throw e.getCause() where e is an UncheckedIOException, without a cast. Ensure the surrounding method signature includes throws IOException. This does not apply to other unchecked exceptions; verify that e is actually an UncheckedIOException before using this pattern.

Applied to files:

  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/annotations/BoundChoice.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/InlineDefineField.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/io/AbstractProblemHandler.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/BoundInstanceModelChoice.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/AbstractNamedModelInstanceTypeInfo.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/model/impl/BoundChoiceTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/def/AssemblyDefinitionTypeInfoImpl.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/AssemblyModelGenerator.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/METASCHEMA.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/AssemblyModel.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/INamedModelInstanceTypeInfo.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/BindingModuleLoader.java
📚 Learning: 2025-12-24T21:22:07.082Z
Learnt from: david-waltermire
Repo: metaschema-framework/metaschema-java PR: 567
File: metaschema-testing/src/main/java/gov/nist/secauto/metaschema/model/testing/testsuite/GenerationCase.java:74-80
Timestamp: 2025-12-24T21:22:07.082Z
Learning: Files in the package gov.nist.secauto.metaschema.model.testing.testsuite in metaschema-testing are generated binding classes created from Metaschema definitions. Documentation and style improvements for these files should be made at the code generator level (metaschema-maven-plugin) rather than by manually editing the generated code.

Applied to files:

  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/InlineDefineField.java
  • PRDs/20251224-codegen-quality/implementation-plan.md
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/AbstractNamedModelInstanceTypeInfo.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/model/impl/BoundChoiceTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/def/AssemblyDefinitionTypeInfoImpl.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/AssemblyModelGenerator.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/METASCHEMA.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/AssemblyModel.java
  • .claude/skills/metaschema-java-library.md
📚 Learning: 2025-12-24T21:21:40.208Z
Learnt from: david-waltermire
Repo: metaschema-framework/metaschema-java PR: 567
File: metaschema-testing/src/main/java/gov/nist/csrc/ns/metaschema/test_suite/_1_0/Metaschema.java:41-47
Timestamp: 2025-12-24T21:21:40.208Z
Learning: In metaschema-framework/metaschema-java, generated binding classes in package gov.nist.csrc.ns.metaschema.test_suite._1_0 (and similar generated binding packages) are pre-generated by metaschema-maven-plugin and checked into source control. Javadoc coverage issues in these generated classes should be tracked as code generator improvements rather than file-level issues, and improvements are deferred to generator enhancements.

Applied to files:

  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/InlineDefineField.java
  • PRDs/20251224-codegen-quality/implementation-plan.md
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/AbstractNamedModelInstanceTypeInfo.java
  • databind/src/test/java/gov/nist/secauto/metaschema/databind/model/impl/BoundChoiceTest.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/AssemblyModelGenerator.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/METASCHEMA.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/AssemblyModel.java
  • .claude/skills/metaschema-java-library.md
📚 Learning: 2025-12-17T13:27:43.679Z
Learnt from: CR
Repo: metaschema-framework/metaschema-java PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T13:27:43.679Z
Learning: For larger initiatives requiring multiple PRs, use structured PRD (Product Requirements Document) approach. PRDs stored in PRDs/<YYYYMMDD>-<name>/ with PRD.md and implementation-plan.md. Target ≤50 files per PR, maximum 100 files per PR.

Applied to files:

  • PRDs/20251224-codegen-quality/implementation-plan.md
📚 Learning: 2025-12-24T21:21:56.361Z
Learnt from: david-waltermire
Repo: metaschema-framework/metaschema-java PR: 567
File: metaschema-testing/src/main/java/gov/nist/secauto/metaschema/model/testing/testsuite/Metaschema.java:41-47
Timestamp: 2025-12-24T21:21:56.361Z
Learning: In metaschema-testing, generated binding classes under gov.nist.secauto.metaschema.model.testing.testsuite are produced by metaschema-maven-plugin from YAML metaschema definitions. Javadoc issues in these generated classes should not be flagged for manual fixes; improvements are tracked and handled through code generator enhancements rather than manual edits to the generated source.

Applied to files:

  • PRDs/20251224-codegen-quality/implementation-plan.md
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/AbstractNamedModelInstanceTypeInfo.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/AssemblyModelGenerator.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/METASCHEMA.java
  • databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/AssemblyModel.java
  • .claude/skills/metaschema-java-library.md
📚 Learning: 2025-12-19T04:01:45.001Z
Learnt from: david-waltermire
Repo: metaschema-framework/metaschema-java PR: 550
File: core/src/main/java/gov/nist/secauto/metaschema/core/metapath/format/JsonPointerFormatter.java:56-100
Timestamp: 2025-12-19T04:01:45.001Z
Learning: In Java code for metaschema-framework/metaschema-java, override methods (annotated with Override) that implement interface methods automatically inherit Javadoc from the interface and do not require redundant documentation in the implementing class unless there is implementation-specific behavior that needs to be documented beyond what the interface specifies.

Applied to files:

  • .claude/skills/metaschema-java-library.md
📚 Learning: 2025-12-17T13:27:43.679Z
Learnt from: CR
Repo: metaschema-framework/metaschema-java PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T13:27:43.679Z
Learning: Applies to **/*.java : Follow package naming convention gov.nist.secauto.metaschema.* for all Java packages

Applied to files:

  • .claude/skills/metaschema-java-library.md
📚 Learning: 2025-12-17T13:27:43.679Z
Learnt from: CR
Repo: metaschema-framework/metaschema-java PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T13:27:43.679Z
Learning: Applies to core/metaschema/schema/xml/** : XMLBeans code is generated from XSD schemas in core/metaschema/schema/xml during Maven build. Generated sources are placed in target/generated-sources/

Applied to files:

  • .claude/skills/metaschema-java-library.md
📚 Learning: 2025-12-17T13:27:43.679Z
Learnt from: CR
Repo: metaschema-framework/metaschema-java PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T13:27:43.679Z
Learning: Applies to **/metapath/**/*.java : Metapath is an implementation of XPath 3.1. Use the XPath 3.1 specification (https://www.w3.org/TR/xpath-31/) and XPath Functions 3.1 (https://www.w3.org/TR/xpath-functions-31/) as authoritative reference when implementing new functions, fixing bugs, or understanding error handling. Raise clarification before making changes if implementation differs from spec.

Applied to files:

  • .claude/skills/metaschema-java-library.md
📚 Learning: 2025-12-17T13:27:43.679Z
Learnt from: CR
Repo: metaschema-framework/metaschema-java PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T13:27:43.679Z
Learning: Applies to **/*.java : Java target version must be Java 11. Use SpotBugs annotations (NonNull, Nullable) for null safety in code.

Applied to files:

  • .claude/skills/metaschema-java-library.md
📚 Learning: 2025-12-17T13:27:43.679Z
Learnt from: CR
Repo: metaschema-framework/metaschema-java PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T13:27:43.679Z
Learning: Applies to **/*.{xmlbeans,antlr} : Generated code in *.xmlbeans and *.antlr packages is excluded from Javadoc and style checks. Generated sources are placed in target/generated-sources/

Applied to files:

  • .claude/skills/metaschema-java-library.md
📚 Learning: 2025-12-17T13:27:43.679Z
Learnt from: CR
Repo: metaschema-framework/metaschema-java PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-17T13:27:43.679Z
Learning: Applies to core/src/main/antlr4/** : Metapath parser is generated from ANTLR4 grammar files in core/src/main/antlr4. Code generation occurs during Maven build producing output in target/generated-sources/

Applied to files:

  • .claude/skills/metaschema-java-library.md
📚 Learning: 2024-11-14T17:07:03.586Z
Learnt from: david-waltermire
Repo: metaschema-framework/metaschema-java PR: 245
File: core/src/main/java/gov/nist/secauto/metaschema/core/metapath/item/atomic/IIPv4AddressItem.java:66-73
Timestamp: 2024-11-14T17:07:03.586Z
Learning: In the Metaschema Java codebase, differences in casting patterns across atomic type implementations are intentional and required; any differences in approach are significant and necessary.

Applied to files:

  • .claude/skills/metaschema-java-library.md
🧬 Code graph analysis (1)
databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/BoundInstanceModelChoice.java (1)
core/src/main/java/gov/nist/secauto/metaschema/core/datatype/markup/MarkupMultiline.java (1)
  • MarkupMultiline (19-80)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Code
  • GitHub Check: Website
🔇 Additional comments (31)
PRDs/20251224-codegen-quality/implementation-plan.md (3)

297-308: Clarify required field validation feature flag default state.

Line 304 states "Required field validation enabled by default," but the PR objectives for #593 specify the feature flag DESERIALIZE_VALIDATE_REQUIRED_FIELDS is "disabled by default." These two statements conflict. Verify which is the intended behavior and update the acceptance criteria accordingly.


312-321: Clarify PR 5 scope and determine if work has already started in PR #593.

The PR objectives and commit messages reference introducing @BoundChoice annotation and InstanceModelChoice implementation, yet PR 5 is marked as "Pending." Verify whether:

  1. This work is already included in PR #593 (in which case PR 5 acceptance criteria should reference it as completed or partially completed)
  2. PR #593 is a prerequisite that enables PR 5, but the annotation and model work is genuinely deferred

Additionally, the commit messages mention "regenerated binding classes" and "updates to emit @BoundChoice," which suggests binding class regeneration is in scope. Confirm whether this should update the file estimate.


316-316: Re-estimate PR 5 files if bootstrap regeneration is in scope.

The "~10" file estimate for PR 5 assumes minimal file changes. However, if bootstrap binding classes must be regenerated (as implied by line 349: "Bootstrap binding classes | Regenerate with new annotations"), the file count could be substantially higher (similar to PR 3's ~55 files). Clarify the scope and adjust the estimate accordingly.

databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/BindingModuleLoader.java (1)

62-67: Lambda-based Lazy initialization is fine

Switching from a method reference to a lambda for Lazy.of is behaviorally equivalent here and keeps the constructor logic clear. No issues.

databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/METASCHEMA.java (1)

28-29: BoundChoice application correctly groups mutually-exclusive alternatives

Using @BoundChoice(choiceId = "choice-1") on use-name vs root-name and on json-value-key vs json-value-key-flag, with each pair declared consecutively, matches the intended mutually-exclusive choice semantics and the adjacency requirement described for BoundChoice. Looks consistent with the new annotation contract.

Also applies to: 769-789, 1537-1551

databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/AssemblyModel.java (1)

26-27: Choice metadata on inline field definition is coherent

Annotating _jsonValueKey and _jsonValueKeyFlag with the same @BoundChoice(choiceId = "choice-1") and keeping them adjacent cleanly models their mutual exclusivity inside the choice group. This matches the BoundChoice semantics and existing patterns in METASCHEMA.

Also applies to: 1863-1877

databind/src/main/java/gov/nist/secauto/metaschema/databind/model/metaschema/binding/InlineDefineField.java (1)

26-27: Inline field JSON key choice is modeled consistently

The use of @BoundChoice(choiceId = "choice-1") on _jsonValueKey and _jsonValueKeyFlag mirrors the global definitions and keeps the mutually-exclusive JSON key alternatives clearly grouped. No issues spotted.

Also applies to: 212-225

databind/src/main/java/gov/nist/secauto/metaschema/databind/model/annotations/BoundChoice.java (1)

18-48: BoundChoice annotation API and documentation are well-structured

The new @BoundChoice annotation has a minimal, clear contract (@NonNull String choiceId()), appropriate retention/targets, and Javadoc that explains mutual exclusivity, adjacency, and how it differs from BoundChoiceGroup. This is a solid foundation for the new choice semantics.

databind/src/main/java/gov/nist/secauto/metaschema/databind/codegen/typeinfo/def/AssemblyDefinitionTypeInfoImpl.java (3)

19-19: LGTM!

Import correctly added to support the new setChoiceId call on named model instance type info.


45-46: LGTM!

The counter field correctly generates unique choice IDs within the scope of a single definition's model processing.


80-130: LGTM!

The overloaded method cleanly propagates choice IDs through recursive model processing. The Javadoc is complete with proper @param and @return tags per coding guidelines.

databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/AssemblyModelGenerator.java (4)

37-86: LGTM!

The BoundAssemblyModelBuilder inner class cleanly extends the default builder to support annotation-based bindings where choice alternatives are already in the model instances list. The Javadoc is comprehensive with proper type parameter documentation.


88-148: LGTM!

The factory method correctly orchestrates choice instance creation: grouping by @BoundChoice annotation, validating adjacency, and appending choice metadata without duplicating entries in the model instances list.


150-178: LGTM!

The grouping logic correctly extracts @BoundChoice annotations and maintains index information for adjacency validation.


180-213: LGTM!

The adjacency validation correctly enforces that choice alternatives must be declared consecutively. The IllegalStateException is appropriate for this configuration error, and the error message provides useful debugging information.

databind/src/main/java/gov/nist/secauto/metaschema/databind/model/impl/BoundInstanceModelChoice.java (3)

26-48: LGTM!

The class structure correctly extends AbstractChoiceInstance with appropriate type parameters for annotation-based bindings. The Javadoc is comprehensive.


70-96: Verify handling of unexpected instance types.

The buildModelContainer method silently ignores instances that are neither IBoundInstanceModelField nor IBoundInstanceModelAssembly. While this is likely intentional (since only these types should appear), consider whether a warning log or assertion would help catch unexpected cases during development.


98-115: LGTM!

The accessor methods are correctly implemented with appropriate annotations.

databind/src/test/java/gov/nist/secauto/metaschema/databind/model/impl/BoundChoiceTest.java (5)

33-141: LGTM!

The test fixture classes are well-designed to cover the key scenarios: valid adjacent choices, invalid non-adjacent choices, and multiple independent choice groups.


143-159: LGTM!

Test correctly validates that valid adjacent choice fields result in a single choice instance with two alternatives.


161-173: LGTM!

Test correctly verifies that non-adjacent choice fields trigger an IllegalStateException during model initialization.


175-192: LGTM!

Test correctly validates that multiple independent choice groups (choice-1 and choice-2) each produce their own choice instance with the expected number of alternatives.


194-226: LGTM!

Tests comprehensively verify choice instance properties including minOccurs, maxOccurs, containing definition, and the choiceId accessor on BoundInstanceModelChoice.

databind/src/main/java/gov/nist/secauto/metaschema/databind/io/AbstractProblemHandler.java (8)

28-53: LGTM: Well-structured constructors and clear Javadoc.

The class documentation clearly describes the purpose, and the constructor pattern (no-arg delegates to parameterized) is a good design. Javadoc coverage is complete with appropriate @param tags.


55-63: LGTM: Clean getter with proper documentation.


65-74: LGTM: Clean integration of validation logic.

The conditional validation before applying defaults is a good design that maintains backward compatibility through the feature flag.


133-156: LGTM: Well-documented and safe helper method.

The instanceof guard on line 145 ensures safe casting, and the use of JSON names for instance identification is consistent with the validation logic.


158-190: LGTM: Clear logic for choice satisfaction.

The Javadoc clearly explains the satisfaction conditions, and the implementation correctly checks whether at least one alternative was provided or the choice is optional.


192-216: LGTM: Robust handling of different instance types.

The method correctly prioritizes default value checks and handles both flag and model instance types appropriately. The safe fallback on line 215 for unknown types is a good defensive practice.


218-228: LGTM: Clean abstraction for instance naming.


76-131: The choice validation logic checks choice-level minOccurs but only after filtering instances where isRequiredAndMissingDefault() returns true.

At line 189, isChoiceSatisfied() correctly evaluates choice.getMinOccurs() to determine if missing all siblings is valid. However, this check only applies to alternatives that pass isRequiredAndMissingDefault() at line 106.

Edge case to verify: If a choice group has minOccurs > 0 (required) but all its individual alternatives have minOccurs = 0 (optional), no alternative would be flagged as "required and missing default" at line 106, so none would enter the choice-satisfaction check. Confirm whether metaschema modeling rules guarantee that if a choice is required, at least one alternative is also required.

@david-waltermire
Copy link
Contributor Author

The documentation in the skill file is correct - DESERIALIZE_VALIDATE_REQUIRED_FIELDS is enabled by default (true in DeserializationFeature.java line 72). The PR description confirms this: 'Enabled by default now that choice validation works correctly'. The CodeRabbit review comment appears to be based on an earlier version of the PR objectives before we changed the default from disabled to enabled.

@david-waltermire david-waltermire merged commit 572a125 into metaschema-framework:develop Dec 28, 2025
4 checks passed
@david-waltermire david-waltermire deleted the feature/parser-required-validation branch December 28, 2025 19:06
david-waltermire added a commit to david-waltermire/metaschema-java that referenced this pull request Dec 28, 2025
Updates PRD and implementation plan to reflect all work is complete:
- PR 1 (metaschema-framework#577): Code generator improvements
- PR 2 (metaschema-framework#584): Collection class override support
- PR 3: Databind bootstrap (combined with PR 2)
- PR 4 (metaschema-framework#593): Parser required field validation
- PR 5: Choice instance support (addressed by PR 4)

Move PRD from Active to Completed in CLAUDE.md tracking.
david-waltermire added a commit that referenced this pull request Dec 28, 2025
Updates PRD and implementation plan to reflect all work is complete:
- PR 1 (#577): Code generator improvements
- PR 2 (#584): Collection class override support
- PR 3: Databind bootstrap (combined with PR 2)
- PR 4 (#593): Parser required field validation
- PR 5: Choice instance support (addressed by PR 4)

Move PRD from Active to Completed in CLAUDE.md tracking.
david-waltermire added a commit to david-waltermire/metaschema-java that referenced this pull request Dec 29, 2025
…n contexts

Refinements to PR metaschema-framework#593 (parser validation for required fields):

- Add newPermissiveBoundLoader() to IBindingContext for creating loaders
  with DESERIALIZE_VALIDATE_REQUIRED_FIELDS disabled
- Update constraint validation to use permissive loaders for referenced
  documents
- Update CLI convert command to use permissive loading
- Update CLI metapath eval command to use permissive loading and set
  document loader on DynamicContext to enable doc() function support
- Add tests for permissive loading behavior
david-waltermire added a commit to david-waltermire/metaschema-java that referenced this pull request Dec 29, 2025
…sages

Refinements to PR metaschema-framework#593 (parser validation for required fields):

Permissive Loading:
- Add newPermissiveBoundLoader() to IBindingContext for creating loaders
  with DESERIALIZE_VALIDATE_REQUIRED_FIELDS disabled
- Update constraint validation to use permissive loaders for referenced
  documents (enables doc() function during constraint evaluation)
- Update CLI convert command to use permissive loading
- Update CLI metapath eval command to use permissive loading and set
  document loader on DynamicContext to enable doc() function support
- Add tests for permissive loading behavior

Error Message Fixes:
- Add plural parameter to getFormatPropertyTypeName() and getPropertyTypeName()
- Fix plural forms: 'properties' instead of 'propertys' for JSON/YAML
- Consolidate getFormatPropertyGroupLabel() to delegate to
  getFormatPropertyTypeName() and capitalize, reducing code duplication
david-waltermire added a commit that referenced this pull request Dec 29, 2025
…sages (#600)

Refinements to PR #593 (parser validation for required fields):

Permissive Loading:
- Add newPermissiveBoundLoader() to IBindingContext for creating loaders
  with DESERIALIZE_VALIDATE_REQUIRED_FIELDS disabled
- Update constraint validation to use permissive loaders for referenced
  documents (enables doc() function during constraint evaluation)
- Update CLI convert command to use permissive loading
- Update CLI metapath eval command to use permissive loading and set
  document loader on DynamicContext to enable doc() function support
- Add tests for permissive loading behavior

Error Message Fixes:
- Add plural parameter to getFormatPropertyTypeName() and getPropertyTypeName()
- Fix plural forms: 'properties' instead of 'propertys' for JSON/YAML
- Consolidate getFormatPropertyGroupLabel() to delegate to
  getFormatPropertyTypeName() and capitalize, reducing code duplication
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.

Add choice instance support for annotation-based bindings Provide full support for choice in bound classes

1 participant