✨ feat(guard): Guard takes the owner's batch answer on the Approvals issue (#501)

Merged
AT
11d ago
+198-24

Slice: #501

The shared Guard now takes the owner's batch answer on the Approvals issue, as the work rules do. Alok, 2026-11-20: "file the slice to make Guard read the Approvals issue", then Decision: #501 as written on #501.

Why. On athya_mono, Decision: approve #3789 on Approvals issue #3376 passed the work rules, but Guard failed on #3806 until Alok repeated the Decision on #3789 itself.

What changes, in scripts/guard.mjs:

  • approvalsIn reads "approvals": N from the default branch's .github/niyam.json. Anything but an issue number fails closed, as src/agent.ts refuses it.
  • approvedIn reads a batch answer's first line with the patterns src/approvals.ts uses. A test holds the two to the same patterns.
  • approvedAt, for a slice added after its Work item's approval, also reads the Approvals issue's comments. It counts an owner's comment that is unedited, made after the slice joined, and whose first line approves the slice.
  • The earliest answer across the slice, its Work item and the Approvals issue sets when Guards: counts from.
  • A 404 on the Approvals issue counts nothing. Any other failure fails closed, so a lost read cannot let a later Decision pin a newer Guards:.
  • Guard reads the Approvals issue only for a slice that joined after the approval, and only when the settings name one.

The README (work rules and Guard) and docs/decisions.md say so.

Checked:

  • pnpm check passes (output below).
  • New tests cover a batch answer naming the slice, and one that does not count because it:
    • names another issue only;
    • names the slice on a later line only;
    • names it as o/r#10 or #10;
    • was edited;
    • is older than the slice joining;
    • is another login's.
  • Further tests: the earliest of the three places wins; a missing Approvals issue; a 502 fails closed; settings without approvals read nothing; a slice that joined before the approval reads nothing; main wiring, including a bad approvals value.
pnpm check: exit 0
pnpm test:          tests 2117, pass 2117, fail 0
pnpm test:scripts:  tests 103,  pass 103,  fail 0
  guard.mjs  | line 100.00 | branch 96.45 | funcs 100.00

After merge: clients get it with the next release, on their next niyam onboard. niyam's own Guard also runs from its last release, so this PR is judged by 0.7.6's Guard.

Guards: scripts/guard.mjs, scripts/guard.test.mjs. scripts/guard.mjs is code-owned by Alok, so this waits for his review.

🤖 Generated with Claude Code


Summary by cubic

The shared Guard now accepts the owner's batch answer on the Approvals issue, matching what the work rules already do. Previously, a Decision: approve #slice on the Approvals issue passed the work rules but Guard still refused the slice until the owner repeated the Decision on the slice itself.

  • Reads "approvals": N from .github/niyam.json; any other value fails closed.
  • Counts an owner's unedited comment on the Approvals issue, made after the slice joined, whose first line approves the slice.
  • The earliest answer across the slice, its Work item, and the Approvals issue sets when Guards: counts from.
  • A 404 on the Approvals issue counts nothing; any other read failure fails closed.
  • Guard reads the Approvals issue only for a slice added after approval, and only when the settings name one.