Skip to content

Enforce the course-cohort invariant across imports and existing rows #295

Description

@alexeygrigorev

Goal

Every persisted Course has at least one Cohort. A course with no scheduled offering uses one synthetic, open-ended self_paced cohort rather than a fabricated schedule.

C5.1a already defines this model contract. The course parser currently creates an implicit self-paced cohort for source repositories without a cohorts/ directory, and the curriculum service can create one lazily. The remaining gap is guaranteeing the invariant for pre-existing rows and courses created through Studio or another package-owned path.

Scope

  • Backfill existing Course rows with no cohorts.
  • Apply the same guarantee to Studio and package-owned course creation paths.
  • Preserve the parser/import behavior for cohortless source repositories and prove re-import remains idempotent.
  • Keep the generated cohort explicitly self-paced: stable self-paced slug, mode=self_paced, and no start or end date. Do not invent registration or event dates.

Acceptance criteria

  • An additive data migration creates one self-paced cohort for every existing course with zero cohorts. Courses that already have one or more cohorts remain unchanged, and the migration does not alter enrollment, progress, source provenance, or dated cohort rows.
  • Creating a course through Studio or another package-owned creation endpoint cannot leave it without a cohort. If no cohort is supplied, the course receives the synthetic self-paced cohort in the same transaction.
  • The curriculum importer persists the implicit self-paced cohort for a source course with no cohorts/ directory; re-import creates no duplicate and keeps the cohort stable.
  • Package operator flows cannot remove a course's last cohort and leave a cohortless course; they either reject that removal or create the fallback atomically.
  • Generated self-paced cohorts are represented without schedule dates or scheduled-offering registration/event details in course and learner surfaces.
  • Tests cover the migration with both cohortless and already-cohorted courses, importer re-import, Studio/API creation, and last-cohort removal.
  • Package quality gates pass, and both consuming sites run their own affected checks against the package change, with the three results reported separately.

Related work

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions