|
|
|
@@ -63,7 +63,7 @@ describe("ulw-loop verification", () => {
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test("#given ulw loop emits DONE #when idle fires #then verification phase starts instead of completing", async () => {
|
|
|
|
|
test("#given ulw loop emits DONE #when idle fires #then verification phase starts instead of completing", async () => {
|
|
|
|
|
const hook = createRalphLoopHook(createMockPluginInput(), {
|
|
|
|
|
getTranscriptPath: (sessionID) => sessionID === "ses-oracle" ? oracleTranscriptPath : parentTranscriptPath,
|
|
|
|
|
})
|
|
|
|
@@ -75,11 +75,11 @@ describe("ulw-loop verification", () => {
|
|
|
|
|
|
|
|
|
|
await hook.event({ event: { type: "session.idle", properties: { sessionID: "session-123" } } })
|
|
|
|
|
|
|
|
|
|
expect(hook.getState()?.verification_pending).toBe(true)
|
|
|
|
|
expect(hook.getState()?.completion_promise).toBe(ULTRAWORK_VERIFICATION_PROMISE)
|
|
|
|
|
expect(hook.getState()?.verification_session_id).toBeUndefined()
|
|
|
|
|
expect(hook.getState()?.verification_pending).toBeUndefined()
|
|
|
|
|
expect(hook.getState()?.completion_promise).toBe("DONE")
|
|
|
|
|
expect(hook.getState()?.iteration).toBe(2)
|
|
|
|
|
expect(promptCalls).toHaveLength(1)
|
|
|
|
|
expect(promptCalls[0].text).toContain('task(subagent_type="oracle"')
|
|
|
|
|
expect(promptCalls[0].text).not.toContain('task(subagent_type="oracle"')
|
|
|
|
|
expect(toastCalls.some((toast) => toast.title === "ULTRAWORK LOOP COMPLETE!")).toBe(false)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
@@ -90,7 +90,7 @@ describe("ulw-loop verification", () => {
|
|
|
|
|
hook.startLoop("session-123", "Build API", { ultrawork: true })
|
|
|
|
|
writeFileSync(
|
|
|
|
|
parentTranscriptPath,
|
|
|
|
|
`${JSON.stringify({ type: "tool_result", timestamp: new Date().toISOString(), tool_output: { output: "done <promise>DONE</promise>" } })}\n`,
|
|
|
|
|
`${JSON.stringify({ type: "assistant", timestamp: new Date().toISOString(), content: "done <promise>DONE</promise>" })}\n`,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
await hook.event({ event: { type: "session.idle", properties: { sessionID: "session-123" } } })
|
|
|
|
@@ -100,7 +100,7 @@ describe("ulw-loop verification", () => {
|
|
|
|
|
})
|
|
|
|
|
writeFileSync(
|
|
|
|
|
oracleTranscriptPath,
|
|
|
|
|
`${JSON.stringify({ type: "tool_result", timestamp: new Date().toISOString(), tool_output: { output: `verified <promise>${ULTRAWORK_VERIFICATION_PROMISE}</promise>` } })}\n`,
|
|
|
|
|
`${JSON.stringify({ type: "assistant", timestamp: new Date().toISOString(), content: `verified <promise>${ULTRAWORK_VERIFICATION_PROMISE}</promise>` })}\n`,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
await hook.event({ event: { type: "session.idle", properties: { sessionID: "session-123" } } })
|
|
|
|
@@ -116,7 +116,7 @@ describe("ulw-loop verification", () => {
|
|
|
|
|
hook.startLoop("session-123", "Build API", { ultrawork: true })
|
|
|
|
|
writeFileSync(
|
|
|
|
|
parentTranscriptPath,
|
|
|
|
|
`${JSON.stringify({ type: "tool_result", timestamp: new Date().toISOString(), tool_output: { output: "done <promise>DONE</promise>" } })}\n`,
|
|
|
|
|
`${JSON.stringify({ type: "assistant", timestamp: new Date().toISOString(), content: "done <promise>DONE</promise>" })}\n`,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
await hook.event({ event: { type: "session.idle", properties: { sessionID: "session-123" } } })
|
|
|
|
@@ -126,7 +126,7 @@ describe("ulw-loop verification", () => {
|
|
|
|
|
})
|
|
|
|
|
writeFileSync(
|
|
|
|
|
oracleTranscriptPath,
|
|
|
|
|
`${JSON.stringify({ type: "tool_result", timestamp: new Date().toISOString(), tool_output: { output: `verified <promise>${ULTRAWORK_VERIFICATION_PROMISE}</promise>` } })}\n`,
|
|
|
|
|
`${JSON.stringify({ type: "assistant", timestamp: new Date().toISOString(), content: `verified <promise>${ULTRAWORK_VERIFICATION_PROMISE}</promise>` })}\n`,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
await hook.event({ event: { type: "session.idle", properties: { sessionID: "ses-oracle" } } })
|
|
|
|
@@ -142,7 +142,7 @@ describe("ulw-loop verification", () => {
|
|
|
|
|
hook.startLoop("session-123", "Build API", { ultrawork: true })
|
|
|
|
|
writeFileSync(
|
|
|
|
|
parentTranscriptPath,
|
|
|
|
|
`${JSON.stringify({ type: "tool_result", timestamp: new Date().toISOString(), tool_output: { output: "done <promise>DONE</promise>" } })}\n`,
|
|
|
|
|
`${JSON.stringify({ type: "assistant", timestamp: new Date().toISOString(), content: "done <promise>DONE</promise>" })}\n`,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
await hook.event({ event: { type: "session.idle", properties: { sessionID: "session-123" } } })
|
|
|
|
@@ -166,7 +166,7 @@ describe("ulw-loop verification", () => {
|
|
|
|
|
hook.startLoop("session-123", "Build API", { ultrawork: true })
|
|
|
|
|
writeFileSync(
|
|
|
|
|
parentTranscriptPath,
|
|
|
|
|
`${JSON.stringify({ type: "tool_result", timestamp: new Date().toISOString(), tool_output: { output: "done <promise>DONE</promise>" } })}\n`,
|
|
|
|
|
`${JSON.stringify({ type: "assistant", timestamp: new Date().toISOString(), content: "done <promise>DONE</promise>" })}\n`,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
await hook.event({ event: { type: "session.idle", properties: { sessionID: "session-123" } } })
|
|
|
|
@@ -213,7 +213,7 @@ describe("ulw-loop verification", () => {
|
|
|
|
|
hook.startLoop("session-123", "Build API", { ultrawork: true })
|
|
|
|
|
writeFileSync(
|
|
|
|
|
parentTranscriptPath,
|
|
|
|
|
`${JSON.stringify({ type: "tool_result", timestamp: new Date().toISOString(), tool_output: { output: "done <promise>DONE</promise>" } })}\n`,
|
|
|
|
|
`${JSON.stringify({ type: "assistant", timestamp: new Date().toISOString(), content: "done <promise>DONE</promise>" })}\n`,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
await hook.event({ event: { type: "session.idle", properties: { sessionID: "session-123" } } })
|
|
|
|
@@ -256,7 +256,7 @@ describe("ulw-loop verification", () => {
|
|
|
|
|
test("#given prior transcript completion from older run #when new ulw loop starts #then old completion is ignored", async () => {
|
|
|
|
|
writeFileSync(
|
|
|
|
|
parentTranscriptPath,
|
|
|
|
|
`${JSON.stringify({ type: "tool_result", timestamp: "2000-01-01T00:00:00.000Z", tool_output: { output: "old <promise>DONE</promise>" } })}\n`,
|
|
|
|
|
`${JSON.stringify({ type: "assistant", timestamp: "2000-01-01T00:00:00.000Z", content: "old <promise>DONE</promise>" })}\n`,
|
|
|
|
|
)
|
|
|
|
|
const hook = createRalphLoopHook(createMockPluginInput(), {
|
|
|
|
|
getTranscriptPath: (sessionID) => sessionID === "ses-oracle" ? oracleTranscriptPath : parentTranscriptPath,
|
|
|
|
@@ -277,7 +277,7 @@ describe("ulw-loop verification", () => {
|
|
|
|
|
hook.startLoop("session-123", "Build API", { ultrawork: true })
|
|
|
|
|
writeFileSync(
|
|
|
|
|
parentTranscriptPath,
|
|
|
|
|
`${JSON.stringify({ type: "tool_result", timestamp: new Date().toISOString(), tool_output: { output: "done <promise>DONE</promise>" } })}\n`,
|
|
|
|
|
`${JSON.stringify({ type: "assistant", timestamp: new Date().toISOString(), content: "done <promise>DONE</promise>" })}\n`,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
await hook.event({ event: { type: "session.idle", properties: { sessionID: "session-123" } } })
|
|
|
|
@@ -295,7 +295,7 @@ describe("ulw-loop verification", () => {
|
|
|
|
|
hook.startLoop("session-123", "Build API", { ultrawork: true })
|
|
|
|
|
writeFileSync(
|
|
|
|
|
parentTranscriptPath,
|
|
|
|
|
`${JSON.stringify({ type: "tool_result", timestamp: new Date().toISOString(), tool_output: { output: "done <promise>DONE</promise>" } })}\n`,
|
|
|
|
|
`${JSON.stringify({ type: "assistant", timestamp: new Date().toISOString(), content: "done <promise>DONE</promise>" })}\n`,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
await hook.event({ event: { type: "session.idle", properties: { sessionID: "session-123" } } })
|
|
|
|
@@ -314,7 +314,7 @@ describe("ulw-loop verification", () => {
|
|
|
|
|
hook.startLoop("session-123", "Build API", { ultrawork: true })
|
|
|
|
|
writeFileSync(
|
|
|
|
|
parentTranscriptPath,
|
|
|
|
|
`${JSON.stringify({ type: "tool_result", timestamp: new Date().toISOString(), tool_output: { output: "done <promise>DONE</promise>" } })}\n`,
|
|
|
|
|
`${JSON.stringify({ type: "assistant", timestamp: new Date().toISOString(), content: "done <promise>DONE</promise>" })}\n`,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
await hook.event({ event: { type: "session.idle", properties: { sessionID: "session-123" } } })
|
|
|
|
@@ -325,7 +325,7 @@ describe("ulw-loop verification", () => {
|
|
|
|
|
hook.startLoop("session-456", "Ship CLI", { ultrawork: true })
|
|
|
|
|
writeFileSync(
|
|
|
|
|
oracleTranscriptPath,
|
|
|
|
|
`${JSON.stringify({ type: "tool_result", timestamp: new Date().toISOString(), tool_output: { output: `verified <promise>${ULTRAWORK_VERIFICATION_PROMISE}</promise>` } })}\n`,
|
|
|
|
|
`${JSON.stringify({ type: "assistant", timestamp: new Date().toISOString(), content: `verified <promise>${ULTRAWORK_VERIFICATION_PROMISE}</promise>` })}\n`,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
await hook.event({ event: { type: "session.idle", properties: { sessionID: "ses-oracle-old" } } })
|
|
|
|
@@ -343,7 +343,7 @@ describe("ulw-loop verification", () => {
|
|
|
|
|
hook.startLoop("session-123", "Build API", { ultrawork: true })
|
|
|
|
|
writeFileSync(
|
|
|
|
|
parentTranscriptPath,
|
|
|
|
|
`${JSON.stringify({ type: "tool_result", timestamp: new Date().toISOString(), tool_output: { output: "done <promise>DONE</promise>" } })}\n`,
|
|
|
|
|
`${JSON.stringify({ type: "assistant", timestamp: new Date().toISOString(), content: "done <promise>DONE</promise>" })}\n`,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
await hook.event({ event: { type: "session.idle", properties: { sessionID: "session-123" } } })
|
|
|
|
@@ -354,7 +354,7 @@ describe("ulw-loop verification", () => {
|
|
|
|
|
hook.startLoop("session-123", "Restarted task", { ultrawork: true })
|
|
|
|
|
writeFileSync(
|
|
|
|
|
oracleTranscriptPath,
|
|
|
|
|
`${JSON.stringify({ type: "tool_result", timestamp: new Date().toISOString(), tool_output: { output: `verified <promise>${ULTRAWORK_VERIFICATION_PROMISE}</promise>` } })}\n`,
|
|
|
|
|
`${JSON.stringify({ type: "assistant", timestamp: new Date().toISOString(), content: `verified <promise>${ULTRAWORK_VERIFICATION_PROMISE}</promise>` })}\n`,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
await hook.event({ event: { type: "session.idle", properties: { sessionID: "ses-oracle-old" } } })
|
|
|
|
@@ -373,13 +373,13 @@ describe("ulw-loop verification", () => {
|
|
|
|
|
hook.startLoop("session-123", "Build API", { ultrawork: true })
|
|
|
|
|
writeFileSync(
|
|
|
|
|
parentTranscriptPath,
|
|
|
|
|
`${JSON.stringify({ type: "tool_result", timestamp: new Date().toISOString(), tool_output: { output: "done <promise>DONE</promise>" } })}\n`,
|
|
|
|
|
`${JSON.stringify({ type: "assistant", timestamp: new Date().toISOString(), content: "done <promise>DONE</promise>" })}\n`,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
await hook.event({ event: { type: "session.idle", properties: { sessionID: "session-123" } } })
|
|
|
|
|
writeFileSync(
|
|
|
|
|
parentTranscriptPath,
|
|
|
|
|
`${JSON.stringify({ type: "tool_result", timestamp: new Date().toISOString(), tool_output: { output: "done <promise>DONE</promise>" } })}\n${JSON.stringify({ type: "tool_result", timestamp: new Date().toISOString(), tool_output: { output: `verified <promise>${ULTRAWORK_VERIFICATION_PROMISE}</promise>` } })}\n`,
|
|
|
|
|
`${JSON.stringify({ type: "assistant", timestamp: new Date().toISOString(), content: "done <promise>DONE</promise>" })}\n${JSON.stringify({ type: "assistant", timestamp: new Date().toISOString(), content: `verified <promise>${ULTRAWORK_VERIFICATION_PROMISE}</promise>` })}\n`,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
await hook.event({ event: { type: "session.idle", properties: { sessionID: "session-123" } } })
|
|
|
|
@@ -409,7 +409,7 @@ describe("ulw-loop verification", () => {
|
|
|
|
|
hook.startLoop("session-123", "Build API", { ultrawork: true })
|
|
|
|
|
writeFileSync(
|
|
|
|
|
parentTranscriptPath,
|
|
|
|
|
`${JSON.stringify({ type: "tool_result", timestamp: new Date().toISOString(), tool_output: { output: "done <promise>DONE</promise>" } })}\n`,
|
|
|
|
|
`${JSON.stringify({ type: "assistant", timestamp: new Date().toISOString(), content: "done <promise>DONE</promise>" })}\n`,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
await hook.event({ event: { type: "session.idle", properties: { sessionID: "session-123" } } })
|
|
|
|
@@ -449,7 +449,7 @@ describe("ulw-loop verification", () => {
|
|
|
|
|
hook.startLoop("session-123", "Build API", { ultrawork: true })
|
|
|
|
|
writeFileSync(
|
|
|
|
|
parentTranscriptPath,
|
|
|
|
|
`${JSON.stringify({ type: "tool_result", timestamp: new Date().toISOString(), tool_output: { output: "done <promise>DONE</promise>" } })}\n`,
|
|
|
|
|
`${JSON.stringify({ type: "assistant", timestamp: new Date().toISOString(), content: "done <promise>DONE</promise>" })}\n`,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
await hook.event({ event: { type: "session.idle", properties: { sessionID: "session-123" } } })
|
|
|
|
@@ -467,7 +467,7 @@ describe("ulw-loop verification", () => {
|
|
|
|
|
|
|
|
|
|
writeFileSync(
|
|
|
|
|
parentTranscriptPath,
|
|
|
|
|
`${JSON.stringify({ type: "tool_result", timestamp: new Date().toISOString(), tool_output: { output: "fixed it <promise>DONE</promise>" } })}\n`,
|
|
|
|
|
`${JSON.stringify({ type: "assistant", timestamp: new Date().toISOString(), content: "fixed it <promise>DONE</promise>" })}\n`,
|
|
|
|
|
)
|
|
|
|
|
writeState(testDir, {
|
|
|
|
|
...hook.getState()!,
|
|
|
|
|