fix(36): compile token scope catalog once in pier boot coverage warning

This commit is contained in:
Jakub Zych
2026-11-25 01:29:28 +01:00
parent 0b90f757bc
commit 51b60b94b8
4 changed files with 109 additions and 22 deletions

View File

@@ -17,6 +17,7 @@ func warnUncoveredBackendWriteTools(app *backpack.App, plugins []party.Plugin, c
if cat == nil || len(cat.tools) == 0 {
return
}
var matcher *cabana.TokenScopeMatcher
byPlugin := map[string][]string{}
var pluginOrder []string
for _, t := range cat.tools {
@@ -26,7 +27,18 @@ func warnUncoveredBackendWriteTools(app *backpack.App, plugins []party.Plugin, c
if t.method == http.MethodGet || t.method == http.MethodHead {
continue
}
if cabana.TokenScopeCovers(app, plugins, t.method, t.decl.Permissions) {
if matcher == nil {
var err error
matcher, err = cabana.NewTokenScopeMatcher(app, plugins)
if err != nil {
logger().Warn(
"pier: could not compile token scope catalog while checking backend write MCP tool coverage",
"err", err,
)
return
}
}
if matcher.Covers(t.method, t.decl.Permissions) {
continue
}
if _, seen := byPlugin[t.pluginID]; !seen {