Skip to content

fix: skip recovered files during refresh_managed overwrite check#2919

Merged
mnriem merged 1 commit into
mainfrom
mnriem/fix-2918-recovered-file-overwrite
Jun 10, 2026
Merged

fix: skip recovered files during refresh_managed overwrite check#2919
mnriem merged 1 commit into
mainfrom
mnriem/fix-2918-recovered-file-overwrite

Conversation

@mnriem

@mnriem mnriem commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Closes #2918

Problem

specify integration use/switch can overwrite team-customized files under .specify/scripts/ and .specify/templates/ when those files are recorded with recovered=True in the manifest.

The _is_managed() function only checked hash equality to decide if a file is "managed" (safe to overwrite). It did not consult manifest.is_recovered(), violating the manifest API's own documented requirement:

callers that would overwrite based on hash equality (e.g. refresh_managed) MUST check is_recovered first.

Fix

Added a 2-line guard in _is_managed() that returns False for recovered files — they are never treated as managed, regardless of hash match.

Test

Added test_switch_preserves_recovered_files regression test confirming that a team-customized file recorded with recovered=True survives integration switch without --force.

_is_managed() in install_shared_infra now consults manifest.is_recovered()
before treating a hash-matching file as managed. Files marked recovered
(pre-existing on disk, not installed by Spec Kit) are no longer overwritten
by integration use/switch even when their hash matches the manifest entry.

This closes the gap documented in the manifest API: callers using
refresh_managed MUST check is_recovered first.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 10, 2026 20:52

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.

Pull request overview

This PR fixes a shared-infra refresh behavior where integration use/switch could overwrite files that were observed (not produced) during install and therefore recorded in the manifest as recovered=True.

Changes:

  • Updated the shared-infra “managed file” check to treat manifest-recovered files as never-managed, even when their hash matches the manifest.
  • Added a regression test ensuring integration switch preserves a recovered shared script without --refresh-shared-infra.
Show a summary per file
File Description
src/specify_cli/shared_infra.py Adds a guard in _is_managed() to skip overwrite eligibility for manifest.is_recovered(rel) entries.
tests/integrations/test_integration_subcommand.py Adds regression coverage for preserving recovered files during integration switch.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@mnriem mnriem merged commit 5ae7ff5 into main Jun 10, 2026
13 checks passed
@mnriem mnriem deleted the mnriem/fix-2918-recovered-file-overwrite branch June 10, 2026 21:40
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.

[Bug]: integration use overwrites team-customized shared scripts/templates when custom baseline is recorded in speckit manifest

2 participants