okami.mom/albedo
git clone https://git.nkp.pet/okami.mom/albedo
9dd3a56
main
1//// Concurrent revision updates must have exactly one winner. 2//// Two writes at one revision force the race that E2E cannot reliably order. 3//// Empty workspace scopes are rejected by HTTP admission before reaching SQL. 4 5import albedo/daemon/store 6import albedo/harness/extensions/work/ledger as work 7import gleam/erlang/process 8import gleam/option .{ None } 9 10pub fn only_one_concurrent_edit_wins_test () -> Nil { 11let assert Ok ( store ) = store . start ( ":memory:" , "" ) 12let assert Ok ( _ ) = work . initialise ( store ) 13let assert Ok ( item ) = work . create ( store , "/cwd" , "original" , "" , None ) 14let reply = process . new_subject () 15let _ = 16process . spawn_unlinked ( fn () { 17process . send ( 18reply , 19work . update ( store , "/cwd" , work . Item (.. item , title : "human" )), 20) 21}) 22let _ = 23process . spawn_unlinked ( fn () { 24process . send ( 25reply , 26work . update ( store , "/cwd" , work . Item (.. item , title : "agent" )), 27) 28}) 29let assert Ok ( a ) = process . receive ( reply , 5000 ) 30let assert Ok ( b ) = process . receive ( reply , 5000 ) 31case a , b { 32Ok ( _ ), Error ( work . Conflict ) |Error ( work . Conflict ), Ok ( _ ) -> Nil 33_ , _ -> panic as "exactly one edit must win" 34} 35store . close ( store ) 36} 37 38pub fn empty_workspace_is_not_a_ledger_scope_test () -> Nil { 39let assert Ok ( store ) = store . start ( ":memory:" , "" ) 40let assert Ok ( _ ) = work . initialise ( store ) 41let assert Error ( work . Invalid ( _ )) = work . list ( store , "" , 0 , 10 ) 42store . close ( store ) 43}