fix(sessions): terminalize session on workflow completion

DefaultSessionReducer skipped WorkflowCompletedEvent to avoid terminalizing on freestyle planning's mid-session completion, but that left execution/normal completions stuck ACTIVE forever — headless watchers and approval loops never saw a terminal state. Add workflowId to WorkflowCompletedEvent (defaulted for replay compat), pass graph.id at all completeWorkflow sites, and terminalize to COMPLETED unless it's the freestyle_planning handoff. Correct stale tests that pinned the ACTIVE-forever behavior.
This commit is contained in:
2026-07-02 12:23:39 +04:00
parent c1de2281c8
commit 1a9e1019ec
10 changed files with 58 additions and 16 deletions
@@ -75,7 +75,7 @@ class DefaultSessionReducerTest {
}
@Test
fun `WorkflowCompletedEvent leaves ACTIVE status`() {
fun `WorkflowCompletedEvent flips to COMPLETED status`() {
val state = activeState()
val result = reducer.reduce(
@@ -86,11 +86,11 @@ class DefaultSessionReducerTest {
)
)
assertEquals(SessionStatus.ACTIVE, result.status)
assertEquals(SessionStatus.COMPLETED, result.status)
}
@Test
fun `WorkflowFailedEvent leaves ACTIVE status`() {
fun `WorkflowFailedEvent flips to FAILED status`() {
val state = activeState()
val result = reducer.reduce(
@@ -101,7 +101,7 @@ class DefaultSessionReducerTest {
)
)
assertEquals(SessionStatus.ACTIVE, result.status)
assertEquals(SessionStatus.FAILED, result.status)
}
@Test
@@ -35,7 +35,7 @@ class SessionProjectorTest {
state = projector.apply(state, it)
}
assertEquals(SessionStatus.CREATED, state.status)
assertEquals(SessionStatus.COMPLETED, state.status)
}
@Test