Merge reviewed inventory diagnostic completeness correction

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-11-02 17:18:54 -06:00
commit e8568b5565
5 files changed
+63 -8

No files matched your search

+2 -1
View File
@@ -16,6 +16,7 @@ const record = (value: unknown): Record<string, unknown> | null =>
export async function readIdleIssueSchedule(tx: Pick<Db, "execute">, ownerId: string, now: number): Promise<{
blocked: boolean;
inspectionComplete?: false;
scheduledWake?: ScheduledWake;
generation?: string;
}> {
@@ -56,7 +57,7 @@ export async function readIdleIssueSchedule(tx: Pick<Db, "execute">, ownerId: st
FROM issues i JOIN companies c ON c.id = i.company_id
LEFT JOIN agents a ON a.id = i.assignee_agent_id AND a.company_id = i.company_id
WHERE i.status NOT IN ('done', 'cancelled') ORDER BY i.id LIMIT ${limit + 1}`);
if (rows.length > limit) return { blocked: true };
if (rows.length > limit) return { blocked: true, inspectionComplete: false };
let earliest = Infinity;
for (const row of rows) {
const policy = record(row.execution_policy);
+2 -1
View File
@@ -15,6 +15,7 @@ export interface ScheduledWake {
export async function readIdleRoutineSchedule(tx: Pick<Db, "execute">, ownerId: string, now: number): Promise<{
blocked: boolean;
inspectionComplete?: false;
scheduledWake?: ScheduledWake;
}> {
const unknown = await tx.execute<{ blocked: boolean }>(sql`SELECT EXISTS (
@@ -33,7 +34,7 @@ export async function readIdleRoutineSchedule(tx: Pick<Db, "execute">, ownerId:
FROM routine_triggers t JOIN routines r ON r.id = t.routine_id
WHERE r.status = 'active' AND t.enabled AND NOT t.archived
ORDER BY t.id LIMIT ${limit + 1}`);
if (rows.length > limit) return { blocked: true };
if (rows.length > limit) return { blocked: true, inspectionComplete: false };
let earliest = Infinity;
const validTimezones = new Set<string>();
const validCrons = new Set<string>();
+4 -4
View File
@@ -391,17 +391,17 @@ export async function readIdleSleepSafety(
if (scheduledRoutines) {
if (!owned()) return undefined;
const schedule = await readIdleRoutineSchedule(tx, ownerId!, now());
diagnostic?.record("routines.schedule", schedule.blocked ? "present" : "none");
diagnostic?.record("routines.schedule", schedule.inspectionComplete === false ? "unknown" : schedule.blocked ? "present" : "none");
if (schedule.blocked && !diagnostic) return true;
found ||= schedule.blocked;
found ||= schedule.blocked && schedule.inspectionComplete !== false;
scheduledWake = schedule.scheduledWake;
}
if (scheduledIssueMonitors) {
if (!scheduledRoutines || !owned()) return undefined;
const schedule = await readIdleIssueSchedule(tx, ownerId!, now());
diagnostic?.record("issues.schedule", schedule.blocked ? "present" : "none");
diagnostic?.record("issues.schedule", schedule.inspectionComplete === false ? "unknown" : schedule.blocked ? "present" : "none");
if (schedule.blocked && !diagnostic) return true;
found ||= schedule.blocked;
found ||= schedule.blocked && schedule.inspectionComplete !== false;
scheduledWake = combineIdleSchedules(scheduledWake, schedule.scheduledWake, schedule.generation);
}
return found;