Skip to content

Migrate claude_code profile rule UUIDs to deterministic builtin: format#995

Open
0x0079 wants to merge 2 commits into
mainfrom
claude/migrate-profile-ids-KQ0oZ
Open

Migrate claude_code profile rule UUIDs to deterministic builtin: format#995
0x0079 wants to merge 2 commits into
mainfrom
claude/migrate-profile-ids-KQ0oZ

Conversation

@0x0079

@0x0079 0x0079 commented May 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR introduces a data migration (2026-05-19) that rewrites claude_code profile rule UUIDs from random UUIDs to a deterministic builtin:claude_code:{profileID}:{model} format. It also updates the rule creation logic to use this deterministic format for new profiles.

Key Changes

  • New migration function migrate20260519(): Processes all claude_code profile rules and:

    • For unified profiles (1 rule): rewrites UUID to builtin:claude_code:{profileID}:cc
    • For separate profiles (≥2 rules): normalizes to exactly 5 rules in fixed order (default/haiku/sonnet/opus/subagent), deleting overflow rules and filling missing slots with new rules
    • Handles orphaned rules whose ProfileMeta no longer exists
    • Is idempotent and skips non-claude_code rules
  • Updated newCCProfileRules(): Now accepts profileID parameter and generates rules with deterministic UUIDs instead of random ones, enabling consistent rule identification and migration

  • Comprehensive test coverage: Added 8 test cases covering:

    • Unified single rule migration
    • Separate mode with 5 rules in mixed order
    • Overflow handling (excess rules dropped)
    • Missing slot filling (partial rules expanded to 5)
    • Orphaned rules (ProfileMeta deleted but rules remain)
    • Idempotency (running migration twice is safe)
    • Non-claude_code rule preservation
    • Already-migrated rule handling

Implementation Details

  • Migration is integrated into the standard Migrate() flow and automatically saves config on changes
  • Uses profile grouping and two-pass slot assignment (match by RequestModel first, then fill remaining slots)
  • Logs warnings for dropped overflow rules and info messages for filled slots
  • Prevents UUID collisions by tracking taken UUIDs during migration
  • Synthesized rules for empty slots include default LBTactic configuration and descriptive names

https://claude.ai/code/session_01UxrWbxE84Yyg6GC9Dx3huE

claude added 2 commits May 19, 2026 14:54
…le rules

Rules created under a claude_code profile previously got random UUIDs,
which made them impossible to reference, lock, or migrate reliably.
Switch to a deterministic format mirroring the Claude Desktop pattern:

  builtin:claude_code:{profileID}:{cc|default|haiku|sonnet|opus|subagent}

- newCCProfileRules now generates UUIDs from profileID + RequestModel.
- migrate20260519 rewrites existing profile rules to the new format:
  * 1 rule  -> unified, UUID becomes :cc
  * >=2 rules -> normalized to exactly 5 (default/haiku/sonnet/opus/subagent);
    extras dropped, missing slots filled from a service-bearing sibling.
  * Orphan rules (ProfileMeta gone) are migrated in place, not deleted.
- ProfileMeta.ID, profile names, frontend routes, and other builtin
  constants are untouched.
migrate20260519 should only rewrite UUIDs and synthesize empty placeholder
rules for missing slots — copying services from a sibling rule conflated
the migration with user-facing configuration. Newly created rules now
match newCCProfileRules behavior: empty services for the user to set.
@0x0079 0x0079 force-pushed the claude/migrate-profile-ids-KQ0oZ branch from 1a331b8 to 5c6c7d6 Compare May 19, 2026 14:59
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