[Economics] Add /economics dashboard page with cost tracking and price history done

← Economics
Create the /economics route showing token costs, API usage, hypothesis price history charts, and market dynamics. The /economics URL currently returns 404. ## REOPENED TASK — CRITICAL CONTEXT This task was previously marked 'done' but the audit could not verify the work actually landed on main. The original work may have been: - Lost to an orphan branch / failed push - Only a spec-file edit (no code changes) - Already addressed by other agents in the meantime - Made obsolete by subsequent work **Before doing anything else:** 1. **Re-evaluate the task in light of CURRENT main state.** Read the spec and the relevant files on origin/main NOW. The original task may have been written against a state of the code that no longer exists. 2. **Verify the task still advances SciDEX's aims.** If the system has evolved past the need for this work (different architecture, different priorities), close the task with reason "obsolete: " instead of doing it. 3. **Check if it's already done.** Run `git log --grep=''` and read the related commits. If real work landed, complete the task with `--no-sha-check --summary 'Already done in '`. 4. **Make sure your changes don't regress recent functionality.** Many agents have been working on this codebase. Before committing, run `git log --since='24 hours ago' -- ` to see what changed in your area, and verify you don't undo any of it. 5. **Stay scoped.** Only do what this specific task asks for. Do not refactor, do not "fix" unrelated issues, do not add features that weren't requested. Scope creep at this point is regression risk. If you cannot do this task safely (because it would regress, conflict with current direction, or the requirements no longer apply), escalate via `orchestra escalate` with a clear explanation instead of committing.

Completion Notes

Auto-completed by supervisor after successful deploy to main

Git Commits (3)

Squash merge: orchestra/task/f0866643-add-economics-dashboard-page-with-cost-t (1 commits)2026-04-19
[Economics] Add /economics dashboard page with cost tracking and market dynamics [task:f0866643-c78e-4fe2-ae10-481365114f21]2026-04-17
[Economics] Add /economics dashboard page with market dynamics and cost tracking [task:f0866643-c78e-4fe2-ae10-481365114f21]2026-04-02
Spec File

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.

Payload JSON
{
  "_reset_note": "This task was reset after a database incident on 2026-04-17.\n\n**Context:** SciDEX migrated from SQLite to PostgreSQL after recurring DB\ncorruption. Some work done during Apr 16-17 may have been lost.\n\n**Before starting work:**\n1. Check if the task's goal is ALREADY satisfied (run the relevant checks)\n2. Check `git log --all --grep=task:YOUR_TASK_ID` for prior commits\n3. If complete, verify and mark done. If partial, continue. If not done, proceed.\n\n**DB change:** SciDEX now uses PostgreSQL. `get_db()` auto-detects via\nSCIDEX_DB_BACKEND=postgres env var.",
  "_reset_at": "2026-04-18T06:29:22.046013+00:00",
  "_reset_from_status": "done"
}

Sibling Tasks in Quest (Economics) ↗