Skip to content

refactor(migration): make migrations user-invoked via 'amplifier-agent migrate'#52

Merged
manojp99 merged 1 commit into
mainfrom
feat/standalone-migrate-subcommand
Jun 12, 2026
Merged

refactor(migration): make migrations user-invoked via 'amplifier-agent migrate'#52
manojp99 merged 1 commit into
mainfrom
feat/standalone-migrate-subcommand

Conversation

@manojp99

Copy link
Copy Markdown
Collaborator

Motivation

Two storage migrations were auto-running on every engine boot and update, producing log noise:

  1. Sessions migration (flat → workspaces): Ran on every engine boot via _runtime.py:286
  2. XDG migration (~/.amplifier-agent): Ran after every amplifier-agent update via update.py:300

Both migrations are idempotent one-shot operations — auto-execution provided little value beyond the first invocation. Making them explicitly user-invoked via amplifier-agent migrate subcommand improves the UX.

What changed

Removed auto-invocation sites:

  • src/amplifier_agent_lib/_runtime.py: Removed import, _MIGRATION_RAN guard, and migrate_legacy_sessions_if_needed() call from handler()
  • src/amplifier_agent_cli/admin/update.py: Removed import and entire migration call block from the returncode == 0 path

Added standalone subcommand:

  • src/amplifier_agent_cli/admin/migrate.py (NEW): amplifier-agent migrate Click command that calls both migrations in sequence, supports --output {text,json}
  • src/amplifier_agent_cli/__main__.py: Wired subcommand into CLI

Updated documentation:

  • src/amplifier_agent_lib/migration.py docstring: Functions now user-invoked, not auto-run
  • docs/designs/2026-06-11-drop-xdg-and-flag-cleanup.md: Appended "Amendment — Migration Auto-Invocation Removed" section

Test changes:

  • tests/test_runtime_migration_wired.py: Inverted assertions (now tests NOT called on boot)
  • tests/cli/test_admin_migrate.py (NEW): 15 tests covering migration invocation, idempotency, JSON output, exit codes, CLI wiring

Migration UX after this PR

Before After
Sessions migration: ran on every engine boot (logs every turn) Sessions migration: user runs amplifier-agent migrate when ready
XDG migration: ran on every update XDG migration: user runs amplifier-agent migrate when ready

Both migrations remain idempotent and safe to re-run. Subsequent calls report skipped=True.

Wrapper contract preservation

No wrapper-facing surface changed. Wrappers never relied on auto-migration. No flag changes, no envelope shape changes, no exit code changes.

Test results

710 tests pass.

Pre-existing integration failures (test_audit_e2e, test_workspace_e2e, test_migration_e2e) reference a --provider flag and predate this branch — unrelated to this change.

Companion

Companion to the design doc at docs/designs/2026-06-11-drop-xdg-and-flag-cleanup.md (which now has an amendment section noting this follow-up).

…t migrate'

Removed automatic invocation of storage migrations from the engine boot path
and update command. Both migrations (flat sessions → workspaces, XDG → ~/.amplifier-agent)
are idempotent one-shot operations that provided minimal value via auto-execution.

User feedback: migration logs are annoying during normal use. Making migrations
explicitly invoked via 'amplifier-agent migrate' subcommand improves the UX.

Changes:
- Removed migrate_legacy_sessions_if_needed() call from _runtime.py handler()
- Removed maybe_migrate_legacy_xdg_storage() call from update.py
- Added 'amplifier-agent migrate' subcommand (admin/migrate.py)
- Wired subcommand into CLI (__main__.py)
- Updated migration.py docstring to reflect user-invoked contract
- Inverted assertions in test_runtime_migration_wired.py (now tests NOT called)
- Added comprehensive test suite test_admin_migrate.py (15 tests)
- Appended 'Amendment' section to design doc documenting follow-up

Both migrations remain idempotent and safe to re-run. Subsequent invocations
report skipped=True. Wrapper-facing contracts unchanged.

Test results: 710 pass; pre-existing integration failures unrelated.

Generated with [Amplifier](https://github.com/microsoft/amplifier)

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
@manojp99 manojp99 merged commit adc0552 into main Jun 12, 2026
2 of 3 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