š fix(board): board-audit reads as the agent from the keychain when GH_TOKEN is unset (#548)
With no GH_TOKEN, as in the owner's terminal, niyam board-audit now reads the board with the agent's token. niyam machine keeps that token in this Mac's keychain. Its error no longer tells the owner to run GH_TOKEN="$(gh auth token)" niyam board-audit, which needs the gh sign-in machine removes.
Why. On 2026-11-22 Alok ran niyam board-audit athya-hq/athya-rules in his terminal, right after niyam machine had signed him out of gh, as doctor asks. It refused:
niyam board-audit: board-audit needs GH_TOKEN, with read access to the Project: run it in an agent session, or GH_TOKEN="$(gh auth token)" niyam board-audit
The audit only reads. The agent's classic token has project and read:org (README, niyam machine), so it can read the board. This is a fix under #408, which made board-audit, so the slice's approval carries it.
Shape. auditToken in src/board-audit.ts:
GH_TOKENcomes first, where it is set, as in an agent session.- Otherwise it reads the agent's token from this Mac's keychain (
readToken). The agent is:- in a clone, the one its settings name that sessions here work as (
agentHere); - outside a clone, the one
machineset up on this Mac (agentsSetUp).
- in a clone, the one its settings name that sessions here work as (
- No stored token, none set up, or several and none named: it says so, names
niyam machine, and reads nothing. Never a guess. - Rejected: the owner's one-time browser sign-in, as
owner-stepuses. It costs a device code for a read the agent can do.
README ("Checking the board") and a Record in docs/decisions.md say so.
Tests (src/board-audit.test.ts; the old "needs GH_TOKEN" case is replaced):
- With no
GH_TOKEN, in the clone: every request carries the agent's keychain token. - With no
GH_TOKEN, outside a clone, with one agent set up: the same. - Each of these reads nothing and never runs
gh, and its error namesniyam machine:- no stored token;
- no agent set up;
- two agents set up and none named;
- in a clone whose settings name two agents, with neither set up.
- In a clone whose settings name two agents, with one set up: it reads as that one.
- The help line (
src/run.ts) says the same.
Evidence:
pnpm exec node --test src/board-audit.test.ts: 15 pass, 0 fail.pnpm check: exit 0.- 2132 pass, 0 fail; coverage 99.57% lines, 97.26% branches.
src/board-audit.tshas 100% lines and 99.28% branches. test:scripts: 133 pass, 0 fail.- Typecheck, lint, pins, pariksha, sarathi, build and smoke all passed.
- 2132 pass, 0 fail; coverage 99.57% lines, 97.26% branches.
- Not run against GitHub from a real terminal: this session's hook allows only
niyam review-thread. The tests use the fake keychain. The proof is the owner's firstniyam board-audit athya-hq/athya-rulesafter upgrading.
After merge: a release. Then the owner runs niyam board-audit athya-hq/athya-rules in their own terminal, with no gh sign-in.
š¤ Generated with Claude Code
Summary by cubic
niyam board-audit now reads the board with the agent's keychain token when GH_TOKEN is unset, so it works in the owner's terminal after niyam machine signs them out of gh. Previously it failed and told the owner to run GH_TOKEN="$(gh auth token)" niyam board-audit, which needs that sign-in back.
GH_TOKENstill takes priority when set, but a locked session's placeholder counts as no token: it reads nothing, never the keychain's instead, and says to runniyam doctor.- Without
GH_TOKEN, the agent is resolved from the clone's settings, or the single agentmachineset up on the Mac; the keychain is read under the login asmachinespelled it. - On a platform with no token store, it says
GH_TOKENis needed there instead of namingniyam machine. - With no token, no agent set up, or several agents and none named, it says so, names the fix, and reads nothing. It never falls back to the owner's one-time browser sign-in.
- README,
docs/decisions.md, and theniyam board-audithelp line document the new behavior.