@agoric/portfolio-api 0.1.1-dev-68817f5.0.68817f5 → 0.1.1-dev-96faaf4.0.96faaf4

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.
@@ -0,0 +1,56 @@
1
+ stateDiagram-v2
2
+ [*] --> transaction_defined
3
+ state transaction_defined
4
+ note right of transaction_defined
5
+ User specifies their portfolio offer in a transaction (usually in the Ymax web UI)
6
+ end note
7
+ transaction_defined --> transaction_committed: User signed a transaction with the offer and broadcast it
8
+ state transaction_committed
9
+ note right of transaction_committed
10
+ The user's transaction is in consensus
11
+ end note
12
+ transaction_committed --> flow_inited: Agoric contract machinery forwards it from smart-wallet bridge to the Portfolio Contract
13
+ state flow_inited
14
+ note right of flow_inited
15
+ Flow basic details recorded in flowsRunning (type and optional amount). Virtual FlowStatus=init, not yet FlowStatus=run
16
+ end note
17
+ flow_inited --> planning: Planner service observes the new key in `flowsRunning`
18
+ state planning
19
+ note right of planning
20
+ Planner computes steps/order from balances + targetAllocation and posts flow(n).steps.
21
+ end note
22
+ planning --> planned: Planner submits a transaction to the contract and the contract handles it.
23
+ planning --> failed: Planner/solver errored or allocation infeasible.
24
+ state planned
25
+ note right of planned
26
+ Planner has submitted transaction to the contract with the steps for the flow.
27
+ end note
28
+ planned --> executing: executePlan() begins, FlowStatus state=run emitted.
29
+ state executing {
30
+ [*] --> provisioning
31
+ state provisioning
32
+ note right of provisioning
33
+ Make/resolve accounts (Agoric, Noble, EVM) and register resolver pending transactions when needed.
34
+ end note
35
+ provisioning --> moving: provideCosmosAccount/provideEVMAccount resolved, accountsPending empty.
36
+ provisioning --> failed: Account creation or resolver registerTransaction failed.
37
+ state moving
38
+ note right of moving
39
+ Execute MovementDesc steps concurrently. Each step runs as one of the Way types below.
40
+ end note
41
+ }
42
+ note right of executing
43
+ Contract performing ordered movements, publishes FlowStatus run/fail/done.
44
+ end note
45
+ executing --> failed: FlowStatus state=fail emitted.
46
+ executing --> completed: FlowStatus state=done and all relevant pendingTxs are success.
47
+ state completed
48
+ note right of completed
49
+ Flow finished, balances/positions updated, pendingTxs (if any) marked success.
50
+ end note
51
+ completed --> [*]
52
+ state failed
53
+ note right of failed
54
+ Flow halted, partial effects possible, operator or planner must retry/correct.
55
+ end note
56
+ failed --> [*]
@@ -0,0 +1,180 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "Ymax canonical state machine schema",
4
+ "type": "object",
5
+ "required": ["machines"],
6
+ "properties": {
7
+ "$schema": { "type": "string" },
8
+ "version": { "type": "string", "description": "Semantic version of the machine definitions" },
9
+ "machines": {
10
+ "type": "object",
11
+ "description": "Dictionary of named state machines",
12
+ "patternProperties": {
13
+ "^[-A-Za-z0-9_]+$": { "$ref": "#/definitions/machineDefinition" }
14
+ },
15
+ "additionalProperties": false
16
+ }
17
+ },
18
+ "additionalProperties": false,
19
+ "definitions": {
20
+ "machineDefinition": {
21
+ "type": "object",
22
+ "required": ["description", "initial", "states"],
23
+ "properties": {
24
+ "description": { "type": "string" },
25
+ "initial": { "type": "string", "description": "Initial state key" },
26
+ "states": { "$ref": "#/definitions/stateDictionary" },
27
+ "category": {
28
+ "type": "string",
29
+ "enum": ["flow", "step"],
30
+ "description": "Whether this is a top-level flow machine or a step execution machine"
31
+ }
32
+ },
33
+ "additionalProperties": false
34
+ },
35
+ "stateDictionary": {
36
+ "type": "object",
37
+ "patternProperties": {
38
+ "^[-A-Za-z0-9_.]+$": { "$ref": "#/definitions/stateNode" }
39
+ },
40
+ "additionalProperties": false
41
+ },
42
+ "stateNode": {
43
+ "type": "object",
44
+ "required": ["description"],
45
+ "properties": {
46
+ "description": { "type": "string" },
47
+ "type": {
48
+ "type": "string",
49
+ "enum": ["atomic", "compound", "final", "parallel"],
50
+ "default": "atomic"
51
+ },
52
+ "initial": { "type": "string" },
53
+ "states": { "$ref": "#/definitions/stateDictionary" },
54
+ "on": { "$ref": "#/definitions/transitionMap" },
55
+ "onDone": {
56
+ "$ref": "#/definitions/transitionTarget",
57
+ "description": "Transition when all parallel regions reach final states (for type: parallel)"
58
+ },
59
+ "onError": {
60
+ "$ref": "#/definitions/transitionTarget",
61
+ "description": "Transition when any parallel region reaches an error state (for type: parallel)"
62
+ },
63
+ "after": {
64
+ "type": "object",
65
+ "additionalProperties": { "$ref": "#/definitions/transitionTarget" }
66
+ },
67
+ "entry": {
68
+ "type": "array",
69
+ "items": { "type": "string" }
70
+ },
71
+ "exit": {
72
+ "type": "array",
73
+ "items": { "type": "string" }
74
+ },
75
+ "tags": {
76
+ "type": "array",
77
+ "items": { "type": "string" }
78
+ },
79
+ "meta": { "$ref": "#/definitions/meta" }
80
+ },
81
+ "additionalProperties": false,
82
+ "allOf": [
83
+ {
84
+ "if": {
85
+ "required": ["states"]
86
+ },
87
+ "then": {
88
+ "required": ["initial"]
89
+ }
90
+ },
91
+ {
92
+ "if": {
93
+ "properties": { "type": { "const": "final" } }
94
+ },
95
+ "then": {
96
+ "not": { "required": ["states", "initial", "on", "after"] }
97
+ }
98
+ }
99
+ ]
100
+ },
101
+ "transitionMap": {
102
+ "type": "object",
103
+ "patternProperties": {
104
+ "^[-A-Za-z0-9_.:]+$": { "$ref": "#/definitions/transitionList" }
105
+ },
106
+ "additionalProperties": false
107
+ },
108
+ "transitionList": {
109
+ "oneOf": [
110
+ { "$ref": "#/definitions/transitionTarget" },
111
+ {
112
+ "type": "array",
113
+ "items": { "$ref": "#/definitions/transitionTarget" },
114
+ "minItems": 1
115
+ }
116
+ ]
117
+ },
118
+ "transitionTarget": {
119
+ "type": "object",
120
+ "required": ["target"],
121
+ "properties": {
122
+ "target": { "type": "string" },
123
+ "description": { "type": "string" },
124
+ "guard": { "type": "string" },
125
+ "actions": {
126
+ "type": "array",
127
+ "items": { "type": "string" }
128
+ }
129
+ },
130
+ "additionalProperties": false
131
+ },
132
+ "meta": {
133
+ "type": "object",
134
+ "properties": {
135
+ "row": {
136
+ "type": "string",
137
+ "description": "Visualization row grouping (e.g., 'Cosmos Realm', 'Portfolio Contract', 'Planner Service', 'Orchestration', 'Final States')"
138
+ },
139
+ "userMessage": { "type": "string" },
140
+ "expectedSlaMs": { "type": "integer", "minimum": 0 },
141
+ "invariants": {
142
+ "type": "array",
143
+ "items": { "type": "string" }
144
+ },
145
+ "observedFrom": {
146
+ "type": "array",
147
+ "items": { "type": "string" },
148
+ "description": "Data sources where this state can be observed"
149
+ },
150
+ "observabilityTodo": {
151
+ "type": "string",
152
+ "description": "TODO note for states that are not yet observable - describes investigation needed"
153
+ },
154
+ "signals": {
155
+ "type": "array",
156
+ "items": { "type": "string" }
157
+ },
158
+ "notes": { "type": "string" },
159
+ "severity": {
160
+ "type": "string",
161
+ "enum": ["info", "warn", "error"]
162
+ },
163
+ "wayMachines": {
164
+ "type": "array",
165
+ "items": { "type": "string" },
166
+ "description": "List of step machine names that can execute within this state"
167
+ },
168
+ "txType": {
169
+ "type": "string",
170
+ "description": "Resolver TxType for correlating with pendingTxs (e.g., CCTP_TO_EVM, GMP, CCTP_TO_AGORIC, MAKE_ACCOUNT)"
171
+ },
172
+ "protocol": {
173
+ "type": "string",
174
+ "description": "External protocol involved (e.g., Circle CCTP, Axelar GMP, IBC)"
175
+ }
176
+ },
177
+ "additionalProperties": false
178
+ }
179
+ }
180
+ }