refactor(storage): remove the unused legacy Usage session scanner - #4060
Merged
Astro-Han merged 5 commits intoAug 29, 2026
Merged
Conversation
Astro-Han
force-pushed
the
refactor/remove-legacy-usage-scanner
branch
from
August 29, 2026 09:48
fd35428 to
1c8d538
Compare
SettingsStore.usageStats and packages/storage/src/usage-stats-store.ts have no production consumer. Desktop reads Usage through the Runtime Host client in runtime-host-usage-ipc-main.ts; the only .usageStats( call site in the repository is window.maka.settings.usageStats(range, host), which resolves through that same Host path. Refs apache#4059 Generated-by: Claude Opus 5
Its only importer was SettingsStore.usageStats, removed in this branch. Refs apache#4059 Generated-by: Claude Opus 5
These cover SettingsStore.usageStats and the legacy scanner only; both are gone. Refs apache#4059 Generated-by: Claude Opus 5
usage-stats-store.ts held the only import that pulled node:sqlite into ./settings-store's module graph. With the legacy scanner gone that entrypoint is SQLite-free, so it leaves SQLITE_BACKED_ENTRYPOINTS -- updated in the same change with the reason, as the list's own comment asks. Refs apache#4059 Generated-by: Claude Opus 5
…ne line Dropping UsageRange and UsageStats leaves three specifiers, which biome format prints inline. Caught by `npx biome format packages/storage`. Refs apache#4059 Generated-by: Claude Opus 5
Astro-Han
force-pushed
the
refactor/remove-legacy-usage-scanner
branch
from
August 29, 2026 10:00
1c8d538 to
e1f40e0
Compare
Astro-Han
approved these changes
Aug 29, 2026
Astro-Han
left a comment
Contributor
There was a problem hiding this comment.
Approved at exact head e1f40e073609ca506fa773dd3721f08af1689e94.
Codex assisted with call-site tracing, package-boundary analysis, and exact-head verification. I independently reviewed the final diff and commit messages and own this approval.
I verified that Desktop Usage remains Runtime Host-owned; the removed Storage scanner has no production consumer or supported external contract; ./settings-store no longer reaches node:sqlite; and the change introduces no replacement state or parallel path. The exact-head test and windows_recovery checks are green, the branch is mergeable, and there are no unresolved review threads. No P0–P3 findings.
This was referenced Aug 29, 2026
liuxiaocs7
added a commit
to liuxiaocs7/maka
that referenced
this pull request
Aug 29, 2026
The Usage Statistics activity log's 任务 (Task) column showed `未命名会话 · <id>` for every row. apache#3833 fixed this by carrying `SessionHeader.name` through the old usage-stats-store.ts pipeline, but apache#3697 moved usage onto the Runtime Host projection and apache#4060 deleted that store — the new pipeline only carried `sessionId`, so `UsageRequestLog.sessionName` was declared but never populated and the UI always hit the untitled fallback. Resolve the title on the Host, where every usage-bearing session is reachable. HostUsagePricingCoordinator takes a session-title reader (sessionStore.readHeaderSnapshot) and, per logs page, resolves the title for each row's sessionId, emitting it as a new bounded `sessionTitle` field on the LLM/tool usage projections. Reading the durable header by id bypasses the catalog's role/preparing/ledger-v0 filters, so reserved-role, coordination, and legacy sessions are named too; an unreadable session is tolerated per-row and simply stays untitled. The desktop layer copies `sessionTitle` onto `sessionName`; the renderer (usageSessionDisplayLabel) already owns the untitled fallback. Closes apache#4218 Generated-by: Claude Code (claude-opus-4-8)
liuxiaocs7
added a commit
to liuxiaocs7/maka
that referenced
this pull request
Aug 29, 2026
The Usage Statistics activity log's 任务 (Task) column showed `未命名会话 · <id>` for every row. apache#3833 fixed this by carrying `SessionHeader.name` through the old usage-stats-store.ts pipeline, but apache#3697 moved usage onto the Runtime Host projection and apache#4060 deleted that store — the new pipeline only carried `sessionId`, so `UsageRequestLog.sessionName` was declared but never populated and the UI always hit the untitled fallback. Resolve the title on the Host, where every usage-bearing session is reachable. HostUsagePricingCoordinator takes a session-title reader (sessionStore.readHeaderSnapshot) and, per logs page, resolves the title for each row's sessionId, emitting it as a new bounded `sessionTitle` field on the LLM/tool usage projections. Reading the durable header by id bypasses the catalog's role/preparing/ledger-v0 filters, so reserved-role, coordination, and legacy sessions are named too; an unreadable session is tolerated per-row and simply stays untitled. The desktop layer copies `sessionTitle` onto `sessionName`; the renderer (usageSessionDisplayLabel) already owns the untitled fallback. Bump the Host compatibility epoch (68 → 69): the new projection field is rejected by older Clients, so the same protocol version no longer guarantees safe interoperability. Closes apache#4218 Generated-by: Claude Code (claude-opus-4-8)
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.
Summary
SettingsStore.usageStatsandpackages/storage/src/usage-stats-store.tshave no production consumer. Desktop reads Usage through the Runtime Host: thesettings:usageStatshandler inruntime-host-usage-ipc-main.tsresolves vialoadUsageStats(deps.client, ...), and the only.usageStats(call site in the repository iswindow.maka.settings.usageStats(range, host)atsettings-surface.tsx:636, which goes through that same Host path.@maka/core/usage-stats/*is a separate module and is untouched, as areSettingsStoreitself andprojectDesktopUsageStats.Removing the scanner also removes the only import that pulled
node:sqliteinto./settings-store's module graph —usage-stats-store.tsimportedcreateSqliteSessionMetadataStore.public-entrypoints.test.tsfails ononly the declared entrypoints load node:sqliteuntil'./settings-store'leavesSQLITE_BACKED_ENTRYPOINTS, so that list is updated in the same change with the reason, as its own comment asks. A consumer importing@maka/storage/settings-storeno longer pays the SQLite load.usage-stats-storeis not inpackages/storage'sexportsmap, so this is not a public-API change.Refs #4059
Verification
Ran:
tsc -p packages/core/tsconfig.jsonandtsc -p packages/storage/tsconfig.json— clean.biome lint packages/storageandbiome format packages/storage— clean. The format run is what caught the collapsed type import infd35428.@maka/storagesuite (node --test "dist/**/*.test.js"): 991 tests, 969 pass, 3 fail, 19 skipped.mainin the same container: 995 tests, 973 pass, and the same 3 failures —rejects a second authority for the same storage root in another process,does not classify a SQLite write failure as a migration blocker, andan unmarked read-only workspace fails without leaving marker state. Two of them assert that a permission denial rejects, and my test process runs as root, sochmoddoes not deny it. Unrelated to this change.readUsageStats,usage-stats-store, andSettingsStore.usageStats: no remaining reference.Not run: the Desktop build, Desktop tests, and e2e. The Electron postinstall and one registry dependency are blocked in my environment, so the Desktop side is verified by reference inspection only, not by execution. Worth a reviewer confirming
npm --workspace @maka/desktop test.AI use
Select exactly one:
Tool(s) and scope: Claude Opus 5 — call-site verification, the edits themselves, and running the checks above. Each commit carries a
Generated-by: Claude Opus 5trailer.Checklist
Does this PR entail a change in behavior?