feat(stats): merge token statistics onto latest main - #950
Merged
Conversation
(cherry picked from commit 00212cb)
(cherry picked from commit 96488ae)
(cherry picked from commit da679ad)
(cherry picked from commit 1b6cc10)
(cherry picked from commit 9b614d1)
(cherry picked from commit cffbb74)
(cherry picked from commit 7c731b4)
(cherry picked from commit 412c1e7)
(cherry picked from commit e1fc9aa)
(cherry picked from commit f226ae2)
(cherry picked from commit cc359bb)
(cherry picked from commit b75a63a)
(cherry picked from commit a9bd287)
(cherry picked from commit dbb03ee)
(cherry picked from commit 481acb4)
(cherry picked from commit 2122058)
(cherry picked from commit 157d353)
(cherry picked from commit 3ec8b23)
P1-1: wire backup/restore barriers into raw snapshot and Room managers; persist and consume the restore REPLACING marker across crashes so pre-restore spool is never replayed into a replaced database. P1-2: fail-open statistics finalization - a persistence failure must never fail a successful model result; degraded tracking context when the stats DB is unavailable. P1-3: run finalization on Dispatchers.IO so FutureTask.get and fsync never block the Main thread. P1-4: bill Gemini thoughts on top of candidates and extract usageMetadata before early returns. Adds BackupRestoreBarrierTest covering production manager wiring, marker consumption on startup, and corrupt-zip pre-commit rejection.
Preserve PR #922 authorship and review history on the dedicated token-statistics baseline branch. Follow-up redesign work continues on fix/token-stats-922-review before any main merge.
Replace the spool, baseline, recovery, cleanup, and quarantine implementation with structured Room usage records and model settings. Integrate provider usage capture, SQL-backed statistics, settings and UI updates, and normal backup/restore handling. Document the redesigned storage model and remove obsolete tests.
…eview # Conflicts: # app/src/main/java/com/ai/assistance/operit/api/chat/library/MemoryLibrary.kt # app/src/main/java/com/ai/assistance/operit/data/backup/RawSnapshotBackupManager.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更说明 / Description
将完整的 token 统计功能及其当前审查修复合入最新
main,保留原有统计分支的提交历史,并补齐数据库访问串行化与编译修正。背景与基线 / Context and baseline
feat/token-stats-922-basemainfix/token-stats-922-revieworigin/main@6819ac4401c91bc6eecf1ee5691675960c03f3c6main本分支在
3d567320上合入最新origin/main,随后完成本次收尾修复。改动范围 / Changes
TokenUsageRepository的数据库访问锁。RoomDatabaseBackupRestoreLock,避免不同锁之间产生竞态。MemoryLibrary调用parseAnalysisResult时遗留的旧参数,恢复compileDebugKotlin编译。不包含:统计数据单独导入/导出;现有聊天记录 JSON 导入/导出协议;统计产品口径和 UI 设计的额外变更。
兼容性与风险 / Compatibility and risks
app_database,每日/手动 Room 备份及原始快照会一起保存,统计无需单独导入。关联 Issue / Related issue
Supersedes #928 and carries forward the implementation from #922.
验证方式 / Verification
证据 / Evidence
:app:compileDebugKotlinmain的祖先关系已检查通过docs/TODO/token_stats_922_review_20260811/检查清单 / Checklist
Candidate checks覆盖改动范围,并会处理技术失败项 /Candidate checkscovers the change scope and technical failures will be addressed