feat(portfolio): fold in RAILIANCE-WP-0016 apps-pg evidence

First delegated evidence from RESOURCE-WP-0003-T04 to land. railiance-platform
delivered apps-pg capacity, utilization, consumers, and the apps-pg-dbbytes-v1
allocation driver, and correctly delivered no EUR.

- data/resources/apps-pg.json: real capacity; allocation unattributed -> shared
  under apps-pg-dbbytes-v1; second consumer vergabe-teilnahme registered
- data/control-cycle/apps-pg-2026-09-base.json: first operational control-cycle
  record in the repository
- examples/control-cycle/apps-pg-*.json retired; the invented fixture collided
  with the real record's identifier
- data/portfolio-coverage-2026-08-14.json: gap marked delivered with three
  residual unknowns still open

The real evidence exposed a design gap in the T05 schema: v0.1 required a number
for every cost field, so recording genuine usage without a booked cost meant
inventing one. Schema 0.2 permits null costs, null unattributed_eur, a technical
unattributed_share, and null measurements. Null is unknown, never zero; an
unknown component makes the total null rather than the sum of the known parts;
and the comparator classifies unknown amounts as data_quality instead of
computing a variance. Existing 0.1 records are not rewritten.

apps-pg is now measured (idle at 5.8% of volume) and attributed, and remains
unpriced: delivered technical evidence does not create a booked cost.

86 tests pass.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
tegwick 2026-08-14 09:36:57 +02:00
parent b64b5683df
commit 17de8b831e
16 changed files with 908 additions and 71 deletions

View file

@ -11,7 +11,11 @@ COST_FIELDS = ("infrastructure", "internal_labor", "external_labor", "total")
ATTRIBUTIONS = {"demand", "provider_price", "allocation", "labor", "model", "data_quality"}
def delta(forecast: float, actual: float) -> dict:
def delta(forecast: float | None, actual: float | None) -> dict:
# A missing amount is unknown, not zero: subtracting against it would
# manufacture a variance the evidence does not support.
if forecast is None or actual is None:
return {"forecast": forecast, "actual": actual, "status": "unknown"}
error = actual - forecast
return {
"forecast": forecast,
@ -50,7 +54,12 @@ def compare(forecast: dict, actual: dict) -> dict:
costs = {}
for name in COST_FIELDS:
default_category = "labor" if "labor" in name else "provider_price"
costs[name] = {**delta(forecast["costs"][name], actual["costs"][name]), "currency": "EUR", "category": attribution.get(f"costs.{name}", default_category)}
result = delta(forecast["costs"][name], actual["costs"][name])
# An unknown amount is a data-quality gap, not a price or labour movement.
category = "data_quality" if result.get("status") == "unknown" else attribution.get(
f"costs.{name}", default_category
)
costs[name] = {**result, "currency": "EUR", "category": category}
if forecast["allocation"] != actual["allocation"]:
costs["allocation_method"] = {"status": "changed", "category": attribution.get("allocation", "allocation")}

View file

@ -27,6 +27,7 @@ USAGE_PAIRS = {
"cpu": "cpu_usage",
"memory": "memory_usage",
"root_filesystem": "root_filesystem_used",
"storage": "storage_used",
}
@ -59,9 +60,23 @@ def coverage_section(coverage: dict | None) -> dict:
{"group": group["group"], "status": group["status"], "resources": len(group["resource_ids"])}
for group in coverage["coverage"]
],
# A delivered gap stays visible with its residual unknowns rather than
# disappearing, so partial delivery is not read as full coverage.
"unresolved_gaps": [
{"owner": gap["owner"], "gap": gap["gap"], "delegated_workplan": gap["delegated_workplan"]}
for gap in coverage["owned_gaps"]
if gap.get("status", "open") == "open"
],
"delivered_gaps": [
{
"owner": gap["owner"],
"delegated_workplan": gap["delegated_workplan"],
"delivered_on": gap.get("delivered_on"),
"interface": gap.get("interface", []),
"residual_unknowns": gap.get("residual_unknowns", []),
}
for gap in coverage["owned_gaps"]
if gap.get("status", "open") == "delivered"
],
}
@ -250,6 +265,9 @@ def next_actions(report: dict) -> list[str]:
actions = []
for gap in report["coverage"]["unresolved_gaps"]:
actions.append(f"{gap['owner']}: deliver {gap['delegated_workplan']}{gap['gap']}")
for gap in report["coverage"].get("delivered_gaps", []):
for residual in gap["residual_unknowns"]:
actions.append(f"{gap['owner']}: {gap['delegated_workplan']} delivered, still open — {residual}")
if report["cost"]["unpriced"]:
actions.append(
"resource-control: no portfolio spend figure exists until at least one booked cost arrives "

View file

@ -44,16 +44,30 @@ def main() -> int:
for resource in resources:
assert not required - resource.keys(), f"missing fields: {required - resource.keys()}"
validate_record(resource)
operational_records = [load(str(path)) for path in Path("data/control-cycle").glob("*.json")]
control_records += operational_records
record_ids = {record["record_id"] for record in control_records}
assert len(record_ids) == len(control_records)
assert {record["resource_class"] for record in control_records} == {"storage", "cluster_compute", "shared_platform_service"}
assert {record["resource_class"] for record in control_records} >= {"storage", "cluster_compute", "shared_platform_service"}
for record in control_records:
assert record["schema_version"] == "0.1"
assert record["schema_version"] in {"0.1", "0.2"}
assert record["resource_id"].startswith("resource:")
costs = record["costs"]
assert costs["total"] == round(costs["infrastructure"] + costs["internal_labor"] + costs["external_labor"], 2)
components = [costs["infrastructure"], costs["internal_labor"], costs["external_labor"]]
if any(component is None for component in components):
# An unknown component makes the total unknown; it is never the sum
# of the parts that happen to be known.
assert record["schema_version"] == "0.2", "null costs require schema 0.2"
assert costs["total"] is None
else:
assert costs["total"] == round(sum(components), 2)
if record["record_type"] == "actual":
assert record["forecast_ref"] in record_ids
# Operational records assert real facts and must cite the authoritative
# repository evidence they came from.
for record in operational_records:
assert record["evidence"], f"{record['record_id']} cites no evidence"
assert record["uncertainty"]["notes"], f"{record['record_id']} states no uncertainty"
case_schema = load("schemas/optimization-case.schema.json")
assert case_schema["$schema"].endswith("2020-12/schema")
assert case_schema["properties"]["schema_version"]["const"] == "0.1"