Skip to content

Require an integer value constant for a behavior array size and keep it unevaluated 🤖 - #3213

Merged
lwrage merged 11 commits into
masterfrom
3208_reject_nonconstant_array_size
Sep 11, 2026
Merged

Require an integer value constant for a behavior array size and keep it unevaluated 🤖#3213
lwrage merged 11 commits into
masterfrom
3208_reject_nonconstant_array_size

Conversation

@lwrage

@lwrage lwrage commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Fixes #3208
Fixes #3210

This branch carries both defects, since they are the same declaration read two ways: what the grammar accepts as an array size, and what translation does with the size it accepted.

Cause and correction

#3208 — AS5506/3 Rev A D.3 writes a behavior variable array size as the D.7 integer value constant. The shared integer-value grammar also accepts an ordinary reference expression, which names a value variable rather than a constant, and no strict checker constrains an array size. BehaviorAnnexValidator.checkArraySizes now reports a reference expression with no property tail, so the illegal form is rejected rather than silently turned into a zero extent.

#3210aadl2::ArraySize carries either a literal extent or a property constant, so a property reference had nowhere to go. Translation compensated by evaluating an element-prefixed reference against the declarative model and storing the number it read. That answers a per-instance question at declarative translation time, and declarative property lookup sees only the element's own associations, the single-element contained associations of its immediate containing classifier, and the property default (NamedElementImpl.getPropertyValueInternalPropertyAcc.addLocalContained). A contained association with a longer path, or one declared further up, is invisible to it and belongs to the instance model, so the extent was either rejected as unavailable or frozen at a value the instance model contradicts.

The correction adds BehaviorArraySize to the strict Behavior Annex metamodel, a subclass of aadl2::ArraySize that owns the size as a BA IntegerValue the way BehaviorTime owns the value of a behavior time. Translation now routes the declared size through the same toIntegerValue every other integer value position uses, so a property reference keeps its own form, prefix, indexes, and fields included. Subclassing rather than replacing the dimension keeps a behavior variable an ArrayableElement, so AadlBaUtils and AadlUtil.getElementCount keep working, and the inherited extent is still set for the two forms core AADL can express: an integer literal and an unindexed property constant. Validation no longer asks whether the declarative model can supply a value, since that is not a question about the legality of the declaration.

Reading the branch commit by commit, note that a939c9d87e introduced the element-prefixed evaluation and eb16aaf6b4 removes it again; the net diff is the unevaluated representation.

8765cbc1d2 then removes property value readers in org.osate.utils.internal.PropertyUtils that nothing in the reactor calls: twenty-two public methods and the private getUnit helper only setFloatValue used. The eight methods the Behavior Annex uses stay.

Regression models and assertions

  • models/issue3208/ — an array size written as a reference expression with no property tail; asserts the D.3 error.
  • models/issue3210/Issue3210.aadlbyLiteral[8], byConstant[# AADL_Project::Max_Queue_Size], byPrefixed[input#Queue_Size]. Asserts that the literal and the constant also reach the inherited aadl2::ArraySize extent, and that the prefixed reference keeps its own form as a ClassifierFeaturePropertyReference naming input and Queue_Size with the core extent left unset. The prefixed feature declares Queue_Size => 8, so a translation that read the property would have frozen that 8.
  • models/issue3210/BareProperty.aadl — a bare property definition as a size; now accepted and kept as a PropertySetPropertyReference.
  • models/issue3210/ContainedProperty.aadl — the extent comes from Queue_Size => 16 applies to worker.input in the enclosing process implementation, a two-element containment path. Declarative lookup cannot see it and answered with the property default of 1; the assertion requires the reference to be kept with no extent read.

Corpus goldens are regenerated. The resolved-model projections change shape (size : BehaviorArraySize with its integerValue child) for every model with an array dimension, and BareProperty's validated diagnostics lose the evaluability error.

Validation

Clean root reactor, run outside the sandbox:

mvn -s releng/osate.releng/settings.xml -Plocal -T5 \
  -Dtycho.localArtifacts=ignore -Dpr.build=true -Dsign=false \
  -Dspotbugs=false -Dcodecoverage=false -Djavadoc=false \
  -DfailIfNoTests=false clean install

BUILD SUCCESS, 143 modules, no failures or errors. org.osate.ba.tests: 119 tests, 0 failures, 5 pre-existing conformance skips, including Issue3210Test (4) and Issue3176Test (3). Goldens verified with regeneration off after regenerating.

Dependencies and merge order

No dependency on an unmerged change; the branch is based on master at d2899cc7a4. PR for #3211 is based on this branch and should merge after it.

Residual risk

This PR removes exported API and does not carry the version change. org.osate.utils.internal is exported, and org.osate.ba re-exports the requirement, so the twenty-two removed public methods were reachable by external Behavior Annex tooling. org.osate.utils is at 2.1.0 and both requiring bundles ask for [2.1.0,3.0.0); a major bump to 3.0.0 with the consumer ranges widened is required through releng/version-management/ before merge, and is deliberately not hand-edited here.

Other risks:

  • The metamodel gains an EClass, so the aadlba classifier IDs after it shift. That is generated renumbering, not a source change, but anything binding to those integers rather than to AadlBaPackage.Literals would need rebuilding.
  • For a property-reference size the core-level extent stays unset, so a consumer reading a dimension the core way sees no extent where it previously saw an evaluated number for the element-prefixed form. Resolving that value belongs to instantiation.
  • BehaviorArraySizeImpl.getAadlBaLocationReference is hand-written in generated code, as in every BA implementation that extends an aadl2 implementation, and must survive future regeneration.

🤖 Generated with Claude Code

@lwrage
lwrage added this pull request to stack #3215 September 11, 2026 14:50
@lwrage
lwrage force-pushed the 3208_reject_nonconstant_array_size branch from 8765cbc to 3b8c5f3 Compare September 11, 2026 16:35
sei-lwrage and others added 11 commits September 11, 2026 12:52
Model a behavior variable used as another variable's array extent alongside valid literal and property-constant controls. Assert that validation reports exactly one error on the offending size; the test currently fails because the annex is accepted without diagnostics.
Validate behavior-variable array dimensions before invoking the strict-model checkers. Report an ordinary reference expression on the written size while preserving the literal and property-reference forms admitted by the standard.
Model bare and element-prefixed property definitions as behavior-variable array extents alongside valid literal and property-constant controls. Assert that both unrepresentable property references are rejected on their written sizes.
Require a Behavior Annex array-size property reference to translate directly to a property constant. Report bare and element-prefixed property definitions on the written size before strict checking so they cannot silently become zero extents, and update the G12 conformance status.
Record the plain and BA-validated diagnostics, strict-model shape, source positions, and unparse output for the issue #3208 and #3210 regression projects. The validated projections pin one nonconstant-reference error and two property-definition errors.
Separate the ownerless property definition from the element-prefixed reference. Require input#Queue_Size to validate and translate its single non-modal value to extent 8, while retaining one source-local error for a bare property definition with no unambiguous value owner.
Evaluate an element-prefixed array-size property when its referenced owner supplies one non-modal integer value, and store that value as the strict extent. Track representable dimensions so validation rejects only property references whose value is absent, modal, non-integer, or ownerless instead of rejecting all property definitions.
Record the accepted prefixed-property model without BA diagnostics and add separate projections for the rejected bare property definition. The new validated diagnostic pins the ownerless property reference at its source range.
AS5506/3 Rev A D.3 writes a behavior variable array size as an integer
value constant, which D.7 spells as an integer literal or a property
reference. An aadl2::ArraySize can carry only a literal extent or a
property constant, so a property reference has nowhere to go and cannot
be kept as written.

Add BehaviorArraySize, a subclass of aadl2::ArraySize that owns the size
as a BA IntegerValue, the way BehaviorTime owns the value of a behavior
time. Subclassing keeps a behavior variable an ArrayableElement, so every
consumer that reads a core array dimension keeps working, and the owned
containment reference gives the integer value a real owner instead of
hanging it off the non-containment sizeProperty.

Generated with the EMF model and edit generators. BehaviorArraySizeImpl
implements getAadlBaLocationReference by hand, as every BA class whose
implementation extends an aadl2 implementation does.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Translation evaluated an element-prefixed array-size property reference
against the declarative model and stored the number it read. That reads a
per-instance value at declarative translation time, and declarative
property lookup answers it with only the element's own associations, the
single-element contained associations of its immediate containing
classifier, and the property default. A contained association with a
longer path, or one declared further up, is invisible to it and belongs to
the instance model, so the extent was either rejected as unavailable or
frozen at a value the instance model contradicts.

Build the size as a BehaviorArraySize and store the declared integer value
through toIntegerValue, the way every other integer value position keeps
what was written. A property reference now keeps its own form, prefix,
indexes, and fields included. The inherited extent is still set for the two
forms core AADL can express, an integer literal and an unindexed property
constant, so consumers that read a core array dimension see those. Drop
propertyArraySize and the representable-array-size tracking with it.

Validation keeps the D.3 legality rule that an array size is an integer
literal or a property reference, and no longer asks whether the
declarative model can supply a value: that question is not about the
legality of the declaration.

The new ContainedProperty model puts the extent in a contained property
association two path elements away, which the old code answered with the
property default of 1.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
org.osate.utils.internal.PropertyUtils carried a set of property value
readers that nothing in the reactor calls, and the array-size translation
that read a property value no longer exists. Remove the twenty-two unused
public readers, the private getUnit helper that only setFloatValue used,
and the imports that went with them. The eight methods the Behavior Annex
does use stay: findPropertyAssociation, isInAppliesTo, the two-argument
getIntValue, getEnumValue, findPropertyExpression, getPropertyExpression,
getValue, and getContainingProperty.

org.osate.utils.internal is an exported package, so this removes API.
org.osate.utils needs a major version bump and both requiring bundles need
their ranges widened accordingly; that belongs to the version-management
tooling and is not done here.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@lwrage
lwrage force-pushed the 3208_reject_nonconstant_array_size branch from 3b8c5f3 to 4ec8f7b Compare September 11, 2026 16:52
@lwrage
lwrage merged commit 817cb70 into master Sep 11, 2026
1 check passed
@lwrage
lwrage deleted the 3208_reject_nonconstant_array_size branch September 11, 2026 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants