Skip to content

server/course: preserve accepted student access during reconfigure - #304

Merged
williamstein merged 3 commits into
mainfrom
fix/course-student-collaborator-loss
Aug 27, 2026
Merged

server/course: preserve accepted student access during reconfigure#304
williamstein merged 3 commits into
mainfrom
fix/course-student-collaborator-loss

Conversation

@williamstein

@williamstein williamstein commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • preserve an authoritative student account binding when a stale course snapshot temporarily omits account_id
  • defer destructive collaborator cleanup while an active student's identity is unresolved
  • carry explicit student-deletion intent so deliberate roster removals still proceed

Root cause

A student accepted a course email invitation, which added them to the authoritative student project and recorded their account in projects.course. Before the collaborative .course document observed that account ID, a course reconfiguration submitted a stale snapshot without it. The worker treated the student as absent, erased the authoritative binding, and removed their collaborator access. A subsequent direct course purchase then failed its authoritative collaborator check.

This restores the legacy safety invariant that unresolved identity must not cause destructive collaborator cleanup. Once identity resolves, normal cleanup resumes; explicit roster deletion remains destructive.

Remediation scope

This prevents future removals. It intentionally does not bulk-restore historical missing collaborators because some students may have intentionally left their projects.

Validation

  • built src/packages/conat
  • built src/packages/server
  • passed 22 focused PGlite tests covering course admission, worker behavior, and managed-project reconciliation

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Course email invite acceptance can update the authoritative student project before the collaborative course roster observes the account id. A stale reconfiguration snapshot previously erased that binding and removed the newly accepted student.

Preserve a valid authoritative student account binding, defer destructive collaborator cleanup while an active student's identity is unresolved, and carry explicit deletion intent so deliberate roster removals still take effect. Add regression coverage for accepted, unresolved, and deleted student states.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 17e569efb4

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/packages/server/projects/course/reconcile-managed-project.ts Outdated
Resolve student identity directly from the requested or authoritative course binding instead of inferring it from non-manager desired collaborators. Reject conflicting or multiple student bindings and prevent current course managers from being assigned to student projects.

Also reject course student invitation acceptance by an account that already manages the course project, directing instructors to use a separate student account.
Validate account- and email-based student additions against the current course project managers before writing any student records to the collaborative course document. Resolve exact submitted emails in bounded batches and fail closed while collaborator state is unavailable.

When an instructor enters their own address, explain that student testing requires a separate CoCalc account and provide a plus-address example derived from their current email.
@williamstein

Copy link
Copy Markdown
Contributor Author

Added the frontend prevention layer in 4ba06f5. Student enrollment now checks current course-project managers before writing any student row to the collaborative .course document, covering both account IDs and exact submitted email addresses. Entering the current instructor email gives an actionable separate-account message with a derived +1 address example. The guard fails closed while collaborator state is unavailable. Focused frontend tests, frontend lint, and the frontend package typecheck pass.

@williamstein
williamstein merged commit 58260a7 into main Aug 27, 2026
7 checks passed
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