Parent epic
Epic E7: admin matching and assignment (P0) — #44
User story
As an admin, I can reassign a different tutor to an active match — so that if the original tutor becomes unavailable or underperforms, tutoring can continue without interruption.
Background
From docs/MVP.md section 10.3:
"reassign tutor with history tracking (at least a log entry)"
From docs/OPS.md section 9 (tutor quality monitoring):
"if 3 incidents: pause assignments and consider replacement"
Reassignment is rare but must be possible. The history must be kept (audit log) so the admin knows who taught the student in each period.
Acceptance criteria
Audit log for reassignment
await admin.from('audit_logs').insert([{
actor_user_id: adminUserId,
action: 'tutor_reassigned',
entity_type: 'match',
entity_id: matchId,
details: {
old_tutor_user_id: previousTutorId,
new_tutor_user_id: newTutorId,
reason: reason, // optional admin note
}
}])
RLS impact on sessions after reassignment
Sessions have an RLS policy that allows the tutor_user_id of the match to SELECT. After reassignment, the new tutor's ID is now the matches.tutor_user_id, so:
- New tutor can see all sessions via the sessions RLS policy (which joins via matches)
- Old tutor loses SELECT access to those sessions
This is handled automatically by the RLS policy — no additional code needed.
Dependencies
References
docs/MVP.md — section 10.3 (admin — reassign tutor with history)
docs/OPS.md — section 9 (tutor quality monitoring), section 8.3 (escalation when tutor has repeated issues)
docs/ARCHITECTURE.md — section 6.6 (audit log), section 6.4 (matches RLS)
Parent epic
Epic E7: admin matching and assignment (P0) — #44
User story
As an admin, I can reassign a different tutor to an active match — so that if the original tutor becomes unavailable or underperforms, tutoring can continue without interruption.
Background
From
docs/MVP.mdsection 10.3:From
docs/OPS.mdsection 9 (tutor quality monitoring):Reassignment is rare but must be possible. The history must be kept (audit log) so the admin knows who taught the student in each period.
Acceptance criteria
matches.tutor_user_idupdated to new tutor's user IDaction = 'tutor_reassigned',details = { old_tutor_id, new_tutor_id }matches.statusstays unchanged (usuallyactive)Audit log for reassignment
RLS impact on sessions after reassignment
Sessions have an RLS policy that allows the
tutor_user_idof the match toSELECT. After reassignment, the new tutor's ID is now thematches.tutor_user_id, so:This is handled automatically by the RLS policy — no additional code needed.
Dependencies
matchestable and initial assignment must existReferences
docs/MVP.md— section 10.3 (admin — reassign tutor with history)docs/OPS.md— section 9 (tutor quality monitoring), section 8.3 (escalation when tutor has repeated issues)docs/ARCHITECTURE.md— section 6.6 (audit log), section 6.4 (matches RLS)