From 6c3458a5ec37a5b69957ad17c84de58984698f25 Mon Sep 17 00:00:00 2001 From: tanaka takashi Date: Tue, 11 Aug 2026 21:44:53 +0900 Subject: Audit and align v1 runtime design --- tests/Agent.Core.Tests/TaskRegistryTests.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests/Agent.Core.Tests/TaskRegistryTests.cs') diff --git a/tests/Agent.Core.Tests/TaskRegistryTests.cs b/tests/Agent.Core.Tests/TaskRegistryTests.cs index 28a2844..7e84dfd 100644 --- a/tests/Agent.Core.Tests/TaskRegistryTests.cs +++ b/tests/Agent.Core.Tests/TaskRegistryTests.cs @@ -17,6 +17,23 @@ public sealed class TaskRegistryTests Assert.True(registry.GetCancellationToken(taskId).IsCancellationRequested); } + [Fact] + public async Task Running_cancel_is_terminal_only_after_runtime_cleanup_transition() + { + var registry = new TaskRegistry(); + TaskSnapshot task = registry.Enqueue("work", null, null); + Assert.True(registry.Transition(task.TaskId, AgentTaskState.Planning)); + Assert.True(registry.Transition(task.TaskId, AgentTaskState.Running)); + + Assert.True(registry.Cancel(task.TaskId)); + Assert.True(registry.GetCancellationToken(task.TaskId).IsCancellationRequested); + Task wait = registry.WaitForTerminalAsync(task.TaskId, CancellationToken.None); + Assert.False(wait.IsCompleted); + + Assert.True(registry.Transition(task.TaskId, AgentTaskState.Cancelled, result: "clean")); + Assert.Equal(AgentTaskState.Cancelled, (await registry.WaitForTerminalAsync(task.TaskId, TestContext.Current.CancellationToken)).State); + } + [Fact] public void NewTaskGetsUniqueTaskAndSessionIds() { -- cgit v1.2.3