Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/1625-migrate-standards-refused-move.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`sw migrate-standards` reports a standard whose destination name the index walk does not list as skipped, instead of stopping with a traceback (#1625).
6 changes: 5 additions & 1 deletion extensions/software-kb/src/pyrite_software_kb/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ def sw_migrate_standards(
"""Migrate type:standard entries to programmatic_validation or development_convention."""
from pathlib import Path

from pyrite.exceptions import EntryLoadError, KBReadOnlyError
from pyrite.exceptions import EntryLoadError, KBReadOnlyError, ValidationError
from pyrite.storage.database import PyriteDB
from pyrite.storage.entry_writer import FileChanged, move_entry_text, publish_entry_text
from pyrite.storage.file_operations import FrontmatterSpan, Set, Unset, apply
Expand Down Expand Up @@ -887,6 +887,10 @@ def sw_migrate_standards(
)
skipped += 1
continue
except ValidationError as e:
console.print(f" [red]Skip[/red] {row['title']}: {e}", markup=False)
skipped += 1
continue
console.print(path_line(f" [green]Migrated[/green] {row['title']} -> ", new_path))
else:
try:
Expand Down
3 changes: 3 additions & 0 deletions tests/test_index_health_names_unlisted_entry_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ def test_each_surface_carries_rows_or_a_count_as_decided(tmp_path, cli_world, su
assert body.get("healthy", True) is True # a warning, never unhealthy


@pytest.mark.control(
reason="a structural guard: dev makes no such call either; it goes red when a server module reads the health report itself"
)
def test_no_network_surface_reads_the_health_report_directly():
"""REST and MCP reach index health only through
`KBRegistryService.health_kb`, the one place that turns
Expand Down
33 changes: 31 additions & 2 deletions tests/test_remaining_writers_write_through_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,17 @@ def test_a_pin_outside_git_writes_without_a_lock(tmp_path: Path):
@pytest.fixture
def software_plugin():
pytest.importorskip("pyrite_software_kb.cli")
from pyrite.plugins.registry import PluginRegistry
from pyrite.plugins import get_registry
from pyrite_software_kb.plugin import SoftwareKBPlugin

PluginRegistry().register(SoftwareKBPlugin())
plugin = SoftwareKBPlugin()
get_registry().register(plugin)
cli_app._plugins_mounted = False
try:
yield plugin
finally:
get_registry()._plugins.pop(plugin.name, None)
cli_app._plugins_mounted = False


def _migrate_standards(config: PyriteConfig, *, exit_code: int = 0) -> str:
Expand Down Expand Up @@ -416,6 +423,28 @@ def test_migrate_standards_never_writes_a_file_its_type_can_no_longer_load(
assert "title must be a string" in out.replace("\n", " "), out


def test_migrate_standards_reports_and_skips_when_move_is_refused(tmp_path: Path, software_plugin):
import sqlite3

# #1625 item 3: sw_migrate_standards catches ValidationError from a refused move,
# reports the skip, and exits with 1.
config, kb_path = _kb(tmp_path, {"standards/s.md": STANDARD}, kb_type="software")
readme_path = kb_path / "standards" / "README.md"
(kb_path / "standards" / "s.md").rename(readme_path)
before = readme_path.read_bytes()

with sqlite3.connect(config.settings.index_path) as conn:
conn.execute("UPDATE entry SET file_path = ? WHERE id = 's'", (str(readme_path),))
conn.commit()

out = _migrate_standards(config, exit_code=1)

assert readme_path.read_bytes() == before
assert not (kb_path / "validations" / "README.md").exists()
assert "Skip" in out
assert "the index walk does not list that path" in out


# --------------------------------------------------------------------------
# #978 cold read (2026-10-19): a rename is refused only for the entry renamed;
# the migrate version is stamped only on a written result; a move holds one
Expand Down
Loading