Feat: Re-key task_metadata/task_checklists per user (T433369 phase 1)

Working-state tables were keyed (wiki_url, task_key) with no username, so a wiki's users shared and overwrote each other's in-progress selections and checklists — blocking per-user repeatability for create-essential-article. Move both tables to UNIQUE(wiki_url, task_key, username).

  • server/db/index.js: two idempotent boot-migration blocks (tell: !hasColumn(...,'username')) rebuilding each table to the 3-column key, copying the established task_completions run_count table-rebuild pattern (BEGIN; CREATE _new; INSERT ... SELECT ..., NULL as username; DROP; RENAME; recreate index; COMMIT). The 5 DB fns (get/saveTaskChecklist, get/saveTaskMetadata, deleteTaskState) gain a username param. deleteTaskState now scopes every delete by username and also clears the task_verifications ledger row so the same article can be re-tested.
  • server/db/schema.sql: task_metadata/task_checklists defined in the new shape so fresh DBs match the migrated shape (kept in sync with the boot block).
  • server/routes/tasks.js: thread req.session.user?.name into the metadata/checklist/delete routes and getEssentialArticleCompletionStatus.

Legacy rows migrate with username=NULL and become unreadable, resetting only working (metadata/checklist) state for the per-user tasks; completion rows survive. Caveat: create-essential-article's DISPLAYED status is still metadata-gated at this phase, so a completed card reads "not started" until the verification/backfill phase lands — therefore this migration MUST NOT reach production ahead of that phase (the T433369 stack deploys together).

Co-Authored-By: Claude Opus 4.8 Bug: T433369

Closes T433369

Merge request reports

Loading