headless_lms_credit_registration/lib.rs
1//! The credit registration pipeline: the phases that take a course module completion to a credit
2//! in Sisu through Suotar, the worker loops that run them, and the account-linking actions an
3//! admin or teacher sets off by hand.
4//!
5//! Modules:
6//! - `runtime`: composition. The worker loop, the one-iteration dispatcher and the manual actions
7//! build a study registry and hand it to a use case.
8//! - `use_cases`: one module per phase, and `account_linking` for the linking mail resend. They
9//! claim rows, ask the study registry, decide and write, calling the models crate directly.
10//! - `registry`: the study registry as use cases see it: the `StudyRegistry` port a phase asks, the
11//! `InteractiveStudyRegistry` a manual action asks, their requests and their answers.
12//! - `workflow`: the claim, the decision and its guarded write, and the accounting every phase
13//! shares.
14//! - `phase`: which phases exist, which process owns each, and what each may be narrowed to.
15//!
16//! Dependencies point from `runtime` to `use_cases` to `registry` and `workflow`, and from
17//! `workflow` to `registry`. `runtime::suotar` implements both registry traits and is the only code
18//! that names Suotar's wire types and codes or sends through its client; the rest of `runtime` only
19//! builds and passes the client, and nothing outside `runtime` can reach it.
20//!
21//! Where to look:
22//! - phase list, spec, scope support, owning process: `phase.rs`
23//! - one iteration's lifecycle and the phase dispatch: `runtime/dispatch.rs`
24//! - worker loops: `runtime/worker_loop.rs`
25//! - study registry operations: `registry/`
26//! - Suotar encoding, decoding, limiter and breakers: `runtime/suotar/`, what each Suotar item code
27//! means in `runtime/suotar/codes.rs`, and the adapter's contract tests in
28//! `runtime/suotar/contract_tests.rs`
29//! - what each move does to a row (state, error code, admin flag, backoff, timeline line): models'
30//! `library::credit_registration::outcomes`
31//! - batch phase lifecycle (claim, send, split, apply, shutdown): `use_cases/batch_flow.rs`
32//! - a decision and writing it to its row: `workflow/decision.rs`
33//! - import: `use_cases/import/`
34//! - enrolment resolution: `use_cases/resolve_enrolments/`
35//! - verification: `use_cases/verify/`
36//! - roster listing and account-linking mails: `use_cases/enrolment_discovery/`
37//! - mail queue phases: `use_cases/link_emails.rs`, `use_cases/student_notifications.rs`, sharing
38//! `use_cases/mail_queue.rs`
39//! - manual account-linking actions: `runtime/manual.rs`, and the resend in
40//! `use_cases/account_linking.rs`
41//! - the admin "materialize now" button: [`materialize_now`], the `materialize` phase's own body
42//! - an iteration's error: `error.rs`; what reaches the admin Errors page: `error_reports.rs`
43//!
44//! Both the worker loops and the test tick endpoint go through [`run_phase_once`], so a phase cannot
45//! behave differently depending on who ran it.
46
47#[macro_use]
48extern crate tracing;
49
50pub mod error;
51mod error_reports;
52mod phase;
53mod registry;
54mod runtime;
55#[cfg(test)]
56mod test_fixtures;
57mod use_cases;
58mod workflow;
59
60pub use phase::{CreditRegistrationPhase, PhaseSpec, ScopeSupport, WorkerProcess};
61pub use runtime::{
62 PhaseContext, PhaseSkipReason, PhaseTick, Runner, is_waiting_item, run_phase_once, worker_loop,
63};
64pub use use_cases::materialize::{Materialized, materialize_now};
65
66/// The account-linking actions an admin or a teacher sets off by hand, what they answer, and the
67/// roster listing a student's own visit books.
68pub mod account_linking {
69 pub use crate::registry::{PersonLookupError, RegistryPerson};
70 pub use crate::runtime::{ManualActionContext, look_up_person, resend_linking_mail_for_target};
71 pub use crate::use_cases::account_linking::{RateCapOverride, ResendAttempt, ResendOutcome};
72 pub use crate::use_cases::enrolment_discovery::book_listing_for_unlinked_student;
73}
74
75/// What the dashboard and the test controls read of the study registry, or reset: its circuit
76/// breakers and limiter, and the Suotar endpoints each phase calls.
77pub mod registry_health {
78 pub use crate::runtime::{
79 endpoints_paused_by, is_waiting_to_probe, max_study_registry_wait, reset_rate_limits,
80 };
81}