From 3f5aa92067d1880b1c2f254784e525469e499912 Mon Sep 17 00:00:00 2001 From: garvitkaushik-123 Date: Tue, 15 Sep 2026 14:22:12 +0530 Subject: [PATCH] fix(addie): reduce admin negative cache TTL from 5 minutes to 60 seconds Align the negative cache TTL with the positive cache TTL (both now 60s). A legitimate admin whose working-group membership lookup returned false transiently was locked out for 5 minutes across all requests on that instance. The existing comment at admin-status-lookup.ts already acknowledges that invalidation only reaches the instance that performed the grant/revoke, making a shorter negative TTL consistent with the design intent. Also replaces a hardcoded 5-minute literal in the Slack admin-group- not-found path with the named ADMIN_NEGATIVE_CACHE_TTL_MS constant. --- server/src/addie/admin-status-lookup.ts | 2 +- server/src/addie/mcp/admin-tools.ts | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/server/src/addie/admin-status-lookup.ts b/server/src/addie/admin-status-lookup.ts index daf2ed7711a..a0d0de44242 100644 --- a/server/src/addie/admin-status-lookup.ts +++ b/server/src/addie/admin-status-lookup.ts @@ -36,7 +36,7 @@ const AAO_ADMIN_WORKING_GROUP_SLUG = 'aao-admin'; // performed an admin grant/revoke. Other replicas must therefore re-check // membership quickly enough for an emergency revocation to take effect. export const AAO_ADMIN_POSITIVE_CACHE_TTL_MS = 60 * 1000; -const AAO_ADMIN_NEGATIVE_CACHE_TTL_MS = 5 * 60 * 1000; +const AAO_ADMIN_NEGATIVE_CACHE_TTL_MS = 60 * 1000; const wgDb = new WorkingGroupDatabase(); diff --git a/server/src/addie/mcp/admin-tools.ts b/server/src/addie/mcp/admin-tools.ts index 2747ac97a22..c547a8af11b 100644 --- a/server/src/addie/mcp/admin-tools.ts +++ b/server/src/addie/mcp/admin-tools.ts @@ -202,7 +202,7 @@ const KITCHEN_CABINET_SLUG = "kitchen-cabinet"; // Site-admin membership can be revoked on another replica. Keep successful // membership decisions short-lived so every replica rechecks within a minute. const ADMIN_POSITIVE_CACHE_TTL_MS = 60 * 1000; -const ADMIN_NEGATIVE_CACHE_TTL_MS = 5 * 60 * 1000; +const ADMIN_NEGATIVE_CACHE_TTL_MS = 60 * 1000; const COUNCIL_CACHE_TTL_MS = 30 * 60 * 1000; // Shared cache module — invalidators can be called without dragging the // rest of admin-tools (and its Anthropic-instantiating dependencies) @@ -247,10 +247,9 @@ export async function isSlackUserAAOAdmin( if (!adminGroup) { logger.warn("Admin check: aao-admin working group not found in DB"); - // Cache the negative result for a shorter time to avoid repeated DB lookups adminStatusCache.set(slackUserId, { isAdmin: false, - expiresAt: Date.now() + 5 * 60 * 1000, + expiresAt: Date.now() + ADMIN_NEGATIVE_CACHE_TTL_MS, }); return false; }