Media delivery incident
Cedar Media's incident owner needs a tenant-level summary of supplied delivery observations. Deliver a checked recommendation, isolate or observe, together with nonretry totals and per-tenant error evidence. The threshold is supplied by the owner, not invented by the function.
Cedar Media's support team sees failed delivery rows and wants to isolate a noisy tenant. Counting every failed attempt makes the incident look larger when retries are included, while dropping zero-error tenants hides part of the observed population.
You build an evidence summary through five checked steps. Start with the failure count, add its denominator, then remove retries consistently from both. The tenant breakdown supports a final recommendation tied to a supplied threshold. It's a decision rule for these fictional records, rather than a claim that one operational response suits every service. Keep the evidence fields in the final result so the person acting on it can trace the recommendation. An empty window should produce an ordinary, complete answer.
import json
def process_payload(payload: str) -> str:
data = json.loads(payload)
rows = data['rows']
errors = sum(not row['ok'] for row in rows)
result = {'errors':errors}
return json.dumps(result,sort_keys=True,separators=(',',':'))
The error count includes failed observations only. Define the eligible observation population first, then derive every summary field from that same population. The summary needs linear work in eligible rows and one group entry per tenant.