"""Tests for the 2026-07-03 scavenge sweep (batch 3/5: docs/superpowers/plans/). Lifted 12 new directives from implementation plans in `docs/superpowers/plans/`. Each one encodes a constraint or "don't do X" rule that surfaced from past regressions or design docs during implementation of the corresponding track. These tests pin the structural contract: - every new directive has both a v1.md and a meta.md file - every new directive's v1.md body starts with a '# ' imperative heading - every new directive's meta.md has the ## v1 section + Source/Lifted lines - every new directive is referenced in conductor/directives/presets/current_baseline.md - the total directive count in baseline grew from 90 to 102 Additive to tests/test_aggregate_directives.py, tests/test_scavenge_directives_lift.py, and tests/test_scavenge_batch_1.py. """ from __future__ import annotations from pathlib import Path import pytest REPO_ROOT = Path(__file__).resolve().parent.parent DIRECTIVES_DIR = REPO_ROOT / "conductor" / "directives" PRESET = REPO_ROOT / "conductor" / "directives" / "presets" / "current_baseline.md" SCAVENGE_BATCH_3_DIRECTIVES: list[str] = [ "adapt_test_mocks_to_production_api_change", "cheap_fix_first_investigation_phases", "controller_property_delegation_no_dual_state", "docs_philosophy_then_boundaries_then_logic_then_verify", "enforce_no_real_toml_in_tests", "imgui_scope_entered_flag_for_no_op_return", "imscope_tuple_return_per_scope_override", "log_pruner_backoff_for_locked_files", "modal_explicit_opened_list_for_lifecycle", "no_content_duplication_across_agent_docs", "opt_in_integration_test_via_env_var_marker", "toml_loader_global_then_project_merge", ] def _read(path: Path) -> str: return path.read_text(encoding="utf-8") def test_scavenge_batch_3_lift_count_matches_expected() -> None: assert len(SCAVENGE_BATCH_3_DIRECTIVES) == 12, "scavenge batch 3 lifted 12 directives; list must stay in sync" @pytest.mark.parametrize("directive_name", SCAVENGE_BATCH_3_DIRECTIVES) def test_scavenge_batch_3_directive_has_v1_file(directive_name: str) -> None: path = DIRECTIVES_DIR / directive_name / "v1.md" assert path.is_file(), "missing v1.md for scavenge-batch-3 directive: " + directive_name @pytest.mark.parametrize("directive_name", SCAVENGE_BATCH_3_DIRECTIVES) def test_scavenge_batch_3_directive_has_meta_file(directive_name: str) -> None: path = DIRECTIVES_DIR / directive_name / "meta.md" assert path.is_file(), "missing meta.md for scavenge-batch-3 directive: " + directive_name @pytest.mark.parametrize("directive_name", SCAVENGE_BATCH_3_DIRECTIVES) def test_scavenge_batch_3_v1_starts_with_imperative_heading(directive_name: str) -> None: path = DIRECTIVES_DIR / directive_name / "v1.md" first_line = _read(path).splitlines()[0] assert first_line.startswith("# "), ( directive_name + " v1.md first line is not a '# ' imperative heading: " + first_line ) @pytest.mark.parametrize("directive_name", SCAVENGE_BATCH_3_DIRECTIVES) def test_scavenge_batch_3_meta_has_required_sections(directive_name: str) -> None: path = DIRECTIVES_DIR / directive_name / "meta.md" body = _read(path) assert "## v1" in body, directive_name + " meta.md missing '## v1' section" assert "**Source:**" in body, directive_name + " meta.md missing **Source:** line" assert "**Lifted:**" in body, directive_name + " meta.md missing **Lifted:** line" def test_scavenge_batch_3_directives_listed_in_current_baseline_preset() -> None: preset_body = _read(PRESET) for name in SCAVENGE_BATCH_3_DIRECTIVES: assert name in preset_body, ( "current_baseline.md does not reference scavenge-batch-3 directive: " + name ) def test_total_directive_count_at_least_102_after_scavenge_batch_3() -> None: v1_files = sorted(DIRECTIVES_DIR.glob("*/v1.md")) assert len(v1_files) >= 102, ( "expected >= 102 directives after scavenge batch 3 (90 baseline + 12 batch-3); found " + str(len(v1_files)) ) def test_baseline_preset_size_grew_after_scavenge_batch_3() -> None: preset_body = _read(PRESET) assert preset_body.count("\n- ") >= 102, ( "current_baseline.md should have >= 102 directive lines after scavenge batch 3" ) @pytest.mark.parametrize("directive_name", SCAVENGE_BATCH_3_DIRECTIVES) def test_scavenge_batch_3_v1_first_line_is_complete_sentence(directive_name: str) -> None: path = DIRECTIVES_DIR / directive_name / "v1.md" first_line = _read(path).splitlines()[0].lstrip("# ").strip() assert len(first_line) > 20, ( directive_name + " v1.md first-line statement is too short to be a complete imperative: " + first_line ) @pytest.mark.parametrize("directive_name", SCAVENGE_BATCH_3_DIRECTIVES) def test_scavenge_batch_3_meta_references_docs_superpowers_plans_source(directive_name: str) -> None: path = DIRECTIVES_DIR / directive_name / "meta.md" body = _read(path) assert "docs/superpowers/plans/" in body, ( directive_name + " meta.md must cite docs/superpowers/plans/ as the source" )