ConceptsExecution ModelConsistency and concurrency

Consistency and concurrency

Causet orders work per entity. The sync response waits for the ledger and the entity snapshot. A named query reads the projection built after that commit.


One intent at a time for an entity

Intents for the same stream and entity are serialized. A second intent for that entity waits. Intents for different entities proceed independently.

The commit for an accepted sync intent writes the ledger and the entity snapshot for that cursor. A follow-up entity read sees that snapshot. A named query does not read that snapshot. It reads a projection table filled by the projection worker after the event is published.

Idempotency is a separate control. Resubmitting the same intent id does not create a second commit. See Idempotency.


Committed state versus a query

QuestionWhere the answer lives
What did this commit store?Entity snapshot
What does a list or a product query show?Projection table, unless a token read is enforced
Has this cursor been applied to that projection?projection_entity_watermarks, and only if the query flag is on

The worker records the watermark in the same database transaction as the projection change. The cursor it stores is the greatest one applied for that stream, entity, projection, and version. An older apply cannot mark a newer cursor visible. The query gate accepts the read when that row is READY, the projection version matches, and the watermark cursor is at least the token cursor. Otherwise the response is 409 PROJECTION_NOT_VISIBLE and the body is not cached.

Details and status codes: Read consistency.


Determinism

Rules see the entity state from the previous cursor and the intent payload. They do not read the projection tables they are about to update. A rule that called the current time, a random source, or an unrecorded external system would not replay to the same result. Lookups that are part of the ruleset are recorded with the decision. Model output and other nondeterministic tool results have to be stored as intent or event data if a later inspection needs the same value.


What is still open

These are not fixed by turning the query flag on:

  • A crash after a cursor is allocated and before its projection event is applied. The recovery scan, when enabled, finalizes an expired open allocation as a no-op and does not publish to Kafka. It ignores cursors that never had an allocation row.
  • Writers that move the cursor without that allocation: saga prepare, commit apply, genesis import, fork clone, and surgical replay. The scan does not invent a row for them, and the token gate does not cover them.
  • A deployment with the flag off. The token header is ignored.

Next steps