šŸ› fix(guard): Guard reads a slice as of the owner's latest answer, so a šŸ‘ on a new proposal counts (#534)

Merged
AT
3d ago
+191-56

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).

  • approvedAt collects the owner's answers since the later of the slice joining and the Work item's last approved label, and takes the latest. The answers are a Decision: on the slice, a Decision: on the Work item naming it, a batch answer on Approvals, or a šŸ‘ on an agent's Proposal:. 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 a Decision: there. It gives the slice's full URL. niyam propose posts 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.md and docs/lessons.md say 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, a Decision: 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 approved label, a slice with no parent needs adding under one, and an unsettled slice needs a new Proposal: comment with the owner's šŸ‘ or a new Decision:.
  • 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, and docs/lessons.md document the new behavior, including that a later owner Decision: on the slice re-settles its body, and that the new path needs a release.