WRITE · TRACE · UNDERSTAND
Project: apply atomic versioned index updates and revocations
State has tenant,integer version,documents mapping and seen event-digest mapping.
Read lesson: Project: apply atomic versioned index updates and revocations →
Your experiment
State has tenant,integer version,documents mapping and seen event-digest mapping. Require expected_version==state.version. Work on a deep copy. Events contain tenant,event,id,positive integer revision,op=upsert/delete; upsert also needs string text and list of string roles. Reject unknown event fields and cross-tenant events. Canonical JSON SHA-256 identifies an event: identical event replay is ignored, changed replay rejected. Every new document revision must exceed the previous revision, including tombstones. Store revision,deleted,text,sorted unique roles; deletion clears text/roles but retains revision. Advance state version once if any new event applied. Errors leave the original state unchanged.
Python runs in your browser. Your draft stays on this device.
What to look for
Review replay identities, CAS retries, ACL revocation and stale resurrection. A content digest is a consistency key, not approval of a document's instructions. Replay follows the main orchestration function; helper computations execute and are checked separately.
Watch your code work
Ready to experimentWrite a solution or load the worked answer, then choose Trace & check.
Step through arrays, variables and training curves produced by your own Python.
