From 4e49dcf4458ac956cb7c4cb1b2928e4608079e69 Mon Sep 17 00:00:00 2001 From: Alex Newman Date: Mon, 4 May 2026 20:43:00 -0700 Subject: [PATCH] fix: address Greptile P1 findings on PR #2302 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - process-registry.ts: skip the trailing notifySlotAvailable() when pruneDeadEntries() removed entries — prune already wakes one waiter per removed SDK process, so the unconditional call double-woke and could let two waiters spawn in the same synchronous tick, briefly exceeding maxConcurrent. Only fire the safety-net notify when nothing was pruned. - install.ts: persistClaudeProvider() no longer silently rewrites CLAUDE_MEM_CLAUDE_AUTH_METHOD to 'subscription'. When called without an explicit auth method, preserve the existing setting; only fall back to 'subscription' when none is configured. Prevents re-running 'claude-mem install --provider claude' from wiping a user's configured 'api-key' or 'gateway' auth. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/npx-cli/commands/install.ts | 10 ++++++++-- src/supervisor/process-registry.ts | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/npx-cli/commands/install.ts b/src/npx-cli/commands/install.ts index 7535e7f8..1f4cbbcf 100644 --- a/src/npx-cli/commands/install.ts +++ b/src/npx-cli/commands/install.ts @@ -591,10 +591,16 @@ type ClaudeApiMode = 'direct' | 'gateway'; async function promptProvider(options: InstallOptions): Promise { const initialProvider = (getSetting('CLAUDE_MEM_PROVIDER') as ProviderId) || 'claude'; - const persistClaudeProvider = (authMethod: 'subscription' | 'api-key' | 'gateway' = 'subscription') => { + const persistClaudeProvider = (authMethod?: 'subscription' | 'api-key' | 'gateway') => { + const existingAuthMethod = getSetting('CLAUDE_MEM_CLAUDE_AUTH_METHOD') as + | 'subscription' + | 'api-key' + | 'gateway' + | undefined; + const resolvedAuthMethod = authMethod ?? existingAuthMethod ?? 'subscription'; const wrote = mergeSettings({ CLAUDE_MEM_PROVIDER: 'claude', - CLAUDE_MEM_CLAUDE_AUTH_METHOD: authMethod, + CLAUDE_MEM_CLAUDE_AUTH_METHOD: resolvedAuthMethod, }); if (wrote) log.info('Saved Claude Agent SDK configuration to ~/.claude-mem/settings.json'); }; diff --git a/src/supervisor/process-registry.ts b/src/supervisor/process-registry.ts index 7e33c03f..48f72c97 100644 --- a/src/supervisor/process-registry.ts +++ b/src/supervisor/process-registry.ts @@ -482,6 +482,7 @@ export async function waitForSlot(maxConcurrent: number): Promise { const removed = getProcessRegistry().pruneDeadEntries(); if (removed > 0) { logger.info('PROCESS', 'Pruned stale process registry entries while waiting for agent slot', { removed }); + return; } notifySlotAvailable(); }, SLOT_RECHECK_INTERVAL_MS);