libpetri 2.12.1 → 2.13.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.
@@ -97,6 +97,80 @@ function crossProduct(a, b) {
97
97
  return result;
98
98
  }
99
99
 
100
+ // src/core/transition-action.ts
101
+ function passthrough() {
102
+ return PASSTHROUGH;
103
+ }
104
+ var PASSTHROUGH = async () => {
105
+ };
106
+ function isPassthrough(action) {
107
+ return action === PASSTHROUGH;
108
+ }
109
+ function transform(fn) {
110
+ return async (ctx) => {
111
+ const result = fn(ctx);
112
+ for (const outputPlace of ctx.outputPlaces()) {
113
+ ctx.output(outputPlace, result);
114
+ }
115
+ };
116
+ }
117
+ function fork() {
118
+ return transform((ctx) => {
119
+ const inputPlaces = ctx.inputPlaces();
120
+ if (inputPlaces.size !== 1) {
121
+ throw new Error(`Fork requires exactly 1 input place, found ${inputPlaces.size}`);
122
+ }
123
+ const inputPlace = inputPlaces.values().next().value;
124
+ return ctx.input(inputPlace);
125
+ });
126
+ }
127
+ function transformFrom(inputPlace, fn) {
128
+ return transform((ctx) => fn(ctx.input(inputPlace)));
129
+ }
130
+ function transformAsync(fn) {
131
+ return async (ctx) => {
132
+ const result = await fn(ctx);
133
+ for (const outputPlace of ctx.outputPlaces()) {
134
+ ctx.output(outputPlace, result);
135
+ }
136
+ };
137
+ }
138
+ function produce(place, value) {
139
+ return async (ctx) => {
140
+ ctx.output(place, value);
141
+ };
142
+ }
143
+ function withTimeout(action, timeoutMs, timeoutPlace2, timeoutValue) {
144
+ return (ctx) => {
145
+ return new Promise((resolve, reject) => {
146
+ let completed = false;
147
+ const timer = setTimeout(() => {
148
+ if (!completed) {
149
+ completed = true;
150
+ ctx.output(timeoutPlace2, timeoutValue);
151
+ resolve();
152
+ }
153
+ }, timeoutMs);
154
+ action(ctx).then(
155
+ () => {
156
+ if (!completed) {
157
+ completed = true;
158
+ clearTimeout(timer);
159
+ resolve();
160
+ }
161
+ },
162
+ (err) => {
163
+ if (!completed) {
164
+ completed = true;
165
+ clearTimeout(timer);
166
+ reject(err);
167
+ }
168
+ }
169
+ );
170
+ });
171
+ };
172
+ }
173
+
100
174
  // src/verification/marking-state.ts
101
175
  var MARKING_STATE_KEY = /* @__PURE__ */ Symbol("MarkingState.internal");
102
176
  var MarkingState = class _MarkingState {
@@ -1400,6 +1474,17 @@ var StateClass = class {
1400
1474
  }
1401
1475
  };
1402
1476
 
1477
+ // src/core/internal/output-action-check.ts
1478
+ function requireOutputProducingActions(net) {
1479
+ for (const t of net.transitions) {
1480
+ if (t.outputSpec !== null && isPassthrough(t.action)) {
1481
+ throw new Error(
1482
+ `Transition '${t.name}' declares an output spec but carries passthrough(), which produces no tokens. Every firing would fail output validation (IO-015) and the declared output would never arrive. Bind an action that produces it \u2014 fork() moves the input token across \u2014 or drop the output spec if the transition is meant to be a sink.`
1483
+ );
1484
+ }
1485
+ }
1486
+ }
1487
+
1403
1488
  // src/verification/analysis/state-class-graph.ts
1404
1489
  var StateClassGraph = class _StateClassGraph {
1405
1490
  net;
@@ -1430,8 +1515,13 @@ var StateClassGraph = class _StateClassGraph {
1430
1515
  }
1431
1516
  }
1432
1517
  }
1433
- /** Builds the state class graph for a Time Petri Net. */
1518
+ /**
1519
+ * Builds the state class graph for a Time Petri Net.
1520
+ *
1521
+ * @throws Error if the net violates CORE-043 — analysis rejects the same nets execution rejects.
1522
+ */
1434
1523
  static build(net, initialMarking, maxClasses, environmentPlaces, environmentMode) {
1524
+ requireOutputProducingActions(net);
1435
1525
  const envMode = environmentMode ?? ignore();
1436
1526
  const envPlaces = /* @__PURE__ */ new Set();
1437
1527
  if (environmentPlaces) {
@@ -2775,8 +2865,11 @@ var SmtVerifier = class _SmtVerifier {
2775
2865
  }
2776
2866
  /**
2777
2867
  * Runs the verification pipeline.
2868
+ *
2869
+ * @throws Error if the net violates CORE-043 — verification rejects the same nets execution rejects.
2778
2870
  */
2779
2871
  async verify() {
2872
+ requireOutputProducingActions(this.net);
2780
2873
  const start = performance.now();
2781
2874
  const report = [];
2782
2875
  report.push("=== IC3/PDR SAFETY VERIFICATION ===\n");
@@ -3169,6 +3262,14 @@ export {
3169
3262
  forwardInput,
3170
3263
  allPlaces,
3171
3264
  enumerateBranches,
3265
+ passthrough,
3266
+ isPassthrough,
3267
+ transform,
3268
+ fork,
3269
+ transformFrom,
3270
+ transformAsync,
3271
+ produce,
3272
+ withTimeout,
3172
3273
  MarkingState,
3173
3274
  MarkingStateBuilder,
3174
3275
  deadlockFree,
@@ -3199,10 +3300,11 @@ export {
3199
3300
  encode,
3200
3301
  DBM,
3201
3302
  StateClass,
3303
+ requireOutputProducingActions,
3202
3304
  StateClassGraph,
3203
3305
  decode,
3204
3306
  SmtVerifier,
3205
3307
  isProven,
3206
3308
  isViolated
3207
3309
  };
3208
- //# sourceMappingURL=chunk-V3WTQRHC.js.map
3310
+ //# sourceMappingURL=chunk-7VJ5CYUU.js.map