Source: Integration at 605cbc581c27.

JSON Schema Validation#

OSR uses JSON Schema (draft-07) to enforce the structure of all rule files, test fixtures, and the load manifest. Four schemas validate the project’s JSON data files.

Schema Files#

SchemaValidatesLocation
osr-expr.schema.jsonShared expression type (referenced by others)schemas/
rule-file.schema.jsonRule files in rules/schemas/
test-file.schema.jsonTest fixtures in tests/schemas/
meta.schema.jsonrules/meta.json manifestschemas/

Local Validation#

Install#

pip install check-jsonschema

Validate All Files#

scripts/validate.sh

This runs seven validation steps and reports pass/fail for each. The fifth step verifies that each identity:id pair is unique across the complete rule profile; this cross-file invariant cannot be expressed by JSON Schema alone.

Every rule also carries mandatory machine-readable provenance. Converted Rubi rules identify the Rubi source file and source-rule ordinal in provenance.sources.

The sixth step verifies semantic closure: every operator appearing in a rule pattern or result must have a corresponding file-level OpenMath mapping.

The provenance identifies the source of a rule, not the algorithm selected by a host CAS. A client that combines this RUBI profile with a procedural Risch-family integrator should record the selected backend and its version in its proof trace or execution metadata. The JSON rules remain portable and use the same OpenMath semantics regardless of that selection.

The final step verifies the exact duplicate-rule baseline. It fingerprints the pattern, constraints, and result of each rule, and rejects a new group or a changed member list. Regenerate the reviewed legacy baseline only after a conversion update:

python3 scripts/check_duplicate_rules.py rules \
  --baseline scripts/duplicate-rule-baseline.json --write-baseline

Generated rules/ and tests/ are also checked in CI by rerunning the Rubi converter with Julia 1.13. A hand-edited generated file is therefore rejected as converter drift.

Validate Individual Files#

# Validate a rule file
check-jsonschema \
  --schemafile schemas/rule-file.schema.json \
  --base-uri "file://${PWD}/schemas/" \
  rules/1-algebraic/1.1-binomial/1.1.1-linear/1.1.1.1-\(a+b-x\)^m.json

# Validate meta.json
check-jsonschema --schemafile schemas/meta.schema.json rules/meta.json

# Validate a test file
check-jsonschema \
  --schemafile schemas/test-file.schema.json \
  --base-uri "file://${PWD}/schemas/" \
  tests/1-algebraic/1.1-binomial/1.1.1-linear/1.1.1.1-\(a+b-x\)^m.json

# Verify schemas themselves are valid JSON Schema
check-jsonschema --check-metaschema schemas/*.schema.json

Verbose Output#

Add -v for detailed error reporting:

check-jsonschema --schemafile schemas/rule-file.schema.json \
  --base-uri "file://${PWD}/schemas/" \
  rules/1-algebraic/1.1-binomial/1.1.1-linear/1.1.1.1-\(a+b-x\)^m.json -v

Schema-to-Directory Mapping#

DirectorySchemaNotes
rules/meta.jsonmeta.schema.jsonSingle file
rules/**/*.json (excl. meta.json)rule-file.schema.jsonRecursive
tests/**/*.jsontest-file.schema.jsonRecursive
schemas/*.schema.jsonJSON Schema draft-07 meta-schemaSelf-validation

Cross-File Reference Resolution#

The --base-uri "file://${PWD}/schemas/" flag is required because rule-file.schema.json and test-file.schema.json contain $ref references to osr-expr.schema.json. This flag overrides the $id URI (https://domain.org/schemas/v0.1/...) to resolve references against local files.

CI/CD Enforcement#

A GitHub Actions workflow (.github/workflows/validate-schemas.yml) runs schema validation automatically on:

  • Every push that modifies rules/, tests/, or schemas/
  • Every pull request that modifies those directories

If validation fails, the CI check blocks the merge and reports the specific file and field that failed.

Operator and Predicate Enums#

The osr-expr.schema.json schema contains enum definitions that document every operator and predicate in the OSR-Expr catalogue. These enums are for documentation and tooling — the operator-name regex pattern (^[a-zA-Z$][a-zA-Z0-9$]*$) is what actually validates operator names in expressions. The regex accepts both PascalCase standard operators (e.g., Sin, Add) and lowercase inert forms (e.g., sin, cos) used in RUBI’s trig normalization rules.

DefinitionCountSpec Reference
core-arithmetic-operators9OSR-X-010
trig-operators6OSR-X-011
hyperbolic-operators6OSR-X-012
inverse-trig-operators6OSR-X-013
inverse-hyperbolic-operators6OSR-X-014
exp-log-operators2OSR-X-015
special-function-operators29OSR-X-016
constant-symbols7OSR-X-017
integration-operators7OSR-X-018
utility-function-operators54OSR-X-019 (§4.11)
structural-utility-operators28OSR-X-020 (§4.12)
predicate-names77OSR-C-001 to C-030 (§7)

Taxonomy Subsections#

The meta.schema.json supports optional subsections arrays in taxonomy entries, enabling machine-readable representation of the full RUBI hierarchy (e.g. Section 1 > 1.1 Binomial products > 1.1.1 Linear). Subsection numbers use dotted string format (e.g. "1.1", "1.1.1", "8.10").

Converter Usage#

The converter/ directory contains a Julia tool that converts RUBI’s Mathematica source files to OSR JSON format. See converter/README.md for full documentation.

Quick Start#

# Initialize git submodules (RUBI source + test suite)
git submodule update --init

# Convert rules, tests, and update manifest
julia --project=converter converter/scripts/convert.jl --rules
julia --project=converter converter/scripts/convert.jl --tests
julia --project=converter converter/scripts/convert.jl --manifest

# Validate all generated files
scripts/validate.sh

Expected Output#

ArtifactDirectoryFilesItems
Rulesrules/2216,257 rules
Teststests/21572,254 test problems
Manifestrules/meta.json1load_order + counts

Updating Schemas#

When modifying schemas:

  1. Edit the schema file in schemas/.
  2. Run check-jsonschema --check-metaschema schemas/*.schema.json to verify the schema is still valid.
  3. Run scripts/validate.sh to verify existing data files still pass.
  4. Commit the schema change alongside any data file changes.
  5. Include a migration note in the PR describing impact on consumers.

Stable rule identities#

Every generated rule file includes a stable identity. Combined with a rule’s file-local positive integer id, it forms the canonical profile-wide identifier identity:id. section remains a taxonomy label and is not an identifier.