@e4779/pi-fabric 0.92.41-fork.6 → 0.96.4-fork.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LAWS.bend +502 -0
- package/PROOF.bend +452 -0
- package/README.md +5 -1
- package/THIRD_PARTY_NOTICES.md +9 -0
- package/dist/agents/handoff.d.ts +2 -1
- package/dist/agents/handoff.d.ts.map +1 -1
- package/dist/agents/manager.d.ts +2 -0
- package/dist/agents/manager.d.ts.map +1 -1
- package/dist/agents.js +6 -5
- package/dist/agents.js.map +1 -1
- package/dist/chunks/{chunk-3TXOQ5MG.js → chunk-3CJETB4S.js} +828 -204
- package/dist/chunks/chunk-3CJETB4S.js.map +7 -0
- package/dist/chunks/{chunk-IUCVOZRX.js → chunk-3SIXBW6A.js} +2 -2
- package/dist/chunks/chunk-4E63LJDD.js +468 -0
- package/dist/chunks/chunk-4E63LJDD.js.map +7 -0
- package/dist/chunks/{chunk-AAHHYDTO.js → chunk-4NF3S3NM.js} +1 -1
- package/dist/chunks/{chunk-AAHHYDTO.js.map → chunk-4NF3S3NM.js.map} +2 -2
- package/dist/chunks/{chunk-2SWRVIYJ.js → chunk-754HA6KO.js} +2 -2
- package/dist/chunks/{chunk-K6DHXXF5.js → chunk-B2IVWASP.js} +2 -2
- package/dist/chunks/{chunk-ZDNGXLEC.js → chunk-B4HECUJI.js} +2 -2
- package/dist/chunks/{chunk-H6DDV6E2.js → chunk-CSJSHBAT.js} +5 -5
- package/dist/chunks/{chunk-MW5VI7IW.js → chunk-D4B4CCTA.js} +2 -2
- package/dist/chunks/{chunk-EDL4JDW7.js → chunk-EBWMC3OO.js} +2 -2
- package/dist/chunks/{chunk-4NUTVNS2.js → chunk-F72MAIQY.js} +31 -368
- package/dist/chunks/chunk-F72MAIQY.js.map +7 -0
- package/dist/chunks/{chunk-W3FRE4VI.js → chunk-FDIEQEXS.js} +2 -2
- package/dist/chunks/{chunk-7A6NVHB5.js → chunk-FJSHRHOR.js} +7 -4
- package/dist/chunks/chunk-FJSHRHOR.js.map +7 -0
- package/dist/chunks/{chunk-PSNXUZMY.js → chunk-G2F2RDZI.js} +5 -47
- package/dist/chunks/chunk-G2F2RDZI.js.map +7 -0
- package/dist/chunks/{chunk-3WIGAX56.js → chunk-JCV54SSP.js} +2 -2
- package/dist/chunks/chunk-KS44WKJJ.js +51 -0
- package/dist/chunks/chunk-KS44WKJJ.js.map +7 -0
- package/dist/chunks/{chunk-3H7SDWZI.js → chunk-LNLQ2LX3.js} +22 -1
- package/dist/chunks/chunk-LNLQ2LX3.js.map +7 -0
- package/dist/chunks/{chunk-G4LADAYY.js → chunk-OINADFEF.js} +8 -3
- package/dist/chunks/chunk-OINADFEF.js.map +7 -0
- package/dist/chunks/{chunk-UQ4LTUH4.js → chunk-OUAC6O5C.js} +36 -9
- package/dist/chunks/chunk-OUAC6O5C.js.map +7 -0
- package/dist/chunks/{chunk-MQG5QKGI.js → chunk-Q5BMTL6A.js} +217 -95
- package/dist/chunks/chunk-Q5BMTL6A.js.map +7 -0
- package/dist/chunks/{chunk-IK6PPFWG.js → chunk-QFKHAAZA.js} +11 -11
- package/dist/chunks/chunk-QFKHAAZA.js.map +7 -0
- package/dist/chunks/{chunk-RTXZHKMS.js → chunk-QNMQJNXE.js} +7 -3
- package/dist/chunks/chunk-QNMQJNXE.js.map +7 -0
- package/dist/chunks/{chunk-U5FYOMG5.js → chunk-UBPFGMDQ.js} +6 -2
- package/dist/chunks/chunk-UBPFGMDQ.js.map +7 -0
- package/dist/chunks/{chunk-FLKGJPCN.js → chunk-ULQFHZJE.js} +4 -1
- package/dist/chunks/chunk-ULQFHZJE.js.map +7 -0
- package/dist/chunks/{chunk-7VAZ4N43.js → chunk-V3PIO7QL.js} +2 -2
- package/dist/chunks/{chunk-MGDLRV2R.js → chunk-VQGO4P7C.js} +2 -2
- package/dist/chunks/{chunk-XT4346N7.js → chunk-WXSELMFV.js} +9 -3
- package/dist/chunks/chunk-WXSELMFV.js.map +7 -0
- package/dist/chunks/{chunk-D5WKZONW.js → chunk-X3IRR7CV.js} +2 -2
- package/dist/chunks/{chunk-IJL3QK3J.js → chunk-Y57UHPIK.js} +1 -1
- package/dist/chunks/{chunk-IJL3QK3J.js.map → chunk-Y57UHPIK.js.map} +1 -1
- package/dist/chunks/{chunk-RKRVOBVO.js → chunk-YC3QQDZ3.js} +2 -2
- package/dist/chunks/{chunk-Q4XJ4PYL.js → chunk-ZRI433JP.js} +299 -83
- package/dist/chunks/chunk-ZRI433JP.js.map +7 -0
- package/dist/chunks/{chunk-36B4AIRT.js → chunk-ZTXZ6JDO.js} +2 -2
- package/dist/commands/fabric.d.ts.map +1 -1
- package/dist/compaction/bounds.d.ts +4 -0
- package/dist/compaction/bounds.d.ts.map +1 -1
- package/dist/compaction/branch-summary.d.ts.map +1 -1
- package/dist/compaction/dialogue.d.ts +24 -0
- package/dist/compaction/dialogue.d.ts.map +1 -0
- package/dist/compaction/hook.d.ts +6 -2
- package/dist/compaction/hook.d.ts.map +1 -1
- package/dist/compaction/hook.js +6 -5
- package/dist/compaction/instructions.d.ts +1 -0
- package/dist/compaction/instructions.d.ts.map +1 -1
- package/dist/compaction/projections.d.ts +3 -3
- package/dist/compaction/projections.d.ts.map +1 -1
- package/dist/compaction/qa.d.ts.map +1 -1
- package/dist/compaction/render.d.ts +11 -0
- package/dist/compaction/render.d.ts.map +1 -1
- package/dist/components/configuration.js +2 -3
- package/dist/components/effect-policy.d.ts +2 -0
- package/dist/components/effect-policy.d.ts.map +1 -1
- package/dist/components/effect-scope.d.ts.map +1 -1
- package/dist/components/supervisor.d.ts +1 -1
- package/dist/components/supervisor.d.ts.map +1 -1
- package/dist/core/action-registry.d.ts +14 -2
- package/dist/core/action-registry.d.ts.map +1 -1
- package/dist/core/action-registry.js +7 -5
- package/dist/core/provider-bindings.d.ts +8 -2
- package/dist/core/provider-bindings.d.ts.map +1 -1
- package/dist/core/provider-operations.d.ts +28 -0
- package/dist/core/provider-operations.d.ts.map +1 -0
- package/dist/core/provider-operations.js +201 -0
- package/dist/core/provider-operations.js.map +7 -0
- package/dist/core/shell-inbox.d.ts +13 -0
- package/dist/core/shell-inbox.d.ts.map +1 -0
- package/dist/core/shell-jobs.d.ts +51 -7
- package/dist/core/shell-jobs.d.ts.map +1 -1
- package/dist/core/shell-limits.d.ts +3 -0
- package/dist/core/shell-limits.d.ts.map +1 -0
- package/dist/core/shell-monitor.d.ts +51 -0
- package/dist/core/shell-monitor.d.ts.map +1 -0
- package/dist/entropy/index.js +8 -7
- package/dist/entropy/normal-form.d.ts.map +1 -1
- package/dist/execution-service.d.ts +1 -1
- package/dist/execution-service.d.ts.map +1 -1
- package/dist/fabric-runtime-state.d.ts +1 -1
- package/dist/fabric-runtime-state.d.ts.map +1 -1
- package/dist/fabric-runtime-state.js +1124 -325
- package/dist/fabric-runtime-state.js.map +4 -4
- package/dist/index.js +155 -44
- package/dist/index.js.map +3 -3
- package/dist/jev/observation.js +5 -3
- package/dist/jev.d.ts +0 -1
- package/dist/jev.d.ts.map +1 -1
- package/dist/jev.js +9 -13
- package/dist/memory/digest.d.ts.map +1 -1
- package/dist/memory/digest.js +2 -1
- package/dist/memory/discovery.js +6 -5
- package/dist/memory/expand-service.d.ts.map +1 -1
- package/dist/memory/file-worker.js +9 -8
- package/dist/memory/file-worker.js.map +1 -1
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/normalize.d.ts.map +1 -1
- package/dist/memory/normalize.js +5 -4
- package/dist/memory/search.js +7 -6
- package/dist/memory/worker-provider.js +10 -9
- package/dist/memory.js +9 -8
- package/dist/memory.js.map +1 -1
- package/dist/mesh/store.d.ts.map +1 -1
- package/dist/prewalk/handoff.d.ts +1 -1
- package/dist/prewalk/handoff.d.ts.map +1 -1
- package/dist/protocol.d.ts +2 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +1 -1
- package/dist/providers/jev-provider.d.ts +1 -1
- package/dist/providers/jev-provider.d.ts.map +1 -1
- package/dist/providers/jev-provider.js +9 -7
- package/dist/providers/memory-provider.js +9 -8
- package/dist/providers/pi-tools-provider.d.ts.map +1 -1
- package/dist/providers/tasks-provider.d.ts +12 -0
- package/dist/providers/tasks-provider.d.ts.map +1 -0
- package/dist/residency/host.js +10 -9
- package/dist/residency/pi-entry.js +10 -9
- package/dist/residency/pi-entry.js.map +1 -1
- package/dist/runtime/core-override-guest-types.js +2 -2
- package/dist/runtime/guest-types.d.ts +1 -1
- package/dist/runtime/guest-types.d.ts.map +1 -1
- package/dist/runtime/guest-types.js +1 -1
- package/dist/runtime/monty-runtime.js +1 -2
- package/dist/runtime/monty-runtime.js.map +1 -1
- package/dist/runtime/typescript-kernel.js +2 -2
- package/dist/runtime-state-builtins.d.ts +1 -1
- package/dist/runtime-state-builtins.d.ts.map +1 -1
- package/dist/schema/controller.d.ts.map +1 -1
- package/dist/state/store.d.ts.map +1 -1
- package/dist/ui/controller.d.ts +1 -0
- package/dist/ui/controller.d.ts.map +1 -1
- package/dist/ui/conversation-targets.js +2 -2
- package/dist/ui/conversation.js +7 -7
- package/dist/ui/dashboard.js +9 -9
- package/dist/ui/highlight.d.ts.map +1 -1
- package/dist/ui/languages/bend.d.ts +4 -0
- package/dist/ui/languages/bend.d.ts.map +1 -0
- package/dist/ui/languages/bend.js +73 -0
- package/dist/ui/languages/bend.js.map +7 -0
- package/dist/ui/settings.js +1 -2
- package/dist/ui/settings.js.map +1 -1
- package/dist/ui/shell-hang-keys.d.ts.map +1 -1
- package/dist/ui/shell-tasks.d.ts +22 -0
- package/dist/ui/shell-tasks.d.ts.map +1 -0
- package/dist/ui/shell-tasks.js +161 -0
- package/dist/ui/shell-tasks.js.map +7 -0
- package/dist/ui/shiki-catalog.d.ts +2 -1
- package/dist/ui/shiki-catalog.d.ts.map +1 -1
- package/dist/ui/snapshot.d.ts.map +1 -1
- package/dist/ui/types.d.ts +1 -0
- package/dist/ui/types.d.ts.map +1 -1
- package/dist/ui/widget.d.ts.map +1 -1
- package/dist/verified/authority.d.ts +17 -0
- package/dist/verified/authority.d.ts.map +1 -0
- package/dist/verified/generated/authority-kernel.d.ts +10 -0
- package/dist/verified/generated/authority-kernel.js +116 -0
- package/dist/verified/generated/kernel.d.ts +31 -0
- package/dist/verified/generated/kernel.js +351 -0
- package/dist/verified/generated/lifecycle-kernel.d.ts +7 -0
- package/dist/verified/generated/lifecycle-kernel.js +155 -0
- package/dist/verified/generated/manifest.json +54 -0
- package/dist/verified/generated/provider-kernel.d.ts +9 -0
- package/dist/verified/generated/provider-kernel.js +80 -0
- package/dist/verified/generated/storage-kernel.d.ts +11 -0
- package/dist/verified/generated/storage-kernel.js +98 -0
- package/dist/verified/memory.d.ts +11 -0
- package/dist/verified/memory.d.ts.map +1 -0
- package/dist/verified/nat.d.ts +2 -0
- package/dist/verified/nat.d.ts.map +1 -0
- package/dist/verified/policy.d.ts +37 -0
- package/dist/verified/policy.d.ts.map +1 -0
- package/dist/verified/resources.d.ts +14 -0
- package/dist/verified/resources.d.ts.map +1 -0
- package/dist/verified/storage.d.ts +32 -0
- package/dist/verified/storage.d.ts.map +1 -0
- package/dist/worker/event-projection.d.ts +6 -0
- package/dist/worker/event-projection.d.ts.map +1 -0
- package/dist/worker/event-projection.js +99 -0
- package/dist/worker/event-projection.js.map +7 -0
- package/dist/worker/recovery-watchdog.d.ts +12 -0
- package/dist/worker/recovery-watchdog.d.ts.map +1 -0
- package/dist/worker/recovery-watchdog.js +41 -0
- package/dist/worker/recovery-watchdog.js.map +7 -0
- package/dist/worker.js +80 -22
- package/dist/worker.js.map +2 -2
- package/docs/agents.md +26 -14
- package/docs/architecture.md +1 -1
- package/docs/background-tasks.md +140 -0
- package/docs/compaction.md +91 -28
- package/docs/components.md +5 -1
- package/docs/configuration.md +6 -6
- package/docs/foreman.md +4 -4
- package/docs/harnesses.md +95 -0
- package/docs/interface.md +7 -0
- package/docs/jev.md +59 -52
- package/docs/kernels.md +2 -2
- package/docs/licenses/bend-apache-2.0.txt +202 -0
- package/docs/memory-recall.md +1 -1
- package/docs/programmatic-compaction.md +13 -2
- package/docs/provider-capabilities.md +197 -0
- package/docs/shell-middleware.md +3 -3
- package/docs/skills.md +1 -1
- package/docs/verified-kernels.md +278 -0
- package/package.json +14 -4
- package/proofs/abi.json +308 -0
- package/proofs/authority-abi.json +7 -0
- package/proofs/authority-kernel.bend +23 -0
- package/proofs/authority-proof.bend +74 -0
- package/proofs/authority-spec.bend +30 -0
- package/proofs/authority-state.bend +43 -0
- package/proofs/authority-types.d.ts +3 -0
- package/proofs/kernel.bend +139 -0
- package/proofs/lifecycle-abi.json +3 -0
- package/proofs/lifecycle-kernel.bend +11 -0
- package/proofs/lifecycle-proof.bend +249 -0
- package/proofs/lifecycle-spec.bend +261 -0
- package/proofs/lifecycle-types.d.ts +4 -0
- package/proofs/lifecycle.bend +119 -0
- package/proofs/provider-abi.json +4 -0
- package/proofs/provider-kernel.bend +14 -0
- package/proofs/provider-plans.bend +28 -0
- package/proofs/provider-spec.bend +14 -0
- package/proofs/provider-types.d.ts +5 -0
- package/proofs/resource-proof.bend +633 -0
- package/proofs/resource-spec.bend +133 -0
- package/proofs/resources.bend +160 -0
- package/proofs/state-kernel.bend +17 -0
- package/proofs/state-plans.bend +40 -0
- package/proofs/state-proof.bend +42 -0
- package/proofs/state-spec.bend +26 -0
- package/proofs/storage-abi.json +3 -0
- package/proofs/storage-kernel.bend +11 -0
- package/proofs/storage-plans.bend +100 -0
- package/proofs/storage-proof.bend +176 -0
- package/proofs/storage-spec.bend +70 -0
- package/proofs/storage-types.d.ts +8 -0
- package/proofs/types.d.ts +7 -0
- package/scripts/test-verified-kernels.mjs +107 -0
- package/scripts/verified-kernels.mjs +136 -0
- package/skillsets/python/fabric-jev/SKILL.md +13 -9
- package/skillsets/typescript/fabric-exec/SKILL.md +4 -2
- package/skillsets/typescript/fabric-jev/SKILL.md +13 -9
- package/dist/chunks/chunk-3H7SDWZI.js.map +0 -7
- package/dist/chunks/chunk-3TXOQ5MG.js.map +0 -7
- package/dist/chunks/chunk-4NUTVNS2.js.map +0 -7
- package/dist/chunks/chunk-77PDIBK2.js +0 -129
- package/dist/chunks/chunk-77PDIBK2.js.map +0 -7
- package/dist/chunks/chunk-7A6NVHB5.js.map +0 -7
- package/dist/chunks/chunk-FLKGJPCN.js.map +0 -7
- package/dist/chunks/chunk-G4LADAYY.js.map +0 -7
- package/dist/chunks/chunk-IK6PPFWG.js.map +0 -7
- package/dist/chunks/chunk-MQG5QKGI.js.map +0 -7
- package/dist/chunks/chunk-PSNXUZMY.js.map +0 -7
- package/dist/chunks/chunk-Q4XJ4PYL.js.map +0 -7
- package/dist/chunks/chunk-RTXZHKMS.js.map +0 -7
- package/dist/chunks/chunk-U5FYOMG5.js.map +0 -7
- package/dist/chunks/chunk-UQ4LTUH4.js.map +0 -7
- package/dist/chunks/chunk-XT4346N7.js.map +0 -7
- package/dist/jev/browser.d.ts +0 -37
- package/dist/jev/browser.d.ts.map +0 -1
- package/dist/jev/browser.js +0 -13
- package/dist/jev/browser.js.map +0 -7
- /package/dist/chunks/{chunk-IUCVOZRX.js.map → chunk-3SIXBW6A.js.map} +0 -0
- /package/dist/chunks/{chunk-2SWRVIYJ.js.map → chunk-754HA6KO.js.map} +0 -0
- /package/dist/chunks/{chunk-K6DHXXF5.js.map → chunk-B2IVWASP.js.map} +0 -0
- /package/dist/chunks/{chunk-ZDNGXLEC.js.map → chunk-B4HECUJI.js.map} +0 -0
- /package/dist/chunks/{chunk-H6DDV6E2.js.map → chunk-CSJSHBAT.js.map} +0 -0
- /package/dist/chunks/{chunk-MW5VI7IW.js.map → chunk-D4B4CCTA.js.map} +0 -0
- /package/dist/chunks/{chunk-EDL4JDW7.js.map → chunk-EBWMC3OO.js.map} +0 -0
- /package/dist/chunks/{chunk-W3FRE4VI.js.map → chunk-FDIEQEXS.js.map} +0 -0
- /package/dist/chunks/{chunk-3WIGAX56.js.map → chunk-JCV54SSP.js.map} +0 -0
- /package/dist/chunks/{chunk-7VAZ4N43.js.map → chunk-V3PIO7QL.js.map} +0 -0
- /package/dist/chunks/{chunk-MGDLRV2R.js.map → chunk-VQGO4P7C.js.map} +0 -0
- /package/dist/chunks/{chunk-D5WKZONW.js.map → chunk-X3IRR7CV.js.map} +0 -0
- /package/dist/chunks/{chunk-RKRVOBVO.js.map → chunk-YC3QQDZ3.js.map} +0 -0
- /package/dist/chunks/{chunk-36B4AIRT.js.map → chunk-ZTXZ6JDO.js.map} +0 -0
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import Base
|
|
2
|
+
import ./lifecycle-kernel.bend as K
|
|
3
|
+
import ./lifecycle.bend as L
|
|
4
|
+
import ./lifecycle-spec.bend as S
|
|
5
|
+
import ./resource-proof.bend as P
|
|
6
|
+
import ./state-proof.bend as SP
|
|
7
|
+
|
|
8
|
+
def openCases(+revoked: Bool, +cleanup: Bool, p: {cleanup == True{} : Bool} | {Bool.not(revoked) == True{} : Bool}) -> {cleanup == True{} : Bool} | {revoked == False{} : Bool}:
|
|
9
|
+
match p:
|
|
10
|
+
case Inl{yes}:
|
|
11
|
+
Inl{yes}
|
|
12
|
+
case Inr{no}:
|
|
13
|
+
Inr{SP.notTrue(revoked, no)}
|
|
14
|
+
|
|
15
|
+
def openSound(+phase: L.Phase, +revoked: Bool, +cleanup: Bool, p: {L.open(phase, revoked, cleanup) == True{} : Bool}) -> S.Open(phase, revoked, cleanup):
|
|
16
|
+
match phase:
|
|
17
|
+
case L.Closing{}:
|
|
18
|
+
P.falseTrue(p)
|
|
19
|
+
case L.Closed{}:
|
|
20
|
+
P.falseTrue(p)
|
|
21
|
+
case L.Failed{}:
|
|
22
|
+
p
|
|
23
|
+
case L.Staged{}:
|
|
24
|
+
openCases(revoked, cleanup, P.orCases(cleanup, Bool.not(revoked), p))
|
|
25
|
+
case L.Active{}:
|
|
26
|
+
openCases(revoked, cleanup, P.orCases(cleanup, Bool.not(revoked), p))
|
|
27
|
+
case L.Retiring{}:
|
|
28
|
+
openCases(revoked, cleanup, P.orCases(cleanup, Bool.not(revoked), p))
|
|
29
|
+
|
|
30
|
+
def notRevoked(+revoked: Bool, p: {revoked == False{} : Bool}) -> {Bool.not(revoked) == True{} : Bool}:
|
|
31
|
+
%Equal.sym(Bool, revoked, False{}, p) : {Bool.not(_) == True{} : Bool}
|
|
32
|
+
{==}
|
|
33
|
+
|
|
34
|
+
def openEvidence(+revoked: Bool, +cleanup: Bool, p: {cleanup == True{} : Bool} | {revoked == False{} : Bool}) -> {cleanup || Bool.not(revoked) == True{} : Bool}:
|
|
35
|
+
match p:
|
|
36
|
+
case Inl{yes}:
|
|
37
|
+
P.orLeft(cleanup, Bool.not(revoked), yes)
|
|
38
|
+
case Inr{no}:
|
|
39
|
+
P.orRight(cleanup, Bool.not(revoked), notRevoked(revoked, no))
|
|
40
|
+
|
|
41
|
+
def openComplete(+phase: L.Phase, +revoked: Bool, +cleanup: Bool, p: S.Open(phase, revoked, cleanup)) -> {L.open(phase, revoked, cleanup) == True{} : Bool}:
|
|
42
|
+
match phase:
|
|
43
|
+
case L.Closing{}:
|
|
44
|
+
Empty.absurd({False{} == True{} : Bool}, p)
|
|
45
|
+
case L.Closed{}:
|
|
46
|
+
Empty.absurd({False{} == True{} : Bool}, p)
|
|
47
|
+
case L.Failed{}:
|
|
48
|
+
p
|
|
49
|
+
case L.Staged{}:
|
|
50
|
+
openEvidence(revoked, cleanup, p)
|
|
51
|
+
case L.Active{}:
|
|
52
|
+
openEvidence(revoked, cleanup, p)
|
|
53
|
+
case L.Retiring{}:
|
|
54
|
+
openEvidence(revoked, cleanup, p)
|
|
55
|
+
|
|
56
|
+
def beginSelected(+phase: L.Phase, +owner: Bool, +holds: Nat, +calls: Nat, +revoked: Bool, +cleanup: Bool, +good: Bool, p: {L.open(phase, revoked, cleanup) == good : Bool}) -> S.BeginSafe(L.Life{phase, owner, holds, calls, revoked}, cleanup, L.selectBegin(good, L.Life{phase, owner, holds, calls, revoked})):
|
|
57
|
+
match good:
|
|
58
|
+
case False{}:
|
|
59
|
+
{==}
|
|
60
|
+
case True{}:
|
|
61
|
+
(openSound(phase, revoked, cleanup, p), {==})
|
|
62
|
+
|
|
63
|
+
def retainSelected(+phase: L.Phase, +owner: Bool, +holds: Nat, +calls: Nat, +revoked: Bool, +cleanup: Bool, +good: Bool, p: {L.open(phase, revoked, cleanup) == good : Bool}) -> S.RetainSafe(L.Life{phase, owner, holds, calls, revoked}, cleanup, L.selectRetain(good, L.Life{phase, owner, holds, calls, revoked})):
|
|
64
|
+
match good:
|
|
65
|
+
case False{}:
|
|
66
|
+
{==}
|
|
67
|
+
case True{}:
|
|
68
|
+
(openSound(phase, revoked, cleanup, p), {==})
|
|
69
|
+
|
|
70
|
+
def inspectSelected(+phase: L.Phase, +owner: Bool, +holds: Nat, +calls: Nat, +revoked: Bool, +good: Bool, p: {L.open(phase, revoked, False{}) == good : Bool}) -> S.InspectSafe(L.Life{phase, owner, holds, calls, revoked}, L.selectInspect(good, L.Life{phase, owner, holds, calls, revoked})):
|
|
71
|
+
match good:
|
|
72
|
+
case False{}:
|
|
73
|
+
{==}
|
|
74
|
+
case True{}:
|
|
75
|
+
(openSound(phase, revoked, False{}, p), {==})
|
|
76
|
+
|
|
77
|
+
def S.inspect_safe(life):
|
|
78
|
+
match life:
|
|
79
|
+
case L.Life{phase, owner, holds, calls, revoked}:
|
|
80
|
+
inspectSelected(phase, owner, holds, calls, revoked, L.open(phase, revoked, False{}), {==})
|
|
81
|
+
|
|
82
|
+
def S.inspect_complete(owner, holds, calls):
|
|
83
|
+
{==}
|
|
84
|
+
|
|
85
|
+
def S.begin_safe(life, cleanup):
|
|
86
|
+
match life:
|
|
87
|
+
case L.Life{phase, owner, holds, calls, revoked}:
|
|
88
|
+
beginSelected(phase, owner, holds, calls, revoked, cleanup, L.open(phase, revoked, cleanup), {==})
|
|
89
|
+
|
|
90
|
+
def S.retain_safe(life, cleanup):
|
|
91
|
+
match life:
|
|
92
|
+
case L.Life{phase, owner, holds, calls, revoked}:
|
|
93
|
+
retainSelected(phase, owner, holds, calls, revoked, cleanup, L.open(phase, revoked, cleanup), {==})
|
|
94
|
+
|
|
95
|
+
def S.begin_open_complete(phase, owner, holds, calls, revoked, cleanup, p):
|
|
96
|
+
%Equal.sym(Bool, L.open(phase, revoked, cleanup), True{}, openComplete(phase, revoked, cleanup, p)) : {L.selectBegin(_, L.Life{phase, owner, holds, calls, revoked}) == L.Outcome{L.Life{phase, owner, holds, 1n+calls, revoked}, L.Granted{}} : L.Outcome}
|
|
97
|
+
{==}
|
|
98
|
+
|
|
99
|
+
def S.retain_open_complete(phase, owner, holds, calls, revoked, cleanup, p):
|
|
100
|
+
%Equal.sym(Bool, L.open(phase, revoked, cleanup), True{}, openComplete(phase, revoked, cleanup, p)) : {L.selectRetain(_, L.Life{phase, owner, holds, calls, revoked}) == L.Outcome{L.Life{phase, owner, 1n+holds, calls, revoked}, L.Granted{}} : L.Outcome}
|
|
101
|
+
{==}
|
|
102
|
+
|
|
103
|
+
def S.inspect_open_complete(phase, owner, holds, calls, revoked, p):
|
|
104
|
+
%Equal.sym(Bool, L.open(phase, revoked, False{}), True{}, openComplete(phase, revoked, False{}, p)) : {L.selectInspect(_, L.Life{phase, owner, holds, calls, revoked}) == L.Outcome{L.Life{phase, owner, holds, calls, revoked}, L.Granted{}} : L.Outcome}
|
|
105
|
+
{==}
|
|
106
|
+
|
|
107
|
+
def S.close_safe(life):
|
|
108
|
+
match life:
|
|
109
|
+
case L.Life{L.Retiring{}, False{}, 0n, 0n, revoked}:
|
|
110
|
+
({==}, ({==}, ({==}, ({==}, {==}))))
|
|
111
|
+
case L.Life{L.Staged{}, owner, holds, calls, revoked}:
|
|
112
|
+
{==}
|
|
113
|
+
case L.Life{L.Active{}, owner, holds, calls, revoked}:
|
|
114
|
+
{==}
|
|
115
|
+
case L.Life{L.Retiring{}, True{}, holds, calls, revoked}:
|
|
116
|
+
{==}
|
|
117
|
+
case L.Life{L.Retiring{}, False{}, 1n+holds, calls, revoked}:
|
|
118
|
+
{==}
|
|
119
|
+
case L.Life{L.Retiring{}, False{}, 0n, 1n+calls, revoked}:
|
|
120
|
+
{==}
|
|
121
|
+
case L.Life{L.Closing{}, owner, holds, calls, revoked}:
|
|
122
|
+
{==}
|
|
123
|
+
case L.Life{L.Closed{}, owner, holds, calls, revoked}:
|
|
124
|
+
{==}
|
|
125
|
+
case L.Life{L.Failed{}, owner, holds, calls, revoked}:
|
|
126
|
+
{==}
|
|
127
|
+
|
|
128
|
+
def S.close_complete(revoked):
|
|
129
|
+
{==}
|
|
130
|
+
|
|
131
|
+
def S.begin_complete(owner, holds, calls):
|
|
132
|
+
{==}
|
|
133
|
+
|
|
134
|
+
def S.release_exact(phase, owner, holds, calls, revoked):
|
|
135
|
+
{==}
|
|
136
|
+
|
|
137
|
+
def S.end_exact(phase, owner, holds, calls, revoked):
|
|
138
|
+
{==}
|
|
139
|
+
|
|
140
|
+
def S.revoke_preserves_work(phase, owner, holds, calls, revoked):
|
|
141
|
+
match phase:
|
|
142
|
+
case L.Staged{}:
|
|
143
|
+
{==}
|
|
144
|
+
case L.Active{}:
|
|
145
|
+
{==}
|
|
146
|
+
case L.Retiring{}:
|
|
147
|
+
{==}
|
|
148
|
+
case L.Closing{}:
|
|
149
|
+
{==}
|
|
150
|
+
case L.Closed{}:
|
|
151
|
+
{==}
|
|
152
|
+
case L.Failed{}:
|
|
153
|
+
{==}
|
|
154
|
+
|
|
155
|
+
def S.drop_owner_preserves_work(phase, owner, holds, calls, revoked):
|
|
156
|
+
{==}
|
|
157
|
+
|
|
158
|
+
def S.retire_preserves_work(phase, owner, holds, calls, revoked):
|
|
159
|
+
match phase:
|
|
160
|
+
case L.Staged{}:
|
|
161
|
+
{==}
|
|
162
|
+
case L.Active{}:
|
|
163
|
+
{==}
|
|
164
|
+
case L.Retiring{}:
|
|
165
|
+
{==}
|
|
166
|
+
case L.Closing{}:
|
|
167
|
+
{==}
|
|
168
|
+
case L.Closed{}:
|
|
169
|
+
{==}
|
|
170
|
+
case L.Failed{}:
|
|
171
|
+
{==}
|
|
172
|
+
|
|
173
|
+
def S.retain_complete(owner, holds, calls):
|
|
174
|
+
{==}
|
|
175
|
+
|
|
176
|
+
def S.release_underflow_refused(phase, owner, calls, revoked):
|
|
177
|
+
{==}
|
|
178
|
+
|
|
179
|
+
def S.end_underflow_refused(phase, owner, holds, revoked):
|
|
180
|
+
{==}
|
|
181
|
+
|
|
182
|
+
def S.quarantine_preserves_work(owner, holds, calls, revoked):
|
|
183
|
+
{==}
|
|
184
|
+
|
|
185
|
+
def S.cleanup_after_revocation(owner, holds, calls):
|
|
186
|
+
{==}
|
|
187
|
+
|
|
188
|
+
def S.activation_exact(phase, owner, holds, calls, revoked):
|
|
189
|
+
match phase:
|
|
190
|
+
case L.Staged{}:
|
|
191
|
+
{==}
|
|
192
|
+
case L.Active{}:
|
|
193
|
+
{==}
|
|
194
|
+
case L.Retiring{}:
|
|
195
|
+
{==}
|
|
196
|
+
case L.Closing{}:
|
|
197
|
+
{==}
|
|
198
|
+
case L.Closed{}:
|
|
199
|
+
{==}
|
|
200
|
+
case L.Failed{}:
|
|
201
|
+
{==}
|
|
202
|
+
|
|
203
|
+
def S.completion_exact(phase, owner, holds, calls, revoked):
|
|
204
|
+
match phase:
|
|
205
|
+
case L.Staged{}:
|
|
206
|
+
{==}
|
|
207
|
+
case L.Active{}:
|
|
208
|
+
{==}
|
|
209
|
+
case L.Retiring{}:
|
|
210
|
+
{==}
|
|
211
|
+
case L.Closing{}:
|
|
212
|
+
{==}
|
|
213
|
+
case L.Closed{}:
|
|
214
|
+
{==}
|
|
215
|
+
case L.Failed{}:
|
|
216
|
+
{==}
|
|
217
|
+
|
|
218
|
+
def S.failure_exact(phase, owner, holds, calls, revoked):
|
|
219
|
+
match phase:
|
|
220
|
+
case L.Staged{}:
|
|
221
|
+
{==}
|
|
222
|
+
case L.Active{}:
|
|
223
|
+
{==}
|
|
224
|
+
case L.Retiring{}:
|
|
225
|
+
{==}
|
|
226
|
+
case L.Closing{}:
|
|
227
|
+
{==}
|
|
228
|
+
case L.Closed{}:
|
|
229
|
+
{==}
|
|
230
|
+
case L.Failed{}:
|
|
231
|
+
{==}
|
|
232
|
+
|
|
233
|
+
def S.closing_refuses_work(owner, holds, calls, revoked, cleanup):
|
|
234
|
+
{==}
|
|
235
|
+
|
|
236
|
+
def S.revoked_refuses_work(phase, owner, holds, calls):
|
|
237
|
+
match phase:
|
|
238
|
+
case L.Staged{}:
|
|
239
|
+
{==}
|
|
240
|
+
case L.Active{}:
|
|
241
|
+
{==}
|
|
242
|
+
case L.Retiring{}:
|
|
243
|
+
{==}
|
|
244
|
+
case L.Closing{}:
|
|
245
|
+
{==}
|
|
246
|
+
case L.Closed{}:
|
|
247
|
+
{==}
|
|
248
|
+
case L.Failed{}:
|
|
249
|
+
{==}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import Base
|
|
2
|
+
import ./lifecycle-kernel.bend as K
|
|
3
|
+
import ./lifecycle.bend as L
|
|
4
|
+
|
|
5
|
+
# Independent obligations over input and output records. Host promises, opaque
|
|
6
|
+
# identities and delivery of completion events are not encoded as proved facts.
|
|
7
|
+
def Open(phase: L.Phase, revoked: Bool, cleanup: Bool) -> Type:
|
|
8
|
+
match phase:
|
|
9
|
+
case L.Closing{}:
|
|
10
|
+
Empty
|
|
11
|
+
case L.Closed{}:
|
|
12
|
+
Empty
|
|
13
|
+
case L.Failed{}:
|
|
14
|
+
{cleanup == True{} : Bool}
|
|
15
|
+
case _:
|
|
16
|
+
{cleanup == True{} : Bool} | {revoked == False{} : Bool}
|
|
17
|
+
|
|
18
|
+
def BeginSafe(+before: L.Life, cleanup: Bool, outcome: L.Outcome) -> Type:
|
|
19
|
+
match before outcome:
|
|
20
|
+
case L.Life{phase, owner, holds, calls, revoked} L.Outcome{after, L.Granted{}}:
|
|
21
|
+
Open(phase, revoked, cleanup) & {after == L.Life{phase, owner, holds, 1n+calls, revoked} : L.Life}
|
|
22
|
+
case _ L.Outcome{after, L.Denied{}}:
|
|
23
|
+
{after == before : L.Life}
|
|
24
|
+
case _ L.Outcome{after, L.StartClose{}}:
|
|
25
|
+
Empty
|
|
26
|
+
|
|
27
|
+
def RetainSafe(+before: L.Life, cleanup: Bool, outcome: L.Outcome) -> Type:
|
|
28
|
+
match before outcome:
|
|
29
|
+
case L.Life{phase, owner, holds, calls, revoked} L.Outcome{after, L.Granted{}}:
|
|
30
|
+
Open(phase, revoked, cleanup) & {after == L.Life{phase, owner, 1n+holds, calls, revoked} : L.Life}
|
|
31
|
+
case _ L.Outcome{after, L.Denied{}}:
|
|
32
|
+
{after == before : L.Life}
|
|
33
|
+
case _ L.Outcome{after, L.StartClose{}}:
|
|
34
|
+
Empty
|
|
35
|
+
|
|
36
|
+
def CloseSafe(+before: L.Life, outcome: L.Outcome) -> Type:
|
|
37
|
+
match before outcome:
|
|
38
|
+
case L.Life{phase, owner, holds, calls, revoked} L.Outcome{after, L.StartClose{}}:
|
|
39
|
+
{phase == L.Retiring{} : L.Phase} & ({owner == False{} : Bool} & ({holds == 0n : Nat} & ({calls == 0n : Nat} & {after == L.Life{L.Closing{}, False{}, 0n, 0n, revoked} : L.Life})))
|
|
40
|
+
case _ L.Outcome{after, L.Denied{}}:
|
|
41
|
+
{after == before : L.Life}
|
|
42
|
+
case _ L.Outcome{after, L.Granted{}}:
|
|
43
|
+
Empty
|
|
44
|
+
|
|
45
|
+
def InspectSafe(+before: L.Life, outcome: L.Outcome) -> Type:
|
|
46
|
+
match before outcome:
|
|
47
|
+
case L.Life{phase, owner, holds, calls, revoked} L.Outcome{after, L.Granted{}}:
|
|
48
|
+
Open(phase, revoked, False{}) & {after == before : L.Life}
|
|
49
|
+
case _ L.Outcome{after, L.Denied{}}:
|
|
50
|
+
{after == before : L.Life}
|
|
51
|
+
case _ L.Outcome{after, L.StartClose{}}:
|
|
52
|
+
Empty
|
|
53
|
+
|
|
54
|
+
law inspect_safe:
|
|
55
|
+
for +life: L.Life
|
|
56
|
+
InspectSafe(life, K.bindingStep(life, L.Inspect{}))
|
|
57
|
+
|
|
58
|
+
law inspect_complete:
|
|
59
|
+
for +owner: Bool
|
|
60
|
+
for +holds: Nat
|
|
61
|
+
for +calls: Nat
|
|
62
|
+
{K.bindingStep(L.Life{L.Active{}, owner, holds, calls, False{}}, L.Inspect{}) == L.Outcome{L.Life{L.Active{}, owner, holds, calls, False{}}, L.Granted{}} : L.Outcome}
|
|
63
|
+
|
|
64
|
+
law begin_safe:
|
|
65
|
+
for +life: L.Life
|
|
66
|
+
for +cleanup: Bool
|
|
67
|
+
BeginSafe(life, cleanup, K.bindingStep(life, L.Begin{cleanup}))
|
|
68
|
+
|
|
69
|
+
law retain_safe:
|
|
70
|
+
for +life: L.Life
|
|
71
|
+
for +cleanup: Bool
|
|
72
|
+
RetainSafe(life, cleanup, K.bindingStep(life, L.Retain{cleanup}))
|
|
73
|
+
|
|
74
|
+
# Completeness follows the independent Open predicate for every phase, not
|
|
75
|
+
# just the Active/non-revoked examples below.
|
|
76
|
+
law begin_open_complete:
|
|
77
|
+
for +phase: L.Phase
|
|
78
|
+
for +owner: Bool
|
|
79
|
+
for +holds: Nat
|
|
80
|
+
for +calls: Nat
|
|
81
|
+
for +revoked: Bool
|
|
82
|
+
for +cleanup: Bool
|
|
83
|
+
for p: Open(phase, revoked, cleanup)
|
|
84
|
+
{K.bindingStep(L.Life{phase, owner, holds, calls, revoked}, L.Begin{cleanup}) == L.Outcome{L.Life{phase, owner, holds, 1n+calls, revoked}, L.Granted{}} : L.Outcome}
|
|
85
|
+
|
|
86
|
+
law retain_open_complete:
|
|
87
|
+
for +phase: L.Phase
|
|
88
|
+
for +owner: Bool
|
|
89
|
+
for +holds: Nat
|
|
90
|
+
for +calls: Nat
|
|
91
|
+
for +revoked: Bool
|
|
92
|
+
for +cleanup: Bool
|
|
93
|
+
for p: Open(phase, revoked, cleanup)
|
|
94
|
+
{K.bindingStep(L.Life{phase, owner, holds, calls, revoked}, L.Retain{cleanup}) == L.Outcome{L.Life{phase, owner, 1n+holds, calls, revoked}, L.Granted{}} : L.Outcome}
|
|
95
|
+
|
|
96
|
+
law inspect_open_complete:
|
|
97
|
+
for +phase: L.Phase
|
|
98
|
+
for +owner: Bool
|
|
99
|
+
for +holds: Nat
|
|
100
|
+
for +calls: Nat
|
|
101
|
+
for +revoked: Bool
|
|
102
|
+
for p: Open(phase, revoked, False{})
|
|
103
|
+
{K.bindingStep(L.Life{phase, owner, holds, calls, revoked}, L.Inspect{}) == L.Outcome{L.Life{phase, owner, holds, calls, revoked}, L.Granted{}} : L.Outcome}
|
|
104
|
+
|
|
105
|
+
law close_safe:
|
|
106
|
+
for +life: L.Life
|
|
107
|
+
CloseSafe(life, K.bindingStep(life, L.Close{}))
|
|
108
|
+
|
|
109
|
+
law close_complete:
|
|
110
|
+
for +revoked: Bool
|
|
111
|
+
{K.bindingStep(L.Life{L.Retiring{}, False{}, 0n, 0n, revoked}, L.Close{}) == L.Outcome{L.Life{L.Closing{}, False{}, 0n, 0n, revoked}, L.StartClose{}} : L.Outcome}
|
|
112
|
+
|
|
113
|
+
law begin_complete:
|
|
114
|
+
for +owner: Bool
|
|
115
|
+
for +holds: Nat
|
|
116
|
+
for +calls: Nat
|
|
117
|
+
{K.bindingStep(L.Life{L.Active{}, owner, holds, calls, False{}}, L.Begin{False{}}) == L.Outcome{L.Life{L.Active{}, owner, holds, 1n+calls, False{}}, L.Granted{}} : L.Outcome}
|
|
118
|
+
|
|
119
|
+
law release_exact:
|
|
120
|
+
for +phase: L.Phase
|
|
121
|
+
for +owner: Bool
|
|
122
|
+
for +holds: Nat
|
|
123
|
+
for +calls: Nat
|
|
124
|
+
for +revoked: Bool
|
|
125
|
+
{K.bindingStep(L.Life{phase, owner, 1n+holds, calls, revoked}, L.Release{}) == L.Outcome{L.Life{phase, owner, holds, calls, revoked}, L.Granted{}} : L.Outcome}
|
|
126
|
+
|
|
127
|
+
law end_exact:
|
|
128
|
+
for +phase: L.Phase
|
|
129
|
+
for +owner: Bool
|
|
130
|
+
for +holds: Nat
|
|
131
|
+
for +calls: Nat
|
|
132
|
+
for +revoked: Bool
|
|
133
|
+
{K.bindingStep(L.Life{phase, owner, holds, 1n+calls, revoked}, L.End{}) == L.Outcome{L.Life{phase, owner, holds, calls, revoked}, L.Granted{}} : L.Outcome}
|
|
134
|
+
|
|
135
|
+
def RetiredPhase(phase: L.Phase) -> L.Phase:
|
|
136
|
+
match phase:
|
|
137
|
+
case L.Staged{}:
|
|
138
|
+
L.Retiring{}
|
|
139
|
+
case L.Active{}:
|
|
140
|
+
L.Retiring{}
|
|
141
|
+
case _:
|
|
142
|
+
phase
|
|
143
|
+
|
|
144
|
+
law revoke_preserves_work:
|
|
145
|
+
for +phase: L.Phase
|
|
146
|
+
for +owner: Bool
|
|
147
|
+
for +holds: Nat
|
|
148
|
+
for +calls: Nat
|
|
149
|
+
for +revoked: Bool
|
|
150
|
+
{K.bindingStep(L.Life{phase, owner, holds, calls, revoked}, L.Revoke{}) == L.Outcome{L.Life{RetiredPhase(phase), False{}, holds, calls, True{}}, L.Granted{}} : L.Outcome}
|
|
151
|
+
|
|
152
|
+
law drop_owner_preserves_work:
|
|
153
|
+
for +phase: L.Phase
|
|
154
|
+
for +owner: Bool
|
|
155
|
+
for +holds: Nat
|
|
156
|
+
for +calls: Nat
|
|
157
|
+
for +revoked: Bool
|
|
158
|
+
{K.bindingStep(L.Life{phase, owner, holds, calls, revoked}, L.DropOwner{}) == L.Outcome{L.Life{phase, False{}, holds, calls, revoked}, L.Granted{}} : L.Outcome}
|
|
159
|
+
|
|
160
|
+
law retire_preserves_work:
|
|
161
|
+
for +phase: L.Phase
|
|
162
|
+
for +owner: Bool
|
|
163
|
+
for +holds: Nat
|
|
164
|
+
for +calls: Nat
|
|
165
|
+
for +revoked: Bool
|
|
166
|
+
{K.bindingStep(L.Life{phase, owner, holds, calls, revoked}, L.Retire{}) == L.Outcome{L.Life{RetiredPhase(phase), owner, holds, calls, revoked}, L.Granted{}} : L.Outcome}
|
|
167
|
+
|
|
168
|
+
law retain_complete:
|
|
169
|
+
for +owner: Bool
|
|
170
|
+
for +holds: Nat
|
|
171
|
+
for +calls: Nat
|
|
172
|
+
{K.bindingStep(L.Life{L.Active{}, owner, holds, calls, False{}}, L.Retain{False{}}) == L.Outcome{L.Life{L.Active{}, owner, 1n+holds, calls, False{}}, L.Granted{}} : L.Outcome}
|
|
173
|
+
|
|
174
|
+
law release_underflow_refused:
|
|
175
|
+
for +phase: L.Phase
|
|
176
|
+
for +owner: Bool
|
|
177
|
+
for +calls: Nat
|
|
178
|
+
for +revoked: Bool
|
|
179
|
+
{K.bindingStep(L.Life{phase, owner, 0n, calls, revoked}, L.Release{}) == L.Outcome{L.Life{phase, owner, 0n, calls, revoked}, L.Denied{}} : L.Outcome}
|
|
180
|
+
|
|
181
|
+
law end_underflow_refused:
|
|
182
|
+
for +phase: L.Phase
|
|
183
|
+
for +owner: Bool
|
|
184
|
+
for +holds: Nat
|
|
185
|
+
for +revoked: Bool
|
|
186
|
+
{K.bindingStep(L.Life{phase, owner, holds, 0n, revoked}, L.End{}) == L.Outcome{L.Life{phase, owner, holds, 0n, revoked}, L.Denied{}} : L.Outcome}
|
|
187
|
+
|
|
188
|
+
law quarantine_preserves_work:
|
|
189
|
+
for +owner: Bool
|
|
190
|
+
for +holds: Nat
|
|
191
|
+
for +calls: Nat
|
|
192
|
+
for +revoked: Bool
|
|
193
|
+
{K.bindingStep(L.Life{L.Retiring{}, owner, holds, calls, revoked}, L.Fail{}) == L.Outcome{L.Life{L.Failed{}, False{}, holds, calls, True{}}, L.Granted{}} : L.Outcome}
|
|
194
|
+
|
|
195
|
+
law cleanup_after_revocation:
|
|
196
|
+
for +owner: Bool
|
|
197
|
+
for +holds: Nat
|
|
198
|
+
for +calls: Nat
|
|
199
|
+
{K.bindingStep(L.Life{L.Retiring{}, owner, holds, calls, True{}}, L.Begin{True{}}) == L.Outcome{L.Life{L.Retiring{}, owner, holds, 1n+calls, True{}}, L.Granted{}} : L.Outcome}
|
|
200
|
+
|
|
201
|
+
def Activation(phase: L.Phase, owner: Bool, holds: Nat, calls: Nat, revoked: Bool) -> L.Outcome:
|
|
202
|
+
match phase:
|
|
203
|
+
case L.Staged{}:
|
|
204
|
+
L.Outcome{L.Life{L.Active{}, owner, holds, calls, revoked}, L.Granted{}}
|
|
205
|
+
case L.Active{}:
|
|
206
|
+
L.Outcome{L.Life{L.Active{}, owner, holds, calls, revoked}, L.Granted{}}
|
|
207
|
+
case _:
|
|
208
|
+
L.Outcome{L.Life{phase, owner, holds, calls, revoked}, L.Denied{}}
|
|
209
|
+
|
|
210
|
+
def Completion(phase: L.Phase, owner: Bool, holds: Nat, calls: Nat, revoked: Bool) -> L.Outcome:
|
|
211
|
+
match phase:
|
|
212
|
+
case L.Closing{}:
|
|
213
|
+
L.Outcome{L.Life{L.Closed{}, owner, holds, calls, revoked}, L.Granted{}}
|
|
214
|
+
case _:
|
|
215
|
+
L.Outcome{L.Life{phase, owner, holds, calls, revoked}, L.Denied{}}
|
|
216
|
+
|
|
217
|
+
def Failure(phase: L.Phase, owner: Bool, holds: Nat, calls: Nat, revoked: Bool) -> L.Outcome:
|
|
218
|
+
match phase:
|
|
219
|
+
case L.Closed{}:
|
|
220
|
+
L.Outcome{L.Life{L.Closed{}, owner, holds, calls, revoked}, L.Denied{}}
|
|
221
|
+
case _:
|
|
222
|
+
L.Outcome{L.Life{L.Failed{}, False{}, holds, calls, True{}}, L.Granted{}}
|
|
223
|
+
|
|
224
|
+
law activation_exact:
|
|
225
|
+
for +phase: L.Phase
|
|
226
|
+
for +owner: Bool
|
|
227
|
+
for +holds: Nat
|
|
228
|
+
for +calls: Nat
|
|
229
|
+
for +revoked: Bool
|
|
230
|
+
{K.bindingStep(L.Life{phase, owner, holds, calls, revoked}, L.Activate{}) == Activation(phase, owner, holds, calls, revoked) : L.Outcome}
|
|
231
|
+
|
|
232
|
+
law completion_exact:
|
|
233
|
+
for +phase: L.Phase
|
|
234
|
+
for +owner: Bool
|
|
235
|
+
for +holds: Nat
|
|
236
|
+
for +calls: Nat
|
|
237
|
+
for +revoked: Bool
|
|
238
|
+
{K.bindingStep(L.Life{phase, owner, holds, calls, revoked}, L.Complete{}) == Completion(phase, owner, holds, calls, revoked) : L.Outcome}
|
|
239
|
+
|
|
240
|
+
law failure_exact:
|
|
241
|
+
for +phase: L.Phase
|
|
242
|
+
for +owner: Bool
|
|
243
|
+
for +holds: Nat
|
|
244
|
+
for +calls: Nat
|
|
245
|
+
for +revoked: Bool
|
|
246
|
+
{K.bindingStep(L.Life{phase, owner, holds, calls, revoked}, L.Fail{}) == Failure(phase, owner, holds, calls, revoked) : L.Outcome}
|
|
247
|
+
|
|
248
|
+
law closing_refuses_work:
|
|
249
|
+
for +owner: Bool
|
|
250
|
+
for +holds: Nat
|
|
251
|
+
for +calls: Nat
|
|
252
|
+
for +revoked: Bool
|
|
253
|
+
for +cleanup: Bool
|
|
254
|
+
{K.bindingStep(L.Life{L.Closing{}, owner, holds, calls, revoked}, L.Begin{cleanup}) == L.Outcome{L.Life{L.Closing{}, owner, holds, calls, revoked}, L.Denied{}} : L.Outcome}
|
|
255
|
+
|
|
256
|
+
law revoked_refuses_work:
|
|
257
|
+
for +phase: L.Phase
|
|
258
|
+
for +owner: Bool
|
|
259
|
+
for +holds: Nat
|
|
260
|
+
for +calls: Nat
|
|
261
|
+
{K.bindingStep(L.Life{phase, owner, holds, calls, True{}}, L.Begin{False{}}) == L.Outcome{L.Life{phase, owner, holds, calls, True{}}, L.Denied{}} : L.Outcome}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type BindingPhase = { $: "Staged" | "Active" | "Retiring" | "Closing" | "Closed" | "Failed" };
|
|
2
|
+
export interface BindingLife { $: "Life"; phase: BindingPhase; owner: boolean; holds: bigint; calls: bigint; revoked: boolean }
|
|
3
|
+
export type BindingEvent = { $: "Inspect" | "Activate" | "Retire" | "DropOwner" | "Revoke" | "Release" | "End" | "Close" | "Complete" | "Fail" } | { $: "Retain" | "Begin"; cleanup: boolean };
|
|
4
|
+
export interface BindingOutcome { $: "Outcome"; next: BindingLife; command: { $: "Denied" | "Granted" | "StartClose" } }
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import Base
|
|
2
|
+
|
|
3
|
+
type Phase is Data:
|
|
4
|
+
Staged{}
|
|
5
|
+
Active{}
|
|
6
|
+
Retiring{}
|
|
7
|
+
Closing{}
|
|
8
|
+
Closed{}
|
|
9
|
+
Failed{}
|
|
10
|
+
|
|
11
|
+
type Life is Data:
|
|
12
|
+
Life{phase: Phase, owner: Bool, holds: Nat, calls: Nat, revoked: Bool}
|
|
13
|
+
|
|
14
|
+
type BindingEvent is Data:
|
|
15
|
+
Inspect{}
|
|
16
|
+
Activate{}
|
|
17
|
+
Retire{}
|
|
18
|
+
DropOwner{}
|
|
19
|
+
Revoke{}
|
|
20
|
+
Retain{cleanup: Bool}
|
|
21
|
+
Release{}
|
|
22
|
+
Begin{cleanup: Bool}
|
|
23
|
+
End{}
|
|
24
|
+
Close{}
|
|
25
|
+
Complete{}
|
|
26
|
+
Fail{}
|
|
27
|
+
|
|
28
|
+
type Command is Data:
|
|
29
|
+
Denied{}
|
|
30
|
+
Granted{}
|
|
31
|
+
StartClose{}
|
|
32
|
+
|
|
33
|
+
type Outcome is Data:
|
|
34
|
+
Outcome{next: Life, command: Command}
|
|
35
|
+
|
|
36
|
+
def open(phase: Phase, revoked: Bool, cleanup: Bool) -> Bool:
|
|
37
|
+
match phase:
|
|
38
|
+
case Closing{}:
|
|
39
|
+
False{}
|
|
40
|
+
case Closed{}:
|
|
41
|
+
False{}
|
|
42
|
+
case Failed{}:
|
|
43
|
+
cleanup
|
|
44
|
+
case _:
|
|
45
|
+
cleanup || Bool.not(revoked)
|
|
46
|
+
|
|
47
|
+
def retiring(phase: Phase) -> Phase:
|
|
48
|
+
match phase:
|
|
49
|
+
case Staged{}:
|
|
50
|
+
Retiring{}
|
|
51
|
+
case Active{}:
|
|
52
|
+
Retiring{}
|
|
53
|
+
case _:
|
|
54
|
+
phase
|
|
55
|
+
|
|
56
|
+
def selectBegin(good: Bool, life: Life) -> Outcome:
|
|
57
|
+
match good life:
|
|
58
|
+
case False{} _:
|
|
59
|
+
Outcome{life, Denied{}}
|
|
60
|
+
case True{} Life{phase, owner, holds, calls, revoked}:
|
|
61
|
+
Outcome{Life{phase, owner, holds, 1n+calls, revoked}, Granted{}}
|
|
62
|
+
|
|
63
|
+
def selectRetain(good: Bool, life: Life) -> Outcome:
|
|
64
|
+
match good life:
|
|
65
|
+
case False{} _:
|
|
66
|
+
Outcome{life, Denied{}}
|
|
67
|
+
case True{} Life{phase, owner, holds, calls, revoked}:
|
|
68
|
+
Outcome{Life{phase, owner, 1n+holds, calls, revoked}, Granted{}}
|
|
69
|
+
|
|
70
|
+
def selectInspect(good: Bool, life: Life) -> Outcome:
|
|
71
|
+
match good:
|
|
72
|
+
case False{}:
|
|
73
|
+
Outcome{life, Denied{}}
|
|
74
|
+
case True{}:
|
|
75
|
+
Outcome{life, Granted{}}
|
|
76
|
+
|
|
77
|
+
def step(event: BindingEvent, life: Life) -> Outcome:
|
|
78
|
+
match event life:
|
|
79
|
+
case Inspect{} Life{+phase, +owner, +holds, +calls, +revoked}:
|
|
80
|
+
selectInspect(open(phase, revoked, False{}), life)
|
|
81
|
+
case Activate{} Life{Staged{}, owner, holds, calls, revoked}:
|
|
82
|
+
Outcome{Life{Active{}, owner, holds, calls, revoked}, Granted{}}
|
|
83
|
+
case Activate{} Life{Active{}, owner, holds, calls, revoked}:
|
|
84
|
+
Outcome{life, Granted{}}
|
|
85
|
+
case Activate{} _:
|
|
86
|
+
Outcome{life, Denied{}}
|
|
87
|
+
case Retire{} Life{+phase, +owner, +holds, +calls, +revoked}:
|
|
88
|
+
Outcome{Life{retiring(phase), owner, holds, calls, revoked}, Granted{}}
|
|
89
|
+
case DropOwner{} Life{+phase, +owner, +holds, +calls, +revoked}:
|
|
90
|
+
Outcome{Life{phase, False{}, holds, calls, revoked}, Granted{}}
|
|
91
|
+
case Revoke{} Life{+phase, +owner, +holds, +calls, +revoked}:
|
|
92
|
+
Outcome{Life{retiring(phase), False{}, holds, calls, True{}}, Granted{}}
|
|
93
|
+
case Retain{cleanup} Life{+phase, +owner, +holds, +calls, +revoked}:
|
|
94
|
+
selectRetain(open(phase, revoked, cleanup), life)
|
|
95
|
+
case Release{} Life{phase, owner, 0n, calls, revoked}:
|
|
96
|
+
Outcome{life, Denied{}}
|
|
97
|
+
case Release{} Life{phase, owner, 1n+holds, calls, revoked}:
|
|
98
|
+
Outcome{Life{phase, owner, holds, calls, revoked}, Granted{}}
|
|
99
|
+
case Begin{cleanup} Life{+phase, +owner, +holds, +calls, +revoked}:
|
|
100
|
+
selectBegin(open(phase, revoked, cleanup), life)
|
|
101
|
+
case End{} Life{phase, owner, holds, 0n, revoked}:
|
|
102
|
+
Outcome{life, Denied{}}
|
|
103
|
+
case End{} Life{phase, owner, holds, 1n+calls, revoked}:
|
|
104
|
+
Outcome{Life{phase, owner, holds, calls, revoked}, Granted{}}
|
|
105
|
+
case Close{} Life{Retiring{}, False{}, 0n, 0n, revoked}:
|
|
106
|
+
Outcome{Life{Closing{}, False{}, 0n, 0n, revoked}, StartClose{}}
|
|
107
|
+
case Close{} _:
|
|
108
|
+
Outcome{life, Denied{}}
|
|
109
|
+
case Complete{} Life{Closing{}, owner, holds, calls, revoked}:
|
|
110
|
+
Outcome{Life{Closed{}, owner, holds, calls, revoked}, Granted{}}
|
|
111
|
+
case Complete{} _:
|
|
112
|
+
Outcome{life, Denied{}}
|
|
113
|
+
case Fail{} Life{Closed{}, owner, holds, calls, revoked}:
|
|
114
|
+
Outcome{life, Denied{}}
|
|
115
|
+
case Fail{} Life{+phase, +owner, +holds, +calls, +revoked}:
|
|
116
|
+
Outcome{Life{Failed{}, False{}, holds, calls, True{}}, Granted{}}
|
|
117
|
+
|
|
118
|
+
def bindingStep(life: Life, event: BindingEvent) -> Outcome:
|
|
119
|
+
step(event, life)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import Base
|
|
2
|
+
import ./provider-plans.bend as P
|
|
3
|
+
|
|
4
|
+
def providerTake(ticket: P.Ticket, key: +List<Nat>, observed: +List<Nat>, stopped: Bool) -> P.Outcome:
|
|
5
|
+
P.take(ticket, key, observed, stopped)
|
|
6
|
+
|
|
7
|
+
def providerRevoke(ticket: P.Ticket) -> P.Ticket:
|
|
8
|
+
P.revoke(ticket)
|
|
9
|
+
|
|
10
|
+
type ProviderKernel is Type:
|
|
11
|
+
ProviderKernel{take: P.Ticket -> +List<Nat> -> +List<Nat> -> Bool -> P.Outcome, revoke: P.Ticket -> P.Ticket}
|
|
12
|
+
|
|
13
|
+
def main() -> IO(ProviderKernel):
|
|
14
|
+
IO.pure(ProviderKernel, ProviderKernel{providerTake, providerRevoke})
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import Base
|
|
2
|
+
import ./state-plans.bend as S
|
|
3
|
+
|
|
4
|
+
type Ticket is Data:
|
|
5
|
+
Ticket{grant: S.Grant, expected: +List<Nat>, payload: +List<Nat>}
|
|
6
|
+
|
|
7
|
+
type Outcome is Data:
|
|
8
|
+
Outcome{next: Ticket, plan: S.Plan}
|
|
9
|
+
|
|
10
|
+
def take(ticket: Ticket, key: +List<Nat>, observed: +List<Nat>, stopped: Bool) -> Outcome:
|
|
11
|
+
match ticket:
|
|
12
|
+
case Ticket{+grant, +expected, +payload}:
|
|
13
|
+
Outcome{Ticket{S.revoke(grant), expected, payload}, S.writePlan(grant, key, expected, observed, payload, stopped)}
|
|
14
|
+
|
|
15
|
+
def revoke(ticket: Ticket) -> Ticket:
|
|
16
|
+
match ticket:
|
|
17
|
+
case Ticket{grant, expected, payload}:
|
|
18
|
+
Ticket{S.revoke(grant), expected, payload}
|
|
19
|
+
|
|
20
|
+
def next(outcome: Outcome) -> Ticket:
|
|
21
|
+
match outcome:
|
|
22
|
+
case Outcome{ticket, plan}:
|
|
23
|
+
ticket
|
|
24
|
+
|
|
25
|
+
def plan(outcome: Outcome) -> S.Plan:
|
|
26
|
+
match outcome:
|
|
27
|
+
case Outcome{ticket, plan}:
|
|
28
|
+
plan
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import Base
|
|
2
|
+
import ./provider-plans.bend as P
|
|
3
|
+
import ./state-plans.bend as S
|
|
4
|
+
import ./state-spec.bend as SS
|
|
5
|
+
|
|
6
|
+
def Safe(ticket: P.Ticket, key: +List<Nat>, observed: +List<Nat>, stopped: Bool, plan: S.Plan) -> Type:
|
|
7
|
+
match ticket:
|
|
8
|
+
case P.Ticket{grant, expected, payload}:
|
|
9
|
+
SS.WriteSafe(grant, key, expected, observed, payload, stopped, plan)
|
|
10
|
+
|
|
11
|
+
def Consumed(before: P.Ticket, after: P.Ticket) -> Type:
|
|
12
|
+
match before after:
|
|
13
|
+
case P.Ticket{S.Grant{active, key}, expected, payload} P.Ticket{S.Grant{live, target}, revision, value}:
|
|
14
|
+
{live == False{} : Bool} & ({target == key : +List<Nat>} & ({revision == expected : +List<Nat>} & {value == payload : +List<Nat>}))
|