Per-MEP voting baseline computation for anomaly detection.
Provides primitives for the detect_voting_anomalies MCP tool:
resolveGroupMajority — DOCEO group-breakdown → plurality position
(FOR/AGAINST/ABSTAIN) with deterministic alphabetical tie-breaking.
classifyMepVote — for a given MEP and a single
LatestVoteRecord, returns whether the MEP was aligned with their
home group's majority, defected, abstained, or was absent, plus the
list of other groups whose majority matched the MEP's position (used to
detect cross-party alignment shifts).
bucketByWeek — groups classified votes into ISO-week buckets and
computes per-week defection / abstention rates.
computeBaseline / zScore — running mean & standard
deviation of weekly rates and per-week z-score.
findOutlierWeeks — collects weeks whose rate has a z-score
≥ a configurable threshold (default 1.5 per issue spec).
findWoWShifts — collects consecutive-week pairs whose defection
rate jumped by ≥ a configurable threshold (default 20 percentage points).
findCrossPartyAlignmentWindows — sub-windows where the MEP voted
with non-home group majorities on ≥ a configurable share (default 60%)
of decisive RCVs.
All helpers are pure and deterministic so they can be exercised with
synthetic fixtures and the golden-snapshot suite referenced in the
detect_voting_anomalies issue.
Fileoverview
Per-MEP voting baseline computation for anomaly detection.
Provides primitives for the
detect_voting_anomaliesMCP tool:alignedwith their home group's majority,defected,abstained, or wasabsent, plus the list of other groups whose majority matched the MEP's position (used to detect cross-party alignment shifts).All helpers are pure and deterministic so they can be exercised with synthetic fixtures and the golden-snapshot suite referenced in the
detect_voting_anomaliesissue.ISMS Policy: SC-002 (Input Validation), AC-003 (Least Privilege), AU-002 (Audit Logging). GDPR Article 5(1)(d) — accuracy.
Since
1.4.0