netrun-sim 0.1.0__cp38-abi3-macosx_11_0_arm64.whl

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.
netrun_sim/__init__.py ADDED
@@ -0,0 +1,51 @@
1
+ # Re-export all types from the native extension
2
+ from netrun_sim.netrun_sim import *
3
+
4
+ __all__ = [
5
+ # Exceptions
6
+ "NetrunError",
7
+ "PacketNotFoundError",
8
+ "EpochNotFoundError",
9
+ "EpochNotRunningError",
10
+ "EpochNotStartableError",
11
+ "CannotFinishNonEmptyEpochError",
12
+ "PacketNotInNodeError",
13
+ "OutputPortNotFoundError",
14
+ "OutputPortFullError",
15
+ "SalvoConditionNotFoundError",
16
+ "SalvoConditionNotMetError",
17
+ "MaxSalvosExceededError",
18
+ "NodeNotFoundError",
19
+ "PacketNotAtInputPortError",
20
+ "InputPortNotFoundError",
21
+ "InputPortFullError",
22
+ "CannotMovePacketFromRunningEpochError",
23
+ "CannotMovePacketIntoRunningEpochError",
24
+ "EdgeNotFoundError",
25
+ "UnconnectedOutputPortError",
26
+ "GraphValidationError",
27
+ # Graph types
28
+ "PortSlotSpec",
29
+ "PortSlotSpecFinite",
30
+ "PortState",
31
+ "PortStateNumeric",
32
+ "SalvoConditionTerm",
33
+ "Port",
34
+ "PortType",
35
+ "PortRef",
36
+ "Edge",
37
+ "EdgeRef",
38
+ "SalvoCondition",
39
+ "Node",
40
+ "Graph",
41
+ # Net types
42
+ "PacketLocation",
43
+ "EpochState",
44
+ "Packet",
45
+ "Salvo",
46
+ "Epoch",
47
+ "NetAction",
48
+ "NetEvent",
49
+ "NetActionResponseData",
50
+ "Net",
51
+ ]
@@ -0,0 +1,486 @@
1
+ """Type stubs for netrun_sim - Flow-based development runtime simulation."""
2
+
3
+ from typing import Dict, List, Optional, Tuple, Union
4
+ from ulid import ULID
5
+
6
+ # === Exceptions ===
7
+
8
+ class NetrunError(Exception):
9
+ """Base exception for all netrun errors."""
10
+ ...
11
+
12
+ class PacketNotFoundError(NetrunError):
13
+ """Packet with the given ID was not found."""
14
+ ...
15
+
16
+ class EpochNotFoundError(NetrunError):
17
+ """Epoch with the given ID was not found."""
18
+ ...
19
+
20
+ class EpochNotRunningError(NetrunError):
21
+ """Epoch exists but is not in Running state."""
22
+ ...
23
+
24
+ class EpochNotStartableError(NetrunError):
25
+ """Epoch exists but is not in Startable state."""
26
+ ...
27
+
28
+ class CannotFinishNonEmptyEpochError(NetrunError):
29
+ """Cannot finish epoch because it still contains packets."""
30
+ ...
31
+
32
+ class PacketNotInNodeError(NetrunError):
33
+ """Packet is not inside the specified epoch's node location."""
34
+ ...
35
+
36
+ class OutputPortNotFoundError(NetrunError):
37
+ """Output port does not exist on the node."""
38
+ ...
39
+
40
+ class OutputPortFullError(NetrunError):
41
+ """Output port has reached its capacity."""
42
+ ...
43
+
44
+ class SalvoConditionNotFoundError(NetrunError):
45
+ """Salvo condition with the given name was not found."""
46
+ ...
47
+
48
+ class SalvoConditionNotMetError(NetrunError):
49
+ """Salvo condition exists but its term is not satisfied."""
50
+ ...
51
+
52
+ class MaxSalvosExceededError(NetrunError):
53
+ """Maximum number of salvos reached for this condition."""
54
+ ...
55
+
56
+ class NodeNotFoundError(NetrunError):
57
+ """Node with the given name was not found."""
58
+ ...
59
+
60
+ class PacketNotAtInputPortError(NetrunError):
61
+ """Packet is not at the expected input port."""
62
+ ...
63
+
64
+ class InputPortNotFoundError(NetrunError):
65
+ """Input port does not exist on the node."""
66
+ ...
67
+
68
+ class InputPortFullError(NetrunError):
69
+ """Input port has reached its capacity."""
70
+ ...
71
+
72
+ class CannotMovePacketFromRunningEpochError(NetrunError):
73
+ """Cannot move packet out of a running epoch."""
74
+ ...
75
+
76
+ class CannotMovePacketIntoRunningEpochError(NetrunError):
77
+ """Cannot move packet into a running epoch."""
78
+ ...
79
+
80
+ class EdgeNotFoundError(NetrunError):
81
+ """Edge does not exist in the graph."""
82
+ ...
83
+
84
+ class UnconnectedOutputPortError(NetrunError):
85
+ """Output port is not connected to any edge."""
86
+ ...
87
+
88
+ class GraphValidationError(NetrunError):
89
+ """Graph validation failed."""
90
+ ...
91
+
92
+
93
+ # === Graph Types ===
94
+
95
+ class PortSlotSpec:
96
+ """Port capacity specification."""
97
+ Infinite: PortSlotSpec
98
+ Finite: PortSlotSpec
99
+
100
+ @staticmethod
101
+ def infinite() -> PortSlotSpec: ...
102
+
103
+ @staticmethod
104
+ def finite(n: int) -> PortSlotSpecFinite: ...
105
+
106
+
107
+ class PortSlotSpecFinite:
108
+ """Finite port capacity with a specific limit."""
109
+ @property
110
+ def capacity(self) -> int: ...
111
+
112
+
113
+ class PortState:
114
+ """Port state predicate for salvo conditions."""
115
+ Empty: PortState
116
+ Full: PortState
117
+ NonEmpty: PortState
118
+ NonFull: PortState
119
+
120
+ @staticmethod
121
+ def empty() -> PortState: ...
122
+
123
+ @staticmethod
124
+ def full() -> PortState: ...
125
+
126
+ @staticmethod
127
+ def non_empty() -> PortState: ...
128
+
129
+ @staticmethod
130
+ def non_full() -> PortState: ...
131
+
132
+ @staticmethod
133
+ def equals(n: int) -> PortStateNumeric: ...
134
+
135
+ @staticmethod
136
+ def less_than(n: int) -> PortStateNumeric: ...
137
+
138
+ @staticmethod
139
+ def greater_than(n: int) -> PortStateNumeric: ...
140
+
141
+ @staticmethod
142
+ def equals_or_less_than(n: int) -> PortStateNumeric: ...
143
+
144
+ @staticmethod
145
+ def equals_or_greater_than(n: int) -> PortStateNumeric: ...
146
+
147
+
148
+ class PortStateNumeric:
149
+ """Numeric port state predicate."""
150
+ @property
151
+ def kind(self) -> str: ...
152
+ @property
153
+ def value(self) -> int: ...
154
+
155
+
156
+ class SalvoConditionTerm:
157
+ """Boolean expression over port states."""
158
+
159
+ @staticmethod
160
+ def port(port_name: str, state: Union[PortState, PortStateNumeric]) -> SalvoConditionTerm: ...
161
+
162
+ @staticmethod
163
+ def and_(terms: List[SalvoConditionTerm]) -> SalvoConditionTerm: ...
164
+
165
+ @staticmethod
166
+ def or_(terms: List[SalvoConditionTerm]) -> SalvoConditionTerm: ...
167
+
168
+ @staticmethod
169
+ def not_(term: SalvoConditionTerm) -> SalvoConditionTerm: ...
170
+
171
+
172
+ class Port:
173
+ """A port on a node."""
174
+
175
+ def __init__(self, slots_spec: Optional[Union[PortSlotSpec, PortSlotSpecFinite]] = None) -> None: ...
176
+
177
+ @property
178
+ def slots_spec(self) -> Union[PortSlotSpec, PortSlotSpecFinite]: ...
179
+
180
+
181
+ class PortType:
182
+ """Port type: Input or Output."""
183
+ Input: PortType
184
+ Output: PortType
185
+
186
+
187
+ class PortRef:
188
+ """Reference to a specific port on a node."""
189
+
190
+ def __init__(self, node_name: str, port_type: PortType, port_name: str) -> None: ...
191
+
192
+ @property
193
+ def node_name(self) -> str: ...
194
+ @property
195
+ def port_type(self) -> PortType: ...
196
+ @property
197
+ def port_name(self) -> str: ...
198
+
199
+ def __eq__(self, other: object) -> bool: ...
200
+ def __hash__(self) -> int: ...
201
+
202
+
203
+ class Edge:
204
+ """An edge in the graph."""
205
+
206
+ def __init__(self) -> None: ...
207
+
208
+
209
+ class EdgeRef:
210
+ """Reference to an edge by its source and target ports."""
211
+
212
+ def __init__(self, source: PortRef, target: PortRef) -> None: ...
213
+
214
+ @property
215
+ def source(self) -> PortRef: ...
216
+ @property
217
+ def target(self) -> PortRef: ...
218
+
219
+ def __eq__(self, other: object) -> bool: ...
220
+ def __hash__(self) -> int: ...
221
+
222
+
223
+ class SalvoCondition:
224
+ """A condition that defines when packets can trigger an epoch or be sent."""
225
+
226
+ def __init__(self, max_salvos: int, ports: List[str], term: SalvoConditionTerm) -> None: ...
227
+
228
+ @property
229
+ def max_salvos(self) -> int: ...
230
+ @property
231
+ def ports(self) -> List[str]: ...
232
+ @property
233
+ def term(self) -> SalvoConditionTerm: ...
234
+
235
+
236
+ class Node:
237
+ """A processing node in the graph."""
238
+
239
+ def __init__(
240
+ self,
241
+ name: str,
242
+ in_ports: Optional[Dict[str, Port]] = None,
243
+ out_ports: Optional[Dict[str, Port]] = None,
244
+ in_salvo_conditions: Optional[Dict[str, SalvoCondition]] = None,
245
+ out_salvo_conditions: Optional[Dict[str, SalvoCondition]] = None,
246
+ ) -> None: ...
247
+
248
+ @property
249
+ def name(self) -> str: ...
250
+ @property
251
+ def in_ports(self) -> Dict[str, Port]: ...
252
+ @property
253
+ def out_ports(self) -> Dict[str, Port]: ...
254
+ @property
255
+ def in_salvo_conditions(self) -> Dict[str, SalvoCondition]: ...
256
+ @property
257
+ def out_salvo_conditions(self) -> Dict[str, SalvoCondition]: ...
258
+
259
+
260
+ class Graph:
261
+ """The static topology of a flow-based network."""
262
+
263
+ def __init__(self, nodes: List[Node], edges: List[Tuple[EdgeRef, Edge]]) -> None: ...
264
+
265
+ def nodes(self) -> Dict[str, Node]: ...
266
+ def edges(self) -> Dict[EdgeRef, Edge]: ...
267
+ def validate(self) -> List[GraphValidationError]: ...
268
+ def to_json(self) -> str: ...
269
+
270
+ @staticmethod
271
+ def from_json(json_str: str) -> Graph: ...
272
+
273
+
274
+ # === Net Types ===
275
+
276
+ class PacketLocation:
277
+ """Where a packet is located in the network."""
278
+
279
+ @staticmethod
280
+ def node(epoch_id: Union[ULID, str]) -> PacketLocation: ...
281
+
282
+ @staticmethod
283
+ def input_port(node_name: str, port_name: str) -> PacketLocation: ...
284
+
285
+ @staticmethod
286
+ def output_port(epoch_id: Union[ULID, str], port_name: str) -> PacketLocation: ...
287
+
288
+ @staticmethod
289
+ def edge(edge_ref: EdgeRef) -> PacketLocation: ...
290
+
291
+ @staticmethod
292
+ def outside_net() -> PacketLocation: ...
293
+
294
+ @property
295
+ def kind(self) -> str: ...
296
+
297
+
298
+ class EpochState:
299
+ """Epoch lifecycle state."""
300
+ Startable: EpochState
301
+ Running: EpochState
302
+ Finished: EpochState
303
+
304
+
305
+ class Packet:
306
+ """A packet in the network."""
307
+
308
+ @property
309
+ def id(self) -> str: ...
310
+ @property
311
+ def location(self) -> PacketLocation: ...
312
+
313
+ def get_id(self) -> ULID: ...
314
+
315
+
316
+ class Salvo:
317
+ """A collection of packets entering or exiting a node."""
318
+
319
+ def __init__(self, salvo_condition: str, packets: List[Tuple[str, str]]) -> None: ...
320
+
321
+ @property
322
+ def salvo_condition(self) -> str: ...
323
+ @property
324
+ def packets(self) -> List[Tuple[str, str]]: ...
325
+
326
+
327
+ class Epoch:
328
+ """An execution instance of a node."""
329
+
330
+ @property
331
+ def id(self) -> str: ...
332
+ @property
333
+ def node_name(self) -> str: ...
334
+ @property
335
+ def in_salvo(self) -> Salvo: ...
336
+ @property
337
+ def out_salvos(self) -> List[Salvo]: ...
338
+ @property
339
+ def state(self) -> EpochState: ...
340
+
341
+ def get_id(self) -> ULID: ...
342
+ def start_time(self) -> int: ...
343
+
344
+
345
+ class NetAction:
346
+ """An action to perform on the network."""
347
+
348
+ @staticmethod
349
+ def run_net_until_blocked() -> NetAction: ...
350
+
351
+ @staticmethod
352
+ def create_packet(epoch_id: Optional[Union[ULID, str]] = None) -> NetAction: ...
353
+
354
+ @staticmethod
355
+ def consume_packet(packet_id: Union[ULID, str]) -> NetAction: ...
356
+
357
+ @staticmethod
358
+ def start_epoch(epoch_id: Union[ULID, str]) -> NetAction: ...
359
+
360
+ @staticmethod
361
+ def finish_epoch(epoch_id: Union[ULID, str]) -> NetAction: ...
362
+
363
+ @staticmethod
364
+ def cancel_epoch(epoch_id: Union[ULID, str]) -> NetAction: ...
365
+
366
+ @staticmethod
367
+ def create_and_start_epoch(node_name: str, salvo: Salvo) -> NetAction: ...
368
+
369
+ @staticmethod
370
+ def load_packet_into_output_port(packet_id: Union[ULID, str], port_name: str) -> NetAction: ...
371
+
372
+ @staticmethod
373
+ def send_output_salvo(epoch_id: Union[ULID, str], salvo_condition_name: str) -> NetAction: ...
374
+
375
+ @staticmethod
376
+ def transport_packet_to_location(packet_id: Union[ULID, str], destination: PacketLocation) -> NetAction: ...
377
+
378
+
379
+ class NetEvent:
380
+ """An event that occurred during a network action."""
381
+
382
+ @property
383
+ def kind(self) -> str: ...
384
+ @property
385
+ def timestamp(self) -> int: ...
386
+ @property
387
+ def packet_id(self) -> Optional[str]: ...
388
+ @property
389
+ def epoch_id(self) -> Optional[str]: ...
390
+ @property
391
+ def location(self) -> Optional[PacketLocation]: ...
392
+ @property
393
+ def salvo_condition(self) -> Optional[str]: ...
394
+
395
+
396
+ class NetActionResponseData:
397
+ """Response data from a successful action."""
398
+
399
+ class Packet:
400
+ packet_id: str
401
+
402
+ class StartedEpoch:
403
+ epoch: Epoch
404
+
405
+ class FinishedEpoch:
406
+ epoch: Epoch
407
+
408
+ class CancelledEpoch:
409
+ epoch: Epoch
410
+ destroyed_packets: List[str]
411
+
412
+ class Empty:
413
+ pass
414
+
415
+
416
+ class Net:
417
+ """The runtime state of a flow-based network."""
418
+
419
+ def __init__(self, graph: Graph) -> None: ...
420
+
421
+ def do_action(self, action: NetAction) -> Tuple[NetActionResponseData, List[NetEvent]]: ...
422
+
423
+ def packet_count_at(self, location: PacketLocation) -> int: ...
424
+
425
+ def get_packets_at_location(self, location: PacketLocation) -> List[ULID]: ...
426
+
427
+ def get_epoch(self, epoch_id: Union[ULID, str]) -> Optional[Epoch]: ...
428
+
429
+ def get_startable_epochs(self) -> List[ULID]: ...
430
+
431
+ def get_packet(self, packet_id: Union[ULID, str]) -> Optional[Packet]: ...
432
+
433
+ @property
434
+ def graph(self) -> Graph: ...
435
+
436
+
437
+ # === Re-exports ===
438
+
439
+ __all__ = [
440
+ # Exceptions
441
+ "NetrunError",
442
+ "PacketNotFoundError",
443
+ "EpochNotFoundError",
444
+ "EpochNotRunningError",
445
+ "EpochNotStartableError",
446
+ "CannotFinishNonEmptyEpochError",
447
+ "PacketNotInNodeError",
448
+ "OutputPortNotFoundError",
449
+ "OutputPortFullError",
450
+ "SalvoConditionNotFoundError",
451
+ "SalvoConditionNotMetError",
452
+ "MaxSalvosExceededError",
453
+ "NodeNotFoundError",
454
+ "PacketNotAtInputPortError",
455
+ "InputPortNotFoundError",
456
+ "InputPortFullError",
457
+ "CannotMovePacketFromRunningEpochError",
458
+ "CannotMovePacketIntoRunningEpochError",
459
+ "EdgeNotFoundError",
460
+ "UnconnectedOutputPortError",
461
+ "GraphValidationError",
462
+ # Graph types
463
+ "PortSlotSpec",
464
+ "PortSlotSpecFinite",
465
+ "PortState",
466
+ "PortStateNumeric",
467
+ "SalvoConditionTerm",
468
+ "Port",
469
+ "PortType",
470
+ "PortRef",
471
+ "Edge",
472
+ "EdgeRef",
473
+ "SalvoCondition",
474
+ "Node",
475
+ "Graph",
476
+ # Net types
477
+ "PacketLocation",
478
+ "EpochState",
479
+ "Packet",
480
+ "Salvo",
481
+ "Epoch",
482
+ "NetAction",
483
+ "NetEvent",
484
+ "NetActionResponseData",
485
+ "Net",
486
+ ]
Binary file
netrun_sim/py.typed ADDED
File without changes
@@ -0,0 +1,7 @@
1
+ Metadata-Version: 2.4
2
+ Name: netrun-sim
3
+ Version: 0.1.0
4
+ Classifier: Programming Language :: Rust
5
+ Classifier: Programming Language :: Python :: Implementation :: CPython
6
+ Requires-Dist: python-ulid>=1.0
7
+ Requires-Python: >=3.8
@@ -0,0 +1,7 @@
1
+ netrun_sim-0.1.0.dist-info/METADATA,sha256=WptXNdmqI5V7s3MxS4DldwyMyOIJJbl80C9crtq2osQ,222
2
+ netrun_sim-0.1.0.dist-info/WHEEL,sha256=tsXOb_QjXfrIzsTjWbzE9EA8s59Oy2CLZwoCmtd6s2o,103
3
+ netrun_sim/__init__.py,sha256=njQWg7Vvcc_aWIrZlB_ZL7ItlO244mroOLrzOMzY2mw,1176
4
+ netrun_sim/__init__.pyi,sha256=Na11c6IyeFyssLRNqIlptwejbE1VERaBRD81vXeXNtc,11907
5
+ netrun_sim/netrun_sim.abi3.so,sha256=jturfO4tp7sU2kc4mE9GwTDP1Ghro_CvwY-qFBCb8lI,1424416
6
+ netrun_sim/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ netrun_sim-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.10.2)
3
+ Root-Is-Purelib: false
4
+ Tag: cp38-abi3-macosx_11_0_arm64