Skip to content

Remove leftover service storage purge after production inventory is empty - #1569

Merged
kody-bot merged 2 commits into
mainfrom
cursor/retire-service-storage-purge-8713
Aug 19, 2026
Merged

kody-bot merged 2 commits into
mainfrom
cursor/retire-service-storage-purge-8713

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Aug 19, 2026 •

Copy link
Copy Markdown
Member

Intent

Finish #1565 now that production APP_DB has zero leftover kind='service' inventory: drop the retired-service purge lane and stop accepting that kind.

Summary

  • Confirmed production user_storage_buckets kinds on 2026-08-19: execute 1, job 105, package 94, repo_session 1103, unknown 6. No service rows.
  • Remove purgeRetiredServiceStorageBuckets from the storage_bucket_estimate_backfill lane and delete the purge module.
  • Add migration 0018 that rebuilds user_storage_buckets without 'service' in the CHECK. Fail closed if a leftover row appears.
  • Estimate reads no longer special-case leftover service rows; unexpected kinds still map to unknown.
  • Garden data-storage.md, ADR 0025, and the runtime-worker transferred-class runbook.

Closes #1565.

This supersedes the docs-only gardens in #1566 (runbook + ADR 0025).

Testing

  • Production D1 GROUP BY kind count (Cloudflare API, read-only)
  • npm run migrations:check — 18 files, next prefix 0019
  • vitest run --project node-unit packages/worker/src/storage-buckets — 3 passed
  • vitest run --project workers-unit packages/worker/src/storage-buckets — 7 passed, including CHECK rejection of 'service'
  • npm run docs:check-temporal

System changes

Medium: extends d1-app-db CHECK for user_storage_buckets. Purge-lane TypeScript is inventory bookkeeping around that table, not a new primitive.

System recap — extends existing primitives (medium risk)

Mode: recap · Base: main @ c4d75a07 · Head: d710e41b

Classification: extends — migration 0018 tightens the live user_storage_buckets.kind CHECK.

Primitives touched

Primitive Group Impact
d1-app-db storage extends — rebuild user_storage_buckets without 'service'

Unmatched paths include the estimate-backfill purge removal and leftover-service doc gardens.

Change flow

Estimate-backfill no longer clears retired service StorageRunner objects; D1 rejects new kind='service' rows.

sequenceDiagram
	participant estimateBackfill as storage_bucket_estimate_backfill
	participant d1AppDb as d1-app-db
	estimateBackfill->>d1AppDb: list unmeasured buckets (no service filter)
	Note over d1AppDb: 0018 CHECK drops retired service kind
	d1AppDb-->>estimateBackfill: live kinds only
Loading
Open in Web Open in Cursor 

Summary by CodeRabbit

  • Bug Fixes

    • Removed support for retired service storage records.
    • Storage estimates now include all eligible inventory records, including previously excluded entries.
    • Improved reconciliation of active repository-session storage registrations.
  • Documentation

    • Updated architecture guidance and migration runbooks for storage cleanup and runtime-worker deletion workflows.
  • Data Integrity

    • Storage records now accept only supported storage types, preventing new retired service entries.

…is empty

Production APP_DB has zero kind=service user_storage_buckets rows. Remove
the estimate-backfill purge hook, tighten the live CHECK in migration 0017,
and garden the leftover-service docs. Closes #1565.

Co-authored-by: me <me@kentcdodds.com>
@coderabbitai

coderabbitai Bot commented Aug 19, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 88f970a8-7cc8-4846-ba9c-54d5d21e157b

📥 Commits

Reviewing files that changed from the base of the PR and between c4d75a0 and d710e41.

📒 Files selected for processing (13)
  • docs/contributing/architecture/data-storage.md
  • docs/contributing/architecture/runtime-worker-migration-runbook.md
  • docs/contributing/decisions/0025-no-package-services-primitive.md
  • packages/worker/migrations/0018-drop-retired-service-storage-kind.sql
  • packages/worker/src/storage-buckets/estimate-backfill.node.test.ts
  • packages/worker/src/storage-buckets/estimate-backfill.ts
  • packages/worker/src/storage-buckets/estimate-backfill.workers.test.ts
  • packages/worker/src/storage-buckets/purge-retired-service-storage.node.test.ts
  • packages/worker/src/storage-buckets/purge-retired-service-storage.ts
  • packages/worker/src/storage-buckets/service.ts
  • packages/worker/src/storage-buckets/service.workers.test.ts
  • packages/worker/src/storage-buckets/test-schema.ts
  • tools/migration-ledger.json
💤 Files with no reviewable changes (5)
  • packages/worker/src/storage-buckets/estimate-backfill.ts
  • packages/worker/src/storage-buckets/purge-retired-service-storage.node.test.ts
  • packages/worker/src/storage-buckets/estimate-backfill.workers.test.ts
  • packages/worker/src/storage-buckets/purge-retired-service-storage.ts
  • packages/worker/src/storage-buckets/estimate-backfill.node.test.ts

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The change removes retired service storage-row purging, adds migration 0018 to reject new service rows, updates estimate backfill behavior, and records the completed cleanup and runtime-worker deletion procedures.

Changes

Service storage retirement

Layer / File(s) Summary
Enforce storage-kind constraint
packages/worker/migrations/0018-drop-retired-service-storage-kind.sql, packages/worker/src/storage-buckets/test-schema.ts, packages/worker/src/storage-buckets/service.workers.test.ts, tools/migration-ledger.json
Migration 0018 recreates user_storage_buckets without service in the kind constraint. The test schema, integration test, and migration ledger reflect the new schema.
Update estimate backfill
packages/worker/src/storage-buckets/estimate-backfill.ts, packages/worker/src/storage-buckets/service.ts, packages/worker/src/storage-buckets/*test.ts
The backfill reconciles missing active repository-session registrations, processes all missing estimates, and removes retired-service purge coverage and implementation.
Update migration and storage documentation
docs/contributing/architecture/data-storage.md, docs/contributing/architecture/runtime-worker-migration-runbook.md, docs/contributing/decisions/0025-no-package-services-primitive.md
The documentation records the completed service-row purge, the revised deletion sequence, preview requirements, and repository-session reconciliation behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to d710e

The PR removes the retired service-storage purge path and rejects new service entries after production inventory reached zero; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes removal of the retired service storage purge after production inventory reached zero.
Description check ✅ Passed The description includes intent, summary, testing, and system changes with concrete implementation and verification details.
Linked Issues check ✅ Passed The changes satisfy #1565 by removing the purge machinery, adding migration 0018, updating tests and schema, and refreshing stale documentation.
Out of Scope Changes check ✅ Passed The changes remain within #1565 scope and do not remove unrelated service infrastructure or alter migration 0016.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/retire-service-storage-purge-8713

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

main already used 0017 for package-owned invocation tokens.

Co-authored-by: me <me@kentcdodds.com>
@kody-bot
kody-bot marked this pull request as ready for review August 19, 2026 17:57
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Preview deployed: https://kody-pr-1569.kody-a99.workers.dev

Worker: kody-pr-1569
Runtime worker: kody-pr-1569-runtime (https://kody-pr-1569-runtime.kody-a99.workers.dev)
D1: kody-pr-1569-db
KV: kody-pr-1569-oauth-kv

Mocks:

@kody-bot

Copy link
Copy Markdown
Member

Preview manual test

Seeded user on https://kody-pr-1569.kody-a99.workers.dev (me@kentcdodds.com / user-me):

  • Signed in; /account and /account/usage render.
  • GET /account/export.json and GET /account/packages.json returned 200.
  • First GET /account/usage.json was HTTP 500 (likely UserMeter cold start). Immediate retry and a later curl both returned 200 with storage_bytes current 0 / limit 16777216.
  • HTML /account/usage shows 0 B / 16.0 MiB storage.

Migration 0018 applied on preview D1 (kody-pr-1569-db); inventory estimate reads still work after dropping leftover-service handling.

@kody-bot
kody-bot merged commit 1d8a06c into main Aug 19, 2026
19 checks passed
@kody-bot
kody-bot deleted the cursor/retire-service-storage-purge-8713 branch August 19, 2026 18:12
Sign up for free to 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.

Confirm leftover kind='service' storage inventory is purged, then remove the retired-service purge lane

3 participants