package contribution projection: the resource write and the ledger record are not one transaction #1336

Open
opened 2026-10-27 13:39:59 +00:00 by sam · 0 comments
Owner

Found while reviewing archie-core-em7s.9 (package contribution projection, merged at 783c0cfc).

The projection writes the contribution into the org resource and THEN records the projection ledger, as two separate writes. A failure between them leaves a contributed entry with no ledger row, and a later Withdraw cannot see it -- so the contribution sits in the resource with nothing able to remove it.

Bounded (the Record is a local transaction and the window is small) but it is the non-atomic seam of an otherwise transactional path. Both writes go through the same postgres pool, so one transaction over the resource write and the ledger record closes it.

If the reverse order is simpler, check first that Withdraw is idempotent when a ledger row exists but the resource entry does not -- that is the failure the other order introduces.

Evidence: the lane's own residual-risk note; internal/domain/storepkg/contributions.go (project/withdraw), the ledger queries, and internal/app/controlplane/workflow_projector.go.


Imported from beads archie-core-gf3f · GitHub #1385 · type bug · priority P3 · created 2026-09-29

Found while reviewing archie-core-em7s.9 (package contribution projection, merged at 783c0cfc). The projection writes the contribution into the org resource and THEN records the projection ledger, as two separate writes. A failure between them leaves a contributed entry with no ledger row, and a later Withdraw cannot see it -- so the contribution sits in the resource with nothing able to remove it. Bounded (the Record is a local transaction and the window is small) but it is the non-atomic seam of an otherwise transactional path. Both writes go through the same postgres pool, so one transaction over the resource write and the ledger record closes it. If the reverse order is simpler, check first that Withdraw is idempotent when a ledger row exists but the resource entry does not -- that is the failure the other order introduces. Evidence: the lane's own residual-risk note; internal/domain/storepkg/contributions.go (project/withdraw), the ledger queries, and internal/app/controlplane/workflow_projector.go. --- _Imported from beads `archie-core-gf3f` · GitHub #1385 · type bug · priority P3 · created 2026-09-29_
sam added the lowbug labels 2026-10-27 13:39:59 +00:00
sam self-assigned this 2026-10-27 13:39:59 +00:00
sam added a new dependency 2026-10-27 13:42:22 +00:00
sam added the deferred label 2026-11-15 17:26:19 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: sam/archie#1336