Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Bulk count agent fleet approvals
rcourtman0b98cded4544
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex 70fcf42e06..97024ffc6f 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -971,9 +971,10 @@ prefixes preserved — in one call. The endpoint is read-only under`AgentFindingsProvider` adapter wired in `router.go` from thepatrol service so the api package stays free of an `internal/ai`import; the parallel `AgentApprovalsProvider` adapter resolves the-canonical approval store at request time and filters by-canonical resource id and org. The agent runtime keeps both-providers wired across restarts.+canonical approval store at request time, filters full per-resource+summaries by canonical resource id and org, and exposes a separate+resource-keyed count projection for fleet reads. The agent runtime+keeps both providers wired across restarts.`/api/agent/fleet-context` is the companion triage view: one readreturns a thin per-resource rollup across every resource visible@@ -983,9 +984,10 @@ to the org — identity, operator flagspending-approval count. Same auth scope (`monitoring:read`) andsame provider wiring as the per-resource bundle; the fleet sweepwalks the registry once and reuses the in-memory findings index,-the bounded approval-store scan, and a per-resource operator-state-SQLite point lookup. Agents pick "where do I focus?" from the-fleet view and then drill into the per-resource bundle for depth.+one bounded approval-store scan grouped by canonical resource id,+and a per-resource operator-state SQLite point lookup. Agents pick+"where do I focus?" from the fleet view and then drill into the+per-resource bundle for depth.`/api/agent/capabilities` is registered in the router's`publicPaths` list so the global auth middleware does not gatediff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 1a51fdfe01..69e6fc1676 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -1582,10 +1582,10 @@ wired at startup so the api package stays free of an`internal/ai` import; the patrol service holds the canonicalfindings store and projects each `Finding` into the snapshotshape. Pending approvals come through the parallel-`AgentApprovalsProvider` adapter — the router wires a closure-that resolves `approval.GetStore()` at request time (so-multi-tenant store rebuilds stay honored), filters via-`approval.BelongsToOrg` for tenant scope, and matches+`AgentApprovalsProvider` adapter — the router wires a request-time+approval-store provider that resolves `approval.GetStore()` on+each read (so multi-tenant store rebuilds stay honored), filters+via `approval.BelongsToOrg` for tenant scope, and matches`req.CanonicalResourceID()` against the requested resource socross-resource approvals don't leak into the bundle. Activefindings, pending approvals, and recent actions are always arrays@@ -1608,11 +1608,12 @@ nil-checking; an empty registry surfaces as `resources: []`. Theendpoint walks the registry once and reuses the same per-resourceadapters as the per-resource bundle (operator-state via`unified.ResourceStore.GetResourceOperatorState`, findings via-`AgentFindingsProvider`, pending approvals via-`AgentApprovalsProvider`), so the fleet sweep is the per-resource-bundle's wiring multiplied by N — no new dependencies. Agents pick-a focus from the fleet view, then drill into the per-resource-bundle for depth.+`AgentFindingsProvider`, pending approvals via the+`AgentApprovalsProvider` bulk count projection). Fleet-context+approval counts must come from one org-scoped, resource-keyed scan+of the bounded pending-approval list, not N calls to the+per-resource approval summary helper. Agents pick a focus from the+fleet view, then drill into the per-resource bundle for depth.The TS client `frontend-modern/src/api/resourceOperatorState.ts`mirrors the canonical Go shape fromdiff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.mdindex 534ff0fa80..ea540790db 100644--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md@@ -554,14 +554,18 @@ finding volume.`/api/agent/fleet-context` is O(N) over registry size with boundedper-resource cost: one operator-state SQLite point lookup and onein-memory findings index lookup per resource, plus one bounded-pending-approvals lookup per resource against the same store-scan-ceiling that bounds the per-resource bundle. No action-audit reads-in the fleet path — the rollup is intentionally light enough to-serve the "where do I focus?" question without triggering N audit-queries. Sized for the hundreds-of-resources regime that is-canonical Pulse fleet scale; agents that need to scan tens of-thousands of resources should narrow the registry first via the-existing filtered list endpoints, not the fleet rollup.+pending-approvals scan grouped by canonical resource id before the+registry walk. Fleet context must not call the per-resource+approval-summary helper once per resource; the approval list is+bounded, but scanning it N times would make the rollup scale with+resource cardinality and pending-approval cardinality. No+action-audit reads in the fleet path — the rollup is intentionally+light enough to serve the "where do I focus?" question without+triggering N audit queries. Sized for the hundreds-of-resources+regime that is canonical Pulse fleet scale; agents that need to+scan tens of thousands of resources should narrow the registry+first via the existing filtered list endpoints, not the fleet+rollup.`/api/agent/capabilities` is unauthenticated and cacheable(`Cache-Control: public, max-age=300`); the manifest is a small,diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex 18e6245da1..6bacf2ec00 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -1009,10 +1009,14 @@ The fleet view at `/api/agent/fleet-context` introduces no newpersistence either — it walks the registry once and reads the samedurable `resource_operator_state` table per resource, the samein-memory findings store, and the same in-memory approval store.-The recovery posture is identical to the per-resource bundle: when-the unified-resources store and the approval store rehydrate on-startup, the fleet view recovers the same situated picture without-any fleet-specific rehydration step.+Fleet pending-approval counts may be grouped by canonical resource+id from one bounded approval-store scan, but that is still a+read-only projection over `approvals.json`, not a new recovery+artifact or storage/recovery freshness signal. The recovery posture+is identical to the per-resource bundle: when the unified-resources+store and the approval store rehydrate on startup, the fleet view+recovers the same situated picture without any fleet-specific+rehydration step.The agent capabilities manifest at `/api/agent/capabilities` ishand-authored static data. There is no persistence to recover —diff --git a/internal/api/agent_resource_context.go b/internal/api/agent_resource_context.goindex 51a12bf95b..75d64e9ebf 100644--- a/internal/api/agent_resource_context.go+++ b/internal/api/agent_resource_context.go@@ -3,6 +3,7 @@ package apiimport ("encoding/json""net/http"+ "reflect""strings""time"@@ -197,25 +198,32 @@ func (f agentFindingsProviderFunc) ActiveFindingsForResource(resourceID string)return f(resourceID)}-// AgentApprovalsProvider returns the still-pending approvals scoped-// to a single resource as agent-stable summaries. The implementation-// lives outside this package (the approval store is owned by the-// AIHandler); this interface keeps the bundle handler decoupled-// from the global approval store and lets tests pass a fake.+// AgentApprovalsProvider returns still-pending approvals as+// agent-stable projections. Per-resource context needs full+// summaries; fleet context needs only a resource-keyed count map so+// it can aggregate approval pressure without scanning the global+// approval list once per resource. The implementation lives outside+// this package (the approval store is owned by the AIHandler); this+// interface keeps the bundle handler decoupled from the global+// approval store and lets tests pass a fake.type AgentApprovalsProvider interface {PendingApprovalsForResource(resourceID, orgID string) []AgentResourceApprovalSummary+ PendingApprovalCountsByResource(orgID string) map[string]int}-// agentApprovalsProviderFunc is a function adapter so wire-up code-// can pass a closure without declaring a struct.-type agentApprovalsProviderFunc func(resourceID, orgID string) []AgentResourceApprovalSummary+// agentApprovalStoreProvider adapts the process-global approval+// store into the agent context provider contract. It resolves the+// store at request time so multi-tenant rebuilds that install a new+// global store via approval.SetStore are honored without re-wiring+// the router.+type agentApprovalStoreProvider struct{}-// PendingApprovalsForResource implements AgentApprovalsProvider.-func (f agentApprovalsProviderFunc) PendingApprovalsForResource(resourceID, orgID string) []AgentResourceApprovalSummary {- if f == nil {- return nil- }- return f(resourceID, orgID)+func (agentApprovalStoreProvider) PendingApprovalsForResource(resourceID, orgID string) []AgentResourceApprovalSummary {+ return pendingApprovalsForResourceFromStore(approval.GetStore(), resourceID, orgID)+}++func (agentApprovalStoreProvider) PendingApprovalCountsByResource(orgID string) map[string]int {+ return pendingApprovalCountsByResourceFromStore(approval.GetStore(), orgID)}// AgentContextHandler owns the agent-paradigm bundled context@@ -410,21 +418,9 @@ func (h *AgentContextHandler) HandleFleetContext(w http.ResponseWriter, r *http.// of fleet size — one scan suffices.pendingByResource := map[string]int{}if h.approvalsProvider != nil {- // The provider is keyed per-resource; for the fleet scan we- // take the resource-keyed projection per registry entry. This- // keeps the seam decoupled from approval-store internals at- // the cost of one extra map allocation per resource — still- // cheap, and tests can stub the provider without setting up- // a global approval store.- for _, resource := range resources {- canonical := unified.CanonicalResourceID(resource.ID)- if canonical == "" {- continue- }- pending := h.approvalsProvider.PendingApprovalsForResource(canonical, orgID)- if len(pending) > 0 {- pendingByResource[canonical] = len(pending)- }+ counts := h.approvalsProvider.PendingApprovalCountsByResource(orgID)+ if counts != nil {+ pendingByResource = counts}}@@ -545,7 +541,7 @@ func projectAgentResourceActions(// normalizes nil to []AgentResourceApprovalSummary{} so the wire// shape is always an array.func pendingApprovalsForResourceFromStore(store approvalsPendingProvider, resourceID, orgID string) []AgentResourceApprovalSummary {- if store == nil || strings.TrimSpace(resourceID) == "" {+ if isNilApprovalsPendingProvider(store) || strings.TrimSpace(resourceID) == "" {return nil}pending := store.GetPendingApprovals()@@ -575,6 +571,39 @@ func pendingApprovalsForResourceFromStore(store approvalsPendingProvider, resourreturn out}+// pendingApprovalCountsByResourceFromStore is the fleet-context+// companion to pendingApprovalsForResourceFromStore. It scans the+// bounded pending-approval list once, applies the same org isolation+// predicate, and groups counts by canonical resource id so the fleet+// handler does not perform one store scan per resource.+func pendingApprovalCountsByResourceFromStore(store approvalsPendingProvider, orgID string) map[string]int {+ if isNilApprovalsPendingProvider(store) {+ return nil+ }+ pending := store.GetPendingApprovals()+ if len(pending) == 0 {+ return nil+ }+ counts := map[string]int{}+ for _, req := range pending {+ if req == nil {+ continue+ }+ if !approval.BelongsToOrg(req, orgID) {+ continue+ }+ resourceID := req.CanonicalResourceID()+ if resourceID == "" {+ continue+ }+ counts[resourceID]+++ }+ if len(counts) == 0 {+ return nil+ }+ return counts+}+// approvalsPendingProvider is the minimal accessor surface the// pending-approvals bundle filter depends on. The production// implementation is *approval.Store; the interface keeps the@@ -583,6 +612,14 @@ type approvalsPendingProvider interface {GetPendingApprovals() []*approval.ApprovalRequest}+func isNilApprovalsPendingProvider(store approvalsPendingProvider) bool {+ if store == nil {+ return true+ }+ v := reflect.ValueOf(store)+ return v.Kind() == reflect.Ptr && v.IsNil()+}+// projectAgentResourceVerification converts the canonical// ActionVerificationResult into the agent-stable projection that// both the resource-context bundle and the action.completed SSEdiff --git a/internal/api/agent_resource_context_test.go b/internal/api/agent_resource_context_test.goindex 23e73299c8..24027dc046 100644--- a/internal/api/agent_resource_context_test.go+++ b/internal/api/agent_resource_context_test.go@@ -44,6 +44,38 @@ func (s staticApprovalsProvider) PendingApprovalsForResource(resourceID, _ strinreturn s.byResource[resourceID]}+func (s staticApprovalsProvider) PendingApprovalCountsByResource(_ string) map[string]int {+ if s.byResource == nil {+ return nil+ }+ counts := map[string]int{}+ for resourceID, pending := range s.byResource {+ if len(pending) > 0 {+ counts[resourceID] = len(pending)+ }+ }+ if len(counts) == 0 {+ return nil+ }+ return counts+}++type countingApprovalsProvider struct {+ staticApprovalsProvider+ resourceCalls int+ countCalls int+}++func (p *countingApprovalsProvider) PendingApprovalsForResource(resourceID, orgID string) []AgentResourceApprovalSummary {+ p.resourceCalls+++ return p.staticApprovalsProvider.PendingApprovalsForResource(resourceID, orgID)+}++func (p *countingApprovalsProvider) PendingApprovalCountsByResource(orgID string) map[string]int {+ p.countCalls+++ return p.staticApprovalsProvider.PendingApprovalCountsByResource(orgID)+}+// agentContextFixtureHandlers wires a ResourceHandlers around a// pre-built unified-resource seed (using the same// `resourceUnifiedSeedProvider` pattern from resources_test.go) plus@@ -582,6 +614,58 @@ func TestHandleAgentFleetContext_PropagatesPendingApprovalCount(t *testing.T) {}}+func TestHandleAgentFleetContext_UsesBulkPendingApprovalCounts(t *testing.T) {+ h, _, _ := fleetFixtureHandlers(t, []unified.Resource{+ {ID: "vm:101", Type: "vm", Name: "db-01"},+ {ID: "vm:202", Type: "vm", Name: "db-02"},+ {ID: "container:web-1", Type: "container", Name: "web-1"},+ })+ approvals := &countingApprovalsProvider{+ staticApprovalsProvider: staticApprovalsProvider{+ byResource: map[string][]AgentResourceApprovalSummary{+ "vm:101": {+ {ID: "appr-1"},+ {ID: "appr-2"},+ },+ "container:web-1": {+ {ID: "appr-3"},+ },+ },+ },+ }+ h.SetApprovalsProvider(approvals)++ rec := httptest.NewRecorder()+ req := httptest.NewRequest(http.MethodGet, "/api/agent/fleet-context", nil)+ h.HandleFleetContext(rec, req)+ if rec.Code != http.StatusOK {+ t.Fatalf("status: got %d, body=%s", rec.Code, rec.Body.String())+ }+ if approvals.countCalls != 1 {+ t.Fatalf("PendingApprovalCountsByResource calls = %d; want 1", approvals.countCalls)+ }+ if approvals.resourceCalls != 0 {+ t.Fatalf("PendingApprovalsForResource calls = %d; want 0", approvals.resourceCalls)+ }+ var fleet AgentFleetContext+ if err := json.NewDecoder(rec.Body).Decode(&fleet); err != nil {+ t.Fatalf("decode: %v", err)+ }+ byID := map[string]AgentFleetResourceSummary{}+ for _, s := range fleet.Resources {+ byID[s.CanonicalID] = s+ }+ if got := byID["vm:101"].PendingApprovalCount; got != 2 {+ t.Errorf("vm:101 pendingApprovalCount = %d; want 2", got)+ }+ if got := byID["vm:202"].PendingApprovalCount; got != 0 {+ t.Errorf("vm:202 pendingApprovalCount = %d; want 0", got)+ }+ if got := byID["container:web-1"].PendingApprovalCount; got != 1 {+ t.Errorf("container:web-1 pendingApprovalCount = %d; want 1", got)+ }+}+func TestHandleAgentFleetContext_EmptyArrayWhenRegistryEmpty(t *testing.T) {// Empty registry must surface as `resources: []`, never null —// agents iterate without nil-checking. This mirrors the@@ -716,6 +800,10 @@ func TestPendingApprovalsForResource_EmptyInputsReturnNil(t *testing.T) {if got := pendingApprovalsForResourceFromStore(nil, "vm:101", "org-a"); got != nil {t.Errorf("nil store must return nil; got %+v", got)}+ var typedNil *approval.Store+ if got := pendingApprovalsForResourceFromStore(typedNil, "vm:101", "org-a"); got != nil {+ t.Errorf("typed nil store must return nil; got %+v", got)+ }store := newApprovalsTestStore(t)if got := pendingApprovalsForResourceFromStore(store, "", "org-a"); got != nil {t.Errorf("empty resource id must return nil; got %+v", got)@@ -725,6 +813,57 @@ func TestPendingApprovalsForResource_EmptyInputsReturnNil(t *testing.T) {}}+func TestPendingApprovalCountsByResourceFromStore_EmptyInputsReturnNil(t *testing.T) {+ if got := pendingApprovalCountsByResourceFromStore(nil, "org-a"); got != nil {+ t.Errorf("nil store must return nil; got %+v", got)+ }+ var typedNil *approval.Store+ if got := pendingApprovalCountsByResourceFromStore(typedNil, "org-a"); got != nil {+ t.Errorf("typed nil store must return nil; got %+v", got)+ }+ store := newApprovalsTestStore(t)+ if got := pendingApprovalCountsByResourceFromStore(store, "org-a"); got != nil {+ t.Errorf("empty store must return nil; got %+v", got)+ }+}++func TestPendingApprovalCountsByResourceFromStore_GroupsByOrgAndResource(t *testing.T) {+ store := newApprovalsTestStore(t,+ &approval.ApprovalRequest{+ ID: "appr-org-a-vm-101-a", OrgID: "org-a",+ Command: "systemctl restart nginx", TargetType: "vm", TargetID: "101", TargetName: "vm-101",+ },+ &approval.ApprovalRequest{+ ID: "appr-org-a-vm-101-b", OrgID: "org-a",+ Command: "systemctl restart nginx", TargetType: "vm", TargetID: "101", TargetName: "vm-101",+ },+ &approval.ApprovalRequest{+ ID: "appr-org-a-vm-202", OrgID: "org-a",+ Command: "systemctl restart nginx", TargetType: "vm", TargetID: "202", TargetName: "vm-202",+ },+ &approval.ApprovalRequest{+ ID: "appr-org-b-vm-101", OrgID: "org-b",+ Command: "systemctl restart nginx", TargetType: "vm", TargetID: "101", TargetName: "vm-101",+ },+ )++ got := pendingApprovalCountsByResourceFromStore(store, "org-a")+ if got["vm:101"] != 2 {+ t.Errorf("vm:101 count = %d; want 2", got["vm:101"])+ }+ if got["vm:202"] != 1 {+ t.Errorf("vm:202 count = %d; want 1", got["vm:202"])+ }+ if len(got) != 2 {+ t.Errorf("counts len = %d; want 2; got %+v", len(got), got)+ }++ gotB := pendingApprovalCountsByResourceFromStore(store, "org-b")+ if gotB["vm:101"] != 1 || len(gotB) != 1 {+ t.Errorf("org-b counts = %+v; want only vm:101=1", gotB)+ }+}+func TestExtractAgentResourceContextID(t *testing.T) {cases := []struct {path stringdiff --git a/internal/api/contract_test.go b/internal/api/contract_test.goindex aa7e73b2ee..55f4da9a1e 100644--- a/internal/api/contract_test.go+++ b/internal/api/contract_test.go@@ -13634,36 +13634,52 @@ func TestContract_AgentResourceContextEndpointSurfacesStableShape(t *testing.T)// one read" contract for the governance dimension.//// The wire-up has two halves: router.go installs the provider with-// a closure that delegates to a named function in-// agent_resource_context.go, and that function applies the org and-// resource filters. Both halves are pinned here so a refactor that-// moves the filter logic still passes the test only if the-// resulting code preserves the safety properties.+// a provider that delegates to named functions in+// agent_resource_context.go, and those functions apply the org and+// resource filters while supporting the fleet endpoint's bulk count+// projection. Both halves are pinned here so a refactor that moves+// the filter logic still passes the test only if the resulting code+// preserves the safety and scale properties.func TestContract_AgentResourceContextWiresApprovalsProvider(t *testing.T) {router, err := os.ReadFile("router.go")if err != nil {t.Fatalf("read router.go: %v", err)}- if !strings.Contains(string(router), "r.agentContextHandler.SetApprovalsProvider(agentApprovalsProviderFunc(") {+ if !strings.Contains(string(router), "r.agentContextHandler.SetApprovalsProvider(agentApprovalStoreProvider{})") {t.Error("router.go must wire the approvals provider on the agent context handler so the bundle's pendingApprovals section is populated")}- if !strings.Contains(string(router), "pendingApprovalsForResourceFromStore(approval.GetStore(), resourceID, orgID)") {- t.Error("router.go must delegate to pendingApprovalsForResourceFromStore so the request-time store lookup and the filter logic stay together and stay testable")+ if !strings.Contains(string(router), "approval.SetStore") {+ t.Error("router.go must keep documenting that the agent approval provider resolves the process-global approval store at request time")}bundle, err := os.ReadFile("agent_resource_context.go")if err != nil {t.Fatalf("read agent_resource_context.go: %v", err)}+ if !strings.Contains(string(bundle), "type agentApprovalStoreProvider struct{}") {+ t.Error("agent_resource_context.go must define the request-time approval store provider that router.go wires")+ }+ if !strings.Contains(string(bundle), "return pendingApprovalsForResourceFromStore(approval.GetStore(), resourceID, orgID)") {+ t.Error("agentApprovalStoreProvider must resolve the approval store at request time for per-resource context reads")+ }+ if !strings.Contains(string(bundle), "return pendingApprovalCountsByResourceFromStore(approval.GetStore(), orgID)") {+ t.Error("agentApprovalStoreProvider must use the bulk count helper for fleet context reads")+ }if !strings.Contains(string(bundle), "func pendingApprovalsForResourceFromStore(") {t.Error("agent_resource_context.go must define pendingApprovalsForResourceFromStore as the named, testable filter — drift here breaks the cross-org / cross-resource isolation pins")}+ if !strings.Contains(string(bundle), "func pendingApprovalCountsByResourceFromStore(") {+ t.Error("agent_resource_context.go must define pendingApprovalCountsByResourceFromStore so fleet context counts are grouped by one bounded pending-approval scan")+ }if !strings.Contains(string(bundle), "if !approval.BelongsToOrg(req, orgID)") {- t.Error("the named filter must scope pending approvals via BelongsToOrg so cross-tenant requests don't leak into a resource-context bundle")+ t.Error("the named filters must scope pending approvals via BelongsToOrg so cross-tenant requests don't leak into an agent context bundle")}if !strings.Contains(string(bundle), "if req.CanonicalResourceID() != resourceID") {t.Error("the named filter must filter pending approvals by CanonicalResourceID so the bundle only carries approvals targeting the requested resource")}+ if !strings.Contains(string(bundle), "counts[resourceID]++") {+ t.Error("the bulk count helper must group pending approvals by canonical resource id instead of forcing fleet context into per-resource scans")+ }}// TestContract_GetResourceContextCapabilityListsPendingApprovals pinsdiff --git a/internal/api/router.go b/internal/api/router.goindex ce06a73ec4..0f599170f0 100644--- a/internal/api/router.go+++ b/internal/api/router.go@@ -437,18 +437,13 @@ func (r *Router) setupRoutes() {r.kubernetesAgentHandlers.SetRecoveryIngestor(r.recoveryHandlers)r.resourceHandlers = NewResourceHandlers(r.config)r.agentContextHandler = NewAgentContextHandler(r.resourceHandlers)- // Wire pending-approvals into the bundle. The closure resolves+ // Wire pending-approvals into the bundle. The provider resolves// the approval store at request time so multi-tenant rebuilds// (which install a new global store via approval.SetStore) stay- // honored without a re-wire — the bundle just reads whatever is- // currently global. Org scoping uses BelongsToOrg so cross-tenant- // pending requests don't leak into a resource-context read for- // the wrong org.- r.agentContextHandler.SetApprovalsProvider(agentApprovalsProviderFunc(- func(resourceID, orgID string) []AgentResourceApprovalSummary {- return pendingApprovalsForResourceFromStore(approval.GetStore(), resourceID, orgID)- },- ))+ // honored without a re-wire. Org scoping uses BelongsToOrg so+ // cross-tenant pending requests don't leak into an agent context+ // read for the wrong org.+ r.agentContextHandler.SetApprovalsProvider(agentApprovalStoreProvider{})r.agentEventBroadcaster = NewAgentEventBroadcaster()if r.resourceHandlers != nil {if store, err := r.resourceHandlers.getStore("default"); err == nil && store != nil {