Skip to content

feat(upgrade): implement awf upgrade self-update command#299

Merged
pocky merged 1 commit intomainfrom
feature/F076-awf-upgrade-command-not-implemented--sel
Apr 6, 2026
Merged

feat(upgrade): implement awf upgrade self-update command#299
pocky merged 1 commit intomainfrom
feature/F076-awf-upgrade-command-not-implemented--sel

Conversation

@pocky
Copy link
Copy Markdown
Contributor

@pocky pocky commented Apr 6, 2026

Summary

  • Implements the awf upgrade self-update command (F076), which was previously a stub returning NotImplementedError
  • Downloads platform-specific binaries from GitHub Releases, verifies SHA256 checksums, and atomically replaces the running executable with cross-filesystem fallback
  • Adds --check, --force, and --version flags; warns when the binary appears managed by a package manager; supports GITHUB_TOKEN for rate-limited environments
  • Reuses pkg/registry transport (already used by plugin and workflow pack installers) with no new application service layer — command is wired directly in the CLI interfaces layer

Changes

CLI Command

  • internal/interfaces/cli/upgrade.go: New upgrade command implementing version check, GitHub release fetch, binary download + SHA256 verification, and atomic binary replacement via updater.ReplaceBinary(); flags: --check, --force, --version; package-manager path heuristic with --force escape hatch
  • internal/interfaces/cli/root.go: Register upgradeCmd on the root command

Infrastructure

  • internal/infrastructure/updater/replacer.go: New ReplaceBinary() function — resolves symlinks via EvalSymlinks, writes to temp file, atomically renames (with copy+chmod cross-FS fallback), and verifies the replaced binary is executable

Domain

  • internal/domain/errors/codes.go: Five new typed error codes — USER.UPGRADE.VERSION_NOT_FOUND, USER.UPGRADE.ALREADY_LATEST, SYSTEM.UPGRADE.CHECKSUM_MISMATCH, SYSTEM.UPGRADE.BINARY_REPLACE_FAILED, SYSTEM.UPGRADE.DOWNLOAD_FAILED

Architecture

  • .go-arch-lint.yml: Register infra-updater component; allow interfaces-cli to depend on it alongside existing infra components

Tests

  • internal/interfaces/cli/upgrade_test.go: Table-driven tests covering update-available, already-latest, --check mode, --force, --version, checksum mismatch, permission error, and package-manager warning paths
  • internal/infrastructure/updater/replacer_test.go: Unit tests for ReplaceBinary() covering same-FS success, cross-FS fallback, symlink resolution, and permission denial
  • internal/domain/errors/codes_test.go: Extend existing exhaustive constant, uniqueness, and exit-code tests to include all five new upgrade error codes

Documentation

  • docs/user-guide/upgrade.md: New reference page covering all flags, authentication, and troubleshooting
  • docs/user-guide/commands.md: Add awf upgrade, --check, and --version rows to command table
  • docs/README.md: Link to new upgrade guide
  • README.md: Add awf upgrade to the quick-reference command table
  • CHANGELOG.md: Document F076 under [Unreleased] → Added
  • CLAUDE.md: Add two new pitfall entries for symlink-aware binary replacement and package-manager path warnings

Test plan

  • awf upgrade --check against a repo with a newer release reports the available version without modifying the binary
  • awf upgrade downloads, verifies checksum, and replaces the binary; awf version reflects the new version after execution
  • awf upgrade --version v0.5.0 installs the specified older version (downgrade path)
  • Unit and integration tests pass: make test

Closes #298


Generated with awf commit workflow

- `.go-arch-lint.yml`: Add `infra-updater` component and dependency rules
- `CHANGELOG.md`: Document F076 upgrade command feature
- `CLAUDE.md`: Remove stale pitfall entries, add upgrade pitfalls
- `README.md`: Add upgrade command to feature list
- `docs/README.md`: Add upgrade command reference
- `docs/user-guide/commands.md`: Add upgrade command entry
- `docs/user-guide/upgrade.md`: Add full upgrade command user guide
- `internal/domain/errors/codes.go`: Add USER.UPGRADE.* and SYSTEM.UPGRADE.* error codes
- `internal/domain/errors/codes_test.go`: Add tests for new upgrade error codes
- `internal/infrastructure/updater/replacer.go`: Add ReplaceBinary() with symlink resolution and cross-FS fallback
- `internal/infrastructure/updater/replacer_test.go`: Add unit tests for ReplaceBinary
- `internal/interfaces/cli/root.go`: Register upgrade command
- `internal/interfaces/cli/upgrade.go`: Implement upgrade CLI command with --check, --force, --version flags
- `internal/interfaces/cli/upgrade_test.go`: Add 400+ line test suite for upgrade command

Closes #298
@pocky pocky marked this pull request as ready for review April 6, 2026 21:29
@pocky pocky merged commit fac8b78 into main Apr 6, 2026
5 checks passed
@pocky pocky deleted the feature/F076-awf-upgrade-command-not-implemented--sel branch April 6, 2026 21:30
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.

F076: awf upgrade command not implemented — self-update functionality missing

1 participant