✨ feat(onboard): onboard writes the shared Guard's caller, and doctor checks it
Slice: #470
Each client gets a thin caller for the shared Guard (#469): niyam onboard writes it, moves it with every other pin, and niyam doctor checks it.
What changes
src/guard-caller.ts(new), shared by onboard and doctor:guardCaller(branch, version)renders the caller;callerAt(text)reads the release and branch of a file YAML-equal to that render (comments and layout aside);callerIsOnboards(text)says a file is onboard's (that, or onboard's header);callerWanted(on)is the one condition for writing it.- The caller, for a default branch
trunkat v0.7.4:
so its check ison: pull_request_target: types: [opened, edited, synchronize, reopened] branches: ["trunk"] permissions: { contents: read, pull-requests: read, issues: read } # block form, at the top and on the job jobs: niyam-guard: name: niyam-guard uses: veda-hq/niyam/.github/workflows/shared-guard.yml@v0.7.4niyam-guard / judge. Its header names no release, so a run that moves the pin changes theuses:line alone, which Guard's onboard exemption takes as a version move. onboard:- writes it with
work-ruleson, on pull requests to the repository's default branch (from GitHub, as forniyam.yml), notmain(#470's comment); - a run again moves its pin and branch; a caller of its own edited by hand is written again; a
niyam-guard.ymlit did not write is refused before any plan, naming the file, changing nothing; - the plan shows
guard caller, and the pull request says what the file holds; - in a public repository (
private: falseorvisibility: publicfrom theGET /repos/{slug}onboard already makes), "By hand" and the pull request's "Left to do by hand" add one step: allowpull_request_targetfor the caller under Settings → Actions → Policies. A private one gets none.
- writes it with
doctor, under "This repo", in a repository withwork-ruleson and aniyam.yml: ✓ when the caller is as onboard writes it atniyam.yml's release and push branch; ✗ when missing, at another release or branch, or of another shape (fix:niyam onboard again, or rename or delete it first when onboard did not write it).ONBOARD_FILESincludes the caller, so pr-work-rules' onboard exemption covers it.- README (onboard, doctor, The shared Guard) and a
docs/decisions.mdrecord (2026-11-19).
Assumption to check: the caller is written only with work-rules on. Guard refuses any guard-file change that no approved Work item's slice names, and only work-rules repositories have Work items, so a caller elsewhere would block every .github/ change. It is one function, callerWanted, to change.
Evidence
pnpm checkpasses: 2103 CLI tests and 96 script tests, 0 failures;guard-caller.ts100% lines and branches,doctor.ts100% lines,onboard.ts99.57% lines (its uncovered lines predate this).- New tests: first write; a pin move changing only
uses:; a default branchtrunkand a branch change; rewrite after a comment edit and after hand edits (with:, sha pin, added trigger); three files onboard did not write refused with nothing changed; work-rules off writes none; public byprivate: falseorvisibility: publicgets the step, private does not; doctor's ✓ and 16 ✗ shapes, files onboard did not write, other release and branch; the rendered caller meets the Guard'sisCallerconditions.
After release: every work-rules client, niyam included, gets doctor ✗ until it runs onboard again. The first onboard pull request that adds the caller adds a guard file, which a version move does not cover, so in niyam it needs #472's slice.
🤖 Generated with Claude Code
Summary by cubic
niyam onboard now writes the shared Guard's caller, .github/workflows/niyam-guard.yml, in work-rules repositories, and niyam doctor checks it under "This repo".
- The caller runs on pull requests to the repository's default branch and calls the shared Guard at the release
niyam.ymlpins, so its check isniyam-guard / judge. - A run again moves its pin and branch; a caller onboard wrote is rewritten even if hand-edited, and a
niyam-guard.ymlonboard did not write is refused before any plan. - The caller's pin counts in the downgrade guard, in the checkout and on GitHub, so an older CLI cannot move it back.
- Public repositories get a one-time by-hand step to allow
pull_request_targetunder Settings → Actions → Policies. doctormarks the caller ✓ when it matches onboard's write, and ✗ when missing, at another release or branch, of another shape, or unreadable.
Release
- After release, every work-rules client, niyam included, shows
doctor✗ until it runsonboardagain. - In niyam, the first onboard pull request that adds the caller needs slice #472, as adding a guard file is not covered by a version move.