Agent-Hellboy / Agent-Hellboy/mcp-runtime

feat(policy): shadow/monitor mode for MCPAccessGrants

Ouverte
#307 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Go
Étoiles
6
Forks
1
Merge moyen
11 h 33 min
PR mergées (30 j)
13

Description

## Summary

Add `mode: monitor` to `MCPAccessGrant` so operators can deploy governance rules without immediately blocking agents. The authz filter evaluates the full policy, lets the request through, but records `would_deny: true` in the audit event.

## Motivation

Right now flipping a grant from allow→deny is instant and irreversible in production — you can't safely test a new policy rule without risk of breaking agents. Every serious enforcement platform has a dry-run/shadow mode (Kuma `AllowWithShadowDeny`, Envoy RBAC `shadow_rules`, Portkey log-only guardrails).

**Pitch:** "Deploy governance on day 1 without breaking a single agent. Watch what *would* be denied, then flip to enforce."

## Implementation sketch

### Policy schema
Add `mode` field to `MCPAccessGrant`:
```go
type Grant struct {
Name string `json:"name"`
Mode string `json:"mode,omitempty"` // "enforce" (default) | "monitor"
// ...existing fields
}
```

### `filter_authz.go`
```go
if !decision.Allowed {
if grantIsMonitorMode(policy, decision.MatchedGrant) {
ex.WouldDeny = true
ex.WouldDenyReason = decision.Reason
// fall through — request is allowed
} else {
return Deny(decision.Status, decision.Reason)
}
}
```

### `exchange.go`
Add fields to `Exchange`:
```go
WouldDeny bool
WouldDenyReason string
```

### `proxy.go` — `auditPayload`
```go
if ex.WouldDeny {
payload["would_deny"] = true
payload["would_deny_reason"] = ex.WouldDenyReason
}
```

## Acceptance criteria
- [ ] `mode: monitor` grants allow all requests through
- [ ] Audit events for monitor-mode denials include `would_deny: true` and `would_deny_reason`
- [ ] `mode: enforce` (default) behaviour unchanged
- [ ] `pkg/policy.Validate` rejects unknown mode values
- [ ] Unit tests covering monitor vs enforce paths in authzFilter

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Piste de recherche

Start with the Grant definition and pkg/policy.Validate, then trace the authzFilter path in filter_authz.go through Exchange in exchange.go and auditPayload in proxy.go. Add tests for monitor and enforce behavior, confirming monitor requests pass with would_deny audit fields while enforce remains unchanged and unknown modes are rejected.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
go
Domaine
authorization
Type d'issue
Fonctionnalité
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Calme
Clarté
Clairement spécifiée
Accessibilité débutants
68/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.