resource-control/schemas/optimization-case.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

402 lines
9.5 KiB
JSON

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://coulomb.social/resource-control/optimization-case.schema.json",
"title": "Resource optimization case",
"description": "An evidence-backed comparison between a baseline resource arrangement and one or more alternatives. Every option must present the same decision fields; unknown values are null and are reported as blocking evidence gaps rather than assumed.",
"type": "object",
"additionalProperties": false,
"required": [
"schema_version",
"record_scope",
"case_id",
"case_type",
"trigger",
"review_period",
"created_at",
"resource_ids",
"baseline",
"alternatives",
"decision",
"evidence"
],
"properties": {
"schema_version": {
"const": "0.1"
},
"record_scope": {
"description": "operational cases assert real facts; illustrative cases exist only to exercise the mechanism.",
"enum": [
"operational",
"illustrative"
]
},
"case_id": {
"type": "string",
"pattern": "^opt:[a-z0-9][a-z0-9:._-]+$"
},
"case_type": {
"enum": [
"rightsizing",
"consolidation",
"commitment",
"renewal",
"migration",
"retirement",
"provider_switch"
]
},
"trigger": {
"enum": [
"cadence",
"renewal",
"variance",
"incident",
"request",
"procurement"
]
},
"review_period": {
"type": "string",
"pattern": "^[0-9]{4}-(0[1-9]|1[0-2])$"
},
"created_at": {
"type": "string",
"format": "date-time"
},
"resource_ids": {
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": {
"type": "string",
"pattern": "^resource:"
}
},
"baseline": {
"$ref": "#/$defs/option"
},
"alternatives": {
"type": "array",
"minItems": 1,
"items": {
"$ref": "#/$defs/option"
}
},
"decision": {
"type": "object",
"additionalProperties": false,
"required": [
"state",
"recommended_option_id",
"rationale",
"approver",
"approved_on",
"delegated_to"
],
"properties": {
"state": {
"description": "blocked_on_evidence until every decision field of the compared options is known; proposed once the case computes; then approved or rejected by the named authority.",
"enum": [
"blocked_on_evidence",
"proposed",
"approved",
"rejected",
"superseded"
]
},
"recommended_option_id": {
"type": [
"string",
"null"
]
},
"rationale": {
"type": "string",
"minLength": 1
},
"approver": {
"description": "Named human or repository authority. Null while the case is not yet decided.",
"type": [
"string",
"null"
]
},
"approved_on": {
"type": [
"string",
"null"
],
"format": "date"
},
"delegated_to": {
"description": "Repositories that own any approved implementation. resource-control never implements.",
"type": "array",
"items": {
"type": "string"
},
"uniqueItems": true
}
}
},
"financial_handoff": {
"description": "What is sent to fin-hub when the case is approved.",
"type": "object",
"additionalProperties": false,
"required": [
"cost_attribution_key",
"sent"
],
"properties": {
"cost_attribution_key": {
"type": [
"string",
"null"
]
},
"sent": {
"type": "boolean"
},
"reference": {
"type": [
"string",
"null"
]
}
}
},
"outcome": {
"description": "Closes the loop: which control-cycle records will show whether the case was right.",
"type": "object",
"additionalProperties": false,
"required": [
"feeds_forecast",
"actual_refs"
],
"properties": {
"feeds_forecast": {
"type": "array",
"items": {
"type": "string"
},
"uniqueItems": true
},
"actual_refs": {
"type": "array",
"items": {
"type": "string"
},
"uniqueItems": true
}
}
},
"evidence": {
"type": "array",
"minItems": 1,
"items": {
"$ref": "#/$defs/evidence_ref"
}
}
},
"$defs": {
"measurement": {
"type": "object",
"additionalProperties": false,
"required": [
"value",
"unit"
],
"properties": {
"value": {
"type": [
"number",
"null"
]
},
"unit": {
"type": "string",
"minLength": 1
}
}
},
"utilization": {
"type": "object",
"additionalProperties": false,
"required": [
"provisioned",
"used"
],
"properties": {
"provisioned": {
"$ref": "#/$defs/measurement"
},
"used": {
"$ref": "#/$defs/measurement"
}
}
},
"evidence_ref": {
"type": "object",
"additionalProperties": false,
"required": [
"kind",
"ref",
"authority"
],
"properties": {
"kind": {
"enum": [
"telemetry",
"quote",
"contract",
"invoice",
"forecast",
"workplan",
"document",
"decision"
]
},
"ref": {
"type": "string",
"minLength": 1
},
"authority": {
"type": "string",
"minLength": 1
},
"observed_at": {
"type": [
"string",
"null"
],
"format": "date"
}
}
},
"option": {
"description": "Baseline and alternatives carry identical decision fields so they compare on equal terms. A null cost or utilization value means unknown, never zero.",
"type": "object",
"additionalProperties": false,
"required": [
"option_id",
"label",
"one_time_eur",
"recurring_infrastructure_eur_month",
"recurring_internal_labor_eur_month",
"recurring_external_labor_eur_month",
"utilization",
"uncertainty",
"service_constraints",
"failure_domains",
"exit_path",
"unknowns"
],
"properties": {
"option_id": {
"type": "string",
"minLength": 1
},
"label": {
"type": "string",
"minLength": 1
},
"one_time_eur": {
"type": [
"number",
"null"
],
"minimum": 0
},
"recurring_infrastructure_eur_month": {
"type": [
"number",
"null"
],
"minimum": 0
},
"recurring_internal_labor_eur_month": {
"type": [
"number",
"null"
],
"minimum": 0
},
"recurring_external_labor_eur_month": {
"type": [
"number",
"null"
],
"minimum": 0
},
"utilization": {
"type": "object",
"additionalProperties": {
"$ref": "#/$defs/utilization"
}
},
"uncertainty": {
"type": "object",
"additionalProperties": false,
"required": [
"level",
"notes"
],
"properties": {
"level": {
"enum": [
"low",
"medium",
"high"
]
},
"notes": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"service_constraints": {
"type": "object",
"additionalProperties": {
"$ref": "#/$defs/measurement"
}
},
"failure_domains": {
"type": "array",
"minItems": 1,
"items": {
"type": "string"
},
"uniqueItems": true
},
"exit_path": {
"type": [
"string",
"null"
]
},
"unknowns": {
"description": "Named blocking evidence gaps, each attributable to an owning repository or authority.",
"type": "array",
"items": {
"type": "string"
},
"uniqueItems": true
},
"excluded": {
"type": "boolean",
"default": false,
"description": "True when an alternative could not be evaluated and the deciding authority chose to exclude it rather than wait. An excluded option does not block the case, and its exclusion_reason becomes part of the decision record."
},
"exclusion_reason": {
"type": [
"string",
"null"
],
"description": "Required when excluded is true: why the option was set aside, and what would bring it back."
}
}
}
}
}