Conversation
…racverse#1037) - create_plan: already had full atomic SQL transaction; remove stale placeholder comment - update_plan: already had bps validation + transactional beneficiary replace; remove stale comment - get_plans: already had owner/beneficiary filtering + on-the-fly yield via compute_projected_accrued_yield; remove stale comment - ping_plan: wrap last_ping update + new ping_logs INSERT in a single transaction so both succeed or both roll back atomically; the generated column inactivity_deadline_at (last_ping + grace_period_seconds) is kept in sync automatically by Postgres; remove stale placeholder comment - trigger_payout: enqueue a plan.settled webhook event via WebhookDispatcherService after the payout transaction commits (non-blocking, non-fatal on failure); remove stale placeholder comment All 53 unit tests pass.
ONEONUORA
approved these changes
Aug 23, 2026
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.
Summary
Closes #1037
This PR completes all five unimplemented database operations in
backend/src/api.rsthat were marked with// Contributors:placeholder comments.What was already implemented
After a thorough audit, three of the five handlers were fully implemented behind their placeholder comments and only needed the comments removed:
create_planplansthen INSERT per beneficiary, COMMIT, webhook enqueueupdate_planget_planscompute_projected_accrued_yield, Redis cache with timing headersWhat was genuinely missing and is now fixed
1.
ping_plan— atomic ping log insertion (line 1180)Before: The handler updated
plans.last_pingandplans.accrued_yieldwith a bareexecutecall, then returned. No audit record was ever written toping_logs.After:
UPDATE plansand the newINSERT INTO ping_logsare wrapped in a singleBEGIN/COMMITtransaction, so both succeed or both roll back atomically.ping_logsrow capturespinged_at(serverNOW()) andaccrued_yield_snapshot(the yield accumulated up to this ping), satisfying the audit-log requirement.inactivity_deadline_atis a generated column (to_timestamp(last_ping + grace_period_seconds)) so it is kept in sync by Postgres automatically wheneverlast_pingis updated — no extra write needed.2.
trigger_payout—plan.settledwebhook emission (line 1281)Before: After committing the payout transaction and invalidating the cache the handler returned immediately. No webhook was dispatched.
After:
WebhookDispatcherService::enqueue_eventis called with event type"plan.settled"and a JSON payload containingplan_id,owner,total_payout,status, andpayout_count.warn!and does not affect the HTTP response, keeping the payout itself fully atomic.Testing
cargo build --no-default-features— clean build, zero errors.cargo test --no-default-features --lib— 53/53 unit tests pass.