Skip to content

refactor(account): detach pending daily counter table - #1134

Merged
kody-bot merged 51 commits into
mainfrom
cursor/meter-do-38c8
Aug 1, 2026
Merged

kody-bot merged 51 commits into
mainfrom
cursor/meter-do-38c8

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Aug 1, 2026 •

Copy link
Copy Markdown
Member

Summary

  • detach quiescent entitlement_daily_counters from runtime export/deletion SQL
  • retain pending-drop schema coverage until migration deploy

Validation

System recap — contracts account inventory wiring (low risk)

Mode: recap · Base: main @ a838a167 · Head: fe1766ba

Runtime account operations no longer query the pending-drop table; schema coverage remains explicit.

Conductor report

Open in Web Open in Cursor 

Summary by CodeRabbit

  • Documentation

    • Clarified the staged retirement of entitlement counter data and its pending migration removal.
    • Updated account export, deletion, retention, and data coverage documentation.
  • Bug Fixes

    • Ensured entitlement counter data is excluded from runtime account exports and deletions while remaining represented in schema coverage.
    • Clarified that no scheduled retention processing accesses this data.
  • Tests

    • Added coverage verifying schema presence, account-data reporting, export exclusion, and retention behavior.

cursoragent and others added 30 commits July 31, 2026 22:46
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
# Conflicts:
#	packages/worker/src/email/inbound.ts
#	packages/worker/src/email/outbound.ts
#	packages/worker/worker-configuration.d.ts

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
# Conflicts:
#	docs/contributing/architecture/data-storage.md
#	packages/worker/src/account/export.node.test.ts
#	packages/worker/src/account/export.ts

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
# Conflicts:
#	docs/contributing/architecture/data-storage.md

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
# Conflicts:
#	docs/contributing/architecture/data-storage.md

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
cursoragent and others added 18 commits August 1, 2026 10:45
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@coderabbitai

coderabbitai Bot commented Aug 1, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change retires entitlement_daily_counters from runtime account deletion, export, and retention handling. It adds pending-drop inventory and schema coverage, updates retention behavior, adds tests, and documents the staged migration sequence.

Changes

Pending-drop table retirement

Layer / File(s) Summary
Pending-drop inventory and coverage
packages/worker/src/account/data-targets.ts
Adds pending-drop target metadata, removes entitlement_daily_counters from active targets, and includes its user columns in schema coverage.
Retirement behavior validation
packages/worker/src/account/data-targets.node.test.ts, packages/worker/src/account/export.node.test.ts, packages/worker/src/app/account-retention-dispositions.ts, packages/worker/src/app/account-retention-dispositions.node.test.ts
Tests pending-drop metadata, export exclusion, migrated-schema coverage, user-column coverage, and non-scheduled retention behavior.
Retirement sequence documentation
docs/contributing/architecture/data-storage.md, docs/contributing/architecture/entitlements.md
Documents stopped runtime access, pending-drop coverage, export exclusion, retention behavior, and staged table removal.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

  • kentcdodds/kody#1115: Moved daily quota handling to UserMeter, which this change follows by retiring the D1 mirror.
  • kentcdodds/kody#1133: Started the entitlement_daily_counters retirement that this change extends.
  • kentcdodds/kody#1064: Uses the same account data-target and retention mechanisms for D1 table retirement.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.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
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: detaching the pending daily counter table from runtime account operations.
✨ 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/meter-do-38c8

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.

@kody-bot
kody-bot marked this pull request as ready for review August 1, 2026 16:44
@cursor

cursor Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

@coderabbitai review

@github-actions

github-actions Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

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

Worker: kody-pr-1134
D1: kody-pr-1134-db
KV: kody-pr-1134-oauth-kv

Mocks:

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
docs/contributing/architecture/entitlements.md (1)

365-375: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Record the exact stage-3 exit actions.

The sequence currently says only “third, migration-only deploy drops the table.” Add migration-only 0126, removal of the pending-drop registry and retention exemption, and the post-deploy assertion daily.mirrorRetired === true. These steps make the retirement runbook executable.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/contributing/architecture/entitlements.md` around lines 365 - 375,
Update the “Daily-counter mirror retirement (three-deploy)” sequence to
explicitly document stage 3 as migration-only migration 0126, including removal
of the pending-drop registry and retention exemption. Add the post-deploy
verification that daily.mirrorRetired === true.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/contributing/architecture/data-storage.md`:
- Around line 77-80: Update the documentation reference to point to
packages/worker/src/account/data-targets.node.test.ts, and revise the
description to identify it as the schema coverage guardrail rather than a
runtime deletion test.

---

Nitpick comments:
In `@docs/contributing/architecture/entitlements.md`:
- Around line 365-375: Update the “Daily-counter mirror retirement
(three-deploy)” sequence to explicitly document stage 3 as migration-only
migration 0126, including removal of the pending-drop registry and retention
exemption. Add the post-deploy verification that daily.mirrorRetired === true.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 41db76e4-7856-49cf-aa1b-2ffe99257a54

📥 Commits

Reviewing files that changed from the base of the PR and between a838a16 and fc3bf7a.

📒 Files selected for processing (7)
  • docs/contributing/architecture/data-storage.md
  • docs/contributing/architecture/entitlements.md
  • packages/worker/src/account/data-targets.node.test.ts
  • packages/worker/src/account/data-targets.ts
  • packages/worker/src/account/export.node.test.ts
  • packages/worker/src/app/account-retention-dispositions.node.test.ts
  • packages/worker/src/app/account-retention-dispositions.ts

Comment on lines +77 to +80
test in `packages/worker/src/app/account-deletion.node.test.ts` applies the
live migrations to SQLite and fails if a user-owned schema column is not
represented in the deletion target list or pending-drop registry, or if those
lists reference a stale column.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

fd -t f -e ts 'account-deletion|data-targets' packages/worker
rg -n -C 4 'accountUserDataPendingDropTargets|entitlement_daily_counters|schema coverage' packages/worker

Repository: kentcdodds/kody

Length of output: 34428


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== docs excerpt =="
sed -n '60,90p' docs/contributing/architecture/data-storage.md || true

echo
echo "== account deletion test outline/searches =="
wc -l packages/worker/src/app/account-deletion.node.test.ts packages/worker/src/account/data-targets.node.test.ts
rg -n 'pending-drop|pending drop|schema coverage|column.*represented|stale column|entitlement_daily_counters|accountUserDataPendingDropTargets|delete.*migration|migration.*deletion' packages/worker/src/app/account-deletion.node.test.ts packages/worker/src/account/data-targets.node.test.ts docs/contributing/architecture/data-storage.md

Repository: kentcdodds/kody

Length of output: 5274


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== account deletion test relevant search =="
rg -n -C 5 "entitlement_daily_counters|pendingDrop|pending-drop|pending drop|accountUserDataPendingDropTargets|schema coverage|coveredColumns|live migrations|apply.*migration|migration.*live|live migrations" packages/worker/src/app/account-deletion.node.test.ts packages/worker/src/account/data-targets.node.test.ts packages/worker/src/account/data-targets.ts || true

echo
echo "== account deletion imports/subjects relevant to data targets =="
sed -n '1,220p' packages/worker/src/app/account-deletion.node.test.ts

Repository: kentcdodds/kody

Length of output: 21668


Point the schema coverage guardrail at the right test.

Update this reference from packages/worker/src/app/account-deletion.node.test.ts to packages/worker/src/account/data-targets.node.test.ts, and mention schema coverage rather than runtime deletion.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/contributing/architecture/data-storage.md` around lines 77 - 80, Update
the documentation reference to point to
packages/worker/src/account/data-targets.node.test.ts, and revise the
description to identify it as the schema coverage guardrail rather than a
runtime deletion test.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@kody-bot
kody-bot merged commit cd3686b into main Aug 1, 2026
10 checks passed
@kody-bot
kody-bot deleted the cursor/meter-do-38c8 branch August 1, 2026 16:58
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.

3 participants