fix(ralph-loop): revalidate ownership and harden commit/session-creation failures
Three correctness fixes on top of the dispatch-before-commit invariant: - ralph-loop-event-handler.ts: after idleSettleMs, also require state ownership and non-verification-pending to match the event source before dispatching. Applied to both the session.idle and session.error retry paths. - verification-failure-handler.ts: if incrementIteration fails after a successful continuation injection, clear the loop state and emit a warning toast instead of returning success. - session-reset-strategy.ts: catch thrown session.create errors so they route through the typed session_creation_rejected path instead of surfacing as an unhandled rejection.
This commit is contained in:
@@ -7,23 +7,31 @@ export async function createIterationSession(
|
||||
parentSessionID: string,
|
||||
directory: string,
|
||||
): Promise<string | null> {
|
||||
const createResult = await ctx.client.session.create({
|
||||
body: {
|
||||
parentID: parentSessionID,
|
||||
title: "Ralph Loop Iteration",
|
||||
},
|
||||
query: { directory },
|
||||
})
|
||||
try {
|
||||
const createResult = await ctx.client.session.create({
|
||||
body: {
|
||||
parentID: parentSessionID,
|
||||
title: "Ralph Loop Iteration",
|
||||
},
|
||||
query: { directory },
|
||||
})
|
||||
|
||||
if (createResult.error || !createResult.data?.id) {
|
||||
log("[ralph-loop] Failed to create iteration session", {
|
||||
if (createResult.error || !createResult.data?.id) {
|
||||
log("[ralph-loop] Failed to create iteration session", {
|
||||
parentSessionID,
|
||||
error: String(createResult.error ?? "No session ID returned"),
|
||||
})
|
||||
return null
|
||||
}
|
||||
|
||||
return createResult.data.id
|
||||
} catch (error: unknown) {
|
||||
log("[ralph-loop] session.create threw during iteration session creation", {
|
||||
parentSessionID,
|
||||
error: String(createResult.error ?? "No session ID returned"),
|
||||
error: String(error),
|
||||
})
|
||||
return null
|
||||
}
|
||||
|
||||
return createResult.data.id
|
||||
}
|
||||
|
||||
export async function selectSessionInTui(
|
||||
|
||||
Reference in New Issue
Block a user