š fix(onboard): ask GitHub with the agent's token, name a rate limit (#546)
Slice: #546
niyam onboard now makes its public GitHub reads with the agent's stored token. These are the release-tag compare, account for the owner and the agent, and isOrganisation. They used to go out with no token, so they shared the 60 requests an hour that every tokenless request from the Mac's address gets. When GitHub refuses a read for its rate limit (403 or 429 with x-ratelimit-remaining: 0), the error now names the limit and its reset time instead of a bare HTTP status.
Why: on 2026-11-22 at 13:48 IST, onboard 0.7.14 in veda-hq/veda stopped with cannot tell whether veda-hq is an organisation (HTTP 403). That Mac's tokenless core limit was at remaining: 0 of 60, with reset epoch 1795337721 (08:55:21Z).
What changed:
agent.ts:rateLimited(answer, token)gives the words for a rate-limit refusal, with the reset fromx-ratelimit-reset.publicRead(sys, url, token)asks with the token. On a 401 it asks once more with no token, so an expired agent token still reaches onboard's "run niyam machine" message.accountuses both, and fails at once on a spent limit instead of waiting 7 seconds.
isOrganisation(sys, login, token)takes a token,string | undefined, as a required argument. doctor andissue-typepass the token they already hold.tagOnMain(sys, version, token?)takes an optional token, soupgradeis unchanged.- onboard picks the token for these reads before its first one. It uses the agent named, else the agent the settings name, else any agent
machineset up on the Mac. Once the run knows its agent, it switches to that agent's token. It never uses the owner's sign-in here, because the sign-in's scopes depend on the owner-type answer. - README: the compare and the token paragraph.
GitHub's behaviour: "If you exceed your primary rate limit, you will receive a 403 or 429 response" (GitHub Docs, "Rate limits for the REST API", section "Exceeding the rate limit", https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api, read 2026-11-22).
x-ratelimit-remainingis then 0, andx-ratelimit-resetis "in UTC epoch seconds".- Unauthenticated requests are tied to the originating IP address, at 60 an hour. A personal token gets 5,000 an hour.
Checked and left as they are (outside onboard, or authenticated by other means):
board-app.ts:98, the manifest conversion. Its one-time code is its credential.upgrade.ts:29, the latest-release read, andupgrade'stagOnMain.cloud-key.ts:59is in thecloud-keycommand, not in themakeCloudKeythat onboard calls.doctor.ts:74and:112, andmachine.ts:137, are not in onboard's path.
The onboard test's wrapper counts every tokenless read it refuses. It counts none in the three passing runs, so no tokenless read is left in onboard's path in the fake.
Tests:
src/owner-login.test.ts: the token is passed, a refused token is retried with none, and the rate-limit words for 403 with no token, 429 with a token, and a 403 that is not the rate limit.src/agent.test.ts:accountfails at once on a spent limit,rateLimitedhandles its edge cases, and a refused token is retried with none.src/release-tag.test.ts: the token and its 401 fallback, and the rate-limit words.src/onboard.test.ts, "onboard on a Mac with no requests left that need no token (#546)": every tokenless GitHub read answers 403 with remaining 0. The run gets past the owner-type check and opens its pull request. This holds with the owner and agent named, with settings and no agent named, and with neither (the agent set up on the Mac). With no stored token, it stops naming the rate limit and changes nothing.
Evidence: pnpm check output is in the first comment.
After merge: a release, then the owner's rerun of niyam onboard in veda-hq/veda. onboard refuses agent sessions, so the onboard test above is the agent-side proof.
š¤ Generated with Claude Code
Summary by cubic
niyam onboard's public GitHub reads (release-tag compare, account lookup, organisation check) now ask with the agent's stored token instead of going out tokenless, so they count against the token's 5,000/hour limit rather than the 60/hour shared by the Mac's address. Previously, a spent tokenless limit stopped onboard with a bare HTTP 403, as happened in veda-hq/veda on 2026-11-22.
- A 403 or 429 with
x-ratelimit-remaining: 0now names the limit and when it resets, when GitHub sends a validx-ratelimit-reset. - Reads retry with no token on a 401, and that retry gets only the time the first ask left, not a fresh timeout.
- onboard picks the token from the named agent, the settings' agent, or any agent
machineset up; a login in another case still finds its token, and the owner's sign-in is never used. isOrganisationnow takes a token as a required argument;doctorandissue-typepass theirs.upgradeand itstagOnMainread are unchanged.