|
| 1 | += Decoration bridge — candidate instance sketches |
| 2 | +:toc: macro |
| 3 | +:toclevels: 2 |
| 4 | +:sectnums: |
| 5 | +:sectnumlevels: 2 |
| 6 | +:icons: font |
| 7 | +:source-highlighter: rouge |
| 8 | + |
| 9 | +[CAUTION] |
| 10 | +==== |
| 11 | +Exploratory pseudocode. Not committed Agda. Each candidate is an |
| 12 | +*analogy that may or may not fit* the `Choreo × Graded` shape that |
| 13 | +`EchoIntegration` integrates, with an explicit falsifier. Failure to |
| 14 | +fit retires the candidate; success commits nothing beyond the |
| 15 | +candidate itself. See `README.adoc` § "Scope discipline". |
| 16 | +==== |
| 17 | + |
| 18 | +toc::[] |
| 19 | + |
| 20 | +== Reading these sketches |
| 21 | + |
| 22 | +Each candidate names: (a) the *external construction* it draws on, |
| 23 | +(b) the *fit shape* — what would need to be supplied to discharge the |
| 24 | +`DecorationFit` record from `proofs/agda/EchoDecorationBridge.agda`, |
| 25 | +(c) one or two pseudo-Agda lines showing the would-be predicate / |
| 26 | +stability witness / knowledge witness, and (d) the *falsifier* — the |
| 27 | +concrete condition under which the analogy collapses and the |
| 28 | +candidate is retired. |
| 29 | + |
| 30 | +The pseudocode is illustrative. It uses the names from |
| 31 | +`EchoChoreo` (`Role`, `Client`, `Server`, `Global`, |
| 32 | +`scramble-server`, `client-stability`), `EchoEpistemic` (`Knows`), |
| 33 | +and `EchoGraded` (`keep`, `residue`, `keep≤residue`, `degrade`). |
| 34 | +No file in this directory is intended to typecheck as-is. |
| 35 | + |
| 36 | +== Candidate A — CRDT join semilattices |
| 37 | + |
| 38 | +*External construction.* A replicated value held at two replicas |
| 39 | +(`Client` and `Server`); each replica maintains a local update log. |
| 40 | +A merge operation combines logs into a joined state. |
| 41 | + |
| 42 | +*Fit shape.* |
| 43 | + |
| 44 | +* `Pred` names the invariant "the client's locally-observed value is |
| 45 | + `b : Bool`". Local observation is preserved across the merge step |
| 46 | + whenever the merge is observation-preserving from the client's |
| 47 | + side — which is precisely the `scramble-client-square` shape |
| 48 | + `EchoChoreo` already pins. |
| 49 | +* `Pred-stable` is the witness that the merge step does not change |
| 50 | + the client-side observation. In CRDT terms, this is *the |
| 51 | + client-side projection of the merge is a no-op on the merged |
| 52 | + bit*. For a state-based CRDT whose merge is the lattice join, |
| 53 | + this is the *join-idempotence* property restricted to the |
| 54 | + client-observable component. |
| 55 | +* `knowledge` is the proof that every client-side preimage of a |
| 56 | + given visible value satisfies `Pred`. For a Boolean-bit CRDT, |
| 57 | + this is exhaustion over the two-element preimage. |
| 58 | + |
| 59 | +*Pseudocode.* |
| 60 | + |
| 61 | +[source,agda] |
| 62 | +---- |
| 63 | +-- pseudocode; not committed |
| 64 | +PredA : Global → Set |
| 65 | +PredA (cBit , _) = cBit ≡ true -- "client observes true" |
| 66 | +
|
| 67 | +stableA : ∀ g → PredA g → PredA (scramble-server g) |
| 68 | +stableA (true , _) refl = refl -- merge does not touch cBit |
| 69 | +
|
| 70 | +knowledgeA : Knows Client PredA true |
| 71 | +knowledgeA ((true , _) , refl) = refl |
| 72 | +---- |
| 73 | + |
| 74 | +*Falsifier.* If the CRDT's merge is genuinely commutative — i.e. |
| 75 | +*both* `Pred-stable` and a hypothetical `Pred-stable-reverse` hold |
| 76 | +under a symmetric `scramble-client` and `scramble-server` — then no |
| 77 | +residue survives composition, and the analogy fits but says nothing |
| 78 | +the CRDT's own commutativity proof did not already say. This is the |
| 79 | +candidate's *commutative-merge collapse*: the bridge characterises a |
| 80 | +property the system already has by design, not a phenomenon worth |
| 81 | +naming. Retire if the target CRDT's merge is uniformly commutative |
| 82 | +on the observable. |
| 83 | + |
| 84 | +*Why this is not generic Σ.* The fit *requires* the stability |
| 85 | +witness to mention `scramble-server` — a specific update on `Global`, |
| 86 | +not a generic Σ-projection. A `Σ`-only encoding would have no way to |
| 87 | +name the merge step; it would have to project to the visible bit and |
| 88 | +discard the structure that makes `Pred-stable` mean anything. |
| 89 | + |
| 90 | +== Candidate B — Local-first causal histories |
| 91 | + |
| 92 | +*External construction.* A document is edited by the client; the |
| 93 | +server periodically reconciles. The document state carries |
| 94 | +`(cBit, sBit)`: `cBit` is the client's last committed edit, `sBit` is |
| 95 | +the server's reconciled view. A reconciliation step is the |
| 96 | +`scramble-server` analogue: it may update `sBit` without changing |
| 97 | +`cBit`. |
| 98 | + |
| 99 | +*Fit shape.* |
| 100 | + |
| 101 | +* `Pred` names the invariant "the client's edit history reaches a |
| 102 | + state where `cBit ≡ true`". Causal-history depth is bounded by |
| 103 | + the client's edit count. |
| 104 | +* `Pred-stable` is the witness that reconciliation does not rewrite |
| 105 | + client history. This is the *no-server-side-rewrite* property |
| 106 | + local-first systems offer by design. |
| 107 | +* `knowledge` is the proof that any client-observable witness |
| 108 | + (a state with `cBit ≡ true`) lies in the predicate. |
| 109 | + |
| 110 | +*Pseudocode.* |
| 111 | + |
| 112 | +[source,agda] |
| 113 | +---- |
| 114 | +-- pseudocode; not committed |
| 115 | +PredB : Global → Set |
| 116 | +PredB (cBit , _) = cBit ≡ true -- "client history reached true" |
| 117 | +
|
| 118 | +stableB : ∀ g → PredB g → PredB (scramble-server g) |
| 119 | +stableB (true , _) refl = refl -- reconciliation does not rewrite cBit |
| 120 | +
|
| 121 | +knowledgeB : Knows Client PredB true |
| 122 | +knowledgeB ((true , _) , refl) = refl |
| 123 | +---- |
| 124 | + |
| 125 | +*Falsifier.* If the local-first system already maintains a complete |
| 126 | +causal-history record on every document state (vector clocks, OT |
| 127 | +metadata, full event-log), then the residue the bridge names is |
| 128 | +*already captured* in the system's own provenance metadata. The |
| 129 | +analogy fits but is redundant: the bridge says nothing the system |
| 130 | +did not already say. This is the candidate's *metadata-already-complete* |
| 131 | +failure mode. Retire if the target system's provenance metadata |
| 132 | +fully reconstructs the residue. |
| 133 | + |
| 134 | +*Why this is not generic Σ.* Same reason as Candidate A — the |
| 135 | +stability witness has to mention `scramble-server` specifically. But |
| 136 | +there is a second reason: the `Knows Client P y` predicate is |
| 137 | +fundamentally about *what every preimage satisfies*, which is a |
| 138 | +universal quantification a `Σ`-only encoding would have to write out |
| 139 | +explicitly. The bridge inherits the universal quantification from |
| 140 | +`EchoEpistemic.Knows`. |
| 141 | + |
| 142 | +== Candidate C — Gossip partial views |
| 143 | + |
| 144 | +*External construction.* A node maintains a partial view of the |
| 145 | +cluster membership; gossip messages refresh the view. Local |
| 146 | +observation is the *fresh-or-stale bit* of the node's own view; |
| 147 | +remote-side updates may change which peer a node is observing |
| 148 | +without changing the freshness bit. |
| 149 | + |
| 150 | +*Fit shape.* |
| 151 | + |
| 152 | +* `Pred` names the invariant "the node's view of its own freshness |
| 153 | + bit is `true`". |
| 154 | +* `Pred-stable` is the witness that a remote-view refresh |
| 155 | + (`scramble-server`-analogue) does not change the local freshness |
| 156 | + bit. This is the *view-update-locality* property gossip protocols |
| 157 | + guarantee. |
| 158 | +* `knowledge` is the proof that any local-observable witness lies in |
| 159 | + the predicate. |
| 160 | + |
| 161 | +*Pseudocode.* |
| 162 | + |
| 163 | +[source,agda] |
| 164 | +---- |
| 165 | +-- pseudocode; not committed |
| 166 | +PredC : Global → Set |
| 167 | +PredC (cBit , _) = cBit ≡ true -- "local freshness bit is true" |
| 168 | +
|
| 169 | +stableC : ∀ g → PredC g → PredC (scramble-server g) |
| 170 | +stableC (true , _) refl = refl -- view refresh does not touch cBit |
| 171 | +
|
| 172 | +knowledgeC : Knows Client PredC true |
| 173 | +knowledgeC ((true , _) , refl) = refl |
| 174 | +---- |
| 175 | + |
| 176 | +*Falsifier.* Most gossip protocols are designed to be |
| 177 | +*view-oblivious*: the node accepts any refresh that arrives without |
| 178 | +caring which peer sent it. If view-obliviousness is the design |
| 179 | +intent, the residue the bridge would name is *intentionally |
| 180 | +discarded* — the protocol is built precisely to erase that residue. |
| 181 | +The bridge characterises a property the protocol does not have and |
| 182 | +does not want. Retire if the target protocol's design discards |
| 183 | +peer-provenance on refresh. |
| 184 | + |
| 185 | +*Why this is not generic Σ.* Same as Candidates A and B. |
| 186 | + |
| 187 | +== The shared pseudocode shape (and why it matters) |
| 188 | + |
| 189 | +All three candidates instantiate the same record: |
| 190 | + |
| 191 | +[source,agda] |
| 192 | +---- |
| 193 | +-- pseudocode; the actual record is in proofs/agda/EchoDecorationBridge.agda |
| 194 | +record DecorationFit (y : Bool) : Set₁ where |
| 195 | + field |
| 196 | + Pred : Global → Set |
| 197 | + Pred-stable : ∀ g → Pred g → Pred (scramble-server g) |
| 198 | + knowledge : Knows Client Pred y |
| 199 | +---- |
| 200 | + |
| 201 | +That every candidate shares the same record is the bridge's *only* |
| 202 | +positive content — the claim that "decorations on shared state |
| 203 | +evolution" is a structural pattern that admits a uniform fit shape. |
| 204 | +If two candidates need genuinely different records to express their |
| 205 | +fit, the bridge's positive content collapses and the exploration |
| 206 | +loses its motivation. |
| 207 | + |
| 208 | +[NOTE] |
| 209 | +==== |
| 210 | +"Same record" is not "same instance". The three candidates above all |
| 211 | +discharge `DecorationFit` with the same `Pred` (`λ (cBit , _) → cBit |
| 212 | +≡ true`) and the same trivial proofs. That is because they are |
| 213 | +pseudocode sketches over the same toy `Global = Bool × Bool`. Real |
| 214 | +candidates would differ in their `Pred` (CRDT lattice element vs |
| 215 | +causal-history segment vs view-freshness predicate), their stability |
| 216 | +witness (idempotent join vs server-side-rewrite-freedom vs |
| 217 | +view-update-locality), and the `Global` carrier they project from. |
| 218 | +The toy version is what types under the actual |
| 219 | +`EchoChoreo.Global = Bool × Bool`. Promoting any candidate to a real |
| 220 | +discharge is a rung-consolidation, with its own forbidden-rebrandings |
| 221 | +audit. |
| 222 | +==== |
| 223 | + |
| 224 | +== Falsifier summary |
| 225 | + |
| 226 | +The three falsifiers above are *distinct*. None subsumes another. |
| 227 | +The bridge's exploratory value is in the cases where *exactly one* |
| 228 | +candidate fits — that is, the case is non-commutative enough to have |
| 229 | +a residue (rules out A's commutative collapse), the system does not |
| 230 | +already track that residue (rules out B's metadata-already-complete |
| 231 | +collapse), and the system does not want to discard the residue |
| 232 | +(rules out C's view-obliviousness collapse). If no domain |
| 233 | +construction simultaneously falsifies all three, the bridge has no |
| 234 | +useful target and retires. |
| 235 | + |
| 236 | +== What an actual fit would need |
| 237 | + |
| 238 | +Promoting any candidate from sketch to discharged instance would |
| 239 | +require: |
| 240 | + |
| 241 | +. A concrete `Global` carrier richer than `Bool × Bool`. The |
| 242 | + `Choreo × Graded` shape `EchoIntegration` integrates is fixed to |
| 243 | + `Bool × Bool` for the obvious reason of toy-size; a real candidate |
| 244 | + needs a domain-appropriate carrier, and the bridge then has to |
| 245 | + exhibit role-projections (`obs Client`, `obs Server`) that respect |
| 246 | + the domain's natural observation interface. |
| 247 | +. A real predicate stability proof — not a one-line `refl` over |
| 248 | + exhaustion, but a structural argument that the |
| 249 | + `scramble-server`-analogue update preserves the candidate's |
| 250 | + `Pred`. This is where the real content lives, and where most |
| 251 | + candidates will fail. |
| 252 | +. A real `Knows` witness, which means a real `Echo` over the |
| 253 | + domain's observation map — not the toy |
| 254 | + `obs Client (cBit , _) = cBit`. |
| 255 | +. A real-domain falsifier check: the analogy must demonstrably |
| 256 | + *fail* in some natural instance of the candidate's domain, not |
| 257 | + just in pathological edge cases. A candidate that fits every |
| 258 | + instance is suspicious and almost certainly trips |
| 259 | + "the recipe is uniformly applicable" in the |
| 260 | + forbidden-rebrandings register. |
| 261 | + |
| 262 | +Any session attempting such a promotion should consult |
| 263 | +`README.adoc` § "Termination criteria" first; promotion is *not* |
| 264 | +pre-authorised. |
0 commit comments