You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(node): apply runtime group state only from committed state - #5070
JoinGroup, KeySetWrite, KeySetRemove and the Groups cluster commands changed the in-memory FabricGroups state of a fabric while the command ran: the key sets, the group→key set map, the endpoint map and the multicast address policy. JoinGroup also emitted the Groupcast auxiliary ACL entries, which AccessControlServer persists in its own transaction. All of this happened before the command's transaction committed. Some checks only run at commit, for example the GroupKeyMap length limit in a $Changing validation. When such a check or the storage write failed, the behavior state rolled back, but the runtime state did not. The client got an error and Membership did not list the group, yet the node kept decrypting and dispatching group messages for it, and the auxiliary ACL entry kept granting Operate until the next restart or membership change.
The entries this code manages now follow committed state only. A pre-check before JoinGroup's side effects would have covered only the GroupKeyMap limit and left every other commit failure with the same leak, so both servers apply their runtime state from a transaction participant's conclusion hook instead. Tx awaits that hook before commit() resolves, so the state is in place before the command response is sent.
GroupKeyManagementServer brings FabricGroups in line with the committed GroupKeySets, GroupKeyMap and GroupTable. It does nothing after a rollback. After a storage failure in commit phase two, where the new values are canonical, it still syncs. Each sync reads all its sources before it awaits anything, and syncs run one after another, so an older sync never overwrites a newer commit. A sync removes only entries that an earlier sync installed, so entries that other code writes to FabricGroups directly, such as those of a controller fabric, stay. It records what it is about to install before installing, so a sync that fails halfway leaves nothing that a later sync cannot remove. A fabric whose sync fails is logged and skipped, and the other fabrics still sync. Unchanged key sets stay installed, so their derived keys and the message reception state are kept, and new entries come before removals, so a group never maps to a key set the fabric does not hold.
GroupcastServer gives that sync the multicast policies of its committed membership. It emits the auxiliary ACL entries from its own participant, which reads the membership when the transaction ends, whatever the outcome. A rolled back change therefore never reaches the access control list, a storage failure in commit phase two still does although no change event is emitted, and a transaction that ends late never restores entries that a newer one removed.
KeySetRead now reads key sets other than the IPK from the transaction's state, like KeySetReadAllIndices, so a read after KeySetWrite or KeySetRemove in the same transaction sees that change.
KeySetWrite used to install the key set in the handler, which threw for a key set whose first epoch key the request disables with the maximum start time. Because the install now happens after the commit, where nobody would see that failure, KeySetWrite validates the key set after normalizing the maximum start time and refuses such a request with INVALID_COMMAND. A groupKeySets validation refuses a key set without EpochKey0 or EpochStartTime0 from a local state write too, so no key set reaches the state that the sync can never install. The sync copies its sources with deepCopy, which turned an ArrayBuffer into an empty object; it now copies the bytes, so an epoch key given as an ArrayBuffer installs correctly.
Fabric removal waited for a stateChanged event after sanitizing each fabric-scoped attribute, with a 5 s timeout. When a reactor had already removed the entries, the write changed nothing, the event never fired and the removal waited the full timeout. setStateOf resolves only after the commit and its change events, so the wait is removed.
JoinGroup, KeySetWrite, KeySetRemove and the Groups cluster changed the
in-memory FabricGroups state (key sets, group key map, endpoint map,
multicast policy) and emitted Groupcast auxiliary ACL entries while the
command ran, before the transaction committed. When the commit failed,
for example because the GroupKeyMap limit was exceeded, the behavior
state rolled back but the node kept decrypting and dispatching group
messages for the failed group, and the auxiliary ACL entry stayed.
GroupKeyManagementServer now brings FabricGroups in line with the
committed state in a transaction conclusion hook, which runs only after
a successful commit and before the command response. GroupcastServer
supplies multicast policies and emits auxiliary ACL entries from its
committed membership.
Fabric removal no longer waits five seconds for a state change event
that never fires when a reactor already cleaned up the attribute.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.
Queue this pull request once it meets the queue conditions
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Active findings identify inconsistent state reads that can reject group messages, notification-order dependence that selects the wrong group address, and validation that allows an unusable key set to persist while reporting success.
This PR moves runtime group updates behind transaction commit so failed commands do not leave active group keys, endpoints, multicast policies, or auxiliary access grants.
Changes:
Synchronize runtime group state from committed behavior state while preserving unchanged keys.
Remove the redundant fabric-cleanup event wait.
Add regression tests for rollback safety and synchronization ordering.
… snapshot
The FabricGroups sync now removes only entries an earlier sync installed,
so key sets, group key maps, endpoints and multicast policies that other
code writes directly, such as those of a controller fabric, stay. Each
sync reads GroupKeySets, GroupKeyMap, GroupTable and the multicast
policies once before it awaits anything, so it never maps a group to a
key set it has not installed.
GroupKeySets changes trigger the sync through their own $Changing event,
so a local state write reaches FabricGroups too. Groupcast reads the
multicast policies from its committed Membership instead of a cache that
depended on notification order, and emits auxiliary ACL entries only
from committed membership.
KeySetWrite validates the key set after disabling epoch keys with the
maximum start time, so a request whose first epoch key is disabled is
refused instead of being stored as a key set that cannot be installed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Post-commit notifications can arrive out of order and restore an Operate ACL entry that committed membership no longer permits, requiring a current-state read and a regression test.
…ship
Post-commit notifications run after the transaction released its locks,
so a newer commit can finish while an older membership change is still
being dispatched. Emitting the membership carried by that notification
could restore an auxiliary ACL entry the newer commit removed. The
reactor now reads the committed membership instead.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A storage failure in commit2 skips postCommit and therefore membership$Changed, even though the membership datasource has already made its new values canonical. A failed ConfigureAuxiliaryAcl({ useAuxiliaryAcl: false }) can therefore leave the provider and runtime ACL granting Operate while the current membership disables it. Refresh auxiliary ACLs from a transaction conclusion hook for canonical-state outcomes, including inconsistent, and add a storage-failure regression test.
If deriving a later key set rejects, earlier key sets and multicast policies are already installed, but their ownership is never recorded here. A later successful sync that removes those entries from committed state cannot clean them up because previous does not include them. Track successful installations incrementally, or undo partial installations on failure, so subsequent syncs can remove them.
keySetRead() still reads the runtime store, which is now updated only after the action finishes. Within one node.online() action, a read after keySetWrite() returns NOT_FOUND or the previous value, while a read after keySetRemove() still succeeds; keySetReadAllIndices() already reflects transaction state. Read nonzero key sets from the current behavior state, retaining the runtime lookup for the implicit IPK key set.
…action ends
GroupcastServer emits the auxiliary ACL entries from a transaction participant
that reads the committed membership when the transaction ends, so a storage
failure in commit phase two still updates the access control list.
The FabricGroups sync records the entries it is about to install before
installing them, skips a fabric whose sync fails, never removes the IPK key set
and drops ownership records of fabrics it no longer iterates. KeySetRead reads
key sets other than the IPK from the transaction state.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Key-installation failures can leave committed key removals unapplied while the command reports success, allowing messages encrypted with removed keys to remain accepted.
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 012c883 at the root: deepCopy now copies an ArrayBuffer with its bytes, so every caller benefits, not only this snapshot. A test writes an epoch key as an ArrayBuffer and checks that the installed key has the same bytes.
…sets without a first epoch key
deepCopy turned an ArrayBuffer into an empty object, so an epoch key passed as
an ArrayBuffer reached the FabricGroups sync without its bytes.
GroupKeyManagementServer refuses a groupKeySets write whose entry has no
EpochKey0 or EpochStartTime0, so a local state write cannot store a key set
that the sync can never install.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
ArrayBuffer equality ignores byte contents, which can suppress key-replacement detection and leave an old operational key active; the shared comparator needs byte-sensitive equality and a replacement regression test.
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 5f86405: isDeepEqual compares the bytes of two ArrayBuffers, like it handles Date, Map and Set. A test writes a key set twice with different ArrayBuffer epoch keys and checks that the second key is installed.
isDeepEqual treated every pair of ArrayBuffers as equal because they have no
own properties. The FabricGroups sync therefore kept the old key installed when
a local write replaced an epoch key given as an ArrayBuffer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because storage-failure and asynchronous ACL-revocation paths can leave group membership stale or permissions active after command completion.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JoinGroup, KeySetWrite, KeySetRemove and the Groups cluster commands changed the in-memory
FabricGroupsstate of a fabric while the command ran: the key sets, the group→key set map, the endpoint map and the multicast address policy. JoinGroup also emitted the Groupcast auxiliary ACL entries, which AccessControlServer persists in its own transaction. All of this happened before the command's transaction committed. Some checks only run at commit, for example the GroupKeyMap length limit in a$Changingvalidation. When such a check or the storage write failed, the behavior state rolled back, but the runtime state did not. The client got an error and Membership did not list the group, yet the node kept decrypting and dispatching group messages for it, and the auxiliary ACL entry kept granting Operate until the next restart or membership change.The entries this code manages now follow committed state only. A pre-check before JoinGroup's side effects would have covered only the GroupKeyMap limit and left every other commit failure with the same leak, so both servers apply their runtime state from a transaction participant's
conclusionhook instead.Txawaits that hook beforecommit()resolves, so the state is in place before the command response is sent.GroupKeyManagementServerbringsFabricGroupsin line with the committed GroupKeySets, GroupKeyMap and GroupTable. It does nothing after a rollback. After a storage failure in commit phase two, where the new values are canonical, it still syncs. Each sync reads all its sources before it awaits anything, and syncs run one after another, so an older sync never overwrites a newer commit. A sync removes only entries that an earlier sync installed, so entries that other code writes toFabricGroupsdirectly, such as those of a controller fabric, stay. It records what it is about to install before installing, so a sync that fails halfway leaves nothing that a later sync cannot remove. A fabric whose sync fails is logged and skipped, and the other fabrics still sync. Unchanged key sets stay installed, so their derived keys and the message reception state are kept, and new entries come before removals, so a group never maps to a key set the fabric does not hold.GroupcastServergives that sync the multicast policies of its committed membership. It emits the auxiliary ACL entries from its own participant, which reads the membership when the transaction ends, whatever the outcome. A rolled back change therefore never reaches the access control list, a storage failure in commit phase two still does although no change event is emitted, and a transaction that ends late never restores entries that a newer one removed.KeySetRead now reads key sets other than the IPK from the transaction's state, like KeySetReadAllIndices, so a read after KeySetWrite or KeySetRemove in the same transaction sees that change.
KeySetWrite used to install the key set in the handler, which threw for a key set whose first epoch key the request disables with the maximum start time. Because the install now happens after the commit, where nobody would see that failure, KeySetWrite validates the key set after normalizing the maximum start time and refuses such a request with INVALID_COMMAND. A
groupKeySetsvalidation refuses a key set without EpochKey0 or EpochStartTime0 from a local state write too, so no key set reaches the state that the sync can never install. The sync copies its sources withdeepCopy, which turned anArrayBufferinto an empty object; it now copies the bytes, so an epoch key given as anArrayBufferinstalls correctly.Fabric removal waited for a
stateChangedevent after sanitizing each fabric-scoped attribute, with a 5 s timeout. When a reactor had already removed the entries, the write changed nothing, the event never fired and the removal waited the full timeout.setStateOfresolves only after the commit and its change events, so the wait is removed.🤖 Generated with Claude Code