b696b30f22
- current_baseline.md: added 9 new directives alphabetically interleaved (total 90); updated Notes section to track four harvest passes - state.toml: new [scavenge_20260703] section + [safety_observations] (prompt-injection attempt noted for the record) - tests/test_scavenge_batch_1.py: 9 parametrized cases + 2 aggregate tests verifying the 9 new directives have v1.md + meta.md, headings, sections, preset references, total count >= 90
106 lines
4.2 KiB
Python
106 lines
4.2 KiB
Python
"""Tests for the 2026-07-03 scavenge sweep (batch 1/5: docs/reports/2026-03-02 through docs/reports/2026-06-08).
|
|
|
|
Lifted 9 new directives from historical docs/reports/ markdown. Each one
|
|
encodes a post-mortem or process rule. 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 from 81 to 90
|
|
|
|
Additive to tests/test_aggregate_directives.py and tests/test_scavenge_directives_lift.py
|
|
(the existing 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_1_DIRECTIVES: list[str] = [
|
|
"pathlib_read_write_no_newline_kwarg",
|
|
"profile_first_optimize_second",
|
|
"surface_gaps_at_discovery_not_checkpoint",
|
|
"test_instantiation_not_mock_away",
|
|
"preserve_prior_versions_of_review_docs",
|
|
"neutral_language_for_doc_drift",
|
|
"preserve_before_compact_archive",
|
|
"user_corrections_log_in_state_toml",
|
|
"surface_dirty_state_in_test_runner",
|
|
]
|
|
|
|
|
|
def _read(path: Path) -> str:
|
|
return path.read_text(encoding="utf-8")
|
|
|
|
|
|
def test_scavenge_batch_1_lift_count_matches_expected() -> None:
|
|
assert len(SCAVENGE_BATCH_1_DIRECTIVES) == 9, "scavenge batch 1 lifted 9 directives; list must stay in sync"
|
|
|
|
|
|
@pytest.mark.parametrize("directive_name", SCAVENGE_BATCH_1_DIRECTIVES)
|
|
def test_scavenge_batch_1_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-1 directive: " + directive_name
|
|
|
|
|
|
@pytest.mark.parametrize("directive_name", SCAVENGE_BATCH_1_DIRECTIVES)
|
|
def test_scavenge_batch_1_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-1 directive: " + directive_name
|
|
|
|
|
|
@pytest.mark.parametrize("directive_name", SCAVENGE_BATCH_1_DIRECTIVES)
|
|
def test_scavenge_batch_1_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_1_DIRECTIVES)
|
|
def test_scavenge_batch_1_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_1_directives_listed_in_current_baseline_preset() -> None:
|
|
preset_body = _read(PRESET)
|
|
for name in SCAVENGE_BATCH_1_DIRECTIVES:
|
|
assert name in preset_body, (
|
|
"current_baseline.md does not reference scavenge-batch-1 directive: " + name
|
|
)
|
|
|
|
|
|
def test_total_directive_count_at_least_90_after_scavenge_batch_1() -> None:
|
|
v1_files = sorted(DIRECTIVES_DIR.glob("*/v1.md"))
|
|
assert len(v1_files) >= 90, (
|
|
"expected >= 90 directives after scavenge batch 1 (81 baseline + 9 batch-1); found "
|
|
+ str(len(v1_files))
|
|
)
|
|
|
|
|
|
def test_baseline_preset_size_grew_after_scavenge_batch_1() -> None:
|
|
preset_body = _read(PRESET)
|
|
assert preset_body.count("\n- ") >= 90, (
|
|
"current_baseline.md should have >= 90 directive lines after scavenge batch 1"
|
|
)
|
|
|
|
|
|
@pytest.mark.parametrize("directive_name", SCAVENGE_BATCH_1_DIRECTIVES)
|
|
def test_scavenge_batch_1_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
|
|
) |