Skip to content

fix(shifts): persist per-shift assignments and unify effective roster resolution - #216

Draft
theosiemensrhodes wants to merge 4 commits into
mainfrom
fix/neuron-n04-assignment-history
Draft

theosiemensrhodes wants to merge 4 commits into
mainfrom
fix/neuron-n04-assignment-history

Conversation

@theosiemensrhodes

@theosiemensrhodes theosiemensrhodes commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Shift rosters were rebuilt from current schedule membership, so later schedule edits changed historical rosters and hid attendance. Reminder, cancellation, and coverage eligibility queries also disagreed about substitutions.

Change

Persist per-shift volunteer and instructor base assignments. Schedule roster edits update only future, non-canceled shifts, retaining early attendance and slots already transferred to covering volunteers. Shift reads, visibility, reminders, cancellation audiences, and overlapping coverage eligibility share the effective volunteer rule: base + resolved incoming coverage - resolved outgoing coverage > 0. Open and withdrawn requests do not transfer membership.

Decision: choose per-shift snapshots over effective-dated schedule assignments because shifts are already materialized on publication. This preserves existing join-table keys and avoids interval splitting/range joins; resolved coverage remains the substitution source. The shared queries accept database transactions for coverage-transition callers. Hydration reuses loaded coverage records, conflict checks reuse the SQL membership predicate, and schedule removal withdraws obsolete requests in one query. Shift creation persists the shift and its snapshots atomically; early check-in locks the shift and rechecks membership before inserting attendance. Coverage labels describe remaining net incoming slots. Re-adding a released base member preserves the accepted substitute on that occurrence rather than granting a second slot.

Verification

  • Lint: passed (0 errors, 270 existing warnings); route type generation and typecheck passed.
  • Drizzle migration metadata check and diff whitespace check passed.
  • All 73 unit tests and 169 integration tests passed using a verified, unique disposable local Postgres database.
  • Regression coverage includes historical roster/attendance edits, substitutions, withdrawals, overlapping coverage, round-trip removal, canceled/early-check-in preservation, SQL migration backfill for chains and round trips, standalone creation rollback, and a schedule-removal/check-in race.

Deployment notes

Apply 0013_add_shift_assignments.sql before deploying the updated services. It creates assignment tables and backfills from current schedules, attendance, and resolved coverage origins. Membership erased before this migration without attendance or coverage evidence cannot be recovered; historical membership inferred from current schedules is necessarily approximate. Legacy data can also leave original base membership indistinguishable from coverage followed by a schedule addition; request creation order is a reconstruction heuristic, not fulfillment chronology.

Coverage transition atomicity and the existing unassign operation's transfer-history mutation remain follow-up work. This PR supplies the shared assignment contract for that work.

Signed-off-by: Theo Siemens-Rhodes <112789743+theosiemensrhodes@users.noreply.github.com>
Signed-off-by: Theo Siemens-Rhodes <112789743+theosiemensrhodes@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant