feat(data): add task numbers schema, allocator, and backfill migration
TaskEntity.Number is a global, monotonically increasing, never-reused integer (displayed as #123), allocated from AppSettingsEntity.NextTaskNumber via a single UPDATE...RETURNING statement rather than MAX(number)+1, which would reissue a deleted task's number. Both insert paths (TaskRepository. AddAsync and CreateChildAsync) route through the new TaskNumberAllocator, with a bounded retry on a unique-index collision. One migration adds the columns, backfills existing rows in creation order, and creates the unique index afterwards. Data-layer only; MCP/UI wiring is later slices.
This commit is contained in:
@@ -6,6 +6,11 @@ public sealed class AppSettingsEntity
|
||||
|
||||
public int Id { get; set; } = SingletonId;
|
||||
|
||||
// Persistent counter backing TaskNumberAllocator: the next task number to hand out. Lives on
|
||||
// the singleton row so allocation is a single atomic UPDATE...RETURNING in the task's own
|
||||
// insert transaction, never a MAX(number)+1 recompute.
|
||||
public int NextTaskNumber { get; set; } = 1;
|
||||
|
||||
public string DefaultClaudeInstructions { get; set; } = string.Empty;
|
||||
public string DefaultModel { get; set; } = "sonnet";
|
||||
public int DefaultMaxTurns { get; set; } = 40;
|
||||
|
||||
@@ -22,6 +22,10 @@ public enum PlanningPhase
|
||||
public sealed class TaskEntity
|
||||
{
|
||||
public required string Id { get; init; }
|
||||
// Global, monotonically increasing, never-reused display/lookup handle shown as `#123`.
|
||||
// Allocated by TaskNumberAllocator from AppSettingsEntity.NextTaskNumber -- never MAX(number)+1,
|
||||
// which would reissue a deleted task's number. The GUID Id stays the real identity everywhere else.
|
||||
public int Number { get; set; }
|
||||
public required string ListId { get; init; }
|
||||
public required string Title { get; set; }
|
||||
public string? Description { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user