Deal confidence - #8
Open
Bhavesh114 wants to merge 3 commits into
Open
Conversation
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.
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
Out of scope
Vs calculator, agent confirmation portal, automatic analysis on show booking, expense aggregation. All discussed in the memo.
How to test
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

