Buckets:

download
raw
5.19 kB
"""Release hygiene policy checks for warnings and tracked skip markers."""
import re
from pathlib import Path
import yaml
ROOT = Path(__file__).resolve().parents[1]
TESTS = ROOT / "tests"
DOCS = ROOT / "docs"
MKDOCS_CONFIG = ROOT / "mkdocs.yml"
POLICY_TEST = Path(__file__).name
XFAIL_INVENTORY = DOCS / "development/xfail-inventory.md"
FALLBACK_TEST_FILES = [
TESTS / "test_auto.py",
TESTS / "test_fallback_chunking.py",
TESTS / "test_overlapping_fallback.py",
]
PUBLIC_BOUNDARY_DOCS = {
"agent-interface-readiness.md",
"interface-boundary-roadmap.md",
"interface-boundary-spec.md",
"grammar_management.md",
}
INTERNAL_DOCS = {
"development/DEPLOYMENT.md",
"development/RELEASE_CHECKLIST.md",
}
UNTRACKED_INTERNAL_DOCS = {
"development/xfail-inventory.md",
"language-coverage.md",
# RELEASE traceability matrix — maintainer/internal, like xfail-inventory.
"development/traceability-matrix.md",
}
def _test_sources() -> list[Path]:
return [
path
for path in TESTS.rglob("test_*.py")
if path.name != POLICY_TEST and "__pycache__" not in path.parts
]
def _mkdocs_config() -> dict:
return yaml.safe_load(MKDOCS_CONFIG.read_text(encoding="utf-8"))
def _collect_nav_paths(items: list) -> set[str]:
paths: set[str] = set()
for item in items:
if isinstance(item, str):
paths.add(item)
continue
if isinstance(item, dict):
for value in item.values():
if isinstance(value, str):
paths.add(value)
elif isinstance(value, list):
paths.update(_collect_nav_paths(value))
return paths
def test_xfail_markers_are_capped_and_tracked():
"""Every xfail must appear in the capped inventory with a clearing phase."""
inventory = XFAIL_INVENTORY.read_text(encoding="utf-8")
cap_match = re.search(r"^Maximum active xfails: (\d+)$", inventory, re.MULTILINE)
assert cap_match is not None
cap = int(cap_match.group(1))
inventory_entries = [
line for line in inventory.splitlines() if line.startswith("| tests/")
]
assert len(inventory_entries) <= cap
markers = []
for path in _test_sources():
text = path.read_text(encoding="utf-8")
if "pytest.xfail(" in text:
markers.append(f"{path.relative_to(ROOT)}: pytest.xfail")
for test_name in re.findall(
r"@pytest\.mark\.xfail\([\s\S]*?\n\s*def (test_\w+)", text
):
markers.append(f"{path.relative_to(ROOT)}::{test_name}")
assert len(markers) <= cap
for marker in markers:
assert any(marker in entry for entry in inventory_entries)
def test_conftest_has_no_collection_time_policy_mutation():
"""Keep xfail/skip and fallback-warning policy local to tests."""
text = (TESTS / "conftest.py").read_text(encoding="utf-8")
assert "pytest_collection_modifyitems" not in text
assert "FallbackWarning" not in text
assert "filterwarnings" not in text
def test_no_global_fallback_warning_filter():
"""Expected fallback warnings should be asserted where they are triggered."""
text = (ROOT / "pyproject.toml").read_text(encoding="utf-8")
assert "filterwarnings" not in text
assert "FallbackWarning" not in text
def test_fallback_warning_tests_use_scoped_assertions():
"""Fallback-warning tests should assert local warning contracts."""
for path in FALLBACK_TEST_FILES:
text = path.read_text(encoding="utf-8")
assert "warnings.catch_warnings(record=True)" not in text
assert "pytest.warns" in text
assert "FallbackWarning" in text
def test_mkdocs_tracks_every_phase7_doc_explicitly():
"""Public docs belong in nav; internal docs belong in exact not_in_nav entries."""
config = _mkdocs_config()
nav_paths = _collect_nav_paths(config["nav"])
configured_not_in_nav = {
line.strip().lstrip("/")
for line in config["not_in_nav"].splitlines()
if line.strip()
}
doc_paths = {
path.relative_to(DOCS).as_posix()
for path in DOCS.rglob("*.md")
if path.is_file()
}
not_in_nav = {path for path in configured_not_in_nav if (DOCS / path).is_file()}
assert "*" not in config["not_in_nav"]
assert not_in_nav == INTERNAL_DOCS
assert doc_paths == nav_paths | not_in_nav | UNTRACKED_INTERNAL_DOCS
assert nav_paths >= PUBLIC_BOUNDARY_DOCS
def test_public_boundary_docs_are_linked_from_docs_index():
"""The landing page should expose the public Boundary IR entry points."""
text = (DOCS / "index.md").read_text(encoding="utf-8")
for path in sorted(PUBLIC_BOUNDARY_DOCS):
assert f"({path})" in text
def test_internal_phase7_docs_keep_maintainer_notices():
"""Internal docs omitted from nav should declare that status near the top."""
for path in INTERNAL_DOCS | {"development/xfail-inventory.md"}:
lines = (DOCS / path).read_text(encoding="utf-8").splitlines()[:6]
joined = "\n".join(lines)
assert "Maintainer/internal documentation." in joined
assert "intentionally omitted from" in joined

Xet Storage Details

Size:
5.19 kB
·
Xet hash:
1f6e4dfad55fc1435482d8df0c25d098c7322510c5b22c851bee4943e33363bc

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.