"""Deterministic incident workflow. Author: Sandeep Belgavi. Synthetic only.""" from dataclasses import dataclass @dataclass(frozen=True) class Checkpoint: incident: str stage: str = "new" category: str = "" evidence: str = "" def advance(state, classifier, inventory): if not isinstance(state, Checkpoint) or not state.incident: raise ValueError("incident checkpoint required") if state.stage == "new": category = classifier(state.incident) if category not in {"latency", "availability"}: raise ValueError("unsupported classification") return Checkpoint(state.incident, "classified", category) if state.stage == "classified": if state.category not in {"latency", "availability"}: raise ValueError("invalid stored category") value = inventory.get(state.category) if not isinstance(value, str) or not value: raise ValueError("evidence missing") return Checkpoint(state.incident, "collected", state.category, value) if state.stage in {"collected", "ready"}: if state.category not in {"latency", "availability"} or not state.evidence: raise ValueError("incomplete checkpoint") return Checkpoint(state.incident, "ready", state.category, state.evidence) raise ValueError("unknown stage") if __name__ == "__main__": state = Checkpoint("INC-42") for _ in range(3): state = advance(state, lambda _: "latency", {"latency": "fixture:L1"}) print(f"stage={state.stage} category={state.category} evidence={state.evidence}")