Skip to content

feat(proposals): atomic proposal acceptance and contract creation - #269

Open
smithd2423-beep wants to merge 2 commits into
Lumina-eX:mainfrom
smithd2423-beep:feat/217-proposal-acceptance
Open

smithd2423-beep wants to merge 2 commits into
Lumina-eX:mainfrom
smithd2423-beep:feat/217-proposal-acceptance

Conversation

@smithd2423-beep

Copy link
Copy Markdown

Closes #217

What changed

  • Accepting a proposal now runs as ONE SQL statement (data-modifying CTEs): proposal -> accepted, contract (status pending_funding, escrow unfunded), milestones from the proposal breakdown, and audit rows. Any failure rolls back everything.
  • Migration 012: contracts.proposal_id (UNIQUE) for traceability; partial unique index so only one proposal per project can be accepted; proposal_acceptance_audit_logs (proposal_accepted, contract_created, escrow_initialized, with actor and timestamp).
  • Existing PATCH /api/proposals/[id] already restricts status changes to the project's client; a concurrent double-accept returns 409.

Why

Issue #217 acceptance criteria: atomicity, one accepted proposal per project, proposal->contract link, status updates, rollback, audit trail.

Technical considerations

  • The Neon HTTP driver cannot hold a transaction across calls, so a single CTE statement is used for atomicity.
  • escrow_status has no pending_funding value; 'unfunded' is used as the Pending Funding state, and contract_status is pending_funding. No escrow logic changed.
  • Tests: tests/api/proposal-acceptance.test.ts

@drips-wave

drips-wave Bot commented Nov 19, 2026

Copy link
Copy Markdown

@smithd2423-beep Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@smithd2423-beep
smithd2423-beep marked this pull request as ready for review November 19, 2026 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Proposal Acceptance & Contract Creation Service

1 participant