Skip to content

feat(reconciler): auto-deregister repos delisted from gittensor master list #137

@plind-junior

Description

@plind-junior

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfeature

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions