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: defer auto-update repair dispatch while an agent owns the checkout (#12227)
[._.]/ Adam Eivy2b0ac403fc07
diff --git a/server/services/autoUpdateScheduler.js b/server/services/autoUpdateScheduler.jsindex fdaccf8400..20aaba23d0 100644--- a/server/services/autoUpdateScheduler.js+++ b/server/services/autoUpdateScheduler.js@@ -292,7 +292,13 @@ export async function runAutoUpdateTick({ io = ioRef } = {}) {const read = await checkUpdateRepoReadiness({ fetch: true }).catch((err) => ({ ready: false, needsAgent: false, reasons: ['git-unreadable'], summary: err.message, repairable: [] }));if (!read.ready && !isRepairableOnly(read)) {- if (read.needsAgent && config.resolveBlockersWithAgent && repairDispatchDue(runtime, config.minIntervalMs, now)) {+ // A live owner (or an unreadable owner registry) means the repair agent could+ // only stand down — the claim-ownership coordinator refuses it while another+ // agent holds the checkout. Dispatching anyway would burn the repair cooldown+ // on a run that cannot act; defer so the first tick after the owners release+ // the checkout enqueues the repair instead.+ const ownerHoldsCheckout = read.reasons?.includes('agent-at-work') || read.reasons?.includes('agent-check-unreadable');+ if (read.needsAgent && !ownerHoldsCheckout && config.resolveBlockersWithAgent && repairDispatchDue(runtime, config.minIntervalMs, now)) {const task = await queueRepoRepairTask(read);// Stamp only on a REAL dispatch. `addTask`'s dedup (cosTaskStore.js)// only collapses repeat ticks onto one task while that task stays opendiff --git a/server/services/autoUpdateScheduler.test.js b/server/services/autoUpdateScheduler.test.jsindex 36cff5d7c0..4b7ae95229 100644--- a/server/services/autoUpdateScheduler.test.js+++ b/server/services/autoUpdateScheduler.test.js@@ -232,6 +232,51 @@ describe('checkout readiness gate', () => {expect(deps.queueRepair).not.toHaveBeenCalled();});+ // #12227: a live owner makes the repair agent stand down, so dispatching it+ // would only burn the cooldown. Defer, and repair on the first tick after+ // the owners release the checkout.+ describe('active checkout owners', () => {+ const owned = { ...notReady, reasons: ['agent-at-work', 'unpushed-commits'], summary: 'a CoS agent is working in this checkout' };++ it('neither queues a repair nor stamps the cooldown while an agent holds the checkout', async () => {+ deps.readRepo.mockResolvedValue(owned);+ deps.queueRepair.mockResolvedValue({ id: 'task-1' });+ await expect(runAutoUpdateTick({ io: {} })).resolves.toMatchObject({ ran: false, reason: 'repo-not-ready' });+ expect(deps.queueRepair).not.toHaveBeenCalled();+ expect(deps.recordRuntime).not.toHaveBeenCalledWith(expect.objectContaining({ repairQueuedAt: expect.any(String) }));+ expect(deps.prepareRepo).not.toHaveBeenCalled();+ expect(deps.selfUpdate).not.toHaveBeenCalled();+ });++ it('does not dispatch repair or update when agent ownership is unreadable', async () => {+ deps.readRepo.mockResolvedValue({ ...owned, reasons: ['agent-check-unreadable', 'unpushed-commits'] });+ await expect(runAutoUpdateTick({ io: {} })).resolves.toMatchObject({ ran: false, reason: 'repo-not-ready' });+ expect(deps.queueRepair).not.toHaveBeenCalled();+ expect(deps.appUpdate).not.toHaveBeenCalled();+ });++ it('dispatches exactly one repair once ownership clears, then honours the cooldown', async () => {+ deps.queueRepair.mockResolvedValue({ id: 'task-1' });+ deps.readRepo.mockResolvedValue(owned);+ await runAutoUpdateTick({ io: {} });+ expect(deps.queueRepair).not.toHaveBeenCalled();++ deps.readRepo.mockResolvedValue({ ...notReady, reasons: ['unpushed-commits'] });+ await runAutoUpdateTick({ io: {} });+ expect(deps.queueRepair).toHaveBeenCalledTimes(1);+ const [[{ repairQueuedAt }]] = deps.recordRuntime.mock.calls.filter(([patch]) => typeof patch.repairQueuedAt === 'string');++ deps.queueRepair.mockClear();+ deps.gateState.mockResolvedValue({+ runtime: { armedAt: iso(Date.now() - 48 * HOUR), lastRunAt: null, repairQueuedAt },+ lastUpdateResult: null,+ updateInProgress: false,+ });+ await runAutoUpdateTick({ io: {} });+ expect(deps.queueRepair).not.toHaveBeenCalled();+ });+ });+// The core regression (#7468): a repair agent that stands down without// fixing the tree must not be re-queued every 5-minute tick forever.// `addTask`'s dedup only holds while that task stays open, and