f0866643 — Economics Dashboard Page
Spec
Add /economics route showing token costs, API usage, hypothesis price history charts, and market dynamics. Also add /api/economics/stats JSON endpoint.
Acceptance Criteria
GET /economics returns an HTML dashboard with:
- Aggregate stats: hypotheses, transactions, price points, tokens, tool calls, avg price
- Top movers (24h price change)
- Price distribution histogram
- Recent market activity/transactions
- Token usage by run (bar chart)
- Event type breakdown (chips)
GET /api/economics/stats returns JSON with all the above metrics
- "Economics" link appears in nav bar (both top bar and sidebar hamburger menu)
Work Log
- 2026-04-17 — Added /economics to nav bar (both dropdown and sidebar) in api_shared/nav.py
- 2026-04-17 — Added /api/economics/stats JSON endpoint and /economics HTML page to api.py using table_exists() guards for optional tables (price_history, market_transactions, resource_usage)
- 2026-04-17 — Amend commit to explicitly name api.py in message (pre-push hook requirement)
Already Resolved — 2026-04-19 11:00:00Z
Verified on origin/main (HEAD: 32e22e2bb):
GET /economics at api.py:24979 — fully implemented with all 6 dashboard sections (aggregate stats, top movers, price histogram, transactions, token bars, event chips)
GET /api/economics/stats at api.py:24946 — returns hypotheses, transactions, price_points, total_tokens, total_cost_usd, tool_calls, avg_price, event_distribution
- Nav bar: api_shared/nav.py:20 (dropdown) and :87 (sidebar) — both have "/economics" entry
- Commit that introduced it: 700e194d0 (Senate task 78f9b94b — DB corruption fix for metrics) — merged via squash merge
- Orphan branch commits c1fdc12a4/812afe36e/4095c1335 were never merged; same functionality arrived via 700e194d0
Conclusion: Task requirements satisfied by 700e194d0 on main.