š fix(guard): Guard reads a slice as of the owner's latest answer, so a š on a new proposal counts (#534)
Slice: #534
Guard now reads a slice's Guards: section as it stood at the owner's latest answer, so a š on a new proposal counts. Today the first answer counts. Proposal: https://github.com/veda-hq/niyam/issues/534#issuecomment-7078534180 (page: https://claude.ai/artifact/UnbZRKx93bMwefWRb44A5J).
Why. Slice https://github.com/veda-hq/veda/issues/376 joined Work item https://github.com/veda-hq/veda/issues/43, and Alok's š settled it at 2026-11-21T19:31:14Z. An agent then added a Guards: section, posted a new proposal (https://github.com/veda-hq/veda/issues/376#issuecomment-7068450411), and Alok š'd it at 2026-11-22T10:08:01Z. Guard on https://github.com/veda-hq/veda/pull/383 still read the body as of the first š. It passed only after Alok re-added approved on #43. athya_mono#3814 and #3845 hit the same thing. Guard's own remedy, "approve the slice again", did nothing.
What changes (scripts/guard.mjs).
approvedAtcollects the owner's answers since the later of the slice joining and the Work item's lastapprovedlabel, and takes the latest. The answers are aDecision:on the slice, aDecision:on the Work item naming it, a batch answer on Approvals, or a š on an agent'sProposal:. The.at(-1)replaces[0].- A slice already in the Work item at approval counts the label as one answer, so later answers move it too. Before, the label was all it read.
- What is unchanged: the body is still read as it stood at that answer (
bodyAt), so an agent's edit after it counts for nothing. A š on a proposal edited after the š still counts for nothing. - Every proposal's reactions are read, because an old proposal's š can be the latest. Before, they were skipped when an earlier answer existed. A failed read fails closed.
- The "does not name it" refusal now says what works. The agent posts a new
Proposal:comment on the slice, and the owner šs it or writes aDecision:there. It gives the slice's full URL.niyam proposeposts nothing for a settled slice, so the refusal does not send the agent to it. Refusals for an unapproved Work item or an unsettled slice keep a remedy that matches their problem. - The README Guard section,
docs/decisions.mdanddocs/lessons.mdsay so.
Cost, accepted on the page. Any later owner Decision: on the slice re-settles its body as it then stands, even one about something else.
Checked: pnpm check, exit 0:
pnpm test: tests 2164, pass 2164, fail 0
pnpm test:scripts: tests 134, pass 134, fail 0
guard.mjs 100.00 lines / 96.76 branches / 100.00 funcs
typecheck, lint, pins, pariksha, sarathi, build, smoke: pass
New and changed tests in scripts/guard.test.mjs:
- The veda #376 case. Proposal 1 gets a š, then a Guards edit, then proposal 2 gets a š: it passes. Before the second š it is refused, citing the first.
- An edit after the later š: a file only that edit names is refused, read as of the second š. A file the approved body names still passes.
- A proposal edited after its š: that š no longer counts.
- The latest answer wins across a
Decision:on the slice, aDecision:on the Work item, a batch answer and a š. A slice already there before the label moves on a later batch answer. - A failed reactions read fails closed even when an earlier
Decision:exists. - Each remedy's text.
When it takes effect. Guard runs on pull_request_target from the release each repository's caller pins, never from this pull request. This pull request is judged by the current Guard: the š on #534 is its first answer, so it passes. The fix reaches niyam's own pull requests after the next niyam release and niyam's onboard at it. It reaches veda, athya_mono and athya-rules after each one's onboard at that release.
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
Guard reads a slice's Guards: section as it stood at the owner's latest answer, so a š on a new proposal approves the slice again.
- For a slice already in the Work item at approval, the label counts as an answer, and any later answer moves it.
- Every proposal's reactions are read, since an old proposal's š can be the latest answer; a failed read fails closed.
- An edit to the slice after the latest answer still counts for nothing, as does a š on a proposal edited after it.
- Each refusal names its own remedy: an unapproved Work item needs the
approvedlabel, a slice with no parent needs adding under one, and an unsettled slice needs a newProposal:comment with the owner's š or a newDecision:. - Only a 404 on the slice's parent means it has no Work item; any other answer tells the agent to run Guard again once GitHub answers.
- README,
docs/decisions.md, anddocs/lessons.mddocument the new behavior, including that a later ownerDecision:on the slice re-settles its body, and that the new path needs a release.