✨ feat(sarathi): asks name GitHub issues and comments by full URL; agents delete their own branches (#397)

Merged
AT
8d ago
+378-19

Slice: #397

Under work item #43.

Alok asked on 2026-11-22 that two corrections be enforced in code, not only kept as agent memory.

Rule B: links in asks. sarathi's ask-gate.sh now refuses an ask of the owner that names a GitHub issue, pull request or comment by number alone, and says how to fix it: give the full https://github.com/... URL.

  • A bare reference is #N, owner/repo#N, or PR, pull request, issue or comment followed by a number. It is read with the URLs taken out. A github.com URL in the same ask that carries the same number covers it (/issues/N, /pull/N, #issuecomment-N, #discussion_rN …), with the number ending where its digits do.
  • PreToolUse (AskUserQuestion, and a wrap_up with an ask, buttons included): exit 2 with BLOCKED: give the full link.. This runs before every other pass: a go-ahead, research, a look, a declared Kind: approval. A repeat is refused too, since the fix is always to hand. A URL in the wrap_up recap covers, because the ask holds 100 characters.
  • Stop: asking sentences are read with fenced code, quoted lines, inline code and quoted text left out. A line that opens Needs you: or ends on a question is read whole. The turn goes on once (additionalContext starting give the full link.), before the "file the ask" nudge and the research hold, which that continuation skips. A URL anywhere in the message covers.
  • Acceptance, pinned in ask-gate.test.ts:
  • Each refusal is a line in the ask log, outcome: "held: bare reference", with refs.
  • Old fixtures changed on purpose. A few research-hold fixtures used bare ids inside asks (PR #12 failed CI. Retry it or revert?, Close #12 or keep it?, Needs you: add the approved label to #289.). The new check now refuses those by design, so they say "The PR" or carry the URL. What each one tests (state naming, the nudge) is unchanged.

Rule A: agents delete their own branches.

  • kavach: no rule refuses git push origin --delete <branch>. git_safety.py's push refuses --force, --force-with-lease, --mirror and their abbreviations, -f, and + refspecs; --delete and -d are none of these. New rows in command_guard_cases.py:
    • allowed: --delete, -d, :branch, and two branches;
    • still refused: --force … --delete, -fd, a delete beside +main, and --mirror --delete.
    • kavach's behaviour does not change; this is tests only.
  • CLAUDE.md Guards: "any push that rewrites or deletes history" now names what kavach refuses. It says deleting a branch rewrites no history, and that agents delete their own superseded or closed PR branches themselves and never ask Alok to.
  • ask-gate.test.ts's yes/no fixture is now "Publish v1.0.0?" in place of "Delete the branch?", and so is the README's example.
  • New lesson in docs/lessons/git-github.md, "Delete your own old branches". On https://github.com/veda-hq/veda/pull/383, an old branch kept for the owner to delete held a secret-shaped token and failed every PR's Secret scans check.

When it takes effect. The gate guards sessions only after these steps:

  1. A sarathi release carrying this change.
  2. A pin bump of @veda-hq/sarathi in veda, niyam and athya_mono.
  3. pnpm install in each main checkout (veda, niyam, athya_mono). This last step is Alok's.

kavach already allows the branch delete, so Rule A needs no release; only its wording and tests change here.

Out of scope: niyam's Guard and refusal texts, and athya-rules' process text, change in their own repositories (separate sessions).

Tests: pnpm --filter @veda-hq/sarathi run check (53 ask-gate tests, coverage and smoke) and pnpm --filter kavach test:python pass locally. So do pnpm guards and eslint on the test file.

šŸ¤– Generated with Claude Code


Summary by cubic

sarathi's ask gate now refuses any ask that names a GitHub issue, pull request, or comment by number alone (#376, PR 382, comment 7068450411, #issuecomment-N) and requires the full https://github.com/... URL instead. It also documents that agents delete their own superseded or closed PR branches; kavach already allowed branch deletion, so only tests and docs change there.

Ask gate

  • AskUserQuestion and wrap_up asks with a bare reference are refused with BLOCKED: give the full link. before every other check, including repeats.
  • A closing Stop message that asks with a bare reference goes on once with instructions to rewrite it; a sentence opening check or open counts as asking.
  • Only a github.com owner/repository route URL carrying the same number covers a reference; search and query URLs cover nothing.
  • Refusals are logged as held: bare reference with the references; old fixtures that used bare ids now carry URLs or say "the PR", and what each tests is unchanged.
  • The gate takes effect after a sarathi release, a pin bump of @veda-hq/sarathi in veda, niyam and athya_mono, and pnpm install in each main checkout.

Branch deletion

  • kavach's guard tests pin git push origin --delete <branch>, -d, and :branch as allowed; --force, -fd, + refspecs, and --mirror deletions stay refused.
  • CLAUDE.md, README.md, and the git lessons now say agents delete their own superseded or closed branches and never ask the owner to.
  • The "Delete the branch?" yes/no fixture and README example became "Publish v1.0.0?".