Expand description
The thirteen credit-registration pipeline phases and the one-iteration dispatcher.
Both the worker loops and the test tick endpoint go through run_phase_once, so a phase cannot
behave differently depending on who ran it.
Modulesยง
- breaker
- The circuit breaker the study-registry phases share within one worker process.
- config_
validation ๐ - The
config-validationphase: the daily pass over every Suotar-enabled moduleโs configuration. - enrolment_
discovery ๐ - The
enrolment-discoveryphase: who the study registry says is on the course. - import ๐
- The
importphase: the one call that creates something in the study registry. - ledger_
snapshot ๐ - The
ledger-snapshotphase: the dayโs queue-depth snapshot for every ledger state. - link_
emails ๐ - The
link-emailsphase: turning a claimed mail slot into a queued message. - linking_
mail_ resend - Re-running the account-linking send path for one person on one course.
- product_
token_ ๐refresh - The
product-token-refreshphase: keeping the open university product access tokens current. - resolve_
enrolments ๐ - The
resolve-enrolmentsphase: which enrolment the attainment belongs to, and what we will send. - retention_
sweep ๐ - The
retention-sweepphase: the call logโs 90-day window and the expired linking tokens. - student_
notifications ๐ - The
student-notificationsphase: the only thing that queues a student mail about a credit registration. - verify ๐
- The
verifyphase: asking the study registry what became of a submission. - worker_
loop - The loop both credit registration workers run.
Structsยง
- Outcome
Event ๐ - The audit half of applying an outcome. Both bodies are scrubbed on the way into the event row.
- Phase
Context - Everything a phase iteration needs from its caller: the worker loop or the test tick endpoint.
- Phase
Scope - Which rows one iteration may touch. Which rows a phase iteration may touch. Empty means every row, which is what production runs; a narrowed scope lets a test drive the pipeline for its own course on a shared database.
- Prepared ๐
- What one iteration of a
SuotarBatchPhasesettled before it sent anything. - Scope
Support - Which of the scopeโs dimensions a phaseโs claim query can apply. Declared rather than assumed, so a phase added later cannot quietly ignore a scope and sweep the whole database.
- Template
Cache ๐ - One template lookup per type and language per iteration rather than per mail.
Nonemeans no template exists, which a mail phase reports rather than failing the batch it was found in.
Enumsยง
- Credit
Registration Phase - A pipeline phase.
CreditRegistrationPhase::as_stris canonical: it iscredit_registration_phase_state.phase, the tick endpointโs?phase=and the audit logโstarget_phase. - Phase
Skip Reason - Phase
Tick - What one dispatch attempt did.
Traitsยง
- Mail
Queue ๐Phase - A phase whose whole body is โclaim rows, look up each oneโs template, skip it if the template is
missing, otherwise queue a mailโ.
link-emailsandstudent-notificationsare its only two shapes;run_mail_queue_phaseis the loop they share. - Suotar
Batch ๐Phase - A phase whose iteration is โclaim rows, decide in one transaction what may be asked, send one
batch, write one answer per rowโ.
import,resolve-enrolments, and each ofverifyโs two flows;run_suotar_batch_phaseis the loop they share, and the only place the transaction shape, the moved-on skipping and the counters are written down.
Functionsยง
- apply_
outcome ๐ - Applies one decided outcome to one row, with the exchange that produced it.
- apply_
request_ ๐level_ outcome - Applies one request-level outcome to one row of a batch the study registry rejected whole. Returns whether the row ended up carrying an error code.
- count_
applied ๐ - Counts one written row, or skips one that had already moved on. Skipped rather than propagated: the row belongs to whoever moved it, and aborting would leave the rest of the batch in the state the preflight wrote, which no phase claims again.
- counts_
as_ ๐failed - Whether an outcome counts against the iterationโs
items_failed: an error code is a failed item, so a verify poll answerednotRegisteredis not one. - every_
item_ ๐failed_ transiently - Whether the whole batch came back saying โnot nowโ, so the worker stops burning calls. A batch with one good item is a success: something moved.
- listed_
person_ ๐addresses - Every address the study registry holds for a listed person, in the order it lists them; which one they read is not something we can know.
- outcome_
transition ๐ - The ledger write one decided outcome asks for, without the audit half
apply_outcomeadds. For the paths that decide an outcome without an exchange to record. - requests_
json ๐ - The request bodies as sent, kept alongside the typed items so a rejected batch can pair each row with what was actually asked of it for the audit log.
- response_
item_ ๐json - The response item for one request item, read from the raw body rather than rebuilt from the typed value, so the audit trail holds what actually arrived.
- row_
facts ๐ - The scheduling history one outcome decision needs from a row.
- row_
moved_ ๐on - Whether the error is
transitionrefusing to write because another writer moved the row since the snapshot the decision was made from. - run_
legacy_ ๐mirror - run_
mail_ ๐queue_ phase - Claims, resolves templates for, and queues mail for one iteration of a
MailQueuePhase. A mail with no template is skipped rather than failing the iteration: the batch is one transaction, so an error would roll back every mail that could be queued, and the claimed rows stay claimable. - run_
materialize ๐ - Both statements that create ledger rows, bounded apart from each other. Together in one phase so the Workers tabโs row-creation counter accounts for every row the pipeline invented.
- run_
phase_ once - Runs exactly one iteration of one phase. The match below is the only place a phase
implementation is registered; it is exhaustive over
CreditRegistrationPhase, so a variant added there without a dispatch arm here fails to compile. - run_
preconditions ๐ - Database-only, so it keeps running while the study registry is unreachable.
- run_
suotar_ ๐batch_ phase - Runs one iteration of a
SuotarBatchPhase. - suotar_
error_ ๐variant - A failure that never reached the study registry is safe to send again; everything else may have been acted on. Anything that is not a client error was raised before the request was built.
- template_
language ๐ - Templates are stored per language and courses carry a locale. The courseโs language, not the recipientโs: the linking mailโs recipient may have no account here, and an account records no UI language to prefer.
- worker_
name ๐ - The audit logโs
worker_name, which the database caps at 64 characters.