Repository navigation
Live aggregation stamps a strong-typed aggregate id (#426) - #428
Merged
Merged
Conversation
AggregateIdentity.TrySetIdentity backfills the stream id onto an aggregate whose Create did not set it, as Marten and Polecat do. It assigned only a value the identity member could hold as-is, and a raw Guid is never a KilnId, so a strong-typed id was skipped and the aggregate came back with a default id from live aggregation, FetchForWriting, FetchManyForWriting and ProjectLatest. The fold was right and the identity was not, silently. Not AOT-specific: it reproduced under the JIT. It now wraps the stream id through StrongTypedId.Wrap when the member is a wrapper around the stream id's own type. A Guid is never turned into a string-backed id or the reverse, the rule FetchForWriting<T, TId> refuses by. strong_typed_aggregate_identity fails 5 of 7 against the old backfill. The inline snapshot never had the bug (it goes through the projection's identity setter), and that test pins it. The AOT smoke asserts both strong-typed aggregates' ids natively. Closes #426 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
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.
Closes #426.
The bug.
AggregateIdentity.TrySetIdentitybackfills the stream id onto an aggregate whoseCreatedidn't set one, as Marten and Polecat do. It only assigned a value the identity member could hold as-is, and a rawGuidis never aKilnId. So a strong-typed id was skipped, and the aggregate came back with a defaultIdfrom live aggregation,FetchForWriting(by raw id and by wrapper),FetchManyForWritingandProjectLatest. The fold was correct; only the identity was wrong, with no error. It isn't AOT-specific: it reproduced under the JIT on 2.80.1.The fix. When the member is a strong-typed wrapper around the stream id's own type, the id is wrapped through
StrongTypedId.Wrapand then assigned. AGuidis never turned into a string-backed id or the reverse, the same ruleFetchForWriting<T, TId>refuses by.Verification.
strong_typed_aggregate_identitycovers each of those paths plus a string-backed wrapper; 5 of its 7 tests fail against the old backfill. The inline snapshot never had the bug (it goes through the projection's identity setter), and a test pins that, since the issue couldn't say either way.check_scoreboard.pyagrees for both TFMs; leak check clean.🤖 Generated with Claude Code