Repository navigation
fix(free): journal compare-and-set on prior state (#296) - #300
Merged
Merged
Conversation
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.
Authorization
Founder GO: #296 comment 2026-10-15T13:47:45Z (journal CAS only) + #294 superseding P0 GO. Scope is #296 only; no #295/#297, no version bump, no release.
Problem
Price_Apply_Journal::transition()updated by(plan_id, product_id)with no state predicate, so a stale/lock-free caller could demoteAPPLIEDand theapplied_at=IF(...NULL)expression cleared durable evidence.Change (narrow)
transition()takes required $expected prior state, validates the pair against a closed allowlist (PENDING->{PENDING,APPLYING,CONFLICT,FAILED,NEEDS_REVIEW},APPLYING->{APPLIED}; no transition out ofAPPLIED, noPENDING->APPLIEDskip), and addsAND state=%sto the UPDATE predicate. Zero affected rows throwsJOURNAL_MISMATCH.Woo_Price_Mutatorpass the state read under lock. Failure paths unchanged (throw -> rollback -> NEEDS_REVIEW, never intosave()).applied_atexpression, schema (v3), and existing semantics untouched.Tests
wordpress/tests/durable/journal-cas-unit.php:php wordpress/tests/durable/journal-cas-unit.php-> PASS 49/49 (happy path, stale-vs-APPLIED, legacy-shape defect control, duplicates, interleaving, invalid pairs, failure contract).durable/integration.php: appended real-engine stale/duplicate/skip/demotion cases (run in CI on MySQL+MariaDB).php -lclean,bash .github/ci/pr-fast.sh-> PR_FAST PASS.durable/run.sh, jobs/undo suites -> must go green in CI before merge.Maintainer
Please inspect diff + CI before merge. Do not merge until journal/jobs/undo workflows pass. Closes nothing automatically; reconciles #296 acceptance criteria.