import Base import ./world.bend as W import ./owner_product.bend as Product import ./owned_event_log.bend as Log import ./ordinary_owned_event.bend as Pub import ./ordinary_owned_event_binding.bend as Binding import ./ordinary_owned_event_declaration.bend as D import ./owned_event_journal.bend as Journal # Normal setup receives a canonical binding; all executable log/receipt paths # remain erased until the declaration is specialized at its full recovery tree. # Nominal owned-publication capability family bound to one domain identity. # The opaque owner is the staged journal; no runtime log alias is exposed. def Ops(~S:Data,~P:Type,~identity:Pub.Domain,H:Type) -> Type:Pub.Write def empty(~P:Type,unit:Unit) -> List

:[] def emit_named(~S:Data,~C:Type,~R:Type,~P:Type,~Rest:Type,~E:Data,~path:Product.Lens,Rest>,~inject:Nat -> E,~identity:Pub.Domain,~All:Type,~RecoveryRest:Type,~recovery:Product.Lens,RecoveryRest>,stage:Journal.Stage,All>,payload:P) -> Journal.Stage,All>: Journal.emit(~S,~C,~R,~P,~Rest,~E,~path,~inject,~All,~RecoveryRest,~recovery,Journal.record_named(~W.World,~All,Pub.name(~S,~P,identity),stage),payload) # Advanced closed grant constructor for the selected log/recovery paths. # Payload emit stages one owned P; canonical binding and erased lenses must # refer to the same schema/log. Raw adapters are trusted engine setup. def grant(~S:Data,~C:Type,~R:Type,~P:Type,~Rest:Type,~E:Data,~path:Product.Lens,Rest>,~inject:Nat -> E,~identity:Pub.Domain,~All:Type,~RecoveryRest:Type,~recovery:Product.Lens,RecoveryRest>,unit:Unit) -> Pub.Write,All>>: Pub.Write{emit_named(~S,~C,~R,~P,~Rest,~E,~path,~inject,~identity,~All,~RecoveryRest,~recovery)} # Declare owned publication from the canonical family binding, deriving # both operational authority and complete event description. Staged owners # commit to logs on success or return in the typed recovery product on abort; # this constructor performs neither. Compose heterogeneous domains with # ordinary-owned-event-declaration.both; see docs/parity/affine-events.md. def declaration(~S:Data,~C:Type,~R:Type,~P:Type,~Rest:Type,~E:Data,~path:Product.Lens,Rest>,~inject:Nat -> E,~select:List<&2,E> -> List<&2,Nat>,~identity:Pub.Domain,~binding:Binding.Binding) -> D.Declaration,List

,Ops(~S,~P,~identity),grant(~S,~C,~R,~P,~Rest,~E,~path,~inject,~identity)>: D.Described{empty(~P),[Pub.access(~S,~P,identity,":write")],D.Description{[Pub.name(~S,~P,identity)],False{}}}