πŸ› fix(sarathi): ask-gate holds a bare preference, a relabel and a repo read for an outside question, 0.7.10

Merged
AT
6d ago
+580-96

Slice: #293

ask-gate.sh closes three ways a session got a researchable question past the gate on 2026-11-19 (the owner's ask log, one niyam session). sarathi goes to 0.7.10 (package.json, src/cli.ts; since #294 the plugin manifest carries no version).

  • A bare declared kind. Kind: preference, private or ambiguity passes only after research or a look in the turn. For a question that names something outside the repository, only research counts. approval, money and irreversible still pass at once, and go-aheads are not gated, as before.
  • A relabel after a hold. The state file now keeps the turn's held questions (plain text, with their kinds) on a JSON line after the turn key. An ask that repeats a held question with only its Kind: fields added or changed is held once more (held: relabelled). The ask after it passes (passed: second ask, relabelled: true), so a turn holds at most twice. This works across the PreToolUse and Stop paths. A 0.7.8 state file (the turn alone) reads as a hold with no questions; a second line it cannot parse passes as passed: state unreadable.
  • A repo read for an outside question. A look counts question by question, and only when the question names repository state and nothing outside it (OUTSIDE: API/SDK, a dollar amount, prices, billing, credits, quotas, rate limits, credentials, Keychain, OAuth, API keys, Claude Code, claude.ai, Anthropic, OpenAI, marketplaces, Homebrew, documentation, release notes, changelogs, the latest version). On 2026-11-19 one option's description naming a file let a four-question batch about credits and API spend pass.

The log gains names_outside, plus names_state and names_outside per question, and relabelled on a second-ask pass. The README's "Research before you ask" and "The ask log", research-first and working-rules describe the new rules. The held messages keep their advice (research, then ask again with the recommendation first), and the gate stays fail-open.

Measured. Over 2,448 local transcripts, 0.7.8's reading passed 412 asks on a look; this one passes 364. Of the 48 now held, 25 name something outside the repository and 28 have a question naming no state. "cost", "docs", "endpoint", "registry", "login" and "sign in" were dropped from the word list because they mostly described the repository's own work. The script is on #293. Replaying that session's asks in order through the new gate: the 18:46 batch takes the turn's one hold, so the rest of that turn passes as the second ask, and the 19:00 and 19:01 bare-preference asks are held.

Left as it is. A turn still holds once (twice with a relabel), and approval/money pass at once, so a researchable question labelled an approval still passes. The log shows every kind.

Tests. src/hooks/ask-gate.test.ts covers each case on the PreToolUse and Stop paths, and the new outcome values and log fields. It also covers the old and corrupt state files. pnpm check passes.

πŸ€– Generated with Claude Code