Backlog sweep: zero-time-delta, polar dwell, rate-limiter isolation, nonfinite-speed tests - #66
Merged
Merged
Conversation
…xed) The nonfinite/huge speed_mps 500 is already fixed (PointIn._drop_implausible_speed + MAX_SPEED_MPS drop any non-finite or >1e7 value to None). The 4 tests failed only because a strict httpx encoder (allow_nan=False) refuses to serialize inf in the request json=, failing client-side before reaching the server — a harness quirk, not a server bug. Send the bad speeds as raw JSON number literals (what a real client actually sends; the server parses 1e400 -> inf), which faithfully exercises the fix on any httpx version. Assertions unchanged. Verified all 6 pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Consecutive samples sharing a timestamp but differing in position (a logger batch-flushing buffered fixes under one wall-clock stamp) had their step speed forced to 0 by the divide-by-zero guard, so segment_by_motion classified real movement as "stopped" — a self-contradictory "stopped" segment carrying multiple km. Fix: force such zero-elapsed-time-but-moved samples to "moving" (position demonstrably changed; no finite speed derivable so they don't inflate max speed), and add a mobility.zero_time_position_change_count helper that compute_insights uses to surface a quality note (real distance at undefined speed) instead of silently reporting distance at 0 km/h. Also: reset the slowapi limiter before each adversary test (conftest autouse) — the module-singleton limiter accumulated across the fast full-suite run, so the later tests got spurious 429s (30/minute on /v1/insights) rather than exercising the behaviour under test. Proper per-test isolation; also relevant in CI where tests/adversary runs. Verified: both zero_time tests pass; full suite now only pole (unrelated backlog) + local-venv artifacts fail; 190 passed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
latlon_to_xy_m projected longitude linearly with a single global meters_per_deg_lon; near a pole longitude is degenerate (two points metres apart can differ by ~180°) and the lat/lon-mean centroid is wrong (the centre of two points straddling the pole is the pole itself), so a tight polar dwell projected to a far wider spread than its true extent and detect_stops missed it (a spec- named "known trap" from the antimeridian cycle). Fix: for clusters within ~11km of a pole (|lat0|>89.9), project via a proper spherical orthographic tangent plane about the 3D mean of the points' unit vectors. Gate never fires for ordinary tracks — verified BYTE-IDENTICAL to master over 5000 |lat|<=89.9 tracks — so cycles 4/5 (antimeridian projection/centroid) stay green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Backlog sweep — clears the remaining real red tests
Four items, each verified; the suite drops from 19 → 9 failures, and the 9 remaining are all local-venv artifacts (
test_file_parsersneeds gpxpy/fitparse,test_geocodingneeds httpx mocking — they pass under Poetry/CI). No real defect failures remain.1.
zero_time_deltamovement misreported as a stopped segment (real fix) — consecutive samples sharing a timestamp but differing in position had their step speed forced to 0, sosegment_by_motionclassified real movement as "stopped" (a self-contradictory "stopped" segment carrying km). Now such zero-elapsed-but-moved samples are forced to moving (no finite speed derivable, so they don't inflate max speed) andcompute_insightsadds aqualitynote. Newmobility.zero_time_position_change_count.2. Polar dwell false-negative (real fix) —
latlon_to_xy_mprojected longitude linearly with one global scale; near a pole longitude is degenerate and the lat/lon-mean centroid is wrong, so a tight polar dwell projected too wide anddetect_stopsmissed it. Now clusters within ~11 km of a pole (|lat0|>89.9) use a spherical orthographic tangent plane about the 3D unit-vector mean. Byte-identical to master over 5000 non-pole tracks — cycles 4/5 stay green.3. Rate-limiter test isolation (test infra) — the slowapi limiter is a module singleton whose in-memory storage accumulated across the fast full-suite run, so later adversary tests got spurious 429s (30/min on
/v1/insights) instead of exercising the behaviour under test. Added an autouse conftest fixture that resets it before each test. Relevant in CI too (tests/adversary runs there).4.
nonfinite_speedtests (test repair — server already fixed) — the non-finite/hugespeed_mps500 was already fixed (_drop_implausible_speed+MAX_SPEED_MPS). The tests only failed because a strict httpx encoder refuses to serializeinfin the requestjson=— a harness quirk. They now send raw JSON literals (what a real client sends), faithfully exercising the fix on any httpx version. Assertions unchanged.All under the standing "make the judgment calls and merge as needed" authorization.