fix(ai): read AI switches, modules and consent afresh inside background jobs

A background job opens one wide event for its whole run, and the per-request
memo cached the operator switches, module availability, module preferences,
provider presence and consent kinds on it. The nightly status passes loop
over every candidate inside that one event, so a switch turned off mid-run
did not stop the remaining users, and the wire re-check read the same cached
answer.

memoizePerRequest takes a freshInBackground option; every input that decides
whether AI work may run sets it, so a background caller reads them on every
call while a request still reads them once.
This commit is contained in:
Marc-André Bombeck committed 2026-09-24 12:08:39 +02:00
1 parent 4ae231d757
commit 06251d7219
10 files changed
+236 -67

No files matched your search

+5
View File
@@ -288,6 +288,11 @@ export class WideEventBuilder {
return structuredClone(this.event) as WideEvent;
}
/** `http` for a request, `background` for a job or a hand-rolled route. */
getKind(): EventKind {
return this.event.kind ?? "http";
}
getDurationMs(): number {
return Math.round(performance.now() - this.startTime);
}