Severity: critical | Category: data-integrity | Phase: P0.1
Problem
No production code creates token_usage; the only CREATE TABLE is in test fixtures. Verified: grep finds zero CREATE TABLE ... token_usage in codeframe/. Every write raises OperationalError: no such table (double-swallowed in react_agent), so all token/cost data is silently dropped and the /costs page/cf stats render zeros or crash. Contradicts shipped Phase 5.2 cost tracking.
Evidence
codeframe/platform_store/repositories/token_repository.py:54 (INSERT), codeframe/core/workspace.py (schema build omits it), codeframe/cli/stats_commands.py:116 (crash)
Acceptance criteria
token_usage is created by create_or_load_workspace() with the columns the INSERT expects and indexes on timestamp, task_id, agent_id.
- A fresh workspace can
save_token_usage() and read it back with no error.
react_agent._persist_token_usage logs at WARNING (not debug/swallow) on failure.
- Test fixtures invoke the real schema builder instead of hand-rolling the table.
Dependencies
None
Filed from the SaaS launch-readiness audit. Atomic: one developer, one session. Work order: strictly P0.1 → P3.12 (no forward dependencies).
Severity: critical | Category: data-integrity | Phase: P0.1
Problem
No production code creates
token_usage; the onlyCREATE TABLEis in test fixtures. Verified:grepfinds zeroCREATE TABLE ... token_usageincodeframe/. Every write raisesOperationalError: no such table(double-swallowed inreact_agent), so all token/cost data is silently dropped and the/costspage/cf statsrender zeros or crash. Contradicts shipped Phase 5.2 cost tracking.Evidence
codeframe/platform_store/repositories/token_repository.py:54(INSERT),codeframe/core/workspace.py(schema build omits it),codeframe/cli/stats_commands.py:116(crash)Acceptance criteria
token_usageis created bycreate_or_load_workspace()with the columns the INSERT expects and indexes ontimestamp,task_id,agent_id.save_token_usage()and read it back with no error.react_agent._persist_token_usagelogs at WARNING (not debug/swallow) on failure.Dependencies
None
Filed from the SaaS launch-readiness audit. Atomic: one developer, one session. Work order: strictly P0.1 → P3.12 (no forward dependencies).