Reconcile host preparation on heartbeats instead of polls

This commit is contained in:
2026-10-06 14:52:03 -04:00
parent d99e5979fa
commit b17673720b
4 changed files with 12 additions and 6 deletions
+2 -2
View File
@@ -173,7 +173,7 @@ function supersedeUndeliveredDownloads(hostId: string): void {
}
}
/** Agent heartbeats and polls drive durable preparation; no open UI or in-memory worker is needed. */
/** Heartbeats drive durable preparation; idle checks do not reserve the SQLite writer. */
export function reconcileHostPreparation(hostId: string): HostPreparation {
return db().transaction(() => {
const host = getHost(hostId);
@@ -203,5 +203,5 @@ export function reconcileHostPreparation(hostId: string): HostPreparation {
scheduleAvailabilityRefresh();
}
return status;
}).immediate();
})();
}
@@ -1,10 +1,8 @@
import { pendingHostOperationRows, waitForHostWork } from '$lib/server/hosts/index.js';
import { authenticateAgent } from '$lib/server/hosts/http.js';
import { reconcileHostPreparation } from '$lib/server/hosts/preparation.js';
import { hostOperationsResponse } from '$lib/server/hosts/delivery.js';
export async function GET({ request }: { request: Request }) {
const host = authenticateAgent(request);
reconcileHostPreparation(host.id);
const params = new URL(request.url).searchParams;
const lane = params.get('lane') === 'health' ? 'health' : params.get('lane') === 'read' ? 'read' : params.get('lane') === 'write' ? 'write' : 'all';
let operations = pendingHostOperationRows(host.id, lane, false);