Skip to main content

Module credit_registrations

Module credit_registrations 

Source
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 transition writes: 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 against CreditRegistrationState::allowed_targets.

Structs§

AdminCreditRegistration
One ledger row as an admin sees it: every identifier support needs to answer “what happened to this student”, across courses.
AdminCreditRegistrationFilters
The narrowings the admin explorer applies, all of them in SQL.
AttentionRegistration
One row the Errors tab wants a human to look at, with the detectors that picked it.
AttentionSelection
Which rows of the attention queue a call wants, and which slice of them.
BatchMove
One row’s move in a transition_batch.
CourseModuleStateCount
Live rows of one course grouped by module and state, with the preconditions a pending row is waiting on and how many of each group the pipeline handed to support.
CreditRegistration
CreditRegistrationErrorCodeCount
Live rows carrying an error code, split by whether the pipeline is still working on them.
CreditRegistrationThroughputDay
One day of terminal outcomes, for the throughput series.
HandActionAvailability
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.
LiveSuccessForModule
Another live attempt, of any completion of the same student and module, that the study registry already holds.
ModuleRegistrationTotals
Live volumes per course module, for the Courses tab’s one row per module.
NewCreditRegistration
OldestNonTerminalRegistration
The row that has been waiting longest for the pipeline to do something with it.
PayloadSnapshot
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.
RecordedCredit
A credit for the student and module that our own records say the study registry holds.
RegistrationLatency
How long registration took, in seconds, for rows that reached registered in a window.
RegistrationScope
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.
ResubmissionFacts
What decides whether a row may be moved by hand, read off whichever row type the caller has.
StuckRegistrationCount
StuckThresholds
How long a row may sit in one state before it counts as stuck. Seconds, per state.
StudentCreditRegistration
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.
StudentRegistrationFilter
Narrows get_student_facing_by_user_id; the default returns every row of the user’s.
TeacherCreditRegistration
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.
TeacherCreditRegistrationFilters
The optional narrowings a teacher surface applies, all of them in SQL.
TerminalOutcomeTotals
What the pipeline finished in a window.
Transition

Enums§

AdminAttention
What a move does to the row’s admin-attention flag.
AdminCreditRegistrationSort
How the explorer orders a page. Descending only: an ops table is read newest-worst first.
AttentionReason
Which detector picked a row for the attention queue. A row can carry several.
AttentionSort
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.
CheckNowTarget
What checking a row now brings forward.
CreditRegistrationErrorCode
Why a ledger row is where it is; state says what happens to it next.
CreditRegistrationState
What the pipeline does next with a ledger row.
ResubmissionAvailability
Whether a row may be sent again by hand.
ResubmissionRefusal
Why ResubmissionFacts refuses a hand action on a row.
ResubmissionRisk
How a resend ResubmissionFacts::resubmission_refusal allows may go wrong, which the admin surfaces warn about before it is confirmed.
ResubmissionStrictness
How far outside a failure ResubmissionFacts::resubmission_refusal will still allow a row to move back to ready_to_submit.
TransitionPolicy
Which (from → to) edges transition will write.
Transitioned
What transition_unless_moved_on did.
VerifyFlow
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_refusal does not refuse: putting a row back on the pipeline, and writing one off.

Functions§

claim_due_for_import
Claims, for import, checking_enrolment rows, 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 in uq_credit_registrations_person_module is 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_resolve would take, the later EnrolmentCheckGroup first.
claim_due_for_resolve
Claims, for resolve-enrolments, ready_to_submit rows and parked rows due an enrolment check, the later EnrolmentCheckGroup first, 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; see crate::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_enrolment does for a row on its first resolve. The answer’s transition ends the claim; one a worker died holding expires after RESOLVING_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_count is failed_permanent and misregistered only, 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_enrolment that 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. misregistered is not terminal, so terminal_at cannot 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 pending rows per blocker. Derived from credit_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_id would 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_state caps every state independently, via ROW_NUMBER, so one state with many rows cannot crowd another out of a shared LIMIT.
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. None when 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 pending with a created event.
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 in uq_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 duplicate without sending it, in the caller’s transaction and before the transition.
requeue_retryable_now
Makes every due-later failed_retryable row 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 from state_entered_at, for a split batch whose later halves are still to be sent.
restamp_submitting
Restamps submitted_at on rows still submitting, 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_attempt for a whole batch, each row with its own time.
set_needs_admin_attention
set_payload_snapshot
set_resubmit_not_before
Records Suotar’s retryAfter for the pending submission, before which a resubmission may register the credits twice. See ResubmissionFacts::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
transition for a whole batch: one lock, one update, one insert of events, whatever the size.
transition_unless_moved_on
transition for a caller deciding from a snapshot another writer may have overtaken: a row no longer in expected_from_state comes back as Transitioned::MovedOn rather than as an error, since the row is now that writer’s and the caller carries on with the rest of its work.