1 import Base 2 import ./ordinary_machine_declaration.bend as OD 3 import ./machine_queue.bend as Q 4 import ./machine.bend as M 5 import ./machine_world.bend as MW 6 import ./transaction.bend as Tx 7 import ./world.bend as W 8 import ./capabilities.bend as Cap 9 # Schema-authored closed lenses/comparator grant operations to an opaque owner. 10 # The existing declaration remains unchanged; names carry no authority. 11 def current(~S:Data,~K:Data,~V:Data,~C:Type,~R:Type,~E:Data,pair:Tx.Tx,E> & M.Slot) -> Tx.Tx,E> & M.CurrentView: 12 (frame,slot)=pair 13 (frame,M.current_view(~S,~K,~V,slot)) 14 # Advanced transactional read of the committed machine CurrentView through 15 # the trusted nominal slot lens, returning the transaction owner. Queued targets 16 # are not committed current state; a missing slot remains explicit. 17 def get(~S:Data,~K:Data,~V:Data,~C:Type,~R:Type,~E:Data,~take:R -> R & M.Slot,frame:Tx.Tx,E>) -> Tx.Tx,E> & M.CurrentView: 18 current(~S,~K,~V,~C,~R,~E,M.read(~S,~K,~V,~W.World,~E,~MW.take(~S,~K,~V,~C,~R,~E,~take),frame)) 19 # Stage a Set or Reset next-state request in the current ECS transaction. 20 # Returns the transaction owner; the slot change is journaled for rollback. 21 # Does not execute handlers or immediately change committed state: transition 22 # markers apply queued work. Vocabulary metadata is not a membership validator. 23 def set(~S:Data,~K:Data,~V:Data,~C:Type,~R:Type,~E:Data,~take:R -> R & M.Slot,~put:R -> M.Slot -> R,~same:V -> V -> Bool,~declaration:OD.Declaration,frame:Tx.Tx,E>,input:M.QueueInput) -> Tx.Tx,E>: 24 Q.next_declared(~S,~K,~V,~W.World,~E,~MW.take(~S,~K,~V,~C,~R,~E,~take),~MW.put(~S,~K,~V,~C,~R,~E,~put),~same,M.Family{OD.name(~S,~K,~V,~R,~take,declaration)},frame,input) 25 # Declare current-state read access to the nominal machine slot. 26 # The resulting capability threads the transaction owner and exposes only 27 # CurrentView; building it does not read state or grant next-state writes. 28 def read(~S:Data,~K:Data,~V:Data,~C:Type,~R:Type,~E:Data,~take:R -> R & M.Slot,~declaration:OD.Declaration) -> Cap.ValueRead,E>,M.CurrentView>: 29 Cap.ValueRead{get(~S,~K,~V,~C,~R,~E,~take)} 30 # Declare current-state reads plus Set/Reset next-state requests for one 31 # nominal slot. take/put/comparator are trusted schema setup. Requests are 32 # journaled by set and later processed at explicit transition markers, with 33 # existing exit/transition/enter failure boundaries. Does not grant raw resources. 34 def write(~S:Data,~K:Data,~V:Data,~C:Type,~R:Type,~E:Data,~take:R -> R & M.Slot,~put:R -> M.Slot -> R,~same:V -> V -> Bool,~declaration:OD.Declaration) -> Cap.ValueWrite,E>,M.QueueInput,M.CurrentView>: 35 Cap.ValueWrite{get(~S,~K,~V,~C,~R,~E,~take),set(~S,~K,~V,~C,~R,~E,~take,~put,~same,~declaration)}