From 22245a5032a9cb8b0abc5e3ac2b457f9f76464cc Mon Sep 17 00:00:00 2001 From: Zac Lou <97340247+ZacLou@users.noreply.github.com> Date: Fri, 28 Aug 2026 07:48:33 +0800 Subject: [PATCH 1/3] feat: add labels field to GitHubPullRequest for #13 --- crates/shared/src/types.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/shared/src/types.rs b/crates/shared/src/types.rs index 8aeb332..97b86be 100644 --- a/crates/shared/src/types.rs +++ b/crates/shared/src/types.rs @@ -66,6 +66,13 @@ pub struct GitHubPullRequest { pub merged: bool, pub user: GitHubUser, pub base: GitHubRef, + #[serde(default)] + pub labels: Vec, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct GitHubLabel { + pub name: String, } #[derive(Debug, Clone, Deserialize, Serialize)] From 6277078e46e22f8c476b7f66e58383393c0d9328 Mon Sep 17 00:00:00 2001 From: Zac Lou <97340247+ZacLou@users.noreply.github.com> Date: Fri, 28 Aug 2026 07:48:35 +0800 Subject: [PATCH 2/3] feat: map GitHub labels to Wave complexity points (#13) --- crates/gateway/src/webhook.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/gateway/src/webhook.rs b/crates/gateway/src/webhook.rs index c576085..c5cab43 100644 --- a/crates/gateway/src/webhook.rs +++ b/crates/gateway/src/webhook.rs @@ -27,6 +27,21 @@ pub fn verify_github_signature(secret: &str, body: &[u8], signature_header: &str } /// Returns attestation inputs when the payload is a merged PR on the default branch. + +/// Map GitHub PR labels to Wave complexity points. +/// Labels follow Drips Wave convention: complexity:low=1, complexity:medium=3, complexity:high=5. +fn label_to_points(labels: &[waveflow_shared::GitHubLabel]) -> u32 { + for label in labels { + match label.name.as_str() { + "complexity:high" => return 5, + "complexity:medium" => return 3, + "complexity:low" => return 2, + _ => continue, + } + } + 1 // default points when no recognized complexity label +} + pub fn parse_merge_event(payload: &GitHubPullRequestEvent) -> WaveFlowResult { if payload.action != "closed" { return Err(WaveFlowError::Validation("ignored non-closed action".into())); @@ -42,7 +57,7 @@ pub fn parse_merge_event(payload: &GitHubPullRequestEvent) -> WaveFlowResult Date: Fri, 28 Aug 2026 07:49:01 +0800 Subject: [PATCH 3/3] test: add label-to-points mapping tests (#13) --- crates/gateway/src/webhook.rs | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/crates/gateway/src/webhook.rs b/crates/gateway/src/webhook.rs index c5cab43..f51586d 100644 --- a/crates/gateway/src/webhook.rs +++ b/crates/gateway/src/webhook.rs @@ -86,6 +86,7 @@ mod tests { base: GitHubRef { ref_name: base_ref.into(), }, + labels: vec![], }, repository: GitHubRepository { full_name: "StellarRoute/WaveFlow".into(), @@ -137,3 +138,42 @@ mod tests { assert!(matches!(err, WaveFlowError::Validation(_))); } } + + + #[test] + fn parse_merge_event_maps_complexity_labels_to_points() { + let mut event = sample_event(true, "main", "main"); + event.pull_request.labels = vec![ + waveflow_shared::GitHubLabel { name: "complexity:medium".into() }, + waveflow_shared::GitHubLabel { name: "bug".into() }, + ]; + let attestation = parse_merge_event(&event).expect("merge"); + assert_eq!(attestation.points, 3); + } + + #[test] + fn parse_merge_event_defaults_points_to_1_without_label() { + let event = sample_event(true, "main", "main"); + let attestation = parse_merge_event(&event).expect("merge"); + assert_eq!(attestation.points, 1); + } + + #[test] + fn parse_merge_event_maps_high_complexity() { + let mut event = sample_event(true, "main", "main"); + event.pull_request.labels = vec![ + waveflow_shared::GitHubLabel { name: "complexity:high".into() }, + ]; + let attestation = parse_merge_event(&event).expect("merge"); + assert_eq!(attestation.points, 5); + } + + #[test] + fn parse_merge_event_maps_low_complexity() { + let mut event = sample_event(true, "main", "main"); + event.pull_request.labels = vec![ + waveflow_shared::GitHubLabel { name: "complexity:low".into() }, + ]; + let attestation = parse_merge_event(&event).expect("merge"); + assert_eq!(attestation.points, 2); + }