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.
3.8 KiB
3.8 KiB
ClaudeDo.Data
Shared data layer: models, repositories, SQLite infrastructure, and git operations.
Models
- TaskEntity — Id, ListId, Title, Description, Status (
Idle|Queued|Running|Done|Failed|Cancelled), PlanningPhase (None|Active|Finalized— parent-only), BlockedByTaskId (nullable FK to predecessor in a chain), ScheduledFor, Result, LogPath, timestamps, CommitType, Model / SystemPrompt / AgentPath (nullable overrides), IsStarred, IsMyDay, Notes, ParentTaskId, PlanningSessionId, PlanningSessionToken, PlanningFinalizedAt, CreatedBy. Legacy valuesManual/Planning/Planned/Draft/Waitingwere retired; existing rows backfill automatically via theRetireLegacyTaskStatusmigration. - ListEntity — Id, Name, WorkingDir, DefaultCommitType, CreatedAt
- ListConfigEntity — ListId (PK, 1:1 with list), Model, SystemPrompt, AgentPath (all nullable)
- TagEntity — Id (autoincrement), Name (unique)
- WorktreeEntity — TaskId (PK, 1:1 with task), Path, BranchName, BaseCommit, HeadCommit, DiffStat, State (Active|Merged|Discarded|Kept)
- TaskRunEntity — per-run record (session_id, tokens, turns, result, structured output, exit code, log path)
- SubtaskEntity, AppSettingsEntity, AgentInfo — existing helpers / settings / record for scanned agent files
Repositories
All repositories use EF Core LINQ queries via ClaudeDoDbContext. Exception: TaskRepository.GetNextQueuedAgentTaskAsync uses FromSqlRaw for atomic queue claim.
- TaskRepository — CRUD, planning helpers (
CreateChildAsync,SetPlanningStartedAsync,DiscardPlanningAsync,TryCompleteParentAsync,UpdateChildAsync), tag management (GetEffectiveTagsAsync— union of task + list tags),UpdateAgentSettingsAsync(model / system-prompt / agent-path overrides). Status-mutation primitivesMarkRunningAsync/MarkDoneAsync/MarkFailedAsync/FlipAllRunningToFailedAsyncareinternaland called only byTaskStateServicein the worker.CreateChildAsyncproduces children withStatus=Idle, PlanningPhase=None; once their parent'sPlanningPhasebecomesFinalized, the chain coordinator queues them. - ListRepository — CRUD, tag junction management,
GetConfigAsync/SetConfigAsync(upsert) /DeleteConfigAsyncforlist_config - TagRepository —
GetOrCreateAsync(idempotent) - WorktreeRepository — CRUD,
UpdateHeadAsync,SetStateAsync - TaskRunRepository, SubtaskRepository, AppSettingsRepository
Infrastructure
- ClaudeDoDbContext — EF Core DbContext; configured with WAL mode and foreign keys via
UseSqliteoptions - IDbContextFactory — registered in DI; used by singleton consumers (e.g. Worker hosted service)
- Paths — expands
~and%USERPROFILE%, resolves relative paths. App root:~/.todo-app - AppSettings — loads
~/.todo-app/ui.config.json(DbPath, SignalRUrl)
Git
- GitService — async wrapper around git CLI (ProcessStartInfo, no shell). Operations: worktree add/remove, add all, commit (stdin for message), merge ff-only, rev-parse, diff-stat, has-changes, is-git-repo
Schema
Tables: lists, tasks, tags, list_tags, task_tags, worktrees, list_config, task_runs, subtasks, app_settings. Managed by EF Core migrations in the Migrations/ folder. Seed data: tags "agent" and "manual". The tasks table holds status, planning_phase (default none), and blocked_by_task_id (FK to tasks.id, ON DELETE SET NULL).
Conventions
- Enum <-> string mapping via EF Core
ValueConverter(configured inIEntityTypeConfiguration<T>) - Entity configurations live in the
Configuration/folder - Primary keys are
init-only strings (GUIDs assigned at creation) - All methods are async with CancellationToken where applicable