@fairfox/polly 0.31.0 → 0.32.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.
|
@@ -469,6 +469,7 @@ var init_tla = __esm(() => {
|
|
|
469
469
|
temporalProperties = [];
|
|
470
470
|
symmetrySets = [];
|
|
471
471
|
resolvedActionNames = new Map;
|
|
472
|
+
paramDomains = new Map;
|
|
472
473
|
tabSymmetryEnabled = false;
|
|
473
474
|
tabCount = 0;
|
|
474
475
|
moduleName = "UserApp";
|
|
@@ -1086,6 +1087,7 @@ var init_tla = __esm(() => {
|
|
|
1086
1087
|
this.line("");
|
|
1087
1088
|
}
|
|
1088
1089
|
addInit(config, _analysis) {
|
|
1090
|
+
this.deriveParamDomains(config, _analysis);
|
|
1089
1091
|
this.line("\\* Initial application state");
|
|
1090
1092
|
this.line("InitialState == [");
|
|
1091
1093
|
this.indent++;
|
|
@@ -1122,10 +1124,66 @@ var init_tla = __esm(() => {
|
|
|
1122
1124
|
static inferFieldType(name) {
|
|
1123
1125
|
return TLAGenerator.BOOL_PARAM_PATTERN.test(name) ? "BOOLEAN" : "Value";
|
|
1124
1126
|
}
|
|
1127
|
+
flattenStateConfig(config) {
|
|
1128
|
+
const out = new Map;
|
|
1129
|
+
const recurse = (prefix, fc) => {
|
|
1130
|
+
if (this.hasTypeIndicators(fc)) {
|
|
1131
|
+
out.set(this.sanitizeFieldName(prefix), fc);
|
|
1132
|
+
return;
|
|
1133
|
+
}
|
|
1134
|
+
for (const [key, value] of Object.entries(fc)) {
|
|
1135
|
+
if (typeof value !== "object" || value === null)
|
|
1136
|
+
continue;
|
|
1137
|
+
if (key === "item" || key === "element")
|
|
1138
|
+
continue;
|
|
1139
|
+
recurse(`${prefix}_${key}`, value);
|
|
1140
|
+
}
|
|
1141
|
+
};
|
|
1142
|
+
for (const [fieldPath, fc] of Object.entries(config.state)) {
|
|
1143
|
+
if (typeof fc !== "object" || fc === null)
|
|
1144
|
+
continue;
|
|
1145
|
+
recurse(fieldPath, fc);
|
|
1146
|
+
}
|
|
1147
|
+
return out;
|
|
1148
|
+
}
|
|
1149
|
+
deriveParamDomains(config, analysis) {
|
|
1150
|
+
this.paramDomains.clear();
|
|
1151
|
+
const fieldMap = this.flattenStateConfig(config);
|
|
1152
|
+
const provenance = new Map;
|
|
1153
|
+
for (const handler of analysis.handlers) {
|
|
1154
|
+
for (const a of handler.assignments ?? []) {
|
|
1155
|
+
this.recordParamDomain(handler.messageType, a, fieldMap, provenance, config);
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
recordParamDomain(messageType, a, fieldMap, provenance, config) {
|
|
1160
|
+
if (typeof a.value !== "string" || !a.value.startsWith("param:"))
|
|
1161
|
+
return;
|
|
1162
|
+
const paramName = this.sanitizeFieldName(a.value.substring(6));
|
|
1163
|
+
const fieldKey = this.sanitizeFieldName(a.field);
|
|
1164
|
+
const fc = fieldMap.get(fieldKey);
|
|
1165
|
+
if (!fc)
|
|
1166
|
+
return;
|
|
1167
|
+
const tlaType = this.fieldConfigToTLAType(fieldKey, fc, config);
|
|
1168
|
+
if (tlaType === "Value")
|
|
1169
|
+
return;
|
|
1170
|
+
const prior = provenance.get(paramName);
|
|
1171
|
+
if (prior && prior.domain !== tlaType) {
|
|
1172
|
+
throw new Error(`PayloadType conflict: parameter "${paramName}" is written to multiple state fields with incompatible TLA+ domains.
|
|
1173
|
+
` + ` - Handler "${prior.msg}" assigns it to field "${prior.field}" with domain ${prior.domain}
|
|
1174
|
+
` + ` - Handler "${messageType}" assigns it to field "${a.field}" with domain ${tlaType}
|
|
1175
|
+
` + `Either rename one parameter, split the handlers across subsystems, or set both fields to the same domain in your verification config.`);
|
|
1176
|
+
}
|
|
1177
|
+
this.paramDomains.set(paramName, tlaType);
|
|
1178
|
+
provenance.set(paramName, { msg: messageType, field: a.field, domain: tlaType });
|
|
1179
|
+
}
|
|
1125
1180
|
collectPayloadFields(analysis) {
|
|
1126
1181
|
const fields = new Map;
|
|
1127
1182
|
for (const f of ["id", "text", "userId"])
|
|
1128
1183
|
fields.set(f, "Value");
|
|
1184
|
+
for (const [name, domain] of this.paramDomains) {
|
|
1185
|
+
fields.set(name, domain);
|
|
1186
|
+
}
|
|
1129
1187
|
for (const handler of analysis.handlers) {
|
|
1130
1188
|
this.addHandlerParams(handler.parameters, fields);
|
|
1131
1189
|
this.addPayloadRefsFromHandler(handler, fields);
|
|
@@ -1136,9 +1194,17 @@ var init_tla = __esm(() => {
|
|
|
1136
1194
|
if (!params)
|
|
1137
1195
|
return;
|
|
1138
1196
|
for (const param of params) {
|
|
1139
|
-
if (
|
|
1140
|
-
|
|
1197
|
+
if (TLAGenerator.PAYLOAD_EXCLUDED.has(param))
|
|
1198
|
+
continue;
|
|
1199
|
+
const sanitized = this.sanitizeFieldName(param);
|
|
1200
|
+
const configDomain = this.paramDomains.get(sanitized);
|
|
1201
|
+
if (configDomain) {
|
|
1202
|
+
fields.set(param, configDomain);
|
|
1203
|
+
continue;
|
|
1141
1204
|
}
|
|
1205
|
+
if (fields.has(param))
|
|
1206
|
+
continue;
|
|
1207
|
+
fields.set(param, TLAGenerator.inferFieldType(param));
|
|
1142
1208
|
}
|
|
1143
1209
|
}
|
|
1144
1210
|
collectHandlerTexts(handler) {
|
|
@@ -7593,4 +7659,4 @@ main().catch((error) => {
|
|
|
7593
7659
|
process.exit(1);
|
|
7594
7660
|
});
|
|
7595
7661
|
|
|
7596
|
-
//# debugId=
|
|
7662
|
+
//# debugId=2D8DDA7C0A85F5E664756E2164756E21
|