Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: log scrubbed warning when persistent mind turn is degraded (#11386)
[._.]/ Adam Eivy7a36449aa8ea
diff --git a/server/services/persistentMindSupervisor.js b/server/services/persistentMindSupervisor.jsindex 15686962e9..b6c9790e5c 100644--- a/server/services/persistentMindSupervisor.js+++ b/server/services/persistentMindSupervisor.js@@ -84,6 +84,7 @@ import {isContextBudgetFitnessError,} from '../lib/persistentMindContextBudget.js';import { isProviderAvailable, markProviderUsageLimit } from './providerStatus.js';+import { scrubSecretTokens } from '../lib/secretText.js';export const PERSISTENT_MIND_WAKE_EVENT_ID = 'cos-persistent-mind-wake';export const PERSISTENT_MIND_WATCHDOG_EVENT_ID = 'cos-persistent-mind-watchdog';@@ -499,6 +500,9 @@ async function interruptActiveTurn(reason, status, { retry = false, expectedTurn*/async function parkActiveTurn(turnId, reason, status = 'waiting', { retryAt = null, consumedAttempt = false, retireWake = false } = {}) {const paused = status === 'paused';+ if (status === 'degraded') {+ console.warn(`⚠️ Persistent mind turn degraded: ${scrubSecretTokens(String(reason)).slice(0, 300)}`);+ }const result = await mutateMindState((mind) => {if (mind.activeTurn?.id !== turnId) return { mind, value: false };// Transport/slot waits may retry; a revoked route or uncertain inferencediff --git a/server/services/persistentMindSupervisor.test.js b/server/services/persistentMindSupervisor.test.jsindex 256cc1d415..8dcca4ca13 100644--- a/server/services/persistentMindSupervisor.test.js+++ b/server/services/persistentMindSupervisor.test.js@@ -1868,4 +1868,75 @@ describe('usage-limit retry time', () => {expect(supervisor.persistentMindUsageLimitRetryAt()).toBeNull();});});++ describe('degraded park logging', () => {+ let warnSpy;++ beforeEach(() => {+ warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});+ });++ afterEach(() => {+ warnSpy.mockRestore();+ });++ it('scrubs credentials and truncates a 21K reason in the degraded park log', async () => {+ const secret = 'sk-ant-api03-abcdefghijklmnopqrstuvwxyz123456';+ const longReason = `Preparation failed with token ${secret} ` + 'x'.repeat(21_000);+ await supervisor.registerPersistentMindTurnAdapter({+ prepare: vi.fn(async () => ({ ok: false, error: longReason })),+ run: vi.fn(),+ });+ await supervisor.setPersistentMindEnabled(true);+ await supervisor.startPersistentMind();+ await supervisor.enqueuePersistentMindMessage({ id: 'msg-degraded', text: 'Degraded test' });+ await supervisor.drainPersistentMind();++ expect(mock.root.persistentMind.status).toBe('degraded');+ const degradedCalls = warnSpy.mock.calls.filter(([msg]) =>+ typeof msg === 'string' && msg.startsWith('⚠️ Persistent mind turn degraded:')+ );+ expect(degradedCalls).toHaveLength(1);+ const [logged] = degradedCalls[0];+ expect(logged).toContain('[REDACTED]');+ expect(logged).not.toContain(secret);+ expect(logged.length).toBe('⚠️ Persistent mind turn degraded: '.length + 300);+ });++ it('does not log when a turn is parked as waiting or paused', async () => {+ // 1. Waiting park (local endpoint at capacity)+ mock.localEndpointOfProvider.mockReturnValue('http://localhost:1234');+ const run = vi.fn();+ await supervisor.registerPersistentMindTurnAdapter({+ prepare: vi.fn(async () => ({ ok: true, provider: mock.profile.provider })),+ run,+ });+ mock.acquireSlot.mockResolvedValueOnce({ ok: false, reason: 'local endpoint localhost:1234 is at capacity (1/1)' });+ await supervisor.setPersistentMindEnabled(true);+ await supervisor.startPersistentMind();+ await supervisor.enqueuePersistentMindMessage({ id: 'msg-waiting', text: 'Wait for capacity.' });+ await supervisor.drainPersistentMind();++ expect(mock.root.persistentMind.status).toBe('waiting');+ expect(warnSpy.mock.calls.filter(([msg]) =>+ typeof msg === 'string' && msg.startsWith('⚠️ Persistent mind turn degraded:')+ )).toHaveLength(0);++ // 2. Paused park (provider usage limit refusal)+ mock.acquireSlot.mockResolvedValue({ ok: true, release: vi.fn() });+ await supervisor.registerPersistentMindTurnAdapter({+ prepare: vi.fn(async () => ({ ok: true, provider: { id: 'example-cloud' } })),+ run: vi.fn(async () => {+ throw new Error("You've hit your usage limit Get Cursor Pro to keep going.");+ }),+ });+ await supervisor.enqueuePersistentMindMessage({ id: 'msg-paused', text: 'Quota test' });+ await supervisor.drainPersistentMind();++ expect(mock.root.persistentMind.status).toBe('paused');+ expect(warnSpy.mock.calls.filter(([msg]) =>+ typeof msg === 'string' && msg.startsWith('⚠️ Persistent mind turn degraded:')+ )).toHaveLength(0);+ });+ });});