A function can pass its happy example and still break when two windows touch, a dependency repeats or a retried event carries a zero effect. Those cases belong in the contract rather than in a later patch.
You implement four service components with explicit adversarial boundaries. Intervals merge when they overlap or touch. Dependency edges may repeat without increasing the logical prerequisite count. A sliding window expires accepted requests exactly at its left boundary, and rejected arrivals consume no capacity. An idempotent ledger remembers zero-effect events too. These rules are small enough to test independently but common enough to matter in larger systems. Preserve the supplied order whenever the contract makes it observable, and use a stable tie rule where several choices are otherwise valid.
import json
def process_payload(payload: str) -> str:
data = json.loads(payload)
result = []
for start, end in sorted(data):
if result and start <= result[-1][1]:
result[-1][1] = max(result[-1][1], end)
else:
result.append([start,end])
return json.dumps(result,separators=(',',':'))
Touching intervals merge, and an inner interval cannot shorten its containing interval. Sort intervals before comparing the next start with the current merged end. Sorting dominates at O(n log n); the merge pass visits each interval once.