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
refactor: drop the now-unused clearPerpetualPark in favor of recordPerpetualDispatch (#3848)
[._.]/ Adam Eivy6668a45e2f6b
diff --git a/server/services/cosTaskGenerator.referenceWatch.test.js b/server/services/cosTaskGenerator.referenceWatch.test.jsindex 48b15460bf..f171b8591d 100644--- a/server/services/cosTaskGenerator.referenceWatch.test.js+++ b/server/services/cosTaskGenerator.referenceWatch.test.js@@ -45,7 +45,6 @@ vi.mock('./taskSchedule.js', () => ({getTaskInterval: vi.fn(async () => ({ type: 'weekly', taskMetadata: { readOnly: false } })),stripManagedAgentOptionsFromOverride: vi.fn((_type, meta) => meta),recordExecution: vi.fn(async () => {}),- clearPerpetualPark: vi.fn(async () => {}),parkPerpetual: vi.fn(async () => {}),// This is a FULL-REPLACEMENT mock (no importActual spread), so it is the entire// taskSchedule surface this suite sees — it has to track the real module's draindiff --git a/server/services/taskSchedule.js b/server/services/taskSchedule.jsindex 2bbd4bd6b7..0d7024ac3e 100644--- a/server/services/taskSchedule.js+++ b/server/services/taskSchedule.js@@ -1065,8 +1065,9 @@ const PARK_FIELDS = ['parkedUntil', 'parkReason', 'parkActionableCount', 'parkCo* is a step a future park path can forget — and a stale non-zero dispatch count* makes the NEXT fresh drain cap out early, which looks exactly like the task* silently doing nothing. Note `dispatchCount` is deliberately NOT in- * `PARK_FIELDS`: `clearPerpetualPark` runs mid-drain, and zeroing the counter- * there would reset the budget before every dispatch, so the cap could never fire.+ * `PARK_FIELDS`: `recordPerpetualDispatch` clears those fields mid-drain on every+ * dispatch, and zeroing the counter there would reset the budget before every+ * dispatch, so the cap could never fire.*/export async function parkPerpetual(taskType, appId = null, { reason = null, actionableCount = 0, counts = null, signature, dispatchCount } = {}) {const schedule = await loadSchedule();@@ -1197,19 +1198,6 @@ export async function recordPerpetualDispatch(taskType, appId = null, signature)return count;}-/**- * Clear a perpetual task's park so the drain resumes (its work-detector found- * actionable work). No-op (and no write) when there's nothing parked.- */-export async function clearPerpetualPark(taskType, appId = null) {- const schedule = await loadSchedule();- const record = resolveExecutionRecord(schedule, taskType, appId);- if (!record || record.parkedUntil == null) return false;- for (const field of PARK_FIELDS) delete record[field];- await saveSchedule(schedule);- return true;-}-/*** Reset a perpetual task's cached drain state for an explicit user-initiated* re-run. Drops any park AND the convergence `lastActionableSignature` in adiff --git a/server/services/taskSchedule.test.js b/server/services/taskSchedule.test.jsindex fa97d16084..f166aa4521 100644--- a/server/services/taskSchedule.test.js+++ b/server/services/taskSchedule.test.js@@ -120,7 +120,6 @@ import {getScheduleStatus,computePerpetualRecheckAt,parkPerpetual,- clearPerpetualPark,resetPerpetualForManualRun,getPerpetualParkInfo,isPerpetualParkActive,@@ -1610,7 +1609,7 @@ describe('taskSchedule', () => {})})- describe('parkPerpetual / clearPerpetualPark', () => {+ describe('parkPerpetual / perpetual park state', () => {it('parkPerpetual stamps parkedUntil + reason on the per-app record', async () => {mockSchedule({ tasks: { 'claim-issue': { type: 'perpetual', enabled: true, recheckIntervalMs: 3600000 } } })const record = await parkPerpetual('claim-issue', 'app-1', { reason: 'no-actionable-issues', actionableCount: 0, counts: { open: 40, inFlight: 2, filtered: 38 } })@@ -1663,21 +1662,21 @@ describe('taskSchedule', () => {expect(record.parkCounts).toBeUndefined()})- it('clearPerpetualPark returns true when a park existed', async () => {+ // The mid-drain unpark is recordPerpetualDispatch's job (it clears the park+ // fields in the same write it spends a dispatch) — there is no separate+ // clear-only path any more, so a resumed drain can never forget to spend+ // one and slip the cap.+ it('recordPerpetualDispatch clears an existing park as it spends a dispatch', async () => {const future = new Date(Date.now() + 60 * 60 * 1000).toISOString()mockSchedule({tasks: { 'claim-issue': { type: 'perpetual', enabled: true } },- executions: { 'task:claim-issue': { lastRun: null, count: 0, perApp: { 'app-1': { lastRun: null, count: 0, parkedUntil: future } } } }- })- expect(await clearPerpetualPark('claim-issue', 'app-1')).toBe(true)- })-- it('clearPerpetualPark is a no-op (false) when nothing is parked', async () => {- mockSchedule({- tasks: { 'claim-issue': { type: 'perpetual', enabled: true } },- executions: { 'task:claim-issue': { lastRun: null, count: 0, perApp: {} } }+ executions: { 'task:claim-issue': { lastRun: null, count: 0, perApp: {+ 'app-1': { lastRun: null, count: 0, parkedUntil: future, parkReason: 'no-actionable-issues', perpetualDispatchCount: 2 }+ } } }})- expect(await clearPerpetualPark('claim-issue', 'app-1')).toBe(false)+ expect(await recordPerpetualDispatch('claim-issue', 'app-1', null)).toBe(3)+ expect(await isPerpetualParkActive('claim-issue', 'app-1')).toBe(false)+ expect(await getPerpetualParkInfo('claim-issue', 'app-1')).toBeNull()})it('resetPerpetualForManualRun drops the park, the convergence signature, AND the dispatch count', async () => {