Run your first assurance decision
This is the smallest complete path: declare a service contract, admit a versioned observation, evaluate it at an explicit time, inspect the explanation, and retain the evidence reference.
1. Install
python -m pip install --pre assurance-lab
Use import assurance_lab in Python. The base wheel has no third-party runtime dependency.
2. Declare the business contract
The contract is the part an owner reviews: which service is in scope, which assertion must be true, and which business metric must meet a target.
from datetime import datetime, timezone from assurance_lab import compile_service_contract now = datetime.now(timezone.utc) contract = compile_service_contract({ "service_id": "checkout", "name": "Payment checkout", "controls": [{ "control_id": "backup", "title": "Backup is fresh", "assertion": "backup_fresh", "expected_value": True, }], "objectives": [{ "objective_id": "rto", "metric": "rto_minutes", "target": 60, "comparator": "<=", }], "dependencies": [], })
3. Admit evidence
Telemetry is versioned at the boundary. The adapter turns each record into immutable evidence; it does not decide the result.
from assurance_lab import MappingEvidenceAdapter, ingest_json_envelope payload = { "schema_version": "assurance-telemetry/v1", "records": [ { "evidence_id": "backup-001", "subject": "checkout", "assertion": "backup_fresh", "value": True, "observed_at": now.isoformat(), "kind": "runtime", "provenance": "backup-monitor", }, { "evidence_id": "rto-001", "subject": "checkout", "assertion": "rto_minutes", "value": 42, "observed_at": now.isoformat(), "kind": "test", "provenance": "recovery-test-2026-10", }, ], } batch = ingest_json_envelope(payload, MappingEvidenceAdapter()) evidence = batch.evidence
4. Evaluate and inspect the explanation
from assurance_lab import AssuranceEngine decision = AssuranceEngine(require_provenance=True).evaluate( contract, evidence, now=now, ) print(decision.state.value) # PASS print(decision.control_results) print(decision.objective_results) print(decision.evidence_ids) print(decision.reasons)
The result is scoped to this contract, evidence set, rule version and evaluation time. PASS does not mean certification or absence of cyber risk.
5. Learn the negative states
| State | What caused it | What the operator should do |
|---|---|---|
| UNKNOWN | Required evidence or trust condition is missing. | Collect, bind or repair the evidence path. |
| FAIL | Valid evidence contradicts the declared target. | Route to the approved response/risk owner. |
| EXPIRED | The observation is outside its validity window. | Refresh the observation; do not silently reuse it. |
| CONFLICT | Relevant observations disagree. | Investigate source identity, timing and mapping. |
| NOT_TESTED | No evidence reached the evaluator. | Fix scheduling, collection or admission. |
6. Add trust gates gradually
Start with local smoke tests, then enable gates only when their upstream evidence exists.
require_integrity=TrueEvery relevant evidence hash must match the canonical payload.
require_signature=TrueAdapter metadata must record a verified signature.
require_replay=TrueAdapter metadata must record an accepted nonce/sequence.
require_dependency_binding=TrueEvery declared dependency must be bound to an assertion.
require_business_linkage=TrueControls and objectives must have explicit typed links.
7. Retain and reproduce
from assurance_lab import EvidenceLedger, AuditChain ledger = EvidenceLedger() for item in evidence: ledger.append(item) ledger.export_jsonl("artifacts/evidence.jsonl") chain = AuditChain("artifacts/audit.jsonl") chain.append({"event": "decision", "state": decision.state.value, "evidence_ids": decision.evidence_ids}) assert chain.verify().valid