fix(ralph-loop): restrict semantic completion to DONE promise and assistant entries

- Gate semantic detection on promise === 'DONE' in both transcript and
  session message paths to prevent false positives on VERIFIED promises
- Restrict transcript semantic fallback to assistant/text entries only,
  skipping tool_use/tool_result to avoid matching file content
- Add regression test for VERIFIED promise not triggering semantic detection
This commit is contained in:
MoerAI
2026-03-25 16:49:53 +09:00
parent aaaeb6997c
commit 774d0bd84d
2 changed files with 27 additions and 4 deletions
@@ -273,6 +273,28 @@ describe("detectCompletionInSessionMessages", () => {
// #then
expect(detected).toBe(true)
})
test("#when promise is VERIFIED #then semantic completion should NOT trigger", async () => {
// #given
const messages: SessionMessage[] = [
{
info: { role: "assistant" },
parts: [{ type: "text", text: "The task is complete. All work has been finished." }],
},
]
const ctx = createPluginInput(messages)
// #when
const detected = await detectCompletionInSessionMessages(ctx, {
sessionID: "session-123",
promise: "VERIFIED",
apiTimeoutMs: 1000,
directory: "/tmp",
})
// #then
expect(detected).toBe(false)
})
})
})