|
Some checks failed
Veza CI / Backend (Go) (push) Failing after 0s
Veza CI / Frontend (Web) (push) Failing after 0s
Veza CI / Rust (Stream Server) (push) Failing after 0s
Security Scan / Secret Scanning (gitleaks) (push) Failing after 0s
Veza CI / Notify on failure (push) Failing after 0s
Day-1 foundation for item B (async Stripe Connect reversal worker).
No worker code, no runtime enforcement yet — just the authoritative
state machine that day 2's code will route through. Before writing
the worker we want a single place where the legal transitions are
defined and tested, so the worker's behavior can be argued against
the matrix rather than implicitly codified across call sites.
transfer_transitions.go:
* SellerTransferStatus constants (Pending, Completed, Failed,
ReversalPending [new], Reversed [new], PermanentlyFailed).
* AllowedTransferTransitions map: pending → {completed, failed};
completed → {reversal_pending}; failed → {completed,
permanently_failed}; reversal_pending → {reversed,
permanently_failed}; reversed and permanently_failed as dead ends.
* CanTransitionTransferStatus(from, to) — same-state always OK
(idempotent bumps of retry_count / next_retry_at); unknown from
fails conservatively (typos in call sites become visible).
transfer_transitions_test.go:
* TestTransferStateTransitions iterates the full 6×6 matrix (36
pairs) and asserts every pair against the expected outcome.
* TestTransferStateTransitions_TerminalStatesHaveNoOutgoing
double-locks Reversed + PermanentlyFailed as dead ends at the
map level (not just at the caller level).
* TestTransferStateTransitions_MatrixKeysAreAccountedFor keeps the
canonical status list in sync with the map; a new status added
to one but not the other fails the test.
* TestCanTransitionTransferStatus_UnknownFromIsConservative
documents the "unknown from → always false" policy so a future
reader sees the intent.
Migration 982 adds a partial composite index on (status,
next_retry_at) WHERE status='reversal_pending', sibling to the
existing idx_seller_transfers_retry (scoped to failed). Two parallel
partial indexes cost less than widening the existing one (which
would need a table-level lock) and keep the worker query planner-
friendly.
Day 2 routes processSellerTransfers, TransferRetryWorker,
reverseSellerAccounting, admin_transfer_handler through
CanTransitionTransferStatus at every Status mutation, and writes
StripeReversalWorker. Day 3 exercises the end-to-end flow
(refund → reversal_pending → worker → reversed) in a smoke probe.
Checkpoint: ping user at end of day 1 before day 2 per discipline
agreed upfront.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|---|---|---|
| .. | ||
| 076_create_gear_items_down.sql | ||
| 077_create_live_streams_down.sql | ||
| 078_add_missing_indexes_down.sql | ||
| 082_create_api_keys_down.sql | ||
| 125_follow_counts_triggers_down.sql | ||
| 129_playlist_editorial_down.sql | ||
| 132_quiet_hours_down.sql | ||
| 133_notification_grouping_down.sql | ||
| 134_weekly_digest_prefs_down.sql | ||
| 900_triggers_and_functions_down.sql | ||
| 910_create_audit_logs_down.sql | ||
| 920_add_performance_indexes_down.sql | ||
| 930_add_missing_foreign_keys_down.sql | ||
| 931_add_refresh_tokens_updated_at_down.sql | ||
| 940_performance_indexes_v0951_down.sql | ||
| 941_notification_prefs_defaults_v0105_down.sql | ||
| 942_create_co_listening_sessions_down.sql | ||
| 943_create_track_stems_down.sql | ||
| 944_create_data_exports_down.sql | ||
| 945_creator_analytics_v0110_down.sql | ||
| 946_advanced_analytics_v0111_down.sql | ||
| 947_moderation_advanced_v0112_down.sql | ||
| 948_marketplace_complete_v0120_down.sql | ||
| 949_subscription_plans_v0121_down.sql | ||
| 950_distribution_platforms_v0122_down.sql | ||
| 951_education_courses_v0123_down.sql | ||
| 960_performance_indexes_v0124_down.sql | ||
| 970_password_login_history_v0130_down.sql | ||
| 971_security_advanced_v0133_down.sql | ||
| 972_seller_kyc_v0135_down.sql | ||
| 973_support_tickets_v0135_down.sql | ||
| 980_void_unpaid_subscriptions_down.sql | ||
| 981_seller_transfers_stripe_reversal_id_down.sql | ||
| 982_seller_transfers_reversal_pending_index_down.sql | ||