state-hub/tests/test_c07_retired_rows.py
tegwick 5830ba3c15
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 1s
Build and Publish Multi-Context Image / build-and-push (push) Successful in 30s
fix(consistency): projection-retired rows are C-08 tombstones, not C-07 failures
Forge-projection retirement stamps the slug with "@retired-YYYYMMDD" and sets
projection_retired_at but leaves status untouched. Three railiance-platform
rows retired on 2026-08-26 while blocked (and re-set to blocked by a
2026-09-27 user-requested correction) therefore failed C-07 permanently, with
no file the repo could add. Their canonical successors are file-backed
RPF-WP-0015/0025/0027.

_check_orphan_db now reports retired rows (projection_retired_at, or the slug
stamp on APIs that do not yet expose it) as C-08 INFO. WorkplanRead exposes
projection_retired_at so read clients can filter tombstones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Assistant: claude-code
Assistant-Model: opus
Assistant-Process: 1370019@bnt-lap001
Assistant-Session: d462dd63-16de-4189-ae70-b9cd6566bf87
2026-10-11 21:08:20 +02:00

39 lines
1.6 KiB
Python

"""C-07 must not fail on rows forge projection retired (railiance-platform, 2026-10-11).
Retirement stamps the slug with ``@retired-YYYYMMDD`` and sets
``projection_retired_at`` but leaves status untouched, so a row retired while
blocked stayed blocked and C-07 reported it as an ADR-001 violation the repo
could never fix.
"""
from __future__ import annotations
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent / "scripts"))
import consistency_check # noqa: E402
from consistency_check import ConsistencyReport, _check_orphan_db # noqa: E402
def _run(monkeypatch, rows, file_ids=frozenset()):
monkeypatch.setattr(consistency_check, "_api_get", lambda *a, **k: rows)
report = ConsistencyReport(repo_slug="r", repo_path="/tmp/r")
_check_orphan_db("http://hub", "repo-id", set(file_ids), report)
return [(i.severity, i.check_id) for i in report.issues]
def test_retired_slug_blocked_row_is_info_not_fail(monkeypatch):
rows = [{"id": "038bc3c0-0000", "slug": "railiance-wp-0029@retired-20260826", "status": "blocked"}]
assert _run(monkeypatch, rows) == [("INFO", "C-08")]
def test_projection_retired_at_field_is_info_not_fail(monkeypatch):
rows = [{"id": "aaaa0000-0000", "slug": "x-wp-0001", "status": "active",
"projection_retired_at": "2026-08-26T00:00:00Z"}]
assert _run(monkeypatch, rows) == [("INFO", "C-08")]
def test_unretired_open_orphan_still_fails(monkeypatch):
rows = [{"id": "bbbb0000-0000", "slug": "x-wp-0002", "status": "blocked"}]
assert _run(monkeypatch, rows) == [("FAIL", "C-07")]