Skip to content

feat: source-level inventory reservations behind a feature flag - #6

Merged
jeanmarcos-dev merged 7 commits into
dist-2.4.9from
feat/source-level-reservations
Jul 12, 2026
Merged

feat: source-level inventory reservations behind a feature flag#6
jeanmarcos-dev merged 7 commits into
dist-2.4.9from
feat/source-level-reservations

Conversation

@jeanmarcos-dev

Copy link
Copy Markdown
Owner

Summary

Adds opt-in source-level reservations (global flag cataloginventory/source_reservations/enabled, default off). When enabled, each sales reservation is split into one row per source, allocated across the enabled sources of the stock in priority order, so reservations affect the salable quantity of every stock sharing the source — closing the cross-stock oversell gap.

  • Schema: nullable source_code + object_increment_id on inventory_reservation with covering indexes; the ledger stays append-only and the write path keeps its single insertArray.
  • All six sales-event flows are covered through a router on the single PlaceReservationsForSalesEventInterface preference; the legacy implementation is untouched and remains the flag-off path.
  • Compensations (shipment, cancellation, credit memo, failed placement) are distributed against the outstanding per-source balance of the order, so they always land on the sources the demand was allocated to, regardless of which source ships.
  • Runtime readers and the stock indexer aggregate stock-scoped rows (NULL source) plus rows of every enabled source linked to the stock; toggling the flag requires a full inventory reindex.
  • Unconditional fixes: reservation cleanup now groups its zero-balance check by source, and the SKU-list reservations cache no longer casts a null stock id to 0 on clean.

Validation

  • 84 unit tests green; phpcs (Magento2) and phpmd clean on every touched file.
  • Live-environment stress: 1040 concurrent reservation ops with zero errors and zero unbalanced (order, source) groups; dual readers match legacy performance at 200k reservation rows; 48 concurrent real checkouts + mass cancellation fully balanced per source.
  • End-to-end suite (24 checks): split on placement, cross-stock salability at runtime and index time, ship-from-alternate-source compensation, partial and multiple shipments, cancel, credit memo, flag-off byte-identical behavior, mid-flight toggle.

@jeanmarcos-dev
jeanmarcos-dev force-pushed the feat/source-level-reservations branch from 791ea9a to 88e45be Compare July 12, 2026 17:49
@jeanmarcos-dev
jeanmarcos-dev merged commit 88e45be into dist-2.4.9 Jul 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant