1 import Base 2 import ./recovery_use.bend as Use 3 import ./world.bend as W 4 import ./owner_product.bend as Product 5 import ./ordinary_recovery_declaration.bend as D 6 import ./ordinary_recoverable_array_resource.bend as F 7 import ./ordinary_recoverable_component_capture.bend as Existing 8 import ./recoverable_array.bend as A 9 import ./recoverable_array_owner.bend as AO 10 import ./recovery_journal.bend as Journal 11 import ./world_resource_owner.bend as WR 12 import ./ordinary_schema.bend as Schema 13 # Canonical World resource target and generated recovery path; no caller inverse. 14 # Nominal recoverable Array
resource capability family with whole-array
15 # replace and bounded element swap. P may be arbitrary affine Type; this does
16 # not provide automatic inverses for unrelated resource mutations.
17 def Ops(~S:Data,~P:Type,~identity:Schema.Resource>,H:Type) -> Type:F.Write
18 # Advanced trusted lens selecting the Array
World resource while
19 # retaining capture and the rest of World. No live owner is copied or exposed.
20 def target(~S:Data,~C:Type,~E:Data,~Capture:Type,~P:Type) -> Product.Lens ,Capture & WR.Rest ,~WR.Rest ,~E))
22 def empty(~Capture:Type,~P:Type,unit:Unit) -> List resource in the shared recovery journal.
27 # Consumes incoming array and returns frame; commit recovers the displaced
28 # array, rollback restores it and recovers the replacement. Capture and other
29 # World owners remain siblings, not independent copies.
30 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
38 # with incoming P and unchanged journal; success records the displaced owner.
39 # Receipt recovery follows the enclosing commit/rollback, not immediate copying.
40 def swap(~S:Data,~C:Type,~E:Data,~Capture:Type,~P:Type,~All:Type,~Rest:Type,~path:Product.Lens resource operations using its ordinary
48 # resource identity. Supplies complete access/use metadata and generated
49 # recovery path; performs no resource mutation or allocation of payload values.
50 # Supported domain and receipts: docs/parity/recovery.md.
51 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>>:
21 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))
33 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))
43 # Advanced closed grant builder for canonical resource and recovery paths.
44 # Gameplay receives typed replace/swap; it does not author inverses or journals.
45 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>>:
46 F.Write{replace(~S,~C,~E,~Capture,~P,~All,~Rest,~path),swap(~S,~C,~E,~Capture,~P,~All,~Rest,~path)}
47 # Declare recoverable Array>) -> D.Declaration,E>,Capture>,List