Skip to content

fix(proxy): return implementing modules in the system's module order (PPT-2816) - #172

Merged
stakach merged 2 commits into
masterfrom
PPT-2816-implementing-order
Sep 30, 2026
Merged

stakach merged 2 commits into
masterfrom
PPT-2816-implementing-order

Conversation

@camreeves

Copy link
Copy Markdown
Contributor

What

system.implementing(interface) walked the redis hash that maps a system's module names to ids and returned modules in that hash's order. The hash has no defined order and core rewrites it on every system update. On HIO UAT on 24 Sep two overlapping updates of one system left it with the Calendar module ahead of the mailers, and every driver that takes the first Mailer implementer (fourteen of them) sent through Calendar, while the Template Mailer, which took the second, forwarded to itself until core was OOM killed.

DriverModel::ControlSystem now carries the system's modules list, which core already includes in the system payload, and implementing sorts its results by position in that list. Modules not on the list follow in name and index order. all(name) is sorted by index for the same reason. The first result is now the module an administrator listed first on the system, whatever order the hash is in.

For a remote system config is fetched once per proxy, the same request system.name and friends already make.

Testing

  • New case in spec/drivers_proxy_spec.cr: the hash is written in one order, the system lists another, and implementing follows the system.
  • Full suite: 116 examples, 0 failures, 1 pending, against a local redis.

Related

  • PlaceOS/drivers #635: the Template Mailer never forwards to itself.
  • PlaceOS/core: mapping writes for one system are serialised.

PPT-2816

system.implementing(interface) walked the redis hash that maps module
names to ids and returned modules in that hash's order. The hash has no
defined order, and core rewrites it on every system update, so two
overlapping updates left it in an arbitrary order. Drivers that take
the first or second implementer (the mailers do) then picked the wrong
module: on HIO UAT the visitor mailer sent through the Calendar module
and the Template Mailer forwarded to itself.

The system model now carries its module id list and implementing sorts
by it, so the first result is the module listed first on the system.
Modules not on the list follow in name and index order. all(name) is
sorted by index for the same reason.

PPT-2816
@camreeves
camreeves marked this pull request as ready for review September 28, 2026 06:50
@camreeves
camreeves requested a review from stakach September 28, 2026 06:50
@camreeves camreeves self-assigned this Sep 29, 2026
@stakach
stakach merged commit aad8ed7 into master Sep 30, 2026
2 checks passed
@stakach
stakach deleted the PPT-2816-implementing-order branch September 30, 2026 05:49
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.

2 participants