Skip to content

[Bug]: integration switch leaves the manifest out of date when a preset overrides a core command #5078

Open

Description

@hnipps

Bug Description

specify integration switch <target> installs the target integration and saves its manifest (src/specify_cli/integrations/command_switch.py:309-316). It then re-registers installed presets for the target (command_switch.py:380-389). A preset that overrides a core command rewrites a file the manifest already tracks, and the manifest is not re-hashed afterwards. As a result integration status reports the file as modified, and a later integration upgrade without --force refuses to run, even though the user changed nothing.

integration upgrade handles the same situation by calling _resync_manifest_after_registration (command_upgrade.py:352, added for #4696). switch does not call it.

Steps to Reproduce

From the root of a fresh clone, after uv sync, save the script below as repro.py and run it with uv run python repro.py.

import hashlib, json, os, tempfile
from pathlib import Path
from typer.testing import CliRunner
from specify_cli import app

tmp = Path(tempfile.mkdtemp())
project = tmp / "proj"
project.mkdir()
os.chdir(project)
run = lambda *args: CliRunner().invoke(app, list(args))

run("init", "--here", "--integration", "claude", "--script", "sh", "--ignore-agent-tools")

preset = tmp / "tasks-preset"
(preset / "commands").mkdir(parents=True)
(preset / "commands" / "speckit.tasks.md").write_text(
    "---\ndescription: Tasks override\n---\nPreset tasks body\n")
(preset / "preset.yml").write_text("""schema_version: '1.0'
preset: {id: tasks-preset, name: Tasks Preset, version: 1.0.0, description: x}
requires: {speckit_version: '>=0.1.0'}
provides:
  templates:
  - {type: command, name: speckit.tasks, file: commands/speckit.tasks.md}
""")
run("preset", "add", "--dev", str(preset))

r = run("integration", "switch", "codex", "--script", "sh")
print("switch exit code:", r.exit_code)

rel = ".agents/skills/speckit-tasks/SKILL.md"
manifest = json.loads(Path(".specify/integrations/codex.manifest.json").read_text())
on_disk = hashlib.sha256(Path(rel).read_bytes()).hexdigest()
print("preset body in skill:", "Preset tasks body" in Path(rel).read_text())
print("manifest hash matches file:", manifest["files"][rel] == on_disk)

r = run("integration", "upgrade", "codex", "--script", "sh")
print("upgrade exit code:", r.exit_code)
print(r.output.strip())

The script initialises a project with Claude Code, adds a local preset that overrides speckit.tasks, switches to Codex, compares the manifest hash with the file on disk, and then runs integration upgrade codex without --force.

Expected Behavior

After the switch, the manifest hash for .agents/skills/speckit-tasks/SKILL.md matches the file that preset registration wrote, and integration upgrade codex succeeds. The docstring of _resync_manifest_after_registration (src/specify_cli/integrations/_helpers.py:486-505) says files rewritten by registration must be re-hashed "so check_modified() doesn't misreport a legitimate override as tampering", and names switch among the operations it serves. The regression test test_upgrade_force_syncs_manifest_hash_for_preset_overridden_skill (tests/specify_cli/integrations/test_command_upgrade.py:1320-1385) sets the same expectation for upgrade.

Actual Behavior

switch exit code: 0
preset body in skill: True
manifest hash matches file: False
upgrade exit code: 1
⚠  1 file(s) have been modified since installation:
    .agents/skills/speckit-tasks/SKILL.md

Use --force to overwrite modified files, or resolve manually.

Specify CLI Version

1.2.4.dev0 (main at 27d14e2)

AI Agent

Codex CLI

Operating System

Linux 6.18 (Ubuntu container)

Python Version

Python 3.12.3

Error Logs

⚠  1 file(s) have been modified since installation:
    .agents/skills/speckit-tasks/SKILL.md

Use --force to overwrite modified files, or resolve manually.

Additional Context

integration use (src/specify_cli/integrations/command_use.py) also re-registers presets without a manifest resync, so it looks affected in the same way, but I have not reproduced that path. Calling _resync_manifest_after_registration after preset registration in switch (and probably use) would likely fix it.

Also reproduced on macOS (Darwin 25.6, arm64) with Python 3.14.4 and uv run python -I repro.py against 27d14e2; the output matches the above.

AI Disclosure

Found and reproduced with Claude Code (model: Claude Opus 4.8), run autonomously under human supervision. The human reporter re-ran every reproduction above before filing.

Activity

  1. added
    triage-must-haveVerdict: high-value, important work for Spec Kit — do first
    on Oct 23, 2026
  2. github-actions commented on Oct 29, 2026

    @github-actions
    Contributor

    Bug assessment — switch-manifest-stale: Invalid · severity low


    Bug Assessment: integration switch manifest hash drift after preset override

    Report (summarized)

    Issue author @hnipps reports that integration switch saved a target manifest before preset re-registration, so preset-overridden files (example: .agents/skills/speckit-tasks/SKILL.md) could diverge from manifest hashes. Reported result: integration status/integration upgrade then flagged the file as modified unless --force was used.

    Issue title: "[Bug]: integration switch leaves the manifest out of date when a preset overrides a core command".

    No additional comments were present.

    Symptom

    Reported behavior: after switching integrations with a preset override, manifest hashes could remain stale, causing false-positive "modified since installation" failures in integration upgrade.

    Expected behavior: manifest hashes should be re-synced after registration writes so normal upgrades do not fail on untouched user projects.

    Reproduction

    1. Initialize a project (report used init --integration claude).
    2. Add a preset overriding speckit.tasks.
    3. Run integration switch codex.
    4. Compare .specify/integrations/codex.manifest.json hash for .agents/skills/speckit-tasks/SKILL.md with on-disk bytes.
    5. Run integration upgrade codex without --force.

    The issue report included a complete Python repro script and expected/actual output.

    Suspected Code Paths

    • src/specify_cli/integrations/command_switch.py:404 — calls _resync_manifest_after_registration(...) after preset/extension re-registration, explicitly covering post-registration hash refresh.
    • src/specify_cli/integrations/command_switch.py:380-389 — registers extensions/presets before the resync call; this is the formerly vulnerable ordering if resync were absent.
    • src/specify_cli/integrations/_helpers.py:535-550 — _resync_manifest_after_registration docstring and logic explicitly describe this false-positive scenario and mention switch/use handling.
    • src/specify_cli/integrations/command_use.py:75 — integration use also performs _resync_manifest_after_registration(...) after registration.
    • tests/specify_cli/integrations/test_command_switch.py:31 — regression test test_switch_syncs_manifest_hash_for_preset_override validates switch now records preset-final bytes and allows subsequent upgrade.

    Root Cause Hypothesis

    The reported root cause is credible historically: saving manifest hashes before preset registration can stale tracked hashes when registration rewrites managed files. In the current codebase, that gap appears addressed by a dedicated post-registration manifest resync in switch (and use), plus targeted regression tests tied to #5078. Confidence: high that the specific bug report no longer reflects current behavior on main.

    Proposed Remediation

    Preferred: No new code change from this triage. Treat this issue as no longer actionable on current main because the fix path and regression tests are already present. If maintainers need release bookkeeping, close as fixed by existing changes and/or link the fixing PR/commit.

    Alternatives (optional):

    • If concern remains for older release branches, backport the existing switch/use resync behavior and associated tests there (trade-off: release branch churn and compatibility validation).

    Files likely to change:

    • None required for current main triage outcome.

    Tests to add or update:

    • None required for current main; existing regression coverage is present in test_command_switch.py and related integration tests.

    Risks & Considerations

    • Release skew risk: users on older commits/tags may still observe the bug even if main is fixed.
    • Triage semantics: marking invalid here means "not currently reproducible/actionable on current codebase," not that the original report lacked merit.

    Open Questions

    • [NEEDS CLARIFICATION: Should this issue be closed as fixed on main and tracked separately for any supported release backports, if needed?]

    Generated by 🐛 Assess Bug from Labeled Issue for #5078 · copilot · gpt53codex · 16 AIC · ⌖ 0.592 AIC · ⊞ 22.4K · ◷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug-assessinvalidThis doesn't seem righttriage-must-haveVerdict: high-value, important work for Spec Kit — do first

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions