DAO refer_to_resolution is validated against an unlocked row: a decide can commit a referral to a resolution withdrawn mid-flight
Report
Summary. portal.decide runs under the proposal's row lock, but the resolution it names is read with a plain SELECT and never locked or re-read. A concurrent withdraw by the resolution's proposer can commit in between, and the decide then commits anyway: the proposal ends decided with a recorded referral to a withdrawn resolution, contradicting the function's own stated rule.
Documented rule. dao/services/portal.py:370 _decision_resolution docstring: "A referral names one that is open or passed, an adoption or follow-up one that has passed." Withdrawal is the proposer's right while a resolution is open (dao/services/resolutions.py:227), and refer_to_resolution is exactly the decision that may name an open resolution - the only decision type exposed to this race (adopt/decline require passed, and a passed resolution cannot be withdrawn).
Code path. dao/services/portal.py:413 decide() -> :370 _decision_resolution() for referrals - plain select via resolutions.get(db, res_id) with no lock=True (contrast resolutions.py:248, where the same getter takes with_for_update() when asked, and portal.py:126, where proposals are loaded with_for_update()). dao/api/members.py:53 withdraw_resolution locks and mutates the resolution in its own transaction; nothing orders it against an in-flight decide. Affected code is at dao HEAD 2efbfee.
Reproduction (executed). Two real DB sessions, real route handlers; the decide is paused immediately after _decision_resolution has read the resolution as open, the withdraw commits, then the decide resumes. Output: "T2 withdraw committed first: resolution status now 'withdrawn'"; "T1 decide then committed: proposal status='decided'" with the referral naming that resolution. Final state: resolution='withdrawn', proposal='decided' with a refer_to_resolution decision.
Impact. The published, signed decision record refers the matter to a resolution that no longer exists as a live instrument; the referral can never be acted on, and readers of the log see a decision whose premise was already false when it committed. Recovery exists - decide still permits one subsequent adopt/decline after an interim step - so this is record integrity, not a funds or safety issue.
Novelty. The HEAD sweep's row locks cover the proposal, resolution-signing, and session paths; no TAKEN entry covers the decide path reading a different row (the named resolution) unlocked. Not a re-report of XE-4591 or the session row-lock fix.
Thread
Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the first verifiable submission, so this one closes as a duplicate. If you believe it is a different bug, file a new report that links https://bounty.xe.network/XE-13152 and says what differs; it is read like any other.