Skip to content

refactor(storage): remove the unused legacy Usage session scanner - #4060

Open
heeoneie wants to merge 5 commits into
apache:mainfrom
heeoneie:refactor/remove-legacy-usage-scanner
Open

refactor(storage): remove the unused legacy Usage session scanner#4060
heeoneie wants to merge 5 commits into
apache:mainfrom
heeoneie:refactor/remove-legacy-usage-scanner

Conversation

@heeoneie

Copy link
Copy Markdown
Contributor

Summary

SettingsStore.usageStats and packages/storage/src/usage-stats-store.ts have no production consumer. Desktop reads Usage through the Runtime Host: the settings:usageStats handler in runtime-host-usage-ipc-main.ts resolves via loadUsageStats(deps.client, ...), and the only .usageStats( call site in the repository is window.maka.settings.usageStats(range, host) at settings-surface.tsx:636, which goes through that same Host path. @maka/core/usage-stats/* is a separate module and is untouched, as are SettingsStore itself and projectDesktopUsageStats.

Removing the scanner also removes the only import that pulled node:sqlite into ./settings-store's module graph — usage-stats-store.ts imported createSqliteSessionMetadataStore. public-entrypoints.test.ts fails on only the declared entrypoints load node:sqlite until './settings-store' leaves SQLITE_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-store no longer pays the SQLite load.

usage-stats-store is not in packages/storage's exports map, so this is not a public-API change.

Refs #4059

Verification

Ran:

  • tsc -p packages/core/tsconfig.json and tsc -p packages/storage/tsconfig.json — clean.
  • biome lint packages/storage and biome format packages/storage — clean. The format run is what caught the collapsed type import in fd35428.
  • @maka/storage suite (node --test "dist/**/*.test.js"): 991 tests, 969 pass, 3 fail, 19 skipped.
  • The same suite on unmodified main in 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, and an 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, so chmod does not deny it. Unrelated to this change.
  • Repository-wide grep for readUsageStats, usage-stats-store, and SettingsStore.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:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

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 5 trailer.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

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
@github-actions github-actions Bot added the effort/L Under 1000 readable lines label Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/L Under 1000 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant