Fixture inconsistency: DecimalTenthStep and QuantityFractionalTooBig disagree on scale-9 Decimal literals

Abierto
#192 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 5 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
1-2 días
Aptitud para principiantes
42/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
xml
Área
testing-qa

Línea de trabajo

Start by reading the four fixtures in tests/cql/ValueLiteralsAndSelectors.xml and tests/cql/CqlTypesTest.xml alongside CQL 1.5.2 §9 and the two proposed resolutions. Reproduce the conflict with the cql-tests runner so you can see how DecimalTenthStep and QuantityFractionalTooBig disagree under a reject-scale-9 policy. Done means the corpus adopts one policy consistently, either by changing QuantityFractionalTooBig to an 8-decimal literal or by removing invalid="true" from the TenthStep fixtures and adding matching output.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Summary

Two fixtures in the published conformance corpus assert incompatible oracles for Decimal literals exceeding CQL 1.5.2 §9's "maximum of 8 decimal places of precision" rule. The two expressions use exactly 9 fractional digits and reach the same parse path, but their <output> oracles disagree on whether that should be an error or a passing exact value. No engine policy on scale-9 Decimal literals can satisfy both fixtures simultaneously.

The two fixtures

File: tests/cql/ValueLiteralsAndSelectors.xml

<test name="DecimalTenthStep" invalid="true">
  <expression>0.000000001</expression>
</test>
<test name="DecimalPosTenthStep" invalid="true">
  <expression>+0.000000001</expression>
</test>
<test name="DecimalNegTenthStep" invalid="true">
  <expression>-0.000000001</expression>
</test>

File: tests/cql/CqlTypesTest.xml

<test name="QuantityFractionalTooBig">
  <expression>5.999999999 'g'</expression>
  <output>5.999999999 'g'</output>
</test>

The three TenthStep fixtures expect the engine to raise an error on a scale-9 Decimal literal. QuantityFractionalTooBig expects the engine to succeed and return a scale-9 Quantity whose value carries the same 9-decimal fractional component.

Normative context

CQL 1.5.2 §9 "Types" (https://cql.hl7.org/09-b-cqlreference.html#types):

Decimal. The Decimal type represents real values in the range (−10^28..10^28) with a maximum of 8 decimal places of precision.

Both expressions are scale-9 Decimal literals, so both exceed this rule. There is no sub-clause that exempts Quantity-wrapped Decimal literals from the 8-decimal precision bound; the Quantity type's value component is specified as Decimal.

Why this is an inconsistency, not two separable oracles

Both expressions reach the engine's Decimal parser along the same code path: the ELM translator emits a Decimal literal whose value is parsed by the runtime's from-string equivalent, regardless of whether the literal appears bare or inside a Quantity. The Quantity type's value component is a Decimal; there is no Quantity-specific parser that bypasses the 8-decimal rule.

  • An engine policy of "reject scale > 8" closes the three TenthStep cases (correctly raises an error) but breaks QuantityFractionalTooBig (which expects success).
  • An engine policy of "accept scale > 8" passes QuantityFractionalTooBig but fails the three TenthStep cases (no error is raised).

A single uniform policy at the Decimal parse layer cannot satisfy both.

Repro

Build an engine that implements the §9 precision bound at Decimal parse time (e.g. reject or return Null on scale > 8). Run the four cases through the cql-tests runner:

  • DecimalTenthStep / DecimalPosTenthStep / DecimalNegTenthStep return Null or raise; the fixture oracle is invalid="true" which classifies as "expected error of category True". Null is not "error"; raising matches.
  • QuantityFractionalTooBig fails because the Quantity constructor chain encounters a rejected Decimal component.

Alternatively, build an engine that accepts scale > 8 verbatim: all four cases now disagree with their respective oracles in the opposite direction.

Observed behaviour across first-party engines

Both CQFramework reference engines (Java engine 5.6.1 via $cql, cql-execution 4.0.0-beta.1) accept scale-9 Decimal literals as valid and return them without error. Neither implements the §9 bound as a parse-time rejection. The three TenthStep fixtures' invalid="true" oracle is currently not matched by either first-party engine.

Proposed resolutions

Either direction unblocks a consistent engine policy; the fixture suite needs to pick one.

  1. Strict (direct §9 reading). Rewrite QuantityFractionalTooBig so its expression uses an 8-decimal-or-fewer Decimal (e.g. 5.99999999 'g'), or set invalid="true" and remove <output>. This preserves the TenthStep family's error-expectation and makes the §9 precision bound enforceable uniformly at the Decimal layer.

  2. Permissive (observed-engine reading). Drop invalid="true" from the three TenthStep fixtures and add <output>0.000000001</output> (or <output>0</output> under a rounded reading). This acknowledges that multiple first-party engines accept scale > 8 via their underlying numeric representation and that the §9 bound is treated as a presentation rule rather than a parse-time rule.

Prior investigation

An empirical attempt at the strict policy (reject scale > 8 at the decimal.from-string layer) against the full 2037-case corpus produced 0 net recoveries and 1 regression (the QuantityFractionalTooBig case). Investigation receipt at docs/engineering/dec-01-decimal-precision-enforcement-blocked-receipt-2026-11-24.md in the originating repo.

Related upstream filing from the same investigation family: #1953 in cqframework/clinical_quality_language (cql-to-elm Divide function-call form missing libraryName=System).

Lenguaje dominante
Sin datos de lenguaje
Estrellas
8
Forks
9
Merge medio
4 d 2 h
PR fusionados (30 d)
3

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de cqframework/cql-tests

Todos los issues de cqframework/cql-tests

Issues similares

Más issues de Testing & QA

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.