Design a service contract

A contract is a reviewable statement of what a service must demonstrate. Start with a material outcome, then bind controls and dependencies to explicit evidence—not to keywords.

Ask five questions first

QuestionContract elementFailure if omitted
Which service is in scope?service_idEvidence can be applied to the wrong subject.
Which outcome matters?objectivesControls become disconnected from business purpose.
What must be observed?controlsThe obligation cannot be evaluated consistently.
Which services can invalidate a local result?dependenciesA local PASS hides upstream uncertainty.
Who owns the response?Contract metadata / response planResults are produced without accountable action.

Model a measurable objective

The API expresses a business objective as a metric, target and comparator. For recovery, a smaller observed time may be better, so the criterion can be restore_minutes <= 60.

contract_spec = {
    "service_id": "checkout",
    "name": "Checkout service",
    "objectives": [{
        "objective_id": "restore-orders",
        "metric": "restore_minutes",
        "target": 60,
        "comparator": "<=",
    }],
}

Add the supporting control

contract_spec["controls"] = [{
    "control_id": "restore-test",
    "title": "Restore test succeeded",
    "assertion": "restore_test_passed",
    "expected_value": True,
}]
contract_spec["control_objective_links"] = [{
    "control_id": "restore-test",
    "objective_id": "restore-orders",
    "relation": "measures",
    "provenance": "approved recovery design",
    "scope_conditions": ["production-like data volume"],
}]

The link records why the control relates to the objective and under which conditions. It does not prove that the relation is universally valid.

Bind critical dependencies

contract_spec["dependencies"] = ["orders-database"]
contract_spec["dependency_requirements"] = [{
    "dependency_id": "orders-database",
    "assertion": "database_restored",
    "expected_value": True,
}]
contract = compile_service_contract(contract_spec)

Contract review checklist

Anti-pattern: importing a control catalog and marking every item PASS because a policy document exists. Design evidence for operating effectiveness and the stated decision, not for checklist completion.