Skip to content

feat(migrations): port data-integrity migrations with shell-summary backfill#60

Merged
tyulyukov merged 7 commits into
mainfrom
marcode/port-data-integrity-migrations
Apr 22, 2026
Merged

feat(migrations): port data-integrity migrations with shell-summary backfill#60
tyulyukov merged 7 commits into
mainfrom
marcode/port-data-integrity-migrations

Conversation

@tyulyukov
Copy link
Copy Markdown
Owner

Summary

  • Add projection_threads shell-summary columns (latest_user_message_at, pending_approval_count, pending_user_input_count, has_actionable_proposed_plan) to support MarCode's two-phase bootstrap (sidebar renders immediately with hollow threads)
  • Backfill shell-summary columns from existing activities, messages, and proposed plans
  • Clean up invalid pending approvals that lack corresponding approval-requested activities
  • Add projection pipeline logic to mark stale approval request failures as resolved (handles "unknown pending permission request" edge case)
  • Port upstream migrations 027-029 with MarCode-specific adaptations (e.g., lazy computation of pendingApprovalCount via SQL aggregate instead of denormalized column at runtime)

Testing

  • bun run test — all tests pass, including comprehensive migration backfill tests (028_BackfillProjectionThreadShellSummary.test.ts)
  • ProjectionPipeline.test.ts — new tests verify stale approval cleanup and non-stale failure handling
  • Migration tests verify SQL assertions for backfilled data and cleanup results
  • serverSettings tests updated to match schema changes
  • No breaking changes to public APIs; migrations are additive and backfill-safe for existing users

tyulyukov and others added 7 commits April 22, 2026 20:47
Backport upstream ce9f337 (pingdotgg#1973 "Add shell snapshot queries") as a
column-only migration — just the four ALTER TABLE statements needed by
downstream backfill / cleanup migrations.

MarCode's ProjectionSnapshotQuery still computes these values on the
fly via SQL aggregates (lazy-hydration design), so this migration adds
the columns as dormant storage to unblock upstream migrations that
write to them. The aggregate-query reads remain authoritative.

Columns added to projection_threads:
- latest_user_message_at (TEXT)
- pending_approval_count (INTEGER NOT NULL DEFAULT 0)
- pending_user_input_count (INTEGER NOT NULL DEFAULT 0)
- has_actionable_proposed_plan (INTEGER NOT NULL DEFAULT 0)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Upstream c9b07d6 (pingdotgg#2004) added two ProjectionPipeline tests that assert
on projection_threads.pending_approval_count after runtime projection.
The prerequisite commit ce9f337 (pingdotgg#1973) teaches the pipeline to update
that denormalized column alongside the projection_pending_approvals
table, but MarCode's lazy-hydration design (see FEATURES.md) keeps the
count computed via SQL aggregate at query time and leaves the column
dormant (migration-time backfill only).

Drop the threadRows queries + assertions from both upstream tests and
leave a comment pointing to the architectural divergence. The approval
row assertions (the actual stale/non-stale routing behavior) are
preserved.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@tyulyukov tyulyukov merged commit 33ef2dc into main Apr 22, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants