Skip to content

Deal confidence - #8

Open
Bhavesh114 wants to merge 3 commits into
samay-cbh:mainfrom
Bhavesh114:bhavesh-singhal-deal-confidence
Open

Deal confidence#8
Bhavesh114 wants to merge 3 commits into
samay-cbh:mainfrom
Bhavesh114:bhavesh-singhal-deal-confidence

Conversation

@Bhavesh114

@Bhavesh114 Bhavesh114 commented May 17, 2026

Copy link
Copy Markdown

TL;DR
Slice: Upstream deal ambiguity detection (the "Wednesday move").
Adds an AI pass over a show's deal_notes_freetext that extracts structured terms, detects conflicts between prose and the database's structured fields, and flags ambiguities before they become 2am settlement disputes.
Introduces the codebase's first API routes, first LLM integration, and surfaces latent data integrity bugs on deals previously assumed clean.

Why this slice
Per the case study brief and the four user interviews:
Disputes are upstream, not downstream. Sarah Kim (WME): "Almost always rooted in a deal-term ambiguity, sometimes in a math error."
The product UI already labels deal_notes_freetext as "what Mariana actually trusts" — implicit admission that the structured fields are unreliable.
Marcus Holland (GM) names the cost: "We're paying a tax on every poorly-written deal email we ever signed."
82% of customers abandon the in-app settlement tool — symptom of the structured deal model not matching reality.
Building the missing Vs calculator first would produce confident wrong math on ambiguous terms — worse than honest no-math. Confirm the deal first, then compute.

What's in here
Schema: new deal_clarifications table; lastAnalyzedAt + extractionConfidence on deals
API: POST /api/deals/[id]/analyze (first API route in the codebase) and PATCH /api/clarifications/[id]
LLM: Anthropic SDK + claude-sonnet-4-6. Three-job system prompt (EXTRACT → COMPARE → FLAG) with convention rules and a severity rubric
UI: on the show detail page, with severity-sorted flags, a conflict comparison strip for prose-vs-structured divergence, and inline dismiss/resolve

Known limitations

  1. Resolve doesn't write back to the structured field. Intentionally deferred — Resolve is intent-ambiguous; one-click write-back risks silent corruption. Sprint 3 ships bidirectional Resolve (Use prose / Use structured).
  2. Duplicate flags on re-analysis — consequence of the above.

Out of scope
Vs calculator, agent confirmation portal, automatic analysis on show booking, expense aggregation. All discussed in the memo.

How to test

git checkout bhavesh-singhal-deal-confidence
npm install && echo "ANTHROPIC_API_KEY=<key>" > .env.local
npm run db:reset && npm run dev

Then:
/shows/show_0001 → expect HIGH conflict on deal_type (prose = Vs, DB = percentage_of_net)
/shows/show_0007 → expect HIGH conflict on bonuses[0].threshold ($11k structured vs $6k prose)

UI
Screenshot 2026-05-17 at 10 25 05 AM
Screenshot 2026-05-17 at 10 25 56 AM

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.

1 participant