Delivers the offline runnable specification foundation for the Trust Layer (TSD §3-§6), not a hosted Trust Service: - JSON Schemas for Phase Manifest, Ledger Entry, Extension Contract, and Conversion Attestation, encoding the Stage 0 working defaults (Q3 future license enum, Q6 single-currency Phases, Q8 required longstop_at). - src/target_revenue: pure Outstanding Target fold, SHA-256 hash-chain verification, Ed25519 signing helpers, extension conformance checks (including a core-term-redefinition heuristic), and conversion detection that never requires an attestation document to determine conversion status. - examples/phase-001: golden Phase package matching the concept doc's worked example, generated via scripts/generate_golden_phase.py so the hash chain is computed by the library itself, not hand-typed. - 32 passing pytest tests covering manifest/ledger/extension conformance, tamper/reorder detection, and the full lifecycle fold to conversion. - docs/adr/ADR-0001: proposed (not accepted) Stage 0 stack choice, per the WP-0002-T01 human-accept gate — implementation proceeded against the proposal as the workplan note permits, but the task stays open. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
52 lines
2 KiB
Python
52 lines
2 KiB
Python
import pytest
|
|
from conftest import golden_entries, golden_manifest
|
|
|
|
from target_revenue import conversion, validation
|
|
|
|
|
|
def test_conversion_status_not_converted_partway_through():
|
|
manifest = golden_manifest()
|
|
status = conversion.conversion_status(manifest, golden_entries()[:4])
|
|
assert status.is_converted is False
|
|
assert status.outstanding_target == 45000
|
|
|
|
|
|
def test_conversion_status_converted_after_full_sequence():
|
|
manifest = golden_manifest()
|
|
status = conversion.conversion_status(manifest, golden_entries())
|
|
assert status.is_converted is True
|
|
assert status.outstanding_target == 0
|
|
assert status.future_license == "MIT"
|
|
|
|
|
|
def test_conversion_status_requires_no_attestation_document():
|
|
"""PRD FR-7/G6: conversion status must be computable from Manifest +
|
|
Ledger alone, with no attestation file consulted or required."""
|
|
manifest = golden_manifest()
|
|
entries = golden_entries()
|
|
status_without_attestation = conversion.conversion_status(manifest, entries)
|
|
assert status_without_attestation.is_converted is True
|
|
|
|
|
|
def test_generate_attestation_for_converted_phase():
|
|
manifest = golden_manifest()
|
|
entries = golden_entries()
|
|
attestation = conversion.generate_attestation(
|
|
manifest, entries, conversion_timestamp="2027-06-01T00:00:00Z"
|
|
)
|
|
validation.validate_conversion_attestation(attestation)
|
|
assert attestation["final_outstanding_target"] == 0
|
|
assert attestation["final_development_credit"] == 67000
|
|
assert attestation["final_remission_credit"] == 33000
|
|
assert attestation["future_license"] == "MIT"
|
|
assert attestation["phase"] == "trsl:phase:example-001"
|
|
assert attestation["ledger_checkpoint"] == entries[-1]["id"]
|
|
|
|
|
|
def test_generate_attestation_rejects_unconverted_phase():
|
|
manifest = golden_manifest()
|
|
partial_entries = golden_entries()[:4] # Outstanding Target still 45000
|
|
with pytest.raises(ValueError, match="Outstanding Target"):
|
|
conversion.generate_attestation(
|
|
manifest, partial_entries, conversion_timestamp="2026-12-01T00:00:00Z"
|
|
)
|