✨ feat(guard): every onboarded repository gets the shared Guard, and one without work rules its refusals alone

Merged
AT
13d ago
+230-95

Slice: #485

Every onboarded repository gets the shared Guard's caller, not only work-rules ones. Alok, 2026-11-19: "Every onboarded repo should get the Guard, not just work-rules ones." This replaces #482's assumption.

What changes

  • onboard writes .github/workflows/niyam-guard.yml whatever the features, identity alone included. callerWanted is gone. A public repository gets the pull_request_target policy step whatever its features.
  • doctor checks the caller in every onboarded repository.
    • Where there is no niyam.yml to pin a release or name a branch, it checks the caller's shape alone: ✓ … calls the shared Guard at vX, as onboard writes it.
    • Settings it cannot parse no longer skip the check.
  • scripts/guard.mjs: workRulesIn(settings) reads features from the default branch's .github/niyam.json. Without work-rules, judge gets an unjudged list.

How a repository without work rules is judged (Alok chose "Refusals only"; asked in the session that built this)

  • Such a repository has no Work items, so no slice can name a change. Guard judges no slice there.
  • It logs each change a slice would have had to name: a guard file, the scripts of package.json, a test file deleted or left with fewer tests or more skipped.
  • It still refuses what no slice passes:
    • a workflow job added under the name of a check the default branch's ruleset requires;
    • a job that could report niyam-guard / judge but is not onboard's caller;
    • a pull request with more files than GitHub lists.
  • With work-rules on, or with no features listed (every feature on), it judges every change as before. A features value it cannot read refuses (fail closed).

Needs you, Alok

  • #485 is a new slice under Work item #468, filed after #468's approval. For such a slice, Guard counts its Guards: from your first unedited Decision: comment written since it joined, on #485 or on #468 naming #485 (approvedAt in scripts/guard.mjs). This pull request's change to scripts/guard.mjs passes Guard once you write one, for example Decision: #485 as written. on #485. Then edit or push the pull request so Guard runs again.
  • scripts/guard.mjs and its tests are yours in CODEOWNERS, so this pull request also waits for your review.

After release: a client onboarded at 0.7.4 without work-rules gets doctor's ✗ until onboard runs again.

Evidence

  • pnpm check passes: 2117 CLI tests and 97 script tests, 0 failures, typecheck and lint clean. Lines covered: guard.mjs 100% (96.35% branches), guard-caller.ts 100%, doctor.ts 100%.
  • New and changed tests:
    • onboard writes the caller with work rules off and with identity alone, and refuses a foreign one either way;
    • a public repository without work rules gets the policy step;
    • doctor checks the caller with work rules off, and its shape alone without niyam.yml;
    • Guard, with work rules off, passes a hooks and package.json scripts change with both logged and no slice or approval read;
    • Guard still refuses a job named after a required check;
    • Guard judges slices with work-rules listed (spaces trimmed) or no features listed, and fails closed on an unreadable features.

🤖 Generated with Claude Code


Summary by cubic

Every onboarded repository now gets the shared Guard's caller: onboard writes .github/workflows/niyam-guard.yml whatever the features, doctor checks it everywhere, and callerWanted is gone. Where no niyam.yml pins a release, doctor checks the caller's shape alone.

In a repository without work rules, Guard judges no slice and logs each change a slice would have had to name; it still refuses what no slice passes — a job added under a required check's name, a caller that is not onboard's, a pull request with more files than GitHub lists. With work-rules on, or no features listed, it judges every change as before; a features value it cannot read, or a feature name it does not know, fails closed.

Migration

  • A client onboarded at 0.7.4 without work-rules shows doctor's ✗ for the caller until onboard runs again.
  • This pull request needs #485's owner to write a Decision: comment naming #485 (for example Decision: #485 as written.), then an edit or push so Guard runs again.