feat(entitlements): reap remaining authority narrows - #1217
Conversation
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
📝 WalkthroughWalkthroughUserMeter is now authoritative for account-write leases, package-service liveness, storage bytes, and deletion state. Migration 0141 removes obsolete D1 lease storage and flags. Exports, parity reports, tests, and architecture documentation now use the authoritative model. ChangesUserMeter authority migration
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
|
🔎 Preview deployed: https://kody-pr-1217.kody-a99.workers.dev Worker: Mocks:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/worker/src/entitlements/account-write-lease-cleanup-migration.node.test.ts (1)
67-74: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winAssert repair-audit row retention.
Lines 67-74 only prove that
account_write_lease_repairsexists. Insert a valid repair row before migration 0141 and assert that it remains afterward. This verifies retained audit history and detects foreign-key action or cascade behavior caused by droppingaccount_write_leases.🤖 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 `@packages/worker/src/entitlements/account-write-lease-cleanup-migration.node.test.ts` around lines 67 - 74, Extend the migration test around the existing account_write_lease_repairs table assertion by inserting a valid repair-audit row before migration 0141 runs, then query the table afterward and assert that the row is still present. Use the schema’s required fields and valid references, and retain the existing table-existence assertion to verify both table creation and audit-row preservation.
🤖 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 `@packages/worker/src/account/export.ts`:
- Around line 310-313: Update the documentation for the storageBytesState field
in the user-meter export result to state that the first page provides the
authoritative state and later pages include the property with a null value,
rather than omitting it. Keep the existing type and paging semantics unchanged.
---
Nitpick comments:
In
`@packages/worker/src/entitlements/account-write-lease-cleanup-migration.node.test.ts`:
- Around line 67-74: Extend the migration test around the existing
account_write_lease_repairs table assertion by inserting a valid repair-audit
row before migration 0141 runs, then query the table afterward and assert that
the row is still present. Use the schema’s required fields and valid references,
and retain the existing table-existence assertion to verify both table creation
and audit-row preservation.
🪄 Autofix
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: ef3b655f-a8b9-41ee-87bb-1848968f7cb2
📒 Files selected for processing (23)
docs/contributing/account-write-lease-repair.mddocs/contributing/architecture/data-storage.mddocs/contributing/architecture/entitlements.mddocs/contributing/architecture/primitives.yamldocs/contributing/architecture/run-records.mdpackages/worker/migrations/0141-drop-account-write-leases-and-stale-flags.sqlpackages/worker/src/account/data-targets.tspackages/worker/src/account/deletion-state.node.test.tspackages/worker/src/account/export.node.test.tspackages/worker/src/account/export.tspackages/worker/src/account/user-owned-surfaces.tspackages/worker/src/admin/user-meter-parity.node.test.tspackages/worker/src/admin/user-meter-parity.tspackages/worker/src/entitlements/account-write-lease-cleanup-migration.node.test.tspackages/worker/src/entitlements/package-service-states.workers.test.tspackages/worker/src/entitlements/service.tspackages/worker/src/entitlements/user-meter-do.tspackages/worker/src/entitlements/user-meter.workers.test.tspackages/worker/src/mcp/capabilities/admin/admin-user-meter-parity.node.test.tspackages/worker/src/mcp/capabilities/admin/admin-user-meter-parity.tspackages/worker/src/test-support/user-meter.tspackages/worker/src/users-test-schema.tstools/migration-ledger.json
💤 Files with no reviewable changes (2)
- packages/worker/src/account/data-targets.ts
- packages/worker/src/entitlements/package-service-states.workers.test.ts
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Intent
Close the remaining pre-launch UserMeter entitlement narrows from #1069 so no runtime or documentation presents D1 as a package-service liveness or account-write-lease authority.
Summary
authoritycolumn*Shadownames to authoritative namesTesting
npm run validate— passedSystem changes
System recap — extends existing primitives (medium risk)
Mode: recap · Base:
main@6a77bf08· Head:989b9370Classification: extends — this PR narrows persisted schemas and exported/admin contracts without adding a primitive.
Primitives touched
user-meterauthoritycolumnd1-app-dbentitlementsaccount-export*ShadownamesrbacSystem map
Entitlement enforcement and account export read authoritative UserMeter state; D1 retains payload recomputation, enumeration inventories, deletion tombstones, and repair audit data only.
Legend: green = composes (wiring only) · amber = extended by this PR · red = new primitive · gray = context (unchanged, included only when an edge crosses it).
Before / after
authorityauthoritystorageBytesShadow,packageServiceStatesShadow,deletionShadowstorageBytesState,packageServiceStates,deletionStateInvariants
Per-user Durable Object isolation remains unchanged: each stable user id maps to one UserMeter object, and the v8 rebuild runs inside that object's serialized initialization.
Conductor report
STATUS done — PR #1217 squash-merged as
b9f83a33; local validate, AI review, and main CI are green; production deploy applied migration 0141 and deployed Worker version223c78c5-0618-4050-af66-5b070a4e2234; productionadmin_feature_flag_listreturns onlydemo-indicator, with no stale flags or overrides. Remains: none for this track.Summary by CodeRabbit
New Features
Bug Fixes
Documentation