Skip to content

Commit

Permalink
Check for causal mismatches
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPenner committed Feb 26, 2024
1 parent 073cffd commit b96fb2b
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions unison-cli/src/Unison/Share/Sync.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import Unison.Debug qualified as Debug
import Unison.Hash32 (Hash32)
import Unison.Prelude
import Unison.Share.API.Hash qualified as Share
import Unison.Share.ExpectedHashMismatches (expectedComponentHashMismatches)
import Unison.Share.ExpectedHashMismatches (expectedCausalHashMismatches, expectedComponentHashMismatches)
import Unison.Share.Sync.Types
import Unison.Sqlite qualified as Sqlite
import Unison.Sync.API qualified as Share (API)
Expand Down Expand Up @@ -470,12 +470,17 @@ validateEntities entities =
let entityWithHashes = entity & Share.entityHashes_ %~ Share.hashJWTHash
case EV.validateEntity hash entityWithHashes of
Nothing -> pure ()
Just err@(Share.EntityHashMismatch _et (Share.HashMismatchForEntity {supplied, computed})) ->
case Map.lookup supplied expectedComponentHashMismatches of
Just expected
| expected == computed -> pure ()
_ -> do
Left err
Just err@(Share.EntityHashMismatch et (Share.HashMismatchForEntity {supplied, computed})) ->
let expectedMismatches = case et of
Share.TermComponentType -> expectedComponentHashMismatches
Share.DeclComponentType -> expectedComponentHashMismatches
Share.CausalType -> expectedCausalHashMismatches
_ -> mempty
in case Map.lookup supplied expectedMismatches of
Just expected
| expected == computed -> pure ()
_ -> do
Left err
Just err -> do
Left err

Expand Down

0 comments on commit b96fb2b

Please sign in to comment.