Skip to content

feat(array): support type="literal" for exact-value arrays (EE parity)#193

Merged
ake2l merged 2 commits into
developmentfrom
feat/array-literal-type
Jul 6, 2026
Merged

feat(array): support type="literal" for exact-value arrays (EE parity)#193
ake2l merged 2 commits into
developmentfrom
feat/array-literal-type

Conversation

@ake2l

@ake2l ake2l commented Jul 6, 2026

Copy link
Copy Markdown
Member

Summary

  • CE already had <array> (type+count random generation, script mode) - this adds the one mode EE has that CE didn't: type="literal" with <value constant="..."/> children, preserving values exactly (no random generation, no script evaluation). Mirrors datamimic-ee's docs/specs/model/elements/08-array.md and its model/parsers/tasks array_* implementation, ported as-is per the standing CE<->EE migration method (reuse EE's existing pattern, don't invent a new one).
  • ArrayModel: literal added to allowed types; literal mode forbids script/count (mirrors the existing script-forbids-count/type rule).
  • New ValueModel for <value constant="..."/>.
  • ArrayParser: literal arrays parse their <value> children; non-literal arrays keep rejecting any children, with a clearer error naming the array.
  • ArrayTask: literal arrays skip generator/script logic entirely.
  • <value> wired as a structural child of <array> only (not independently dispatchable - same treatment as <field>/<transition>), updated the two authoring-schema gate tests that enforce this invariant.

Test plan

  • TDD: wrote the failing DSL tests first, confirmed RED (pydantic rejects type="literal", then "does not accept any sub-elements"), implemented, confirmed GREEN.
  • test_array_literal (exact value preservation), test_array_literal_conflicting_attrs (count+literal rejected).
  • Full suite: 1427 passed, 15 skipped.
  • mypy/ruff clean.

ake2l added 2 commits July 6, 2026 17:29
<array> already existed in CE (type+count random generation, script mode) -
this adds the one mode EE has that CE didn't: type="literal" with <value
constant="..."/"> children, preserving values exactly with no random
generation or script evaluation (mirrors datamimic-ee docs/specs/model/
elements/08-array.md and datamimic_ee/{model,parsers,tasks}/array_*.py).

- ArrayModel: DATA_TYPE_LITERAL added to allowed types; literal mode forbids
  script/count (mirroring the existing script-forbids-count/type rule).
- New ValueModel for <value constant="..."/"> (EE's shape, ported as-is).
- ArrayParser: literal arrays parse their <value> children; non-literal
  arrays keep rejecting any children (now with a clearer error naming the
  array).
- ArrayTask: literal arrays skip generator/script logic entirely, just
  return the preserved list.
- Wired EL_VALUE as a structural child of <array> only (parser_util.py) -
  not independently dispatchable, same treatment as <field>/<transition>,
  updated the authoring schema gate tests accordingly.

TDD: wrote the failing DSL tests first (test_array_literal.xml, unsupported
literal+count/script combo), confirmed RED, implemented, confirmed GREEN.
Full suite 1427 passed/15 skipped, mypy/ruff clean.
SonarCloud flagged 86.2% coverage on new code. Two causes:
- test_array_literal.xml ran multiprocessing="True" numProcess="2" (copied
  from the pre-existing simple_types fixture) - array_task.py/
  array_statement.py execute in worker subprocesses, invisible to coverage.
  Dropped multiprocessing for this fixture; nothing about literal-array
  parsing needs it.
- Missing test cases for the actual new error paths: type='literal' +
  script= together, a non-literal array with <value> children, a <value>
  missing its 'constant' attribute, and an empty literal array (zero <value>
  children).

Local coverage on the touched files: array_parser.py 82.6% -> 100%,
array_model.py 87.5% -> 93% (remaining misses are pre-existing branches this
PR didn't touch), array_statement.py 80% -> 90%.
@ake2l
ake2l merged commit 2005af3 into development Jul 6, 2026
11 checks passed
@sonarqubecloud

sonarqubecloud Bot commented Jul 6, 2026

Copy link
Copy Markdown

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.

1 participant