Skip to content

Detach legacy RunLog D1 inventories - #1206

Merged
kentcdodds merged 3 commits into
mainfrom
cursor/runlog-consolidation-1b40
Aug 4, 2026
Merged

kentcdodds merged 3 commits into
mainfrom
cursor/runlog-consolidation-1b40

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Aug 4, 2026 •

Copy link
Copy Markdown
Owner

Intent

Deploy the final application-side inventory and retention cleanup before the migration-only D1 drop. This keeps the old Worker compatible when the later deploy applies migration 0137 before Worker code.

Summary

  • remove workflow_runs, user_package_run_successes, and user_activation_milestones from account deletion/export D1 targets
  • remove the obsolete D1 workflow retention lane and retention dispositions
  • keep all three physical tables quiescent as rollback copies
  • document the three-deploy sequence and pending migration-only drop

Testing

  • application authority cutover deployed: https://github.com/kentcdodds/kody/actions/runs/30876391371
  • production parity: 41/41 non-deleting users, 9 pages, zero gaps
  • pre-drop Time Travel bookmark: 0000116d-000000d2-000050bd-c7ecd5892a189df7cda145af746bc9c9
  • pre-push Node/Workers: 554 files, 1,877 tests passed
  • pre-push E2E: 7 tests passed
  • migration ledger remains at 139 files; next free prefix 0137

System changes

No D1 tables are dropped in this PR. Physical rollback copies remain until the migration-only follow-up deploy.

Conductor report

STATUS: in-progress

What shipped: inventory/retention detachment is pushed; CI/AI review and deployment pending.

Risk self-assessment: medium — deletion/export and retention inventories change, but physical tables and Time Travel recovery remain.

Merged/deployed: no / no.

Scope spill: none. This is deploy 2 of 3; deploy 3 is migration-only 0137 and will stop for conductor review.

Open in Web Open in Cursor 

Summary by CodeRabbit

  • Data Management

    • Account deletion and export inventories no longer include retired workflow projection data.
    • Retention processing no longer manages workflow-run records.
    • Legacy projection data remains available as a rollback copy until scheduled migration cleanup.
  • Documentation

    • Clarified deployment, rollback, retention, and data-storage behavior.
    • Documented the pre-removal recovery checkpoint and migration status.
  • Entitlements & Administration

    • Updated usage and administrative reporting to stop relying on retired workflow-run projections.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The change detaches legacy RunLog D1 projection tables from account deletion/export, retention, runtime queries, and entitlement mocks. The tables remain rollback copies until migration 0137 removes them. Documentation and tests record the new state and migration evidence.

Changes

RunLog projection detachment

Layer / File(s) Summary
Account inventory detachment
packages/worker/src/account/data-targets.ts, packages/worker/src/account/*test.ts, packages/worker/src/app/account-deletion.node.test.ts
Defines detached projection tables and removes them from account deletion/export inventories and coverage requirements.
Retention path removal
packages/worker/src/app/retention.ts, packages/worker/src/app/*retention*test.ts
Removes workflow-run and package-success retention handling. Retention tests use platform feedback and audit events instead.
Runtime consumer cleanup
packages/worker/src/admin/user-usage-data.node.test.ts, packages/worker/src/entitlements/*, packages/worker/src/mcp/capabilities/admin/admin-capabilities.node.test.ts
Removes workflow-run mirror handling from mocks and clarifies the authoritative entitlement usage reader.
Migration and RunLog documentation
docs/contributing/architecture/*.md, packages/worker/src/account/user-owned-surfaces.*
Documents the detached rollback-copy state, cutover evidence, Time Travel bookmark, and migration 0137 removal procedure.

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

Possibly related PRs

  • kentcdodds/kody#1195: Migrates and verifies the legacy D1 projections into RunLog.
  • kentcdodds/kody#1114: Covers the related migration that precedes detachment of legacy RunLog projections.
  • kentcdodds/kody#1064: Retires legacy D1-backed user-data projections across inventories, retention, tests, and documentation.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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 and concisely describes detaching legacy RunLog D1 inventories, which is the main change.
Description check ✅ Passed The description includes all required sections and clearly explains intent, changes, testing evidence, and system impact.
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.
✨ 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/runlog-consolidation-1b40

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.

@cursor cursor Bot changed the title Drop legacy RunLog D1 projections Detach legacy RunLog D1 inventories Aug 4, 2026
@kody-bot
kody-bot marked this pull request as ready for review August 4, 2026 04:33
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

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

Worker: kody-pr-1206
D1: kody-pr-1206-db
KV: kody-pr-1206-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: 2

🤖 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 217-222: Update the account-erasure flow to continue purging
deleted-user rows from the legacy projection tables workflow_runs,
user_package_run_successes, and user_activation_milestones until migration 0137
drops them. Add an explicit pre-drop per-user purge or retain these tables in
the existing deletion coverage, and ensure the coverage stops only after the
physical tables are removed.

In `@packages/worker/src/account/data-targets.ts`:
- Around line 74-84: Remove the user-scoped tables from
accountQuiescentDetachedD1ProjectionTables so workflow_runs,
user_package_run_successes, and user_activation_milestones remain covered by
deletion, export, and retention until their physical drop; use only a
non-user-owned sanitized rollback artifact if rollback data is needed.
🪄 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: 75fec259-6f5e-476d-9952-38f2671b8847

📥 Commits

Reviewing files that changed from the base of the PR and between 8b8a6d7 and 1d31576.

📒 Files selected for processing (17)
  • docs/contributing/architecture/data-storage.md
  • docs/contributing/architecture/entitlements.md
  • docs/contributing/architecture/run-records.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/account/user-owned-surfaces.node.test.ts
  • packages/worker/src/account/user-owned-surfaces.ts
  • packages/worker/src/admin/user-usage-data.node.test.ts
  • packages/worker/src/app/account-deletion.node.test.ts
  • packages/worker/src/app/account-retention-dispositions.node.test.ts
  • packages/worker/src/app/account-retention-dispositions.ts
  • packages/worker/src/app/retention.node.test.ts
  • packages/worker/src/app/retention.ts
  • packages/worker/src/entitlements/entitlements.node.test.ts
  • packages/worker/src/entitlements/service.ts
  • packages/worker/src/mcp/capabilities/admin/admin-capabilities.node.test.ts
💤 Files with no reviewable changes (4)
  • packages/worker/src/app/account-retention-dispositions.ts
  • packages/worker/src/admin/user-usage-data.node.test.ts
  • packages/worker/src/mcp/capabilities/admin/admin-capabilities.node.test.ts
  • packages/worker/src/app/retention.ts

Comment on lines +217 to +222
by retention. Legacy D1 projection tables (`workflow_runs`,
`user_package_run_successes`, `user_activation_milestones`) are quiescent
rollback copies outside account deletion/export inventory; migration-only
`0137` drops the physical tables. Pre-drop D1 Time Travel bookmark for
database `8c1014d1-6b41-4695-a0a2-159071f0f919`:
`0000116d-000000d2-000050bd-c7ecd5892a189df7cda145af746bc9c9`. See

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

rg -n -C 8 \
  'workflow_runs|user_package_run_successes|user_activation_milestones' \
  packages/worker/src/account packages/worker/src/app packages/worker/migrations

Repository: kentcdodds/kody

Length of output: 38361


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

echo "== docs references =="
sed -n '190,235p' docs/contributing/architecture/data-storage.md
sed -n '318,345p' docs/contributing/architecture/data-storage.md
sed -n '1488,1512p' docs/contributing/architecture/data-storage.md

echo
echo "== data-targets around quiescent tables =="
sed -n '60,95p' packages/worker/src/account/data-targets.ts

echo
echo "== user-owned-surfaces run_log notes =="
sed -n '110,129p' packages/worker/src/account/user-owned-surfaces.ts

echo
echo "== account-related references =="
rg -n -C 5 'accountQuiescentDetachedD1ProjectionTables|legacy projection|workflow_runs|user_package_run_successes|user_activation_milestones|delete .*account|account deletion|retention' packages/worker/src/account packages/worker/src/app docs/contributing/architecture/data-storage.md

echo
echo "== account deletion code outline candidates =="
rg -n 'deleteAccount|clearAll|DELETED|deleted|account.*delete|durable storage|D1|workflow_runs|user_package_run_successes|user_activation_milestones' packages/worker/src/account packages/worker/src/app -g '!*.test.*' -g '!*.node.test.*' | head -n 250

Repository: kentcdodds/kody

Length of output: 50372


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

echo "== definitions and array consumers =="
rg -n -C 5 'accountQuiescentDetachedD1ProjectionTables|accountUserDataTargets|buildUserScopedTargetMatch|userOwnedD1Surfaces|D1Table|D1Target|deleteAll|clearAllRows|account deletion|deleteByUserId' packages/worker/src/account packages/worker/src/app packages/worker/src -g '!*.test.*' -g '!*.node.test.*'

echo
echo "== account data-targets full relevant area =="
sed -n '1,180p' packages/worker/src/account/data-targets.ts

echo
echo "== migration 0137 schema/drop =="
fd -e sql . packages/worker/migrations | rg '0137|0136' || true
for f in packages/worker/migrations/0137*.sql packages/worker/migrations/0136*.sql; do
  if [ -f "$f" ]; then
    echo "--- $f ($(wc -l < "$f") lines) ---"
    head -n 220 "$f"
  fi
done

Repository: kentcdodds/kody

Length of output: 50372


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

echo "== 0137 drops / related cleanup =="
for f in packages/worker/migrations/0137*.sql packages/worker/migrations/0136*.sql packages/worker/migrations/0138*.sql; do
  [ -f "$f" ] || continue
  echo "--- $f ($(wc -l < "$f") lines) ---"
  rg -n -C 4 'workflow_runs|user_package_run_successes|user_activation_milestones|DROP TABLE|DROP INDEX|CREATE TRIGGER|DELETE FROM|ON DELETE CASCADE' "$f" || true
done

echo
echo "== buildUserScopedTargetMatch implementation =="
sed -n '450,620p' packages/worker/src/account/data-targets.ts

echo
echo "== account deletion D1 section =="
sed -n '1000,1090p' packages/worker/src/app/account-deletion.ts

echo
echo "== retention dispositions relevant lines =="
sed -n '1,110p' packages/worker/src/app/account-retention-dispositions.ts

Repository: kentcdodds/kody

Length of output: 10074


Keep legacy projection rows in user-account erasure until migration 0137.

workflow_runs, user_package_run_successes, and user_activation_milestones still hold rows for deleted users until the destructive migration drops the physical tables, because account deletion/export and retention inventory no longer touch them. Add an explicit pre-drop purge for these per-user rows, or keep them covered until the physical drop.

🤖 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 217 - 222,
Update the account-erasure flow to continue purging deleted-user rows from the
legacy projection tables workflow_runs, user_package_run_successes, and
user_activation_milestones until migration 0137 drops them. Add an explicit
pre-drop per-user purge or retain these tables in the existing deletion
coverage, and ensure the coverage stops only after the physical tables are
removed.

Source: Coding guidelines

Comment on lines +74 to +84
/**
* Legacy RunLog D1 projection tables kept as quiescent rollback copies after
* the RunLog authority application deploy. Deploy 2 detaches account
* deletion/export inventory and the hourly D1 workflow_runs retention lane;
* migration-only `0137` drops the physical tables.
*/
export const accountQuiescentDetachedD1ProjectionTables = [
'workflow_runs',
'user_package_run_successes',
'user_activation_milestones',
] as const

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift

Keep these user-scoped tables in deletion and export coverage.

These tables remain present and contain user_id rows. Detaching deletion, export, and retention leaves deleted-user RunLog data in durable storage with no scheduled cleanup. Keep deletion and export coverage until the physical drop. If rollback data is required, store only a sanitized artifact that is not user-owned.

As per coding guidelines, “Every signed-in user must have a fully isolated personal assistant, including separate packages, jobs, secrets, values, memories, remote connectors, email inboxes, and durable storage.”

🤖 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/account/data-targets.ts` around lines 74 - 84, Remove the
user-scoped tables from accountQuiescentDetachedD1ProjectionTables so
workflow_runs, user_package_run_successes, and user_activation_milestones remain
covered by deletion, export, and retention until their physical drop; use only a
non-user-owned sanitized rollback artifact if rollback data is needed.

Source: Coding guidelines

@kentcdodds
kentcdodds merged commit 0a67365 into main Aug 4, 2026
17 checks passed
@kentcdodds
kentcdodds deleted the cursor/runlog-consolidation-1b40 branch August 4, 2026 04:44
kentcdodds added a commit that referenced this pull request Aug 4, 2026
Migration-only follow-up to the RunLog authority cutover (#1205) and
inventory detach (#1206). Drops quiescent workflow_runs,
user_package_run_successes, and user_activation_milestones with their
indexes. Pre-drop Time Travel bookmark recorded in the migration header.

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
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.

2 participants