tla-sbuilder 0.1.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +116 -33
  3. data/VERSION +1 -1
  4. data/lib/cli/cli-customer.rb +41 -23
  5. data/lib/cli/cli-example.rb +1 -1
  6. data/lib/cli/cli-pet.rb +33 -30
  7. data/lib/cli/cli-text.rb +57 -17
  8. data/lib/cli/cli.rb +56 -10
  9. data/lib/sbuilder.rb +3 -1
  10. data/lib/sbuilder/constants.rb +5 -2
  11. data/lib/sbuilder/controller.rb +289 -59
  12. data/lib/sbuilder/default-sbuilder.yaml +25 -3
  13. data/lib/sbuilder/domain.rb +1 -1
  14. data/lib/sbuilder/domain_cardinality.rb +1 -1
  15. data/lib/sbuilder/domain_value.rb +1 -1
  16. data/lib/sbuilder/exception.rb +13 -7
  17. data/lib/sbuilder/extension_loader.rb +75 -18
  18. data/lib/sbuilder/facade/api_loader.rb +293 -0
  19. data/lib/sbuilder/factory.rb +66 -3
  20. data/lib/sbuilder/model.rb +59 -3
  21. data/lib/sbuilder/mustache/template.rb +13 -13
  22. data/lib/sbuilder/mustache/template_reader_context.rb +5 -3
  23. data/lib/sbuilder/param_set.rb +2 -1
  24. data/lib/sbuilder/param_set_db.rb +1 -1
  25. data/lib/sbuilder/param_set_def.rb +1 -1
  26. data/lib/sbuilder/param_set_if.rb +1 -1
  27. data/lib/sbuilder/param_set_loader_swagger.rb +122 -121
  28. data/lib/sbuilder/param_set_step.rb +1 -1
  29. data/lib/sbuilder/parameter.rb +1 -1
  30. data/lib/sbuilder/parameter_container.rb +1 -1
  31. data/lib/sbuilder/parameter_dom.rb +1 -1
  32. data/lib/sbuilder/parameter_ref.rb +2 -2
  33. data/lib/sbuilder/resolver_rule.rb +1 -1
  34. data/lib/sbuilder/resolver_rule_match.rb +1 -1
  35. data/lib/sbuilder/resolver_rule_ref.rb +1 -1
  36. data/lib/sbuilder/spec/README +5 -0
  37. data/lib/sbuilder/spec/api_loader_facade.rb +247 -0
  38. data/lib/utils/cache_lines.rb +21 -0
  39. data/lib/utils/netio.rb +5 -13
  40. data/mustache/cfg/macro_run.mustache +1 -0
  41. data/mustache/interface_processes.mustache +9 -2
  42. data/mustache/interface_stubs_dummy.mustache +7 -0
  43. data/mustache/interface_types.mustache +3 -3
  44. data/mustache/invariant_activate.mustache +16 -0
  45. data/mustache/setup/assumptions_activate.mustache +16 -0
  46. data/mustache/{domains_run.mustache → setup/domains_run.mustache} +2 -2
  47. data/mustache/setup/operator_run.mustache +2 -0
  48. data/mustache/setup/steps_run_bind_set.mustache +1 -1
  49. data/mustache/setup/steps_run_parameterBind.mustache +4 -2
  50. data/mustache/tla/macro_run.mustache +8 -0
  51. data/mustache/tla/operator_run.mustache +1 -0
  52. data/mustache/tla/plc_define_run.mustache +2 -4
  53. data/mustache/tla/plc_run_state.mustache +1 -1
  54. data/src-extend/extend/extend_invariant_cfg.mustache +1 -1
  55. data/src/pet/assumption_domains.tla +1 -1
  56. data/src/pet/correctness.cfg +4 -0
  57. data/tla-sbuilder.gemspec +3 -1
  58. metadata +14 -10
  59. data/lib/sbuilder/param_set_loader.rb +0 -77
  60. data/src-extend/extend_app/correctness.cfg +0 -9
@@ -0,0 +1,16 @@
1
+ {{!
2
+
3
+ invariant_activate.mustache
4
+
5
+ }}
6
+
7
+
8
+ (******************************************************************
9
+ Activate Type invariants: {{META.desc}}
10
+ - modelData {{META.modelData}}
11
+ - template {{META.template}}
12
+ ******************************************************************)
13
+
14
+ {{#invariants}}
15
+ INVARIANT {{name}}
16
+ {{/invariants}}
@@ -0,0 +1,16 @@
1
+ {{!
2
+
3
+ assumptions_activate.mustache
4
+
5
+ }}
6
+
7
+
8
+ (******************************************************************
9
+ Activate Assumptions: {{META.desc}}
10
+ - modelData {{META.modelData}}
11
+ - template {{META.template}}
12
+ ******************************************************************)
13
+
14
+ {{#assumptions}}
15
+ ASSUME {{name}}
16
+ {{/assumptions}}
@@ -3,7 +3,7 @@
3
3
  run_domains.mustache - define domain values
4
4
 
5
5
  - iterate #domain_values
6
- - include Nil to valid domain value
6
+ - include Nil to valid domain value if property 'nil-value' defined
7
7
 
8
8
  }}
9
9
 
@@ -15,7 +15,7 @@ Assign values to skeleton domains: {{META.desc}}
15
15
 
16
16
  (* Domains for {{META.setup}} start *)
17
17
  {{#domains}}
18
- Run_{{>name_domain.mustache}} == { {{#domain_values}}"{{>name_domain_value.mustache}}"{{_comma}} {{/domain_values}} } \cup {Nil} \*
18
+ Run_{{>name_domain.mustache}} == { {{#domain_values}}"{{>name_domain_value.mustache}}"{{_comma}} {{/domain_values}} } {{#nil_value}} \cup {Nil} {{/nil_value}} \*
19
19
  {{/domains}}
20
20
  (* Domains for {{META.setup}} end *)
21
21
 
@@ -5,3 +5,5 @@ RunProcessRunning( stepdefs ) == (CHOOSE s \in Head( stepdefs ): TRUE ).process
5
5
  RunProcessEnabled( stepdefs, s ) == Len( stepdefs ) # 0 /\ s = RunProcessRunning( stepdefs )
6
6
  RunProcessesToRun( stepdefs ) == Tail( stepdefs )
7
7
  RunProcessParameter( stepdefs ) == Head( stepdefs )
8
+
9
+ RunInTransaction == tx_running \* state variable tx_running records transaction state
@@ -29,7 +29,7 @@
29
29
 
30
30
  }}{{^bindSets}}{{!
31
31
 
32
- Nil if 'bindSet' not defined.
32
+ {Nil} if 'bindSet' not defined.
33
33
 
34
34
 
35
35
  }}Nil{{/bindSets}}{{!
@@ -33,7 +33,7 @@
33
33
  }}{{^domain_value}}{{^domain_element}}{{^columns.length}}{{^rows.length}}{{parameter_name}}|->Nil{{_comma}}{{/rows.length}}{{/columns.length}}{{/domain_element}}{{/domain_value}}{{!
34
34
 
35
35
 
36
- Record
36
+ Case 4: Record
37
37
 
38
38
  :parameter:
39
39
  columns: (*HERE* NOTICE NO domain_element )
@@ -45,15 +45,17 @@
45
45
  rows: false
46
46
  columns: false
47
47
  _comma: ","
48
+ _index: 0
48
49
  - :parameter_name: tag
49
50
  :domain_element: pet_tag_1
50
51
  rows: false
51
52
  columns: false
52
53
  _comma: ''
54
+ _index: 1
53
55
  _comma: ''
54
56
 
55
57
 
56
- }}{{#columns.length}} _key |-> {[ key |-> "{{parameter_name}}", rec |-> [ {{/columns.length}}{{!
58
+ }}{{#columns.length}} _key{{_index}} |-> {[ key |-> "{{parameter_name}}", rec |-> [ {{/columns.length}}{{!
57
59
 
58
60
  Here recurse columns
59
61
 
@@ -18,6 +18,9 @@
18
18
  (* Reset infrastructure service responses on process entry *)
19
19
  responses := InfrastructureServiceInit;
20
20
 
21
+ (* Flag Transaction started *)
22
+ tx_running := TRUE;
23
+
21
24
  (* time advances by one tick for each process step *)
22
25
  tick();
23
26
  \* debug( s );
@@ -33,7 +36,12 @@
33
36
  *)
34
37
 
35
38
  macro process_done( s ) {
39
+
36
40
  steps := ProcessesToRun( steps ); \* Tail( steps );
41
+
42
+ (* Flag Transaction started *)
43
+ tx_running := FALSE;
44
+
37
45
  }
38
46
 
39
47
 
@@ -6,3 +6,4 @@ ProcessParameter( stepdefs ) == {} \* Head( stepdefs )
6
6
  ProcessesToRun( stepdefs ) == {} \* Tail( stepdefs )
7
7
 
8
8
  TickNext( t ) == t + 1 \* advance time (when process start)
9
+ InTransaction == FALSE \* TRUE when application service running, FALSE when not
@@ -30,12 +30,10 @@
30
30
  Recurse one level down in 'inputParam' using keys 'bindDefs._key.key'.
31
31
  Recursion is done only if 'bindDefs' defines field '_key'.
32
32
 
33
- Should be implemented using recursion, but at the time of writing this comment could not make it work.
34
-
35
33
  *)
36
34
  RECURSIVE ProcessParameterEnables( _, _ )
37
- ProcessParameterEnables( inputParam, bindDefs ) == ( \A key \in { k \in DOMAIN bindDefs : k # "_key" /\ k # "_rows" }: bindDefs[key] = inputParam[key] )
38
- /\ ( \A reckey \in { k \in DOMAIN bindDefs : k = "_key" }: \A r \in bindDefs[reckey] : ProcessParameterEnables( inputParam[r.key], r.rec ) )
35
+ ProcessParameterEnables( inputParam, bindDefs ) == ( \A key \in { k \in DOMAIN bindDefs : Len(k)<4 \/ (SubSeq(k,1,4) # "_key" /\ k # "_rows" )}: bindDefs[key] = inputParam[key] )
36
+ /\ ( \A reckey \in { k \in DOMAIN bindDefs : Len(k)>3 /\SubSeq(k,1,4) = "_key" }: \A r \in bindDefs[reckey] : ProcessParameterEnables( inputParam[r.key], r.rec ) )
39
37
  /\ ( \A reckey \in { k \in DOMAIN bindDefs : k = "_rows" }: \A r \in bindDefs[reckey] :
40
38
  Cardinality( r.set ) = Cardinality( inputParam[r.key] ) /\ \A bDef \in r.set: \E ip \in inputParam[r.key]: ProcessParameterEnables( ip, bDef )
41
39
  )
@@ -9,4 +9,4 @@ variables
9
9
  step = Nil; \* processes currently enabled
10
10
  step_parameter = {}; \* paramter binding for currently enabled processes
11
11
  now = 0; \* current time
12
-
12
+ tx_running = FALSE; \* TRUE when process is running
@@ -4,4 +4,4 @@
4
4
  - template {{META.template}}
5
5
  *)
6
6
 
7
- {{>correctness.cfg}}
7
+ {{! >correctness.cfg}}
@@ -13,4 +13,4 @@ Assume_Domains ==
13
13
  /\ Assume_Owner_Domains
14
14
 
15
15
 
16
- ASSUME Assume_Domains
16
+ \* ASSUME Assume_Domains
@@ -1,3 +1,5 @@
1
+ (*
2
+
1
3
  INVARIANT ValidatePets
2
4
  INVARIANT UniquePet
3
5
  INVARIANT UniqueTag
@@ -7,3 +9,5 @@ INVARIANT CoherentOwnerAddress
7
9
  \* Type invariants
8
10
  INVARIANT Pets_TypeInvariant
9
11
  INVARIANT Tags_TypeInvariant
12
+
13
+ *)
@@ -29,13 +29,15 @@ EOF
29
29
  s.executables = [ "sbuilder.rb" ]
30
30
  s.license = 'MIT'
31
31
 
32
+ s.homepage = "https://github.com/jarjuk/tla-sbuilder"
33
+
32
34
  s.required_ruby_version = '~> 2'
33
35
 
34
36
  s.add_runtime_dependency 'mustache', '~>1.0', ">=1.0.2"
35
37
  s.add_runtime_dependency 'hashie', '~>3.3', ">=3.3.2"
36
38
  s.add_runtime_dependency 'thor', '~>0.19', ">=0.19.1"
37
39
  s.add_runtime_dependency 'json-schema', '~>2.5', ">=2.5.2"
38
- s.add_runtime_dependency 'tla-parser-s', '~>0.1'
40
+ s.add_runtime_dependency 'tla-parser-s', ">=0.1.2"
39
41
 
40
42
  # # used in pet.sh
41
43
  # s.add_runtime_dependency 'bcat'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tla-sbuilder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - jarjuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-03 00:00:00.000000000 Z
11
+ date: 2016-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mustache
@@ -94,16 +94,16 @@ dependencies:
94
94
  name: tla-parser-s
95
95
  requirement: !ruby/object:Gem::Requirement
96
96
  requirements:
97
- - - "~>"
97
+ - - ">="
98
98
  - !ruby/object:Gem::Version
99
- version: '0.1'
99
+ version: 0.1.2
100
100
  type: :runtime
101
101
  prerelease: false
102
102
  version_requirements: !ruby/object:Gem::Requirement
103
103
  requirements:
104
- - - "~>"
104
+ - - ">="
105
105
  - !ruby/object:Gem::Version
106
- version: '0.1'
106
+ version: 0.1.2
107
107
  description: |2+
108
108
 
109
109
  A tool to generate runnable specification models in TLA+ language
@@ -134,6 +134,7 @@ files:
134
134
  - lib/sbuilder/domain_value.rb
135
135
  - lib/sbuilder/exception.rb
136
136
  - lib/sbuilder/extension_loader.rb
137
+ - lib/sbuilder/facade/api_loader.rb
137
138
  - lib/sbuilder/factory.rb
138
139
  - lib/sbuilder/model.rb
139
140
  - lib/sbuilder/mustache/template.rb
@@ -143,7 +144,6 @@ files:
143
144
  - lib/sbuilder/param_set_db.rb
144
145
  - lib/sbuilder/param_set_def.rb
145
146
  - lib/sbuilder/param_set_if.rb
146
- - lib/sbuilder/param_set_loader.rb
147
147
  - lib/sbuilder/param_set_loader_swagger.rb
148
148
  - lib/sbuilder/param_set_step.rb
149
149
  - lib/sbuilder/param_sets.rb
@@ -157,6 +157,9 @@ files:
157
157
  - lib/sbuilder/resolver_rule.rb
158
158
  - lib/sbuilder/resolver_rule_match.rb
159
159
  - lib/sbuilder/resolver_rule_ref.rb
160
+ - lib/sbuilder/spec/README
161
+ - lib/sbuilder/spec/api_loader_facade.rb
162
+ - lib/utils/cache_lines.rb
160
163
  - lib/utils/hash_inject.rb
161
164
  - lib/utils/logger.rb
162
165
  - lib/utils/netio.rb
@@ -174,7 +177,6 @@ files:
174
177
  - mustache/definition_types.mustache
175
178
  - mustache/domains.mustache
176
179
  - mustache/domains_assign.mustache
177
- - mustache/domains_run.mustache
178
180
  - mustache/extend/extend_assumptions.mustache
179
181
  - mustache/extend/extend_const.mustache
180
182
  - mustache/extend/extend_implementation.mustache
@@ -188,6 +190,7 @@ files:
188
190
  - mustache/interface_processes.mustache
189
191
  - mustache/interface_stubs_dummy.mustache
190
192
  - mustache/interface_types.mustache
193
+ - mustache/invariant_activate.mustache
191
194
  - mustache/markdown-header.mustache
192
195
  - mustache/markdown-toc.mustache
193
196
  - mustache/name_definition_type.mustache
@@ -208,6 +211,8 @@ files:
208
211
  - mustache/possibility/possibility_definition.mustache
209
212
  - mustache/possibility/possibility_directive.mustache
210
213
  - mustache/possibility/possility_setup.mustache
214
+ - mustache/setup/assumptions_activate.mustache
215
+ - mustache/setup/domains_run.mustache
211
216
  - mustache/setup/module_footer.mustache
212
217
  - mustache/setup/module_header.mustache
213
218
  - mustache/setup/operator_run.mustache
@@ -250,7 +255,6 @@ files:
250
255
  - src-extend/extend/extend_state.mustache
251
256
  - src-extend/extend_app/assumption
252
257
  - src-extend/extend_app/correctness
253
- - src-extend/extend_app/correctness.cfg
254
258
  - src-extend/extend_app/infrastructure
255
259
  - src-extend/extend_app/interface
256
260
  - src-extend/extend_app/operator
@@ -325,7 +329,7 @@ files:
325
329
  - src/pet/transaction_enter_tag.tla
326
330
  - src/pet/transaction_error.tla
327
331
  - tla-sbuilder.gemspec
328
- homepage:
332
+ homepage: https://github.com/jarjuk/tla-sbuilder
329
333
  licenses:
330
334
  - MIT
331
335
  metadata: {}
@@ -1,77 +0,0 @@
1
-
2
- module Sbuilder
3
-
4
- class ParamSetLoader
5
-
6
- attr_reader :factory # to create stuff
7
- attr_accessor :controller # get sets when load starts
8
-
9
- # ------------------------------------------------------------------
10
- # mixer
11
- PROGNAME = "ParamSetLoader" # progname for logger
12
- include Sbuilder::Utils::MyLogger # mix logger
13
-
14
-
15
- # ------------------------------------------------------------------
16
- # constructore
17
-
18
- def initialize( factory, options = {} )
19
- @logger = getLogger( PROGNAME, options )
20
- @logger.info( "#{__method__} initialized" )
21
- @factory = factory
22
- end
23
-
24
- # @param loaderDef [Hash] adding configuration for loader (override)
25
- def configure( loaderDef )
26
- doConfigure( loaderDef )
27
- end
28
-
29
- def doConfigure( loaderDef )
30
- msg = "Sub class should implement doConfigure -method"
31
- @logger.error( "#{__method__} #{msg}" )
32
- raise NoMethodError.new( msg )
33
- end
34
-
35
- # ------------------------------------------------------------------
36
- # load paramset from 'fileUri'
37
- def load( controller, fileUri, cacheFile=nil )
38
- # controller which control loading
39
- @controller = controller
40
-
41
- begin
42
- loaded = doLoad( fileUri, cacheFile )
43
- rescue Exception => e
44
- msg = "Exception '#{e}' when loading fileUri '#{fileUri}'"
45
- @logger.error( "#{__method__} #{msg}" )
46
- puts msg
47
- raise e
48
- end
49
-
50
- # # iterate && report to controller
51
- # loaded.each do |paramSet|
52
- # controller.interfaceEncountered( paramSet )
53
- # end
54
- end
55
-
56
- def createParamSet( type )
57
- factory.createParamSet( type )
58
- end
59
-
60
- def createParameter( type )
61
- factory.createParameter( type )
62
- end
63
-
64
-
65
- # ------------------------------------------------------------------
66
- # sub-class should implement the doload method
67
- def doLoad( fileUri, cacheFile=nil )
68
- msg = "Sub class should implement doLoad -method"
69
- @logger.error( "#{__method__} #{msg}" )
70
- raise NoMethodError.new( msg )
71
- end
72
-
73
-
74
- end # class ParamSetLoader
75
-
76
-
77
- end # module
@@ -1,9 +0,0 @@
1
- {{!
2
-
3
- Activate correcness predicates
4
-
5
- For example:
6
-
7
- INVARIANT PetStore_ValidatePets
8
-
9
- }}