Dealops demo AI quote flow

Adds a Dealops 2 demo-only AI quote path that can create an approval-safe Yappatron quote from Salesforce context, packaged fallbacks, benchmark deals, and deterministic pricing rules.

Author: @yijunz166 PR: #6247 State: open Stack: Dealops 2 AI quoting Branch: dealops-demo-ai-quoting Files: 14 Diff: +2648 / -336 Validation: Mocha pass, diff-check pass, typecheck blocked upstream

What it adds

A hard-gated Dealops demo quote path for org 15aaa862-... and opportunity 006Dp00000Zf5HxIAJ.

It bypasses pre-flow term selection and generates a quote for the Yappatron AI demo scenario.

Server behavior

New dealopsDemoQuote.ts supplies SFDC fallback context, similar accounts, historical deals, list-price overrides, minimum-commitment math, and V3 approval preflight.

Pricing guardrails

Voice AI list price is forced to $0.20/min, stale L1 floors can be capped at list, and the minimum commitment becomes 100% usage - Enterprise Support.

UI polish

The modal streams demo-specific progress and the quote view shows Deal Thesis plus Usage Minimum reasoning in the AI header.

Demo gate
Salesforce context
Benchmarks
Rule validation
V3 approvals
Client UI

1. Why this exists

Problem today
  • The generic AI quote flow depends on modal-selected pricebook/currency terms.
  • The demo needs a fast, reliable Yappatron quote path that looks complete even when live SFDC context is sparse or unavailable.
  • The demo quote must not accidentally trigger V3 approvals.
PR strategy
  • Gate the special behavior to one Dealops org + one SFDC opportunity.
  • Use live Salesforce when possible, then fall back to packaged account, note, task, event, and transcript fixtures.
  • Generate a deterministic recommendation instead of relying on a generic LLM pass for the demo package.
$706k Committed first-year demo package described in fallback notes
3M Annual modeled Voice AI minutes
$45k/mo Usage minimum after Enterprise Support offset
0 Required V3 approval groups expected on happy path

2. What changes

Before

The AI quote modal always waited for pricebook and currency terms before starting the SSE quote stream.

Open modal Pick CPQ / currency Run generic pipeline
After

The specific Dealops demo org/opportunity skips term selection and posts an empty body to the existing AI quote stream.

Open Yappatron modal Detect demo gate Run demo pipeline
Area Files Meaningful change
Client modal AIQuoteModal.tsx
useAIQuoteStream.ts
Looks up organizationId, detects the demo org/opportunity, skips Configure Quote, and allows terms? on the stream request.
Demo pipeline dealopsDemoQuote.ts
orchestrator.ts
orchestratorStream.ts
Adds the demo-only context builders, comparable accounts/deals, deterministic recommendation, list-price overrides, progress pauses, and branch points in both normal and SSE orchestrators.
Rule validation validateAiRecommendationAgainstRules.ts Adds configurable minimum commitment formulas and optional capL1AtListPrice so list can win when L1 metadata is stale.
Finalize / approvals finalizeAiQuote.ts Runs V3 approval preflight before creating the demo quote, injects no-approval terms, and blocks quote creation if approvals are required.
Reasoning display AIReasoningTooltip.tsx
CategoryStep.tsx
Surfaces opportunityContext.dealOverview as Deal Thesis and minimumCommitmentReasoning as Usage Minimum.
Pricing spec/UI minimum minimumCommitmentTable.tsx
pricingSpec.json
Marks enterprise-support as a support offset for the demo org and changes Dealops onboarding minimum percentage from 70 to 100.
File-level diff map
apps/server/src/dealops2/aiQuoting/pipeline/dealopsDemoQuote.ts+1680
apps/server/src/dealops2/aiQuoting/pipeline/orchestratorStream.ts+382 / -205
apps/server/src/dealops2/aiQuoting/pipeline/validateAiRecommendationAgainstRules.ts+187 / -35
apps/server/src/dealops2/aiQuoting/pipeline/orchestrator.ts+87 / -52
apps/server/src/dealops2/aiQuoting/pipeline/finalizeAiQuote.ts+51 / -10
apps/client/src/dashboard/PricingFlowV2/components/AIReasoningTooltip.tsx+38 / -9

3. How it works

Demo detection

isDealopsDemoQuote(organizationId, opportunityId) accepts the 18-char and 15-char SFDC opportunity ID variants.

The gate is used in the modal, orchestrators, and finalization path.

Fallback context

Live SFDC fetch uses the org’s Ampersand Salesforce connection.

If that fails, the server logs a warning and builds packaged Yappatron account, notes, tasks, events, and Gong-like summaries.

Deterministic recommendation

The demo recommendation returns the fixed launch package: Voice AI, seats, platform access, implementation, Highway integration, and Enterprise Support.

Dealops demo minimum formula
monthly minimum = round up to $500 of max(0, usage monthly revenue × 1.0 − prorated Enterprise Support)

For the target scenario: 250,000 minutes × $0.20 = $50,000/mo; $60,000 support / 12 = $5,000/mo; result is $45,000/mo.

Price normalization
  • applyDealopsDemoListPriceOverrides() sets voice-ai-per-minute to 0.2.
  • capL1AtListPrice lets list price win when stale L1 is above list.
  • Validation still rejects prices below the effective L1 floor or above list.
No-approval finalization
  • Injects subscriptionTerms=12, paymentTerms=net_30, billingFrequency=annual, and autoRenewal=Yes.
  • Calls evaluateV3ForPrediction before quote creation.
  • Throws a formatted error if any approval group is required.

4. What it doesn't change

5. Validation

Passed

pnpm exec mocha --no-config --node-option import=tsx src/dealops2/aiQuoting/pipeline/__tests__/validateAiRecommendationAgainstRules.test.ts --timeout 10000 --exit

Passed

git diff --check origin/main...HEAD

Blocked

pnpm run typecheck is blocked by upstream src/trpc/router/v3Admin/getPreviewConfig.ts(36,31) on latest main.

Test area Coverage added
validateAiRecommendationAgainstRules.test.ts Demo minimum commitment formula, Enterprise Support offset, stale L1 above list, and updated ramp wording.
resolvePricebookFromTerms.test.ts Fallback to modal terms and row name when selector metadata is sparse; stricter missing currency/type cases.

6. Risks / rollback / open questions

Reviewer focus
Rollback shape

Fastest rollback is to disable the demo gate by changing or removing the org/opportunity constants, which returns the modal to the generic Configure Quote path. Full rollback is reverting the demo file plus the orchestrator/finalize branches.