Repository navigation
S5a-es: draw Elm purchases of batch offers from the live batch (fail-soft) - #78
Merged
Merged
Conversation
… batch Plan §9 (D2). Inside transferSale's existing transaction, after the replay guard: a `batches` offer calls the backend's frozen public.shop_draw_from_batch(product, units, block time) in a savepoint with SET LOCAL lock_timeout = '2s' (the caller's timeout is restored, since SET LOCAL outlives a released savepoint). Deadlock / serialization / lock timeouts retry 3× 50 ms apart; anything else, or a 4th failure, rolls back only the savepoint and records the order unassigned with draw_outcome = 'error' — the block commits and the indexer keeps running. batch_id and draw_outcome are written only for batch offers; every other insert is unchanged. A startup check (and again after every draw error) logs "S5 draw function missing" to stderr when the function or order_items.draw_outcome is absent. The product lookup no longer filters is_deleted, and a product that truly doesn't exist is a ResolveError (skip, re-indexable) instead of a crash loop. First test runner (mocha): a scratch DB built from written_columns.json (byte-identical to the backend's) plus the migration's definitions; 15 cases incl. window edges in São Paulo and Costa Rica, a forced deadlock, a held product lock, the function dropped, replay, and "transferSale writes only manifest columns". Green on Node 16.20.2 and 26. CI workflow added (GitHub Actions is out of credits, so it won't run yet). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017TeHsQCwWCBJzuob6cYEPo
…. tables) The backend's S5a-core migration now refuses a zero or negative quantity and schema-qualifies its tables; the fixture copy follows, regenerated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017TeHsQCwWCBJzuob6cYEPo
lucca65
marked this pull request as ready for review
October 17, 2026 09:38
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.
Plan §9 (D2). The backend half (the frozen
public.shop_draw_from_batchandorder_items.draw_outcome) is cambiatus/backend#525. Deploy only after that backend is live.transferSale: abatchesoffer draws at block time, in a savepoint withlock_timeout = '2s'. Deadlock, serialization and lock-timeout errors retry ×3; anything else records the order unassigned (draw_outcome = 'error') and the block commits, so the indexer keeps running. Every other offer's insert is unchanged.S5 draw function missingto stderr when the function or the column is absent.ResolveError(skip, re-indexable) instead of crash-looping.written_columns.json, byte-identical to the backend's..github/workflows/test.ymlis added; it won't run until GitHub Actions has credits.🤖 Generated with Claude Code
https://claude.ai/code/session_017TeHsQCwWCBJzuob6cYEPo