Fas 3 steg 3a: cooking_sessions-tabell + lifecycle-endpoints + timeout-jobb, gamla /cook kvar som kortkommando

This commit is contained in:
Sven (AAMOS AI)
2026-08-07 03:14:13 +07:00
parent 4a4f448e1c
commit e9fb4a17d4
17 changed files with 10619 additions and 196 deletions
+8 -1
View File
@@ -1,9 +1,10 @@
import { and, asc, eq, gt, inArray, isNull, lte, sql } from "drizzle-orm";
import { and, asc, eq, gt, inArray, isNull, lt, lte, sql } from "drizzle-orm";
import { schema } from "@app/database";
import { classifyExpiry, computeTrust } from "@app/inventory-engine";
import { deriveMemoryUpdates } from "@app/memory-client";
import { getLocaleContext } from "../locale.js";
import type { WorkerContext } from "../context.js";
import { cancelTimedOutCookingSessions } from "@app/database";
/**
* Återkommande underhållsjobb: outbox-publicering, bäst före-notiser,
@@ -84,6 +85,12 @@ export async function processTrustDecay(ctx: WorkerContext): Promise<number> {
return updated;
}
/** COOKING_SESSION_TIMEOUT (Fas 3 §6 / §20): avbryt STARTED-sessioner äldre än 24 h. */
export async function processCookingSessionTimeout(ctx: WorkerContext): Promise<number> {
const sessions = await cancelTimedOutCookingSessions(ctx.db);
return sessions.length;
}
/** SEND_EXPIRY_NOTIFICATION (spec §54): skapa notiser för varor som snart går ut. */
export async function processExpiryNotifications(ctx: WorkerContext): Promise<number> {
const households = await ctx.db.select({ id: schema.households.id }).from(schema.households);