Skip to content

Fix CPM hallucination: pricing_type enum + quote validation#7

Open
atc964 wants to merge 2 commits intomainfrom
feature/cpm-hallucination-fix
Open

Fix CPM hallucination: pricing_type enum + quote validation#7
atc964 wants to merge 2 commits intomainfrom
feature/cpm-hallucination-fix

Conversation

@atc964
Copy link
Copy Markdown
Collaborator

@atc964 atc964 commented Mar 31, 2026

Summary

Seller-side fix for CPM hallucination. Two layers:

  • Layer 1 (pricing_type enum): Added PricingType enum (fixed/floor/on_request) to ProductDefinition, Package, QuotePricing, and Pricing models. Made pricing fields Optional when on_request. Defaults to fixed for backward compatibility.
  • Layer 4 (quote validation): Added QuoteHistoryStore that records quotes when issued and cross-references buyer-submitted CPMs against quote history. Proposals with unverified pricing are flagged (pricing_verified=false), not blocked. 1% tolerance for price matching.

Test Results

  • Layer 1: 638 passed (2 pre-existing failures), 18 new tests
  • Layer 4: 648 passed (2 pre-existing failures), 10 new tests
  • Both layers Quinn VERIFIED independently
  • Cross-repo smoke test: 6/6 scenarios PASS

Beads

  • Epic: ar-rrgw
  • ar-7rgy (Layer 1), ar-hm9l (Layer 4)

Companion PR

Buyer-side fix (remove fallbacks, pricing provenance, LLM guardrails) in separate PR on ad_buyer_system.

🤖 Generated with Claude Code

atc964 and others added 2 commits March 31, 2026 12:53
Sellers can now express whether a price is fixed, a floor for
negotiation, or unavailable (rate on request). This is the
foundation for preventing buyer agent CPM hallucination --
when pricing_type=on_request, pricing fields are None and
buyer agents must negotiate rather than fabricate numbers.

Changes:
- New models/pricing_type.py with PricingType(fixed|floor|on_request)
- ProductDefinition: add pricing_type, make base_cpm/floor_cpm Optional
- Package: add pricing_type, make base_price/floor_price Optional
- QuotePricing: add pricing_type, make base_cpm Optional
- Pricing (core): add pricing_type
- All default to FIXED for backward compatibility
- 18 new tests covering all models and backward compat

bead: ar-7rgy

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Records every quote the seller issues to quote_history storage and
cross-references incoming buyer proposals against that history. Proposals
with CPMs that don't match any active quote are flagged as
pricing_verified=false (not rejected — flagged for review).

- QuoteHistoryStore: record/find/verify quotes with 1% tolerance
- create_quote endpoint: persists to quote_history on issue
- submit_proposal endpoint: runs pricing verification, returns result
- ProposalResponse: new pricing_verified + pricing_verification_reason
- ProposalEvaluation: new pricing_verified field
- 10 new tests (9 unit + 1 integration-level)

bead: ar-hm9l

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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