You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat(costs): per-task and per-agent breakdowns + task board cost badge (#558)
Extends the /costs page (added in #557) with two analytics sections and
adds an inline cost badge to each task card on the /tasks board.
Backend (Python):
- New TokenRepository.get_top_tasks_by_cost(days, limit) and
get_costs_by_agent(days), aggregating the workspace token_usage table.
- New endpoints under /api/v2/costs:
GET /tasks -> top 10 tasks with titles, agent, tokens, cost
GET /by-agent -> per-agent rollup + total input/output tokens
- Title resolution falls back to a placeholder when token_usage references
a task no longer present in the workspace, so the table never blanks out.
- TokenUsage.task_id widened to Optional[Union[int, str]] so v2 UUID
task IDs are preserved end-to-end (react_agent.py was int()-casting and
storing NULL for every v2 record, blocking per-task analytics).
Frontend (TypeScript / Next.js):
- New types TaskCostEntry, TaskCostsResponse, AgentCostEntry,
AgentCostsResponse and matching costsApi.getTopTasks / getByAgent.
- New CostsView sections: TopTasksTable and AgentCostBars (pure-Tailwind
horizontal bars + input/output token split row, no charting library).
- TaskCard renders a small MoneyBag02Icon + cost badge with a tooltip
showing input/output token breakdown when costMap has a positive entry
for that task. costMap threads through TaskBoardView -> Content -> Column
as an optional prop; non-breaking.
* fix(costs): address review feedback on #558 PR
- TaskCard badge: format sub-cent costs at 4dp instead of collapsing to
$0.00. Adds a regression test against the $0.0042 case.
- /api/v2/costs/tasks: expose a `limit` query param (1..1000, default 10).
Analytics view keeps the top-10 default; TaskBoardView now requests
limit=1000 so the badge map covers every task with spend, not just the
top 10 (a board task outside the top-10 would otherwise never show).
- react_agent: simplify task_id persistence — the upstream caller never
passes None, so drop the unreachable branch.
- TokenRepository: TODO note on the N+1 dominant-agent lookup. Fine at
current scale; flagged for a future CTE refactor.
- New direct unit tests for TopTasksTable and AgentCostBars covering
empty/loading/data states and the zero-total token-split edge case.
* docs: mark Phase 5.2 (cost analytics) complete (#558)
---------
Co-authored-by: Test User <test@example.com>
Copy file name to clipboardExpand all lines: CLAUDE.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,8 @@ If you are an agent working in this repo: **do not improvise architecture**. Fol
36
36
37
37
### Current Focus: Phase 4A
38
38
39
+
**Phase 5.2 is complete** — Costs page now ships per-task and per-agent breakdowns (#558) on top of the spend summary (#557). Backend: `GET /api/v2/costs/tasks?days=N&limit=M` (top-N tasks with titles, agent, tokens, cost) and `GET /api/v2/costs/by-agent?days=N` (per-agent rollup + total input/output tokens), both via `TokenRepository.get_top_tasks_by_cost` and `get_costs_by_agent`. Task board cards show an inline `MoneyBag02Icon` cost badge with token-breakdown tooltip when cost data exists. Fixed a v2 data-loss bug where `react_agent` int-cast UUID task IDs and stored NULL in `token_usage`.
40
+
39
41
**Phase 5.1 is complete** — Settings page now ships three working tabs: Agent (#554), API Keys (#555), and PROOF9 Defaults + Workspace Config (#556). Backend: `GET/PUT /api/v2/proof/config` and `/api/v2/workspaces/config`, plus `run_proof()` now honors `enabled_gates` filtering and `strictness` (`strict` vs `warn`). Atomic JSON writes via `codeframe/ui/routers/_helpers.atomic_write_json`. The 9-gate canonical order and `proof_config.json` filename live in `codeframe/core/proof/models.py`.
40
42
41
43
**Phase 3.5C is complete** — `CaptureGlitchModal` form (description/markdown, source, scope, gate obligations, severity, expiry) reachable from the PROOF9 page and the persistent sidebar "Capture Glitch" button. REQ detail view (`/proof/[req_id]`) ships markdown description rendering, `ProofScope` metadata display, obligations table with `Latest Run` column, sortable/filterable evidence history, and empty-state CTA. Backend: `ScopeOut` model on `RequirementResponse`. Issues #568, #569.
0 commit comments