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:
YeonGyu-Kim
2026-05-13 18:59:07 +09:00
parent 1fa97c6efe
commit 61ba4e3b41
3 changed files with 64 additions and 2 deletions
+13 -1
View File
@@ -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)) {