Summary
Add a background reconciler that periodically fetches the canonical gittensor
repo list and automatically sets registered = false for any repo that has
been removed from it.
Motivation
Currently, registered is only flipped to false when the GitHub App is
uninstalled via the installation webhook. If a repo is delisted from
gittensor but the bot stays installed, registered remains true and the
mirror continues persisting webhook events indefinitely — accumulating scoring
data for a repo that is no longer part of the subnet.
The repos table schema already calls this out — registered defaults to
false with a comment: "Manually flipped today; a future reconciler will sync
from on-chain registration."
Proposed Solution
Fetch the canonical repo list from
master_repositories.json
every 2 hours. Any repo in the DB with registered = true whose key is absent
from that file gets flipped to registered = false.
Key design decisions:
- Fail-safe on fetch error — if the HTTP request fails or returns non-200,
the reconciler logs and exits without touching the DB. A network hiccup will
never mass-deregister repos.
installationId is preserved — delisting ≠ uninstalling the bot. If a
repo is re-listed, the admin can re-register via the existing
POST /api/v1/admin/repos/register endpoint without a GitHub App reinstall.
- BullMQ repeatable job — runs on the existing
github-fetch queue with
cron 0 */2 * * *. BullMQ deduplicates by repeat key so app restarts don't
pile up duplicate schedules.
- No new dependencies — uses the existing BullMQ queue, TypeORM, and plain
fetch.
Summary
Add a background reconciler that periodically fetches the canonical gittensor
repo list and automatically sets
registered = falsefor any repo that hasbeen removed from it.
Motivation
Currently,
registeredis only flipped tofalsewhen the GitHub App isuninstalled via the
installationwebhook. If a repo is delisted fromgittensor but the bot stays installed,
registeredremainstrueand themirror continues persisting webhook events indefinitely — accumulating scoring
data for a repo that is no longer part of the subnet.
The
repostable schema already calls this out —registereddefaults tofalsewith a comment: "Manually flipped today; a future reconciler will syncfrom on-chain registration."
Proposed Solution
Fetch the canonical repo list from
master_repositories.jsonevery 2 hours. Any repo in the DB with
registered = truewhose key is absentfrom that file gets flipped to
registered = false.Key design decisions:
the reconciler logs and exits without touching the DB. A network hiccup will
never mass-deregister repos.
installationIdis preserved — delisting ≠ uninstalling the bot. If arepo is re-listed, the admin can re-register via the existing
POST /api/v1/admin/repos/registerendpoint without a GitHub App reinstall.github-fetchqueue withcron
0 */2 * * *. BullMQ deduplicates by repeat key so app restarts don'tpile up duplicate schedules.
fetch.