import Base import ./recovery_use.bend as Use import ./world.bend as W import ./owner_product.bend as Product import ./ordinary_recovery_declaration.bend as D import ./ordinary_recoverable_array_resource.bend as F import ./ordinary_recoverable_component_capture.bend as Existing import ./recoverable_array.bend as A import ./recoverable_array_owner.bend as AO import ./recovery_journal.bend as Journal import ./world_resource_owner.bend as WR import ./ordinary_schema.bend as Schema # Canonical World resource target and generated recovery path; no caller inverse. # Nominal recoverable Array
resource capability family with whole-array
# replace and bounded element swap. P may be arbitrary affine Type; this does
# not provide automatic inverses for unrelated resource mutations.
def Ops(~S:Data,~P:Type,~identity:Schema.Resource>,H:Type) -> Type:F.Write
# Advanced trusted lens selecting the Array
World resource while
# retaining capture and the rest of World. No live owner is copied or exposed.
def target(~S:Data,~C:Type,~E:Data,~Capture:Type,~P:Type) -> Product.Lens ,Capture & WR.Rest ,~WR.Rest ,~E))
def empty(~Capture:Type,~P:Type,unit:Unit) -> List resource in the shared recovery journal.
# Consumes incoming array and returns frame; commit recovers the displaced
# array, rollback restores it and recovers the replacement. Capture and other
# World owners remain siblings, not independent copies.
def replace(~S:Data,~C:Type,~E:Data,~Capture:Type,~P:Type,~All:Type,~Rest:Type,~path:Product.Lens ) -> F.Frame resource element swap. Out-of-bounds returns Refused
# with incoming P and unchanged journal; success records the displaced owner.
# Receipt recovery follows the enclosing commit/rollback, not immediate copying.
def swap(~S:Data,~C:Type,~E:Data,~Capture:Type,~P:Type,~All:Type,~Rest:Type,~path:Product.Lens resource operations using its ordinary
# resource identity. Supplies complete access/use metadata and generated
# recovery path; performs no resource mutation or allocation of payload values.
# Supported domain and receipts: docs/parity/recovery.md.
def declaration(~S:Data,~C:Type,~E:Data,~Capture:Type,~P:Type,~identity:Schema.Resource ,identity)],Use.known([Use.Use{Use.Resource{Schema.resource_key(~S,~Array ,identity)},Use.Write{}}])}
,E>>:
Product.compose(~Product.Owner,E>,~Capture,~Array,E>,~Product.lens(~W.World,E>,~Capture,~Product.Left{}),~WR.lens(~S,~C,~Array,E>),~target(~S,~C,~E,~Capture,~P),~All,~Rest,~path,state,journal,incoming))
def swapped(~S:Data,~C:Type,~E:Data,~Capture:Type,~P:Type,~All:Type,~Rest:Type,~path:Product.Lens,E>),~target(~S,~C,~E,~Capture,~P),~All,~Rest,~path,state,journal,index,incoming))
# Advanced closed grant builder for canonical resource and recovery paths.
# Gameplay receives typed replace/swap; it does not author inverses or journals.
def grant(~S:Data,~C:Type,~E:Data,~Capture:Type,~P:Type,~identity:Schema.Resource>,~All:Type,~Rest:Type,~path:Product.Lens,E>,Capture>,All>>:
F.Write{replace(~S,~C,~E,~Capture,~P,~All,~Rest,~path),swap(~S,~C,~E,~Capture,~P,~All,~Rest,~path)}
# Declare recoverable Array>) -> D.Declaration,E>,Capture>,List