"""Synthetic event grouping, not a reproduction of any fleet measurement.""" import hashlib import json import math from pathlib import Path def group_starts(starts, window, *, anchor_first=False): """Group sorted starts; equality joins and duplicate times are retained.""" if isinstance(window, bool) or not isinstance(window, (int, float)) or not math.isfinite(window) or window <= 0: raise ValueError("window must be finite and positive") values = list(starts) if any(isinstance(t, bool) or not isinstance(t, (int, float)) or not math.isfinite(t) or t < 0 for t in values): raise ValueError("starts must be finite nonnegative seconds") groups = [] for value in sorted(values): reference = groups[-1][0 if anchor_first else -1] if groups else None if reference is None or value - reference > window: groups.append([value]) else: groups[-1].append(value) return groups def examples(): starts = [0, 90, 180, 600] rows = [] for window in [60, 120, 420]: groups = group_starts(starts, window) anchored = group_starts(starts, window, anchor_first=True) rows.append({ "windowSeconds": window, "adjacentGapGroups": groups, "anchoredGroups": anchored, "burstCountIncludingSingletons": len(groups), "longestSpanSeconds": max(group[-1] - group[0] for group in groups), "eventsInNonSingletonBursts": sum(len(group) for group in groups if len(group) >= 2), "totalEvents": len(starts), }) return { "schemaVersion": 1, "evidenceType": "synthetic-deterministic-example", "method": "Sort event starts; join when the gap from the previous start is <= window. Compare with an explicitly different first-start-anchored rule.", "source": "https://www.usenix.org/legacy/event/osdi10/tech/full_papers/Ford.pdf", "sourceSection": "4.1", "sourceBoundary": "Implements the adjacent-gap definition on chosen inputs, not the paper's fleet filtering, causal analysis or empirical 37% result.", "assumptions": [ "Each timestamp is one already-selected event on a distinct node.", "Seconds use one common clock; input order is irrelevant.", "Equality joins; singleton groups count as bursts.", "No duration filtering, exposure model, deduplication or causal inference." ], "startsSeconds": starts, "rows": rows, "generatorSha256": hashlib.sha256(Path(__file__).read_bytes()).hexdigest(), } if __name__ == "__main__": print(json.dumps(examples(), indent=2, allow_nan=False))