Repository navigation
fix(software-kb): catch refused move in sw_migrate_standards and mark health guard (#1625) - #1671
Conversation
markramm
left a comment
There was a problem hiding this comment.
Automated review (agent-written; the maintainer reads it too).
Thanks, Mohit. This takes items 2 and 3 of #1625 as you said in your comment, and it does them closely. The control mark on test_no_network_surface_reads_the_health_report_directly has the reason the issue asked for. sw_migrate_standards now catches ValidationError from a refused move, prints Skip, counts the entry as skipped, and the existing exit_unless_whole turns that into exit 1. I read the code at current dev and found one blocker (a missing changelog fragment) and a few small things.
Blocking
changelog.d/(new file): this changes production code (extensions/software-kb/src/pyrite_software_kb/cli.py) under afix:title, so it needs a fragment per CONTRIBUTING ("A changelog fragment"). Please add a new file such aschangelog.d/1625-migrate-standards-refused-move.fixed.md, one line in the style of the others, for example: "sw migrate-standardsreports a standard whose destination name the index walk does not list as skipped, instead of stopping with a traceback (#1625)." Do not editCHANGELOG.md.
Non-blocking
cli.py, the secondexcept ValidationError(the in-placepublish_entry_textbranch):publish_entry_textnever callsentry_paths.require_listed; onlymove_entry_textdoes. So this handler cannot be reached today and has no test. Either drop it, or keep it with a short comment saying it is a guard for later. The first handler (aroundmove_entry_text) is the one that matters, and it is tested.cli.py:ValidationErroris the base of a large family (schema, undeclared type, exists, unsafe destination). That is what you want for a skip-and-continue loop, but the message prints{e}only, so the skip carries no error code. That matches the otherSkiplines in this function, so I think it fits what the issue means by "its own error shape". No MCP tool wrapssw_migrate_standards(I searchedpyrite/andextensions/; it is only the CLI command), so there is no second path to cover.tests/test_remaining_writers_write_through_apply.py: thesoftware_pluginfixture rewrite (get_registry, resettingcli_app._plugins_mounted, popping the plugin on teardown) is not part of #1625. It looks like a reasonable isolation fix, but please say in the PR description why it was needed, since it changes a fixture other tests share.- The new test name differs from the one you proposed on the issue (
..._skips_and_reports_unlisted_destination). That is fine; I mention it only so nobody searches for the old name. - Test strength: without the fix the
ValidationErrorescapes, andCliRunnerstill reports exit code 1, so the exit-code assertion alone would not catch a revert. The"Skip" in outand message assertions do, so the test is red without the fix. Nice that it uses the real refusal (an index row pointed atREADME.md) rather than a stand-in. The lineassert (kb_path / "standards" / "README.md").exists()repeats the byte check above it and can go. - The
controlmark: the reason string matches the issue text, and the form@pytest.mark.control(reason=...)matches the other uses (for exampletests/test_reserved_kb_names.py,tests/test_find_file_prefilter.py). I found no registry or ratchet that counts control marks; the only consumer isscripts/verify-red.sh, which reports a marked test as a control rather than an "unexpected pass". Nothing else to update. - Nothing is silently dropped: the skipped entry is printed, counted, and the run exits non-zero; the other entries continue, as with the existing skip cases.
CI
gh pr checks 1671 shows two jobs, changes and lock, both pending at the time of review. I did not run any tests locally.
Triggers
Cold-read triggers: none. The change touches no file under pyrite/server/, storage/, schema/ or auth, changes no public interface, and has 3 files. (extensions/software-kb CLI error handling and tests only.)
The fix: commit touches tests/, so scripts/check_fix_commit_has_tests.py is satisfied.
Recommendation: request changes.
|
Thank you for the review! Addressed the feedback in commit
|
Follow-up to #1576 (#1552), addressing items 2 and 3 of #1625:
1. Item 2: Control mark on health structural guard
Added
@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")totest_no_network_surface_reads_the_health_report_directlyintests/test_index_health_names_unlisted_entry_files.py.2. Item 3:
sw_migrate_standardscatches refused moveextensions/software-kb/src/pyrite_software_kb/cli.py,move_entry_text(andpublish_entry_text) calls now catchValidationError as e.README.md),sw_migrate_standardsprints[red]Skip[/red] {title}: {e}, incrementsskipped += 1, and continues.exit_unless_wholethen exits 1 as expected.test_migrate_standards_reports_and_skips_when_move_is_refusedintests/test_remaining_writers_write_through_apply.pyvalidating that an unlisted destination path (standards/README.md) triggersValidationError, reports the skip, preserves existing files untouched, and exits 1 without mocking service boundaries.Fixes #1625 (items 2 & 3)
Changelog: none