Skip to content

feat: per-repo label multipliers with fnmatch wildcard support (closes #1016) - #1021

Closed
wdeveloper16 wants to merge 5 commits into
entrius:testfrom
wdeveloper16:fix/per-repo-label-multipliers
Closed

feat: per-repo label multipliers with fnmatch wildcard support (closes #1016)#1021
wdeveloper16 wants to merge 5 commits into
entrius:testfrom
wdeveloper16:fix/per-repo-label-multipliers

Conversation

@wdeveloper16

@wdeveloper16 wdeveloper16 commented May 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #1016.

Moves label-multiplier scoring from a single global table to per-repository configuration in RepositoryConfig. Each repo can now define its own label patterns (with fnmatch wildcard support) and a default multiplier, allowing custom label taxonomies like kind/feature, type:bug-fix, or release-prefixed labels such as 3.0/feature.

Changes

Core

  • Remove global LABEL_MULTIPLIERS from constants.py
  • Add label_multipliers: Optional[Dict[str, float]] and default_label_multiplier: float = 1.0 to RepositoryConfig
  • Add resolve_label_multiplier(label, repo_config) helper using fnmatch for wildcard pattern matching
  • JSON loading validates multiplier values in [0.0, 20.0] and enforces a max of 10 entries per repo, logging warnings and skipping invalid entries

Legacy scoring path

  • PullRequest now stores current_labels: frozenset (all currently-applied labels, set at construction)
  • New _resolve_label() in scoring.py: tries the last timeline-applied label first, falls back to the highest-multiplier fnmatch match across all current labels, then defaults to default_label_multiplier

Mirror scoring path

  • _resolve_trusted_scoring_label and _calculate_pr_multipliers use per-repo fnmatch instead of the global table

Example config

"entrius/gittensor": {
  "weight": 1.0,
  "label_multipliers": {
    "kind/feature": 1.5,
    "type/*": 1.1,
    "*-dev": 0.5
  },
  "default_label_multiplier": 1.0
}

Tests

  • All 17 original label-extraction test cases preserved, now driven through a per-repo config fixture that mirrors the old global table
  • New parameterized tests for resolve_label_multiplier: exact matches, prefix/suffix/middle wildcards (kind/*, type:*, *-dev), case insensitivity, release-prefixed labels
  • New tests for _resolve_label fallback logic: timeline candidate wins if it matches, falls back to highest-multiplier match from current labels, returns default multiplier when nothing matches
  • Constraint enforcement tests via load_master_repo_weights: rejects dicts with >10 entries, skips individual entries outside [0.0, 20.0], resets out-of-range default_label_multiplier to 1.0, accepts valid configs end-to-end
  • End-to-end wildcard matching tests: kind/*, type:*, *-dev, 3.0/*, multi-pattern with last-applied-wins semantics, no-match fallback to default
  • Mirror label-resolution tests updated to use explicit label_multipliers on the config fixture instead of the removed global table

@xiao-xiao-mao xiao-xiao-mao Bot added the enhancement New feature or request label May 5, 2026
@wdeveloper16
wdeveloper16 force-pushed the fix/per-repo-label-multipliers branch 2 times, most recently from b970c26 to 18e5ce7 Compare May 5, 2026 23:17
@wdeveloper16

Copy link
Copy Markdown
Contributor Author

Hi, @anderdc
Ready to review.
I'd appreciate your feedback with this.
Thanks.

@wdeveloper16
wdeveloper16 force-pushed the fix/per-repo-label-multipliers branch from 18e5ce7 to e081ad1 Compare May 6, 2026 01:55
@wdeveloper16

Copy link
Copy Markdown
Contributor Author

Ready to review.

@anderdc

anderdc commented May 6, 2026

Copy link
Copy Markdown
Collaborator

Duplicate of #1027 which is better scoped/implemented. Closing.

@anderdc anderdc closed this May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move label-multiplier scoring to RepositoryConfig (per-repo dict + default, no global table)

2 participants