import Base import ./ordinary_lifetime_scope.bend as Ord import ./lifetime_scope.bend as Sc import ./world_io.bend as IOCreate import ./ordinary_schema_provision.bend as Provision import ./world.bend as W import ./relation_commands.bend as A # Canonical IO creation remains foreign execution, never a mathematical proof. 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>): IO.pure(Provision.Provision>,R,Ord.empty_store(~S,~C,~empty),Ord.count_store(~S,~C,~count)> & IOCreate.Creation>,R,A.Notice>,(value,result)) # Create a World with the scope/relation-wrapped provision in host IO. # Consumes resource R and returns the provision together with world-io.Creation: # Created carries the new World; Refused returns the incoming resource owner. # Uses the checked host namespace allocator, not a caller-chosen namespace. # No entity is spawned, made live or assigned to a scope by World creation. # Use lifetime-scope.scope on the returned World to obtain a same-world token; # scoped spawn and cleanup remain deferred until an explicit command barrier. # This is an IO setup boundary, not a mathematical proof or an automatic affine # finalizer. Example: test-fixtures/public-scopes/feature-timing-v1/fixture.bend: # create; main.bend observes linked, persistent, failed and retried scope work. 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>): 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))