refactor(core): simplify session run coordination (#33388)

This commit is contained in:
Kit Langton 2026-06-22 18:16:30 +02:00 committed by GitHub
commit fe840d42b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 211 additions and 1378 deletions

View file

@ -21,7 +21,7 @@ export interface Interface {
/** Drains eligible durable work. Explicit runs perform one provider attempt even when no work is eligible. */
readonly run: (input: {
readonly sessionID: SessionSchema.ID
readonly force?: boolean
readonly force: boolean
}) => Effect.Effect<void, RunError>
}

View file

@ -346,14 +346,14 @@ export const layer = Layer.effect(
const run = Effect.fn("SessionRunner.run")(function* (input: {
readonly sessionID: SessionSchema.ID
readonly force?: boolean
readonly force: boolean
}) {
const hasSteer = yield* SessionInput.hasPending(db, input.sessionID, "steer")
const hasQueue = hasSteer ? false : yield* SessionInput.hasPending(db, input.sessionID, "queue")
if (input.force !== true && !hasSteer && !hasQueue) return
if (!input.force && !hasSteer && !hasQueue) return
yield* failInterruptedTools(input.sessionID)
let promotion: SessionInput.Delivery | undefined = hasSteer ? "steer" : hasQueue ? "queue" : undefined
let openActivity = input.force === true || hasSteer || hasQueue
let openActivity = input.force || hasSteer || hasQueue
while (openActivity) {
let needsContinuation = true
for (let step = 1; needsContinuation; step++) {