dizzy.engine.dagstore.store¶
dizzy.engine.dagstore.store
¶
The DAG store: append / add / heads / iterate over SQLite.
The write method is the store's entire correctness kernel: append hashes
the payload with parents = the current local heads and inserts both atomically
inside one BEGIN IMMEDIATE transaction, so concurrent writers on one node
serialize on SQLite's writer lock — the head advance is race-free by
construction.
Heads are not maintained state; they are derived — an event is a head iff
no known event names it as a parent. That makes add (ingesting replicated
events) unable to corrupt the frontier: merge order can't matter because
nothing is being merged, only queried.
iterate yields the canonical replay order: a deterministic topological
sort — parents before children, concurrent siblings tiebroken by id. Any two
stores holding the same event set iterate identically; that property is the
convergence invariant the Hypothesis suite pins down.
MissingParents
¶
Bases: KeyError
add() was given an event whose parents are not yet in the store.
Source code in dizzy/src/dizzy/engine/dagstore/store.py
32 33 | |
DagStore
¶
A single node's event DAG. :memory: (default) or a file path.
Source code in dizzy/src/dizzy/engine/dagstore/store.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
append(type, payload)
¶
Mint a new event on top of the current heads and store it.
Source code in dizzy/src/dizzy/engine/dagstore/store.py
64 65 66 67 68 69 70 | |
add(event)
¶
Ingest a replicated event. Returns False if already present.
Verifies the content hash (raises TamperedEvent) and requires every
parent to be present already (raises MissingParents) — replication
must deliver ancestry first, which sync guarantees.
Source code in dizzy/src/dizzy/engine/dagstore/store.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
heads()
¶
The DAG frontier (sorted): events no known event names as parent.
Source code in dizzy/src/dizzy/engine/dagstore/store.py
103 104 105 106 107 108 | |
iterate()
¶
Yield every event in canonical replay order.
Kahn's algorithm with the ready set kept as a sorted frontier: an event becomes ready once all its parents have been emitted; among ready events the smallest id goes first. Purely a function of the event set — no clocks, no insertion order.
Source code in dizzy/src/dizzy/engine/dagstore/store.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |