tla-sbuilder 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +328 -0
- data/VERSION +1 -0
- data/bin/sbuilder.rb +5 -0
- data/lib/cli/cli-customer.rb +420 -0
- data/lib/cli/cli-example.rb +92 -0
- data/lib/cli/cli-pet.rb +767 -0
- data/lib/cli/cli-text.rb +226 -0
- data/lib/cli/cli.rb +298 -0
- data/lib/sbuilder.rb +52 -0
- data/lib/sbuilder/constants.rb +72 -0
- data/lib/sbuilder/controller.rb +798 -0
- data/lib/sbuilder/default-sbuilder.yaml +372 -0
- data/lib/sbuilder/domain.rb +124 -0
- data/lib/sbuilder/domain_cardinality.rb +37 -0
- data/lib/sbuilder/domain_value.rb +81 -0
- data/lib/sbuilder/exception.rb +27 -0
- data/lib/sbuilder/extension_loader.rb +721 -0
- data/lib/sbuilder/factory.rb +234 -0
- data/lib/sbuilder/model.rb +356 -0
- data/lib/sbuilder/mustache/template.rb +125 -0
- data/lib/sbuilder/mustache/template_reader.rb +206 -0
- data/lib/sbuilder/mustache/template_reader_context.rb +371 -0
- data/lib/sbuilder/param_set.rb +132 -0
- data/lib/sbuilder/param_set_db.rb +20 -0
- data/lib/sbuilder/param_set_def.rb +57 -0
- data/lib/sbuilder/param_set_if.rb +68 -0
- data/lib/sbuilder/param_set_loader.rb +77 -0
- data/lib/sbuilder/param_set_loader_swagger.rb +424 -0
- data/lib/sbuilder/param_set_step.rb +62 -0
- data/lib/sbuilder/param_sets.rb +54 -0
- data/lib/sbuilder/parameter.rb +97 -0
- data/lib/sbuilder/parameter_container.rb +72 -0
- data/lib/sbuilder/parameter_dom.rb +70 -0
- data/lib/sbuilder/parameter_ref.rb +71 -0
- data/lib/sbuilder/resolver.rb +78 -0
- data/lib/sbuilder/resolver_loader.rb +79 -0
- data/lib/sbuilder/resolver_loader_yaml.rb +103 -0
- data/lib/sbuilder/resolver_rule.rb +36 -0
- data/lib/sbuilder/resolver_rule_match.rb +55 -0
- data/lib/sbuilder/resolver_rule_ref.rb +37 -0
- data/lib/utils/hash_inject.rb +12 -0
- data/lib/utils/logger.rb +80 -0
- data/lib/utils/netio.rb +58 -0
- data/lib/utils/string_inject.rb +10 -0
- data/lib/utils/version.rb +13 -0
- data/mustache/cfg/const_def.mustache +8 -0
- data/mustache/cfg/const_run.mustache +3 -0
- data/mustache/cfg/invariant-infrastructure-service.mustache +4 -0
- data/mustache/cfg/macro_run.mustache +6 -0
- data/mustache/cfg/module_footer.mustache +0 -0
- data/mustache/cfg/module_header.mustache +7 -0
- data/mustache/data-model-dump.mustache +19 -0
- data/mustache/data-model-footer.mustache +5 -0
- data/mustache/data-model-header.mustache +16 -0
- data/mustache/definition_types.mustache +40 -0
- data/mustache/domains.mustache +20 -0
- data/mustache/domains_assign.mustache +22 -0
- data/mustache/domains_run.mustache +21 -0
- data/mustache/extend/extend_assumptions.mustache +7 -0
- data/mustache/extend/extend_const.mustache +5 -0
- data/mustache/extend/extend_implementation.mustache +9 -0
- data/mustache/extend/extend_invariant.mustache +7 -0
- data/mustache/extend/extend_invariant_cfg.mustache +7 -0
- data/mustache/extend/extend_macros.mustache +19 -0
- data/mustache/extend/extend_operations.mustache +9 -0
- data/mustache/extend/extend_state.mustache +9 -0
- data/mustache/infrastructure-service-init.mustache +36 -0
- data/mustache/infrastructure-service-variables.mustache +10 -0
- data/mustache/interface_processes.mustache +38 -0
- data/mustache/interface_stubs_dummy.mustache +13 -0
- data/mustache/interface_types.mustache +52 -0
- data/mustache/markdown-header.mustache +24 -0
- data/mustache/markdown-toc.mustache +13 -0
- data/mustache/name_definition_type.mustache +5 -0
- data/mustache/name_domain.mustache +5 -0
- data/mustache/name_domain_value.mustache +5 -0
- data/mustache/name_domain_value_prefix.mustache +5 -0
- data/mustache/name_interface_response_type.mustache +6 -0
- data/mustache/name_interface_type.mustache +6 -0
- data/mustache/name_parameter_definition.mustache +5 -0
- data/mustache/name_parameter_type.mustache +6 -0
- data/mustache/name_process.mustache +6 -0
- data/mustache/name_type_invariant.mustache +5 -0
- data/mustache/name_variable.mustache +6 -0
- data/mustache/operator-infrastructure-service.mustache +13 -0
- data/mustache/possibility/module_extends.mustache +1 -0
- data/mustache/possibility/module_footer.mustache +1 -0
- data/mustache/possibility/module_header.mustache +8 -0
- data/mustache/possibility/possibility_definition.mustache +12 -0
- data/mustache/possibility/possibility_directive.mustache +1 -0
- data/mustache/possibility/possility_setup.mustache +28 -0
- data/mustache/setup/module_footer.mustache +1 -0
- data/mustache/setup/module_header.mustache +9 -0
- data/mustache/setup/operator_run.mustache +7 -0
- data/mustache/setup/operator_tick.mustache +2 -0
- data/mustache/setup/steps_run.mustache +22 -0
- data/mustache/setup/steps_run_bind_rule.mustache +51 -0
- data/mustache/setup/steps_run_bind_set.mustache +37 -0
- data/mustache/setup/steps_run_parameterBind.mustache +80 -0
- data/mustache/setup/steps_run_parameterExact.mustache +79 -0
- data/mustache/state_type_invariant-infrastructure-service.mustache +49 -0
- data/mustache/state_type_invariant.mustache +17 -0
- data/mustache/state_type_invariant_cfg.mustache +18 -0
- data/mustache/state_variables.mustache +20 -0
- data/mustache/tla/const_def.mustache +5 -0
- data/mustache/tla/const_run.mustache +3 -0
- data/mustache/tla/macro-infrastructure-service.mustache +14 -0
- data/mustache/tla/macro_run.mustache +40 -0
- data/mustache/tla/module_footer.mustache +2 -0
- data/mustache/tla/module_header.mustache +9 -0
- data/mustache/tla/operator_run.mustache +8 -0
- data/mustache/tla/operators-infrastructure-service.mustache +12 -0
- data/mustache/tla/plc_define_footer.mustache +1 -0
- data/mustache/tla/plc_define_header.mustache +1 -0
- data/mustache/tla/plc_define_run.mustache +59 -0
- data/mustache/tla/plc_footer.mustache +2 -0
- data/mustache/tla/plc_header.mustache +2 -0
- data/mustache/tla/plc_run_state.mustache +12 -0
- data/mustache/tla/plc_tail.mustache +8 -0
- data/mustache/tla/plc_translation.mustache +2 -0
- data/resources/schema/json_schema/draft-04.json +150 -0
- data/resources/schema/swagger/2.0/schema.json +1591 -0
- data/src-extend/README +2 -0
- data/src-extend/extend/extend_assumptions.mustache +7 -0
- data/src-extend/extend/extend_const.mustache +5 -0
- data/src-extend/extend/extend_implementation.mustache +9 -0
- data/src-extend/extend/extend_invariant.mustache +11 -0
- data/src-extend/extend/extend_invariant_cfg.mustache +7 -0
- data/src-extend/extend/extend_macros.mustache +19 -0
- data/src-extend/extend/extend_operations.mustache +9 -0
- data/src-extend/extend/extend_state.mustache +9 -0
- data/src-extend/extend_app/assumption +20 -0
- data/src-extend/extend_app/correctness +19 -0
- data/src-extend/extend_app/correctness.cfg +9 -0
- data/src-extend/extend_app/infrastructure +25 -0
- data/src-extend/extend_app/interface +11 -0
- data/src-extend/extend_app/operator +18 -0
- data/src-extend/extend_app/possibility +16 -0
- data/src-extend/extend_app/service +33 -0
- data/src-extend/extend_app/state +16 -0
- data/src-extend/extend_app/transaction +22 -0
- data/src/pet/assumption +29 -0
- data/src/pet/assumption_address_domains.tla +12 -0
- data/src/pet/assumption_domains.tla +16 -0
- data/src/pet/assumption_generic.tla +8 -0
- data/src/pet/assumption_id_domains.tla +2 -0
- data/src/pet/assumption_owner_domains.tla +14 -0
- data/src/pet/assumption_pet_domains.tla +16 -0
- data/src/pet/assumption_tag_domains.tla +13 -0
- data/src/pet/correctness +24 -0
- data/src/pet/correctness.cfg +9 -0
- data/src/pet/correctness_coherent_owner_address.tla +6 -0
- data/src/pet/correctness_pet_name.tla +4 -0
- data/src/pet/correctness_ref_tag.tla +13 -0
- data/src/pet/correctness_type_invariants.tla +12 -0
- data/src/pet/correctness_unique_pet.tla +3 -0
- data/src/pet/correctness_unique_tag.tla +3 -0
- data/src/pet/docs/Petstore.md +117 -0
- data/src/pet/extend/extend_assumptions.mustache +7 -0
- data/src/pet/extend/extend_implementation.mustache +9 -0
- data/src/pet/extend/extend_invariant.mustache +11 -0
- data/src/pet/extend/extend_invariant_cfg.mustache +7 -0
- data/src/pet/extend/extend_macros.mustache +19 -0
- data/src/pet/extend/extend_operations.mustache +9 -0
- data/src/pet/extend/extend_state.mustache +9 -0
- data/src/pet/infrastructure +25 -0
- data/src/pet/infrastructure_id_get.tla +24 -0
- data/src/pet/interface +12 -0
- data/src/pet/interface_delete_pet.tla +5 -0
- data/src/pet/interface_get_pet.tla +4 -0
- data/src/pet/interface_post_pet.tla +5 -0
- data/src/pet/interface_post_tag.tla +5 -0
- data/src/pet/interface_put_tag.tla +3 -0
- data/src/pet/operator +30 -0
- data/src/pet/operator_find_tag_by_owner_name.tla +1 -0
- data/src/pet/operator_get_pet.tla +4 -0
- data/src/pet/operator_get_pet_by_tag.tla +4 -0
- data/src/pet/operator_get_tag.tla +10 -0
- data/src/pet/operator_new_owner.tla +3 -0
- data/src/pet/operator_new_pet.tla +13 -0
- data/src/pet/operator_new_tag.tla +3 -0
- data/src/pet/operator_next_pet_id.tla +3 -0
- data/src/pet/operator_responses.tla +8 -0
- data/src/pet/operator_tag_exists.tla +2 -0
- data/src/pet/operator_tag_owner_validated.tla +2 -0
- data/src/pet/operator_tag_referenced.tla +4 -0
- data/src/pet/operator_valid_owner.tla +17 -0
- data/src/pet/operator_valid_pet.tla +6 -0
- data/src/pet/operator_valid_tag.tla +5 -0
- data/src/pet/possibility +18 -0
- data/src/pet/possibility_at_least_two_tags.tla +12 -0
- data/src/pet/possibility_invalid_tag_address.tla +8 -0
- data/src/pet/service +35 -0
- data/src/pet/service_pet_delete.tla +11 -0
- data/src/pet/service_pet_get.tla +27 -0
- data/src/pet/service_pet_post.tla +78 -0
- data/src/pet/service_tag_post.tla +53 -0
- data/src/pet/service_tag_put.tla +82 -0
- data/src/pet/state +16 -0
- data/src/pet/state_infra.tla +6 -0
- data/src/pet/state_pet.tla +5 -0
- data/src/pet/state_tag_id.tla +2 -0
- data/src/pet/transaction +23 -0
- data/src/pet/transaction_delete_pet.tla +13 -0
- data/src/pet/transaction_enter_pet.tla +13 -0
- data/src/pet/transaction_enter_tag.tla +56 -0
- data/src/pet/transaction_error.tla +23 -0
- data/tla-sbuilder.gemspec +43 -0
- metadata +353 -0
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
(*
|
3
|
+
* Reference integrity of pet tags
|
4
|
+
*
|
5
|
+
* For all pets there exists a unique, valid tag entry.
|
6
|
+
*)
|
7
|
+
|
8
|
+
ValidReferecendTag ==
|
9
|
+
\A pet \in v_pets: \E tag \in v_tags:
|
10
|
+
tag.tag = pet.tag
|
11
|
+
/\ ValidOwner( tag.owner )
|
12
|
+
/\ \A pet2 \in v_pets: pet2.tag = pet.tag => pet = pet2
|
13
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
(*
|
2
|
+
{{META.desc}}
|
3
|
+
- modelData {{META.modelData}}
|
4
|
+
- template {{META.template}}
|
5
|
+
*)
|
6
|
+
|
7
|
+
\* Type of all entries in 'v_pets' is 't_Pet'
|
8
|
+
Pets_TypeInvariant == \A entry \in v_pets: entry \in t_Pet
|
9
|
+
|
10
|
+
Tags_TypeInvariant == \A entry \in v_tags: entry \in t_Tag
|
11
|
+
|
12
|
+
|
@@ -0,0 +1,117 @@
|
|
1
|
+
# Problem domain
|
2
|
+
|
3
|
+
Each pet is assigned a unique tag, which identifies pet owner. Valid
|
4
|
+
owner has an address, which may later change. One owner may possess
|
5
|
+
several pets.
|
6
|
+
|
7
|
+
Pet store application supports creating tag identifiers. Owner
|
8
|
+
information may be given, when a tag is created, or it may be updated
|
9
|
+
later on a tag.
|
10
|
+
|
11
|
+
# Solution domain
|
12
|
+
|
13
|
+
## Features
|
14
|
+
|
15
|
+
- I can generate new tag for an owner
|
16
|
+
- I can associate owner with an existing tag
|
17
|
+
- I can update owner address on a existing tag
|
18
|
+
- I can assign an existig tag to a pet
|
19
|
+
|
20
|
+
## Data model
|
21
|
+
|
22
|
+
### Data types
|
23
|
+
|
24
|
+
* Pet
|
25
|
+
* id : String
|
26
|
+
* name : String
|
27
|
+
* tag : String
|
28
|
+
|
29
|
+
* Tag
|
30
|
+
* tag : String
|
31
|
+
* owner : Owner
|
32
|
+
|
33
|
+
* Owner
|
34
|
+
* name: String
|
35
|
+
* address: Address
|
36
|
+
|
37
|
+
* Address
|
38
|
+
* city: String
|
39
|
+
* street: String
|
40
|
+
|
41
|
+
### Data base
|
42
|
+
|
43
|
+
* pets: Pet
|
44
|
+
|
45
|
+
* tags: Tag
|
46
|
+
|
47
|
+
|
48
|
+
## Design
|
49
|
+
|
50
|
+
### Application services
|
51
|
+
|
52
|
+
* /tags(post)
|
53
|
+
* Features
|
54
|
+
* I can generate tags
|
55
|
+
* I can update owner address on tag
|
56
|
+
* I can associate owner with a tag
|
57
|
+
* Design
|
58
|
+
* Create unique 'tag` identifier
|
59
|
+
* Insert into `tags`
|
60
|
+
* If address given: update address on existing tags
|
61
|
+
|
62
|
+
* /tags(put)
|
63
|
+
* Features
|
64
|
+
* I can update owner address on tag
|
65
|
+
* I can associate owner with a tag
|
66
|
+
* Design
|
67
|
+
* Update `tags`
|
68
|
+
* Update address on existing tags
|
69
|
+
|
70
|
+
* /pets(post):
|
71
|
+
* Features
|
72
|
+
* I can associate owner with a pet
|
73
|
+
* Design
|
74
|
+
* Create new entry in `pets`
|
75
|
+
* Generate unique identifier
|
76
|
+
|
77
|
+
### Infrastructure services
|
78
|
+
|
79
|
+
* /id/pet(get):
|
80
|
+
|
81
|
+
### Correctness
|
82
|
+
|
83
|
+
* Unique pet id
|
84
|
+
* Unique tag id
|
85
|
+
* Reference integrity of pet tags for all pets there exists a
|
86
|
+
unique valid tag entry
|
87
|
+
* Owner address coherence: address on all tags with the same ower are equal
|
88
|
+
|
89
|
+
|
90
|
+
### Traces
|
91
|
+
|
92
|
+
* tag-post (O1,A1):
|
93
|
+
* <TAG: T1,O1,A1>
|
94
|
+
|
95
|
+
* tag-pos( T1 )
|
96
|
+
<PET: P1,T1> <TAG: T1,O1,A1>
|
97
|
+
* <P1,T1> <T1,O1,A1>: pos
|
98
|
+
* <P2,T2> <T2,O1,A1>
|
99
|
+
* <P2,T1> <T2,O1,A2>
|
100
|
+
* <P2,T2> <T2,O1,A2>
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
* Post pet1, tag1
|
107
|
+
* Post pet2, tag1 ==> ERROR
|
108
|
+
|
109
|
+
* Post tag1, owner1, address1
|
110
|
+
* Post pet1, tag1
|
111
|
+
* Post tag2, owner1, address2
|
112
|
+
-->
|
113
|
+
* Post pet1, tag1
|
114
|
+
* Post pet2, tag1 ==> ERROR
|
115
|
+
|
116
|
+
|
117
|
+
* Put tag
|
@@ -0,0 +1,19 @@
|
|
1
|
+
(*
|
2
|
+
{{META.desc}}
|
3
|
+
- modelData {{META.modelData}}
|
4
|
+
- template {{META.template}}
|
5
|
+
*)
|
6
|
+
|
7
|
+
(* ******************************************************************
|
8
|
+
Transactions (modify state)
|
9
|
+
* ******************************************************************)
|
10
|
+
|
11
|
+
{{>transaction}}
|
12
|
+
|
13
|
+
|
14
|
+
(* ******************************************************************
|
15
|
+
Macros implmeneting entries to interface services
|
16
|
+
* ******************************************************************)
|
17
|
+
|
18
|
+
{{>interface}}
|
19
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
{{!
|
2
|
+
|
3
|
+
Procedure implmenting services for infrastructure interfaces.
|
4
|
+
|
5
|
+
May use 'operators' defined earlier
|
6
|
+
|
7
|
+
For example:
|
8
|
+
|
9
|
+
procedure generateId() {
|
10
|
+
|
11
|
+
generateId_start:
|
12
|
+
|
13
|
+
\* remove one id from set of valid ids
|
14
|
+
v_pet_ids := v_pet_ids \ { Next_pet_id } ;
|
15
|
+
|
16
|
+
|
17
|
+
\* return generated identifier
|
18
|
+
InfrastructureServiceReturn( "/id/{type}(get)", [ id |-> Next_pet_id ] );
|
19
|
+
return;
|
20
|
+
}
|
21
|
+
|
22
|
+
}}
|
23
|
+
|
24
|
+
|
25
|
+
{{>infrastructure_id_get.tla}}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
\* infrastructure service /id/{type}(get)
|
3
|
+
|
4
|
+
procedure infrastructure_id_get( id_type ) {
|
5
|
+
|
6
|
+
|
7
|
+
infrastructure_id_get_start:
|
8
|
+
|
9
|
+
\* any ids left?
|
10
|
+
if ( Cardinality( v_ids[ id_type ] ) = 0 ) {
|
11
|
+
|
12
|
+
\* response: 404 & Nil
|
13
|
+
InfrastructureServiceReturn( "/id/{type}(get)", "status_404", Nil );
|
14
|
+
}
|
15
|
+
else {
|
16
|
+
|
17
|
+
\* remove generated id from set of free ids
|
18
|
+
v_ids := [ v_ids EXCEPT ![id_type] = @ \ { Next_id( id_type ) } ] ;
|
19
|
+
|
20
|
+
\* response: 200 && generated id
|
21
|
+
InfrastructureServiceReturn( "/id/{type}(get)", "status_200", [ id |-> Next_id( id_type ) ] );
|
22
|
+
};
|
23
|
+
return;
|
24
|
+
}
|
data/src/pet/interface
ADDED
data/src/pet/operator
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
{{!
|
2
|
+
|
3
|
+
Application operators
|
4
|
+
|
5
|
+
Example:
|
6
|
+
|
7
|
+
\* All pets should have a name
|
8
|
+
ValidatePetData( pet ) == pet.name # Nil
|
9
|
+
|
10
|
+
|
11
|
+
}}
|
12
|
+
|
13
|
+
|
14
|
+
{{>operator_next_pet_id.tla}}
|
15
|
+
{{>operator_valid_pet.tla}}
|
16
|
+
{{>operator_get_pet.tla}}
|
17
|
+
{{>operator_responses.tla}}
|
18
|
+
{{>operator_new_owner.tla}}
|
19
|
+
{{>operator_new_pet.tla}}
|
20
|
+
{{>operator_new_tag.tla}}
|
21
|
+
{{>operator_valid_owner.tla}}
|
22
|
+
{{>operator_valid_tag.tla}}
|
23
|
+
|
24
|
+
\* Accessing state
|
25
|
+
{{>operator_find_tag_by_owner_name.tla}}
|
26
|
+
{{>operator_tag_exists.tla}}
|
27
|
+
{{>operator_tag_owner_validated.tla}}
|
28
|
+
{{>operator_get_tag.tla}}
|
29
|
+
{{>operator_tag_referenced.tla}}
|
30
|
+
{{>operator_get_pet_by_tag.tla}}
|
@@ -0,0 +1 @@
|
|
1
|
+
FindTagsByOwnerName( owner ) == { entry \in v_tags: entry.owner.name = owner.name }
|
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
\* Create new pet
|
3
|
+
|
4
|
+
New_Pet( pet_input, id ) == [ id |-> id, name |-> pet_input.name, tag |-> pet_input.tag ]
|
5
|
+
|
6
|
+
(*
|
7
|
+
Copy all other fields from 'pet_input' expect Next_pet_id
|
8
|
+
{
|
9
|
+
CHOOSE p \in t_Pet :
|
10
|
+
p.id = Next_pet_id
|
11
|
+
/\ \A key \in DOMAIN pet_input.pet: p[key] = pet_input.pet[key]
|
12
|
+
};
|
13
|
+
*)
|