fix(extensions): set-priority repairs corrupted boolean priority
Description
The extension set-priority command has a skip-if-unchanged guard whose comment promises that corrupted values get repaired:
# This ensures corrupted values (e.g., "high") get repaired even when setting to default (10)
if isinstance(raw_priority, int) and raw_priority == priority:
console.print(f"...already has priority {priority}")
raise typer.Exit(0)
But in Python isinstance(True, int) is True and True == 1 (False == 0). So a corrupted boolean priority (e.g. True) matches the guard when the user runs set-priority <ext> 1: the command reports "already has priority 1" and exits without rewriting the bool to a real int — the exact opposite of what the comment promises. normalize_priority() already guards this (if isinstance(value, bool): return default); this call site didn't.
Fix
Exclude bools from the skip guard, mirroring normalize_priority:
if (
isinstance(raw_priority, int)
and not isinstance(raw_priority, bool)
and raw_priority == priority
):
Now a corrupted bool falls through and is repaired to a real int.
Testing
- New
test_set_priority_repairs_corrupted_bool: installs an extension, injectspriority: True, runsset-priority test-ext 1, asserts it reports priority changed (not already has priority) and the reloaded value is1withnot isinstance(..., bool). Fails before (reports "already has priority 1", verified by source-stash), passes after. TestExtensionPriorityCLIpasses (8 tests);uvx ruff checkclean. The existing same-value test (priority 5, a real int) stays green.
AI Disclosure
- [x] I did use AI assistance (describe below)
Found and fixed with Claude Code (Claude Opus 4.8) under my direction. AI flagged the bool-is-int trap against the comment's promise; I confirmed the short-circuit, proved fail-before via source-stash, and reviewed the diff before submitting.