Scoring Safety Mode and Fallback Points

scoring safety-mode modes fallback

Scoring Safety Mode and Fallback Points

Cade is designed to never halt a game in progress. If a scoring rule panics, times out, or produces bad state, the engine catches the fault, awards a fallback point value, and keeps running. After too many consecutive faults on the same event, the engine switches into safety mode — it keeps scoring at a reduced level until normal rules start succeeding again.

This behavior is automatic. You do not need to enable it. The only thing you configure directly is the fallback point value per event.

Fallback Points

When a scoring rule fails, the engine looks up a fallback point value rather than awarding zero. The lookup has three tiers, in order:

  1. Event-specific fallback — a fallback_points value on the score event itself.
  2. Category default — looked up from the first segment of the event name.
  3. Global minimum — a final floor of 10 points.

Event-Specific fallback_points

score "event" "bumper_hit" {
  when            = switch.bumper.hit
  points          = var.bumper_value * var.multiplier
  fallback_points = 100
}

score "event" "jackpot" {
  when            = jackpot.collected
  points          = var.base_jackpot * var.jackpot_multiplier
  fallback_points = 10000
}

fallback_points is used whenever the rule’s points expression cannot be evaluated (panic, timeout, or invalid state) and whenever the engine is in safety mode.

Category Defaults

If no fallback_points is set, the engine extracts a category from the dot-delimited event name and uses a built-in default:

CategoryFallback points
switch10
target100
bumper100
ramp1,000
loop1,000
mode5,000
jackpot10,000
wizard50,000

For example, switch.bumper.hit matches bumper and falls back to 100 points.

Global Minimum

If neither an event-specific fallback nor a category match exists, the engine awards the global minimum (10 points). Zero is never awarded on a recovered error.

Safety Mode Activation

When any single event’s rule fails several times in a row, the engine enters safety mode. In safety mode it:

  • Skips conditions, complex point expressions, and variable updates.
  • Skips accumulator processing.
  • Awards only fallback points per event.

The engine exits safety mode after a longer run of successful scores. The thresholds default to:

ThresholdDefaultWhat it controls
Activation5 consecutive failures on any single eventWhen the engine enters safety mode
Recovery20 consecutive successesWhen the engine returns to full operation

Observability

When safety mode activates or deactivates, and whenever an individual scoring error is recovered, the engine emits system events so external observers can react:

System eventEmitted when
system.scoring.safety_mode.activatedEngine enters safety mode
system.scoring.safety_mode.deactivatedEngine exits safety mode
system.scoring.errorA scoring error was recovered and fallback points were awarded

The deactivation event also includes how long the engine spent in safety mode.

Three performance counters track the cumulative impact of error recovery across a game:

CounterIncremented when
safe_mode_activationsEngine enters safety mode
total_scoring_errorsAny recovered scoring error
fallback_points_awardedFallback points are awarded

Watch these via the console to spot systematic problems before they affect players.

Best Practices

  • Assign fallback_points to high-value events. Jackpots and wizard mode scoring especially benefit from explicit fallback values — category defaults are intentionally modest.
  • Favor conservative fallback values. It is better to under-award than to over-award when a rule misbehaves.
  • Monitor counters. Rising total_scoring_errors without a matching rise in safe_mode_activations usually indicates a buggy rule that is within tolerance but still failing regularly.