Expand description
The credit registration ledger.
transition, and its batched twin transition_batch, are the only writers of state,
stamping state_entered_at, the lifecycle timestamps and the audit event in one transaction.
Which transition to make is the caller’s decision; whether it is one the machine has is decided
here, from CreditRegistrationState::allowed_targets.
Modules§
- admin_
view 🔒 - The ledger as the admin explorer and the reconciliation detectors read it, across courses.
- attention 🔒
- The Errors tab’s attention queue: the rows that want a human, and why.
- claims 🔒
- Claiming due rows for a worker phase.
- competing_
credits 🔒 - The other credits of a student’s module that a new attempt is weighed against before it is sent.
- metrics 🔒
- The dashboard’s and the health alerts’ counts over the whole ledger.
- registration 🔒
- The ledger row itself: creating it and reading it back whole.
- row_
writes 🔒 - Writes to a row’s fields other than its state, which only
transitionwrites: the frozen payload, what the study registry answered, the schedule, the counters and the flags. - state 🔒
- The ledger’s states and error codes, the edges between states, and which rows a human may move by hand.
- student_
view 🔒 - The ledger as the student surfaces show it.
- teacher_
view 🔒 - The ledger as a course’s teacher surfaces show it, and what a teacher’s bulk retry may move.
- testing
- Test-mode setup the system tests drive through the mock Suotar control routes. Nothing here belongs on a live path: each helper writes a stamp or a hold the pipeline otherwise owns.
- transition 🔒
- Moving a row between states: the only writer of
state, and the one place an edge is checked againstCreditRegistrationState::allowed_targets.
Structs§
- Admin
Credit Registration - One ledger row as an admin sees it: every identifier support needs to answer “what happened to this student”, across courses.
- Admin
Credit Registration Filters - The narrowings the admin explorer applies, all of them in SQL.
- Attention
Registration - One row the Errors tab wants a human to look at, with the detectors that picked it.
- Attention
Selection - Which rows of the attention queue a call wants, and which slice of them.
- Batch
Move - One row’s move in a
transition_batch. - Course
Module State Count - Live rows of one course grouped by module and state, with the preconditions a
pendingrow is waiting on and how many of each group the pipeline handed to support. - Credit
Registration - Credit
Registration Error Code Count - Live rows carrying an error code, split by whether the pipeline is still working on them.
- Credit
Registration Throughput Day - One day of terminal outcomes, for the throughput series.
- Hand
Action Availability - Which hand actions a row is offered, decided once on the server for every admin surface. Clearing the attention flag is refused only on a superseded row, so it is not in here.
- Live
Success ForModule - Another live attempt, of any completion of the same student and module, that the study registry already holds.
- Module
Registration Totals - Live volumes per course module, for the Courses tab’s one row per module.
- NewCredit
Registration - Oldest
NonTerminal Registration - The row that has been waiting longest for the pipeline to do something with it.
- Payload
Snapshot - Frozen copy of what we are about to submit. Written once, before the row leaves
checking_enrolment: a later regrade must not alter a submitted row. - Recorded
Credit - A credit for the student and module that our own records say the study registry holds.
- Registration
Latency - How long registration took, in seconds, for rows that reached
registeredin a window. - Registration
Scope - 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.
- Resubmission
Facts - What decides whether a row may be moved by hand, read off whichever row type the caller has.
- Stuck
Registration Count - Stuck
Thresholds - How long a row may sit in one state before it counts as stuck. Seconds, per state.
- Student
Credit Registration - One ledger row with the course, module and enrolment facts every student view needs, so a status page is one query rather than a fan-out per row.
- Student
Registration Filter - Narrows
get_student_facing_by_user_id; the default returns every row of the user’s. - Teacher
Credit Registration - One ledger row as a teacher sees it: the raw state, the student’s identity and the unmasked verified student number, but never the study registry’s own error text.
- Teacher
Credit Registration Filters - The optional narrowings a teacher surface applies, all of them in SQL.
- Terminal
Outcome Totals - What the pipeline finished in a window.
- Transition
Enums§
- Admin
Attention - What a move does to the row’s admin-attention flag.
- Admin
Credit Registration Sort - How the explorer orders a page. Descending only: an ops table is read newest-worst first.
- Attention
Reason - Which detector picked a row for the attention queue. A row can carry several.
- Attention
Sort - How the attention queue orders a page. The default puts the row that has been waiting longest first, which is the order an operator works the queue in.
- Check
NowTarget - What checking a row now brings forward.
- Credit
Registration Error Code - Why a ledger row is where it is;
statesays what happens to it next. - Credit
Registration State - What the pipeline does next with a ledger row.
- Resubmission
Availability - Whether a row may be sent again by hand.
- Resubmission
Refusal - Why
ResubmissionFactsrefuses a hand action on a row. - Resubmission
Risk - How a resend
ResubmissionFacts::resubmission_refusalallows may go wrong, which the admin surfaces warn about before it is confirmed. - Resubmission
Strictness - How far outside a failure
ResubmissionFacts::resubmission_refusalwill still allow a row to move back toready_to_submit. - Transition
Policy - Which (from → to) edges
transitionwill write. - Transitioned
- What
transition_unless_moved_ondid. - Verify
Flow - Which of verify’s flows a claim is for.
Constants§
- ADMIN_
ONLY_ TARGETS - The edges only a hand transition may take, from any state
ResubmissionFacts::admin_transition_refusaldoes not refuse: putting a row back on the pipeline, and writing one off.
Functions§
- claim_
due_ for_ import - Claims, for import,
checking_enrolmentrows, minus any whose student and course code already have a submission in flight, which Suotar’s hour-old copy of Sisu would not stop from registering twice, and any whose person and module slot inuq_credit_registrations_person_moduleis taken. Of two rows for the same student and course code claimed together only the first comes back; the other stays claimable where it is. - claim_
due_ for_ person_ lookup - Claims, for the person lookup that precedes resolve-enrolments, the rows
claim_due_for_resolvewould take, the laterEnrolmentCheckGroupfirst. - claim_
due_ for_ resolve - Claims, for resolve-enrolments,
ready_to_submitrows and parked rows due an enrolment check, the laterEnrolmentCheckGroupfirst, minus any whose student already has another live row for the module somewhere between resolving and a known outcome. First pulls slow checks due soon into the batch; seecrate::library::credit_registration::enrolment_checks::pull_forward_batched_checks. - claim_
due_ for_ verify - Claims rows for one of verify’s flows. Each flow is claimed on its own, so that rows one flow has no allowance to send cannot fill the other’s claim.
- claim_
enrolment_ checks - Keeps parked rows out of every claim while a lookup for them is out, as
resolving_enrolmentdoes for a row on its first resolve. The answer’stransitionends the claim; one a worker died holding expires afterRESOLVING_RECOVERY_GRACE. A no-op for a row in any other state. - count_
by_ error_ code - The error-code breakdown the Overview shows.
- count_
by_ module failed_countisfailed_permanentandmisregisteredonly, so the columns do not add up to the total by design.- count_
by_ module_ and_ state_ for_ course - The course’s live rows per module and state, narrowed to one instance where the caller names one.
- count_
by_ state - Live rows per state, for the dashboard funnel. Superseded attempts are excluded, as in the per-course sibling, or a course that regrades counts every student twice.
- count_
due_ enrolment_ checks - Live rows parked in
no_usable_enrolmentthat an unscoped resolve-enrolments claim would take for an enrolment check now; the rest wait for their schedule, their module, or a lookup already out. Leaves out the claim’s one-row-per-student-and-module hold, which only defers a row. - count_
entered_ state_ since - Live rows that entered one state within the window.
misregisteredis not terminal, soterminal_atcannot answer this. - count_
needing_ attention - The whole queue’s totals: how many rows need a human, and how many of them each detector picked.
- count_
pending_ by_ reason - Live
pendingrows per blocker. Derived fromcredit_registration_preconditions, so it cannot disagree with what the recompute is waiting for or with what the student is shown. - count_
stuck - Rows the pipeline should have moved by now, per state. Only the four states with a threshold count: the rest wait on a student or a human, where an alert would fire on normal operation.
- count_
submission_ uncertain_ by_ course_ id - How many of a course’s live rows a bulk retry has to refuse, all for the one remaining reason: the submission may have landed, so only a human may move that row.
- count_
teacher_ facing_ by_ course_ id - How many rows
get_teacher_facing_by_course_idwould return without a page limit. - count_
terminal_ outcomes_ since - dismiss_
enrolment_ banner - The student dismissed the in-course-material re-enrol banner for this registration.
- exists_
for_ user_ and_ course - Whether this account has any attempt, live or replaced, on this course.
- get_
admin_ facing - A page of the ledger for the admin explorer, cross-course.
- get_
attention_ items - A page of the attention queue, with the totals for everything the call selected on every row.
- get_
by_ course_ id - get_
by_ id - get_
by_ ids_ for_ update - The named rows, locked until the caller’s transaction ends. Must be called inside one.
- get_
by_ user_ id - get_
live_ by_ states - Live rows in each of the given states, newest activity first within each state, for the
Reconciliation lists.
limit_per_statecaps every state independently, viaROW_NUMBER, so one state with many rows cannot crowd another out of a sharedLIMIT. - get_
oldest_ non_ terminal - get_
recorded_ credits_ for_ same_ module - Every credit for the row’s student and module that our records say the registry holds: another of our live attempts in a success state, or a registrar’s pull-path registration.
- get_
registration_ latency_ between - get_
retryable_ ids_ by_ course_ id - The course’s live rows a bulk retry can actually move: failed for good, and not held open by
Suotar. Oldest first, capped by
limit. - get_
student_ facing_ by_ user_ id - The user’s registrations as the student surfaces show them, newest completion first. Superseded attempts are included: the student is entitled to see an earlier attempt Sisu may still hold.
- get_
teacher_ facing_ attempts_ for_ completion - Every attempt for the same completion as
row, that one included, newest attempt first. - get_
teacher_ facing_ by_ course_ id - The course’s ledger rows as the teacher surfaces show them, newest completion first.
- get_
teacher_ facing_ by_ id - One row for a teacher surface, by id.
Nonewhen no such live row exists. - get_
throughput_ by_ day - Daily terminal outcomes over the window. Withdrawn rows are in no column: they are neither a success nor a failure.
- increment_
submit_ retry_ count - increment_
verify_ attempt_ counts - Counts one verify poll for every row of a batch and returns each row’s new count, which sets the backoff the poll’s answer is scheduled by.
- insert
- Creates a ledger row at
pendingwith acreatedevent. - is_
waiting_ for_ enrolment - Whether a row is waiting for an enrolment: parked without a usable one, check schedule started or not, or on its first check or a retry on its way there. Only such a row is moved by a visit or a check request, and kept waiting through a lookup that fails in transit.
- lock_
live_ successes_ for_ same_ module - The student’s other live attempts for the row’s module that the registry already holds, locked until the caller’s transaction ends.
- make_
due_ now_ batch - Makes rows claimable again now, whatever backoff parked them. A row waiting for an enrolment
check has its check marked as
enrolment_check_source: who asked for it. - mark_
improvement_ checked - Records that the grade-improvement scan looked at this accepted attempt against a completion in the given revision and found nothing better.
- mark_
partially_ registered - Notes that verify saw only the assessment item attainment, keeping the first sighting, and returns when that was.
- mark_
pending_ superseded - Marks a registered row as being replaced by
superseded_by_id, a later attempt with a better grade, of the same completion or another, which takes over the row’s slot inuq_credit_registrations_person_module. - mark_
superseded - Points an old attempt at the newer one that replaced it. The old row keeps its state and
terminal_at: it really was registered. - prepare_
unsent_ duplicate - Readies a row that resolve-enrolments settles as
duplicatewithout sending it, in the caller’s transaction and before the transition. - requeue_
retryable_ now - Makes every due-later
failed_retryablerow due now; returns how many. The button pressed once the study registry says an outage is over. - reset_
for_ resubmission - Forgets a submission Suotar says never landed, so the row resolves its enrolment and imports again from scratch, and returns how many times that has now happened.
- restamp_
resolving_ enrolment - Restarts the recovery grace of rows waiting out an enrolment lookup in
resolving_enrolment, which runs fromstate_entered_at, for a split batch whose later halves are still to be sent. - restamp_
submitting - Restamps
submitted_aton rows stillsubmitting, for an import that sends them again after splitting a refused batch: the precondition sweep times a lost submission from this stamp, and must not condemn a row still waiting its turn in the same iteration. - schedule_
next_ attempt - Defers when the pipeline may next claim this row; the delay is the caller’s policy.
- schedule_
next_ attempts schedule_next_attemptfor a whole batch, each row with its own time.- set_
needs_ admin_ attention - set_
payload_ snapshot - set_
resubmit_ not_ before - Records Suotar’s
retryAfterfor the pending submission, before which a resubmission may register the credits twice. SeeResubmissionFacts::resubmission_refusal. - set_
sisu_ attainment_ if_ unclaimed - Records the attainment the study registry holds, unless another live row already claims it.
- set_
submitted_ attainment - transition
- Moves a ledger row to a new state and appends the matching audit event, atomically.
- transition_
batch transitionfor a whole batch: one lock, one update, one insert of events, whatever the size.- transition_
unless_ moved_ on transitionfor a caller deciding from a snapshot another writer may have overtaken: a row no longer inexpected_from_statecomes back asTransitioned::MovedOnrather than as an error, since the row is now that writer’s and the caller carries on with the rest of its work.