Skip to content

feat(user): run numbered migration steps on the user data directory - #211

Draft
ehennestad wants to merge 1 commit into
claude/project-catalog-save-path-2f51f0from
chain-user-data-migrations
Draft

ehennestad wants to merge 1 commit into
claude/project-catalog-save-path-2f51f0from
chain-user-data-migrations

Conversation

@ehennestad

Copy link
Copy Markdown
Collaborator

Problem

A change that moves user data needs to know which earlier changes a directory has had. Someone who skipped several updates has to pass through all of them in order. The startup actions in NansenUserSession each decide from what they find on disk, which cannot tell one layout from another once there are several.

Change

nansen.internal.user.UserDataLayout.getMigrationSteps lists numbered steps for the user data directory. nansen.internal.migration.applyMigrationSteps runs the steps above the stored version in order and records each one as it finishes. A failed step stops the session with NANSEN:Migration:StepFailed, the stored version stays at the last step that finished, and the next start resumes there.

The list is empty today. The next change that moves data adds a step with Version one above the last, and sets CURRENT_VERSION to that number. testCurrentVersionMatchesTheLastMigrationStep fails if the two disagree. A directory without a version file holds FIRST_VERSION, the layout that the move out of the preference directory produces.

A session stops with NANSEN:UserSession:UserDataLayoutNewer when a newer version of NANSEN organised the directory, for example after checking out an older branch. The check runs before any startup action, because this code could write over data it does not recognise.

What is not a step

The move out of the preference directory is not a step. Each MATLAB release has its own preference directory, so a release has to move its own data even when the shared directory is already versioned. Once the directory has passed FIRST_VERSION, a release that starts later renames its folders to <name>.unmigrated and moves nothing, so two layouts are never mixed.

The other startup actions stay as they are. The _userdata move belongs to an installation, moveExternalToolboxes to the add-ons, and upgradeProjects to each project, so a version stored with the user data does not describe them.

🤖 Generated with Claude Code

The layout version stored in the user data directory only recorded a
state. A later change that moves data needs to know which changes a
directory has had, including several for someone who skipped updates.

UserDataLayout.getMigrationSteps lists numbered steps, and
applyMigrationSteps runs those above the stored version in order and
records each as it finishes, so a chain that stops resumes where it
stopped. The list is empty today: the next change that moves data adds
the first step and sets CURRENT_VERSION to its number.

A session refuses a directory that a newer version of NANSEN organised,
because this code could write over data it does not recognise. A
release that starts after the directory has moved past the first layout
renames its folders instead of moving them in, so that two layouts are
never mixed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ehennestad
ehennestad added this pull request to stack #212 November 9, 2026 08:57
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Test Results

784 tests  +15   783 ✅ +15   2m 0s ⏱️ +3s
 59 suites + 1     1 💤 ± 0 
  1 files   ± 0     0 ❌ ± 0 

Results for commit db5055d. ± Comparison against base commit 44abca3.

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