✨ feat(guard): one shared Guard judges any repository's pull request from a niyam release
Slice: #469
A client's pull request today runs its own copy of the checks that judge it, and only niyam has a Guard (#468). This adds one Guard, shipped from niyam as checks.yml is, that any repository calls. Nothing calls it yet: the client's caller is #470, the owner-step is #471, and niyam moves onto it in #472. guard.yml keeps judging niyam's pull requests from main, this one included.
What changes
.github/workflows/shared-guard.yml(workflow_call, no inputs, no secrets): one job,judge. It checks outjob.workflow_repositoryatjob.workflow_sha, sparse toscripts/guard.mjsand what installsyaml, withpersist-credentials: false, and refuses when GitHub gives nojob.workflow_sha. It checks out nothing of the caller's; it reads the pull request through the API with the caller's token. Read-only permissions, a timeout, and a concurrency group of its own (niyam-guard-<number>).scripts/guard.mjs:- refuses any event but
pull_request_target; - reads owners and the repository's own
"guard"paths from the default branch's.github/niyam.jsonthrough the API; missing, unparsed or no owner refuses; - a fixed floor of guard files:
.github/,.githooks/,.husky/,lefthook.yml,package.json's scripts, the dvara, gitleaks and trufflehog settings; - the onboard exemption's tag is checked on
veda-hq/niyam'smain; - refuses any job that could report
niyam-guard / judgeunless its workflow runs onpull_request_targetalone and the job only callsveda-hq/niyam/.github/workflows/shared-guard.yml@<ref>, with no steps.
- refuses any event but
.github/niyam.jsongains"guard": ["scripts/*.mjs"], which moved out of the floor, so niyam guards the same files before and after..github/CODEOWNERSnames Alok forshared-guard.yml;.github/actionlint.yamlknowsjob.workflow_sha/job.workflow_repositorythere.- README's Guard section and a
docs/decisions.mdrecord (2026-11-19, P-74) say so, with the rejected alternatives.
Evidence
pnpm checkpasses on the branch rebased ontomain(db534a2): 2084 CLI tests and 95 script tests, 0 failures;guard.mjs100% lines, 96.17% branches.- New script tests cover the floor and own paths,
guardPathsIn,workflowOf,isCaller, the caller shape (an added caller and a release move pass; an addedpull_requesttrigger, own steps, a localuses:and a job namedniyam-guard / judgeare refused), settings read from the default branch, the onboard tag on niyam, and the event refusal with no API calls. - The sparse checkout installs: a sparse clone of this branch with exactly those six paths ran
pnpm install --frozen-lockfile --ignore-scripts("Lockfile is up to date", 156 packages) and resolvesyaml. actionlintpasses onshared-guard.yml.
Still to show: #469 asks this pull request to show how GitHub judges a required check with one failing and one passing run of the same name. That test needs a release and a caller (#470), so it runs on an unmerged test pull request once one exists; the result goes on #469.
Guard files: all named in #469's Guards:. CODEOWNERS holds this for Alok's review.
🤖 Generated with Claude Code
Summary by cubic
Adds one shared Guard, shipped from niyam as checks.yml is, that any repository calls to judge its own pull requests instead of running its own copy.
- Adds
.github/workflows/shared-guard.yml, a reusable workflow that runsscripts/guard.mjsfrom niyam atjob.workflow_shaand reads the pull request through the API with the caller's token, never checking out the caller's code. scripts/guard.mjsnow refuses any event butpull_request_target, reads the owners and the repository's own guard paths from the default branch's.github/niyam.json(failing closed when GitHub names no default branch), checks the onboard release tag onveda-hq/niyam, and refuses any job that could reportniyam-guard / judgeunless it runs onpull_request_targetalone and only callsshared-guard.ymlat a release tag or full commit sha.- Moves niyam's own
scripts/*.mjsfrom the fixed floor into niyam's settings, so niyam guards the same files. - Nothing calls the shared Guard yet; the caller, owner step, and niyam's own adoption land in follow-up work.