Skip to content

fix: correct property introspection in meta.Type - #103

Open
ehennestad wants to merge 1 commit into
add-serialization-round-trip-testsfrom
fix-meta-type-property-introspection
Open

fix: correct property introspection in meta.Type#103
ehennestad wants to merge 1 commit into
add-serialization-round-trip-testsfrom
fix-meta-type-property-introspection

Conversation

@ehennestad

@ehennestad ehennestad commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Two defects in openminds.internal.meta.Type, both found while building the round-trip test synthesizer in the previous PR in this stack. Neither is currently reachable from the serializer, which is why they have gone unnoticed, but both are reachable by any other consumer of the meta layer — including the traversal core proposed in #69.

isPropertyValueScalar reported scalar properties as non-scalar

A property can be restricted to a scalar in two ways: a mustBeScalarOrEmpty validator, or a (1,1) size declaration. The method only looked for the validator on linked and embedded properties. For every other property it consulted the size declaration instead.

The generated type classes declare almost everything as (1,:) and express the scalar constraint through the validator, so any property holding a primitive value that is restricted to a scalar was reported as non-scalar. openminds.core.miscellaneous.Membership/startDate is one example: it is declared (1,:) datetime {mustBeScalarOrEmpty, mustBeValidDate}, assigning two values correctly fails, and isPropertyValueScalar returned false.

The serializer is unaffected because it only asks about linked and embedded properties, which take the branch that worked.

Both constraints are now checked for every property.

The size branch also raised 'Not implemented.' for any dimension that was neither fixed nor unrestricted, with a comment questioning whether that could happen. A dimension that is not fixed leaves the property unconstrained in size, so that case now reports non-scalar rather than erroring.

isPropertyMixedType errored on a property with no declared class

The method read Validation.Class.Name without checking that a class was declared. A property declared without one produces an empty Validation.Class, and the read fails with Insufficient number of outputs from right hand side of equal sign to satisfy assignment rather than answering the question. openminds.neuroimaging.device.MRIScannerUsage/fieldOfView is declared fieldOfView (1,:) with no class and is registered in LINKED_PROPERTIES with an empty allowed-type list, so it reproduces this today.

A property without a declared class cannot be a mixed type, so the check now returns false. getMixedTypeForProperty had the same unguarded read and now raises OPENMINDS_MATLAB:MetaType:NotAMixedType instead.

Note that the fieldOfView declaration itself looks like a gap in the generated classes rather than something to fix here. It is worth raising separately against the pipeline.

Tests

MetaTypeTest gains three cases. The scalar constraint is pinned twice: once against ommtest.helper.PropertyDeclarationFixture, a small class added for this purpose that carries one property of each declaration shape, and once against Membership/startDate so the behaviour is also pinned for a real generated type.

The no-declared-class case is tested only against the fixture. Testing it against MRIScannerUsage/fieldOfView would tie the test to a schema anomaly that may well be corrected upstream, at which point the test would start failing for the wrong reason.

The round-trip synthesizer added in the previous PR inspected validators itself to work around the scalar defect. That workaround is removed here, which also serves as a check that the fix covers the case it was written for.

🤖 Generated with Claude Code

@ehennestad
ehennestad force-pushed the fix-meta-type-property-introspection branch 2 times, most recently from 7051ec1 to a97a378 Compare August 31, 2026 10:39
@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Test Results (R2026a)

740 tests  +3   724 ✅ +3   2m 27s ⏱️ -15s
 19 suites ±0    16 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit f4d03a8. ± Comparison against base commit 5fb026a.

♻️ This comment has been updated with latest results.

@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.10345% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.93%. Comparing base (5fb026a) to head (f4d03a8).

Files with missing lines Patch % Lines
code/internal/+openminds/+internal/+meta/Type.m 93.10% 2 Missing ⚠️
Additional details and impacted files
@@                          Coverage Diff                           @@
##           add-serialization-round-trip-tests     #103      +/-   ##
======================================================================
+ Coverage                               78.79%   78.93%   +0.13%     
======================================================================
  Files                                     417      417              
  Lines                                    4028     4039      +11     
======================================================================
+ Hits                                     3174     3188      +14     
+ Misses                                    854      851       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Test Results (R2022a)

740 tests  +3   724 ✅ +3   2m 40s ⏱️ +23s
 19 suites ±0    16 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit f4d03a8. ± Comparison against base commit 5fb026a.

♻️ This comment has been updated with latest results.

@ehennestad
ehennestad force-pushed the fix-meta-type-property-introspection branch from a97a378 to abe1695 Compare September 1, 2026 14:31
isPropertyValueScalar only looked for a mustBeScalarOrEmpty validator on
linked and embedded properties. For any other property it consulted the
size declaration instead, which is (1,:) for the generated type classes,
so a property restricted to a scalar by a validator was reported as
non-scalar. openminds.core.miscellaneous.Membership/startDate is one
example. Both constraints are now checked for every property.

The size branch also raised 'Not implemented.' for any dimension that was
neither fixed nor unrestricted. A dimension that is not fixed leaves the
property unconstrained in size, so this now reports non-scalar rather
than erroring.

isPropertyMixedType read Validation.Class.Name unguarded and errored on a
property declared without a class, rather than answering that it is not a
mixed type. getMixedTypeForProperty had the same problem and now raises
an identified error instead of failing on the unguarded read.

The round-trip synthesizer inspected validators itself to work around the
scalar bug. It now uses isPropertyValueScalar directly.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ehennestad
ehennestad force-pushed the fix-meta-type-property-introspection branch from abe1695 to f4d03a8 Compare September 1, 2026 20:58
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