Add approval workflows & multi-signature governance (#314) - #381
Merged
robertocarlous merged 5 commits intoAug 27, 2026
Merged
Conversation
High-value withdrawals and deposits can now be gated behind an ApprovalPolicy requiring minApprovers independent co-signers, with expiry, cancellation, and a full audit trail via ApprovalRequest/Approval. guardOperation is called from inside executeDeposit/executeWithdraw (src/controllers/transaction-controller.ts), so the HTTP routes and the recurring-deposit job are covered by a single interception point. All status transitions after PENDING are conditional updateManys, so concurrent approvals can never double-execute. See docs/APPROVALS.md for the full design, including what's deliberately out of scope for v1 (agent-loop rebalances, referral payouts) and why.
…l-workflows # Conflicts: # prisma/schema.prisma # src/controllers/transaction-controller.ts # src/index.ts # src/jobs/recurringDeposits.ts # src/routes/admin.ts
… migration rollback - executeWithdraw now publishes through the new user-event bridge (publishUserEvent) instead of the removed dispatchWebhookEvent, matching executeDeposit — the merge had left a call to an import that no longer exists. - EVENT_TYPE_TOPIC is exhaustive over UserEventType by design (fails the build otherwise); the 6 new approval.* webhook events needed an entry — routed to the 'transactions' topic alongside recurring_deposit.*. - Added the required rollback.sql for the approval_workflows migration. - Updated the recurring-deposit approval test to mock publishUserEvent instead of the now-removed dispatchWebhookEvent.
…into feature/314-approval-workflows # Conflicts: # src/controllers/transaction-controller.ts # src/jobs/recurringDeposits.ts # src/routes/admin.ts
8 tasks
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
ApprovalPolicyrequiringminApproversindependent co-signers, with a fullPENDING → APPROVED → EXECUTED(orREJECTED/EXPIRED/CANCELLED) audit trail.guardOperationis called from insideexecuteDeposit/executeWithdraw(src/controllers/transaction-controller.ts), so the withdraw/deposit HTTP routes and the recurring-deposit job are all covered by one interception point — no per-caller duplication.SubAccountgraph (the policy owner plus their ACTIVE children), matching the issue's "parent + child, or two children" co-sign example with no new approver-list concept.PENDINGis a conditionalupdateMany, never read-then-write, so two concurrent approvals can't double-execute.GET/POST /api/v1/approvals,/api/v1/approval-policies, admin cancel underapprovals:write), and 6 new webhook events.docs/APPROVALS.md): the agent rebalance loop (moves funds protocol-to-protocol inside the vault, no egress) and referral payouts (platform credits to the user, not the user moving funds out) — neither fits the delegated-authority threat model this issue targets.Test plan
npx tsc --noEmitcleannpx eslintclean on all new/touched filesguardOperation,decide's approve/reject/cancel/race-safety paths, the route layer, and theexecuteDeposit/executeWithdrawgate wiring)prisma migrate reset+migrate dev, no drift)highValueThresholdpolicy, hitPOST /withdrawabove it, confirm202 PENDING_APPROVAL, approve from a second user, confirm the withdrawal executes withexecutedTxIdlinkagecloses #314