This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Initialize submodules (required before first build, or in new worktrees)
git submodule update --init --recursive
# Build and install all modules
mvn install
# Replicate CI/CD build (recommended before pushing)
mvn install -PCI -Prelease
# Build with release profile (includes additional checks)
mvn -Prelease install
# Run tests only
mvn test
# Run a single test class
mvn -pl core test -Dtest=FnCountTest
# Run a single test method
mvn -pl core test -Dtest=FnCountTest#testCount
# Skip tests during build
mvn install -DskipTests
# Build specific module (e.g., core)
mvn -pl core install
# Build module with dependencies
mvn -pl core -am install
# Generate site documentation
mvn site site:stage
# Check license headers in source files
mvn license:check
# Add license headers to source files
mvn license:format
# Check source code formatting
mvn formatter:validate
# Auto-format source code
mvn formatter:format
# Check for Checkstyle issues (e.g., missing Javadoc)
mvn checkstyle:checkThe project uses multiple static analysis tools configured in the parent POM (configurations in oss-maven):
- Checkstyle: Code style enforcement (checkstyle.xml)
- PMD: Source code analysis, fails on priority 2+ violations (custom.xml)
- SpotBugs: Bug pattern detection (uses
spotbugs-exclude.xmlfor exclusions) - Jacoco: Code coverage analysis (target: 60% coverage)
metaschema-framework (parent)
├── core (metaschema-core) - Core API, Metapath expression language
├── databind (metaschema-databind) - Data binding and code generation
├── schemagen (metaschema-schema-generator) - XML/JSON schema generation
├── databind-modules - Metaschema binding modules
├── metaschema-maven-plugin - Maven plugin for code/schema generation
├── metaschema-testing - Testing utilities
├── cli-processor - CLI framework
└── metaschema-cli - Command-line interface
- model/ - Metaschema model interfaces (
IModule,IAssemblyDefinition,IFieldDefinition,IFlagDefinition) - metapath/ - Metapath query language implementation
- antlr/ - ANTLR4-generated parser (from
src/main/antlr4) - cst/ - Concrete syntax tree expressions
- function/ - Function library implementation
- item/ - Metapath item types (node items, atomic items)
- antlr/ - ANTLR4-generated parser (from
- datatype/ - Data type adapters for Metaschema types
- mdm/ - Metaschema Document Model node items
Metapath is an implementation of XPath 3.1. The XPath 3.1 specification and XPath Functions 3.1 should be used as the authoritative behavioral reference when:
- Implementing new Metapath functions
- Fixing bugs in existing function implementations
- Understanding expected error handling behavior
When behavior differs from the spec: If you discover that the current Metapath implementation differs from the XPath 3.1 specification, raise this as a clarification to the user before making changes. Consider:
- Whether the deviation is intentional (Metaschema-specific extension)
- The risk of changing behavior that existing code may depend on
- Whether tests need to be added to verify spec-compliant behavior
Code generation occurs during Maven build:
- Metaschema bindings: Generated from Metaschema modules via metaschema-maven-plugin
- ANTLR4: Metapath parser from
core/src/main/antlr4
Generated sources are placed in target/generated-sources/ and excluded from style checks.
Several modules contain pre-generated binding classes that cannot be generated during the normal build due to circular dependencies. These classes must be regenerated manually when their source Metaschema modules change.
| Module | Bootstrap POM | Generated Package | Source Metaschema |
|---|---|---|---|
| metaschema-testing | metaschema-testing/pom-bootstrap.xml |
...model.testing.testsuite |
unit-tests.yaml |
| databind | databind/pom-bootstrap-config.xml |
...databind.config.binding |
metaschema-bindings.yaml |
| databind | databind/pom-bootstrap-model.xml |
...databind.model.metaschema.binding |
metaschema-module-metaschema.xml |
To regenerate binding classes:
# First ensure the project is built
mvn install -DskipTests
# Generate binding classes using bootstrap POM (choose the appropriate module)
# Each bootstrap POM generates classes directly into src/main/java
mvn -f metaschema-testing/pom-bootstrap.xml process-sources
mvn -f databind/pom-bootstrap-config.xml process-sources
mvn -f databind/pom-bootstrap-model.xml process-sourcesSee the README.md files in each module for detailed instructions.
YAML-first approach: When creating new Metaschema modules, prefer YAML format over XML.
- YAML modules use
.yamlextension and are stored insrc/main/metaschema/ - Use the JSON schema at
databind-modules/target/generated-resources/schema/json/metaschema-model_schema.jsonfor IDE validation - Reference existing YAML modules (e.g.,
databind/src/main/metaschema/metaschema-bindings.yaml) for structure examples
IModule- Represents a Metaschema module with definitionsIModuleLoader- Loads Metaschema modules from various sourcesIDataTypeAdapter- Adapts between Java types and Metaschema data typesStaticContext/DynamicContext- Metapath evaluation contexts
- Tests use JUnit 5 with parallel execution enabled (Maven Surefire plugin)
- Test utilities are in the
metaschema-testingmodule - Integration tests for the Maven plugin use the maven-invoker-plugin
- All PRs require passing CI checks before merge
- 100% of unit tests must pass before pushing code (BLOCKING)
All code changes should follow TDD principles:
- Write tests first: Before implementing new functionality, write tests that capture the expected behavior
- Watch tests fail: Verify the tests fail with the current implementation (proving the tests are meaningful)
- Write minimal code: Implement just enough code to make the tests pass
- Refactor: Clean up the code while keeping tests green
For existing code without tests:
- When modifying existing files, add tests as you touch the code
- This ensures behavioral equivalence before and after changes
# Run a single test class
mvn -pl core test -Dtest=FnCountTest
# Run a single test method
mvn -pl core test -Dtest=FnCountTest#testCount- Java 11 target
- Uses SpotBugs annotations (
@NonNull,@Nullable) for null safety - Package structure follows
dev.metaschema.*convention
All code changes must follow the Javadoc style guide: docs/javadoc-style-guide.md
Key requirements:
- New code: 100% Javadoc coverage on
public/protectedmembers (BLOCKING) - Modified code: Add/update Javadoc on any members you touch (Required)
- Surrounding code: Document nearby undocumented members when practical (Encouraged)
Checkstyle enforces these rules (configured in oss-maven checkstyle.xml):
MissingJavadocMethod- requires Javadoc on protected+ methodsJavadocMethod- validates@param,@return,@throwstagsJavadocType- requires Javadoc on protected+ typesNonEmptyAtclauseDescription- tags must have meaningful contentAtclauseOrder- tags must follow order:@param,@return,@throws,@deprecated
Exceptions (no Javadoc required):
@Overridemethods (inherit documentation from interface/superclass)@Testmethods (use descriptive names)- Generated code (
*.antlrpackages)
When adding implementation-specific behavior to @Override methods, use {@inheritDoc} with additional notes:
/**
* {@inheritDoc}
* <p>
* Implementation note: delegates to the model container.
*/
@Override
public List<IChoiceInstance> getChoiceInstances() {
return getModelContainer().getChoiceInstances();
}When automated reviewers (e.g., CodeRabbit) flag Javadoc issues:
- Critical/blocking issues: Address immediately per project conventions
- @Override method flags: Use
{@inheritDoc}if adding implementation notes, otherwise explain the project exception - Missing
@throwstags: Add for declared exceptions - Nitpick suggestions: Address if in scope, defer otherwise with explanation
After addressing review comments:
- Reply explaining what was fixed or why the comment doesn't apply
- Close resolved conversation threads
# Check Javadoc compliance
mvn checkstyle:check
# Generate Javadoc to find errors
mvn javadoc:javadoc- Repository: https://github.com/metaschema-framework/metaschema-java
- All PRs MUST be created from a personal fork (BLOCKING - required by CONTRIBUTING.md)
- All PRs MUST target the
developbranch (BLOCKING - required by CONTRIBUTING.md) - Clone with submodules:
git clone --recurse-submodules - All changes require PR review (CODEOWNERS enforced)
- Squash non-relevant commits before submitting PR (BLOCKING)
Key entry points for XML deserialization (see databind/parsing-api-notes.md):
DefaultXmlDeserializer.deserialize(Reader)- main entry pointAbstractClassBinding.readInternal()- reads flags then bodyDefaultAssemblyClassBinding.readBody()- parses assembly model contentsDefaultFieldClassBinding- handles field value parsing
For larger initiatives requiring multiple PRs, use a structured PRD (Product Requirements Document) approach.
PRDs are stored in PRDs/<YYYYMMDD>-<name>/ with:
PRD.md- Main requirements document (goals, requirements, success metrics)implementation-plan.md- Detailed PR breakdown with acceptance criteria- Supporting analysis documents as needed
- Planning Phase: Create PRD folder with requirements and implementation plan
- PR Size Limits: Target ≤50 files per PR, maximum 100 files per PR
- TDD Requirement: All functional code changes require test-driven development:
- Write/update tests first to capture expected behavior
- Verify tests pass with existing implementation
- Make code changes
- Verify tests still pass after changes
- Verification: After each PR, run
mvn clean install -PCI -Prelease - Completion Tracking: Mark completed items in
implementation-plan.mdacceptance criteria
When starting development on a PRD:
- Add entry to "Active PRDs" section below with status "In Progress"
When completing a PRD:
- Update status to "Completed" with completion date
- Move to "Completed PRDs" section if list grows
| PRD | Description | Status |
|---|---|---|
PRDs/20251206-build-cleanup/ |
Build warnings and deprecation removal | In Progress |
| PRD | Description | Completed |
|---|---|---|
PRDs/20251229-javadoc-coverage/ |
Complete Javadoc coverage for schemagen, databind, and maven-plugin modules | 2025-12-29 |
PRDs/20251228-targeted-report-constraint/ |
Add constraint processing support for TargetedReportConstraint (issue #592) | 2025-12-29 |
PRDs/20251228-validation-errors/ |
Validation error message improvements (#595, #596, #205) | 2025-12-28 |
PRDs/20251224-codegen-quality/ |
Code generator Javadoc and quality improvements | 2025-12-28 |
PRDs/20251217-cli-processor-refactor/ |
CLI processor refactoring (issue #252) | 2025-12-21 |
PRDs/20251217-context-functions/ |
Complete Metapath context functions (issue #162) | 2025-12-17 |
PRDs/20251221-xmlbeans-removal/ |
Replace XMLBeans with Metaschema bindings | 2025-12-24 |