MODULE 10 · 5 HOUR BUILD
Inspectable incident control loop
Build a small controller with typed observations, working state, memory lookup, strategy choice, execution simulation, and a decision record for every action.
Build evidence Record your actual checks, results, and limitations.
Build it in stages
- Run the seed to see freshness and uncertainty alter selected actions.
- Create explicit dataclasses or dictionaries for observations, beliefs, actions, and results.
- Add independent perception, memory, strategy, executor, and verification functions.
- Add stale, missing, duplicated, and conflicting observation scenarios.
- Compare an adaptive strategy selector with an always-inspect baseline on the same fixtures.
Your acceptance criteria
Use these as your project review. Record commands, outputs, and failure cases in your repository.
- At least 10 deterministic incidents produce complete decision records.
- Stale observations trigger refresh before any remediation proposal.
- Repeated representations of one source event do not count as independent evidence.
- The report includes task outcome, action cost, and unresolved cases by scenario class.
A working starting point
The seed runs as supplied. Extend it to satisfy the full brief. It is a teaching starting point, not a finished portfolio submission.
main.py
python
import json
from dataclasses import dataclass
@dataclass(frozen=True)
class Incident:
identity: str
observed_at: int
latency_ms: int
deployment_probability: float
def perceive(incident, now):
return {"age": now - incident.observed_at,
"high": incident.latency_ms > 800,
"deployment": incident.deployment_probability}
def decide(state):
if state["age"] < 0:
return "reject timestamp", "future observation"
if state["age"] > 5:
return "refresh", "measurement stale"
if not state["high"]:
return "monitor", "threshold not exceeded"
if state["deployment"] >= 0.7:
return "inspect deployment", "deployment hypothesis prioritized"
return "compare causes", "hypotheses remain uncertain"
incidents = [Incident("old", 2, 900, 0.9), Incident("likely", 9, 900, 0.8),
Incident("uncertain", 9, 900, 0.4), Incident("normal", 9, 300, 0.8)]
for incident in incidents:
state = perceive(incident, now=10)
action, reason = decide(state)
record = {"incident": incident.identity, "action": action, "reason": reason,
"source_time": incident.observed_at, "simulation": True}
print(json.dumps(record, sort_keys=True))
Push it further
Fit a probability calibration model on one fixture partition and evaluate it on a held-out time partition, reporting calibration and discrimination separately.