Skip to content

Sub-Issue 3: Implement Auto-Migration Logic #109

@leppikallio

Description

@leppikallio

Parent Issue: #84
Estimated Time: ~25 minutes
Phase: 3 (Parallel with Sub-Issue 4)

Goal

Auto-migrate config on first run - create user config with vault_location and migrate oauth.client_id from repo config.

Files

  • Modify: .workspace/scripts/config.py (add migration function)
  • Modify: .workspace/config.yaml (remove oauth.client_id during migration)
  • Test: .workspace/tests/test_config_migration.py (new file)

Dependencies

Requires: Sub-Issues 1 & 2 completed
Phase: Phase 3 (parallel with Sub-Issue 4)

Implementation Steps

See full implementation steps in issue #84 under "Sub-Issue 3: Implement Auto-Migration Logic"

Summary

  1. Write failing tests for migration (4 tests)
  2. Implement _migrate_config() function
  3. Add migration call to load_config()
  4. Run tests to verify they pass
  5. Test migration with real config
  6. Run type checker
  7. Commit changes
  8. Close this sub-issue

Key Requirements

  • CRITICAL: Use atomic writes (temp file → chmod 0o600 → os.replace)
  • Never delete or corrupt existing files
  • Follow OAuth storage pattern (.workspace/scripts/oauth/storage.py:136-175)
  • Set 0o600 permissions on user config
  • Preserve user config if it already exists

Acceptance Criteria

  • Creates ~/.config/vipunen/config.yaml on first run
  • Sets vault_location from cwd
  • Moves oauth.client_id from repo to user config
  • Removes oauth section from repo config
  • Sets 0o600 permissions on user config
  • Preserves existing user config (no overwrite)
  • All tests pass
  • Type checking passes

Testing Commands

uv run pytest .workspace/tests/test_config_migration.py -v
uv run pyright .workspace/scripts/config.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions