@fairfox/polly 0.35.0 → 0.36.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.
@@ -40,6 +40,14 @@ ContextType == {"background", "content", "popup", "devtools", "options", "offscr
40
40
  PortState == {"connected", "disconnected"}
41
41
  MessageStatus == {"pending", "routing", "delivered", "failed", "timeout"}
42
42
 
43
+ \* Sentinel value for messages that have not been routed to a concrete
44
+ \* target yet. Once RouteMessage selects a target from msg.targets, that
45
+ \* target is recorded in deliveredTo so step-temporal postcondition
46
+ \* properties can identify which single target was actually mutated.
47
+ \* Without this field a property that quantifies over msg.targets
48
+ \* false-positives whenever routing picks one target out of many.
49
+ NoTarget == "NoTarget"
50
+
43
51
  Message == [
44
52
  id: Nat,
45
53
  source: ContextType,
@@ -47,7 +55,8 @@ Message == [
47
55
  tabId: Nat,
48
56
  msgType: STRING, \* Message type for handler dispatch
49
57
  status: MessageStatus,
50
- timestamp: Nat
58
+ timestamp: Nat,
59
+ deliveredTo: ContextType \cup {NoTarget}
51
60
  ]
52
61
 
53
62
  -----------------------------------------------------------------------------
@@ -97,7 +106,8 @@ SendMessage(source, targetSet, tabId, messageType) ==
97
106
  tabId |-> tabId,
98
107
  msgType |-> messageType,
99
108
  status |-> "pending",
100
- timestamp |-> time
109
+ timestamp |-> time,
110
+ deliveredTo |-> NoTarget
101
111
  ]
102
112
  IN /\ messages' = Append(messages, newMsg)
103
113
  /\ pendingRequests' = pendingRequests @@
@@ -118,7 +128,8 @@ RouteMessage(msgIndex) ==
118
128
  \E target \in msg.targets :
119
129
  /\ IF target \in Contexts /\ ports[target] = "connected"
120
130
  THEN \* Successful delivery to this target
121
- /\ messages' = [messages EXCEPT ![msgIndex].status = "delivered"]
131
+ /\ messages' = [messages EXCEPT ![msgIndex].status = "delivered",
132
+ ![msgIndex].deliveredTo = target]
122
133
  /\ delivered' = delivered \union {msg.id}
123
134
  /\ pendingRequests' = [id \in DOMAIN pendingRequests \ {msg.id} |->
124
135
  pendingRequests[id]]
@@ -1422,7 +1422,7 @@ var init_tla = __esm(() => {
1422
1422
  const predicateClauses = postconditions.map((pc) => this.tsExpressionToTLA(pc.expression, true)).filter((p) => p && p.length > 0).map((p) => p.replace(/\[ctx\]/g, "[target]"));
1423
1423
  if (predicateClauses.length === 0)
1424
1424
  return;
1425
- const conjunction = predicateClauses.length === 1 ? predicateClauses[0] : predicateClauses.map((c) => ` /\\ ${c}`).join(`
1425
+ const conjunction = predicateClauses.length === 1 ? predicateClauses[0] : predicateClauses.map((c) => ` /\\ ${c}`).join(`
1426
1426
  `);
1427
1427
  const propertyName = `EnsuresAfter_${actionName}`;
1428
1428
  const messages = postconditions.map((pc) => pc.message).filter((m) => Boolean(m)).join("; ");
@@ -1431,7 +1431,7 @@ var init_tla = __esm(() => {
1431
1431
  ` + ` (messages[m].status = "pending"
1432
1432
  ` + ` /\\ messages'[m].status = "delivered"
1433
1433
  ` + ` /\\ messages[m].msgType = "${messageType}")
1434
- ` + ` => \\A target \\in messages[m].targets :
1434
+ ` + ` => LET target == messages'[m].deliveredTo IN
1435
1435
  ` + ` (target \\in Contexts /\\ ports[target] = "connected")
1436
1436
  ` + ` =>
1437
1437
  ` + (predicateClauses.length === 1 ? ` ${predicateClauses[0]}` : conjunction);
@@ -2018,7 +2018,8 @@ var init_tla = __esm(() => {
2018
2018
  this.line(" /\\ \\E target \\in msg.targets :");
2019
2019
  this.line(' /\\ IF target \\in Contexts /\\ ports[target] = "connected"');
2020
2020
  this.line(" THEN \\* Successful delivery - route AND invoke handler");
2021
- this.line(` /\\ messages' = [messages EXCEPT ![msgIndex].status = "delivered"]`);
2021
+ this.line(` /\\ messages' = [messages EXCEPT ![msgIndex].status = "delivered",`);
2022
+ this.line(" ![msgIndex].deliveredTo = target]");
2022
2023
  this.line(" /\\ delivered' = delivered \\union {msg.id}");
2023
2024
  this.line(" /\\ pendingRequests' = [id \\in DOMAIN pendingRequests \\ {msg.id} |->");
2024
2025
  this.line(" pendingRequests[id]]");
@@ -7716,4 +7717,4 @@ main().catch((error) => {
7716
7717
  process.exit(1);
7717
7718
  });
7718
7719
 
7719
- //# debugId=616D5E99FD251E9364756E2164756E21
7720
+ //# debugId=F1333D1589EFA94964756E2164756E21