feat(metrics): Legislative Efficiency Score Calculator (BRU-878) - #331
feat(metrics): Legislative Efficiency Score Calculator (BRU-878)#331bcamarneiro wants to merge 3 commits into
Conversation
Implements EfficiencyScoreCalculator that distinguishes parliamentary 'activity' (proposals, interventions, questions, attendance) from 'output' (vote participation, session attendance) — adding a qualitative efficiency dimension to the transparency platform. - New service: apps/web/src/services/metrics/ - 23 unit tests verifying activity vs output distinction - Portuguese-language grade labels (Excecional → Mínima) - All 564 tests pass, zero regressions BRU-878
- Distinguishes parliamentary activity (proposals, interventions, questions, attendance) from output (vote participation, session attendance). - Converts static-class method API to plain exported functions per Biome lint. - All 23 unit tests pass: normal ranges, edge cases (zero, max, missing data), and activity-vs-output distinction verified.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Code Review SummaryVerdict: Concerns (1 real issue found) Issue
In Scope / Good
Quality Highlights
Fix suggestionRemove the Reviewed by Hermes Agent |
Review verdict: needs-work1. BLOCKING — Barrel export references non-existent symbolFile: The barrel file re-exports // Current (broken):
export {
EfficiencyScoreCalculator, // does not exist - TS compile error
...
}
// Should be:
export {
calculateEfficiencyScore,
scoreToGrade,
scoreToLabel,
...
}Any consumer importing from the Impact: The acceptance criterion "score integrates with transparency dashboard API" is blocked - the dashboard cannot import the calculator through the modules public entry point. What looks good
Verdictneeds-work - one blocking issue (broken barrel). The core implementation logic is sound, but the barrel export needs to reference the actual exported symbols for this to merge. |
…eCalculator with actual exports calculateEfficiencyScore, scoreToGrade, scoreToLabel Addresses review concern on PR #331: the barrel index.ts re-exported EfficiencyScoreCalculator which was never exported from the source module. Replaced with the three actual function exports. TypeScript typecheck passes clean, all 23 tests pass.
Summary
Adds a Legislative Efficiency Score (
calculateEfficiencyScore) to the Adamastor transparency platform.The metric distinguishes parliamentary activity (proposals submitted, interventions made, questions asked, attendance) from output (vote participation, session attendance) and assigns a qualitative Portuguese-language grade, providing deeper assessment beyond raw activity counts.
Changes
apps/web/src/services/metrics/EfficiencyScoreCalculator.ts— Core calculator with types (ActivityMetrics,OutputMetrics,EfficiencyScore,EfficiencyGrade), exported weight constants, and helper functions (calculateEfficiencyScore,scoreToGrade,scoreToLabel).apps/web/src/services/metrics/EfficiencyScoreCalculator.test.ts— 23 unit tests covering normal ranges, edge cases (zero, max, missing data), division-by-zero safety, NaN safety, weight validation, grade classification, label classification, and activity-vs-output distinction.Design Decisions
noStaticOnlyClass.as constfor downstream reuse.