tooling: pin window arithmetic and refusals in startup_audio_timeline_check #1835

Merged
Asimmimx merged 1 commit from upstream-pr/1842 into main 2026-11-24 19:42:22 +00:00
Asimmimx commented 2026-11-24 19:22:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T19:22:09Z.


Change

tests/startup_audio_timeline_check.py drives tools/startup_audio_timeline.py (added in #1763) with one fixture. That fixture uses a symmetric window (--before 0.1 --after 0.1), the default sample rate, packets already in time order with no overlap, and only fully covered or fully empty windows with audio. It never feeds an invalid row or option. So several documented behaviors could change without the check failing.

I applied single-point mutants to the tool by hand, ran the check after each one, then reverted the tool:

Mutant Existing check With the new cases
M1 drop the negative-flags refusal survived killed
M2 frames < 1 -> frames < 0 (accept zero-frame packets) survived killed
M3 drop rms <= peak from the level check survived killed
M4 skip mask flags & 4 -> flags & 2 killed killed
M5 drop the sorted(...) of packets survived killed
M6 max(cursor, packet.start) -> packet.start killed killed
M6b max(cursor, packet.start) -> max(start, packet.start) (count overlap twice) survived killed
M6c drop cursor = last survived killed
M7 discontinuity count flags & 1 -> any nonzero flag survived killed
M8 drop count += 1 (packets field) survived killed
M9 RMS divides energy by window length instead of covered time survived killed
M10 window start uses --after instead of --before survived killed
M11 ignore --sample-rate (always 48,000 Hz) survived killed
M12 packet_peak keeps the last packet instead of the maximum killed killed
M13 loop break packet.start >= end -> > survived survived (equivalent: a packet that starts at end has no overlap and is skipped)
M14 drop the zero-length window refusal survived killed
M15 drop the "action must be a string" refusal survived killed

The new cases:

  • test_unsorted_overlap_and_asymmetric_window runs at --sample-rate 1000 with --before 0.2 --after 0.1, so 200 frames last 0.2 s and an event at QPC 101.2 has the window 101.0..101.3. The CSV lists a later packet first. A silent packet (flag 2) covers 101.0..101.2, and a discontinuity packet (flag 1, RMS 0.6, peak 0.9) covers 101.1..101.3. The overlap counts once, so coverage is 1 and the RMS is sqrt(0.6^2 * 0.1 / 0.3), with 2 packets, 1 discontinuity and peak 0.9. A second event at 103.2 is covered only by 103.0..103.1 at RMS 0.5. Coverage is 1/3 and the RMS estimate stays 0.5, because the docs average over covered time only.
  • test_invalid_rows_and_options_are_refused checks that the CLI exits with status 2 and names the reason for: negative flags, zero frames, RMS above peak, a non-string action, and --before 0 --after 0.

Verification

Based on origin/main 813045b3 (merge of #1763). Windows 11 Pro 26300.9974, Python 3.12.10.

> python -B tests/startup_audio_timeline_check.py
Ran 3 tests in 0.782s
OK

> python -B tests/docs_links_check.py
Self-test passed.
Checked 18 Markdown files and 369 links.

> python -B tests/bidi_controls_check.py
Self-test passed.
Checked 1320 tracked source, script and build/CI files: no bidirectional controls.

The mutation table above comes from a local probe script (not committed). It rewrites one line of tools/startup_audio_timeline.py, runs python -B tests/startup_audio_timeline_check.py, records a nonzero exit as "killed" and restores the tool. I ran it against the check at 813045b3 and again against this branch.

Evidence and follow-up

  • All inputs are synthetic packet statistics and control events generated in a temporary directory.
  • M13 is not pinned because it is an equivalent mutant.
  • I could not find startup_audio_timeline_check in CMakeLists.txt or .github/workflows/, so it runs only when someone invokes it directly. I left registration out of this PR so it stays a test-only change.
  • The tool is not changed.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed. (No capability or build requirement changed.)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6589600615 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1842). Originally posted by [Asimmimx](https://github.com/Asimmimx) on 2026-11-24T19:22:09Z. --- ## Change `tests/startup_audio_timeline_check.py` drives `tools/startup_audio_timeline.py` (added in #1763) with one fixture. That fixture uses a symmetric window (`--before 0.1 --after 0.1`), the default sample rate, packets already in time order with no overlap, and only fully covered or fully empty windows with audio. It never feeds an invalid row or option. So several documented behaviors could change without the check failing. I applied single-point mutants to the tool by hand, ran the check after each one, then reverted the tool: | Mutant | Existing check | With the new cases | |---|---|---| | M1 drop the negative-`flags` refusal | survived | killed | | M2 `frames < 1` -> `frames < 0` (accept zero-frame packets) | survived | killed | | M3 drop `rms <= peak` from the level check | survived | killed | | M4 skip mask `flags & 4` -> `flags & 2` | killed | killed | | M5 drop the `sorted(...)` of packets | survived | killed | | M6 `max(cursor, packet.start)` -> `packet.start` | killed | killed | | M6b `max(cursor, packet.start)` -> `max(start, packet.start)` (count overlap twice) | survived | killed | | M6c drop `cursor = last` | survived | killed | | M7 discontinuity count `flags & 1` -> any nonzero flag | survived | killed | | M8 drop `count += 1` (`packets` field) | survived | killed | | M9 RMS divides energy by window length instead of covered time | survived | killed | | M10 window start uses `--after` instead of `--before` | survived | killed | | M11 ignore `--sample-rate` (always 48,000 Hz) | survived | killed | | M12 `packet_peak` keeps the last packet instead of the maximum | killed | killed | | M13 loop break `packet.start >= end` -> `>` | survived | survived (equivalent: a packet that starts at `end` has no overlap and is skipped) | | M14 drop the zero-length window refusal | survived | killed | | M15 drop the "action must be a string" refusal | survived | killed | The new cases: - `test_unsorted_overlap_and_asymmetric_window` runs at `--sample-rate 1000` with `--before 0.2 --after 0.1`, so 200 frames last 0.2 s and an event at QPC 101.2 has the window 101.0..101.3. The CSV lists a later packet first. A silent packet (flag 2) covers 101.0..101.2, and a discontinuity packet (flag 1, RMS 0.6, peak 0.9) covers 101.1..101.3. The overlap counts once, so coverage is 1 and the RMS is `sqrt(0.6^2 * 0.1 / 0.3)`, with 2 packets, 1 discontinuity and peak 0.9. A second event at 103.2 is covered only by 103.0..103.1 at RMS 0.5. Coverage is 1/3 and the RMS estimate stays 0.5, because the docs average over covered time only. - `test_invalid_rows_and_options_are_refused` checks that the CLI exits with status 2 and names the reason for: negative flags, zero frames, RMS above peak, a non-string action, and `--before 0 --after 0`. ## Verification Based on `origin/main` 813045b3 (merge of #1763). Windows 11 Pro 26300.9974, Python 3.12.10. ```text > python -B tests/startup_audio_timeline_check.py Ran 3 tests in 0.782s OK > python -B tests/docs_links_check.py Self-test passed. Checked 18 Markdown files and 369 links. > python -B tests/bidi_controls_check.py Self-test passed. Checked 1320 tracked source, script and build/CI files: no bidirectional controls. ``` The mutation table above comes from a local probe script (not committed). It rewrites one line of `tools/startup_audio_timeline.py`, runs `python -B tests/startup_audio_timeline_check.py`, records a nonzero exit as "killed" and restores the tool. I ran it against the check at 813045b3 and again against this branch. ## Evidence and follow-up - All inputs are synthetic packet statistics and control events generated in a temporary directory. - M13 is not pinned because it is an equivalent mutant. - I could not find `startup_audio_timeline_check` in `CMakeLists.txt` or `.github/workflows/`, so it runs only when someone invokes it directly. I left registration out of this PR so it stays a test-only change. - The tool is not changed. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. (No capability or build requirement changed.) - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-24 20:00:57 +00:00
tedin7 commented 2026-11-24 20:00:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:35:36Z.

Review: COMMENTED


Reviewed head f3363374fd85bb06b8440b6e60ee7b5dd02a3585 in a clean Linux worktree.

  • git diff --check origin/main...HEAD: clean (rc 0)
  • python -B tests/bidi_controls_check.py: rc 0
  • python -B tests/startup_audio_timeline_check.py: rc 0

Local mutations on tools/startup_audio_timeline.py (each restored with git checkout -- .). startup_audio_timeline_check.py failed (rc 1) when I:

  • removed the overlap cursor advance (cursor = last)
  • removed the sort by packet start
  • averaged RMS over the whole window instead of covered time
  • disabled the negative flags check
  • swapped the before and after window sides

The unsorted, overlapping and asymmetric-window cases and the refusal cases test real logic with exact expected values.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6046029798 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1842#pullrequestreview-6046029798). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T19:35:36Z. **Review:** COMMENTED --- Reviewed head `f3363374fd85bb06b8440b6e60ee7b5dd02a3585` in a clean Linux worktree. - `git diff --check origin/main...HEAD`: clean (rc 0) - `python -B tests/bidi_controls_check.py`: rc 0 - `python -B tests/startup_audio_timeline_check.py`: rc 0 Local mutations on `tools/startup_audio_timeline.py` (each restored with `git checkout -- .`). `startup_audio_timeline_check.py` failed (rc 1) when I: - removed the overlap cursor advance (`cursor = last`) - removed the sort by packet start - averaged RMS over the whole window instead of covered time - disabled the negative flags check - swapped the before and after window sides The unsorted, overlapping and asymmetric-window cases and the refusal cases test real logic with exact expected values. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-24 20:01:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:30:47Z.


Thanks for writing these thorough edge-case checks across the test suite (#1824–#1842) — the test cases themselves are clean and well-scoped.

Quick friendly workflow suggestion for future batches: because each separate PR triggers a full Windows CI build (and another main-branch CI run on merge), grouping related 10–30 line test additions by area into 2–3 PRs instead of ~19 individual PRs helps keep GitHub Actions runners and the open PR queue much lighter for everyone.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7142204225 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1842#issuecomment-7142204225). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T19:30:47Z. --- Thanks for writing these thorough edge-case checks across the test suite (#1824–#1842) — the test cases themselves are clean and well-scoped. Quick friendly workflow suggestion for future batches: because each separate PR triggers a full Windows CI build (and another main-branch CI run on merge), grouping related 10–30 line test additions by area into 2–3 PRs instead of ~19 individual PRs helps keep GitHub Actions runners and the open PR queue much lighter for everyone. AI-assisted.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!1835
No description provided.