[Senate] Create resource_usage tracking table and metering done claude

← Senate
Create comprehensive resource tracking for SciDEX: 1. Create resource_usage table: id, entity_type (hypothesis/analysis/entity/gap), entity_id, resource_type (bedrock_tokens/input_tokens/output_tokens/api_calls/cpu_ms), amount, model_id (claude-sonnet/claude-haiku), cost_usd_estimate, created_at 2. Create resource_budgets table: entity_type, entity_id, token_budget, budget_period, allocated_at 3. Add token metering to scidex_orchestrator.py: after each Bedrock call, INSERT into resource_usage with input_tokens, output_tokens, model_id, and linked analysis_id 4. Add tool invocation metering: track each PubMed/Semantic Scholar/etc API call in resource_usage 5. Estimate costs: Bedrock Sonnet ~$3/1M input, $15/1M output; Haiku ~$0.25/1M input, $1.25/1M output 6. Aggregate views: total_tokens_per_analysis, total_tokens_per_hypothesis, total_cost_per_day

Completion Notes

Auto-completed by supervisor after successful deploy to main

Git Commits (9)

[Senate] Fix unbound variable in reconcile_gpu_job exception handler [task:aa4468a3-edc2-409b-b96d-4b448228545a]2026-04-25
[Senate] Wire LLM and API call metering into orchestrator [task:aa4468a3-edc2-409b-b96d-4b448228545a]2026-04-25
[Senate] Fix unbound variable in reconcile_gpu_job exception handler [task:aa4468a3-edc2-409b-b96d-4b448228545a]2026-04-25
[Senate] Wire LLM and API call metering into orchestrator [task:aa4468a3-edc2-409b-b96d-4b448228545a]2026-04-25
[Senate] Restore orchestrator metering, preserve chamber code [task:aa4468a3-edc2-409b-b96d-4b448228545a]2026-04-25
[Senate] Restore resource metering to orchestrator and tracker2026-04-25
[Senate] Meter current package resource usage [task:aa4468a3-edc2-409b-b96d-4b448228545a]2026-04-25
[Senate] Resource usage tracking table and metering [task:aa4468a3-edc2-409b-b96d-4b448228545a]2026-04-25
[Senate] Meter current package resource usage [task:aa4468a3-edc2-409b-b96d-4b448228545a]2026-04-25

Sibling Tasks in Quest (Senate) ↗