soma.cell

E0009: consistency_mismatch

E0009 consistency_mismatch — a slot property contradicts the scale section's consistency.

A compile-time error of soma check, the checker of the Soma programming language (soma explain E0009).

The rule

A slot used as the shard: of a scale section must agree with its consistency:. An [ephemeral] slot sharded under consistency: strong is refused as contradictory. Change one side: declare consistency: eventual (as here, for a rate limiter's throwaway counters), or drop [ephemeral] from the slot.

A program that triggers it

wrong.cell

cell RateLimiter {
    memory {
        hits: Map<String, Int> [ephemeral]
    }
    scale {
        replicas: 4
        shard: hits
        consistency: strong
    }
    on hit(client: String) {
        hits.set(client, (hits.get(client) ?? 0) + 1)
    }
}

What soma check prints:

$ soma check wrong.cell
error: scale: shard 'hits' uses [ephemeral] but scale declares consistency: strong — contradictory
  --> wrong.cell:5:5
  |
5 |     scale {
  |     ^
  = code: E0009
✗ 1 error(s), 0 warning(s).

The fix field of soma check --json: Memory slot 'hits' uses [ephemeral] but scale declares consistency: strong. Change either the memory property or the scale consistency level.

On line 8, consistency: strong becomes consistency: eventual.

wrong.cell → right.cell

--- wrong.cell
+++ right.cell
@@ -6,5 +6,5 @@
         replicas: 4
         shard: hits
-        consistency: strong
+        consistency: eventual
     }
     on hit(client: String) {

With the fix, soma check accepts the program:

$ soma check right.cell
✓ All checks passed.