Skip to content

Rename DataModel to InteractionModel, introduce InteractionModelState uniting Events, Subscriptions, Networks and others.#485

Open
ivmarkov wants to merge 14 commits into
project-chip:mainfrom
sysgrok:data-model-state
Open

Rename DataModel to InteractionModel, introduce InteractionModelState uniting Events, Subscriptions, Networks and others.#485
ivmarkov wants to merge 14 commits into
project-chip:mainfrom
sysgrok:data-model-state

Conversation

@ivmarkov

@ivmarkov ivmarkov commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Addresses #411

Goal is to simplify the life of the user by not asking him to think about too many structs related to Matter internals.

=========

EDIT: As part of this relatively large change, I thought I'd bite the bullet and do the following renames / file moves as part of this PR or else all clients will have to do two migrations - one, to the DataModelState, and then another shortly after - to the new Interaction* names:

  • dm::DataModel -> im::InteractionModel
  • dm::DataModelState -> im::InteractionModelState
  • dm::DataModelHandler -> dm::DataModel (now that the DataModel name is available)

And also (but these should not concern users, as subscriptions and events are now part of the State struct):

  • dm::Subscriptions -> im::Subscriptions
  • dm::Events -> im::Events
  • (and other internal-use-only types)

Further, what used to be knows as the im module is now in im::encoding (except the BusyInteractionModel which is now lined-up as a sibling of InteractionModel).

That's because the im module really only used to contain the "encoding" IM types, like AttrPath, CmdPath, NodeId, EndptId and so on. Moving these to im::encoding allowed us to establish the following dependency chain:
im -> dm -> (a tiny subset of) im::encoding

where:

  • im = InteractionModel, InteractionModelState, BusyInteractionModel` etc.
  • dm = DataModel, (Async)Handler, Metadata and many others
  • im::encoding = NodeId, EndptId, ClusterIdm AttrId, CmdIdm, AttrPath, CmdPath and similar

The justification for these type renames and migrations to the im module is that they match more closely what these types actually do. What (used to be) called DataModel is in reality the InteractionModel Exchange handler. I.e. the thing which responds to IM messages coming via exchanges.

The combo of (Async)Handler + Metadata is really our data model (per Matter spec).
Though the *Handler type still contains the "handling" verbs' read/write/invoke/subscribe, these are now at an individual command/attribute level, rather than dealing with the IM protocol message payloads directly.

Now, this rename introduces circular dependencies between the dm and im modules, in that the InteractionModel would obviously reference and use the (Async)Handler + Metadata and other supporting traits defined in the dm module, but also the other way around, where some basic types defined in the im module would be used by the dm module, like type aliases for node/endpoint/cluster/attr/cmd IDs, as well as some IM structs, like AttrPath, CmdPath and others. But I don't see a way around that. It is not worth it to completely abstract the data model from these IM types.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request consolidates the data model's state—including the subscriptions table, events queue, and network store—into a single unified 'DataModelState' struct (along with its specialized type aliases 'EthDataModelState' and 'WirelessDataModelState'). This change simplifies the 'DataModel::new' constructor by replacing multiple separate arguments with a single reference to the consolidated state. Consequently, numerous example binaries, tests, and internal references have been refactored to instantiate and use this unified state struct, reducing boilerplate and improving code organization. I have no feedback to provide as there are no review comments.

@github-actions

Copy link
Copy Markdown

PR #485: Size comparison from 256033b to 3b6b540

Increases above 0.2%:

platform target config section 256033b 3b6b540 change % change
onoff-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1856152 1861288 5136 0.3
Full report (8 builds for (core), dimmable-light, onoff-light, onoff-light-bt, speaker)
platform target config section 256033b 3b6b540 change % change
(core) riscv32imac-unknown-none-elf infodefmt-optz-ltofat FLASH 418504 418640 136 0.0
RAM 72336 72336 0 0.0
thumbv6m-none-eabi infodefmt-optz-ltofat FLASH 338108 338252 144 0.0
RAM 67812 67812 0 0.0
thumbv7em-none-eabi infodefmt-optz-ltofat FLASH 318472 318496 24 0.0
RAM 67580 67580 0 0.0
x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 836939 837019 80 0.0
RAM 73162 73146 -16 -0.0
dimmable-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1921960 1921824 -136 -0.0
RAM 60800 5488 -55312 -91.0
onoff-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1856152 1861288 5136 0.3
RAM 59968 5472 -54496 -90.9
onoff-light-bt x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 3322504 3323128 624 0.0
RAM 5776 5776 0 0.0
speaker x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1890744 1891160 416 0.0
RAM 5472 5472 0 0.0

@github-actions

Copy link
Copy Markdown

PR #485: Size comparison from 256033b to 3b5a27d

Increases above 0.2%:

platform target config section 256033b 3b5a27d change % change
dimmable-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1921960 1928304 6344 0.3
onoff-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1856152 1868456 12304 0.7
onoff-light-bt x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 3322504 3334672 12168 0.4
speaker x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1890744 1897640 6896 0.4
Full report (8 builds for (core), dimmable-light, onoff-light, onoff-light-bt, speaker)
platform target config section 256033b 3b5a27d change % change
(core) riscv32imac-unknown-none-elf infodefmt-optz-ltofat FLASH 418504 418390 -114 -0.0
RAM 72336 72296 -40 -0.1
thumbv6m-none-eabi infodefmt-optz-ltofat FLASH 338108 338076 -32 -0.0
RAM 67812 67796 -16 -0.0
thumbv7em-none-eabi infodefmt-optz-ltofat FLASH 318472 318252 -220 -0.1
RAM 67580 67564 -16 -0.0
x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 836939 836419 -520 -0.1
RAM 73162 73090 -72 -0.1
dimmable-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1921960 1928304 6344 0.3
RAM 60800 5488 -55312 -91.0
onoff-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1856152 1868456 12304 0.7
RAM 59968 5472 -54496 -90.9
onoff-light-bt x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 3322504 3334672 12168 0.4
RAM 5776 5776 0 0.0
speaker x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1890744 1897640 6896 0.4
RAM 5472 5472 0 0.0

@github-actions

Copy link
Copy Markdown

PR #485: Size comparison from 256033b to 230a022

Increases above 0.2%:

platform target config section 256033b 230a022 change % change
dimmable-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1921960 1930096 8136 0.4
onoff-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1856152 1869144 12992 0.7
onoff-light-bt x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 3322504 3333896 11392 0.3
speaker x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1890744 1899256 8512 0.5
Full report (8 builds for (core), dimmable-light, onoff-light, onoff-light-bt, speaker)
platform target config section 256033b 230a022 change % change
(core) riscv32imac-unknown-none-elf infodefmt-optz-ltofat FLASH 418504 418824 320 0.1
RAM 72336 72272 -64 -0.1
thumbv6m-none-eabi infodefmt-optz-ltofat FLASH 338108 338440 332 0.1
RAM 67812 67788 -24 -0.0
thumbv7em-none-eabi infodefmt-optz-ltofat FLASH 318472 318556 84 0.0
RAM 67580 67556 -24 -0.0
x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 836939 836803 -136 -0.0
RAM 73162 73082 -80 -0.1
dimmable-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1921960 1930096 8136 0.4
RAM 60800 5488 -55312 -91.0
onoff-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1856152 1869144 12992 0.7
RAM 59968 5472 -54496 -90.9
onoff-light-bt x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 3322504 3333896 11392 0.3
RAM 5776 5776 0 0.0
speaker x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1890744 1899256 8512 0.5
RAM 5472 5472 0 0.0

@ivmarkov ivmarkov force-pushed the data-model-state branch 2 times, most recently from c4d9ff8 to 34d1d65 Compare June 18, 2026 14:44
@github-actions

Copy link
Copy Markdown

PR #485: Size comparison from 13a6675 to 34d1d65

Increases above 0.2%:

platform target config section 13a6675 34d1d65 change % change
dimmable-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1922120 1930720 8600 0.4
onoff-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1856520 1869784 13264 0.7
onoff-light-bt x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 3322864 3334552 11688 0.4
speaker x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1890896 1899896 9000 0.5
Full report (8 builds for (core), dimmable-light, onoff-light, onoff-light-bt, speaker)
platform target config section 13a6675 34d1d65 change % change
(core) riscv32imac-unknown-none-elf infodefmt-optz-ltofat FLASH 418764 419084 320 0.1
RAM 72336 72272 -64 -0.1
thumbv6m-none-eabi infodefmt-optz-ltofat FLASH 338268 338556 288 0.1
RAM 67812 67788 -24 -0.0
thumbv7em-none-eabi infodefmt-optz-ltofat FLASH 318640 318724 84 0.0
RAM 67580 67556 -24 -0.0
x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 837163 837027 -136 -0.0
RAM 73162 73082 -80 -0.1
dimmable-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1922120 1930720 8600 0.4
RAM 60800 5488 -55312 -91.0
onoff-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1856520 1869784 13264 0.7
RAM 59968 5472 -54496 -90.9
onoff-light-bt x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 3322864 3334552 11688 0.4
RAM 5776 5776 0 0.0
speaker x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1890896 1899896 9000 0.5
RAM 5472 5472 0 0.0

@ivmarkov ivmarkov changed the title DataModelState Rename DataModel to InteractionModel, introduce InteractionModelState uniting Events, Subscriptions, Networks and others. Jun 19, 2026
@github-actions

Copy link
Copy Markdown

PR #485: Size comparison from f3044ab to 8096b2b

Increases above 0.2%:

platform target config section f3044ab 8096b2b change % change
dimmable-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1922120 1930720 8600 0.4
onoff-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1856520 1869784 13264 0.7
onoff-light-bt x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 3322864 3334552 11688 0.4
speaker x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1890896 1899896 9000 0.5
Full report (8 builds for (core), dimmable-light, onoff-light, onoff-light-bt, speaker)
platform target config section f3044ab 8096b2b change % change
(core) riscv32imac-unknown-none-elf infodefmt-optz-ltofat FLASH 418764 419088 324 0.1
RAM 72336 72272 -64 -0.1
thumbv6m-none-eabi infodefmt-optz-ltofat FLASH 338268 338592 324 0.1
RAM 67812 67788 -24 -0.0
thumbv7em-none-eabi infodefmt-optz-ltofat FLASH 318640 318732 92 0.0
RAM 67580 67556 -24 -0.0
x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 837163 837019 -144 -0.0
RAM 73162 73082 -80 -0.1
dimmable-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1922120 1930720 8600 0.4
RAM 60800 5488 -55312 -91.0
onoff-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1856520 1869784 13264 0.7
RAM 59968 5472 -54496 -90.9
onoff-light-bt x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 3322864 3334552 11688 0.4
RAM 5776 5776 0 0.0
speaker x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1890896 1899896 9000 0.5
RAM 5472 5472 0 0.0

@github-actions

Copy link
Copy Markdown

PR #485: Size comparison from db10663 to 893c9ea

Increases above 0.2%:

platform target config section db10663 893c9ea change % change
dimmable-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1922120 1930712 8592 0.4
onoff-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1856520 1869792 13272 0.7
onoff-light-bt x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 3322864 3334544 11680 0.4
speaker x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1890896 1899896 9000 0.5
Full report (8 builds for (core), dimmable-light, onoff-light, onoff-light-bt, speaker)
platform target config section db10663 893c9ea change % change
(core) riscv32imac-unknown-none-elf infodefmt-optz-ltofat FLASH 418764 419084 320 0.1
RAM 72336 72272 -64 -0.1
thumbv6m-none-eabi infodefmt-optz-ltofat FLASH 338268 338588 320 0.1
RAM 67812 67788 -24 -0.0
thumbv7em-none-eabi infodefmt-optz-ltofat FLASH 318640 318724 84 0.0
RAM 67580 67556 -24 -0.0
x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 837163 837019 -144 -0.0
RAM 73162 73082 -80 -0.1
dimmable-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1922120 1930712 8592 0.4
RAM 60800 5488 -55312 -91.0
onoff-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1856520 1869792 13272 0.7
RAM 59968 5472 -54496 -90.9
onoff-light-bt x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 3322864 3334544 11680 0.4
RAM 5776 5776 0 0.0
speaker x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1890896 1899896 9000 0.5
RAM 5472 5472 0 0.0

@github-actions

Copy link
Copy Markdown

PR #485: Size comparison from db10663 to cbad7d1

Increases above 0.2%:

platform target config section db10663 cbad7d1 change % change
dimmable-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1922120 1930712 8592 0.4
onoff-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1856520 1869792 13272 0.7
onoff-light-bt x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 3322864 3334544 11680 0.4
speaker x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1890896 1899896 9000 0.5
Full report (8 builds for (core), dimmable-light, onoff-light, onoff-light-bt, speaker)
platform target config section db10663 cbad7d1 change % change
(core) riscv32imac-unknown-none-elf infodefmt-optz-ltofat FLASH 418764 419084 320 0.1
RAM 72336 72272 -64 -0.1
thumbv6m-none-eabi infodefmt-optz-ltofat FLASH 338268 338588 320 0.1
RAM 67812 67788 -24 -0.0
thumbv7em-none-eabi infodefmt-optz-ltofat FLASH 318640 318724 84 0.0
RAM 67580 67556 -24 -0.0
x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 837163 837019 -144 -0.0
RAM 73162 73082 -80 -0.1
dimmable-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1922120 1930712 8592 0.4
RAM 60800 5488 -55312 -91.0
onoff-light x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1856520 1869792 13272 0.7
RAM 59968 5472 -54496 -90.9
onoff-light-bt x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 3322864 3334544 11680 0.4
RAM 5776 5776 0 0.0
speaker x86_64-unknown-linux-gnu infologs-optz-ltofat FLASH 1890896 1899896 9000 0.5
RAM 5472 5472 0 0.0

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