state-hub/api/routers
tegwick 58e1bafce9 feat(token-tracking): record AI token consumption per task (CUST-WP-0029)
Introduces end-to-end token consumption tracking so agent work is
visible as a cost/effort metric alongside tasks and workplans.

- Migration o2j3k4l5m6n7: token_events table with FK indexes on
  task_id, workstream_id, repo_id, created_at
- ORM model, Pydantic schemas (TokenEventCreate, TokenEventRead with
  computed tokens_total, TokenSummary)
- Router: POST /token-events/, GET /token-events/ (7 filters),
  GET /token-events/summary/ (task|workstream|repo|commit|release scope)
- MCP tools: record_token_event, get_token_summary (formatted table)
- update_task_status enriched with optional tokens_in/tokens_out
  passthrough — one call creates status update + token event
- Dashboard token-cost.md page: by-repo bar, by-workplan table,
  by-model bar, top-10 tasks by tokens
- ralph-workplan skill updated with token reporting guidance and
  per-task heuristics for estimating counts
- Tests: test_token_events.py + test_token_passthrough.py (182 pass)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-29 17:46:46 +02:00
..
__init__.py Add state-hub v0.1 — local-first state service for the Custodian 2026-02-24 17:47:49 +01:00
capability_requests.py feat(capability-requests): add routing dispute & reroute workflow (CUST-WP-0027) 2026-03-21 23:58:52 +01:00
contributions.py feat(state-hub): v0.3 schema — contributions + sbom_entries migrations, models, schemas, routers 2026-02-28 17:28:27 +01:00
decisions.py feat(api): CUST-WP-0018 — API hardening & code quality 2026-03-18 02:17:04 +01:00
domain_goals.py feat(goals): add domain/repo goal tracking and update_workstream MCP tool 2026-03-09 00:15:29 +01:00
domains.py feat(CUST-WP-0016): kaizen-agentic integration — MCP tools, templates, direct install 2026-03-17 22:24:30 +01:00
extension_points.py feat(gems): three-pass schema migration aligning state-hub with GEMS 2026-03-02 23:39:17 +01:00
messages.py feat(CUST-WP-0015): implement agent inbox for inter-agent coordination 2026-03-16 02:55:45 +01:00
policy.py feat(tasks): add needs_human intervention flag (CUST-WP-0009) 2026-03-04 19:44:14 +01:00
progress.py feat(api): CUST-WP-0018 — API hardening & code quality 2026-03-18 02:17:04 +01:00
repo_goals.py feat(goals): add domain/repo goal tracking and update_workstream MCP tool 2026-03-09 00:15:29 +01:00
repos.py feat(repos): git-fingerprint-based machine-independent repo identity 2026-03-28 23:55:06 +01:00
sbom.py feat(gems): three-pass schema migration aligning state-hub with GEMS 2026-03-02 23:39:17 +01:00
state.py feat(capability-requests): add cross-domain capability catalog and request routing 2026-03-19 21:07:50 +01:00
tasks.py feat(token-tracking): record AI token consumption per task (CUST-WP-0029) 2026-03-29 17:46:46 +02:00
technical_debt.py feat(suggestions): full suggestion workflow with per-step notes 2026-03-18 00:57:34 +01:00
token_events.py feat(token-tracking): record AI token consumption per task (CUST-WP-0029) 2026-03-29 17:46:46 +02:00
topics.py feat(tests): pytest-asyncio test suite — 119 tests across 3 modules 2026-03-18 12:00:06 +01:00
tpsc.py feat(doi): Repository DoI automated gate and dashboard integration (CUST-WP-0024) 2026-03-20 01:08:18 +01:00
workstream_dependencies.py Implement State Hub v0.2: dependency graph, next-steps suggestions, design boundary 2026-02-25 23:33:14 +01:00
workstreams.py feat(api): CUST-WP-0018 — API hardening & code quality 2026-03-18 02:17:04 +01:00