refactor(data): retire legacy TaskStatus values and backfill existing rows
Slice 6 of the worker state and queue consolidation refactor. * Drop Manual, Planning, Planned, Draft, Waiting from the TaskStatus enum and from the EF value converter; only the lifecycle values remain (Idle, Queued, Running, Done, Failed, Cancelled). * Add migration RetireLegacyTaskStatus that rewrites existing rows: manual/draft -> idle, planning -> idle+planning_phase=active, planned -> idle+planning_phase=finalized, waiting -> queued+blocked_by derived from sort_order via a CTE with LAG(). * Reroute every call site that compared/set legacy values to the new three-field model (Status + PlanningPhase + BlockedByTaskId), including the planning repo helpers, MCP services, the planning chain coordinator, and the UI view-models. TaskRowViewModel now exposes PlanningPhase to drive the planning badge. * Refresh Worker/CLAUDE.md and Data/CLAUDE.md, the docs/plan.md status section, and the planning verification notes in docs/open.md.
This commit is contained in:
@@ -37,7 +37,8 @@ public sealed class TaskRepositoryParentCompletionTests : IDisposable
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
ListId = listId,
|
||||
Title = "p",
|
||||
Status = TaskStatus.Planned,
|
||||
Status = TaskStatus.Idle,
|
||||
PlanningPhase = PlanningPhase.Finalized,
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
CommitType = "chore",
|
||||
};
|
||||
@@ -102,35 +103,37 @@ public sealed class TaskRepositoryParentCompletionTests : IDisposable
|
||||
await _tasks.TryCompleteParentAsync(parent.Id);
|
||||
|
||||
var loaded = await _tasks.GetByIdAsync(parent.Id);
|
||||
Assert.Equal(TaskStatus.Planned, loaded!.Status);
|
||||
Assert.Equal(TaskStatus.Idle, loaded!.Status);
|
||||
Assert.Equal(PlanningPhase.Finalized, loaded.PlanningPhase);
|
||||
Assert.Null(loaded.FinishedAt);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TryCompleteParentAsync_ChildStillDraft_ParentStaysPlanned()
|
||||
public async Task TryCompleteParentAsync_ChildStillIdle_ParentStaysFinalized()
|
||||
{
|
||||
var listId = await ListAsync();
|
||||
var parent = await PlannedParentAsync(listId);
|
||||
await ChildAsync(listId, parent.Id, TaskStatus.Done);
|
||||
await ChildAsync(listId, parent.Id, TaskStatus.Draft);
|
||||
await ChildAsync(listId, parent.Id, TaskStatus.Idle);
|
||||
|
||||
await _tasks.TryCompleteParentAsync(parent.Id);
|
||||
|
||||
var loaded = await _tasks.GetByIdAsync(parent.Id);
|
||||
Assert.Equal(TaskStatus.Planned, loaded!.Status);
|
||||
Assert.Equal(PlanningPhase.Finalized, loaded!.PlanningPhase);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TryCompleteParentAsync_ParentIsNotPlanned_NoChange()
|
||||
public async Task TryCompleteParentAsync_ParentIsNotFinalized_NoChange()
|
||||
{
|
||||
var listId = await ListAsync();
|
||||
var parent = await PlannedParentAsync(listId);
|
||||
await _ctx.Database.ExecuteSqlRawAsync("UPDATE tasks SET status = 'planning' WHERE id = {0}", parent.Id);
|
||||
await _ctx.Database.ExecuteSqlRawAsync(
|
||||
"UPDATE tasks SET planning_phase = 'active' WHERE id = {0}", parent.Id);
|
||||
await ChildAsync(listId, parent.Id, TaskStatus.Done);
|
||||
|
||||
await _tasks.TryCompleteParentAsync(parent.Id);
|
||||
|
||||
var loaded = await _tasks.GetByIdAsync(parent.Id);
|
||||
Assert.Equal(TaskStatus.Planning, loaded!.Status);
|
||||
Assert.Equal(PlanningPhase.Active, loaded!.PlanningPhase);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user