Skip to content

storage: migrate usage and pricing to SQLite - #1692

Merged
likun666661 merged 1 commit into
apache:mainfrom
likun666661:agent/usage-pricing-sqlite
Jul 31, 2026
Merged

storage: migrate usage and pricing to SQLite#1692
likun666661 merged 1 commit into
apache:mainfrom
likun666661:agent/usage-pricing-sqlite

Conversation

@likun666661

Copy link
Copy Markdown
Member

Summary

Stage 4b of #1649 moves usage telemetry and pricing authority into the shared runtime.sqlite owner.

  • adds SQLite tables for LLM calls, tool invocations, pricing revision, and pricing overrides
  • switches Runtime Host usage stores and Desktop telemetry wiring to the SQLite repositories
  • imports telemetry.json and pricing.json together through the durable cutover journal
  • keeps legacy source bytes unchanged after migration

Migration guarantees

  • both legacy documents are decoded before cutover and fingerprinted as one source set
  • copied rows, pricing revision, validation, and the completed marker commit in one transaction
  • a crash after copied rows rolls back and resumes cleanly on the next open
  • a legacy source changed after completed cutover fails closed
  • pricing multi-row mutations advance revision atomically or roll back completely
  • opaque identities, including NULs and unpaired surrogates, use a lossless hashed SQLite key while canonical JSON preserves the original value
  • production writes touch runtime.sqlite only

Scope boundary

This completes the usage/pricing part of Stage 4. Artifact metadata and lifecycle remain the next migration PR because their SQLite metadata transaction must coordinate with recoverable payload-file publication. Artifact payload bytes remain files. StoredMessage transcripts remain JSONL.

Verification

  • npm --workspace @maka/storage test — 843 passed, 1 skipped
  • focused Storage + Runtime Host usage/pricing suites — 27 passed
  • npm --workspace @maka/desktop run build:main — passed
  • Biome on changed files and git diff --check — passed
  • full Runtime Host suite — 413 passed; the existing steering/shutdown race failed once, and its isolated rerun passed

@likun666661
likun666661 marked this pull request as ready for review July 31, 2026 09:19
@likun666661
likun666661 merged commit bfab362 into apache:mainJul 31, 2026
2 of 3 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@likun666661