Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions .github/workflows/actions.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ workflows:
- 'haskell-actions/setup@v2.12.1'
'.github/workflows/codeql.yml':
- 'actions/checkout@v7.0.1'
- 'github/codeql-action@v4.38.3'
- 'github/codeql-action@v4.39.3'
'.github/workflows/dogfood-gate.yml':
- 'actions/checkout@v7.0.1'
'.github/workflows/governance.yml': []
Expand All @@ -25,13 +25,13 @@ workflows:
'.github/workflows/placement-guard.yml':
- 'actions/checkout@v7.0.1'
'.github/workflows/push-email-notify.yml':
- 'hyperpolymath/smtp-notify-action@v0.5.0'
- 'hyperpolymath/smtp-notify-action@v0.5.1'
'.github/workflows/scorecard.yml': []
'.github/workflows/secret-scanner.yml': []
'.github/workflows/verify-tlaplus.yml':
- 'actions/cache@v6.1.0'
- 'actions/checkout@v7.0.1'
- 'actions/setup-java@v6.0.1'
- 'actions/setup-java@v6.2.0'
- 'actions/upload-artifact@v7.0.2'
dependencies:
'actions/cache@v6.1.0':
Expand All @@ -54,9 +54,9 @@ dependencies:
commit: 'sha1-368f82528645a54fb793d4d04e342629a3f51346'
owner_id: 44036562
repo_id: 438112499
'actions/setup-java@v6.0.1':
ref: 'v6.0.1'
commit: 'sha1-de7274f081f381c8f8158605e0321c36c376e2e6'
'actions/setup-java@v6.2.0':
ref: 'v6.2.0'
commit: 'sha1-77dd5b2ce225ea11469928ac317850245a74ae78'
owner_id: 44036562
repo_id: 196057608
'actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f':
Expand All @@ -76,18 +76,18 @@ dependencies:
repo_id: 496012378
uses:
- 'actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f'
'github/codeql-action@v4.38.3':
ref: 'v4.38.3'
commit: 'sha1-24c54180a607b1449ed407dd24f251e4e9147c8d'
'github/codeql-action@v4.39.3':
ref: 'v4.39.3'
commit: 'sha1-33d7b85da1a04171e211befe2c739303b9a4c066'
owner_id: 9919
repo_id: 259445878
'haskell-actions/setup@v2.12.1':
ref: 'v2.12.1'
commit: 'sha1-0f8e8c99d88aeb3fbfd523f1ef2c6f762d10d64d'
owner_id: 75048950
repo_id: 623796603
'hyperpolymath/smtp-notify-action@v0.5.0':
ref: 'v0.5.0'
commit: 'sha1-c1c9fa07992a02c1fd3d67a0dc1b08cccb852aef'
'hyperpolymath/smtp-notify-action@v0.5.1':
ref: 'v0.5.1'
commit: 'sha1-e384daf6167a7a7567642d6a62060106244d2413'
owner_id: 6759885
repo_id: 1352485172
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ jobs:
uses: actions/checkout@v7.0.1

- name: Initialize CodeQL
uses: github/codeql-action/init@v4.38.3
uses: github/codeql-action/init@v4.39.3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4.38.3
uses: github/codeql-action/analyze@v4.39.3
with:
category: "/language:${{ matrix.language }}"
2 changes: 1 addition & 1 deletion .github/workflows/push-email-notify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
timeout-minutes: 5
steps:
- name: Send push notification email
uses: hyperpolymath/smtp-notify-action@v0.5.0
uses: hyperpolymath/smtp-notify-action@v0.5.1
with:
server_address: ${{ secrets.SMTP_HOST }}
server_port: ${{ secrets.SMTP_PORT }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/verify-tlaplus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
uses: actions/checkout@v7.0.1

- name: Set up Eclipse Temurin 21 JRE
uses: actions/setup-java@v6.0.1
uses: actions/setup-java@v6.2.0
with:
distribution: temurin
java-version: '21'
Expand Down
4 changes: 4 additions & 0 deletions verisimdb/verification/proofs/tlaplus/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# SPDX-License-Identifier: MPL-2.0
# TLC model-checker scratch output.
states/
tlc.log
25 changes: 25 additions & 0 deletions verisimdb/verification/proofs/tlaplus/Normalizer.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
\* SPDX-License-Identifier: MPL-2.0
\* TLC configuration for Normalizer.tla (V9).
\*
\* Bounded instance: 4 modalities (abstracted from 8), 3 distinct values,
\* MaxSteps=3. State space = |Values|^|Modalities| initial states (3^4=81)
\* times up to MaxSteps transitions. Convergence happens in 1 step, so
\* effective space ~= 81 * 2 = 162 reachable states. Finishes instantly.
\*
\* Run with:
\* java -cp tla2tools.jar tlc2.TLC -config Normalizer.cfg Normalizer.tla
\* or via `just verify-tlaplus`.

SPECIFICATION Spec

CONSTANTS
Values = {"v0", "v1", "v2"}
MaxSteps = 3

INVARIANTS
NormalizerSafe

PROPERTIES
Convergence

CHECK_DEADLOCK FALSE
139 changes: 139 additions & 0 deletions verisimdb/verification/proofs/tlaplus/Normalizer.tla
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
------------------------------- MODULE Normalizer -------------------------------
\* SPDX-License-Identifier: MPL-2.0
\* Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
\*
\* V9: Normalizer determinism + convergence.
\* Corresponds to rust-core/verisim-normalizer/src/lib.rs (StorageRegenerator).
\*
\* The verisim-normalizer resolves drift between the 8 modalities of an octad
\* by picking an authoritative source modality and regenerating the others
\* from it. The real system has a (source, target) strategy table -- Document
\* is the usual authoritative source for Vector/Semantic/Graph regeneration,
\* with cosine-similarity drift measured against Vector and Jaccard against
\* Semantic. This spec abstracts that machinery into its essential claim:
\*
\* - Determinism: normalisation is a *function* of state. Given the same
\* input octad, normalisation always produces the same output octad;
\* there is no schedule-dependent or source-rank-tie non-determinism.
\* - Convergence: starting from any drift-ed state, repeated normalisation
\* reaches a drift-free fixed point in bounded time.
\*
\* The spec also checks that the fixed point is *stable* (Normalize is
\* identity on a drift-free state).

EXTENDS Naturals, FiniteSets, TLC

CONSTANTS
Values, \* abstract set of possible modality payload hashes
MaxSteps \* bound on normalisation rounds for model-checking

\* Modalities and their deterministic priority ordering are module-level (TLC
\* config files cannot represent record literals, and the real system has a
\* fixed strategy table anyway). Priority is strictly injective by
\* construction here -- that injectivity is exactly what makes the CHOOSE in
\* SourceOf deterministic, and it is the spec's central structural claim.
Modalities == {"graph", "vector", "semantic", "document"}

Priority == [graph |-> 1, vector |-> 2, semantic |-> 3, document |-> 4]

ASSUME Cardinality(Values) >= 1
ASSUME MaxSteps \in Nat
ASSUME \A m1, m2 \in Modalities: (m1 /= m2) => (Priority[m1] /= Priority[m2])

VARIABLES
state, \* [Modalities -> Values] -- current octad snapshot
steps \* Nat -- normalisation rounds elapsed

vars == <<state, steps>>

TypeOK ==
/\ state \in [Modalities -> Values]
/\ steps \in 0..MaxSteps

\* Drift holds when any two modalities disagree on the payload.
HasDrift(s) ==
\E m1, m2 \in Modalities: s[m1] /= s[m2]

\* The deterministic authoritative-source function. Under the injectivity
\* ASSUME above, CHOOSE returns the unique highest-priority modality. This
\* is the single piece of the spec that, if wrong, would make the whole
\* normaliser non-deterministic -- so it is the thing determinism hinges on.
SourceOf(s) ==
CHOOSE m \in Modalities:
\A other \in Modalities: Priority[m] >= Priority[other]

\* The normaliser: rewrite every modality to the source's value.
Normalize(s) ==
[m \in Modalities |-> s[SourceOf(s)]]

\* Non-deterministic initial state; all octads are possible starting points
\* for the model-check.
Init ==
/\ state \in [Modalities -> Values]
/\ steps = 0

\* One round of normalisation. Guard by HasDrift so converged states are
\* stuttering; guard by MaxSteps for finite model-check.
Step ==
/\ steps < MaxSteps
/\ HasDrift(state)
/\ state' = Normalize(state)
/\ steps' = steps + 1

Next == Step

\* Weak fairness forces Step to fire while drift remains, which is what makes
\* Convergence true. Without it, the system could stutter forever in a drifted
\* state (that would be a real bug in the implementation, not the spec).
Spec == Init /\ [][Next]_vars /\ WF_vars(Step)

--------------------------------------------------------------------------------
\* Safety
--------------------------------------------------------------------------------

\* I1. SourceOf is well-defined: the CHOOSE always returns an element of
\* Modalities, and that element is the unique priority-maximum. Trivial from
\* the ASSUME, but stated explicitly so TLC exercises it on every state.
SourceIsMaximal ==
\A other \in Modalities:
Priority[SourceOf(state)] >= Priority[other]

\* I2. Idempotence of Normalize: normalising a normalised state is a no-op.
\* This is a property of the *definition* of Normalize; TLC checks it across
\* all reachable states including the non-deterministic Init.
NormalizeIdempotent ==
Normalize(Normalize(state)) = Normalize(state)

\* I3. Post-Step drift-free: immediately after Step, no drift remains.
\* Implementation: Step replaces state with Normalize(state), which makes
\* every modality equal to state[SourceOf(state)] -- so any two modalities
\* agree, i.e. ~HasDrift. TLC verifies by exploring.
PostStepNoDrift ==
(steps > 0) => ~HasDrift(state)

\* I4. Stability of fixed point: in any drift-free state, Normalize is the
\* identity. This is the "once converged, stay converged" guarantee.
FixedPointStable ==
~HasDrift(state) => (Normalize(state) = state)

NormalizerSafe ==
/\ TypeOK
/\ SourceIsMaximal
/\ NormalizeIdempotent
/\ PostStepNoDrift
/\ FixedPointStable

--------------------------------------------------------------------------------
\* Liveness / convergence
--------------------------------------------------------------------------------

\* Eventually, drift is gone and stays gone. Stronger than "eventually no
\* drift" because the system could in principle re-drift if Step non-
\* deterministically reintroduced disagreement -- the <>[] form forbids that.
Convergence ==
<>[]~HasDrift(state)

THEOREM NormalizerSafety == Spec => []NormalizerSafe
THEOREM NormalizerConverges == Spec => Convergence

================================================================================
24 changes: 24 additions & 0 deletions verisimdb/verification/proofs/tlaplus/OctadAtomicity.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
\* SPDX-License-Identifier: MPL-2.0
\* TLC configuration for OctadAtomicity.tla (V5).
\*
\* Bounded instance: 2 transactions, up to 2 crashes per run. With 8 modalities
\* and 3 status values, state space is bounded by
\* (3 * 2^8)^2 * 3 ~ 1.8M states upper bound; in practice < 100k reachable.
\*
\* Run with:
\* java -cp tla2tools.jar tlc2.TLC -config OctadAtomicity.cfg OctadAtomicity.tla
\* or via the repo `just verify-tlaplus` recipe (see verisimdb Justfile).

SPECIFICATION Spec

CONSTANTS
Txns = {"t1", "t2"}
MaxCrashes = 2

INVARIANTS
OctadSafe

PROPERTIES
EveryTxnResolves

CHECK_DEADLOCK FALSE
Loading
Loading