From e5926ab2e5d5f790ae21d3b298c2d3aaae92f573 Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Tue, 10 Nov 2026 20:27:14 -0500 Subject: [PATCH 01/37] feat(formal): the temporal snapshot, the laws (SNP-1 to SNP-9) `as of ` reads one relation at the cut and every other store as it is now, and nothing says what a read of a store at a cut must satisfy before code is written for it. This states it and proves it, on a model of a store as a family of append chains and a cut as a prefix length for each (the vector of per-chain positions of the event clock). SNP-1, append invariance: a read at a cut inside the store, a read between two such cuts and every derived view are unchanged by any growth of the store. SNP-2, monotonicity: an earlier cut reads a prefix of a later one, and a cut of a cut is the meet. SNP-3, composition: the read at a followed by the read between a and b is the read at b, so a fold continued from a checkpoint over the delta is the fold of the prefix. SNP-4, idempotence: the read at the head cut is the store. SNP-5: a reader is append invariant exactly when it is a function of the prefixes; for keyed writes the generational store read at a cut is the state recomputed from the prefix, and at most one generation of a key is alive at a cut. SNP-6: a narrower grant's snapshot is the restriction of a wider one's. SNP-7: no erased event is visible at any cut, the store with holes keeps every position, and a key retired after a cut is served at no earlier cut. SNP-8: consistent cuts are closed under meet and join, they are the clock's cuts (CLK-2) among the frontier cuts, and every frontier resolves to one greatest consistent cut under it. SNP-9: a certificate of prefix digests verifies on every extension of the store, pins the read under a collision-free digest, extends over the delta, and survives an erasure that keeps commitments. The controls are theorems too: the reader that ignores the cut, the store rewritten in place, an event filter applied before the cut, the erasure that deletes rows, a digest with collisions. Design theorems: no code relies on them yet, so they have no ledger rows and no Spec statements. The module is registered in the Palace root. Co-Authored-By: Claude Fable 5.2 --- formal/Palace.lean | 2 + formal/Palace/Snapshot.lean | 922 +++++++++++++++++++++++++++++++ formal/Palace/Snapshot/Defs.lean | 294 ++++++++++ 3 files changed, 1218 insertions(+) create mode 100644 formal/Palace/Snapshot.lean create mode 100644 formal/Palace/Snapshot/Defs.lean diff --git a/formal/Palace.lean b/formal/Palace.lean index f5703f66..a1a28363 100644 --- a/formal/Palace.lean +++ b/formal/Palace.lean @@ -65,6 +65,8 @@ public import Palace.Sever public import Palace.Sever.Defs public import Palace.SigmaStar public import Palace.SigmaStar.Defs +public import Palace.Snapshot +public import Palace.Snapshot.Defs public import Palace.Spectral public import Palace.Spectral.Defs public import Palace.Superconnection diff --git a/formal/Palace/Snapshot.lean b/formal/Palace/Snapshot.lean new file mode 100644 index 00000000..4b945fa9 --- /dev/null +++ b/formal/Palace/Snapshot.lean @@ -0,0 +1,922 @@ +module + +public import Palace.Snapshot.Defs +public import Palace.Clock +public import Mathlib.Data.List.Induction +public import Mathlib.Data.List.ReduceOption +public import Mathlib.Order.Lattice +public import Mathlib.Order.Lattice.Nat +public import Mathlib.Order.Sublattice + +/-! +# The temporal snapshot: the laws of a read at a cut + +Design theorems of `docs/design-notes/dn-temporal-snapshot.md`, proved before any code reads a +store at a cut, on the model of `Palace/Snapshot/Defs.lean`: a store is a family of append chains, +a cut a prefix length for each. Cited from the note, not from the ledger. + +* SNP-1, append invariance: a read at a cut inside the store, a read between two such cuts and + every derived view of them are the same after any growth of the store (`readAt_grow`, + `readAt_of_extends`, `readBetween_grow`, `appendInvariant_view`). The control is the reader that + ignores the cut (`Witness.present_not_appendInvariant`). +* SNP-2, monotonicity: the read at an earlier cut is a prefix of the read at a later one, and a + cut of a cut is the meet (`readAt_mono`, `readAt_readAt`, `head_readAt`). +* SNP-3, composition: the read at `a` followed by the read between `a` and `b` is the read at + `b`, and two adjacent reads-between compose (`readAt_append_readBetween`, + `readBetween_append`); so a fold continued from a checkpoint over the events since is the fold + of the whole prefix (`foldAt_readBetween`, `stateAt_eq_foldl`): a job's checkpoint is a cut. +* SNP-4, idempotence: the read at the head cut is the store, and every derived view at it is + the derivation of the present (`readAt_head`, `view_head`, `genRead_gens_length`). +* SNP-5, a derived view is a function of the prefixes: a reader is append invariant exactly when + it reads only the prefixes, exactly when it is a derived view + (`appendInvariant_iff_prefixOnly`, `appendInvariant_iff_exists_view`). For a store of keyed + writes the three ways of holding it agree: the generational store read at a cut is the state + recomputed from the prefix (`genRead_gens`), it is the last write inside the prefix + (`stateAt_eq_lastWrite`), and at most one generation of a key is alive at a cut + (`length_filter_selects_le_one`). The store rewritten in place determines no read at a past + cut (`Witness.stateOf_forgets`). +* SNP-6, grant restriction: a narrower grant's snapshot is the restriction of a wider one's, a + snapshot reads only the chains the grant names and the cut on them, and it is append + invariant (`snapshot_narrow`, `snapshot_congr`, `snapshot_grow`). Restricting to chains commutes + with the cut; filtering events before the cut does not, and a cut's positions count the events + a filter hides (`restrict_readAt`, `Witness.filter_before_cut`, `Witness.position_channel`). +* SNP-7, erasure dominance: no erased event is visible at any cut, a larger erasure shows a + sublist, the store with holes keeps every position, and two stores that differ only in erased + events give every derived view the same reading at every cut (`not_erased_of_mem_visible`, + `visible_sublist`, `redact_readAt`, `erased_invisible`); a kept derived row is served only when + none of its sources is erased (`mem_serve_iff`); a key retired after a cut is served at no + earlier cut, and growth of the chain changes a served value only by removing it + (`servedAt_append_of_retire`, `servedAt_append_of_no_retire`, `servedAt_of_append`). The control + is the erasure that deletes rows (`Witness.compact_moves`). +* SNP-8, consistent cuts: closed under meet and join, so a sublattice of the cuts + (`Consistent.inf`, `Consistent.sup`, `consistentCuts`); they are the clock's cuts, CLK-2, among + the frontier cuts (`consistent_iff_isCut`); every frontier resolves to exactly one greatest + consistent cut under it, monotonically (`exists_resolves`, `Resolves.unique`, `Resolves.mono`); + and a consistent cut stays consistent as the store grows (`Consistent.of_grown`). +* SNP-9, certified cuts: the certificate of a cut verifies on every extension of the store, two + stores that verify one certificate under a collision-free digest have the same read at its cut + and so the same derived views, a certificate extends over the events since an earlier one, the + meet and the join of two certified cuts are certified from the two certificates alone, and an + erasure that keeps commitments keeps every certificate (`verifies_certify_of_extends`, + `Verifies.readAt_eq`, `Verifies.view_eq`, `certify_digest_readBetween`, `certify_inf`, + `certify_sup`, `verifies_purge`). +-/ + +@[expose] public section + +namespace Palace.Snapshot + +/-! ### SNP-1 to SNP-4 Reads -/ + +section Reads + +variable {K α β : Type*} + +theorem extends_grow (s t : Store K α) : Extends s (grow s t) := fun _ ↦ List.prefix_append _ _ + +/-- An extension of a store is the store grown: append is all that happened. -/ +theorem Extends.exists_grow {s s' : Store K α} (h : Extends s s') : ∃ t, s' = grow s t := + ⟨fun k ↦ (s' k).drop (s k).length, funext fun k ↦ (List.prefix_iff_eq_append.1 (h k)).symm⟩ + +theorem Extends.head_le {s s' : Store K α} (h : Extends s s') : head s ≤ head s' := + fun k ↦ (h k).length_le + +/-- SNP-1 Append invariance: the read at a cut inside the store does not change when the store +grows. -/ +theorem readAt_grow {s : Store K α} (t : Store K α) {c : Cut K} (h : c ≤ head s) : + readAt (grow s t) c = readAt s c := + funext fun k ↦ List.take_append_of_le_length (h k) + +/-- SNP-1 The same over every extension: a later state of an append-only store reads, at a cut +of an earlier state, what the earlier state read. -/ +theorem readAt_of_extends {s s' : Store K α} {c : Cut K} (h : Extends s s') (hc : c ≤ head s) : + readAt s' c = readAt s c := by + obtain ⟨t, rfl⟩ := h.exists_grow + exact readAt_grow t hc + +/-- SNP-1 The read between two cuts inside the store does not change when the store grows. -/ +theorem readBetween_grow {s : Store K α} (t : Store K α) (a : Cut K) {b : Cut K} + (h : b ≤ head s) : readBetween (grow s t) a b = readBetween s a b := + funext fun k ↦ congrArg (List.drop (a k)) (List.take_append_of_le_length (h k)) + +/-- SNP-1 Every derived view is append invariant. -/ +theorem appendInvariant_view (D : Store K α → β) : AppendInvariant (view D) := + fun _ t _ h ↦ congrArg D (readAt_grow t h) + +theorem readAt_extends (s : Store K α) (c : Cut K) : Extends (readAt s c) s := + fun k ↦ List.take_prefix (c k) (s k) + +/-- SNP-2 Monotonicity: the read at an earlier cut is a prefix, chain by chain, of the read at a +later one. -/ +theorem readAt_mono (s : Store K α) {c d : Cut K} (h : c ≤ d) : + Extends (readAt s c) (readAt s d) := + fun k ↦ List.take_prefix_take_left (h k) + +/-- SNP-2 An event read at a cut is read at every later cut. -/ +theorem mem_readAt_of_le {s : Store K α} {c d : Cut K} (h : c ≤ d) {k : K} {a : α} + (ha : a ∈ readAt s c k) : a ∈ readAt s d k := + (readAt_mono s h k).subset ha + +/-- SNP-2 A cut of a cut is the meet of the two. -/ +theorem readAt_readAt (s : Store K α) (c d : Cut K) : + readAt (readAt s c) d = readAt s (d ⊓ c) := + funext fun _ ↦ List.take_take + +theorem head_readAt (s : Store K α) (c : Cut K) : head (readAt s c) = c ⊓ head s := + funext fun _ ↦ List.length_take + +theorem head_readAt_of_le {s : Store K α} {c : Cut K} (h : c ≤ head s) : + head (readAt s c) = c := by + rw [head_readAt, inf_of_le_left h] + +/-- SNP-4 A cut at or past the head reads the store. -/ +theorem readAt_of_head_le {s : Store K α} {c : Cut K} (h : head s ≤ c) : readAt s c = s := + funext fun k ↦ List.take_of_length_le (h k) + +/-- SNP-4 Idempotence: the read at the head cut is the store. -/ +theorem readAt_head (s : Store K α) : readAt s (head s) = s := readAt_of_head_le le_rfl + +/-- SNP-4 Every derived view at the head cut is the derivation of the present: `as of` the +current cut is no `as of`. -/ +theorem view_head (D : Store K α → β) (s : Store K α) : view D s (head s) = D s := + congrArg D (readAt_head s) + +theorem drop_take_append_drop (l : List α) {a b : ℕ} (h : a ≤ b) : + (l.take b).drop a ++ l.drop b = l.drop a := by + conv_rhs => rw [← List.take_append_drop b l, List.drop_append] + congr 1 + rcases Nat.le_total b l.length with hb | hb + · rw [List.length_take, Nat.min_eq_left hb, Nat.sub_eq_zero_of_le h, List.drop_zero] + · rw [List.drop_of_length_le hb, List.drop_nil] + +/-- SNP-3 Composition: the read at `a` followed by the read between `a` and `b` is the read at +`b`. -/ +theorem readAt_append_readBetween (s : Store K α) {a b : Cut K} (h : a ≤ b) : + grow (readAt s a) (readBetween s a b) = readAt s b := by + funext k + have h1 : (s k).take (a k) = ((s k).take (b k)).take (a k) := by + rw [List.take_take, Nat.min_eq_left (h k)] + change (s k).take (a k) ++ ((s k).take (b k)).drop (a k) = (s k).take (b k) + rw [h1, List.take_append_drop] + +/-- SNP-3 Two adjacent reads-between compose. -/ +theorem readBetween_append (s : Store K α) {a b c : Cut K} (hab : a ≤ b) (hbc : b ≤ c) : + grow (readBetween s a b) (readBetween s b c) = readBetween s a c := by + funext k + have h1 : (s k).take (b k) = ((s k).take (c k)).take (b k) := by + rw [List.take_take, Nat.min_eq_left (hbc k)] + change ((s k).take (b k)).drop (a k) ++ ((s k).take (c k)).drop (b k) + = ((s k).take (c k)).drop (a k) + rw [h1] + exact drop_take_append_drop _ (hab k) + +/-- The read between the empty cut and a cut is the read at it. -/ +theorem readBetween_zero (s : Store K α) (b : Cut K) : + readBetween s (fun _ ↦ 0) b = readAt s b := rfl + +/-- The read between a cut and itself is empty. -/ +theorem readBetween_self (s : Store K α) (a : Cut K) : readBetween s a a = fun _ ↦ [] := by + funext k + refine List.drop_of_length_le ?_ + rw [List.length_take] + exact Nat.min_le_left _ _ + +/-- The read between a cut and the head is what the store appended since the cut. -/ +theorem readBetween_head (s : Store K α) (a : Cut K) : + readBetween s a (head s) = fun k ↦ (s k).drop (a k) := by + funext k + change ((s k).take (s k).length).drop (a k) = (s k).drop (a k) + rw [List.take_length] + +/-- SNP-3 The journal: a fold of the prefixes at a later cut is the fold at an earlier cut +continued over the events between the two. A job that keeps its state and the cut it stopped at +reads only the delta. -/ +theorem foldAt_readBetween (f : β → α → β) (init : K → β) (s : Store K α) {a b : Cut K} + (h : a ≤ b) (k : K) : + foldAt f init s b k = (readBetween s a b k).foldl f (foldAt f init s a k) := + calc foldAt f init s b k + = ((s k).take (a k) ++ ((s k).take (b k)).drop (a k)).foldl f (init k) := + congrArg (fun l ↦ l.foldl f (init k)) (congrFun (readAt_append_readBetween s h) k).symm + _ = _ := List.foldl_append + +/-- SNP-5 A derived view reads only the prefixes. -/ +theorem prefixOnly_view (D : Store K α → β) : PrefixOnly (view D) := fun s c _ ↦ by + change D (readAt s c) = D (readAt (readAt s c) c) + rw [readAt_readAt, inf_idem] + +/-- SNP-5 Two stores with the same prefixes at a cut give every derived view the same +reading. -/ +theorem view_congr (D : Store K α → β) {s s' : Store K α} {c : Cut K} + (h : readAt s c = readAt s' c) : view D s c = view D s' c := congrArg D h + +/-- SNP-5 A reader is append invariant exactly when it reads only the prefixes. -/ +theorem appendInvariant_iff_prefixOnly (F : Store K α → Cut K → β) : + AppendInvariant F ↔ PrefixOnly F := by + constructor + · intro h s c hc + obtain ⟨t, ht⟩ := (readAt_extends s c).exists_grow + have hc' : c ≤ head (readAt s c) := le_of_eq (head_readAt_of_le hc).symm + calc F s c = F (grow (readAt s c) t) c := by rw [← ht] + _ = F (readAt s c) c := h _ t c hc' + · intro h s t c hc + rw [h (grow s t) c (hc.trans (extends_grow s t).head_le), readAt_grow t hc, ← h s c hc] + +/-- SNP-5 A reader is append invariant exactly when it is a derived view: on cuts inside the +store, a function of the prefixes alone. -/ +theorem appendInvariant_iff_exists_view (F : Store K α → Cut K → β) : + AppendInvariant F ↔ ∃ D : Store K α → β, ∀ s c, c ≤ head s → F s c = view D s c := by + rw [appendInvariant_iff_prefixOnly] + constructor + · intro h + refine ⟨fun t ↦ F t (head t), fun s c hc ↦ ?_⟩ + change F s c = F (readAt s c) (head (readAt s c)) + rw [head_readAt_of_le hc] + exact h s c hc + · rintro ⟨D, hD⟩ s c hc + have hc' : c ≤ head (readAt s c) := le_of_eq (head_readAt_of_le hc).symm + rw [hD s c hc, hD (readAt s c) c hc'] + exact prefixOnly_view D s c hc + +end Reads + +/-! ### SNP-5 A derived store, three ways -/ + +section Generations + +variable {κ β : Type*} [DecidableEq κ] + +theorem stateOf_append_singleton (l : List (κ × β)) (e : κ × β) : + stateOf (l ++ [e]) = Function.update (stateOf l) e.1 (some e.2) := by + simp only [stateOf, List.foldl_append, List.foldl_cons, List.foldl_nil] + +theorem stateAt_length (l : List (κ × β)) : stateAt l l.length = stateOf l := by + unfold stateAt + rw [List.take_length] + +theorem stateAt_of_length_le {l : List (κ × β)} {c : ℕ} (h : l.length ≤ c) : + stateAt l c = stateOf l := by + unfold stateAt + rw [List.take_of_length_le h] + +/-- SNP-1 The state at a cut inside the chain does not change when the chain grows. -/ +theorem stateAt_append {l : List (κ × β)} (t : List (κ × β)) {c : ℕ} (h : c ≤ l.length) : + stateAt (l ++ t) c = stateAt l c := by + unfold stateAt + rw [List.take_append_of_le_length h] + +/-- SNP-3 The journal of the keyed state: the state at a later cut is the state at an earlier +cut with the writes between the two applied in order. -/ +theorem stateAt_eq_foldl (l : List (κ × β)) {a b : ℕ} (h : a ≤ b) : + stateAt l b = ((l.take b).drop a).foldl + (fun (m : κ → Option β) (e : κ × β) ↦ Function.update m e.1 (some e.2)) (stateAt l a) := by + have h1 : l.take a = (l.take b).take a := by rw [List.take_take, Nat.min_eq_left h] + unfold stateAt stateOf + rw [h1, ← List.foldl_append, List.take_append_drop] + +theorem stateOf_eq_find? (l : List (κ × β)) (x : κ) : + stateOf l x = (l.reverse.find? fun e ↦ decide (e.1 = x)).map Prod.snd := by + induction l using List.reverseRecOn with + | nil => rfl + | append_singleton l e ih => + rw [stateOf_append_singleton, List.reverse_append, List.reverse_singleton, + List.singleton_append] + by_cases hx : e.1 = x + · simp [hx] + · simp [hx, Function.update_of_ne (Ne.symm hx), ih] + +/-- SNP-5 The state at a cut is the last write of the key inside the prefix: one seek on an +index of (key, position). -/ +theorem stateAt_eq_lastWrite (l : List (κ × β)) (c : ℕ) (x : κ) : + stateAt l c x = lastWrite l c x := + stateOf_eq_find? _ x + +theorem closeAt_key (x : κ) (p : ℕ) (r : Gen κ β) : (closeAt x p r).key = r.key := by + unfold closeAt + split_ifs <;> rfl + +theorem closeAt_val (x : κ) (p : ℕ) (r : Gen κ β) : (closeAt x p r).val = r.val := by + unfold closeAt + split_ifs <;> rfl + +theorem closeAt_of_ne {x : κ} {r : Gen κ β} (h : r.key ≠ x) (p : ℕ) : closeAt x p r = r := by + simp only [closeAt, h, false_and, ↓reduceIte] + +/-- Closing a row at a position past the cut changes nothing the cut selects. -/ +theorem selects_closeAt_of_lt (x y : κ) {c p : ℕ} (h : c < p) (r : Gen κ β) : + selects c x (closeAt y p r) = selects c x r := by + unfold closeAt + split_ifs with hr + · simp [selects, Gen.aliveAt, hr.2, h] + · rfl + +/-- Closing the rows of one key changes nothing a read of another key selects. -/ +theorem selects_closeAt_of_ne {x y : κ} (h : x ≠ y) (c p : ℕ) (r : Gen κ β) : + selects c x (closeAt y p r) = selects c x r := by + by_cases hr : r.key = y + · have hx : r.key ≠ x := fun h' ↦ h (h'.symm.trans hr) + simp [selects, closeAt_key, hx] + · rw [closeAt_of_ne hr] + +/-- A row of the key closed at a position inside the cut is not selected, when every earlier +closing stamp lies under that position. -/ +theorem selects_closeAt_self {y : κ} {n c : ℕ} (hc : n + 1 ≤ c) {r : Gen κ β} + (hr : ∀ d, r.died = some d → d ≤ n) : selects c y (closeAt y (n + 1) r) = false := by + unfold closeAt + split_ifs with h + · simp [selects, Gen.aliveAt, Nat.not_lt.2 hc] + · by_cases hk : r.key = y + · obtain ⟨d, hd⟩ := Option.ne_none_iff_exists'.1 fun h0 ↦ h ⟨hk, h0⟩ + have hcd : ¬c < d := by have := hr d hd; omega + simp [selects, Gen.aliveAt, hd, hcd] + · simp [selects, hk] + +theorem gens_nil : gens ([] : List (κ × β)) = [] := rfl + +/-- The generational store is appended to, and one closing stamp is written: the landing of a +write closes the key's open row and opens its own. -/ +theorem gens_append_singleton (l : List (κ × β)) (e : κ × β) : + gens (l ++ [e]) = landGen (gens l) (l.length + 1) e := by + simp [gens, gensRev] + +theorem died_le_of_mem_gens {l : List (κ × β)} {r : Gen κ β} (hr : r ∈ gens l) : + ∀ d, r.died = some d → d ≤ l.length := by + induction l using List.reverseRecOn generalizing r with + | nil => simp [gens_nil] at hr + | append_singleton l e ih => + rw [gens_append_singleton] at hr + intro d hd + rw [List.length_append, List.length_singleton] + rcases List.mem_append.1 hr with hr | hr + · obtain ⟨r', hr', rfl⟩ := List.mem_map.1 hr + unfold closeAt at hd + split_ifs at hd with h + · have h1 : l.length + 1 = d := Option.some.inj hd + omega + · exact (ih hr' d hd).trans (Nat.le_succ _) + · rw [List.mem_singleton.1 hr] at hd + exact absurd hd (by simp) + +theorem find?_landGen_of_stable {rs : List (Gen κ β)} {p : ℕ} {e : κ × β} + {q : Gen κ β → Bool} (hq : ∀ r, q (closeAt e.1 p r) = q r) + (hnew : q ⟨e.1, e.2, p, none⟩ = false) : + ((landGen rs p e).find? q).map Gen.val = (rs.find? q).map Gen.val := by + have hcomp : q ∘ closeAt e.1 p = q := funext hq + unfold landGen + rw [List.find?_append, List.find?_map, hcomp, List.find?_singleton, hnew] + simp [Function.comp_def, closeAt_val] + +theorem find?_landGen_of_new {rs : List (Gen κ β)} {p : ℕ} {e : κ × β} {q : Gen κ β → Bool} + (hq : ∀ r ∈ rs, q (closeAt e.1 p r) = false) (hnew : q ⟨e.1, e.2, p, none⟩ = true) : + (landGen rs p e).find? q = some ⟨e.1, e.2, p, none⟩ := by + have hnone : (rs.map (closeAt e.1 p)).find? q = none := by + rw [List.find?_eq_none] + intro r hr + obtain ⟨r', hr', rfl⟩ := List.mem_map.1 hr + simp [hq r' hr'] + simp only [landGen, List.find?_append, hnone, Option.none_or, List.find?_singleton, hnew, + ↓reduceIte] + +/-- SNP-5 Generations are recomputation: the generational store read at a cut is the state +recomputed from the chain's prefix, at every cut. -/ +theorem genRead_gens (l : List (κ × β)) (c : ℕ) (x : κ) : + genRead (gens l) c x = stateAt l c x := by + induction l using List.reverseRecOn with + | nil => simp [genRead, gens_nil, stateAt, stateOf] + | append_singleton l e ih => + rw [gens_append_singleton] + unfold genRead at ih ⊢ + rcases Nat.lt_or_ge c (l.length + 1) with hc | hc + · rw [find?_landGen_of_stable (rs := gens l) (p := l.length + 1) (e := e) (q := selects c x) + (fun r ↦ selects_closeAt_of_lt x e.1 hc r) + (by simp [selects, Gen.aliveAt, Nat.not_le.2 hc]), ih, + stateAt_append [e] (Nat.le_of_lt_succ hc)] + · have hlen : (l ++ [e]).length ≤ c := by simpa using hc + rw [stateAt_of_length_le hlen, stateOf_append_singleton] + by_cases hx : x = e.1 + · subst hx + rw [find?_landGen_of_new (rs := gens l) (p := l.length + 1) (e := e) + (q := selects c e.1) (fun r hr ↦ selects_closeAt_self hc (died_le_of_mem_gens hr)) + (by simp [selects, Gen.aliveAt, hc])] + simp only [Option.map_some, Function.update_self] + · rw [find?_landGen_of_stable (rs := gens l) (p := l.length + 1) (e := e) + (q := selects c x) (fun r ↦ selects_closeAt_of_ne hx c _ r) + (by simp [selects, Ne.symm hx]), ih, Function.update_of_ne hx, + stateAt_of_length_le (Nat.le_of_succ_le hc)] + +/-- SNP-4 At the head cut the generational store reads the store rewritten in place. -/ +theorem genRead_gens_length (l : List (κ × β)) (x : κ) : + genRead (gens l) l.length x = stateOf l x := by + rw [genRead_gens, stateAt_length] + +/-- SNP-1 The generational store read at a cut inside the chain does not change when the chain +grows, though the growth writes closing stamps into it. -/ +theorem genRead_gens_append {l : List (κ × β)} (t : List (κ × β)) {c : ℕ} (h : c ≤ l.length) + (x : κ) : genRead (gens (l ++ t)) c x = genRead (gens l) c x := by + rw [genRead_gens, genRead_gens, stateAt_append t h] + +theorem length_filter_landGen_of_stable {rs : List (Gen κ β)} {p : ℕ} {e : κ × β} + {q : Gen κ β → Bool} (hq : ∀ r, q (closeAt e.1 p r) = q r) + (hnew : q ⟨e.1, e.2, p, none⟩ = false) : + ((landGen rs p e).filter q).length = (rs.filter q).length := by + have hcomp : q ∘ closeAt e.1 p = q := funext hq + unfold landGen + rw [List.filter_append, List.filter_map, hcomp] + simp [hnew] + +theorem length_filter_landGen_of_new {rs : List (Gen κ β)} {p : ℕ} {e : κ × β} + {q : Gen κ β → Bool} (hq : ∀ r ∈ rs, q (closeAt e.1 p r) = false) + (hnew : q ⟨e.1, e.2, p, none⟩ = true) : ((landGen rs p e).filter q).length = 1 := by + have hnil : (rs.map (closeAt e.1 p)).filter q = [] := by + rw [List.filter_eq_nil_iff] + intro r hr + obtain ⟨r', hr', rfl⟩ := List.mem_map.1 hr + simp [hq r' hr'] + unfold landGen + rw [List.filter_append, hnil] + simp [hnew] + +/-- SNP-5 At most one generation of a key is alive at a cut: the snapshot of a keyed store is a +transversal of its chains. -/ +theorem length_filter_selects_le_one (l : List (κ × β)) (c : ℕ) (x : κ) : + ((gens l).filter (selects c x)).length ≤ 1 := by + induction l using List.reverseRecOn with + | nil => simp [gens_nil] + | append_singleton l e ih => + rw [gens_append_singleton] + rcases Nat.lt_or_ge c (l.length + 1) with hc | hc + · exact (length_filter_landGen_of_stable (rs := gens l) (p := l.length + 1) (e := e) + (q := selects c x) (fun r ↦ selects_closeAt_of_lt x e.1 hc r) + (by simp [selects, Gen.aliveAt, Nat.not_le.2 hc])).le.trans ih + · by_cases hx : x = e.1 + · subst hx + exact (length_filter_landGen_of_new (rs := gens l) (p := l.length + 1) (e := e) + (q := selects c e.1) (fun r hr ↦ selects_closeAt_self hc (died_le_of_mem_gens hr)) + (by simp [selects, Gen.aliveAt, hc])).le + · exact (length_filter_landGen_of_stable (rs := gens l) (p := l.length + 1) (e := e) + (q := selects c x) (fun r ↦ selects_closeAt_of_ne hx c _ r) + (by simp [selects, Ne.symm hx])).le.trans ih + +/-- SNP-4 At the head cut nothing is sealed: a chain of landings and retires serves what the +store rewritten in place holds live. -/ +theorem servedAt_length (l : List (κ × Option β)) (x : κ) : + servedAt l l.length x = (stateOf l x).join := by + simp [servedAt, sealedAt, stateAt_length] + +/-- SNP-7 What is served at a cut is what the key held at the cut: the seal only withholds. -/ +theorem stateAt_of_servedAt {l : List (κ × Option β)} {c : ℕ} {x : κ} {v : β} + (h : servedAt l c x = some v) : stateAt l c x = some (some v) := by + by_cases hs : sealedAt l c x = true + · simp [servedAt, hs] at h + · simp only [servedAt, hs] at h + exact Option.join_eq_some_iff.1 h + +theorem sealedAt_append {l : List (κ × Option β)} (t : List (κ × Option β)) {c : ℕ} + (hc : c ≤ l.length) (x : κ) : + sealedAt (l ++ t) c x = (sealedAt l c x || t.any fun e ↦ decide (e.1 = x) && e.2.isNone) := by + unfold sealedAt + rw [List.drop_append_of_le_length hc, List.any_append] + +/-- SNP-7 Erasure dominance for a retire: once the chain retires a key, no cut before the +retire serves the key. -/ +theorem servedAt_append_of_retire {l t : List (κ × Option β)} {c : ℕ} {x : κ} + (hc : c ≤ l.length) (h : (x, none) ∈ t) : servedAt (l ++ t) c x = none := by + have hs : sealedAt (l ++ t) c x = true := by + rw [sealedAt_append t hc, Bool.or_eq_true] + exact Or.inr (List.any_eq_true.2 ⟨(x, none), h, by simp⟩) + simp only [servedAt, hs, ↓reduceIte] + +/-- SNP-1 under the seal: growth that does not retire the key changes nothing served of it at +a cut inside the chain. -/ +theorem servedAt_append_of_no_retire {l t : List (κ × Option β)} {c : ℕ} {x : κ} + (hc : c ≤ l.length) (h : (x, none) ∉ t) : servedAt (l ++ t) c x = servedAt l c x := by + have ht : (t.any fun e ↦ decide (e.1 = x) && e.2.isNone) = false := by + rw [Bool.eq_false_iff] + intro h' + obtain ⟨⟨e1, e2⟩, he, hq⟩ := List.any_eq_true.1 h' + simp only [Bool.and_eq_true, decide_eq_true_eq, Option.isNone_iff_eq_none] at hq + obtain ⟨rfl, rfl⟩ := hq + exact h he + unfold servedAt + rw [sealedAt_append t hc, ht, Bool.or_false, stateAt_append t hc] + +/-- SNP-7 Growth of the chain changes a served value only by removing it. -/ +theorem servedAt_of_append {l t : List (κ × Option β)} {c : ℕ} {x : κ} {v : β} + (hc : c ≤ l.length) (h : servedAt (l ++ t) c x = some v) : servedAt l c x = some v := by + by_cases ht : (x, none) ∈ t + · rw [servedAt_append_of_retire hc ht] at h + exact absurd h (by simp) + · rwa [servedAt_append_of_no_retire hc ht] at h + +end Generations + +/-! ### SNP-6 The grant -/ + +section Grant + +variable {K α : Type*} + +/-- SNP-6 A snapshot under a grant is append invariant. -/ +theorem snapshot_grow (G : K → Prop) [DecidablePred G] (p : α → Bool) {s : Store K α} + (t : Store K α) {c : Cut K} (h : c ≤ head s) : + snapshot G p (grow s t) c = snapshot G p s c := by + unfold snapshot + rw [readAt_grow t h] + +/-- Restricting twice is restricting to the chains both grants name and the events both +let through. -/ +theorem restrict_restrict (G G' : K → Prop) [DecidablePred G] [DecidablePred G'] + (p p' : α → Bool) (t : Store K α) : + restrict G p (restrict G' p' t) = restrict (fun k ↦ G k ∧ G' k) (fun a ↦ p a && p' a) t := by + funext k + by_cases h : G k <;> by_cases h' : G' k <;> simp [restrict, h, h', List.filter_filter] + +/-- SNP-6 Grant restriction: a narrower grant's snapshot is the restriction of a wider one's, +at every cut. What a wider grant was shown at a cut bounds what a narrower one is shown there. -/ +theorem snapshot_narrow {G G' : K → Prop} [DecidablePred G] [DecidablePred G'] + {p p' : α → Bool} (hG : ∀ k, G k → G' k) (hp : ∀ a, p a = true → p' a = true) + (s : Store K α) (c : Cut K) : + snapshot G p s c = restrict G p (snapshot G' p' s c) := by + funext k + by_cases h : G k + · have h' := hG k h + simp only [snapshot, restrict, h, h', ↓reduceIte, List.filter_filter] + refine List.filter_congr fun a _ ↦ ?_ + cases hpa : p a + · rfl + · simp [hp a hpa] + · simp [snapshot, restrict, h] + +/-- SNP-6 Noninterference: a snapshot under a grant reads only the chains the grant names, and +of the cut only its positions on them. Two stores that agree on those chains, at two cuts that +agree on them, are one snapshot. -/ +theorem snapshot_congr (G : K → Prop) [DecidablePred G] (p : α → Bool) {s s' : Store K α} + {c c' : Cut K} (hs : ∀ k, G k → s k = s' k) (hc : ∀ k, G k → c k = c' k) : + snapshot G p s c = snapshot G p s' c' := by + funext k + by_cases h : G k + · simp [snapshot, restrict, readAt, h, hs k h, hc k h] + · simp [snapshot, restrict, h] + +/-- SNP-4 At the head cut a snapshot is the grant's restriction of the store. -/ +theorem snapshot_head (G : K → Prop) [DecidablePred G] (p : α → Bool) (s : Store K α) : + snapshot G p s (head s) = restrict G p s := by + unfold snapshot + rw [readAt_head] + +/-- SNP-6 Restricting to chains commutes with the cut: a grant that names whole chains may be +applied before the read or after it. -/ +theorem restrict_readAt (G : K → Prop) [DecidablePred G] (s : Store K α) (c : Cut K) : + restrict G (fun _ ↦ true) (readAt s c) = readAt (restrict G (fun _ ↦ true) s) c := by + funext k + by_cases h : G k <;> simp [restrict, readAt, h] + +end Grant + +/-! ### SNP-7 The erasure -/ + +section Erasure + +variable {K α β C : Type*} + +/-- SNP-7 The store with holes keeps every position. -/ +theorem head_redact (E : α → Bool) (s : Store K α) : head (redact E s) = head s := + funext fun _ ↦ List.length_map _ + +/-- SNP-7 Erasing with holes commutes with the cut: the positions of the events that stay are +the positions they had. -/ +theorem redact_readAt (E : α → Bool) (s : Store K α) (c : Cut K) : + readAt (redact E s) c = redact E (readAt s c) := + funext fun _ ↦ List.map_take.symm + +theorem reduceOption_map_hole (E : α → Bool) (l : List α) : + (l.map fun a ↦ if E a then none else some a).reduceOption = l.filter fun a ↦ !E a := by + induction l with + | nil => rfl + | cons a l ih => + cases h : E a + · simp [h, List.reduceOption_cons_of_some, ih] + · simp [h, List.reduceOption_cons_of_none, ih] + +/-- SNP-7 What is visible at a cut is the store with holes read at the cut, the holes dropped. -/ +theorem visible_eq_reduceOption (E : α → Bool) (s : Store K α) (c : Cut K) (k : K) : + visible E s c k = (readAt (redact E s) c k).reduceOption := by + rw [redact_readAt] + exact (reduceOption_map_hole E _).symm + +/-- SNP-7 Erasure dominance: no erased event is visible at any cut. -/ +theorem not_erased_of_mem_visible {E : α → Bool} {s : Store K α} {c : Cut K} {k : K} {a : α} + (h : a ∈ visible E s c k) : E a = false := by + simpa using (List.mem_filter.1 h).2 + +/-- SNP-7 A larger erasure shows a sublist of what a smaller one shows, at every cut. -/ +theorem visible_sublist {E E' : α → Bool} (h : ∀ a, E a = true → E' a = true) + (s : Store K α) (c : Cut K) (k : K) : (visible E' s c k).Sublist (visible E s c k) := by + refine List.monotone_filter_right _ fun a ha ↦ ?_ + cases hE : E a + · rfl + · simp [h a hE] at ha + +/-- SNP-2 under an erasure: what is visible at an earlier cut is a prefix of what is visible +at a later one. -/ +theorem visible_mono (E : α → Bool) (s : Store K α) {c d : Cut K} (h : c ≤ d) (k : K) : + visible E s c k <+: visible E s d k := + (List.take_prefix_take_left (h k)).filter _ + +/-- SNP-4 under an erasure: at the head cut what is visible is the store without the erased +events. -/ +theorem visible_head (E : α → Bool) (s : Store K α) : visible E s (head s) = compact E s := + funext fun _ ↦ congrArg (List.filter fun a ↦ !E a) List.take_length + +/-- SNP-1 under an erasure: growth of the store changes nothing visible at a cut inside it. -/ +theorem visible_grow (E : α → Bool) {s : Store K α} (t : Store K α) {c : Cut K} + (h : c ≤ head s) : visible E (grow s t) c = visible E s c := + funext fun k ↦ congrArg (List.filter fun a ↦ !E a) (List.take_append_of_le_length (h k)) + +/-- SNP-7 Two stores that differ only in erased events show the same at every cut. -/ +theorem visible_congr {E : α → Bool} {s s' : Store K α} (h : redact E s = redact E s') + (c : Cut K) : visible E s c = visible E s' c := by + funext k + rw [visible_eq_reduceOption, visible_eq_reduceOption, h] + +/-- SNP-7 So erased content is an argument of no read: every derivation of what is visible at +a cut is the same on two stores that differ only in erased events. -/ +theorem erased_invisible (D : Store K α → β) {E : α → Bool} {s s' : Store K α} + (h : redact E s = redact E s') (c : Cut K) : D (visible E s c) = D (visible E s' c) := + congrArg D (visible_congr h c) + +/-- SNP-7 A kept derived row is served exactly when none of its sources is erased. -/ +theorem mem_serve_iff {E : α → Bool} {rows : List (List α × β)} {r : List α × β} : + r ∈ serve E rows ↔ r ∈ rows ∧ ∀ a ∈ r.1, E a = false := by + simp [serve, List.mem_filter] + +/-- SNP-7 A larger erasure serves a sublist of the kept rows. -/ +theorem serve_sublist {E E' : α → Bool} (h : ∀ a, E a = true → E' a = true) + (rows : List (List α × β)) : (serve E' rows).Sublist (serve E rows) := by + refine List.monotone_filter_right _ fun r hr ↦ ?_ + rw [List.all_eq_true] at hr ⊢ + intro a ha + have h1 := hr a ha + cases hE : E a + · rfl + · simp [h a hE] at h1 + +/-- SNP-9 An erasure on a committed store keeps every commitment in its place. -/ +theorem commitments_purge (E : α → Bool) (t : Store K (C × Option α)) : + commitments (purge E t) = commitments t := by + funext k + simp [commitments, purge, Function.comp_def] + +/-- SNP-7 What a reader reads of a committed store after an erasure is the store with holes. -/ +theorem contents_purge_committed (commit : α → C) (E : α → Bool) (s : Store K α) : + contents (purge E (committed commit s)) = redact E s := by + funext k + simp only [contents, purge, committed, redact, List.map_map] + refine List.map_congr_left fun a _ ↦ ?_ + cases h : E a <;> simp [h] + +end Erasure + +/-! ### SNP-8 Consistent cuts -/ + +section Consistency + +variable {K : Type*} {R : K → ℕ → K → ℕ → Prop} + +/-- The empty cut is consistent. -/ +theorem consistent_zero : Consistent R fun _ ↦ 0 := fun _ _ _ _ _ h ↦ absurd h (Nat.not_lt_zero _) + +/-- SNP-8 Consistent cuts are closed under the meet. -/ +theorem Consistent.inf {c d : Cut K} (hc : Consistent R c) (hd : Consistent R d) : + Consistent R (c ⊓ d) := fun k i k' j h hi ↦ by + have hi' : i < c k ∧ i < d k := lt_inf_iff.1 hi + exact lt_inf_iff.2 ⟨hc k i k' j h hi'.1, hd k i k' j h hi'.2⟩ + +/-- SNP-8 And under the join. -/ +theorem Consistent.sup {c d : Cut K} (hc : Consistent R c) (hd : Consistent R d) : + Consistent R (c ⊔ d) := fun k i k' j h hi ↦ by + have hi' : i < c k ∨ i < d k := lt_sup_iff.1 hi + rcases hi' with hi' | hi' + · exact lt_sup_iff.2 (Or.inl (hc k i k' j h hi')) + · exact lt_sup_iff.2 (Or.inr (hd k i k' j h hi')) + +/-- SNP-8 The consistent cuts are a sublattice of the cuts, so a distributive lattice. -/ +def consistentCuts (R : K → ℕ → K → ℕ → Prop) : Sublattice (Cut K) where + carrier := {c | Consistent R c} + supClosed' := fun _ hc _ hd ↦ Consistent.sup hc hd + infClosed' := fun _ hc _ hd ↦ Consistent.inf hc hd + +/-- SNP-8 The consistent cuts are the clock's cuts (CLK-2) among the frontier cuts: a cut is +consistent exactly when the events under its frontier are a down-set of the order the append +chains and the reads-from references generate. -/ +theorem consistent_iff_isCut (R : K → ℕ → K → ℕ → Prop) (c : Cut K) : + Consistent R c ↔ Clock.IsCut (generator R) (Clock.frontierCut Prod.fst Prod.snd c) := by + rw [Clock.isCut_iff_not_crossed] + constructor + · rintro h ⟨a, b, hab, hb, ha⟩ + have hb' : b.2 < c b.1 := hb + rcases hab with ⟨h1, h2⟩ | hR + · refine ha ?_ + change a.2 < c a.1 + rw [h1] + exact lt_trans h2 hb' + · exact ha (h _ _ _ _ hR hb') + · intro h k i k' j hR hi + by_contra hj + exact h ⟨(k', j), (k, i), Or.inr hR, hi, hj⟩ + +/-- A frontier resolves to at most one cut. -/ +theorem Resolves.unique {f c c' : Cut K} (h : Resolves R f c) (h' : Resolves R f c') : c = c' := + le_antisymm (h'.2.2 c h.1 h.2.1) (h.2.2 c' h'.1 h'.2.1) + +/-- SNP-8 Resolution is monotone: a later frontier resolves to a later cut. -/ +theorem Resolves.mono {f f' c c' : Cut K} (hf : f ≤ f') (h : Resolves R f c) + (h' : Resolves R f' c') : c ≤ c' := + h'.2.2 c h.1 (h.2.1.trans hf) + +/-- A consistent frontier resolves to itself. -/ +theorem resolves_self {f : Cut K} (h : Consistent R f) : Resolves R f f := + ⟨h, le_rfl, fun _ _ hd ↦ hd⟩ + +/-- SNP-8 Every frontier resolves: among the consistent cuts under it there is a greatest. -/ +theorem exists_resolves (R : K → ℕ → K → ℕ → Prop) (f : Cut K) : ∃ c, Resolves R f c := by + have hne : ∀ k, (reached R f k).Nonempty := fun k ↦ + ⟨0, fun _ ↦ 0, consistent_zero, fun _ ↦ Nat.zero_le _, rfl⟩ + have hbdd : ∀ k, BddAbove (reached R f k) := fun k ↦ + ⟨f k, by rintro n ⟨d, -, hd, rfl⟩; exact hd k⟩ + refine ⟨fun k ↦ sSup (reached R f k), ?_, ?_, ?_⟩ + · intro k i k' j hR hi + obtain ⟨d, hd, hdf, hdk⟩ := Nat.sSup_mem (hne k) (hbdd k) + have hj : j < d k' := hd k i k' j hR (by rw [hdk]; exact hi) + exact lt_of_lt_of_le hj (le_csSup (hbdd k') ⟨d, hd, hdf, rfl⟩) + · intro k + exact csSup_le (hne k) (by rintro n ⟨d, -, hd, rfl⟩; exact hd k) + · intro d hd hdf k + exact le_csSup (hbdd k) ⟨d, hd, hdf, rfl⟩ + +/-- SNP-8 Consistency is append invariant: when the references a store gains by growing all +start at events at or past its old head, a cut inside the old head that was consistent stays +consistent. -/ +theorem Consistent.of_grown {R' : K → ℕ → K → ℕ → Prop} {h c : Cut K} + (hR : ∀ k i k' j, R' k i k' j → R k i k' j ∨ h k ≤ i) (hc : c ≤ h) + (hcons : Consistent R c) : Consistent R' c := fun k i k' j hr hi ↦ + (hR k i k' j hr).elim (fun h0 ↦ hcons k i k' j h0 hi) + fun hle ↦ absurd (lt_of_lt_of_le hi (hc k)) (not_lt.2 hle) + +end Consistency + +/-! ### SNP-9 Certified cuts -/ + +section Certified + +variable {K α C H : Type*} {step : H → α → H} {h₀ : H} + +theorem verifies_certify {s : Store K α} {c : Cut K} (h : c ≤ head s) : + Verifies step h₀ (certify step h₀ s c) s := + ⟨h, fun _ ↦ rfl⟩ + +/-- SNP-9 A certificate is append invariant: the certificate of a cut of a store verifies on +every extension of the store. -/ +theorem verifies_certify_of_extends {s s' : Store K α} {c : Cut K} (h : Extends s s') + (hc : c ≤ head s) : Verifies step h₀ (certify step h₀ s c) s' := + ⟨hc.trans h.head_le, + fun k ↦ congrArg (chainDigest step h₀) (congrFun (readAt_of_extends h hc) k)⟩ + +theorem chainDigest_append_singleton (step : H → α → H) (h₀ : H) (l : List α) (a : α) : + chainDigest step h₀ (l ++ [a]) = step (chainDigest step h₀ l) a := by + simp only [chainDigest, List.foldl_append, List.foldl_cons, List.foldl_nil] + +/-- Under a collision-free step, two chains of one length with one digest are one chain. -/ +theorem eq_of_chainDigest_eq (hstep : CollisionFree step) {l l' : List α} + (hlen : l.length = l'.length) + (h : chainDigest step h₀ l = chainDigest step h₀ l') : l = l' := by + induction l using List.reverseRecOn generalizing l' with + | nil => exact (List.length_eq_zero_iff.1 hlen.symm).symm + | append_singleton l a ih => + rcases List.eq_nil_or_concat l' with rfl | ⟨m, b, rfl⟩ + · simp at hlen + · rw [List.concat_eq_append] at hlen h + rw [chainDigest_append_singleton, chainDigest_append_singleton] at h + obtain ⟨h1, rfl⟩ := hstep _ _ _ _ h + rw [List.concat_eq_append, ih (by simpa using hlen) h1] + +/-- SNP-9 A certificate pins the read: under a collision-free digest, two stores that verify +one certificate have the same read at its cut. -/ +theorem Verifies.readAt_eq (hstep : CollisionFree step) {z : Certificate K H} + {s s' : Store K α} (h : Verifies step h₀ z s) (h' : Verifies step h₀ z s') : + readAt s z.cut = readAt s' z.cut := by + funext k + refine eq_of_chainDigest_eq hstep ?_ ((h.2 k).trans (h'.2 k).symm) + have hk : z.cut k ≤ (s k).length := h.1 k + have hk' : z.cut k ≤ (s' k).length := h'.1 k + change ((s k).take (z.cut k)).length = ((s' k).take (z.cut k)).length + rw [List.length_take, List.length_take, Nat.min_eq_left hk, Nat.min_eq_left hk'] + +/-- SNP-9 So a snapshot is reproducible and checkable: every derived view at a certified cut +is the same on every store that verifies the certificate. -/ +theorem Verifies.view_eq {β : Type*} (hstep : CollisionFree step) (D : Store K α → β) + {z : Certificate K H} {s s' : Store K α} (h : Verifies step h₀ z s) + (h' : Verifies step h₀ z s') : view D s z.cut = view D s' z.cut := + congrArg D (h.readAt_eq hstep h') + +/-- SNP-9 A certificate extends: the digest at a later cut is the digest at an earlier cut +continued over the events between the two, so certifying costs the delta. -/ +theorem certify_digest_readBetween (s : Store K α) {a b : Cut K} (h : a ≤ b) (k : K) : + (certify step h₀ s b).digest k + = chainDigest step ((certify step h₀ s a).digest k) (readBetween s a b k) := + foldAt_readBetween step (fun _ ↦ h₀) s h k + +/-- SNP-9 The meet of two certified cuts is certified from the two certificates alone: on each +chain, the digest of the one that is earlier there. -/ +theorem certify_inf (s : Store K α) (c d : Cut K) (k : K) : + (certify step h₀ s (c ⊓ d)).digest k + = if c k ≤ d k then (certify step h₀ s c).digest k else (certify step h₀ s d).digest k := by + by_cases h : c k ≤ d k + · simp only [h, ↓reduceIte] + change chainDigest step h₀ ((s k).take (c k ⊓ d k)) = chainDigest step h₀ ((s k).take (c k)) + rw [inf_of_le_left h] + · simp only [h, ↓reduceIte] + change chainDigest step h₀ ((s k).take (c k ⊓ d k)) = chainDigest step h₀ ((s k).take (d k)) + rw [inf_of_le_right (not_le.1 h).le] + +/-- SNP-9 And the join: on each chain, the digest of the one that is later there. -/ +theorem certify_sup (s : Store K α) (c d : Cut K) (k : K) : + (certify step h₀ s (c ⊔ d)).digest k + = if c k ≤ d k then (certify step h₀ s d).digest k else (certify step h₀ s c).digest k := by + by_cases h : c k ≤ d k + · simp only [h, ↓reduceIte] + change chainDigest step h₀ ((s k).take (c k ⊔ d k)) = chainDigest step h₀ ((s k).take (d k)) + rw [sup_of_le_right h] + · simp only [h, ↓reduceIte] + change chainDigest step h₀ ((s k).take (c k ⊔ d k)) = chainDigest step h₀ ((s k).take (c k)) + rw [sup_of_le_left (not_le.1 h).le] + +/-- SNP-9 Erasure keeps the certificate: a certificate over the commitments of a committed +store verifies after any erasure of contents. -/ +theorem verifies_purge {step : H → C → H} {z : Certificate K H} {t : Store K (C × Option α)} + (E : α → Bool) (h : Verifies step h₀ z (commitments t)) : + Verifies step h₀ z (commitments (purge E t)) := by + rwa [commitments_purge] + +end Certified + +namespace Witness + +/-- The control for SNP-1: the reader that ignores the cut, which is what a verb reads of a +store rewritten in place, is not append invariant. -/ +theorem present_not_appendInvariant : + ¬AppendInvariant (present fun s : Store Unit ℕ ↦ (s ()).length) := by + intro h + have h1 := h (fun _ ↦ []) (fun _ ↦ [0]) (fun _ ↦ 0) (fun _ ↦ le_rfl) + simp [present, grow] at h1 + +/-- The control for SNP-5: the store rewritten in place determines no read at a past cut. Two +chains leave one head state and had different states at the first cut. -/ +theorem stateOf_forgets : + ¬∃ G : (Unit → Option ℕ) → ℕ → Unit → Option ℕ, + ∀ (l : List (Unit × ℕ)) (c : ℕ), stateAt l c = G (stateOf l) c := by + rintro ⟨G, hG⟩ + have h1 := congrFun (hG [((), 0), ((), 1)] 1) () + have h2 := congrFun (hG [((), 1)] 1) () + have e : stateOf [((), 0), ((), 1)] = stateOf [((), 1)] := by + funext u + simp [stateOf] + rw [e, ← h2] at h1 + simp [stateAt, stateOf] at h1 + +/-- The control for SNP-6: an event filter applied before the cut reads another thing than the +snapshot, since it moves the positions. -/ +theorem filter_before_cut : + ∃ (s : Store Unit Bool) (c : Cut Unit), + readAt (restrict (fun _ ↦ True) id s) c ≠ snapshot (fun _ ↦ True) id s c := by + refine ⟨fun _ ↦ [false, true], fun _ ↦ 1, fun h ↦ ?_⟩ + have h1 := congrFun h () + simp [readAt, restrict, snapshot] at h1 + +/-- The control for SNP-6: a cut's positions count the events an event filter hides. Two stores +that agree on every admitted event have different snapshots at one cut, so within a chain a +position tells how many hidden events came before: what must be hidden in number is hidden by +chain. -/ +theorem position_channel : + ∃ (s s' : Store Unit Bool) (c : Cut Unit), (∀ k, (s k).filter id = (s' k).filter id) ∧ + snapshot (fun _ ↦ True) id s c ≠ snapshot (fun _ ↦ True) id s' c := by + refine ⟨fun _ ↦ [false, true], fun _ ↦ [true], fun _ ↦ 1, fun _ ↦ rfl, fun h ↦ ?_⟩ + have h1 := congrFun h () + simp [readAt, restrict, snapshot] at h1 + +/-- The control for SNP-7: an erasure that deletes rows moves the later ones up, so a read at a +cut then holds an event from after the cut. -/ +theorem compact_moves : + ∃ (E : ℕ → Bool) (s : Store Unit ℕ) (c : Cut Unit) (a : ℕ), + a ∈ readAt (compact E s) c () ∧ a ∉ readAt s c () := by + refine ⟨fun n ↦ n == 0, fun _ ↦ [0, 1], fun _ ↦ 1, 1, ?_, ?_⟩ <;> simp [readAt, compact] + +/-- The control for SNP-9: a digest that is not collision free pins nothing. Under addition two +chains of one length and one digest differ. -/ +theorem digest_collides : + ∃ l l' : List ℕ, l.length = l'.length ∧ + chainDigest (· + ·) 0 l = chainDigest (· + ·) 0 l' ∧ l ≠ l' := + ⟨[1, 2], [2, 1], rfl, rfl, by decide⟩ + +end Witness + +end Palace.Snapshot diff --git a/formal/Palace/Snapshot/Defs.lean b/formal/Palace/Snapshot/Defs.lean new file mode 100644 index 00000000..37c3d39e --- /dev/null +++ b/formal/Palace/Snapshot/Defs.lean @@ -0,0 +1,294 @@ +module + +public import Mathlib.Data.List.Basic +public import Mathlib.Logic.Function.Basic +public import Mathlib.Order.Basic +public import Mathlib.Order.SetNotation + +/-! +# The temporal snapshot: the model + +dn-temporal-snapshot, on the clock's cuts (`Palace/Clock/Defs.lean`, CLK-2). A **store** is a +family of append chains: for every chain key the events appended to it, in order. The palace's +ledgers are such families (a document's versions, a session's turns, a class's landing log, the +attestations), and a chain only grows at its end. A **cut** is a prefix length for every chain, +the vector of per-chain positions of dn-global-event-clock §2.4. The **read at a cut** is the +prefix of every chain, the **read between two cuts** the events after the first and up to the +second, and a **derived view** at a cut is a derivation applied to the prefixes. + +What is derived can be held three ways, and the model has each: recomputed from the prefix +(`stateAt`, the fold of a chain of keyed writes), journaled (the same fold continued from a +checkpoint over the events between two cuts, `foldAt`), or kept by generation (`gens`: one row +per write, valid from the cut that contains it up to the cut that contains the key's next write, +read by `genRead`). The store rewritten in place is `stateOf`, the fold of the whole chain, which +has no past. + +Two things are parameters of a read and no function of the cut, because they are the present's: +the asker's **grant** (`snapshot`: the chains it names and the events it may see named) and the +**erasure** (`visible`: the erased events masked; `redact`: the store with a hole at each, every +position kept; `servedAt`: a key retired after the cut is served at no earlier cut). The control +for the erasure is `compact`, an erasure that deletes rows and lets the later ones move up. + +Events may read from events of other chains (`R k i k' j`: the `i`-th event of chain `k` reads +from the `j`-th of chain `k'`); a cut is **consistent** when every source of an event inside it is +inside it, and a frontier **resolves** to the greatest consistent cut under it. A cut is +**certified** by the digest of each chain's prefix under a chain digest (`chainDigest`, a fold), +and a later store **verifies** the certificate when its own prefixes have those digests. A store +that keeps a commitment beside each event (`committed`) can lose an event's content to an erasure +(`purge`) and keep every certificate. +-/ + +@[expose] public section + +namespace Palace.Snapshot + +/-- A store: a family of append chains, the events of each chain in the order they were +appended. -/ +abbrev Store (K α : Type*) := K → List α + +/-- A cut: a prefix length for every chain (dn-global-event-clock §2.4, the vector of per-chain +positions). -/ +abbrev Cut (K : Type*) := K → ℕ + +/-! ### Reads -/ + +section Reads + +variable {K α β : Type*} + +/-- The head cut: every chain whole. -/ +def head (s : Store K α) : Cut K := fun k ↦ (s k).length + +/-- The store grown by appending `t`, chain by chain. -/ +def grow (s t : Store K α) : Store K α := fun k ↦ s k ++ t k + +/-- `s'` extends `s`: every chain of `s` is a prefix of its chain in `s'`, which is all an +append-only store can do. -/ +def Extends (s s' : Store K α) : Prop := ∀ k, s k <+: s' k + +/-- The read at a cut: the prefix of every chain. -/ +def readAt (s : Store K α) (c : Cut K) : Store K α := fun k ↦ (s k).take (c k) + +/-- The read between two cuts: the events after `a` and up to `b`, chain by chain. -/ +def readBetween (s : Store K α) (a b : Cut K) : Store K α := + fun k ↦ ((s k).take (b k)).drop (a k) + +/-- A derived view at a cut: the derivation applied to the prefixes. -/ +def view (D : Store K α → β) (s : Store K α) (c : Cut K) : β := D (readAt s c) + +/-- The reader that ignores the cut: the derivation applied to the whole store, which is what a +verb reads of a store that keeps no past. -/ +def present (D : Store K α → β) : Store K α → Cut K → β := fun s _ ↦ D s + +/-- A reader of a store at a cut is append invariant when no growth of the store changes what it +reads at a cut inside the store. -/ +def AppendInvariant (F : Store K α → Cut K → β) : Prop := + ∀ s t c, c ≤ head s → F (grow s t) c = F s c + +/-- A reader reads only the prefixes when what it reads at a cut inside the store is what it +reads of the prefixes alone. -/ +def PrefixOnly (F : Store K α → Cut K → β) : Prop := + ∀ s c, c ≤ head s → F s c = F (readAt s c) c + +/-- A journaled view: every chain's prefix folded by a step function from the chain's start +value. A job that keeps such a state and a checkpoint continues the fold over the events between +its checkpoint and a later cut. -/ +def foldAt (f : β → α → β) (init : K → β) (s : Store K α) (c : Cut K) : K → β := + fun k ↦ ((s k).take (c k)).foldl f (init k) + +end Reads + +/-! ### A derived store, three ways -/ + +section Generations + +variable {κ β : Type*} + +/-- The store rewritten in place: after a chain of keyed writes, each key's last value. It is +the fold of the whole chain, so it has no past. -/ +def stateOf [DecidableEq κ] (l : List (κ × β)) : κ → Option β := + l.foldl (fun m e ↦ Function.update m e.1 (some e.2)) fun _ ↦ none + +/-- The state at a cut, recomputed from the chain's prefix. -/ +def stateAt [DecidableEq κ] (l : List (κ × β)) (c : ℕ) : κ → Option β := stateOf (l.take c) + +/-- The state at a cut read off the chain by one seek: the last write of the key inside the +prefix. -/ +def lastWrite [DecidableEq κ] (l : List (κ × β)) (c : ℕ) (x : κ) : Option β := + ((l.take c).reverse.find? fun e ↦ decide (e.1 = x)).map Prod.snd + +/-- A generation: one write of a key, valid from the cut `born` up to, and not at, the cut +`died`. -/ +structure Gen (κ β : Type*) where + /-- The key written. -/ + key : κ + /-- The value written. -/ + val : β + /-- The first cut that contains the write. -/ + born : ℕ + /-- The first cut that contains the key's next write; `none` while the row is the key's + head. -/ + died : Option ℕ + +/-- A generation is alive at a cut from its birth up to, and not at, its death. -/ +def Gen.aliveAt (r : Gen κ β) (c : ℕ) : Bool := + decide (r.born ≤ c) && r.died.all fun d ↦ decide (c < d) + +/-- Close a row at position `p` when it is the open row of the key `x`; any other row is left +as it is. The closing stamp is the one field ever written after a row is appended, and it is a +function of the rows: the position of the key's next write. -/ +def closeAt [DecidableEq κ] (x : κ) (p : ℕ) (r : Gen κ β) : Gen κ β := + if r.key = x ∧ r.died = none then { r with died := some p } else r + +/-- One landing in the generational store, at position `p`: the key's open row is closed at `p` +and the write's own row opens there. -/ +def landGen [DecidableEq κ] (rs : List (Gen κ β)) (p : ℕ) (e : κ × β) : List (Gen κ β) := + rs.map (closeAt e.1 p) ++ [⟨e.1, e.2, p, none⟩] + +/-- The generational store of a chain given newest first: the write over `n` older ones lands at +position `n + 1`, the first cut that contains it. -/ +def gensRev [DecidableEq κ] : List (κ × β) → List (Gen κ β) + | [] => [] + | e :: older => landGen (gensRev older) (older.length + 1) e + +/-- The generational store after a chain of keyed writes. -/ +def gens [DecidableEq κ] (l : List (κ × β)) : List (Gen κ β) := gensRev l.reverse + +/-- What a read of the generational store selects: the rows of the key alive at the cut. -/ +def selects [DecidableEq κ] (c : ℕ) (x : κ) (r : Gen κ β) : Bool := + decide (r.key = x) && r.aliveAt c + +/-- The read of the generational store at a cut: the value of the key's row alive there. -/ +def genRead [DecidableEq κ] (rs : List (Gen κ β)) (c : ℕ) (x : κ) : Option β := + (rs.find? (selects c x)).map Gen.val + +/-- A key is sealed at a cut when the chain retires it after the cut: a retire, the write of +`none`, among the events the cut does not contain. -/ +def sealedAt [DecidableEq κ] (l : List (κ × Option β)) (c : ℕ) (x : κ) : Bool := + (l.drop c).any fun e ↦ decide (e.1 = x) && e.2.isNone + +/-- What a chain of landings and retires serves of a key at a cut: nothing when the key is +sealed there, else the value the key held at the cut, if it was live. The seal is read off the +whole chain, the present, and no prefix of it. -/ +def servedAt [DecidableEq κ] (l : List (κ × Option β)) (c : ℕ) (x : κ) : Option β := + if sealedAt l c x then none else (stateAt l c x).join + +end Generations + +/-! ### The grant and the erasure, the present's -/ + +section Present + +variable {K α β C : Type*} + +/-- A family of chains restricted to the chains `G` names and, within them, to the events `p` +admits. -/ +def restrict (G : K → Prop) [DecidablePred G] (p : α → Bool) (t : Store K α) : Store K α := + fun k ↦ if G k then (t k).filter p else [] + +/-- What a grant reads of a store at a cut: the chains it names, each read at the cut and kept to +the events it may see named. The grant is no function of the cut: it is the asker's now. -/ +def snapshot (G : K → Prop) [DecidablePred G] (p : α → Bool) (s : Store K α) (c : Cut K) : + Store K α := + restrict G p (readAt s c) + +/-- The store with every erased event replaced by a hole: the erasure keeps every position. -/ +def redact (E : α → Bool) (s : Store K α) : Store K (Option α) := + fun k ↦ (s k).map fun a ↦ if E a then none else some a + +/-- What is visible at a cut once `E` is erased: the prefixes without the erased events. The +erasure is no function of the cut either. -/ +def visible (E : α → Bool) (s : Store K α) (c : Cut K) : Store K α := + fun k ↦ ((s k).take (c k)).filter fun a ↦ !E a + +/-- The control: an erasure that deletes the rows, so that the later ones move up. -/ +def compact (E : α → Bool) (s : Store K α) : Store K α := + fun k ↦ (s k).filter fun a ↦ !E a + +/-- The kept derived rows that may be served once `E` is erased: those none of whose sources is +erased. A row is its sources and its value. -/ +def serve (E : α → Bool) (rows : List (List α × β)) : List (List α × β) := + rows.filter fun r ↦ r.1.all fun a ↦ !E a + +/-- A store that keeps a commitment beside each event: the pair of the event's commitment and +its content. -/ +def committed (commit : α → C) (s : Store K α) : Store K (C × Option α) := + fun k ↦ (s k).map fun a ↦ (commit a, some a) + +/-- The erasure on a committed store: the content of every erased event goes, its commitment +and its position stay. -/ +def purge (E : α → Bool) (t : Store K (C × Option α)) : Store K (C × Option α) := + fun k ↦ (t k).map fun x ↦ (x.1, x.2.filter fun a ↦ !E a) + +/-- The commitments of a committed store, chain by chain: what a certificate digests. -/ +def commitments (t : Store K (C × Option α)) : Store K C := fun k ↦ (t k).map Prod.fst + +/-- The contents of a committed store, chain by chain, a hole where an event was erased: what a +reader reads. -/ +def contents (t : Store K (C × Option α)) : Store K (Option α) := fun k ↦ (t k).map Prod.snd + +end Present + +/-! ### Consistent cuts -/ + +section Consistency + +variable {K : Type*} + +/-- A cut is consistent for the reads-from relation `R` (`R k i k' j`: the `i`-th event of chain +`k` reads from the `j`-th event of chain `k'`) when every source of an event inside the cut is +inside it: no fact whose sources lie after the cut. -/ +def Consistent (R : K → ℕ → K → ℕ → Prop) (c : Cut K) : Prop := + ∀ k i k' j, R k i k' j → i < c k → j < c k' + +/-- The generator edges of the clock on events as (chain, index) pairs: an earlier event of a +chain is before a later one (g1), and a source is before its reader (g2). -/ +def generator (R : K → ℕ → K → ℕ → Prop) (a b : K × ℕ) : Prop := + (a.1 = b.1 ∧ a.2 < b.2) ∨ R b.1 b.2 a.1 a.2 + +/-- The positions of chain `k` that some consistent cut under the frontier `f` reaches. -/ +def reached (R : K → ℕ → K → ℕ → Prop) (f : Cut K) (k : K) : Set ℕ := + {n | ∃ d, Consistent R d ∧ d ≤ f ∧ d k = n} + +/-- The cut `c` resolves the frontier `f`: it is the greatest consistent cut under `f`. A name +(a commit, a certificate, a wall time looked up in the bookmarks) selects a frontier; the read is +at the cut that resolves it. -/ +def Resolves (R : K → ℕ → K → ℕ → Prop) (f c : Cut K) : Prop := + Consistent R c ∧ c ≤ f ∧ ∀ d, Consistent R d → d ≤ f → d ≤ c + +end Consistency + +/-! ### Certified cuts -/ + +section Certified + +variable {K α H : Type*} + +/-- The digest of a chain's prefix: the fold of a step function from a seed, the shape of a hash +chain. -/ +def chainDigest (step : H → α → H) (h₀ : H) (l : List α) : H := l.foldl step h₀ + +/-- A step function is collision free when it is injective in the pair of the digest so far and +the event: the property a cryptographic hash is used for. -/ +def CollisionFree (step : H → α → H) : Prop := + ∀ h a h' a', step h a = step h' a' → h = h' ∧ a = a' + +/-- A certificate of a cut: the cut and the digest of every chain's prefix at it. -/ +structure Certificate (K H : Type*) where + /-- The cut certified. -/ + cut : Cut K + /-- The digest of each chain's prefix at the cut. -/ + digest : K → H + +/-- The certificate of a cut of a store. -/ +def certify (step : H → α → H) (h₀ : H) (s : Store K α) (c : Cut K) : Certificate K H := + ⟨c, fun k ↦ chainDigest step h₀ ((s k).take (c k))⟩ + +/-- A store verifies a certificate when the cut lies inside it and its own prefixes at the cut +have the certified digests. -/ +def Verifies (step : H → α → H) (h₀ : H) (z : Certificate K H) (s : Store K α) : Prop := + z.cut ≤ head s ∧ ∀ k, chainDigest step h₀ ((s k).take (z.cut k)) = z.digest k + +end Certified + +end Palace.Snapshot From a296ccf9e7e166d7563459485ae07c5e0ad5d44e Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Tue, 10 Nov 2026 21:05:53 -0500 Subject: [PATCH 02/37] feat(formal): two seals for a retired key, in their order (SNP-7) A key retired after a cut must not be served at the cut. Two rules do that, and the design note has to choose between them, so both are in the model. The stricter one (`servedAt`) reads the seal off the chain: a retire among the events past the cut closes every earlier cut for good, and growth of the chain changes a served value only by removing it. The looser one (`servedNow`) withholds a key only while it is not live at the head, so a landing after the retire brings the key's past back. `servedNow_of_servedAt` proves the order: whatever the stricter seal serves, the looser one serves, so either rule bounds the other and both keep a key that is retired now out of every cut (`servedNow_of_not_live`). `Witness.servedNow_restores` is the cost of the looser rule as a theorem: under it growth does not only remove. Co-Authored-By: Claude Fable 5.2 --- formal/Palace/Snapshot.lean | 67 +++++++++++++++++++++++++++++++- formal/Palace/Snapshot/Defs.lean | 10 ++++- 2 files changed, 73 insertions(+), 4 deletions(-) diff --git a/formal/Palace/Snapshot.lean b/formal/Palace/Snapshot.lean index 4b945fa9..140754ea 100644 --- a/formal/Palace/Snapshot.lean +++ b/formal/Palace/Snapshot.lean @@ -46,8 +46,11 @@ a cut a prefix length for each. Cited from the note, not from the ledger. `visible_sublist`, `redact_readAt`, `erased_invisible`); a kept derived row is served only when none of its sources is erased (`mem_serve_iff`); a key retired after a cut is served at no earlier cut, and growth of the chain changes a served value only by removing it - (`servedAt_append_of_retire`, `servedAt_append_of_no_retire`, `servedAt_of_append`). The control - is the erasure that deletes rows (`Witness.compact_moves`). + (`servedAt_append_of_retire`, `servedAt_append_of_no_retire`, `servedAt_of_append`); the looser + seal, under which a key is withheld only while it is not live, serves everything the stricter + one serves and is lifted by a later landing (`servedNow_of_servedAt`, + `Witness.servedNow_restores`). The control is the erasure that deletes rows + (`Witness.compact_moves`). * SNP-8, consistent cuts: closed under meet and join, so a sublattice of the cuts (`Consistent.inf`, `Consistent.sup`, `consistentCuts`); they are the clock's cuts, CLK-2, among the frontier cuts (`consistent_iff_isCut`); every frontier resolves to exactly one greatest @@ -507,6 +510,58 @@ theorem servedAt_of_append {l t : List (κ × Option β)} {c : ℕ} {x : κ} {v exact absurd h (by simp) · rwa [servedAt_append_of_no_retire hc ht] at h +theorem isSome_join_foldl {t : List (κ × Option β)} {m : κ → Option (Option β)} {x : κ} + (hm : ((m x).join).isSome = true) (ht : ∀ e ∈ t, e.1 = x → e.2.isSome = true) : + (((t.foldl (fun (m : κ → Option (Option β)) (e : κ × Option β) ↦ + Function.update m e.1 (some e.2)) m) x).join).isSome = true := by + induction t generalizing m with + | nil => exact hm + | cons e t ih => + refine ih ?_ fun e' he' ↦ ht e' (List.mem_cons_of_mem _ he') + change ((Function.update m e.1 (some e.2) x).join).isSome = true + by_cases hx : e.1 = x + · have he := ht e List.mem_cons_self hx + rw [← hx, Function.update_self] + simpa using he + · rw [Function.update_of_ne (Ne.symm hx)] + exact hm + +/-- SNP-7 Under the looser seal too, a key that is not live now is served at no cut. -/ +theorem servedNow_of_not_live {l : List (κ × Option β)} {x : κ} + (h : (stateOf l x).join = none) (c : ℕ) : servedNow l c x = none := by + simp [servedNow, h] + +/-- SNP-4 At the head cut the looser seal serves what the store rewritten in place holds +live. -/ +theorem servedNow_length (l : List (κ × Option β)) (x : κ) : + servedNow l l.length x = (stateOf l x).join := by + unfold servedNow + rw [stateAt_length] + cases (stateOf l x).join <;> rfl + +/-- SNP-7 The two seals are ordered: what the seal that a retire closes for good serves, the +seal that a later landing lifts serves too. Whichever is chosen, the other bounds it. -/ +theorem servedNow_of_servedAt {l : List (κ × Option β)} {c : ℕ} {x : κ} {v : β} + (h : servedAt l c x = some v) : servedNow l c x = some v := by + have hstate := stateAt_of_servedAt h + have hseal : ∀ e ∈ l.drop c, e.1 = x → e.2.isSome = true := by + intro e he hx + by_contra hnone + have hs : sealedAt l c x = true := + List.any_eq_true.2 ⟨e, he, by simpa [hx] using hnone⟩ + simp [servedAt, hs] at h + have hfold := stateAt_eq_foldl l (Nat.le_max_left c l.length) + rw [stateAt_of_length_le (Nat.le_max_right c l.length), + List.take_of_length_le (Nat.le_max_right c l.length)] at hfold + have hlive : ((stateOf l x).join).isSome = true := by + rw [hfold] + exact isSome_join_foldl (by rw [hstate]; rfl) hseal + have hnot : ((stateOf l x).join).isNone = false := by + cases hj : (stateOf l x).join with + | none => rw [hj] at hlive; exact absurd hlive (by simp) + | some w => rfl + simp only [servedNow, hnot, Bool.false_eq_true, ↓reduceIte, hstate, Option.join_some] + end Generations /-! ### SNP-6 The grant -/ @@ -910,6 +965,14 @@ theorem compact_moves : a ∈ readAt (compact E s) c () ∧ a ∉ readAt s c () := by refine ⟨fun n ↦ n == 0, fun _ ↦ [0, 1], fun _ ↦ 1, 1, ?_, ?_⟩ <;> simp [readAt, compact] +/-- The control for SNP-7's stricter seal: the looser seal is lifted by a later landing, so +under it growth of the chain brings a retired key's past back to a cut inside the chain. -/ +theorem servedNow_restores : + ∃ (l t : List (Unit × Option ℕ)) (c : ℕ), c ≤ l.length ∧ + servedNow l c () = none ∧ servedNow (l ++ t) c () = some 0 := by + refine ⟨[((), some 0), ((), none)], [((), some 1)], 1, by decide, ?_, ?_⟩ <;> + simp [servedNow, stateAt, stateOf] + /-- The control for SNP-9: a digest that is not collision free pins nothing. Under addition two chains of one length and one digest differ. -/ theorem digest_collides : diff --git a/formal/Palace/Snapshot/Defs.lean b/formal/Palace/Snapshot/Defs.lean index 37c3d39e..6b838b60 100644 --- a/formal/Palace/Snapshot/Defs.lean +++ b/formal/Palace/Snapshot/Defs.lean @@ -26,8 +26,9 @@ has no past. Two things are parameters of a read and no function of the cut, because they are the present's: the asker's **grant** (`snapshot`: the chains it names and the events it may see named) and the **erasure** (`visible`: the erased events masked; `redact`: the store with a hole at each, every -position kept; `servedAt`: a key retired after the cut is served at no earlier cut). The control -for the erasure is `compact`, an erasure that deletes rows and lets the later ones move up. +position kept; `servedAt`: a key retired after the cut is served at no earlier cut, with +`servedNow` the looser seal that a later landing lifts). The control for the erasure is +`compact`, an erasure that deletes rows and lets the later ones move up. Events may read from events of other chains (`R k i k' j`: the `i`-th event of chain `k` reads from the `j`-th of chain `k'`); a cut is **consistent** when every source of an event inside it is @@ -173,6 +174,11 @@ whole chain, the present, and no prefix of it. -/ def servedAt [DecidableEq κ] (l : List (κ × Option β)) (c : ℕ) (x : κ) : Option β := if sealedAt l c x then none else (stateAt l c x).join +/-- The looser seal: a key is withheld at every cut exactly while it is not live at the head, so +a key landed again after its retire is served again at the cuts before the retire. -/ +def servedNow [DecidableEq κ] (l : List (κ × Option β)) (c : ℕ) (x : κ) : Option β := + if ((stateOf l x).join).isNone then none else (stateAt l c x).join + end Generations /-! ### The grant and the erasure, the present's -/ From 3622289002203c4dc6fb3712e994ca2176fa868d Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Tue, 10 Nov 2026 21:06:08 -0500 Subject: [PATCH 03/37] test(formal): attack the snapshot's laws, with their controls The laws of Palace/Snapshot.lean are attacked on the model's own definitions before any code is written to them (seeds 430 to 474): stores of two chains over three events, cuts from two naturals, keyed chains over three keys, chains of landings and retires from codes, grants from two bits and event filters and erasures from three, reads-from relations as lists of edges, and a digest that reads a chain as a numeral in base four. Thirty attacks survive, every one all 500 instances, and fifteen controls are refuted within 53 instances: a read at a cut past the head, the store rewritten in place, generations without their closing stamp, an event filter applied before the cut, a hidden event before the cut, an erasure that deletes rows, a state served without the seal, the looser seal taken for a monotone one, kept rows served without their sources, a frontier taken for a cut, a consistent cut advanced by one position, an additive digest, a digest over contents. One thing is attacked that the library does not define: the resolver a build will transcribe, the descent that lowers a frontier until no event inside it has a source outside. It is checked against the greatest consistent cut by enumerating every cut under the frontier. The descent holds its cut as a pair, since a function-valued cut is re-evaluated at every pass and the attack did not finish. formal/README.md gains the family's paragraph and its attacks, and names Snapshot among the design theorems and the modules with attacks. The counts in README.md are this tree's: 1,453 theorems, 208 attacks and 176 controls over 33 modules. formal/check.sh is green: sorry 0, standard axioms only, 5,099 declarations audited, the export's 56,062 accepted by the six kernel checkers, the 328 judged statements unchanged. Co-Authored-By: Claude Fable 5.2 --- README.md | 10 +- formal/PalaceTest.lean | 1 + formal/PalaceTest/Snapshot.lean | 349 ++++++++++++++++++++++++++++++++ formal/README.md | 74 ++++++- 4 files changed, 426 insertions(+), 8 deletions(-) create mode 100644 formal/PalaceTest/Snapshot.lean diff --git a/README.md b/README.md index 7e10df50..5a234031 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Lean statements](https://img.shields.io/badge/Lean-328_statements_judged-blue)](formal/README.md) [![sorry](https://img.shields.io/badge/sorry-0-brightgreen)](formal/sorry-budget) [![kernels](https://img.shields.io/badge/kernel_replay-6_checkers-6f42c1)](formal/check.sh) -[![attacks](https://img.shields.io/badge/attacks-178_with_controls-blue)](formal/PalaceTest) +[![attacks](https://img.shields.io/badge/attacks-208_with_controls-blue)](formal/PalaceTest) [![tests](https://img.shields.io/badge/tests-3633-brightgreen)](docs/runbook.md) [![coverage](https://img.shields.io/badge/coverage-77%25-green)](pyproject.toml) [![mypy](https://img.shields.io/badge/mypy-0_errors_in_core-brightgreen)](pyproject.toml) @@ -121,12 +121,12 @@ A law has one row in [`docs/LAWS.md`](docs/LAWS.md): its statement, the structur | | | |---|---| | toolchain | Lean `v4.36.0-rc2`, Mathlib; Plausible for the attacks | -| the library | 37 proof modules, 36 models, 26 statement files; 23,101 lines of models and proofs, 3,460 of statements, 4,990 of attacks | -| theorems | 1,345 proved in `formal/Palace`; 328 statements in `formal/Spec` judged identical by the comparator | +| the library | 38 proof modules, 37 models, 26 statement files; 24,386 lines of models and proofs, 3,460 of statements, 5,339 of attacks | +| theorems | 1,453 proved in `formal/Palace`; 328 statements in `formal/Spec` judged identical by the comparator | | the ledger | 100 rows in 15 families, 334 cited declarations, 87 law markers checked against the rows | -| attacks | 178 Plausible attacks and 161 negative controls over 32 modules, fixed seeds | +| attacks | 208 Plausible attacks and 176 negative controls over 33 modules, fixed seeds | | axioms | `propext`, `Classical.choice`, `Quot.sound`; `sorry` 0 | -| the replay | 55,746 declarations accepted by all six checkers on the run of `formal/check.sh` this commit was built with | +| the replay | 56,062 declarations accepted by all six checkers on the run of `formal/check.sh` this commit was built with | | families | memberships · Laplacian, balance and spectral · cut and conductance · curvature · the global event clock · the shared prose plane · capability scopes · the abstraction ultrametric σ* · bridges · the retrieval curve · the query sentence algebra · the ingress · stored vectors · the growth readout · the utility field | ## The mathematics diff --git a/formal/PalaceTest.lean b/formal/PalaceTest.lean index 8e066937..b16be187 100644 --- a/formal/PalaceTest.lean +++ b/formal/PalaceTest.lean @@ -30,6 +30,7 @@ public import PalaceTest.Scope public import PalaceTest.Script public import PalaceTest.Sentence public import PalaceTest.SigmaStar +public import PalaceTest.Snapshot public import PalaceTest.Spectral public import PalaceTest.Superconnection public import PalaceTest.Utility diff --git a/formal/PalaceTest/Snapshot.lean b/formal/PalaceTest/Snapshot.lean new file mode 100644 index 00000000..aec0b6b7 --- /dev/null +++ b/formal/PalaceTest/Snapshot.lean @@ -0,0 +1,349 @@ +module + +public import Palace.Snapshot +public import PalaceTest.Attack +public meta import Palace.Snapshot +public meta import PalaceTest.Attack + +/-! +# Attacks on `Palace.Snapshot` + +The Plausible attacks and negative controls for the laws of `Palace/Snapshot.lean`, on the +model's own definitions: stores of two chains over an alphabet of three events, each chain a +list; cuts from two naturals; keyed chains as lists of (key, value) over three keys; chains of +landings and retires from codes in `Fin 9`; grants from two bits and event filters and erasures +from three; reads-from relations as lists of edges between events of the two chains at positions +under four; a digest that reads a chain as a numeral in base four, which is collision free, and +one that adds, which is not. Beside the model the attacks carry one thing the library does not: +an executable resolver, the descent that lowers a frontier until no event inside it has a source +outside, tested against the definition of the greatest consistent cut by enumeration. The +controls are the readings a build must not take: a read at a cut past the head, the store +rewritten in place, generations without their closing stamp, an event filter before the cut, an +erasure that deletes rows, a state served without the seal, the looser seal taken for a +monotone one, kept rows served without their sources, a frontier taken for a cut, an additive digest, a digest over contents. They run when +this module builds (`lake test`). +-/ + +@[expose] public section + +namespace Palace.Snapshot.Attack + +/-- A store of two chains. -/ +def st {γ : Type} (a b : List γ) : Store (Fin 2) γ := fun k ↦ if k = 0 then a else b + +/-- A cut of two chains. -/ +def cu (m n : ℕ) : Cut (Fin 2) := fun k ↦ if k = 0 then m else n + +/-- Two stores of two chains agree. -/ +def same {γ : Type} [BEq γ] (s t : Store (Fin 2) γ) : Bool := + (List.finRange 2).all fun k ↦ s k == t k + +/-- A grant from two bits: the chains it names. -/ +def gr (g : Fin 4) (k : Fin 2) : Bool := g.val.testBit k.val + +/-- An event filter, or an erasure, from three bits. -/ +def pf (c : Fin 8) (a : Fin 3) : Bool := c.val.testBit a.val + +/-- A landing or a retire from a code: the key from the residue, `none` (a retire) or a value +from the quotient. -/ +def ev (n : Fin 9) : Fin 3 × Option (Fin 2) := + (⟨n.val % 3, Nat.mod_lt _ (by decide)⟩, + match n.val / 3 with + | 0 => none + | 1 => some 0 + | _ => some 1) + +/-- Generations without the closing stamp: every write a row that never dies. -/ +def openRows (l : List (Fin 3 × Fin 3)) : List (Gen (Fin 3) (Fin 3)) := + l.zipIdx.map fun x ↦ ⟨x.1.1, x.1.2, x.2 + 1, none⟩ + +/-- A reads-from edge: the reader's chain and position, then the source's. -/ +abbrev Edge := (Fin 2 × Fin 4) × (Fin 2 × Fin 4) + +/-- Consistency, decided on a list of edges. -/ +def cons (es : List Edge) (c : Cut (Fin 2)) : Bool := + es.all fun e ↦ !decide (e.1.2.val < c e.1.1) || decide (e.2.2.val < c e.2.1) + +/-- A cut of two chains read off a pair: the descent holds values, not closures. -/ +def at2 (c : ℕ × ℕ) (k : Fin 2) : ℕ := if k = 0 then c.1 else c.2 + +/-- One pass of the descent on one chain: its position lowered to the first event inside it +whose source lies outside the cut. -/ +def lowerAt (es : List Edge) (c : ℕ × ℕ) (k : Fin 2) : ℕ := + es.foldl (fun n e ↦ + if e.1.1 = k ∧ e.1.2.val < n ∧ ¬e.2.2.val < at2 c e.2.1 then e.1.2.val else n) (at2 c k) + +/-- One pass of the descent on both chains. -/ +def lower (es : List Edge) (c : ℕ × ℕ) : ℕ × ℕ := (lowerAt es c 0, lowerAt es c 1) + +/-- The executable resolver: the descent run from the frontier `(x, y)` until it can lower +nothing more, which is at most as many passes as the frontier has positions. -/ +def resolve (es : List Edge) (x y : ℕ) : Cut (Fin 2) := + cu ((lower es)^[x + y] (x, y)).1 ((lower es)^[x + y] (x, y)).2 + +/-- A collision-free step: the chain read as a numeral in base four, digits one to three. -/ +def step4 (h : ℕ) (a : Fin 3) : ℕ := 4 * h + a.val + 1 + +/-- The additive step, which forgets the order. -/ +def stepAdd (h : ℕ) (a : Fin 3) : ℕ := h + a.val + 1 + +/-- A commitment of an event, and the step that digests commitments. -/ +def commit3 (a : Fin 3) : ℕ := a.val + 1 + +/-- The step over commitments. -/ +def stepC (h c : ℕ) : ℕ := 4 * h + c + +/-- A step over contents, a hole digested as zero. -/ +def stepO (h : ℕ) (o : Option (Fin 3)) : ℕ := + 4 * h + match o with + | none => 0 + | some a => a.val + 1 + +/-- Whether a store of two chains verifies a certificate, decided. -/ +def verifies (z : Certificate (Fin 2) ℕ) (s : Store (Fin 2) (Fin 3)) : Bool := + (List.finRange 2).all fun k ↦ + decide (z.cut k ≤ (s k).length) && chainDigest step4 0 ((s k).take (z.cut k)) == z.digest k + +/- SNP-1: a read at a cut inside the store is the same after any growth. -/ +#eval survives (∀ (a b a' b' : List (Fin 3)) (m n : ℕ), + same (readAt (grow (st a b) (st a' b')) (cu m n ⊓ head (st a b))) + (readAt (st a b) (cu m n ⊓ head (st a b))) = true) 430 + +/- Control: a read at a cut past the head changes when the store grows. -/ +#eval refuted (∀ (a b a' b' : List (Fin 3)) (m n : ℕ), + same (readAt (grow (st a b) (st a' b')) (cu m n)) (readAt (st a b) (cu m n)) = true) 431 + +/- SNP-1: a read between two cuts, the later inside the store, is the same after any growth. -/ +#eval survives (∀ (a b t : List (Fin 3)) (i m n : ℕ), + same (readBetween (grow (st a b) (st t t)) (cu i i) (cu m n ⊓ head (st a b))) + (readBetween (st a b) (cu i i) (cu m n ⊓ head (st a b))) = true) 432 + +/- SNP-2: the read at the meet of two cuts is a prefix of the read at either. -/ +#eval survives (∀ (a b : List (Fin 3)) (m n i j : ℕ), + (List.finRange 2).all (fun k ↦ + (readAt (st a b) (cu m n ⊓ cu i j) k).isPrefixOf (readAt (st a b) (cu i j) k)) = true) 433 + +/- Control: the read at one cut is not a prefix of the read at any other. -/ +#eval refuted (∀ (a b : List (Fin 3)) (m n i j : ℕ), + (List.finRange 2).all (fun k ↦ + (readAt (st a b) (cu m n) k).isPrefixOf (readAt (st a b) (cu i j) k)) = true) 434 + +/- SNP-2: a cut of a cut is the meet. -/ +#eval survives (∀ (a b : List (Fin 3)) (m n i j : ℕ), + same (readAt (readAt (st a b) (cu m n)) (cu i j)) (readAt (st a b) (cu i j ⊓ cu m n)) + = true) 435 + +/- SNP-3: the read at `a` followed by the read between `a` and `b` is the read at `b`. -/ +#eval survives (∀ (a b : List (Fin 3)) (i j m n : ℕ), + same (grow (readAt (st a b) (cu i j)) (readBetween (st a b) (cu i j) (cu (i + m) (j + n)))) + (readAt (st a b) (cu (i + m) (j + n))) = true) 436 + +/- Control: with the two cuts in any order it is not. -/ +#eval refuted (∀ (a b : List (Fin 3)) (i j m n : ℕ), + same (grow (readAt (st a b) (cu i j)) (readBetween (st a b) (cu i j) (cu m n))) + (readAt (st a b) (cu m n)) = true) 437 + +/- SNP-3: two adjacent reads-between compose. -/ +#eval survives (∀ (a b : List (Fin 3)) (i j m n : ℕ), + same (grow (readBetween (st a b) (cu i j) (cu (i + m) (j + n))) + (readBetween (st a b) (cu (i + m) (j + n)) (cu (i + m + n) (j + n + m)))) + (readBetween (st a b) (cu i j) (cu (i + m + n) (j + n + m))) = true) 438 + +/- SNP-3: a fold continued from a checkpoint over the delta is the fold of the prefix. -/ +#eval survives (∀ (a b : List (Fin 3)) (i j m n : ℕ), + (List.finRange 2).all (fun k ↦ + foldAt step4 (fun _ ↦ 0) (st a b) (cu (i + m) (j + n)) k + == (readBetween (st a b) (cu i j) (cu (i + m) (j + n)) k).foldl step4 + (foldAt step4 (fun _ ↦ 0) (st a b) (cu i j) k)) = true) 439 + +/- SNP-4: the read at the head cut, and at any cut past it, is the store. -/ +#eval survives (∀ (a b : List (Fin 3)) (m n : ℕ), + (same (readAt (st a b) (head (st a b))) (st a b) + && same (readAt (st a b) (head (st a b) + cu m n)) (st a b)) = true) 440 + +/- SNP-5: the generational store read at a cut is the state recomputed from the prefix. -/ +#eval survives (∀ (l : List (Fin 3 × Fin 3)) (c : ℕ) (x : Fin 3), + (genRead (gens l) c x == stateAt l c x) = true) 441 + +/- SNP-5: and the last write of the key inside the prefix. -/ +#eval survives (∀ (l : List (Fin 3 × Fin 3)) (c : ℕ) (x : Fin 3), + (lastWrite l c x == stateAt l c x) = true) 442 + +/- SNP-5: at most one generation of a key is alive at a cut. -/ +#eval survives (∀ (l : List (Fin 3 × Fin 3)) (c : ℕ) (x : Fin 3), + decide (((gens l).filter (selects c x)).length ≤ 1) = true) 443 + +/- Control: the store rewritten in place is not the state at a cut. -/ +#eval refuted (∀ (l : List (Fin 3 × Fin 3)) (c : ℕ) (x : Fin 3), + (stateOf l x == stateAt l c x) = true) 444 + +/- Control: generations without the closing stamp read the key's oldest write. -/ +#eval refuted (∀ (l : List (Fin 3 × Fin 3)) (c : ℕ) (x : Fin 3), + (genRead (openRows l) c x == stateAt l c x) = true) 445 + +/- SNP-1: the generational store read at a cut inside the chain is the same after growth. -/ +#eval survives (∀ (l t : List (Fin 3 × Fin 3)) (c : ℕ) (x : Fin 3), + (genRead (gens (l ++ t)) (min c l.length) x == genRead (gens l) (min c l.length) x) + = true) 446 + +/- SNP-3: the state at a later cut is the state at an earlier cut with the writes between. -/ +#eval survives (∀ (l : List (Fin 3 × Fin 3)) (a d : ℕ), + (List.finRange 3).all (fun x ↦ + stateAt l (a + d) x == ((l.take (a + d)).drop a).foldl + (fun (m : Fin 3 → Option (Fin 3)) (e : Fin 3 × Fin 3) ↦ Function.update m e.1 (some e.2)) + (stateAt l a) x) = true) 447 + +/- SNP-6: a narrower grant's snapshot is the restriction of a wider one's. -/ +#eval survives (∀ (a b : List (Fin 3)) (m : ℕ) (g g' : Fin 4) (c c' : Fin 8), + same (snapshot (fun k ↦ (gr g k && gr g' k) = true) (fun x ↦ pf c x && pf c' x) (st a b) + (cu m m)) + (restrict (fun k ↦ (gr g k && gr g' k) = true) (fun x ↦ pf c x && pf c' x) + (snapshot (fun k ↦ gr g' k = true) (pf c') (st a b) (cu m m))) = true) 448 + +/- Control: an event filter applied before the cut is not the snapshot. -/ +#eval refuted (∀ (a b : List (Fin 3)) (m n : ℕ) (g : Fin 4) (c : Fin 8), + same (readAt (restrict (fun k ↦ gr g k = true) (pf c) (st a b)) (cu m n)) + (snapshot (fun k ↦ gr g k = true) (pf c) (st a b) (cu m n)) = true) 449 + +/- SNP-6: a snapshot reads only the chains the grant names, and the cut on them. -/ +#eval survives (∀ (a b b' : List (Fin 3)) (m n n' : ℕ) (c : Fin 8), + same (snapshot (fun k ↦ k = 0) (pf c) (st a b) (cu m n)) + (snapshot (fun k ↦ k = 0) (pf c) (st a b') (cu m n')) = true) 450 + +/- Control: a hidden event before the cut changes the snapshot, though every admitted event +is the same: positions count what an event filter hides. -/ +#eval refuted (∀ (a b : List (Fin 3)) (m n : ℕ), + same (snapshot (fun _ ↦ True) (fun x ↦ x != 0) (st a b) (cu m n)) + (snapshot (fun _ ↦ True) (fun x ↦ x != 0) (st (0 :: a) b) (cu m n)) = true) 451 + +/- SNP-7: no erased event is visible at any cut. -/ +#eval survives (∀ (a b : List (Fin 3)) (m n : ℕ) (e : Fin 8), + (List.finRange 2).all (fun k ↦ + (visible (pf e) (st a b) (cu m n) k).all fun x ↦ !pf e x) = true) 452 + +/- SNP-7: the store with holes keeps every position, and reading it commutes with the cut. -/ +#eval survives (∀ (a b : List (Fin 3)) (m n : ℕ) (e : Fin 8), + (same (readAt (redact (pf e) (st a b)) (cu m n)) (redact (pf e) (readAt (st a b) (cu m n))) + && (List.finRange 2).all fun k ↦ + head (redact (pf e) (st a b)) k == head (st a b) k) = true) 453 + +/- SNP-7: what is visible is the store with holes read at the cut, the holes dropped. -/ +#eval survives (∀ (a b : List (Fin 3)) (m n : ℕ) (e : Fin 8), + (List.finRange 2).all (fun k ↦ visible (pf e) (st a b) (cu m n) k + == (readAt (redact (pf e) (st a b)) (cu m n) k).reduceOption) = true) 454 + +/- Control: after an erasure that deletes rows, a read at a cut holds events from after it. -/ +#eval refuted (∀ (a b : List (Fin 3)) (m n : ℕ) (e : Fin 8), + (List.finRange 2).all (fun k ↦ (readAt (compact (pf e) (st a b)) (cu m n) k).all fun x ↦ + (readAt (st a b) (cu m n) k).contains x) = true) 455 + +/- SNP-7: once the chain retires a key, no cut before the retire serves it. -/ +#eval survives (∀ (l t : List (Fin 9)) (c : ℕ) (x : Fin 3), + (servedAt (l.map ev ++ (x, none) :: t.map ev) (min c l.length) x == none) = true) 456 + +/- SNP-7: growth of the chain changes a served value only by removing it. -/ +#eval survives (∀ (l t : List (Fin 9)) (c : ℕ) (x : Fin 3), + ((servedAt (l.map ev ++ t.map ev) (min c l.length) x).isNone + || servedAt (l.map ev ++ t.map ev) (min c l.length) x + == servedAt (l.map ev) (min c l.length) x) = true) 457 + +/- Control: the state at the cut, without the seal, serves a key retired since. -/ +#eval refuted (∀ (l t : List (Fin 9)) (c : ℕ) (x : Fin 3), + ((stateAt (l.map ev ++ t.map ev) (min c l.length) x).join + == servedAt (l.map ev ++ t.map ev) (min c l.length) x) = true) 458 + +/- SNP-7: the looser seal serves everything the stricter one serves. -/ +#eval survives (∀ (l : List (Fin 9)) (c : ℕ) (x : Fin 3), + ((servedAt (l.map ev) c x).isNone || servedAt (l.map ev) c x == servedNow (l.map ev) c x) + = true) 473 + +/- Control: under the looser seal growth does not only remove: a landing after a retire +brings the key's past back. -/ +#eval refuted (∀ (l t : List (Fin 9)) (c : ℕ) (x : Fin 3), + ((servedNow (l.map ev ++ t.map ev) (min c l.length) x).isNone + || servedNow (l.map ev ++ t.map ev) (min c l.length) x + == servedNow (l.map ev) (min c l.length) x) = true) 474 + +/- SNP-7: a served kept row has no erased source. -/ +#eval survives (∀ (rows : List (List (Fin 3) × Fin 2)) (e : Fin 8), + (serve (pf e) rows).all (fun r ↦ r.1.all fun a ↦ !pf e a) = true) 459 + +/- Control: the kept rows served as they are hold erased sources. -/ +#eval refuted (∀ (rows : List (List (Fin 3) × Fin 2)) (e : Fin 8), + rows.all (fun r ↦ r.1.all fun a ↦ !pf e a) = true) 460 + +/- SNP-8: the resolver's cut is consistent, lies under the frontier, and is above every +consistent cut under the frontier (all thirty-six of the grid). -/ +#eval survives (∀ (es : List Edge) (x y : Fin 6), + (cons es (resolve es x.val y.val) + && decide (resolve es x.val y.val ≤ cu x.val y.val) + && (List.range 6).all fun u ↦ (List.range 6).all fun v ↦ + !(cons es (cu u v) && decide (cu u v ≤ cu x.val y.val)) + || decide (cu u v ≤ resolve es x.val y.val)) = true) 461 + +/- Control: the frontier itself is not always consistent. -/ +#eval refuted (∀ (es : List Edge) (x y : Fin 6), cons es (cu x.val y.val) = true) 462 + +/- SNP-8: the meet and the join of two consistent cuts are consistent. -/ +#eval survives (∀ (es : List Edge) (x y u v : Fin 6), + (cons es (resolve es x.val y.val ⊓ resolve es u.val v.val) + && cons es (resolve es x.val y.val ⊔ resolve es u.val v.val)) = true) 463 + +/- Control: a consistent cut advanced by one position on a chain is not always consistent. -/ +#eval refuted (∀ (es : List Edge) (x y : Fin 6), + cons es (resolve es x.val y.val + cu 1 0) = true) 464 + +/- SNP-8: resolution is monotone in the frontier. -/ +#eval survives (∀ (es : List Edge) (x y u v : Fin 6), + decide (resolve es (min x.val u.val) (min y.val v.val) ≤ resolve es x.val y.val) + = true) 465 + +/- SNP-9: the certificate of a cut of a store verifies on the store grown. -/ +#eval survives (∀ (a b a' b' : List (Fin 3)) (m n : ℕ), + verifies (certify step4 0 (st a b) (cu m n ⊓ head (st a b))) (grow (st a b) (st a' b')) + = true) 466 + +/- SNP-9: under the collision-free step a chain and its reverse have one digest only when +they are one chain. -/ +#eval survives (∀ (l : List (Fin 3)), + (l.reverse == l || chainDigest step4 0 l.reverse != chainDigest step4 0 l) = true) 467 + +/- Control: under the additive step a chain and its reverse always have one digest. -/ +#eval refuted (∀ (l : List (Fin 3)), + (l.reverse == l || chainDigest stepAdd 0 l.reverse != chainDigest stepAdd 0 l) = true) 468 + +/- SNP-9: the digest at a later cut is the digest at an earlier cut continued over the +delta. -/ +#eval survives (∀ (a b : List (Fin 3)) (i j m n : ℕ), + (List.finRange 2).all (fun k ↦ + (certify step4 0 (st a b) (cu (i + m) (j + n))).digest k + == chainDigest step4 ((certify step4 0 (st a b) (cu i j)).digest k) + (readBetween (st a b) (cu i j) (cu (i + m) (j + n)) k)) = true) 469 + +/- SNP-9: the meet and the join of two certified cuts are certified from the certificates. -/ +#eval survives (∀ (a b : List (Fin 3)) (i j m n : ℕ), + (List.finRange 2).all (fun k ↦ + ((certify step4 0 (st a b) (cu i j ⊓ cu m n)).digest k + == if cu i j k ≤ cu m n k then (certify step4 0 (st a b) (cu i j)).digest k + else (certify step4 0 (st a b) (cu m n)).digest k) + && (certify step4 0 (st a b) (cu i j ⊔ cu m n)).digest k + == if cu i j k ≤ cu m n k then (certify step4 0 (st a b) (cu m n)).digest k + else (certify step4 0 (st a b) (cu i j)).digest k) = true) 470 + +/- SNP-9: an erasure on a committed store keeps the certificate over its commitments, and +what a reader reads is the store with holes. -/ +#eval survives (∀ (a b : List (Fin 3)) (m n : ℕ) (e : Fin 8), + ((List.finRange 2).all (fun k ↦ + (certify stepC 0 (commitments (purge (pf e) (committed commit3 (st a b)))) (cu m n)).digest k + == (certify stepC 0 (commitments (committed commit3 (st a b))) (cu m n)).digest k) + && same (contents (purge (pf e) (committed commit3 (st a b)))) (redact (pf e) (st a b))) + = true) 471 + +/- Control: a digest over the contents does not survive an erasure. -/ +#eval refuted (∀ (a b : List (Fin 3)) (m n : ℕ) (e : Fin 8), + (List.finRange 2).all (fun k ↦ + chainDigest stepO 0 ((contents (purge (pf e) (committed commit3 (st a b))) k).take (cu m n k)) + == chainDigest stepO 0 ((contents (committed commit3 (st a b)) k).take (cu m n k))) + = true) 472 + +end Palace.Snapshot.Attack diff --git a/formal/README.md b/formal/README.md index 7db85666..32cb330a 100644 --- a/formal/README.md +++ b/formal/README.md @@ -27,7 +27,7 @@ Each family comes in three parts: `Spec/` is proved in `Palace` with exactly the same statement, from the standard axioms, and everything the statements reach passes Lean's kernel and five independent checkers. A proof file therefore cannot change what the ledger's laws state: only `Spec/` and the model can. The design -theorems (Sever, Frustration, Leak, Transport, Superconnection, Lineage, Dynamics, Scale, and the parts of Magnetic and +theorems (Sever, Frustration, Leak, Transport, Superconnection, Lineage, Dynamics, Scale, Snapshot, and the parts of Magnetic and NegativeType no row cites) have no `Spec/` statements yet: the kernel replays their proofs, but their statements live in the proof files, which can change them, until code relies on them and a row cites them. Whether a statement says what its row says stays a reader's judgment, and the reading is now confined to those two places; @@ -297,6 +297,44 @@ Roundoff and FloatModel, so it has no statements of its own): `eval/utility_field.py` transcribes the model on synthetic graphs and its tests are the Python falsifiers, so the six laws are the ledger's family XV (`Spec/Utility.lean`, 20 statements); the controls and the gap stay design theorems. +- `Snapshot`: a read of the stores at a cut (`docs/design-notes/dn-temporal-snapshot.md`), proved + before any code reads a store at a cut, on a model of a store as a family of append chains (a + document's versions, a session's turns, a class's landing log), a cut as a prefix length for + each chain (the frontier of the event clock's §2.4), the read at a cut and between two cuts, a + derived view as a derivation of the prefixes, a store of keyed writes held three ways (rewritten + in place, recomputed from the prefix, kept by generation with a closing stamp), the grant and + the erasure as parameters of a read that are the present's, the reads-from references between + chains, and the certificate of a cut as the digest of each chain's prefix. SNP-1 append + invariance: a read at a cut inside the store, a read between two such cuts and every derived + view are unchanged by any growth of the store; SNP-2 the read at an earlier cut is a prefix of + the read at a later one, and a cut of a cut is the meet; SNP-3 the read at `a` followed by the + read between `a` and `b` is the read at `b` and adjacent reads-between compose, so a fold + continued from a checkpoint over the events since is the fold of the prefix (a job's checkpoint + is a cut); SNP-4 the read at the head cut is the store, so `as of` the current cut is no + `as of`; SNP-5 a reader is append invariant exactly when it reads only the prefixes, exactly + when it is a derived view, and for keyed writes the generational store read at a cut is the + state recomputed from the prefix and the last write inside it, with at most one generation of a + key alive at a cut, while the store rewritten in place determines no read at a past cut; SNP-6 + a narrower grant's snapshot is the restriction of a wider one's, a snapshot reads only the + chains the grant names and the cut on them, and restricting to chains commutes with the cut + where filtering events does not (a cut's positions count the events a filter hides); SNP-7 no + erased event is visible at any cut, a larger erasure shows a sublist, the store with holes + keeps every position, two stores that differ only in erased events give every derivation the + same reading at every cut, a kept derived row is served only when none of its sources is + erased, and a key retired after a cut is served at no earlier cut, growth changing a served + value only by removing it, where the looser seal that withholds a key only while it is not + live serves everything the stricter one serves and is lifted by a later landing; SNP-8 consistent cuts (every source of an event inside is inside) + are closed under meet and join, a sublattice of the cuts, they are CLK-2's cuts among the + frontier cuts, every frontier resolves to exactly one greatest consistent cut under it, + monotonically, and a consistent cut stays consistent as the store grows; SNP-9 the certificate + of a cut verifies on every extension of the store, two stores that verify one certificate under + a collision-free digest have the same read at its cut and so the same derived views, a + certificate extends over the events since an earlier one, the meet and the join of two + certified cuts are certified from the two certificates alone, and an erasure that keeps a + commitment beside each event keeps every certificate. The controls as theorems: the reader + that ignores the cut, the store rewritten in place, an event filter applied before the cut, the + erasure that deletes rows, a digest with collisions. Design theorems (Palace and PalaceTest, no + Spec rows): `as of` reads the citation graph at a commit and every other store as it is now. - `Bridges`: theorems that join two families, so that what one proves serves the other: BRG-1 the Laplacian as `∂₁ ∂₁ᵀ`, BRG-2 Euler and Poincaré on the flag complex, BRG-3 Thomson's principle on edge flows, BRG-4 the clock's cuts and scope's closed strata as lower sets, BRG-5 @@ -313,8 +351,8 @@ Roundoff and FloatModel, so it has no statements of its own): exported, every module contributes, and only the unsafe compiler helpers are left out, and `check.sh` holds its count to the audit's, since a checker accepts an empty export. - `PalaceTest/`: the attacks, one module per ledger family's `Palace` module (of the design - theorems, Magnetic, NegativeType, Superconnection, Dynamics and Scale have them), as Mathlib keeps - its tests in `MathlibTest`. `lake test` builds them, which runs every attack and negative control. + theorems, Magnetic, NegativeType, Superconnection, Dynamics, Scale and Snapshot have them), as + Mathlib keeps its tests in `MathlibTest`. `lake test` builds them, which runs every attack and negative control. `PalaceTest/Attack.lean` holds `survives` and `refuted`, which run Plausible with a fixed seed and count the instances that passed their guards. - `Audit.lean`: lists the axioms behind every `Palace` declaration and fails on anything beyond @@ -827,6 +865,36 @@ at a gain above the rate the ceiling is fixed, on the first instance; at exponen not constant, on the first instance; and the greedy walk's empirical measure is not within `1/8` of the structural stationary distribution, on the first instance. +The snapshot is attacked on the model's own definitions (seeds 430 to 474): stores of two +chains over three events, cuts from two naturals, keyed chains over three keys, chains of +landings and retires from codes, grants from two bits and event filters and erasures from three, +reads-from relations as lists of edges between the two chains at positions under four, and a +digest that reads a chain as a numeral in base four, which is collision free. Thirty attacks +survived, every one all 500 instances: the read at a cut and between two cuts under growth; the +prefix order and the meet; the two compositions and the journal; the head cut; the generational +store against the recomputed state and the last write, one generation alive at most, the same +under growth, and the keyed journal; the narrower grant, and the chains a snapshot reads; the +erasure (nothing erased visible, positions kept, the holes dropped), the retire that seals every +earlier cut, growth that only removes, the two seals in their order, and the kept rows with their +sources; the resolver, the +meet and the join of consistent cuts, and the monotone resolution; the certificate under growth, +the digest of a reversed chain, the certificate over the delta, at the meet and the join, and +across an erasure on a committed store. The resolver is the one thing attacked that the library +does not define: the descent that lowers a frontier until no event inside it has a source +outside, checked against the greatest consistent cut by enumerating the thirty-six cuts of the +grid. The fifteen controls, each refuted: a read at a cut past the head changes with growth, +within 11 instances; the read at one cut is a prefix of the read at any other, within 6; the +composition with the cuts in any order, within 6; the store rewritten in place as the state at a +cut, within 5; generations without the closing stamp, which read a key's oldest write, within 18; +an event filter applied before the cut, within 26; two stores with the same admitted events and +one hidden event more before the cut, within 7; an erasure that deletes rows, after which a read +at a cut holds an event from after it, within 29; the state at a cut served without the seal, +within 53; the looser seal taken for one under which growth only removes, within 48; the kept +rows served without their sources, within 11; the frontier taken for a +consistent cut, within 11; a consistent cut advanced by one position, within 12; the additive +digest, under which a chain and its reverse agree, within 11; and a digest over the contents, +which an erasure changes, within 14. + ## Build The toolchain is pinned in `lean-toolchain` (elan resolves it); Mathlib is pinned in From 9611e0680b0f4f2a5f0185df287debce7648bb6f Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 01:31:20 -0500 Subject: [PATCH 04/37] feat(formal): the horizon and the delta's reach (SNP-10, SNP-3) The design note has to say what a store that drops old generations still reads exactly, what a question under that horizon gets, and at which cut a read is taken when some store cannot serve the cut asked. None of the three had a statement. SNP-10, the horizon. `prune h` drops the generations closed at or under a horizon. At every cut from the horizon on the pruned store reads the state recomputed from the whole prefix (`genRead_prune_gens`); under the horizon a value it returns is still the value the key held (`stateAt_of_genRead_prune`), and what it lost it reads as absent, which nothing in the remaining rows tells from a key that was never there (`Witness.prune_forgets`): so the horizon is recorded and a cut under it is not served. Two horizons are the later one (`prune_prune`). Where the chains serve only some positions (those from a horizon on, and the empty prefix), every frontier still resolves to exactly one greatest consistent cut among them (`ResolvesIn`, `exists_resolvesIn`, `ResolvesIn.unique`). That cut rises with what is served and with the frontier (`ResolvesIn.mono`), never passes the resolution of the cut asked (`ResolvesIn.le_resolves`), and is that resolution when every position is served (`resolvesIn_univ`). It is the cut a read under `as of` is taken at, so such a read holds no event from after the cut it names. SNP-3 gains the membership form of the composition: an event read at the later cut was read at the earlier one or lies in the delta (`mem_readAt_iff`), a pair of events likewise, which is the rule for a job that joins two chains (`pair_readAt`), and a key the delta does not write has one state at both cuts (`stateAt_eq_of_not_written`). Co-Authored-By: Claude Fable 5.2 --- formal/Palace/Snapshot.lean | 186 +++++++++++++++++++++++++++++++ formal/Palace/Snapshot/Defs.lean | 25 ++++- 2 files changed, 209 insertions(+), 2 deletions(-) diff --git a/formal/Palace/Snapshot.lean b/formal/Palace/Snapshot.lean index 140754ea..6001a4a0 100644 --- a/formal/Palace/Snapshot.lean +++ b/formal/Palace/Snapshot.lean @@ -25,6 +25,9 @@ a cut a prefix length for each. Cited from the note, not from the ledger. `b`, and two adjacent reads-between compose (`readAt_append_readBetween`, `readBetween_append`); so a fold continued from a checkpoint over the events since is the fold of the whole prefix (`foldAt_readBetween`, `stateAt_eq_foldl`): a job's checkpoint is a cut. + An event read at the later cut was read at the earlier one or lies in the delta, a pair of + events likewise, and a key the delta does not write has one state at both cuts + (`mem_readAt_iff`, `pair_readAt`, `stateAt_eq_of_not_written`). * SNP-4, idempotence: the read at the head cut is the store, and every derived view at it is the derivation of the present (`readAt_head`, `view_head`, `genRead_gens_length`). * SNP-5, a derived view is a function of the prefixes: a reader is append invariant exactly when @@ -63,6 +66,15 @@ a cut a prefix length for each. Cited from the note, not from the ledger. erasure that keeps commitments keeps every certificate (`verifies_certify_of_extends`, `Verifies.readAt_eq`, `Verifies.view_eq`, `certify_digest_readBetween`, `certify_inf`, `certify_sup`, `verifies_purge`). +* SNP-10, the horizon: a generational store that drops the rows closed at or under a horizon + reads, at every cut from the horizon on, the state recomputed from the whole prefix; under the + horizon it is never wrong and reads what it lost as absent; horizons compose to the later one + (`genRead_prune`, `genRead_prune_gens`, `stateAt_of_genRead_prune`, `prune_prune`). Where the + chains serve only some positions, every frontier resolves to exactly one greatest consistent + cut among them, which rises with what is served and never passes the cut asked + (`exists_resolvesIn`, `ResolvesIn.unique`, `ResolvesIn.mono`, `ResolvesIn.le_resolves`, + `resolvesIn_univ`). The control is the pruned store read under its horizon + (`Witness.prune_forgets`). -/ @[expose] public section @@ -202,6 +214,25 @@ theorem foldAt_readBetween (f : β → α → β) (init : K → β) (s : Store K congrArg (fun l ↦ l.foldl f (init k)) (congrFun (readAt_append_readBetween s h) k).symm _ = _ := List.foldl_append +/-- SNP-3 An event read at the later cut was read at the earlier cut or lies in the delta. -/ +theorem mem_readAt_iff {s : Store K α} {a b : Cut K} (h : a ≤ b) {k : K} {x : α} : + x ∈ readAt s b k ↔ x ∈ readAt s a k ∨ x ∈ readBetween s a b k := by + rw [← readAt_append_readBetween s h] + exact List.mem_append + +/-- SNP-3 The delta rule for a job that joins two chains: a pair of events read at the later +cut was read at the earlier cut, or one of the two lies in the delta. So a job that kept the +pairs of its checkpoint has only the pairs with a new member left to visit. -/ +theorem pair_readAt {s : Store K α} {a b : Cut K} (h : a ≤ b) {k k' : K} {x y : α} + (hx : x ∈ readAt s b k) (hy : y ∈ readAt s b k') : + (x ∈ readAt s a k ∧ y ∈ readAt s a k') ∨ x ∈ readBetween s a b k ∨ + y ∈ readBetween s a b k' := by + rcases (mem_readAt_iff h).1 hx with hx | hx + · rcases (mem_readAt_iff h).1 hy with hy | hy + · exact Or.inl ⟨hx, hy⟩ + · exact Or.inr (Or.inr hy) + · exact Or.inr (Or.inl hx) + /-- SNP-5 A derived view reads only the prefixes. -/ theorem prefixOnly_view (D : Store K α → β) : PrefixOnly (view D) := fun s c _ ↦ by change D (readAt s c) = D (readAt (readAt s c) c) @@ -276,6 +307,24 @@ theorem stateAt_eq_foldl (l : List (κ × β)) {a b : ℕ} (h : a ≤ b) : unfold stateAt stateOf rw [h1, ← List.foldl_append, List.take_append_drop] +theorem foldl_update_of_ne {t : List (κ × β)} {m : κ → Option β} {x : κ} + (ht : ∀ e ∈ t, e.1 ≠ x) : + (t.foldl (fun (m : κ → Option β) (e : κ × β) ↦ Function.update m e.1 (some e.2)) m) x + = m x := by + induction t generalizing m with + | nil => rfl + | cons e t ih => + rw [List.foldl_cons, ih fun e' he' ↦ ht e' (List.mem_cons_of_mem _ he')] + exact Function.update_of_ne (Ne.symm (ht e List.mem_cons_self)) _ _ + +/-- SNP-3 The delta bounds the change: a key the writes between two cuts do not name has the +same state at both. What changed between two cuts is found among the keys of the delta. -/ +theorem stateAt_eq_of_not_written (l : List (κ × β)) {a b : ℕ} (h : a ≤ b) {x : κ} + (hx : ∀ e ∈ (l.take b).drop a, e.1 ≠ x) : stateAt l b x = stateAt l a x := by + have h1 := congrFun (stateAt_eq_foldl l h) x + rw [h1] + exact foldl_update_of_ne hx + theorem stateOf_eq_find? (l : List (κ × β)) (x : κ) : stateOf l x = (l.reverse.find? fun e ↦ decide (e.1 = x)).map Prod.snd := by induction l using List.reverseRecOn with @@ -459,6 +508,78 @@ theorem length_filter_selects_le_one (l : List (κ × β)) (c : ℕ) (x : κ) : (q := selects c x) (fun r ↦ selects_closeAt_of_ne hx c _ r) (by simp [selects, Ne.symm hx])).le.trans ih +/-- A row a cut selects is kept by every horizon at or under the cut. -/ +theorem keeps_of_selects {h c : ℕ} (hc : h ≤ c) {x : κ} {r : Gen κ β} + (hr : selects c x r = true) : (r.died.all fun d ↦ decide (h < d)) = true := by + have h2 : (r.died.all fun d ↦ decide (c < d)) = true := by + simp only [selects, Gen.aliveAt, Bool.and_eq_true] at hr + exact hr.2.2 + cases hd : r.died with + | none => rfl + | some d => + rw [hd] at h2 + simp only [Option.all_some, decide_eq_true_eq] at h2 ⊢ + omega + +theorem find?_prune {h c : ℕ} (hc : h ≤ c) (rs : List (Gen κ β)) (x : κ) : + (prune h rs).find? (selects c x) = rs.find? (selects c x) := by + induction rs with + | nil => rfl + | cons r rs ih => + by_cases hk : (r.died.all fun d ↦ decide (h < d)) = true + · have e : prune h (r :: rs) = r :: prune h rs := by simp [prune, hk] + rw [e, List.find?_cons, List.find?_cons, ih] + · have hs : ¬selects c x r = true := fun hs ↦ hk (keeps_of_selects hc hs) + have e : prune h (r :: rs) = prune h rs := by simp [prune, hk] + rw [e, List.find?_cons_of_neg hs, ih] + +/-- SNP-10 Retention is exact from the horizon on: dropping the generations closed at or under +a horizon changes no read at a cut at or past it. -/ +theorem genRead_prune {h c : ℕ} (hc : h ≤ c) (rs : List (Gen κ β)) (x : κ) : + genRead (prune h rs) c x = genRead rs c x := by + unfold genRead + rw [find?_prune hc] + +/-- SNP-10 So the pruned generational store read at a cut from the horizon on is the state +recomputed from the whole prefix, though the prefix is no longer held. -/ +theorem genRead_prune_gens {h c : ℕ} (hc : h ≤ c) (l : List (κ × β)) (x : κ) : + genRead (prune h (gens l)) c x = stateAt l c x := by + rw [genRead_prune hc, genRead_gens] + +/-- SNP-10 Under the horizon the pruned store is never wrong: a value it returns at a cut is the +value the key held at the cut. What it has lost it reads as absent. -/ +theorem stateAt_of_genRead_prune {h c : ℕ} {l : List (κ × β)} {x : κ} {v : β} + (hv : genRead (prune h (gens l)) c x = some v) : stateAt l c x = some v := by + rw [← genRead_gens] + unfold genRead at hv ⊢ + obtain ⟨r, hr, rfl⟩ := Option.map_eq_some_iff.1 hv + have hsel : selects c x r = true := List.find?_some hr + have hmem : r ∈ gens l := List.mem_of_mem_filter (List.mem_of_find?_eq_some hr) + have hfil : r ∈ (gens l).filter (selects c x) := List.mem_filter.2 ⟨hmem, hsel⟩ + have hlen := length_filter_selects_le_one l c x + have heq : (gens l).filter (selects c x) = [r] := by + rcases hf : (gens l).filter (selects c x) with _ | ⟨a, _ | ⟨b, t⟩⟩ + · rw [hf] at hfil + exact absurd hfil List.not_mem_nil + · rw [hf] at hfil + rw [List.mem_singleton.1 hfil] + · rw [hf] at hlen + simp at hlen + rw [← List.head?_filter, heq] + rfl + +omit [DecidableEq κ] in +/-- SNP-10 Horizons compose: pruning at two horizons is pruning at the later one, so a horizon +only ever advances. -/ +theorem prune_prune (h h' : ℕ) (rs : List (Gen κ β)) : + prune h (prune h' rs) = prune (max h h') rs := by + unfold prune + rw [List.filter_filter] + refine List.filter_congr fun r _ ↦ ?_ + cases r.died with + | none => rfl + | some d => simp [max_lt_iff] + /-- SNP-4 At the head cut nothing is sealed: a chain of landings and retires serves what the store rewritten in place holds live. -/ theorem servedAt_length (l : List (κ × Option β)) (x : κ) : @@ -817,6 +938,61 @@ theorem Consistent.of_grown {R' : K → ℕ → K → ℕ → Prop} {h c : Cut K (hR k i k' j hr).elim (fun h0 ↦ hcons k i k' j h0 hi) fun hle ↦ absurd (lt_of_lt_of_le hi (hc k)) (not_lt.2 hle) +/-- SNP-10 Every frontier resolves among the positions the chains serve, when every chain serves +its empty prefix: among the consistent cuts under the frontier with every position served there +is a greatest. This is the cut a read is taken at when a store cannot serve the cut asked. -/ +theorem exists_resolvesIn (R : K → ℕ → K → ℕ → Prop) {S : K → Set ℕ} (h0 : ∀ k, 0 ∈ S k) + (f : Cut K) : ∃ c, ResolvesIn R S f c := by + have hne : ∀ k, (reachedIn R S f k).Nonempty := fun k ↦ + ⟨0, fun _ ↦ 0, consistent_zero, fun k' ↦ h0 k', fun _ ↦ Nat.zero_le _, rfl⟩ + have hbdd : ∀ k, BddAbove (reachedIn R S f k) := fun k ↦ + ⟨f k, by rintro n ⟨d, -, -, hd, rfl⟩; exact hd k⟩ + refine ⟨fun k ↦ sSup (reachedIn R S f k), ?_, ?_, ?_, ?_⟩ + · intro k i k' j hR hi + obtain ⟨d, hd, hS, hdf, hdk⟩ := Nat.sSup_mem (hne k) (hbdd k) + have hj : j < d k' := hd k i k' j hR (by rw [hdk]; exact hi) + exact lt_of_lt_of_le hj (le_csSup (hbdd k') ⟨d, hd, hS, hdf, rfl⟩) + · intro k + obtain ⟨d, -, hS, -, hdk⟩ := Nat.sSup_mem (hne k) (hbdd k) + change sSup (reachedIn R S f k) ∈ S k + rw [← hdk] + exact hS k + · intro k + exact csSup_le (hne k) (by rintro n ⟨d, -, -, hd, rfl⟩; exact hd k) + · intro d hd hS hdf k + exact le_csSup (hbdd k) ⟨d, hd, hS, hdf, rfl⟩ + +/-- A frontier resolves among the served positions to at most one cut. -/ +theorem ResolvesIn.unique {S : K → Set ℕ} {f c c' : Cut K} (h : ResolvesIn R S f c) + (h' : ResolvesIn R S f c') : c = c' := + le_antisymm (h'.2.2.2 c h.1 h.2.1 h.2.2.1) (h.2.2.2 c' h'.1 h'.2.1 h'.2.2.1) + +/-- SNP-10 The cut read rises with what is served and with the frontier: a store that gains a +past, or a later cut asked, never lowers the cut read. -/ +theorem ResolvesIn.mono {S S' : K → Set ℕ} {f f' c c' : Cut K} (hS : ∀ k, S k ⊆ S' k) + (hf : f ≤ f') (h : ResolvesIn R S f c) (h' : ResolvesIn R S' f' c') : c ≤ c' := + h'.2.2.2 c h.1 (fun k ↦ hS k (h.2.1 k)) (h.2.2.1.trans hf) + +/-- When every position is served the cut read is the resolution of the frontier. -/ +theorem resolvesIn_univ {f c : Cut K} : + ResolvesIn R (fun _ ↦ Set.univ) f c ↔ Resolves R f c := by + constructor + · rintro ⟨h1, -, h3, h4⟩ + exact ⟨h1, h3, fun d hd hdf ↦ h4 d hd (fun _ ↦ Set.mem_univ _) hdf⟩ + · rintro ⟨h1, h2, h3⟩ + exact ⟨h1, fun _ ↦ Set.mem_univ _, h2, fun d hd _ hdf ↦ h3 d hd hdf⟩ + +/-- SNP-10 The cut read is never past the cut asked: it lies under the resolution of the +frontier, so a read under `as of` holds no event from after the cut it names. -/ +theorem ResolvesIn.le_resolves {S : K → Set ℕ} {f c c' : Cut K} (h : ResolvesIn R S f c) + (h' : Resolves R f c') : c ≤ c' := + h'.2.2 c h.1 h.2.2.1 + +/-- A consistent frontier every position of which is served is read as asked. -/ +theorem resolvesIn_self {S : K → Set ℕ} {f : Cut K} (h : Consistent R f) + (hS : ∀ k, f k ∈ S k) : ResolvesIn R S f f := + ⟨h, hS, le_rfl, fun _ _ _ hd ↦ hd⟩ + end Consistency /-! ### SNP-9 Certified cuts -/ @@ -973,6 +1149,16 @@ theorem servedNow_restores : refine ⟨[((), some 0), ((), none)], [((), some 1)], 1, by decide, ?_, ?_⟩ <;> simp [servedNow, stateAt, stateOf] +/-- The control for SNP-10: under the horizon the pruned store reads a key as absent where it +held a value, and nothing in the rows that remain says which. So the horizon is recorded, and a +cut under it is not served. -/ +theorem prune_forgets : + ∃ (l : List (Unit × ℕ)) (h c : ℕ), c < h ∧ + genRead (prune h (gens l)) c () = none ∧ stateAt l c () = some 0 := by + refine ⟨[((), 0), ((), 1)], 2, 1, by decide, ?_, ?_⟩ + · decide + · decide + /-- The control for SNP-9: a digest that is not collision free pins nothing. Under addition two chains of one length and one digest differ. -/ theorem digest_collides : diff --git a/formal/Palace/Snapshot/Defs.lean b/formal/Palace/Snapshot/Defs.lean index 6b838b60..64315ab9 100644 --- a/formal/Palace/Snapshot/Defs.lean +++ b/formal/Palace/Snapshot/Defs.lean @@ -21,7 +21,8 @@ What is derived can be held three ways, and the model has each: recomputed from checkpoint over the events between two cuts, `foldAt`), or kept by generation (`gens`: one row per write, valid from the cut that contains it up to the cut that contains the key's next write, read by `genRead`). The store rewritten in place is `stateOf`, the fold of the whole chain, which -has no past. +has no past. Retention drops the generations closed at or under a horizon (`prune`), after which +the store serves the cuts from the horizon on. Two things are parameters of a read and no function of the cut, because they are the present's: the asker's **grant** (`snapshot`: the chains it names and the events it may see named) and the @@ -32,7 +33,9 @@ position kept; `servedAt`: a key retired after the cut is served at no earlier c Events may read from events of other chains (`R k i k' j`: the `i`-th event of chain `k` reads from the `j`-th of chain `k'`); a cut is **consistent** when every source of an event inside it is -inside it, and a frontier **resolves** to the greatest consistent cut under it. A cut is +inside it, and a frontier **resolves** to the greatest consistent cut under it, or, where a store +serves only some positions (those from its horizon on, and the empty prefix), to the greatest +consistent cut under it among the served positions (`ResolvesIn`). A cut is **certified** by the digest of each chain's prefix under a chain digest (`chainDigest`, a fold), and a later store **verifies** the certificate when its own prefixes have those digests. A store that keeps a commitment beside each event (`committed`) can lose an event's content to an erasure @@ -163,6 +166,11 @@ def selects [DecidableEq κ] (c : ℕ) (x : κ) (r : Gen κ β) : Bool := def genRead [DecidableEq κ] (rs : List (Gen κ β)) (c : ℕ) (x : κ) : Option β := (rs.find? (selects c x)).map Gen.val +/-- Retention by a horizon: the generations kept are those whose closing stamp, if any, lies past +the horizon. A row closed at or under the horizon is alive at no cut from the horizon on. -/ +def prune (h : ℕ) (rs : List (Gen κ β)) : List (Gen κ β) := + rs.filter fun r ↦ r.died.all fun d ↦ decide (h < d) + /-- A key is sealed at a cut when the chain retires it after the cut: a retire, the write of `none`, among the events the cut does not contain. -/ def sealedAt [DecidableEq κ] (l : List (κ × Option β)) (c : ℕ) (x : κ) : Bool := @@ -262,6 +270,19 @@ at the cut that resolves it. -/ def Resolves (R : K → ℕ → K → ℕ → Prop) (f c : Cut K) : Prop := Consistent R c ∧ c ≤ f ∧ ∀ d, Consistent R d → d ≤ f → d ≤ c +/-- The positions of chain `k` that some consistent cut under the frontier `f`, every position +of which its chain serves, reaches. -/ +def reachedIn (R : K → ℕ → K → ℕ → Prop) (S : K → Set ℕ) (f : Cut K) (k : K) : Set ℕ := + {n | ∃ d, Consistent R d ∧ (∀ k', d k' ∈ S k') ∧ d ≤ f ∧ d k = n} + +/-- The cut `c` resolves the frontier `f` among the positions the chains serve: `S k` is the set +of positions at which the store of chain `k` can be read exactly (every position from its horizon +on, and the empty prefix), and `c` is the greatest consistent cut under `f` every position of +which is served. It is the cut a read is taken at when the cut asked cannot be served whole. -/ +def ResolvesIn (R : K → ℕ → K → ℕ → Prop) (S : K → Set ℕ) (f c : Cut K) : Prop := + Consistent R c ∧ (∀ k, c k ∈ S k) ∧ c ≤ f ∧ + ∀ d, Consistent R d → (∀ k, d k ∈ S k) → d ≤ f → d ≤ c + end Consistency /-! ### Certified cuts -/ From e831cb8330074ef55506692553bb38dbef286ce4 Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 01:31:20 -0500 Subject: [PATCH 05/37] test(formal): attack the horizon and the delta's reach Seeds 475 to 486 on the model's own definitions. Nine attacks survive, every one all 500 instances: an event of the later cut is in the earlier one or in the delta; a key the delta does not write keeps its state; the pruned generational store at and past its horizon is the recomputed state, and at any cut returns nothing or the right value; two horizons are the later one; among positions served from ten bits, the pointwise maximum of every consistent served cut under a frontier is consistent and served, lies under the resolution of the frontier, rises with what is served, and is the resolution when every position is served. Three controls are refuted: a key's state taken for the same at two cuts whatever the delta writes (17 instances), the pruned store read under its horizon as the state at the cut (30), and a frontier lowered to the served positions without the descent (24). formal/README.md names SNP-10 and the new attacks. The counts in README.md are this tree's: 1,470 theorems, 217 attacks and 179 controls over 33 modules. formal/check.sh is green: sorry 0, standard axioms only, 5,122 declarations audited, the export's 56,098 accepted by the six kernel checkers, the 328 judged statements unchanged. Co-Authored-By: Claude Fable 5.2 --- README.md | 10 ++-- formal/PalaceTest/Snapshot.lean | 102 ++++++++++++++++++++++++++++++-- formal/README.md | 41 +++++++++---- 3 files changed, 130 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 5a234031..47ee83c8 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Lean statements](https://img.shields.io/badge/Lean-328_statements_judged-blue)](formal/README.md) [![sorry](https://img.shields.io/badge/sorry-0-brightgreen)](formal/sorry-budget) [![kernels](https://img.shields.io/badge/kernel_replay-6_checkers-6f42c1)](formal/check.sh) -[![attacks](https://img.shields.io/badge/attacks-208_with_controls-blue)](formal/PalaceTest) +[![attacks](https://img.shields.io/badge/attacks-217_with_controls-blue)](formal/PalaceTest) [![tests](https://img.shields.io/badge/tests-3633-brightgreen)](docs/runbook.md) [![coverage](https://img.shields.io/badge/coverage-77%25-green)](pyproject.toml) [![mypy](https://img.shields.io/badge/mypy-0_errors_in_core-brightgreen)](pyproject.toml) @@ -121,12 +121,12 @@ A law has one row in [`docs/LAWS.md`](docs/LAWS.md): its statement, the structur | | | |---|---| | toolchain | Lean `v4.36.0-rc2`, Mathlib; Plausible for the attacks | -| the library | 38 proof modules, 37 models, 26 statement files; 24,386 lines of models and proofs, 3,460 of statements, 5,339 of attacks | -| theorems | 1,453 proved in `formal/Palace`; 328 statements in `formal/Spec` judged identical by the comparator | +| the library | 38 proof modules, 37 models, 26 statement files; 24,593 lines of models and proofs, 3,460 of statements, 5,429 of attacks | +| theorems | 1,470 proved in `formal/Palace`; 328 statements in `formal/Spec` judged identical by the comparator | | the ledger | 100 rows in 15 families, 334 cited declarations, 87 law markers checked against the rows | -| attacks | 208 Plausible attacks and 176 negative controls over 33 modules, fixed seeds | +| attacks | 217 Plausible attacks and 179 negative controls over 33 modules, fixed seeds | | axioms | `propext`, `Classical.choice`, `Quot.sound`; `sorry` 0 | -| the replay | 56,062 declarations accepted by all six checkers on the run of `formal/check.sh` this commit was built with | +| the replay | 56,098 declarations accepted by all six checkers on the run of `formal/check.sh` this commit was built with | | families | memberships · Laplacian, balance and spectral · cut and conductance · curvature · the global event clock · the shared prose plane · capability scopes · the abstraction ultrametric σ* · bridges · the retrieval curve · the query sentence algebra · the ingress · stored vectors · the growth readout · the utility field | ## The mathematics diff --git a/formal/PalaceTest/Snapshot.lean b/formal/PalaceTest/Snapshot.lean index aec0b6b7..2314caeb 100644 --- a/formal/PalaceTest/Snapshot.lean +++ b/formal/PalaceTest/Snapshot.lean @@ -16,12 +16,15 @@ from three; reads-from relations as lists of edges between events of the two cha under four; a digest that reads a chain as a numeral in base four, which is collision free, and one that adds, which is not. Beside the model the attacks carry one thing the library does not: an executable resolver, the descent that lowers a frontier until no event inside it has a source -outside, tested against the definition of the greatest consistent cut by enumeration. The -controls are the readings a build must not take: a read at a cut past the head, the store -rewritten in place, generations without their closing stamp, an event filter before the cut, an -erasure that deletes rows, a state served without the seal, the looser seal taken for a -monotone one, kept rows served without their sources, a frontier taken for a cut, an additive digest, a digest over contents. They run when -this module builds (`lake test`). +outside, tested against the definition of the greatest consistent cut by enumeration; and, for +the horizon, the positions a chain serves from ten bits, with the greatest consistent cut among +them found by enumeration. The controls are the readings a build must not take: a read at a cut +past the head, the store rewritten in place, generations without their closing stamp, a key's +state taken for unchanged whatever the delta writes, an event filter before the cut, an erasure +that deletes rows, a state served without the seal, the looser seal taken for a monotone one, +kept rows served without their sources, a frontier taken for a cut, an additive digest, a digest +over contents, the pruned store read under its horizon, a frontier lowered to the served +positions without the descent. They run when this module builds (`lake test`). -/ @[expose] public section @@ -81,6 +84,29 @@ nothing more, which is at most as many passes as the frontier has positions. -/ def resolve (es : List Edge) (x y : ℕ) : Cut (Fin 2) := cu ((lower es)^[x + y] (x, y)).1 ((lower es)^[x + y] (x, y)).2 +/-- The rows of a generational store as tuples, to compare two of them. -/ +def rowsOf (rs : List (Gen (Fin 3) (Fin 3))) : List (Fin 3 × Fin 3 × ℕ × Option ℕ) := + rs.map fun r ↦ (r.key, r.val, r.born, r.died) + +/-- The positions a chain serves, from ten bits: its empty prefix always, and of the positions +one to five those whose bit is set. -/ +def sv (m : Fin 1024) (k : Fin 2) (p : ℕ) : Bool := + p == 0 || (decide (p ≤ 5) && m.val.testBit (5 * k.val + p - 1)) + +/-- The greatest consistent cut under the frontier `(x, y)` among the served positions, by +enumeration: the pointwise maximum of every consistent cut of the grid under the frontier whose +two positions are served. -/ +def bestIn (es : List Edge) (p : Fin 2 → ℕ → Bool) (x y : ℕ) : ℕ × ℕ := + (List.range 6).foldl (fun (acc : ℕ × ℕ) (u : ℕ) ↦ + (List.range 6).foldl (fun (acc : ℕ × ℕ) (v : ℕ) ↦ + if cons es (cu u v) && p 0 u && p 1 v && decide (u ≤ x) && decide (v ≤ y) + then (max acc.1 u, max acc.2 v) else acc) acc) (0, 0) + +/-- The greatest served position of a chain at or under a position: the frontier lowered to +what is served, before any descent. -/ +def floorSv (p : Fin 2 → ℕ → Bool) (k : Fin 2) (x : ℕ) : ℕ := + (List.range (x + 1)).foldl (fun (n : ℕ) (q : ℕ) ↦ if p k q then q else n) 0 + /-- A collision-free step: the chain read as a numeral in base four, digits one to three. -/ def step4 (h : ℕ) (a : Fin 3) : ℕ := 4 * h + a.val + 1 @@ -193,6 +219,22 @@ def verifies (z : Certificate (Fin 2) ℕ) (s : Store (Fin 2) (Fin 3)) : Bool := (fun (m : Fin 3 → Option (Fin 3)) (e : Fin 3 × Fin 3) ↦ Function.update m e.1 (some e.2)) (stateAt l a) x) = true) 447 +/- SNP-3: an event read at the later cut was read at the earlier cut or lies in the delta. -/ +#eval survives (∀ (a b : List (Fin 3)) (i j m n : ℕ), + (List.finRange 2).all (fun k ↦ + (readAt (st a b) (cu (i + m) (j + n)) k).all fun x ↦ + (readAt (st a b) (cu i j) k).contains x + || (readBetween (st a b) (cu i j) (cu (i + m) (j + n)) k).contains x) = true) 475 + +/- SNP-3: a key the writes between two cuts do not name has the same state at both. -/ +#eval survives (∀ (l : List (Fin 3 × Fin 3)) (a d : ℕ) (x : Fin 3), + (((l.take (a + d)).drop a).any (fun e ↦ e.1 == x) + || stateAt l (a + d) x == stateAt l a x) = true) 476 + +/- Control: a key's state at two cuts is not the same whatever the delta writes. -/ +#eval refuted (∀ (l : List (Fin 3 × Fin 3)) (a d : ℕ) (x : Fin 3), + (stateAt l (a + d) x == stateAt l a x) = true) 477 + /- SNP-6: a narrower grant's snapshot is the restriction of a wider one's. -/ #eval survives (∀ (a b : List (Fin 3)) (m : ℕ) (g g' : Fin 4) (c c' : Fin 8), same (snapshot (fun k ↦ (gr g k && gr g' k) = true) (fun x ↦ pf c x && pf c' x) (st a b) @@ -346,4 +388,52 @@ what a reader reads is the store with holes. -/ == chainDigest stepO 0 ((contents (committed commit3 (st a b)) k).take (cu m n k))) = true) 472 +/- SNP-10: the generational store pruned at a horizon reads, at every cut from the horizon on, +the state recomputed from the whole prefix. -/ +#eval survives (∀ (l : List (Fin 3 × Fin 3)) (h d : ℕ) (x : Fin 3), + (genRead (prune h (gens l)) (h + d) x == stateAt l (h + d) x) = true) 478 + +/- SNP-10: at any cut the pruned store returns nothing or the value the key held there. -/ +#eval survives (∀ (l : List (Fin 3 × Fin 3)) (h c : ℕ) (x : Fin 3), + ((genRead (prune h (gens l)) c x).isNone + || genRead (prune h (gens l)) c x == stateAt l c x) = true) 479 + +/- Control: the pruned store read at a cut under its horizon is not the state at the cut. -/ +#eval refuted (∀ (l : List (Fin 3 × Fin 3)) (h c : ℕ) (x : Fin 3), + (genRead (prune h (gens l)) c x == stateAt l c x) = true) 480 + +/- SNP-10: pruning at two horizons is pruning at the later one. -/ +#eval survives (∀ (l : List (Fin 3 × Fin 3)) (h h' : ℕ), + (rowsOf (prune h (prune h' (gens l))) == rowsOf (prune (max h h') (gens l))) = true) 481 + +/- SNP-10: among the served positions the greatest consistent cut under a frontier exists: the +pointwise maximum of every consistent served cut under the frontier (all thirty-six of the grid) +is consistent and served. -/ +#eval survives (∀ (es : List Edge) (m : Fin 1024) (x y : Fin 6), + (cons es (at2 (bestIn es (sv m) x.val y.val)) + && sv m 0 (bestIn es (sv m) x.val y.val).1 + && sv m 1 (bestIn es (sv m) x.val y.val).2) = true) 482 + +/- Control: the frontier lowered to the served positions, without the descent, is not always +consistent. -/ +#eval refuted (∀ (es : List Edge) (m : Fin 1024) (x y : Fin 6), + cons es (cu (floorSv (sv m) 0 x.val) (floorSv (sv m) 1 y.val)) = true) 483 + +/- SNP-10: the cut read lies under the resolution of the frontier, and under the frontier +lowered to the served positions. -/ +#eval survives (∀ (es : List Edge) (m : Fin 1024) (x y : Fin 6), + (decide (at2 (bestIn es (sv m) x.val y.val) ≤ resolve es x.val y.val) + && decide ((bestIn es (sv m) x.val y.val).1 ≤ floorSv (sv m) 0 x.val) + && decide ((bestIn es (sv m) x.val y.val).2 ≤ floorSv (sv m) 1 y.val)) = true) 484 + +/- SNP-10: the cut read rises with what is served. -/ +#eval survives (∀ (es : List Edge) (m m' : Fin 1024) (x y : Fin 6), + decide (at2 (bestIn es (fun k p ↦ sv m k p && sv m' k p) x.val y.val) + ≤ at2 (bestIn es (sv m) x.val y.val)) = true) 485 + +/- SNP-10: when every position is served the cut read is the resolution of the frontier. -/ +#eval survives (∀ (es : List Edge) (x y : Fin 6), + (List.finRange 2).all (fun k ↦ + at2 (bestIn es (fun _ _ ↦ true) x.val y.val) k == resolve es x.val y.val k) = true) 486 + end Palace.Snapshot.Attack diff --git a/formal/README.md b/formal/README.md index 32cb330a..880858e3 100644 --- a/formal/README.md +++ b/formal/README.md @@ -310,7 +310,9 @@ Roundoff and FloatModel, so it has no statements of its own): the read at a later one, and a cut of a cut is the meet; SNP-3 the read at `a` followed by the read between `a` and `b` is the read at `b` and adjacent reads-between compose, so a fold continued from a checkpoint over the events since is the fold of the prefix (a job's checkpoint - is a cut); SNP-4 the read at the head cut is the store, so `as of` the current cut is no + is a cut), an event or a pair of events read at the later cut was read at the earlier one or + lies in the delta, and a key the delta does not write has one state at both cuts; SNP-4 the + read at the head cut is the store, so `as of` the current cut is no `as of`; SNP-5 a reader is append invariant exactly when it reads only the prefixes, exactly when it is a derived view, and for keyed writes the generational store read at a cut is the state recomputed from the prefix and the last write inside it, with at most one generation of a @@ -331,9 +333,15 @@ Roundoff and FloatModel, so it has no statements of its own): a collision-free digest have the same read at its cut and so the same derived views, a certificate extends over the events since an earlier one, the meet and the join of two certified cuts are certified from the two certificates alone, and an erasure that keeps a - commitment beside each event keeps every certificate. The controls as theorems: the reader - that ignores the cut, the store rewritten in place, an event filter applied before the cut, the - erasure that deletes rows, a digest with collisions. Design theorems (Palace and PalaceTest, no + commitment beside each event keeps every certificate; SNP-10 the horizon: a generational store + that drops the rows closed at or under a horizon reads, at every cut from the horizon on, the + state recomputed from the whole prefix, under the horizon it is never wrong and reads what it + lost as absent, horizons compose to the later one, and where the chains serve only some + positions (those from a horizon on, and the empty prefix) every frontier resolves to exactly + one greatest consistent cut among them, which rises with what is served and never passes the + cut asked. The controls as theorems: the reader that ignores the cut, the store rewritten in + place, an event filter applied before the cut, the erasure that deletes rows, a digest with + collisions, the pruned store read under its horizon. Design theorems (Palace and PalaceTest, no Spec rows): `as of` reads the citation graph at a commit and every other store as it is now. - `Bridges`: theorems that join two families, so that what one proves serves the other: BRG-1 the Laplacian as `∂₁ ∂₁ᵀ`, BRG-2 Euler and Poincaré on the flag complex, BRG-3 Thomson's @@ -865,24 +873,31 @@ at a gain above the rate the ceiling is fixed, on the first instance; at exponen not constant, on the first instance; and the greedy walk's empirical measure is not within `1/8` of the structural stationary distribution, on the first instance. -The snapshot is attacked on the model's own definitions (seeds 430 to 474): stores of two +The snapshot is attacked on the model's own definitions (seeds 430 to 486): stores of two chains over three events, cuts from two naturals, keyed chains over three keys, chains of landings and retires from codes, grants from two bits and event filters and erasures from three, -reads-from relations as lists of edges between the two chains at positions under four, and a -digest that reads a chain as a numeral in base four, which is collision free. Thirty attacks +reads-from relations as lists of edges between the two chains at positions under four, a +digest that reads a chain as a numeral in base four, which is collision free, and the positions +a chain serves from ten bits. Thirty-nine attacks survived, every one all 500 instances: the read at a cut and between two cuts under growth; the prefix order and the meet; the two compositions and the journal; the head cut; the generational store against the recomputed state and the last write, one generation alive at most, the same -under growth, and the keyed journal; the narrower grant, and the chains a snapshot reads; the +under growth, and the keyed journal; an event of the later cut in the earlier one or in the +delta, and the key the delta does not write; the narrower grant, and the chains a snapshot +reads; the erasure (nothing erased visible, positions kept, the holes dropped), the retire that seals every earlier cut, growth that only removes, the two seals in their order, and the kept rows with their sources; the resolver, the meet and the join of consistent cuts, and the monotone resolution; the certificate under growth, the digest of a reversed chain, the certificate over the delta, at the meet and the join, and -across an erasure on a committed store. The resolver is the one thing attacked that the library +across an erasure on a committed store; the pruned generational store at and past its horizon, +never wrong under it, and two horizons as the later one; and, among the served positions, the +greatest consistent cut under a frontier found by enumeration, consistent and served, under the +resolution of the frontier, rising with what is served, and equal to the resolution when every +position is served. The resolver is the one thing attacked that the library does not define: the descent that lowers a frontier until no event inside it has a source outside, checked against the greatest consistent cut by enumerating the thirty-six cuts of the -grid. The fifteen controls, each refuted: a read at a cut past the head changes with growth, +grid. The eighteen controls, each refuted: a read at a cut past the head changes with growth, within 11 instances; the read at one cut is a prefix of the read at any other, within 6; the composition with the cuts in any order, within 6; the store rewritten in place as the state at a cut, within 5; generations without the closing stamp, which read a key's oldest write, within 18; @@ -892,8 +907,10 @@ at a cut holds an event from after it, within 29; the state at a cut served with within 53; the looser seal taken for one under which growth only removes, within 48; the kept rows served without their sources, within 11; the frontier taken for a consistent cut, within 11; a consistent cut advanced by one position, within 12; the additive -digest, under which a chain and its reverse agree, within 11; and a digest over the contents, -which an erasure changes, within 14. +digest, under which a chain and its reverse agree, within 11; a digest over the contents, +which an erasure changes, within 14; a key's state taken for the same at two cuts whatever the +delta writes, within 17; the pruned store read under its horizon as the state at the cut, within +30; and a frontier lowered to the served positions without the descent, within 24. ## Build From 1ef11aec055e7c16ff80c194f630620a3a7a95a1 Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 01:35:21 -0500 Subject: [PATCH 06/37] docs(design): dn-temporal-snapshot, the inventory and the cut The first three sections of the note. What `as of` does today, read on main: it moves the citation graph and a repository file to the cut and reads every other store as it is now; it takes a commit's sha and refuses `HEAD` and a date; the note it attaches lists `read` as reading the present though a repository path is read at the cut, and the hit drops the commit the text came from. The inventory classes every store an instance writes by what a past state of it is, with its clock, what names a position and what a rewrite loses. Seven corrections to the two-class picture follow from it. The catalog is the gap: rewritten in place by six methods called from seven modules, with no ledger of its past outside one place. Lexical units and superseded vectors are kept, and a stamp on their rows would be wrong, since a path that returns to earlier bytes makes the same rows current again. The causal store depends on the order of two jobs, and its edge ids change when a session grows. A purge leaves the words in the lexical index and in the vector table's earlier versions. A reset takes the ledgers too. The cut is one position per chain, about a dozen for an instance, the chains per provenance class where clearances separate rows, and a position is a number the store keeps. The missing ledger is a landing log in the catalog's file, written by the catalog's own methods, with the catalog as its fold. A recorded cut is a content-addressed row with its attestation. A name (`head`, a cut's id, a commit, a date) resolves to a frontier and the read is at the greatest consistent cut under it; each row records the head of the chain it reads, which is what the resolver compares. A certificate is the digest of each chain's prefix. Co-Authored-By: Claude Fable 5.2 --- docs/design-notes/dn-temporal-snapshot.md | 479 ++++++++++++++++++++++ 1 file changed, 479 insertions(+) create mode 100644 docs/design-notes/dn-temporal-snapshot.md diff --git a/docs/design-notes/dn-temporal-snapshot.md b/docs/design-notes/dn-temporal-snapshot.md new file mode 100644 index 00000000..50173245 --- /dev/null +++ b/docs/design-notes/dn-temporal-snapshot.md @@ -0,0 +1,479 @@ +--- +type: design-note +id: dn-temporal-snapshot +track: query-language +status: draft # provenance description, never a gate; the merge is ratification +implementation: design-only # nothing built in the store; the laws are machine-checked in formal/Palace/Snapshot.lean +created: 2026-11-10 +updated: 2026-11-11 +links: + - papers/2026-11-10-temporal-snapshot/paper.tex # the article: the same theorems, with proof sketches and the references + - docs/design-notes/global-event-clock.md # N, its generators, the cut as a certified frontier (§2.4) + - docs/brainstorms/limits-of-the-algebra.md # L7: the snapshot as the clock's cut on the version chains + - docs/design-notes/dn-query-sentence-algebra.md # `as of` as the index of the reading; §2.9 what is not in the universe + - docs/design-notes/dn-ingress.md # the one writer, the landing order, the key written last (ING-7) + - docs/design-notes/dn-two-phase-ingestion.md # an item complete without its vector; the pending report (ING-19 to ING-21) + - docs/design-notes/vector-membership-store.md # atoms, occupancies per class, purge (A3.7) + - docs/design-notes/dn-utility-field.md # the use log and the field as its fold (UTL-4); its open question 1 + - docs/design-notes/dn-graph-dynamics.md # GD-4: velocity over a window of cuts, which waits on the snapshot + - docs/design-notes/dn-mathematical-foundations.md # the ladder; design theorems before code + - formal/Palace/Snapshot.lean # the theorems (Snapshot/Defs.lean the model; PalaceTest/Snapshot.lean the attacks) +supersedes: null +superseded_by: null +warrant: null +--- + +# The temporal snapshot: the palace as of a cut + +> Composed on the snapshot session (Fable 5.2, 2026-11-10 and 2026-11-11), on the standing +> direction that the design and its proofs come first and the build follows a licence given at +> the merge. Agent-drafted, filed `draft` on a branch; the merge is ratification. Nothing is +> built: `core/` is untouched and no store of any instance was read. Every nontrivial claim +> carries a grade: `[THEOREM]` is machine-checked in `formal/Palace/Snapshot.lean` and names its +> declaration; `[ESTABLISHED]` is a ratified note's, or a fact of the code read at the line +> cited; `[DERIVED]` is argued here from those; `[MEASURED]` is a figure taken for this note on a +> synthetic fixture (§11 says how); `[INFERENCE]` is a design call with a named falsifier; +> `[HYPOTHESIS]` is a claim nothing here checks, with what would check it named. Code claims were +> read on `origin/main` at `e3e3ee47`. The article `papers/2026-11-10-temporal-snapshot/paper.tex` +> states the same theorems with proof sketches and the references. + +## 1. Purpose and scope + +### 1.1 The requirement + +A sentence of the query language can carry `as of ""`. Today it moves one relation: the +citation graph, which the stores index by commit, is read at the cut, and a file of the repository +is read as git's blob there. Every other verb reads the stores as they are now, and the answer +says so. The requirement is the rest: the palace as of a cut. A read at a cut must be the same +whenever it is asked, since the store only grows above the cut; it must never return what was +erased since; it must respect the grant the asker holds today; and where it cannot read a store at +the cut it must say so instead of answering from the present. + +The same object serves three needs the record already names: a generic integrator, whose +checkpoint is a cut and whose input is the delta between two cuts; the velocity of an identity +over a window of cuts (dn-graph-dynamics GD-4, which waits on the snapshot); and the utility field +as of a cut (dn-utility-field, open question 1). + +### 1.2 Decisions + +1. **A cut is one position per chain, about a dozen positions for an instance, not one per + document (§3.1, §3.3).** The chains are the stores' own append orders, one per provenance class + where clearances separate the rows. `[DERIVED from global-event-clock §2.4; INFERENCE, + falsifier SNF-2]` +2. **The missing ledger is a landing log (§3.2).** The catalog is rewritten in place, and no + ledger records which digest a path held when, except the version chains of one place. One + append-only, hash-chained log a provenance class, written by the catalog's own methods in the + transaction of the row they write, makes the catalog its fold and gives every landed stratum a + past. `[ESTABLISHED for the gap; INFERENCE for the log, falsifier SNF-1]` +3. **A name resolves to a frontier, and the read is at the greatest consistent cut under it + (§3.4, §3.5).** Consistent cuts are closed under meet and join, and every frontier resolves to + exactly one. Wall time selects a frontier by lookup in the bookmarks and orders nothing. + `[THEOREM: SNP-8]` +4. **A cut is certified by the digest of each chain's prefix, recorded and attested (§3.6).** A + certificate verifies on every later state of the store and, under a collision-free digest, + pins the read. `[THEOREM: SNP-9]` +5. **Derived data is a function of the prefixes, held store by store in the cheapest of the + equal ways (§5):** version-keyed rows selected by the log for vectors and lexical units, + recomputation for the causal fiber, kept generations for model output. `[THEOREM: SNP-5; + INFERENCE per store]` +6. **The grant and the erasure are the present's (§6).** A narrower grant's snapshot is the + restriction of a wider one's; nothing erased is visible at any cut; a retired identity is + sealed at every earlier cut. `[THEOREM: SNP-6, SNP-7]` +7. **A read under `as of` holds no event from after the cut it names (§7).** Where a store + cannot serve the cut asked, it is read at the greatest position at or under it that it serves, + the cut read is the greatest consistent cut among those positions, and the answer names it + chain by chain. `[THEOREM: SNP-10; INFERENCE for the surface, falsifier SNF-4]` +8. **History is exact from the horizon, and the horizon is an event of the chain (§8).** A + store that drops old generations reads every cut from its horizon on exactly, and a cut under + the horizon is not served. `[THEOREM: SNP-10]` +9. **Retention is counted in positions and drops derived rows before ledgers (§9).** + `[INFERENCE, falsifier SNF-9]` +10. **The build is eight stages, each a pull request with its tests and its rollback; the first + is the landing log (§12).** `[INFERENCE, falsifier SNF-1]` + +### 1.3 Out of scope + +Any change to `core/` (code is licensed at the merge); the storage engines (a study of storage at +scale is under way and none of its figures is in the repository, so this note cites none, measures +what it needs on fixtures of its own, and names for each choice the evidence that would change +it); the spine's reachability index; a second embedder identity held beside the first +(dn-two-phase-ingestion, open question 4); a snapshot of the job queue, the task list and the +telemetry, which are operational state and not content; backups and migration archives, which a +purge does not reach today and which this note does not design. + +### 1.4 What is proved, what is measured, what is open + +Proved, in `formal/Palace/Snapshot.lean` over `formal/Palace/Snapshot/Defs.lean`: SNP-1 to SNP-10 +as §10 states them, 125 theorems, eight of them the controls; attacked in +`formal/PalaceTest/Snapshot.lean` (seeds 430 to 486: thirty-nine attacks, every one surviving all +500 instances, and eighteen negative controls, each refuted). They are design theorems: no code +relies on them, so they have no row in `docs/LAWS.md` and no statement in `formal/Spec/`; §12 says +when they enter the ledger. + +Measured, on synthetic fixtures only (§11): the landing log's size and the cost of its reads; what +a kept version costs in the lexical index; what a purge leaves behind today; that the causal store +depends on the order of two jobs; that the events of a transcript's prefix are not always the +prefix of its events, and what re-deriving a session costs; what `as of` accepts; that a position +taken from a store's row numbering is given again after a delete. + +Open, stated where it bites: reading every head at a cut on a store of millions of paths (§4.2); +the attestation ledger's own content hashes under an erasure (§6.1); the cadence of recorded cuts +(§3.3); a repository history that is not one line (§3.1). + +## 2. What exists + +### 2.1 `as of` today + +`as of ""` is an adjective of the grammar (`core/sentence/grammar.py:253-256`, +`core/sentence/ast.py:205-210`): the index of the reading, never a letter of a chain +(dn-query-sentence-algebra §2.3). `[ESTABLISHED]` + +- **One cut a sentence.** The universe's builder keeps the cut of the `as of` it meets + (`core/sentence/universe.py:125-127`), and the executor refuses a clause whose cut is not the + universe's (`core/sentence/execute.py:713-718`). `[ESTABLISHED]` +- **The names it accepts.** A commit's sha, whole, or a prefix the reference store resolves to + one commit (`universe.py:466-477`, `core/stores/reference_edges.py:381-388`). A commit the store + holds no reading for falls back to the newest reading (`universe.py:478-484`) and the clause is + then refused; so are `HEAD` and a date. `[ESTABLISHED; MEASURED §11]` +- **What is read at the cut.** The citation graph (`universe.py:485-486`), and a file of the + repository, as git's blob in the tree at the commit (`execute.py:249-302`, called with the + universe's cut at `universe.py:787-788`). `[ESTABLISHED]` +- **What is read as it is now.** Everything else, and the answer carries a note naming the verbs + (`execute.py:503-521`, `:719-725`). The note lists `read` among them, though a `read` of a + repository path is at the cut: on a file that changed since the cut the text returned is the + cut's blob and the note says the present. `[MEASURED §11]` The record of such a read carries the + commit it was read at, and the hit built from the record drops it (`execute.py:296-299`, + `:1121-1126`), so the answer does not show which commit the text is from. A note's `read` opens + the vault file when its reference is a path under the vault, and the raw object of the catalog's + digest otherwise (`execute.py:342-350`): the present, in the first case newer than the catalog. + `[ESTABLISHED]` +- **The cut the spine certifies.** `Spine.cut_at` (`core/temporal/spine.py:1004-1029`) builds a + `CertifiedCut` from the frontier the stores have now: one position per chain, a chain per + document for the versions (`spine.py:222-234`, `:805-816`), with the quiescence certificates of + the event clock's §2.4 as evidence strings. No past cut can be named through it, nothing in it + lets a later reader check that a store still holds the prefix that was cut, and the catalog + enters the spine with no chain at all (`spine.py:549-556`). `[ESTABLISHED]` + +### 2.2 The inventory + +Every store an instance writes, by what a past state of it is. The clock is the order that +positions its rows; wall-time columns are bookmarks and position nothing (event clock, Law C4). +The job queue, the task list and the telemetry are left out (§1.3). + +**Ledgers: a past state is a prefix.** + +| store | clock | what names a position | what a rewrite loses today | +|---|---|---|---| +| raw objects (`core/kernel/stores/rawstore.py:28-40`) | none of its own; an object is ordered by the events that name its digest | the digest | nothing is rewritten; a purge deletes the object (`rawstore.py:51-61`); a transcript that grew is retained whole again under a new digest (`ops/chat_sensor.py:289-333`) | +| version chains (`core/stores/versions.py:77-86`) | `version_seq` per document | `(doc_id, version_seq)` | nothing (one admitted relabel of `doc_id`, `versions.py:132`); kept by one place only, `mirror_authored` (`core/ingest/table.py:241-251`) | +| attestations (`core/attestation/store.py:27-36`) | insertion order and the parents' graph; read back `ORDER BY timestamp, id` (`store.py:130`) | the content-addressed id | nothing; one per (action, digest) unless a version event (`core/ingest/landing.py:77-86`), so not one a landing, and no path | +| chat utterances (`core/stores/chatlog.py:77-92`) | `turn_index` per session | `(session_id, turn_index)` | nothing: the first write of a turn stands (`chatlog.py:161`); the store is wiped by a reset and filled again from the raw store (`chatlog.py:41-45`) | +| citation readings (`core/stores/reference_edges.py:134-148`) | the commit of the reading; git orders the commits | `commit_sha`, part of every edge's identity (`reference_edges.py:164-174`) | nothing: one whole reading a commit, append-only (`reference_edges.py:289-302`) | +| commit ledger (`ops/code_snapshot.py:44-58`) | git's ancestry: the ledger keeps no parent, and the sensor reads the commits of one branch in `rev-list` order (`ops/code_sensor.py:404-418`) | `commit_sha` | nothing | +| observation history (`core/stores/observation_history.py:46-56`) | the interpreter's generation per identity | (store, identity, interpreter) | nothing: a superseded generation is archived, never dropped (`core/stores/code_observations.py:211-254`) | +| run ledger, verdicts (`core/stores/runledger.py:140`, `:161`; `core/stores/verdicts.py:145`) | insertion order | the row's id | nothing | +| staging (`core/stores/staging.py:118-138`) | its own generation clock | the generation | a sweep stamps `tombstoned_at_gen` and the row stays; `read_at(g)` exists (`staging.py:232-244`) | +| query log (`core/sentence/surface.py:93`) | line order | the line | nothing | + +**Version-keyed derived stores: every version's rows are kept and a flag marks the head.** + +| store | clock | what names a position | what a rewrite loses today | +|---|---|---|---| +| plane occupancies (`core/stores/plane.py:268-278`) | none: `landed_at` is wall time | (path, digest, chunk) | which version was the head when: only `current` flips, and flips back when a path returns to bytes it held before (`plane.py:466-487`) | +| the plane's supersession log (`plane.py:282-289`) | `seq` per path | (path, seq) | a purge deletes entries and the next entry takes the position again (`plane.py:491-495`, `:552-553`) `[MEASURED §11]`; a reset drops it (`plane.py:628-640`); an instance with no plane has none; under lazy embedding it records the drain's order, not the landing's | +| atoms (the vector table) | none: content-addressed (`plane.py:113-115`) | the atom's id | the `held` and `current` cache columns; the table's own dataset versions, one a write, which a compaction drops (`core/stores/vectorstore.py:780-812`) | +| lexical units and postings (`core/stores/lexical.py:56-82`) | none: `landed_at` is wall time | (path, digest, chunk) | the head flag (`lexical.py:251-256`, `:260-265`); every unit, when the tokenizer changes (`lexical.py:180-194`) | +| code memberships (`core/stores/memberships.py:140-155`) | git: (path, blob) | the version's identity | the head flag; a purge leaves a recorded hole (`memberships.py:153`, `:491-497`) | + +**Stores rewritten in place: no past.** + +| store | clock | what names a position | what a rewrite loses today | +|---|---|---|---| +| catalog (`core/stores/catalog.py:36-45`) | none: `updated_at` is wall time | the path | which digest a path held before and whether it was active: an upsert (`catalog.py:113-121`), a tombstone that flips `active` (`catalog.py:167-170`), a purge that deletes the row (`catalog.py:254-258`) | +| chat events (`core/stores/chat_events.py:40-48`) | `ord` per session, on each row | (session, ord) | the session's rows are deleted and written again (`chat_events.py:72-88`); re-derivable from the retained transcript | +| causal edges (`core/stores/causal_edges.py:51-61`) | `event_order` and `witness_turn`, on each row | the edge's id, a hash that includes the transcript's digest (`causal_edges.py:71-76`) | the session's rows are deleted and written again (`causal_edges.py:130-154`), under new ids when the session grew; what they were before the commit ledger gained a commit | +| interpreted artifacts and hyperedges (`core/stores/derived.py:97-100`) | none: `created_at` is wall time | hash of (kind, subkind, subjects) | the artifact a later pass over the same subjects replaced (`derived.py:209-216`): model output, not recomputable | +| relation edges (`core/stores/edges.py:37-46`) | none: `created_at` is wall time | hash of (u, v, relation) | the weight, sign and provenance a re-assertion replaced (`edges.py:88-106`) | +| claim ops, authored supersessions (`core/stores/claim_ops.py:73`, `core/stores/authored_supersession.py:161`) | none | the key | the replaced row | + +### 2.3 What the two-class picture misses + +The picture this note started from has two classes: ledgers that only append, where a past state +is a prefix, and derived stores rewritten in place, which keep no past and are recomputed from the +ledgers. Read against the code it needs seven corrections. `[ESTABLISHED, each at the lines cited +in §2.2 unless given]` + +1. **The catalog is neither, and it is the gap.** It is the head of every landed item and the + idempotence key (ING-7), rewritten in place, and outside one place no ledger holds its past. + The version chains exist for `mirror_authored` only; for the dialogue, observed and curated + places the sequence of digests a path held is recorded nowhere. It has six writing methods + (`record`, `tombstone`, `remove`, `remove_digest`, `relabel_provenance`, + `migrate_rekey_doc_id`: `catalog.py:100-123`, `:160-172`, `:195-208`, `:210-241`, `:243-246`, + `:254-259`) called from seven modules of `core/ingest/` (`writer.py:419`, `:433`, `:518`; + `sync.py:201`, `:238`; `founding.py:110`; `dialogue.py:75`; `curated.py:80`; `purge.py:61`; + `mint_ids.py:252`), so a record of its past has to be written inside the catalog and not by a + caller. +2. **The attestations do not fill it.** An attestation names a digest and no path, and a landing + attests once per (action, digest): a path that returns to bytes it held before, or bytes that + land at a second path, leave no new record. The ledger is read back in wall-time order. +3. **Lexical postings and a changed item's vectors are not rewritten.** The units and the + occupancies of a superseded version stay; only a `current` flag moves. They are generations in + all but the stamp. And a stamp on the row would be wrong: a path that returns to bytes it held + before makes the same rows current again (`plane.py:466-487`), so a version's rows are valid on + a set of intervals, not on one. What they lack is the position at which each version became the + head and stopped being it, which is the catalog's past again. +4. **The causal store is not a function of its inputs' present state.** The integrator skips a + session whose transcript digest is unchanged (`core/integrator.py:106-111`) and resolves a + commit against the ledger as it is at that pass (`integrator.py:148-164`), so two instances with + the same transcripts and the same ledger hold different edges when the two jobs ran in + different orders. `[MEASURED §11]` The extractor reads every tool result of the transcript + before it walks it (`core/chat_events.py:110-123`, `:153`), so the events of a prefix that ends + between a commit and its result are not the prefix of the events. `[MEASURED §11]` And an + edge's id is a hash over the transcript's digest (`integrator.py:134-137`), so every edge of a + session takes a new id when the session grows, and an id noted from an earlier answer names + nothing. +5. **`read` under `as of` is already at the cut for a repository path** (§2.1). +6. **An erasure does not reach every store.** `purge_raw` removes the vector rows, the raw object + and the catalog rows (`core/ingest/purge.py:58-62`). On a synthetic palace, after the purge of + both versions of a note: the lexical units and postings of the purged versions remain, with + their words; the version rows and the attestations still name the digests; and the purged text + is still returned by the vector table read at its earlier dataset versions, until a compaction + with no retention, which the purge does not call. `[MEASURED §11]` The relation edges whose + endpoint is the digest and the interpreted artifacts whose subject it is are not touched + either, and no deletion attestation is written, though the attestation store's header says one + is (`core/attestation/store.py:3-6`; no call in `purge.py` or `scripts/purge_raw.py`). A + snapshot that read those stores at a cut would return what the purge left, so §6.1 states what + an erasure must reach before any of them is read at a cut. +7. **A reset takes the ledgers with the derived stores.** Its targets are the raw store, the + vector store, the catalog, the attestations, the version chains, the chat log and the stores + derived from them (`ops/lifecycle/launcher.py:1748-1800`); the commit ledger and the + observation history are guarded (`launcher.py:111-118`). The raw store is the first target + listed (`launcher.py:1753`), while the comment beside the chat log's entry says it is not one + (`launcher.py:1779-1780`). Whatever the intent, no chain of an instance survives a reset with + its positions, so a reset opens a new history (§8). + +## 3. The cut + +### 3.1 Chains and positions + +A chain is an append order a store already records, or the one §3.2 adds; a position is a prefix +length of it. `[DERIVED from global-event-clock §2.2, generator g1]` + +| chain | store | position | today | +|---|---|---|---| +| `land:`, one a provenance class | the landing log (§3.2), in the catalog's file | `seq`, from 1, never given twice | not built | +| `chat` | the chat log | a sequence number beside each row; within a session it is the turn order | the order is recorded, the number is not | +| `att` | the attestation ledger | a sequence number beside each row | the order is recorded, the number is not; the ledger is read in wall-time order | +| `repo` | git, mirrored by the commit ledger and the per-commit readings | a commit, standing for its ancestors | recorded | +| `interp` | interpreted artifacts, relation edges, claim ops | a generation (§5.4) | not built | +| `staging` | the staging store | its generation | recorded | +| `runs` | the run ledger | a sequence number | recorded as insertion order | +| `use` | the utility field's use log (dn-utility-field §3.1) | the tick | not built | + +Three choices are made here. + +**The position is the store's, not the document's.** The spine's frontier has a pair per document +(`spine.py:222-234`), which is a frontier of millions of pairs on a corpus instance, where one +position a store with the per-path order inside it says the same thing (CLK-2: a frontier cut +needs only its cross-store edges checked). `[DERIVED]` The version chains stay as they are: the +log carries each landing's document and version number, so a document's chain is the log's +sub-chain, and the versions store remains the primary record of supersession. + +**Where clearances separate rows the chain is per class.** A position counts every event before +it, so on a chain that mixes classes a reader of one class learns from its positions how many +landings the others made (`Witness.position_channel`), and a snapshot under a grant reads only the +chains the grant names and the cut on them (`snapshot_congr`). `[THEOREM: SNP-6]` + +**A position is a number the store keeps, never the row numbering it happens to have.** The chat +log and the attestation ledger are keyed by text, and SQLite numbers their rows as the largest +number in use plus one, so a number is given again after the last row is deleted. `[MEASURED +§11]` Stage SN-2 adds a chain table beside each (an integer key, the row's own key, the running +hash of §3.6), written in the transaction of the append. + +On `repo` the order is git's ancestry, which is a chain only when the history read is one line. A +commit names the down-set of its ancestors, and CLK-2's laws are stated for down-sets of any +order (`Clock.IsCut.inter`, `Clock.IsCut.union`), so the meet of two cuts at two commits is the +down-set of their common ancestors and the join the down-set of both; a join of two commits +neither of which is the other's ancestor is not named by one sha. On an instance that reads one +branch whose history is a line, which is what this repository's merges by rebase produce, every +cut on `repo` is a commit and the model's chain applies as it stands. `[DERIVED from CLK-2; +INFERENCE for the line, parked as SN-f]` + +### 3.2 The landing log + +One table in the catalog's file, written by the catalog's own methods in the transaction that +writes the catalog's row, so the key and its log entry land together, no caller can write one +without the other, and ING-7's order is unchanged (the key last, now two rows of one +transaction): + +```sql +CREATE TABLE landings ( + class TEXT NOT NULL, -- the provenance class: one chain a class + seq INTEGER NOT NULL, -- the position in the class's chain, from 1, never given twice + kind TEXT NOT NULL, -- genesis | store | retire | move | unseal | horizon + source_path TEXT, -- NULL once purged + doc_id TEXT, -- the identity the event belongs to; NULL once purged + version INTEGER, -- the version number, where the place keeps a chain + digest TEXT, -- NULL for a retire, and once purged + title TEXT, -- NULL once purged + att_head INTEGER, -- the head of `att` when the row was written (§3.5) + salt BLOB, -- 16 random bytes; NULL once purged + commitment BLOB NOT NULL, -- sha256(salt, the row's fields): what the chain digests + hash BLOB NOT NULL, -- sha256(the previous row's hash, commitment) + closed_at INTEGER, -- the seq of the path's next event; NULL while it is the head + at TEXT NOT NULL, -- wall bookmark: lookup only, never an order + PRIMARY KEY (class, seq) +) WITHOUT ROWID; +CREATE INDEX landings_path ON landings (class, source_path, seq); +CREATE INDEX landings_closed ON landings (class, closed_at) WHERE closed_at IS NOT NULL; +``` + +The kinds are the catalog's writes. `store` is a landing (`record`). `retire` is the tombstone of +an identity no other active path holds. `move` is a tombstone that leaves the identity at another +path (the second half of a rename, which the writer tells from a delete by the catalog, +`writer.py:409-413`) and the owner-gated re-key of an identity (`catalog.py:210-241`). `genesis` +opens a class's chain and is followed by one row for each path the catalog holds at that moment, +in path order. `unseal` and `horizon` are §6.2's and §8's. A purge is not a kind: it empties rows +(§6.1). A relabel of a whole class (`catalog.py:195-208`) renames its chain and moves no position. + +The catalog is then the fold of the log: each path's last event (`stateOf`). The state at a +position is the same fold of the prefix (`stateAt`), read by one seek as the path's last event at +or under the position (`stateAt_eq_lastWrite`), or for every path at once through the closing +stamp: the rows with `seq ≤ c` and `closed_at` absent or above `c` (`genRead_gens`). The stamp is +the one field written after a row is appended, and it is a function of the rows, the position of +the path's next event (`gens_append_singleton`), so it can be rebuilt and it changes no read at a +cut inside the chain (`genRead_gens_append`). At most one row of a path is alive at a cut +(`length_filter_selects_le_one`), which is L7's falsifier turned into a theorem. `[THEOREM: +SNP-5]` The store's own precedent is the staging store: a generation clock, an admission stamp +and a tombstone stamp on each row, and `read_at(g)` as exactly this predicate +(`core/stores/staging.py:232-244`). `[ESTABLISHED]` + +The chain is hashed like the prediction ledger (`eval/predictions/ledger.py:1-12`), with one +difference that §6.1 needs: a row's hash covers a commitment to the row and not the row, so a +purge can empty the row and keep the chain (`commitments_purge`, `verifies_purge`). `[THEOREM: +SNP-9]` + +### 3.3 The cut and its record + +A cut is a position for every chain of §3.1: for an instance, about a dozen integers. +`[DERIVED]` The read at a cut is the prefix of every chain (`readAt`), and everything else in this +note is a function of that. A cut is worth recording when it is consistent (§3.5) and the stores +were quiescent when it was taken, which is the event clock's certified frontier: between two jobs +of the one writer, with the handoff empty, the head of every chain is such a cut (GC-N3). +`[ESTABLISHED: global-event-clock §2.4]` + +A recorded cut is a row of a `cuts` table beside the log and an attestation of it. An attestation +has no field for a payload: it names an action, input and output hashes and its parents +(`core/attestation/record.py:51-62`). So the record is content-addressed: its id is the hash of +its canonical bytes (the frontier, the digest of each chain's prefix at it (§3.6), the horizons in +force (§8), the quiescence certificates as the spine sources them (`spine.py:1064` on), the reason +it was taken, the previous record's id), with a wall bookmark beside it; and the attestation, of +action `cut`, names the id as its output and the previous cut's attestation as its parent, passed +as the batched landing passes its parents (`writer.py:427-430`). The recorded cuts are then a +chain inside the attestation ledger, signed when attestations are, and the id is the cut's name. +Since each record is the head of every chain at some moment and chains only grow, the recorded +cuts are totally ordered. `[INFERENCE, falsifier SNF-3]` + +Three moments record one: the code sensor reading a commit (`ops/code_sensor.py:404-418`, where it +already attests the commit), so that every commit of the ledger has a cut; the trough, when the +frontier moved since the last record; and the owner's command. At the kilobyte a row the +attestation ledger takes in the repository's records +(`docs/experiments/corpus-measurements-2026-11-07.md:107`) a recorded cut is about two kilobytes +with its row. A record a job would be tens of megabytes a day at the job rate those records show +(720 an hour, `corpus-measurements-2026-11-07.md:94-95`); a record a sensed commit and a moved +trough is far less, and the cadence is parked (SN-a). + +### 3.4 Names + +`as of` takes a string, and the string resolves to a frontier. The shapes do not overlap: + +| name | resolves to | exact | +|---|---|---| +| `head` | the head cut; the answer is the answer without `as of` (`view_head`) | yes | +| `cut:` and a recorded cut's id, or a prefix that names one | that record's frontier | yes, and checkable against its certificate | +| a commit's sha or an unambiguous prefix, as today | the cut recorded when the sensor read the commit; where none was recorded, the commit on `repo` and the empty prefix on every chain whose horizon is later (§8) | on `repo` always; elsewhere from the first recorded cut | +| a date or a date and time | the last recorded cut whose bookmark is at or before it | to the cadence of the records; the answer names the cut it read | + +Wall time enters in the last row only, as a lookup key into bookmarks, and the cut it selects is +ordered by the chains (Law C4; the staging store's sweep resolves wall time to a generation the +same way, `staging.py:26-30`). A commit is resolved by the moment the palace read it, which is an +event of its own chains, and not by the commit's date, which is another clock's. A branch or a +tag is not a name: it moves. The grammar does not change; the names it accepts do, and the answer +always carries the cut read. `[INFERENCE, falsifier SNF-3]` + +### 3.5 Consistency and resolution + +An event of one chain may read from an event of another: `R k i k' j` says the `i`-th event of +chain `k` reads from the `j`-th of chain `k'` (the event clock's generators g2 and g3). The +references between the chains of §3.1 are these. `[ESTABLISHED: read off the writers]` + +- a landing reads from its attestation and, where the place keeps chains, its version row, by the + order the writer lands them in (`core/ingest/writer.py:397-436`: the version, the attestation, + the key last); +- a causal edge reads from the turn that witnessed it and, when it ends at a commit, from the + commit (`causal_edges.py:58-60`, `integrator.py:134-137`); +- a citation reading reads from its commit; +- an interpreted artifact reads from its subjects' landings and from the run that produced it; + a relation edge from the landings of its two endpoints; +- a recorded cut reads from the prefix of every chain it certifies. + +A cut is **consistent** when every source of an event inside it is inside it (`Consistent`): no +fact whose sources lie after the cut, every cross-chain reference closed. `[THEOREM: SNP-8]` + +- Consistent cuts are closed under the pointwise meet and join, with the empty cut at the bottom + (`Consistent.inf`, `Consistent.sup`, `consistent_zero`): a sublattice of the cuts, so a + distributive lattice (`consistentCuts`). +- They are the event clock's cuts among the frontier cuts: a cut is consistent exactly when the + events under its frontier are a down-set of the order the chains and the references generate + (`consistent_iff_isCut`, on CLK-2's `IsCut` and `frontierCut`). +- Every frontier has exactly one greatest consistent cut under it, and a later frontier has a + later one (`exists_resolves`, `Resolves.unique`, `Resolves.mono`); a consistent frontier is its + own (`resolves_self`). This is what a name's resolution is. +- Consistency is append invariant: the references a store gains by growing start at events at or + past its old head, so a cut inside the old head that was consistent stays consistent + (`Consistent.of_grown`). + +So ING-7's invariant, that a key implies its rows, holds at every consistent cut and not only at +the head: a cut that holds a landing holds its attestation and its version. `[DERIVED]` + +**Where the references are recorded.** The resolver has to know, for an event, where its sources +lie. Each row of a chain that reads another records the head of the chain it reads at the moment +the row was written: the landing's `att_head`, a kept generation's birth (§5.4), a causal edge's +turn and commit, a recorded cut's whole frontier. With one writer a row's sources were all +written before it, so the head at its writing bounds them, the bound is sound (it can only make +fewer cuts consistent, each of them consistent for the true references), and it rises along the +chain. `[DERIVED from the one-writer rule, dn-ingress D3]` + +**The resolver.** A name that selects a recorded cut needs none: the record is consistent. For +any other frontier it is a descent: lower each chain's position to the first event inside the cut +whose recorded bound lies outside it, and repeat until nothing moves, which is at most as many +passes as the frontier has positions. The library proves the cut exists and is unique; the attack +module runs the descent against the definition by enumerating every cut under the frontier (seed +461), and SN-2 transcribes that descent. `[THEOREM for existence and uniqueness; the descent +attacked, not proved]` + +### 3.6 Certificates + +The certificate of a cut is, for each chain, the digest of its prefix under the chain's hash +(`certify`): for a landing log the `hash` of the row at the position, for `repo` the commit's sha, +which is git's own chain, for `chat` and `att` the running hash of the chain table SN-2 adds +beside them. A store verifies a certificate when its own prefixes have those digests (`Verifies`). +`[THEOREM: SNP-9]` + +- **Reproducible.** The certificate of a cut verifies on every extension of the store + (`verifies_certify_of_extends`): the same store later, a restored backup, a clone. +- **Checkable.** Under a collision-free digest, two stores that verify one certificate have the + same read at its cut (`Verifies.readAt_eq`), so every derived view at it is the same on both + (`Verifies.view_eq`). The control is a digest with collisions, under which two different chains + of one length agree (`Witness.digest_collides`). +- **Cheap.** A certificate extends over the events since an earlier one + (`certify_digest_readBetween`), and the meet and the join of two certified cuts are certified + from the two certificates alone, chain by chain the earlier or the later digest (`certify_inf`, + `certify_sup`). +- **Compatible with erasure.** A chain that digests commitments keeps every certificate when an + event's content is erased (`verifies_purge`), and what a reader then reads is the store with + holes (`contents_purge_committed`). + +Checking a certificate against a store is one seek a chain, the stored hash at the position +against the certified digest, 3 microseconds; recomputing a chain from its first row is the +audit, 0.8 s for a million rows. `[MEASURED §11]` From e058ed8f19a13de4cbc3bddd9903371db69807a5 Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 01:37:47 -0500 Subject: [PATCH 07/37] docs(design): dn-temporal-snapshot, the reads, derived data, erasure Sections 4 to 6. The reads: `read_at` and `read_between` for each ledger with the index each needs and its cost; the landing log's two reads are the ones every other store's read at a cut goes through. Reading every head at a cut costs the part of the log walked, not the answer, and the journal form bounds it. Derived data: a view at a cut is a derivation of the prefixes, the three ways of holding one agree, so the choice is cost, store by store. Vectors and lexical units are version-keyed rows the stores keep already, and the log selects the version; a stamp on the rows would be wrong and the vector table's own versions cannot be the snapshot, since a purged text is still read through them until a compaction that drops every earlier version. The lexical statistics at a cut are the masked set's own, as under a clearance. The causal fiber is recomputed from the transcript as retained at the cut, which also removes its dependence on job order. Model output is kept by generation, archive then replace. An instance with no embedder is served: the node set comes from the log, not from the plane. Erasure and scope: a purge leaves a hole that keeps its position and its salted commitment, and the table says what a purge must reach before a store is read at a cut. A retire seals the identity's earlier cuts; the stricter seal is taken because a new note at a deleted note's path has its identity. The grant is the asker's now, an event filter is applied after the read, and an answer names the cut on the chains the grant names only. The read-only principal's list is the present's, applied to the edges inside the cut. Co-Authored-By: Claude Fable 5.2 --- docs/design-notes/dn-temporal-snapshot.md | 291 ++++++++++++++++++++++ 1 file changed, 291 insertions(+) diff --git a/docs/design-notes/dn-temporal-snapshot.md b/docs/design-notes/dn-temporal-snapshot.md index 50173245..a5c01c4a 100644 --- a/docs/design-notes/dn-temporal-snapshot.md +++ b/docs/design-notes/dn-temporal-snapshot.md @@ -477,3 +477,294 @@ beside them. A store verifies a certificate when its own prefixes have those dig Checking a certificate against a store is one seek a chain, the stored hash at the position against the certified digest, 3 microseconds; recomputing a chain from its first row is the audit, 0.8 s for a million rows. `[MEASURED §11]` + +## 4. Reads + +### 4.1 `read_at` and `read_between`, ledger by ledger + +`read_at(c)` is the prefix of a chain at a position and `read_between(a, b)` the events after `a` +and up to `b` (`readAt`, `readBetween`). The second composes with the first and with itself +(`readAt_append_readBetween`, `readBetween_append`), so nothing more is needed of a ledger than +these two. `[THEOREM: SNP-3]` For each ledger, the read, the index it needs and its cost: + +| ledger | `read_at(c)` | `read_between(a, b)` | index | cost | +|---|---|---|---|---| +| landing log, a class | one path: its last event at or under `c`; every path: the rows with `seq ≤ c` not closed at or under `c` | the rows with `a < seq ≤ b` | the primary key, `landings_path`, `landings_closed` | one path 3 to 4 µs through `landings_path`, and 6 ms when the planner takes the primary key, so the statement names the index; 1,000 positions 0.7 ms; every head §4.2 `[MEASURED §11]` | +| a document's version chain | the log's rows of the identity at or under `c` | the same rows in the range | `(class, doc_id, seq)`, partial where the identity is not the path | as one path's | +| raw objects | the object of the digest the log names at `c` | the objects the delta names | none: content-addressed | one file | +| chat log | a session's turns whose chain number is at or under `c` | the turns numbered in the range | the chain table's key and its `(session, turn)` | a range | +| attestations | by id, as today; in order, the chain table at or under `c` | a range of the chain table | the chain table | a range, where `all()` sorts the ledger by wall time and `producers_of` decodes every record today (`core/attestation/store.py:127-132`, `:159-165`) | +| citation readings | the reading of the commit, as today | the paths whose blob differs between the two commits, by the commit ledger's `files` rows (`ops/code_snapshot.py:59-69`), with their readings at each | exists: `(target_ref, commit_sha)` and `(source_ref, commit_sha)` (`reference_edges.py:149-156`) | as today | +| commit ledger | the commit and, through git, its ancestors | git's range | none: the ledger keeps no parent, so the range is git's | git's | +| staging | `read_at(g)`, as built | the rows admitted or tombstoned in the range | `staged_rows_generation` exists; none on the tombstone stamp | as built | +| run ledger, verdicts, observation history | by key; in insertion order | a range | a sequence number, when a consumer needs one | none needs one yet | + +The landing log's two reads are the ones every other store's read at a cut goes through, since +it is the log that says which version of a path a cut holds (§5). + +### 4.2 Every head at a cut + +Reading the head of every path of a class at a cut is the rows with `seq ≤ c` whose `closed_at` +is absent or above `c`. On a synthetic log of a million events over 100,000 paths it took 149 to +163 ms at the middle cut and 246 to 285 ms at and near the head. `[MEASURED §11]` The cost is the +part of the log the statement walks, not the size of the answer. Two readers need it: the +universe, for the strata it loads whole (`core/sentence/universe.py:275-299`), and the lexical +statistics at a cut (§5.3). The bound is the journal form: the heads kept at some recorded cuts +and continued over the events since (`stateAt_eq_foldl`), which costs the distance to the nearest +kept cut instead of the prefix. It is parked until an instance shows the need (SN-c). `[THEOREM +for the journal; INFERENCE for parking it, falsifier SNF-6]` + +### 4.3 What the reads cost in bytes + +A landing is 409 bytes in the log with its two indexes (the table 315, the path index 67, the +closing index 27), measured without the two integer columns `version` and `att_head`. +`[MEASURED §11]` A chain table's row is an integer, the row's key and a 32-byte hash. A recorded +cut is about two kilobytes (§3.3). None of it is content: the log holds paths, digests and +titles, which the catalog holds already. + +## 5. Derived data as a function of a cut + +### 5.1 The rule and the four forms + +A derived view at a cut is a derivation applied to the prefixes (`view`), and a reader of a store +at a cut is append invariant exactly when it is one (`appendInvariant_iff_exists_view`). On a +store of keyed writes three ways of holding such a view agree: recomputed from the prefix +(`stateAt`), journaled from a checkpoint over the delta (`stateAt_eq_foldl`, +`foldAt_readBetween`), and kept by generation, a row valid from the cut that contains its write +up to the cut that contains the key's next one (`genRead_gens`). The store rewritten in place +determines no read at a past cut (`Witness.stateOf_forgets`). `[THEOREM: SNP-5]` So the choice +among the three is cost, store by store. A fourth form is a way of storing the third: immutable +segments under a versioned manifest, where the manifest's version is the position. The vector +table is built that way, and §5.2 says why its versions are not the snapshot. + +| derived store | a function of | held as | what it costs here | what would change the choice | +|---|---|---|---|---| +| vectors (atoms, occupancies) | the chunk's text and the embedder's identity | version-keyed rows the plane keeps already; the log selects the version | no new bytes; a search over superseded rows, then a join with the heads at the cut | an instance that must drop superseded atoms (§9), after which a cut finds them pending | +| lexical units and postings | the chunk's text and the tokenizer's identity | version-keyed rows the index keeps already; the log selects the version; the statistics from the mask | no new bytes; 4,179 bytes a kept unit on synthetic text `[MEASURED §11]` | a query at a past cut over its budget at the instance's size: then statistics stored per class and per recorded cut | +| chat events, causal edges | the transcript as retained at the cut, and the commits inside the cut | recomputed at the cut, the present rows a cache of the head | 6 ms a session of 2,000 records `[MEASURED §11]`; no bytes | a sentence that walks the causal fiber at a past cut over a second on a real instance (SNF-5): then generations, written with a diff | +| interpreted artifacts, hyperedges, relation edges, claim ops | a model's output: of nothing that can be computed again | generations, the replaced row archived with its interval | one archived row a replacement, which is thrown away today | a measured churn so low that declaring them outside the snapshot loses nothing | +| the similarity backbone | the vectors of the support | recomputed, as today | nothing | nothing | +| citation readings | the tree at the commit | one whole reading a commit, as built | 3,029,562 rows over 1,487 commits at 567 bytes a row in the repository's records | the store's size: then a row valid over a range of commits (SN-b) | +| code memberships | git's blob at the path | version-keyed by blob; git's tree selects the version | nothing new | nothing | +| the utility field (not built) | the use log | a fold with kept checkpoints | a checkpoint a declared number of ticks | its own note's measurements | + +The figures for the citation readings are `docs/experiments/corpus-measurements-2026-11-07.md:106` +and `core/reference_view.py:15-16`. + +### 5.2 Vectors + +An atom is one chunk text under one embedder: its id is its layer and the hash of its text +(`core/stores/plane.py:113-115`), the plane records the embedder's identity and refuses another +(`plane.py:350-362`), and an occupancy says that a document at a version holds an atom at a +position (`plane.py:268-278`). So a vector is a function of a content digest and an embedder +identity, and a past version's vectors are still in the plane: a superseded version's occupancies +and atoms stay, and only `current` moves. `[ESTABLISHED]` The vectors at a cut are therefore the +atoms of the versions the landing log says were the heads at the cut: a read of the plane with +its superseded rows (`plane.py:772-821`) joined with the heads. `[DERIVED from SNP-5]` + +Three things follow. + +- **No stamp on the rows.** The interval a version's rows are valid on is read from the log. A + stamp on the rows would have to be a set of intervals (§2.3, item 3). +- **Not the table's own versions.** The vector table keeps a dataset version a write, and an + earlier version can be read. After a purge the purged text was still returned by eight and by + five of the table's ten versions, and the compaction that removes it leaves one version, so it + removes every earlier snapshot with it. `[MEASURED §11]` A manifest's version cannot be both + the position a snapshot is read at and something an erasure reaches. The cut is a predicate on + rows, taken from the log; the manifest stays a physical form. +- **The embedder's identity is the present's.** After a model change the plane is reset and the + drain derives the current versions only (`core/ingest/derive.py:85-118` lists the active + entries the plane does not hold current), so a superseded version has no vector. At a cut such + a version is pending, and a semantic clause ranks it by the lexical index or reports it, which + is ING-21's rule read at a cut. Deriving it is the same drain run over the versions a cut + holds. `[DERIVED from ING-19, ING-21]` A snapshot is of content, not of the geometry in force + when the content landed (decision D5, §13). + +### 5.3 The lexical index + +The index keeps every version's units and postings and marks the head (`core/stores/lexical.py: +56-82`, `:251-256`), and it computes its statistics at query time over the current units of the +reader's classes: the unit count and the mean length (`lexical.py:316-321`) and each term's +document frequency (`lexical.py:337-340`). `[ESTABLISHED]` At a cut the arithmetic is the same +with one predicate changed: a unit counts when its version is its path's head at the cut, in +place of `current = 1`. The collection size, the mean length and the document frequencies are +then the masked set's own, which is what makes a score at a cut the score the index gave then +under the same tokenizer. A clearance and a cut are the same kind of thing to this index: a mask +over units whose statistics must be the mask's. `[DERIVED]` + +The other forms cost more here. Recomputing means tokenizing every item alive at the cut, since +the statistics are the collection's and not the support's: right for a few hundred notes, not for +a corpus. A journal of the changes to the document frequencies has an entry a term a unit, no +fewer than the postings (122 a unit on the synthetic text). An index with its statistics built in +cannot serve a cut, or a clearance, without a copy a mask; if the index moves to immutable +segments, a segment has to carry its statistics per class and per recorded cut, or leave them to +be computed from the mask. `[INFERENCE, falsifier SNF-7]` The tokenizer's identity is the +present's, as the embedder's is: a changed tokenizer resets the index (`lexical.py:180-194`) and +the backfill lands the active items, so a superseded version's units are derived again from the +raw store when a cut asks for them. + +### 5.4 Model output + +Interpreted artifacts, relation edges and claim ops are written by passes that call a model, and +each is keyed by what it is about, so a later pass over the same subjects replaces the row +(`core/stores/derived.py:209-216`, `core/stores/edges.py:88-106`). The output cannot be computed +again, so the two choices are to keep it by generation or to declare it outside the snapshot. +This note keeps it. `[INFERENCE, falsifier SNF-8]` + +The form is the one the observation stores use: archive, then replace +(`core/stores/code_observations.py:211-254`, `core/stores/observation_history.py:46-56`). Each +store gets a sequence number a write (its chain; the three are written `interp` in §3.1), each +row the number it was written at, and a replaced row goes to a history table with the number it +was replaced at. The read at a cut is the row whose interval holds the position (`genRead`), and +at the head it is the present row (`genRead_gens_length`). `[THEOREM: SNP-5, SNP-4]` + +A kept row is served at a cut only when its sources are there. An artifact's subjects and a +relation edge's endpoints are content digests (`derived.py:186-189`, `edges.py:39-40`), so the row +is about particular versions: it is in the snapshot when it was written at or under the cut, every +digest it names is some path's head at the cut, and none of them is erased or sealed +(`mem_serve_iff`). `[THEOREM: SNP-7 for the erasure; DERIVED for the heads]` Until SN-6 builds +this the three stores serve two positions, the empty prefix and the head (§7.1). + +### 5.5 The causal fiber + +The events of a session and its causal edges are a deterministic function of the transcript and +the commit ledger (`core/chat_events.py:136-176`, `core/integrator.py:118-164`), so recomputing is +exact, and it is the definition here. At a cut: for each session, the transcript is the raw +object the session's last turn inside the cut names (`core/chat_events.py:211` takes the last +row's digest the same way for the head); its events are extracted and kept when their turn is +inside the cut; a commit event resolves against the commits inside the cut on `repo`. `[DERIVED +from SNP-5]` + +This repairs three things the stored rows have today (§2.3, item 4). The result no longer depends +on the order in which the projector, the integrator and the code sensor ran. An event whose +result arrived after the cut is read without it, as it stood. And an edge is named by its session, +its event's order and its endpoint, which a session's growth does not change. + +The cost is an extraction a session: 6 ms for a synthetic session of 2,000 records and 0.79 MB. +`[MEASURED §11]` The builder reads the causal store whole once a sentence +(`core/sentence/universe.py:581-595`), so at a cut it would extract every session with a turn +inside the cut, and a memo keyed by the session and its transcript's digest makes each +extraction happen once a process. Generations are the alternative: the rows kept, keyed by +session and order, each with the range of `chat` positions it was valid on, written with a diff so +that a session's growth adds its new events and closes only the rows that changed. They cost a +rewrite of the projector and the integrator and are kept for the instance that needs them +(SNF-5). + +### 5.6 An instance with no embedder + +Nothing above reads the plane to learn what existed. The node set of a snapshot comes from the +landing log, which lives in the catalog's file; the lexical units, the version chains, the causal +fiber and the citation readings need no vector; and a semantic clause on such an instance ranks +by the lexical index and says so, at a cut as at the head (ING-21). The plane's own supersession +log could not carry this: an instance with no plane has none, and under lazy embedding it records +the order in which the drain reached the items, not the order in which they landed. Today the +universe takes the mirror's nodes from the plane's rows (`core/query.py:462-465`); at a cut it +takes them from the log. `[DERIVED; ESTABLISHED for the present reads]` + +## 6. Erasure and scope + +Two things are parameters of a read and no function of the cut, because they are the present's: +what has been erased, and what the asker may see. + +### 6.1 A purge leaves a hole + +No erased event is visible at any cut (`not_erased_of_mem_visible`), a larger erasure shows a +sublist (`visible_sublist`), and two stores that differ only in erased events give every +derivation the same reading at every cut (`erased_invisible`): erased content is an argument of +no read. `[THEOREM: SNP-7]` + +The erasure keeps positions. The store with a hole at each erased event has the head it had and +commutes with the cut (`head_redact`, `redact_readAt`); an erasure that deletes rows moves the +later ones up, and a read at a cut then holds an event from after it (`Witness.compact_moves`). +`[THEOREM]` The plane's supersession log is the second kind today: after a purge, a later landing +at the path took position 1 again. `[MEASURED §11]` In the landing log a purge empties the row: +the path, the identity, the digest, the title and the salt become null, and the commitment and +the hash stay. The certificates keep verifying (`verifies_purge`), a reader reads a hole +(`contents_purge_committed`), and since the commitment was salted and the salt is gone, it can no +longer be tested against a guess of the content. `[THEOREM: SNP-9 for the chain; DERIVED for the +salt]` + +That last point is a rule the record already has: no tombstone keeps a content hash of purged +private text (`docs/design-notes/vector-membership-store.md:810-813`). A digest of purged bytes +is a test for those bytes. What a purge has to reach, against what it reaches today: + +| store | today, after a purge `[MEASURED §11]` | what a snapshot needs | +|---|---|---| +| raw object, catalog row, plane occupancies and their freed atoms | removed | the same, and the log's rows emptied | +| the vector table's earlier dataset versions | still return the text | the purge ends with a compaction that keeps no earlier version | +| lexical units, postings and version records | remain, with the words | removed with the plane's rows | +| the version chain's rows | still name the digest | the digest nulled, the row and its number kept: a second owner-gated write beside the relabel (`core/stores/versions.py:132`) | +| relation edges and artifacts that name the digest | untouched | not served (`mem_serve_iff`), and removed by the purge | +| the attestation ledger | still names the digest | open: decision D9 | +| a deletion attestation | none is written (`core/attestation/store.py:3-6` says one is) | one, of action `purge`, naming the commitment and not the digest | + +Until the stores of the middle rows are reached, a read of them at a cut would return what a +purge left. So the erasure's reach is stage SN-4, and it lands before any of those stores is read +at a past cut (§12). + +### 6.2 A retire seals + +A vault delete is a tombstone: the catalog's row goes inactive and the raw object stays +(`catalog.py:160-172`). The requirement is that a tombstoned item does not come back through a +snapshot either. Two rules do that, both proved, and they are ordered. + +- **The stricter seal** (`servedAt`). A retire among the events past the cut closes the cut for + that identity. Once the chain retires an identity, no cut before the retire serves it + (`servedAt_append_of_retire`); growth that does not retire it changes nothing + (`servedAt_append_of_no_retire`); so growth changes a served value only by removing it + (`servedAt_of_append`). +- **The looser seal** (`servedNow`). An identity is withheld at every cut exactly while it is not + live at the head. It serves everything the stricter one serves (`servedNow_of_servedAt`), keeps + an identity that is retired now out of every cut (`servedNow_of_not_live`), and is lifted by a + later landing, which brings the past back (`Witness.servedNow_restores`). `[THEOREM: SNP-7]` + +This note takes the stricter seal, keyed by identity, with an `unseal` event that only the owner +writes. `[INFERENCE, falsifier SNF-10]` The reason is in the code: a new row's identity is its +path unless it declares one (`catalog.py:103-110`), so a different note written later at a +deleted note's path has the deleted note's identity, and under the looser seal it would bring +the deleted note's versions back at the earlier cuts. The seal is by identity and not by path so +that a rename seals nothing: the old path's tombstone is a `move` (§3.2). The cost of the +stricter seal is also in the code: a rescan tombstones every catalog path whose file is gone +(`core/ingest/sync.py:262`, `:285-286`), so a vault that is missing at a rescan seals every +note's past, and the owner lifts it with one `unseal` over the range. + +The seal is read off the whole chain, the present, and off no prefix of it: one more seek, the +position of the identity's last retire that no later `unseal` names. At the head nothing is +sealed (`servedAt_length`). + +### 6.3 The grant is the asker's now + +A snapshot under a grant is the read at the cut restricted to the chains the grant names and, +within them, to the events it may see named (`snapshot`). The grant is no function of the cut. +`[THEOREM: SNP-6]` + +- A narrower grant's snapshot is the restriction of a wider one's, at every cut + (`snapshot_narrow`): what a wider grant was shown at a cut bounds what a narrower one is shown + there. +- It reads only the chains the grant names and the cut's positions on them (`snapshot_congr`), + and it is append invariant (`snapshot_grow`). +- Restricting to whole chains commutes with the cut (`restrict_readAt`). Filtering events before + the cut does not: it moves the positions (`Witness.filter_before_cut`), and a position on a + chain counts the events a filter hides (`Witness.position_channel`). So an event filter is + applied after the read, and what must be hidden in number is hidden by chain, which is why the + landing log is a chain a class. + +Two consequences for the surface. An answer names the cut it read on the chains the asker's grant +names and on no other, and the bounds a row records (§3.5) are never shown: `att` mixes every +class, so its positions count other classes' landings. And a class is a row's class now: a +whole-class relabel renames a chain, and nothing else moves a row between chains (ING-17). +`[DERIVED]` + +### 6.4 A reader that is shown only named endpoints + +A read-only principal is being added that is shown a causal edge only when the edge ends at a +commit or at a file git tracks at `HEAD`. That rule is an event filter in the sense of §6.3, and +at a cut it is the present's filter applied to the edges inside the cut: an edge is shown when its +witness turn is inside the cut on `chat`, its commit, if it ends at one, is inside the cut on +`repo`, and its endpoint passes the list as the list stands now. The list is not taken at the +cut's tree. `[DERIVED from SNP-6]` Two reasons. The grant is the asker's now, so a file that left +the tracked tree since the cut is withheld at the cut as it is at the head, and no cut shows a +name the head withholds. And the filter is then applied after the read, which is the order +`restrict_readAt` and its control require. The principal's snapshot is the restriction of the +owner's at every cut (`snapshot_narrow`). The alternative, the list taken at the cut's tree, is +decision D11. From 299f37e87d135f1824de15c4ed19496c9cc3a6bf Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 01:40:10 -0500 Subject: [PATCH 08/37] docs(design): dn-temporal-snapshot, the surface, the horizon, retention Sections 7 to 9. The sentence surface: the name gives the cut asked, each chain serves the positions from its horizon on and its empty prefix, and the read is at the greatest consistent cut among the served positions under the cut asked. So a read under `as of` holds no event from after the cut it names, the cut read rises as stores gain a past, and the answer names the cut it read and each chain on which it differs from the cut asked, with the reason. That replaces reading those stores at the head with a note. Each mode and each edge species is given its meaning at a cut, `as of "head"` is the sentence without `as of`, and one two-cut form is admitted: the region of identities with an event between two cuts, sound for what did not change, composable, one range read. The exactness boundary: a chain's horizon is set by its genesis, by retention or by a reset; from it on every cut is exact, under it the store is never wrong but cannot tell what it lost, so the horizon is a row of the chain and a cut under it is read at the empty prefix and said to be. Retention and cost: most bytes of a past are paid already, since no store drops a superseded version; the snapshot adds 409 bytes a landing and about two kilobytes a recorded cut. The rule is a window a chain, counted in positions, with the horizon declared before anything is dropped and derived rows dropped before ledgers. A derived row is a cache entry, absent or present and reported when absent, which is lazy landing read in time. The utility field as of a cut is the fold of its use log's prefix. Co-Authored-By: Claude Fable 5.2 --- docs/design-notes/dn-temporal-snapshot.md | 241 ++++++++++++++++++++++ 1 file changed, 241 insertions(+) diff --git a/docs/design-notes/dn-temporal-snapshot.md b/docs/design-notes/dn-temporal-snapshot.md index a5c01c4a..25b568cd 100644 --- a/docs/design-notes/dn-temporal-snapshot.md +++ b/docs/design-notes/dn-temporal-snapshot.md @@ -768,3 +768,244 @@ name the head withholds. And the filter is then applied after the read, which is `restrict_readAt` and its control require. The principal's snapshot is the restriction of the owner's at every cut (`snapshot_narrow`). The alternative, the list taken at the cut's tree, is decision D11. + +## 7. The sentence surface + +### 7.1 The cut asked and the cut read + +A sentence has one cut, as today (§2.1). The name resolves to a frontier, the cut asked (§3.4). +Each chain serves some positions exactly: every position from its horizon to its head (§8), and +the empty prefix; a store that keeps no past serves the empty prefix and the head. The read is +taken at the greatest consistent cut under the frontier asked every position of which is served +(`ResolvesIn`). `[THEOREM: SNP-10]` + +- It exists and is unique whatever the stores serve (`exists_resolvesIn`, `ResolvesIn.unique`). +- It never passes the cut asked (`ResolvesIn.le_resolves`), so what is read is a prefix, chain by + chain, of what the cut asked holds (`readAt_mono`): a read under `as of` holds no event from + after the cut it names. +- It rises with what is served and with the frontier (`ResolvesIn.mono`): as the stages of §12 + give stores a past, the cut read climbs toward the cut asked and never falls. +- When every position is served it is the resolution of the frontier (`resolvesIn_univ`), and at + the head it is the head (`resolvesIn_self`). + +The answer is then exact for the cut it names: every law of §10 holds at the cut read. What the +answer says is that cut. It carries one note with the cut asked, the cut read on the chains the +asker's grant names (§6.3), and each chain on which the two differ with the reason: the store +keeps no past, the cut is under the chain's horizon, or the stage that reads the store at a cut +is not built. For example, on an instance where the relation edges do not yet keep generations: + +``` +as of "9de5325d": read at the cut recorded when the commit was read (cut:4c1f09a2). +land:authored-solo 412, chat 9318, repo 9de5325. Not read at the cut: the relation edges +keep no past and were read at their empty prefix. +``` + +This replaces what the executor does today, which reads those stores at the head and says so +(`core/sentence/execute.py:719-725`). The head is later than the cut asked, and a reader that +ignores the cut is not append invariant: the same sentence gives another answer after the store +grows (`Witness.present_not_appendInvariant`). `[THEOREM: SNP-1]` + +A store read at its empty prefix makes its clauses empty. That is the answer at the cut named, +and it is not a bound on the answer at the cut asked: `reach` and `relate` only lose members when +edges are missing, but `diffuse` normalizes by degree and `top` ranks, and both can move either +way (the executor says so of an assumption that removes weight, `execute.py:473-481`). So the +note is part of the answer's meaning. The alternative is to refuse such a sentence (decision D4). +`[INFERENCE, falsifier SNF-4]` + +### 7.2 Each mode and each edge species at a cut + +The mode of a clause follows from its scope (`core/query.py:273-281`). + +| mode | verbs | what it reads at the cut | exact from | +|---|---|---|---| +| semantic | `near`, `diffuse S`, `reach S`, `relate` | the heads of the clause's classes, from the log; their vectors by content address and the lexical index for the pending ones (§5.2, §5.3); the backbone recomputed among them | SN-3; `relate` SN-6 | +| structural | `reach F`, `diffuse F`, `walk` over `F` | the citation reading of the cut's commit | today | +| temporal | `trace`, `reach D`, `walk` over `D`, `changed` (§7.4) | the version chain's prefix: the log's rows of the identity at or under the cut | SN-3 | +| causal | `reach C`, `walk` over `C`, `witness` | the causal fiber recomputed at the cut (§5.5); an attestation at or under the cut on `att` | SN-5 | + +| species | at a cut | +|---|---| +| `S`, similarity | recomputed from the vectors of the versions alive at the cut, within a stratum, as today (`core/sentence/universe.py:733-739`); no edge at a pending node | +| `F`, citation | the edges of the reading at the commit; a reading is whole, so nothing is inferred between commits | +| `D`, supersession | consecutive versions of the chain's prefix; at the node grain it is empty today and stays so (`universe.py:810`) | +| `C`, causal witness | an edge whose witness turn is inside the cut on `chat` and whose commit, if it ends at one, is inside the cut on `repo` | +| the signed relations (supports, contradicts, contextualizes) | a kept generation whose two endpoint digests are heads at the cut (§5.4) | +| an assumed edge (`assume`) | applied to the universe of the cut read; nothing is stored, and the result is a `Hyp` as today | + +### 7.3 The verbs + +- **`near`, `diffuse`, `reach`, `relate`, `walk`, `trace`, `witness`** read as their mode says. +- **`far`, `top`, `atleast`, `not`, `minus`, `and`, `or`, `then`, `within`, `over`** are the + algebra on whatever universe the clauses built. Their laws (QSA-1 to QSA-4, QSA-10) are stated + for any universe, so they hold at a cut with no change. `over` masks by a row's class, which is + its class now (§6.3). +- **`read`.** A repository path: git's blob at the cut's commit, as today, with the commit shown + on the hit. A note or a dialogue turn: the raw object of the digest the log names for the path + at the cut, never the vault file, which is the present and can be newer than the catalog + (§2.1). A hole reads as erased and a sealed identity as nothing (§6). A transcript turn: the + chat log's row when its number is at or under the cut. +- **`witness`.** The record when it lies inside the cut: an attestation by its number on `att`, a + causal edge by its turn and its commit, a citation edge by its commit. +- **`assume`.** The overlay applied to the universe of the cut read: a hypothetical at a past cut. +- **`do`.** A request is a whole sentence and takes no adjective (`core/sentence/grammar.py:4-5`), + so it cannot be written under `as of`: a write has no past. + +**`as of "head"` is no `as of`.** At the head cut the read is the store (`readAt_head`), every +derived view is the derivation of the present (`view_head`), the generational store reads the +store rewritten in place (`genRead_gens_length`), a snapshot is the grant's restriction of the +store (`snapshot_head`), nothing is sealed (`servedAt_length`) and what is visible is the store +without the erased events (`visible_head`). `[THEOREM: SNP-4]` On the code this is the first test +of every stage: the same sentence with and without `as of "head"` returns the same hits. + +**Refusals.** An ambiguous prefix, as today (`universe.py:471-475`). A name that selects nothing: +a sha no chain knows, a cut id no record has, a date before the first record; the refusal says +which names would resolve. A date after the newest bookmark is the head. + +### 7.4 Between two cuts + +One form is worth admitting, and it is a region: + +``` +changed between "" and "" changed since "" +``` + +Its members are the identities with an event in the delta, on the landing chains of the classes +the clause reads; `since` is `between` with `head`. `[INFERENCE, falsifier SNF-14]` + +- **It is sound for what did not change.** An identity outside the region has the same state at + both cuts (`stateAt_eq_of_not_written`). It over-approximates what did: a path that returned to + the bytes it had is a member. +- **It composes.** The region between `a` and `c` is the union of the regions between `a` and `b` + and between `b` and `c` (`readBetween_append`, `mem_readAt_iff`). `[THEOREM: SNP-3]` +- **It is cheap.** One range read of the log: 0.7 ms a thousand positions. `[MEASURED §11]` +- **It composes with the algebra.** A region masks a field or meets a region, so + `near "x" within (changed since "")` needs no new rule; its mode is temporal, since its + window is not a point (`core/query.py:277`). + +The general form, a sentence evaluated at two cuts with the difference reported as `assume` +reports its two universes (`execute.py:1045-1063`), is the `velocity of` that dn-graph-dynamics +designs as GD-4. This note supplies the two readings it needs and does not add a second way to +write it. + +## 8. The exactness boundary + +History is exact from the first retained generation and from no earlier. Each chain has a +**horizon**: the first position from which it serves every cut. Three things set one. + +- **The genesis.** The landing log opens with the catalog as it stood (§3.2). What a path held + before was never recorded, so the positions before the genesis rows end are under the horizon. + For the chat log and the attestation ledger the genesis is the rows they hold when their chain + tables are added, in the order they were inserted. +- **Retention** (§9), which drops the generations closed at or under a declared position. +- **A reset**, after which every chain is a new chain (§2.3, item 7). + +The law is the same for the three. A generational store that drops the rows closed at or under a +horizon reads, at every cut from the horizon on, the state recomputed from the whole prefix +(`genRead_prune_gens`), though the prefix is no longer held. Under the horizon it is never wrong: +a value it returns at a cut is the value the key held (`stateAt_of_genRead_prune`). But what it +lost it reads as absent, and nothing in the rows that remain tells a lost key from a key that was +never there (`Witness.prune_forgets`). Two horizons are the later one (`prune_prune`). +`[THEOREM: SNP-10]` The journal form says the same of a fold: continued from the state kept at the +horizon over the events since, it is the fold of the whole prefix (`foldAt_readBetween`), and the +chain's digest at the horizon, kept as the seed, lets every certificate from the horizon on +verify (`certify_digest_readBetween`). `[THEOREM: SNP-3, SNP-9]` + +So the horizon is recorded, and a cut under it is not served. + +- **Where.** As a `horizon` row of the chain, which the chain's hash covers, and in every + recorded cut (§3.3). It only advances. +- **What a question before it gets.** The chain is read at its empty prefix (§7.1), and the + answer says the cut is under the chain's horizon and names the first cut the chain serves. A + sentence all of whose chains are under their horizons returns the note and no hit. +- **What that means today.** A commit read before the log exists resolves, on every chain but + `repo`, under the horizon: `as of` such a commit reads the citation graph and the repository's + files at the commit, which are exact, and nothing else. That is the lawful part of what it does + now. The observation that the version store held one generation and so had nothing to + snapshot (limits-of-the-algebra, L7) is this boundary seen from the other side. + `[DERIVED]` + +## 9. Retention and cost + +### 9.1 What grows + +Nothing in the stores is dropped today except by a purge: a retired path's rows and a superseded +version's rows stay in the plane and in the lexical index (`core/stores/plane.py:497-499`, +`core/stores/lexical.py:260-265`). So the bytes of a past are mostly paid already, and the +snapshot adds three things. + +| what | a | bytes | source | +|---|---|---|---| +| the landing log | landing | 409 | `[MEASURED §11]` | +| a recorded cut, with its attestation | record | about 2,000 | §3.3 | +| archived model output | replaced row | the row's | §5.4 | +| kept already: a lexical unit of a superseded version | unit | 4,179 on synthetic text, 122 postings a unit | `[MEASURED §11]` | +| kept already: a plane occupancy | row | 734 to 1,084 | `docs/experiments/corpus-stage1-2026-11-07.md:416`, `corpus-measurements-2026-11-07.md:104` | +| kept already: an atom | changed chunk | 2,215, of which the vector 1,536 | `corpus-measurements-2026-11-07.md:103` | +| kept already: a raw object | version | the version's bytes; a transcript's, whole, at each growth | §2.2 | + +By arithmetic, not measurement: an instance with a hundred landings a day adds 41 kilobytes a day +to the log, 15 megabytes a year, and thirty recorded cuts a day add 60 kilobytes. The rows kept +already are what grows: with three versions an item, two thirds of the synthetic lexical index +were superseded versions. `[MEASURED §11]` What the snapshot brings is less a cost than the means +to stop paying one: a horizon makes it safe to drop. + +### 9.2 The rule, counted in events + +Each chain declares a window `keep`, in positions. A retention pass, run at a recorded cut, moves +the chain's horizon to the later of the horizon in force and the head less `keep`, and drops in +this order: + +1. the `horizon` row is appended, so the positions under it are unserved from that moment; +2. the derived rows of the versions closed at or under it: lexical units and postings, plane + occupancies, and the atoms nothing retained holds; +3. the raw objects no retained row names; +4. the log's rows closed at or under it, the chain's digest at the horizon kept as its seed. + +The order is the one the stores use for a cache: the horizon is declared first, so a crash in +the middle leaves rows that are no longer served, never a position that is served and +incomplete (the discipline of PLN-4, where a cache is stale only by excess). `[DERIVED]` The +attestation ledger and the version chains are not pruned: they are the audit record, they are +small, and they have no delete. + +The window is counted in events because wall time orders nothing (Law C4): the last ten thousand +landings of a class, not the last ninety days. It is one position a chain, not a number of +versions an identity. Keeping the last `n` versions of each identity would leave no horizon: +which cuts are exact would differ from one identity to the next, and the control of §8 says such +a store cannot tell what it lost. `[INFERENCE, falsifier SNF-9]` + +The default instance declares no window and keeps everything; by the arithmetic above its log is +megabytes a year. An instance that must bound its disk declares one (decision D8). + +### 9.3 Lazy landing, in time + +Under lazy embedding an item is complete without its vector, and the drain derives the vectors of +the current versions (`core/ingest/derive.py:85-118`). A version superseded before the drain +reached it never gets one. So at a past cut the plane can hold nothing for a version that was +the head, and the rule is the one two-phase ingestion already has: the item is pending, a +semantic clause ranks it by the lexical index or reports it, and no vector is invented (ING-21). +`[DERIVED from ING-19, ING-21]` + +Retention's second step and lazy derivation are then one mechanism run in two directions. A +derived row is an entry of a cache of a function of a content digest and an identity (§5.2, +§5.3): present or absent, reported when absent, derivable again from the raw object while the +ledger holds it. The drain run over the versions a cut holds derives what a cut's readers ask +for, and nothing obliges an instance to derive a past nobody reads. + +### 9.4 The utility field + +The field is the fold of its update over the use log (UTL-4, `evolve_append`), so it is a derived +view in the sense of §5: its use log is a chain of the cut, its tick the position, and the field +as of a cut is the fold of the prefix, continued from a kept checkpoint over the uses since +(`foldAt_readBetween`). `[THEOREM: SNP-3 with UTL-4]` That answers the first open question of +dn-utility-field: the field's clock can be a chain of the cut, and then the field as of a cut is +exact. Two more things follow. + +- **The use log has a natural horizon.** A site left alone returns within `ε` of its baseline + after `log(c/(lam ε))/lam` ticks (UTL-2, `idle_window`), so a horizon that far behind the head, + with the field's state at the horizon kept, is exact from the horizon on and loses nothing a + reader of the present could see. `[DERIVED from UTL-2 and SNP-3]` +- **The field can order what retention drops.** When a window forces a choice among the derived + rows of superseded versions, the ones whose sites stand at the baseline were not used for + anything that produced value, and go first. `[HYPOTHESIS: checked by comparing, on the corpus + instance, how often a pass ordered by the field drops a row a later cut asks for against a + pass ordered by age; falsifier SNF-9]` From b24f11ab0b5b72e6568dc06c6053cd6e71c2575b Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 01:45:15 -0500 Subject: [PATCH 09/37] docs(design): dn-temporal-snapshot, the laws, the build, the decisions The rest of the note. The ten laws, SNP-1 to SNP-10, each with its Lean declarations, its controls, its attack seeds and the property test it becomes at its stage, and what the model leaves out: one writer, opaque events, the hash's collision freedom as a hypothesis, the descent attacked and not proved. The measurements, every one on a synthetic fixture: the landing log at a million rows (409 bytes a row, a path read in 3 to 4 microseconds through its index, every head in 149 to 285 ms), a kept version in the lexical index, what a purge leaves on the test suite's throwaway palace, the order of two jobs, the events of a transcript's prefix, what `as of` accepts, row numbering after a delete. The build is eight stages, each a pull request with its tests and its rollback. The first is the landing log: one table in the catalog's file, written inside the catalog's six writing methods, with its reads and no reader. The erasure's reach lands before the first stage that reads a superseded version. A generic integrator's checkpoint is a cut and its input the delta, and three laws make a run equal a rebuild. Twelve decisions for the owner, each with a recommendation and what the alternative costs, then the parked decisions, fourteen falsifiers, the open questions and the cross-references. Co-Authored-By: Claude Fable 5.2 --- docs/design-notes/dn-temporal-snapshot.md | 371 +++++++++++++++++++++- 1 file changed, 366 insertions(+), 5 deletions(-) diff --git a/docs/design-notes/dn-temporal-snapshot.md b/docs/design-notes/dn-temporal-snapshot.md index 25b568cd..d9ac51e4 100644 --- a/docs/design-notes/dn-temporal-snapshot.md +++ b/docs/design-notes/dn-temporal-snapshot.md @@ -89,7 +89,7 @@ as of a cut (dn-utility-field, open question 1). 9. **Retention is counted in positions and drops derived rows before ledgers (§9).** `[INFERENCE, falsifier SNF-9]` 10. **The build is eight stages, each a pull request with its tests and its rollback; the first - is the landing log (§12).** `[INFERENCE, falsifier SNF-1]` + is the landing log (§12).** `[INFERENCE, falsifier SNF-11]` ### 1.3 Out of scope @@ -694,12 +694,12 @@ is a test for those bytes. What a purge has to reach, against what it reaches to | the vector table's earlier dataset versions | still return the text | the purge ends with a compaction that keeps no earlier version | | lexical units, postings and version records | remain, with the words | removed with the plane's rows | | the version chain's rows | still name the digest | the digest nulled, the row and its number kept: a second owner-gated write beside the relabel (`core/stores/versions.py:132`) | -| relation edges and artifacts that name the digest | untouched | not served (`mem_serve_iff`), and removed by the purge | +| relation edges and artifacts that name the digest | untouched (read, not measured: `core/ingest/purge.py:58-62` names neither store) | not served (`mem_serve_iff`), and removed by the purge | | the attestation ledger | still names the digest | open: decision D9 | | a deletion attestation | none is written (`core/attestation/store.py:3-6` says one is) | one, of action `purge`, naming the commitment and not the digest | Until the stores of the middle rows are reached, a read of them at a cut would return what a -purge left. So the erasure's reach is stage SN-4, and it lands before any of those stores is read +purge left. So the erasure's reach is stage SN-3, and it lands before any of those stores is read at a past cut (§12). ### 6.2 A retire seals @@ -818,9 +818,9 @@ The mode of a clause follows from its scope (`core/query.py:273-281`). | mode | verbs | what it reads at the cut | exact from | |---|---|---|---| -| semantic | `near`, `diffuse S`, `reach S`, `relate` | the heads of the clause's classes, from the log; their vectors by content address and the lexical index for the pending ones (§5.2, §5.3); the backbone recomputed among them | SN-3; `relate` SN-6 | +| semantic | `near`, `diffuse S`, `reach S`, `relate` | the heads of the clause's classes, from the log; their vectors by content address and the lexical index for the pending ones (§5.2, §5.3); the backbone recomputed among them | SN-4; `relate` SN-6 | | structural | `reach F`, `diffuse F`, `walk` over `F` | the citation reading of the cut's commit | today | -| temporal | `trace`, `reach D`, `walk` over `D`, `changed` (§7.4) | the version chain's prefix: the log's rows of the identity at or under the cut | SN-3 | +| temporal | `trace`, `reach D`, `walk` over `D`, `changed` (§7.4) | the version chain's prefix: the log's rows of the identity at or under the cut | SN-4; `changed` SN-8 | | causal | `reach C`, `walk` over `C`, `witness` | the causal fiber recomputed at the cut (§5.5); an attestation at or under the cut on `att` | SN-5 | | species | at a cut | @@ -1009,3 +1009,364 @@ exact. Two more things follow. anything that produced value, and go first. `[HYPOTHESIS: checked by comparing, on the corpus instance, how often a pass ordered by the field drops a row a later cut asks for against a pass ordered by age; falsifier SNF-9]` + +## 10. The laws + +Each law is stated so that it becomes a property test when its stage is built, and is proved +now. The Lean names are in `formal/Palace/Snapshot.lean`, the attacks and controls in +`formal/PalaceTest/Snapshot.lean`, by seed. `[THEOREM]` throughout. + +- **SNP-1 append invariance.** A read at a cut inside the store, a read between two such cuts + and every derived view are unchanged by any growth of the store (`readAt_grow`, + `readAt_of_extends`, `readBetween_grow`, `appendInvariant_view`), also under an erasure and a + grant (`visible_grow`, `snapshot_grow`) and for the keyed forms (`stateAt_append`, + `genRead_gens_append`). Controls: the reader that ignores the cut + (`Witness.present_not_appendInvariant`); a read at a cut past the head (seed 431). Attacks 430, + 432, 446. The test, at SN-1: over random sequences of catalog writes, `read_at(c)` taken after + every further write equals the one taken when `c` was the head. +- **SNP-2 monotonicity.** The read at an earlier cut is a prefix, chain by chain, of the read at + a later one, and a cut of a cut is the meet (`readAt_mono`, `mem_readAt_of_le`, + `readAt_readAt`, `head_readAt`, `visible_mono`). Control: the read at one cut taken for a prefix + of the read at any other (434). Attacks 433, 435. The test, at SN-1: for `a ≤ b`, `read_at(a)` + is a prefix of `read_at(b)`. +- **SNP-3 composition.** The read at `a` followed by the read between `a` and `b` is the read at + `b`, and two adjacent reads-between compose (`readAt_append_readBetween`, `readBetween_append`); + a fold continued from a checkpoint over the delta is the fold of the prefix + (`foldAt_readBetween`, `stateAt_eq_foldl`); an event, or a pair of events, read at the later cut + was read at the earlier one or lies in the delta (`mem_readAt_iff`, `pair_readAt`); a key the + delta does not write has one state at both cuts (`stateAt_eq_of_not_written`). Controls: the + two cuts in any order (437); a key's state taken for unchanged whatever the delta writes (477). + Attacks 436, 438, 439, 447, 475, 476. The test, at SN-1: the catalog rebuilt from the state at + a checkpoint and the delta equals the catalog; at SN-8: the region of §7.4. +- **SNP-4 idempotence.** The read at the head cut is the store, and every reading at it is the + present's (`readAt_head`, `readAt_of_head_le`, `view_head`, `genRead_gens_length`, + `snapshot_head`, `servedAt_length`, `servedNow_length`, `visible_head`). Attack 440. The test, + at every stage: a sentence under `as of "head"` returns what it returns without. +- **SNP-5 a derived view depends only on the prefixes.** A reader is append invariant exactly + when it reads only the prefixes, exactly when it is a derived view (`prefixOnly_view`, + `view_congr`, `appendInvariant_iff_prefixOnly`, `appendInvariant_iff_exists_view`). For keyed + writes the generational store read at a cut is the state recomputed from the prefix and the + key's last write inside it, and at most one generation of a key is alive at a cut + (`genRead_gens`, `stateAt_eq_lastWrite`, `length_filter_selects_le_one`). Controls: the store + rewritten in place (`Witness.stateOf_forgets`, 444); generations without the closing stamp + (445). Attacks 441, 442, 443. The test, at SN-1: the three reads of the log agree at every + position, and no path has two rows alive. +- **SNP-6 grant restriction.** A narrower grant's snapshot is the restriction of a wider one's; + a snapshot reads only the chains the grant names and the cut on them; restricting to chains + commutes with the cut (`snapshot_narrow`, `snapshot_congr`, `snapshot_grow`, + `restrict_restrict`, `restrict_readAt`). Controls: an event filter applied before the cut + (`Witness.filter_before_cut`, 449); positions that count hidden events + (`Witness.position_channel`, 451). Attacks 448, 450. The test, at SN-4: of two grants one under + the other, the narrower answer at a cut is the wider one masked, and landings of a class the + grant does not name change neither the answer nor the cut it shows. +- **SNP-7 erasure dominance.** No erased event is visible at any cut; a larger erasure shows a + sublist; the store with holes keeps every position; stores that differ only in erased events + read the same at every cut; a kept row is served only when none of its sources is erased + (`not_erased_of_mem_visible`, `visible_sublist`, `head_redact`, `redact_readAt`, + `visible_eq_reduceOption`, `visible_congr`, `erased_invisible`, `mem_serve_iff`, + `serve_sublist`). A key retired after a cut is served at no earlier cut, growth changes a served + value only by removing it, and the looser seal serves what the stricter one serves + (`stateAt_of_servedAt`, `servedAt_append_of_retire`, `servedAt_append_of_no_retire`, + `servedAt_of_append`, `servedNow_of_servedAt`, `servedNow_of_not_live`). Controls: the erasure + that deletes rows (`Witness.compact_moves`, 455); the state served without the seal (458); the + looser seal taken for a monotone one (`Witness.servedNow_restores`, 474); kept rows served + without their sources (460). Attacks 452, 453, 454, 456, 457, 459, 473. The test, at SN-3: after + a purge no read at any cut and no scan of the instance's files finds the purged words; after a + retire no cut before it serves the identity. +- **SNP-8 consistent cuts.** They are closed under meet and join, a sublattice of the cuts; they + are CLK-2's cuts among the frontier cuts; every frontier resolves to exactly one greatest + consistent cut under it, monotonically; a consistent cut stays consistent as the store grows + (`consistent_zero`, `Consistent.inf`, `Consistent.sup`, `consistentCuts`, + `consistent_iff_isCut`, `exists_resolves`, `Resolves.unique`, `Resolves.mono`, `resolves_self`, + `Consistent.of_grown`). Controls: a frontier taken for a cut (462); a consistent cut advanced + by one position (464). Attacks 461, 463, 465. The test, at SN-2: the resolver against + enumeration on small stores, and no recorded cut with a reference crossing it. +- **SNP-9 certified cuts.** A certificate verifies on every extension of the store; under a + collision-free digest two stores that verify one certificate have the same read at its cut and + the same derived views; a certificate extends over the delta; the meet and the join are + certified from the two certificates; an erasure that keeps commitments keeps every certificate + (`verifies_certify`, `verifies_certify_of_extends`, `eq_of_chainDigest_eq`, + `Verifies.readAt_eq`, `Verifies.view_eq`, `certify_digest_readBetween`, `certify_inf`, + `certify_sup`, `commitments_purge`, `verifies_purge`, `contents_purge_committed`). Controls: a + digest with collisions (`Witness.digest_collides`, 468); a digest over contents, which an + erasure changes (472). Attacks 466, 467, 469, 470, 471. The test, at SN-2: a certificate + verifies after any further writes and on a copy of the files, and fails when one row under the + cut is edited. +- **SNP-10 the horizon.** A generational store pruned at a horizon is exact at every cut from + the horizon on and never wrong under it; horizons compose to the later one (`genRead_prune`, + `genRead_prune_gens`, `stateAt_of_genRead_prune`, `prune_prune`). Among the positions the + chains serve, every frontier resolves to exactly one greatest consistent cut, which rises with + what is served and never passes the cut asked (`exists_resolvesIn`, `ResolvesIn.unique`, + `ResolvesIn.mono`, `ResolvesIn.le_resolves`, `resolvesIn_univ`, `resolvesIn_self`). Controls: + the pruned store read under its horizon (`Witness.prune_forgets`, 480); a frontier lowered to + the served positions without the descent (483). Attacks 478, 479, 481, 482, 484, 485, 486. The + test, at SN-4: the cut read is under the cut asked on every chain; at SN-7: every read at a cut + from the horizon on is the same before and after a retention pass. + +What the model leaves out, said plainly. A chain is a list and a store a family of lists: one +writer is assumed, and nothing is said of two. Events are opaque, and so is the stores' SQL. The +hash's collision freedom is a hypothesis of SNP-9 (`CollisionFree`), not a theorem about SHA-256. +The `unseal` and `horizon` events are not in the model of the seal, and the owner's gate on them +is the code's. A repository history with merges is covered by CLK-2's down-sets and not by the +chain model (§3.1). The descent that computes a resolution is attacked, not proved. + +## 11. Measurements + +Every figure in this note is from a synthetic fixture: a temporary directory or in-memory stores +built by the probe, the test suite's throwaway palace for the purge, and nothing of any +instance. One machine (Apple M2 Pro, 12 cores, 32 GB, macOS 27.0) with other work running, the +load average between 2.4 and 5; Python 3.15.2, SQLite 3.54.1, LanceDB 0.33.0; the code at +`e3e3ee47`. The timings are medians with their ranges. Each probe was run at least twice, and a +range across the runs is given where they differed. `[MEASURED]` + +| probe | fixture | result | +|---|---|---| +| the landing log | the table of §3.2 without `version` and `att_head`, with its two indexes, in one SQLite file; one class, 100,000 paths, ten landings a path in a shuffled order, one transaction, every row hashed and the path's previous row stamped | 1,000,000 rows in 408.9 MB: 409 bytes a row (table 315, path index 67, closing index 27); 50,000 to 54,000 rows a second written | +| its reads | the same file, 200 repetitions a point read, 5 a scan | one path at the middle cut 3 to 4 µs through the path index and 6.0 to 7.1 ms when the planner took the primary key; 1,000 positions 0.69 ms; every head 149 to 163 ms at the middle cut (99,908 rows) and 246 to 285 ms at and near the head (100,000 rows); the chain's hash recomputed from the first row in 0.77 to 0.79 s; the stored hash at a position read in 3 µs | +| a kept version in the lexical index | `LexicalStore` on a temporary file; 500 items of 4 chunks in 3 versions, each chunk 171 words drawn from a vocabulary of 20,000 with frequencies falling as the inverse of the rank | 6,000 units held, 2,000 of them current; 734,409 postings, 122 a unit; 25.1 MB, 4,179 bytes a unit; superseded share 0.67 | +| what a purge leaves | the test suite's throwaway palace (`tests/fixtures/ingress.py:73`), lazy, with its fake embedder: two notes landed and drained, one edited and drained, then deleted from the vault, then both its digests purged (`purge_raw`); a control note never purged, found at every step | gone: the raw objects, the plane's occupancies and supersession entries, the catalog rows. Left: the words in the vector table read at versions 2 to 9 and 3 to 7 of its 10; the lexical units, postings, title and version records; both version rows; one attestation a digest | +| after the purge | the same palace: the vector table compacted with no retention; every SQLite file checkpointed, then vacuumed; a new note landed at the path | the compaction left 1 dataset version and no purged word in the table's files; the deleted catalog and plane rows' path and digest were still in the files' bytes after the checkpoint and gone after the vacuum; the plane's supersession log held position 1 for the path again, and the version chain appended number 3 | +| the order of two jobs | in-memory stores; one session with a commit event; the ledger holds the commit before the integrator's first pass, or gains it after | 1 edge against 0, and still 0 after a second pass, the session being skipped as unchanged | +| the events of a prefix | a transcript of four records: a prompt, a reply with a `git commit` call, the call's result with the sha, a reply | the prefix that ends before the result gives the commit event an empty reference; the whole gives the sha; the two longer prefixes agree with the whole | +| re-deriving a session | a synthetic transcript of 2,000 records, 0.79 MB, 7 repetitions | 6.0 to 6.1 ms median (5.7 to 7.2) | +| what `as of` accepts | the unit tests' store fakes; git read-only on the checkout | `as of "HEAD"` and `as of "2026-11-01"` refused; a sha prefix accepted; `read` of a repository path under a commit where the file differed returned that commit's blob and not the head's, under a note saying that `read` read the present | +| row numbering | a table keyed by text, five rows, in a temporary file | after the last row was deleted the next insert was numbered 5 again; a vacuum after a delete in the middle kept the numbers | + +Not measured: anything on an instance's own stores; the lexical statistics computed from a mask +at a corpus's size; the causal fiber recomputed over a real instance's sessions; a vector search +with superseded rows joined to the heads at a cut; a retention pass. Each is the measurement of +the stage that builds it. + +## 12. The build order + +Nothing is built by this note. What the merge licenses is decision D12. The stages, each a pull +request against main with its tests and its rollback, each transcribing its laws and +property-testing the transcription against the Lean statements; the laws a stage relies on enter +`docs/LAWS.md` and `formal/Spec/` with it, as design theorems do when code comes to rely on them. + +- **SN-1 the landing log.** The `landings` table of §3.2 in the catalog's file, created by the + catalog's own migration (`core/stores/catalog.py:77-92`) and written inside `record`, + `tombstone`, `remove`, `remove_digest`, `relabel_provenance` and `migrate_rekey_doc_id`, in the + transaction of the row each writes, so that a `deferred()` batch (`catalog.py:125-138`) carries + its log rows; a `genesis` at first open; the reads `read_at(class, path, c)`, + `heads_at(class, c)`, `read_between(class, a, b)`, `head(class)` and `verify(class)`. Nothing + reads them yet, and no reader's behaviour changes. Tests: SNP-1 to SNP-5 as §10 states them, + over random sequences of catalog writes; the catalog equals the fold of the log after every + write; a store the UNCHANGED check skips writes no row; a transaction killed between the two + rows leaves neither; the genesis equals the catalog; `verify` fails on an edited row. The laws + SNP-1 to SNP-5 enter the ledger here. Rollback: the table is additive and unread, so dropping + it restores the file; a build that stops writing it and resumes later appends a `horizon`. +- **SN-2 cuts.** The chain tables for `chat` and `att`; the `cuts` table and the `cut` + attestation; a record at a sensed commit, at a moved trough and on command; the four names; the + resolver; a command that records, lists and verifies cuts. Tests: SNP-8 and SNP-9 as stated. + Rollback: additive tables; the names fall back to today's. +- **SN-3 the erasure's reach and the seal.** A purge empties the log's rows, removes the lexical + units, nulls the version rows' digests, removes the relation edges and artifacts that name the + digest, compacts the vector table and writes its attestation; the seal by identity and the + owner's `unseal`. It lands before SN-4, since SN-4 is the first stage that reads a superseded + version. Tests: SNP-7 as stated, with the purge probe of §11 turned into a test that must find + nothing. Rollback: a purge has none by its nature; the rest is additive. +- **SN-4 the notes at a cut.** The universe's nodes from `heads_at`; `read` from the raw object + the log names; the vectors and the lexical units joined to the heads; the pending rule at a + cut; `trace` at a cut; the cut read and its note (§7.1), which retires the note that says a verb + read the present; the commit on a `read` hit. Tests: `as of "head"` against no `as of` over the + query battery (`eval/query_battery.py`); a sentence at a recorded cut asked before and after + unrelated landings; SNP-6 with two grants; the cut read under the cut asked. Rollback: one + configuration switch under `[query]`, off being today's behaviour. +- **SN-5 the causal fiber at a cut.** The recomputation of §5.5 with its memo; edges named by + session, order and endpoint; the transcript integrator's checkpoint a cut on `chat` and `repo`. + Tests: the two job orders giving one result; the prefix that ends before a result; the stored + rows at the head equal to the recomputation. Rollback: the stored rows stay the head's cache. +- **SN-6 model output by generation.** A sequence number and a history table for artifacts, + relation edges and claim ops; `relate` at a cut; a kept row served only with its sources. + Tests: SNP-5 on random sequences of writes and replacements; `mem_serve_iff`'s test. Rollback: + additive columns and tables. +- **SN-7 retention.** The window a chain in the instance's configuration; the pass in the order + of §9.2; the `horizon` row; the horizon in the answers. Tests: SNP-10 as stated, and a pass + killed at each step leaving no served position incomplete. Rollback: none for dropped rows by + their nature; nothing runs unless a window is declared. +- **SN-8 the delta.** `changed between` and `changed since` (§7.4); the integrator interface + below. Tests: the region's union law, and equal reads at both cuts for an identity outside it. + +**A generic integrator on the delta.** An integrator job is a registered, scoped job that reads +what changed and writes one batch of edges with their evidence. Its checkpoint is a cut `a`. A +run takes `b`, the greatest consistent cut under the head on the chains the job reads; reads +`read_between(a, b)` on them; writes its batch, every edge's sources inside `b`; and records `b` +as its checkpoint in the transaction of the batch. Three laws make that correct. The state the +job would compute from the whole prefix at `b` is its state at `a` continued over the delta +(`foldAt_readBetween`), so a run and a rebuild agree. The delta up to `b` is the same however +the stores grow while the job runs or after it (`readBetween_grow`), so a run repeated after a +crash reads what the interrupted one read, and anything more lies after `b` +(`readBetween_append`). And for a job that joins two chains, a pair read at `b` was read +at `a` or has a member in the delta (`pair_readAt`), so the job visits the old events of one +chain only against the new events of the other. The transcript integrator is the case at hand: +it joins `chat` and `repo`, a commit that reaches the ledger after its session was read is a +delta on `repo`, and the session's unresolved commit events are visited against it, which the +digest it keeps a session today does not do (§2.3, item 4). The integrators that +dn-decision-integrators designs, and the embed drain, are jobs of this shape; their designs stay +where they are. `[THEOREM: SNP-1, SNP-3; DERIVED for the job]` + +## 13. Decisions for the owner + +Each with the recommendation and what the alternative costs. + +1. **D1, where the catalog's past is kept.** Recommended: the landing log in the catalog's file, + written by the catalog (§3.2). The alternatives: version chains for every place, which is a + second file, so the key and its history are two transactions and ING-7's order gains a stage, + and whose chains are per document, so a cut is a pair a document; or the plane's supersession + log, which an instance with no plane lacks, which records the drain's order under lazy + embedding, and which gives a position again after a purge. +2. **D2, the grain of a cut.** Recommended: one position a chain, the landing chains one a + provenance class (§3.1). The alternatives: a position a document, the spine's frontier today, + which is millions of pairs a cut on a corpus instance; or one landing chain for every class, + which saves a few integers a cut and tells a narrower reader, by its positions, how many + landings the classes it cannot read made. +3. **D3, what a retire does to the past.** Recommended: the stricter seal, by identity, lifted + only by the owner's `unseal` (§6.2). The alternative, the looser seal, brings a deleted note's + versions back at earlier cuts when another note is written at its path, and lets a past answer + grow; it needs no unseal when a vault is missing at a rescan, where the stricter one does. +4. **D4, a store that cannot serve the cut asked.** Recommended: read it at the greatest position + at or under the cut that it serves, and name the cut read (§7.1). The alternatives: refuse the + sentence, after which `as of` answers nothing that touches a store without a past until SN-6, + and nothing under a horizon ever; or keep today's behaviour, which answers from after the cut + and changes as the store grows. +5. **D5, the embedder's and the tokenizer's identity at a cut.** Recommended: the present's + (§5.2, §5.3). The alternative, the identity in force when the content landed, needs every + identity's vectors kept, a vector table an identity (1,536 bytes an atom at the present + dimension and precision), in a plane that refuses a second identity today. +6. **D6, the names `as of` takes.** Recommended: `head`, a recorded cut's id, a commit, a date + (§3.4). The alternatives: commits only, as today, which leaves no name for a moment between + two commits and none on an instance with no repository; or dates without the cut read in the + answer, which gives an answer that cannot be asked again. +7. **D7, between two cuts.** Recommended: the region `changed between` and `changed since` + (§7.4). The alternatives: nothing, and every integrator and every question about change is a + hand-written read; or a general two-cut adjective, which is a second universe a sentence and a + pair sort, and which dn-graph-dynamics designs already as GD-4. +8. **D8, retention.** Recommended: no window on the default instance, a declared window a chain + where the disk is bounded (§9.2). The alternatives: a window everywhere, which loses the + default instance's history to save megabytes a year; or the last `n` versions an identity, + which leaves no horizon to name. +9. **D9, the attestation ledger under a purge.** It still names a purged digest (§6.1), against + the plane's rule that no content hash of purged text is kept. Recommended: from SN-3 on a + landing's attestation names the log row's commitment in place of the content digest, so a + purge leaves nothing that can be tested; the rows written before stay, and a purge lists them + as what it could not reach. It makes an attestation a landing, a kilobyte each at the recorded + row size, where today there is one per action and digest, and it turns the landing's check + for an earlier attestation into a read of the log, where today it scans the ledger + (`core/ingest/landing.py:16-19`). The alternatives: rewrite the ledger at a purge, which + breaks its construction as append-only and every id computed from a row; or leave it, and a + digest of purged bytes stays. +10. **D10, model output.** Recommended: kept by generation (§5.4). The alternative, outside the + snapshot, costs nothing and means `relate` and the dreams are never read at a past cut. +11. **D11, the read-only principal at a cut.** Recommended: the present's list, applied to the + edges inside the cut (§6.4). The alternative, the list taken at the cut's tree, shows at a + past cut a file that was tracked then and is not now, which the head withholds, and makes the + grant a function of the cut. +12. **D12, what the merge licenses.** Recommended: SN-1 and SN-2, which add tables and change no + reader. SN-3 to SN-8 change an erasure, the universe and what an instance keeps, and each is + licensed with its own pull request. The alternative, all eight at once, saves the owner seven + decisions and reviews the purge, the universe and retention together. + +## Parked decisions + +| id | decision | default recorded | re-entry condition | +|---|---|---|---| +| SN-a | the cadence of recorded cuts | a sensed commit, a moved trough, the owner's command | a date that resolves to a cut farther from it than a declared tolerance | +| SN-b | the citation readings as rows valid over a range of commits | one whole reading a commit, as built | the store's size on an instance | +| SN-c | the heads kept at some recorded cuts | none: every head is read from the log | reading every head at a cut past a tenth of a second on an instance | +| SN-d | a second embedder identity's vectors kept beside the first | none: the present's identity | dn-two-phase-ingestion's open question 4 | +| SN-e | lexical statistics stored per class and per recorded cut | computed from the mask | a lexical query at a past cut over its budget | +| SN-f | `repo` as a graph of commits | the line of the branch the sensor reads | an instance whose history has merges or that reads several repositories | +| SN-g | which recorded cuts are kept under a horizon | the records stay as attested claims; their chains' rows go | a consumer that must verify a cut under a horizon | +| SN-h | generations with a diff for the causal fiber | recomputation with a memo | SNF-5 | + +## Falsifiers + +- **SNF-1 (the log is not the catalog's past):** after some sequence of writes the fold of the + log differs from the catalog, or a row of one is found without its row of the other. Then the + log is not written in the key's transaction and SN-1 does not land. +- **SNF-2 (a position a document is needed):** a consumer that must name a cut holding one + document of a class at an older version and another at a newer one in an order the class's + chain did not have. Then chains are per document and decision D2 is reopened. +- **SNF-3 (a name resolves far from what was meant):** a date, or a commit, whose recorded cut + lies farther from it than the tolerance SN-a declares. Then the cadence changes; the names do + not. +- **SNF-4 (the cut read misleads):** readers take an answer at a lowered cut for the answer at + the cut asked, seen as `as of` sentences in the query log asked again without `as of` after an + answer with a lowered chain. Then such a sentence is refused (D4's first alternative). +- **SNF-5 (recomputing the causal fiber is too slow):** a sentence that walks `C` at a past cut + over a second on a real instance, the memo warm. Then generations with a diff (SN-h). +- **SNF-6 (every head is too slow):** `heads_at` past a tenth of a second on an instance's log. + Then the kept heads of SN-c. +- **SNF-7 (the mask is too slow for the lexical statistics):** a lexical query at a past cut over + its budget at the instance's size. Then SN-e; the rule that the statistics are the mask's does + not change. +- **SNF-8 (kept model output is never read):** no sentence under `as of` reads an archived + artifact or relation in a declared period. Then the archive stops and D10 takes its + alternative. +- **SNF-9 (retention drops what is asked for):** cuts asked for under a declared horizon, or a + pass ordered by the field that drops rows later asked for more often than a pass ordered by + age. Then the window grows, or the order is age. +- **SNF-10 (the stricter seal is the wrong default):** unseals become routine, as an instance + whose vault goes missing at rescans would show. Then D3 takes the looser seal, with its cost. +- **SNF-11 (a transcription lies):** a built stage whose property test against a Lean statement + fails. A transcription defect; the stage does not land until it agrees. +- **SNF-12 (an erasure leaks):** after a purge, a read at any cut or a scan of the instance's + files finds the purged words. Then SN-3's reach is incomplete and no stage after it is on. +- **SNF-13 (append invariance fails on the code):** a sentence at a recorded cut that answers + differently after unrelated landings, the erasure and the grant unchanged; or `as of "head"` + that differs from no `as of`. Then some reader is not a function of the prefixes, and SNP-5 + says which kind of store to look for. +- **SNF-14 (the region is not what is asked):** questions about change that need the two + readings and cannot be put with the region. Then GD-4's form is built sooner, on the two + readings this note supplies. + +## Open questions + +- May a narrower grant name a date? The answer names a cut on its own chains only, but the + cadence of recorded cuts is itself a fact about when the stores were written. +- The chat log and the attestation ledger have no erasure today except a reset. Their chain + tables digest commitments so that one can leave a hole; who may erase a turn is not decided + here. +- Should the genesis of a class the plane holds be seeded from the plane's supersession log? It + would recover an order per path before the log existed, without positions across paths, and + not on an instance with no plane. +- A purge does not reach a backup or a migration's archive. Whether a recorded cut is taken + before a purge, so that the purge's own moment is certified, belongs with that design. +- On an instance that reads several repositories, is `repo` one chain a repository? + +## Cross-references + +**Formal (this branch):** `formal/Palace/Snapshot/Defs.lean` (`Store`, `Cut`, `head`, `grow`, +`Extends`, `readAt`, `readBetween`, `view`, `present`, `AppendInvariant`, `PrefixOnly`, `foldAt`, +`stateOf`, `stateAt`, `lastWrite`, `Gen`, `closeAt`, `landGen`, `gens`, `selects`, `genRead`, +`prune`, `sealedAt`, `servedAt`, `servedNow`, `restrict`, `snapshot`, `redact`, `visible`, +`compact`, `serve`, `committed`, `purge`, `commitments`, `contents`, `Consistent`, `generator`, +`reached`, `Resolves`, `reachedIn`, `ResolvesIn`, `chainDigest`, `CollisionFree`, `Certificate`, +`certify`, `Verifies`); `formal/Palace/Snapshot.lean` (the declarations §10 names, by law, and +the `Witness` controls); `formal/PalaceTest/Snapshot.lean` (seeds 430 to 486); the families +cited: `Palace/Clock.lean` (CLK-2: `IsCut`, `frontierCut`, `isCut_iff_not_crossed`, +`IsCut.inter`, `IsCut.union`), `Palace/Ingress.lean` (ING-7), `Palace/Script.lean` (ING-17), +`Palace/Derived.lean` (ING-19 to ING-21), `Palace/Plane.lean` (PLN-4), `Palace/Utility.lean` +(UTL-2, UTL-4), `Palace/Sentence.lean` (QSA-1 to QSA-4, QSA-10). + +**Code (read at `e3e3ee47`, unchanged):** `core/sentence/grammar.py`, `ast.py`, `universe.py`, +`execute.py` (`as of`, the universe, `read`); `core/query.py` (the modes, `note_graph`); +`core/temporal/spine.py` (`CertifiedCut`, `cut_at`); `core/stores/catalog.py`, `versions.py`, +`chatlog.py`, `chat_events.py`, `causal_edges.py`, `reference_edges.py`, `plane.py`, +`vectorstore.py`, `lexical.py`, `memberships.py`, `derived.py`, `edges.py`, `claim_ops.py`, +`authored_supersession.py`, `staging.py`, `observation_history.py`, `code_observations.py`, +`runledger.py`, `verdicts.py`; `core/kernel/stores/rawstore.py`; `core/attestation/store.py`, +`record.py`, `attestor.py`; `core/ingest/writer.py`, `landing.py`, `table.py`, `purge.py`, +`derive.py`, `sync.py`; `core/chat_events.py`, `core/integrator.py`; `ops/code_sensor.py`, +`ops/code_snapshot.py`, `ops/chat_sensor.py`, `ops/lifecycle/launcher.py`; +`eval/predictions/ledger.py`. + +**Design:** global-event-clock §2.2 to §2.4 (the generators, Law C4, the certified frontier); +limits-of-the-algebra L7; dn-query-sentence-algebra §2.3, §2.7, §2.9; dn-ingress D1, D3, D5 +(ING-7, the one writer); dn-ingress-language (ING-13 to ING-17); dn-two-phase-ingestion D1, D2 +(ING-19 to ING-21); vector-membership-store A3.5, A3.7 (noninterference, the purge); +dn-utility-field §3.1, §4 (UTL-2, UTL-4) and its first open question; dn-graph-dynamics §6, §7.1 +(GD-4, the state at a cut); dn-decision-integrators (the integrators' layer); +dn-mathematical-foundations §2.4 (design theorems and the ledger); +`papers/2026-11-10-temporal-snapshot/paper.tex`. From d394bbd0fabe368c5db1894a388762e02a63a460 Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 01:45:32 -0500 Subject: [PATCH 10/37] docs(tracks): the snapshot's design on the query-language track The track's manifest gains SN-0, the temporal snapshot's design proved, and links the note and its article; the board is regenerated. Co-Authored-By: Claude Fable 5.2 --- docs/TRACKS.md | 1 + docs/tracks/query-language.md | 3 +++ 2 files changed, 4 insertions(+) diff --git a/docs/TRACKS.md b/docs/TRACKS.md index fb2124c5..a71212ed 100644 --- a/docs/TRACKS.md +++ b/docs/TRACKS.md @@ -170,6 +170,7 @@ - QL-2 the executor — clause evaluators over the existing stores, the mask/column/product/threshold operators, the product-automaton walker, the overlay for assume - QL-3 the surface — palace query, a /context skill, the resolution ledger, the query log as a sensor - QL-4 the falsifier battery run — composed sentences against flat search on owner-endorsed answers, a finding either way + - SN-0 the temporal snapshot's design proved: dn-temporal-snapshot with SNP-1 to SNP-10 machine-checked in formal/Palace/Snapshot.lean (append invariance, monotonicity, composition, idempotence at the head, derived views as functions of the prefixes, grant restriction, erasure dominance, the lattice of consistent cuts, certified cuts, the horizon), attacks and controls green, the measurements on synthetic fixtures - **Reference bookkeeper** (active): - the async F-consistency agent designed (a FABLE design-pass) — bookkeeper still unbuilt - the reference-sensor gap closed (finding-0145) diff --git a/docs/tracks/query-language.md b/docs/tracks/query-language.md index 09ed944f..9e2803cc 100644 --- a/docs/tracks/query-language.md +++ b/docs/tracks/query-language.md @@ -11,6 +11,7 @@ dod: - QL-2 the executor — clause evaluators over the existing stores, the mask/column/product/threshold operators, the product-automaton walker, the overlay for assume - QL-3 the surface — palace query, a /context skill, the resolution ledger, the query log as a sensor - QL-4 the falsifier battery run — composed sentences against flat search on owner-endorsed answers, a finding either way + - SN-0 the temporal snapshot's design proved: dn-temporal-snapshot with SNP-1 to SNP-10 machine-checked in formal/Palace/Snapshot.lean (append invariance, monotonicity, composition, idempotence at the head, derived views as functions of the prefixes, grant restriction, erasure dominance, the lattice of consistent cuts, certified cuts, the horizon), attacks and controls green, the measurements on synthetic fixtures backlog_deskcheck: null links: - docs/design-notes/dn-query-sentence-algebra.md @@ -19,6 +20,8 @@ links: - docs/brainstorms/ingress.md - docs/design-notes/dn-two-phase-ingestion.md - docs/design-notes/dn-embedder-use.md + - docs/design-notes/dn-temporal-snapshot.md + - papers/2026-11-10-temporal-snapshot/paper.tex --- # Track — Query language (the sentence algebra, its compiler, and the surface) From 8f1a90d7a632fc8466f5952b043cf193b77c312d Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 01:51:35 -0500 Subject: [PATCH 11/37] docs(paper): the article for the temporal snapshot A knowledge store as of a cut, in ten pages: the model (a family of append chains, a cut, the reads at and between cuts, a derived view, the grant, the erasure, certificates), the ten laws as eight theorems with proof sketches and the Lean declarations that check them, the design read off the code (the landing log as the one missing ledger, cuts and their names, each derived store as a function of a cut, what an erasure must reach, the cut asked and the cut read, retention), the resolver as pseudocode, what is proved and attacked, and the measurements on synthetic fixtures. The related work is consistent cuts and their lattice, temporal and multiversion data, hash chains and commitments, view maintenance and noninterference. Built with scripts/build_papers.sh: 10 pages, no undefined reference, no overfull box, no BibTeX warning. Co-Authored-By: Claude Fable 5.2 --- papers/2026-11-10-temporal-snapshot/paper.tex | 506 ++++++++++++++++++ papers/2026-11-10-temporal-snapshot/refs.bib | 172 ++++++ 2 files changed, 678 insertions(+) create mode 100644 papers/2026-11-10-temporal-snapshot/paper.tex create mode 100644 papers/2026-11-10-temporal-snapshot/refs.bib diff --git a/papers/2026-11-10-temporal-snapshot/paper.tex b/papers/2026-11-10-temporal-snapshot/paper.tex new file mode 100644 index 00000000..63ae68cf --- /dev/null +++ b/papers/2026-11-10-temporal-snapshot/paper.tex @@ -0,0 +1,506 @@ +\documentclass[11pt]{article} +\usepackage[T1]{fontenc} +\usepackage{lmodern} +\usepackage{microtype} +\usepackage[margin=1in]{geometry} +\usepackage{amsmath,amssymb,amsthm,mathtools} +\usepackage{algorithm} +\usepackage{algpseudocode} +\usepackage{booktabs} +\usepackage[numbers,sort&compress]{natbib} +\usepackage[hidelinks]{hyperref} +\usepackage[capitalise,noabbrev]{cleveref} +\setlength{\emergencystretch}{3em} + +\theoremstyle{plain} +\newtheorem{theorem}{Theorem}[section] +\newtheorem{proposition}[theorem]{Proposition} +\theoremstyle{definition} +\newtheorem{definition}[theorem]{Definition} + +\newcommand{\lean}[1]{\path{#1}} +\newcommand{\N}{\mathbb{N}} +\newcommand{\at}[2]{#1|_{#2}} +\newcommand{\btw}[3]{#1|_{(#2,\,#3]}} +\newcommand{\hd}[1]{\lvert #1 \rvert} +\newcommand{\pre}{\preceq} + +\title{A Knowledge Store as of a Cut:\\ +Append Chains, Consistent Cuts, and What Erasure and Scope Do to a Snapshot} +\author{Alberto Serrano-Calva} +\date{November 10, 2026} + +\begin{document} +\maketitle + +\begin{abstract} +A query on a knowledge store can ask for the store as of a past moment. In the store studied here +that reading exists for one relation, a citation graph indexed by commit, and every other store is +read as it is now. We design the rest. A store is modelled as a family of append chains, a cut as a +prefix length for each, and the read at a cut as the prefixes. Ten laws are machine-checked in +Lean~4 over Mathlib. A read at a cut is unchanged by growth of the store, and a reader has that +property exactly when it is a function of the prefixes. Reads at cuts are ordered and compose with +reads between cuts, so a job's checkpoint is a cut. A derived store kept by generation reads what +recomputation reads, with at most one generation of a key alive at a cut. A narrower grant's +snapshot is the restriction of a wider one's, and positions on a shared chain count what a filter +hides. Nothing erased is visible at any cut when an erasure leaves holes, and a seal keeps a +retired identity out of earlier cuts. Consistent cuts form a sublattice, and every frontier +resolves to one greatest consistent cut. The digest of each prefix certifies a cut and survives an +erasure that keeps commitments. A store that drops old generations is exact from its horizon on, +never wrong under it, and unable to tell what it lost. The last law gives the rule for an +incomplete history: a read is taken at the greatest consistent cut among the positions the stores +still serve, which never lies after the cut asked. Reading the code against the usual picture of +ledgers and derived stores locates the one missing ledger, the past of the map from paths to +content, and a log of 409 bytes a landing supplies it. Measurements on synthetic fixtures give the +cost of its reads and show what an erasure leaves behind today. +\end{abstract} + +\section{Introduction} + +The system is a personal knowledge store \cite{serranocalva2026palace}: notes, dialogue, papers and +code land through one writer into a dozen stores (content-addressed raw objects, a catalog from +paths to content, version chains, a chat log, attestations, a vector plane, a lexical index, edge +stores), and a sentence of a small query algebra reads them. A sentence may carry +\texttt{as of ""}. Today that adjective moves one relation. The citation graph, which is +stored as one whole reading per commit, is read at the commit named; every other verb reads the +present, and the answer says so. + +Finishing the adjective is not a matter of adding a timestamp filter. The stores have no common +clock: each has its own append order, and wall time is by rule never an ordering key. Some stores +keep their past and some are rewritten in place. Content can be erased, and an erased item must +not return through a snapshot. The asker's grant is today's, not the cut's. And a history is never +complete: it starts somewhere, and retention may move the start. Each of these changes what +``the store as of a cut'' has to mean, and each can be stated and proved before any code reads a +store at a cut. That is what this article does. The contributions: +\begin{enumerate} +\item A model (\Cref{sec:model}) of a multi-store as a family of append chains with cuts, reads at + and between cuts, derived views, a grant, an erasure and certificates. +\item Ten laws (\Cref{sec:laws}), SNP-1 to SNP-10, machine-checked as 125 theorems, with the + failure modes as theorems too: the reader that ignores the cut, the store rewritten in place, a + filter applied before the cut, an erasure that deletes rows, a digest with collisions, a pruned + store read under its horizon. +\item A rule for incomplete histories (\Cref{thm:horizon}): among the positions the stores still + serve there is one greatest consistent cut under the cut asked, and a read taken there holds no + event from after the cut it names. +\item A design (\Cref{sec:design}) read off the code: the one ledger that is missing, how each + derived store is a function of a cut, what an erasure must reach, and what an answer says. +\item Measurements on synthetic fixtures (\Cref{sec:eval}). +\end{enumerate} + +\section{Background and related work} + +\paragraph{Consistent cuts.} +Lamport's happened-before relation \cite{lamport1978time} orders events without a global clock; a +global state is a consistent cut, a set of events closed under that order +\cite{chandy1985snapshots}. Vector timestamps characterize the order +\cite{fidge1988timestamps,mattern1989virtual}, and Mattern observed that the consistent cuts form +a lattice \cite{mattern1989virtual}; the down-sets of any partial order form a distributive +lattice \cite{birkhoff1937rings,davey2002lattices}. The store's own clock design already takes a +cut to be a down-set of a derived event order with a per-store frontier. Here there is one +writer, so no marker protocol is needed; what is needed is the greatest consistent cut under a +frontier that a name selects, and its behaviour when some stores cannot serve a position. + +\paragraph{Temporal and multiversion data.} +Temporal databases keep rows valid over a period, and system-versioned tables answer a query as +of a system time \cite{snodgrass1999temporal,kulkarni2012sql2011}; multiversion concurrency +control keeps versions so that a reader sees a state as of its start +\cite{reed1978naming,bernstein1983mvcc}. Our generations are system-versioned rows whose period +is counted in positions of an append chain, never in wall time, and \Cref{thm:forms} is the +statement that such rows read what the log replays. Maintaining a derived view from the changes +to its inputs is the subject of incremental view maintenance \cite{gupta1995views}; the delta +between two cuts is its input here. + +\paragraph{Hash chains and commitments.} +A hash chain makes an append-only history tamper-evident +\cite{merkle1987signature,haber1991timestamp}. A chain over contents cannot survive an erasure of +content, and a chain that keeps a plain hash of erased content leaves a test for that content. A +salted commitment \cite{halevi1996commitment} whose salt is destroyed avoids both, and +\Cref{thm:cert} says the certificates then survive. + +\paragraph{Noninterference.} +A grant restricts what a reader may learn \cite{goguen1982security}. A position on a chain is +itself data: it counts every event before it, hidden or not, which \Cref{thm:grant} turns into a +design rule. + +\paragraph{The proof environment.} +The laws are stated in Lean~4 \cite{moura2021lean4} over Mathlib \cite{mathlib2020}, in a library +whose every declaration is replayed by Lean's kernel and five independent checkers. + +\section{The model}\label{sec:model} + +\begin{definition}[Stores, cuts, reads] +A \emph{store} is a family of append chains $s : K \to \mathrm{List}\,\alpha$: for each chain key +the events appended to it, in order. Its \emph{head} is $\hd{s}(k) = \mathrm{length}(s\,k)$. +$s'$ \emph{extends} $s$, written $s \pre s'$, when every chain of $s$ is a prefix of its chain in +$s'$; $s \mathbin{+\!\!+} t$ appends chain by chain. A \emph{cut} is $c : K \to \N$, ordered +pointwise. The \emph{read at} $c$ is $\at{s}{c}(k) = \mathrm{take}\,(c\,k)\,(s\,k)$, and the +\emph{read between} $a$ and $b$ is $\btw{s}{a}{b}(k) = \mathrm{drop}\,(a\,k)\,(\at{s}{b}\,k)$. A +\emph{derived view} at a cut is $D(\at{s}{c})$ for a derivation $D$. A reader $F(s, c)$ is +\emph{append invariant} when $F(s \mathbin{+\!\!+} t, c) = F(s, c)$ for all $t$ and all +$c \le \hd{s}$. +\end{definition} + +\begin{definition}[A keyed chain, three ways] +For a chain $l$ of writes $(x, v)$, $\mathrm{state}(l)$ maps each key to its last value: the store +rewritten in place. $\mathrm{state}_c(l) = \mathrm{state}(\at{l}{c})$ is the state recomputed at a +cut. The \emph{generational} store $\mathrm{gens}(l)$ has a row per write: the $i$-th write +$(x, v)$ gives $(x, v, \mathrm{born} = i, \mathrm{died})$ with $\mathrm{died}$ the position of +the next write of $x$, absent while the row is the head; a row is \emph{alive} at $c$ when +$\mathrm{born} \le c < \mathrm{died}$, and $\mathrm{read}(\mathrm{gens}(l), c, x)$ is the value of +the row of $x$ alive at $c$. Retention at a horizon $h$, $\mathrm{prune}_h$, drops the rows with +$\mathrm{died} \le h$. +\end{definition} + +\begin{definition}[Grant, erasure, seal] +For a set of chains $G$ and an event predicate $p$, the \emph{snapshot} is +$\mathrm{snap}_{G,p}(s, c) = \mathrm{restrict}_{G,p}(\at{s}{c})$: the chains in $G$, each read at +the cut and filtered by $p$. For an erasure predicate $E$, $\mathrm{redact}_E(s)$ replaces each +erased event by a hole, $\mathrm{visible}_E(s, c)$ is $\at{s}{c}$ without the erased events, and +$\mathrm{compact}_E(s)$ deletes them. In a chain of landings $(x, \mathrm{some}\,v)$ and retires +$(x, \mathrm{none})$, the \emph{stricter seal} serves at $c$ the value $x$ held at $c$ unless a +retire of $x$ lies after $c$; the \emph{looser seal} serves it unless $x$ is not live at the head. +\end{definition} + +\begin{definition}[Consistency, resolution, certificates] +Let $R\,k\,i\,k'\,j$ say that the $i$-th event of chain $k$ reads from the $j$-th of $k'$. A cut +$c$ is \emph{consistent} when $R\,k\,i\,k'\,j$ and $i < c\,k$ imply $j < c\,k'$. It \emph{resolves} +a frontier $f$ when it is the greatest consistent cut under $f$. Given for each chain a set $S_k$ +of \emph{served} positions, it resolves $f$ \emph{among} them when it is the greatest consistent +cut under $f$ with $c\,k \in S_k$ for all $k$. For a step $\sigma : H \to \alpha \to H$ and a seed +$h_0$, the \emph{digest} of a chain is its left fold; the \emph{certificate} of a cut is the cut +with the digest of every prefix, and a store \emph{verifies} it when the cut lies inside the +store and its own prefixes have those digests. +\end{definition} + +\section{The laws}\label{sec:laws} + +Each statement names the declarations of \lean{formal/Palace/Snapshot.lean} that check it. + +\begin{theorem}[SNP-1 and SNP-5: append invariance]\label{thm:append} +For $c \le \hd{s}$ and any $t$, $\at{(s \mathbin{+\!\!+} t)}{c} = \at{s}{c}$ and +$\btw{(s \mathbin{+\!\!+} t)}{a}{c} = \btw{s}{a}{c}$. A reader $F$ is append invariant if and only +if there is a derivation $D$ with $F(s, c) = D(\at{s}{c})$ for all $c \le \hd{s}$. The reader +$F(s, c) = D(s)$, which ignores the cut, is not append invariant. +\end{theorem} +\begin{proof}[Sketch] +Taking a prefix of an appended list within the first list's length ignores the second +(\lean{readAt_grow}, \lean{readBetween_grow}). For the equivalence, $s$ is $\at{s}{c}$ grown by +its own suffix, so an append invariant $F$ satisfies $F(s, c) = F(\at{s}{c}, c)$, and +$D(t) = F(t, \hd{t})$ works; the converse is the first part (\lean{appendInvariant_iff_exists_view}). +The control is \lean{Witness.present_not_appendInvariant}. +\end{proof} + +\begin{theorem}[SNP-2 to SNP-4: order, composition, the head]\label{thm:compose} +If $c \le d$ then $\at{s}{c} \pre \at{s}{d}$, and $\at{(\at{s}{c})}{d} = \at{s}{c \sqcap d}$. For +$a \le b \le c$, $\at{s}{a} \mathbin{+\!\!+} \btw{s}{a}{b} = \at{s}{b}$ and +$\btw{s}{a}{b} \mathbin{+\!\!+} \btw{s}{b}{c} = \btw{s}{a}{c}$. A fold of the prefix at $b$ is the +fold at $a$ continued over $\btw{s}{a}{b}$. An event read at $b$ was read at $a$ or lies in +$\btw{s}{a}{b}$, and a key the delta does not write has the same state at both cuts. Finally +$\at{s}{\hd{s}} = s$, so every view at the head is the derivation of the present. +\end{theorem} +\begin{proof}[Sketch] +List identities for \texttt{take} and \texttt{drop} (\lean{readAt_mono}, \lean{readAt_readAt}, +\lean{readAt_append_readBetween}, \lean{readBetween_append}, \lean{foldAt_readBetween}, +\lean{mem_readAt_iff}, \lean{stateAt_eq_of_not_written}, \lean{readAt_head}, \lean{view_head}). +\end{proof} +The composition is what lets a job keep a checkpoint: its state at $b$ is its state at $a$ +continued over the delta, so a run and a rebuild agree. For a job that joins two chains, a pair +read at $b$ was read at $a$ or has a member in the delta (\lean{pair_readAt}), the usual delta +rule of view maintenance \cite{gupta1995views}. + +\begin{theorem}[SNP-5: three ways of holding a derived store]\label{thm:forms} +For every chain $l$ of keyed writes, cut $c$ and key $x$, +$\mathrm{read}(\mathrm{gens}(l), c, x) = \mathrm{state}_c(l)(x)$, and both are the last write of +$x$ inside $\at{l}{c}$. At most one row of $x$ is alive at $c$. Growth of the chain, which writes +closing stamps into $\mathrm{gens}$, changes no read at a cut inside it. There is no function $G$ +with $\mathrm{state}_c(l) = G(\mathrm{state}(l), c)$ for all $l$ and $c$. +\end{theorem} +\begin{proof}[Sketch] +Induction on the chain from its end: a landing closes the key's open row at its own position and +opens a row there, which leaves every read at an earlier cut and of another key as it was +(\lean{genRead_gens}, \lean{stateAt_eq_lastWrite}, \lean{length_filter_selects_le_one}, +\lean{genRead_gens_append}). For the last part two chains with one final state differ at the +first cut (\lean{Witness.stateOf_forgets}). +\end{proof} + +\begin{theorem}[SNP-6: the grant]\label{thm:grant} +If $G \subseteq G'$ and $p$ implies $p'$, then +$\mathrm{snap}_{G,p}(s, c) = \mathrm{restrict}_{G,p}(\mathrm{snap}_{G',p'}(s, c))$. A snapshot +depends only on the chains of $G$ and on the cut's positions on them, and it is append invariant. +Restricting to whole chains commutes with the cut. Filtering events does not: there are stores +that agree on every admitted event and differ in their snapshots at one cut. +\end{theorem} +\begin{proof}[Sketch] +Filters compose and are applied after the prefix (\lean{snapshot_narrow}, \lean{snapshot_congr}, +\lean{snapshot_grow}, \lean{restrict_readAt}). For the control, $[\mathrm{hidden}, a]$ and $[a]$ +read at position one give nothing and $a$ (\lean{Witness.filter_before_cut}, +\lean{Witness.position_channel}). +\end{proof} +So what must be hidden in number is hidden by chain: where clearances separate rows, a chain per +class. + +\begin{theorem}[SNP-7: erasure]\label{thm:erase} +No erased event is in $\mathrm{visible}_E(s, c)$; a larger erasure shows a sublist; reading the +store with holes commutes with the cut and keeps the head; and if +$\mathrm{redact}_E(s) = \mathrm{redact}_E(s')$ then $D(\mathrm{visible}_E(s, c)) = +D(\mathrm{visible}_E(s', c))$ for every $D$ and $c$. After $\mathrm{compact}_E$ a read at a cut +can hold an event from after it. Under the stricter seal, once a chain retires a key no cut +before the retire serves it, and for any growth $t$ a value served by $l \mathbin{+\!\!+} t$ at a +cut inside $l$ was served by $l$. The looser seal serves everything the stricter one serves, and +a landing after a retire brings the key's past back under it. +\end{theorem} +\begin{proof}[Sketch] +Filtering and mapping commute with \texttt{take} (\lean{not_erased_of_mem_visible}, +\lean{visible_sublist}, \lean{redact_readAt}, \lean{head_redact}, \lean{erased_invisible}); the +seal is a predicate on the suffix past the cut, which only grows +(\lean{servedAt_append_of_retire}, \lean{servedAt_of_append}, \lean{servedNow_of_servedAt}). The +controls are \lean{Witness.compact_moves} and \lean{Witness.servedNow_restores}. +\end{proof} + +\begin{theorem}[SNP-8: consistent cuts]\label{thm:lattice} +Consistent cuts are closed under pointwise meet and join and contain the empty cut, so they are a +sublattice of the cuts. A cut is consistent exactly when the events under its frontier are a +down-set of the order generated by the chains and by $R$. Every frontier is resolved by exactly +one cut, monotonically in the frontier. If growth only adds references that start at or past the +old head, a consistent cut inside the old head stays consistent. +\end{theorem} +\begin{proof}[Sketch] +Closure is pointwise (\lean{Consistent.inf}, \lean{Consistent.sup}, \lean{consistentCuts}); the +down-set form is the clock's cut criterion, no generator edge crossing +(\lean{consistent_iff_isCut}). For resolution take on each chain the supremum of the positions +reached by consistent cuts under $f$: it is attained, and a source of an event under it is under +the witness's position on the source's chain (\lean{exists_resolves}, \lean{Resolves.unique}, +\lean{Resolves.mono}, \lean{Consistent.of_grown}). +\end{proof} + +\begin{theorem}[SNP-9: certificates]\label{thm:cert} +The certificate of a cut of $s$ verifies on every $s' \succeq s$. If the step is collision free, +two stores that verify one certificate have the same read at its cut, hence the same derived +views. The digest at $b$ is the digest at $a$ continued over $\btw{s}{a}{b}$, and the digests at +$c \sqcap d$ and $c \sqcup d$ are, chain by chain, those of $c$ or of $d$. If the chain digests +commitments kept beside the events, erasing contents changes no certificate, and the contents +then read as the store with holes. +\end{theorem} +\begin{proof}[Sketch] +Append invariance of the prefix; induction from the end for injectivity of the fold +(\lean{verifies_certify_of_extends}, \lean{Verifies.readAt_eq}, \lean{Verifies.view_eq}, +\lean{certify_digest_readBetween}, \lean{certify_inf}, \lean{certify_sup}, \lean{verifies_purge}, +\lean{contents_purge_committed}). Under addition two chains of one length collide +(\lean{Witness.digest_collides}). +\end{proof} + +\begin{theorem}[SNP-10: the horizon]\label{thm:horizon} +For $h \le c$, $\mathrm{read}(\mathrm{prune}_h(\mathrm{gens}(l)), c, x) = \mathrm{state}_c(l)(x)$. +For any $c$, a value the pruned store returns at $c$ is $\mathrm{state}_c(l)(x)$; but there are +$l$ and $c < h$ at which it returns nothing where a value stood. +$\mathrm{prune}_h \circ \mathrm{prune}_{h'} = \mathrm{prune}_{\max(h, h')}$. If every $S_k$ +contains $0$, every frontier $f$ is resolved among the served positions by exactly one cut; that +cut rises with the $S_k$ and with $f$, lies under the resolution of $f$, and equals it when every +position is served. +\end{theorem} +\begin{proof}[Sketch] +A row alive at $c \ge h$ has no closing stamp at or under $h$, so pruning removes no row a read +at $c$ selects; under $h$ a selected row is still the unique row alive in the full store +(\lean{genRead_prune_gens}, \lean{stateAt_of_genRead_prune}, \lean{prune_prune}, +\lean{Witness.prune_forgets}). Resolution among served positions is the argument of +\Cref{thm:lattice} with the supremum taken over served consistent cuts: the supremum on a chain +is attained by one of them, so it is served (\lean{exists_resolvesIn}, \lean{ResolvesIn.unique}, +\lean{ResolvesIn.mono}, \lean{ResolvesIn.le_resolves}, \lean{resolvesIn_univ}). +\end{proof} + +\section{The design}\label{sec:design} + +\paragraph{The missing ledger.} +The usual picture has ledgers that only append and derived stores that are rewritten and can be +recomputed. Read against the code it fails at one place that matters. The catalog, the map from a +path to the content it holds and the idempotence key of every landing, is rewritten in place: an +upsert, a tombstone flag, a delete. Version chains exist for one of four places; the attestation +ledger names a digest and no path, once per action and digest; so for most items the sequence of +contents a path held is recorded nowhere. Meanwhile the vector plane and the lexical index, which +the picture calls rewritten, keep every version's rows and move a flag. They are generations +without a clock. A clock on their rows would be wrong, since a path that returns to earlier bytes +makes the same rows current again, so a version's rows are valid on a set of intervals. The fix +is one ledger: a \emph{landing log} in the catalog's own file, one hash chain per provenance +class, a row per catalog write (class, position, kind, path, identity, digest, a salt, a +commitment, the chain hash, the position of the path's next event), written by the catalog's own +methods in the transaction of the row they write. The catalog is then the fold of the log +(\Cref{thm:forms}), and every version-keyed store has a past: the log says which version a cut +holds. + +\paragraph{Cuts, names, certificates.} +A cut is one position per chain, about a dozen integers: the landing chains, the chat log, the +attestations, the repository's commit, the generations of model output. It is not a position per +document, which is millions of pairs on a large instance and adds nothing, since a frontier cut +needs only its cross-store references checked. A cut is recorded, with the digest of every +prefix, at the moments the stores are quiescent, and attested; the records form a chain. The +adjective takes \texttt{head}, a record's id, a commit (the record made when the commit was +read), or a date, which selects the last record whose wall bookmark is not later. Wall time is a +lookup key there and orders nothing. Each row that reads another chain records that chain's head +at its writing, which bounds its sources because there is one writer; the resolver compares +those bounds. + +\begin{algorithm}[t] +\caption{The cut a read under \texttt{as of} is taken at. $S_k$: the positions chain $k$ serves. +$\beta_k(i)$: for the $i$-th event of chain $k$, the heads of the chains it reads, as recorded at +its writing; they rise with $i$.}\label{alg:resolve} +\begin{algorithmic}[1] +\Require a frontier $f$ from the name +\Ensure the greatest consistent cut under $f$ every position of which is served +\State $c \gets f$ +\Repeat + \For{each chain $k$} + \State $c_k \gets \max\{p \in S_k : p \le c_k\}$ \Comment{$0 \in S_k$} + \If{some event of $k$ under $c_k$ has $\beta_k(i)(k') > c_{k'}$ for some $k'$} + \State $c_k \gets$ the least such $i$ \Comment{a binary search} + \EndIf + \EndFor +\Until{nothing moved} +\State \Return $c$ +\end{algorithmic} +\end{algorithm} + +\paragraph{Derived stores.} +By \Cref{thm:append} a derived store can be read at a cut exactly when it is a function of the +prefixes, and by \Cref{thm:forms} the ways of holding it agree, so the choice is cost. Vectors +are a function of a chunk's text and the embedder's identity and are content addressed; the +plane keeps superseded versions, so the vectors at a cut are those of the versions the log names, +at no new bytes. The lexical index is the same, and its collection statistics +\cite{robertson2009bm25} at a cut are those of the units alive at the cut: a cut, like a +clearance, is a mask whose statistics must be its own. The causal edges from session transcripts +to commits and files are recomputed from the transcript as retained at the cut, which is cheap +and also removes a dependence on job order that the stored rows have today. Model output cannot +be recomputed and is kept by generation, the replaced row archived with its interval; a kept row +is served only while every content it is about is alive and not erased. One storage form is +ruled out as the carrier of a snapshot: the vector table's own versioned manifests. An erased +text stays readable through an earlier manifest until a compaction that removes every earlier +manifest (\Cref{sec:eval}), so a manifest version cannot be both the position of a snapshot and +within reach of an erasure. The cut is a predicate on rows taken from the log. + +\paragraph{Erasure and scope.} +Both are parameters of a read, not functions of the cut. A purge empties the log's row and keeps +its position, its commitment and its hash (\Cref{thm:erase,thm:cert}); the salt goes with the +content, so the commitment cannot be tested against a guess. A retire seals the identity's +earlier cuts under the stricter seal, lifted only by an owner's act. The looser seal would let a +new note written at a deleted note's path, which by default inherits its identity, bring the +deleted versions back. The grant is the asker's now, an event filter is applied after the read, +and an answer names the cut only on the chains the grant names (\Cref{thm:grant}). + +\paragraph{What an answer says.} +A store may be unable to serve the cut asked: it keeps no past yet, or the cut is under its +horizon. The read is then taken at the cut \Cref{alg:resolve} returns, which by +\Cref{thm:horizon} exists, is unique, never lies after the cut asked and rises as stores gain a +past. The answer is exact for that cut and names it, chain by chain, with the reason wherever it +differs from the cut asked. Reading such a store at the present instead, which is what the +executor does today, is the reader \Cref{thm:append} refutes. At the head the read is the +present (\Cref{thm:compose}), so \texttt{as of "head"} is the sentence without the adjective. + +\paragraph{The horizon and retention.} +A chain's horizon is set by the genesis of its log, by retention, or by a reset. Retention is a +window per chain counted in positions. A pass appends a horizon row first and then drops, in +order, the derived rows of the versions closed under it, the raw objects nothing retained names, +and the log's rows, the digest at the horizon kept as the seed. Declaring the horizon first +means a crash leaves rows that are unserved, never a position that is served and incomplete. A +window counted per identity (the last $n$ versions of each) would leave no horizon, and +\Cref{thm:horizon} says such a store cannot tell what it lost. + +\section{Evaluation}\label{sec:eval} + +\paragraph{What is proved.} +\Cref{thm:append,thm:compose,thm:forms,thm:grant,thm:erase,thm:lattice,thm:cert,thm:horizon} are +machine-checked in \lean{formal/Palace/Snapshot.lean} over \lean{formal/Palace/Snapshot/Defs.lean} +on Lean v4.36.0-rc2 and the Mathlib it pins: 125 theorems, eight of them the controls, no +\lean{sorry}, and the axioms of all 5{,}122 library declarations audited (\lean{propext}, +\lean{Classical.choice}, \lean{Quot.sound} only). The library's export, 56{,}098 declarations +from \lean{Init} up, is replayed by Lean's kernel and by \lean{leanchecker-paranoid}, +\lean{lean4lean}, \lean{nanoda}, \lean{con-leche} and \lean{con-ron}. These are design theorems: +no code relies on them yet, so they are not among the 328 statements the library restates +separately and judges against its ledger of laws. + +\paragraph{The attacks.} +The definitions compute, so they are attacked as they are with property-based testing +(\lean{formal/PalaceTest/Snapshot.lean}, seeds 430 to 486, 500 draws each): stores of two chains +over three events, keyed chains over three keys, chains of landings and retires, grants and +erasures from bit masks, reads-from relations as edge lists, a base-four digest, served positions +from ten bits. Thirty-nine attacks survive every draw. \Cref{alg:resolve}'s descent, which the +library does not define, is checked against the definition by enumerating every cut under the +frontier, and the served resolution by taking the pointwise maximum of every consistent served +cut. Eighteen controls are refuted within 53 draws: among them a read at a cut past the head, +generations without the closing stamp, an event filter before the cut, an erasure that deletes +rows, the state served without the seal, an additive digest, the pruned store read under its +horizon, and a frontier lowered to the served positions without the descent. + +\paragraph{What is measured.} +All on synthetic fixtures built by each probe, on one machine (Apple M2 Pro, SQLite 3.54.1, +LanceDB 0.33.0), with other work running; no instance was read. \Cref{tab:measure} gives the +figures. + +\begin{table}[t] +\centering +\small +\begin{tabular}{@{}p{0.34\linewidth}p{0.60\linewidth}@{}} +\toprule +probe & result \\ +\midrule +landing log, $10^6$ events over $10^5$ paths, hashed, one transaction & + 409 bytes a row with its two indexes; 50{,}000 to 54{,}000 rows a second \\ +one path at the middle cut & 3 to 4 $\mu$s through the path index; 6 to 7 ms when the planner + takes the primary key \\ +the delta of 1{,}000 positions & 0.69 ms \\ +every head at a cut & 149 to 163 ms at the middle; 246 to 285 ms at the head \\ +the chain's hash from the first row; the stored hash at a position & 0.8 s; 3 $\mu$s \\ +lexical index, 500 items, 4 chunks, 3 versions & + 4{,}179 bytes a unit at 122 postings; 0.67 of the units superseded \\ +a purge of both versions of a note, on the test suite's throwaway store & + the words remain in the lexical postings, and in the vector table read at 8 and at 5 of its 10 + versions until a compaction that leaves 1; the version rows and attestations keep the + digests; the plane's per-path log gives position 1 again \\ +the same transcripts and commits, two job orders & 1 causal edge against 0 \\ +re-deriving a session of 2{,}000 records & 6 ms \\ +\bottomrule +\end{tabular} +\caption{Measurements on synthetic fixtures. Ranges are across two runs.}\label{tab:measure} +\end{table} + +The log's cost is small against what the stores already keep: no store drops a superseded +version today, so most bytes of a past are paid whether or not anything reads them. The purge +row is the finding that orders the build: the stores that would be read at a cut are the ones an +erasure does not reach, so the erasure's reach lands before the first stage that reads a +superseded version. + +\section{Limitations} + +The model has one writer: a chain is a list, and nothing is said of two writers. Collision +freedom is a hypothesis of \Cref{thm:cert}, not a theorem about a hash function. The descent of +\Cref{alg:resolve} is attacked, not proved; the library proves the cut it must return exists and +is unique. A repository history with merges is a partial order and not a chain; the clock's +down-set laws cover it, the chain model does not. The owner's unseal is not in the model of the +seal. Every measurement is on a synthetic fixture: the cost of the lexical statistics from a +mask at a corpus's size, of a vector search joined to the heads at a cut, and of a retention +pass are not measured. The attestation ledger still names an erased digest, and what to do +about it is left to the store's owner. + +\section{Future work} + +The build is eight stages, each shipped with its tests and its rollback: the landing log, with +its reads and no reader; recorded cuts, names and the resolver; the erasure's reach and the seal; +the notes, vectors and lexical index at a cut, with the answer naming the cut read; the causal +edges recomputed at a cut; model output by generation; retention; and the delta, as a region of +what changed between two cuts and as the input of integrator jobs whose checkpoint is a cut. +Each stage transcribes its laws and property-tests the transcription against the Lean +statements, at which point the laws enter the ledger. Two further readings wait on these: the +velocity of an identity over a window of cuts, and a field of use folded over its own log, which +\Cref{thm:compose} makes exact as of a cut. + +\section{Conclusion} + +A snapshot of a store with many stores is a prefix of each chain at a consistent cut, read +through the present's grant and the present's erasure. Stated that way its properties are +theorems: it does not change as the store grows, it composes with the delta, every derived store +that can be read at a cut is a function of the prefixes, and an incomplete history has one best +cut under any cut asked. The same statements located what the code lacked, a ledger of the +catalog's past, and what it must not do, which is to answer a question about the past from the +present. + +\bibliographystyle{plainnat} +\bibliography{refs} +\end{document} diff --git a/papers/2026-11-10-temporal-snapshot/refs.bib b/papers/2026-11-10-temporal-snapshot/refs.bib new file mode 100644 index 00000000..e5642659 --- /dev/null +++ b/papers/2026-11-10-temporal-snapshot/refs.bib @@ -0,0 +1,172 @@ +@article{lamport1978time, + author = {Lamport, Leslie}, + title = {Time, Clocks, and the Ordering of Events in a Distributed System}, + journal = {Communications of the ACM}, + volume = {21}, + number = {7}, + pages = {558--565}, + year = {1978} +} + +@article{chandy1985snapshots, + author = {Chandy, K. Mani and Lamport, Leslie}, + title = {Distributed Snapshots: Determining Global States of Distributed Systems}, + journal = {ACM Transactions on Computer Systems}, + volume = {3}, + number = {1}, + pages = {63--75}, + year = {1985} +} + +@incollection{mattern1989virtual, + author = {Mattern, Friedemann}, + title = {Virtual Time and Global States of Distributed Systems}, + booktitle = {Parallel and Distributed Algorithms}, + publisher = {North-Holland}, + pages = {215--226}, + year = {1989} +} + +@inproceedings{fidge1988timestamps, + author = {Fidge, Colin J.}, + title = {Timestamps in Message-Passing Systems That Preserve the Partial Ordering}, + booktitle = {Proceedings of the 11th Australian Computer Science Conference}, + year = {1988} +} + +@article{birkhoff1937rings, + author = {Birkhoff, Garrett}, + title = {Rings of Sets}, + journal = {Duke Mathematical Journal}, + volume = {3}, + number = {3}, + pages = {443--454}, + year = {1937} +} + +@book{davey2002lattices, + author = {Davey, B. A. and Priestley, H. A.}, + title = {Introduction to Lattices and Order}, + edition = {Second}, + publisher = {Cambridge University Press}, + year = {2002} +} + +@phdthesis{reed1978naming, + author = {Reed, David P.}, + title = {Naming and Synchronization in a Decentralized Computer System}, + school = {Massachusetts Institute of Technology}, + year = {1978} +} + +@article{bernstein1983mvcc, + author = {Bernstein, Philip A. and Goodman, Nathan}, + title = {Multiversion Concurrency Control: Theory and Algorithms}, + journal = {ACM Transactions on Database Systems}, + volume = {8}, + number = {4}, + pages = {465--483}, + year = {1983} +} + +@book{snodgrass1999temporal, + author = {Snodgrass, Richard T.}, + title = {Developing Time-Oriented Database Applications in {SQL}}, + publisher = {Morgan Kaufmann}, + year = {1999} +} + +@article{kulkarni2012sql2011, + author = {Kulkarni, Krishna and Michels, Jan-Eike}, + title = {Temporal Features in {SQL}:2011}, + journal = {ACM SIGMOD Record}, + volume = {41}, + number = {3}, + pages = {34--43}, + year = {2012} +} + +@inproceedings{merkle1987signature, + author = {Merkle, Ralph C.}, + title = {A Digital Signature Based on a Conventional Encryption Function}, + booktitle = {Advances in Cryptology -- CRYPTO '87}, + series = {Lecture Notes in Computer Science}, + volume = {293}, + pages = {369--378}, + publisher = {Springer}, + year = {1988} +} + +@article{haber1991timestamp, + author = {Haber, Stuart and Stornetta, W. Scott}, + title = {How to Time-Stamp a Digital Document}, + journal = {Journal of Cryptology}, + volume = {3}, + number = {2}, + pages = {99--111}, + year = {1991} +} + +@inproceedings{halevi1996commitment, + author = {Halevi, Shai and Micali, Silvio}, + title = {Practical and Provably-Secure Commitment Schemes from Collision-Free Hashing}, + booktitle = {Advances in Cryptology -- CRYPTO '96}, + series = {Lecture Notes in Computer Science}, + volume = {1109}, + publisher = {Springer}, + year = {1996} +} + +@article{gupta1995views, + author = {Gupta, Ashish and Mumick, Inderpal Singh}, + title = {Maintenance of Materialized Views: Problems, Techniques, and Applications}, + journal = {IEEE Data Engineering Bulletin}, + volume = {18}, + number = {2}, + pages = {3--18}, + year = {1995} +} + +@inproceedings{goguen1982security, + author = {Goguen, Joseph A. and Meseguer, Jos{\'e}}, + title = {Security Policies and Security Models}, + booktitle = {Proceedings of the 1982 IEEE Symposium on Security and Privacy}, + pages = {11--20}, + year = {1982} +} + +@article{robertson2009bm25, + author = {Robertson, Stephen and Zaragoza, Hugo}, + title = {The Probabilistic Relevance Framework: {BM25} and Beyond}, + journal = {Foundations and Trends in Information Retrieval}, + volume = {3}, + number = {4}, + pages = {333--389}, + year = {2009} +} + +@inproceedings{moura2021lean4, + author = {de Moura, Leonardo and Ullrich, Sebastian}, + title = {The {L}ean 4 theorem prover and programming language}, + booktitle = {Automated Deduction -- CADE 28}, + series = {Lecture Notes in Computer Science}, + volume = {12699}, + pages = {625--635}, + publisher = {Springer}, + year = {2021} +} + +@inproceedings{mathlib2020, + author = {{The mathlib Community}}, + title = {The {L}ean mathematical library}, + booktitle = {Proceedings of the 9th ACM SIGPLAN International Conference on Certified Programs and Proofs}, + pages = {367--381}, + year = {2020} +} + +@misc{serranocalva2026palace, + author = {Serrano-Calva, Alberto}, + title = {mind-palace}, + howpublished = {\url{https://github.com/ascalva/mind-palace}}, + year = {2026} +} From a64e22d9aa2f671787f09f28350c137f61500a71 Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 01:55:52 -0500 Subject: [PATCH 12/37] docs(snapshot): retention in two windows, and three wordings On a final reading the retention rule dropped raw objects in the same pass as derived rows, which the note's own account of derived rows as a cache does not need and the store's rule that raw objects are kept does not allow by default. The rule is now two windows. A window for derived rows drops lexical units, occupancies and atoms and moves no horizon: the log and the raw objects stay, every ledger read is still exact, and a dropped row is pending and derived again when a cut asks for it. A window for the history moves the horizon, drops raw objects and log rows, and is the owner's to declare. Decision D8, stage SN-7 and the article's paragraph follow. Also: a citation that broke across a line, the principal of section 6.4 described without saying it is being added, and the statement that nothing is dropped today narrowed to what a landing does. Co-Authored-By: Claude Fable 5.2 --- docs/design-notes/dn-temporal-snapshot.md | 97 ++++++++++--------- papers/2026-11-10-temporal-snapshot/paper.tex | 16 +-- 2 files changed, 62 insertions(+), 51 deletions(-) diff --git a/docs/design-notes/dn-temporal-snapshot.md b/docs/design-notes/dn-temporal-snapshot.md index d9ac51e4..75c32b27 100644 --- a/docs/design-notes/dn-temporal-snapshot.md +++ b/docs/design-notes/dn-temporal-snapshot.md @@ -582,15 +582,16 @@ Three things follow. ### 5.3 The lexical index -The index keeps every version's units and postings and marks the head (`core/stores/lexical.py: -56-82`, `:251-256`), and it computes its statistics at query time over the current units of the -reader's classes: the unit count and the mean length (`lexical.py:316-321`) and each term's -document frequency (`lexical.py:337-340`). `[ESTABLISHED]` At a cut the arithmetic is the same -with one predicate changed: a unit counts when its version is its path's head at the cut, in -place of `current = 1`. The collection size, the mean length and the document frequencies are -then the masked set's own, which is what makes a score at a cut the score the index gave then -under the same tokenizer. A clearance and a cut are the same kind of thing to this index: a mask -over units whose statistics must be the mask's. `[DERIVED]` +The index keeps every version's units and postings and marks the head +(`core/stores/lexical.py:56-82`, `:251-256`), and it computes its statistics at query time over +the current units of the reader's classes: the unit count and the mean length +(`lexical.py:316-321`) and each term's document frequency (`lexical.py:337-340`). +`[ESTABLISHED]` At a cut the arithmetic is the same with one predicate changed: a unit counts +when its version is its path's head at the cut, in place of `current = 1`. The collection size, +the mean length and the document frequencies are then the masked set's own, which is what makes +a score at a cut the score the index gave then under the same tokenizer. A clearance and a cut +are the same kind of thing to this index: a mask over units whose statistics must be the mask's. +`[DERIVED]` The other forms cost more here. Recomputing means tokenizing every item alive at the cut, since the statistics are the collection's and not the support's: right for a few hundred notes, not for @@ -757,9 +758,9 @@ whole-class relabel renames a chain, and nothing else moves a row between chains ### 6.4 A reader that is shown only named endpoints -A read-only principal is being added that is shown a causal edge only when the edge ends at a -commit or at a file git tracks at `HEAD`. That rule is an event filter in the sense of §6.3, and -at a cut it is the present's filter applied to the edges inside the cut: an edge is shown when its +Take a read-only principal that is shown a causal edge only when the edge ends at a commit or +at a file git tracks at `HEAD`. That rule is an event filter in the sense of §6.3, and at a cut +it is the present's filter applied to the edges inside the cut: an edge is shown when its witness turn is inside the cut on `chat`, its commit, if it ends at one, is inside the cut on `repo`, and its endpoint passes the list as the list stands now. The list is not taken at the cut's tree. `[DERIVED from SNP-6]` Two reasons. The grant is the asker's now, so a file that left @@ -928,10 +929,10 @@ So the horizon is recorded, and a cut under it is not served. ### 9.1 What grows -Nothing in the stores is dropped today except by a purge: a retired path's rows and a superseded -version's rows stay in the plane and in the lexical index (`core/stores/plane.py:497-499`, -`core/stores/lexical.py:260-265`). So the bytes of a past are mostly paid already, and the -snapshot adds three things. +A landing drops nothing today: a retired path's rows and a superseded version's rows stay in the +plane and in the lexical index (`core/stores/plane.py:497-499`, `core/stores/lexical.py:260-265`), +and rows go only with a purge or a reset. So the bytes of a past are mostly paid already, and +the snapshot adds three things. | what | a | bytes | source | |---|---|---|---| @@ -951,30 +952,36 @@ to stop paying one: a horizon makes it safe to drop. ### 9.2 The rule, counted in events -Each chain declares a window `keep`, in positions. A retention pass, run at a recorded cut, moves -the chain's horizon to the later of the horizon in force and the head less `keep`, and drops in -this order: - -1. the `horizon` row is appended, so the positions under it are unserved from that moment; -2. the derived rows of the versions closed at or under it: lexical units and postings, plane - occupancies, and the atoms nothing retained holds; -3. the raw objects no retained row names; -4. the log's rows closed at or under it, the chain's digest at the horizon kept as its seed. - -The order is the one the stores use for a cache: the horizon is declared first, so a crash in -the middle leaves rows that are no longer served, never a position that is served and -incomplete (the discipline of PLN-4, where a cache is stale only by excess). `[DERIVED]` The -attestation ledger and the version chains are not pruned: they are the audit record, they are -small, and they have no delete. - -The window is counted in events because wall time orders nothing (Law C4): the last ten thousand +A chain can declare two windows, each in positions, and a retention pass runs at a recorded cut. + +- **A window for derived rows.** The derived rows of the versions closed at or under the head + less the window are dropped: lexical units and postings, plane occupancies, and the atoms + nothing retained holds. No horizon moves. The log and the raw objects stay, so every read of a + ledger at those cuts is still exact, and a derived row a cut asks for is pending and can be + derived again (§9.3). +- **A window for the history.** The chain's horizon moves to the later of the horizon in force + and the head less the window. A `horizon` row is appended first, so the positions under it are + unserved from that moment; then the derived rows still under it, the raw objects no retained + row names, and the log's rows closed at or under it are dropped, the chain's digest at the + horizon kept as its seed. + +The second is an exception to the rule that raw objects are kept +(`core/kernel/stores/rawstore.py:1-8`), which only the owner's purge makes today, so it is the +owner's to declare. Its order is the one the stores use for a cache: the horizon is declared +first, so a crash in the middle leaves rows that are no longer served, never a position that is +served and incomplete (the discipline of PLN-4, where a cache is stale only by excess). +`[DERIVED]` The attestation ledger and the version chains are not pruned: they are the audit +record, they are small, and they have no delete. + +A window is counted in events because wall time orders nothing (Law C4): the last ten thousand landings of a class, not the last ninety days. It is one position a chain, not a number of versions an identity. Keeping the last `n` versions of each identity would leave no horizon: which cuts are exact would differ from one identity to the next, and the control of §8 says such a store cannot tell what it lost. `[INFERENCE, falsifier SNF-9]` -The default instance declares no window and keeps everything; by the arithmetic above its log is -megabytes a year. An instance that must bound its disk declares one (decision D8). +The default instance declares neither window and keeps everything; by the arithmetic above its +log is megabytes a year. An instance that must bound its disk declares the first, and the second +only by its owner's decision (D8). ### 9.3 Lazy landing, in time @@ -985,7 +992,7 @@ the head, and the rule is the one two-phase ingestion already has: the item is p semantic clause ranks it by the lexical index or reports it, and no vector is invented (ING-21). `[DERIVED from ING-19, ING-21]` -Retention's second step and lazy derivation are then one mechanism run in two directions. A +The first window of §9.2 and lazy derivation are then one mechanism run in two directions. A derived row is an entry of a cache of a function of a content digest and an identity (§5.2, §5.3): present or absent, reported when absent, derivable again from the raw object while the ledger holds it. The drain run over the versions a cut holds derives what a cut's readers ask @@ -1181,10 +1188,11 @@ property-testing the transcription against the Lean statements; the laws a stage relation edges and claim ops; `relate` at a cut; a kept row served only with its sources. Tests: SNP-5 on random sequences of writes and replacements; `mem_serve_iff`'s test. Rollback: additive columns and tables. -- **SN-7 retention.** The window a chain in the instance's configuration; the pass in the order - of §9.2; the `horizon` row; the horizon in the answers. Tests: SNP-10 as stated, and a pass - killed at each step leaving no served position incomplete. Rollback: none for dropped rows by - their nature; nothing runs unless a window is declared. +- **SN-7 retention.** The two windows a chain in the instance's configuration; the pass of + §9.2; the `horizon` row; the horizon in the answers. Tests: SNP-10 as stated; a pass killed at + each step leaving no served position incomplete; a derived row dropped under the first window + reported pending and derived again. Rollback: none for dropped rows by their nature; nothing + runs unless a window is declared. - **SN-8 the delta.** `changed between` and `changed since` (§7.4); the integrator interface below. Tests: the region's union law, and equal reads at both cuts for an identity outside it. @@ -1242,10 +1250,11 @@ Each with the recommendation and what the alternative costs. (§7.4). The alternatives: nothing, and every integrator and every question about change is a hand-written read; or a general two-cut adjective, which is a second universe a sentence and a pair sort, and which dn-graph-dynamics designs already as GD-4. -8. **D8, retention.** Recommended: no window on the default instance, a declared window a chain - where the disk is bounded (§9.2). The alternatives: a window everywhere, which loses the - default instance's history to save megabytes a year; or the last `n` versions an identity, - which leaves no horizon to name. +8. **D8, retention.** Recommended: no window on the default instance; where the disk is bounded, + a window for derived rows, which moves no horizon, and a window for the history only when the + owner declares one, since it drops raw objects (§9.2). The alternatives: a horizon everywhere, + which loses the default instance's history to save megabytes a year; or the last `n` versions + an identity, which leaves no horizon to name. 9. **D9, the attestation ledger under a purge.** It still names a purged digest (§6.1), against the plane's rule that no content hash of purged text is kept. Recommended: from SN-3 on a landing's attestation names the log row's commitment in place of the content digest, so a diff --git a/papers/2026-11-10-temporal-snapshot/paper.tex b/papers/2026-11-10-temporal-snapshot/paper.tex index 63ae68cf..a87ac922 100644 --- a/papers/2026-11-10-temporal-snapshot/paper.tex +++ b/papers/2026-11-10-temporal-snapshot/paper.tex @@ -395,13 +395,15 @@ \section{The design}\label{sec:design} present (\Cref{thm:compose}), so \texttt{as of "head"} is the sentence without the adjective. \paragraph{The horizon and retention.} -A chain's horizon is set by the genesis of its log, by retention, or by a reset. Retention is a -window per chain counted in positions. A pass appends a horizon row first and then drops, in -order, the derived rows of the versions closed under it, the raw objects nothing retained names, -and the log's rows, the digest at the horizon kept as the seed. Declaring the horizon first -means a crash leaves rows that are unserved, never a position that is served and incomplete. A -window counted per identity (the last $n$ versions of each) would leave no horizon, and -\Cref{thm:horizon} says such a store cannot tell what it lost. +A chain's horizon is set by the genesis of its log, by retention, or by a reset. Retention is +counted in positions and has two levels. The derived rows of old versions can be dropped without +moving a horizon: they are cache entries of a function of content, a cut that asks for one finds +it pending, and it is derived again from the raw object. Moving the horizon drops raw objects and +the log's rows, which only the store's owner declares. That pass appends a horizon row first, so +a crash leaves rows that are unserved, never a position that is served and incomplete, and it +keeps the digest at the horizon as the chain's seed. A window counted per identity (the last $n$ +versions of each) would leave no horizon, and \Cref{thm:horizon} says such a store cannot tell +what it lost. \section{Evaluation}\label{sec:eval} From a1d9651ec178591ae649cb938d6c9eca683fd6fc Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 01:59:05 -0500 Subject: [PATCH 13/37] docs(design): what a lazy plane's log and a reset leave, in the inventory Two facts read on main and missing from the inventory. Under lazy embedding the plane's supersession log is written by the drain, in the drain's order, and only for the versions still current when it runs, so it cannot stand in for the landing log. And a reset's targets do not include the lexical index or the relation edges, which outlast it with rows about items that are gone. Co-Authored-By: Claude Fable 5.2 --- docs/design-notes/dn-temporal-snapshot.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/design-notes/dn-temporal-snapshot.md b/docs/design-notes/dn-temporal-snapshot.md index 75c32b27..34ff4c06 100644 --- a/docs/design-notes/dn-temporal-snapshot.md +++ b/docs/design-notes/dn-temporal-snapshot.md @@ -180,7 +180,7 @@ The job queue, the task list and the telemetry are left out (§1.3). | store | clock | what names a position | what a rewrite loses today | |---|---|---|---| | plane occupancies (`core/stores/plane.py:268-278`) | none: `landed_at` is wall time | (path, digest, chunk) | which version was the head when: only `current` flips, and flips back when a path returns to bytes it held before (`plane.py:466-487`) | -| the plane's supersession log (`plane.py:282-289`) | `seq` per path | (path, seq) | a purge deletes entries and the next entry takes the position again (`plane.py:491-495`, `:552-553`) `[MEASURED §11]`; a reset drops it (`plane.py:628-640`); an instance with no plane has none; under lazy embedding it records the drain's order, not the landing's | +| the plane's supersession log (`plane.py:282-289`) | `seq` per path | (path, seq) | a purge deletes entries and the next entry takes the position again (`plane.py:491-495`, `:552-553`) `[MEASURED §11]`; a reset drops it (`plane.py:628-640`); an instance with no plane has none; under lazy embedding it is written by the drain, in the drain's order, and only for the versions still current then (`core/ingest/derive.py:85-118`) | | atoms (the vector table) | none: content-addressed (`plane.py:113-115`) | the atom's id | the `held` and `current` cache columns; the table's own dataset versions, one a write, which a compaction drops (`core/stores/vectorstore.py:780-812`) | | lexical units and postings (`core/stores/lexical.py:56-82`) | none: `landed_at` is wall time | (path, digest, chunk) | the head flag (`lexical.py:251-256`, `:260-265`); every unit, when the tokenizer changes (`lexical.py:180-194`) | | code memberships (`core/stores/memberships.py:140-155`) | git: (path, blob) | the version's identity | the head flag; a purge leaves a recorded hole (`memberships.py:153`, `:491-497`) | @@ -249,8 +249,9 @@ in §2.2 unless given]` derived from them (`ops/lifecycle/launcher.py:1748-1800`); the commit ledger and the observation history are guarded (`launcher.py:111-118`). The raw store is the first target listed (`launcher.py:1753`), while the comment beside the chat log's entry says it is not one - (`launcher.py:1779-1780`). Whatever the intent, no chain of an instance survives a reset with - its positions, so a reset opens a new history (§8). + (`launcher.py:1779-1780`). The lexical index and the relation edges are not among the targets, + so they outlast a reset with rows about items that are gone. Whatever the intent, no chain of + an instance survives a reset with its positions, so a reset opens a new history (§8). ## 3. The cut From 427c7d663af32be65479f134325f4ca997c948a9 Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 02:04:18 -0500 Subject: [PATCH 14/37] docs(design): why the head is its own cut read The note said that at the head the cut read is the head and cited the lemma, whose hypothesis is that the frontier is consistent. The head is: a store holds the sources of its own events. The sentence now says so. Co-Authored-By: Claude Fable 5.2 --- docs/design-notes/dn-temporal-snapshot.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/design-notes/dn-temporal-snapshot.md b/docs/design-notes/dn-temporal-snapshot.md index 34ff4c06..44f0286f 100644 --- a/docs/design-notes/dn-temporal-snapshot.md +++ b/docs/design-notes/dn-temporal-snapshot.md @@ -788,7 +788,8 @@ taken at the greatest consistent cut under the frontier asked every position of - It rises with what is served and with the frontier (`ResolvesIn.mono`): as the stages of §12 give stores a past, the cut read climbs toward the cut asked and never falls. - When every position is served it is the resolution of the frontier (`resolvesIn_univ`), and at - the head it is the head (`resolvesIn_self`). + the head, which is consistent because a store holds the sources of its own events, it is the + head (`resolvesIn_self`). The answer is then exact for the cut it names: every law of §10 holds at the cut read. What the answer says is that cut. It carries one note with the cut asked, the cut read on the chains the From e20666f09f14c5c415cb7ec465ea7d7140df56e5 Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 06:33:56 -0500 Subject: [PATCH 15/37] feat(formal): keyed holes, the unread chain, what a certificate pins The audit found five places where the snapshot's laws said less than the note claimed of them, or where the note's reading had no theorem. A purge that nulls a row's key makes a seek by key return a superseded version, or one from after the cut. The keyed read is now defined on a chain whose holes keep their keys (holes) and proved to return the key's last write at or under the cut, as a hole when that write is erased, on all three reads (stateAt_holes, genRead_gens_holes, lastWrite_holes). The served resolution is not a per-chain floor: a record on a chain that content reads drags every reader down (Witness.record_drags). The local lowering is proved for a chain that nothing else reads (resolvesIn_update_of_unread), and the cut read on a grant's chains is a function of them when they read no chain outside (ResolvesIn.eq_on_of_closed). A certificate over commitments attests no erasure and no seal (verifies_purge_iff, Witness.seal_not_certified); under a binding commitment it pins the events (Verifies.readAt_eq_of_committed, Verifies.contents_eq). The grant and the erasure applied to one read (shown) keep the laws of each. Closure of consistent cuts under meet and join is CLK-2's, so it is now derived from Clock.IsCut.frontier_inf and frontier_sup. Two law tags are aligned with the note, and the pruned store's control is proved in its stronger form (Witness.prune_indistinct). Co-Authored-By: Claude Fable 5.2 --- formal/Palace/Snapshot.lean | 470 ++++++++++++++++++++++++++++--- formal/Palace/Snapshot/Defs.lean | 19 +- 2 files changed, 452 insertions(+), 37 deletions(-) diff --git a/formal/Palace/Snapshot.lean b/formal/Palace/Snapshot.lean index 6001a4a0..06760883 100644 --- a/formal/Palace/Snapshot.lean +++ b/formal/Palace/Snapshot.lean @@ -43,6 +43,10 @@ a cut a prefix length for each. Cited from the note, not from the ledger. invariant (`snapshot_narrow`, `snapshot_congr`, `snapshot_grow`). Restricting to chains commutes with the cut; filtering events before the cut does not, and a cut's positions count the events a filter hides (`restrict_readAt`, `Witness.filter_before_cut`, `Witness.position_channel`). + The grant and the erasure applied to one read keep these laws (`shown_narrow`, `shown_grow`, + `not_erased_of_mem_shown`). The cut read on the chains a grant names is a function of those + chains when they read from no chain outside them (`ResolvesIn.eq_on_of_closed`); the control + is a named chain that reads an unnamed one (`Witness.resolution_reads_unnamed`). * SNP-7, erasure dominance: no erased event is visible at any cut, a larger erasure shows a sublist, the store with holes keeps every position, and two stores that differ only in erased events give every derived view the same reading at every cut (`not_erased_of_mem_visible`, @@ -53,19 +57,31 @@ a cut a prefix length for each. Cited from the note, not from the ledger. seal, under which a key is withheld only while it is not live, serves everything the stricter one serves and is lifted by a later landing (`servedNow_of_servedAt`, `Witness.servedNow_restores`). The control is the erasure that deletes rows - (`Witness.compact_moves`). -* SNP-8, consistent cuts: closed under meet and join, so a sublattice of the cuts - (`Consistent.inf`, `Consistent.sup`, `consistentCuts`); they are the clock's cuts, CLK-2, among - the frontier cuts (`consistent_iff_isCut`); every frontier resolves to exactly one greatest - consistent cut under it, monotonically (`exists_resolves`, `Resolves.unique`, `Resolves.mono`); - and a consistent cut stays consistent as the store grows (`Consistent.of_grown`). + (`Witness.compact_moves`). For a keyed chain whose holes keep their keys, the read of a key at + a cut is its last write at or under the cut, a hole when that write is erased, and the three + reads agree on it (`stateAt_holes`, `stateAt_holes_of_erased`, `not_erased_of_stateAt_holes`, + `genRead_gens_holes`, `lastWrite_holes`); the control is the hole that loses its key, which + returns a superseded version or one from after the cut (`Witness.keyless_hole`). +* SNP-8, resolution: the consistent cuts are the clock's cuts, CLK-2, among the frontier cuts + (`consistent_iff_isCut`), so their closure under meet and join is CLK-2's, read through that + equivalence (`Consistent.inf`, `Consistent.sup`, `consistentCuts`). What this law adds is + resolution: every frontier resolves to exactly one greatest consistent cut under it, + monotonically (`exists_resolves`, `Resolves.unique`, `Resolves.mono`); a consistent cut stays + consistent as the store grows (`Consistent.of_grown`); and a cut consistent for a recorded + bound on the references is consistent for the true ones (`Consistent.of_bound`). * SNP-9, certified cuts: the certificate of a cut verifies on every extension of the store, two stores that verify one certificate under a collision-free digest have the same read at its cut and so the same derived views, a certificate extends over the events since an earlier one, the meet and the join of two certified cuts are certified from the two certificates alone, and an erasure that keeps commitments keeps every certificate (`verifies_certify_of_extends`, `Verifies.readAt_eq`, `Verifies.view_eq`, `certify_digest_readBetween`, `certify_inf`, - `certify_sup`, `verifies_purge`). + `certify_sup`, `verifies_purge`). A certificate over commitments attests no erasure + (`verifies_purge_iff`); under a binding commitment it pins the events, so two stores that + verify it read the same store with holes under one erasure + (`Verifies.readAt_eq_of_committed`, `Verifies.contents_eq`, `contents_purge_committed`, + `Verifies.shown_eq`). The controls: a digest with collisions (`Witness.digest_collides`), a + seal written after the cut (`Witness.seal_not_certified`), a renamed chain + (`Witness.rename_breaks_certificate`). * SNP-10, the horizon: a generational store that drops the rows closed at or under a horizon reads, at every cut from the horizon on, the state recomputed from the whole prefix; under the horizon it is never wrong and reads what it lost as absent; horizons compose to the later one @@ -73,8 +89,13 @@ a cut a prefix length for each. Cited from the note, not from the ledger. chains serve only some positions, every frontier resolves to exactly one greatest consistent cut among them, which rises with what is served and never passes the cut asked (`exists_resolvesIn`, `ResolvesIn.unique`, `ResolvesIn.mono`, `ResolvesIn.le_resolves`, - `resolvesIn_univ`). The control is the pruned store read under its horizon - (`Witness.prune_forgets`). + `resolvesIn_univ`). A chain that no other chain reads is lowered alone, every other chain + read as asked (`Consistent.update_of_unread`, `resolvesIn_update_of_unread`), and retention + commutes with growth (`prune_landGen`). The controls: the pruned store read under its horizon, + which cannot tell a lost key from one never written (`Witness.prune_forgets`, + `Witness.prune_indistinct`); a record on a chain that content reads, which drags every reader + down (`Witness.record_drags`); served sets that shrink, under which the cut read falls + (`Witness.served_set_shrinks`). -/ @[expose] public section @@ -580,6 +601,21 @@ theorem prune_prune (h h' : ℕ) (rs : List (Gen κ β)) : | none => rfl | some d => simp [max_lt_iff] +/-- SNP-10 Retention commutes with growth: a store pruned at a horizon and then landed on, past +the horizon, is the landed store pruned at the horizon. -/ +theorem prune_landGen {h p : ℕ} (hp : h < p) (rs : List (Gen κ β)) (e : κ × β) : + prune h (landGen rs p e) = landGen (prune h rs) p e := by + have hq : (fun r : Gen κ β ↦ r.died.all fun d ↦ decide (h < d)) ∘ closeAt e.1 p + = fun r ↦ r.died.all fun d ↦ decide (h < d) := by + funext r + simp only [Function.comp_apply, closeAt] + split_ifs with hr + · simp [hr.2, hp] + · rfl + unfold landGen prune + rw [List.filter_append, List.filter_map, hq] + simp + /-- SNP-4 At the head cut nothing is sealed: a chain of landings and retires serves what the store rewritten in place holds live. -/ theorem servedAt_length (l : List (κ × Option β)) (x : κ) : @@ -609,8 +645,8 @@ theorem servedAt_append_of_retire {l t : List (κ × Option β)} {c : ℕ} {x : exact Or.inr (List.any_eq_true.2 ⟨(x, none), h, by simp⟩) simp only [servedAt, hs, ↓reduceIte] -/-- SNP-1 under the seal: growth that does not retire the key changes nothing served of it at -a cut inside the chain. -/ +/-- SNP-7 Append invariance under the seal: growth that does not retire the key changes nothing +served of it at a cut inside the chain. -/ theorem servedAt_append_of_no_retire {l t : List (κ × Option β)} {c : ℕ} {x : κ} (hc : c ≤ l.length) (h : (x, none) ∉ t) : servedAt (l ++ t) c x = servedAt l c x := by have ht : (t.any fun e ↦ decide (e.1 = x) && e.2.isNone) = false := by @@ -683,6 +719,72 @@ theorem servedNow_of_servedAt {l : List (κ × Option β)} {c : ℕ} {x : κ} {v | some w => rfl simp only [servedNow, hnot, Bool.false_eq_true, ↓reduceIte, hstate, Option.join_some] +omit [DecidableEq κ] in +theorem holes_append (E : κ × β → Bool) (l t : List (κ × β)) : + holes E (l ++ t) = holes E l ++ holes E t := + List.map_append + +/-- The store rewritten in place, with holes: each key's last write, erased or not. -/ +theorem stateOf_holes (E : κ × β → Bool) (l : List (κ × β)) (x : κ) : + stateOf (holes E l) x = (stateOf l x).map fun v ↦ if E (x, v) then none else some v := by + induction l using List.reverseRecOn with + | nil => rfl + | append_singleton l e ih => + rw [holes_append] + change stateOf (holes E l ++ [(e.1, if E e then none else some e.2)]) x = _ + rw [stateOf_append_singleton, stateOf_append_singleton] + by_cases hx : e.1 = x + · subst hx + simp + · rw [Function.update_of_ne (Ne.symm hx), Function.update_of_ne (Ne.symm hx)] + exact ih + +/-- SNP-7 The keyed read under an erasure: on a chain whose holes keep their keys, the read of +a key at a cut is its last write at or under the cut, as a hole when that write is erased. It is +never an earlier write of the key and never a later one. -/ +theorem stateAt_holes (E : κ × β → Bool) (l : List (κ × β)) (c : ℕ) (x : κ) : + stateAt (holes E l) c x = (stateAt l c x).map fun v ↦ if E (x, v) then none else some v := by + unfold stateAt + rw [holes, ← List.map_take] + exact stateOf_holes E _ x + +/-- SNP-7 A key whose head at the cut is erased reads as erased at that cut. -/ +theorem stateAt_holes_of_erased {E : κ × β → Bool} {l : List (κ × β)} {c : ℕ} {x : κ} {v : β} + (h : stateAt l c x = some v) (hE : E (x, v) = true) : + stateAt (holes E l) c x = some none := by + rw [stateAt_holes, h, Option.map_some, hE] + rfl + +/-- SNP-7 No keyed read at any cut returns an erased value. -/ +theorem not_erased_of_stateAt_holes {E : κ × β → Bool} {l : List (κ × β)} {c : ℕ} {x : κ} + {v : β} (h : stateAt (holes E l) c x = some (some v)) : + stateAt l c x = some v ∧ E (x, v) = false := by + rw [stateAt_holes] at h + cases hs : stateAt l c x with + | none => rw [hs] at h; exact absurd h (by simp) + | some w => + rw [hs, Option.map_some] at h + cases hE : E (x, w) + · rw [hE] at h + simp only [Bool.false_eq_true, ↓reduceIte, Option.some.injEq] at h + exact ⟨by rw [h], by rw [← h]; exact hE⟩ + · rw [hE] at h + simp at h + +/-- SNP-7 The three reads agree on a chain with holes: the generational store of the chain with +holes, read at a cut, is the keyed read under the erasure. -/ +theorem genRead_gens_holes (E : κ × β → Bool) (l : List (κ × β)) (c : ℕ) (x : κ) : + genRead (gens (holes E l)) c x + = (stateAt l c x).map fun v ↦ if E (x, v) then none else some v := by + rw [genRead_gens, stateAt_holes] + +/-- SNP-7 And so is the seek by key: the last row of the key at or under the cut, hole or +not. -/ +theorem lastWrite_holes (E : κ × β → Bool) (l : List (κ × β)) (c : ℕ) (x : κ) : + lastWrite (holes E l) c x + = (stateAt l c x).map fun v ↦ if E (x, v) then none else some v := by + rw [← stateAt_eq_lastWrite, stateAt_holes] + end Generations /-! ### SNP-6 The grant -/ @@ -746,6 +848,41 @@ theorem restrict_readAt (G : K → Prop) [DecidablePred G] (s : Store K α) (c : funext k by_cases h : G k <;> simp [restrict, readAt, h] +/-- SNP-1 for the composite reader: what an asker is shown at a cut inside the store is the +same after any growth. -/ +theorem shown_grow (G : K → Prop) [DecidablePred G] (p E : α → Bool) {s : Store K α} + (t : Store K α) {c : Cut K} (h : c ≤ head s) : + shown G p E (grow s t) c = shown G p E s c := + snapshot_grow G _ t h + +/-- SNP-7 for the composite reader: no erased event is shown at any cut, under any grant. -/ +theorem not_erased_of_mem_shown {G : K → Prop} [DecidablePred G] {p E : α → Bool} + {s : Store K α} {c : Cut K} {k : K} {a : α} (h : a ∈ shown G p E s c k) : E a = false := by + unfold shown snapshot restrict at h + split_ifs at h + · exact (by simpa using (List.mem_filter.1 h).2 : p a = true ∧ E a = false).2 + · simp at h + +/-- SNP-6 for the composite reader: under a narrower grant and a larger erasure, what is shown +is the restriction of what the wider grant is shown under the smaller erasure. -/ +theorem shown_narrow {G G' : K → Prop} [DecidablePred G] [DecidablePred G'] + {p p' E E' : α → Bool} (hG : ∀ k, G k → G' k) (hp : ∀ a, p a = true → p' a = true) + (hE : ∀ a, E' a = true → E a = true) (s : Store K α) (c : Cut K) : + shown G p E s c = restrict G (fun a ↦ p a && !E a) (shown G' p' E' s c) := + snapshot_narrow hG (fun a ha ↦ by + rw [Bool.and_eq_true] at ha ⊢ + refine ⟨hp a ha.1, ?_⟩ + cases h : E' a + · rfl + · have := hE a h + simp [this] at ha) s c + +/-- SNP-4 for the composite reader: at the head cut it is the grant's restriction of the store +without the erased events. -/ +theorem shown_head (G : K → Prop) [DecidablePred G] (p E : α → Bool) (s : Store K α) : + shown G p E s (head s) = restrict G (fun a ↦ p a && !E a) s := + snapshot_head G _ s + end Grant /-! ### SNP-7 The erasure -/ @@ -842,7 +979,7 @@ theorem commitments_purge (E : α → Bool) (t : Store K (C × Option α)) : funext k simp [commitments, purge, Function.comp_def] -/-- SNP-7 What a reader reads of a committed store after an erasure is the store with holes. -/ +/-- SNP-9 What a reader reads of a committed store after an erasure is the store with holes. -/ theorem contents_purge_committed (commit : α → C) (E : α → Bool) (s : Store K α) : contents (purge E (committed commit s)) = redact E s := by funext k @@ -861,26 +998,6 @@ variable {K : Type*} {R : K → ℕ → K → ℕ → Prop} /-- The empty cut is consistent. -/ theorem consistent_zero : Consistent R fun _ ↦ 0 := fun _ _ _ _ _ h ↦ absurd h (Nat.not_lt_zero _) -/-- SNP-8 Consistent cuts are closed under the meet. -/ -theorem Consistent.inf {c d : Cut K} (hc : Consistent R c) (hd : Consistent R d) : - Consistent R (c ⊓ d) := fun k i k' j h hi ↦ by - have hi' : i < c k ∧ i < d k := lt_inf_iff.1 hi - exact lt_inf_iff.2 ⟨hc k i k' j h hi'.1, hd k i k' j h hi'.2⟩ - -/-- SNP-8 And under the join. -/ -theorem Consistent.sup {c d : Cut K} (hc : Consistent R c) (hd : Consistent R d) : - Consistent R (c ⊔ d) := fun k i k' j h hi ↦ by - have hi' : i < c k ∨ i < d k := lt_sup_iff.1 hi - rcases hi' with hi' | hi' - · exact lt_sup_iff.2 (Or.inl (hc k i k' j h hi')) - · exact lt_sup_iff.2 (Or.inr (hd k i k' j h hi')) - -/-- SNP-8 The consistent cuts are a sublattice of the cuts, so a distributive lattice. -/ -def consistentCuts (R : K → ℕ → K → ℕ → Prop) : Sublattice (Cut K) where - carrier := {c | Consistent R c} - supClosed' := fun _ hc _ hd ↦ Consistent.sup hc hd - infClosed' := fun _ hc _ hd ↦ Consistent.inf hc hd - /-- SNP-8 The consistent cuts are the clock's cuts (CLK-2) among the frontier cuts: a cut is consistent exactly when the events under its frontier are a down-set of the order the append chains and the reads-from references generate. -/ @@ -900,6 +1017,29 @@ theorem consistent_iff_isCut (R : K → ℕ → K → ℕ → Prop) (c : Cut K) by_contra hj exact h ⟨(k', j), (k, i), Or.inr hR, hi, hj⟩ +/-- Closure under the meet is CLK-2's: the frontier cut of a pointwise minimum is the +intersection of the two cuts (`Clock.IsCut.frontier_inf`), read here through +`consistent_iff_isCut`. -/ +theorem Consistent.inf {c d : Cut K} (hc : Consistent R c) (hd : Consistent R d) : + Consistent R (c ⊓ d) := + (consistent_iff_isCut R _).2 + (Clock.IsCut.frontier_inf Prod.fst Prod.snd ((consistent_iff_isCut R c).1 hc) + ((consistent_iff_isCut R d).1 hd)) + +/-- And under the join, CLK-2's again (`Clock.IsCut.frontier_sup`). -/ +theorem Consistent.sup {c d : Cut K} (hc : Consistent R c) (hd : Consistent R d) : + Consistent R (c ⊔ d) := + (consistent_iff_isCut R _).2 + (Clock.IsCut.frontier_sup Prod.fst Prod.snd ((consistent_iff_isCut R c).1 hc) + ((consistent_iff_isCut R d).1 hd)) + +/-- The consistent cuts as a sublattice of the cuts, so a distributive lattice: CLK-2's +closure, packaged. -/ +def consistentCuts (R : K → ℕ → K → ℕ → Prop) : Sublattice (Cut K) where + carrier := {c | Consistent R c} + supClosed' := fun _ hc _ hd ↦ Consistent.sup hc hd + infClosed' := fun _ hc _ hd ↦ Consistent.inf hc hd + /-- A frontier resolves to at most one cut. -/ theorem Resolves.unique {f c c' : Cut K} (h : Resolves R f c) (h' : Resolves R f c') : c = c' := le_antisymm (h'.2.2 c h.1 h.2.1) (h.2.2 c' h'.1 h'.2.1) @@ -993,6 +1133,109 @@ theorem resolvesIn_self {S : K → Set ℕ} {f : Cut K} (h : Consistent R f) (hS : ∀ k, f k ∈ S k) : ResolvesIn R S f f := ⟨h, hS, le_rfl, fun _ _ _ hd ↦ hd⟩ +/-- SNP-8 A recorded bound is sound: when every true source of an event lies at or under a +recorded one on its chain, a cut consistent for the recorded references is consistent for the +true ones. So a resolver may work from the head a row recorded at its writing. -/ +theorem Consistent.of_bound {R' : K → ℕ → K → ℕ → Prop} + (hb : ∀ k i k' j, R k i k' j → ∃ j', j ≤ j' ∧ R' k i k' j') {c : Cut K} + (h : Consistent R' c) : Consistent R c := fun k i k' j hr hi ↦ by + obtain ⟨j', hj, hr'⟩ := hb k i k' j hr + exact lt_of_le_of_lt hj (h k i k' j' hr' hi) + +/-- SNP-10 A chain that no other chain reads can be lowered alone: a consistent cut stays +consistent when its position on such a chain is lowered, the chain's own references pointing +backward. -/ +theorem Consistent.update_of_unread [DecidableEq K] {c : Cut K} {x : K} {p : ℕ} + (hc : Consistent R c) (hp : p ≤ c x) (hx : ∀ k i j, R k i x j → k = x ∧ j ≤ i) : + Consistent R (Function.update c x p) := fun k i k' j hr hi ↦ by + have hik : i < c k := by + by_cases hk : k = x + · subst hk + rw [Function.update_self] at hi + exact lt_of_lt_of_le hi hp + · rwa [Function.update_of_ne hk] at hi + by_cases hk' : k' = x + · subst hk' + obtain ⟨rfl, hji⟩ := hx k i j hr + rw [Function.update_self] at hi ⊢ + exact lt_of_le_of_lt hji hi + · rw [Function.update_of_ne hk'] + exact hc k i k' j hr hik + +/-- SNP-10 The local lowering: when the cut asked is consistent and every chain but one serves +its position, and no other chain reads that one, the cut read is the cut asked with that chain +at the greatest position it serves at or under the one asked. Every other chain is read as +asked. The control is a chain that others read (`Witness.record_drags`). -/ +theorem resolvesIn_update_of_unread [DecidableEq K] {S : K → Set ℕ} {f : Cut K} {x : K} {p : ℕ} + (hf : Consistent R f) (hS : ∀ k, k ≠ x → f k ∈ S k) + (hx : ∀ k i j, R k i x j → k = x ∧ j ≤ i) (hp : p ∈ S x) (hpf : p ≤ f x) + (hmax : ∀ q ∈ S x, q ≤ f x → q ≤ p) : ResolvesIn R S f (Function.update f x p) := by + refine ⟨hf.update_of_unread hpf hx, fun k ↦ ?_, fun k ↦ ?_, fun d _ hdS hdf k ↦ ?_⟩ + · by_cases hk : k = x + · subst hk + rwa [Function.update_self] + · rw [Function.update_of_ne hk] + exact hS k hk + · by_cases hk : k = x + · subst hk + rwa [Function.update_self] + · rw [Function.update_of_ne hk] + · by_cases hk : k = x + · subst hk + rw [Function.update_self] + exact hmax _ (hdS k) (hdf k) + · rw [Function.update_of_ne hk] + exact hdf k + +theorem ResolvesIn.le_on_of_closed {R' : K → ℕ → K → ℕ → Prop} {S S' : K → Set ℕ} + {f f' c c' : Cut K} (G : K → Prop) + (hclosed : ∀ k i k' j, G k → R' k i k' j → G k') + (hR : ∀ k i k' j, G k → R' k i k' j → R k i k' j) (hS : ∀ k, G k → S k ⊆ S' k) + (h0 : ∀ k, 0 ∈ S' k) (hf : ∀ k, G k → f k ≤ f' k) (h : ResolvesIn R S f c) + (h' : ResolvesIn R' S' f' c') : ∀ k, G k → c k ≤ c' k := by + classical + have hcons : Consistent R' fun k ↦ if G k then c k else 0 := by + intro k i k' j hr hi + by_cases hk : G k + · have hk' := hclosed k i k' j hk hr + simp only [hk, ↓reduceIte] at hi + simp only [hk', ↓reduceIte] + exact h.1 k i k' j (hR k i k' j hk hr) hi + · simp [hk] at hi + have hserved : ∀ k, (if G k then c k else 0) ∈ S' k := by + intro k + by_cases hk : G k + · simp only [hk, ↓reduceIte] + exact hS k hk (h.2.1 k) + · simp only [hk, ↓reduceIte] + exact h0 k + have hle : (fun k ↦ if G k then c k else 0) ≤ f' := by + intro k + by_cases hk : G k + · simp only [hk, ↓reduceIte] + exact (h.2.2.1 k).trans (hf k hk) + · simp only [hk, ↓reduceIte] + exact Nat.zero_le _ + intro k hk + simpa [hk] using h'.2.2.2 _ hcons hserved hle k + +/-- SNP-6 The cut read on the chains a grant names is a function of those chains when they +read from no chain outside them: two stores of references, served positions and frontiers that +agree on such a set of chains resolve to cuts that agree on it. The control is a named chain +that reads an unnamed one (`Witness.resolution_reads_unnamed`). -/ +theorem ResolvesIn.eq_on_of_closed {R' : K → ℕ → K → ℕ → Prop} {S S' : K → Set ℕ} + {f f' c c' : Cut K} (G : K → Prop) + (hclosed : ∀ k i k' j, G k → R k i k' j → G k') + (hR : ∀ k i k' j, G k → (R k i k' j ↔ R' k i k' j)) (hS : ∀ k, G k → S k = S' k) + (h0 : ∀ k, 0 ∈ S k) (h0' : ∀ k, 0 ∈ S' k) (hf : ∀ k, G k → f k = f' k) + (h : ResolvesIn R S f c) (h' : ResolvesIn R' S' f' c') : ∀ k, G k → c k = c' k := + fun k hk ↦ le_antisymm + (h.le_on_of_closed G (fun a i b j ha hr ↦ hclosed a i b j ha ((hR a i b j ha).2 hr)) + (fun a i b j ha hr ↦ (hR a i b j ha).2 hr) (fun a ha ↦ (hS a ha).subset) h0' + (fun a ha ↦ (hf a ha).le) h' k hk) + (h'.le_on_of_closed G hclosed (fun a i b j ha hr ↦ (hR a i b j ha).1 hr) + (fun a ha ↦ (hS a ha).superset) h0 (fun a ha ↦ (hf a ha).ge) h k hk) + end Consistency /-! ### SNP-9 Certified cuts -/ @@ -1088,6 +1331,51 @@ theorem verifies_purge {step : H → C → H} {z : Certificate K H} {t : Store K Verifies step h₀ z (commitments (purge E t)) := by rwa [commitments_purge] +/-- SNP-9 And only the commitments: a store verifies a certificate after an erasure exactly +when it did before, so a certificate attests no erasure. A copy taken before a purge verifies +every certificate the purged store verifies. -/ +theorem verifies_purge_iff {step : H → C → H} {z : Certificate K H} + {t : Store K (C × Option α)} (E : α → Bool) : + Verifies step h₀ z (commitments (purge E t)) ↔ Verifies step h₀ z (commitments t) := by + rw [commitments_purge] + +/-- SNP-9 Under a binding commitment a certificate over commitments pins the events: two +committed stores that verify one certificate, each after an erasure of its own, were made from +the same events at its cut. -/ +theorem Verifies.readAt_eq_of_committed {step : H → C → H} (hstep : CollisionFree step) + {commit : α → C} (hcommit : Function.Injective commit) {z : Certificate K H} + {s s' : Store K α} (E E' : α → Bool) + (h : Verifies step h₀ z (commitments (purge E (committed commit s)))) + (h' : Verifies step h₀ z (commitments (purge E' (committed commit s')))) : + readAt s z.cut = readAt s' z.cut := by + rw [commitments_purge] at h h' + funext k + have hk := congrFun (h.readAt_eq hstep h') k + simp only [readAt, commitments, committed, List.map_map] at hk + have hfun : (Prod.fst ∘ fun a : α ↦ (commit a, some a)) = commit := rfl + rw [hfun, ← List.map_take, ← List.map_take] at hk + exact List.map_injective_iff.2 hcommit hk + +/-- SNP-9 So what is read at a certified cut is pinned up to the erasure: two committed stores +that verify one certificate read, at its cut and under one erasure, the same store with holes. -/ +theorem Verifies.contents_eq {step : H → C → H} (hstep : CollisionFree step) + {commit : α → C} (hcommit : Function.Injective commit) (E : α → Bool) + {z : Certificate K H} {s s' : Store K α} + (h : Verifies step h₀ z (commitments (purge E (committed commit s)))) + (h' : Verifies step h₀ z (commitments (purge E (committed commit s')))) : + readAt (contents (purge E (committed commit s))) z.cut + = readAt (contents (purge E (committed commit s'))) z.cut := by + rw [contents_purge_committed, contents_purge_committed, redact_readAt, redact_readAt, + Verifies.readAt_eq_of_committed hstep hcommit E E h h'] + +/-- SNP-9 for the composite reader: two stores that verify one certificate show the same at +its cut under one grant and one erasure. The grant and the erasure are not in the certificate. -/ +theorem Verifies.shown_eq (hstep : CollisionFree step) (G : K → Prop) [DecidablePred G] + (p E : α → Bool) {z : Certificate K H} {s s' : Store K α} (h : Verifies step h₀ z s) + (h' : Verifies step h₀ z s') : shown G p E s z.cut = shown G p E s' z.cut := by + unfold shown snapshot + rw [h.readAt_eq hstep h'] + end Certified namespace Witness @@ -1150,8 +1438,7 @@ theorem servedNow_restores : simp [servedNow, stateAt, stateOf] /-- The control for SNP-10: under the horizon the pruned store reads a key as absent where it -held a value, and nothing in the rows that remain says which. So the horizon is recorded, and a -cut under it is not served. -/ +held a value. So the horizon is recorded, and a cut under it is not served. -/ theorem prune_forgets : ∃ (l : List (Unit × ℕ)) (h c : ℕ), c < h ∧ genRead (prune h (gens l)) c () = none ∧ stateAt l c () = some 0 := by @@ -1166,6 +1453,121 @@ theorem digest_collides : chainDigest (· + ·) 0 l = chainDigest (· + ·) 0 l' ∧ l ≠ l' := ⟨[1, 2], [2, 1], rfl, rfl, by decide⟩ +/-- The control for SNP-10, in its stronger form: nothing in the rows that remain tells a lost +key from a key that was never there. Two chains have the same pruned store, and at one cut under +the horizon a key held a value in the first and had never been written in the second. -/ +theorem prune_indistinct : + ∃ (l l' : List (ℕ × ℕ)) (h c : ℕ), c < h ∧ + (prune h (gens l)).map (fun r ↦ (r.key, r.val, r.born, r.died)) + = (prune h (gens l')).map (fun r ↦ (r.key, r.val, r.born, r.died)) ∧ + stateAt l c 1 = some 0 ∧ stateAt l' c 1 = none := + ⟨[(0, 0), (1, 0), (0, 1), (1, 1)], [(0, 0), (0, 2), (0, 1), (1, 1)], 4, 2, by decide, + by decide, by decide, by decide⟩ + +/-- The control for SNP-7's keyed read: a hole that loses its key. Path `()` lands versions 1, +2 and 3 and version 2 is erased. With the key kept, the read at cut 2 is a hole. A seek over the +rows of the prefix that still carry the key returns version 1, which was superseded at the cut; +a seek over the chain with the holes deleted returns version 3, which landed after it. -/ +theorem keyless_hole : + ∃ (l : List (Unit × ℕ)) (E : Unit × ℕ → Bool) (c : ℕ), + stateAt (holes E l) c () = some none ∧ + stateOf ((l.take c).filter fun e ↦ !E e) () = some 1 ∧ + lastWrite (l.filter fun e ↦ !E e) c () = some 3 := + ⟨[((), 1), ((), 2), ((), 3)], fun e ↦ e.2 == 2, 2, by decide, by decide, by decide⟩ + +/-- The control for SNP-9: a certificate attests no seal. A chain and its growth by a retire +verify the certificate of one cut, under every digest, and serve different things at it. -/ +theorem seal_not_certified : + ∃ (l t : List (Unit × Option ℕ)) (c : ℕ), + (∀ (step : ℕ → Unit × Option ℕ → ℕ) (h₀ : ℕ), + Verifies step h₀ (certify step h₀ (fun _ : Unit ↦ l) fun _ ↦ c) fun _ ↦ l ++ t) ∧ + servedAt l c () = some 5 ∧ servedAt (l ++ t) c () = none := by + refine ⟨[((), some 5)], [((), none)], 1, fun step h₀ ↦ ?_, by decide, by decide⟩ + exact verifies_certify_of_extends (extends_grow (fun _ ↦ [((), some 5)]) fun _ ↦ [((), none)]) + fun _ ↦ le_rfl + +/-- The control for SNP-9's fixed chain keys: a renamed chain is not an extension. The +certificate of a cut does not verify on the store with its two chains exchanged, under any +digest, so a chain is keyed by an id that a relabel does not change. -/ +theorem rename_breaks_certificate : + ∃ (s s' : Store Bool ℕ) (c : Cut Bool), c ≤ head s ∧ (∀ k, s' k = s (!k)) ∧ + ∀ (step : ℕ → ℕ → ℕ) (h₀ : ℕ), ¬Verifies step h₀ (certify step h₀ s c) s' := by + refine ⟨fun k ↦ if k then [7] else [], fun k ↦ if k then [] else [7], + fun k ↦ if k then 1 else 0, fun k ↦ ?_, fun k ↦ ?_, ?_⟩ + · cases k <;> simp [head] + · cases k <;> rfl + · rintro step h₀ ⟨h, -⟩ + have := h true + simp [certify, head] at this + +/-- The control for SNP-10's local lowering: a record on a chain that content reads. Chain 0 is +a landing log, chain 1 the attestations, chain 2 a chain `X`. The first attestation is a recorded +cut that certifies the first event of `X`; the landing reads its own attestation, the second. +The frontier asked is consistent, and the landing log and the attestations serve every position. +`X` serves its empty prefix and the positions from 2 on. Then every cut the frontier resolves to +among the served positions reads the landing log and the attestations at their empty prefixes: +one chain read low drags down every chain that reads the chain the record sits on. -/ +theorem record_drags : + ∃ (R : ℕ → ℕ → ℕ → ℕ → Prop) (S : ℕ → Set ℕ) (f : Cut ℕ), + Consistent R f ∧ (∀ k, k ≠ 2 → S k = Set.univ) ∧ + ∀ c, ResolvesIn R S f c → c 0 = 0 ∧ c 1 = 0 := by + refine ⟨fun k i k' j ↦ (k = 1 ∧ i = 0 ∧ k' = 2 ∧ j = 0) ∨ (k = 0 ∧ i = 0 ∧ k' = 1 ∧ j = 1), + fun k ↦ if k = 2 then {p | p = 0 ∨ 2 ≤ p} else Set.univ, + fun k ↦ if k = 0 then 1 else if k = 1 then 2 else 1, ?_, fun k hk ↦ by simp [hk], ?_⟩ + · rintro k i k' j (⟨rfl, rfl, rfl, rfl⟩ | ⟨rfl, rfl, rfl, rfl⟩) _ <;> decide + · rintro c ⟨hc, hS, hcf, -⟩ + have hX : c 2 = 0 := by + have h2 : c 2 = 0 ∨ 2 ≤ c 2 := by simpa using hS 2 + have h1 : c 2 ≤ 1 := by simpa using hcf 2 + omega + have hatt : c 1 = 0 := by + by_contra h + have := hc 1 0 2 0 (Or.inl ⟨rfl, rfl, rfl, rfl⟩) (Nat.pos_of_ne_zero h) + omega + have hland : c 0 = 0 := by + by_contra h + have := hc 0 0 1 1 (Or.inr ⟨rfl, rfl, rfl, rfl⟩) (Nat.pos_of_ne_zero h) + omega + exact ⟨hland, hatt⟩ + +/-- The control for SNP-6's closed set of chains: the cut read on a chain a grant names depends +on what a chain it reads serves. One relation and one frontier, served positions that agree on +the named chain, and two different cuts read on it. -/ +theorem resolution_reads_unnamed : + ∃ (R : Bool → ℕ → Bool → ℕ → Prop) (S S' : Bool → Set ℕ) (f c c' : Cut Bool), + S true = S' true ∧ ResolvesIn R S f c ∧ ResolvesIn R S' f c' ∧ c true ≠ c' true := by + refine ⟨fun k i k' j ↦ k = true ∧ i = 0 ∧ k' = false ∧ j = 0, fun _ ↦ Set.univ, + fun k ↦ if k then Set.univ else {0}, fun _ ↦ 1, fun _ ↦ 1, fun _ ↦ 0, by simp, ?_, ?_, + by simp⟩ + · refine resolvesIn_self (fun k i k' j h _ ↦ ?_) fun _ ↦ Set.mem_univ _ + obtain ⟨-, -, -, rfl⟩ := h + exact Nat.one_pos + · refine ⟨consistent_zero, fun k ↦ ?_, fun _ ↦ Nat.zero_le _, fun d hd hS _ k ↦ ?_⟩ + · cases k <;> simp + · have h0 : d false = 0 := by simpa using hS false + have h1 : d true = 0 := by + by_contra h + have := hd true 0 false 0 ⟨rfl, rfl, rfl, rfl⟩ (Nat.pos_of_ne_zero h) + omega + cases k + · exact h0.le + · exact h1.le + +/-- The control for SNP-10's monotonicity: it needs the served sets to grow. A store that keeps +no past serves its empty prefix and its head, and loses its old head when it grows. Asked at 5 +while the head is 5 the cut read is 5; asked again at 5 after the head moved to 7 it is 0. -/ +theorem served_set_shrinks : + ∃ (S S' : Unit → Set ℕ) (f : Cut Unit), + ResolvesIn (fun _ _ _ _ ↦ False) S f f ∧ + ResolvesIn (fun _ _ _ _ ↦ False) S' f fun _ ↦ 0 := by + refine ⟨fun _ ↦ {0, 5}, fun _ ↦ {0, 7}, fun _ ↦ 5, ?_, ?_⟩ + · exact resolvesIn_self (fun _ _ _ _ h ↦ h.elim) fun _ ↦ by simp + · refine ⟨consistent_zero, fun _ ↦ by simp, fun _ ↦ Nat.zero_le _, fun d _ hS hdf u ↦ ?_⟩ + have h1 : d u = 0 ∨ d u = 7 := by simpa using hS u + have h2 : d u ≤ 5 := hdf u + change d u ≤ 0 + omega + end Witness end Palace.Snapshot diff --git a/formal/Palace/Snapshot/Defs.lean b/formal/Palace/Snapshot/Defs.lean index 64315ab9..ce8ee978 100644 --- a/formal/Palace/Snapshot/Defs.lean +++ b/formal/Palace/Snapshot/Defs.lean @@ -27,9 +27,10 @@ the store serves the cuts from the horizon on. Two things are parameters of a read and no function of the cut, because they are the present's: the asker's **grant** (`snapshot`: the chains it names and the events it may see named) and the **erasure** (`visible`: the erased events masked; `redact`: the store with a hole at each, every -position kept; `servedAt`: a key retired after the cut is served at no earlier cut, with -`servedNow` the looser seal that a later landing lifts). The control for the erasure is -`compact`, an erasure that deletes rows and lets the later ones move up. +position kept; `holes`: the same for a keyed chain, the hole keeping its key; `shown`: the grant +and the erasure applied to one read; `servedAt`: a key retired after the cut is served at no +earlier cut, with `servedNow` the looser seal that a later landing lifts). The control for the +erasure is `compact`, an erasure that deletes rows and lets the later ones move up. Events may read from events of other chains (`R k i k' j`: the `i`-th event of chain `k` reads from the `j`-th of chain `k'`); a cut is **consistent** when every source of an event inside it is @@ -187,6 +188,12 @@ a key landed again after its retire is served again at the cuts before the retir def servedNow [DecidableEq κ] (l : List (κ × Option β)) (c : ℕ) (x : κ) : Option β := if ((stateOf l x).join).isNone then none else (stateAt l c x).join +/-- A keyed chain with a hole at each erased write: the hole keeps the write's key and its +position and loses its value, so it still shadows the key's earlier writes. The alternative, a +hole that loses its key too, is the control (`Witness.keyless_hole`). -/ +def holes (E : κ × β → Bool) (l : List (κ × β)) : List (κ × Option β) := + l.map fun e ↦ (e.1, if E e then none else some e.2) + end Generations /-! ### The grant and the erasure, the present's -/ @@ -206,6 +213,12 @@ def snapshot (G : K → Prop) [DecidablePred G] (p : α → Bool) (s : Store K Store K α := restrict G p (readAt s c) +/-- What an asker is shown of a store at a cut: the grant's snapshot with the erased events +masked. The cut, the grant and the erasure in one reader, the last two the present's. -/ +def shown (G : K → Prop) [DecidablePred G] (p E : α → Bool) (s : Store K α) (c : Cut K) : + Store K α := + snapshot G (fun a ↦ p a && !E a) s c + /-- The store with every erased event replaced by a hole: the erasure keeps every position. -/ def redact (E : α → Bool) (s : Store K α) : Store K (Option α) := fun k ↦ (s k).map fun a ↦ if E a then none else some a From 26953481a2d6a3aa358c711c9a3ba93c959edcc6 Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 06:33:56 -0500 Subject: [PATCH 16/37] test(formal): attack the served resolver, the keyed hole and 16 controls The served resolution was tested only by enumeration, and the build has to transcribe a descent. The floor and the descent alternated until nothing moves is now executable in the attack module and checked against the enumeration (seed 492); each one-shot order is a control (493, 494). New attacks for the keyed read under an erasure (495, controls 496 and 497), the lowering of an unread chain (498, control 499) and the composite reader (509, 511, control 510). Sixteen earlier attacks had no control of their shape; seeds 487 to 491 and 500 to 508 supply them. Co-Authored-By: Claude Fable 5.2 --- formal/PalaceTest/Snapshot.lean | 182 +++++++++++++++++++++++++++++++- 1 file changed, 181 insertions(+), 1 deletion(-) diff --git a/formal/PalaceTest/Snapshot.lean b/formal/PalaceTest/Snapshot.lean index 2314caeb..c53d9359 100644 --- a/formal/PalaceTest/Snapshot.lean +++ b/formal/PalaceTest/Snapshot.lean @@ -24,7 +24,11 @@ state taken for unchanged whatever the delta writes, an event filter before the that deletes rows, a state served without the seal, the looser seal taken for a monotone one, kept rows served without their sources, a frontier taken for a cut, an additive digest, a digest over contents, the pruned store read under its horizon, a frontier lowered to the served -positions without the descent. They run when this module builds (`lake test`). +positions without the descent, the floor and the descent each run once in either order, a hole +that loses its key, a chain that others read lowered alone, and each law of growth, order and +composition with its hypothesis dropped or its sides exchanged. The served resolver is +executable here too: the floor and the descent alternated until nothing moves, tested against +the enumeration. They run when this module builds (`lake test`). -/ @[expose] public section @@ -107,6 +111,35 @@ what is served, before any descent. -/ def floorSv (p : Fin 2 → ℕ → Bool) (k : Fin 2) (x : ℕ) : ℕ := (List.range (x + 1)).foldl (fun (n : ℕ) (q : ℕ) ↦ if p k q then q else n) 0 +/-- One round of the served resolver: each chain lowered to the greatest position it serves at +or under its own, then one pass of the descent. -/ +def roundIn (es : List Edge) (p : Fin 2 → ℕ → Bool) (c : ℕ × ℕ) : ℕ × ℕ := + lower es (floorSv p 0 c.1, floorSv p 1 c.2) + +/-- The executable served resolver: the floor and the descent alternated from the frontier +`(x, y)` until nothing moves. A round that moves anything lowers a position, so that is at most +as many rounds as the frontier has positions. -/ +def resolveIn (es : List Edge) (p : Fin 2 → ℕ → Bool) (x y : ℕ) : ℕ × ℕ := + (roundIn es p)^[x + y] (x, y) + +/-- The edges whose source lies in chain 0: with them alone, no event reads chain 1. -/ +def into0 (es : List Edge) : List Edge := es.filter fun e ↦ e.2.1 = 0 + +/-- Chain 0 serves every position and chain 1 the positions of the mask. -/ +def sv1 (m : Fin 1024) (k : Fin 2) (q : ℕ) : Bool := k == 0 || sv m 1 q + +/-- An erasure of keyed writes by their value. -/ +def ek (e : Fin 8) (w : Fin 3 × Fin 3) : Bool := pf e w.2 + +/-- What is shown under the narrower of two grants and the larger of two erasures is the +restriction of what the wider grant is shown under the smaller erasure. -/ +def shownNarrow (a b : List (Fin 3)) (m : ℕ) (g g' : Fin 4) (c c' e e' : Fin 8) : Bool := + same (shown (fun k ↦ (gr g k && gr g' k) = true) (fun x ↦ pf c x && pf c' x) + (fun x ↦ pf e x || pf e' x) (st a b) (cu m m)) + (restrict (fun k ↦ (gr g k && gr g' k) = true) + (fun x ↦ (pf c x && pf c' x) && !(pf e x || pf e' x)) + (shown (fun k ↦ gr g' k = true) (pf c') (pf e') (st a b) (cu m m))) + /-- A collision-free step: the chain read as a numeral in base four, digits one to three. -/ def step4 (h : ℕ) (a : Fin 3) : ℕ := 4 * h + a.val + 1 @@ -436,4 +469,151 @@ lowered to the served positions. -/ (List.finRange 2).all (fun k ↦ at2 (bestIn es (fun _ _ ↦ true) x.val y.val) k == resolve es x.val y.val k) = true) 486 +/- SNP-10: the served resolver, the floor and the descent alternated until nothing moves, +returns the greatest consistent served cut under the frontier. -/ +#eval survives (∀ (es : List Edge) (m : Fin 1024) (x y : Fin 6), + (resolveIn es (sv m) x.val y.val == bestIn es (sv m) x.val y.val) = true) 492 + +/- Control: the floor once and then the descent alone does not: the descent leaves the served +positions. -/ +#eval refuted (∀ (es : List Edge) (m : Fin 1024) (x y : Fin 6), + (List.finRange 2).all (fun k ↦ + resolve es (floorSv (sv m) 0 x.val) (floorSv (sv m) 1 y.val) k + == at2 (bestIn es (sv m) x.val y.val) k) = true) 493 + +/- Control: nor the descent and then the floor once: the floor breaks consistency again. -/ +#eval refuted (∀ (es : List Edge) (m : Fin 1024) (x y : Fin 6), + ((floorSv (sv m) 0 (resolve es x.val y.val 0), floorSv (sv m) 1 (resolve es x.val y.val 1)) + == bestIn es (sv m) x.val y.val) = true) 494 + +/- SNP-7: on a keyed chain whose holes keep their keys, the read of a key at a cut is its last +write at or under the cut, a hole when that write is erased, and the three reads agree. -/ +#eval survives (∀ (l : List (Fin 3 × Fin 3)) (e : Fin 8) (c : ℕ) (x : Fin 3), + (stateAt (holes (ek e) l) c x + == (stateAt l c x).map (fun v ↦ if pf e v then none else some v) + && genRead (gens (holes (ek e) l)) c x == stateAt (holes (ek e) l) c x + && lastWrite (holes (ek e) l) c x == stateAt (holes (ek e) l) c x) = true) 495 + +/- Control: a seek over the rows of the prefix that kept their key returns a superseded +version where the head is a hole. -/ +#eval refuted (∀ (l : List (Fin 3 × Fin 3)) (e : Fin 8) (c : ℕ) (x : Fin 3), + ((stateOf ((l.take c).filter fun w ↦ !ek e w) x).map some + == stateAt (holes (ek e) l) c x) = true) 496 + +/- Control: a seek over the chain with its holes deleted returns a version from after the +cut. -/ +#eval refuted (∀ (l : List (Fin 3 × Fin 3)) (e : Fin 8) (c : ℕ) (x : Fin 3), + ((lastWrite (l.filter fun w ↦ !ek e w) c x).map some + == stateAt (holes (ek e) l) c x) = true) 497 + +/- SNP-10: a chain that no event reads is lowered alone. From a consistent frontier, with +chain 0 serving every position, the cut read is the frontier with chain 1 at the greatest +position it serves. -/ +#eval survives (∀ (es : List Edge) (m : Fin 1024) (x y : Fin 6), + (bestIn (into0 es) (sv1 m) (resolve (into0 es) x.val y.val 0) (resolve (into0 es) x.val y.val 1) + == (resolve (into0 es) x.val y.val 0, + floorSv (sv1 m) 1 (resolve (into0 es) x.val y.val 1))) = true) 498 + +/- Control: when events may read chain 1, lowering it alone is not the cut read. -/ +#eval refuted (∀ (es : List Edge) (m : Fin 1024) (x y : Fin 6), + (bestIn es (sv1 m) (resolve es x.val y.val 0) (resolve es x.val y.val 1) + == (resolve es x.val y.val 0, floorSv (sv1 m) 1 (resolve es x.val y.val 1))) = true) 499 + +/- SNP-6, SNP-7: under a narrower grant and a larger erasure, what is shown is the restriction +of what the wider grant is shown under the smaller erasure. -/ +#eval survives (∀ (a b : List (Fin 3)) (m : ℕ) (g g' : Fin 4) (c c' e e' : Fin 8), + shownNarrow a b m g g' c c' e e' = true) 509 + +/- SNP-7: and it holds no erased event. -/ +#eval survives (∀ (a b : List (Fin 3)) (m n : ℕ) (g : Fin 4) (c e : Fin 8), + (List.finRange 2).all (fun k ↦ + (shown (fun k ↦ gr g k = true) (pf c) (pf e) (st a b) (cu m n) k).all fun x ↦ !pf e x) + = true) 511 + +/- Control: under a smaller erasure the narrower grant is shown more than that restriction. -/ +#eval refuted (∀ (a b : List (Fin 3)) (m : ℕ) (g g' : Fin 4) (c c' e e' : Fin 8), + same (shown (fun k ↦ (gr g k && gr g' k) = true) (fun x ↦ pf c x && pf c' x) (pf e) (st a b) + (cu m m)) + (restrict (fun k ↦ (gr g k && gr g' k) = true) (fun x ↦ (pf c x && pf c' x) && !pf e x) + (shown (fun k ↦ gr g' k = true) (pf c') (fun x ↦ pf e x || pf e' x) (st a b) (cu m m))) + = true) 510 + +/- Control for 432: a read between two cuts, the later past the head, changes with growth. -/ +#eval refuted (∀ (a b t : List (Fin 3)) (i m n : ℕ), + same (readBetween (grow (st a b) (st t t)) (cu i i) (cu m n)) + (readBetween (st a b) (cu i i) (cu m n)) = true) 487 + +/- Control for 446: the generational store read at a cut past the old head changes with +growth. -/ +#eval refuted (∀ (l t : List (Fin 3 × Fin 3)) (c : ℕ) (x : Fin 3), + (genRead (gens (l ++ t)) c x == genRead (gens l) c x) = true) 488 + +/- Control for 466: the certificate of a cut past the head does not verify on the store +grown. -/ +#eval refuted (∀ (a b a' b' : List (Fin 3)) (m n : ℕ), + verifies (certify step4 0 (st a b) (cu m n)) (grow (st a b) (st a' b')) = true) 489 + +/- Control for 465: resolution does not fall as the frontier rises. -/ +#eval refuted (∀ (es : List Edge) (x y u v : Fin 6), + decide (resolve es x.val y.val ≤ resolve es (min x.val u.val) (min y.val v.val)) + = true) 490 + +/- Control for 481: pruning at two horizons is not pruning at the earlier one. -/ +#eval refuted (∀ (l : List (Fin 3 × Fin 3)) (h h' : ℕ), + (rowsOf (prune h (prune h' (gens l))) == rowsOf (prune (min h h') (gens l))) = true) 491 + +/- Control for 435: a cut of a cut is not the join. -/ +#eval refuted (∀ (a b : List (Fin 3)) (m n i j : ℕ), + same (readAt (readAt (st a b) (cu m n)) (cu i j)) (readAt (st a b) (cu i j ⊔ cu m n)) + = true) 500 + +/- Control for 440: the read at a cut that is not the head is not the store. -/ +#eval refuted (∀ (a b : List (Fin 3)) (m n : ℕ), + same (readAt (st a b) (cu m n)) (st a b) = true) 501 + +/- Control for 438: two adjacent reads-between do not compose in the other order. -/ +#eval refuted (∀ (a b : List (Fin 3)) (i j m n : ℕ), + same (grow (readBetween (st a b) (cu (i + m) (j + n)) (cu (i + m + n) (j + n + m))) + (readBetween (st a b) (cu i j) (cu (i + m) (j + n)))) + (readBetween (st a b) (cu i j) (cu (i + m + n) (j + n + m))) = true) 502 + +/- Control for 439 and 469: the fold at a later cut is not the fold at the earlier one: the +delta counts. -/ +#eval refuted (∀ (a b : List (Fin 3)) (i j m n : ℕ), + (List.finRange 2).all (fun k ↦ + (certify step4 0 (st a b) (cu (i + m) (j + n))).digest k + == (certify step4 0 (st a b) (cu i j)).digest k) = true) 503 + +/- Control for 470: the meet of two certified cuts does not take, chain by chain, the later +digest. -/ +#eval refuted (∀ (a b : List (Fin 3)) (i j m n : ℕ), + (List.finRange 2).all (fun k ↦ + (certify step4 0 (st a b) (cu i j ⊓ cu m n)).digest k + == if cu i j k ≤ cu m n k then (certify step4 0 (st a b) (cu m n)).digest k + else (certify step4 0 (st a b) (cu i j)).digest k) = true) 504 + +/- Control for 447 and 475: an event read at the later cut was not always read at the +earlier. -/ +#eval refuted (∀ (a b : List (Fin 3)) (i j m n : ℕ), + (List.finRange 2).all (fun k ↦ + decide ((readAt (st a b) (cu (i + m) (j + n)) k).length + ≤ (readAt (st a b) (cu i j) k).length)) = true) 505 + +/- Control for 484: the cut read does not always reach the frontier lowered to the served +positions. -/ +#eval refuted (∀ (es : List Edge) (m : Fin 1024) (x y : Fin 6), + (decide (floorSv (sv m) 0 x.val ≤ (bestIn es (sv m) x.val y.val).1) + && decide (floorSv (sv m) 1 y.val ≤ (bestIn es (sv m) x.val y.val).2)) = true) 506 + +/- Control for 485: the cut read does not rise when less is served. -/ +#eval refuted (∀ (es : List Edge) (m m' : Fin 1024) (x y : Fin 6), + decide (at2 (bestIn es (sv m) x.val y.val) + ≤ at2 (bestIn es (fun k p ↦ sv m k p && sv m' k p) x.val y.val)) = true) 507 + +/- Control for 486: when not every position is served the cut read is not the resolution of +the frontier. -/ +#eval refuted (∀ (es : List Edge) (m : Fin 1024) (x y : Fin 6), + (List.finRange 2).all (fun k ↦ + at2 (bestIn es (sv m) x.val y.val) k == resolve es x.val y.val k) = true) 508 + end Palace.Snapshot.Attack From d194cecca23e85a97c17d6c5778b0d87aaf887b1 Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 06:41:03 -0500 Subject: [PATCH 17/37] feat(formal): the seal covers a key's versions, not only its value The stricter seal was defined on the value served at a cut. A new item written under a retired identity then carried the retired item's versions in its history, at the head and at every later cut. historyAt is the history a chain serves of a key at a cut: nothing where the key is sealed, else its landings inside the cut that no retire follows. It ends at the value served (getLast?_historyAt), and after a retire it holds only versions landed after it, at every cut (historyAt_of_retire_inside). Attacked at seed 512, with the unsealed history as its control (513). Co-Authored-By: Claude Fable 5.2 --- formal/Palace/Snapshot.lean | 85 ++++++++++++++++++++++++++++++-- formal/Palace/Snapshot/Defs.lean | 16 +++++- formal/PalaceTest/Snapshot.lean | 14 ++++++ 3 files changed, 108 insertions(+), 7 deletions(-) diff --git a/formal/Palace/Snapshot.lean b/formal/Palace/Snapshot.lean index 06760883..f342dc2f 100644 --- a/formal/Palace/Snapshot.lean +++ b/formal/Palace/Snapshot.lean @@ -56,11 +56,14 @@ a cut a prefix length for each. Cited from the note, not from the ledger. (`servedAt_append_of_retire`, `servedAt_append_of_no_retire`, `servedAt_of_append`); the looser seal, under which a key is withheld only while it is not live, serves everything the stricter one serves and is lifted by a later landing (`servedNow_of_servedAt`, - `Witness.servedNow_restores`). The control is the erasure that deletes rows - (`Witness.compact_moves`). For a keyed chain whose holes keep their keys, the read of a key at - a cut is its last write at or under the cut, a hole when that write is erased, and the three - reads agree on it (`stateAt_holes`, `stateAt_holes_of_erased`, `not_erased_of_stateAt_holes`, - `genRead_gens_holes`, `lastWrite_holes`); the control is the hole that loses its key, which + `Witness.servedNow_restores`). The seal covers the key's versions as it covers its value: the + history served at a cut ends at the value served there, and at every cut after a retire, the + head included, it holds only versions landed after that retire (`getLast?_historyAt`, + `historyAt_append_of_retire`, `historyAt_of_retire_inside`, `sinceRetire_append_retire`). The + control is the erasure that deletes rows (`Witness.compact_moves`). For a keyed chain whose + holes keep their keys, the read of a key at a cut is its last write at or under the cut, a + hole when that write is erased, and the three reads agree on it (`stateAt_holes`, + `stateAt_holes_of_erased`, `not_erased_of_stateAt_holes`, `genRead_gens_holes`, `lastWrite_holes`); the control is the hole that loses its key, which returns a superseded version or one from after the cut (`Witness.keyless_hole`). * SNP-8, resolution: the consistent cuts are the clock's cuts, CLK-2, among the frontier cuts (`consistent_iff_isCut`), so their closure under meet and join is CLK-2's, read through that @@ -719,6 +722,78 @@ theorem servedNow_of_servedAt {l : List (κ × Option β)} {c : ℕ} {x : κ} {v | some w => rfl simp only [servedNow, hnot, Bool.false_eq_true, ↓reduceIte, hstate, Option.join_some] +theorem sinceRetire_append_singleton (l : List (κ × Option β)) (e : κ × Option β) (x : κ) : + sinceRetire (l ++ [e]) x + = if e.1 = x then (e.2.elim [] fun v ↦ sinceRetire l x ++ [v]) else sinceRetire l x := by + simp only [sinceRetire, List.foldl_append, List.foldl_cons, List.foldl_nil] + +theorem foldl_sinceRetire_of_retire (t : List (κ × Option β)) (x : κ) (acc : List β) : + ((x, none) :: t).foldl + (fun acc e ↦ if e.1 = x then (e.2.elim [] fun v ↦ acc ++ [v]) else acc) acc + = sinceRetire t x := by + simp [sinceRetire] + +/-- SNP-7 A retire closes the key's history: the versions landed before a retire of the key +are in no later history. -/ +theorem sinceRetire_append_retire (l t : List (κ × Option β)) (x : κ) : + sinceRetire (l ++ (x, none) :: t) x = sinceRetire t x := by + unfold sinceRetire + rw [List.foldl_append] + exact foldl_sinceRetire_of_retire t x _ + +/-- The last version of a key's present life is the value the key holds live. -/ +theorem getLast?_sinceRetire (l : List (κ × Option β)) (x : κ) : + (sinceRetire l x).getLast? = (stateOf l x).join := by + induction l using List.reverseRecOn with + | nil => rfl + | append_singleton l e ih => + rw [sinceRetire_append_singleton, stateOf_append_singleton] + by_cases hx : e.1 = x + · subst hx + rw [Function.update_self] + cases e.2 <;> simp + · rw [Function.update_of_ne (Ne.symm hx)] + simpa [hx] using ih + +/-- SNP-7 The history served at a cut ends at the value served there: the seal that withholds +a key's value withholds its versions with it. -/ +theorem getLast?_historyAt (l : List (κ × Option β)) (c : ℕ) (x : κ) : + (historyAt l c x).getLast? = servedAt l c x := by + unfold historyAt servedAt + split_ifs + · rfl + · exact getLast?_sinceRetire _ x + +/-- SNP-7 Once the chain retires a key, no cut before the retire serves any version of it. -/ +theorem historyAt_append_of_retire {l t : List (κ × Option β)} {c : ℕ} {x : κ} + (hc : c ≤ l.length) (h : (x, none) ∈ t) : historyAt (l ++ t) c x = [] := by + have hs : sealedAt (l ++ t) c x = true := by + rw [sealedAt_append t hc, Bool.or_eq_true] + exact Or.inr (List.any_eq_true.2 ⟨(x, none), h, by simp⟩) + simp only [historyAt, hs, ↓reduceIte] + +/-- SNP-7 At every cut after a retire of a key, the head included, the history served of the +key holds only versions landed after that retire: a new item under a retired identity does not +bring the retired item's versions with it. -/ +theorem historyAt_of_retire_inside (l t : List (κ × Option β)) (x : κ) {c : ℕ} + (hc : l.length + 1 ≤ c) : + historyAt (l ++ (x, none) :: t) c x + = if sealedAt (l ++ (x, none) :: t) c x then [] + else sinceRetire (t.take (c - (l.length + 1))) x := by + unfold historyAt + split_ifs + · rfl + · have h1 : (l ++ (x, none) :: t).take c + = l ++ (x, none) :: t.take (c - (l.length + 1)) := by + rw [List.take_append, List.take_of_length_le (by omega), + show c - l.length = (c - (l.length + 1)) + 1 by omega, List.take_succ_cons] + rw [h1, sinceRetire_append_retire] + +/-- SNP-4 At the head cut the history served is the key's present life. -/ +theorem historyAt_length (l : List (κ × Option β)) (x : κ) : + historyAt l l.length x = sinceRetire l x := by + simp [historyAt, sealedAt] + omit [DecidableEq κ] in theorem holes_append (E : κ × β → Bool) (l t : List (κ × β)) : holes E (l ++ t) = holes E l ++ holes E t := diff --git a/formal/Palace/Snapshot/Defs.lean b/formal/Palace/Snapshot/Defs.lean index ce8ee978..411c137a 100644 --- a/formal/Palace/Snapshot/Defs.lean +++ b/formal/Palace/Snapshot/Defs.lean @@ -29,8 +29,9 @@ the asker's **grant** (`snapshot`: the chains it names and the events it may see **erasure** (`visible`: the erased events masked; `redact`: the store with a hole at each, every position kept; `holes`: the same for a keyed chain, the hole keeping its key; `shown`: the grant and the erasure applied to one read; `servedAt`: a key retired after the cut is served at no -earlier cut, with `servedNow` the looser seal that a later landing lifts). The control for the -erasure is `compact`, an erasure that deletes rows and lets the later ones move up. +earlier cut, with `servedNow` the looser seal that a later landing lifts, and `historyAt` the +versions the stricter seal serves). The control for the erasure is `compact`, an erasure that +deletes rows and lets the later ones move up. Events may read from events of other chains (`R k i k' j`: the `i`-th event of chain `k` reads from the `j`-th of chain `k'`); a cut is **consistent** when every source of an event inside it is @@ -188,6 +189,17 @@ a key landed again after its retire is served again at the cuts before the retir def servedNow [DecidableEq κ] (l : List (κ × Option β)) (c : ℕ) (x : κ) : Option β := if ((stateOf l x).join).isNone then none else (stateAt l c x).join +/-- The landings of a key that no retire of it follows, oldest first: the versions of the key's +present life. -/ +def sinceRetire [DecidableEq κ] (l : List (κ × Option β)) (x : κ) : List β := + l.foldl (fun acc e ↦ if e.1 = x then (e.2.elim [] fun v ↦ acc ++ [v]) else acc) [] + +/-- The history a chain of landings and retires serves of a key at a cut, under the stricter +seal: nothing when the key is sealed there, else its landings inside the cut that no retire +follows. A version landed before a retire of its key is in no history, at any cut. -/ +def historyAt [DecidableEq κ] (l : List (κ × Option β)) (c : ℕ) (x : κ) : List β := + if sealedAt l c x then [] else sinceRetire (l.take c) x + /-- A keyed chain with a hole at each erased write: the hole keeps the write's key and its position and loses its value, so it still shadows the key's earlier writes. The alternative, a hole that loses its key too, is the control (`Witness.keyless_hole`). -/ diff --git a/formal/PalaceTest/Snapshot.lean b/formal/PalaceTest/Snapshot.lean index c53d9359..c3028eca 100644 --- a/formal/PalaceTest/Snapshot.lean +++ b/formal/PalaceTest/Snapshot.lean @@ -538,6 +538,20 @@ of what the wider grant is shown under the smaller erasure. -/ (shown (fun k ↦ gr g' k = true) (pf c') (fun x ↦ pf e x || pf e' x) (st a b) (cu m m))) = true) 510 +/- SNP-7: the history served of a key at a cut ends at the value served there, and after a +retire of the key it holds no version landed before the retire. -/ +#eval survives (∀ (l t : List (Fin 9)) (c : ℕ) (x : Fin 3), + ((historyAt (l.map ev) c x).getLast? == servedAt (l.map ev) c x + && historyAt (l.map ev ++ (x, none) :: t.map ev) (l.length + 1 + c) x + == if sealedAt (l.map ev ++ (x, none) :: t.map ev) (l.length + 1 + c) x then [] + else sinceRetire ((t.map ev).take c) x) = true) 512 + +/- Control: the versions of a key inside the cut, without the seal, hold versions landed +before a retire. -/ +#eval refuted (∀ (l : List (Fin 9)) (c : ℕ) (x : Fin 3), + (((l.map ev).take c).filterMap (fun e ↦ if e.1 = x then e.2 else none) + == historyAt (l.map ev) c x) = true) 513 + /- Control for 432: a read between two cuts, the later past the head, changes with growth. -/ #eval refuted (∀ (a b t : List (Fin 3)) (i m n : ℕ), same (readBetween (grow (st a b) (st t t)) (cu i i) (cu m n)) From f381a38797c0442477e55ae9a851985fe6abb27a Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 06:41:38 -0500 Subject: [PATCH 18/37] docs(formal): rewrap the keyed-read bullet of the Snapshot header One line of the module docstring ran past the 100-character limit, which the build treats as fatal. Co-Authored-By: Claude Fable 5.2 --- formal/Palace/Snapshot.lean | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/formal/Palace/Snapshot.lean b/formal/Palace/Snapshot.lean index f342dc2f..c10d927e 100644 --- a/formal/Palace/Snapshot.lean +++ b/formal/Palace/Snapshot.lean @@ -63,8 +63,9 @@ a cut a prefix length for each. Cited from the note, not from the ledger. control is the erasure that deletes rows (`Witness.compact_moves`). For a keyed chain whose holes keep their keys, the read of a key at a cut is its last write at or under the cut, a hole when that write is erased, and the three reads agree on it (`stateAt_holes`, - `stateAt_holes_of_erased`, `not_erased_of_stateAt_holes`, `genRead_gens_holes`, `lastWrite_holes`); the control is the hole that loses its key, which - returns a superseded version or one from after the cut (`Witness.keyless_hole`). + `stateAt_holes_of_erased`, `not_erased_of_stateAt_holes`, `genRead_gens_holes`, + `lastWrite_holes`); the control is the hole that loses its key, which returns a superseded + version or one from after the cut (`Witness.keyless_hole`). * SNP-8, resolution: the consistent cuts are the clock's cuts, CLK-2, among the frontier cuts (`consistent_iff_isCut`), so their closure under meet and join is CLK-2's, read through that equivalence (`Consistent.inf`, `Consistent.sup`, `consistentCuts`). What this law adds is From 0ddab8e87ae62fe11c2e491f6f55d32e4e3c9e05 Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 06:53:45 -0500 Subject: [PATCH 19/37] feat(formal): every unread chain is lowered at once (SNP-10) The local lowering was proved for one chain. The design applies it to all the chains that can fail to serve a cut, which are the chains no recorded bound reads, so the theorem is stated for a set of them: resolvesIn_of_unread. Co-Authored-By: Claude Fable 5.2 --- formal/Palace/Snapshot.lean | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/formal/Palace/Snapshot.lean b/formal/Palace/Snapshot.lean index c10d927e..e5ddd6a0 100644 --- a/formal/Palace/Snapshot.lean +++ b/formal/Palace/Snapshot.lean @@ -94,7 +94,8 @@ a cut a prefix length for each. Cited from the note, not from the ledger. cut among them, which rises with what is served and never passes the cut asked (`exists_resolvesIn`, `ResolvesIn.unique`, `ResolvesIn.mono`, `ResolvesIn.le_resolves`, `resolvesIn_univ`). A chain that no other chain reads is lowered alone, every other chain - read as asked (`Consistent.update_of_unread`, `resolvesIn_update_of_unread`), and retention + read as asked (`Consistent.update_of_unread`, `resolvesIn_update_of_unread`, + `resolvesIn_of_unread`), and retention commutes with growth (`prune_landGen`). The controls: the pruned store read under its horizon, which cannot tell a lost key from one never written (`Witness.prune_forgets`, `Witness.prune_indistinct`); a record on a chain that content reads, which drags every reader @@ -1263,6 +1264,38 @@ theorem resolvesIn_update_of_unread [DecidableEq K] {S : K → Set ℕ} {f : Cut · rw [Function.update_of_ne hk] exact hdf k +/-- SNP-10 The same for every chain that no other chain reads, at once: from a consistent cut +asked, when the chains others read serve their positions, the cut read is the cut asked with +each unread chain at the greatest position it serves at or under the one asked. -/ +theorem resolvesIn_of_unread {S : K → Set ℕ} {f p : Cut K} (U : K → Prop) [DecidablePred U] + (hf : Consistent R f) (hS : ∀ k, ¬U k → f k ∈ S k) + (hU : ∀ k i x j, U x → R k i x j → k = x ∧ j ≤ i) + (hp : ∀ x, U x → p x ∈ S x ∧ p x ≤ f x ∧ ∀ q ∈ S x, q ≤ f x → q ≤ p x) : + ResolvesIn R S f fun k ↦ if U k then p k else f k := by + have hle : ∀ k, (if U k then p k else f k) ≤ f k := fun k ↦ by + by_cases hk : U k + · simp only [hk, ↓reduceIte] + exact (hp k hk).2.1 + · simp only [hk, ↓reduceIte] + exact le_rfl + refine ⟨fun k i k' j hr hi ↦ ?_, fun k ↦ ?_, hle, fun d _ hdS hdf k ↦ ?_⟩ + · have hj := hf k i k' j hr (lt_of_lt_of_le hi (hle k)) + by_cases hk' : U k' + · obtain ⟨rfl, hji⟩ := hU k i k' j hk' hr + exact lt_of_le_of_lt hji hi + · simp only [hk', ↓reduceIte] + exact hj + · by_cases hk : U k + · simp only [hk, ↓reduceIte] + exact (hp k hk).1 + · simp only [hk, ↓reduceIte] + exact hS k hk + · by_cases hk : U k + · simp only [hk, ↓reduceIte] + exact (hp k hk).2.2 _ (hdS k) (hdf k) + · simp only [hk, ↓reduceIte] + exact hdf k + theorem ResolvesIn.le_on_of_closed {R' : K → ℕ → K → ℕ → Prop} {S S' : K → Set ℕ} {f f' c c' : Cut K} (G : K → Prop) (hclosed : ∀ k i k' j, G k → R' k i k' j → G k') From 14ebe5d443a5321f8b9f18eb75c832d957735099 Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 07:01:13 -0500 Subject: [PATCH 20/37] docs(design): bring dn-temporal-snapshot into agreement with the code Three audits of the note found claims about the code that main does not bear out, laws cited for more than they prove, and items a builder would have to guess. This is the repair, section by section. What exists. An artifact's subjects are titles and its sources are its derived_from; a commit's citation reading grows at a re-projection; a revert in the mirror is attested again; as of refuses HEAD only when the reference store holds a reading; a repository read falls back to HEAD when git lacks the commit; a path written again after a delete carries the deleted note's versions. The inventory gains the curated store, the observation readings, the structural snapshots and the dispositions, and the stores left out are named with their reasons. The cut. A chain has an id and its class is a label, so a relabel moves no row and no certificate. Recorded cuts sit on a chain of their own: on the attestation ledger one chain read low would take every landing chain to its empty prefix. A record is taken at a trough, never inside the sensor's job, and GC-N3 is quoted as written. A purged row keeps a keyed hash of its path, so a read by path returns a hole and not a superseded version. The seal covers an identity's versions. The laws. Closure under meet and join is cited to CLK-2; a certificate is said to pin what it digests and to attest no erasure, seal or grant; the grant's law is stated for the read and not for a scored answer; each law says what holds by the construction of the model. The build. Stage one names its tables, the commitment's bytes, the genesis, the reads and their returns, the tests and the ledger rows. The decisions are fourteen: D9 no longer reorders the landing, D13 and D14 are new. Co-Authored-By: Claude Fable 5.2 --- docs/design-notes/dn-temporal-snapshot.md | 1607 ++++++++++++++------- 1 file changed, 1103 insertions(+), 504 deletions(-) diff --git a/docs/design-notes/dn-temporal-snapshot.md b/docs/design-notes/dn-temporal-snapshot.md index 44f0286f..0cbd253c 100644 --- a/docs/design-notes/dn-temporal-snapshot.md +++ b/docs/design-notes/dn-temporal-snapshot.md @@ -30,11 +30,13 @@ warrant: null > the merge. Agent-drafted, filed `draft` on a branch; the merge is ratification. Nothing is > built: `core/` is untouched and no store of any instance was read. Every nontrivial claim > carries a grade: `[THEOREM]` is machine-checked in `formal/Palace/Snapshot.lean` and names its -> declaration; `[ESTABLISHED]` is a ratified note's, or a fact of the code read at the line -> cited; `[DERIVED]` is argued here from those; `[MEASURED]` is a figure taken for this note on a -> synthetic fixture (§11 says how); `[INFERENCE]` is a design call with a named falsifier; -> `[HYPOTHESIS]` is a claim nothing here checks, with what would check it named. Code claims were -> read on `origin/main` at `e3e3ee47`. The article `papers/2026-11-10-temporal-snapshot/paper.tex` +> declaration; `[ESTABLISHED]` is a ratified note's, a fact of the code read at the line cited, +> or a figure of the repository's own experiment records, cited by file and line; `[DERIVED]` is +> argued here from those; `[MEASURED]` is a figure taken for this note on a synthetic fixture, by +> a probe that is not in the repository (§11 says how, and which stage commits its harness); +> `[INFERENCE]` is a design call with a named falsifier; `[HYPOTHESIS]` is a claim nothing here +> checks, with what would check it named. Code claims were read on +> `origin/main` at `e3e3ee47`. The article `papers/2026-11-10-temporal-snapshot/paper.tex` > states the same theorems with proof sketches and the references. ## 1. Purpose and scope @@ -43,8 +45,8 @@ warrant: null A sentence of the query language can carry `as of ""`. Today it moves one relation: the citation graph, which the stores index by commit, is read at the cut, and a file of the repository -is read as git's blob there. Every other verb reads the stores as they are now, and the answer -says so. The requirement is the rest: the palace as of a cut. A read at a cut must be the same +is read as git's blob there when git holds the commit. Every other verb reads the stores as they +are now, and the answer says so. The requirement is the rest: the palace as of a cut. A read at a cut must be the same whenever it is asked, since the store only grows above the cut; it must never return what was erased since; it must respect the grant the asker holds today; and where it cannot read a store at the cut it must say so instead of answering from the present. @@ -57,32 +59,38 @@ as of a cut (dn-utility-field, open question 1). ### 1.2 Decisions 1. **A cut is one position per chain, about a dozen positions for an instance, not one per - document (§3.1, §3.3).** The chains are the stores' own append orders, one per provenance class - where clearances separate the rows. `[DERIVED from global-event-clock §2.4; INFERENCE, - falsifier SNF-2]` + document (§3.1, §3.3).** The chains are the stores' own append orders. A chain has an id that + never changes and carries a provenance class as a label, so clearances that separate rows + separate chains. `[DERIVED from global-event-clock §2.4; INFERENCE, falsifier SNF-2]` 2. **The missing ledger is a landing log (§3.2).** The catalog is rewritten in place, and no ledger records which digest a path held when, except the version chains of one place. One - append-only, hash-chained log a provenance class, written by the catalog's own methods in the - transaction of the row they write, makes the catalog its fold and gives every landed stratum a - past. `[ESTABLISHED for the gap; INFERENCE for the log, falsifier SNF-1]` + append-only, hash-chained log, written by the catalog's own methods in the transaction of the + row they write, makes the catalog its fold and gives every landed stratum a past. + `[ESTABLISHED for the gap; INFERENCE for the log, falsifier SNF-1]` 3. **A name resolves to a frontier, and the read is at the greatest consistent cut under it - (§3.4, §3.5).** Consistent cuts are closed under meet and join, and every frontier resolves to - exactly one. Wall time selects a frontier by lookup in the bookmarks and orders nothing. - `[THEOREM: SNP-8]` -4. **A cut is certified by the digest of each chain's prefix, recorded and attested (§3.6).** A - certificate verifies on every later state of the store and, under a collision-free digest, - pins the read. `[THEOREM: SNP-9]` + (§3.4, §3.5).** Every frontier resolves to exactly one such cut. That consistent cuts are + closed under meet and join is CLK-2's, already in the ledger. Wall time selects a frontier by + lookup in the bookmarks and orders nothing. `[THEOREM: SNP-8, CLK-2]` +4. **A cut is certified by the digest of each hashed chain's prefix, recorded on a chain of + records that nothing reads (§3.3, §3.6).** A certificate verifies on every later state of the + store and, under a collision-free digest, pins the prefix it digests. For the landing log that + prefix is the commitments, so under a binding commitment it pins the events. It attests no + erasure, no seal and no grant: those are the present's, and an answer at a certified cut is + the same on two stores for one erasure, one grant and one set of seals. `[THEOREM: SNP-9]` 5. **Derived data is a function of the prefixes, held store by store in the cheapest of the equal ways (§5):** version-keyed rows selected by the log for vectors and lexical units, - recomputation for the causal fiber, kept generations for model output. `[THEOREM: SNP-5; - INFERENCE per store]` + recomputation for the causal fiber and for the relations a note declares, kept generations + for model output. `[THEOREM: SNP-5; INFERENCE per store]` 6. **The grant and the erasure are the present's (§6).** A narrower grant's snapshot is the - restriction of a wider one's; nothing erased is visible at any cut; a retired identity is - sealed at every earlier cut. `[THEOREM: SNP-6, SNP-7]` + restriction of a wider one's; nothing erased is visible at any cut, and a read by path returns + a hole where the version at the cut is erased; a retired identity is sealed at every earlier + cut, its versions with its value. `[THEOREM: SNP-6, SNP-7]` 7. **A read under `as of` holds no event from after the cut it names (§7).** Where a store - cannot serve the cut asked, it is read at the greatest position at or under it that it serves, - the cut read is the greatest consistent cut among those positions, and the answer names it - chain by chain. `[THEOREM: SNP-10; INFERENCE for the surface, falsifier SNF-4]` + cannot serve the cut asked, the cut read is the greatest consistent cut among the positions + the stores serve, and the answer names it chain by chain. A chain that no other chain reads is + lowered alone; a chain that others read takes its readers down with it, which is why a + recorded cut is kept off the chains that content reads. `[THEOREM: SNP-10; INFERENCE for the + surface, falsifier SNF-4]` 8. **History is exact from the horizon, and the horizon is an event of the chain (§8).** A store that drops old generations reads every cut from its horizon on exactly, and a cut under the horizon is not served. `[THEOREM: SNP-10]` @@ -97,28 +105,43 @@ Any change to `core/` (code is licensed at the merge); the storage engines (a st scale is under way and none of its figures is in the repository, so this note cites none, measures what it needs on fixtures of its own, and names for each choice the evidence that would change it); the spine's reachability index; a second embedder identity held beside the first -(dn-two-phase-ingestion, open question 4); a snapshot of the job queue, the task list and the -telemetry, which are operational state and not content; backups and migration archives, which a -purge does not reach today and which this note does not design. +(dn-two-phase-ingestion, open question 4); backups and migration archives, which a purge does +not reach today and which this note does not design. + +Not in a snapshot, each for its reason. The job queue, the task list and the telemetry are +operational state and not content. So are the launcher's run ledger (`ops/lifecycle/runs.py:27`, +whose rows are updated at a stop, `:117`), the self-modification proposal ledger +(`ops/ledger.py:294`) and the effect ledger (`ops/effect_ledger.py:294`): they record the +system's own runs and acts, and no sentence reads them. The eval results +(`eval/harness/store.py:164`) are measurements of the system; the spine cuts them as a stratum +of its own (`core/temporal/spine.py:279`, `:346`) and no sentence reads them either. The spools +and state files hold what is in flight: the ingress spools with their receipts +(`core/ingest/ingress.py:1-27`), the dialogue handoff documents and their `.synced` marks +(`core/ingest/table.py:276`, `ops/heartbeat.py:298`), the two sensing handoffs +(`ops/code_sensor.py:862`, `ops/self_sensor.py:345`), a stream source's cursor +(`core/ingest/stream.py:30`) and the heartbeat's tick files (`ops/heartbeat.py:76`). A recorded +cut is taken when the handoff is empty (§3.3), which is the statement that none of it is in +flight; one of them keeps text, the rejected requests, and §6.1 names it for the purge. ### 1.4 What is proved, what is measured, what is open Proved, in `formal/Palace/Snapshot.lean` over `formal/Palace/Snapshot/Defs.lean`: SNP-1 to SNP-10 -as §10 states them, 125 theorems, eight of them the controls; attacked in -`formal/PalaceTest/Snapshot.lean` (seeds 430 to 486: thirty-nine attacks, every one surviving all -500 instances, and eighteen negative controls, each refuted). They are design theorems: no code -relies on them, so they have no row in `docs/LAWS.md` and no statement in `formal/Spec/`; §12 says -when they enter the ledger. +as §10 states them, 161 theorems, fifteen of them the controls; attacked in +`formal/PalaceTest/Snapshot.lean` (seeds 430 to 513: forty-five attacks, every one surviving all +500 instances, and thirty-nine negative controls, each refuted). They are design theorems: no +code relies on them, so they have no row in `docs/LAWS.md` and no statement in `formal/Spec/`; +§12 says when they enter the ledger. Some of what §6 and §7 require holds by the construction of +the model and not by a theorem about the code: §10 says which, law by law. Measured, on synthetic fixtures only (§11): the landing log's size and the cost of its reads; what a kept version costs in the lexical index; what a purge leaves behind today; that the causal store depends on the order of two jobs; that the events of a transcript's prefix are not always the -prefix of its events, and what re-deriving a session costs; what `as of` accepts; that a position -taken from a store's row numbering is given again after a delete. +prefix of its events, and what re-deriving a session costs; what `as of` accepts and when; that a +position taken from a store's row numbering is given again after a delete. -Open, stated where it bites: reading every head at a cut on a store of millions of paths (§4.2); -the attestation ledger's own content hashes under an erasure (§6.1); the cadence of recorded cuts -(§3.3); a repository history that is not one line (§3.1). +Open, stated where it bites: the attestation ledger's own content hashes under an erasure +(decision D9); the cadence of recorded cuts (§3.3); a repository history that is not one line +(§3.1); rows written to the curated store outside the catalog (§5.6). ## 2. What exists @@ -132,18 +155,26 @@ the attestation ledger's own content hashes under an erasure (§6.1); the cadenc (`core/sentence/universe.py:125-127`), and the executor refuses a clause whose cut is not the universe's (`core/sentence/execute.py:713-718`). `[ESTABLISHED]` - **The names it accepts.** A commit's sha, whole, or a prefix the reference store resolves to - one commit (`universe.py:466-477`, `core/stores/reference_edges.py:381-388`). A commit the store - holds no reading for falls back to the newest reading (`universe.py:478-484`) and the clause is - then refused; so are `HEAD` and a date. `[ESTABLISHED; MEASURED §11]` + one commit (`universe.py:466-477`, `core/stores/reference_edges.py:381-388`). When the store + holds some reading, a name it has no reading for falls back to the newest reading + (`universe.py:478-484`, taken only when `latest_commit()` is not `None`) and the clause is then + refused; so are `HEAD` and a date. When the store holds no reading at all, as on an instance + with no repository or one just reset, the string asked becomes the universe's cut as it is, the + executor's prefix check passes (`execute.py:714`), and `as of "HEAD"`, a date and any other + string are answered: a walk over `F` over an empty graph with no note, another verb with the + note that it read the present. `[ESTABLISHED; MEASURED §11]` - **What is read at the cut.** The citation graph (`universe.py:485-486`), and a file of the repository, as git's blob in the tree at the commit (`execute.py:249-302`, called with the - universe's cut at `universe.py:787-788`). `[ESTABLISHED]` + universe's cut at `universe.py:787-788`), when git resolves the cut. When it does not, a + reading whose commit the checkout lacks, the read tries the cut and then `HEAD` + (`execute.py:266-270`) and returns `HEAD`'s blob. `[ESTABLISHED; MEASURED §11]` - **What is read as it is now.** Everything else, and the answer carries a note naming the verbs (`execute.py:503-521`, `:719-725`). The note lists `read` among them, though a `read` of a - repository path is at the cut: on a file that changed since the cut the text returned is the - cut's blob and the note says the present. `[MEASURED §11]` The record of such a read carries the - commit it was read at, and the hit built from the record drops it (`execute.py:296-299`, - `:1121-1126`), so the answer does not show which commit the text is from. A note's `read` opens + repository path is at the cut where git holds it: on a file that changed since the cut the text + returned is the cut's blob and the note says the present. `[MEASURED §11]` The record of such a + read carries the commit it was read at, and the hit built from the record drops it + (`execute.py:296-299`, `:1121-1126`), so the answer does not show which commit the text is + from, the cut's or, after the fallback, `HEAD`'s. A note's `read` opens the vault file when its reference is a path under the vault, and the raw object of the catalog's digest otherwise (`execute.py:342-350`): the present, in the first case newer than the catalog. `[ESTABLISHED]` @@ -156,9 +187,10 @@ the attestation ledger's own content hashes under an erasure (§6.1); the cadenc ### 2.2 The inventory -Every store an instance writes, by what a past state of it is. The clock is the order that -positions its rows; wall-time columns are bookmarks and position nothing (event clock, Law C4). -The job queue, the task list and the telemetry are left out (§1.3). +Every store an instance writes that holds content a sentence can read, by what a past state of +it is. The clock is the order that positions its rows; wall-time columns are bookmarks and +position nothing (event clock, Law C4). The operational stores, the eval results, the spools and +the state files are left out, each with its reason (§1.3). **Ledgers: a past state is a prefix.** @@ -166,12 +198,15 @@ The job queue, the task list and the telemetry are left out (§1.3). |---|---|---|---| | raw objects (`core/kernel/stores/rawstore.py:28-40`) | none of its own; an object is ordered by the events that name its digest | the digest | nothing is rewritten; a purge deletes the object (`rawstore.py:51-61`); a transcript that grew is retained whole again under a new digest (`ops/chat_sensor.py:289-333`) | | version chains (`core/stores/versions.py:77-86`) | `version_seq` per document | `(doc_id, version_seq)` | nothing (one admitted relabel of `doc_id`, `versions.py:132`); kept by one place only, `mirror_authored` (`core/ingest/table.py:241-251`) | -| attestations (`core/attestation/store.py:27-36`) | insertion order and the parents' graph; read back `ORDER BY timestamp, id` (`store.py:130`) | the content-addressed id | nothing; one per (action, digest) unless a version event (`core/ingest/landing.py:77-86`), so not one a landing, and no path | +| attestations (`core/attestation/store.py:27-36`) | insertion order and the parents' graph; read back `ORDER BY timestamp, id` (`store.py:130`) | the content-addressed id | nothing; one per (action, digest), and one more for a landing that appended a version (`core/ingest/landing.py:77-86`), so not one a landing outside the place that keeps chains, and no path | | chat utterances (`core/stores/chatlog.py:77-92`) | `turn_index` per session | `(session_id, turn_index)` | nothing: the first write of a turn stands (`chatlog.py:161`); the store is wiped by a reset and filled again from the raw store (`chatlog.py:41-45`) | -| citation readings (`core/stores/reference_edges.py:134-148`) | the commit of the reading; git orders the commits | `commit_sha`, part of every edge's identity (`reference_edges.py:164-174`) | nothing: one whole reading a commit, append-only (`reference_edges.py:289-302`) | +| citation readings (`core/stores/reference_edges.py:134-148`) | the commit of the reading; git orders the commits | `commit_sha`, part of every edge's identity (`reference_edges.py:164-174`) | no row: the store is append-only (`reference_edges.py:289-302`). What is lost is which projection wrote an edge: a deliberate re-projection under a later extractor (`ops/code_sensor.py:827-845`, through `_project`, `:473-490`) adds edges under the old `commit_sha`, the rows carry no extractor version, and one is owed (`code_sensor.py:83-91`). So a commit's reading is the union of every projection of it so far, not a function of its tree | | commit ledger (`ops/code_snapshot.py:44-58`) | git's ancestry: the ledger keeps no parent, and the sensor reads the commits of one branch in `rev-list` order (`ops/code_sensor.py:404-418`) | `commit_sha` | nothing | -| observation history (`core/stores/observation_history.py:46-56`) | the interpreter's generation per identity | (store, identity, interpreter) | nothing: a superseded generation is archived, never dropped (`core/stores/code_observations.py:211-254`) | -| run ledger, verdicts (`core/stores/runledger.py:140`, `:161`; `core/stores/verdicts.py:145`) | insertion order | the row's id | nothing | +| code and agent observations, current readings (`core/stores/code_observations.py:246`, `core/stores/agent_observations.py:205`) with their history (`core/stores/observation_history.py:46-56`) | the interpreter's generation per identity | (store, identity, interpreter) | nothing: a superseding write archives the old generation first, and it is never dropped (`code_observations.py:211-254`); a reset wipes the current readings and keeps the history (`ops/lifecycle/launcher.py:1765`, `:1776`, `:111-118`). This is generations as built, the form §5.4 takes | +| run ledger, verdicts (`core/stores/runledger.py:140`, `:161`; `core/stores/verdicts.py:145`) | insertion order | the row's id | nothing; a dream claim keeps the digests it rests on and its surface text (`runledger.py:90-97`) | +| structural snapshots (`core/complex/temporal.py:41-58`, `:208`) | a sequence of its own, one row a dream pass (`core/dreaming/dreamer.py:288`) | `snapshot_id` | nothing: invariants of the graph as it stood at the pass, appended | +| claim ops (`core/stores/claim_ops.py:40-48`) | none: `at` is wall time | a hash of (kind, claim, related, text) (`core/kernel/recursion_ops.py:134-135`) | nothing but the bookmark: a row is keyed by its whole content, so the `INSERT OR REPLACE` of a second application (`claim_ops.py:73`) only stamps `at` again. An append-only set with no position; no model writes it (`claim_ops.py:14-15`) | +| authored supersessions (`core/stores/authored_supersession.py:112-120`) | none: `at` is wall time | the pair (superseded, superseding) | the bookmark and the note of an earlier declaration of the same pair (`authored_supersession.py:159-161`); owner-declared, never model output (`:150-157`). An append-only set with no position | | staging (`core/stores/staging.py:118-138`) | its own generation clock | the generation | a sweep stamps `tombstoned_at_gen` and the row stays; `read_at(g)` exists (`staging.py:232-244`) | | query log (`core/sentence/surface.py:93`) | line order | the line | nothing | @@ -182,6 +217,7 @@ The job queue, the task list and the telemetry are left out (§1.3). | plane occupancies (`core/stores/plane.py:268-278`) | none: `landed_at` is wall time | (path, digest, chunk) | which version was the head when: only `current` flips, and flips back when a path returns to bytes it held before (`plane.py:466-487`) | | the plane's supersession log (`plane.py:282-289`) | `seq` per path | (path, seq) | a purge deletes entries and the next entry takes the position again (`plane.py:491-495`, `:552-553`) `[MEASURED §11]`; a reset drops it (`plane.py:628-640`); an instance with no plane has none; under lazy embedding it is written by the drain, in the drain's order, and only for the versions still current then (`core/ingest/derive.py:85-118`) | | atoms (the vector table) | none: content-addressed (`plane.py:113-115`) | the atom's id | the `held` and `current` cache columns; the table's own dataset versions, one a write, which a compaction drops (`core/stores/vectorstore.py:780-812`) | +| the curated store: a second vector table with a plane of its own (`core/stores/curated_store.py:30-38`, `core/stores/vectorstore.py:243`) | as the plane and the atoms | as the plane and the atoms | as the plane and the atoms. It has two writers. `ingest_curated` lands through the catalog (`core/ingest/curated.py:66-82`). `scripts/curate_local.py:96-108` writes rows with `store.add` and no catalog row, raw object or attestation, so nothing positions them. `near` seeds from it (`core/sentence/universe.py:378-393`) and `read` opens its rows (`core/sentence/execute.py:318-326`); the purge does not open it (`scripts/purge_raw.py:51-56`) | | lexical units and postings (`core/stores/lexical.py:56-82`) | none: `landed_at` is wall time | (path, digest, chunk) | the head flag (`lexical.py:251-256`, `:260-265`); every unit, when the tokenizer changes (`lexical.py:180-194`) | | code memberships (`core/stores/memberships.py:140-155`) | git: (path, blob) | the version's identity | the head flag; a purge leaves a recorded hole (`memberships.py:153`, `:491-497`) | @@ -192,30 +228,36 @@ The job queue, the task list and the telemetry are left out (§1.3). | catalog (`core/stores/catalog.py:36-45`) | none: `updated_at` is wall time | the path | which digest a path held before and whether it was active: an upsert (`catalog.py:113-121`), a tombstone that flips `active` (`catalog.py:167-170`), a purge that deletes the row (`catalog.py:254-258`) | | chat events (`core/stores/chat_events.py:40-48`) | `ord` per session, on each row | (session, ord) | the session's rows are deleted and written again (`chat_events.py:72-88`); re-derivable from the retained transcript | | causal edges (`core/stores/causal_edges.py:51-61`) | `event_order` and `witness_turn`, on each row | the edge's id, a hash that includes the transcript's digest (`causal_edges.py:71-76`) | the session's rows are deleted and written again (`causal_edges.py:130-154`), under new ids when the session grew; what they were before the commit ledger gained a commit | -| interpreted artifacts and hyperedges (`core/stores/derived.py:97-100`) | none: `created_at` is wall time | hash of (kind, subkind, subjects) | the artifact a later pass over the same subjects replaced (`derived.py:209-216`): model output, not recomputable | -| relation edges (`core/stores/edges.py:37-46`) | none: `created_at` is wall time | hash of (u, v, relation) | the weight, sign and provenance a re-assertion replaced (`edges.py:88-106`) | -| claim ops, authored supersessions (`core/stores/claim_ops.py:73`, `core/stores/authored_supersession.py:161`) | none | the key | the replaced row | +| interpreted artifacts and hyperedges (`core/stores/derived.py:49-60`) | none: `created_at` is wall time | a hash of the kind, the subkind and the sorted subjects, which are note titles (`derived.py:55`, `:97-100`) | the artifact a later pass over the same titles replaced (`derived.py:209-216`), whatever versions of those notes each pass read: model output, not recomputable. What a row was built from is its `derived_from`, note digests or other artifacts' ids (`derived.py:186-189`); it records no run, only the attestation that produced it (`derived.py:59`) | +| relation edges (`core/stores/edges.py:37-46`) | none: `created_at` is wall time | hash of (u, v, relation), the two ends content digests | the weight, sign and provenance a re-assertion replaced (`edges.py:88-106`). Two producers, kept apart by provenance (`core/relations.py:7-16`): authored edges read off a note's own `supports::`, `contradicts::` and `contextualizes::` properties (`relations.py:140-158`), a function of the note's text and so recomputable; and interpreted edges from a model (`relations.py:192-210`) or a `link` request (`core/ingest/writer.py:521-535`), which never replace an authored one (`writer.py:526-530`) | +| verdict dispositions (`core/verdict/dispositions.py:59-64`) | the verdict's sequence number | `verdict_seq` | the row a second application replaced (`dispositions.py:86`); a fold of the verdict ledger, so recomputable from its prefix | ### 2.3 What the two-class picture misses The picture this note started from has two classes: ledgers that only append, where a past state is a prefix, and derived stores rewritten in place, which keep no past and are recomputed from the -ledgers. Read against the code it needs seven corrections. `[ESTABLISHED, each at the lines cited +ledgers. Read against the code it needs eight corrections. `[ESTABLISHED, each at the lines cited in §2.2 unless given]` 1. **The catalog is neither, and it is the gap.** It is the head of every landed item and the idempotence key (ING-7), rewritten in place, and outside one place no ledger holds its past. The version chains exist for `mirror_authored` only; for the dialogue, observed and curated - places the sequence of digests a path held is recorded nowhere. It has six writing methods - (`record`, `tombstone`, `remove`, `remove_digest`, `relabel_provenance`, - `migrate_rekey_doc_id`: `catalog.py:100-123`, `:160-172`, `:195-208`, `:210-241`, `:243-246`, - `:254-259`) called from seven modules of `core/ingest/` (`writer.py:419`, `:433`, `:518`; - `sync.py:201`, `:238`; `founding.py:110`; `dialogue.py:75`; `curated.py:80`; `purge.py:61`; - `mint_ids.py:252`), so a record of its past has to be written inside the catalog and not by a - caller. -2. **The attestations do not fill it.** An attestation names a digest and no path, and a landing - attests once per (action, digest): a path that returns to bytes it held before, or bytes that - land at a second path, leave no new record. The ledger is read back in wall-time order. + places the sequence of digests a path held is recorded nowhere. It has six writing methods: + `record` (`catalog.py:100-123`), `tombstone` (`:160-172`), `relabel_provenance` (`:195-208`), + `migrate_rekey_doc_id` (`:210-241`), `remove` (`:243-246`) and `remove_digest` (`:254-259`). + A seventh write is the migration's, which fills `doc_id` at open (`catalog.py:91`). The + callers are seven modules of `core/ingest/` (`writer.py:419`, `:433`, `:518`; `sync.py:201`, + `:238`; `founding.py:110`; `dialogue.py:75`; `curated.py:80`; `purge.py:61`; + `mint_ids.py:252`) and one script, the only caller of `relabel_provenance` + (`scripts/migrate_provenance_split.py:61`); `remove` has no caller. No statement outside + `catalog.py` writes the table. So a record of its past written inside the catalog misses + nothing, and one written by a caller would. +2. **The attestations do not fill it.** An attestation names a digest and no path. In the + dialogue, observed and curated places a landing attests once per (action, digest), so a path + that returns to bytes it held before, or bytes that land at a second path, leave no new + record. In `mirror_authored` both append a version and are attested again + (`core/ingest/landing.py:77-86`, `core/ingest/writer.py:409-418`), which is the one place + whose past is already kept. The ledger is read back in wall-time order. 3. **Lexical postings and a changed item's vectors are not rewritten.** The units and the occupancies of a superseded version stay; only a `current` flag moves. They are generations in all but the stamp. And a stamp on the row would be wrong: a path that returns to bytes it held @@ -239,11 +281,12 @@ in §2.2 unless given]` their words; the version rows and the attestations still name the digests; and the purged text is still returned by the vector table read at its earlier dataset versions, until a compaction with no retention, which the purge does not call. `[MEASURED §11]` The relation edges whose - endpoint is the digest and the interpreted artifacts whose subject it is are not touched - either, and no deletion attestation is written, though the attestation store's header says one - is (`core/attestation/store.py:3-6`; no call in `purge.py` or `scripts/purge_raw.py`). A - snapshot that read those stores at a cut would return what the purge left, so §6.1 states what - an erasure must reach before any of them is read at a cut. + endpoint is the digest and the interpreted artifacts whose `derived_from` names it are not + touched either, nor are the curated store, the dream claims, the staging rows and the claim + ops (§6.1 lists each), and no deletion attestation is written, though the attestation store's + header says one is (`core/attestation/store.py:3-6`; no call in `purge.py` or + `scripts/purge_raw.py`). A snapshot that read those stores at a cut would return what the + purge left, so §6.1 states what an erasure must reach before any of them is read at a cut. 7. **A reset takes the ledgers with the derived stores.** Its targets are the raw store, the vector store, the catalog, the attestations, the version chains, the chat log and the stores derived from them (`ops/lifecycle/launcher.py:1748-1800`); the commit ledger and the @@ -252,29 +295,41 @@ in §2.2 unless given]` (`launcher.py:1779-1780`). The lexical index and the relation edges are not among the targets, so they outlast a reset with rows about items that are gone. Whatever the intent, no chain of an instance survives a reset with its positions, so a reset opens a new history (§8). +8. **A path written again after a delete continues the deleted note's history.** A re-record of + an existing path keeps the stored identity, and a tombstoned row stays in the catalog + (`catalog.py:103-121`, `:160-172`), so the version chain of the identity appends + (`core/stores/versions.py:109-119`): a new note written at a deleted note's path has the + deleted note's versions under it. §6.2 seals them. ## 3. The cut ### 3.1 Chains and positions -A chain is an append order a store already records, or the one §3.2 adds; a position is a prefix -length of it. `[DERIVED from global-event-clock §2.2, generator g1]` +A chain is an append order a store already records, or one this note adds; a position is a +prefix length of it. `[DERIVED from global-event-clock §2.2, generator g1]` | chain | store | position | today | |---|---|---|---| -| `land:`, one a provenance class | the landing log (§3.2), in the catalog's file | `seq`, from 1, never given twice | not built | +| `land`, one or more a provenance class | the landing log (§3.2), in the catalog's file | `seq`, from 1, never given twice | not built | | `chat` | the chat log | a sequence number beside each row; within a session it is the turn order | the order is recorded, the number is not | | `att` | the attestation ledger | a sequence number beside each row | the order is recorded, the number is not; the ledger is read in wall-time order | | `repo` | git, mirrored by the commit ledger and the per-commit readings | a commit, standing for its ancestors | recorded | -| `interp` | interpreted artifacts, relation edges, claim ops | a generation (§5.4) | not built | +| `interp`, one a store | interpreted artifacts with their hyperedges, interpreted relation edges, claim ops: rows of the class `interpreted` only | a sequence number a write (§5.4) | not built | +| `decl` | authored supersessions | a sequence number a declaration | not built | | `staging` | the staging store | its generation | recorded | -| `runs` | the run ledger | a sequence number | recorded as insertion order | +| `runs` | the run ledger, with the structural snapshot of a pass | a sequence number | recorded as insertion order | | `use` | the utility field's use log (dn-utility-field §3.1) | the tick | not built | +| `cuts` | the recorded cuts (§3.3) | `seq` | not built; no chain reads it | -Three choices are made here. +Four choices are made here. -**The position is the store's, not the document's.** The spine's frontier has a pair per document -(`spine.py:222-234`), which is a frontier of millions of pairs on a corpus instance, where one +**The position is the store's, not the document's.** The spine's frontier has a pair per version +chain and a pair per chat session (`spine.py:414-427`, `:428-445`). The version chains exist for +one place, so on a corpus instance, whose items land in `observed` +(`ingress/sync_corpus.palace:5`, `core/ingest/table.py:241-251`), today's frontier has no pair +for them at all. Giving every place a per-document chain, which is decision D1's first +alternative, is what would make a frontier of one pair an item, ten million at the scale the +repository's records plan for (`docs/experiments/corpus-measurements-2026-11-07.md:94-96`). One position a store with the per-path order inside it says the same thing (CLK-2: a frontier cut needs only its cross-store edges checked). `[DERIVED]` The version chains stay as they are: the log carries each landing's document and version number, so a document's chain is the log's @@ -283,7 +338,19 @@ sub-chain, and the versions store remains the primary record of supersession. **Where clearances separate rows the chain is per class.** A position counts every event before it, so on a chain that mixes classes a reader of one class learns from its positions how many landings the others made (`Witness.position_channel`), and a snapshot under a grant reads only the -chains the grant names and the cut on them (`snapshot_congr`). `[THEOREM: SNP-6]` +chains the grant names and the cut on them (`snapshot_congr`). `[THEOREM: SNP-6]` So the `interp` +chains hold rows of the class `interpreted` only: the relations a note declares are of the +note's class and are recomputed from the note at the cut (§5.4), not numbered with the model's. + +**A chain is keyed by an id, and its class is a label.** A certificate and a recorded cut name +chains, and a certificate of a cut does not verify on a store whose chains were renamed +(`Witness.rename_breaks_certificate`). The catalog's whole-class relabel +(`catalog.py:195-208`) changes the class of every row at once, and its one use merges a class +into another that already has rows (`scripts/migrate_provenance_split.py:58-61`). So a landing +chain has an integer id that is never reused or changed, and a row of a `landing_chains` table +gives the class it holds now. A relabel rewrites that label and no row of the log; after a merge +a class has two chains, and the read of a class is the union of its chains' reads. `[THEOREM +for the control; INFERENCE for the id]` **A position is a number the store keeps, never the row numbering it happens to have.** The chat log and the attestation ledger are keyed by text, and SQLite numbers their rows as the largest @@ -302,87 +369,167 @@ INFERENCE for the line, parked as SN-f]` ### 3.2 The landing log -One table in the catalog's file, written by the catalog's own methods in the transaction that +Two tables in the catalog's file, written by the catalog's own methods in the transaction that writes the catalog's row, so the key and its log entry land together, no caller can write one without the other, and ING-7's order is unchanged (the key last, now two rows of one transaction): ```sql +CREATE TABLE landing_chains ( + chain INTEGER PRIMARY KEY, -- the chain's id: never reused, never changed + class TEXT NOT NULL, -- the provenance class it holds now; a relabel rewrites this only + secret BLOB NOT NULL -- 32 random bytes: the key of path_key +); CREATE TABLE landings ( - class TEXT NOT NULL, -- the provenance class: one chain a class - seq INTEGER NOT NULL, -- the position in the class's chain, from 1, never given twice + chain INTEGER NOT NULL, -- landing_chains.chain + seq INTEGER NOT NULL, -- the position in the chain, from 1, never given twice kind TEXT NOT NULL, -- genesis | store | retire | move | unseal | horizon + path_key BLOB, -- hmac-sha256(secret, source_path): the key a hole keeps source_path TEXT, -- NULL once purged doc_id TEXT, -- the identity the event belongs to; NULL once purged version INTEGER, -- the version number, where the place keeps a chain digest TEXT, -- NULL for a retire, and once purged title TEXT, -- NULL once purged - att_head INTEGER, -- the head of `att` when the row was written (§3.5) + att_head INTEGER, -- the head of att when the row was written; NULL before SN-2 + ref_lo INTEGER, -- a horizon: the horizon; an unseal: the first retire it lifts + ref_hi INTEGER, -- an unseal: the last retire it lifts salt BLOB, -- 16 random bytes; NULL once purged commitment BLOB NOT NULL, -- sha256(salt, the row's fields): what the chain digests hash BLOB NOT NULL, -- sha256(the previous row's hash, commitment) closed_at INTEGER, -- the seq of the path's next event; NULL while it is the head - at TEXT NOT NULL, -- wall bookmark: lookup only, never an order - PRIMARY KEY (class, seq) + at TEXT, -- wall bookmark: lookup only, never an order; NULL once purged + PRIMARY KEY (chain, seq) ) WITHOUT ROWID; -CREATE INDEX landings_path ON landings (class, source_path, seq); -CREATE INDEX landings_closed ON landings (class, closed_at) WHERE closed_at IS NOT NULL; +CREATE INDEX landings_path ON landings (chain, path_key, seq) WHERE path_key IS NOT NULL; +CREATE INDEX landings_doc ON landings (chain, doc_id, seq) + WHERE doc_id IS NOT NULL AND doc_id <> source_path; +CREATE INDEX landings_closed ON landings (chain, closed_at) WHERE closed_at IS NOT NULL; ``` -The kinds are the catalog's writes. `store` is a landing (`record`). `retire` is the tombstone of -an identity no other active path holds. `move` is a tombstone that leaves the identity at another -path (the second half of a rename, which the writer tells from a delete by the catalog, -`writer.py:409-413`) and the owner-gated re-key of an identity (`catalog.py:210-241`). `genesis` -opens a class's chain and is followed by one row for each path the catalog holds at that moment, -in path order. `unseal` and `horizon` are §6.2's and §8's. A purge is not a kind: it empties rows -(§6.1). A relabel of a whole class (`catalog.py:195-208`) renames its chain and moves no position. - -The catalog is then the fold of the log: each path's last event (`stateOf`). The state at a -position is the same fold of the prefix (`stateAt`), read by one seek as the path's last event at -or under the position (`stateAt_eq_lastWrite`), or for every path at once through the closing -stamp: the rows with `seq ≤ c` and `closed_at` absent or above `c` (`genRead_gens`). The stamp is -the one field written after a row is appended, and it is a function of the rows, the position of -the path's next event (`gens_append_singleton`), so it can be rebuilt and it changes no read at a -cut inside the chain (`genRead_gens_append`). At most one row of a path is alive at a cut +**The kinds** are the catalog's writes. `store` is a landing (`record`). `retire` is the +tombstone of an identity no other active path holds. `move` is a tombstone that leaves the +identity at another path (the second half of a rename, which the writer tells from a delete by +the catalog, `writer.py:409-413`), the owner-gated re-key of an identity (`catalog.py:210-241`), +and the row that closes a path in one chain when a `record` gives it another class, its `store` +then landing in a chain of the new class. `genesis`, `unseal` and `horizon` are below, §6.2 and +§8. A purge is not a kind: it empties rows (§6.1). A `record` that changes nothing, the same +path, digest, title, class and identity as the path's open row, appends nothing: the log is of +the changes of the map, and the catalog's `updated_at` is a bookmark (the curated lane re-lands +an unchanged digest after a plane reset, `core/ingest/curated.py:66-82`). + +**Which chain a landing goes to.** The chain that holds the path's last event; for a path with +no event, the newest chain of its class, opened if the class has none. So a relabel moves no row +and no position (§3.1), and after a merge both chains go on growing, each with the paths it +holds. + +**The commitment and the hash.** `commitment` is SHA-256 over the salt followed by the canonical +JSON (keys sorted, no white space, UTF-8) of the object with the fields `chain`, `seq`, `kind`, +`source_path`, `doc_id`, `version`, `digest`, `title`, `att_head`, `ref_lo`, `ref_hi` and `at`. +`closed_at` is out, since it is written later, and so is `path_key`, which is an index key. +`hash` is SHA-256 over the previous row's `hash` followed by the commitment; the first row's +previous hash is 32 zero bytes, and after a history window (§9.2) it is the hash of the last row +dropped, kept in the `horizon` row. The chain is hashed like the prediction ledger +(`eval/predictions/ledger.py:1-12`), with one difference that §6.1 needs: a row's hash covers a +commitment to the row and not the row, so a purge can empty the row and keep the chain +(`commitments_purge`, `verifies_purge`). `[THEOREM: SNP-9]` + +**The key of a hole.** `path_key` is a keyed hash of the path under the chain's secret. It is +what a read by path seeks on, and it is the one name a purged row keeps, so a hole still shadows +the path's earlier versions (§6.1). `version` and `att_head` are the two fields a caller +supplies: `record` gains a `version` argument, passed by the writer's last step from the version +it just appended or found (`writer.py:408-419`, `:433`; `sync.py:201`) and left out where the +place keeps no chain; `att_head` is the attestation ledger's head read inside the key's +transaction, after the landing's own attestation, and stays `NULL` until SN-2 numbers that +ledger, which reads as the end of the ledger's genesis (§8). + +**The genesis.** At the first open after the migration that fills `doc_id` +(`catalog.py:77-92`), each class the catalog holds gets a chain: a `genesis` row, then the +catalog's rows of the class in path order, an active path as one `store` and a tombstoned path +as a `store` of the digest it held followed by a `retire`, then a `horizon` row whose `ref_lo` +is its own position. The order inside the block is not history, so the positions before the +`horizon` are under it (§8). A class that first appears later opens its chain at its first +landing, with a `genesis` and a `horizon` and nothing between. + +The catalog is then the fold of the log: each path's last event (`stateOf`), an active row for a +`store`, a tombstoned row for a `retire` with the digest of the path's last `store`, and no row +when that `store` is a hole or the path's last event is a `move`. The state at a position is the +same fold of the prefix (`stateAt`), read by one seek as the path's last event at or under the +position (`stateAt_eq_lastWrite`), or for every path at once through the closing stamp: the rows +with `seq ≤ c` and `closed_at` absent or above `c` (`genRead_gens`). The stamp is the one field +written after a row is appended, and it is a function of the rows, the position of the path's +next event (`gens_append_singleton`), so it can be rebuilt and it changes no read at a cut inside +the chain (`genRead_gens_append`). At most one row of a path is alive at a cut (`length_filter_selects_le_one`), which is L7's falsifier turned into a theorem. `[THEOREM: SNP-5]` The store's own precedent is the staging store: a generation clock, an admission stamp and a tombstone stamp on each row, and `read_at(g)` as exactly this predicate (`core/stores/staging.py:232-244`). `[ESTABLISHED]` -The chain is hashed like the prediction ledger (`eval/predictions/ledger.py:1-12`), with one -difference that §6.1 needs: a row's hash covers a commitment to the row and not the row, so a -purge can empty the row and keep the chain (`commitments_purge`, `verifies_purge`). `[THEOREM: -SNP-9]` - ### 3.3 The cut and its record A cut is a position for every chain of §3.1: for an instance, about a dozen integers. `[DERIVED]` The read at a cut is the prefix of every chain (`readAt`), and everything else in this -note is a function of that. A cut is worth recording when it is consistent (§3.5) and the stores -were quiescent when it was taken, which is the event clock's certified frontier: between two jobs -of the one writer, with the handoff empty, the head of every chain is such a cut (GC-N3). -`[ESTABLISHED: global-event-clock §2.4]` +note is a function of that. A cut is worth recording when it is consistent (§3.5) and certified +in the event clock's sense. GC-N3 names three certificates +(`docs/design-notes/global-event-clock.md:175-186`): the commit, which certifies the strata the +repository backs; trough quiescence, an empty queue with no queued and no running job +(`core/temporal/spine.py:197-206`), which certifies that no causality of the core is in flight; +and the empty handoff, which certifies that nothing is in flight between the edge and the core. +A cut across strata composes the three, and the spine refuses a cut whose certificate it cannot +source (`spine.py:275-281`, `:1064-1084`). `[ESTABLISHED]` + +So a cut is recorded at a trough and at no other moment. Two things ask for one: the trough +itself, when the queue and the handoff are empty and the frontier moved since the last record; +and the owner's command, which is served at the next trough, or at once when no daemon runs. The +sensor reading a commit does not record a cut: it reads inside its job +(`ops/code_sensor.py:404-418`), where the trough certificate is refused. A record names the +newest commit of the ledger as its `repo` position, so it covers every commit sensed since the +record before it, and §3.4 says what a commit's name resolves to. + +A recorded cut is a row of a chain of its own: -A recorded cut is a row of a `cuts` table beside the log and an attestation of it. An attestation +```sql +CREATE TABLE cuts ( + seq INTEGER PRIMARY KEY, -- the position in the records' chain, from 1 + id BLOB NOT NULL UNIQUE, -- sha256 of the canonical bytes: the cut's name + prev BLOB, -- the previous record's id; NULL for the first + reason TEXT NOT NULL, -- trough | command + commit_sha TEXT, -- the newest commit of the ledger; NULL with no repository + frontier TEXT NOT NULL, -- JSON: [[chain, position, digest or null, horizon], ...] + certs TEXT NOT NULL, -- JSON: the commit, trough and handoff evidence strings + attestation BLOB, -- the attestation of action cut; NULL with no attestor + at TEXT NOT NULL -- wall bookmark: the key a date is looked up by +); +CREATE INDEX cuts_at ON cuts (at); +CREATE INDEX cuts_commit ON cuts (commit_sha) WHERE commit_sha IS NOT NULL; +``` + +The id is the hash of the record's canonical bytes: the JSON, keys sorted and no white space, of +the previous id, the reason, the commit, the frontier in chain order (each chain's name or id, +its position, the digest of its prefix where the chain is hashed (§3.6) and its horizon (§8)) +and the certificates as the spine sources them. The bookmark is not in the id. An attestation has no field for a payload: it names an action, input and output hashes and its parents -(`core/attestation/record.py:51-62`). So the record is content-addressed: its id is the hash of -its canonical bytes (the frontier, the digest of each chain's prefix at it (§3.6), the horizons in -force (§8), the quiescence certificates as the spine sources them (`spine.py:1064` on), the reason -it was taken, the previous record's id), with a wall bookmark beside it; and the attestation, of -action `cut`, names the id as its output and the previous cut's attestation as its parent, passed -as the batched landing passes its parents (`writer.py:427-430`). The recorded cuts are then a -chain inside the attestation ledger, signed when attestations are, and the id is the cut's name. -Since each record is the head of every chain at some moment and chains only grow, the recorded -cuts are totally ordered. `[INFERENCE, falsifier SNF-3]` +(`core/attestation/record.py:51-62`). So the record's attestation, of action `cut`, names the id +as its output and the previous record's attestation as its parent, and it is built and signed +as any other is (`core/attestation/attestor.py:59-90`) but kept in the record's row and not +appended to the ledger that landings read. `[INFERENCE, falsifier SNF-3]` + +That last point is forced. A record reads from the prefix of every chain it certifies, and every +landing reads from the attestation ledger. If records sat on that ledger, a chain that could +serve only a position below one a record certified would exclude the record, the ledger's +prefix would stop before it, and every landing attested later would go with it: one chain read +low would take every landing chain to its empty prefix (`Witness.record_drags`). On a chain of +their own, which no event reads, the records constrain nothing (§3.5). `[THEOREM: SNP-10]` -Three moments record one: the code sensor reading a commit (`ops/code_sensor.py:404-418`, where it -already attests the commit), so that every commit of the ledger has a cut; the trough, when the -frontier moved since the last record; and the owner's command. At the kilobyte a row the -attestation ledger takes in the repository's records -(`docs/experiments/corpus-measurements-2026-11-07.md:107`) a recorded cut is about two kilobytes -with its row. A record a job would be tens of megabytes a day at the job rate those records show -(720 an hour, `corpus-measurements-2026-11-07.md:94-95`); a record a sensed commit and a moved -trough is far less, and the cadence is parked (SN-a). +Since each record is the head of every chain at some moment and chains only grow, the recorded +cuts are totally ordered. A record is about 2.7 kilobytes by arithmetic from its fields, not +measured: twelve chains at about 110 bytes each in the frontier, the certificates, and an +attestation at the 1,060 bytes a row of the attestation ledger takes in the repository's +records (`docs/experiments/corpus-measurements-2026-11-07.md:107`). A record at every trough +that moved is at most one a job. At the job rate those records show, 720 an hour +(`corpus-measurements-2026-11-07.md:94-95`), a record a job would be 47 megabytes a day; but +those were sync jobs that mostly land nothing, and a job that moves no chain asks for no record. +An instance with thirty troughs a day that moved writes 81 kilobytes a day. The cadence is +parked (SN-a). ### 3.4 Names @@ -391,16 +538,23 @@ trough is far less, and the cadence is parked (SN-a). | name | resolves to | exact | |---|---|---| | `head` | the head cut; the answer is the answer without `as of` (`view_head`) | yes | -| `cut:` and a recorded cut's id, or a prefix that names one | that record's frontier | yes, and checkable against its certificate | -| a commit's sha or an unambiguous prefix, as today | the cut recorded when the sensor read the commit; where none was recorded, the commit on `repo` and the empty prefix on every chain whose horizon is later (§8) | on `repo` always; elsewhere from the first recorded cut | -| a date or a date and time | the last recorded cut whose bookmark is at or before it | to the cadence of the records; the answer names the cut it read | +| `cut:` and a recorded cut's id, or a prefix that names one | that record's frontier | yes, and checkable against its certificate on the chains it digests | +| a commit's sha or an unambiguous prefix, as today | the frontier of the first record that holds the commit, with `repo` lowered to the commit, resolved as §3.5 says. For a commit sensed before the first record: the commit on `repo` and the empty prefix elsewhere | on `repo` for the tree; elsewhere a consistent cut between two records, which the answer names. It carries the commit certificate and not the trough's | +| a date or a date and time | the last recorded cut whose bookmark is at or before it. A date after the newest record is the newest record, never the head | to the cadence of the records; the answer names the record, and says when the head has moved since | + +A commit's name needs the resolution because the sensor's attestation of a commit reads from the +commit (`code_sensor.py:413-418`): with `repo` lowered, the attestation of the next commit is +outside the cut, so `att` stops before it, and the landing chains stop at the last landing +attested before it. A chain that reads nothing, as `chat`, stands at the record. The cut read is +then no later than the record on any chain and holds nothing that read a later commit. +`[DERIVED]` Wall time enters in the last row only, as a lookup key into bookmarks, and the cut it selects is ordered by the chains (Law C4; the staging store's sweep resolves wall time to a generation the -same way, `staging.py:26-30`). A commit is resolved by the moment the palace read it, which is an -event of its own chains, and not by the commit's date, which is another clock's. A branch or a -tag is not a name: it moves. The grammar does not change; the names it accepts do, and the answer -always carries the cut read. `[INFERENCE, falsifier SNF-3]` +same way, `staging.py:26-30`). A branch or a tag is not a name: it moves. A name that resolves +to nothing is refused whether or not the stores hold a reading, which is not so today (§2.1). +The grammar does not change; the names it accepts do, and the answer always carries the cut +read. `[INFERENCE, falsifier SNF-3]` ### 3.5 Consistency and resolution @@ -408,28 +562,38 @@ An event of one chain may read from an event of another: `R k i k' j` says the ` chain `k` reads from the `j`-th of chain `k'` (the event clock's generators g2 and g3). The references between the chains of §3.1 are these. `[ESTABLISHED: read off the writers]` -- a landing reads from its attestation and, where the place keeps chains, its version row, by the - order the writer lands them in (`core/ingest/writer.py:397-436`: the version, the attestation, - the key last); -- a causal edge reads from the turn that witnessed it and, when it ends at a commit, from the - commit (`causal_edges.py:58-60`, `integrator.py:134-137`); -- a citation reading reads from its commit; -- an interpreted artifact reads from its subjects' landings and from the run that produced it; - a relation edge from the landings of its two endpoints; -- a recorded cut reads from the prefix of every chain it certifies. +- a landing reads from its attestation and, where the place keeps chains, its version row, by + the order the writer lands them in (`core/ingest/writer.py:397-436`: the version, the + attestation, the key last); +- the attestation of a sensed commit, and of a projection of it, reads from the commit + (`ops/code_sensor.py:413-418`, `:489-492`); +- a citation edge reads from its commit and from the projection that wrote it; +- an interpreted artifact reads from the digests its `derived_from` names, through the artifacts + it names there, and from the attestation its `attestation_id` names + (`core/stores/derived.py:186-191`); an interpreted relation edge reads from the landings of its + two endpoint digests; +- a recorded cut reads from the prefix of every chain it certifies, and nothing reads a + recorded cut. + +A causal edge reads from the turn that witnessed it and, when it ends at a commit, from the +commit (`causal_edges.py:58-60`, `integrator.py:134-137`); it is recomputed at a cut (§5.5), so +it is a filter of a read and no row of a chain. A cut is **consistent** when every source of an event inside it is inside it (`Consistent`): no fact whose sources lie after the cut, every cross-chain reference closed. `[THEOREM: SNP-8]` -- Consistent cuts are closed under the pointwise meet and join, with the empty cut at the bottom - (`Consistent.inf`, `Consistent.sup`, `consistent_zero`): a sublattice of the cuts, so a - distributive lattice (`consistentCuts`). -- They are the event clock's cuts among the frontier cuts: a cut is consistent exactly when the - events under its frontier are a down-set of the order the chains and the references generate - (`consistent_iff_isCut`, on CLK-2's `IsCut` and `frontierCut`). -- Every frontier has exactly one greatest consistent cut under it, and a later frontier has a - later one (`exists_resolves`, `Resolves.unique`, `Resolves.mono`); a consistent frontier is its - own (`resolves_self`). This is what a name's resolution is. +- Consistent cuts are the event clock's cuts among the frontier cuts: a cut is consistent + exactly when the events under its frontier are a down-set of the order the chains and the + references generate (`consistent_iff_isCut`, on CLK-2's `IsCut` and `frontierCut`). +- So they are closed under the pointwise meet and join, with the empty cut at the bottom: this + is CLK-2, which the ledger already states for frontiers (`docs/LAWS.md:114`, + `Clock.IsCut.frontier_inf`, `Clock.IsCut.frontier_sup`), read through that equivalence + (`Consistent.inf`, `Consistent.sup`, `consistent_zero`, `consistentCuts`). It is not a new law. + `[THEOREM: CLK-2]` +- What SNP-8 adds is resolution. Every frontier has exactly one greatest consistent cut under + it, and a later frontier has a later one (`exists_resolves`, `Resolves.unique`, + `Resolves.mono`); a consistent frontier is its own (`resolves_self`). This is what a name's + resolution is. - Consistency is append invariant: the references a store gains by growing start at events at or past its old head, so a cut inside the old head that was consistent stays consistent (`Consistent.of_grown`). @@ -438,35 +602,74 @@ So ING-7's invariant, that a key implies its rows, holds at every consistent cut the head: a cut that holds a landing holds its attestation and its version. `[DERIVED]` **Where the references are recorded.** The resolver has to know, for an event, where its sources -lie. Each row of a chain that reads another records the head of the chain it reads at the moment -the row was written: the landing's `att_head`, a kept generation's birth (§5.4), a causal edge's -turn and commit, a recorded cut's whole frontier. With one writer a row's sources were all -written before it, so the head at its writing bounds them, the bound is sound (it can only make -fewer cuts consistent, each of them consistent for the true references), and it rises along the -chain. `[DERIVED from the one-writer rule, dn-ingress D3]` - -**The resolver.** A name that selects a recorded cut needs none: the record is consistent. For -any other frontier it is a descent: lower each chain's position to the first event inside the cut -whose recorded bound lies outside it, and repeat until nothing moves, which is at most as many -passes as the frontier has positions. The library proves the cut exists and is unique; the attack -module runs the descent against the definition by enumerating every cut under the frontier (seed -461), and SN-2 transcribes that descent. `[THEOREM for existence and uniqueness; the descent -attacked, not proved]` +lie. A landing records the head of `att` at its writing (`att_head`); an attestation of a +commit names the commit; a recorded cut carries its whole frontier. With one writer a row's +sources were all written before it, so the head at its writing bounds them, the bound rises +along the chain, and it is sound: a cut consistent for the recorded bounds is consistent for the +true references (`Consistent.of_bound`). It can only make fewer cuts consistent. `[THEOREM: +SNP-8; DERIVED from the one-writer rule, dn-ingress D3, for the bound]` + +**Rows that are filtered, not resolved.** An interpreted row records no head of the chains it +reads, and it needs none. No chain reads the `interp` chains, so their positions constrain no +other chain (`resolvesIn_update_of_unread`), and the closure of their own references is kept row +by row: a row is in the read at a cut when its position is at or under the cut, the attestation +it names is at or under the cut on `att`, and every digest its sources reach is a head at the +cut (§5.4). A row whose sources lie outside the cut is withheld and a later row whose sources +lie inside is served. That read is a derived view of the prefixes (SNP-5) which holds no fact +whose sources lie after the cut; it is not the prefix of the chain. `[DERIVED]` + +**The resolver.** A name that selects a recorded cut needs none while every chain serves the +record's positions: the record is consistent. Otherwise it is two steps alternated until +nothing moves: + +1. the floor: each chain's position is lowered to the greatest position at or under it that the + chain serves (§7.1); +2. one pass of the descent: each chain's position is lowered to the first event inside the cut + whose recorded bound lies outside it. + +A round that moves anything lowers a position, so there are at most as many rounds as the +frontier has positions. Neither step alone is enough, in either order: the descent leaves the +served positions, and the floor breaks consistency again. The library proves that the cut +exists and is unique, with and without served positions. The attack module runs the descent +against the definition by enumerating every cut under the frontier (seed 461) and the +alternation against the greatest consistent served cut (seed 492), with each one-shot order as +a control that is refuted (493, 494). SN-2 transcribes the alternation. `[THEOREM for existence +and uniqueness; the resolver attacked, not proved]` ### 3.6 Certificates The certificate of a cut is, for each chain, the digest of its prefix under the chain's hash -(`certify`): for a landing log the `hash` of the row at the position, for `repo` the commit's sha, -which is git's own chain, for `chat` and `att` the running hash of the chain table SN-2 adds -beside them. A store verifies a certificate when its own prefixes have those digests (`Verifies`). -`[THEOREM: SNP-9]` +(`certify`). A store verifies a certificate when its own prefixes have those digests +(`Verifies`). `[THEOREM: SNP-9]` + +**Which chains have a hash.** A landing chain from SN-1, as the `hash` of the row at the +position. `repo` always: the commit's sha is git's own chain. `chat`, `att`, `staging` and +`runs` from SN-2, as the running hash of the chain table added beside each. The `interp` chains +and `decl` from SN-6, and `use` with the stage that builds the field. A record carries a digest +for each chain that has a hash when it is taken and a null for the others, and `verify` says +which chains it checked. Until a chain is hashed, a recorded cut fixes its position and nothing +about its rows, and the two conclusions below do not reach a view that reads it. `[INFERENCE]` - **Reproducible.** The certificate of a cut verifies on every extension of the store (`verifies_certify_of_extends`): the same store later, a restored backup, a clone. -- **Checkable.** Under a collision-free digest, two stores that verify one certificate have the - same read at its cut (`Verifies.readAt_eq`), so every derived view at it is the same on both - (`Verifies.view_eq`). The control is a digest with collisions, under which two different chains - of one length agree (`Witness.digest_collides`). +- **Checkable, for what it digests.** Under a collision-free digest, two stores that verify one + certificate have the same prefix of each digested chain at its cut (`Verifies.readAt_eq`), so + every derived view of those prefixes is the same on both (`Verifies.view_eq`). A landing chain + digests commitments, so what is pinned directly is the commitments. A commitment that is + binding, as a salted SHA-256 is under the same hypothesis, pins the events behind them: two + committed stores that verify one certificate were made from the same events at its cut + (`Verifies.readAt_eq_of_committed`), and under one erasure they read the same store with holes + (`Verifies.contents_eq`). The control is a digest with collisions, under which two different + chains of one length agree (`Witness.digest_collides`). +- **What it does not attest.** An erasure: a store verifies a certificate after a purge exactly + when it did before (`verifies_purge_iff`), so a backup taken before a purge and restored later + verifies every certificate and still holds what was purged. A restore therefore has to apply + again the purges recorded since, which §6.1's attestation of a purge makes listable. A seal: a + retire written after a certified cut changes what is served at it, and the certificate still + verifies (`Witness.seal_not_certified`). The grant, and the identity of the embedder and the + tokenizer (D5). So an answer at a recorded cut is the same on two stores that verify it for + one erasure, one set of seals, one grant and one derivation identity, and not otherwise; for + the grant and the erasure together that is `Verifies.shown_eq`. - **Cheap.** A certificate extends over the events since an earlier one (`certify_digest_readBetween`), and the meet and the join of two certified cuts are certified from the two certificates alone, chain by chain the earlier or the later digest (`certify_inf`, @@ -477,7 +680,7 @@ beside them. A store verifies a certificate when its own prefixes have those dig Checking a certificate against a store is one seek a chain, the stored hash at the position against the certified digest, 3 microseconds; recomputing a chain from its first row is the -audit, 0.8 s for a million rows. `[MEASURED §11]` +audit, 0.7 to 0.8 s for a million rows. `[MEASURED §11]` ## 4. Reads @@ -486,42 +689,56 @@ audit, 0.8 s for a million rows. `[MEASURED §11]` `read_at(c)` is the prefix of a chain at a position and `read_between(a, b)` the events after `a` and up to `b` (`readAt`, `readBetween`). The second composes with the first and with itself (`readAt_append_readBetween`, `readBetween_append`), so nothing more is needed of a ledger than -these two. `[THEOREM: SNP-3]` For each ledger, the read, the index it needs and its cost: +these two. `[THEOREM: SNP-3]` For a ledger of keyed rows the read a caller wants is the state of +a key at a cut, which is a function of the prefix (`stateAt`); the table names it `state_at`. +For each ledger, the reads, the index each needs and the cost. A cost with no grade is an +estimate from the measured log, the same engine and the same shape of index, and is not +measured: | ledger | `read_at(c)` | `read_between(a, b)` | index | cost | |---|---|---|---|---| -| landing log, a class | one path: its last event at or under `c`; every path: the rows with `seq ≤ c` not closed at or under `c` | the rows with `a < seq ≤ b` | the primary key, `landings_path`, `landings_closed` | one path 3 to 4 µs through `landings_path`, and 6 ms when the planner takes the primary key, so the statement names the index; 1,000 positions 0.7 ms; every head §4.2 `[MEASURED §11]` | -| a document's version chain | the log's rows of the identity at or under `c` | the same rows in the range | `(class, doc_id, seq)`, partial where the identity is not the path | as one path's | -| raw objects | the object of the digest the log names at `c` | the objects the delta names | none: content-addressed | one file | -| chat log | a session's turns whose chain number is at or under `c` | the turns numbered in the range | the chain table's key and its `(session, turn)` | a range | -| attestations | by id, as today; in order, the chain table at or under `c` | a range of the chain table | the chain table | a range, where `all()` sorts the ledger by wall time and `producers_of` decodes every record today (`core/attestation/store.py:127-132`, `:159-165`) | -| citation readings | the reading of the commit, as today | the paths whose blob differs between the two commits, by the commit ledger's `files` rows (`ops/code_snapshot.py:59-69`), with their readings at each | exists: `(target_ref, commit_sha)` and `(source_ref, commit_sha)` (`reference_edges.py:149-156`) | as today | -| commit ledger | the commit and, through git, its ancestors | git's range | none: the ledger keeps no parent, so the range is git's | git's | -| staging | `read_at(g)`, as built | the rows admitted or tombstoned in the range | `staged_rows_generation` exists; none on the tombstone stamp | as built | -| run ledger, verdicts, observation history | by key; in insertion order | a range | a sequence number, when a consumer needs one | none needs one yet | - -The landing log's two reads are the ones every other store's read at a cut goes through, since -it is the log that says which version of a path a cut holds (§5). +| landing log, a chain | the rows with `seq ≤ c`; `state_at` of one path: its last event at or under `c`, by its key; every head of a class: the `store` rows with `seq ≤ c` not closed at or under `c`, over the class's chains | the rows with `a < seq ≤ b` | the primary key, `landings_path`, `landings_closed` | one path 3 µs through `landings_path`, and 1.4 µs for its keyed hash; 1,000 positions 0.64 to 0.69 ms; every head §4.2 `[MEASURED §11]` | +| a document's version chain | the log's rows of the identity at or under `c`, after its last retire (§6.2) | the same rows in the range | `landings_path` where the identity is the path, `landings_doc` where it is not | 9 µs for seven versions through the index, and 49 to 57 ms when the planner takes the primary key, so the statement names the index `[MEASURED §11]` | +| raw objects | the object of the digest the log names at `c` | the objects the delta names | none: content-addressed | one file read, the object's bytes | +| chat log | a session's turns whose chain number is at or under `c` | the turns numbered in the range | the chain table's key and its `(session, turn)` | a range of an integer key: of the order of the log's 0.7 ms a thousand rows | +| attestations | by id, as today; in order, the chain table at or under `c` | a range of the chain table | the chain table | the same order, where `all()` sorts the ledger by wall time and `producers_of` decodes every record today (`core/attestation/store.py:127-132`, `:159-165`) | +| citation readings | the edges of the commit projected at or under `c` on `att` (§5.1) | the paths whose blob differs between the two commits, by the commit ledger's `files` rows (`ops/code_snapshot.py:59-69`), with their readings at each | exists: `(target_ref, commit_sha)` and `(source_ref, commit_sha)` (`reference_edges.py:149-156`); the projection's position is one integer column more | one indexed lookup a reference, as today | +| commit ledger | the commit and, through git, its ancestors | git's range | none: the ledger keeps no parent, so the range is git's | one `rev-list`, not measured | +| staging | `read_at(g)`, as built | the rows admitted or tombstoned in the range | `staged_rows_generation` exists; none on the tombstone stamp | a range of the generation index; a scan for the tombstones | +| run ledger, verdicts, structural snapshots, observation history | by key; in insertion order | a range | a sequence number, from SN-2 for the run ledger | no reader at a cut yet | + +The landing log's reads are the ones every other store's read at a cut goes through, since it +is the log that says which version of a path a cut holds (§5). ### 4.2 Every head at a cut -Reading the head of every path of a class at a cut is the rows with `seq ≤ c` whose `closed_at` -is absent or above `c`. On a synthetic log of a million events over 100,000 paths it took 149 to -163 ms at the middle cut and 246 to 285 ms at and near the head. `[MEASURED §11]` The cost is the -part of the log the statement walks, not the size of the answer. Two readers need it: the -universe, for the strata it loads whole (`core/sentence/universe.py:275-299`), and the lexical -statistics at a cut (§5.3). The bound is the journal form: the heads kept at some recorded cuts -and continued over the events since (`stateAt_eq_foldl`), which costs the distance to the nearest -kept cut instead of the prefix. It is parked until an instance shows the need (SN-c). `[THEOREM -for the journal; INFERENCE for parking it, falsifier SNF-6]` +Reading the head of every path of a class at a cut is the `store` rows with `seq ≤ c` whose +`closed_at` is absent or above `c`. On a synthetic chain of a million events over 100,000 paths +it took 52 to 56 ms at a cut a tenth of the way in, 147 to 166 ms at the middle cut and 240 to +275 ms at and near the head. `[MEASURED §11]` The cost is the part of the log the statement +walks, about a quarter of a microsecond an event, and not the size of the answer. Two readers +need it: the universe, for the strata it loads whole (`core/sentence/universe.py:275-299`), and +the lexical statistics at a cut (§5.3). + +So the read from the log alone passes a tenth of a second at between a quarter and a third of a +million events in one chain, and the rule is by size. A chain under 250,000 events reads its +heads from the log. A chain over it keeps heads: the heads at some recorded cuts, continued +over the events since (`stateAt_eq_foldl`), which costs the distance to the nearest kept cut +instead of the prefix. That is built with SN-4 for an instance that has such a chain, and a +corpus instance has one from the start: ten million items are ten million events at the least. +An instance of a few thousand notes never needs it. `[THEOREM for the journal; INFERENCE for the +threshold, falsifier SNF-6]` ### 4.3 What the reads cost in bytes -A landing is 409 bytes in the log with its two indexes (the table 315, the path index 67, the -closing index 27), measured without the two integer columns `version` and `att_head`. -`[MEASURED §11]` A chain table's row is an integer, the row's key and a 32-byte hash. A recorded -cut is about two kilobytes (§3.3). None of it is content: the log holds paths, digests and -titles, which the catalog holds already. +On the fixture a landing is 434 bytes in the log with its indexes when the identity is the path +(the table 374, the key index 47, the closing index 13), and 396 when the identity is a short +id of its own (the table 315, the key index 47, the identity index 21, the closing index 13). +`[MEASURED §11]` The fixture's paths are 37 characters and its titles under twelve; a row grows +by the bytes of a longer path, twice where the identity is the path. A chain table's row is an +integer, the row's key and a 32-byte hash. A recorded cut is about 2.7 kilobytes by arithmetic +(§3.3). None of it is content: the log holds paths, digests and titles, which the catalog holds +already. ## 5. Derived data as a function of a cut @@ -540,17 +757,28 @@ table is built that way, and §5.2 says why its versions are not the snapshot. | derived store | a function of | held as | what it costs here | what would change the choice | |---|---|---|---|---| -| vectors (atoms, occupancies) | the chunk's text and the embedder's identity | version-keyed rows the plane keeps already; the log selects the version | no new bytes; a search over superseded rows, then a join with the heads at the cut | an instance that must drop superseded atoms (§9), after which a cut finds them pending | +| vectors (atoms, occupancies), in the plane and in the curated store for what landed through the catalog | the chunk's text and the embedder's identity | version-keyed rows the plane keeps already; the log selects the version | no new bytes; a search over every version's rows, then a join with the heads at the cut. Not measured: the rows searched are the current ones over the current share, three times as many where two thirds are superseded, as on the lexical fixture | an instance that must drop superseded atoms (§9), after which a cut finds them pending | | lexical units and postings | the chunk's text and the tokenizer's identity | version-keyed rows the index keeps already; the log selects the version; the statistics from the mask | no new bytes; 4,179 bytes a kept unit on synthetic text `[MEASURED §11]` | a query at a past cut over its budget at the instance's size: then statistics stored per class and per recorded cut | | chat events, causal edges | the transcript as retained at the cut, and the commits inside the cut | recomputed at the cut, the present rows a cache of the head | 6 ms a session of 2,000 records `[MEASURED §11]`; no bytes | a sentence that walks the causal fiber at a past cut over a second on a real instance (SNF-5): then generations, written with a diff | -| interpreted artifacts, hyperedges, relation edges, claim ops | a model's output: of nothing that can be computed again | generations, the replaced row archived with its interval | one archived row a replacement, which is thrown away today | a measured churn so low that declaring them outside the snapshot loses nothing | +| interpreted artifacts with their hyperedges, interpreted relation edges | a model's output: of nothing that can be computed again | generations, the replaced row archived with its interval | one archived row a replacement, which is thrown away today; how often a row is replaced is not measured | a measured churn so low that declaring them outside the snapshot loses nothing | +| the relations a note declares | the note's text at a version, and the titles the catalog resolves at the cut | recomputed from the heads at the cut | one parse of a note's properties a head that has any, kept in a memo by digest; no bytes | nothing | +| claim ops, authored supersessions | nothing: they are appended, keyed by their content | a position a first insert; the read at a cut is the rows at or under it | one integer a row | nothing | +| verdict dispositions | the verdict ledger | recomputed from the ledger's prefix | a fold over the verdicts inside the cut | nothing | | the similarity backbone | the vectors of the support | recomputed, as today | nothing | nothing | -| citation readings | the tree at the commit | one whole reading a commit, as built | 3,029,562 rows over 1,487 commits at 567 bytes a row in the repository's records | the store's size: then a row valid over a range of commits (SN-b) | +| citation readings | the tree at the commit and the extractor that projected it | append-only rows, as built, each stamped with the extractor's version and the position on `att` of the projection that wrote it; the reading of a commit at a cut is its rows stamped at or under the cut | one integer and a short string a row, on 3,029,562 rows over 1,487 commits at 567 bytes a row in the repository's records | the store's size: then a row valid over a range of commits (SN-b) | | code memberships | git's blob at the path | version-keyed by blob; git's tree selects the version | nothing new | nothing | | the utility field (not built) | the use log | a fold with kept checkpoints | a checkpoint a declared number of ticks | its own note's measurements | The figures for the citation readings are `docs/experiments/corpus-measurements-2026-11-07.md:106` -and `core/reference_view.py:15-16`. +and `core/reference_view.py:15-16`. `[ESTABLISHED]` + +The stamp on a citation edge is what makes its reading a function of a cut. Today a commit's +reading is the union of every projection of it so far (§2.2), so `as of` a commit answers +differently after a re-projection though the cut did not move, which is the reader SNP-1's +control refutes; and the commit's sha does not pin it. With the stamp, the reading at a cut is +the edges projected at or under it, a later projection is a later event, and the head reads +every projection as it does today. The rows the store holds when the stamp is added are stamped +with the `att` genesis, so their history starts there (§8). `[DERIVED from SNP-1]` ### 5.2 Vectors @@ -595,37 +823,71 @@ are the same kind of thing to this index: a mask over units whose statistics mus `[DERIVED]` The other forms cost more here. Recomputing means tokenizing every item alive at the cut, since -the statistics are the collection's and not the support's: right for a few hundred notes, not for -a corpus. A journal of the changes to the document frequencies has an entry a term a unit, no +the statistics are the collection's and not the support's: every unit of every head, where the +mask reads the units' stored lengths and postings. A journal of the changes to the document frequencies has an entry a term a unit, no fewer than the postings (122 a unit on the synthetic text). An index with its statistics built in cannot serve a cut, or a clearance, without a copy a mask; if the index moves to immutable -segments, a segment has to carry its statistics per class and per recorded cut, or leave them to -be computed from the mask. `[INFERENCE, falsifier SNF-7]` The tokenizer's identity is the +segments, a segment carries no statistics and they are computed from the mask, as they are +today, until a query at a past cut runs over its budget (SN-e). None of the three is measured +at a corpus's size. `[INFERENCE, falsifier SNF-7]` The tokenizer's identity is the present's, as the embedder's is: a changed tokenizer resets the index (`lexical.py:180-194`) and the backfill lands the active items, so a superseded version's units are derived again from the raw store when a cut asks for them. -### 5.4 Model output +### 5.4 Model output, and what is not model output -Interpreted artifacts, relation edges and claim ops are written by passes that call a model, and -each is keyed by what it is about, so a later pass over the same subjects replaces the row -(`core/stores/derived.py:209-216`, `core/stores/edges.py:88-106`). The output cannot be computed -again, so the two choices are to keep it by generation or to declare it outside the snapshot. -This note keeps it. `[INFERENCE, falsifier SNF-8]` +Three stores were read as one kind, and they are three. + +**The relations a note declares** are not model output. The edge store has two producers kept +apart by provenance (`core/relations.py:7-16`): an authored edge is read off a note's own +`supports::`, `contradicts::` and `contextualizes::` properties and resolved by title through +the catalog (`relations.py:140-158`), so it is a function of the note's text at a version and of +the catalog. At a cut it is recomputed: for each head at the cut that has such a property, the +property parsed from the raw object the log names, the title resolved among the heads at the +cut. Nothing is stored and the edge has its note's class. `[DERIVED from SNP-5]` + +**Claim ops and authored supersessions** are not rewritten in place. Each row is keyed by its +whole content (§2.2), so a second write stamps a bookmark and changes nothing else, and no +model writes either (`core/stores/claim_ops.py:14-15`; the supersessions are the owner's +declarations). They are append-only sets that lack a position. Each gets a sequence number at a +row's first insert, and the read at a cut is the rows at or under it. `[DERIVED]` + +**Interpreted artifacts and interpreted relation edges** are model output: written by a pass +that calls a model or by a `link` request (`core/relations.py:192-210`, +`core/ingest/writer.py:521-535`), each keyed by what it is about, so a later write replaces the +row (`core/stores/derived.py:209-216`, `core/stores/edges.py:88-106`). The output cannot be +computed again, so the two choices are to keep it by generation or to declare it outside the +snapshot. This note keeps it. `[INFERENCE, falsifier SNF-8]` The form is the one the observation stores use: archive, then replace (`core/stores/code_observations.py:211-254`, `core/stores/observation_history.py:46-56`). Each -store gets a sequence number a write (its chain; the three are written `interp` in §3.1), each -row the number it was written at, and a replaced row goes to a history table with the number it -was replaced at. The read at a cut is the row whose interval holds the position (`genRead`), and -at the head it is the present row (`genRead_gens_length`). `[THEOREM: SNP-5, SNP-4]` - -A kept row is served at a cut only when its sources are there. An artifact's subjects and a -relation edge's endpoints are content digests (`derived.py:186-189`, `edges.py:39-40`), so the row -is about particular versions: it is in the snapshot when it was written at or under the cut, every -digest it names is some path's head at the cut, and none of them is erased or sealed -(`mem_serve_iff`). `[THEOREM: SNP-7 for the erasure; DERIVED for the heads]` Until SN-6 builds -this the three stores serve two positions, the empty prefix and the head (§7.1). +store gets a sequence number a write, its chain; each row the number it was written at; and a +replaced row goes to a history table with the number it was replaced at. The read at a cut is +the row whose interval holds the position (`genRead`), and at the head it is the present row +(`genRead_gens_length`). `[THEOREM: SNP-5, SNP-4]` + +A kept row is served at a cut only when its sources are there, and what a row's sources are +differs between the two stores. + +- A relation edge's two ends are content digests (`edges.py:39-40`), so the row is about two + particular versions. +- An artifact's key is not its sources. The key hashes the kind, the subkind and the sorted + `subjects`, which are note titles (`derived.py:55`, `:97-100`; the callers pass titles, + `core/curator/curator.py:98`, `core/dreaming/dreamer.py:153`), so one row is replaced by a + later pass over the same titles whatever versions of those notes the two passes read. Its + sources are its `derived_from`: note digests, or the ids of other artifacts + (`derived.py:186-189`; `curator.py:175`, `dreamer.py:160`). The artifact records no run. Its + link to the pass that wrote it is the attestation it names (`derived.py:59`). + +So a kept row is in the read at a cut when four things hold: it was written at or under the cut +on its own chain; the attestation it names, if any, is at or under the cut on `att`; every +digest its sources reach is some path's head at the cut, where an artifact's sources are +followed through the artifacts it names, each as it stood at the cut, down to digests (the +store refuses a cycle, `derived.py:186-189`); and none of those digests is erased or sealed +(`mem_serve_iff`). `[THEOREM: SNP-7 for the erasure; DERIVED for the rest]` This is the row +filter of §3.5: it withholds a row and lowers no position. Until SN-6 builds it the `interp` +chains serve two positions, the empty prefix and the head (§7.1), and lowering them moves no +other chain, since nothing reads them. ### 5.5 The causal fiber @@ -646,11 +908,14 @@ The cost is an extraction a session: 6 ms for a synthetic session of 2,000 recor `[MEASURED §11]` The builder reads the causal store whole once a sentence (`core/sentence/universe.py:581-595`), so at a cut it would extract every session with a turn inside the cut, and a memo keyed by the session and its transcript's digest makes each -extraction happen once a process. Generations are the alternative: the rows kept, keyed by -session and order, each with the range of `chat` positions it was valid on, written with a diff so -that a session's growth adds its new events and closes only the rows that changed. They cost a -rewrite of the projector and the integrator and are kept for the instance that needs them -(SNF-5). +extraction happen once a process. By arithmetic from that figure, not measured: the first +sentence of a process that walks the fiber at a past cut pays 6 ms and one transcript read a +session, so 6 s and 0.8 GB read for a thousand sessions of the fixture's size, and the memo's +price after that. Generations are the alternative: the rows kept, keyed by session and order, +each with the range of `chat` positions it was valid on, written with a diff so that a session's +growth adds its new events and closes only the rows that changed. They need the projector and +the integrator written again, which is not sized here, and are kept for the instance that needs +them (SNF-5). ### 5.6 An instance with no embedder @@ -663,6 +928,14 @@ the order in which the drain reached the items, not the order in which they land universe takes the mirror's nodes from the plane's rows (`core/query.py:462-465`); at a cut it takes them from the log. `[DERIVED; ESTABLISHED for the present reads]` +One set of rows the log cannot give. The curated store is read by `near` and by `read` +(§2.2), and one of its two writers, `scripts/curate_local.py:96-108`, adds rows with no catalog +row, so no landing and no position. Such a row is outside the snapshot: at a cut it is not a +node, and the answer's note says how many curated rows have no landing and were not read. What +`ingest_curated` landed is in the log's `curated` chain and is read at a cut as a note is. The +repair is to route that script through the writer's `store`, as every other source is; it is +parked (SN-i) because it changes a writer and not a reader. `[INFERENCE]` + ## 6. Erasure and scope Two things are parameters of a read and no function of the cut, because they are the present's: @@ -672,43 +945,80 @@ what has been erased, and what the asker may see. No erased event is visible at any cut (`not_erased_of_mem_visible`), a larger erasure shows a sublist (`visible_sublist`), and two stores that differ only in erased events give every -derivation the same reading at every cut (`erased_invisible`): erased content is an argument of -no read. `[THEOREM: SNP-7]` +derivation of what is visible the same reading at every cut (`erased_invisible`). `[THEOREM: +SNP-7]` That is a statement about a reader that reads the visible events. It becomes a +statement about the code only when every reader of a store goes through the erasure, which is +what the table below is for. The erasure keeps positions. The store with a hole at each erased event has the head it had and commutes with the cut (`head_redact`, `redact_readAt`); an erasure that deletes rows moves the later ones up, and a read at a cut then holds an event from after it (`Witness.compact_moves`). `[THEOREM]` The plane's supersession log is the second kind today: after a purge, a later landing -at the path took position 1 again. `[MEASURED §11]` In the landing log a purge empties the row: -the path, the identity, the digest, the title and the salt become null, and the commitment and -the hash stay. The certificates keep verifying (`verifies_purge`), a reader reads a hole -(`contents_purge_committed`), and since the commitment was salted and the salt is gone, it can no -longer be tested against a guess of the content. `[THEOREM: SNP-9 for the chain; DERIVED for the -salt]` - -That last point is a rule the record already has: no tombstone keeps a content hash of purged -private text (`docs/design-notes/vector-membership-store.md:810-813`). A digest of purged bytes -is a test for those bytes. What a purge has to reach, against what it reaches today: - -| store | today, after a purge `[MEASURED §11]` | what a snapshot needs | +at the path took position 1 again. `[MEASURED §11]` + +**The hole keeps its key.** A purge is by digest, and it may take an old version of a path +that is still live, since only the digest's active references block it +(`core/ingest/purge.py:52`). If the emptied row lost its path, a seek by path would pass over it +and return the version before it as the path's head at a cut where the purged version was the +head; and a reader that dropped the holes before seeking would return a version from after the +cut (`Witness.keyless_hole`). So the row keeps `path_key`, the keyed hash of its path. On a +chain whose holes keep their keys, the read of a path at a cut is its last event at or under +the cut, returned as a hole when that event is erased, never an earlier version and never a +later one (`stateAt_holes`, `stateAt_holes_of_erased`, `not_erased_of_stateAt_holes`), and the +seek, the closing-stamp read and the fold still agree (`lastWrite_holes`, `genRead_gens_holes`). +`[THEOREM: SNP-7]` On the fixture, after the fifth of a path's ten versions was emptied, the +seek at a cut where it was the head returned the emptied row. `[MEASURED §11]` + +**What a purge empties in the log.** The path, the identity, the digest, the title, the salt +and the wall bookmark become null; the commitment and the hash stay. The certificates keep +verifying (`verifies_purge`), a reader reads a hole (`contents_purge_committed`), and since the +commitment was salted and the salt is gone, it can no longer be tested against a guess of the +content. `[THEOREM: SNP-9 for the chain; DERIVED for the salt]` What stays, and why: + +- `chain`, `seq` and `kind`: the position, which the erasure must keep. +- `path_key`: so that the hole shadows. It can be tested against a guess of the path only with + the chain's secret, which is in the same file as the rows. +- `closed_at` and `version`: positions and a count, no content. `closed_at` is a function of + the rows that keep their keys, so nulling it would hide nothing. +- `att_head`: a position on another chain. + +The hole is thus still tied to its path while another row of the path keeps the name, which is +the intent: the purge is of a digest, and the path with its other versions is not erased. When +every row of a path is emptied no row names the path. The bookmark goes because nothing looks a +landing up by its date, and a date on a hole says when the erased content arrived. + +That is a rule the record already has: no tombstone keeps a content hash of purged private text, +and for prose privacy outranks lineage (`docs/design-notes/vector-membership-store.md:810-813`). +A digest of purged bytes is a test for those bytes. What a purge has to reach, against what it +reaches today: + +| store | today, after a purge | what a snapshot needs | |---|---|---| -| raw object, catalog row, plane occupancies and their freed atoms | removed | the same, and the log's rows emptied | -| the vector table's earlier dataset versions | still return the text | the purge ends with a compaction that keeps no earlier version | -| lexical units, postings and version records | remain, with the words | removed with the plane's rows | -| the version chain's rows | still name the digest | the digest nulled, the row and its number kept: a second owner-gated write beside the relabel (`core/stores/versions.py:132`) | -| relation edges and artifacts that name the digest | untouched (read, not measured: `core/ingest/purge.py:58-62` names neither store) | not served (`mem_serve_iff`), and removed by the purge | -| the attestation ledger | still names the digest | open: decision D9 | -| a deletion attestation | none is written (`core/attestation/store.py:3-6` says one is) | one, of action `purge`, naming the commitment and not the digest | - -Until the stores of the middle rows are reached, a read of them at a cut would return what a -purge left. So the erasure's reach is stage SN-3, and it lands before any of those stores is read -at a past cut (§12). +| raw object, catalog row, plane occupancies and their freed atoms | removed `[MEASURED §11]` | the same, and the log's rows emptied | +| the vector table's earlier dataset versions | still return the text `[MEASURED §11]` | the purge ends with a compaction that keeps no earlier version | +| lexical units, postings and version records | remain, with the words `[MEASURED §11]` | removed with the plane's rows | +| the version chain's rows | still name the digest `[MEASURED §11]` | the digest nulled, the row and its number kept: a second owner-gated write beside the relabel (`core/stores/versions.py:132`) | +| the curated store's plane and atoms | not opened: the purge is given the main vector store only (`scripts/purge_raw.py:51-56`, `core/stores/curated_store.py:30-38`) | the same removal and compaction as the main store | +| relation edges and artifacts that name the digest | untouched (`core/ingest/purge.py:58-62` names neither store) | not served (`mem_serve_iff`), and removed by the purge, with the archived generations that name it | +| dream claims of the run ledger | keep the digests a claim rests on and its surface text (`core/stores/runledger.py:90-97`) | the claim's support and text nulled, the row kept | +| staging rows | keep the content digest and the payload (`core/stores/staging.py:130-131`) | the digest and the payload nulled, the row and its generation kept | +| claim ops | keep the warrant's text (`core/stores/claim_ops.py:40-48`) | the ops on a removed artifact removed | +| rejected requests of the ingress spools | keep the request's text (`core/ingest/ingress.py:20-27`, `:505-517`) | the files that hold the purged text removed | +| the attestation ledger | still names the digest `[MEASURED §11]` | decision D9 | +| a deletion attestation | none is written (`core/attestation/store.py:3-6` says one is) | one, of action `purge`, naming the positions emptied and no digest | + +Rows without a grade were read in the code and not measured. Until the stores of the middle +rows are reached, a read of them at a cut would return what a purge left. So the erasure's reach +is stage SN-3, and it lands before any of those stores is read at a past cut (§12). The +attestation of a purge lists the positions it emptied, which is what lets a backup restored from +before it be purged again (§3.6). ### 6.2 A retire seals A vault delete is a tombstone: the catalog's row goes inactive and the raw object stays (`catalog.py:160-172`). The requirement is that a tombstoned item does not come back through a -snapshot either. Two rules do that, both proved, and they are ordered. +snapshot either. Two rules do that for the value served at a cut, both proved, and they are +ordered. - **The stricter seal** (`servedAt`). A retire among the events past the cut closes the cut for that identity. Once the chain retires an identity, no cut before the retire serves it @@ -722,17 +1032,36 @@ snapshot either. Two rules do that, both proved, and they are ordered. This note takes the stricter seal, keyed by identity, with an `unseal` event that only the owner writes. `[INFERENCE, falsifier SNF-10]` The reason is in the code: a new row's identity is its -path unless it declares one (`catalog.py:103-110`), so a different note written later at a -deleted note's path has the deleted note's identity, and under the looser seal it would bring -the deleted note's versions back at the earlier cuts. The seal is by identity and not by path so -that a rename seals nothing: the old path's tombstone is a `move` (§3.2). The cost of the -stricter seal is also in the code: a rescan tombstones every catalog path whose file is gone -(`core/ingest/sync.py:262`, `:285-286`), so a vault that is missing at a rescan seals every -note's past, and the owner lifts it with one `unseal` over the range. +path unless it declares one, and a re-record of a path keeps the identity it has +(`catalog.py:103-121`), so a different note written later at a deleted note's path has the +deleted note's identity, and under the looser seal it would bring the deleted note's versions +back at the earlier cuts. + +**The seal covers the versions, at every cut.** Sealing the value is not enough. The new note's +identity is the deleted note's, so its chain of versions holds the deleted note's versions +(§2.3, item 8), and a read of the history would return them at the head and at every cut after +the new note landed, where no value is sealed. So the history served of an identity at a cut is +defined with the seal (`historyAt`): nothing where the identity is sealed, else its landings +inside the cut that no retire follows. It ends at the value served there +(`getLast?_historyAt`); a retire after the cut empties it (`historyAt_append_of_retire`); and at +every cut after a retire, the head included, it holds only versions landed after that retire +(`historyAt_of_retire_inside`, `sinceRetire_append_retire`). `[THEOREM: SNP-7]` This changes a +read at the head too: `trace` of a note written at a deleted note's path stops at the delete. +The versions store keeps its rows; the read withholds them. + +The seal is by identity and not by path so that a rename seals nothing: the old path's tombstone +is a `move` (§3.2). The cost of the stricter seal is also in the code. The sync retires every +stored path its source no longer lists (`ingress/sync_vault.palace:7-15`, +`core/ingest/writer.py:499-519`), and a source whose directory is missing lists no file +(`core/ingest/readers.py:126-137`), so a vault that is missing at a sync seals every note's +past. The owner lifts it with one `unseal` row, whose `ref_lo` and `ref_hi` name the range of +positions of the retires it lifts; an `unseal` of one identity carries the identity and the +position of its retire in both. The seal is read off the whole chain, the present, and off no prefix of it: one more seek, the -position of the identity's last retire that no later `unseal` names. At the head nothing is -sealed (`servedAt_length`). +position of the identity's last retire that no later `unseal` names. At the head no value is +sealed (`servedAt_length`), and the history served is the identity's landings since that retire +(`historyAt_length`). ### 6.3 The grant is the asker's now @@ -748,14 +1077,41 @@ within them, to the events it may see named (`snapshot`). The grant is no functi - Restricting to whole chains commutes with the cut (`restrict_readAt`). Filtering events before the cut does not: it moves the positions (`Witness.filter_before_cut`), and a position on a chain counts the events a filter hides (`Witness.position_channel`). So an event filter is - applied after the read, and what must be hidden in number is hidden by chain, which is why the - landing log is a chain a class. + applied after the read, and what must be hidden in number is hidden by chain, which is why a + landing chain holds one class. +- The grant and the erasure compose: what an asker is shown, the grant's snapshot with the + erased events masked (`shown`), is append invariant, holds no erased event, and under a + narrower grant and a larger erasure is the restriction of what the wider grant is shown under + the smaller erasure (`shown_grow`, `not_erased_of_mem_shown`, `shown_narrow`). + +**What these laws are about.** They are about the read: the rows a grant is shown. They pass to +an answer when the answer is a filter of the read, as the members of `reach`, `trace`, `read` +and `changed` are. They do not pass to a score. A lexical score uses the statistics of the +reader's own classes, the unit count, the mean length and each term's document frequency +(`core/stores/lexical.py:316-321`, `:337-340`), and §5.3 keeps it so; a rank depends on every +candidate. So for a sentence that scores or ranks, the narrower answer is not the wider one +masked, at the head today as at a cut, and nothing here claims it is. `[ESTABLISHED for the +statistics]` + +**The cut shown.** `snapshot_congr` holds for a fixed cut. The cut read is resolved over every +chain (§7.1), and its position on a chain the grant names can depend on a chain the grant does +not name, when the named chain reads it (`Witness.resolution_reads_unnamed`). On a set of +chains that read from no chain outside the set, the cut read is a function of that set alone +(`ResolvesIn.eq_on_of_closed`). `[THEOREM: SNP-6]` A landing chain reads `att`, and `att` reads +`repo`; both mix every class. So the cut shown to a grant is a function of its own chains, of +`att` and of `repo`. Landings of another class move the head of `att` and change none of that +at a recorded cut: the record's positions are fixed, `att` is never pruned, so it serves them, +and the references of the events inside the cut do not change as the store grows +(`Consistent.of_grown`). What a narrower grant can learn through the cut shown is only that +`att` or `repo` did not serve a position, which is a fact about the instance and no class's +data. `[DERIVED]` Two consequences for the surface. An answer names the cut it read on the chains the asker's grant names and on no other, and the bounds a row records (§3.5) are never shown: `att` mixes every class, so its positions count other classes' landings. And a class is a row's class now: a -whole-class relabel renames a chain, and nothing else moves a row between chains (ING-17). -`[DERIVED]` +whole-class relabel changes the label of a chain, and a row moves between chains only by a +`move` and a `store` (§3.2), after which its earlier events stay under the class they had +(ING-17). `[DERIVED]` ### 6.4 A reader that is shown only named endpoints @@ -785,22 +1141,48 @@ taken at the greatest consistent cut under the frontier asked every position of - It never passes the cut asked (`ResolvesIn.le_resolves`), so what is read is a prefix, chain by chain, of what the cut asked holds (`readAt_mono`): a read under `as of` holds no event from after the cut it names. -- It rises with what is served and with the frontier (`ResolvesIn.mono`): as the stages of §12 - give stores a past, the cut read climbs toward the cut asked and never falls. +- It rises with the frontier, and with what is served while the served positions only grow + (`ResolvesIn.mono`): as the stages of §12 give stores a past, the cut read for one name climbs + toward the cut asked. - When every position is served it is the resolution of the frontier (`resolvesIn_univ`), and at the head, which is consistent because a store holds the sources of its own events, it is the head (`resolvesIn_self`). +**Which chains go down together.** The cut read is not a floor taken chain by chain. A chain +that others read takes its readers with it: where it is read low, every event that reads past +that position is outside the cut, and so is everything that reads those events +(`Witness.record_drags`). A chain that no other chain reads is lowered alone: from a consistent +cut asked, the cut read is the cut asked with each such chain at the greatest position it +serves at or under the one asked, and every other chain as asked (`resolvesIn_of_unread`, and +`resolvesIn_update_of_unread` for one chain). `[THEOREM: SNP-10]` The design is arranged so that +the second case is the only one that occurs at a recorded cut. The references the resolver +records are a landing's to `att` and an attestation's to `repo` (§3.5). Neither `att` nor +`repo` has a horizon that moves: the attestation ledger is never pruned (§9.2) and `repo` is +git's. Every chain that can fail to serve a recorded position, a landing chain behind a history +window, a chain that keeps no past yet, the use log behind its horizon, is read by no recorded +bound. And the recorded cuts, which read every chain, sit on a chain nothing reads (§3.3). So at +a recorded cut each chain that cannot serve is lowered alone and the others are read as +recorded. `[DERIVED]` + +**When the cut read falls.** The monotonicity needs the served positions to grow. They do not +always. A store that keeps no past serves its empty prefix and its head, and loses its old head +when it grows; a history window removes the positions under the new horizon. In both cases the +same name read later is read lower (`Witness.served_set_shrinks`). So an answer read at the head +of a store with no past names a position that store will not serve again. The answer's note +marks such a chain as served at its head only, and the same name asked after the store grew +reads that chain at its empty prefix and says so. `[THEOREM for the control; INFERENCE for the +note]` + The answer is then exact for the cut it names: every law of §10 holds at the cut read. What the answer says is that cut. It carries one note with the cut asked, the cut read on the chains the asker's grant names (§6.3), and each chain on which the two differ with the reason: the store keeps no past, the cut is under the chain's horizon, or the stage that reads the store at a cut -is not built. For example, on an instance where the relation edges do not yet keep generations: +is not built. For example, on an instance where the interpreted relation edges do not yet keep +generations: ``` -as of "9de5325d": read at the cut recorded when the commit was read (cut:4c1f09a2). -land:authored-solo 412, chat 9318, repo 9de5325. Not read at the cut: the relation edges -keep no past and were read at their empty prefix. +as of "cut:4c1f09a2": land 3 (authored-solo) 412, chat 9318, repo 9de5325. Not read at the +cut: the interpreted relation edges keep no past and were read at their empty prefix. ``` This replaces what the executor does today, which reads those stores at the head and says so @@ -822,8 +1204,8 @@ The mode of a clause follows from its scope (`core/query.py:273-281`). | mode | verbs | what it reads at the cut | exact from | |---|---|---|---| | semantic | `near`, `diffuse S`, `reach S`, `relate` | the heads of the clause's classes, from the log; their vectors by content address and the lexical index for the pending ones (§5.2, §5.3); the backbone recomputed among them | SN-4; `relate` SN-6 | -| structural | `reach F`, `diffuse F`, `walk` over `F` | the citation reading of the cut's commit | today | -| temporal | `trace`, `reach D`, `walk` over `D`, `changed` (§7.4) | the version chain's prefix: the log's rows of the identity at or under the cut | SN-4; `changed` SN-8 | +| structural | `reach F`, `diffuse F`, `walk` over `F` | the citation reading of the cut's commit, as projected at or under the cut (§5.1) | today for a commit projected once; SN-4 for one projected again | +| temporal | `trace`, `reach D`, `walk` over `D`, `changed` (§7.4) | the history served of the identity at the cut (§6.2): the log's rows of the identity at or under the cut, after its last retire | SN-4; `changed` SN-8 | | causal | `reach C`, `walk` over `C`, `witness` | the causal fiber recomputed at the cut (§5.5); an attestation at or under the cut on `att` | SN-5 | | species | at a cut | @@ -832,7 +1214,7 @@ The mode of a clause follows from its scope (`core/query.py:273-281`). | `F`, citation | the edges of the reading at the commit; a reading is whole, so nothing is inferred between commits | | `D`, supersession | consecutive versions of the chain's prefix; at the node grain it is empty today and stays so (`universe.py:810`) | | `C`, causal witness | an edge whose witness turn is inside the cut on `chat` and whose commit, if it ends at one, is inside the cut on `repo` | -| the signed relations (supports, contradicts, contextualizes) | a kept generation whose two endpoint digests are heads at the cut (§5.4) | +| the signed relations (supports, contradicts, contextualizes) | an authored edge recomputed from the heads at the cut; an interpreted edge as a kept generation whose two endpoint digests are heads at the cut (§5.4) | | an assumed edge (`assume`) | applied to the universe of the cut read; nothing is stored, and the result is a `Hyp` as today | ### 7.3 The verbs @@ -842,11 +1224,14 @@ The mode of a clause follows from its scope (`core/query.py:273-281`). algebra on whatever universe the clauses built. Their laws (QSA-1 to QSA-4, QSA-10) are stated for any universe, so they hold at a cut with no change. `over` masks by a row's class, which is its class now (§6.3). -- **`read`.** A repository path: git's blob at the cut's commit, as today, with the commit shown - on the hit. A note or a dialogue turn: the raw object of the digest the log names for the path - at the cut, never the vault file, which is the present and can be newer than the catalog - (§2.1). A hole reads as erased and a sealed identity as nothing (§6). A transcript turn: the - chat log's row when its number is at or under the cut. +- **`read`.** A repository path: git's blob at the cut's commit, with the commit shown on the + hit; when git does not hold the cut's commit the read is refused and says so, where today it + returns `HEAD`'s blob (§2.1). A note or a dialogue turn: the raw object of the digest the log + names for the path at the cut, never the vault file, which is the present and can be newer + than the catalog (§2.1). A path whose event at the cut is a hole reads as erased, and not as + the version before it (`stateAt_holes_of_erased`); a sealed identity reads as nothing (§6). A + transcript turn: the chat log's row when its number is at or under the cut. A curated row: + what landed through the catalog as a note is; a row with no landing is not read (§5.6). - **`witness`.** The record when it lies inside the cut: an attestation by its number on `att`, a causal edge by its turn and its commit, a citation edge by its commit. - **`assume`.** The overlay applied to the universe of the cut read: a hypothetical at a past cut. @@ -861,8 +1246,10 @@ without the erased events (`visible_head`). `[THEOREM: SNP-4]` On the code this of every stage: the same sentence with and without `as of "head"` returns the same hits. **Refusals.** An ambiguous prefix, as today (`universe.py:471-475`). A name that selects nothing: -a sha no chain knows, a cut id no record has, a date before the first record; the refusal says -which names would resolve. A date after the newest bookmark is the head. +a sha no chain knows, a cut id no record has, a date before the first record, `HEAD`, a branch; +the refusal says which names would resolve, and it does not depend on what the stores hold. A +date after the newest record is not refused and is not the head: it is the newest record +(§3.4), and the answer says the head has moved since when it has. ### 7.4 Between two cuts @@ -896,19 +1283,26 @@ History is exact from the first retained generation and from no earlier. Each ch **horizon**: the first position from which it serves every cut. Three things set one. - **The genesis.** The landing log opens with the catalog as it stood (§3.2). What a path held - before was never recorded, so the positions before the genesis rows end are under the horizon. - For the chat log and the attestation ledger the genesis is the rows they hold when their chain - tables are added, in the order they were inserted. + before was never recorded, so the positions before the genesis block ends are under the + horizon. For the chat log and the attestation ledger the genesis is the rows they hold when + their chain tables are added, numbered in the order they were inserted and followed by a + horizon: within a chat session the turn order is exact, but the order across sessions and + across the two stores was not recorded, so no cut inside the block is served. The citation + edges held when their stamp is added are stamped with that genesis (§5.1). - **Retention** (§9), which drops the generations closed at or under a declared position. -- **A reset**, after which every chain is a new chain (§2.3, item 7). +- **A reset**, after which every chain is a new chain with a new id (§2.3, item 7), and no + record taken before it names a chain that exists. The law is the same for the three. A generational store that drops the rows closed at or under a horizon reads, at every cut from the horizon on, the state recomputed from the whole prefix -(`genRead_prune_gens`), though the prefix is no longer held. Under the horizon it is never wrong: -a value it returns at a cut is the value the key held (`stateAt_of_genRead_prune`). But what it -lost it reads as absent, and nothing in the rows that remain tells a lost key from a key that was -never there (`Witness.prune_forgets`). Two horizons are the later one (`prune_prune`). -`[THEOREM: SNP-10]` The journal form says the same of a fold: continued from the state kept at the +(`genRead_prune_gens`), though the prefix is no longer held, and landings after the pass leave +it so (`prune_landGen`). Under the horizon it is never wrong: a value it returns at a cut is the +value the key held (`stateAt_of_genRead_prune`). But what it lost it reads as absent +(`Witness.prune_forgets`), and nothing in the rows that remain tells a lost key from a key that +was never there: two chains can leave the same pruned store where, at one cut under the +horizon, a key held a value in the first and had never been written in the second +(`Witness.prune_indistinct`). Two horizons are the later one (`prune_prune`). `[THEOREM: +SNP-10]` The journal form says the same of a fold: continued from the state kept at the horizon over the events since, it is the fold of the whole prefix (`foldAt_readBetween`), and the chain's digest at the horizon, kept as the seed, lets every certificate from the horizon on verify (`certify_digest_readBetween`). `[THEOREM: SNP-3, SNP-9]` @@ -917,15 +1311,21 @@ So the horizon is recorded, and a cut under it is not served. - **Where.** As a `horizon` row of the chain, which the chain's hash covers, and in every recorded cut (§3.3). It only advances. -- **What a question before it gets.** The chain is read at its empty prefix (§7.1), and the - answer says the cut is under the chain's horizon and names the first cut the chain serves. A - sentence all of whose chains are under their horizons returns the note and no hit. +- **What a question before it gets.** The chain is read at the greatest position it serves at + or under the one asked, which under a horizon is its empty prefix, and the answer says the cut + is under the chain's horizon and names the first cut the chain serves. Every other chain is + read as asked: the chains that have a horizon above a recorded position are chains no recorded + bound reads, so each is lowered alone (§7.1, `resolvesIn_of_unread`). What follows a lowered + landing chain is the rows about it: an interpreted row whose sources are not heads at the cut + read is withheld by its own filter (§5.4). A sentence all of whose chains are under their + horizons returns the note and no hit. - **What that means today.** A commit read before the log exists resolves, on every chain but `repo`, under the horizon: `as of` such a commit reads the citation graph and the repository's - files at the commit, which are exact, and nothing else. That is the lawful part of what it does - now. The observation that the version store held one generation and so had nothing to - snapshot (limits-of-the-algebra, L7) is this boundary seen from the other side. - `[DERIVED]` + files at the commit and nothing else. For a commit projected once, and held by the checkout, + that part is exact, and it is the lawful part of what `as of` does now; a commit projected + again has a reading that grew (§5.1), and a commit the checkout lacks is read at `HEAD` + (§2.1). The observation that the version store held one generation and so had nothing to + snapshot (limits-of-the-algebra, L7) is this boundary seen from the other side. `[DERIVED]` ## 9. Retention and cost @@ -938,19 +1338,31 @@ the snapshot adds three things. | what | a | bytes | source | |---|---|---|---| -| the landing log | landing | 409 | `[MEASURED §11]` | -| a recorded cut, with its attestation | record | about 2,000 | §3.3 | -| archived model output | replaced row | the row's | §5.4 | +| the landing log | landing | 396 to 434 on the fixture | `[MEASURED §11]` | +| a recorded cut, with its attestation | record | about 2,700, by arithmetic | §3.3 | +| a chain table's row, for `chat`, `att`, `staging` and `runs` | appended row | under 100, by arithmetic: an integer, the row's key, a 32-byte hash | §3.1 | +| archived model output | replaced row | the row's; how often one is replaced is not measured | §5.4 | | kept already: a lexical unit of a superseded version | unit | 4,179 on synthetic text, 122 postings a unit | `[MEASURED §11]` | | kept already: a plane occupancy | row | 734 to 1,084 | `docs/experiments/corpus-stage1-2026-11-07.md:416`, `corpus-measurements-2026-11-07.md:104` | | kept already: an atom | changed chunk | 2,215, of which the vector 1,536 | `corpus-measurements-2026-11-07.md:103` | | kept already: a raw object | version | the version's bytes; a transcript's, whole, at each growth | §2.2 | -By arithmetic, not measurement: an instance with a hundred landings a day adds 41 kilobytes a day -to the log, 15 megabytes a year, and thirty recorded cuts a day add 60 kilobytes. The rows kept -already are what grows: with three versions an item, two thirds of the synthetic lexical index -were superseded versions. `[MEASURED §11]` What the snapshot brings is less a cost than the means -to stop paying one: a horizon makes it safe to drop. +By arithmetic, not measurement: an instance with a hundred landings a day adds 43 kilobytes a day +to the log, 16 megabytes a year, and thirty recorded cuts a day add 81 kilobytes. A corpus +instance at the ten million items the repository's records plan for +(`docs/experiments/corpus-measurements-2026-11-07.md:94-96`) has a log of about 4 gigabytes for +the first landing of each item. + +The rows kept already are what grows: with three versions an item, two thirds of the synthetic +lexical index were superseded versions. `[MEASURED §11]` What one superseded version keeps, by +arithmetic from the rows above for a note of four chunks all of which changed: four lexical +units, four occupancies and four atoms, 28.5 to 29.9 kilobytes of derived rows, and the note's +own bytes as a raw object, against 0.4 kilobytes in the log. At a hundred such landings a day +that is about 2.9 megabytes a day of derived rows, a gigabyte a year, which the instance pays +today whether or not anything reads a past. A transcript is the other large term: it is +retained whole at each growth, 0.79 MB each time for the fixture's session of 2,000 records. +What the snapshot brings is less a cost than the means to stop paying one: a horizon makes it +safe to drop. ### 9.2 The rule, counted in events @@ -973,7 +1385,9 @@ owner's to declare. Its order is the one the stores use for a cache: the horizon first, so a crash in the middle leaves rows that are no longer served, never a position that is served and incomplete (the discipline of PLN-4, where a cache is stale only by excess). `[DERIVED]` The attestation ledger and the version chains are not pruned: they are the audit -record, they are small, and they have no delete. +record, they are small, and they have no delete. That the ledger keeps every position is also +what §7.1 rests on: `att` is the one chain every landing reads, so a horizon on it would take +the landing chains down with it. A window is counted in events because wall time orders nothing (Law C4): the last ten thousand landings of a class, not the last ninety days. It is one position a chain, not a number of @@ -982,8 +1396,10 @@ which cuts are exact would differ from one identity to the next, and the control a store cannot tell what it lost. `[INFERENCE, falsifier SNF-9]` The default instance declares neither window and keeps everything; by the arithmetic above its -log is megabytes a year. An instance that must bound its disk declares the first, and the second -only by its owner's decision (D8). +log is megabytes a year and its superseded derived rows about a gigabyte a year at a hundred +landings a day. An instance that must bound its disk declares the first window, which frees +those derived rows and moves no horizon. The second frees, beyond that, only the raw objects +and the log's rows of the closed versions, and it is declared only by the owner (D8). ### 9.3 Lazy landing, in time @@ -1006,16 +1422,18 @@ The field is the fold of its update over the use log (UTL-4, `evolve_append`), s view in the sense of §5: its use log is a chain of the cut, its tick the position, and the field as of a cut is the fold of the prefix, continued from a kept checkpoint over the uses since (`foldAt_readBetween`). `[THEOREM: SNP-3 with UTL-4]` That answers the first open question of -dn-utility-field: the field's clock can be a chain of the cut, and then the field as of a cut is -exact. Two more things follow. +dn-utility-field: the field's clock is a chain of the cut, `use`, and the field as of a cut is +then exact. Two more things follow. - **The use log has a natural horizon.** A site left alone returns within `ε` of its baseline after `log(c/(lam ε))/lam` ticks (UTL-2, `idle_window`), so a horizon that far behind the head, with the field's state at the horizon kept, is exact from the horizon on and loses nothing a - reader of the present could see. `[DERIVED from UTL-2 and SNP-3]` -- **The field can order what retention drops.** When a window forces a choice among the derived - rows of superseded versions, the ones whose sites stand at the baseline were not used for - anything that produced value, and go first. `[HYPOTHESIS: checked by comparing, on the corpus + reader of the present could see. No other chain reads the use log, so a cut under its horizon + lowers that chain and no other (§7.1). `[DERIVED from UTL-2, SNP-3 and SNP-10]` +- **The field could order what retention drops.** The order a pass drops in is by age: the + oldest closed versions first. When a window forces a choice among the derived rows of + superseded versions, the ones whose sites stand at the baseline were not used for anything + that produced value, and could go first instead. `[HYPOTHESIS: checked by comparing, on the corpus instance, how often a pass ordered by the field drops a row a later cut asks for against a pass ordered by age; falsifier SNF-9]` @@ -1023,34 +1441,41 @@ exact. Two more things follow. Each law is stated so that it becomes a property test when its stage is built, and is proved now. The Lean names are in `formal/Palace/Snapshot.lean`, the attacks and controls in -`formal/PalaceTest/Snapshot.lean`, by seed. `[THEOREM]` throughout. +`formal/PalaceTest/Snapshot.lean`, by seed. `[THEOREM]` throughout. Each law also says what in +it is a theorem and what holds because the model was built that way, since the second kind +passes to the code only as an obligation of the stage that transcribes it. - **SNP-1 append invariance.** A read at a cut inside the store, a read between two such cuts and every derived view are unchanged by any growth of the store (`readAt_grow`, `readAt_of_extends`, `readBetween_grow`, `appendInvariant_view`), also under an erasure and a - grant (`visible_grow`, `snapshot_grow`) and for the keyed forms (`stateAt_append`, - `genRead_gens_append`). Controls: the reader that ignores the cut - (`Witness.present_not_appendInvariant`); a read at a cut past the head (seed 431). Attacks 430, - 432, 446. The test, at SN-1: over random sequences of catalog writes, `read_at(c)` taken after - every further write equals the one taken when `c` was the head. + grant (`visible_grow`, `snapshot_grow`, `shown_grow`) and for the keyed forms (`stateAt_append`, + `genRead_gens_append`). By construction: a store is a family of lists, so growth is append + and nothing else. That the code's stores only append below a cut is what the stage's test + checks. Controls: the reader that ignores the cut (`Witness.present_not_appendInvariant`); a + read at a cut past the head (431, 487, 488). Attacks 430, 432, 446. The test, at SN-1: over + random sequences of catalog writes, `read_at(chain, c)` and `state_at` of every path at `c`, + taken after every further write, equal the ones taken when `c` was the head. - **SNP-2 monotonicity.** The read at an earlier cut is a prefix, chain by chain, of the read at a later one, and a cut of a cut is the meet (`readAt_mono`, `mem_readAt_of_le`, - `readAt_readAt`, `head_readAt`, `visible_mono`). Control: the read at one cut taken for a prefix - of the read at any other (434). Attacks 433, 435. The test, at SN-1: for `a ≤ b`, `read_at(a)` - is a prefix of `read_at(b)`. + `readAt_readAt`, `head_readAt`, `visible_mono`). Controls: the read at one cut taken for a + prefix of the read at any other (434); a cut of a cut taken for the join (500). Attacks 433, + 435. The test, at SN-1: for `a ≤ b`, `read_at(chain, a)` is a prefix of `read_at(chain, b)`. - **SNP-3 composition.** The read at `a` followed by the read between `a` and `b` is the read at `b`, and two adjacent reads-between compose (`readAt_append_readBetween`, `readBetween_append`); a fold continued from a checkpoint over the delta is the fold of the prefix (`foldAt_readBetween`, `stateAt_eq_foldl`); an event, or a pair of events, read at the later cut was read at the earlier one or lies in the delta (`mem_readAt_iff`, `pair_readAt`); a key the delta does not write has one state at both cuts (`stateAt_eq_of_not_written`). Controls: the - two cuts in any order (437); a key's state taken for unchanged whatever the delta writes (477). + two cuts in any order (437); two reads-between composed in the other order (502); the delta + left out (503, 505); a key's state taken for unchanged whatever the delta writes (477). Attacks 436, 438, 439, 447, 475, 476. The test, at SN-1: the catalog rebuilt from the state at a checkpoint and the delta equals the catalog; at SN-8: the region of §7.4. - **SNP-4 idempotence.** The read at the head cut is the store, and every reading at it is the present's (`readAt_head`, `readAt_of_head_le`, `view_head`, `genRead_gens_length`, - `snapshot_head`, `servedAt_length`, `servedNow_length`, `visible_head`). Attack 440. The test, - at every stage: a sentence under `as of "head"` returns what it returns without. + `snapshot_head`, `shown_head`, `servedAt_length`, `servedNow_length`, `historyAt_length`, + `visible_head`). Control: the read at a cut that is not the head taken for the store (501). + Attack 440. The test, at every stage: a sentence under `as of "head"` returns what it returns + without. - **SNP-5 a derived view depends only on the prefixes.** A reader is append invariant exactly when it reads only the prefixes, exactly when it is a derived view (`prefixOnly_view`, `view_congr`, `appendInvariant_iff_prefixOnly`, `appendInvariant_iff_exists_view`). For keyed @@ -1059,92 +1484,159 @@ now. The Lean names are in `formal/Palace/Snapshot.lean`, the attacks and contro (`genRead_gens`, `stateAt_eq_lastWrite`, `length_filter_selects_le_one`). Controls: the store rewritten in place (`Witness.stateOf_forgets`, 444); generations without the closing stamp (445). Attacks 441, 442, 443. The test, at SN-1: the three reads of the log agree at every - position, and no path has two rows alive. + position, before and after rows are emptied, and no path has two rows alive. - **SNP-6 grant restriction.** A narrower grant's snapshot is the restriction of a wider one's; a snapshot reads only the chains the grant names and the cut on them; restricting to chains - commutes with the cut (`snapshot_narrow`, `snapshot_congr`, `snapshot_grow`, - `restrict_restrict`, `restrict_readAt`). Controls: an event filter applied before the cut - (`Witness.filter_before_cut`, 449); positions that count hidden events - (`Witness.position_channel`, 451). Attacks 448, 450. The test, at SN-4: of two grants one under - the other, the narrower answer at a cut is the wider one masked, and landings of a class the - grant does not name change neither the answer nor the cut it shows. + commutes with the cut; the grant and the erasure applied together keep both (`snapshot_narrow`, + `snapshot_congr`, `snapshot_grow`, `restrict_restrict`, `restrict_readAt`, `shown_narrow`). The + cut read on a set of chains that read from no chain outside it is a function of that set + (`ResolvesIn.eq_on_of_closed`). By construction: the grant is an argument of the reader and + not of the cut, so that it is the asker's now is a choice of the model, not a theorem. + Controls: an event filter applied before the cut (`Witness.filter_before_cut`, 449); positions + that count hidden events (`Witness.position_channel`, 451); a named chain that reads an + unnamed one (`Witness.resolution_reads_unnamed`); a narrower grant under a smaller erasure + (510). Attacks 448, 450, 509. The test, at SN-4: of two grants one under the other, the rows + the narrower is shown at a cut, and the members of a sentence whose answer is a filter of + those rows, are the wider one's masked; a sentence that scores or ranks is not tested so + (§6.3); and landings of a class the grant does not name change neither the rows shown at a + recorded cut nor the cut shown. - **SNP-7 erasure dominance.** No erased event is visible at any cut; a larger erasure shows a sublist; the store with holes keeps every position; stores that differ only in erased events read the same at every cut; a kept row is served only when none of its sources is erased - (`not_erased_of_mem_visible`, `visible_sublist`, `head_redact`, `redact_readAt`, - `visible_eq_reduceOption`, `visible_congr`, `erased_invisible`, `mem_serve_iff`, - `serve_sublist`). A key retired after a cut is served at no earlier cut, growth changes a served - value only by removing it, and the looser seal serves what the stricter one serves - (`stateAt_of_servedAt`, `servedAt_append_of_retire`, `servedAt_append_of_no_retire`, - `servedAt_of_append`, `servedNow_of_servedAt`, `servedNow_of_not_live`). Controls: the erasure - that deletes rows (`Witness.compact_moves`, 455); the state served without the seal (458); the - looser seal taken for a monotone one (`Witness.servedNow_restores`, 474); kept rows served - without their sources (460). Attacks 452, 453, 454, 456, 457, 459, 473. The test, at SN-3: after - a purge no read at any cut and no scan of the instance's files finds the purged words; after a - retire no cut before it serves the identity. -- **SNP-8 consistent cuts.** They are closed under meet and join, a sublattice of the cuts; they - are CLK-2's cuts among the frontier cuts; every frontier resolves to exactly one greatest - consistent cut under it, monotonically; a consistent cut stays consistent as the store grows - (`consistent_zero`, `Consistent.inf`, `Consistent.sup`, `consistentCuts`, - `consistent_iff_isCut`, `exists_resolves`, `Resolves.unique`, `Resolves.mono`, `resolves_self`, - `Consistent.of_grown`). Controls: a frontier taken for a cut (462); a consistent cut advanced - by one position (464). Attacks 461, 463, 465. The test, at SN-2: the resolver against - enumeration on small stores, and no recorded cut with a reference crossing it. + (`not_erased_of_mem_visible`, `not_erased_of_mem_shown`, `visible_sublist`, `head_redact`, + `redact_readAt`, `visible_eq_reduceOption`, `visible_congr`, `erased_invisible`, + `mem_serve_iff`, `serve_sublist`). A read by key on a chain whose holes keep their keys is the + key's last write at or under the cut, a hole when that write is erased, on all three reads + (`stateAt_holes`, `stateAt_holes_of_erased`, `not_erased_of_stateAt_holes`, + `genRead_gens_holes`, `lastWrite_holes`). A key retired after a cut is served at no earlier + cut, growth changes a served value only by removing it, and the looser seal serves what the + stricter one serves (`stateAt_of_servedAt`, `servedAt_append_of_retire`, + `servedAt_append_of_no_retire`, `servedAt_of_append`, `servedNow_of_servedAt`, + `servedNow_of_not_live`). The seal covers the key's versions: the history served ends at the + value served, a retire after the cut empties it, and after a retire it holds only versions + landed since, at every cut (`getLast?_historyAt`, `historyAt_append_of_retire`, + `historyAt_of_retire_inside`, `sinceRetire_append_retire`). By construction: these are laws of + a reader that reads `visible`, `holes` or `historyAt`. That every reader of every store in the + code does is the reach of SN-3, checked by its scan, and no theorem. Controls: the erasure + that deletes rows (`Witness.compact_moves`, 455); the hole that loses its key + (`Witness.keyless_hole`, 496, 497); the state served without the seal (458); the looser seal + taken for a monotone one (`Witness.servedNow_restores`, 474); the history without the seal + (513); kept rows served without their sources (460). Attacks 452, 453, 454, 456, 457, 459, + 473, 495, 511, 512. The test, at SN-3: after a purge no read at any cut and no scan of the + instance's files finds the purged words; after a purge of an old version of a live path, the + read of the path at a cut where that version was the head is a hole, by all three reads; after + a retire no cut before it serves the identity, and after a new note lands at the path no read + of its history, at the head or at any cut, returns a version from before the retire. +- **SNP-8 resolution.** Every frontier resolves to exactly one greatest consistent cut under + it, monotonically; a consistent cut stays consistent as the store grows; a cut consistent for + a recorded bound on the references is consistent for the true ones (`exists_resolves`, + `Resolves.unique`, `Resolves.mono`, `resolves_self`, `Consistent.of_grown`, + `Consistent.of_bound`). The consistent cuts are CLK-2's cuts among the frontier cuts + (`consistent_iff_isCut`), so their closure under meet and join is CLK-2, cited and not + claimed here (`Consistent.inf`, `Consistent.sup` and `consistentCuts`, derived from + `Clock.IsCut.frontier_inf` and `Clock.IsCut.frontier_sup`; `consistent_zero` for the bottom). Controls: a frontier + taken for a cut (462); a consistent cut advanced by one position (464); resolution taken to + fall as the frontier rises (490). Attacks 461, 463, 465. The test, at SN-2: the resolver + against enumeration on small stores, and no recorded cut with a reference crossing it. - **SNP-9 certified cuts.** A certificate verifies on every extension of the store; under a - collision-free digest two stores that verify one certificate have the same read at its cut and - the same derived views; a certificate extends over the delta; the meet and the join are - certified from the two certificates; an erasure that keeps commitments keeps every certificate - (`verifies_certify`, `verifies_certify_of_extends`, `eq_of_chainDigest_eq`, + collision-free digest two stores that verify one certificate have the same prefix of every + digested chain at its cut and the same derived views of it; a certificate extends over the + delta; the meet and the join are certified from the two certificates; an erasure that keeps + commitments keeps every certificate, and a certificate attests no erasure; under a binding + commitment a certificate over commitments pins the events, so two stores that verify it read + the same store with holes under one erasure, and show the same under one grant and one + erasure (`verifies_certify`, `verifies_certify_of_extends`, `eq_of_chainDigest_eq`, `Verifies.readAt_eq`, `Verifies.view_eq`, `certify_digest_readBetween`, `certify_inf`, - `certify_sup`, `commitments_purge`, `verifies_purge`, `contents_purge_committed`). Controls: a - digest with collisions (`Witness.digest_collides`, 468); a digest over contents, which an - erasure changes (472). Attacks 466, 467, 469, 470, 471. The test, at SN-2: a certificate - verifies after any further writes and on a copy of the files, and fails when one row under the - cut is edited. + `certify_sup`, `commitments_purge`, `verifies_purge`, `verifies_purge_iff`, + `contents_purge_committed`, `Verifies.readAt_eq_of_committed`, `Verifies.contents_eq`, + `Verifies.shown_eq`). By hypothesis, not by theorem: the digest is collision free and the + commitment injective. Controls: a digest with collisions (`Witness.digest_collides`, 468); a + digest over contents, which an erasure changes (472); a seal written after the cut + (`Witness.seal_not_certified`); a renamed chain (`Witness.rename_breaks_certificate`); the + certificate of a cut past the head (489); the meet certified from the later digest (504). + Attacks 466, 467, 469, 470, 471. The test, at SN-2: a certificate verifies after any further + writes, on a copy of the files and after a purge, and fails when one row under the cut is + edited or a chain is given another id. - **SNP-10 the horizon.** A generational store pruned at a horizon is exact at every cut from - the horizon on and never wrong under it; horizons compose to the later one (`genRead_prune`, - `genRead_prune_gens`, `stateAt_of_genRead_prune`, `prune_prune`). Among the positions the - chains serve, every frontier resolves to exactly one greatest consistent cut, which rises with - what is served and never passes the cut asked (`exists_resolvesIn`, `ResolvesIn.unique`, - `ResolvesIn.mono`, `ResolvesIn.le_resolves`, `resolvesIn_univ`, `resolvesIn_self`). Controls: - the pruned store read under its horizon (`Witness.prune_forgets`, 480); a frontier lowered to - the served positions without the descent (483). Attacks 478, 479, 481, 482, 484, 485, 486. The - test, at SN-4: the cut read is under the cut asked on every chain; at SN-7: every read at a cut - from the horizon on is the same before and after a retention pass. + the horizon on and never wrong under it; horizons compose to the later one; pruning commutes + with a later landing (`genRead_prune`, `genRead_prune_gens`, `stateAt_of_genRead_prune`, + `prune_prune`, `prune_landGen`). Among the positions the chains serve, every frontier resolves + to exactly one greatest consistent cut, which never passes the cut asked and rises with the + frontier and with served positions that grow (`exists_resolvesIn`, `ResolvesIn.unique`, + `ResolvesIn.mono`, `ResolvesIn.le_resolves`, `resolvesIn_univ`, `resolvesIn_self`). A chain + that no other chain reads is lowered alone, and so is every such chain at once + (`Consistent.update_of_unread`, `resolvesIn_update_of_unread`, `resolvesIn_of_unread`). + Controls: the pruned store read under its horizon, which cannot tell a lost key from one never + written (`Witness.prune_forgets`, `Witness.prune_indistinct`, 480); a record on a chain that + content reads (`Witness.record_drags`); a chain that others read lowered alone (499); served + positions that shrink (`Witness.served_set_shrinks`, 507); a frontier lowered to the served + positions without the descent (483); the floor and the descent each run once, in either order + (493, 494); pruning at the earlier of two horizons (491); the cut read taken to reach the + floor, or the resolution of the frontier (506, 508). Attacks 478, 479, 481, 482, 484, 485, + 486, 492, 498. The test, at SN-2: the served resolver against enumeration; at SN-4: the cut + read is under the cut asked on every chain, and at a recorded cut it differs from the record + only on chains that could not serve; at SN-7: every read at a cut from the horizon on is the + same before and after a retention pass. What the model leaves out, said plainly. A chain is a list and a store a family of lists: one writer is assumed, and nothing is said of two. Events are opaque, and so is the stores' SQL. The -hash's collision freedom is a hypothesis of SNP-9 (`CollisionFree`), not a theorem about SHA-256. -The `unseal` and `horizon` events are not in the model of the seal, and the owner's gate on them -is the code's. A repository history with merges is covered by CLK-2's down-sets and not by the -chain model (§3.1). The descent that computes a resolution is attacked, not proved. +set of chain keys is fixed: a relabel is not in the model, which is why a chain has an id that a +relabel does not change (§3.1). The hash's collision freedom and the commitment's binding are +hypotheses of SNP-9 (`CollisionFree`, an injective `commit`), not theorems about SHA-256. The +`unseal` and `horizon` events are not in the model of the seal, and the owner's gate on them is +the code's. There is no single reader in the model that applies the cut's resolution, the +grant, the erasure and the seal together: `shown` composes the grant and the erasure over one +read, the seal is stated on a keyed chain, and the resolution on cuts; the sentence's reader +applies the resolution first, then `shown`, then the seal to each keyed read, and that order is +the code's to transcribe. The row filter of an interpreted chain (§3.5) is a derived view, not a +prefix. A repository history with merges is covered by CLK-2's down-sets and not by the chain +model (§3.1). The resolver, the descent and its alternation with the floor, is attacked, not +proved. ## 11. Measurements -Every figure in this note is from a synthetic fixture: a temporary directory or in-memory stores -built by the probe, the test suite's throwaway palace for the purge, and nothing of any -instance. One machine (Apple M2 Pro, 12 cores, 32 GB, macOS 27.0) with other work running, the -load average between 2.4 and 5; Python 3.15.2, SQLite 3.54.1, LanceDB 0.33.0; the code at -`e3e3ee47`. The timings are medians with their ranges. Each probe was run at least twice, and a -range across the runs is given where they differed. `[MEASURED]` +Every figure measured for this note is from a synthetic fixture: a temporary directory or +in-memory stores built by the probe, the test suite's throwaway palace for the purge, and +nothing of any instance. The other figures the note uses are the repository's own records of an +instance, cited where they stand and graded `[ESTABLISHED]`: the attestation ledger's bytes a +row, the job rate, the citation store's rows and bytes, the plane's bytes an occupancy and the +curated table's bytes an atom (`docs/experiments/corpus-measurements-2026-11-07.md:94-107`, +`docs/experiments/corpus-stage1-2026-11-07.md:416`, `core/reference_view.py:15-16`). Figures +given as arithmetic are marked so where they stand. + +The probes are short scripts and are not in the repository: this pull request changes no +Python, and the newest notes keep a harness under `eval/` with a record under +`docs/experiments/`. So these figures cannot be repeated from the tree as it stands. Each stage +of §12 commits the harness of what it builds with its record: SN-1 the log's size and reads, +SN-3 the purge probe as a test, SN-5 the causal probes. The table gives each fixture closely +enough to be built again. + +One machine (Apple M2 Pro, 12 cores, 32 GB, macOS 27.0) with other work running, the load +average between 2.4 and 5; Python 3.15.2, SQLite 3.54.1, LanceDB 0.33.0; the code at `e3e3ee47`. +The timings are medians with their ranges. Each probe was run at least twice, and a range across +the runs is given where they differed. `[MEASURED]` | probe | fixture | result | |---|---|---| -| the landing log | the table of §3.2 without `version` and `att_head`, with its two indexes, in one SQLite file; one class, 100,000 paths, ten landings a path in a shuffled order, one transaction, every row hashed and the path's previous row stamped | 1,000,000 rows in 408.9 MB: 409 bytes a row (table 315, path index 67, closing index 27); 50,000 to 54,000 rows a second written | -| its reads | the same file, 200 repetitions a point read, 5 a scan | one path at the middle cut 3 to 4 µs through the path index and 6.0 to 7.1 ms when the planner took the primary key; 1,000 positions 0.69 ms; every head 149 to 163 ms at the middle cut (99,908 rows) and 246 to 285 ms at and near the head (100,000 rows); the chain's hash recomputed from the first row in 0.77 to 0.79 s; the stored hash at a position read in 3 µs | +| the landing log | the two tables of §3.2 with their three indexes, in one SQLite file; one chain, 100,000 paths of 37 characters with titles under twelve, ten landings a path in a shuffled order, one transaction, every row keyed, committed to and hashed and the path's previous row stamped; built twice, with every identity its path and with every identity a nine-character id | 1,000,000 rows in 434.3 MB where the identity is the path: 434 bytes a row (table 374, key index 47, closing index 13, identity index empty); 396.5 MB where it is an id: 396 bytes a row (table 315, key index 47, identity index 21, closing index 13); 35,000 to 42,000 rows a second written | +| its reads | the same files, 200 repetitions a point read, 5 a scan | one path at the middle cut 3 µs through the key index, and 1.4 to 1.5 µs for the keyed hash of its path; a path's seven versions at the middle cut 9 µs through the key index and 49 to 57 ms when the planner took the primary key; 1,000 positions 0.64 to 0.69 ms; every head 52 to 56 ms at a cut a tenth of the way in (65,103 rows), 147 to 166 ms at the middle cut (99,916 rows) and 240 to 275 ms at and near the head (100,000 rows); the chain's hash recomputed from the first row in 0.71 to 0.76 s; the stored hash at a position read in 3 µs | +| a hole in the log | the same files: the fifth of one path's ten rows emptied as §6.1 says, its key kept | the seek by key at the last cut before the path's next landing returned the emptied row, with no digest | | a kept version in the lexical index | `LexicalStore` on a temporary file; 500 items of 4 chunks in 3 versions, each chunk 171 words drawn from a vocabulary of 20,000 with frequencies falling as the inverse of the rank | 6,000 units held, 2,000 of them current; 734,409 postings, 122 a unit; 25.1 MB, 4,179 bytes a unit; superseded share 0.67 | | what a purge leaves | the test suite's throwaway palace (`tests/fixtures/ingress.py:73`), lazy, with its fake embedder: two notes landed and drained, one edited and drained, then deleted from the vault, then both its digests purged (`purge_raw`); a control note never purged, found at every step | gone: the raw objects, the plane's occupancies and supersession entries, the catalog rows. Left: the words in the vector table read at versions 2 to 9 and 3 to 7 of its 10; the lexical units, postings, title and version records; both version rows; one attestation a digest | | after the purge | the same palace: the vector table compacted with no retention; every SQLite file checkpointed, then vacuumed; a new note landed at the path | the compaction left 1 dataset version and no purged word in the table's files; the deleted catalog and plane rows' path and digest were still in the files' bytes after the checkpoint and gone after the vacuum; the plane's supersession log held position 1 for the path again, and the version chain appended number 3 | | the order of two jobs | in-memory stores; one session with a commit event; the ledger holds the commit before the integrator's first pass, or gains it after | 1 edge against 0, and still 0 after a second pass, the session being skipped as unchanged | | the events of a prefix | a transcript of four records: a prompt, a reply with a `git commit` call, the call's result with the sha, a reply | the prefix that ends before the result gives the commit event an empty reference; the whole gives the sha; the two longer prefixes agree with the whole | | re-deriving a session | a synthetic transcript of 2,000 records, 0.79 MB, 7 repetitions | 6.0 to 6.1 ms median (5.7 to 7.2) | -| what `as of` accepts | the unit tests' store fakes; git read-only on the checkout | `as of "HEAD"` and `as of "2026-11-01"` refused; a sha prefix accepted; `read` of a repository path under a commit where the file differed returned that commit's blob and not the head's, under a note saying that `read` read the present | +| what `as of` accepts | the unit tests' store fakes, with two readings in the reference store and with none; the real reference store on an empty temporary file; git read-only on the checkout | with readings held: `as of "HEAD"` and `as of "2026-11-01"` refused, a sha prefix accepted. With none held (`latest_commit()` is `None` on the empty store): `as of "HEAD"`, the date and an unknown name all answered, the universe's cut the string asked | +| `read` under `as of` | the same fakes, one reading at a commit of the checkout fourteen back and one at a sha of forty `d`s that git does not hold | at the commit git holds: that commit's blob and not the head's, under a note saying that `read` read the present, the hit carrying no commit; at the sha git does not hold: `HEAD`'s blob, the same note, the same hit | | row numbering | a table keyed by text, five rows, in a temporary file | after the last row was deleted the next insert was numbered 5 again; a vacuum after a delete in the middle kept the numbers | -Not measured: anything on an instance's own stores; the lexical statistics computed from a mask -at a corpus's size; the causal fiber recomputed over a real instance's sessions; a vector search -with superseded rows joined to the heads at a cut; a retention pass. Each is the measurement of -the stage that builds it. +Not measured: anything on an instance's own stores; the size of a recorded cut and of a chain +table's row, which are arithmetic; how often a row of model output is replaced; the lexical +statistics computed from a mask at a corpus's size; the causal fiber recomputed over a real +instance's sessions, cold or warm; a vector search with superseded rows joined to the heads at a +cut; the reads of the chat log and the attestation ledger through their chain tables; a +retention pass. Each is the measurement of the stage that builds it. ## 12. The build order @@ -1153,50 +1645,99 @@ request against main with its tests and its rollback, each transcribing its laws property-testing the transcription against the Lean statements; the laws a stage relies on enter `docs/LAWS.md` and `formal/Spec/` with it, as design theorems do when code comes to rely on them. -- **SN-1 the landing log.** The `landings` table of §3.2 in the catalog's file, created by the - catalog's own migration (`core/stores/catalog.py:77-92`) and written inside `record`, - `tombstone`, `remove`, `remove_digest`, `relabel_provenance` and `migrate_rekey_doc_id`, in the - transaction of the row each writes, so that a `deferred()` batch (`catalog.py:125-138`) carries - its log rows; a `genesis` at first open; the reads `read_at(class, path, c)`, - `heads_at(class, c)`, `read_between(class, a, b)`, `head(class)` and `verify(class)`. Nothing - reads them yet, and no reader's behaviour changes. Tests: SNP-1 to SNP-5 as §10 states them, - over random sequences of catalog writes; the catalog equals the fold of the log after every - write; a store the UNCHANGED check skips writes no row; a transaction killed between the two - rows leaves neither; the genesis equals the catalog; `verify` fails on an edited row. The laws - SNP-1 to SNP-5 enter the ledger here. Rollback: the table is additive and unread, so dropping - it restores the file; a build that stops writing it and resumes later appends a `horizon`. -- **SN-2 cuts.** The chain tables for `chat` and `att`; the `cuts` table and the `cut` - attestation; a record at a sensed commit, at a moved trough and on command; the four names; the - resolver; a command that records, lists and verifies cuts. Tests: SNP-8 and SNP-9 as stated. - Rollback: additive tables; the names fall back to today's. -- **SN-3 the erasure's reach and the seal.** A purge empties the log's rows, removes the lexical - units, nulls the version rows' digests, removes the relation edges and artifacts that name the - digest, compacts the vector table and writes its attestation; the seal by identity and the - owner's `unseal`. It lands before SN-4, since SN-4 is the first stage that reads a superseded - version. Tests: SNP-7 as stated, with the purge probe of §11 turned into a test that must find - nothing. Rollback: a purge has none by its nature; the rest is additive. -- **SN-4 the notes at a cut.** The universe's nodes from `heads_at`; `read` from the raw object - the log names; the vectors and the lexical units joined to the heads; the pending rule at a - cut; `trace` at a cut; the cut read and its note (§7.1), which retires the note that says a verb - read the present; the commit on a `read` hit. Tests: `as of "head"` against no `as of` over the - query battery (`eval/query_battery.py`); a sentence at a recorded cut asked before and after - unrelated landings; SNP-6 with two grants; the cut read under the cut asked. Rollback: one - configuration switch under `[query]`, off being today's behaviour. +- **SN-1 the landing log.** What is built: + - The tables `landing_chains` and `landings` of §3.2 with their three indexes, in the + catalog's file, created by the catalog's own migration after it fills `doc_id` + (`core/stores/catalog.py:77-92`), and the genesis of §3.2 for each class the catalog holds. + - The log written inside `record`, `tombstone`, `relabel_provenance`, + `migrate_rekey_doc_id`, `remove` and `remove_digest`, in the transaction of the row each + writes, so that a `deferred()` batch (`catalog.py:125-138`) carries its log rows. `record` + gains a `version` argument (`None` where the place keeps no chain), passed at + `writer.py:419`, `:433` and `sync.py:201`. `att_head` is `NULL` at this stage. + `relabel_provenance` rewrites the label in `landing_chains` and no row of `landings`. + `remove` and `remove_digest` empty the log's rows of the path or of the digest as §6.1 + says, the key kept, so the purge's effect on the log is this stage's and not SN-3's. + - The reads, on `VaultCatalog`: `chains(class)`; `head(chain)`; `read_at(chain, c)`, the rows + with `seq ≤ c` in order; `state_at(class, path, c)`, the path's last event at or under the + cut over the class's chains, which is a `store`, a `retire` or `move`, a hole, or nothing; + `history_at(class, path, c)`, its `store` rows at or under the cut; `heads_at(class, c)`, + the `store` rows alive at the cut over the class's chains, a hole returned as a hole with + its position and no name; `read_between(chain, a, b)`; and `verify(chain)`, which recomputes + the hashes from the first row and the commitment of every row that still has its salt. The + statements of `state_at` and `history_at` name `landings_path`. Here `c` is a position of a + chain, or for a class one position a chain. + - Nothing reads them yet, and no reader's behaviour changes. + + Tests, in `tests/property/test_landing_log.py`: SNP-1 to SNP-5 as §10 states them, over + random sequences of catalog writes that include retires, renames, relabels and purges; the + catalog equals the fold of the log after every write, a purge included; a `record` that + changes nothing, and a store the UNCHANGED check skips, write no row; a transaction killed + between the two rows leaves neither; the genesis equals the catalog, tombstoned paths + included, and is followed by a horizon; after a relabel into a class that has rows, no row of + the log changed and every chain verifies; after a purge of an old version of a live path the + three reads return a hole at a cut where it was the head; `verify` fails on an edited row. + + The ledger: `docs/LAWS.md` gains a family XVI, the temporal snapshot, with rows SNP-1 to + SNP-5, each with its statement as §10 gives it, the reads above as its code, the tests above, + and the Lean declarations §10 lists for it. `formal/Spec/Snapshot.lean` restates those + declarations over `Palace/Snapshot/Defs.lean` with their proofs left out, and + `formal/comparator.json` gains their names, as the last family added did. + + Rollback: the tables are additive and unread, so dropping them restores the file; a build + that stops writing them and resumes later appends a `horizon`. +- **SN-2 cuts.** The chain tables, each with its running hash and its genesis followed by a + horizon, for `chat`, `att`, `staging` and `runs`; `att_head` filled from then on; the + extractor's version and the projection's position on `att` stamped on new citation edges, + the edges already held stamped with the genesis; the `cuts` table of §3.3, a record at a + trough that moved and on command, and an attestor method that builds and signs an attestation + without appending it; the four names, with every name that resolves to nothing refused; the + resolver of §3.5, the floor and the descent alternated; a command, `mind-palace cut` with + `record`, `list` and `verify`. Tests: SNP-8 and SNP-9 as stated; the served resolver against + enumeration; a record refused inside a job. SNP-8 enters the ledger as resolution, with its + closure cited to CLK-2's row, and SNP-9 with it. Rollback: additive tables and columns; the + names fall back to today's. +- **SN-3 the erasure's reach and the seal.** A purge removes the lexical units, nulls the + version rows' digests, removes the relation edges and artifacts that name the digest, opens + the curated store, nulls the support and text of the dream claims and the digest and payload + of the staging rows, removes the claim ops on a removed artifact and the rejected requests + that hold the text, compacts both vector tables and writes its attestation, which names the + positions it emptied (§6.1); decision D9's form for the attestation ledger; the seal by + identity over the value and the history, and the owner's `unseal`. It lands before SN-4, since + SN-4 is the first stage that reads a superseded version. Tests: SNP-7 as stated, with the + purge probe of §11 turned into a test that must find nothing. Rollback: a purge has none by + its nature; the rest is additive. +- **SN-4 the notes at a cut.** The universe's nodes from `heads_at`, with kept heads for a chain + over the size §4.2 gives; `read` from the raw object the log names, and refused for a + repository path whose commit git lacks; the vectors and the lexical units joined to the heads; + the pending rule at a cut; the curated rows that landed through the catalog, and the count of + those that did not; the citation reading as projected at or under the cut; `trace` at a cut; + the cut read and its note (§7.1), which retires the note that says a verb read the present; + the commit on a `read` hit. Tests: `as of "head"` against no `as of` over the query battery + (`eval/query_battery.py`); a sentence at a recorded cut asked before and after unrelated + landings and after a re-projection; SNP-6 with two grants, as §10 states it; the cut read + under the cut asked, and equal to the record but for the chains that could not serve. + Rollback: one configuration switch under `[query]`, off being today's behaviour. - **SN-5 the causal fiber at a cut.** The recomputation of §5.5 with its memo; edges named by session, order and endpoint; the transcript integrator's checkpoint a cut on `chat` and `repo`. Tests: the two job orders giving one result; the prefix that ends before a result; the stored rows at the head equal to the recomputation. Rollback: the stored rows stay the head's cache. -- **SN-6 model output by generation.** A sequence number and a history table for artifacts, - relation edges and claim ops; `relate` at a cut; a kept row served only with its sources. - Tests: SNP-5 on random sequences of writes and replacements; `mem_serve_iff`'s test. Rollback: - additive columns and tables. +- **SN-6 model output by generation.** A sequence number, a running hash and a history table + for the interpreted artifacts and the interpreted relation edges, a chain each, and a + sequence number for the claim ops and the authored supersessions; the authored relations + recomputed at a cut; `relate` at a cut; a kept row served only with its sources and its + attestation inside the cut (§5.4). Tests: SNP-5 on random sequences of writes and + replacements; `mem_serve_iff`'s test; an artifact replaced over the same titles served with + the sources each generation had. Rollback: additive columns and tables. - **SN-7 retention.** The two windows a chain in the instance's configuration; the pass of §9.2; the `horizon` row; the horizon in the answers. Tests: SNP-10 as stated; a pass killed at each step leaving no served position incomplete; a derived row dropped under the first window - reported pending and derived again. Rollback: none for dropped rows by their nature; nothing - runs unless a window is declared. + reported pending and derived again; a cut asked under a landing chain's new horizon read with + every other chain as recorded. Rollback: none for dropped rows by their nature; nothing runs + unless a window is declared. - **SN-8 the delta.** `changed between` and `changed since` (§7.4); the integrator interface below. Tests: the region's union law, and equal reads at both cuts for an identity outside it. + Rollback: the region is a new production of the grammar and the interface a new module, so + both are withdrawn by removing them; no store changes. **A generic integrator on the delta.** An integrator job is a registered, scoped job that reads what changed and writes one batch of edges with their evidence. Its checkpoint is a cut `a`. A @@ -1218,28 +1759,35 @@ where they are. `[THEOREM: SNP-1, SNP-3; DERIVED for the job]` ## 13. Decisions for the owner -Each with the recommendation and what the alternative costs. +Each with the recommendation and what the alternative costs. Where a cost has a figure it is +given; where it has none, that is said. 1. **D1, where the catalog's past is kept.** Recommended: the landing log in the catalog's file, - written by the catalog (§3.2). The alternatives: version chains for every place, which is a - second file, so the key and its history are two transactions and ING-7's order gains a stage, - and whose chains are per document, so a cut is a pair a document; or the plane's supersession - log, which an instance with no plane lacks, which records the drain's order under lazy - embedding, and which gives a position again after a purge. -2. **D2, the grain of a cut.** Recommended: one position a chain, the landing chains one a - provenance class (§3.1). The alternatives: a position a document, the spine's frontier today, - which is millions of pairs a cut on a corpus instance; or one landing chain for every class, - which saves a few integers a cut and tells a narrower reader, by its positions, how many - landings the classes it cannot read made. -3. **D3, what a retire does to the past.** Recommended: the stricter seal, by identity, lifted - only by the owner's `unseal` (§6.2). The alternative, the looser seal, brings a deleted note's - versions back at earlier cuts when another note is written at its path, and lets a past answer - grow; it needs no unseal when a vault is missing at a rescan, where the stricter one does. -4. **D4, a store that cannot serve the cut asked.** Recommended: read it at the greatest position - at or under the cut that it serves, and name the cut read (§7.1). The alternatives: refuse the - sentence, after which `as of` answers nothing that touches a store without a past until SN-6, - and nothing under a horizon ever; or keep today's behaviour, which answers from after the cut - and changes as the store grows. + written by the catalog (§3.2), at about 0.4 kilobytes a landing on the fixture. The + alternatives: version chains for every place, which is a second file, so the key and its + history are two transactions, one more commit a landing, and ING-7's order gains a stage, and + whose chains are per document, so a cut is a pair an item; or the plane's supersession log, + which an instance with no plane lacks, which records the drain's order under lazy embedding, + and which gives a position again after a purge. +2. **D2, the grain of a cut.** Recommended: one position a chain, the landing chains each of one + provenance class (§3.1): about a dozen integers. The alternatives: a position a document, + which today's spine has only for the one place that keeps version chains and which, extended + to every place, is ten million pairs a cut at the scale the corpus records plan for; or one + landing chain for every class, which saves a few integers a cut and tells a narrower reader, + by its positions, how many landings the classes it cannot read made. +3. **D3, what a retire does to the past.** Recommended: the stricter seal, by identity, over the + value and the versions, lifted only by the owner's `unseal` (§6.2). The alternative, the + looser seal, brings a deleted note's versions back at earlier cuts when another note is + written at its path, and lets a past answer grow; it needs no unseal when a vault is missing + at a sync, where the stricter one needs one row. Neither is free at the head: under both, + the history of a note written at a deleted note's path has to stop at the delete, which + today it does not (§2.3, item 8). +4. **D4, a store that cannot serve the cut asked.** Recommended: read at the greatest consistent + cut among the positions the stores serve, and name it (§7.1). With the recorded cuts on a + chain of their own (D13) that lowers only the chains that could not serve. The alternatives: + refuse the sentence, after which `as of` answers nothing that touches a store without a past + until SN-6, and nothing under a horizon ever; or keep today's behaviour, which answers from + after the cut and changes as the store grows. 5. **D5, the embedder's and the tokenizer's identity at a cut.** Recommended: the present's (§5.2, §5.3). The alternative, the identity in force when the content landed, needs every identity's vectors kept, a vector table an identity (1,536 bytes an atom at the present @@ -1249,47 +1797,82 @@ Each with the recommendation and what the alternative costs. two commits and none on an instance with no repository; or dates without the cut read in the answer, which gives an answer that cannot be asked again. 7. **D7, between two cuts.** Recommended: the region `changed between` and `changed since` - (§7.4). The alternatives: nothing, and every integrator and every question about change is a - hand-written read; or a general two-cut adjective, which is a second universe a sentence and a - pair sort, and which dn-graph-dynamics designs already as GD-4. + (§7.4), one range read of the log. The alternatives: nothing, and every integrator and every + question about change is a hand-written read; or a general two-cut adjective, which is a + second universe a sentence and a pair sort, and which dn-graph-dynamics designs already as + GD-4. Neither alternative is sized here. 8. **D8, retention.** Recommended: no window on the default instance; where the disk is bounded, - a window for derived rows, which moves no horizon, and a window for the history only when the - owner declares one, since it drops raw objects (§9.2). The alternatives: a horizon everywhere, - which loses the default instance's history to save megabytes a year; or the last `n` versions + a window for derived rows, which moves no horizon and frees what a superseded version mostly + costs, about 29 kilobytes of derived rows for a note of four chunks by §9.1's arithmetic; and + a window for the history only when the owner declares one, since it drops raw objects + (§9.2). The alternatives: a horizon everywhere, which over the first window frees only a + closed version's raw bytes and its 0.4 kilobytes of log, and loses the default instance's + history for it; that trade is worth making only where raw objects are large, as a transcript + retained whole at each growth is (0.79 MB a growth on the fixture). Or the last `n` versions an identity, which leaves no horizon to name. 9. **D9, the attestation ledger under a purge.** It still names a purged digest (§6.1), against - the plane's rule that no content hash of purged text is kept. Recommended: from SN-3 on a - landing's attestation names the log row's commitment in place of the content digest, so a - purge leaves nothing that can be tested; the rows written before stay, and a purge lists them - as what it could not reach. It makes an attestation a landing, a kilobyte each at the recorded - row size, where today there is one per action and digest, and it turns the landing's check - for an earlier attestation into a read of the log, where today it scans the ledger - (`core/ingest/landing.py:16-19`). The alternatives: rewrite the ledger at a purge, which - breaks its construction as append-only and every id computed from a row; or leave it, and a - digest of purged bytes stays. -10. **D10, model output.** Recommended: kept by generation (§5.4). The alternative, outside the - snapshot, costs nothing and means `relate` and the dreams are never read at a past cut. + the plane's rule that no content hash of purged text is kept. Recommended: from SN-3 on, an + attestation names a content digest by a salted commitment, the salt held in a side table of + the attestation store keyed by a keyed hash of the digest, written in the transaction of the + first attestation that names the digest. The landing order does not change: the attestation + still comes before the key, a re-run after a crash finds the salt by the digest and attests + nothing twice, and the landing still reads from its attestation. A purge deletes the side + row, after which no attestation can be tested against a guess of the content. It costs a + side row a distinct digest, of the order of a hundred bytes; a lookup an attestation; every + reader that matches an attestation's hashes against a digest going through the side table + (`core/attestation/attestor.py:59-69`, `core/ingest/landing.py:60-75`); and an outside + verifier needing the salt to check an attestation against bytes. The rows written before + stay, and a purge lists their ids as what it could not reach. The alternatives. Name the + landing log's commitment in the attestation: the log's row, its salt and its position are + written in the key's transaction, last, and its commitment covers `att_head`, so either the + attestation moves after the key, which reverses the reference of §3.5 and leaves a landed + item unattested after a crash between the two, or the salt and the position are fixed before + the attestation, which is a write before ING-7's first stage. Rewrite the ledger at a purge, + which breaks its construction as append-only and every id computed from a row. Or leave it, + and a digest of purged bytes stays. +10. **D10, model output.** Recommended: the interpreted artifacts and the interpreted relation + edges kept by generation (§5.4). The alternative, outside the snapshot, costs nothing and + means `relate` over interpreted edges and the dreams are never read at a past cut. The + relations a note declares are not part of this decision: they are recomputed at a cut + either way. 11. **D11, the read-only principal at a cut.** Recommended: the present's list, applied to the edges inside the cut (§6.4). The alternative, the list taken at the cut's tree, shows at a past cut a file that was tracked then and is not now, which the head withholds, and makes the grant a function of the cut. -12. **D12, what the merge licenses.** Recommended: SN-1 and SN-2, which add tables and change no - reader. SN-3 to SN-8 change an erasure, the universe and what an instance keeps, and each is - licensed with its own pull request. The alternative, all eight at once, saves the owner seven - decisions and reviews the purge, the universe and retention together. +12. **D12, what the merge licenses.** Recommended: SN-1 and SN-2. SN-1 adds tables and changes + no reader. SN-2 adds tables, columns and names; the one behaviour it changes is that a name + which resolves to nothing is refused on an instance whose reference store is empty, where + today it is answered (§2.1). SN-3 to SN-8 change an erasure, the universe and what an + instance keeps, and each is licensed with its own pull request. The alternative, all eight + at once, saves the owner seven decisions and reviews the purge, the universe and retention + together. +13. **D13, where a recorded cut is kept.** Recommended: a chain of its own that nothing reads, + its attestation in its own row (§3.3). The alternative, a row of the attestation ledger, + is one table fewer and signs a record where every other attestation is signed; but every + landing reads that ledger, so a chain read below a position a record certified, as a + landing chain behind a history window is, takes every landing chain to its empty prefix + (`Witness.record_drags`). +14. **D14, what a purged row of the log keeps.** Recommended: the keyed hash of its path, with + its position (§6.1), 47 bytes a row of index on the fixture. The alternatives: keep the + path, which saves the hash and leaves a purged note's name readable in the log when every + version of it is purged; or keep no key, after which a read by path at a cut returns the + version before the purged one (`Witness.keyless_hole`). ## Parked decisions | id | decision | default recorded | re-entry condition | |---|---|---|---| -| SN-a | the cadence of recorded cuts | a sensed commit, a moved trough, the owner's command | a date that resolves to a cut farther from it than a declared tolerance | -| SN-b | the citation readings as rows valid over a range of commits | one whole reading a commit, as built | the store's size on an instance | -| SN-c | the heads kept at some recorded cuts | none: every head is read from the log | reading every head at a cut past a tenth of a second on an instance | +| SN-a | the cadence of recorded cuts | a trough that moved, the owner's command | a date that resolves to a cut farther from it than a declared tolerance | +| SN-b | the citation readings as rows valid over a range of commits | append-only rows a commit, stamped with their projection | the store's size on an instance | +| SN-c | the heads kept at some recorded cuts | none for a chain under 250,000 events; kept, from SN-4, for a chain over it (§4.2) | `heads_at` past a tenth of a second on a chain under the threshold, or under it by a wide margin on one over | | SN-d | a second embedder identity's vectors kept beside the first | none: the present's identity | dn-two-phase-ingestion's open question 4 | | SN-e | lexical statistics stored per class and per recorded cut | computed from the mask | a lexical query at a past cut over its budget | -| SN-f | `repo` as a graph of commits | the line of the branch the sensor reads | an instance whose history has merges or that reads several repositories | +| SN-f | `repo` as a graph of commits, and a chain a repository | the line of the branch the sensor reads, one repository | an instance whose history has merges or that reads several repositories | | SN-g | which recorded cuts are kept under a horizon | the records stay as attested claims; their chains' rows go | a consumer that must verify a cut under a horizon | | SN-h | generations with a diff for the causal fiber | recomputation with a memo | SNF-5 | +| SN-i | the curated rows written outside the catalog | outside the snapshot, counted in the answer's note (§5.6) | the script routed through the writer | +| SN-j | a date asked under a narrower grant | resolved over every record, the answer showing the record's id and its positions on the grant's chains only | a use that must hide when the instance was quiescent | +| SN-k | the genesis of a class seeded from the plane's supersession log | not seeded: the genesis is the catalog as it stands | a need for a path's order before the log existed, on an instance that has a plane | ## Falsifiers @@ -1307,8 +1890,10 @@ Each with the recommendation and what the alternative costs. answer with a lowered chain. Then such a sentence is refused (D4's first alternative). - **SNF-5 (recomputing the causal fiber is too slow):** a sentence that walks `C` at a past cut over a second on a real instance, the memo warm. Then generations with a diff (SN-h). -- **SNF-6 (every head is too slow):** `heads_at` past a tenth of a second on an instance's log. - Then the kept heads of SN-c. +- **SNF-6 (the threshold for kept heads is wrong):** `heads_at` past a tenth of a second on a + chain under 250,000 events, or the kept heads costing more than the read they save on one + over. Then the threshold moves; on the fixture the read from the log alone passes a tenth of + a second between 100,000 and 500,000 events (§4.2). - **SNF-7 (the mask is too slow for the lexical statistics):** a lexical query at a past cut over its budget at the instance's size. Then SN-e; the rule that the statistics are the mask's does not change. @@ -1317,34 +1902,40 @@ Each with the recommendation and what the alternative costs. alternative. - **SNF-9 (retention drops what is asked for):** cuts asked for under a declared horizon, or a pass ordered by the field that drops rows later asked for more often than a pass ordered by - age. Then the window grows, or the order is age. + age. Then the window grows, or the order stays age. - **SNF-10 (the stricter seal is the wrong default):** unseals become routine, as an instance - whose vault goes missing at rescans would show. Then D3 takes the looser seal, with its cost. + whose vault goes missing at syncs would show. Then D3 takes the looser seal, with its cost. - **SNF-11 (a transcription lies):** a built stage whose property test against a Lean statement fails. A transcription defect; the stage does not land until it agrees. - **SNF-12 (an erasure leaks):** after a purge, a read at any cut or a scan of the instance's files finds the purged words. Then SN-3's reach is incomplete and no stage after it is on. - **SNF-13 (append invariance fails on the code):** a sentence at a recorded cut that answers - differently after unrelated landings, the erasure and the grant unchanged; or `as of "head"` - that differs from no `as of`. Then some reader is not a function of the prefixes, and SNP-5 - says which kind of store to look for. + differently after unrelated landings or a re-projection, the erasure, the seals and the grant + unchanged; or `as of "head"` that differs from no `as of`. Then some reader is not a function + of the prefixes, and SNP-5 says which kind of store to look for. - **SNF-14 (the region is not what is asked):** questions about change that need the two readings and cannot be put with the region. Then GD-4's form is built sooner, on the two readings this note supplies. +- **SNF-15 (a lowering is not local):** at a recorded cut, a chain read below the record though + it serves the record's position. Then some chain that can fail to serve is read through a + recorded bound, the premise of §7.1 is false for it, and that reference is found and moved + off the resolver's bounds or the chain is kept whole. ## Open questions -- May a narrower grant name a date? The answer names a cut on its own chains only, but the - cadence of recorded cuts is itself a fact about when the stores were written. +Each with the default the stages build on until it is decided. + - The chat log and the attestation ledger have no erasure today except a reset. Their chain tables digest commitments so that one can leave a hole; who may erase a turn is not decided - here. -- Should the genesis of a class the plane holds be seeded from the plane's supersession log? It - would recover an order per path before the log existed, without positions across paths, and - not on an instance with no plane. -- A purge does not reach a backup or a migration's archive. Whether a recorded cut is taken - before a purge, so that the purge's own moment is certified, belongs with that design. -- On an instance that reads several repositories, is `repo` one chain a repository? + here. Default: no erasure of a turn is built. +- A purge does not reach a backup or a migration's archive. A backup restored from before a + purge verifies every certificate and holds what was purged (§3.6), so a restore has to apply + the purges recorded since; that procedure, and whether a recorded cut is taken before a purge + so that the purge's own moment is certified, belong with the design of backups. Default: + neither is built, and the purge's attestation lists the positions it emptied so that either + can be. +- The `cuts` chain under a reset: the records name chains by id, and a reset makes new chains. + Default: the records are in the catalog's file and go with it. ## Cross-references @@ -1354,10 +1945,11 @@ Each with the recommendation and what the alternative costs. `prune`, `sealedAt`, `servedAt`, `servedNow`, `restrict`, `snapshot`, `redact`, `visible`, `compact`, `serve`, `committed`, `purge`, `commitments`, `contents`, `Consistent`, `generator`, `reached`, `Resolves`, `reachedIn`, `ResolvesIn`, `chainDigest`, `CollisionFree`, `Certificate`, -`certify`, `Verifies`); `formal/Palace/Snapshot.lean` (the declarations §10 names, by law, and -the `Witness` controls); `formal/PalaceTest/Snapshot.lean` (seeds 430 to 486); the families -cited: `Palace/Clock.lean` (CLK-2: `IsCut`, `frontierCut`, `isCut_iff_not_crossed`, -`IsCut.inter`, `IsCut.union`), `Palace/Ingress.lean` (ING-7), `Palace/Script.lean` (ING-17), +`certify`, `Verifies`, and `sinceRetire`, `historyAt`, `holes`, `shown`); +`formal/Palace/Snapshot.lean` (the declarations §10 names, by law, and the fifteen `Witness` +controls); `formal/PalaceTest/Snapshot.lean` (seeds 430 to 513); the families cited: +`Palace/Clock.lean` (CLK-2: `IsCut`, `frontierCut`, `isCut_iff_not_crossed`, `IsCut.inter`, +`IsCut.union`, `IsCut.frontier_inf`, `IsCut.frontier_sup`), `Palace/Ingress.lean` (ING-7), `Palace/Script.lean` (ING-17), `Palace/Derived.lean` (ING-19 to ING-21), `Palace/Plane.lean` (PLN-4), `Palace/Utility.lean` (UTL-2, UTL-4), `Palace/Sentence.lean` (QSA-1 to QSA-4, QSA-10). @@ -1367,13 +1959,20 @@ cited: `Palace/Clock.lean` (CLK-2: `IsCut`, `frontierCut`, `isCut_iff_not_crosse `chatlog.py`, `chat_events.py`, `causal_edges.py`, `reference_edges.py`, `plane.py`, `vectorstore.py`, `lexical.py`, `memberships.py`, `derived.py`, `edges.py`, `claim_ops.py`, `authored_supersession.py`, `staging.py`, `observation_history.py`, `code_observations.py`, -`runledger.py`, `verdicts.py`; `core/kernel/stores/rawstore.py`; `core/attestation/store.py`, +`agent_observations.py`, `curated_store.py`, `runledger.py`, `verdicts.py`; +`core/kernel/stores/rawstore.py`, `core/kernel/recursion_ops.py`; `core/attestation/store.py`, `record.py`, `attestor.py`; `core/ingest/writer.py`, `landing.py`, `table.py`, `purge.py`, -`derive.py`, `sync.py`; `core/chat_events.py`, `core/integrator.py`; `ops/code_sensor.py`, -`ops/code_snapshot.py`, `ops/chat_sensor.py`, `ops/lifecycle/launcher.py`; -`eval/predictions/ledger.py`. - -**Design:** global-event-clock §2.2 to §2.4 (the generators, Law C4, the certified frontier); +`derive.py`, `sync.py`, `curated.py`, `readers.py`, `ingress.py`, `stream.py`; +`core/relations.py`, `core/curator/curator.py`, `core/dreaming/dreamer.py`, +`core/complex/temporal.py`, `core/verdict/dispositions.py`; `core/chat_events.py`, +`core/integrator.py`; `ingress/sync_vault.palace`, `ingress/sync_corpus.palace`; +`scripts/purge_raw.py`, `scripts/curate_local.py`, `scripts/migrate_provenance_split.py`; +`ops/code_sensor.py`, `ops/self_sensor.py`, `ops/code_snapshot.py`, `ops/chat_sensor.py`, +`ops/heartbeat.py`, `ops/ledger.py`, `ops/effect_ledger.py`, `ops/lifecycle/launcher.py`, +`ops/lifecycle/runs.py`; `eval/harness/store.py`, `eval/predictions/ledger.py`. + +**Design:** global-event-clock §2.2 to §2.4 (the generators, Law C4, the certified frontier, +GC-N3's three certificates); limits-of-the-algebra L7; dn-query-sentence-algebra §2.3, §2.7, §2.9; dn-ingress D1, D3, D5 (ING-7, the one writer); dn-ingress-language (ING-13 to ING-17); dn-two-phase-ingestion D1, D2 (ING-19 to ING-21); vector-membership-store A3.5, A3.7 (noninterference, the purge); From fab4deb441282c358fa239730c493b94980d31bf Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 07:01:13 -0500 Subject: [PATCH 21/37] docs(formal): the Snapshot paragraphs after the audit's theorems The README named six of the controls and counted thirty-nine attacks. It now names all fifteen, states SNP-8 as resolution with its closure derived from CLK-2, and lists the forty-five attacks and thirty-nine controls of seeds 430 to 513 with the instances each control took. The track's line for SN-0 says resolution where it said the lattice. Co-Authored-By: Claude Fable 5.2 --- docs/TRACKS.md | 2 +- docs/tracks/query-language.md | 2 +- formal/README.md | 129 ++++++++++++++++++++-------------- 3 files changed, 80 insertions(+), 53 deletions(-) diff --git a/docs/TRACKS.md b/docs/TRACKS.md index a71212ed..ee9b126f 100644 --- a/docs/TRACKS.md +++ b/docs/TRACKS.md @@ -170,7 +170,7 @@ - QL-2 the executor — clause evaluators over the existing stores, the mask/column/product/threshold operators, the product-automaton walker, the overlay for assume - QL-3 the surface — palace query, a /context skill, the resolution ledger, the query log as a sensor - QL-4 the falsifier battery run — composed sentences against flat search on owner-endorsed answers, a finding either way - - SN-0 the temporal snapshot's design proved: dn-temporal-snapshot with SNP-1 to SNP-10 machine-checked in formal/Palace/Snapshot.lean (append invariance, monotonicity, composition, idempotence at the head, derived views as functions of the prefixes, grant restriction, erasure dominance, the lattice of consistent cuts, certified cuts, the horizon), attacks and controls green, the measurements on synthetic fixtures + - SN-0 the temporal snapshot's design proved: dn-temporal-snapshot with SNP-1 to SNP-10 machine-checked in formal/Palace/Snapshot.lean (append invariance, monotonicity, composition, idempotence at the head, derived views as functions of the prefixes, grant restriction, erasure dominance, the resolution of a frontier to a consistent cut, certified cuts, the horizon), attacks and controls green, the measurements on synthetic fixtures - **Reference bookkeeper** (active): - the async F-consistency agent designed (a FABLE design-pass) — bookkeeper still unbuilt - the reference-sensor gap closed (finding-0145) diff --git a/docs/tracks/query-language.md b/docs/tracks/query-language.md index 9e2803cc..5ba8de4f 100644 --- a/docs/tracks/query-language.md +++ b/docs/tracks/query-language.md @@ -11,7 +11,7 @@ dod: - QL-2 the executor — clause evaluators over the existing stores, the mask/column/product/threshold operators, the product-automaton walker, the overlay for assume - QL-3 the surface — palace query, a /context skill, the resolution ledger, the query log as a sensor - QL-4 the falsifier battery run — composed sentences against flat search on owner-endorsed answers, a finding either way - - SN-0 the temporal snapshot's design proved: dn-temporal-snapshot with SNP-1 to SNP-10 machine-checked in formal/Palace/Snapshot.lean (append invariance, monotonicity, composition, idempotence at the head, derived views as functions of the prefixes, grant restriction, erasure dominance, the lattice of consistent cuts, certified cuts, the horizon), attacks and controls green, the measurements on synthetic fixtures + - SN-0 the temporal snapshot's design proved: dn-temporal-snapshot with SNP-1 to SNP-10 machine-checked in formal/Palace/Snapshot.lean (append invariance, monotonicity, composition, idempotence at the head, derived views as functions of the prefixes, grant restriction, erasure dominance, the resolution of a frontier to a consistent cut, certified cuts, the horizon), attacks and controls green, the measurements on synthetic fixtures backlog_deskcheck: null links: - docs/design-notes/dn-query-sentence-algebra.md diff --git a/formal/README.md b/formal/README.md index 880858e3..b4002f80 100644 --- a/formal/README.md +++ b/formal/README.md @@ -325,24 +325,43 @@ Roundoff and FloatModel, so it has no statements of its own): same reading at every cut, a kept derived row is served only when none of its sources is erased, and a key retired after a cut is served at no earlier cut, growth changing a served value only by removing it, where the looser seal that withholds a key only while it is not - live serves everything the stricter one serves and is lifted by a later landing; SNP-8 consistent cuts (every source of an event inside is inside) - are closed under meet and join, a sublattice of the cuts, they are CLK-2's cuts among the - frontier cuts, every frontier resolves to exactly one greatest consistent cut under it, - monotonically, and a consistent cut stays consistent as the store grows; SNP-9 the certificate - of a cut verifies on every extension of the store, two stores that verify one certificate under - a collision-free digest have the same read at its cut and so the same derived views, a - certificate extends over the events since an earlier one, the meet and the join of two - certified cuts are certified from the two certificates alone, and an erasure that keeps a - commitment beside each event keeps every certificate; SNP-10 the horizon: a generational store - that drops the rows closed at or under a horizon reads, at every cut from the horizon on, the - state recomputed from the whole prefix, under the horizon it is never wrong and reads what it - lost as absent, horizons compose to the later one, and where the chains serve only some + live serves everything the stricter one serves and is lifted by a later landing; the seal + covers a key's versions as it covers its value, so after a retire the history served holds + only versions landed since, at every cut; and on a keyed chain whose holes keep their keys + the read of a key at a cut is its last write at or under the cut, a hole when that write is + erased; SNP-8 resolution: the consistent cuts (every source of an event inside is inside) are + CLK-2's cuts among the frontier cuts, so their closure under meet and join is CLK-2's, derived + here from `Clock.IsCut.frontier_inf` and `frontier_sup`; every frontier resolves to exactly + one greatest consistent cut under it, monotonically, a consistent cut stays consistent as the + store grows, and a cut consistent for a recorded bound on the references is consistent for + the true ones; SNP-9 the certificate of a cut verifies on every extension of the store, two + stores that verify one certificate under a collision-free digest have the same prefix of + every digested chain at its cut and so the same derived views of it, a certificate extends + over the events since an earlier one, the meet and the join of two certified cuts are + certified from the two certificates alone, an erasure that keeps a commitment beside each + event keeps every certificate, a certificate attests no erasure, and under a binding + commitment it pins the events, so two stores that verify it read the same store with holes + under one erasure; SNP-10 the horizon: a generational store that drops the rows closed at or + under a horizon reads, at every cut from the horizon on, the state recomputed from the whole + prefix, under the horizon it is never wrong and reads what it lost as absent, horizons compose + to the later one and commute with a later landing, and where the chains serve only some positions (those from a horizon on, and the empty prefix) every frontier resolves to exactly - one greatest consistent cut among them, which rises with what is served and never passes the - cut asked. The controls as theorems: the reader that ignores the cut, the store rewritten in - place, an event filter applied before the cut, the erasure that deletes rows, a digest with - collisions, the pruned store read under its horizon. Design theorems (Palace and PalaceTest, no - Spec rows): `as of` reads the citation graph at a commit and every other store as it is now. + one greatest consistent cut among them, which never passes the cut asked and rises with the + frontier and with served positions that grow; a chain that no other chain reads is lowered + alone, every other chain read as asked. The grant and the erasure applied to one read + (`shown`) keep the laws of each. The fifteen controls as theorems, in `Witness`: the reader + that ignores the cut (`present_not_appendInvariant`), the store rewritten in place + (`stateOf_forgets`), an event filter applied before the cut (`filter_before_cut`), positions + that count hidden events (`position_channel`), the erasure that deletes rows + (`compact_moves`), the looser seal lifted by a later landing (`servedNow_restores`), the + pruned store read under its horizon and unable to tell a lost key from one never written + (`prune_forgets`, `prune_indistinct`), a digest with collisions (`digest_collides`), a hole + that loses its key (`keyless_hole`), a seal written after a certified cut + (`seal_not_certified`), a renamed chain (`rename_breaks_certificate`), a record on a chain + that content reads (`record_drags`), a named chain that reads an unnamed one + (`resolution_reads_unnamed`), and served positions that shrink (`served_set_shrinks`). Design + theorems (Palace and PalaceTest, no Spec rows): `as of` reads the citation graph at a commit + and every other store as it is now. - `Bridges`: theorems that join two families, so that what one proves serves the other: BRG-1 the Laplacian as `∂₁ ∂₁ᵀ`, BRG-2 Euler and Poincaré on the flag complex, BRG-3 Thomson's principle on edge flows, BRG-4 the clock's cuts and scope's closed strata as lower sets, BRG-5 @@ -873,44 +892,52 @@ at a gain above the rate the ceiling is fixed, on the first instance; at exponen not constant, on the first instance; and the greedy walk's empirical measure is not within `1/8` of the structural stationary distribution, on the first instance. -The snapshot is attacked on the model's own definitions (seeds 430 to 486): stores of two +The snapshot is attacked on the model's own definitions (seeds 430 to 513): stores of two chains over three events, cuts from two naturals, keyed chains over three keys, chains of landings and retires from codes, grants from two bits and event filters and erasures from three, reads-from relations as lists of edges between the two chains at positions under four, a digest that reads a chain as a numeral in base four, which is collision free, and the positions -a chain serves from ten bits. Thirty-nine attacks -survived, every one all 500 instances: the read at a cut and between two cuts under growth; the -prefix order and the meet; the two compositions and the journal; the head cut; the generational -store against the recomputed state and the last write, one generation alive at most, the same -under growth, and the keyed journal; an event of the later cut in the earlier one or in the -delta, and the key the delta does not write; the narrower grant, and the chains a snapshot -reads; the -erasure (nothing erased visible, positions kept, the holes dropped), the retire that seals every -earlier cut, growth that only removes, the two seals in their order, and the kept rows with their -sources; the resolver, the -meet and the join of consistent cuts, and the monotone resolution; the certificate under growth, -the digest of a reversed chain, the certificate over the delta, at the meet and the join, and -across an erasure on a committed store; the pruned generational store at and past its horizon, -never wrong under it, and two horizons as the later one; and, among the served positions, the -greatest consistent cut under a frontier found by enumeration, consistent and served, under the -resolution of the frontier, rising with what is served, and equal to the resolution when every -position is served. The resolver is the one thing attacked that the library -does not define: the descent that lowers a frontier until no event inside it has a source -outside, checked against the greatest consistent cut by enumerating the thirty-six cuts of the -grid. The eighteen controls, each refuted: a read at a cut past the head changes with growth, -within 11 instances; the read at one cut is a prefix of the read at any other, within 6; the -composition with the cuts in any order, within 6; the store rewritten in place as the state at a -cut, within 5; generations without the closing stamp, which read a key's oldest write, within 18; -an event filter applied before the cut, within 26; two stores with the same admitted events and -one hidden event more before the cut, within 7; an erasure that deletes rows, after which a read -at a cut holds an event from after it, within 29; the state at a cut served without the seal, -within 53; the looser seal taken for one under which growth only removes, within 48; the kept -rows served without their sources, within 11; the frontier taken for a -consistent cut, within 11; a consistent cut advanced by one position, within 12; the additive -digest, under which a chain and its reverse agree, within 11; a digest over the contents, -which an erasure changes, within 14; a key's state taken for the same at two cuts whatever the -delta writes, within 17; the pruned store read under its horizon as the state at the cut, within -30; and a frontier lowered to the served positions without the descent, within 24. +a chain serves from ten bits. Forty-five attacks survived, every one all 500 instances: the read +at a cut and between two cuts under growth; the prefix order and the meet; the two compositions +and the journal; the head cut; the generational store against the recomputed state and the last +write, one generation alive at most, the same under growth, and the keyed journal; an event of +the later cut in the earlier one or in the delta, and the key the delta does not write; the +narrower grant, the chains a snapshot reads, and the grant and the erasure together; the erasure +(nothing erased visible or shown, positions kept, the holes dropped), the keyed read on a chain +whose holes keep their keys, the retire that seals every earlier cut, growth that only removes, +the two seals in their order, the history served under the seal, and the kept rows with their +sources; the resolver, the meet and the join of consistent cuts, and the monotone resolution; +the certificate under growth, the digest of a reversed chain, the certificate over the delta, at +the meet and the join, and across an erasure on a committed store; the pruned generational +store at and past its horizon, never wrong under it, and two horizons as the later one; and, +among the served positions, the greatest consistent cut under a frontier found by enumeration, +consistent and served, under the resolution of the frontier, rising with what is served, equal +to the resolution when every position is served, and equal to the frontier with an unread chain +lowered alone. Two resolvers are attacked that the library does not define: the descent that +lowers a frontier until no event inside it has a source outside, checked against the greatest +consistent cut by enumerating the thirty-six cuts of the grid (461), and its alternation with +the floor to the served positions, checked against the greatest consistent served cut (492). + +The thirty-nine controls, each refuted, with the instances it took. A read at a cut past the +head changes with growth, for the prefix, the read between two cuts and the generational store +(11, 11, 7). The read at one cut is a prefix of the read at any other (6); a cut of a cut is +the join (5); the read at a cut that is not the head is the store (8). The composition with +the cuts in any order (6), in the other order (16), and with the delta left out (7, 6). The +store rewritten in place as the state at a cut (5); generations without the closing stamp +(18); a key's state the same at two cuts whatever the delta writes (17). An event filter +applied before the cut (26); a hidden event more before the cut (7); a narrower grant under a +smaller erasure (45). An erasure that deletes rows (29); a seek over the rows that kept their +key, and over the chain with its holes deleted (35, 17); the state served without the seal +(53); the looser seal as one under which growth only removes (48); the history without the +seal (33); the kept rows served without their sources (11). The frontier taken for a +consistent cut (11); a consistent cut advanced by one position (12); resolution falling as the +frontier rises (6). The additive digest (11); a digest over the contents (14); the certificate +of a cut past the head (6); the meet certified from the later digest (5). The pruned store read +under its horizon (30); pruning at the earlier of two horizons (24); a frontier lowered to the +served positions without the descent (24); the floor and the descent each run once, in either +order (17, 26); a chain that others read lowered alone (17); the cut read reaching the floor +(23), rising when less is served (10), and equal to the resolution when not every position is +served (5). ## Build From 8d72ffacf0cdb422f0e14b633b19f62ca3f6cc15 Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 07:10:52 -0500 Subject: [PATCH 22/37] docs(paper): the snapshot article after the audit The article said every other verb reads the present, that no store drops a superseded version, and that the lattice of consistent cuts and the served resolver were this work's own checked results. It now says what the note and the library say. SNP-8 is stated as resolution, with closure derived from the clock's law. SNP-7 gains the keyed read on a chain whose holes keep their keys and the history under the seal. SNP-9 says a certificate pins what it digests and attests no erasure, seal or grant. SNP-10 gains the lowering of unread chains and its control, a record on a chain content reads. The design paragraphs follow: chain ids, records on their own chain at a trough, stamped citation edges, the keyed hash a purged row keeps. The evaluation gives the figures of the redesigned log and of the run of formal/check.sh on this tree, says the probes are not in the repository, and says Algorithm 1 is run as written against enumeration. The references were checked against Crossref and OpenAlex. Fidge 1988 is dropped and the pages of Mattern 1989 and the volume and pages of Robertson and Zaragoza 2009 are left out, since no index reached confirms them; Halevi and Micali 1996 gains its pages. Co-Authored-By: Claude Fable 5.2 --- papers/2026-11-10-temporal-snapshot/paper.tex | 354 ++++++++++-------- papers/2026-11-10-temporal-snapshot/refs.bib | 15 +- 2 files changed, 199 insertions(+), 170 deletions(-) diff --git a/papers/2026-11-10-temporal-snapshot/paper.tex b/papers/2026-11-10-temporal-snapshot/paper.tex index a87ac922..dcdd8195 100644 --- a/papers/2026-11-10-temporal-snapshot/paper.tex +++ b/papers/2026-11-10-temporal-snapshot/paper.tex @@ -35,24 +35,26 @@ \begin{abstract} A query on a knowledge store can ask for the store as of a past moment. In the store studied here -that reading exists for one relation, a citation graph indexed by commit, and every other store is -read as it is now. We design the rest. A store is modelled as a family of append chains, a cut as a +that reading exists for one relation, a citation graph indexed by commit, and for the files of +its repository; every other store is read as it is now. We design the rest. A store is modelled as a family of append chains, a cut as a prefix length for each, and the read at a cut as the prefixes. Ten laws are machine-checked in Lean~4 over Mathlib. A read at a cut is unchanged by growth of the store, and a reader has that property exactly when it is a function of the prefixes. Reads at cuts are ordered and compose with reads between cuts, so a job's checkpoint is a cut. A derived store kept by generation reads what recomputation reads, with at most one generation of a key alive at a cut. A narrower grant's snapshot is the restriction of a wider one's, and positions on a shared chain count what a filter -hides. Nothing erased is visible at any cut when an erasure leaves holes, and a seal keeps a -retired identity out of earlier cuts. Consistent cuts form a sublattice, and every frontier -resolves to one greatest consistent cut. The digest of each prefix certifies a cut and survives an -erasure that keeps commitments. A store that drops old generations is exact from its horizon on, -never wrong under it, and unable to tell what it lost. The last law gives the rule for an -incomplete history: a read is taken at the greatest consistent cut among the positions the stores -still serve, which never lies after the cut asked. Reading the code against the usual picture of -ledgers and derived stores locates the one missing ledger, the past of the map from paths to -content, and a log of 409 bytes a landing supplies it. Measurements on synthetic fixtures give the -cost of its reads and show what an erasure leaves behind today. +hides. Nothing erased is visible at any cut when an erasure leaves holes; a hole must keep its +key, or a read by key returns a superseded version; and a seal keeps a retired identity, with +its versions, out of earlier cuts. Every frontier resolves to one greatest consistent cut. The +digest of each prefix certifies a cut, survives an erasure that keeps commitments, and attests +no erasure. A store that drops old generations is exact from its horizon on, never wrong under +it, and unable to tell what it lost. The last law gives the rule for an incomplete history: a +read is taken at the greatest consistent cut among the positions the stores still serve, which +never lies after the cut asked; a chain that nothing reads is lowered alone, and a chain that +others read takes them down with it. Reading the code against the usual picture of ledgers and +derived stores locates the one missing ledger, the past of the map from paths to content, and a +log of about 400 bytes a landing on a synthetic fixture supplies it. Measurements on synthetic +fixtures give the cost of its reads and show what an erasure leaves behind today. \end{abstract} \section{Introduction} @@ -62,8 +64,8 @@ \section{Introduction} paths to content, version chains, a chat log, attestations, a vector plane, a lexical index, edge stores), and a sentence of a small query algebra reads them. A sentence may carry \texttt{as of ""}. Today that adjective moves one relation. The citation graph, which is -stored as one whole reading per commit, is read at the commit named; every other verb reads the -present, and the answer says so. +stored by commit, is read at the commit named, and a file of the repository is read as that +commit's blob; every other read is of the present, and the answer says so. Finishing the adjective is not a matter of adding a timestamp filter. The stores have no common clock: each has its own append order, and wall time is by rule never an ordering key. Some stores @@ -71,20 +73,22 @@ \section{Introduction} not return through a snapshot. The asker's grant is today's, not the cut's. And a history is never complete: it starts somewhere, and retention may move the start. Each of these changes what ``the store as of a cut'' has to mean, and each can be stated and proved before any code reads a -store at a cut. That is what this article does. The contributions: +store at a cut. The contributions: \begin{enumerate} \item A model (\Cref{sec:model}) of a multi-store as a family of append chains with cuts, reads at and between cuts, derived views, a grant, an erasure and certificates. -\item Ten laws (\Cref{sec:laws}), SNP-1 to SNP-10, machine-checked as 125 theorems, with the - failure modes as theorems too: the reader that ignores the cut, the store rewritten in place, a - filter applied before the cut, an erasure that deletes rows, a digest with collisions, a pruned - store read under its horizon. +\item Ten laws (\Cref{sec:laws}), SNP-1 to SNP-10, machine-checked as 162 theorems, with fifteen + failure modes as theorems too, among them the reader that ignores the cut, the store rewritten + in place, a filter applied before the cut, an erasure that deletes rows, a hole that loses its + key, a digest with collisions, a pruned store read under its horizon, and a record of a cut + placed on a chain that content reads. \item A rule for incomplete histories (\Cref{thm:horizon}): among the positions the stores still - serve there is one greatest consistent cut under the cut asked, and a read taken there holds no - event from after the cut it names. + serve there is one greatest consistent cut under the cut asked, a read taken there holds no + event from after the cut it names, and it differs from the cut asked only on the chains that + could not serve when no other chain reads them. \item A design (\Cref{sec:design}) read off the code: the one ledger that is missing, how each - derived store is a function of a cut, what an erasure must reach, and what an answer says. -\item Measurements on synthetic fixtures (\Cref{sec:eval}). + derived store is a function of a cut, what an erasure must reach, and what an answer says, + with measurements on synthetic fixtures (\Cref{sec:eval}). \end{enumerate} \section{Background and related work} @@ -92,39 +96,32 @@ \section{Background and related work} \paragraph{Consistent cuts.} Lamport's happened-before relation \cite{lamport1978time} orders events without a global clock; a global state is a consistent cut, a set of events closed under that order -\cite{chandy1985snapshots}. Vector timestamps characterize the order -\cite{fidge1988timestamps,mattern1989virtual}, and Mattern observed that the consistent cuts form -a lattice \cite{mattern1989virtual}; the down-sets of any partial order form a distributive +\cite{chandy1985snapshots}. Vector timestamps characterize the order, and the consistent cuts +form a lattice \cite{mattern1989virtual}; the down-sets of any partial order form a distributive lattice \cite{birkhoff1937rings,davey2002lattices}. The store's own clock design already takes a -cut to be a down-set of a derived event order with a per-store frontier. Here there is one -writer, so no marker protocol is needed; what is needed is the greatest consistent cut under a -frontier that a name selects, and its behaviour when some stores cannot serve a position. +cut to be a down-set of a derived event order with a per-store frontier, and its ledger of laws +already has their closure under meet and join. Here there is one writer, so no marker protocol +is needed; what is needed is the greatest consistent cut under a frontier that a name selects, +and its behaviour when some stores cannot serve a position. \paragraph{Temporal and multiversion data.} Temporal databases keep rows valid over a period, and system-versioned tables answer a query as of a system time \cite{snodgrass1999temporal,kulkarni2012sql2011}; multiversion concurrency control keeps versions so that a reader sees a state as of its start \cite{reed1978naming,bernstein1983mvcc}. Our generations are system-versioned rows whose period -is counted in positions of an append chain, never in wall time, and \Cref{thm:forms} is the -statement that such rows read what the log replays. Maintaining a derived view from the changes -to its inputs is the subject of incremental view maintenance \cite{gupta1995views}; the delta -between two cuts is its input here. +is counted in positions of an append chain, never in wall time (\Cref{thm:forms}). Incremental +view maintenance \cite{gupta1995views} takes the changes to a view's inputs; the delta between +two cuts is that input here. \paragraph{Hash chains and commitments.} A hash chain makes an append-only history tamper-evident \cite{merkle1987signature,haber1991timestamp}. A chain over contents cannot survive an erasure of -content, and a chain that keeps a plain hash of erased content leaves a test for that content. A -salted commitment \cite{halevi1996commitment} whose salt is destroyed avoids both, and -\Cref{thm:cert} says the certificates then survive. +content, and a plain hash of erased content is a test for that content. A salted commitment +\cite{halevi1996commitment} whose salt is destroyed avoids both (\Cref{thm:cert}). \paragraph{Noninterference.} A grant restricts what a reader may learn \cite{goguen1982security}. A position on a chain is -itself data: it counts every event before it, hidden or not, which \Cref{thm:grant} turns into a -design rule. - -\paragraph{The proof environment.} -The laws are stated in Lean~4 \cite{moura2021lean4} over Mathlib \cite{mathlib2020}, in a library -whose every declaration is replayed by Lean's kernel and five independent checkers. +itself data: it counts every event before it, hidden or not (\Cref{thm:grant}). \section{The model}\label{sec:model} @@ -156,9 +153,12 @@ \section{The model}\label{sec:model} $\mathrm{snap}_{G,p}(s, c) = \mathrm{restrict}_{G,p}(\at{s}{c})$: the chains in $G$, each read at the cut and filtered by $p$. For an erasure predicate $E$, $\mathrm{redact}_E(s)$ replaces each erased event by a hole, $\mathrm{visible}_E(s, c)$ is $\at{s}{c}$ without the erased events, and -$\mathrm{compact}_E(s)$ deletes them. In a chain of landings $(x, \mathrm{some}\,v)$ and retires -$(x, \mathrm{none})$, the \emph{stricter seal} serves at $c$ the value $x$ held at $c$ unless a -retire of $x$ lies after $c$; the \emph{looser seal} serves it unless $x$ is not live at the head. +$\mathrm{compact}_E(s)$ deletes them. For a keyed chain, $\mathrm{holes}_E(l)$ replaces the value +of each erased write by a hole and keeps its key. In a chain of landings $(x, \mathrm{some}\,v)$ +and retires $(x, \mathrm{none})$, the \emph{stricter seal} serves at $c$ the value $x$ held at +$c$ unless a retire of $x$ lies after $c$, and as its \emph{history} the landings of $x$ inside +$c$ that no retire follows; the \emph{looser seal} serves the value unless $x$ is not live at the +head. \end{definition} \begin{definition}[Consistency, resolution, certificates] @@ -205,8 +205,7 @@ \section{The laws}\label{sec:laws} \end{proof} The composition is what lets a job keep a checkpoint: its state at $b$ is its state at $a$ continued over the delta, so a run and a rebuild agree. For a job that joins two chains, a pair -read at $b$ was read at $a$ or has a member in the delta (\lean{pair_readAt}), the usual delta -rule of view maintenance \cite{gupta1995views}. +read at $b$ was read at $a$ or has a member in the delta (\lean{pair_readAt}). \begin{theorem}[SNP-5: three ways of holding a derived store]\label{thm:forms} For every chain $l$ of keyed writes, cut $c$ and key $x$, @@ -228,49 +227,60 @@ \section{The laws}\label{sec:laws} $\mathrm{snap}_{G,p}(s, c) = \mathrm{restrict}_{G,p}(\mathrm{snap}_{G',p'}(s, c))$. A snapshot depends only on the chains of $G$ and on the cut's positions on them, and it is append invariant. Restricting to whole chains commutes with the cut. Filtering events does not: there are stores -that agree on every admitted event and differ in their snapshots at one cut. +that agree on every admitted event and differ in their snapshots at one cut. The cut read +(\Cref{thm:horizon}) on a set of chains that read from no chain outside it is a function of that +set alone. \end{theorem} \begin{proof}[Sketch] Filters compose and are applied after the prefix (\lean{snapshot_narrow}, \lean{snapshot_congr}, \lean{snapshot_grow}, \lean{restrict_readAt}). For the control, $[\mathrm{hidden}, a]$ and $[a]$ read at position one give nothing and $a$ (\lean{Witness.filter_before_cut}, -\lean{Witness.position_channel}). +\lean{Witness.position_channel}). For the last part, a resolved cut restricted to a closed set +and zero elsewhere is consistent and served (\lean{ResolvesIn.eq_on_of_closed}; the control is +\lean{Witness.resolution_reads_unnamed}). \end{proof} So what must be hidden in number is hidden by chain: where clearances separate rows, a chain per -class. +class. The law is about the rows a grant is shown. It passes to an answer that filters those +rows, and not to a score, whose collection statistics are the reader's own. \begin{theorem}[SNP-7: erasure]\label{thm:erase} No erased event is in $\mathrm{visible}_E(s, c)$; a larger erasure shows a sublist; reading the store with holes commutes with the cut and keeps the head; and if $\mathrm{redact}_E(s) = \mathrm{redact}_E(s')$ then $D(\mathrm{visible}_E(s, c)) = D(\mathrm{visible}_E(s', c))$ for every $D$ and $c$. After $\mathrm{compact}_E$ a read at a cut -can hold an event from after it. Under the stricter seal, once a chain retires a key no cut -before the retire serves it, and for any growth $t$ a value served by $l \mathbin{+\!\!+} t$ at a -cut inside $l$ was served by $l$. The looser seal serves everything the stricter one serves, and -a landing after a retire brings the key's past back under it. +can hold an event from after it. On $\mathrm{holes}_E(l)$ the state of a key at a cut is its +last write at or under the cut, a hole when that write is erased, and the generational read and +the seek by key agree with it; if a hole loses its key, a seek returns a superseded version, or +one from after the cut. Under the stricter seal, once a chain retires a key no cut before the +retire serves it, and for any growth $t$ a value served by $l \mathbin{+\!\!+} t$ at a cut inside +$l$ was served by $l$; the history served ends at the value served, and at every cut after a +retire it holds only landings after that retire. The looser seal serves everything the stricter +one serves, and a landing after a retire brings the key's past back under it. \end{theorem} \begin{proof}[Sketch] Filtering and mapping commute with \texttt{take} (\lean{not_erased_of_mem_visible}, -\lean{visible_sublist}, \lean{redact_readAt}, \lean{head_redact}, \lean{erased_invisible}); the -seal is a predicate on the suffix past the cut, which only grows -(\lean{servedAt_append_of_retire}, \lean{servedAt_of_append}, \lean{servedNow_of_servedAt}). The -controls are \lean{Witness.compact_moves} and \lean{Witness.servedNow_restores}. +\lean{redact_readAt}, \lean{erased_invisible}, \lean{stateAt_holes}). The seal is a predicate +on the suffix past the cut, which only grows (\lean{servedAt_of_append}, +\lean{historyAt_of_retire_inside}, \lean{servedNow_of_servedAt}). The controls are +\lean{Witness.compact_moves}, \lean{Witness.keyless_hole} and \lean{Witness.servedNow_restores}. \end{proof} -\begin{theorem}[SNP-8: consistent cuts]\label{thm:lattice} -Consistent cuts are closed under pointwise meet and join and contain the empty cut, so they are a -sublattice of the cuts. A cut is consistent exactly when the events under its frontier are a -down-set of the order generated by the chains and by $R$. Every frontier is resolved by exactly -one cut, monotonically in the frontier. If growth only adds references that start at or past the -old head, a consistent cut inside the old head stays consistent. +\begin{theorem}[SNP-8: resolution]\label{thm:lattice} +A cut is consistent exactly when the events under its frontier are a down-set of the order +generated by the chains and by $R$. Every frontier is resolved by exactly one cut, monotonically +in the frontier. If growth only adds references that start at or past the old head, a consistent +cut inside the old head stays consistent. If every source of an event lies at or under a +recorded one on its chain, a cut consistent for the recorded references is consistent for $R$. \end{theorem} \begin{proof}[Sketch] -Closure is pointwise (\lean{Consistent.inf}, \lean{Consistent.sup}, \lean{consistentCuts}); the -down-set form is the clock's cut criterion, no generator edge crossing -(\lean{consistent_iff_isCut}). For resolution take on each chain the supremum of the positions -reached by consistent cuts under $f$: it is attained, and a source of an event under it is under -the witness's position on the source's chain (\lean{exists_resolves}, \lean{Resolves.unique}, -\lean{Resolves.mono}, \lean{Consistent.of_grown}). +The down-set form is the clock's cut criterion, no generator edge crossing +(\lean{consistent_iff_isCut}). Closure under pointwise meet and join then is the clock's law for +frontiers, already in the store's ledger, and is derived from it, not claimed here +(\lean{Consistent.inf}, \lean{Consistent.sup}). For resolution take on each chain the supremum +of the positions reached by consistent cuts under $f$: it is attained, and a source of an event +under it is under the witness's position on the source's chain (\lean{exists_resolves}, +\lean{Resolves.unique}, \lean{Resolves.mono}, \lean{Consistent.of_grown}, +\lean{Consistent.of_bound}). \end{proof} \begin{theorem}[SNP-9: certificates]\label{thm:cert} @@ -278,34 +288,51 @@ \section{The laws}\label{sec:laws} two stores that verify one certificate have the same read at its cut, hence the same derived views. The digest at $b$ is the digest at $a$ continued over $\btw{s}{a}{b}$, and the digests at $c \sqcap d$ and $c \sqcup d$ are, chain by chain, those of $c$ or of $d$. If the chain digests -commitments kept beside the events, erasing contents changes no certificate, and the contents -then read as the store with holes. +commitments kept beside the events, a store verifies a certificate after an erasure of contents +exactly when it did before, and the contents then read as the store with holes; if moreover the +commitment is injective, two such stores that verify one certificate were made from the same +events at its cut. \end{theorem} \begin{proof}[Sketch] Append invariance of the prefix; induction from the end for injectivity of the fold (\lean{verifies_certify_of_extends}, \lean{Verifies.readAt_eq}, \lean{Verifies.view_eq}, -\lean{certify_digest_readBetween}, \lean{certify_inf}, \lean{certify_sup}, \lean{verifies_purge}, -\lean{contents_purge_committed}). Under addition two chains of one length collide +\lean{certify_digest_readBetween}, \lean{certify_inf}, \lean{certify_sup}, +\lean{verifies_purge_iff}, \lean{contents_purge_committed}); the last part is +\lean{Verifies.readAt_eq_of_committed}. Under addition two chains of one length collide (\lean{Witness.digest_collides}). \end{proof} +A certificate thus pins what it digests and nothing else. It attests no erasure, so a copy taken +before an erasure verifies it and still holds what was erased; no seal, since a retire written +after the cut changes what is served at it (\lean{Witness.seal_not_certified}); and no grant. +Its chains are named, and a renamed chain no longer verifies +(\lean{Witness.rename_breaks_certificate}). \begin{theorem}[SNP-10: the horizon]\label{thm:horizon} For $h \le c$, $\mathrm{read}(\mathrm{prune}_h(\mathrm{gens}(l)), c, x) = \mathrm{state}_c(l)(x)$. For any $c$, a value the pruned store returns at $c$ is $\mathrm{state}_c(l)(x)$; but there are $l$ and $c < h$ at which it returns nothing where a value stood. -$\mathrm{prune}_h \circ \mathrm{prune}_{h'} = \mathrm{prune}_{\max(h, h')}$. If every $S_k$ -contains $0$, every frontier $f$ is resolved among the served positions by exactly one cut; that -cut rises with the $S_k$ and with $f$, lies under the resolution of $f$, and equals it when every -position is served. +Two chains can have one pruned store and differ, at a cut under $h$, in whether a key had been +written. $\mathrm{prune}_h \circ \mathrm{prune}_{h'} = \mathrm{prune}_{\max(h, h')}$. If every +$S_k$ contains $0$, every frontier $f$ is resolved among the served positions by exactly one cut; +that cut lies under the resolution of $f$, equals it when every position is served, and rises +with $f$ and with served sets that grow. If $f$ is consistent, the chains in a set $U$ are read +by no chain but themselves, and every chain outside $U$ serves its position, then the cut is $f$ +with each chain of $U$ at the greatest position it serves at or under $f$. Without the +hypothesis on $U$ that fails: one chain read low can take every other chain to its empty prefix. \end{theorem} \begin{proof}[Sketch] A row alive at $c \ge h$ has no closing stamp at or under $h$, so pruning removes no row a read at $c$ selects; under $h$ a selected row is still the unique row alive in the full store -(\lean{genRead_prune_gens}, \lean{stateAt_of_genRead_prune}, \lean{prune_prune}, -\lean{Witness.prune_forgets}). Resolution among served positions is the argument of -\Cref{thm:lattice} with the supremum taken over served consistent cuts: the supremum on a chain -is attained by one of them, so it is served (\lean{exists_resolvesIn}, \lean{ResolvesIn.unique}, -\lean{ResolvesIn.mono}, \lean{ResolvesIn.le_resolves}, \lean{resolvesIn_univ}). +(\lean{genRead_prune_gens}, \lean{stateAt_of_genRead_prune}, \lean{prune_prune}); the two +controls are \lean{Witness.prune_forgets} and \lean{Witness.prune_indistinct}. Resolution among +served +positions is the argument of \Cref{thm:lattice} with the supremum taken over served consistent +cuts: the supremum on a chain is attained by one of them, so it is served +(\lean{exists_resolvesIn}, \lean{ResolvesIn.unique}, \lean{ResolvesIn.mono}, +\lean{ResolvesIn.le_resolves}, \lean{resolvesIn_univ}). Lowering an unread chain breaks no +reference, and no served consistent cut under $f$ is higher (\lean{resolvesIn_of_unread}). The +controls are \lean{Witness.record_drags} and, for sets that shrink, +\lean{Witness.served_set_shrinks}. \end{proof} \section{The design}\label{sec:design} @@ -314,30 +341,34 @@ \section{The design}\label{sec:design} The usual picture has ledgers that only append and derived stores that are rewritten and can be recomputed. Read against the code it fails at one place that matters. The catalog, the map from a path to the content it holds and the idempotence key of every landing, is rewritten in place: an -upsert, a tombstone flag, a delete. Version chains exist for one of four places; the attestation -ledger names a digest and no path, once per action and digest; so for most items the sequence of -contents a path held is recorded nowhere. Meanwhile the vector plane and the lexical index, which +upsert, a tombstone flag, a delete. Version chains exist for one of four places; elsewhere the +attestation ledger names a digest and no path, once per action and digest; so for most items the +sequence of contents a path held is recorded nowhere. Meanwhile the vector plane and the lexical index, which the picture calls rewritten, keep every version's rows and move a flag. They are generations without a clock. A clock on their rows would be wrong, since a path that returns to earlier bytes makes the same rows current again, so a version's rows are valid on a set of intervals. The fix -is one ledger: a \emph{landing log} in the catalog's own file, one hash chain per provenance -class, a row per catalog write (class, position, kind, path, identity, digest, a salt, a -commitment, the chain hash, the position of the path's next event), written by the catalog's own -methods in the transaction of the row they write. The catalog is then the fold of the log -(\Cref{thm:forms}), and every version-keyed store has a past: the log says which version a cut -holds. +is one ledger: a \emph{landing log} in the catalog's own file, hash chains that each hold one +provenance class, a row per catalog write (chain, position, kind, a keyed hash of the path, path, +identity, digest, a salt, a commitment, the chain hash, the position of the path's next event), +written by the catalog's own methods in the transaction of the row they write. A chain has an id +and its class is a label, so relabelling a class moves no row and breaks no certificate. The +catalog is then the fold of the log (\Cref{thm:forms}), and every version-keyed store has a +past: the log says which version a cut holds. \paragraph{Cuts, names, certificates.} A cut is one position per chain, about a dozen integers: the landing chains, the chat log, the attestations, the repository's commit, the generations of model output. It is not a position per document, which is millions of pairs on a large instance and adds nothing, since a frontier cut needs only its cross-store references checked. A cut is recorded, with the digest of every -prefix, at the moments the stores are quiescent, and attested; the records form a chain. The -adjective takes \texttt{head}, a record's id, a commit (the record made when the commit was -read), or a date, which selects the last record whose wall bookmark is not later. Wall time is a -lookup key there and orders nothing. Each row that reads another chain records that chain's head -at its writing, which bounds its sources because there is one writer; the resolver compares -those bounds. +hashed prefix, when the writer's queue and its handoff are empty, and attested. The records form +a chain of their own that no event reads: every landing reads the attestation ledger, so a +record placed there would, by \Cref{thm:horizon}, take every landing chain down with any chain +read below a position it certified. The adjective takes \texttt{head}, a record's id, a commit +(the first record that holds it, with the repository lowered to the commit and resolved), or a +date, which selects the last record whose wall bookmark is not later. Wall time is a lookup key +there and orders nothing. Each row that reads another chain records that chain's head at its +writing, which bounds its sources because there is one writer (\Cref{thm:lattice}); the resolver +compares those bounds. \begin{algorithm}[t] \caption{The cut a read under \texttt{as of} is taken at. $S_k$: the positions chain $k$ serves. @@ -368,9 +399,12 @@ \section{The design}\label{sec:design} \cite{robertson2009bm25} at a cut are those of the units alive at the cut: a cut, like a clearance, is a mask whose statistics must be its own. The causal edges from session transcripts to commits and files are recomputed from the transcript as retained at the cut, which is cheap -and also removes a dependence on job order that the stored rows have today. Model output cannot -be recomputed and is kept by generation, the replaced row archived with its interval; a kept row -is served only while every content it is about is alive and not erased. One storage form is +and also removes a dependence on job order that the stored rows have today. The relations a note +declares in its own text are recomputed too. A commit's citation edges are stamped with the +projection that wrote them, since a later extractor adds edges under an old commit and the +reading would otherwise grow under a cut that did not move. Model output cannot be recomputed +and is kept by generation, the replaced row archived with its interval; a kept row is served +only while every content it was derived from is alive at the cut and not erased. One storage form is ruled out as the carrier of a snapshot: the vector table's own versioned manifests. An erased text stays readable through an earlier manifest until a compaction that removes every earlier manifest (\Cref{sec:eval}), so a manifest version cannot be both the position of a snapshot and @@ -378,19 +412,21 @@ \section{The design}\label{sec:design} \paragraph{Erasure and scope.} Both are parameters of a read, not functions of the cut. A purge empties the log's row and keeps -its position, its commitment and its hash (\Cref{thm:erase,thm:cert}); the salt goes with the -content, so the commitment cannot be tested against a guess. A retire seals the identity's -earlier cuts under the stricter seal, lifted only by an owner's act. The looser seal would let a -new note written at a deleted note's path, which by default inherits its identity, bring the -deleted versions back. The grant is the asker's now, an event filter is applied after the read, +its position, its commitment, its hash and the keyed hash of its path, so that a read by path +finds the hole (\Cref{thm:erase,thm:cert}); the salt goes with the content, so the commitment +cannot be tested against a guess. A retire seals the identity's earlier cuts under the stricter +seal, lifted only by an owner's act. A new note written at a deleted note's path inherits its +identity by default; the looser seal would bring the deleted versions back at earlier cuts, and +without the seal on the history they would stand under the new note at every later one. The grant is the asker's now, an event filter is applied after the read, and an answer names the cut only on the chains the grant names (\Cref{thm:grant}). \paragraph{What an answer says.} A store may be unable to serve the cut asked: it keeps no past yet, or the cut is under its horizon. The read is then taken at the cut \Cref{alg:resolve} returns, which by \Cref{thm:horizon} exists, is unique, never lies after the cut asked and rises as stores gain a -past. The answer is exact for that cut and names it, chain by chain, with the reason wherever it -differs from the cut asked. Reading such a store at the present instead, which is what the +past. Every chain that can fail to serve a recorded cut is read by no recorded bound, so only +those chains are lowered. The answer is exact for that cut and names it, chain by chain, with +the reason wherever it differs from the cut asked. Reading such a store at the present instead, which is what the executor does today, is the reader \Cref{thm:append} refutes. At the head the read is the present (\Cref{thm:compose}), so \texttt{as of "head"} is the sentence without the adjective. @@ -402,39 +438,40 @@ \section{The design}\label{sec:design} the log's rows, which only the store's owner declares. That pass appends a horizon row first, so a crash leaves rows that are unserved, never a position that is served and incomplete, and it keeps the digest at the horizon as the chain's seed. A window counted per identity (the last $n$ -versions of each) would leave no horizon, and \Cref{thm:horizon} says such a store cannot tell -what it lost. +versions of each) would leave no horizon to record. \section{Evaluation}\label{sec:eval} \paragraph{What is proved.} \Cref{thm:append,thm:compose,thm:forms,thm:grant,thm:erase,thm:lattice,thm:cert,thm:horizon} are machine-checked in \lean{formal/Palace/Snapshot.lean} over \lean{formal/Palace/Snapshot/Defs.lean} -on Lean v4.36.0-rc2 and the Mathlib it pins: 125 theorems, eight of them the controls, no -\lean{sorry}, and the axioms of all 5{,}122 library declarations audited (\lean{propext}, -\lean{Classical.choice}, \lean{Quot.sound} only). The library's export, 56{,}098 declarations -from \lean{Init} up, is replayed by Lean's kernel and by \lean{leanchecker-paranoid}, -\lean{lean4lean}, \lean{nanoda}, \lean{con-leche} and \lean{con-ron}. These are design theorems: -no code relies on them yet, so they are not among the 328 statements the library restates -separately and judges against its ledger of laws. +on Lean~4 \cite{moura2021lean4}, v4.36.0-rc2, and the Mathlib \cite{mathlib2020} it pins: 162 +theorems, fifteen of them the controls, no +\lean{sorry}, and the axioms of all 5{,}176 library declarations audited (\lean{propext}, +\lean{Classical.choice}, \lean{Quot.sound} only). The library's export, 56{,}159 declarations +from \lean{Init} up, is replayed by Lean's kernel and five independent checkers. These are +design theorems: no code relies on them yet, so they are not among the 328 statements the +library restates separately and judges against its ledger of laws. \paragraph{The attacks.} The definitions compute, so they are attacked as they are with property-based testing -(\lean{formal/PalaceTest/Snapshot.lean}, seeds 430 to 486, 500 draws each): stores of two chains +(\lean{formal/PalaceTest/Snapshot.lean}, seeds 430 to 513, 500 draws each): stores of two chains over three events, keyed chains over three keys, chains of landings and retires, grants and erasures from bit masks, reads-from relations as edge lists, a base-four digest, served positions -from ten bits. Thirty-nine attacks survive every draw. \Cref{alg:resolve}'s descent, which the -library does not define, is checked against the definition by enumerating every cut under the -frontier, and the served resolution by taking the pointwise maximum of every consistent served -cut. Eighteen controls are refuted within 53 draws: among them a read at a cut past the head, -generations without the closing stamp, an event filter before the cut, an erasure that deletes -rows, the state served without the seal, an additive digest, the pruned store read under its -horizon, and a frontier lowered to the served positions without the descent. +from ten bits. Forty-five attacks survive every draw. \Cref{alg:resolve}, which the library does +not define, is run as written, the floor and the descent alternated, and agrees on every draw +with the pointwise maximum of every consistent served cut under the frontier. Thirty-nine +controls are refuted within 53 draws: among them a read at a cut past the head, generations +without the closing stamp, an event filter before the cut, an erasure that deletes rows, a seek +over rows that lost their key, the state served without the seal, an additive digest, the pruned +store read under its horizon, a chain that others read lowered alone, and the floor and the +descent each run once, in either order. \paragraph{What is measured.} All on synthetic fixtures built by each probe, on one machine (Apple M2 Pro, SQLite 3.54.1, -LanceDB 0.33.0), with other work running; no instance was read. \Cref{tab:measure} gives the -figures. +LanceDB 0.33.0), with other work running; no instance was read. The probes are not in the +repository, which holds no code for this design yet; the design note describes each fixture, and +each build stage commits its harness. \Cref{tab:measure} gives the figures. \begin{table}[t] \centering @@ -443,13 +480,14 @@ \section{Evaluation}\label{sec:eval} \toprule probe & result \\ \midrule -landing log, $10^6$ events over $10^5$ paths, hashed, one transaction & - 409 bytes a row with its two indexes; 50{,}000 to 54{,}000 rows a second \\ -one path at the middle cut & 3 to 4 $\mu$s through the path index; 6 to 7 ms when the planner - takes the primary key \\ -the delta of 1{,}000 positions & 0.69 ms \\ -every head at a cut & 149 to 163 ms at the middle; 246 to 285 ms at the head \\ -the chain's hash from the first row; the stored hash at a position & 0.8 s; 3 $\mu$s \\ +landing log, $10^6$ events over $10^5$ paths, keyed and hashed, one transaction & + 396 to 434 bytes a row with its three indexes; 35{,}000 to 42{,}000 rows a second \\ +one path at the middle cut; its seven versions & 3 $\mu$s and 9 $\mu$s through the key index; + 49 to 57 ms when the planner takes the primary key; after a version's row is emptied the + seek returns the hole \\ +the delta of 1{,}000 positions & 0.64 to 0.69 ms \\ +every head at a cut & 147 to 166 ms at the middle; 240 to 275 ms at the head \\ +the chain's hash from the first row; the stored hash at a position & 0.7 to 0.8 s; 3 $\mu$s \\ lexical index, 500 items, 4 chunks, 3 versions & 4{,}179 bytes a unit at 122 postings; 0.67 of the units superseded \\ a purge of both versions of a note, on the test suite's throwaway store & @@ -463,35 +501,36 @@ \section{Evaluation}\label{sec:eval} \caption{Measurements on synthetic fixtures. Ranges are across two runs.}\label{tab:measure} \end{table} -The log's cost is small against what the stores already keep: no store drops a superseded -version today, so most bytes of a past are paid whether or not anything reads them. The purge -row is the finding that orders the build: the stores that would be read at a cut are the ones an -erasure does not reach, so the erasure's reach lands before the first stage that reads a -superseded version. +The log's cost is small against what the stores already keep: the vector plane and the lexical +index drop no superseded version today, so most bytes of a past are paid already. Reading every +head from the log alone passes a tenth of a second at about a quarter of a million events in a +chain, past which heads are kept at recorded cuts. The purge row orders the build: the stores +that would be read at a cut are the ones an erasure does not reach, so the erasure's reach lands +before the first stage that reads a superseded version. \section{Limitations} The model has one writer: a chain is a list, and nothing is said of two writers. Collision -freedom is a hypothesis of \Cref{thm:cert}, not a theorem about a hash function. The descent of -\Cref{alg:resolve} is attacked, not proved; the library proves the cut it must return exists and -is unique. A repository history with merges is a partial order and not a chain; the clock's -down-set laws cover it, the chain model does not. The owner's unseal is not in the model of the -seal. Every measurement is on a synthetic fixture: the cost of the lexical statistics from a -mask at a corpus's size, of a vector search joined to the heads at a cut, and of a retention -pass are not measured. The attestation ledger still names an erased digest, and what to do -about it is left to the store's owner. +freedom and a binding commitment are hypotheses of \Cref{thm:cert}, not theorems about a hash +function. \Cref{alg:resolve} is attacked, not proved; the library proves the cut it must return +exists and is unique. The laws of the grant and the erasure are laws of a reader that reads +through them; that every reader in the code does is an obligation of the build, and no single +reader in the model applies the resolution, the grant, the erasure and the seal together. A +repository history with merges is a partial order, which the clock's down-set laws cover and +the chain model does not. Every measurement is on a synthetic fixture and cannot yet be repeated from the +repository: the cost of the lexical statistics from a mask at a corpus's size, of a vector +search joined to the heads at a cut, and of a retention pass are not measured. The attestation +ledger still names an erased digest; the note proposes a salted commitment in its place and +leaves the choice to the store's owner. \section{Future work} -The build is eight stages, each shipped with its tests and its rollback: the landing log, with -its reads and no reader; recorded cuts, names and the resolver; the erasure's reach and the seal; -the notes, vectors and lexical index at a cut, with the answer naming the cut read; the causal -edges recomputed at a cut; model output by generation; retention; and the delta, as a region of -what changed between two cuts and as the input of integrator jobs whose checkpoint is a cut. -Each stage transcribes its laws and property-tests the transcription against the Lean -statements, at which point the laws enter the ledger. Two further readings wait on these: the -velocity of an identity over a window of cuts, and a field of use folded over its own log, which -\Cref{thm:compose} makes exact as of a cut. +The build is eight stages, each shipped with its tests and its rollback: the landing log; +recorded cuts, names and the resolver; the erasure's reach and the seal; the notes, vectors and +lexical index at a cut; the causal edges at a cut; model output by generation; retention; and +the delta between two cuts, as a region and as the input of jobs whose checkpoint is a cut. Each +stage transcribes its laws and property-tests the transcription against the Lean statements, at +which point the laws enter the ledger. \section{Conclusion} @@ -500,8 +539,7 @@ \section{Conclusion} theorems: it does not change as the store grows, it composes with the delta, every derived store that can be read at a cut is a function of the prefixes, and an incomplete history has one best cut under any cut asked. The same statements located what the code lacked, a ledger of the -catalog's past, and what it must not do, which is to answer a question about the past from the -present. +catalog's past, and what it must not do: answer a question about the past from the present. \bibliographystyle{plainnat} \bibliography{refs} diff --git a/papers/2026-11-10-temporal-snapshot/refs.bib b/papers/2026-11-10-temporal-snapshot/refs.bib index e5642659..9b37ace8 100644 --- a/papers/2026-11-10-temporal-snapshot/refs.bib +++ b/papers/2026-11-10-temporal-snapshot/refs.bib @@ -23,17 +23,9 @@ @incollection{mattern1989virtual title = {Virtual Time and Global States of Distributed Systems}, booktitle = {Parallel and Distributed Algorithms}, publisher = {North-Holland}, - pages = {215--226}, year = {1989} } -@inproceedings{fidge1988timestamps, - author = {Fidge, Colin J.}, - title = {Timestamps in Message-Passing Systems That Preserve the Partial Ordering}, - booktitle = {Proceedings of the 11th Australian Computer Science Conference}, - year = {1988} -} - @article{birkhoff1937rings, author = {Birkhoff, Garrett}, title = {Rings of Sets}, @@ -113,6 +105,7 @@ @inproceedings{halevi1996commitment booktitle = {Advances in Cryptology -- CRYPTO '96}, series = {Lecture Notes in Computer Science}, volume = {1109}, + pages = {201--215}, publisher = {Springer}, year = {1996} } @@ -139,10 +132,8 @@ @article{robertson2009bm25 author = {Robertson, Stephen and Zaragoza, Hugo}, title = {The Probabilistic Relevance Framework: {BM25} and Beyond}, journal = {Foundations and Trends in Information Retrieval}, - volume = {3}, - number = {4}, - pages = {333--389}, - year = {2009} + year = {2009}, + doi = {10.1561/1500000019} } @inproceedings{moura2021lean4, From bd2745fb6418b1e20bc633a5d99ad2aeb5dd7a75 Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 07:10:52 -0500 Subject: [PATCH 23/37] docs(readme): the Lean counts from this tree's check.sh run The Snapshot library grew by 37 theorems, 6 attacks and 21 controls, so the table's counts moved: 1,507 theorems, 223 attacks and 200 controls, 25,129 lines of models and proofs, 5,623 of attacks, and 56,159 declarations replayed. The tests badge is not touched. Co-Authored-By: Claude Fable 5.2 --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 47ee83c8..71fad18f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Lean statements](https://img.shields.io/badge/Lean-328_statements_judged-blue)](formal/README.md) [![sorry](https://img.shields.io/badge/sorry-0-brightgreen)](formal/sorry-budget) [![kernels](https://img.shields.io/badge/kernel_replay-6_checkers-6f42c1)](formal/check.sh) -[![attacks](https://img.shields.io/badge/attacks-217_with_controls-blue)](formal/PalaceTest) +[![attacks](https://img.shields.io/badge/attacks-223_with_controls-blue)](formal/PalaceTest) [![tests](https://img.shields.io/badge/tests-3633-brightgreen)](docs/runbook.md) [![coverage](https://img.shields.io/badge/coverage-77%25-green)](pyproject.toml) [![mypy](https://img.shields.io/badge/mypy-0_errors_in_core-brightgreen)](pyproject.toml) @@ -121,12 +121,12 @@ A law has one row in [`docs/LAWS.md`](docs/LAWS.md): its statement, the structur | | | |---|---| | toolchain | Lean `v4.36.0-rc2`, Mathlib; Plausible for the attacks | -| the library | 38 proof modules, 37 models, 26 statement files; 24,593 lines of models and proofs, 3,460 of statements, 5,429 of attacks | -| theorems | 1,470 proved in `formal/Palace`; 328 statements in `formal/Spec` judged identical by the comparator | +| the library | 38 proof modules, 37 models, 26 statement files; 25,129 lines of models and proofs, 3,460 of statements, 5,623 of attacks | +| theorems | 1,507 proved in `formal/Palace`; 328 statements in `formal/Spec` judged identical by the comparator | | the ledger | 100 rows in 15 families, 334 cited declarations, 87 law markers checked against the rows | -| attacks | 217 Plausible attacks and 179 negative controls over 33 modules, fixed seeds | +| attacks | 223 Plausible attacks and 200 negative controls over 33 modules, fixed seeds | | axioms | `propext`, `Classical.choice`, `Quot.sound`; `sorry` 0 | -| the replay | 56,098 declarations accepted by all six checkers on the run of `formal/check.sh` this commit was built with | +| the replay | 56,159 declarations accepted by all six checkers on the run of `formal/check.sh` this commit was built with | | families | memberships · Laplacian, balance and spectral · cut and conductance · curvature · the global event clock · the shared prose plane · capability scopes · the abstraction ultrametric σ* · bridges · the retrieval curve · the query sentence algebra · the ingress · stored vectors · the growth readout · the utility field | ## The mathematics From 25cdf595abdeaa6d2f50977c66e300d2ed850561 Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 07:11:48 -0500 Subject: [PATCH 24/37] docs(design): three wordings in dn-temporal-snapshot held to their proof The control for a record on the attestation ledger shows one case, so the note says it can take a landing chain to its empty prefix, not that it does. The per-identity retention claim is marked as the step the note infers from the control for one horizon. The decisions' preface says which of them have no cost in bytes or time to give. Co-Authored-By: Claude Fable 5.2 --- docs/design-notes/dn-temporal-snapshot.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/design-notes/dn-temporal-snapshot.md b/docs/design-notes/dn-temporal-snapshot.md index 0cbd253c..6d425ceb 100644 --- a/docs/design-notes/dn-temporal-snapshot.md +++ b/docs/design-notes/dn-temporal-snapshot.md @@ -517,7 +517,7 @@ That last point is forced. A record reads from the prefix of every chain it cert landing reads from the attestation ledger. If records sat on that ledger, a chain that could serve only a position below one a record certified would exclude the record, the ledger's prefix would stop before it, and every landing attested later would go with it: one chain read -low would take every landing chain to its empty prefix (`Witness.record_drags`). On a chain of +low can take a landing chain to its empty prefix (`Witness.record_drags`). On a chain of their own, which no event reads, the records constrain nothing (§3.5). `[THEOREM: SNP-10]` Since each record is the head of every chain at some moment and chains only grow, the recorded @@ -527,7 +527,7 @@ attestation at the 1,060 bytes a row of the attestation ledger takes in the repo records (`docs/experiments/corpus-measurements-2026-11-07.md:107`). A record at every trough that moved is at most one a job. At the job rate those records show, 720 an hour (`corpus-measurements-2026-11-07.md:94-95`), a record a job would be 47 megabytes a day; but -those were sync jobs that mostly land nothing, and a job that moves no chain asks for no record. +those were sync jobs of 0.07 s each, and a job that moves no chain asks for no record. An instance with thirty troughs a day that moved writes 81 kilobytes a day. The cadence is parked (SN-a). @@ -1392,8 +1392,10 @@ the landing chains down with it. A window is counted in events because wall time orders nothing (Law C4): the last ten thousand landings of a class, not the last ninety days. It is one position a chain, not a number of versions an identity. Keeping the last `n` versions of each identity would leave no horizon: -which cuts are exact would differ from one identity to the next, and the control of §8 says such -a store cannot tell what it lost. `[INFERENCE, falsifier SNF-9]` +which cuts are exact would differ from one identity to the next, with no position to record +them by. The control of §8 is proved for a store pruned at one horizon; that a store pruned per +identity is no better at telling what it lost is the step this note infers. `[INFERENCE, +falsifier SNF-9]` The default instance declares neither window and keeps everything; by the arithmetic above its log is megabytes a year and its superseded derived rows about a gigabyte a year at a hundred @@ -1760,7 +1762,8 @@ where they are. `[THEOREM: SNP-1, SNP-3; DERIVED for the job]` ## 13. Decisions for the owner Each with the recommendation and what the alternative costs. Where a cost has a figure it is -given; where it has none, that is said. +given. D3, D4, D6, D11 and D12 are choices of behaviour: they have no cost in bytes or time to +give, and what each alternative costs is the answers it changes, which the entry states. 1. **D1, where the catalog's past is kept.** Recommended: the landing log in the catalog's file, written by the catalog (§3.2), at about 0.4 kilobytes a landing on the fixture. The @@ -1850,7 +1853,7 @@ given; where it has none, that is said. its attestation in its own row (§3.3). The alternative, a row of the attestation ledger, is one table fewer and signs a record where every other attestation is signed; but every landing reads that ledger, so a chain read below a position a record certified, as a - landing chain behind a history window is, takes every landing chain to its empty prefix + landing chain behind a history window is, can take every landing chain to its empty prefix (`Witness.record_drags`). 14. **D14, what a purged row of the log keeps.** Recommended: the keyed hash of its path, with its position (§6.1), 47 bytes a row of index on the fixture. The alternatives: keep the From 4d21389e3e50e2f66239a678243564a7082ca3bf Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 07:56:25 -0500 Subject: [PATCH 25/37] feat(formal): the filtered read, the chain that follows (SNP-8, SNP-10) The resolver was said to lower each chain that cannot serve alone, on a list of references that left out the rows which read landings and record no bound: a pass attestation, a dream claim, a claim op. Resolving them would take the attestation ledger down with a landing chain, and every landing chain after it (Witness.pass_drags). So they are kept by a filter of the read: a row is withheld when a source of it lies outside the cut or is withheld. The filtered read is closed under every reference, the greatest such set inside the cut, the prefix at a consistent cut, never short of a row whose references are all resolved, monotone and append invariant. A chain of records reads every chain it certifies, so it is not read as recorded when one of them is lowered. resolvesIn_of_followed proves the two-level case: a chain that reads the lowered chains, and that nothing else reads, follows them and takes nothing with it (Witness.record_follows). Co-Authored-By: Claude Fable 5.2 --- formal/Palace/Snapshot.lean | 281 ++++++++++++++++++++++++++++++- formal/Palace/Snapshot/Defs.lean | 22 ++- 2 files changed, 300 insertions(+), 3 deletions(-) diff --git a/formal/Palace/Snapshot.lean b/formal/Palace/Snapshot.lean index e5ddd6a0..85ef1b2f 100644 --- a/formal/Palace/Snapshot.lean +++ b/formal/Palace/Snapshot.lean @@ -72,7 +72,16 @@ a cut a prefix length for each. Cited from the note, not from the ledger. resolution: every frontier resolves to exactly one greatest consistent cut under it, monotonically (`exists_resolves`, `Resolves.unique`, `Resolves.mono`); a consistent cut stays consistent as the store grows (`Consistent.of_grown`); and a cut consistent for a recorded - bound on the references is consistent for the true ones (`Consistent.of_bound`). + bound on the references is consistent for the true ones (`Consistent.of_bound`). A reference + the resolver does not follow is kept by a filter of the read: a row is withheld when a source + of it lies outside the cut or is withheld. The filtered read is closed under every reference, + it is the greatest such set of rows inside the cut, it is the prefix at a consistent cut, it + never withholds a row whose references are all resolved, and it is monotone and append + invariant (`Kept.source`, `kept_of_closed`, `kept_iff_of_consistent`, `kept_of_resolved`, + `Kept.mono`, `kept_grown_iff`). The controls: a pass attestation whose reference to a landing + is resolved, which takes another landing chain down, and the same reference filtered, where + the prefix is not closed and the filtered read is (`Witness.pass_drags`, + `Witness.pass_withheld`). * SNP-9, certified cuts: the certificate of a cut verifies on every extension of the store, two stores that verify one certificate under a collision-free digest have the same read at its cut and so the same derived views, a certificate extends over the events since an earlier one, the @@ -95,7 +104,9 @@ a cut a prefix length for each. Cited from the note, not from the ledger. (`exists_resolvesIn`, `ResolvesIn.unique`, `ResolvesIn.mono`, `ResolvesIn.le_resolves`, `resolvesIn_univ`). A chain that no other chain reads is lowered alone, every other chain read as asked (`Consistent.update_of_unread`, `resolvesIn_update_of_unread`, - `resolvesIn_of_unread`), and retention + `resolvesIn_of_unread`); a chain that reads a lowered chain, and that nothing else reads, + follows it and takes nothing with it, which is the case of a chain of records + (`resolvesIn_of_followed`, `Witness.record_follows`); and retention commutes with growth (`prune_landGen`). The controls: the pruned store read under its horizon, which cannot tell a lost key from one never written (`Witness.prune_forgets`, `Witness.prune_indistinct`); a record on a chain that content reads, which drags every reader @@ -1296,6 +1307,63 @@ theorem resolvesIn_of_unread {S : K → Set ℕ} {f p : Cut K} (U : K → Prop) · simp only [hk, ↓reduceIte] exact hdf k +/-- SNP-10 The lowering with followers. `U` are chains that cannot serve the position asked and +`V` chains that read them; nothing else reads a chain of `U`, and nothing but itself reads a +chain of `V`. From a consistent cut asked, the cut read has each chain of `U` at the greatest +position it serves at or under the one asked, each chain of `V` at the greatest position it +serves whose events read the chains of `U` inside those positions, and every other chain as +asked. A chain of records, which reads every chain it certifies and is read by none, is a chain +of `V`: it is lowered with what it certifies, to its last record that the cut read holds, and +takes nothing with it. The control is `Witness.record_follows`. -/ +theorem resolvesIn_of_followed {S : K → Set ℕ} {f p q : Cut K} (U V : K → Prop) + [DecidablePred U] [DecidablePred V] (hf : Consistent R f) (hUV : ∀ k, V k → ¬U k) + (hS : ∀ k, ¬U k → ¬V k → f k ∈ S k) + (hU : ∀ k i x j, U x → R k i x j → (k = x ∧ j ≤ i) ∨ V k) + (hV : ∀ k i x j, V x → R k i x j → k = x ∧ j ≤ i) + (hp : ∀ x, U x → p x ∈ S x ∧ p x ≤ f x ∧ ∀ n ∈ S x, n ≤ f x → n ≤ p x) + (hq : ∀ x, V x → q x ∈ S x ∧ q x ≤ f x ∧ (∀ i y j, U y → R x i y j → i < q x → j < p y) ∧ + ∀ n ∈ S x, n ≤ f x → (∀ i y j, U y → R x i y j → i < n → j < p y) → n ≤ q x) : + ResolvesIn R S f fun k ↦ if U k then p k else if V k then q k else f k := by + have hle : ∀ k, (if U k then p k else if V k then q k else f k) ≤ f k := fun k ↦ by + by_cases hk : U k + · simp only [hk, ↓reduceIte] + exact (hp k hk).2.1 + · by_cases hv : V k + · simp only [hk, hv, ↓reduceIte] + exact (hq k hv).2.1 + · simp only [hk, hv, ↓reduceIte] + exact le_rfl + refine ⟨fun k i k' j hr hi ↦ ?_, fun k ↦ ?_, hle, fun d hd hdS hdf k ↦ ?_⟩ + · by_cases hk' : U k' + · rcases hU k i k' j hk' hr with ⟨rfl, hji⟩ | hv + · exact lt_of_le_of_lt hji hi + · have hk : ¬U k := hUV k hv + simp only [hk, hv, ↓reduceIte] at hi + simp only [hk', ↓reduceIte] + exact (hq k hv).2.2.1 i k' j hk' hr hi + · by_cases hv' : V k' + · obtain ⟨rfl, hji⟩ := hV k i k' j hv' hr + exact lt_of_le_of_lt hji hi + · simp only [hk', hv', ↓reduceIte] + exact hf k i k' j hr (lt_of_lt_of_le hi (hle k)) + · by_cases hk : U k + · simp only [hk, ↓reduceIte] + exact (hp k hk).1 + · by_cases hv : V k + · simp only [hk, hv, ↓reduceIte] + exact (hq k hv).1 + · simp only [hk, hv, ↓reduceIte] + exact hS k hk hv + · by_cases hk : U k + · simp only [hk, ↓reduceIte] + exact (hp k hk).2.2 _ (hdS k) (hdf k) + · by_cases hv : V k + · simp only [hk, hv, ↓reduceIte] + exact (hq k hv).2.2.2 _ (hdS k) (hdf k) fun i y j hy hr hi ↦ + lt_of_lt_of_le (hd k i y j hr hi) ((hp y hy).2.2 _ (hdS y) (hdf y)) + · simp only [hk, hv, ↓reduceIte] + exact hdf k + theorem ResolvesIn.le_on_of_closed {R' : K → ℕ → K → ℕ → Prop} {S S' : K → Set ℕ} {f f' c c' : Cut K} (G : K → Prop) (hclosed : ∀ k i k' j, G k → R' k i k' j → G k') @@ -1345,6 +1413,93 @@ theorem ResolvesIn.eq_on_of_closed {R' : K → ℕ → K → ℕ → Prop} {S S' (h'.le_on_of_closed G hclosed (fun a i b j ha hr ↦ (hR a i b j ha).1 hr) (fun a ha ↦ (hS a ha).superset) h0 (fun a ha ↦ (hf a ha).ge) h k hk) +/-! The filtered read: the references a resolver does not follow. -/ + +section Filter + +variable {ok : K → ℕ → Prop} {c : Cut K} + +/-- SNP-8 The filtered read is closed: every source of a kept row is kept, so it lies inside the +cut and is itself not withheld. The read holds no fact whose sources lie after the cut, whatever +the cut. -/ +theorem Kept.source {k k' : K} {i j : ℕ} (h : Kept R ok c k i) (hr : R k i k' j) : + Kept R ok c k' j := + ⟨lt_of_not_ge fun hle ↦ h.2 (.outside hr hle), fun hw ↦ h.2 (.through hr hw)⟩ + +/-- A kept row passes its own test. -/ +theorem Kept.passes {k : K} {i : ℕ} (h : Kept R ok c k i) : ok k i := + not_not.1 fun hn ↦ h.2 (.own hn) + +/-- SNP-8 The filtered read withholds no more than it must: every set of rows inside the cut +that pass their own test and that holds the sources of its rows is kept. So the filtered read is +the greatest such set. -/ +theorem kept_of_closed (T : K → ℕ → Prop) (hT : ∀ k i, T k i → i < c k ∧ ok k i) + (hclosed : ∀ k i k' j, T k i → R k i k' j → T k' j) {k : K} {i : ℕ} (h : T k i) : + Kept R ok c k i := by + refine ⟨(hT k i h).1, fun hw ↦ ?_⟩ + induction hw with + | own hn => exact hn (hT _ _ h).2 + | outside hr hle => exact absurd (hT _ _ (hclosed _ _ _ _ h hr)).1 (not_lt.2 hle) + | through hr _ ih => exact ih (hclosed _ _ _ _ h hr) + +/-- SNP-8 At a consistent cut, with every row passing its own test, the filter withholds +nothing: the filtered read is the prefix. So it is the prefix at the head. -/ +theorem kept_iff_of_consistent (hc : Consistent R c) (hok : ∀ k i, ok k i) {k : K} {i : ℕ} : + Kept R ok c k i ↔ i < c k := + ⟨fun h ↦ h.1, fun h ↦ kept_of_closed (fun k i ↦ i < c k) (fun k i hi ↦ ⟨hi, hok k i⟩) + (fun k i k' j hi hr ↦ hc k i k' j hr hi) h⟩ + +/-- SNP-8 The rows whose references are all resolved are never withheld. `P` is a set of rows +that pass their own test, whose every reference is one the resolver follows (`R'`) and leads +into `P`: the landings, the attestations of landings and of commits, the commits. At a cut +consistent for `R'` every row of `P` inside the cut is kept under the whole relation `R`. -/ +theorem kept_of_resolved {R' : K → ℕ → K → ℕ → Prop} (P : K → ℕ → Prop) + (hP : ∀ k i k' j, P k i → R k i k' j → R' k i k' j ∧ P k' j) (hok : ∀ k i, P k i → ok k i) + (hc : Consistent R' c) {k : K} {i : ℕ} (h : P k i) (hi : i < c k) : Kept R ok c k i := + kept_of_closed (fun k i ↦ P k i ∧ i < c k) (fun k i hk ↦ ⟨hk.2, hok k i hk.1⟩) + (fun k i k' j hk hr ↦ ⟨(hP k i k' j hk.1 hr).2, hc k i k' j (hP k i k' j hk.1 hr).1 hk.2⟩) + ⟨h, hi⟩ + +/-- A row withheld at a later cut is withheld at an earlier one. -/ +theorem Withheld.anti {c d : Cut K} (hcd : c ≤ d) {k : K} {i : ℕ} (h : Withheld R ok d k i) : + Withheld R ok c k i := by + induction h with + | own hn => exact .own hn + | outside hr hle => exact .outside hr ((hcd _).trans hle) + | through hr _ ih => exact .through hr ih + +/-- SNP-2 The filtered read is monotone in the cut, for a test that does not depend on the cut: +a row kept at a cut is kept at every later one. -/ +theorem Kept.mono {c d : Cut K} (hcd : c ≤ d) {k : K} {i : ℕ} (h : Kept R ok c k i) : + Kept R ok d k i := + ⟨lt_of_lt_of_le h.1 (hcd k), fun hw ↦ h.2 (hw.anti hcd)⟩ + +/-- A row inside the old head that is withheld for the references of a grown store was withheld +for the old ones, when the rows inside the old head kept their references. -/ +theorem Withheld.of_grown {R' : K → ℕ → K → ℕ → Prop} {h : Cut K} + (hR : ∀ k i k' j, i < h k → R' k i k' j → R k i k' j) (hc : c ≤ h) {k : K} {i : ℕ} + (hw : Withheld R' ok c k i) (hi : i < h k) : Withheld R ok c k i := by + induction hw with + | own hn => exact .own hn + | outside hr hle => exact .outside (hR _ _ _ _ hi hr) hle + | @through k k' i j hr _ ih => + by_cases hj : j < h k' + · exact .through (hR _ _ _ _ hi hr) (ih hj) + · exact .outside (hR _ _ _ _ hi hr) ((hc k').trans (not_lt.1 hj)) + +/-- SNP-1 The filtered read is append invariant: when the rows inside the old head keep the +references they had, the rows kept at a cut inside the old head are the same after the store +grows. -/ +theorem kept_grown_iff {R' : K → ℕ → K → ℕ → Prop} {h : Cut K} + (hR : ∀ k i k' j, i < h k → (R' k i k' j ↔ R k i k' j)) (hc : c ≤ h) {k : K} {i : ℕ} : + Kept R' ok c k i ↔ Kept R ok c k i := + ⟨fun hk ↦ ⟨hk.1, fun hw ↦ hk.2 (hw.of_grown (fun a b a' b' hb hr ↦ (hR a b a' b' hb).2 hr) hc + (lt_of_lt_of_le hk.1 (hc k)))⟩, + fun hk ↦ ⟨hk.1, fun hw ↦ hk.2 (hw.of_grown (fun a b a' b' hb hr ↦ (hR a b a' b' hb).1 hr) hc + (lt_of_lt_of_le hk.1 (hc k)))⟩⟩ + +end Filter + end Consistency /-! ### SNP-9 Certified cuts -/ @@ -1639,6 +1794,128 @@ theorem record_drags : omega exact ⟨hland, hatt⟩ +/-- The control for SNP-10's lowering with followers: a chain of records is lowered with what +it certifies. Chain 0 is a landing log, chain 1 the attestations, chain 2 a chain `X` that +serves its empty prefix and the positions from 2 on, chain 3 the records. The landing reads its +attestation, and the one record reads the first event of every other chain. Asked at the head, +the cut read keeps the landing log and the attestations as asked and reads `X` and the records +at their empty prefixes: the records' chain is not read as recorded, and it takes no chain with +it. -/ +theorem record_follows : + ∃ (R : ℕ → ℕ → ℕ → ℕ → Prop) (S : ℕ → Set ℕ) (f : Cut ℕ), + Consistent R f ∧ (∀ k, k ≠ 2 → S k = Set.univ) ∧ (∀ k, f k = 1) ∧ + ∀ c, ResolvesIn R S f c → c 0 = 1 ∧ c 1 = 1 ∧ c 2 = 0 ∧ c 3 = 0 := by + refine ⟨fun k i k' j ↦ (k = 0 ∧ i = 0 ∧ k' = 1 ∧ j = 0) ∨ (k = 3 ∧ i = 0 ∧ k' ≠ 3 ∧ j = 0), + fun k ↦ if k = 2 then {p | p = 0 ∨ 2 ≤ p} else Set.univ, fun _ ↦ 1, ?_, + fun k hk ↦ by simp [hk], fun _ ↦ rfl, ?_⟩ + · rintro k i k' j (⟨rfl, rfl, rfl, rfl⟩ | ⟨rfl, rfl, -, rfl⟩) _ <;> exact Nat.one_pos + · rintro c ⟨hc, hS, hcf, hmax⟩ + have hX : c 2 = 0 := by + have h2 : c 2 = 0 ∨ 2 ≤ c 2 := by simpa using hS 2 + have h1 : c 2 ≤ 1 := hcf 2 + omega + have h3 : c 3 = 0 := by + by_contra h + have := hc 3 0 2 0 (Or.inr ⟨rfl, rfl, by decide, rfl⟩) (Nat.pos_of_ne_zero h) + omega + have hd : Consistent (fun k i k' j ↦ (k = 0 ∧ i = 0 ∧ k' = 1 ∧ j = 0) ∨ + (k = 3 ∧ i = 0 ∧ k' ≠ 3 ∧ j = 0)) (fun k ↦ if k = 2 ∨ k = 3 then 0 else 1) := by + rintro k i k' j (⟨rfl, rfl, rfl, rfl⟩ | ⟨rfl, rfl, -, rfl⟩) hi + · decide + · simp at hi + have hle := hmax _ hd (fun k ↦ by by_cases hk : k = 2 <;> simp [hk]) (fun k ↦ by + change (if k = 2 ∨ k = 3 then 0 else 1) ≤ 1 + by_cases hk : k = 2 ∨ k = 3 <;> simp [hk]) + have a0 : 1 ≤ c 0 := by simpa using hle 0 + have a1 : 1 ≤ c 1 := by simpa using hle 1 + have b0 : c 0 ≤ 1 := hcf 0 + have b1 : c 1 ≤ 1 := hcf 1 + exact ⟨by omega, by omega, hX, h3⟩ + +/-- The control for SNP-8's filtered read: a pass attestation whose reference to a landing is +resolved. Chain 0 is a landing log behind a history window: it serves its empty prefix and the +positions from 2 on. Chain 1 is the attestations: the attestation of the landing on chain 0, a +pass attestation that reads that landing, and the attestation of the landing on chain 2. Chain 2 +is a landing log of another class that serves every position. The cut asked is the head and is +consistent. With the pass attestation's reference followed by the resolver, the second landing +log is read at its empty prefix, though it serves the position asked: the cascade of +`record_drags`, through a pass and not a record. -/ +theorem pass_drags : + ∃ (R : ℕ → ℕ → ℕ → ℕ → Prop) (S : ℕ → Set ℕ) (f : Cut ℕ), + Consistent R f ∧ (∀ k, k ≠ 0 → S k = Set.univ) ∧ f 2 = 1 ∧ + ∀ c, ResolvesIn R S f c → c 2 = 0 := by + refine ⟨fun k i k' j ↦ (k = 0 ∧ i = 0 ∧ k' = 1 ∧ j = 0) ∨ (k = 1 ∧ i = 1 ∧ k' = 0 ∧ j = 0) ∨ + (k = 2 ∧ i = 0 ∧ k' = 1 ∧ j = 2), + fun k ↦ if k = 0 then {p | p = 0 ∨ 2 ≤ p} else Set.univ, + fun k ↦ if k = 0 then 1 else if k = 1 then 3 else 1, ?_, fun k hk ↦ by simp [hk], rfl, ?_⟩ + · rintro k i k' j (⟨rfl, rfl, rfl, rfl⟩ | ⟨rfl, rfl, rfl, rfl⟩ | ⟨rfl, rfl, rfl, rfl⟩) _ <;> + decide + · rintro c ⟨hc, hS, hcf, -⟩ + have h0 : c 0 = 0 := by + have a : c 0 = 0 ∨ 2 ≤ c 0 := by simpa using hS 0 + have b : c 0 ≤ 1 := by simpa using hcf 0 + omega + have h1 : c 1 ≤ 1 := by + by_contra h + have := hc 1 1 0 0 (Or.inr (Or.inl ⟨rfl, rfl, rfl, rfl⟩)) (by omega) + omega + by_contra h + have := hc 2 0 1 2 (Or.inr (Or.inr ⟨rfl, rfl, rfl, rfl⟩)) (Nat.pos_of_ne_zero h) + omega + +/-- The same store with the pass attestation's reference filtered and not resolved. The +resolver follows the landings' references alone, and the cut read is the cut asked with the +first landing log at its empty prefix. That cut is not consistent for the whole relation, so the +prefix read at it holds a pass whose landing is outside. The filtered read withholds that pass +and keeps the attestation after it and the second landing. -/ +theorem pass_withheld : + ∃ (R R' : ℕ → ℕ → ℕ → ℕ → Prop) (S : ℕ → Set ℕ) (f g : Cut ℕ), + (∀ k i k' j, R' k i k' j → R k i k' j) ∧ ResolvesIn R' S f g ∧ g 2 = f 2 ∧ + ¬Consistent R g ∧ ¬Kept R (fun _ _ ↦ True) g 1 1 ∧ Kept R (fun _ _ ↦ True) g 1 2 ∧ + Kept R (fun _ _ ↦ True) g 2 0 := by + let R' : ℕ → ℕ → ℕ → ℕ → Prop := fun k i k' j ↦ + (k = 0 ∧ i = 0 ∧ k' = 1 ∧ j = 0) ∨ (k = 2 ∧ i = 0 ∧ k' = 1 ∧ j = 2) + let R : ℕ → ℕ → ℕ → ℕ → Prop := fun k i k' j ↦ R' k i k' j ∨ (k = 1 ∧ i = 1 ∧ k' = 0 ∧ j = 0) + let S : ℕ → Set ℕ := fun k ↦ if k = 0 then {p | p = 0 ∨ 2 ≤ p} else Set.univ + let f : Cut ℕ := fun k ↦ if k = 0 then 1 else if k = 1 then 3 else 1 + let g : Cut ℕ := fun k ↦ if k = 0 then 0 else f k + have hf : Consistent R' f := by + rintro k i k' j (⟨rfl, rfl, rfl, rfl⟩ | ⟨rfl, rfl, rfl, rfl⟩) _ <;> decide + have hg : ResolvesIn R' S f g := + resolvesIn_of_unread (R := R') (S := S) (f := f) (p := fun _ ↦ 0) (fun k ↦ k = 0) hf + (fun k hk ↦ by simp [S, hk]) (fun k i x j hx hr ↦ by + subst hx + rcases hr with ⟨-, -, h, -⟩ | ⟨-, -, h, -⟩ <;> simp at h) + (fun x hx ↦ by + subst hx + refine ⟨by simp [S], by simp [f], fun n hn hnf ↦ ?_⟩ + have a : n = 0 ∨ 2 ≤ n := by simpa [S] using hn + have b : n ≤ 1 := by simpa [f] using hnf + change n ≤ 0 + omega) + have hP : ∀ k i, Kept R (fun _ _ ↦ True) g k i ↔ i < g k ∧ ¬(k = 1 ∧ i = 1) := by + intro k i + constructor + · intro hk + refine ⟨hk.1, ?_⟩ + rintro ⟨rfl, rfl⟩ + have := (hk.source (Or.inr ⟨rfl, rfl, rfl, rfl⟩ : R 1 1 0 0)).1 + simp [g] at this + · intro hk + refine kept_of_closed (fun k i ↦ i < g k ∧ ¬(k = 1 ∧ i = 1)) (fun k i h ↦ ⟨h.1, trivial⟩) + ?_ hk + rintro k i k' j ⟨hi, hne⟩ ((⟨rfl, rfl, rfl, rfl⟩ | ⟨rfl, rfl, rfl, rfl⟩) | + ⟨rfl, rfl, rfl, rfl⟩) + · simp [g] at hi + · exact ⟨by decide, by decide⟩ + · exact absurd ⟨rfl, rfl⟩ hne + refine ⟨R, R', S, f, g, fun _ _ _ _ h ↦ Or.inl h, hg, rfl, fun h ↦ ?_, fun h ↦ ?_, ?_, ?_⟩ + · have := h 1 1 0 0 (Or.inr ⟨rfl, rfl, rfl, rfl⟩) (by decide) + simp [g] at this + · exact ((hP 1 1).1 h).2 ⟨rfl, rfl⟩ + · exact (hP 1 2).2 ⟨by decide, by decide⟩ + · exact (hP 2 0).2 ⟨by decide, by decide⟩ + /-- The control for SNP-6's closed set of chains: the cut read on a chain a grant names depends on what a chain it reads serves. One relation and one frontier, served positions that agree on the named chain, and two different cuts read on it. -/ diff --git a/formal/Palace/Snapshot/Defs.lean b/formal/Palace/Snapshot/Defs.lean index 411c137a..34247ef7 100644 --- a/formal/Palace/Snapshot/Defs.lean +++ b/formal/Palace/Snapshot/Defs.lean @@ -37,7 +37,9 @@ Events may read from events of other chains (`R k i k' j`: the `i`-th event of c from the `j`-th of chain `k'`); a cut is **consistent** when every source of an event inside it is inside it, and a frontier **resolves** to the greatest consistent cut under it, or, where a store serves only some positions (those from its horizon on, and the empty prefix), to the greatest -consistent cut under it among the served positions (`ResolvesIn`). A cut is +consistent cut under it among the served positions (`ResolvesIn`). A reference the resolver +does not follow is kept by a filter of the read instead: a row is withheld when a source of it +lies outside the cut or is withheld (`Withheld`, `Kept`). A cut is **certified** by the digest of each chain's prefix under a chain digest (`chainDigest`, a fold), and a later store **verifies** the certificate when its own prefixes have those digests. A store that keeps a commitment beside each event (`committed`) can lose an event's content to an erasure @@ -308,6 +310,24 @@ def ResolvesIn (R : K → ℕ → K → ℕ → Prop) (S : K → Set ℕ) (f c : Consistent R c ∧ (∀ k, c k ∈ S k) ∧ c ≤ f ∧ ∀ d, Consistent R d → (∀ k, d k ∈ S k) → d ≤ f → d ≤ c +/-- A row is withheld at a cut when it fails its own test `ok` (it is erased, or it is about a +version the cut does not hold), when one of its sources lies outside the cut, or when one of its +sources is withheld. The last clause is what makes the filter a closure and not a test of the +row alone. -/ +inductive Withheld (R : K → ℕ → K → ℕ → Prop) (ok : K → ℕ → Prop) (c : Cut K) : K → ℕ → Prop + /-- The row fails its own test. -/ + | own {k : K} {i : ℕ} : ¬ok k i → Withheld R ok c k i + /-- A source of the row lies outside the cut. -/ + | outside {k k' : K} {i j : ℕ} : R k i k' j → c k' ≤ j → Withheld R ok c k i + /-- A source of the row is withheld. -/ + | through {k k' : K} {i j : ℕ} : R k i k' j → Withheld R ok c k' j → Withheld R ok c k i + +/-- The filtered read at a cut: the rows inside the cut that are not withheld. Where a +reference is not resolved, because resolving it would lower a chain that others read, the read +at a cut is this filter of the prefix and not the prefix. -/ +def Kept (R : K → ℕ → K → ℕ → Prop) (ok : K → ℕ → Prop) (c : Cut K) (k : K) (i : ℕ) : Prop := + i < c k ∧ ¬Withheld R ok c k i + end Consistency /-! ### Certified cuts -/ From 9a960c9f7912ff813139511982a52b48b9d5729a Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 07:56:25 -0500 Subject: [PATCH 26/37] test(formal): attack the row filter and the chain that follows Seeds 514 to 520. The executable filter is checked against every set of rows of the two chains that lies inside the cut and holds its own sources, so it is the greatest closed set; it is monotone in the cut and withholds nothing at a consistent cut. A chain that reads a lowered chain follows it, against the enumeration. Controls: the filter without its closure, the prefix taken for the filtered read, the follower read as asked. Co-Authored-By: Claude Fable 5.2 --- formal/PalaceTest/Snapshot.lean | 84 ++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) diff --git a/formal/PalaceTest/Snapshot.lean b/formal/PalaceTest/Snapshot.lean index c3028eca..256bab1a 100644 --- a/formal/PalaceTest/Snapshot.lean +++ b/formal/PalaceTest/Snapshot.lean @@ -28,7 +28,11 @@ positions without the descent, the floor and the descent each run once in either that loses its key, a chain that others read lowered alone, and each law of growth, order and composition with its hypothesis dropped or its sides exchanged. The served resolver is executable here too: the floor and the descent alternated until nothing moves, tested against -the enumeration. They run when this module builds (`lake test`). +the enumeration. So is the row filter: the rows no chain of sources leads outside the cut, +tested against every set of rows of the two chains that lies inside the cut and holds its own +sources; its controls are the filter without its closure, the prefix taken for the filtered +read, and a chain that follows a lowered chain read as asked. They run when this module builds +(`lake test`). -/ @[expose] public section @@ -128,6 +132,41 @@ def into0 (es : List Edge) : List Edge := es.filter fun e ↦ e.2.1 = 0 /-- Chain 0 serves every position and chain 1 the positions of the mask. -/ def sv1 (m : Fin 1024) (k : Fin 2) (q : ℕ) : Bool := k == 0 || sv m 1 q +/-- The edges of a store whose chain 1 is read by itself and by chain 0, and whose chain 0 is +read by itself alone, each chain's own references pointing backward: chain 0 follows chain 1. -/ +def foll (es : List Edge) : List Edge := + es.filter fun e ↦ (e.1.1 = 0 || e.2.1 = 1) && (e.1.1 != e.2.1 || decide (e.2.2 ≤ e.1.2)) + +/-- The eight events of two chains of four positions. -/ +def evs : List (Fin 2 × Fin 4) := (List.finRange 2).flatMap fun k ↦ (List.finRange 4).map (k, ·) + +/-- One pass of the row filter: the rows with a source outside the cut or a source already +withheld. -/ +def withholdStep (es : List Edge) (c : ℕ × ℕ) (w : List (Fin 2 × Fin 4)) : + List (Fin 2 × Fin 4) := + evs.filter fun x ↦ es.any fun e ↦ + e.1 == x && (!decide (e.2.2.val < at2 c e.2.1) || w.contains e.2) + +/-- The executable row filter: the rows inside the cut that no chain of sources leads outside +it, the pass run as many times as there are rows. -/ +def keptRows (es : List Edge) (c : ℕ × ℕ) : List (Fin 2 × Fin 4) := + evs.filter fun x ↦ + decide (x.2.val < at2 c x.1) && !((withholdStep es c)^[8] []).contains x + +/-- A set of rows from eight bits. -/ +def rowSet (m : Fin 256) : List (Fin 2 × Fin 4) := + evs.filter fun x ↦ m.val.testBit (4 * x.1.val + x.2.val) + +/-- A set of rows lies inside the cut and holds the sources of its rows. -/ +def closedIn (es : List Edge) (c : ℕ × ℕ) (t : List (Fin 2 × Fin 4)) : Bool := + t.all (fun x ↦ decide (x.2.val < at2 c x.1)) + && es.all fun e ↦ !t.contains e.1 || t.contains e.2 + +/-- The rows whose own sources lie inside the cut: the filter without its closure. -/ +def oneStep (es : List Edge) (c : ℕ × ℕ) : List (Fin 2 × Fin 4) := + evs.filter fun x ↦ decide (x.2.val < at2 c x.1) + && es.all fun e ↦ !(e.1 == x) || decide (e.2.2.val < at2 c e.2.1) + /-- An erasure of keyed writes by their value. -/ def ek (e : Fin 8) (w : Fin 3 × Fin 3) : Bool := pf e w.2 @@ -630,4 +669,47 @@ the frontier. -/ (List.finRange 2).all (fun k ↦ at2 (bestIn es (sv m) x.val y.val) k == resolve es x.val y.val k) = true) 508 +/- SNP-8: the filtered read is closed, and it is the greatest closed set of rows inside the +cut: every such set lies in it. -/ +#eval survives (∀ (es : List Edge) (x y : Fin 6) (m : Fin 256), + (closedIn es (x.val, y.val) (keptRows es (x.val, y.val)) + && (!closedIn es (x.val, y.val) (rowSet m) + || (rowSet m).all fun r ↦ (keptRows es (x.val, y.val)).contains r)) = true) 514 + +/- SNP-2: a row kept at a cut is kept at every later cut. -/ +#eval survives (∀ (es : List Edge) (x y u v : Fin 6), + ((keptRows es (min x.val u.val, min y.val v.val)).all fun r ↦ + (keptRows es (x.val, y.val)).contains r) = true) 515 + +/- SNP-8: at a consistent cut the filter withholds nothing. -/ +#eval survives (∀ (es : List Edge) (x y : Fin 6), + (keptRows es (resolve es x.val y.val 0, resolve es x.val y.val 1) + == evs.filter fun r ↦ decide (r.2.val < resolve es x.val y.val r.1)) = true) 516 + +/- Control: the rows whose own sources lie inside the cut are not closed: a row is withheld +through a source that is withheld. -/ +#eval refuted (∀ (es : List Edge) (x y : Fin 6), + closedIn es (x.val, y.val) (oneStep es (x.val, y.val)) = true) 517 + +/- Control: at a cut that is not consistent the prefix is not the filtered read. -/ +#eval refuted (∀ (es : List Edge) (x y : Fin 6), + (keptRows es (x.val, y.val) == evs.filter fun r ↦ decide (r.2.val < at2 (x.val, y.val) r.1)) + = true) 518 + +/- SNP-10: a chain that reads a lowered chain follows it. Chain 1 is read by itself and by +chain 0, chain 0 by itself alone. From a consistent frontier the cut read has chain 1 at the +greatest position it serves and chain 0 at the first of its events that reads chain 1 past +that position. -/ +#eval survives (∀ (es : List Edge) (m : Fin 1024) (x y : Fin 6), + (bestIn (foll es) (sv1 m) (resolve (foll es) x.val y.val 0) (resolve (foll es) x.val y.val 1) + == (lowerAt (foll es) (resolve (foll es) x.val y.val 0, + floorSv (sv1 m) 1 (resolve (foll es) x.val y.val 1)) 0, + floorSv (sv1 m) 1 (resolve (foll es) x.val y.val 1))) = true) 519 + +/- Control: the chain that follows is not read as asked. -/ +#eval refuted (∀ (es : List Edge) (m : Fin 1024) (x y : Fin 6), + (bestIn (foll es) (sv1 m) (resolve (foll es) x.val y.val 0) (resolve (foll es) x.val y.val 1) + == (resolve (foll es) x.val y.val 0, + floorSv (sv1 m) 1 (resolve (foll es) x.val y.val 1))) = true) 520 + end Palace.Snapshot.Attack From 7ab8a4b2bbcb3c514f2668d0470c82c376d3257c Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 08:14:43 -0500 Subject: [PATCH 27/37] docs(formal): the Snapshot paragraphs with the filter and the follower The bullet, the list of controls and the attacks paragraph say what Snapshot.lean and its attack module now hold: the filtered read under SNP-8, the chain that follows under SNP-10, eighteen controls, and seeds 430 to 520 with the instances each new control took. Co-Authored-By: Claude Fable 5.2 --- formal/README.md | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/formal/README.md b/formal/README.md index b4002f80..620cf516 100644 --- a/formal/README.md +++ b/formal/README.md @@ -334,7 +334,11 @@ Roundoff and FloatModel, so it has no statements of its own): here from `Clock.IsCut.frontier_inf` and `frontier_sup`; every frontier resolves to exactly one greatest consistent cut under it, monotonically, a consistent cut stays consistent as the store grows, and a cut consistent for a recorded bound on the references is consistent for - the true ones; SNP-9 the certificate of a cut verifies on every extension of the store, two + the true ones; a reference the resolver does not follow is kept by a filter of the read, a + row withheld when a source of it lies outside the cut or is withheld, and the filtered read + holds the sources of its rows, is the greatest such set inside the cut, is the prefix at a + consistent cut, never withholds a row whose references are all resolved, and is monotone and + append invariant; SNP-9 the certificate of a cut verifies on every extension of the store, two stores that verify one certificate under a collision-free digest have the same prefix of every digested chain at its cut and so the same derived views of it, a certificate extends over the events since an earlier one, the meet and the join of two certified cuts are @@ -348,8 +352,10 @@ Roundoff and FloatModel, so it has no statements of its own): positions (those from a horizon on, and the empty prefix) every frontier resolves to exactly one greatest consistent cut among them, which never passes the cut asked and rises with the frontier and with served positions that grow; a chain that no other chain reads is lowered - alone, every other chain read as asked. The grant and the erasure applied to one read - (`shown`) keep the laws of each. The fifteen controls as theorems, in `Witness`: the reader + alone, every other chain read as asked, and a chain that reads the lowered chains and that + nothing but itself reads, as a chain of records does, follows them and takes nothing with + it. The grant and the erasure applied to one read + (`shown`) keep the laws of each. The eighteen controls as theorems, in `Witness`: the reader that ignores the cut (`present_not_appendInvariant`), the store rewritten in place (`stateOf_forgets`), an event filter applied before the cut (`filter_before_cut`), positions that count hidden events (`position_channel`), the erasure that deletes rows @@ -358,7 +364,10 @@ Roundoff and FloatModel, so it has no statements of its own): (`prune_forgets`, `prune_indistinct`), a digest with collisions (`digest_collides`), a hole that loses its key (`keyless_hole`), a seal written after a certified cut (`seal_not_certified`), a renamed chain (`rename_breaks_certificate`), a record on a chain - that content reads (`record_drags`), a named chain that reads an unnamed one + that content reads (`record_drags`), a chain of records lowered with a chain it certifies + (`record_follows`), a pass attestation whose reference to a landing is resolved, and the + same reference filtered, where the prefix is not closed and the filtered read is + (`pass_drags`, `pass_withheld`), a named chain that reads an unnamed one (`resolution_reads_unnamed`), and served positions that shrink (`served_set_shrinks`). Design theorems (Palace and PalaceTest, no Spec rows): `as of` reads the citation graph at a commit and every other store as it is now. @@ -892,12 +901,12 @@ at a gain above the rate the ceiling is fixed, on the first instance; at exponen not constant, on the first instance; and the greedy walk's empirical measure is not within `1/8` of the structural stationary distribution, on the first instance. -The snapshot is attacked on the model's own definitions (seeds 430 to 513): stores of two +The snapshot is attacked on the model's own definitions (seeds 430 to 520): stores of two chains over three events, cuts from two naturals, keyed chains over three keys, chains of landings and retires from codes, grants from two bits and event filters and erasures from three, reads-from relations as lists of edges between the two chains at positions under four, a digest that reads a chain as a numeral in base four, which is collision free, and the positions -a chain serves from ten bits. Forty-five attacks survived, every one all 500 instances: the read +a chain serves from ten bits. Forty-nine attacks survived, every one all 500 instances: the read at a cut and between two cuts under growth; the prefix order and the meet; the two compositions and the journal; the head cut; the generational store against the recomputed state and the last write, one generation alive at most, the same under growth, and the keyed journal; an event of @@ -912,13 +921,16 @@ the meet and the join, and across an erasure on a committed store; the pruned ge store at and past its horizon, never wrong under it, and two horizons as the later one; and, among the served positions, the greatest consistent cut under a frontier found by enumeration, consistent and served, under the resolution of the frontier, rising with what is served, equal -to the resolution when every position is served, and equal to the frontier with an unread chain -lowered alone. Two resolvers are attacked that the library does not define: the descent that +to the resolution when every position is served, equal to the frontier with an unread chain +lowered alone, and with a chain that reads it lowered after it; and the row filter, closed, the +greatest closed set of rows inside the cut by enumeration of every set of rows, growing with +the cut, and withholding nothing at a consistent cut. Two resolvers are attacked that the +library does not define: the descent that lowers a frontier until no event inside it has a source outside, checked against the greatest consistent cut by enumerating the thirty-six cuts of the grid (461), and its alternation with the floor to the served positions, checked against the greatest consistent served cut (492). -The thirty-nine controls, each refuted, with the instances it took. A read at a cut past the +The forty-two controls, each refuted, with the instances it took. A read at a cut past the head changes with growth, for the prefix, the read between two cuts and the generational store (11, 11, 7). The read at one cut is a prefix of the read at any other (6); a cut of a cut is the join (5); the read at a cut that is not the head is the store (8). The composition with @@ -937,7 +949,9 @@ under its horizon (30); pruning at the earlier of two horizons (24); a frontier served positions without the descent (24); the floor and the descent each run once, in either order (17, 26); a chain that others read lowered alone (17); the cut read reaching the floor (23), rising when less is served (10), and equal to the resolution when not every position is -served (5). +served (5). The rows whose own sources lie inside the cut taken for a closed set (61); the +prefix taken for the filtered read (15); a chain that follows a lowered chain read as asked +(38). ## Build From 835c298099f195552abd86c3fb9bbb9b57ea2b8e Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 08:14:43 -0500 Subject: [PATCH 28/37] docs(design): resolved and filtered references in dn-temporal-snapshot The list of references between chains left out the rows that read landings and record no bound: a pass attestation (the dreamer's and the curator's, on the ledger every landing reads), a dream claim, a claim op. The claim that each chain which cannot serve is lowered alone held for the recorded bounds only, and with the true references a landing chain behind a history window took the attestation ledger and every later landing chain with it. The references are now two kinds. The resolver follows a landing's to its attestation, an attestation's to its commit and a record's to its frontier. The rest are kept by a filter of the read, proved closed under every reference (SNP-8). The chain of records reads every chain it certifies, so it is lowered with them and nothing follows it (resolvesIn_of_followed). Sections 3.3, 3.5, 5.4, 6.3, 7.1, 7.2, 7.3, 8, 9.2, 9.4, 10, 12 and 13, the falsifiers and the counts follow. Co-Authored-By: Claude Fable 5.2 --- docs/design-notes/dn-temporal-snapshot.md | 416 ++++++++++++++-------- 1 file changed, 275 insertions(+), 141 deletions(-) diff --git a/docs/design-notes/dn-temporal-snapshot.md b/docs/design-notes/dn-temporal-snapshot.md index 6d425ceb..99e7b3a1 100644 --- a/docs/design-notes/dn-temporal-snapshot.md +++ b/docs/design-notes/dn-temporal-snapshot.md @@ -71,12 +71,12 @@ as of a cut (dn-utility-field, open question 1). (§3.4, §3.5).** Every frontier resolves to exactly one such cut. That consistent cuts are closed under meet and join is CLK-2's, already in the ledger. Wall time selects a frontier by lookup in the bookmarks and orders nothing. `[THEOREM: SNP-8, CLK-2]` -4. **A cut is certified by the digest of each hashed chain's prefix, recorded on a chain of - records that nothing reads (§3.3, §3.6).** A certificate verifies on every later state of the +4. **A cut is certified by the digest of each hashed chain's prefix, recorded on a chain of records + that no other chain reads (§3.3, §3.6).** A certificate verifies on every later state of the store and, under a collision-free digest, pins the prefix it digests. For the landing log that prefix is the commitments, so under a binding commitment it pins the events. It attests no - erasure, no seal and no grant: those are the present's, and an answer at a certified cut is - the same on two stores for one erasure, one grant and one set of seals. `[THEOREM: SNP-9]` + erasure, no seal and no grant: those are the present's, and an answer at a certified cut is the + same on two stores for one erasure, one grant and one set of seals. `[THEOREM: SNP-9]` 5. **Derived data is a function of the prefixes, held store by store in the cheapest of the equal ways (§5):** version-keyed rows selected by the log for vectors and lexical units, recomputation for the causal fiber and for the relations a note declares, kept generations @@ -89,8 +89,10 @@ as of a cut (dn-utility-field, open question 1). cannot serve the cut asked, the cut read is the greatest consistent cut among the positions the stores serve, and the answer names it chain by chain. A chain that no other chain reads is lowered alone; a chain that others read takes its readers down with it, which is why a - recorded cut is kept off the chains that content reads. `[THEOREM: SNP-10; INFERENCE for the - surface, falsifier SNF-4]` + recorded cut is kept off the chains that content reads, and why a row that reads a landing + without being a landing's own record, a pass attestation or a row of model output, is + withheld by a filter of the read and lowers no position (§3.5). `[THEOREM: SNP-8, SNP-10; + INFERENCE for the surface, falsifier SNF-4]` 8. **History is exact from the horizon, and the horizon is an event of the chain (§8).** A store that drops old generations reads every cut from its horizon on exactly, and a cut under the horizon is not served. `[THEOREM: SNP-10]` @@ -126,9 +128,9 @@ flight; one of them keeps text, the rejected requests, and §6.1 names it for th ### 1.4 What is proved, what is measured, what is open Proved, in `formal/Palace/Snapshot.lean` over `formal/Palace/Snapshot/Defs.lean`: SNP-1 to SNP-10 -as §10 states them, 161 theorems, fifteen of them the controls; attacked in -`formal/PalaceTest/Snapshot.lean` (seeds 430 to 513: forty-five attacks, every one surviving all -500 instances, and thirty-nine negative controls, each refuted). They are design theorems: no +as §10 states them, 175 theorems, eighteen of them the controls; attacked in +`formal/PalaceTest/Snapshot.lean` (seeds 430 to 520: forty-nine attacks, every one surviving +all 500 instances, and forty-two negative controls, each refuted). They are design theorems: no code relies on them, so they have no row in `docs/LAWS.md` and no statement in `formal/Spec/`; §12 says when they enter the ledger. Some of what §6 and §7 require holds by the construction of the model and not by a theorem about the code: §10 says which, law by law. @@ -319,7 +321,7 @@ prefix length of it. `[DERIVED from global-event-clock §2.2, generator g1]` | `staging` | the staging store | its generation | recorded | | `runs` | the run ledger, with the structural snapshot of a pass | a sequence number | recorded as insertion order | | `use` | the utility field's use log (dn-utility-field §3.1) | the tick | not built | -| `cuts` | the recorded cuts (§3.3) | `seq` | not built; no chain reads it | +| `cuts` | the recorded cuts (§3.3) | `seq` | not built; it reads every chain it certifies, and no other chain reads it | Four choices are made here. @@ -518,7 +520,10 @@ landing reads from the attestation ledger. If records sat on that ledger, a chai serve only a position below one a record certified would exclude the record, the ledger's prefix would stop before it, and every landing attested later would go with it: one chain read low can take a landing chain to its empty prefix (`Witness.record_drags`). On a chain of -their own, which no event reads, the records constrain nothing (§3.5). `[THEOREM: SNP-10]` +their own, which no event of another chain reads, a record takes no chain down. Its own chain +does go down with a chain it certifies: the chain of records is read at its last record every +position of which the cut read holds, and nothing follows it (`resolvesIn_of_followed`, +`Witness.record_follows`; §7.1). `[THEOREM: SNP-10]` Since each record is the head of every chain at some moment and chains only grow, the recorded cuts are totally ordered. A record is about 2.7 kilobytes by arithmetic from its fields, not @@ -568,12 +573,27 @@ references between the chains of §3.1 are these. `[ESTABLISHED: read off the wr - the attestation of a sensed commit, and of a projection of it, reads from the commit (`ops/code_sensor.py:413-418`, `:489-492`); - a citation edge reads from its commit and from the projection that wrote it; +- a recorded cut reads from the prefix of every chain it certifies and from the record before + it, and no row of another chain reads a recorded cut; +- the attestation of a pass reads from the landings of the notes the pass read. The dreamer's + and the curator's attestations sit on the ledger the landings' attestations sit on, name the + notes' digests as their inputs (`core/dreaming/dreamer.py:144-148`, `:223-227`; + `core/curator/curator.py:167-171`; `core/attestation/record.py:57`) and take as parents the + attestations that produced those digests (`core/attestation/attestor.py:64-69`); +- a dream claim of the run ledger reads from the landings of the digests it rests on + (`core/stores/runledger.py:90-97`); - an interpreted artifact reads from the digests its `derived_from` names, through the artifacts it names there, and from the attestation its `attestation_id` names (`core/stores/derived.py:186-191`); an interpreted relation edge reads from the landings of its two endpoint digests; -- a recorded cut reads from the prefix of every chain it certifies, and nothing reads a - recorded cut. +- a claim op reads from the note or the artifact its `claim_id` names, and a supersede from the + conclusion artifact the same call wrote, its `related_id` (`core/stores/claim_ops.py:45`, + `:161-163`); a verdict's disposition reads from the claim or artifact it is about + (`core/verdict/dispositions.py:59-64`). + +The first four are **resolved**: the resolver follows them, and the cut read is consistent for +them. The last four are **filtered**: the resolver does not follow them, and a row that has one +is served at a cut only when its sources are. Both are taken up below, after the definition. A causal edge reads from the turn that witnessed it and, when it ends at a commit, from the commit (`causal_edges.py:58-60`, `integrator.py:134-137`); it is recomputed at a cut (§5.5), so @@ -601,22 +621,69 @@ fact whose sources lie after the cut, every cross-chain reference closed. `[THEO So ING-7's invariant, that a key implies its rows, holds at every consistent cut and not only at the head: a cut that holds a landing holds its attestation and its version. `[DERIVED]` -**Where the references are recorded.** The resolver has to know, for an event, where its sources -lie. A landing records the head of `att` at its writing (`att_head`); an attestation of a -commit names the commit; a recorded cut carries its whole frontier. With one writer a row's +**Where the resolved references are recorded.** The resolver has to know, for an event, where +its sources lie. A landing records the head of `att` at its writing (`att_head`); an attestation +of a commit names the commit; a recorded cut carries its whole frontier. With one writer a row's sources were all written before it, so the head at its writing bounds them, the bound rises along the chain, and it is sound: a cut consistent for the recorded bounds is consistent for the -true references (`Consistent.of_bound`). It can only make fewer cuts consistent. `[THEOREM: -SNP-8; DERIVED from the one-writer rule, dn-ingress D3, for the bound]` - -**Rows that are filtered, not resolved.** An interpreted row records no head of the chains it -reads, and it needs none. No chain reads the `interp` chains, so their positions constrain no -other chain (`resolvesIn_update_of_unread`), and the closure of their own references is kept row -by row: a row is in the read at a cut when its position is at or under the cut, the attestation -it names is at or under the cut on `att`, and every digest its sources reach is a head at the -cut (§5.4). A row whose sources lie outside the cut is withheld and a later row whose sources -lie inside is served. That read is a derived view of the prefixes (SNP-5) which holds no fact -whose sources lie after the cut; it is not the prefix of the chain. `[DERIVED]` +true references they bound (`Consistent.of_bound`). It can only make fewer cuts consistent. The +theorem's hypothesis is a recorded bound at or above every true reference, so it speaks of the +resolved references and of no other. `[THEOREM: SNP-8; DERIVED from the one-writer rule, +dn-ingress D3, for the bound]` + +**Rows that are filtered, not resolved.** The other references must not be given to the +resolver. A pass attestation sits on `att`, which every landing reads, and it reads landings. +Resolved, that reference would put `att` below the first pass that read a landing outside the +cut, and every landing chain attested after that pass would fall with it: a landing chain read +low behind a history window would take the other landing chains to the positions they had when +that pass ran, which is the cascade of a record kept on the ledger, through a pass +(`Witness.pass_drags`). So the closure of these references is kept row by row. A row is +**withheld** at a cut when it fails a test of its own, when a source of it lies outside the cut, +or when a source of it is withheld (`Withheld`); the read at a cut is the rows inside the cut +that are not withheld (`Kept`). `[THEOREM: SNP-8 for the control; INFERENCE for the choice, +falsifier SNF-16]` What a row's sources and its own test are, store by store: + +- **A pass attestation:** an attestation whose inputs name the digests of notes it did not itself + land, which today are the dreamer's and the curator's. Its chain-table row records, at its + writing, the landing chains that held its inputs and the head of each. It is withheld when the cut + read lies under one of those heads. The head stands for the landings the pass read, which lie at + or under it, so the bound can only withhold more; it is a position and names no digest, so a purge + or a history window, which empty rows and move no position, change nothing in what is withheld. + The ledger is read by sequence number with those rows left out. +- **A row of the run ledger.** A run's chain-table row records the same pairs, and a dream + claim is served when its run is. +- **An interpreted artifact and an interpreted relation edge.** §5.4: the attestation the row + names is kept at the cut, and every digest its sources reach is a head at the cut and is not + erased or sealed. +- **A claim op and a disposition.** The note or the artifact it names is served at the cut, + and for a supersede the conclusion artifact as well. + +What is proved of the filtered read, for any reads-from relation and any test. `[THEOREM: +SNP-8, with SNP-1 and SNP-2 for the last item]` + +- It is closed: every source of a kept row is kept, so it lies inside the cut (`Kept.source`, + `Kept.passes`). The read holds no fact whose sources lie after the cut, for every reference + of the list above, whatever cut the resolver returned. +- It withholds no more than it must: every set of rows inside the cut that pass their test and + that holds its own sources is kept (`kept_of_closed`). +- It never withholds a row all of whose references are resolved. The landings, the attestations + of landings and of commits, and the commits read only one another, by resolved references, so + at a cut consistent for those references every one of them inside the cut is kept + (`kept_of_resolved`). The filter takes rows out of `att`, `runs` and the `interp` chains and + takes no landing. +- At a cut consistent for every reference, where every row passes its test, it withholds + nothing and the read is the prefix (`kept_iff_of_consistent`). For the attestations and the + runs, whose test is empty, that is the case at the head, since a store holds the sources of + its own rows, and at a recorded cut every position of which is served. +- For a test that does not depend on the cut it is monotone, a row kept at a cut being kept at + every later one, and it is append invariant (`Kept.mono`, `kept_grown_iff`). + +So the cut read is consistent for the resolved references, and the read at it is filtered for +the rest. That read is a derived view of the prefixes (SNP-5), and on `att`, `runs` and the +`interp` chains it is not the prefix. The control is the store of `Witness.pass_drags` with the +pass's reference filtered: the landing chain behind its window is lowered alone, the prefix at +that cut holds a pass whose landing is outside it, and the filtered read withholds the pass and +keeps the attestation after it and the other class's landing (`Witness.pass_withheld`). **The resolver.** A name that selects a recorded cut needs none while every chain serves the record's positions: the record is consistent. Otherwise it is two steps alternated until @@ -880,14 +947,17 @@ differs between the two stores. link to the pass that wrote it is the attestation it names (`derived.py:59`). So a kept row is in the read at a cut when four things hold: it was written at or under the cut -on its own chain; the attestation it names, if any, is at or under the cut on `att`; every +on its own chain; the attestation it names, if any, is kept at the cut on `att`, which for a +pass attestation is more than lying under the cut (§3.5); every digest its sources reach is some path's head at the cut, where an artifact's sources are followed through the artifacts it names, each as it stood at the cut, down to digests (the store refuses a cycle, `derived.py:186-189`); and none of those digests is erased or sealed -(`mem_serve_iff`). `[THEOREM: SNP-7 for the erasure; DERIVED for the rest]` This is the row -filter of §3.5: it withholds a row and lowers no position. Until SN-6 builds it the `interp` -chains serve two positions, the empty prefix and the head (§7.1), and lowering them moves no -other chain, since nothing reads them. +(`mem_serve_iff`). `[THEOREM: SNP-7 for the erasure, SNP-8 for the closure; DERIVED for the +rest]` This is the row filter of §3.5: it withholds a row and lowers no position. Until SN-6 +builds it the `interp` chains serve two positions, the empty prefix and the head (§7.1). +Lowering them moves no chain outside them but the chain of records, which follows (§7.1): the +other references into them are their own, a claim op's to an artifact and an artifact's to +another, and those are the filter's. ### 5.5 The causal fiber @@ -1104,7 +1174,9 @@ at a recorded cut: the record's positions are fixed, `att` is never pruned, so i and the references of the events inside the cut do not change as the store grows (`Consistent.of_grown`). What a narrower grant can learn through the cut shown is only that `att` or `repo` did not serve a position, which is a fact about the instance and no class's -data. `[DERIVED]` +data. The filtered references do not enter the cut shown, since the resolver does not follow +them. A row withheld because a chain the grant does not name was read low tells the asker that +that chain did not serve the cut, the same kind of fact. `[DERIVED]` Two consequences for the surface. An answer names the cut it read on the chains the asker's grant names and on no other, and the bounds a row records (§3.5) are never shown: `att` mixes every @@ -1154,15 +1226,31 @@ that position is outside the cut, and so is everything that reads those events (`Witness.record_drags`). A chain that no other chain reads is lowered alone: from a consistent cut asked, the cut read is the cut asked with each such chain at the greatest position it serves at or under the one asked, and every other chain as asked (`resolvesIn_of_unread`, and -`resolvesIn_update_of_unread` for one chain). `[THEOREM: SNP-10]` The design is arranged so that -the second case is the only one that occurs at a recorded cut. The references the resolver -records are a landing's to `att` and an attestation's to `repo` (§3.5). Neither `att` nor -`repo` has a horizon that moves: the attestation ledger is never pruned (§9.2) and `repo` is -git's. Every chain that can fail to serve a recorded position, a landing chain behind a history -window, a chain that keeps no past yet, the use log behind its horizon, is read by no recorded -bound. And the recorded cuts, which read every chain, sit on a chain nothing reads (§3.3). So at -a recorded cut each chain that cannot serve is lowered alone and the others are read as -recorded. `[DERIVED]` +`resolvesIn_update_of_unread` for one chain). And a chain that reads a lowered chain, and that +nothing but itself reads, follows it and takes nothing with it: it is read at the greatest +position it serves whose events read the lowered chains inside their new positions +(`resolvesIn_of_followed`). `[THEOREM: SNP-10]` + +The design is arranged so that, among the references the resolver follows, the second and the +third case are the only ones that occur at a recorded cut. Those references are a landing's to +`att`, an attestation's to `repo` and a record's to every chain it certifies (§3.5). Neither +`att` nor `repo` has a horizon that moves: the attestation ledger is never pruned (§9.2) and +`repo` is git's. Every chain that can fail to serve a recorded position, a landing chain behind +a history window, a chain that keeps no past yet, the use log behind its horizon, is read +through a resolved reference by one chain only, the chain of records, which no other chain +reads (§3.3). So at a recorded cut each chain that cannot serve is lowered to the greatest +position it serves; the chain of records is lowered with them, to its last record every +position of which the cut read holds (`Witness.record_follows`); and every other chain is read +as recorded. `[DERIVED]` + +That is a statement about positions, and it holds for the resolved references only. A row that +reads a lowered chain through a filtered reference, a pass attestation, a dream claim, an +interpreted row or a claim op, leaves the read by the filter of §3.5 and moves no position: at +a cut where a landing chain is read at its empty prefix, every pass attestation that read a +landing of that chain is withheld, with the artifacts that name it, and `att` keeps its +position. Resolving those references instead would bring the cascade back through `att` +(`Witness.pass_drags`, against `Witness.pass_withheld`). `[THEOREM: SNP-8 for the two +controls]` **When the cut read falls.** The monotonicity needs the served positions to grow. They do not always. A store that keeps no past serves its empty prefix and its head, and loses its old head @@ -1175,9 +1263,10 @@ note]` The answer is then exact for the cut it names: every law of §10 holds at the cut read. What the answer says is that cut. It carries one note with the cut asked, the cut read on the chains the -asker's grant names (§6.3), and each chain on which the two differ with the reason: the store -keeps no past, the cut is under the chain's horizon, or the stage that reads the store at a cut -is not built. For example, on an instance where the interpreted relation edges do not yet keep +asker's grant names (§6.3), and each chain on which the two differ with the reason: the store keeps +no past, the cut is under the chain's horizon, or the stage that reads the store at a cut is not +built. Where the filter withheld rows because a chain was read low, the note says of which store and +how many. For example, on an instance where the interpreted relation edges do not yet keep generations: ``` @@ -1206,7 +1295,7 @@ The mode of a clause follows from its scope (`core/query.py:273-281`). | semantic | `near`, `diffuse S`, `reach S`, `relate` | the heads of the clause's classes, from the log; their vectors by content address and the lexical index for the pending ones (§5.2, §5.3); the backbone recomputed among them | SN-4; `relate` SN-6 | | structural | `reach F`, `diffuse F`, `walk` over `F` | the citation reading of the cut's commit, as projected at or under the cut (§5.1) | today for a commit projected once; SN-4 for one projected again | | temporal | `trace`, `reach D`, `walk` over `D`, `changed` (§7.4) | the history served of the identity at the cut (§6.2): the log's rows of the identity at or under the cut, after its last retire | SN-4; `changed` SN-8 | -| causal | `reach C`, `walk` over `C`, `witness` | the causal fiber recomputed at the cut (§5.5); an attestation at or under the cut on `att` | SN-5 | +| causal | `reach C`, `walk` over `C`, `witness` | the causal fiber recomputed at the cut (§5.5); an attestation kept at the cut on `att` (§3.5) | SN-5 | | species | at a cut | |---|---| @@ -1232,8 +1321,9 @@ The mode of a clause follows from its scope (`core/query.py:273-281`). the version before it (`stateAt_holes_of_erased`); a sealed identity reads as nothing (§6). A transcript turn: the chat log's row when its number is at or under the cut. A curated row: what landed through the catalog as a note is; a row with no landing is not read (§5.6). -- **`witness`.** The record when it lies inside the cut: an attestation by its number on `att`, a - causal edge by its turn and its commit, a citation edge by its commit. +- **`witness`.** The record when it lies inside the cut: an attestation by its number on `att`, + and a pass attestation only when the landings it read are inside the cut as well (§3.5); a + causal edge by its turn and its commit; a citation edge by its commit. - **`assume`.** The overlay applied to the universe of the cut read: a hypothetical at a past cut. - **`do`.** A request is a whole sentence and takes no adjective (`core/sentence/grammar.py:4-5`), so it cannot be written under `as of`: a write has no past. @@ -1313,12 +1403,14 @@ So the horizon is recorded, and a cut under it is not served. recorded cut (§3.3). It only advances. - **What a question before it gets.** The chain is read at the greatest position it serves at or under the one asked, which under a horizon is its empty prefix, and the answer says the cut - is under the chain's horizon and names the first cut the chain serves. Every other chain is - read as asked: the chains that have a horizon above a recorded position are chains no recorded - bound reads, so each is lowered alone (§7.1, `resolvesIn_of_unread`). What follows a lowered - landing chain is the rows about it: an interpreted row whose sources are not heads at the cut - read is withheld by its own filter (§5.4). A sentence all of whose chains are under their - horizons returns the note and no hit. + is under the chain's horizon and names the first cut the chain serves. Every other chain but + one is read as asked. Among the references the resolver follows, a chain that has a horizon + above a recorded position is read by the chain of records alone, so each such chain is + lowered alone and the chain of records with them, to its last record that the cut read holds + (§7.1, `resolvesIn_of_followed`). What else follows a lowered landing chain is the rows about + it, by the filter and not by position: a pass attestation, a dream claim, an interpreted row + or a claim op whose sources are not inside the cut read is withheld (§3.5, §5.4). A sentence + all of whose chains are under their horizons returns the note and no hit. - **What that means today.** A commit read before the log exists resolves, on every chain but `repo`, under the horizon: `as of` such a commit reads the citation graph and the repository's files at the commit and nothing else. For a commit projected once, and held by the checkout, @@ -1387,7 +1479,9 @@ served and incomplete (the discipline of PLN-4, where a cache is stale only by e `[DERIVED]` The attestation ledger and the version chains are not pruned: they are the audit record, they are small, and they have no delete. That the ledger keeps every position is also what §7.1 rests on: `att` is the one chain every landing reads, so a horizon on it would take -the landing chains down with it. +the landing chains down with it. The converse is why a pass attestation's reference to a +landing is filtered and not resolved (§3.5): resolved, a history window on one landing chain +would lower `att`, and through it every other landing chain. A window is counted in events because wall time orders nothing (Law C4): the last ten thousand landings of a class, not the last ninety days. It is one position a chain, not a number of @@ -1427,11 +1521,12 @@ as of a cut is the fold of the prefix, continued from a kept checkpoint over the dn-utility-field: the field's clock is a chain of the cut, `use`, and the field as of a cut is then exact. Two more things follow. -- **The use log has a natural horizon.** A site left alone returns within `ε` of its baseline - after `log(c/(lam ε))/lam` ticks (UTL-2, `idle_window`), so a horizon that far behind the head, - with the field's state at the horizon kept, is exact from the horizon on and loses nothing a - reader of the present could see. No other chain reads the use log, so a cut under its horizon - lowers that chain and no other (§7.1). `[DERIVED from UTL-2, SNP-3 and SNP-10]` +- **The use log has a natural horizon.** A site left alone returns within `ε` of its baseline after + `log(c/(lam ε))/lam` ticks (UTL-2, `idle_window`), so a horizon that far behind the head, with the + field's state at the horizon kept, is exact from the horizon on and loses nothing a reader of the + present could see. No chain but the chain of records reads the use log, so a cut under its horizon + lowers that chain, the chain of records with it, and no other (§7.1). `[DERIVED from UTL-2, SNP-3 + and SNP-10]` - **The field could order what retention drops.** The order a pass drops in is by age: the oldest closed versions first. When a window forces a choice among the derived rows of superseded versions, the ones whose sites stand at the baseline were not used for anything @@ -1447,21 +1542,23 @@ now. The Lean names are in `formal/Palace/Snapshot.lean`, the attacks and contro it is a theorem and what holds because the model was built that way, since the second kind passes to the code only as an obligation of the stage that transcribes it. -- **SNP-1 append invariance.** A read at a cut inside the store, a read between two such cuts - and every derived view are unchanged by any growth of the store (`readAt_grow`, - `readAt_of_extends`, `readBetween_grow`, `appendInvariant_view`), also under an erasure and a - grant (`visible_grow`, `snapshot_grow`, `shown_grow`) and for the keyed forms (`stateAt_append`, - `genRead_gens_append`). By construction: a store is a family of lists, so growth is append - and nothing else. That the code's stores only append below a cut is what the stage's test - checks. Controls: the reader that ignores the cut (`Witness.present_not_appendInvariant`); a - read at a cut past the head (431, 487, 488). Attacks 430, 432, 446. The test, at SN-1: over - random sequences of catalog writes, `read_at(chain, c)` and `state_at` of every path at `c`, - taken after every further write, equal the ones taken when `c` was the head. +- **SNP-1 append invariance.** A read at a cut inside the store, a read between two such cuts and + every derived view are unchanged by any growth of the store (`readAt_grow`, `readAt_of_extends`, + `readBetween_grow`, `appendInvariant_view`), also under an erasure and a grant (`visible_grow`, + `snapshot_grow`, `shown_grow`), for the keyed forms (`stateAt_append`, `genRead_gens_append`) and + for the filtered read of SNP-8 (`kept_grown_iff`). By construction: a store is a family of lists, + so growth is append and nothing else. That the code's stores only append below a cut is what the + stage's test checks. Controls: the reader that ignores the cut + (`Witness.present_not_appendInvariant`); a read at a cut past the head (431, 487, 488). Attacks + 430, 432, 446. The test, at SN-1: over random sequences of catalog writes, `read_at(chain, c)` and + `state_at` of every path at `c`, taken after every further write, equal the ones taken when `c` + was the head. - **SNP-2 monotonicity.** The read at an earlier cut is a prefix, chain by chain, of the read at a later one, and a cut of a cut is the meet (`readAt_mono`, `mem_readAt_of_le`, - `readAt_readAt`, `head_readAt`, `visible_mono`). Controls: the read at one cut taken for a + `readAt_readAt`, `head_readAt`, `visible_mono`), and the filtered read of SNP-8 grows with + the cut (`Kept.mono`). Controls: the read at one cut taken for a prefix of the read at any other (434); a cut of a cut taken for the join (500). Attacks 433, - 435. The test, at SN-1: for `a ≤ b`, `read_at(chain, a)` is a prefix of `read_at(chain, b)`. + 435, 515. The test, at SN-1: for `a ≤ b`, `read_at(chain, a)` is a prefix of `read_at(chain, b)`. - **SNP-3 composition.** The read at `a` followed by the read between `a` and `b` is the read at `b`, and two adjacent reads-between compose (`readAt_append_readBetween`, `readBetween_append`); a fold continued from a checkpoint over the delta is the fold of the prefix @@ -1536,10 +1633,24 @@ passes to the code only as an obligation of the stage that transcribes it. `Consistent.of_bound`). The consistent cuts are CLK-2's cuts among the frontier cuts (`consistent_iff_isCut`), so their closure under meet and join is CLK-2, cited and not claimed here (`Consistent.inf`, `Consistent.sup` and `consistentCuts`, derived from - `Clock.IsCut.frontier_inf` and `Clock.IsCut.frontier_sup`; `consistent_zero` for the bottom). Controls: a frontier - taken for a cut (462); a consistent cut advanced by one position (464); resolution taken to - fall as the frontier rises (490). Attacks 461, 463, 465. The test, at SN-2: the resolver - against enumeration on small stores, and no recorded cut with a reference crossing it. + `Clock.IsCut.frontier_inf` and `Clock.IsCut.frontier_sup`; `consistent_zero` for the bottom). + The references the resolver does not follow are kept by a filter of the read: a row is + withheld when it fails its own test, when a source of it lies outside the cut or when a + source of it is withheld. The filtered read holds the sources of its rows, is the greatest + such set inside the cut, is the prefix at a cut consistent for every reference, and never + withholds a row whose references are all resolved (`Kept.source`, `Kept.passes`, + `kept_of_closed`, `kept_iff_of_consistent`, `kept_of_resolved`, on `Withheld.anti` and + `Withheld.of_grown`). By construction: which references are resolved and which filtered is + the design's reading of the writers (§3.5), and that every reader of `att`, `runs` and the + `interp` chains at a cut goes through the filter is the stages' to transcribe. Controls: a + frontier taken for a cut (462); a consistent cut advanced by one position (464); resolution + taken to fall as the frontier rises (490); a pass attestation's reference resolved, which + lowers a landing chain that serves its position (`Witness.pass_drags`); the prefix read where + that reference is filtered, which is not closed (`Witness.pass_withheld`, 518); the filter + without its closure (517). Attacks 461, 463, 465, 514, 516. The test, at SN-2: the resolver + against enumeration on small stores, and no recorded cut with a resolved reference crossing + it; at SN-5 and SN-6: at every cut, no row served whose source, by any reference of §3.5, is + outside the cut or withheld, and at the head no row withheld that the present read returns. - **SNP-9 certified cuts.** A certificate verifies on every extension of the store; under a collision-free digest two stores that verify one certificate have the same prefix of every digested chain at its cut and the same derived views of it; a certificate extends over the @@ -1559,41 +1670,44 @@ passes to the code only as an obligation of the stage that transcribes it. Attacks 466, 467, 469, 470, 471. The test, at SN-2: a certificate verifies after any further writes, on a copy of the files and after a purge, and fails when one row under the cut is edited or a chain is given another id. -- **SNP-10 the horizon.** A generational store pruned at a horizon is exact at every cut from - the horizon on and never wrong under it; horizons compose to the later one; pruning commutes - with a later landing (`genRead_prune`, `genRead_prune_gens`, `stateAt_of_genRead_prune`, - `prune_prune`, `prune_landGen`). Among the positions the chains serve, every frontier resolves - to exactly one greatest consistent cut, which never passes the cut asked and rises with the - frontier and with served positions that grow (`exists_resolvesIn`, `ResolvesIn.unique`, - `ResolvesIn.mono`, `ResolvesIn.le_resolves`, `resolvesIn_univ`, `resolvesIn_self`). A chain - that no other chain reads is lowered alone, and so is every such chain at once - (`Consistent.update_of_unread`, `resolvesIn_update_of_unread`, `resolvesIn_of_unread`). +- **SNP-10 the horizon.** A generational store pruned at a horizon is exact at every cut from the + horizon on and never wrong under it; horizons compose to the later one; pruning commutes with a + later landing (`genRead_prune`, `genRead_prune_gens`, `stateAt_of_genRead_prune`, `prune_prune`, + `prune_landGen`). Among the positions the chains serve, every frontier resolves to exactly one + greatest consistent cut, which never passes the cut asked and rises with the frontier and with + served positions that grow (`exists_resolvesIn`, `ResolvesIn.unique`, `ResolvesIn.mono`, + `ResolvesIn.le_resolves`, `resolvesIn_univ`, `resolvesIn_self`). A chain that no other chain reads + is lowered alone, and so is every such chain at once (`Consistent.update_of_unread`, + `resolvesIn_update_of_unread`, `resolvesIn_of_unread`); a chain that reads the lowered chains, and + that nothing but itself reads, follows them and takes nothing with it (`resolvesIn_of_followed`). Controls: the pruned store read under its horizon, which cannot tell a lost key from one never written (`Witness.prune_forgets`, `Witness.prune_indistinct`, 480); a record on a chain that - content reads (`Witness.record_drags`); a chain that others read lowered alone (499); served - positions that shrink (`Witness.served_set_shrinks`, 507); a frontier lowered to the served - positions without the descent (483); the floor and the descent each run once, in either order - (493, 494); pruning at the earlier of two horizons (491); the cut read taken to reach the - floor, or the resolution of the frontier (506, 508). Attacks 478, 479, 481, 482, 484, 485, - 486, 492, 498. The test, at SN-2: the served resolver against enumeration; at SN-4: the cut - read is under the cut asked on every chain, and at a recorded cut it differs from the record - only on chains that could not serve; at SN-7: every read at a cut from the horizon on is the - same before and after a retention pass. - -What the model leaves out, said plainly. A chain is a list and a store a family of lists: one -writer is assumed, and nothing is said of two. Events are opaque, and so is the stores' SQL. The -set of chain keys is fixed: a relabel is not in the model, which is why a chain has an id that a -relabel does not change (§3.1). The hash's collision freedom and the commitment's binding are -hypotheses of SNP-9 (`CollisionFree`, an injective `commit`), not theorems about SHA-256. The -`unseal` and `horizon` events are not in the model of the seal, and the owner's gate on them is -the code's. There is no single reader in the model that applies the cut's resolution, the -grant, the erasure and the seal together: `shown` composes the grant and the erasure over one -read, the seal is stated on a keyed chain, and the resolution on cuts; the sentence's reader -applies the resolution first, then `shown`, then the seal to each keyed read, and that order is -the code's to transcribe. The row filter of an interpreted chain (§3.5) is a derived view, not a -prefix. A repository history with merges is covered by CLK-2's down-sets and not by the chain -model (§3.1). The resolver, the descent and its alternation with the floor, is attacked, not -proved. + content reads (`Witness.record_drags`); a chain of records taken to be read as recorded when a + chain it certifies is lowered (`Witness.record_follows`, 520); a chain that others read lowered + alone (499); served positions that shrink (`Witness.served_set_shrinks`, 507); a frontier lowered + to the served positions without the descent (483); the floor and the descent each run once, in + either order (493, 494); pruning at the earlier of two horizons (491); the cut read taken to reach + the floor, or the resolution of the frontier (506, 508). Attacks 478, 479, 481, 482, 484, 485, + 486, 492, 498, 519. The test, at SN-2: the served resolver against enumeration; at SN-4: the cut + read is under the cut asked on every chain, and at a recorded cut it differs from the record only + on the chains that could not serve and on the chain of records; at SN-7: every read at a cut from + the horizon on is the same before and after a retention pass. + +What the model leaves out, said plainly. A chain is a list and a store a family of lists: one writer +is assumed, and nothing is said of two. Events are opaque, and so is the stores' SQL. The set of +chain keys is fixed: a relabel is not in the model, which is why a chain has an id that a relabel +does not change (§3.1). The hash's collision freedom and the commitment's binding are hypotheses of +SNP-9 (`CollisionFree`, an injective `commit`), not theorems about SHA-256. The `unseal` and +`horizon` events are not in the model of the seal, and the owner's gate on them is the code's. There +is no single reader in the model that applies the cut's resolution, the grant, the erasure and the +seal together: `shown` composes the grant and the erasure over one read, the seal is stated on a +keyed chain, and the resolution on cuts; the sentence's reader applies the resolution first, then +`shown`, then the seal to each keyed read, and that order is the code's to transcribe. The row +filter of §3.5 is in the model as `Kept`, with the reads-from relation and each row's own test as +parameters; what the code's rows read is §3.5's reading of the writers and no theorem, and the bound +a pass attestation records is argued there, not proved. The filtered read is a derived view, not a +prefix. A repository history with merges is covered by CLK-2's down-sets and not by the chain model +(§3.1). The resolver, the descent and its alternation with the floor, is attacked, not proved. ## 11. Measurements @@ -1687,17 +1801,19 @@ property-testing the transcription against the Lean statements; the laws a stage Rollback: the tables are additive and unread, so dropping them restores the file; a build that stops writing them and resumes later appends a `horizon`. -- **SN-2 cuts.** The chain tables, each with its running hash and its genesis followed by a - horizon, for `chat`, `att`, `staging` and `runs`; `att_head` filled from then on; the - extractor's version and the projection's position on `att` stamped on new citation edges, - the edges already held stamped with the genesis; the `cuts` table of §3.3, a record at a +- **SN-2 cuts.** The chain tables, each with its running hash and its genesis followed by a horizon, + for `chat`, `att`, `staging` and `runs`; `att_head` filled from then on; on the chain-table row of + a pass attestation and of a run, the landing chains that held its inputs and the head of each + (§3.5); the extractor's version and the projection's position on `att` stamped on new citation + edges, the edges already held stamped with the genesis; the `cuts` table of §3.3, a record at a trough that moved and on command, and an attestor method that builds and signs an attestation without appending it; the four names, with every name that resolves to nothing refused; the resolver of §3.5, the floor and the descent alternated; a command, `mind-palace cut` with `record`, `list` and `verify`. Tests: SNP-8 and SNP-9 as stated; the served resolver against - enumeration; a record refused inside a job. SNP-8 enters the ledger as resolution, with its - closure cited to CLK-2's row, and SNP-9 with it. Rollback: additive tables and columns; the - names fall back to today's. + enumeration; a record refused inside a job, and refused with jobs queued and no daemon; a cut read + below a record on one chain reading the chain of records at its last record under it. SNP-8 enters + the ledger as resolution, with its closure cited to CLK-2's row, and SNP-9 with it. Rollback: + additive tables and columns; the names fall back to today's. - **SN-3 the erasure's reach and the seal.** A purge removes the lexical units, nulls the version rows' digests, removes the relation edges and artifacts that name the digest, opens the curated store, nulls the support and text of the dream claims and the digest and payload @@ -1717,24 +1833,32 @@ property-testing the transcription against the Lean statements; the laws a stage the commit on a `read` hit. Tests: `as of "head"` against no `as of` over the query battery (`eval/query_battery.py`); a sentence at a recorded cut asked before and after unrelated landings and after a re-projection; SNP-6 with two grants, as §10 states it; the cut read - under the cut asked, and equal to the record but for the chains that could not serve. - Rollback: one configuration switch under `[query]`, off being today's behaviour. + under the cut asked, and equal to the record but for the chains that could not serve and the + chain of records. Rollback: one configuration switch under `[query]`, off being today's behaviour. - **SN-5 the causal fiber at a cut.** The recomputation of §5.5 with its memo; edges named by - session, order and endpoint; the transcript integrator's checkpoint a cut on `chat` and `repo`. - Tests: the two job orders giving one result; the prefix that ends before a result; the stored - rows at the head equal to the recomputation. Rollback: the stored rows stay the head's cache. + session, order and endpoint; the transcript integrator's checkpoint a cut on `chat` and `repo`; + `witness` at a cut, the ledger read by sequence number with the pass attestations filtered (§3.5). + Tests: the two job orders giving one result; the prefix that ends before a result; the stored rows + at the head equal to the recomputation; a pass attestation withheld at a cut that lacks a landing + it read, the attestations after it served, and none withheld at the head. Rollback: the stored + rows stay the head's cache. - **SN-6 model output by generation.** A sequence number, a running hash and a history table - for the interpreted artifacts and the interpreted relation edges, a chain each, and a - sequence number for the claim ops and the authored supersessions; the authored relations - recomputed at a cut; `relate` at a cut; a kept row served only with its sources and its - attestation inside the cut (§5.4). Tests: SNP-5 on random sequences of writes and - replacements; `mem_serve_iff`'s test; an artifact replaced over the same titles served with + for the interpreted artifacts and the interpreted relation edges, a chain each; a sequence + number and a running hash for the claim ops and the authored supersessions, which need no + history table since no row of theirs is replaced; the authored relations recomputed at a cut; + `relate` at a cut; a kept row served only with its sources inside the cut and its attestation + kept there, a claim op only with the artifacts it names, a dream claim only with its run + (§3.5, §5.4). Tests: SNP-5 on random sequences of writes and replacements; `mem_serve_iff`'s + test; SNP-8's filter as §10 states it; an artifact replaced over the same titles served with the sources each generation had. Rollback: additive columns and tables. - **SN-7 retention.** The two windows a chain in the instance's configuration; the pass of §9.2; the `horizon` row; the horizon in the answers. Tests: SNP-10 as stated; a pass killed at each step leaving no served position incomplete; a derived row dropped under the first window reported pending and derived again; a cut asked under a landing chain's new horizon read with - every other chain as recorded. Rollback: none for dropped rows by their nature; nothing runs + every other landing chain, `att` and `repo` as recorded, the chain of records at its last + record under the cut read, and the rows that read a landing of the lowered chain withheld; + after a pass, `verify` of the chain passing from its first row and a certificate taken before + the pass still verifying. Rollback: none for dropped rows by their nature; nothing runs unless a window is declared. - **SN-8 the delta.** `changed between` and `changed since` (§7.4); the integrator interface below. Tests: the region's union law, and equal reads at both cuts for an identity outside it. @@ -1787,7 +1911,10 @@ give, and what each alternative costs is the answers it changes, which the entry today it does not (§2.3, item 8). 4. **D4, a store that cannot serve the cut asked.** Recommended: read at the greatest consistent cut among the positions the stores serve, and name it (§7.1). With the recorded cuts on a - chain of their own (D13) that lowers only the chains that could not serve. The alternatives: + chain of their own (D13), and the rows that read a landing without being its record filtered + and not resolved (§3.5), that lowers only the chains that could not serve and the chain of + records; the rows that read what was lowered are withheld and counted in the answer's note. + The alternatives: refuse the sentence, after which `as of` answers nothing that touches a store without a past until SN-6, and nothing under a horizon ever; or keep today's behaviour, which answers from after the cut and changes as the store grows. @@ -1849,8 +1976,9 @@ give, and what each alternative costs is the answers it changes, which the entry instance keeps, and each is licensed with its own pull request. The alternative, all eight at once, saves the owner seven decisions and reviews the purge, the universe and retention together. -13. **D13, where a recorded cut is kept.** Recommended: a chain of its own that nothing reads, - its attestation in its own row (§3.3). The alternative, a row of the attestation ledger, +13. **D13, where a recorded cut is kept.** Recommended: a chain of its own that no other chain + reads, its attestation in its own row (§3.3). That chain is read at its last record under + the cut read, and takes nothing with it. The alternative, a row of the attestation ledger, is one table fewer and signs a record where every other attestation is signed; but every landing reads that ledger, so a chain read below a position a record certified, as a landing chain behind a history window is, can take every landing chain to its empty prefix @@ -1919,10 +2047,16 @@ give, and what each alternative costs is the answers it changes, which the entry - **SNF-14 (the region is not what is asked):** questions about change that need the two readings and cannot be put with the region. Then GD-4's form is built sooner, on the two readings this note supplies. -- **SNF-15 (a lowering is not local):** at a recorded cut, a chain read below the record though - it serves the record's position. Then some chain that can fail to serve is read through a - recorded bound, the premise of §7.1 is false for it, and that reference is found and moved - off the resolver's bounds or the chain is kept whole. +- **SNF-15 (a lowering is not local):** at a recorded cut, a chain other than the chain of + records read below the record though it serves the record's position. Then some chain that + can fail to serve is read through a resolved reference by a chain that content reads, the + premise of §7.1 is false for it, and that reference is found and moved to the filter of §3.5 + or the chain is kept whole. +- **SNF-16 (a filtered row is served without its source):** at some cut, a pass attestation, a + dream claim, an interpreted row or a claim op served while a row it reads, by a reference of + §3.5 or one that list missed, is outside the cut or withheld. Then the list of §3.5 is + incomplete or a reader goes around the filter, and the stage that reads that store at a cut + does not land until it is closed. ## Open questions @@ -1947,14 +2081,14 @@ Each with the default the stages build on until it is decided. `stateOf`, `stateAt`, `lastWrite`, `Gen`, `closeAt`, `landGen`, `gens`, `selects`, `genRead`, `prune`, `sealedAt`, `servedAt`, `servedNow`, `restrict`, `snapshot`, `redact`, `visible`, `compact`, `serve`, `committed`, `purge`, `commitments`, `contents`, `Consistent`, `generator`, -`reached`, `Resolves`, `reachedIn`, `ResolvesIn`, `chainDigest`, `CollisionFree`, `Certificate`, -`certify`, `Verifies`, and `sinceRetire`, `historyAt`, `holes`, `shown`); -`formal/Palace/Snapshot.lean` (the declarations §10 names, by law, and the fifteen `Witness` -controls); `formal/PalaceTest/Snapshot.lean` (seeds 430 to 513); the families cited: +`reached`, `Resolves`, `reachedIn`, `ResolvesIn`, `Withheld`, `Kept`, `chainDigest`, +`CollisionFree`, `Certificate`, `certify`, `Verifies`, and `sinceRetire`, `historyAt`, `holes`, +`shown`); `formal/Palace/Snapshot.lean` (the declarations §10 names, by law, and the eighteen +`Witness` controls); `formal/PalaceTest/Snapshot.lean` (seeds 430 to 520); the families cited: `Palace/Clock.lean` (CLK-2: `IsCut`, `frontierCut`, `isCut_iff_not_crossed`, `IsCut.inter`, -`IsCut.union`, `IsCut.frontier_inf`, `IsCut.frontier_sup`), `Palace/Ingress.lean` (ING-7), `Palace/Script.lean` (ING-17), -`Palace/Derived.lean` (ING-19 to ING-21), `Palace/Plane.lean` (PLN-4), `Palace/Utility.lean` -(UTL-2, UTL-4), `Palace/Sentence.lean` (QSA-1 to QSA-4, QSA-10). +`IsCut.union`, `IsCut.frontier_inf`, `IsCut.frontier_sup`), `Palace/Ingress.lean` (ING-7), +`Palace/Script.lean` (ING-17), `Palace/Derived.lean` (ING-19 to ING-21), `Palace/Plane.lean` +(PLN-4), `Palace/Utility.lean` (UTL-2, UTL-4), `Palace/Sentence.lean` (QSA-1 to QSA-4, QSA-10). **Code (read at `e3e3ee47`, unchanged):** `core/sentence/grammar.py`, `ast.py`, `universe.py`, `execute.py` (`as of`, the universe, `read`); `core/query.py` (the modes, `note_graph`); From 9d64ac255ec948d48c3f5f22b31148098ca84041 Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 08:14:43 -0500 Subject: [PATCH 29/37] docs(design): two citations in dn-temporal-snapshot held to the text The projection's attestation is emitted at code_sensor.py:498-499; the lines cited minted the edges. Section 3.6 said the claim ops and the authored supersessions are hashed from SN-6, which gave them a sequence number only: SN-6 now gives each a running hash, and 3.6 says so. Co-Authored-By: Claude Fable 5.2 --- docs/design-notes/dn-temporal-snapshot.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/design-notes/dn-temporal-snapshot.md b/docs/design-notes/dn-temporal-snapshot.md index 99e7b3a1..6e104a56 100644 --- a/docs/design-notes/dn-temporal-snapshot.md +++ b/docs/design-notes/dn-temporal-snapshot.md @@ -571,7 +571,7 @@ references between the chains of §3.1 are these. `[ESTABLISHED: read off the wr the order the writer lands them in (`core/ingest/writer.py:397-436`: the version, the attestation, the key last); - the attestation of a sensed commit, and of a projection of it, reads from the commit - (`ops/code_sensor.py:413-418`, `:489-492`); + (`ops/code_sensor.py:413-418`, `:498-499`); - a citation edge reads from its commit and from the projection that wrote it; - a recorded cut reads from the prefix of every chain it certifies and from the record before it, and no row of another chain reads a recorded cut; @@ -711,8 +711,10 @@ The certificate of a cut is, for each chain, the digest of its prefix under the **Which chains have a hash.** A landing chain from SN-1, as the `hash` of the row at the position. `repo` always: the commit's sha is git's own chain. `chat`, `att`, `staging` and -`runs` from SN-2, as the running hash of the chain table added beside each. The `interp` chains -and `decl` from SN-6, and `use` with the stage that builds the field. A record carries a digest +`runs` from SN-2, as the running hash of the chain table added beside each. The `interp` chains, +the claim ops among them, and `decl` from SN-6, which gives each a sequence number and a +running hash over its rows' content, the wall bookmark left out; and `use` with the stage that +builds the field. A record carries a digest for each chain that has a hash when it is taken and a null for the others, and `verify` says which chains it checked. Until a chain is hashed, a recorded cut fixes its position and nothing about its rows, and the two conclusions below do not reach a view that reads it. `[INFERENCE]` From 5380ee9428473f0cb16e42ea9bc175e6b26e309a Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 08:14:43 -0500 Subject: [PATCH 30/37] docs(design): what a record certifies, and a command with no daemon The handoff certificate, as the spine sources it, is the emptiness of two directories of one sensing handoff, not of every spool and handoff the note lists; a cut does not need those empty, since what they hold has not landed. The trough certificate needs no job queued as well as none running, so the owner's command with no daemon is served at once only on an empty queue. Co-Authored-By: Claude Fable 5.2 --- docs/design-notes/dn-temporal-snapshot.md | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/docs/design-notes/dn-temporal-snapshot.md b/docs/design-notes/dn-temporal-snapshot.md index 6e104a56..4c401e60 100644 --- a/docs/design-notes/dn-temporal-snapshot.md +++ b/docs/design-notes/dn-temporal-snapshot.md @@ -122,8 +122,14 @@ and state files hold what is in flight: the ingress spools with their receipts (`core/ingest/table.py:276`, `ops/heartbeat.py:298`), the two sensing handoffs (`ops/code_sensor.py:862`, `ops/self_sensor.py:345`), a stream source's cursor (`core/ingest/stream.py:30`) and the heartbeat's tick files (`ops/heartbeat.py:76`). A recorded -cut is taken when the handoff is empty (§3.3), which is the statement that none of it is in -flight; one of them keeps text, the rejected requests, and §6.1 names it for the purge. +cut does not certify that these are empty. Its handoff certificate, as the spine sources it, is +that the `requests/` and `observations/` directories of the one sensing handoff it is given +hold nothing (`core/temporal/spine.py:218`, `:283-286`, `:1090-1103`), and its trough +certificate that no job is queued or running (§3.3). The code and agent sensing handoffs are +other directories, and the ingress spools and the dialogue handoff are not looked at. A cut +does not need them to be empty: what a spool or a handoff holds has not landed, so it is an +event of no chain, no sentence reads it, and when it lands it lands at a position after the +cut. One of them keeps text, the rejected requests, and §6.1 names it for the purge. ### 1.4 What is proved, what is measured, what is open @@ -477,11 +483,18 @@ repository backs; trough quiescence, an empty queue with no queued and no runnin (`core/temporal/spine.py:197-206`), which certifies that no causality of the core is in flight; and the empty handoff, which certifies that nothing is in flight between the edge and the core. A cut across strata composes the three, and the spine refuses a cut whose certificate it cannot -source (`spine.py:275-281`, `:1064-1084`). `[ESTABLISHED]` +source (`spine.py:275-281`, `:1064-1084`). As the spine sources it, the handoff certificate is +the emptiness of the two directories of the one sensing handoff it is given (`spine.py:218`, +`:283-286`, `:1090-1103`); §1.3 says what that leaves unlooked at, and why a cut does not need +it. `[ESTABLISHED]` So a cut is recorded at a trough and at no other moment. Two things ask for one: the trough itself, when the queue and the handoff are empty and the frontier moved since the last record; -and the owner's command, which is served at the next trough, or at once when no daemon runs. The +and the owner's command, which is served at the next trough. With no daemon running that is at +once only when no job is queued. A landing through the writer enqueues jobs +(`core/ingest/writer.py:203`, `:555`), and the trough certificate needs none queued as well as +none running (`spine.py:197-206`), so with jobs queued and nothing running to take them the +spine refuses the cut: the command says so and records nothing until the queue is drained. The sensor reading a commit does not record a cut: it reads inside its job (`ops/code_sensor.py:404-418`), where the trough certificate is refused. A record names the newest commit of the ledger as its `repo` position, so it covers every commit sensed since the From f598f61c51048c509756907ec539cc4aa7ebaae6 Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 08:14:43 -0500 Subject: [PATCH 31/37] docs(design): the claim ops and the dispositions as the code has them The claim ops are appended by a store that calls no model, and by design they are a model's proposals, through an analyzer whose default proposes none; no caller outside the tests applies one at e3e3ee47. The verdict dispositions are append-only, one row a verdict, and belong with the ledgers, not with the stores rewritten in place. Co-Authored-By: Claude Fable 5.2 --- docs/design-notes/dn-temporal-snapshot.md | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/docs/design-notes/dn-temporal-snapshot.md b/docs/design-notes/dn-temporal-snapshot.md index 4c401e60..1dd4ddde 100644 --- a/docs/design-notes/dn-temporal-snapshot.md +++ b/docs/design-notes/dn-temporal-snapshot.md @@ -213,7 +213,8 @@ the state files are left out, each with its reason (§1.3). | code and agent observations, current readings (`core/stores/code_observations.py:246`, `core/stores/agent_observations.py:205`) with their history (`core/stores/observation_history.py:46-56`) | the interpreter's generation per identity | (store, identity, interpreter) | nothing: a superseding write archives the old generation first, and it is never dropped (`code_observations.py:211-254`); a reset wipes the current readings and keeps the history (`ops/lifecycle/launcher.py:1765`, `:1776`, `:111-118`). This is generations as built, the form §5.4 takes | | run ledger, verdicts (`core/stores/runledger.py:140`, `:161`; `core/stores/verdicts.py:145`) | insertion order | the row's id | nothing; a dream claim keeps the digests it rests on and its surface text (`runledger.py:90-97`) | | structural snapshots (`core/complex/temporal.py:41-58`, `:208`) | a sequence of its own, one row a dream pass (`core/dreaming/dreamer.py:288`) | `snapshot_id` | nothing: invariants of the graph as it stood at the pass, appended | -| claim ops (`core/stores/claim_ops.py:40-48`) | none: `at` is wall time | a hash of (kind, claim, related, text) (`core/kernel/recursion_ops.py:134-135`) | nothing but the bookmark: a row is keyed by its whole content, so the `INSERT OR REPLACE` of a second application (`claim_ops.py:73`) only stamps `at` again. An append-only set with no position; no model writes it (`claim_ops.py:14-15`) | +| claim ops (`core/stores/claim_ops.py:40-48`) | none: `at` is wall time | a hash of (kind, claim, related, text) (`core/kernel/recursion_ops.py:134-135`) | nothing but the bookmark: a row is keyed by its whole content, so the `INSERT OR REPLACE` of a second application (`claim_ops.py:73`) only stamps `at` again. An append-only set with no position. The store calls no model (`claim_ops.py:14-15`), and its rows are by design a model's proposals: extracting the operations from a dialogue is a model task behind an injected analyzer whose default proposes none (`core/kernel/recursion_ops.py:44-46`), and at `e3e3ee47` no caller outside the tests applies an operation. A supersede names the conclusion artifact the same call writes (`claim_ops.py:45`, `:161-163`) | +| verdict dispositions (`core/verdict/dispositions.py:59-64`) | the verdict's sequence number | `verdict_seq` | nothing but the bookmark: append-only, one row a verdict, the latest winning by subject (`dispositions.py:4-6`); a second application of one verdict replaces the row with the same subject and effect and stamps `at` again (`dispositions.py:82-87`) | | authored supersessions (`core/stores/authored_supersession.py:112-120`) | none: `at` is wall time | the pair (superseded, superseding) | the bookmark and the note of an earlier declaration of the same pair (`authored_supersession.py:159-161`); owner-declared, never model output (`:150-157`). An append-only set with no position | | staging (`core/stores/staging.py:118-138`) | its own generation clock | the generation | a sweep stamps `tombstoned_at_gen` and the row stays; `read_at(g)` exists (`staging.py:232-244`) | | query log (`core/sentence/surface.py:93`) | line order | the line | nothing | @@ -238,7 +239,6 @@ the state files are left out, each with its reason (§1.3). | causal edges (`core/stores/causal_edges.py:51-61`) | `event_order` and `witness_turn`, on each row | the edge's id, a hash that includes the transcript's digest (`causal_edges.py:71-76`) | the session's rows are deleted and written again (`causal_edges.py:130-154`), under new ids when the session grew; what they were before the commit ledger gained a commit | | interpreted artifacts and hyperedges (`core/stores/derived.py:49-60`) | none: `created_at` is wall time | a hash of the kind, the subkind and the sorted subjects, which are note titles (`derived.py:55`, `:97-100`) | the artifact a later pass over the same titles replaced (`derived.py:209-216`), whatever versions of those notes each pass read: model output, not recomputable. What a row was built from is its `derived_from`, note digests or other artifacts' ids (`derived.py:186-189`); it records no run, only the attestation that produced it (`derived.py:59`) | | relation edges (`core/stores/edges.py:37-46`) | none: `created_at` is wall time | hash of (u, v, relation), the two ends content digests | the weight, sign and provenance a re-assertion replaced (`edges.py:88-106`). Two producers, kept apart by provenance (`core/relations.py:7-16`): authored edges read off a note's own `supports::`, `contradicts::` and `contextualizes::` properties (`relations.py:140-158`), a function of the note's text and so recomputable; and interpreted edges from a model (`relations.py:192-210`) or a `link` request (`core/ingest/writer.py:521-535`), which never replace an authored one (`writer.py:526-530`) | -| verdict dispositions (`core/verdict/dispositions.py:59-64`) | the verdict's sequence number | `verdict_seq` | the row a second application replaced (`dispositions.py:86`); a fold of the verdict ledger, so recomputable from its prefix | ### 2.3 What the two-class picture misses @@ -845,7 +845,7 @@ table is built that way, and §5.2 says why its versions are not the snapshot. | interpreted artifacts with their hyperedges, interpreted relation edges | a model's output: of nothing that can be computed again | generations, the replaced row archived with its interval | one archived row a replacement, which is thrown away today; how often a row is replaced is not measured | a measured churn so low that declaring them outside the snapshot loses nothing | | the relations a note declares | the note's text at a version, and the titles the catalog resolves at the cut | recomputed from the heads at the cut | one parse of a note's properties a head that has any, kept in a memo by digest; no bytes | nothing | | claim ops, authored supersessions | nothing: they are appended, keyed by their content | a position a first insert; the read at a cut is the rows at or under it | one integer a row | nothing | -| verdict dispositions | the verdict ledger | recomputed from the ledger's prefix | a fold over the verdicts inside the cut | nothing | +| verdict dispositions | nothing: one row a verdict, appended (§2.2) | the key is the position: the read at a cut is the rows whose `verdict_seq` is at or under the cut on the verdicts' own sequence, each served with the claim it is about (§3.5) | nothing new | nothing | | the similarity backbone | the vectors of the support | recomputed, as today | nothing | nothing | | citation readings | the tree at the commit and the extractor that projected it | append-only rows, as built, each stamped with the extractor's version and the position on `att` of the projection that wrote it; the reading of a commit at a cut is its rows stamped at or under the cut | one integer and a short string a row, on 3,029,562 rows over 1,487 commits at 567 bytes a row in the repository's records | the store's size: then a row valid over a range of commits (SN-b) | | code memberships | git's blob at the path | version-keyed by blob; git's tree selects the version | nothing new | nothing | @@ -929,10 +929,17 @@ property parsed from the raw object the log names, the title resolved among the cut. Nothing is stored and the edge has its note's class. `[DERIVED from SNP-5]` **Claim ops and authored supersessions** are not rewritten in place. Each row is keyed by its -whole content (§2.2), so a second write stamps a bookmark and changes nothing else, and no -model writes either (`core/stores/claim_ops.py:14-15`; the supersessions are the owner's -declarations). They are append-only sets that lack a position. Each gets a sequence number at a -row's first insert, and the read at a cut is the rows at or under it. `[DERIVED]` +whole content (§2.2), so a second write stamps a bookmark and changes nothing else. The +supersessions are the owner's declarations. The claim ops are appended by a store that calls no +model (`core/stores/claim_ops.py:14-15`), and what it appends is by design a model's proposal: +extracting the operations from a dialogue is a model task behind an analyzer whose default +proposes none (`core/kernel/recursion_ops.py:44-46`), and at `e3e3ee47` no caller outside the +tests applies one. So the claim ops are rows of the class `interpreted` (§3.1). The storage +choice does not depend on who proposes them: both stores are append-only sets that lack a +position, each gets a sequence number at a row's first insert, and the read at a cut is the +rows at or under it. A claim op is further filtered by what it names, the claim it acts on and, +for a supersede, the conclusion artifact the same call wrote (`claim_ops.py:45`, `:161-163`): +it is served when those are (§3.5). `[DERIVED]` **Interpreted artifacts and interpreted relation edges** are model output: written by a pass that calls a model or by a `link` request (`core/relations.py:192-210`, From 15c9c269aced86b5b111f3a97a3d63ce6052c065 Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 08:14:43 -0500 Subject: [PATCH 32/37] docs(design): a history window empties the log's rows and deletes none The rows a window dropped and the rows still alive under the horizon interleave, so there was no last row dropped whose hash could seed the chain, and no column to hold one. A window now empties a closed row to its position, its closing stamp, its commitment and its hash. The chain is hashed from its first row for as long as it lives, every certificate keeps verifying, and the reads see an emptied row as a dropped one. Co-Authored-By: Claude Fable 5.2 --- docs/design-notes/dn-temporal-snapshot.md | 56 ++++++++++++++++------- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/docs/design-notes/dn-temporal-snapshot.md b/docs/design-notes/dn-temporal-snapshot.md index 1dd4ddde..57f16fca 100644 --- a/docs/design-notes/dn-temporal-snapshot.md +++ b/docs/design-notes/dn-temporal-snapshot.md @@ -435,8 +435,9 @@ JSON (keys sorted, no white space, UTF-8) of the object with the fields `chain`, `source_path`, `doc_id`, `version`, `digest`, `title`, `att_head`, `ref_lo`, `ref_hi` and `at`. `closed_at` is out, since it is written later, and so is `path_key`, which is an index key. `hash` is SHA-256 over the previous row's `hash` followed by the commitment; the first row's -previous hash is 32 zero bytes, and after a history window (§9.2) it is the hash of the last row -dropped, kept in the `horizon` row. The chain is hashed like the prediction ledger +previous hash is 32 zero bytes. No row is ever deleted, by a purge or by a history window: both +empty rows and keep their commitments and hashes (§6.1, §9.2), so the chain is hashed from its +first row for as long as it lives. The chain is hashed like the prediction ledger (`eval/predictions/ledger.py:1-12`), with one difference that §6.1 needs: a row's hash covers a commitment to the row and not the row, so a purge can empty the row and keep the chain (`commitments_purge`, `verifies_purge`). `[THEOREM: SNP-9]` @@ -1415,9 +1416,11 @@ was never there: two chains can leave the same pruned store where, at one cut un horizon, a key held a value in the first and had never been written in the second (`Witness.prune_indistinct`). Two horizons are the later one (`prune_prune`). `[THEOREM: SNP-10]` The journal form says the same of a fold: continued from the state kept at the -horizon over the events since, it is the fold of the whole prefix (`foldAt_readBetween`), and the -chain's digest at the horizon, kept as the seed, lets every certificate from the horizon on -verify (`certify_digest_readBetween`). `[THEOREM: SNP-3, SNP-9]` +horizon over the events since, it is the fold of the whole prefix (`foldAt_readBetween`), and +for a chain that drops its prefix whole, as the use log does, the chain's digest at the horizon, +kept as the seed, lets every certificate from the horizon on verify +(`certify_digest_readBetween`). `[THEOREM: SNP-3, SNP-9]` The landing log needs no seed: a +window empties its rows and keeps their commitments, so it is hashed from its first row (§9.2). So the horizon is recorded, and a cut under it is not served. @@ -1489,11 +1492,26 @@ A chain can declare two windows, each in positions, and a retention pass runs at derived again (§9.3). - **A window for the history.** The chain's horizon moves to the later of the horizon in force and the head less the window. A `horizon` row is appended first, so the positions under it are - unserved from that moment; then the derived rows still under it, the raw objects no retained - row names, and the log's rows closed at or under it are dropped, the chain's digest at the - horizon kept as its seed. - -The second is an exception to the rule that raw objects are kept + unserved from that moment; then the derived rows still under it and the raw objects no + retained row names are dropped, and the log's rows closed at or under it are emptied. + +**What a window leaves of a row.** An emptied row keeps `chain`, `seq`, `kind`, `closed_at`, +`commitment` and `hash`, and loses every other field, its key included. No row of the log is +deleted. The rows closed at or under a horizon and the rows still alive there interleave, and a +row at the horizon's position is never closed under it, so with rows deleted there would be no +last row dropped whose hash could seed the rest, and the hashes of the rows kept under the +horizon could not be computed again. With the commitments kept, `verify` runs from the first +row as it does on a chain that was never pruned (§3.2), every certificate keeps verifying, as +after a purge (`verifies_purge`), and a row still alive under the horizon is checked like any +other, by its commitment and by the chain. For the reads an emptied row is a dropped one +(`genRead_prune_gens`): it has no key, so no seek by path finds it, and it needs none, since a +row closed at or under the horizon is the last event of its path at no cut from the horizon on; +its closing stamp keeps it out of the heads at those cuts. `[THEOREM: SNP-9 for the chain, +SNP-10 for the reads; DERIVED for the key]` By arithmetic, not measured: an emptied row is +about 100 bytes, two 32-byte hashes, the kind, three integers and its entry of the closing +index, against the 396 to 434 measured for a whole one. + +The window for the history is an exception to the rule that raw objects are kept (`core/kernel/stores/rawstore.py:1-8`), which only the owner's purge makes today, so it is the owner's to declare. Its order is the one the stores use for a cache: the horizon is declared first, so a crash in the middle leaves rows that are no longer served, never a position that is @@ -1517,7 +1535,9 @@ The default instance declares neither window and keeps everything; by the arithm log is megabytes a year and its superseded derived rows about a gigabyte a year at a hundred landings a day. An instance that must bound its disk declares the first window, which frees those derived rows and moves no horizon. The second frees, beyond that, only the raw objects -and the log's rows of the closed versions, and it is declared only by the owner (D8). +and about three quarters of the bytes of the log's rows of the closed versions, and it is +declared only by the owner (D8). At the cuts a chain no longer serves it also withholds every +pass attestation, dream claim and interpreted row that read a landing of that chain (§7.1). ### 9.3 Lazy landing, in time @@ -1769,8 +1789,8 @@ the runs is given where they differed. `[MEASURED]` | `read` under `as of` | the same fakes, one reading at a commit of the checkout fourteen back and one at a sha of forty `d`s that git does not hold | at the commit git holds: that commit's blob and not the head's, under a note saying that `read` read the present, the hit carrying no commit; at the sha git does not hold: `HEAD`'s blob, the same note, the same hit | | row numbering | a table keyed by text, five rows, in a temporary file | after the last row was deleted the next insert was numbered 5 again; a vacuum after a delete in the middle kept the numbers | -Not measured: anything on an instance's own stores; the size of a recorded cut and of a chain -table's row, which are arithmetic; how often a row of model output is replaced; the lexical +Not measured: anything on an instance's own stores; the size of a recorded cut, of a chain +table's row and of a row of the log that a window emptied, which are arithmetic; how often a row of model output is replaced; the lexical statistics computed from a mask at a corpus's size; the causal fiber recomputed over a real instance's sessions, cold or warm; a vector search with superseded rows joined to the heads at a cut; the reads of the chat log and the attestation ledger through their chain tables; a @@ -1957,9 +1977,11 @@ give, and what each alternative costs is the answers it changes, which the entry a window for derived rows, which moves no horizon and frees what a superseded version mostly costs, about 29 kilobytes of derived rows for a note of four chunks by §9.1's arithmetic; and a window for the history only when the owner declares one, since it drops raw objects - (§9.2). The alternatives: a horizon everywhere, which over the first window frees only a - closed version's raw bytes and its 0.4 kilobytes of log, and loses the default instance's - history for it; that trade is worth making only where raw objects are large, as a transcript + (§9.2), and at the cuts under the new horizon withholds every pass attestation, dream claim + and interpreted row that read a landing of the chain. The alternatives: a horizon + everywhere, which over the first window frees only a closed version's raw bytes and about + 0.3 of its 0.4 kilobytes of log, by arithmetic, and loses the default instance's history for + it; that trade is worth making only where raw objects are large, as a transcript retained whole at each growth is (0.79 MB a growth on the fixture). Or the last `n` versions an identity, which leaves no horizon to name. 9. **D9, the attestation ledger under a purge.** It still names a purged digest (§6.1), against @@ -2021,7 +2043,7 @@ give, and what each alternative costs is the answers it changes, which the entry | SN-d | a second embedder identity's vectors kept beside the first | none: the present's identity | dn-two-phase-ingestion's open question 4 | | SN-e | lexical statistics stored per class and per recorded cut | computed from the mask | a lexical query at a past cut over its budget | | SN-f | `repo` as a graph of commits, and a chain a repository | the line of the branch the sensor reads, one repository | an instance whose history has merges or that reads several repositories | -| SN-g | which recorded cuts are kept under a horizon | the records stay as attested claims; their chains' rows go | a consumer that must verify a cut under a horizon | +| SN-g | which recorded cuts are kept under a horizon | the records stay; a landing chain keeps its commitments and hashes, so a record under its horizon still verifies there and reads nothing | a consumer that must read, and not only verify, a cut under a horizon | | SN-h | generations with a diff for the causal fiber | recomputation with a memo | SNF-5 | | SN-i | the curated rows written outside the catalog | outside the snapshot, counted in the answer's note (§5.6) | the script routed through the writer | | SN-j | a date asked under a narrower grant | resolved over every record, the answer showing the record's id and its positions on the grant's chains only | a use that must hide when the instance was quiescent | From 6fded32b1af5371123fb4ddddd93347e09c5cae8 Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 08:15:23 -0500 Subject: [PATCH 33/37] docs(paper): the snapshot article with the filtered read The article said each row that reads another chain records that chain's head and that only the chains which cannot serve are lowered. Three references are resolved through recorded bounds; a pass attestation and a row of model output read landings too and are withheld by a filter, stated with SNP-8; the chain of records follows the chains it certifies, stated with SNP-10. A record on the ledger can take a landing chain down, as the control shows, not every one. The attack runs an alternation equivalent to Algorithm 1. A history window empties the log's rows and keeps their commitments. Counts from this tree's run of check.sh; ten pages. Co-Authored-By: Claude Fable 5.2 --- papers/2026-11-10-temporal-snapshot/paper.tex | 104 +++++++++--------- 1 file changed, 53 insertions(+), 51 deletions(-) diff --git a/papers/2026-11-10-temporal-snapshot/paper.tex b/papers/2026-11-10-temporal-snapshot/paper.tex index dcdd8195..920a724d 100644 --- a/papers/2026-11-10-temporal-snapshot/paper.tex +++ b/papers/2026-11-10-temporal-snapshot/paper.tex @@ -62,8 +62,8 @@ \section{Introduction} The system is a personal knowledge store \cite{serranocalva2026palace}: notes, dialogue, papers and code land through one writer into a dozen stores (content-addressed raw objects, a catalog from paths to content, version chains, a chat log, attestations, a vector plane, a lexical index, edge -stores), and a sentence of a small query algebra reads them. A sentence may carry -\texttt{as of ""}. Today that adjective moves one relation. The citation graph, which is +stores), and a sentence of a query algebra reads them. A sentence may carry +\texttt{as of ""}. Today it moves one relation. The citation graph, which is stored by commit, is read at the commit named, and a file of the repository is read as that commit's blob; every other read is of the present, and the answer says so. @@ -77,7 +77,7 @@ \section{Introduction} \begin{enumerate} \item A model (\Cref{sec:model}) of a multi-store as a family of append chains with cuts, reads at and between cuts, derived views, a grant, an erasure and certificates. -\item Ten laws (\Cref{sec:laws}), SNP-1 to SNP-10, machine-checked as 162 theorems, with fifteen +\item Ten laws (\Cref{sec:laws}), SNP-1 to SNP-10, machine-checked as 175 theorems, with eighteen failure modes as theorems too, among them the reader that ignores the cut, the store rewritten in place, a filter applied before the cut, an erasure that deletes rows, a hole that loses its key, a digest with collisions, a pruned store read under its horizon, and a record of a cut @@ -101,8 +101,8 @@ \section{Background and related work} lattice \cite{birkhoff1937rings,davey2002lattices}. The store's own clock design already takes a cut to be a down-set of a derived event order with a per-store frontier, and its ledger of laws already has their closure under meet and join. Here there is one writer, so no marker protocol -is needed; what is needed is the greatest consistent cut under a frontier that a name selects, -and its behaviour when some stores cannot serve a position. +is needed; what is needed is the greatest consistent cut under a named frontier, also when a +store cannot serve a position. \paragraph{Temporal and multiversion data.} Temporal databases keep rows valid over a period, and system-versioned tables answer a query as @@ -114,9 +114,9 @@ \section{Background and related work} two cuts is that input here. \paragraph{Hash chains and commitments.} -A hash chain makes an append-only history tamper-evident +A hash chain makes an append history tamper-evident \cite{merkle1987signature,haber1991timestamp}. A chain over contents cannot survive an erasure of -content, and a plain hash of erased content is a test for that content. A salted commitment +content, and a plain hash of erased content is a test for it. A salted commitment \cite{halevi1996commitment} whose salt is destroyed avoids both (\Cref{thm:cert}). \paragraph{Noninterference.} @@ -271,6 +271,8 @@ \section{The laws}\label{sec:laws} in the frontier. If growth only adds references that start at or past the old head, a consistent cut inside the old head stays consistent. If every source of an event lies at or under a recorded one on its chain, a cut consistent for the recorded references is consistent for $R$. +Withholding from a cut every row with a source outside it or withheld leaves a set that holds +the sources of its rows, the greatest such, and the whole prefix when the cut is consistent. \end{theorem} \begin{proof}[Sketch] The down-set form is the clock's cut criterion, no generator edge crossing @@ -280,7 +282,7 @@ \section{The laws}\label{sec:laws} of the positions reached by consistent cuts under $f$: it is attained, and a source of an event under it is under the witness's position on the source's chain (\lean{exists_resolves}, \lean{Resolves.unique}, \lean{Resolves.mono}, \lean{Consistent.of_grown}, -\lean{Consistent.of_bound}). +\lean{Consistent.of_bound}, \lean{Kept.source}, \lean{kept_of_closed}). \end{proof} \begin{theorem}[SNP-9: certificates]\label{thm:cert} @@ -316,9 +318,11 @@ \section{The laws}\label{sec:laws} $S_k$ contains $0$, every frontier $f$ is resolved among the served positions by exactly one cut; that cut lies under the resolution of $f$, equals it when every position is served, and rises with $f$ and with served sets that grow. If $f$ is consistent, the chains in a set $U$ are read -by no chain but themselves, and every chain outside $U$ serves its position, then the cut is $f$ -with each chain of $U$ at the greatest position it serves at or under $f$. Without the -hypothesis on $U$ that fails: one chain read low can take every other chain to its empty prefix. +only by themselves and by chains of a set $V$ that only themselves read, and every other chain +serves its position, then the cut is $f$ with each chain of $U$ at the greatest position it +serves at or under $f$, and each chain of $V$ at the greatest it serves whose events read $U$ +inside those positions. Without the hypothesis on $U$ that fails: one chain read low can take +every other chain to its empty prefix. \end{theorem} \begin{proof}[Sketch] A row alive at $c \ge h$ has no closing stamp at or under $h$, so pruning removes no row a read @@ -330,9 +334,9 @@ \section{The laws}\label{sec:laws} cuts: the supremum on a chain is attained by one of them, so it is served (\lean{exists_resolvesIn}, \lean{ResolvesIn.unique}, \lean{ResolvesIn.mono}, \lean{ResolvesIn.le_resolves}, \lean{resolvesIn_univ}). Lowering an unread chain breaks no -reference, and no served consistent cut under $f$ is higher (\lean{resolvesIn_of_unread}). The -controls are \lean{Witness.record_drags} and, for sets that shrink, -\lean{Witness.served_set_shrinks}. +reference, and no served consistent cut under $f$ is higher (\lean{resolvesIn_of_unread}, +\lean{resolvesIn_of_followed}). The controls are \lean{Witness.record_drags}, +\lean{Witness.record_follows} and, for sets that shrink, \lean{Witness.served_set_shrinks}. \end{proof} \section{The design}\label{sec:design} @@ -343,7 +347,7 @@ \section{The design}\label{sec:design} path to the content it holds and the idempotence key of every landing, is rewritten in place: an upsert, a tombstone flag, a delete. Version chains exist for one of four places; elsewhere the attestation ledger names a digest and no path, once per action and digest; so for most items the -sequence of contents a path held is recorded nowhere. Meanwhile the vector plane and the lexical index, which +sequence of contents a path held is recorded nowhere. The vector plane and the lexical index, which the picture calls rewritten, keep every version's rows and move a flag. They are generations without a clock. A clock on their rows would be wrong, since a path that returns to earlier bytes makes the same rows current again, so a version's rows are valid on a set of intervals. The fix @@ -353,22 +357,24 @@ \section{The design}\label{sec:design} written by the catalog's own methods in the transaction of the row they write. A chain has an id and its class is a label, so relabelling a class moves no row and breaks no certificate. The catalog is then the fold of the log (\Cref{thm:forms}), and every version-keyed store has a -past: the log says which version a cut holds. +past: the log names the version at a cut. \paragraph{Cuts, names, certificates.} A cut is one position per chain, about a dozen integers: the landing chains, the chat log, the attestations, the repository's commit, the generations of model output. It is not a position per -document, which is millions of pairs on a large instance and adds nothing, since a frontier cut -needs only its cross-store references checked. A cut is recorded, with the digest of every +document, which is millions of pairs on a large instance. A cut is recorded, with the digest of every hashed prefix, when the writer's queue and its handoff are empty, and attested. The records form -a chain of their own that no event reads: every landing reads the attestation ledger, so a -record placed there would, by \Cref{thm:horizon}, take every landing chain down with any chain -read below a position it certified. The adjective takes \texttt{head}, a record's id, a commit +a chain of their own that no other chain reads: every landing reads the attestation ledger, so +a record placed there can, by \Cref{thm:horizon}, take a landing chain to its empty prefix with +any chain read below a position it certified. The adjective takes \texttt{head}, a record's id, a commit (the first record that holds it, with the repository lowered to the commit and resolved), or a date, which selects the last record whose wall bookmark is not later. Wall time is a lookup key -there and orders nothing. Each row that reads another chain records that chain's head at its -writing, which bounds its sources because there is one writer (\Cref{thm:lattice}); the resolver -compares those bounds. +there and orders nothing. The resolver follows three references, each through a recorded bound +that is sound because there is one writer (\Cref{thm:lattice}): a landing's to the attestation +ledger, an attestation's to its commit, a record's to its frontier. A pass's attestation and a +row of model output read landings too; resolved, they would lower the ledger and every landing +chain with it (\lean{Witness.pass_drags}), so the filter of \Cref{thm:lattice} withholds them +from the read instead. \begin{algorithm}[t] \caption{The cut a read under \texttt{as of} is taken at. $S_k$: the positions chain $k$ serves. @@ -424,8 +430,9 @@ \section{The design}\label{sec:design} A store may be unable to serve the cut asked: it keeps no past yet, or the cut is under its horizon. The read is then taken at the cut \Cref{alg:resolve} returns, which by \Cref{thm:horizon} exists, is unique, never lies after the cut asked and rises as stores gain a -past. Every chain that can fail to serve a recorded cut is read by no recorded bound, so only -those chains are lowered. The answer is exact for that cut and names it, chain by chain, with +past. A chain that can fail to serve a recorded cut is read, by resolved references, only by +the chain of records, so only those chains and the records' are lowered, and the rows that read +them are withheld. The answer is exact for that cut and names it, chain by chain, with the reason wherever it differs from the cut asked. Reading such a store at the present instead, which is what the executor does today, is the reader \Cref{thm:append} refutes. At the head the read is the present (\Cref{thm:compose}), so \texttt{as of "head"} is the sentence without the adjective. @@ -434,10 +441,10 @@ \section{The design}\label{sec:design} A chain's horizon is set by the genesis of its log, by retention, or by a reset. Retention is counted in positions and has two levels. The derived rows of old versions can be dropped without moving a horizon: they are cache entries of a function of content, a cut that asks for one finds -it pending, and it is derived again from the raw object. Moving the horizon drops raw objects and -the log's rows, which only the store's owner declares. That pass appends a horizon row first, so -a crash leaves rows that are unserved, never a position that is served and incomplete, and it -keeps the digest at the horizon as the chain's seed. A window counted per identity (the last $n$ +it pending, and it is derived again from the raw object. Moving the horizon drops raw objects +and empties the log's rows closed under it, which only the store's owner declares. That pass +appends a horizon row first, so a crash leaves rows that are unserved, never a position that is +served and incomplete, and it keeps every commitment, so the chain verifies from its first row. A window counted per identity (the last $n$ versions of each) would leave no horizon to record. \section{Evaluation}\label{sec:eval} @@ -445,33 +452,31 @@ \section{Evaluation}\label{sec:eval} \paragraph{What is proved.} \Cref{thm:append,thm:compose,thm:forms,thm:grant,thm:erase,thm:lattice,thm:cert,thm:horizon} are machine-checked in \lean{formal/Palace/Snapshot.lean} over \lean{formal/Palace/Snapshot/Defs.lean} -on Lean~4 \cite{moura2021lean4}, v4.36.0-rc2, and the Mathlib \cite{mathlib2020} it pins: 162 -theorems, fifteen of them the controls, no -\lean{sorry}, and the axioms of all 5{,}176 library declarations audited (\lean{propext}, -\lean{Classical.choice}, \lean{Quot.sound} only). The library's export, 56{,}159 declarations +on Lean~4 \cite{moura2021lean4}, v4.36.0-rc2, and the Mathlib \cite{mathlib2020} it pins: 175 +theorems, eighteen of them the controls, no +\lean{sorry}, and the axioms of all 5{,}213 library declarations audited (\lean{propext}, +\lean{Classical.choice}, \lean{Quot.sound} only). The library's export, 56{,}188 declarations from \lean{Init} up, is replayed by Lean's kernel and five independent checkers. These are design theorems: no code relies on them yet, so they are not among the 328 statements the library restates separately and judges against its ledger of laws. \paragraph{The attacks.} The definitions compute, so they are attacked as they are with property-based testing -(\lean{formal/PalaceTest/Snapshot.lean}, seeds 430 to 513, 500 draws each): stores of two chains +(\lean{formal/PalaceTest/Snapshot.lean}, seeds 430 to 520, 500 draws each): stores of two chains over three events, keyed chains over three keys, chains of landings and retires, grants and erasures from bit masks, reads-from relations as edge lists, a base-four digest, served positions -from ten bits. Forty-five attacks survive every draw. \Cref{alg:resolve}, which the library does -not define, is run as written, the floor and the descent alternated, and agrees on every draw -with the pointwise maximum of every consistent served cut under the frontier. Thirty-nine -controls are refuted within 53 draws: among them a read at a cut past the head, generations +from ten bits. Forty-nine attacks survive every draw. \Cref{alg:resolve}, which the library +does not define, is run as an equivalent alternation, every chain floored and then one pass of +the descent, and agrees on every draw with the pointwise maximum of every consistent served cut +under the frontier. Forty-two controls are refuted within 61 draws: among them a read at a cut past the head, generations without the closing stamp, an event filter before the cut, an erasure that deletes rows, a seek -over rows that lost their key, the state served without the seal, an additive digest, the pruned -store read under its horizon, a chain that others read lowered alone, and the floor and the +over rows that lost their key, an additive digest, the pruned store read under its horizon, a chain that others read lowered alone, and the floor and the descent each run once, in either order. \paragraph{What is measured.} All on synthetic fixtures built by each probe, on one machine (Apple M2 Pro, SQLite 3.54.1, LanceDB 0.33.0), with other work running; no instance was read. The probes are not in the -repository, which holds no code for this design yet; the design note describes each fixture, and -each build stage commits its harness. \Cref{tab:measure} gives the figures. +repository; the design note describes each fixture, and each build stage commits its harness. \Cref{tab:measure} gives the figures. \begin{table}[t] \centering @@ -525,21 +530,18 @@ \section{Limitations} \section{Future work} -The build is eight stages, each shipped with its tests and its rollback: the landing log; +The build is eight stages, each with its tests and its rollback: the landing log; recorded cuts, names and the resolver; the erasure's reach and the seal; the notes, vectors and lexical index at a cut; the causal edges at a cut; model output by generation; retention; and -the delta between two cuts, as a region and as the input of jobs whose checkpoint is a cut. Each -stage transcribes its laws and property-tests the transcription against the Lean statements, at -which point the laws enter the ledger. +the delta between two cuts. Each stage property-tests its transcription against the Lean +statements, and its laws then enter the ledger. \section{Conclusion} A snapshot of a store with many stores is a prefix of each chain at a consistent cut, read through the present's grant and the present's erasure. Stated that way its properties are -theorems: it does not change as the store grows, it composes with the delta, every derived store -that can be read at a cut is a function of the prefixes, and an incomplete history has one best -cut under any cut asked. The same statements located what the code lacked, a ledger of the -catalog's past, and what it must not do: answer a question about the past from the present. +theorems, and the same statements located what the code lacked, a ledger of the catalog's past, +and what it must not do: answer a question about the past from the present. \bibliographystyle{plainnat} \bibliography{refs} From 124222524c2704d70b239d3efabc50206b437b25 Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 08:15:23 -0500 Subject: [PATCH 34/37] docs(readme): the Lean counts from this tree's check.sh run 1,520 theorems, 227 attacks and 203 controls, 25,426 lines of models and proofs and 5,705 of attacks, 56,188 declarations replayed. The tests badge is not touched: no Python changed. Co-Authored-By: Claude Fable 5.2 --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 71fad18f..e023f26f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Lean statements](https://img.shields.io/badge/Lean-328_statements_judged-blue)](formal/README.md) [![sorry](https://img.shields.io/badge/sorry-0-brightgreen)](formal/sorry-budget) [![kernels](https://img.shields.io/badge/kernel_replay-6_checkers-6f42c1)](formal/check.sh) -[![attacks](https://img.shields.io/badge/attacks-223_with_controls-blue)](formal/PalaceTest) +[![attacks](https://img.shields.io/badge/attacks-227_with_controls-blue)](formal/PalaceTest) [![tests](https://img.shields.io/badge/tests-3633-brightgreen)](docs/runbook.md) [![coverage](https://img.shields.io/badge/coverage-77%25-green)](pyproject.toml) [![mypy](https://img.shields.io/badge/mypy-0_errors_in_core-brightgreen)](pyproject.toml) @@ -121,12 +121,12 @@ A law has one row in [`docs/LAWS.md`](docs/LAWS.md): its statement, the structur | | | |---|---| | toolchain | Lean `v4.36.0-rc2`, Mathlib; Plausible for the attacks | -| the library | 38 proof modules, 37 models, 26 statement files; 25,129 lines of models and proofs, 3,460 of statements, 5,623 of attacks | -| theorems | 1,507 proved in `formal/Palace`; 328 statements in `formal/Spec` judged identical by the comparator | +| the library | 38 proof modules, 37 models, 26 statement files; 25,426 lines of models and proofs, 3,460 of statements, 5,705 of attacks | +| theorems | 1,520 proved in `formal/Palace`; 328 statements in `formal/Spec` judged identical by the comparator | | the ledger | 100 rows in 15 families, 334 cited declarations, 87 law markers checked against the rows | -| attacks | 223 Plausible attacks and 200 negative controls over 33 modules, fixed seeds | +| attacks | 227 Plausible attacks and 203 negative controls over 33 modules, fixed seeds | | axioms | `propext`, `Classical.choice`, `Quot.sound`; `sorry` 0 | -| the replay | 56,159 declarations accepted by all six checkers on the run of `formal/check.sh` this commit was built with | +| the replay | 56,188 declarations accepted by all six checkers on the run of `formal/check.sh` this commit was built with | | families | memberships · Laplacian, balance and spectral · cut and conductance · curvature · the global event clock · the shared prose plane · capability scopes · the abstraction ultrametric σ* · bridges · the retrieval curve · the query sentence algebra · the ingress · stored vectors · the growth readout · the utility field | ## The mathematics From c0bba0eb9f54821539ca16b9b0555ce8abffef68 Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 08:16:12 -0500 Subject: [PATCH 35/37] docs(design): a claim op's filter in the table of derived stores The table of section 5.1 still gave the claim ops' read at a cut as the rows at or under it. A claim op is served with what it names, as 3.5 and 5.4 now say. Two paragraphs are wrapped again after the last edits. Co-Authored-By: Claude Fable 5.2 --- docs/design-notes/dn-temporal-snapshot.md | 26 +++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/design-notes/dn-temporal-snapshot.md b/docs/design-notes/dn-temporal-snapshot.md index 57f16fca..aae1636e 100644 --- a/docs/design-notes/dn-temporal-snapshot.md +++ b/docs/design-notes/dn-temporal-snapshot.md @@ -845,7 +845,7 @@ table is built that way, and §5.2 says why its versions are not the snapshot. | chat events, causal edges | the transcript as retained at the cut, and the commits inside the cut | recomputed at the cut, the present rows a cache of the head | 6 ms a session of 2,000 records `[MEASURED §11]`; no bytes | a sentence that walks the causal fiber at a past cut over a second on a real instance (SNF-5): then generations, written with a diff | | interpreted artifacts with their hyperedges, interpreted relation edges | a model's output: of nothing that can be computed again | generations, the replaced row archived with its interval | one archived row a replacement, which is thrown away today; how often a row is replaced is not measured | a measured churn so low that declaring them outside the snapshot loses nothing | | the relations a note declares | the note's text at a version, and the titles the catalog resolves at the cut | recomputed from the heads at the cut | one parse of a note's properties a head that has any, kept in a memo by digest; no bytes | nothing | -| claim ops, authored supersessions | nothing: they are appended, keyed by their content | a position a first insert; the read at a cut is the rows at or under it | one integer a row | nothing | +| claim ops, authored supersessions | nothing: they are appended, keyed by their content | a position a first insert; the read at a cut is the rows at or under it, a claim op served with what it names (§3.5) | one integer a row | nothing | | verdict dispositions | nothing: one row a verdict, appended (§2.2) | the key is the position: the read at a cut is the rows whose `verdict_seq` is at or under the cut on the verdicts' own sequence, each served with the claim it is about (§3.5) | nothing new | nothing | | the similarity backbone | the vectors of the support | recomputed, as today | nothing | nothing | | citation readings | the tree at the commit and the extractor that projected it | append-only rows, as built, each stamped with the extractor's version and the position on `att` of the projection that wrote it; the reading of a commit at a cut is its rows stamped at or under the cut | one integer and a short string a row, on 3,029,562 rows over 1,487 commits at 567 bytes a row in the repository's records | the store's size: then a row valid over a range of commits (SN-b) | @@ -1595,12 +1595,12 @@ passes to the code only as an obligation of the stage that transcribes it. 430, 432, 446. The test, at SN-1: over random sequences of catalog writes, `read_at(chain, c)` and `state_at` of every path at `c`, taken after every further write, equal the ones taken when `c` was the head. -- **SNP-2 monotonicity.** The read at an earlier cut is a prefix, chain by chain, of the read at - a later one, and a cut of a cut is the meet (`readAt_mono`, `mem_readAt_of_le`, - `readAt_readAt`, `head_readAt`, `visible_mono`), and the filtered read of SNP-8 grows with - the cut (`Kept.mono`). Controls: the read at one cut taken for a - prefix of the read at any other (434); a cut of a cut taken for the join (500). Attacks 433, - 435, 515. The test, at SN-1: for `a ≤ b`, `read_at(chain, a)` is a prefix of `read_at(chain, b)`. +- **SNP-2 monotonicity.** The read at an earlier cut is a prefix, chain by chain, of the read at a + later one, and a cut of a cut is the meet (`readAt_mono`, `mem_readAt_of_le`, `readAt_readAt`, + `head_readAt`, `visible_mono`), and the filtered read of SNP-8 grows with the cut (`Kept.mono`). + Controls: the read at one cut taken for a prefix of the read at any other (434); a cut of a cut + taken for the join (500). Attacks 433, 435, 515. The test, at SN-1: for `a ≤ b`, + `read_at(chain, a)` is a prefix of `read_at(chain, b)`. - **SNP-3 composition.** The read at `a` followed by the read between `a` and `b` is the read at `b`, and two adjacent reads-between compose (`readAt_append_readBetween`, `readBetween_append`); a fold continued from a checkpoint over the delta is the fold of the prefix @@ -1789,12 +1789,12 @@ the runs is given where they differed. `[MEASURED]` | `read` under `as of` | the same fakes, one reading at a commit of the checkout fourteen back and one at a sha of forty `d`s that git does not hold | at the commit git holds: that commit's blob and not the head's, under a note saying that `read` read the present, the hit carrying no commit; at the sha git does not hold: `HEAD`'s blob, the same note, the same hit | | row numbering | a table keyed by text, five rows, in a temporary file | after the last row was deleted the next insert was numbered 5 again; a vacuum after a delete in the middle kept the numbers | -Not measured: anything on an instance's own stores; the size of a recorded cut, of a chain -table's row and of a row of the log that a window emptied, which are arithmetic; how often a row of model output is replaced; the lexical -statistics computed from a mask at a corpus's size; the causal fiber recomputed over a real -instance's sessions, cold or warm; a vector search with superseded rows joined to the heads at a -cut; the reads of the chat log and the attestation ledger through their chain tables; a -retention pass. Each is the measurement of the stage that builds it. +Not measured: anything on an instance's own stores; the size of a recorded cut, of a chain table's +row and of a row of the log that a window emptied, which are arithmetic; how often a row of model +output is replaced; the lexical statistics computed from a mask at a corpus's size; the causal fiber +recomputed over a real instance's sessions, cold or warm; a vector search with superseded rows +joined to the heads at a cut; the reads of the chat log and the attestation ledger through their +chain tables; a retention pass. Each is the measurement of the stage that builds it. ## 12. The build order From 3c789df8154334691270d5b1f4d6dfbd1f8c12bc Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 11:23:02 -0500 Subject: [PATCH 36/37] docs(design): a citation edge among the resolved references The list of references in section 3.5 counts four resolved ones and section 7.1 names three that the resolver follows between chains. Say why: a citation edge is a row of no chain and is read by its stamps on the repository and the attestation ledger. Co-Authored-By: Claude Fable 5.2 --- docs/design-notes/dn-temporal-snapshot.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/design-notes/dn-temporal-snapshot.md b/docs/design-notes/dn-temporal-snapshot.md index aae1636e..bba4177e 100644 --- a/docs/design-notes/dn-temporal-snapshot.md +++ b/docs/design-notes/dn-temporal-snapshot.md @@ -606,7 +606,9 @@ references between the chains of §3.1 are these. `[ESTABLISHED: read off the wr (`core/verdict/dispositions.py:59-64`). The first four are **resolved**: the resolver follows them, and the cut read is consistent for -them. The last four are **filtered**: the resolver does not follow them, and a row that has one +them. Three of them join chains of §3.1. A citation edge is a row of no chain: it is read by its +stamps, which are positions on `repo` and `att` (§5.1), so a cut that holds its stamps holds its +sources. The last four are **filtered**: the resolver does not follow them, and a row that has one is served at a cut only when its sources are. Both are taken up below, after the definition. A causal edge reads from the turn that witnessed it and, when it ends at a commit, from the From ed745223585dd9f57e63a78252d3ee94a12d8dd4 Mon Sep 17 00:00:00 2001 From: Alberto Serrano-Calva Date: Wed, 11 Nov 2026 11:23:02 -0500 Subject: [PATCH 37/37] docs(paper): what a resolved pass reference can take down The control shows one other landing chain lowered through the ledger, not every landing chain. Say what it shows. Co-Authored-By: Claude Fable 5.2 --- papers/2026-11-10-temporal-snapshot/paper.tex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/papers/2026-11-10-temporal-snapshot/paper.tex b/papers/2026-11-10-temporal-snapshot/paper.tex index 920a724d..53aa204a 100644 --- a/papers/2026-11-10-temporal-snapshot/paper.tex +++ b/papers/2026-11-10-temporal-snapshot/paper.tex @@ -372,8 +372,8 @@ \section{The design}\label{sec:design} there and orders nothing. The resolver follows three references, each through a recorded bound that is sound because there is one writer (\Cref{thm:lattice}): a landing's to the attestation ledger, an attestation's to its commit, a record's to its frontier. A pass's attestation and a -row of model output read landings too; resolved, they would lower the ledger and every landing -chain with it (\lean{Witness.pass_drags}), so the filter of \Cref{thm:lattice} withholds them +row of model output read landings too; resolved, they would lower the ledger, and that can take +another landing chain down (\lean{Witness.pass_drags}), so the filter of \Cref{thm:lattice} withholds them from the read instead. \begin{algorithm}[t]