Skip to content

feat: Phase 1 complete — DRIFT detection, unit tests, CI fix#3

Merged
Fabien83560 merged 6 commits into
mainfrom
dev
May 15, 2026
Merged

feat: Phase 1 complete — DRIFT detection, unit tests, CI fix#3
Fabien83560 merged 6 commits into
mainfrom
dev

Conversation

@Fabien83560

Copy link
Copy Markdown
Member

Context

Closes Phase 1 of the ApiForge roadmap. This PR brings sdk-python up to spec with the CDC v4.0 requirements: DRIFT insight detection, full unit test suite (≥80% coverage), and CI pipeline fix.

Changes

  • DRIFT insight: progressive latency degradation detection via OLS linear regression on daily P90 buckets over 30 days — emitted when slope ≥ 5ms/day over 7+ data points, with 30-day projection
  • Unit tests: 60 unit tests across aggregator, database, insights, middleware using pytest — all passing
  • CI fix: push trigger extended to main so the README badge resolves correctly
  • Dashboard: added DRIFT filter chip to the Insights panel
  • Version: bumped to 1.0.3

How to test

pip install -e ".[dev]"
pytest tests/ -v    # 60 unit tests — all should pass

Check the Insights panel in the dashboard at http://localhost:4242 — the DRIFT chip should appear alongside ANOMALY, DEAD, and PERF.

Checklist

  • Tests added / updated (60 unit tests, all passing)
  • Documentation updated (CHANGELOG.md)
  • No breaking change
  • Reviewed locally

Mirrors the Node.js implementation (§7.2.4 of the CDC).

get_drift_data() in database.py aggregates P90 latency per endpoint per
day over the last 30 days. _detect_drift() in insights.py runs ordinary
least squares on the daily series: slope >= 5ms/day with at least 7 days
of data emits a DRIFT insight with the slope and a 30-day projection.
…nd middleware

60 tests covering:
- Aggregator: record() (counters, bucket keys), _flush() (percentiles, min/max,
  total_calls, buffer clear), stop() flush-on-exit
- ApiForgeDatabase: insert_batch, get_summary, get_time_series, get_dead_candidates,
  get_release_comparison, upsert_known_routes, get_drift_data, get_global_time_series
- get_insights: ANOMALY, DEAD, PERF, OK, UNTRACKED, DRIFT detection, error resilience
- compute_health_score: None on empty data, 0-100 range, high score on healthy API
- ApiForgeMiddleware: pass-through, parametric routes, ignored paths, sampling,
  5xx error pass-through, crash resilience
The CI workflow only triggers on push to dev — the badge was pointing to
main where no run ever happens, causing the permanent "no status" state.
Adding main to the push trigger ensures a workflow run exists on main
after each merge, so the shields.io badge can resolve a real status
instead of showing "no status".
@Fabien83560 Fabien83560 merged commit 990762a into main May 15, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant