Skip to content

fix(registry): spend less GitHub quota on the sync and page views - #494

Merged
harlan-zw merged 2 commits into
mainfrom
fix/github-quota-registry
Oct 6, 2026
Merged

harlan-zw merged 2 commits into
mainfrom
fix/github-quota-registry

Conversation

@harlan-zw

Copy link
Copy Markdown
Collaborator

🔗 Linked issue

Related to #484

❓ Type of change

  • 📖 Documentation
  • 🐞 Bug fix
  • 👌 Enhancement
  • ✨ New feature
  • 🧹 Chore
  • ⚠️ Breaking change

📚 Description

GITHUB_TOKEN is a personal token, and GitHub counts its quota per account. The registry shares that bucket with every other tool on the account, so each read it skips leaves room for skilld run and CI. Production logs and D1 for the 24 hours to 2026-10-06 15:00 UTC showed where the registry spent reads it did not need:

  • Hourly sync. Each candidate got a queue job whose first act was one GraphQL summary. 1,649 of 1,900 sync jobs wrote no Skill row. The task now reads summaries in aliased GraphQL queries of 100 repositories, and records an unchanged repository with the same statements syncRepo runs. Only the rest get a job. Discovery claims, repositories a job still holds, Skill-less repositories and anything GitHub gave no summary for keep their job. If the batch fails, every candidate is queued as before.
  • Tree reads by SHA. syncRepo and the asset refresh now read the tree at the summary's head tree SHA instead of the branch name. The tree matches the summary, and a repeat read answers 304 from the ETag cache.
  • /api/repos/:owner/:repo. About 630 views asked GitHub for a repository it could not find, and nothing remembered the answer. A 404 is now cached at the edge for an hour. A registry repository is scanned at its synced tree SHA, and the scan is cached by that SHA. A private repository now answers 404: the token can read private repositories, and this page is public. When GitHub refuses with 403, 429, 5xx or a timeout, the page reads its metadata from ungh.cc, without the Skill file list. ungh.cc never serves build content or trees.
  • Owner and commit reads. /api/orgs/:owner, /api/skills/featured and /api/skill-related called GitHub with no Authorization header. They shared the Worker IP's anonymous allowance, and about 330 commit reads failed. They now go through the ETag client with the token. This adds a request to GITHUB_TOKEN the first time each owner or commit list is read; a repeat read answers 304 for free, and both stay behind their existing D1 and edge caches.
  • Pause reasons. Rate limit headers now record their bucket, so a sync pause reads nuxt/ui: 163 graphql requests remaining instead of leaving the bucket unnamed. The 200 request reserve is now a named constant with its sizing.

Architecture after this change: the hourly task prefetches summaries before it queues jobs, and the repository page caches 404s and tree scans and falls back to ungh.cc

🤖 AI disclosure: Harlan Agent Kit modified this description. My AI open-source policy.

GITHUB_TOKEN is a personal token, so the registry shares its hourly quota
with every other tool on that account. Measured 2026-10-06: about 1,650 of
1,900 daily sync jobs only advanced the freshness cursor, about 630 /gh
views a day re-asked GitHub for a repository it had already said was
missing, and the owner and commit reads went out anonymous and failed.

The hourly task now reads candidate summaries in GraphQL batches of 100
and records unchanged repositories in place. Sync and page tree reads go
by tree SHA. The repository page caches 404s and tree scans at the edge,
answers 404 for a private repository, and falls back to ungh.cc metadata
when GitHub refuses. Owner and commit reads authenticate through the ETag
client, so a repeat read answers 304 for free. Sync pauses name the bucket.
@harlan-zw harlan-zw added the harlan-agent-review Pull request triage requires an adversarial Review. Adding this label manually always forces one. label Oct 6, 2026
@harlan-zw

Copy link
Copy Markdown
Collaborator Author

Agent check, outside CI:

  • An authorized conditional read of GET /repos/vercel-labs/agent-skills/git/trees/main answered 304 twice and left x-ratelimit-used at 12; the next unconditional read moved it to 13. So the owner, commit and tree reads this PR routes through the ETag client cost nothing when unchanged.
  • https://ungh.cc/repos/vercel-labs/agent-skills answered the shape readUnghRepoMeta parses; a missing repository answered 404.

@harlan-github-agent harlan-github-agent Bot added harlan-agent-review-required Pull request triage requires an adversarial Review for this head commit. harlan-agent-running An Agent holds a Task on this issue or pull request right now. and removed harlan-agent-review Pull request triage requires an adversarial Review. Adding this label manually always forces one. labels Oct 6, 2026
@harlan-github-agent

harlan-github-agent Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

🤖 MERGED

Harlan Agent Kit posted this automated review. It is not Harlan's personal review or approval. AI open source policy. Last updated: 2026-10-06 16:37 UTC.

GitHub merged this pull request.

  • Logged (27/100): The new 404 negative cache has no invalidation path, so a newly submitted or newly public repository can serve a wrong 404 for up to an hour after it is indexed. View code
    • Ask an agent to verify and fix this finding

975035bd-b2f9-448d-91a2-4e08566a1fb7

Selected findings run after merge and open separate pull requests.

@harlan-github-agent harlan-github-agent Bot added harlan-agent-running An Agent holds a Task on this issue or pull request right now. harlan-agent-ready The automated Review passed every gate on this head commit. and removed harlan-agent-running An Agent holds a Task on this issue or pull request right now. harlan-agent-review-required Pull request triage requires an adversarial Review for this head commit. labels Oct 6, 2026

@harlan-github-agent harlan-github-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Harlan Agent Kit posted this automated review. AI open source policy.

Automated Review: READY.

Read the Review results

@harlan-zw
harlan-zw merged commit a495b6f into main Oct 6, 2026
7 checks passed
@harlan-github-agent harlan-github-agent Bot removed the harlan-agent-ready The automated Review passed every gate on this head commit. label Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant