feat(wp-0002): complete T07 — control loop on the live backup resource
The backup is procured and proven, so the loop runs on real evidence. - data/actuals/2026-08.json: first real observation. database 0.6365 GB, stored 0.0066 GB over 8 objects, backup success 1/1, restore RTO 1.08 min. Five proxies null, each with a named owner in measurement_gaps. - data/thresholds/platform-audit-storage.json + tools/thresholds.py: budget variance, abnormal growth, stale backup, unused commitment. Fail-closed — an unmeasured value is reported as unmeasured, never as within. - financial_exchange.py gains a usage mode emitting technical_usage records to fin-hub, with measurement gaps carried through and no infrastructure amount: fin-hub owns the booked fact and a null is never sent as 0.00. - observation schema 0.2 allows null cost and usage proxies; variance.py fails closed rather than reporting a 100% favourable variance on a missing amount. - platform-audit-storage: ordered -> active, commissioned 2026-08-14, on operational fact rather than on the purchase. The optimization case is now approved by the founder. That needed a schema change: Host Europe never supplied written terms, so options gained excluded/exclusion_reason. Previously an unevaluable alternative blocked its case forever, leaving the record claiming no decision while the bucket was in production. An excluded option keeps its unknowns and must say what would bring it back. August produces no variance and should not: the decision forecast starts at 2026-09, so August is a commissioning baseline. Threshold run is 2 within, 1 not applicable, 6 unmeasured, 0 breaches. Also fixes a pre-existing test failure: reef-storage consumers_actual is now rapp-postgres, which the assertion still expected to be empty. 136 tests pass. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
2704292d45
commit
10b988fa1c
17 changed files with 1312 additions and 122 deletions
|
|
@ -214,11 +214,13 @@ class RegisteredCasesTest(unittest.TestCase):
|
|||
self.assertIn("opt:platform-audit-storage:2026-08", types)
|
||||
self.assertIn("opt:reef-railiance-k3s:2026-08", types)
|
||||
|
||||
def test_storage_case_computes_hetzner_and_blocks_host_europe(self):
|
||||
def test_storage_case_computes_hetzner_and_excludes_host_europe(self):
|
||||
report = evaluate(self.cases["platform-audit-storage-2026-08"])
|
||||
verdicts = {c["option_id"]: c["verdict"] for c in report["comparisons"]}
|
||||
self.assertEqual("reject", verdicts["hetzner-object-storage"])
|
||||
self.assertEqual("blocked_on_evidence", verdicts["host-europe-cloud-storage"])
|
||||
# Host Europe never supplied written terms and was excluded at decision
|
||||
# time rather than left blocking the case indefinitely.
|
||||
self.assertEqual("excluded", verdicts["host-europe-cloud-storage"])
|
||||
hetzner = next(c for c in report["comparisons"] if c["option_id"] == "hetzner-object-storage")
|
||||
self.assertEqual(29.14, hetzner["monthly_delta_eur"])
|
||||
|
||||
|
|
@ -244,5 +246,69 @@ class RegisteredCasesTest(unittest.TestCase):
|
|||
self.assertEqual(before, record, name)
|
||||
|
||||
|
||||
class ExcludedOptionTest(unittest.TestCase):
|
||||
"""An alternative the deciding authority set aside must not block forever."""
|
||||
|
||||
def test_excluded_option_does_not_block_the_case(self):
|
||||
alternative = option("alt", one_time_eur=None, excluded=True,
|
||||
exclusion_reason="no written terms within the decision window")
|
||||
result = compare_option(option("baseline"), alternative)
|
||||
self.assertEqual("excluded", result["verdict"])
|
||||
self.assertEqual([], result["blocking_evidence"])
|
||||
|
||||
def test_exclusion_reason_travels_with_the_verdict(self):
|
||||
alternative = option("alt", excluded=True, exclusion_reason="supplier never replied")
|
||||
self.assertEqual("supplier never replied", compare_option(option("baseline"), alternative)["exclusion_reason"])
|
||||
|
||||
def test_excluding_without_a_reason_is_rejected(self):
|
||||
record = case(alternatives=[option("alt", one_time_eur=None, excluded=True)])
|
||||
with self.assertRaisesRegex(ValueError, "exclusion_reason"):
|
||||
validate_case(record)
|
||||
|
||||
def test_case_with_only_excluded_alternatives_can_be_approved(self):
|
||||
record = case(alternatives=[option("alt", one_time_eur=None, excluded=True,
|
||||
exclusion_reason="unevaluable")])
|
||||
record["decision"].update({"state": "approved", "recommended_option_id": "baseline",
|
||||
"approver": "founder", "approved_on": "2026-08-14"})
|
||||
validate_case(record)
|
||||
|
||||
def test_excluded_option_is_never_recommended(self):
|
||||
record = case(alternatives=[option("alt", recurring_infrastructure_eur_month=0, excluded=True,
|
||||
exclusion_reason="unevaluable")])
|
||||
record["decision"].update({"state": "approved", "recommended_option_id": "baseline",
|
||||
"approver": "founder", "approved_on": "2026-08-14"})
|
||||
self.assertIsNone(evaluate(record)["best_option_id"])
|
||||
|
||||
|
||||
class ApprovedStorageCaseTest(unittest.TestCase):
|
||||
"""The backup decision was made and executed on 2026-08-14."""
|
||||
|
||||
def setUp(self):
|
||||
path = CASE_DIR / "platform-audit-storage-2026-08.json"
|
||||
self.case = json.loads(path.read_text())
|
||||
|
||||
def test_case_is_approved_by_a_named_authority(self):
|
||||
decision = self.case["decision"]
|
||||
self.assertEqual("approved", decision["state"])
|
||||
self.assertEqual("scaleway-standard-multi-az", decision["recommended_option_id"])
|
||||
self.assertEqual("2026-08-14", decision["approved_on"])
|
||||
self.assertTrue(decision["approver"])
|
||||
|
||||
def test_host_europe_is_excluded_with_a_reason_not_silently_dropped(self):
|
||||
host_europe = next(a for a in self.case["alternatives"] if a["option_id"] == "host-europe-cloud-storage")
|
||||
self.assertTrue(host_europe["excluded"])
|
||||
self.assertIn("RESOURCE-WP-0002-T02", host_europe["exclusion_reason"])
|
||||
self.assertTrue(host_europe["unknowns"], "the unknowns stay recorded after exclusion")
|
||||
|
||||
def test_hetzner_stays_a_costed_rejection(self):
|
||||
verdicts = {c["option_id"]: c["verdict"] for c in evaluate(self.case)["comparisons"]}
|
||||
self.assertEqual("reject", verdicts["hetzner-object-storage"])
|
||||
self.assertEqual("excluded", verdicts["host-europe-cloud-storage"])
|
||||
|
||||
def test_outcome_points_at_the_real_actuals(self):
|
||||
self.assertIn("data/actuals/2026-08.json", self.case["outcome"]["actual_refs"])
|
||||
self.assertTrue(self.case["financial_handoff"]["sent"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue