107 lines
4.4 KiB
Python
107 lines
4.4 KiB
Python
"""Tests for the 2026-07-03 scavenge sweep (batch 2/5: docs/superpowers/specs/).
|
|
|
|
Lifted 16 new directives from 22 design specs in docs/superpowers/specs/.
|
|
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 grew by 16 from this batch
|
|
|
|
Additive to tests/test_scavenge_batch_1.py and tests/test_scavenge_directives_lift.py
|
|
(the prior scavenge-pass tests).
|
|
"""
|
|
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_2_DIRECTIVES: list[str] = [
|
|
"defer_heavy_sdk_imports_to_subprocess",
|
|
"graceful_optional_dependency_degradation",
|
|
"interceptor_activates_only_on_matching_shape",
|
|
"missing_data_renders_as_em_dash_not_crash",
|
|
"float_only_math_for_visual_transforms",
|
|
"view_composes_does_not_leak_into_theme_get_color",
|
|
"surface_upstream_api_limits_honestly_in_spec",
|
|
"use_git_history_as_classification_source_of_truth",
|
|
"classifier_must_emit_per_row_evidence",
|
|
"chronology_must_regenerate_after_every_track_ship",
|
|
"quality_gate_catches_broken_classifier_before_ship",
|
|
"generation_script_walks_filesystem_fresh_each_run",
|
|
"quarantine_flag_the_engine_not_shared_types",
|
|
"test_classification_via_import_presence",
|
|
"three_tier_test_strategy_for_fragile_subsystems",
|
|
"runtime_config_flag_vs_test_env_var_gate",
|
|
]
|
|
|
|
|
|
def _read(path: Path) -> str:
|
|
return path.read_text(encoding="utf-8")
|
|
|
|
|
|
def test_scavenge_batch_2_lift_count_matches_expected() -> None:
|
|
assert len(SCAVENGE_BATCH_2_DIRECTIVES) == 16, "scavenge batch 2 lifted 16 directives; list must stay in sync"
|
|
|
|
|
|
@pytest.mark.parametrize("directive_name", SCAVENGE_BATCH_2_DIRECTIVES)
|
|
def test_scavenge_batch_2_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-2 directive: " + directive_name
|
|
|
|
|
|
@pytest.mark.parametrize("directive_name", SCAVENGE_BATCH_2_DIRECTIVES)
|
|
def test_scavenge_batch_2_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-2 directive: " + directive_name
|
|
|
|
|
|
@pytest.mark.parametrize("directive_name", SCAVENGE_BATCH_2_DIRECTIVES)
|
|
def test_scavenge_batch_2_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_2_DIRECTIVES)
|
|
def test_scavenge_batch_2_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_2_directives_listed_in_current_baseline_preset() -> None:
|
|
preset_body = _read(PRESET)
|
|
for name in SCAVENGE_BATCH_2_DIRECTIVES:
|
|
assert name in preset_body, (
|
|
"current_baseline.md does not reference scavenge-batch-2 directive: " + name
|
|
)
|
|
|
|
|
|
def test_scavenge_batch_2_meta_source_cites_docs_superpowers_specs() -> None:
|
|
for name in SCAVENGE_BATCH_2_DIRECTIVES:
|
|
meta_path = DIRECTIVES_DIR / name / "meta.md"
|
|
body = _read(meta_path)
|
|
assert "docs/superpowers/specs/" in body, (
|
|
name + " meta.md Source line must cite docs/superpowers/specs/"
|
|
)
|
|
|
|
|
|
@pytest.mark.parametrize("directive_name", SCAVENGE_BATCH_2_DIRECTIVES)
|
|
def test_scavenge_batch_2_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
|
|
) |