Skip to Content

← All archived runs

Run: fix-demo-reset-duplicate-proposal

run.md

Run: fix-demo-reset-duplicate-proposal

  • lane: bug
  • branch: claude/pipeline-demo-reset-dup-key-ape02u
  • pr: #827

lane/output/notes.md

Bug: fix-demo-reset-duplicate-proposal

  • observed: the demo reset aborts on the first quoting engagement carrying extraQuoteStates with E11000 duplicate key ... proposals index: tenantId_1_lead_1_createdBy_1, leaving the demo tenant purged and half-seeded · expected: the reset purges and re-seeds the whole storyline without colliding
  • cause: the seeder's quoting branch wrote a second proposal by the winning expert on the same lead — one per authored extra quote state — because quote.ts's global unique {lead, proposal} means each extra quote needs its own proposal. But proposal.ts holds a unique {tenantId, lead, createdBy} (one bid per expert per lead), so the winner's second proposal is a duplicate key. Both storylines author two such engagements (quote_draft, quote_rejected), so every reset failed. Nothing to do with leftover rows: the purge hard-deletes, and the collision is between two writes of the same run.
  • fix: packages/services/src/db/services/demo-data/index.ts — the extra quote's proposal now comes from a shortlisted expert who has not already bid. The rejected-bid loop holds one loser back per extra quote state (it already held one back), and those held-back bidders author the extra proposals, with a status matching the quote's fate — proposal_rejected for a rejected quote, proposal_submitted for one still in draft. That is also the shape the app produces: every submitted bid gets its own draft quote (expert-bid-proposal-flow), and rejecting a quote rejects its proposal (customer-quote-response), which is what sends the lead back round to another expert's bid. Running out of held-back bidders now stops rather than colliding, mirroring how extraInvoiceStates handles running out of milestones. storyline/active.test.ts gains the matching authoring guard (extra quote states live on quoting, at most two per engagement).
  • changelog: not user-visible (demo seed data only)