Skip to main content

Module home_migrate

Module home_migrate 

Source
Expand description

Journaled, resumable migration of the legacy oxicode home (~/.oxicode) into the unified Oxi home layout (<oxicode_home>).

Contract:

  • Preflight produces a plan: source, destination, file count, total bytes, and a state (MigrationState::NothingToDo, MigrationState::Ready, MigrationState::AlreadyMigrated, MigrationState::Conflict).
  • Conflict = the destination already contains a file that differs (size or SHA-256) from its source counterpart. The migration aborts, reports both paths, and touches nothing. A destination identical to the source means MigrationState::AlreadyMigrated (no-op).
  • The journal (<oxi_home>/oxicode.migration-journal.json) is written atomically (temp + rename) BEFORE the first filesystem mutation, with status: "in_progress"; on success it is rewritten with status: "complete".
  • The copy step is idempotent per file: a destination file with the same size + SHA-256 is skipped; otherwise the file is copied to <dest>.part-<pid>, fsynced, and renamed into place (destination directory fsynced best-effort). Because of this, a run that dies mid-copy can simply be re-run: the journal stays in_progress and the rerun repairs/resumes.
  • The verify step walks both trees and requires every source file to exist in the destination with a matching hash. Any mismatch is an error and the journal stays in_progress for the next run to repair.
  • The source is never deleted or modified — migration is copy-only. (Rename optimization is deferred to a later cutover release.)

Structs§

MigrationJournal
On-disk migration journal. Written atomically before the first mutation; a missing or unreadable journal is treated as “no journal”.
MigrationPlan
Result of a preflight run.

Enums§

HomeMigrationError
Errors the migration engine can surface.
MigrationState
Outcome of the preflight analysis. See module docs for the semantics.
RunOutcome
What a run invocation did.

Constants§

JOURNAL_VERSION
Current journal schema version.

Functions§

copy_file_idempotent
Copy sourcedestination if the destination does not already match.
preflight
Analyze a legacy → canonical migration without touching the filesystem.
run
Execute (or dry-run) the migration.
verify
Verify the migration: every source file must exist in the destination with a matching size + SHA-256. Extra destination files are not part of the migration set and are ignored.
walk_files
Recursively list files under root as root-relative paths, sorted for deterministic plans.