soma.cell

E0002: invalid_properties

E0002 invalid_properties — a combination of slot properties that cannot hold.

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

The rule

Some slot properties are each valid but cannot hold together: a ttl shorter than the retain period would drop entries before the retention ends, and [evict] needs a capacity. soma check compares the durations and names both durations in its message. Remove the property that breaks the promise or make the durations agree; note that check also warns that ttl does not expire entries by itself.

A program that triggers it

wrong.cell

cell AuditTrail {
    memory {
        entries: Map<String, String> [persistent, ttl(30d), retain(365d)]
    }
    on record(id: String, event: String) {
        entries.set(id, event)
    }
    on lookup(id: String) {
        return entries.get(id) ?? ""
    }
}

What soma check prints:

$ soma check wrong.cell
warning: slot 'entries' of 'AuditTrail' is marked [ttl]: entries are NOT expired after the ttl — delete them yourself (an `every` handler)
  --> wrong.cell:3:51
  |
3 |         entries: Map<String, String> [persistent, ttl(30d), retain(365d)]
  |                                                   ^
error: invalid property combination on 'entries': ttl (30d) is shorter than retain (365d); data would expire before retention period ends
  --> wrong.cell:3:9
  |
3 |         entries: Map<String, String> [persistent, ttl(30d), retain(3…
  |         ^
  = code: E0002
✗ 1 error(s), 1 warning(s).

The fix field of soma check --json: Fix the property combination on 'entries': ttl (30d) is shorter than retain (365d); data would expire before retention period ends

On line 3, entries: Map<String, String> [persistent, ttl(30d), retain(365d)] becomes entries: Map<String, String> [persistent, retain(365d)].

wrong.cell → right.cell

--- wrong.cell
+++ right.cell
@@ -1,5 +1,5 @@
 cell AuditTrail {
     memory {
-        entries: Map<String, String> [persistent, ttl(30d), retain(365d)]
+        entries: Map<String, String> [persistent, retain(365d)]
     }
     on record(id: String, event: String) {

With the fix, soma check accepts the program:

$ soma check right.cell
✓ All checks passed.