test(hrv): split flaky integration into synthetic + floor + opt-in real-data#169
Merged
neuron7xLab merged 1 commit intoneuron7xLab:mainfrom May 1, 2026
Merged
Conversation
…al-data The previous TestHRV.test_gamma_in_range coupled three orthogonal claims into one mandatory mid-CI network call: 1. compute_gamma maths recovers γ ≈ 1 from a 1/f PSD, 2. _ensure_loaded enforces the 3-subject floor, 3. real PhysioNet/NSR2DB data lies in the physiological band. The single point of failure (PhysioNet/wfdb network) made (1) and (2) non-testable when the network flaked, and forced neuron7xLab#168 to bump n_subjects 3→5 — a margin bandaid, not a fix. This change reduces the test to first principles by splitting along the three axes: • test_compute_gamma_recovers_unity_from_synthetic_1f Always-on. Synthesises a 1/f signal through the same VLF-band Welch+mask the adapter uses; no wfdb, no network. Catches the maths regressing. • test_floor_minimum_enforced Always-on. Monkeypatches HRVPhysioNetAdapter._load to return one subject below the 3-subject floor and asserts the documented RuntimeError. Catches floor regressions without network. • test_real_data_gamma_in_range Opt-in via NEOSYNAPTEX_RUN_NETWORK_TESTS=1. Exercises the full wfdb→PSD→γ pipeline on real NSR2DB data; no longer on the PR critical path, so PhysioNet flakes cannot block merges. Intended to run in a dedicated nightly/scheduled CI lane. The floor constant (_HRV_FLOOR_MIN_SUBJECTS = 3) is named, not magic. The CI-run-id comment from neuron7xLab#168 is removed — the test no longer depends on transient network state, so the diagnostic context is documented in this commit message instead of polluting the source. Supersedes neuron7xLab#168. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces #168 (margin bandaid
n_subjects=3→5) with a first-principles split.The previous
TestHRV.test_gamma_in_rangewelded three orthogonal claims onto one mandatory mid-CI network call:compute_gammamathematics recovers γ ≈ 1 from a 1/f PSD,_ensure_loadedenforces the 3-subject floor,When wfdb/PhysioNet flakes — as happened in run 25184505044 — claims (1) and (2) become non-testable. Bumping
n_subjectsonly widens the absorption margin; the substrate is still the network.Decomposition
test_compute_gamma_recovers_unity_from_synthetic_1ftest_floor_minimum_enforced_load)test_real_data_gamma_in_rangeNEOSYNAPTEX_RUN_NETWORK_TESTS=1)The floor constant is named (
_HRV_FLOOR_MIN_SUBJECTS = 3), not magic. The CI-run-id comment from #168 is removed: the test no longer depends on transient network state, so diagnostic context lives in the commit message rather than polluting source.Effect on CI
Verify (3.10/3.11/3.12)) becomes fully offline for the HRV substrate. wfdb/PhysioNet flake can no longer break PRs.NEOSYNAPTEX_RUN_NETWORK_TESTS=1nightly so PhysioNet API drift is still caught.Test plan
pytest tests/test_integrity_v2.py→ 16 passed, 1 skipped (real-data, as designed).ruff format+ruff checkclean.[0.7, 1.3](deterministic seed 42).RuntimeError("Insufficient HRV data").Claim status
claim_status: derived
Pure test-architecture refactor — zero new measurement claims. The synthetic test recovers a textbook 1/f→γ=1 relation; the floor test exercises documented error handling; the real-data test is unchanged in intent, only gated.
Supersedes #168.
🤖 Generated with Claude Code