target-revenue/tests/test_pilot_candidate_manifests.py
tegwick 2a176d9961 Implement WP-0015-T01/T04/T06: Phase provenance schema + ledger UI
Schema: phase.milestone_release gains required repo_hub/repo_hub_uri/
repo_id/repo_name; phase gains optional base_phase_id. Backfilled the
golden phase-001 fixture (placeholder values, it's synthetic) and the
three real pilot-candidate manifests with actual Forgejo repo ids
confirmed live (net-kingdom=67, vergabe-teilnahme=62,
info-tech-canon=47, all coulomb/*).

Discovered along the way: the schema change alone would have broken
the existing Control Plane registration form, since nothing collected
the four new fields. Fixed inline rather than leaving it broken
between tasks -- this also completes T04's ledger UI change (drop the
hand-typed ledger input, auto-compute /phases/{id}/ledger, add a
drill-down reference link on phase_detail.html) since both changes
touch the same form/route.

Full suite: 94 passing offline (was 84), 158 passing with Docker
(was 146).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-03 20:43:30 +02:00

50 lines
2 KiB
Python

"""Conformance test for the draft pilot-candidate Phase Manifests
(WP-0008-T03, examples/pilot-candidates/). These are non-binding worked
examples, not real Phases, but they must stay schema-conformant like
examples/phase-001/ does.
"""
from __future__ import annotations
import json
import pytest
from conftest import REPO_ROOT
from target_revenue import validation
PILOT_CANDIDATES_DIR = REPO_ROOT / "examples" / "pilot-candidates"
PILOT_CANDIDATE_NAMES = [
"net-kingdom-local-identity",
"railiance-vergabe-teilnahme",
"info-tech-canon-service-surface",
]
@pytest.mark.parametrize("name", PILOT_CANDIDATE_NAMES)
def test_pilot_candidate_manifest_is_conformant(name):
manifest = json.loads((PILOT_CANDIDATES_DIR / name / "manifest.json").read_text())
validation.validate_phase_manifest(manifest)
assert manifest["phase"]["id"].startswith("trsl:phase:draft-")
@pytest.mark.parametrize("name", PILOT_CANDIDATE_NAMES)
def test_pilot_candidate_manifest_carries_real_repo_provenance(name):
"""WP-0015-T06: each candidate's repo_id is the real Forgejo id
(confirmed live against forgejo.coulomb.social), not a placeholder,
and none carries a base_phase_id (all three are first-ever Phases)."""
manifest = json.loads((PILOT_CANDIDATES_DIR / name / "manifest.json").read_text())
milestone_release = manifest["phase"]["milestone_release"]
assert milestone_release["repo_hub"] == "forgejo-coulomb"
assert milestone_release["repo_hub_uri"] == "https://forgejo.coulomb.social"
assert isinstance(milestone_release["repo_id"], int) and milestone_release["repo_id"] > 0
assert milestone_release["repo_name"].startswith("coulomb/")
assert "base_phase_id" not in manifest["phase"]
@pytest.mark.parametrize("name", PILOT_CANDIDATE_NAMES)
def test_pilot_candidate_ledger_is_empty_draft_state(name):
ledger = json.loads((PILOT_CANDIDATES_DIR / name / "ledger.json").read_text())
assert ledger == [], "draft candidates must not carry any real ledger entries"