fix(intent): a settlement follows a re-filed payment, and a delayed create event can no longer shrink it - #6873
Merged
Merged
Conversation
…reate event can no longer shrink it (#6864, #6865) Two residues of #6846, found in its review: - A corrected MATCH column - the payment re-filed under another Customer - was invisible to the amount-based recompute (pot - allocated == 0), so the junction rows kept paying the OLD counterparty's invoices forever. The payment's match columns are now grouping keys, so its DAO publishes "-rekeyed" when one moves, and a third settlement listener releases everything and re-allocates from the STORE - both re-key notices run the same store-driven recompute, so their delivery order cannot matter and a redelivery converges. Emitted only for a LOCAL payment: a cross-model payment's DAO belongs to the owner model, and a projection has no repository to re-read - absent rather than silently dead. Closes #6864. - The create handler no longer releases. A create event is the FIRST word about a payment - it has nothing to take back - so a negative pot there can only be a DELAYED create racing a correction the updated handler already allocated, and releasing on the stale payload transiently undid the correction. The updated handler owns every shrink. Closes #6865. Also corrects the module guide's glue-collection note, which still cited the generateUtils.js twin removed by #6707. Covered by GlueSettlementRekeyTest (the third listener, and its deliberate absence for a cross-model payment), EdmIntentGeneratorTest (the match columns as the payment's grouping keys), and IntentEngineIT's settlement emission block (the store-driven re-key recompute, the release-all, and that the create handler carries no release). 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.
Closes #6864 and #6865 — the two settlement residues of #6846's review.
match:columns become grouping keys, so its DAO publishes-rekeyedwhen the counterparty is corrected, and a third settlement listener (<Name>OnPaymentRekeyed) releases the whole allocation and re-allocates from the store — both re-key notices (previous and written row) run the same store-driven recompute, so delivery order cannot matter. Local payments only (a cross-model payment's DAO belongs to the owner model; a projection has no repository to re-read) — the listener is deliberately absent there rather than silently dead.Verified:
GlueSettlementRekeyTest,EdmIntentGeneratorTest(+51 total in the edm suite), engine-intent unit suite,IntentEngineIT56/56 (extended settlement block),IntentEmissionCoverageIT.🤖 Generated with Claude Code