oliver-sales-ops-platform/backend/app/models
DJP b41e3999c6 Per-stage AI cost badges + Stage 10 efficiency UI + Stage 8 fix
Three things in one commit because they share the same plumbing.

1) PER-STAGE COST DISPLAY
Migration 0006 adds cost_usd / input_tokens / output_tokens columns to
stage_artifacts. Every Claude-driven agent now stamps its own run cost
on the artifact it produces:
  - intake_agent (Stage 1)
  - diagnosis_agent (Stage 2)
  - asset_normalizer (Stage 6)
  - ai_matching (Stage 7) — accumulates across the per-asset loop and
    persists a NEW summary artifact (artifact_type='matching_run')
    with the run totals + assets_matched + matches_created counts
  - delivery_model_agent (Stage 9)
  - capability_gap_agent (Stage 12)
  - support_docs_agent (Stage 13)
A new <AgentRunCost> component renders a compact pill (label, cost,
in/out tokens) sourced from the most-recent stage artifact. Embedded
in the header of every Claude-driven stage panel: 1, 2, 6, 7, 9, 12, 13.
Per-deal cumulative cost still on the Stage 8 stats card.

2) STAGE 10 FRONTEND
Wires the Stage 10 efficiency-profile endpoint shipped in 2eb0422 to
a real UI (was placeholder before). Scenario picker (conservative /
moderate / aggressive), blanket slider, per-discipline overrides
(disabled when blanket > 0), tools-applied chips, free-text notes,
live impact preview that hits team-shape with the active settings,
and a Save button that persists to the artifact. Hydrates on mount
from the most recent saved profile.

3) STAGE 8 EMPTY STATE
"No ratecard yet" is now smart: when there ARE selected matches at
Stage 7 it surfaces the count + a primary "Build ratecard from N
matches" action, instead of telling you to do something you've
already done.

Smoke-tested: opp #2 ratecard rebuilt (35 lines); Stage 9 delivery
agent re-run shows $0.0437 / 4994 in / 1915 out on the badge.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 14:38:50 -04:00
..
__init__.py Stages 6/7/8 backend + Stage 3/4 tests: V1 core ported 2026-04-27 14:03:13 -04:00
asset.py Stages 6/7/8 backend + Stage 3/4 tests: V1 core ported 2026-04-27 14:03:13 -04:00
clarification.py Stage 2 backend: Diagnosis Agent + clarification questions 2026-04-27 13:22:13 -04:00
file.py Stage 1 part 2: file upload + Intake Agent 2026-04-27 13:02:26 -04:00
gmal.py Scaffold V2: 17-stage state machine, Alembic, MSAL, Mermaid stage map 2026-04-27 12:35:03 -04:00
notification.py Approval workflow backend: notifications + Mailgun email 2026-04-27 13:28:22 -04:00
opportunity.py Scaffold V2: 17-stage state machine, Alembic, MSAL, Mermaid stage map 2026-04-27 12:35:03 -04:00
stage.py Per-stage AI cost badges + Stage 10 efficiency UI + Stage 8 fix 2026-04-27 14:38:50 -04:00
user.py Scaffold V2: 17-stage state machine, Alembic, MSAL, Mermaid stage map 2026-04-27 12:35:03 -04:00