Skip to content

Milestone 2 slice 3: enrollment pinning and minimal user creation #19

Closed

Description

@TusanHomichi

Existing issue check

  • I searched open and closed issues for this work.

Problem or outcome

Slices 1 (#14/#15) and 2 (#16/#17) delivered versioned program configuration and its authoring interface. The milestone exit — "a complete invented training program can be published, enrolled, exported, and reproduced" — still lacks enrollment, and enrolling needs trainees to exist: Milestone 1 only creates administrators, and full user administration is Milestone 3. This issue is the work record for the last Milestone 2 slice, with the owner-approved scoping: enrollment pinning plus a deliberately minimal user-creation path, leaving user administration proper to Milestone 3.

After merge, an administrator creates a trainee (username and display name; the initial credential is a one-time reset code through the existing, tested reset mechanism — no new secret paths), and anyone holding assign_training enrolls that trainee in a published program version. The database itself refuses enrollment in a draft.

Scope

In scope:

  • migration 0005: enrollment (trainee user, pinned program_version, enrolled_at/by), with a database trigger refusing enrollment in an unpublished version and a uniqueness constraint per (user, version) — re-enrollment semantics arrive with Milestone 3 lifecycle history, which may relax it;
  • enrollments domain service gated on assign_training, appending attributable audit events (trainee as the user subject, the enrollment row as the domain subject);
  • minimal user creation gated on manage_users: create the user with an unusable random credential, then issue a standard administrator-origin reset code — sign-in happens through the existing reset flow;
  • API: create/list users, create/list enrollments per version, stable refusal codes (not_published, already_enrolled, username_taken, plus the existing vocabulary);
  • interface: a create-user card on the status page (existing manage_users section) showing the one-time code; an Enrollments panel on published version pages with a roster picker;
  • tests: service and API refusals, the draft-enrollment raw-SQL trigger proof, and the Milestone 2 exit test — a complete invented program published, a trainee enrolled, the version exported, reproduced byte-identically on a clean installation, published and enrolled there too; the browser e2e extends to create a trainee and enroll them.

Out of scope:

  • enrollment lifecycle: phase history, version changes with reason, withdrawal, concurrent-enrollment policy (Milestone 3);
  • user administration beyond creation: editing, capability grant UI, deactivation (Milestone 3);
  • assignment-scoped record access (Milestone 3).

Acceptance criteria

  • An administrator can create a trainee from the interface and hand them a one-time reset code; the trainee's first sign-in goes through the existing reset flow.
  • assign_training holders can enroll a trainee in a published version and see the version's enrollees; others are refused with capability_required.
  • Enrolling in a draft fails at the service (not_published) and, via raw SQL, at the database.
  • Duplicate enrollment refuses with already_enrolled.
  • Enrollment appends an attributable audit event.
  • The Milestone 2 exit test passes: published → enrolled → exported → reproduced on a clean installation.
  • All repository gates pass (fmt, clippy pedantic, workspace tests, npm run check/build, e2e where Chromium is available).

Expected proof

  • cargo test --workspace (with web/ built first)
  • npm run check, npm run build, npm run e2e in web/

Related roadmap, decisions, or issues

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