fix(ralph-loop): guard delayed start snapshots
Prevent delayed loop-start message counts from overwriting active Ralph Loop state after the loop has already advanced, so ULW completion can still enter Oracle verification instead of iterating forever. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -104,11 +104,23 @@ export function createLoopStateController(options: {
|
||||
return state
|
||||
},
|
||||
|
||||
setMessageCountAtStart(sessionID: string, messageCountAtStart: number): RalphLoopState | null {
|
||||
setMessageCountAtStart(
|
||||
sessionID: string,
|
||||
messageCountAtStart: number,
|
||||
expectedStartedAt?: string,
|
||||
): RalphLoopState | null {
|
||||
const state = readState(directory, stateDir)
|
||||
if (!state || state.session_id !== sessionID) {
|
||||
return null
|
||||
}
|
||||
if (
|
||||
state.iteration !== 1
|
||||
|| state.verification_pending
|
||||
|| state.message_count_at_start !== undefined
|
||||
|| (expectedStartedAt !== undefined && state.started_at !== expectedStartedAt)
|
||||
) {
|
||||
return null
|
||||
}
|
||||
|
||||
state.message_count_at_start = messageCountAtStart
|
||||
if (!writeState(directory, state, stateDir)) {
|
||||
|
||||
Reference in New Issue
Block a user