The /admin/guard page, a Guardrails link, and the policies in force on the profile page

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 15:15:38 +02:00
1 parent 7e18b8ab53
commit 02aac84ca5
11 files changed
+305 -3

No files matched your search

+11
View File
@@ -180,6 +180,17 @@ func (r *Router) Handler() http.Handler {
pages.SetPersonalOff(r.personalOff)
pages.SetLlamaCppVersion(r.llamaVersion)
pages.SetPersonalDefaults(r.personalDefaults)
if pol, ok := r.guard.(interface {
Policy(guard.Subject) (guard.Policy, string)
}); ok {
pages.SetGuardPolicies(func(s guard.Subject) (string, bool) {
p, names := pol.Policy(s)
return names, p.NoStore && p.Mode == "enforce"
})
}
if r.store != nil && len(r.guardLibrary.Policies) > 0 {
pages.RegisterAdminGuard(mux, r.store, r.guardLibrary)
}
pages.Register(mux)
r.registerChat(mux, pages)
// An organization's own page, for the people who manage it.
+7 -2
View File
@@ -89,8 +89,10 @@ type Router struct {
// isLeader says whether this process leads; nil is always.
isLeader atomic.Pointer[func() bool]
acct *accounting.Accountant
// guard judges requests and answers; nil judges nothing.
guard guard.Guard
// guard judges requests and answers; nil judges nothing. guardLibrary
// is the policies it was built from, for the pages that show them.
guard guard.Guard
guardLibrary guard.Config
// threads holds conversations and memory notes. It is store when auth is on,
// its own file when only the threads block is configured, and nil when
@@ -156,6 +158,9 @@ func (r *Router) SetMirror(m web.MirrorAdmin) { r.mirror = m }
// SetGuard has every request and answer judged by g.
func (r *Router) SetGuard(g guard.Guard) { r.guard = g }
// SetGuardLibrary is the policies the guard was built from, for the pages.
func (r *Router) SetGuardLibrary(c guard.Config) { r.guardLibrary = c }
// SetRegistry gives the mirror page somewhere to look models up.
func (r *Router) SetRegistry(reg web.Registry) { r.registry = reg }