resource-control/schemas/monthly-resource-observation.schema.json
tegwick 10b988fa1c 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>
2026-08-14 20:53:12 +02:00

213 lines
5.9 KiB
JSON

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://coulomb.social/resource-control/monthly-resource-observation.schema.json",
"title": "Monthly resource forecast or technical usage observation",
"type": "object",
"additionalProperties": false,
"required": [
"schema_version",
"record_type",
"workload",
"cost_attribution_key",
"provider_id",
"created_at",
"rows"
],
"properties": {
"schema_version": {
"enum": [
"0.1",
"0.2"
],
"description": "0.2 permits null cost fields for periods the provider has not yet invoiced. Existing 0.1 records stay valid and are never rewritten."
},
"record_type": {
"enum": [
"forecast",
"usage_observation"
]
},
"workload": {
"type": "string"
},
"cost_attribution_key": {
"type": "string"
},
"provider_id": {
"type": "string"
},
"created_at": {
"type": "string",
"format": "date-time"
},
"scenario": {
"type": [
"string",
"null"
]
},
"forecast_ref": {
"type": [
"string",
"null"
]
},
"rows": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"period",
"database_gb",
"stored_gb",
"wal_gb",
"restore_egress_gb",
"write_requests",
"read_requests",
"infrastructure_eur",
"internal_labor_hours",
"internal_labor_eur",
"total_eur"
],
"properties": {
"period": {
"type": "string",
"pattern": "^[0-9]{4}-(0[1-9]|1[0-2])$"
},
"database_gb": {
"type": [
"number",
"null"
],
"minimum": 0,
"description": "Null when the period's evidence does not separate or measure this proxy. Null is unknown, never zero."
},
"stored_gb": {
"type": [
"number",
"null"
],
"minimum": 0,
"description": "Null when the period's evidence does not separate or measure this proxy. Null is unknown, never zero."
},
"wal_gb": {
"type": [
"number",
"null"
],
"minimum": 0,
"description": "Null when the period's evidence does not separate or measure this proxy. Null is unknown, never zero."
},
"restore_egress_gb": {
"type": [
"number",
"null"
],
"minimum": 0,
"description": "Null when the period's evidence does not separate or measure this proxy. Null is unknown, never zero."
},
"write_requests": {
"type": [
"integer",
"null"
],
"minimum": 0,
"description": "Null when no request metric is available for the period. Null is unknown, never zero."
},
"read_requests": {
"type": [
"integer",
"null"
],
"minimum": 0,
"description": "Null when no request metric is available for the period. Null is unknown, never zero."
},
"infrastructure_eur": {
"type": [
"number",
"null"
],
"minimum": 0,
"description": "EUR, or null when no invoice or valued time record exists for the period. Null is unknown, never zero."
},
"internal_labor_hours": {
"type": [
"number",
"null"
],
"minimum": 0,
"description": "Null when no time record exists for the period. Null is unknown, never zero."
},
"internal_labor_eur": {
"type": [
"number",
"null"
],
"minimum": 0,
"description": "EUR, or null when no invoice or valued time record exists for the period. Null is unknown, never zero."
},
"total_eur": {
"type": [
"number",
"null"
],
"minimum": 0,
"description": "EUR, or null when no invoice or valued time record exists for the period. Null is unknown, never zero."
},
"backup_success_pct": {
"type": [
"number",
"null"
],
"minimum": 0,
"maximum": 100
},
"restore_rto_minutes": {
"type": [
"number",
"null"
],
"minimum": 0
},
"max_rpo_minutes": {
"type": [
"number",
"null"
],
"minimum": 0
},
"evidence": {
"type": "array",
"items": {
"type": "string"
}
},
"measurement_gaps": {
"type": "array",
"items": {
"type": "string"
},
"uniqueItems": true,
"description": "Named reasons a proxy is null, each attributable to an owner or a missing source."
}
}
}
},
"evidence": {
"type": "array",
"items": {
"type": "string"
},
"uniqueItems": true,
"description": "Non-secret references to the provider usage export or invoice, the database and CNPG measurement, the restore drill record, and any internal time record."
},
"notes": {
"type": "array",
"items": {
"type": "string"
},
"description": "Conditions a reader needs to interpret the row correctly, such as a partial first period."
}
}
}