Skip to content

fix(integrations): refresh the fallback's manifest hashes on uninstall - #5274

Merged
mnriem merged 2 commits into
github:mainfrom
kartsan03:fix/uninstall-fallback-resync
Nov 5, 2026
Merged

mnriem merged 2 commits into
github:mainfrom
kartsan03:fix/uninstall-fallback-resync

Conversation

@kartsan03

@kartsan03 kartsan03 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Description

specify integration uninstall of the default integration makes another installed integration the default and re-registers extensions and presets for it, but never refreshes the hashes of the files those presets rewrite. A preset that overrides a core command then leaves a stale hash on the new default: integration status reports the file as modified, and integration upgrade refuses without --force. #5193 fixed the same gap for init --force and the integration switch rollback, and left this path out because #5100 was going to move it. #5100 has since been closed, so the code is still in command_uninstall.py.

Both fallback blocks in command_uninstall.py (the normal path, and the one taken when the uninstalled integration's manifest is missing) now call _register_fallback_contributions(). Like the switch rollback in #5193, it takes _snapshot_manifest_before_registration() before re-registering and passes unmodified_files to _resync_manifest_after_registration(). Only files that were unmodified before and changed by registration get a new hash, so a file the user edited earlier keeps its old hash and is still reported as modified. Both steps are best-effort: a missing manifest is skipped, a corrupt one or a failed save prints a warning, and the uninstall still succeeds.

Repro with the real CLI and the bundled scaffold preset:

specify init --here --integration claude --script sh --ignore-agent-tools
specify integration install codex --script sh
specify preset add --dev <spec-kit>/presets/scaffold
specify integration uninstall claude          # codex becomes the default
specify integration status --json
specify integration upgrade codex --script sh
Step main (6d7a994) This PR
codex manifest after preset add no modified files no modified files
integration status after the uninstall warning, 1 modified file ok, 0 modified
upgrade codex exit 1, "1 file(s) have been modified since installation: .agents/skills/speckit-specify/SKILL.md" exit 0

On both, the uninstall prints "1 modified file(s) were preserved: .claude/skills/speckit-specify/SKILL.md". That is Claude's own copy, which preset add rewrote earlier; docs/integrations/claude.md says preset commands modify installed skill files and need upgrade --force afterwards. This PR doesn't change that.

A project already left stale by main stays that way until specify integration upgrade codex --force, which also overwrites real edits to managed files. I checked that on a project left stale by main, one forced upgrade makes status clean again and plain upgrades work after it.

Refs #5078

Testing

  • Tested locally with uv run specify --help
  • Ran existing tests with uv sync && uv run pytest
  • Tested with a sample project (if applicable)

New tests in tests/specify_cli/integrations/test_command_uninstall.py, class TestUninstallFallbackManifest, through the CLI with a real preset. Each runs with the uninstalled integration's manifest present and deleted, to cover both fallback blocks:

  • test_uninstall_syncs_fallback_manifest_without_blessing_user_edits[None|plan|tasks]: after the uninstall, codex is the default, its hash matches the preset-rendered skill, status shows 0 modified files and a plain upgrade exits 0. A skill the user edited before the uninstall (plan, which the preset doesn't touch, and tasks, which it rewrites) keeps its old hash, and upgrade still refuses.
  • test_uninstall_fallback_manifest_refresh_is_best_effort[missing|corrupt|save-error]: the preset is still registered, a missing manifest isn't created, a corrupt one is left as it is, and a failed save prints a warning while the uninstall exits 0.

With command_uninstall.py reverted to main, 8 of the 12 cases fail. The tasks edit case and the missing-manifest case pass on main too, since main never re-hashes. With unmodified_files dropped from the resync, the plan and tasks edit cases fail; with the manifest is not None check removed, the missing and corrupt cases fail.

Full suite on Linux, Python 3.13: 13945 passed, 449 skipped, 1 failed (uv sync --extra test, then pytest -n 2, 9 min). The failure, test_version_execution.py::TestWindowsUvToolEnvironment::test_non_windows_uv_tool_dry_run_still_previews_installer, fails the same way on main here: Rich wraps the dry-run output, and my checkout's venv path is long enough to be split mid-path. Ruff 0.15.0 (ruff check src tests) passes. I haven't run it on Windows.

AI Disclosure

  • I did not use AI assistance for this contribution
  • I did use AI assistance (fill in the disclosure below)

AI disclosure: Codex CLI (model: gpt-6.1-sol, reasoning effort xhigh, autonomous, offline sandbox) reproduced the path on main and wrote the fix and the tests. Claude Code (model: claude-opus-5-5, autonomous) reviewed the change, reran the repro with the real CLI on main and the branch, checked which tests fail without each part of the fix, ran the full suite and lint, and drafted this description. The commit carries Assisted-by: trailers for both.

Uninstalling the default integration re-registers extensions and presets
for the fallback integration but never refreshed the hashes of files
those presets rewrite, so status reported them as modified and a plain
upgrade refused. Snapshot the fallback's manifest before registration
and resync files that were unmodified before, as the switch rollback
does since github#5193.

Assisted-by: Codex CLI (model: gpt-6.1-sol, autonomous)
Assisted-by: Claude Code (model: claude-opus-5-5, autonomous)
@kartsan03
kartsan03 requested a review from mnriem as a code owner November 5, 2026 17:17
Copilot AI adaptive review requested due to automatic review settings November 5, 2026 17:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The uninstall regression tests are in the switch test module, causing the uninstall-focused suite to skip all 12 new cases and violating the required command-focused test structure.

1 open issue
What changed in this PR

This PR extends the manifest-hash fixes from #5193 to uninstall fallback handling, preventing preset rewrites from being reported as user modifications on the new default integration.

Changes:

  • Shares fallback registration logic across both uninstall paths.
  • Refreshes hashes only for previously unmodified files, with best-effort handling of manifest failures.
  • Adds 12 regression cases covering hash updates, pre-existing edits, and missing or failing manifests.
File Description
tests/​specify_cli/​integrations/​test_command_switch.py Adds uninstall fallback regression coverage.
src/​specify_cli/​integrations/​command_uninstall.py Refreshes fallback manifest hashes after contribution registration.

Review effort: Balanced (auto)

@mnriem

mnriem commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

Please address Copilot feedback

…all command

Move TestUninstallFallbackManifest from test_command_switch.py to
test_command_uninstall.py, next to the other fallback tests, as the
test structure in design/cli.md asks.

Assisted-by: Claude Code (model: claude-opus-5-5, autonomous)
Copilot AI adaptive review requested due to automatic review settings November 5, 2026 17:37
@kartsan03

Copy link
Copy Markdown
Contributor Author

Addressed in 00d63da.

TestUninstallFallbackManifest now lives in tests/specify_cli/integrations/test_command_uninstall.py, right after TestIntegrationUninstall and its fallback tests, so it runs with the uninstall suite. The tests themselves are unchanged: in the new place, 8 of the 12 cases still fail on main and all 12 pass with the fix. test_command_switch.py is back to its main version.

Full suite on Linux, Python 3.13: 13945 passed, 449 skipped, 1 failed, the same local-only test_non_windows_uv_tool_dry_run_still_previews_installer failure as before (it fails on main here too). Ruff 0.15.0 passes.

Drafted on behalf of @kartsan03 by Claude Code (model: claude-opus-5-5, autonomous).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the change to refresh manifest hashes when uninstalling promotes a fallback integration.

1 open issue

Review effort: Balanced (auto)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified in the fallback-registration and manifest-hash refresh changes.

1 open issue

Review effort: Balanced (auto)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain in the fallback-registration and manifest-hash changes, though tests were not rerun during this review.

No open issues 🎉

1 resolved since last review

Review effort: Balanced (auto)

@mnriem
mnriem merged commit 21b96a5 into github:main Nov 5, 2026
42 checks passed
@mnriem

mnriem commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

Thank you!

kevinnguyenhoang91 pushed a commit to kevinnguyenhoang91/spec-kit that referenced this pull request Nov 10, 2026
github#5274)

* fix(integrations): refresh the fallback's manifest hashes on uninstall

Uninstalling the default integration re-registers extensions and presets
for the fallback integration but never refreshed the hashes of files
those presets rewrite, so status reported them as modified and a plain
upgrade refused. Snapshot the fallback's manifest before registration
and resync files that were unmodified before, as the switch rollback
does since github#5193.

Assisted-by: Codex CLI (model: gpt-6.1-sol, autonomous)
Assisted-by: Claude Code (model: claude-opus-5-5, autonomous)

* test(integrations): keep the uninstall fallback tests with the uninstall command

Move TestUninstallFallbackManifest from test_command_switch.py to
test_command_uninstall.py, next to the other fallback tests, as the
test structure in design/cli.md asks.

Assisted-by: Claude Code (model: claude-opus-5-5, autonomous)
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.

3 participants