@fairfox/polly 0.85.1 → 0.86.0

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.
Files changed (120) hide show
  1. package/dist/cli/polly.js.map +1 -1
  2. package/dist/gallery/gallery.css +1 -1
  3. package/dist/gallery/gallery.js +2 -27
  4. package/dist/scripts/build-extension.js.map +1 -1
  5. package/dist/src/actions/index.js +34 -32
  6. package/dist/src/actions/index.js.map +2 -2
  7. package/dist/src/background/index.js +24 -22
  8. package/dist/src/background/index.js.map +2 -2
  9. package/dist/src/background/message-router.js +21 -19
  10. package/dist/src/background/message-router.js.map +2 -2
  11. package/dist/src/client/index.js +9 -7
  12. package/dist/src/client/index.js.map +3 -3
  13. package/dist/src/client/wrapper.d.ts +3 -3
  14. package/dist/src/elysia/index.d.ts +1 -1
  15. package/dist/src/elysia/index.js +25 -23
  16. package/dist/src/elysia/index.js.map +2 -2
  17. package/dist/src/elysia/types.d.ts +11 -2
  18. package/dist/src/index.js +68 -64
  19. package/dist/src/index.js.map +3 -3
  20. package/dist/src/mesh-node.js +6 -6
  21. package/dist/src/mesh-node.js.map +1 -1
  22. package/dist/src/mesh.js +92 -90
  23. package/dist/src/mesh.js.map +2 -2
  24. package/dist/src/peer.js +83 -52
  25. package/dist/src/peer.js.map +3 -3
  26. package/dist/src/polly-ui/index.css +1 -1
  27. package/dist/src/polly-ui/index.js +37 -35
  28. package/dist/src/polly-ui/index.js.map +2 -2
  29. package/dist/src/polly-ui/markdown.js +233 -96
  30. package/dist/src/polly-ui/markdown.js.map +4 -4
  31. package/dist/src/polly-ui/styles.css +1 -1
  32. package/dist/src/shared/adapters/index.js +30 -28
  33. package/dist/src/shared/adapters/index.js.map +2 -2
  34. package/dist/src/shared/lib/context-helpers.js +23 -21
  35. package/dist/src/shared/lib/context-helpers.js.map +2 -2
  36. package/dist/src/shared/lib/errors.js +16 -14
  37. package/dist/src/shared/lib/errors.js.map +2 -2
  38. package/dist/src/shared/lib/guards.js +11 -9
  39. package/dist/src/shared/lib/guards.js.map +2 -2
  40. package/dist/src/shared/lib/message-bus.js +24 -22
  41. package/dist/src/shared/lib/message-bus.js.map +2 -2
  42. package/dist/src/shared/lib/peer-relay-adapter.d.ts +6 -0
  43. package/dist/src/shared/lib/resource.js +19 -15
  44. package/dist/src/shared/lib/resource.js.map +3 -3
  45. package/dist/src/shared/lib/state.js +26 -22
  46. package/dist/src/shared/lib/state.js.map +3 -3
  47. package/dist/src/shared/lib/test-helpers.js +11 -9
  48. package/dist/src/shared/lib/test-helpers.js.map +2 -2
  49. package/dist/src/shared/state/app-state.js +22 -18
  50. package/dist/src/shared/state/app-state.js.map +3 -3
  51. package/dist/src/shared/types/messages.js +11 -9
  52. package/dist/src/shared/types/messages.js.map +2 -2
  53. package/dist/tools/bdd/src/cli.js +44 -1
  54. package/dist/tools/bdd/src/cli.js.map +4 -4
  55. package/dist/tools/bdd/src/index.js +54 -11
  56. package/dist/tools/bdd/src/index.js.map +4 -4
  57. package/dist/tools/gallery/src/cli.js +1 -1
  58. package/dist/tools/gallery/src/cli.js.map +2 -2
  59. package/dist/tools/init/src/cli.js +1 -1
  60. package/dist/tools/init/src/cli.js.map +2 -2
  61. package/dist/tools/mutate/src/cli.js +1 -1
  62. package/dist/tools/mutate/src/cli.js.map +2 -2
  63. package/dist/tools/mutate/src/index.js +8 -8
  64. package/dist/tools/mutate/src/index.js.map +2 -2
  65. package/dist/tools/quality/src/cli.js +3 -2
  66. package/dist/tools/quality/src/cli.js.map +3 -3
  67. package/dist/tools/quality/src/index.js +37 -36
  68. package/dist/tools/quality/src/index.js.map +3 -3
  69. package/dist/tools/test/src/adapters/index.js +19 -17
  70. package/dist/tools/test/src/adapters/index.js.map +2 -2
  71. package/dist/tools/test/src/browser/index.js +15 -13
  72. package/dist/tools/test/src/browser/index.js.map +2 -2
  73. package/dist/tools/test/src/browser/run.js +12 -3
  74. package/dist/tools/test/src/browser/run.js.map +5 -4
  75. package/dist/tools/test/src/contrast/index.js +14 -12
  76. package/dist/tools/test/src/contrast/index.js.map +2 -2
  77. package/dist/tools/test/src/coverage-policy/cli.js +5 -5
  78. package/dist/tools/test/src/coverage-policy/cli.js.map +2 -2
  79. package/dist/tools/test/src/coverage-policy/index.js +12 -12
  80. package/dist/tools/test/src/coverage-policy/index.js.map +1 -1
  81. package/dist/tools/test/src/e2e-mesh/index.js +88 -50
  82. package/dist/tools/test/src/e2e-mesh/index.js.map +6 -5
  83. package/dist/tools/test/src/e2e-mesh/with-relay.d.ts +1 -1
  84. package/dist/tools/test/src/e2e-relay/index.js +3 -3
  85. package/dist/tools/test/src/e2e-relay/index.js.map +2 -2
  86. package/dist/tools/test/src/e2e-shared/ephemeral-port.d.ts +73 -0
  87. package/dist/tools/test/src/e2e-shared/index.d.ts +1 -0
  88. package/dist/tools/test/src/index.d.ts +1 -0
  89. package/dist/tools/test/src/index.js +68 -24
  90. package/dist/tools/test/src/index.js.map +4 -3
  91. package/dist/tools/test/src/test-utils.js +14 -12
  92. package/dist/tools/test/src/test-utils.js.map +2 -2
  93. package/dist/tools/test/src/tiers/budget.d.ts +32 -0
  94. package/dist/tools/test/src/tiers/cli.js +35 -5
  95. package/dist/tools/test/src/tiers/cli.js.map +6 -5
  96. package/dist/tools/test/src/tiers/index.d.ts +1 -0
  97. package/dist/tools/test/src/tiers/reporter.d.ts +0 -5
  98. package/dist/tools/test/src/tiers/types.d.ts +9 -0
  99. package/dist/tools/test/src/tiers/worker.js +1 -1
  100. package/dist/tools/test/src/tiers/worker.js.map +1 -1
  101. package/dist/tools/test/src/visual/index.js +121 -119
  102. package/dist/tools/test/src/visual/index.js.map +2 -2
  103. package/dist/tools/verify/specs/README.md +18 -0
  104. package/dist/tools/verify/specs/tla/MeshState.cfg +1 -1
  105. package/dist/tools/verify/specs/tla/MeshState.tla +7 -0
  106. package/dist/tools/verify/specs/tla/MessageRouter.cfg +4 -2
  107. package/dist/tools/verify/specs/tla/MessageRouter.tla +45 -10
  108. package/dist/tools/verify/specs/tla/PeerState.cfg +1 -1
  109. package/dist/tools/verify/specs/tla/PeerState.tla +7 -0
  110. package/dist/tools/verify/specs/tla/README.md +1 -1
  111. package/dist/tools/verify/src/cli.js +258 -202
  112. package/dist/tools/verify/src/cli.js.map +12 -11
  113. package/dist/tools/verify/src/config.d.ts +25 -0
  114. package/dist/tools/verify/src/config.js +18 -16
  115. package/dist/tools/verify/src/config.js.map +3 -3
  116. package/dist/tools/verify/src/stryker/index.js +6 -6
  117. package/dist/tools/verify/src/stryker/index.js.map +1 -1
  118. package/dist/tools/visualize/src/cli.js +439 -47
  119. package/dist/tools/visualize/src/cli.js.map +7 -5
  120. package/package.json +2 -2
@@ -38,6 +38,24 @@ cd tools/verify/specs/tla
38
38
  tlc MessageRouter.tla -config MessageRouter.cfg
39
39
  ```
40
40
 
41
+ **Cost.** `MessageRouter.cfg` declares `MaxMessages = 4` over three contexts and
42
+ three tabs, and `SendMessage` quantifies over every non-empty subset of
43
+ contexts, so the model runs to over a million distinct states and takes minutes.
44
+ To check the properties quickly, drop the constants:
45
+
46
+ ```
47
+ CONSTANTS
48
+ Contexts = {background, popup}
49
+ MaxMessages = 1
50
+ Tabs = {0}
51
+ TimeoutLimit = 2
52
+ ```
53
+
54
+ That completes in under a second (308 distinct states) and still exercises both
55
+ temporal properties. Removing the `\A i \in 1..MaxMessages : WF_vars(RouteMessage(i))`
56
+ conjunct from `Spec` makes TLC report a violation, so the fairness is
57
+ load-bearing rather than decorative (polly#172).
58
+
41
59
  ## See Also
42
60
  - [Verify Package Documentation](../README.md)
43
61
  - [TLA+ Specifications](./tla/README.md)
@@ -18,4 +18,4 @@ PROPERTIES
18
18
  RevocationBlocksFutureOps
19
19
 
20
20
  CONSTRAINT
21
- Len(messages) <= MaxOps * 4
21
+ BoundedOps
@@ -170,6 +170,13 @@ Next ==
170
170
 
171
171
  Spec == Init /\ [][Next]_vars /\ WF_vars(Next)
172
172
 
173
+ (* State constraint. Named rather than inline because TLC's CONSTRAINT clause
174
+ takes a defined operator; an inline expression is rejected with "The
175
+ constraint of Len is equal to <Java Method ...>" before exploration begins,
176
+ so the checked-in .cfg could not be run at all (polly#172). *)
177
+ BoundedOps == Len(messages) <= MaxOps * 4
178
+
179
+
173
180
  -----------------------------------------------------------------------------
174
181
 
175
182
  (* Invariants *)
@@ -19,6 +19,8 @@ PROPERTIES
19
19
  EventualResolution
20
20
  ConnectedEventuallyDelivers
21
21
 
22
- \* State constraint (keep state space manageable)
22
+ \* State constraint (keep state space manageable).
23
+ \* polly#172: TLC's CONSTRAINT clause takes a defined operator, not an inline
24
+ \* expression — an inline one stops the run before it reaches the properties.
23
25
  CONSTRAINT
24
- Len(messages) <= MaxMessages
26
+ BoundedMessages
@@ -172,7 +172,16 @@ Next ==
172
172
  \/ CompleteRouting
173
173
  \/ \E i \in 1..Len(messages) : TimeoutMessage(i)
174
174
 
175
- Spec == Init /\ [][Next]_vars /\ WF_vars(Next)
175
+ (* polly#172: WF_vars(Next) alone asks only that SOME step happen, which a port
176
+ connecting and disconnecting for ever satisfies while a message sits pending.
177
+ The temporal properties below need per-message routing fairness to be
178
+ checkable, and the range must be the CONSTANT 1..MaxMessages — TLC refuses a
179
+ temporal formula whose quantifier ranges over a VARIABLE. *)
180
+ Spec ==
181
+ /\ Init
182
+ /\ [][Next]_vars
183
+ /\ WF_vars(Next)
184
+ /\ \A i \in 1..MaxMessages : WF_vars(RouteMessage(i))
176
185
 
177
186
  -----------------------------------------------------------------------------
178
187
 
@@ -214,19 +223,45 @@ TypeOK ==
214
223
 
215
224
  -----------------------------------------------------------------------------
216
225
 
226
+ (* State constraint. Named rather than inline because TLC's CONSTRAINT clause
227
+ takes a defined operator (polly#172). *)
228
+ BoundedMessages == Len(messages) <= MaxMessages
229
+
230
+ -----------------------------------------------------------------------------
231
+
217
232
  (* Temporal properties *)
218
233
 
234
+ (* polly#172: both properties are quantified over the CONSTANT 1..MaxMessages.
235
+ Written as 1..Len(messages) they ranged over a VARIABLE, and TLC refuses that
236
+ with "In evaluation, the identifier messages is either undefined or not an
237
+ operator" — so neither had ever been checkable. Each side is guarded with
238
+ Len(messages) >= i because TLC evaluates the property in states reached
239
+ before message i exists. *)
240
+
219
241
  (* Eventually, all messages resolve (deliver, fail, or timeout) *)
220
242
  EventualResolution ==
221
- \A i \in 1..Len(messages) :
222
- messages[i].status = "pending"
223
- ~> messages[i].status \in {"delivered", "failed", "timeout"}
224
-
225
- (* If ports are connected and message is sent to them, message eventually delivers *)
243
+ \A i \in 1..MaxMessages :
244
+ (Len(messages) >= i /\ messages[i].status = "pending")
245
+ ~> (Len(messages) >= i
246
+ /\ messages[i].status \in {"delivered", "failed", "timeout"})
247
+
248
+ (* A pending message whose targets are all connected is eventually delivered --
249
+ UNLESS one of those targets stops being connected first, in which case
250
+ RouteMessage takes its ELSE arm and the message fails.
251
+
252
+ polly#172: as originally written this demanded delivery outright, and TLC
253
+ finds a two-step counter-example: the target disconnects between the send and
254
+ the route. The property had never been run, so that was never seen. The
255
+ disjunct below is what is actually true, and it still has teeth -- it forbids
256
+ a message sitting pending for ever while its ports stay up, which is the
257
+ routing wedge polly#171 is about. *)
226
258
  ConnectedEventuallyDelivers ==
227
- \A i \in 1..Len(messages) :
228
- LET msg == messages[i]
229
- IN (msg.status = "pending" /\ \A target \in msg.targets : ports[target] = "connected")
230
- ~> (msg.status = "delivered")
259
+ \A i \in 1..MaxMessages :
260
+ (/\ Len(messages) >= i
261
+ /\ messages[i].status = "pending"
262
+ /\ \A target \in messages[i].targets : ports[target] = "connected")
263
+ ~> (/\ Len(messages) >= i
264
+ /\ \/ messages[i].status = "delivered"
265
+ \/ \E target \in messages[i].targets : ports[target] # "connected")
231
266
 
232
267
  =============================================================================
@@ -24,4 +24,4 @@ PROPERTIES
24
24
  \* The Next action can fire indefinitely via SendSyncMessage; this cap
25
25
  \* prevents runaway exploration.
26
26
  CONSTRAINT
27
- Len(messages) <= MaxOps * 4
27
+ BoundedOps
@@ -165,6 +165,13 @@ Next ==
165
165
 
166
166
  Spec == Init /\ [][Next]_vars /\ WF_vars(Next)
167
167
 
168
+ (* State constraint. Named rather than inline because TLC's CONSTRAINT clause
169
+ takes a defined operator; an inline expression is rejected with "The
170
+ constraint of Len is equal to <Java Method ...>" before exploration begins,
171
+ so the checked-in .cfg could not be run at all (polly#172). *)
172
+ BoundedOps == Len(messages) <= MaxOps * 4
173
+
174
+
168
175
  -----------------------------------------------------------------------------
169
176
 
170
177
  (* Invariants *)
@@ -84,7 +84,7 @@ bun run tla:down # Stop container
84
84
  docker-compose -f specs/docker-compose.yml up -d
85
85
 
86
86
  # Run the model checker against each spec
87
- docker-compose -f specs/docker-compose.yml exec tla tlc MessageRouter.tla
87
+ docker-compose -f specs/docker-compose.yml exec tla tlc MessageRouter.tla -config MessageRouter.cfg
88
88
  docker-compose -f specs/docker-compose.yml exec tla tlc PeerState.tla
89
89
  docker-compose -f specs/docker-compose.yml exec tla tlc MeshState.tla
90
90