feat(array): support type="literal" for exact-value arrays (EE parity)#193
Merged
Conversation
<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%.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
<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). Mirrorsdatamimic-ee'sdocs/specs/model/elements/08-array.mdand itsmodel/parsers/tasksarray_* implementation, ported as-is per the standing CE<->EE migration method (reuse EE's existing pattern, don't invent a new one).ArrayModel:literaladded to allowed types; literal mode forbidsscript/count(mirrors the existing script-forbids-count/type rule).ValueModelfor<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
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).