Skip to content

About

Cross-language conformance suite for unitsml: frozen render corpus (norm_text, AsciiMath, UnitsML XML) replayed by unitsml-ruby and unitsml-ts

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

18 Commits

Folders and files

Repository files navigation

unitsml-testsuite

Cross-language conformance suite for UnitsML: the frozen render and conversion corpora replayed by every unitsml runtime (Ruby, TypeScript).

corpora/renders

89 inputs drawn from unitsml-ruby’s conv specs (spec/unitsml/conv/{xml,asciimath,…​}_spec.rb), frozen from unitsml-ruby 0.6.11:

  • expected-renders.json — per input: norm_text, asciimath, and the UnitsML xml document. Two rows are frozen as ruby_error (the pre-existing unitsml-ruby mml NoMethodError on kcal_IT); replays skip them and they must flip to render rows when upstream is fixed.

  • XML comparison is semantic — entities decoded, whitespace between tags collapsed, attribute quoting unified — mirroring the upstream conv specs' be_xml_equivalent_to contract.

corpora/conversions

25 conversion vectors from unitsml-ruby#92 (Conversions execution, unitsml-ruby PRs #98/#99/#100), frozen from the unitsml-ruby implementation:

  • expected-conversions.json — five case kinds:

    • convert — a Quantity#convert_to hop (canonical path, or through caller-supplied definitions given as UnitsML Float64ConversionFrom XML with their lookup key), expected value as an exact decimal string.

    • difference — the same for a difference of two quantities (20 degC − 15 degC → 5 K): conversion must skip the affine addends.

    • definition — Conversion::Definition execution: forward y = d + (b/c)(x + a) and inverse x = (c/b)(y − d) − a in exact rational arithmetic, the exact flag, and verbatim lexical decimal preservation.

    • resolve — initialUnit resolution: document-local fragments before the register, register fragments, and reference URIs.

    • error — typed refusals: affine definitions at power ≠ 1, definition-vs-canonical disagreement, unresolvable initialUnit, and SpecialConversionFrom/WSDLConversionFrom.

  • All numeric values are exact decimal strings; replays parse them as Rationals and compare exactly.

corpora/pma

98 parse vectors for pma (dialect P, "plurimath ascii", specified by plurimath docs/pma.adoc), frozen from plurimath/amath corpora/pma/{accepted,refused}.yml at amath commit 3cbf3f8d0c78 (file checksums recorded in the corpus):

  • expected-parses.json — two case kinds:

    • accept (38) — the input parses. term is the typed model’s bound data with the source texts as written; model is the resolved typed model as {node, fields} (set fields in declaration order, nil fields left out), with quantity assertions such as unit(J::energy) resolved to unitsdb quantity ids (q:energy).

    • refuse (60) — the input is refused with category and the position as byte_offset (UTF-8 bytes) and char_offset (code points). Version 1 refuses every form the specification leaves open.

  • version stamps the amath version, the pma grammar artifact checksum, and the vector set version.

  • Every row was checked on both amath engines (Ruby and native) before it was written; they agree on every row.

  • There are no render vectors yet: amath parses pma and does not render it. == corpora/features

Source-pinned feature vectors (F40). index.json holds the seals, the per-family status, the comparison rules and the git blob ids of the preserved render/conversion vectors above.

  • unitsml-quantities.json: 39 cases executed on unitsml-ruby 92b0f3481cd90e8a7b50ba9bd729363bec150a21 (0.6.14) with unitsdb gem 2.2.13 (data seal in producer_source). The kinds are exact conversions (value as n/d plus a terminating decimal where one exists), dimensions (dimension_id, dimension_vector, scale), kV*A in the watt class, a difference, and typed refusals matched by error_class. source_semantics_findings lists observed behaviour that is recorded but not endorsed.

  • gum-mcm-profiles.json: 13 adaptive-MCM profiles (2 H1 plus 11 extended) from plurimath 8916961a69dc1f586e915790c4fb052b910efa86, GHA run 42904830789. Each result is verbatim: probability, seeds, final generator state and stop metadata. Per-case evidence_gaps mark what the producer did not supply: raw and rounded H2 profiles, published reference values and last-digit gaps.

  • archive/gha-42904830789/: the two producer artifacts, byte for byte.

Families with no exact-head evidence (series/group statistics, conformity, GUM adequacy/normality refusals, the plurimath kV·A evaluator path) are listed as missing evidence in index.json. They are not inferred. python scripts/check_feature_corpus.py checks the seals, counts, verbatim archive agreement and refusal typing.

Replay contract

A conforming runtime parses each input (Unitsml.parse semantics, the unitsml(…​) wrapper and extras included) and asserts:

  • norm_text equality,

  • AsciiMath render equality,

  • semantic XML equality of the UnitsML document.

unitsml-ruby replays via CORPUS_DIR=… bundle exec rspec spec/unitsml/render_corpus_spec.rb; unitsml-ts via CORPUS_DIR=… npm run replay. Both CI pipelines check this repository out and enforce it.

The conversion corpus replays as CONVERSION_CORPUS_DIR=… bundle exec rspec spec/unitsml/conversion_corpus_spec.rb (unitsml-ruby) and CONVERSION_CORPUS_DIR=… npm run replay:conversions (unitsml-ts), the same checkouts enforced by CI.

Host-evaluator vectors (corpora/features/host-evaluator/v1)

74 plurimath 0.11.17 evaluator rows (H.2 raw paired data, raw-input and rounded-summary first-approach outputs, the second output approach, H.4/H.5 grouped statistics, series, JCGM 106 conformity, coverage factors, decimal output, MCM coverage adequacy and typed refusals) plus one unitsml 0.6.14 v*i kV*A to kW row. archive/ holds the producer payloads byte-for-byte; vectors.json splits each row into input and expected without computing anything. The H.2 published last digit is recorded as unresolved, and no named power class is asserted from the kW conversion. index.json lists seals, requested coverage and the coverage that is still missing.

Check: python scripts/host_evaluator_vectors.py check (re-verifies seals and rebuilds both JSON files from archive/, requiring byte equality).

Evaluator reference wires (corpora/features/evaluator-reference/v1)

388 evaluator request/response wires (numeric, quantity and GUM schemas) that the native engines are checked against. archive/ keeps the source wire list and every plurimath-rs fixture it was built from byte-for-byte, plus Ruby reference re-runs, the scripts and the gem locks used for them. vectors.json lists each wire with its family, schema, exact or approximate precision, seeds, outcome, error code and acceptance status. acceptance.json gives the evidence for each family.

Acceptance: the 204 numeric wires are byte-equal to a Ruby re-run, and the 149 GUM wires agree with Ruby re-runs or with the sealed Ruby results they were projected from. 3 quantity wires agree with a Ruby probe. The 32 quantity-register wires are partial: no Ruby caller-register evaluator exists, and exact fraction checks cover 16 of them. The H.2 published last digit and a named power class stay unresolved, as in host-evaluator/v1.

Check: python scripts/evaluator_reference_vectors.py check (re-verifies seals and rebuilds vectors.json from archive/, requiring byte equality).

Ruby feature additions (corpora/features/ruby-feature-additions/v1)

13 Ruby-generated rows for two families the F40 coverage matrix found missing. Six rows cover the accuracy classes (exact, limited_float, limited_<n>, and the least precise operand winning). Seven rows check that a UnitsML unit string survives a parse round trip, using the strings from unitsml-ruby’s composite spec. The same producer script ran at two Ruby heads and the outputs are byte-equal; index.json records both heads.

Check: python scripts/ruby_feature_additions.py check.

UnitsML Ruby features (corpora/features/ruby-unitsml-features/v1)

251 Ruby-generated rows for three F40 families that had no Ruby reference. Quantity kinds: every ordered pair of the 11 UnitsDB quantities with dimension NISTd15, added with declared kinds. Pairs inside the energy equivalence class are allowed and all other pairs are refused; 3 more rows cover a kind with the wrong dimension, an unknown kind and an untyped operand. Primary quantity: the 95 units with several quantity references, each with the primary taken from the primary flag under three reference orders. Caller register: the 32 register requests from evaluator-reference/v1, run through unitsml-ruby’s validated register.

The producer ran at unitsml-ruby 2337a12, the first head with these features, in two separate processes, and the outputs are byte-equal. index.json lists the five register cases where the native wires differ, with the reason for each.

Check: python scripts/ruby_unitsml_features.py check.

Typed quantity accuracy (corpora/features/ruby-typed-quantity-accuracy/v1)

36 Ruby-generated rows that pin the class of each quantity binding value. A BigDecimal binding is limited to its precision, a Float binding is limited_float, and a Rational or a plain String binding is exact. Each row has a plurimath.evaluate.quantity/1 request that keeps the class in the binding value: {"decimal": "2.5"}, {"rational": ["5", "2"]} or {"binary64": "4004000000000000"}; integers and String controls stay plain Strings. The expected result is what Formula#evaluate_quantity returns for the same typed values.

The rows cover the six accuracy rows of ruby-feature-additions/v1 (same ids, same results), String controls with the same digits, unused bindings, decimal precision and Float rounding, plus seven rows added to cover the Ruby source probes behind the Rust typed binding support. Each row also records what the Ruby request entry point answers for the same request at the producer head.

The producer ran at plurimath-ruby 0a1df68 with unitsml-ruby de4f5b9 in two separate processes, and the outputs are byte-equal.

Check: python scripts/ruby_typed_quantity_accuracy.py check.

UnitsDB schema roundtrip (corpora/features/unitsdb-schema-roundtrip/v1)

Ruby-generated schema and provenance roundtrip results for every UnitsDB collection and record. The producer loads each snapshot with the unitsdb gem 2.2.15 (under unitsml-ruby 2ec9583) and writes it back with to_yaml, the same calls the unitsdb-ruby specs make: Database.from_db(dir), each collection class from_yaml(raw) and each entity class per record. Every result is compared with canon’s be_yaml_equivalent_to, which is the unitsdb-ruby contract, and also field by field with value classes, and the collection schema is evaluated on input and output. Any mismatch fails the row.

There are two profiles: the data bundled in the unitsdb 2.2.15 gem, and UnitsDB b0b4315 (the merged #143 data). Each has 897 records in seven collections, and every check passes in both. The producer ran twice per profile in separate processes, and the outputs are byte-equal.

Check: python scripts/unitsdb_schema_roundtrip.py check.

Explicit quantity kind on kV*A (corpora/features/ruby-explicit-kind-power/v1)

22 Ruby-generated rows that pin what the existing explicit quantity-kind API of unitsml-ruby 2ec9583 does with the unit kV*A: construction with a caller-declared kind (NISTq187 apparent power or NISTq20 power), convert_to("kW"), typed addition, subtraction and equality of the two kinds, and the untyped kV * A product with its primary_kind. Each row has one expected result per UnitsDB profile: the published unitsdb gem 2.2.15 data and the merged UnitsDB #143 commit b0b4315. Each snapshot is loaded read-only with Database.from_db. The two profiles give the same results.

These rows record current API behaviour only. Whether kV*A should be typed automatically, or whether convert_to should refuse a kind that differs from the target unit’s primary kind, is an open policy question for the data owner and is not covered here.

Check: python scripts/ruby_explicit_kind_power.py check.

About

Cross-language conformance suite for unitsml: frozen render corpus (norm_text, AsciiMath, UnitsML XML) replayed by unitsml-ruby and unitsml-ts

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages