Skip to content

training(lifecycle): assignments, enrollment events, and phase history - #24

Merged
TusanHomichi merged 4 commits into
mainfrom
claude/milestone-2-org-rename-q8b2q8
Aug 28, 2026
Merged

training(lifecycle): assignments, enrollment events, and phase history#24
TusanHomichi merged 4 commits into
mainfrom
claude/milestone-2-org-rename-q8b2q8

Conversation

@TusanHomichi

Copy link
Copy Markdown
Member

Primary Issue

Closes #23
Refs #22

Problem And Outcome

Milestone 3 slice 1: the access and lifecycle substrate the session/draft slices build on, per the settled design in #22 and ADR 0008 (added here). After merge: coordinators create role-bundled users, assign trainers to enrollments (with an in-app notice), record enrollment lifecycle events and effective-dated phase history validated against the pinned transition graph — and assigned trainers holding view_assigned_records read exactly their trainees' history through the new enrollment page.

Changes

  • Migration 0006_lifecycle.sql: user profile fields (employee identifier, title); training_assignment; append-only enrollment_event and phase_event with database triggers — append-only enforcement, event-mediated enrollment version changes (replacing 0005's blanket repoint refusal), published-version pinning on repoint, per-kind shape checks, effective ≤ recorded, and phase references pinned to the enrollment's version (domain invariant 5)
  • Capabilities author_evaluation, review_evaluation, view_assigned_records; Trainer and Coordinator bundles; RoleBundle consumed at user creation
  • New lifecycle module: status/current-phase/paused derived from the streams; enrollment events (withdraw, complete, reinstate, version change with reason); phase events with transition-graph validation (advance follows advance/skip edges, return follows remediation, restart follows restart, entry from nowhere), pause state machine, required reasons, and append-in-effective-order backfill rules; composed enrollment detail gated by capability + assignment scope
  • New assignments module: create/end with attribution, assignment_created notice to the trainer in the same transaction, audit events, and the trainer's own active-assignment list
  • New training_http handler group; user creation extended with role and profile fields; notify_user for user-targeted workflow notices
  • Web: role/profile-aware user creation, "My trainees" panel, enrollee links, and the enrollment page (assignments, phase timeline with graph-aware target picker and effective backfill, lifecycle actions and version change)
  • ADR 0008 encoding the settled Milestone 3 design (all five Milestone 3 design: sessions, drafts, and attribution (owner decisions needed) #22 decisions as adopted)
  • Tests: tests/lifecycle.rs (database invariants, capability/scope gates, graph and pause rules, effective-order backfill, API round trips) and web/e2e/lifecycle.spec.ts (browser flow from role-bundled trainer creation through scoped read-only trainee view)

Scope

Verification

  • Listed the exact verification commands run below
  • Added or updated tests when behavior changed
  • Added or updated an ADR when a durable decision changed
  • All fixtures and examples are invented; no real agency data
- cargo fmt --check
- cargo clippy --workspace --all-targets -- -D warnings
- cargo test --workspace            (66 passed, 0 failed)
- npm run check                     (web/: 0 errors, 0 warnings)
- npm run build                     (web/)
- npm run e2e                       (web/: 3 passed, includes new lifecycle.spec.ts)

Review And Merge Notes

  • Review focus: the 0006 trigger set (event-mediated repoint, pinned-version phase references), the effective-order backfill contract in lifecycle::record_phase_event, and the read gate in lifecycle::may_read
  • User or operator impact: existing installations migrate additively; the enrollment page and "My trainees" appear for holders of the new capabilities; user creation gains role and profile fields (defaults preserve the old behavior)

🤖 Generated with Claude Code

https://claude.ai/code/session_01DNP3dkn9c84v2YoNwx7KTg


Generated by Claude Code

Add the Milestone 3 slice 1 substrate per ADR 0008: the expanded
capability vocabulary with Trainer and Coordinator bundles and profile
fields at user creation; durable trainer-to-enrollment assignments with
assignment_created notices and assignment-scoped reads; append-only
enrollment lifecycle events with database-mediated version changes; and
effective-dated phase history validated against the pinned transition
graph — with the enrollment page, the assigned-trainee view, and browser
e2e proof.

Closes #23
Refs #22

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DNP3dkn9c84v2YoNwx7KTg
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-28T23:43:11.401054Z 8b1f04e New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: c8be8c8c22

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/consolebook-server/src/training_http.rs
Comment thread crates/consolebook-server/src/lifecycle.rs
Comment thread crates/consolebook-server/src/lifecycle.rs Outdated
Comment thread crates/consolebook-server/src/lifecycle.rs Outdated
Address the four Codex review findings, each verified against the code:

- gate /api/assignments/mine on view_assigned_records, the same
  capability every other scoped read of trainee identity takes;
- stamp each phase event with the pin epoch (the latest version-change
  event id, database-enforced) and derive current phase and pause only
  from the current epoch, so state never resurrects across a version
  change — even back to a previously pinned version;
- refuse version changes that leave the enrollment's continuing program
  (different_program); and
- refuse version changes onto a version the trainee already has another
  enrollment for (already_enrolled) instead of surfacing the UNIQUE
  violation as a 500.

Migration 0006 is amended in place; it has never shipped beyond this
branch.

Refs #23

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DNP3dkn9c84v2YoNwx7KTg

@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: f3c8f98743

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/consolebook-server/src/assignments.rs
An assignment exists to grant scoped reads, and its notice names the
trainee — so a user without view_assigned_records is not assignable.
Refused as trainer_lacks_capability; ADR 0008 states the rule.

Refs #23

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DNP3dkn9c84v2YoNwx7KTg

@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: d676acdea0

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/consolebook-server/src/lifecycle.rs
Comment thread web/src/routes/enrollments/[id]/+page.svelte
Comment thread crates/consolebook-server/src/lifecycle.rs Outdated
…ckers

Address the third Codex round, each finding verified:

- a phase event cannot take effect before the version change that
  opened its epoch was recorded — refused as out_of_order, so the
  stream never claims movement through a version the enrollment did
  not yet pin;
- the enrollment detail reads everything, assignments included, from
  one database snapshot so a concurrent write cannot mix epochs on the
  page; and
- the roster now carries each user's held capabilities, and the
  assignment picker offers only view_assigned_records holders instead
  of discovering ineligibility by refusal.

Refs #23

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DNP3dkn9c84v2YoNwx7KTg

@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: 8b1f04e340

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/consolebook-server/src/lifecycle.rs
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.

Milestone 3 slice 1: capabilities, assignments, and enrollment lifecycle

2 participants