fix(ralph-loop): commit iteration only after verification continuation dispatches
Split the verification-failure restart into clearVerificationState (clears\nthe verification flags so we cleanly transition back to the main loop)\nfollowed by injectContinuationPrompt, with incrementIteration only on\nsuccessful injection. On rejection: clear the loop state and emit a loud\nwarning toast. Mirrors the dispatch-before-commit contract enforced for\nthe idle and session.error paths.
This commit is contained in:
@@ -174,5 +174,27 @@ export function createLoopStateController(options: {
|
||||
|
||||
return state
|
||||
},
|
||||
|
||||
clearVerificationState(sessionID: string, messageCountAtStart?: number): RalphLoopState | null {
|
||||
const state = readState(directory, stateDir)
|
||||
if (!state || state.session_id !== sessionID || !state.ultrawork || !state.verification_pending) {
|
||||
return null
|
||||
}
|
||||
|
||||
state.started_at = new Date().toISOString()
|
||||
state.completion_promise = state.initial_completion_promise ?? DEFAULT_COMPLETION_PROMISE
|
||||
state.verification_pending = undefined
|
||||
state.verification_attempt_id = undefined
|
||||
state.verification_session_id = undefined
|
||||
if (typeof messageCountAtStart === "number") {
|
||||
state.message_count_at_start = messageCountAtStart
|
||||
}
|
||||
|
||||
if (!writeState(directory, state, stateDir)) {
|
||||
return null
|
||||
}
|
||||
|
||||
return state
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user