1 import Base 2 import ./ordinary_lifetime_scope.bend as Ord 3 import ./lifetime_scope.bend as Sc 4 import ./world_io.bend as IOCreate 5 import ./ordinary_schema_provision.bend as Provision 6 import ./world.bend as W 7 import ./relation_commands.bend as A 8 9 # Canonical IO creation remains foreign execution, never a mathematical proof. 10 def created(~S:Data,~C:Type,~R:Type,~empty:Unit -> C,~count:C -> List<&2,W.Handle> -> C & List<&2,Maybe<&2,U32>>,~E:Data,value:Provision.Provision>,R,Ord.empty_store(~S,~C,~empty),Ord.count_store(~S,~C,~count)>,result:IOCreate.Creation>,R,A.Notice>) -> IO(Provision.Provision>,R,Ord.empty_store(~S,~C,~empty),Ord.count_store(~S,~C,~count)> & IOCreate.Creation>,R,A.Notice>): 11 IO.pure(Provision.Provision>,R,Ord.empty_store(~S,~C,~empty),Ord.count_store(~S,~C,~count)> & IOCreate.Creation>,R,A.Notice>,(value,result)) 12 # Create a World with the scope/relation-wrapped provision in host IO. 13 # Consumes resource R and returns the provision together with world-io.Creation: 14 # Created carries the new World; Refused returns the incoming resource owner. 15 # Uses the checked host namespace allocator, not a caller-chosen namespace. 16 # No entity is spawned, made live or assigned to a scope by World creation. 17 # Use lifetime-scope.scope on the returned World to obtain a same-world token; 18 # scoped spawn and cleanup remain deferred until an explicit command barrier. 19 # This is an IO setup boundary, not a mathematical proof or an automatic affine 20 # finalizer. Example: test-fixtures/public-scopes/feature-timing-v1/fixture.bend: 21 # create; main.bend observes linked, persistent, failed and retried scope work. 22 def create(~S:Data,~C:Type,~R:Type,~empty:Unit -> C,~count:C -> List<&2,W.Handle> -> C & List<&2,Maybe<&2,U32>>,~E:Data,value:Provision.Provision>,R,Ord.empty_store(~S,~C,~empty),Ord.count_store(~S,~C,~count)>,resource:R) -> IO(Provision.Provision>,R,Ord.empty_store(~S,~C,~empty),Ord.count_store(~S,~C,~count)> & IOCreate.Creation>,R,A.Notice>): 23 IO.bind(IOCreate.Creation>,R,A.Notice>,Provision.Provision>,R,Ord.empty_store(~S,~C,~empty),Ord.count_store(~S,~C,~count)> & IOCreate.Creation>,R,A.Notice>,IOCreate.create(~S,~A.Store>,~R,~A.Notice,~Ord.empty_store(~S,~C,~empty),resource),result => created(~S,~C,~R,~empty,~count,~E,value,result))