Whole file
conorluddy/ios-simulator-skill
The author described this change as “fix: handle zero-duration clusters in diff_sessions()”. It counts as a record because the checks below fail on the code as it stood at 03e092d54 and pass on 1f98d4c51, with nothing else changed between the two runs.
Fix saved2026-05-23
Sharing licenceMIT · LICENSE.md
Change size+15 −4
What the code was meant to do, written into the code itself as a save note
fix: handle zero-duration clusters in diff_sessions()
The change
| 506 | 506 | if drift: | |
| 507 | 507 | lines.append(f"Drift ({len(drift)}):") | |
| 508 | 508 | for entry in drift[:5]: | |
| 509 | + | # inf delta (0 → N) renders as "new"; finite deltas keep the % suffix. | |
| 510 | + | delta = entry["delta_pct"] | |
| 511 | + | delta_str = "new" if delta == float("inf") else f"{delta:+.0f}%" | |
| 509 | 512 | lines.append( | |
| 510 | 513 | f" ~ {entry['symbol_or_prefix']}: " | |
| 511 | 514 | f"{entry['max_duration_ms_a']:.0f} → {entry['max_duration_ms_b']:.0f}ms " | |
| 512 | - | f"({entry['delta_pct']:+.0f}%)" | |
| 515 | + | f"({delta_str})" | |
| 513 | 516 | ) | |
| 514 | 517 | if stable: | |
| 515 | 518 | lines.append(f"Stable: {stable} cluster(s) unchanged") | |
| ⋯ | |||
| 583 | 586 | stable = 0 | |
| 584 | 587 | for key in shared_keys: | |
| 585 | 588 | ca, cb = a_map[key], b_map[key] | |
| 586 | - | if ca.max_duration_ms == 0: | |
| 589 | + | if ca.max_duration_ms == 0 and cb.max_duration_ms == 0: | |
| 590 | + | stable += 1 | |
| 587 | 591 | continue | |
| 588 | - | delta_pct = (cb.max_duration_ms - ca.max_duration_ms) / ca.max_duration_ms * 100 | |
| 589 | - | if abs(delta_pct) >= drift_threshold_pct: | |
| 592 | + | if ca.max_duration_ms == 0: | |
| 593 | + | # 0 → N: a previously-silent cluster now hangs; treat as max worsening. | |
| 594 | + | delta_pct: float = float("inf") | |
| 595 | + | elif cb.max_duration_ms == 0: | |
| 596 | + | # N → 0: cluster present in A but flat in B; fully improved. | |
| 597 | + | delta_pct = -100.0 | |
| 598 | + | else: | |
| 599 | + | delta_pct = (cb.max_duration_ms - ca.max_duration_ms) / ca.max_duration_ms * 100 | |
| 600 | + | if delta_pct == float("inf") or abs(delta_pct) >= drift_threshold_pct: | |
| 590 | 601 | drift.append( | |
| 591 | 602 | { | |
| 592 | 603 | "fingerprint": key, | |
The check that tells the two apart
fail→pass·tests/test_diff.py::test_diff_zero_to_nonzero_is_drift_with_inf_delta
fail→pass·tests/test_diff.py::test_diff_zero_to_zero_counts_as_stable
fail→pass·tests/test_diff.py::test_format_diff_renders_inf_delta_as_new
Check file tests/test_diff.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it03e092d54357333b64a12c5f25590a8c9e4b9e74
Broken version dated2026-05-23
Moduleios-simulator-skill.skills.ios-simulator-skill.scripts.common.hang_pipeline
Units changeddiff_sessions, format_diff
Fingerprint1df67d1039b17285
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.