spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / sec-default / hooks / held-verdict / verdicts / holds-over.ts
GitHub Actions (publish-mods)chore: Update mods/ bf2323b · 13 days ago History
29 lines · 1.0 KBRaw
1import type { EventResult } from 'claude-code'
2
3import { isSameVerdict } from './is-same-verdict.js'
4import Ranking from './ranking'
5
6/**
7 * Whether the verdict reached past the user tier holds whole over the
8 * chain's answer: a deny, or an ask that names what stands behind it.
9 *
10 * It holds over a more permissive answer and over the same decision reworded
11 * or stripped of what it names; a stricter answer stands. A rule, a hook, a
12 * setting, a host or a ceiling counts; the mode's own ask at a dialog never.
13 *
14 * @param held what the run past the user tier settled on
15 * @param answer what the whole chain settled on
16 * @returns true when the held verdict is the one to return, as it is
17 */
18export const holdsOver = (
19 held: EventResult<'tool.check'>,
20 answer: EventResult<'tool.check'>,
21) =>
22 !Ranking.isLooser(held, answer) &&
23 !isSameVerdict(held, answer) &&
24 (held.decision === 'deny' ||
25 held.rule !== undefined ||
26 held.hook !== undefined ||
27 held.setting !== undefined ||
28 held.decider !== undefined ||
29 held.ceiling !== undefined)