Skip to content

feat(scoring): gate PR scoring by PAT first-registration date - #1001

Closed
HadesHappy wants to merge 4 commits into
entrius:testfrom
HadesHappy:feat/registration-scoring-window
Closed

feat(scoring): gate PR scoring by PAT first-registration date#1001
HadesHappy wants to merge 4 commits into
entrius:testfrom
HadesHappy:feat/registration-scoring-window

Conversation

@HadesHappy

Copy link
Copy Markdown
Contributor

Summary

Closes #1000

Skip merged/closed PRs that predate a miner's first PAT registration on this validator (minus a 7-day grace window). Closes the aged-account-purchase vector - registering a GitHub account that already has merged PRs to whitelisted repos no longer earns emissions for that pre-existing work.

Changes

  • pat_storage: stamp first_registered_at on first save; preserve it across re-broadcasts of the same hotkey; reset it on hotkey change. Legacy entries that lack the field stay grandfathered (no gate). New get_registration_cutoff(uid, hotkey) helper.
  • github_api_tools (legacy path): should_skip_merged_pr and try_add_open_or_closed_pr accept registration_cutoff and skip when merged_at / closed_at falls before it.
  • mirror/load.py (mirror path): same gate at load time on both merged_at and closed_at.
  • reward.py: looks up the cutoff per UID and threads it into both load paths.
  • constants: REGISTRATION_GRACE_DAYS = 7.

Migration

Existing PAT entries without first_registered_at are grandfathered - the gate stays disabled for them indefinitely, even on re-broadcast. No score regressions for current miners.

Test plan

  • pytest - 748 passed
  • ruff check + ruff format --check - clean
  • pyright on touched files - 0 errors
  • New tests cover: before / at / after cutoff (merged + closed), open PRs unaffected, legacy grandfather, hotkey-change reset, malformed ISO, smoke test for first-broadcast stamping

@xiao-xiao-mao xiao-xiao-mao Bot added the enhancement New feature or request label May 5, 2026
@HadesHappy

Copy link
Copy Markdown
Contributor Author

Hi @anderdc
Could you please take a look at this PR at your convenience? ❤️

@anderdc

anderdc commented May 8, 2026

Copy link
Copy Markdown
Collaborator

Closing alongside #1000 — see the issue thread.

@anderdc anderdc closed this May 8, 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.

[Security]

2 participants