Refactor scoring hygiene and profile constants#178
Conversation
…ng constants - Delete dead .weight class attributes from all analyzers; scorer.WEIGHTS is the single source of truth. New tests/test_scoring_weights.py asserts weights sum to 1.0, match the composed dimension set, and introspects analyzer modules so a dead weight attr cannot be silently reintroduced. - Remove dead path_confidence parameter from build_risk_entry (accepted, never read) and its call sites. - Make STALE_THRESHOLD_DAYS, GRADE_THRESHOLDS, COMPLETENESS_TIERS overridable via reserved scoring-profile keys; ScoringProfile carries overrides alongside flat weights so existing custom_weights callers and shipped profiles are byte-identical. - Label the unscored description dimension via display_dimension() on operator-facing render surfaces; data fields keep raw dimension slugs.
|
|
||
|
|
||
| def test_analyzer_classes_do_not_declare_dead_weight_attributes() -> None: | ||
| import src.analyzers as analyzers_package |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ed31350321
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| completeness_tiers = [ | ||
| tuple(tier) for tier in profile.get("completeness_tiers", COMPLETENESS_TIERS) | ||
| ] | ||
| grade_thresholds = [ | ||
| tuple(threshold) for threshold in profile.get("grade_thresholds", GRADE_THRESHOLDS) |
There was a problem hiding this comment.
Propagate profile constants to reports
When a scoring profile includes completeness_tiers or grade_thresholds, the scorer now assigns tiers/grades from those overrides here, but the generated guidance still uses hard-coded defaults: src/report_enrichment.py keeps its own COMPLETENESS_THRESHOLDS, and src/excel_export.py::_build_score_explainer always feeds the default GRADE_THRESHOLDS/COMPLETENESS_TIERS into the workbook. Under a stricter profile, a repo can be graded/tiered one way while the Markdown briefing and Score Explainer describe a different threshold contract, which makes the derived reports misleading.
Useful? React with 👍 / 👎.
| if metadata.pushed_at: | ||
| days_since = (datetime.now(timezone.utc) - metadata.pushed_at).days | ||
| if days_since > STALE_THRESHOLD_DAYS: | ||
| if days_since > stale_threshold_days: |
There was a problem hiding this comment.
Keep stale flags aligned with profile threshold
When stale_threshold_days is overridden by a scoring profile, this condition no longer means “older than two years,” but the emitted flag remains stale-2yr on the next line. For example, a profile that sets the stale threshold to 30 days will label a 31-day-old repo as stale-2yr in JSON/workbook/report outputs, which misstates freshness in exactly the operator surfaces that consume these flags.
Useful? React with 👍 / 👎.
| from src.scoring_dimensions import ( | ||
| UNSCORED_DIMENSIONS as UNSCORED_DIMENSIONS, | ||
| display_dimension as display_dimension, | ||
| ) |
Stack 1/7. Isolates scoring-weight single sourcing and profile-driven thresholds. Merge with a merge commit to preserve ancestry for the dependent stack.