This chapter documents the key invariants and integrity constraints that ensure system correctness throughout the semester lifecycle.
Enforcement Strategy
When feasible, enforce constraints at the database level. For complex business rules, use application-level validations and background reconciliation jobs.
# One confirmed submission per user per campaign
add_index :registration_submissions,
[:registration_campaign_id, :user_id],
unique: true,
where: "status = 'confirmed'",
name: "idx_unique_confirmed_submission"
# Unique preference ranks per user per campaign
add_index :registration_submissions,
[:user_id, :registration_campaign_id, :preference_rank],
unique: true,
where: "preference_rank IS NOT NULL",
name: "idx_unique_preference_rank"
Set up monitoring for these conditions to catch data inconsistencies early:
Metric
Threshold
Action
Explanation
Orphan submissions
= 0
Alert immediately
Submissions without a valid registration_item_id indicate broken foreign keys or data corruption
Allocation failures (last 24h)
> 0
Alert staff
Failed registration assignments need manual review; may indicate capacity or constraint issues
Count drift per item
> 5
Trigger recount job
Difference between assigned_count cache and actual roster count suggests cache staleness
Pending certifications during active campaigns
> 0
Alert staff
Campaigns should not have pending certifications; blocks campaign operations
Stale certifications
> 10% of total
Alert staff
High staleness rate suggests Records are being recomputed but Certifications not reviewed
Performance record age during grading period
> 48h
Trigger recomputation
Stale Records mean certifications are based on outdated data
Count Drift Metric
The "count drift" metric compares the cached assigned_count field on registration items against the actual number of confirmed roster entries. A drift > 5 suggests the cache is out of sync with reality, which can happen after manual roster modifications or failed callbacks. The recount job refreshes these cached values.
Extra Points Allowed
Points exceeding task maximum are intentionally permitted to support extra credit scenarios and bonus points. This is not considered an error condition.