fix: match real GitLab event action_name values
Problem
GitLab's Events API (GET /api/v4/users/:id/events) returns human-readable action_name strings, not clean tokens. A comment is "commented on"; a push is "pushed to" or "pushed new" depending on ref state. The analyzers matched the raw strings literally:
internal/analyzer/collaboration.go:e.Action == "commented"-> on a real instance the comment term is always zero.internal/analyzer/source_control.go:e.Action == "pushed"-> push counts collapse on a real instance.
The fixtures hardcoded the clean tokens ("commented", "pushed"), so every test passed without ever exercising a real value. The bug shipped green.
Fix
Normalize once at the source. New normalizeAction helper in internal/collector/events.go, called from toSchemaEvent, maps raw action_name to a canonical token:
- prefix
pushed->"pushed"(covers"pushed to","pushed new","pushed to and removed") - prefix
commented->"commented"(covers"commented on") - all other actions preserved verbatim, trimmed and lowercased
Analyzers are made resilient as defense-in-depth: both now match the canonical token via strings.HasPrefix. Branch creation in Source Control reads the structured push_data (push_data_action / push_data_ref_type), not the action string, so it survives any wording.
De-vacuify the tests
- Collector fixtures (
events_test.go,integration_test.go) now feed realistic raw values:"commented on","pushed to","pushed new". - New
TestNormalizeActionandTestToSchemaEvent_NormalizesActionNamepin the raw-to-canonical mapping. - New
TestScorers_RealActionNamesasserts an event withaction_name: "commented on"yields a nonzero collaboration comment signal (computed 1.7) and that"pushed to"/"pushed new"count as pushes with branch creation (computed 1.2).
Validation
make checkpasses (go vet ./...+go test ./...).go test -race ./...passes.- Fails-on-old proof: reverting only the normalization and matching fix makes the new tests fail with exactly the zero-signal symptom:
TestScorers_RealActionNames:collaboration: got 0.800000, want 1.7andsource control score is zeroTestToSchemaEvent_NormalizesActionName:action_name="commented on" -> Action="commented on", want "commented"Restoring the fix makes them pass.