Skip to content

CL-9384: migrate persisted approval stores to purge update_plan keys - #1186

Merged
TheGreatAxios merged 4 commits into
mainfrom
cl-9384-migrate-persisted-approval-stores-to-purge-update_plan-keys
Sep 27, 2026
Merged

TheGreatAxios merged 4 commits into
mainfrom
cl-9384-migrate-persisted-approval-stores-to-purge-update_plan-keys

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Collaborator

One-time migration purges update_plan keys from persisted approvals files (session, project, global, provider-model stores). On-disk update_plan grants were dropped at load by normalizeSeededApprovals but never rewritten, so removing the normalizer later would resurrect the hole.

  • Backup-then-rewrite: pre-migration bytes saved to .bak (existing backup kept, so the first backup holds the true original); clean files untouched, no backup written
  • Idempotent: re-run is a no-op (purged 0, no new backups)
  • Reuses canonicalGrantTool as the single owner of is-an-update_plan-key, so disk and memory cannot disagree
  • Wired into loadSeededApprovals; load-time normalizer untouched as defense-in-depth
  • Missing/unreadable/corrupt stores are no-ops; backup failure skips rewrite

Verification: bun run typecheck (exit 0), targeted permission+session suites (589 pass), full bun test ./src ./tests ./evals ./scripts --randomize --seed 424242 (8025 pass, 0 fail), bun run lint (exit 0).

Fixes CL-9384

@linear-code

linear-code Bot commented Sep 26, 2026

Copy link
Copy Markdown

CL-9384

Guard the session-start migration call so a future throw degrades to
log-and-continue, and route the migration rewrite through the shared
chained tmp+rename writer so a concurrent grant mint serializes with
the purge instead of losing an update.
A direct wx write of .bak can crash mid-write and leave a torn
rollback copy. The next start treats that EEXIST as success and
purges live anyway. Write the full backup to a sibling tmp, then
link it onto .bak so the name appears complete or not at all, and
a pre-existing original still wins.
@TheGreatAxios
TheGreatAxios force-pushed the cl-9384-migrate-persisted-approval-stores-to-purge-update_plan-keys branch from 9a53391 to 7145c25 Compare September 27, 2026 22:38
@TheGreatAxios
TheGreatAxios enabled auto-merge (squash) September 27, 2026 22:38
@TheGreatAxios
TheGreatAxios merged commit eb12f0a into main Sep 27, 2026
12 of 13 checks passed
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.

1 participant