Update measurement handling for Cloudflare protocol#321
Open
Victor1Ja wants to merge 7 commits into
Open
Conversation
…ty metrics extraction - Updated `package.json` and `package-lock.json` to use `@nestjs/schedule` version 6.1.3 and `cron` version 4.4.0. - Added new DTOs for Cloudflare measurements, including detailed metrics for data usage, access information, server information, and measurement results. - Implemented mapping functions to convert Cloudflare measurement data into the application's internal format. - Enhanced the `MeasurementController` to support creating measurements by protocol, specifically for Cloudflare. - Added validation for measurement list queries and protocols. - Introduced quality metrics extraction functions to derive metrics from Cloudflare results. - Updated service methods to handle Cloudflare measurements and persist relevant quality metrics. - Added tests to ensure correct functionality for Cloudflare measurement handling and quality metrics extraction. Co-authored-by: Cursor <cursoragent@cursor.com>
…chema, and update migration to drop related database constraints and tables.
…DME with links to new documentation files - Introduced a section in `CONTRIBUTING.md` outlining the process for documenting merged pull requests, including file naming conventions and required content. - Updated `README.md` to include links to `CONTRIBUTING.md`, `CHANGELOG.md`, and new documentation directories for per-PR history and AI agent rules. - Added `CONTEXT_RULES.md` to define operational directives for AI agents working within the repository. - Created `CHANGELOG.md` for maintaining an append-only log of merged PRs. - Established `CURRENT_STATE.md` to serve as the single source of truth for the current system state. - Added architecture decision records (ADR) to document significant architectural choices. This commit enhances the clarity and structure of the contribution process and documentation for future contributors.
- Removed the migration check from the PR template to streamline the validation process. - Updated the validation section in the Cloudflare measurements protocol documentation to reflect that manual testing is now marked as complete, removing the need for a separate migration check. These changes enhance clarity in the PR process and ensure accurate documentation of validation steps.
- Removed the `country-config` module, including its controller, service, and DTOs, as well as the associated database table and enum. - Updated the `CHANGELOG.md` to reflect the removal of the legacy `country-config` API and the introduction of the `protocol-config` module for country/school configuration management. - Enhanced documentation in `CURRENT_STATE.md` and ADR 001 to clarify the new structure and the rationale behind the removal of legacy components. - Adjusted the application module to unregister the `CountryConfigModule` and ensure all references to the legacy API are removed. These changes streamline the configuration management process and eliminate outdated components, promoting a more cohesive architecture.
…test isolation - Removed the direct provision of `AuthGuard` and `ThrottlerGuard` in the test setup. - Implemented overrides for these guards to return a resolved promise for `canActivate`, enhancing test reliability and isolation. - Updated `ProtocolConfigService` tests to include new properties in the country protocol configuration, ensuring alignment with the latest schema changes. These adjustments streamline the testing process and ensure that tests accurately reflect the current application logic.
…ete obsolete migration files related to country configuration and measurement protocol quality metrics. Introduce a new migration for the updated protocol configuration structure, including new tables and foreign key constraints.
Victor1Ja
force-pushed
the
feat/cloudflare-measurements-v2
branch
from
May 28, 2026 13:01
b4d8f48 to
2771778
Compare
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.
Update measurement handling for Cloudflare protocol
Summary
This PR enables dual measurement providers (M-Lab + Cloudflare) on the backend: Cloudflare uploads via a dedicated route, persisted protocol discrimination with derived quality metrics, and a new protocol-config API for country/school provider settings. It also removes the legacy
country_configtable in favor ofcountry_protocol_config/school_protocol_config, and adds repository documentation (PR history, ADR, agent rules).Commits included (last 4):
7e4136082cf5cfCountryConfigmodel andMeasurementProviderenum; migrationremove_old_country_configc7528e0docs/,prs/,.agent/, ADR 001, CONTRIBUTING/README updatesa3195bdContext
Giga Meter must ingest connectivity data from more than one provider without breaking existing M-Lab clients. The Daily Check app and admin flows need:
protocoland quality fields onmeasurementswithout parsing JSON on every read.See ADR 001 and /prs/321-cloudflare-measurements-protocol.md for full technical decisions.
What changed
API
POST/api/v1/measurements/:protocolcloudflareonly;mlabreserved → 400POST/api/v1/measurementsGET/api/v1/measurements,/v2, …protocol=mlab|cloudflareGET/api/v1/protocol-config/resolvePUT/DELETE/api/v1/protocol-config/country/:countryCodePUT/DELETE/api/v1/protocol-config/school/:gigaIdSchoolCode modules
src/measurement/— Cloudflare DTOs, mapper, quality extraction (measurement-quality-metrics.ts), query validation,POST :protocol, list filters.src/protocol-config/— New module (controller, service, DTOs, tests).src/public/— Protocol-related fields on public measurement responses.src/app.module.ts— Registers protocol-config.Database
New / extended:
country_protocol_config,school_protocol_configmeasurements.protocol(defaultmlab), quality columns + index onprotocolRemoved:
country_configtableMeasurementProviderenum (replaced by string provider on protocol-config tables)Migrations:
20260506140000_protocol_config_tables20260512160000_add_measurement_protocol_quality_metrics20260518164253_remove_old_country_configLocal seed (optional):
src/prisma/seed.ts,src/prisma/scripts/local-dev-seed.sqlDocumentation (repo)
.agent/CONTEXT_RULES.md— agent operational rulesdocs/—CURRENT_STATE.md,CHANGELOG.md, ADR 001prs/— PR history template + record for this changeCONTRIBUTING.md/README.md— links and PR documentation processTechnical highlights
mapCloudflareMeasurementToAddDto()then existingcreateMeasurement().results— index-friendly queries; full JSON kept for audit.resultsdo not fail inserts.mlab, 0s delay).country_configdropped after protocol-config tables are in place.Out of scope
POST /api/v1/measurements/mlabon the protocol route (reserved, not implemented).resultsJSON.Test plan
npm run test -- --testPathPattern="measurement|protocol-config|cloudflare"POST /api/v1/measurements/cloudflarewith fixture payloadGET /api/v1/protocol-config/resolve?gigaIdSchool=...Related documentation
docs/adr/001-dual-protocol-measurements-and-config.mdprs/321-cloudflare-measurements-protocol.mddocs/CHANGELOG.md(PR-321)