feat(yes-auth): rebuild principals mirror rows on resource-access Restored events#30
Merged
Merged
Conversation
…tored events The On...Removed handlers hard-delete mirror rows, so a later ...Restored event found no state to rebuild from. The new On...Restored handlers replay the aggregate's stream through the existing per-field event handlers (lifecycle events excluded) to reconstruct the row, and the Restored event types are registered in Yes::Auth::Subscriptions. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…spec requires Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The
On...Removedhandlers hard-delete theauth_principals_*mirror rows. When anAuthorization::{Write,Read}ResourceAccessRestoredevent arrives later, there is no state left to rebuild the row from — the event carries no snapshot by design.This adds
On{Write,Read}ResourceAccessRestoredhandlers that replay the aggregate's stream through the existing per-field event handlers to reconstruct the row. Lifecycle events are excluded from the replay: aRemovedwould delete (and freeze) the row mid-replay, aRestoredwould recurse. The two event types are registered inYes::Auth::Subscriptions.The row itself is recreated blank by the builder's regular
find_or_createread-model resolution before the handler runs; the replay fills the attributes back in.Testing
yes-auth: 81 examples, 0 failures (includes new RestoreReplay integration spec + handler specs)