no_store: refuse conversations, notes and models outside the cluster under a policy that keeps nothing

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-04 12:36:02 +02:00
1 parent 13e6f19301
commit ec737cffb5
9 files changed
+106 -2

No files matched your search

+7
View File
@@ -255,6 +255,13 @@ func (p *placeholders) rewrite(text string, spans []detect.Span) string {
var _ Guard = (*Gate)(nil)
// Directives are the policy in force's demands of the gateway. Not in
// shadow mode, which changes nothing.
func (g *Gate) Directives(s Subject) Directives {
p, _ := g.Policy(s)
return Directives{NoStore: p.NoStore && p.Mode == "enforce"}
}
// Input judges a request body.
func (g *Gate) Input(_ context.Context, s Subject, body []byte) (Verdict, error) {
start := g.now()
+8
View File
@@ -242,3 +242,11 @@ func TestBufferAllHoldsTheWholeAnswer(t *testing.T) {
t.Errorf("released before the end: %v", emit)
}
}
func TestNoStoreIsDemandedOnlyWhenEnforced(t *testing.T) {
enforce := gate(t, lib(map[string]Policy{"p": {NoStore: true}}, "p"))
shadow := gate(t, lib(map[string]Policy{"p": {NoStore: true, Mode: "shadow"}}, "p"))
if !enforce.Directives(Subject{}).NoStore || shadow.Directives(Subject{}).NoStore {
t.Error("no_store")
}
}
+10
View File
@@ -100,6 +100,16 @@ type Guard interface {
// Output is the filter for one attempt's answer, or nil when nothing
// watches it.
Output(ctx context.Context, s Subject) OutputFilter
// Directives are what the policy in force asks of the gateway itself,
// known before anything is stored or sent anywhere.
Directives(s Subject) Directives
}
// Directives are what a policy asks of the gateway beyond judging text.
type Directives struct {
// NoStore keeps nothing of the request: no stored conversation or
// memory note, no prefix routing, nothing sent outside the cluster.
NoStore bool
}
// OutputFilter watches one answer as it is relayed.