Files
archie/modules/judgement/chat.go
T
sam bc72655c8e feat(judgement): refuse privileged and undeclared actions in chat (#2071)
Connector actions and lookups now declare privilege change and secret access,
and an MCP server declares both per installation. Chat withholds and refuses
any tool that has either effect or declared nothing, in judgement and at
execution, so an approval cannot convert the refusal. Workflows and the
dashboard are unchanged.
2026-11-21 21:28:06 +11:00

35 lines
1.4 KiB
Go

package judgement
// ChatWorkflow is the workflow name a chat turn judges its actions under.
const ChatWorkflow = "chat"
// chatProhibitionRule names the refusal of an action chat must never perform.
// It is code rather than a Cedar policy: Policies.Put replaces the whole
// hard-rules set, so an editable policy could remove the prohibition.
const chatProhibitionRule = "chat-prohibited-effect"
// chatProhibition says why a chat turn may not run the action, or nothing when
// it may. An action is prohibited in chat when it changes privileges, accesses
// secrets, or never declared whether it does. Every other workflow is judged
// by the hard rules and guards alone.
func chatProhibition(workflow string, a Action) (reason string, prohibited bool) {
if workflow != ChatWorkflow {
return "", false
}
p := a.Effect.Privileged
switch {
case !p.Declared:
return "the action doesn't declare its effects, so chat can't run it", true
case p.PrivilegeChange:
return "the action changes privileges, which chat never does", true
case p.SecretAccess:
return "the action accesses secrets, which chat never does", true
}
return "", false
}
// chatRefusal is the decision refusing a prohibited chat action.
func chatRefusal(a Action, reason string) Decision {
return Decision{Action: a, Level: Never, RefusedBy: chatProhibitionRule, Reason: reason, Verdicts: []Verdict{}}
}