Skip to content

fix(model): enforce §7.7.9 scene-quality datatype restriction and compare revisions numerically#3990

Merged
mergify[bot] merged 3 commits into
mainfrom
fix/model-scene-quality-and-revision-semver
Jun 26, 2026
Merged

fix(model): enforce §7.7.9 scene-quality datatype restriction and compare revisions numerically#3990
mergify[bot] merged 3 commits into
mainfrom
fix/model-scene-quality-and-revision-semver

Conversation

@Apollon77

Copy link
Copy Markdown
Collaborator

Summary

Two model-layer fixes (from todo backlog).

1. §7.7.9 scene-quality datatype restriction

AttributeValidator now validates that an attribute carrying the Scene (S) quality resolves to an unsigned integer or boolean type of at most 4 bytes (derived types such as enum8/map8 resolve through primitiveBase to their underlying uint and pass). Violations emit INVALID_SCENE_TYPE.

Per spec §7.7.9: "This quality SHALL only apply to attributes having unsigned integer or boolean data types of size at most 4 bytes from the Base Data Types list (e.g. bool, uint8, uint16, uint32), or derived types thereof (e.g. enum8, map8)."

The current standard model already satisfies this — codegen generate-model validation reports zero INVALID_SCENE_TYPE, so this is a guard for future/custom definitions.

2. Numeric (semver-style) revision comparison

Model.appliesTo() previously compared spec revisions with raw string comparison. Because the generation revision is trimmed ("1.6.0""1.6"), a natural asOf: "1.6.0" evaluated "1.6" >= "1.6.0" === false and silently disabled the override. Added Specification.compareRevisions(a, b) — segment-by-segment numeric compare, missing trailing segments treated as zero — and switched appliesTo() to use it.

Verified safe: re-running generate-model produces byte-identical generated output, so all existing asOf/until overrides resolve unchanged; only the patch-length-mismatch trap is fixed.

Tests

  • New AttributeValidatorTest.ts — 5 accept (bool, uint8, uint32, enum8, map8) / 3 reject (uint64, int8, string).
  • New SpecificationTest.tscompareRevisions ordering/equality + appliesTo regression cases.
  • Model package: 466/466 (ESM/CJS/Web). Full monorepo suite green. format-verify + lint clean.

🤖 Generated with Claude Code

…pare revisions numerically

Add AttributeValidator check that a Scene ("S") quality attribute resolves to an unsigned
integer or boolean type of at most 4 bytes (enum8/map8 derived types allowed), emitting
INVALID_SCENE_TYPE otherwise.

Replace raw string comparison in Model.appliesTo() with Specification.compareRevisions(),
which compares dotted-numeric revisions segment-by-segment (missing trailing segments treated
as zero). Fixes the trap where a trimmed generation revision ("1.6.0" -> "1.6") made
asOf "1.6.0" silently fail. Generated model output is byte-identical, so existing overrides
resolve unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 26, 2026 07:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the @matter/model layer to (1) enforce Matter spec §7.7.9’s datatype restriction for attributes with Scene (“S”) quality, and (2) fix revision applicability checks by comparing specification revisions numerically instead of lexically.

Changes:

  • Add AttributeValidator validation that Scene quality only applies to bool/unsigned int ≤ 4 bytes (including derived types like enums/bitmaps via primitiveBase).
  • Introduce Specification.compareRevisions() for segment-by-segment numeric revision comparison and use it in Model.appliesTo().
  • Add targeted unit tests covering the new scene-type validation and revision comparison/appliesTo regressions.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/model/src/logic/definition-validation/AttributeValidator.ts Enforces Scene-quality datatype constraints per spec via primitiveBase + Metatype.
packages/model/src/common/Specification.ts Adds numeric dotted-revision comparison helper.
packages/model/src/models/Model.ts Switches appliesTo() to use numeric revision comparison.
packages/model/test/logic/definition-validation/AttributeValidatorTest.ts Adds tests for allowed/blocked Scene-quality datatypes (including derived types).
packages/model/test/common/SpecificationTest.ts Adds tests for compareRevisions() and appliesTo() trimming regression.

…size

Require byteSize to be present for integer types rather than defaulting a
missing size to 0 (which would have allowed it). Addresses PR review.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Apollon77 Apollon77 added the automerge Set this label if the PR is ready to automatically merged after approval label Jun 26, 2026
@mergify

mergify Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@mergify mergify Bot merged commit 3ab14f7 into main Jun 26, 2026
37 checks passed
@mergify mergify Bot deleted the fix/model-scene-quality-and-revision-semver branch June 26, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge Set this label if the PR is ready to automatically merged after approval

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants