Skip to content

Finish the status → desiredStatus/observedStatus migration #66

Description

@pablopunk

Context

projects.status is deprecated (comment at src/server/db/schema.ts:71: "Deprecated: use desired_status instead. Kept for backward compatibility") in favor of desiredStatus + observedStatus (schema.ts:86-96), but at commit 3531916 the old column is still read and written in at least:

  • src/server/projects/projects.db.ts:61ne(projects.status, "deleting") filter; :97-101updateProjectStatus() dual-writes status and desiredStatus.
  • src/server/projects/sessionDescription.ts:37 — reads project.status === "deleting".
  • src/server/reconciliation/reconcile.ts:151,156 — groups metrics by projects.status.
  • src/pages/api/system/health.ts:22-29 — groups project counts by projects.status and reports old-enum buckets (starting, stopping, error) in the health payload.

The dual model means every writer must keep two fields coherent, and consumers disagree on which is authoritative.

What to do

  1. Migrate each reader to desiredStatus/observedStatus semantics (the mapping for "deleting" filters is desiredStatus = "deleting"). For the health/reconcile metric groupings, decide which dimension is actually wanted (probably both: desired and observed counts).
  2. Remove the dual-write in updateProjectStatus() once no readers remain.
  3. Drop the status column via a Drizzle migration (pnpm drizzle:generate → migration file in drizzle/; the repo uses generated migrations — check drizzle/ for the existing pattern). Note any external consumers of /api/system/health's JSON shape (the monitor UI in src/components/monitor/) and update them together.

Search command to find all remaining usages

grep -rn "projects.status\|project.status\|\.status ===" src/ --include='*.ts' --include='*.astro' --include='*.tsx'

(Filter out unrelated .status hits on jobs/responses.)

Acceptance criteria

  • No source file reads or writes projects.status; column dropped by a migration.
  • /api/system/health and the monitor page still render correct project counts.
  • Reconciliation summary logs still report per-status counts.
  • pnpm check passes.

Risk

Behavioral drift between old status and new fields during the transition — migrate readers one PR-reviewable group at a time and verify the "deleting" exclusion still hides deleting projects from the dashboard.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions