test(prompt-gate): tighten dispatch route regressions
This commit is contained in:
@@ -11,21 +11,29 @@ describe("ralph-loop non-abort error continuation", () => {
|
|||||||
const testDirectory = join(tmpdir(), `ralph-loop-non-abort-error-${Date.now()}`)
|
const testDirectory = join(tmpdir(), `ralph-loop-non-abort-error-${Date.now()}`)
|
||||||
let promptCalls: Array<{ sessionID: string; text: string }>
|
let promptCalls: Array<{ sessionID: string; text: string }>
|
||||||
let messagesCalls: Array<{ sessionID: string }>
|
let messagesCalls: Array<{ sessionID: string }>
|
||||||
|
let syncPromptCalls: number
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
promptCalls = []
|
promptCalls = []
|
||||||
messagesCalls = []
|
messagesCalls = []
|
||||||
|
syncPromptCalls = 0
|
||||||
mkdirSync(testDirectory, { recursive: true })
|
mkdirSync(testDirectory, { recursive: true })
|
||||||
clearState(testDirectory)
|
clearState(testDirectory)
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
expect(syncPromptCalls).toBe(0)
|
||||||
clearState(testDirectory)
|
clearState(testDirectory)
|
||||||
if (existsSync(testDirectory)) {
|
if (existsSync(testDirectory)) {
|
||||||
rmSync(testDirectory, { recursive: true, force: true })
|
rmSync(testDirectory, { recursive: true, force: true })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
async function failSyncPrompt(): Promise<never> {
|
||||||
|
syncPromptCalls += 1
|
||||||
|
throw new Error("Ralph Loop runtime-error continuation must use promptAsync")
|
||||||
|
}
|
||||||
|
|
||||||
test("continues immediately after non-abort session error", async () => {
|
test("continues immediately after non-abort session error", async () => {
|
||||||
// given - an active Ralph Loop receives a recoverable command error
|
// given - an active Ralph Loop receives a recoverable command error
|
||||||
const hook = createRalphLoopHook({
|
const hook = createRalphLoopHook({
|
||||||
@@ -50,16 +58,7 @@ describe("ralph-loop non-abort error continuation", () => {
|
|||||||
})
|
})
|
||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
prompt: async (options: {
|
prompt: failSyncPrompt,
|
||||||
path: { id: string }
|
|
||||||
body: { parts: Array<{ type: string; text: string }> }
|
|
||||||
}) => {
|
|
||||||
promptCalls.push({
|
|
||||||
sessionID: options.path.id,
|
|
||||||
text: options.body.parts[0]?.text ?? "",
|
|
||||||
})
|
|
||||||
return {}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
tui: {
|
tui: {
|
||||||
showToast: async () => ({}),
|
showToast: async () => ({}),
|
||||||
@@ -113,7 +112,7 @@ describe("ralph-loop non-abort error continuation", () => {
|
|||||||
})
|
})
|
||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
prompt: async () => ({}),
|
prompt: failSyncPrompt,
|
||||||
},
|
},
|
||||||
tui: {
|
tui: {
|
||||||
showToast: async () => ({}),
|
showToast: async () => ({}),
|
||||||
@@ -172,7 +171,7 @@ describe("ralph-loop non-abort error continuation", () => {
|
|||||||
})
|
})
|
||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
prompt: async () => ({}),
|
prompt: failSyncPrompt,
|
||||||
},
|
},
|
||||||
tui: {
|
tui: {
|
||||||
showToast: async () => ({}),
|
showToast: async () => ({}),
|
||||||
@@ -248,7 +247,7 @@ describe("ralph-loop non-abort error continuation", () => {
|
|||||||
})
|
})
|
||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
prompt: async () => ({}),
|
prompt: failSyncPrompt,
|
||||||
},
|
},
|
||||||
tui: {
|
tui: {
|
||||||
showToast: async () => ({}),
|
showToast: async () => ({}),
|
||||||
@@ -325,7 +324,7 @@ describe("ralph-loop non-abort error continuation", () => {
|
|||||||
})
|
})
|
||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
prompt: async () => ({}),
|
prompt: failSyncPrompt,
|
||||||
},
|
},
|
||||||
tui: {
|
tui: {
|
||||||
showToast: async () => ({}),
|
showToast: async () => ({}),
|
||||||
@@ -401,7 +400,7 @@ describe("ralph-loop non-abort error continuation", () => {
|
|||||||
})
|
})
|
||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
prompt: async () => ({}),
|
prompt: failSyncPrompt,
|
||||||
},
|
},
|
||||||
tui: {
|
tui: {
|
||||||
showToast: async () => ({}),
|
showToast: async () => ({}),
|
||||||
@@ -460,7 +459,7 @@ describe("ralph-loop non-abort error continuation", () => {
|
|||||||
})
|
})
|
||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
prompt: async () => ({}),
|
prompt: failSyncPrompt,
|
||||||
},
|
},
|
||||||
tui: {
|
tui: {
|
||||||
showToast: async () => ({}),
|
showToast: async () => ({}),
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
describe("dispatchInternalPrompt", () => {
|
describe("dispatchInternalPrompt", () => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
// then
|
// then
|
||||||
|
_setPromptGateMessagesFetchTimeoutMsForTesting(undefined)
|
||||||
releaseAllPromptAsyncReservationsForTesting()
|
releaseAllPromptAsyncReservationsForTesting()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -126,6 +127,7 @@ describe("dispatchInternalPrompt", () => {
|
|||||||
describe("dispatchInternalPrompt shared gate behavior", () => {
|
describe("dispatchInternalPrompt shared gate behavior", () => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
// then
|
// then
|
||||||
|
_setPromptGateMessagesFetchTimeoutMsForTesting(undefined)
|
||||||
releaseAllPromptAsyncReservationsForTesting()
|
releaseAllPromptAsyncReservationsForTesting()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user