Skip to content

Fix CPM hallucination: pricing_type enum + quote validation#7

Merged
atc964 merged 3 commits into
mainfrom
feature/cpm-hallucination-fix
Jul 7, 2026
Merged

Fix CPM hallucination: pricing_type enum + quote validation#7
atc964 merged 3 commits into
mainfrom
feature/cpm-hallucination-fix

Conversation

@atc964

@atc964 atc964 commented Mar 31, 2026

Copy link
Copy Markdown
Collaborator

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 July 7, 2026 15:04
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>
@atc964
atc964 force-pushed the feature/cpm-hallucination-fix branch from fbcb03e to 6d271af Compare July 7, 2026 19:11
…actor after rebase

- models/__init__.py: sort import block (ruff I001)
- storage/quote_history.py: drop unused pydantic.Field import (ruff F401)
- test_quote_endpoints.py: patch _get_static_product_catalog instead of
  the removed ad_seller.flows.ProductSetupFlow, matching sibling tests

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@atc964
atc964 merged commit 85a27e3 into main Jul 7, 2026
2 checks passed
@atc964
atc964 deleted the feature/cpm-hallucination-fix branch July 7, 2026 19:47
atc964 added a commit that referenced this pull request Jul 7, 2026
…, PR #7) (#27)

Co-authored-by: Claude Opus 4.8 (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