Skip to content

feat(rewards): allocate emissions by repository share#1235

Merged
anderdc merged 5 commits into
entrius:testfrom
MkDev11:fix/issue-1215-emission-share
May 13, 2026
Merged

feat(rewards): allocate emissions by repository share#1235
anderdc merged 5 commits into
entrius:testfrom
MkDev11:fix/issue-1215-emission-share

Conversation

@MkDev11
Copy link
Copy Markdown
Contributor

@MkDev11 MkDev11 commented May 13, 2026

Summary

  • Convert repository allocation from a per-PR weight multiplier into bounded emission_share pool slicing at round aggregation.
  • Keep round-level allocation isolated in gittensor/validator/emission_allocation.py, with forward.py only orchestrating the validator cycle.
  • Add per-repo issue_discovery_share allocation with same-repo PR/issue spill in both directions and recycle-only slack behavior.
  • Match mixed-case live GitHub PR/issue repository names against lowercase registry keys.
  • Remove repo weighting from PR, collateral, issue-discovery scoring, multiplier breakdowns, and validator storage writes.
  • Store scored issue-discovery Issue objects on miner evaluations so allocation uses repo-local discovery evidence.
  • Migrate master_repositories.json to emission shares, fail loudly on registry invariant violations, and document the emission-share model.

Diff scope note: this PR is 29 files / +797 / -338 because it includes allocator extraction, removal of now-orphaned normalize modules, dead scoring-plumbing cleanup, README alignment, registry migration, and comprehensive regression coverage. The core allocation logic is isolated in gittensor/validator/emission_allocation.py; the rest is compatibility cleanup and tests.

Storage compatibility note: the validator no longer carries or writes repo_weight_multiplier / discovery_repo_weight_multiplier fields. Existing DB columns are intentionally left dormant so this code PR does not require a coordinated database-schema rollout; a follow-up in gittensor-db can drop the columns once validators are migrated.

Related Issues

Closes #1215

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Other (describe below)

Emission policy / reward allocation change.

Testing

  • Tests added/updated
  • Manually tested

Commands run:

./.venv/bin/pytest tests/validator/oss_contributions/mirror/test_adapters.py tests/validator/oss_contributions/mirror/test_scored_pr.py tests/validator/oss_contributions/mirror/test_scoring.py tests/validator/issue_discovery/test_scan.py tests/cli/test_miner_score.py -q
./.venv/bin/pytest tests/validator/test_blend_emission_pools.py tests/validator/test_load_weights.py tests/cli/test_miner_score.py -q
./.venv/bin/pytest -q
uv run ruff check .
uv run ruff format --check .
uv run pyright
uv run pre-commit run --all-files
git diff --check

Results:

  • Storage-field removal affected suite: 140 passed
  • Focused suite: 89 passed
  • Full suite: 753 passed
  • Ruff, format check, pyright, pre-commit, and diff whitespace checks passed

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Changes are documented (if applicable)

@xiao-xiao-mao xiao-xiao-mao Bot added the enhancement New feature or request label May 13, 2026
@MkDev11 MkDev11 changed the title Fix repo emission share allocation feat(rewards): allocate emissions by repository share May 13, 2026
@MkDev11 MkDev11 force-pushed the fix/issue-1215-emission-share branch from a0f06d5 to 4f496d7 Compare May 13, 2026 01:43
@MkDev11
Copy link
Copy Markdown
Contributor Author

MkDev11 commented May 13, 2026

@anderdc can you please review my pr and let me know your feedback?

@anderdc anderdc added feature Net-new functionality and removed enhancement New feature or request labels May 13, 2026
Copy link
Copy Markdown
Collaborator

@anderdc anderdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two blockers for #1215:

  1. Case-sens: forward.py _collect_repo_pr_scores / _collect_repo_issue_discovery_scores — use pr.repository_full_name.lower() == repo_name and issue.repository_full_name.lower() == repo_name. The loader normalizes registry keys to lowercase (load_weights.py:147) but live PR/issue data preserves GitHub case, so the current comparison silently misses any mixed-case repo.

  2. Out of scope: forward.py _collect_repo_pr_scores — drop the score = max(0.0, earned - collateral) subtraction and the matching test_open_pr_collateral_reduces_pr_side_score_in_same_repo. The spec asks for distribution by per-PR earned score; net-of-collateral is a separate scoring change.

@MkDev11
Copy link
Copy Markdown
Contributor Author

MkDev11 commented May 13, 2026

@anderdc just pushed the changes, can you please review again?

@MkDev11 MkDev11 requested a review from anderdc May 13, 2026 03:01
Copy link
Copy Markdown
Collaborator

@anderdc anderdc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Storage compat retention is the last blocker. ScoredPR.repo_weight_multiplier (classes.py:185) and Issue.discovery_repo_weight_multiplier (classes.py:153) are now write-only at neutral 1.0 — nothing reads them for scoring, the breakdown surface already drops them via _PR_SKIP, and resolve_repo_weight was deleted. Drop the dead fields in this PR so deliverable #7 ships atomically: (1) remove both fields from the dataclasses in classes.py; (2) drop repo_weight_multiplier=scored.repo_weight_multiplier, from adapters.py:119; (3) drop the repo_weight_multiplier column + DO UPDATE SET clause from BULK_UPSERT_PULL_REQUESTS and the discovery_repo_weight_multiplier column + clause from BULK_UPSERT_ISSUES in queries.py:48,74,120,145; (4) drop the param bindings at repository.py:180,277; (5) remove the tests that assert scored.repo_weight_multiplier == 1.0. The DB columns can stay dormant — a follow-up in gittensor-db drops the columns once validators are migrated. With that done the PR hits all 11 deliverables.

@MkDev11
Copy link
Copy Markdown
Contributor Author

MkDev11 commented May 13, 2026

Storage compat retention is the last blocker. ScoredPR.repo_weight_multiplier (classes.py:185) and Issue.discovery_repo_weight_multiplier (classes.py:153) are now write-only at neutral 1.0 — nothing reads them for scoring, the breakdown surface already drops them via _PR_SKIP, and resolve_repo_weight was deleted. Drop the dead fields in this PR so deliverable #7 ships atomically: (1) remove both fields from the dataclasses in classes.py; (2) drop repo_weight_multiplier=scored.repo_weight_multiplier, from adapters.py:119; (3) drop the repo_weight_multiplier column + DO UPDATE SET clause from BULK_UPSERT_PULL_REQUESTS and the discovery_repo_weight_multiplier column + clause from BULK_UPSERT_ISSUES in queries.py:48,74,120,145; (4) drop the param bindings at repository.py:180,277; (5) remove the tests that assert scored.repo_weight_multiplier == 1.0. The DB columns can stay dormant — a follow-up in gittensor-db drops the columns once validators are migrated. With that done the PR hits all 11 deliverables.

addressed the comments and pushed the update again

@MkDev11 MkDev11 requested a review from anderdc May 13, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Net-new functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Convert per-repo weight from unbounded multiplier to emission_share (bounded pool slice)

2 participants