tickflow-py 0.2.0__tar.gz → 0.3.0__tar.gz
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.
- {tickflow_py-0.2.0/tickflow_py.egg-info → tickflow_py-0.3.0}/PKG-INFO +9 -6
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/README.md +8 -5
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/pyproject.toml +1 -1
- tickflow_py-0.3.0/tests/test_failed_terminal.py +188 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tickflow/async_runner.py +5 -1
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tickflow/runner.py +15 -9
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tickflow/views.py +1 -1
- {tickflow_py-0.2.0 → tickflow_py-0.3.0/tickflow_py.egg-info}/PKG-INFO +9 -6
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tickflow_py.egg-info/SOURCES.txt +1 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/LICENSE +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/setup.cfg +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tests/test_async.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tests/test_async_bind.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tests/test_audit_switch.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tests/test_bind.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tests/test_bind_validation.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tests/test_checker.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tests/test_checkpoints.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tests/test_dispatch.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tests/test_engine.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tests/test_failure.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tests/test_fireable.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tests/test_guard_view.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tests/test_hooks.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tests/test_loop.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tests/test_node_state.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tests/test_node_view.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tests/test_parser.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tests/test_persistence.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tests/test_registry_sig.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tests/test_remap.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tests/test_snapshot.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tests/test_status.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tests/test_storage_window.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tests/test_visualization.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tickflow/__init__.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tickflow/__main__.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tickflow/checker.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tickflow/cli.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tickflow/engine.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tickflow/ir.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tickflow/parser.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tickflow/persistence.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tickflow/registry.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tickflow/state.py +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tickflow_py.egg-info/dependency_links.txt +0 -0
- {tickflow_py-0.2.0 → tickflow_py-0.3.0}/tickflow_py.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tickflow-py
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: A small Petri-style workflow control framework
|
|
5
5
|
Author: MountLynx
|
|
6
6
|
License: MIT
|
|
@@ -325,7 +325,8 @@ def call_llm(v):
|
|
|
325
325
|
|
|
326
326
|
- **`type="llm"`** (default): a logical/recoverable failure. The node's
|
|
327
327
|
out-edges write `False`, so downstream AND-joins don't fire (= "upstream
|
|
328
|
-
failed, skip downstream"). The run
|
|
328
|
+
failed, skip downstream"). The run keeps ticking — unless the skip
|
|
329
|
+
strands pending work, in which case it ends `FAILED` (see below).
|
|
329
330
|
- **`type="infrastructure"`**: an unrecoverable failure. Out-edges write
|
|
330
331
|
`False` **and** the runner enters `ABORTED`, halting all further ticks.
|
|
331
332
|
|
|
@@ -335,7 +336,9 @@ A `Failure` is still recorded in `RunState` and the audit log with
|
|
|
335
336
|
> **Important**: a failed node writes `False` to **all** out-edges —
|
|
336
337
|
> guarded edges are not evaluated. To implement controllable routing
|
|
337
338
|
> (e.g. retry on failure), have the body return a result dict and let the
|
|
338
|
-
> guard inspect the output value, rather than returning `Failure`.
|
|
339
|
+
> guard inspect the output value, rather than returning `Failure`. If the
|
|
340
|
+
> skip strands pending work (an AND-join whose other input already
|
|
341
|
+
> arrived), the run ends `FAILED` (starved) instead of `IDLE`.
|
|
339
342
|
|
|
340
343
|
### RunStatus
|
|
341
344
|
|
|
@@ -343,11 +346,11 @@ A `Failure` is still recorded in `RunState` and the audit log with
|
|
|
343
346
|
|
|
344
347
|
| Status | Meaning |
|
|
345
348
|
|--------|---------|
|
|
346
|
-
| `IDLE` | quiescent
|
|
349
|
+
| `IDLE` | quiescent with nothing pending (all work done, or never started) |
|
|
347
350
|
| `RUNNING` | a tick fired (transient; becomes IDLE/terminal next) |
|
|
348
351
|
| `ABORTED` | an infrastructure `Failure` occurred; halted |
|
|
349
352
|
| `CANCELLED` | `cancel()` was called; halted |
|
|
350
|
-
| `FAILED` | (
|
|
353
|
+
| `FAILED` | starved: work is pending (a True slot / armed start) but nothing is fireable; halted |
|
|
351
354
|
|
|
352
355
|
```python
|
|
353
356
|
rn.cancel("user requested") # -> CANCELLED; ticks become no-ops
|
|
@@ -595,7 +598,7 @@ tickflow/
|
|
|
595
598
|
views.py DictView, Resolved, Missing
|
|
596
599
|
persistence.py Backend protocol, JsonBackend, SqliteBackend, NullBackend
|
|
597
600
|
cli.py python -m tickflow ...
|
|
598
|
-
tests/
|
|
601
|
+
tests/ 25 files, 291 tests
|
|
599
602
|
examples/ 8 examples (6 graph + 2 Python scripts)
|
|
600
603
|
```
|
|
601
604
|
|
|
@@ -303,7 +303,8 @@ def call_llm(v):
|
|
|
303
303
|
|
|
304
304
|
- **`type="llm"`** (default): a logical/recoverable failure. The node's
|
|
305
305
|
out-edges write `False`, so downstream AND-joins don't fire (= "upstream
|
|
306
|
-
failed, skip downstream"). The run
|
|
306
|
+
failed, skip downstream"). The run keeps ticking — unless the skip
|
|
307
|
+
strands pending work, in which case it ends `FAILED` (see below).
|
|
307
308
|
- **`type="infrastructure"`**: an unrecoverable failure. Out-edges write
|
|
308
309
|
`False` **and** the runner enters `ABORTED`, halting all further ticks.
|
|
309
310
|
|
|
@@ -313,7 +314,9 @@ A `Failure` is still recorded in `RunState` and the audit log with
|
|
|
313
314
|
> **Important**: a failed node writes `False` to **all** out-edges —
|
|
314
315
|
> guarded edges are not evaluated. To implement controllable routing
|
|
315
316
|
> (e.g. retry on failure), have the body return a result dict and let the
|
|
316
|
-
> guard inspect the output value, rather than returning `Failure`.
|
|
317
|
+
> guard inspect the output value, rather than returning `Failure`. If the
|
|
318
|
+
> skip strands pending work (an AND-join whose other input already
|
|
319
|
+
> arrived), the run ends `FAILED` (starved) instead of `IDLE`.
|
|
317
320
|
|
|
318
321
|
### RunStatus
|
|
319
322
|
|
|
@@ -321,11 +324,11 @@ A `Failure` is still recorded in `RunState` and the audit log with
|
|
|
321
324
|
|
|
322
325
|
| Status | Meaning |
|
|
323
326
|
|--------|---------|
|
|
324
|
-
| `IDLE` | quiescent
|
|
327
|
+
| `IDLE` | quiescent with nothing pending (all work done, or never started) |
|
|
325
328
|
| `RUNNING` | a tick fired (transient; becomes IDLE/terminal next) |
|
|
326
329
|
| `ABORTED` | an infrastructure `Failure` occurred; halted |
|
|
327
330
|
| `CANCELLED` | `cancel()` was called; halted |
|
|
328
|
-
| `FAILED` | (
|
|
331
|
+
| `FAILED` | starved: work is pending (a True slot / armed start) but nothing is fireable; halted |
|
|
329
332
|
|
|
330
333
|
```python
|
|
331
334
|
rn.cancel("user requested") # -> CANCELLED; ticks become no-ops
|
|
@@ -573,7 +576,7 @@ tickflow/
|
|
|
573
576
|
views.py DictView, Resolved, Missing
|
|
574
577
|
persistence.py Backend protocol, JsonBackend, SqliteBackend, NullBackend
|
|
575
578
|
cli.py python -m tickflow ...
|
|
576
|
-
tests/
|
|
579
|
+
tests/ 25 files, 291 tests
|
|
577
580
|
examples/ 8 examples (6 graph + 2 Python scripts)
|
|
578
581
|
```
|
|
579
582
|
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"""Tests for the FAILED terminal state: a starved run (pending work, nothing
|
|
2
|
+
fireable) must end FAILED, not IDLE. Spec: SpecModule
|
|
3
|
+
2026-09-30-tickflow-failed-terminal-design.md."""
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import asyncio
|
|
7
|
+
|
|
8
|
+
import pytest
|
|
9
|
+
|
|
10
|
+
from tickflow import parse, Runner, Registry, RunStatus, Failure
|
|
11
|
+
from tickflow.async_runner import AsyncRunner
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _reg():
|
|
15
|
+
r = Registry()
|
|
16
|
+
|
|
17
|
+
@r.body("ok")
|
|
18
|
+
def _ok(v):
|
|
19
|
+
return "ok"
|
|
20
|
+
|
|
21
|
+
@r.body("fail_llm")
|
|
22
|
+
def _fllm(v):
|
|
23
|
+
return Failure("bad output", type="llm")
|
|
24
|
+
|
|
25
|
+
@r.body("bump")
|
|
26
|
+
def _bump(v):
|
|
27
|
+
v.state["n"] = v.state.get("n", 0) + 1
|
|
28
|
+
return v.state["n"]
|
|
29
|
+
|
|
30
|
+
r.guard("lt3", lambda out: out < 3)
|
|
31
|
+
return r
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _starved_graph(r):
|
|
35
|
+
# A ok -> slot (C,A)=True; B llm-fail -> slot (C,B)=False.
|
|
36
|
+
# AND-join C waits forever for (C,B): pending but nothing fireable.
|
|
37
|
+
return parse(
|
|
38
|
+
"[A]-->C\n[B]-->C\nC.join: AND\nA.body: ok\nB.body: fail_llm",
|
|
39
|
+
registry=r,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def test_starved_sync_ends_failed():
|
|
44
|
+
r = _reg()
|
|
45
|
+
rn = Runner(_starved_graph(r), r)
|
|
46
|
+
rn.run_until_idle(max_ticks=10)
|
|
47
|
+
assert rn.status == RunStatus.FAILED
|
|
48
|
+
assert rn.is_terminal()
|
|
49
|
+
assert not rn.is_idle()
|
|
50
|
+
# FAILED 已在 _TERMINAL:后续 tick 空操作。
|
|
51
|
+
before = len(rn.audit_log())
|
|
52
|
+
rn.tick()
|
|
53
|
+
assert len(rn.audit_log()) == before
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def test_starved_status_set_inside_tick_before_break():
|
|
57
|
+
# 状态判定发生在 tick 内、run_until_idle 空 tick break 读取之前:
|
|
58
|
+
# 首个空 tick 返回 [] 时 status 已是 FAILED。
|
|
59
|
+
r = _reg()
|
|
60
|
+
rn = Runner(_starved_graph(r), r)
|
|
61
|
+
rn.tick() # tick 0: A ok + B fail_llm(双双点火)
|
|
62
|
+
assert rn.status == RunStatus.RUNNING
|
|
63
|
+
firings = rn.tick() # tick 1: 空 tick
|
|
64
|
+
assert firings == []
|
|
65
|
+
assert rn.status == RunStatus.FAILED
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def test_starved_status_set_inside_tick_before_break_async():
|
|
69
|
+
# sync 版的 async 对偶:空 tick 返回 [] 时 status 已在 tick 内定为 FAILED。
|
|
70
|
+
r = _reg()
|
|
71
|
+
rn = AsyncRunner(_starved_graph(r), r)
|
|
72
|
+
|
|
73
|
+
async def _drive():
|
|
74
|
+
await rn.tick() # tick 0: A ok + B fail_llm
|
|
75
|
+
assert rn.status == RunStatus.RUNNING
|
|
76
|
+
firings = await rn.tick() # tick 1: 空 tick
|
|
77
|
+
assert firings == []
|
|
78
|
+
assert rn.status == RunStatus.FAILED
|
|
79
|
+
|
|
80
|
+
asyncio.run(_drive())
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def test_starved_async_ends_failed():
|
|
84
|
+
r = _reg()
|
|
85
|
+
rn = AsyncRunner(_starved_graph(r), r)
|
|
86
|
+
asyncio.run(rn.run_until_idle(max_ticks=10))
|
|
87
|
+
assert rn.status == RunStatus.FAILED
|
|
88
|
+
assert rn.is_terminal()
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
# --- 不误伤面:语义矩阵其余各行不受状态判定改动影响 -----------------------
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def test_full_completion_still_idle():
|
|
95
|
+
# 全部工作完成(无 pending)→ IDLE(Module 层照旧映射 done)。
|
|
96
|
+
r = _reg()
|
|
97
|
+
g = parse("[A]-->B\nA.body: ok\nB.body: ok", registry=r)
|
|
98
|
+
rn = Runner(g, r)
|
|
99
|
+
rn.run_until_idle(max_ticks=10)
|
|
100
|
+
assert rn.status == RunStatus.IDLE
|
|
101
|
+
assert not rn._has_pending()
|
|
102
|
+
assert rn.is_terminal() # IDLE 且无事可做仍是终局
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def test_or_join_loop_exit_stays_idle():
|
|
106
|
+
# OR-join repair 环(producer 条件到场,波间衔接无空 tick):守卫关闭
|
|
107
|
+
# 循环边后所有槽位 False → 空 tick → IDLE 而非 FAILED。
|
|
108
|
+
r = _reg()
|
|
109
|
+
g = parse(
|
|
110
|
+
"[P]-->W\nP.body: ok\nW.body: bump\nW--|lt3|-->W\nW.join: OR",
|
|
111
|
+
registry=r,
|
|
112
|
+
)
|
|
113
|
+
rn = Runner(g, r)
|
|
114
|
+
rn.run_until_idle(max_ticks=50)
|
|
115
|
+
assert rn.status == RunStatus.IDLE
|
|
116
|
+
w_outputs = [f.output for f in rn.audit_log() if f.node == "W"]
|
|
117
|
+
assert w_outputs == [1, 2, 3]
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def test_or_join_loop_exit_stays_idle_async():
|
|
121
|
+
r = _reg()
|
|
122
|
+
g = parse(
|
|
123
|
+
"[P]-->W\nP.body: ok\nW.body: bump\nW--|lt3|-->W\nW.join: OR",
|
|
124
|
+
registry=r,
|
|
125
|
+
)
|
|
126
|
+
rn = AsyncRunner(g, r)
|
|
127
|
+
asyncio.run(rn.run_until_idle(max_ticks=50))
|
|
128
|
+
assert rn.status == RunStatus.IDLE
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def test_failed_upstream_false_slot_still_idle():
|
|
132
|
+
# 失败上游写 False ≠ pending:下游被跳过,照旧 IDLE
|
|
133
|
+
#(与 tests/test_failure.py::test_llm_failure_writes_false_downstream 互为锚)。
|
|
134
|
+
r = _reg()
|
|
135
|
+
g = parse("[A]-->B\nA.body: fail_llm\nB.body: ok", registry=r)
|
|
136
|
+
rn = Runner(g, r)
|
|
137
|
+
rn.run_until_idle(max_ticks=10)
|
|
138
|
+
assert rn.status == RunStatus.IDLE
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def test_max_ticks_cutoff_stays_running():
|
|
142
|
+
# max_ticks 耗尽停在 RUNNING(Module 层映射 truncated,可 resume),
|
|
143
|
+
# 不经过空 tick 判定——不得变成 FAILED/IDLE。
|
|
144
|
+
r = _reg()
|
|
145
|
+
rn = Runner(_starved_graph(r), r)
|
|
146
|
+
rn.run_until_idle(max_ticks=1) # tick 0 点火 A、B 后即达上限
|
|
147
|
+
assert rn.status == RunStatus.RUNNING
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def test_pause_breaks_before_status_judgement():
|
|
151
|
+
# pause 在 tick 前 break,不进状态判定。
|
|
152
|
+
r = _reg()
|
|
153
|
+
rn = Runner(_starved_graph(r), r)
|
|
154
|
+
rn.run_until_idle(max_ticks=10, pause_at={1})
|
|
155
|
+
assert rn.status == RunStatus.RUNNING
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def test_cancel_before_run_and_after_failed():
|
|
159
|
+
r = _reg()
|
|
160
|
+
rn = Runner(_starved_graph(r), r)
|
|
161
|
+
rn.cancel("user")
|
|
162
|
+
assert rn.status == RunStatus.CANCELLED
|
|
163
|
+
assert rn.cancel_reason == "user"
|
|
164
|
+
rn2 = Runner(_starved_graph(r), r)
|
|
165
|
+
rn2.run_until_idle(max_ticks=10)
|
|
166
|
+
assert rn2.status == RunStatus.FAILED
|
|
167
|
+
rn2.cancel("late")
|
|
168
|
+
assert rn2.status == RunStatus.FAILED # 终态 cancel 是 no-op
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def test_reset_from_failed_back_to_idle():
|
|
172
|
+
r = _reg()
|
|
173
|
+
rn = Runner(_starved_graph(r), r)
|
|
174
|
+
rn.run_until_idle(max_ticks=10)
|
|
175
|
+
assert rn.status == RunStatus.FAILED
|
|
176
|
+
rn.reset()
|
|
177
|
+
assert rn.status == RunStatus.IDLE
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def test_restore_failed_snapshot_resumes_as_idle():
|
|
181
|
+
# restore() 把终态快照重置回 IDLE(既有 resume 语义),快照本身带 failed。
|
|
182
|
+
r = _reg()
|
|
183
|
+
rn = Runner(_starved_graph(r), r)
|
|
184
|
+
rn.run_until_idle(max_ticks=10)
|
|
185
|
+
snap = rn.snapshot()
|
|
186
|
+
assert snap["status"] == "failed"
|
|
187
|
+
rn.restore(snap)
|
|
188
|
+
assert rn.status == RunStatus.IDLE
|
|
@@ -221,7 +221,11 @@ class AsyncRunner(_BaseRunner):
|
|
|
221
221
|
if aborted:
|
|
222
222
|
self.status = RunStatus.ABORTED
|
|
223
223
|
elif not firings:
|
|
224
|
-
|
|
224
|
+
# Mirror of Runner.tick: empty-tick fixpoint — pending work with
|
|
225
|
+
# nothing fireable is the starved FAILED terminal.
|
|
226
|
+
self.status = (
|
|
227
|
+
RunStatus.FAILED if self._has_pending() else RunStatus.IDLE
|
|
228
|
+
)
|
|
225
229
|
else:
|
|
226
230
|
self.status = RunStatus.RUNNING
|
|
227
231
|
await self._run_tick_end_hooks(self.tick_count - 1, firings)
|
|
@@ -10,12 +10,13 @@ fires whole ticks.
|
|
|
10
10
|
RunStatus
|
|
11
11
|
---------
|
|
12
12
|
Replaces the old ``_idle: bool``. A run transitions:
|
|
13
|
-
IDLE --tick--> RUNNING --(
|
|
13
|
+
IDLE --tick--> RUNNING --(empty tick, nothing pending)--> IDLE
|
|
14
14
|
--(infra Failure)--> ABORTED
|
|
15
15
|
--cancel()--> CANCELLED
|
|
16
|
-
--(
|
|
16
|
+
--(starved: work pending, nothing fireable)--> FAILED
|
|
17
17
|
``is_idle()`` is ``status == IDLE``. ABORTED/CANCELLED/FAILED ticks return
|
|
18
|
-
empty and do not advance.
|
|
18
|
+
empty and do not advance. (max_ticks exhaustion leaves RUNNING -- the caller
|
|
19
|
+
decides whether to resume; run_until_idle just stops.)
|
|
19
20
|
|
|
20
21
|
Hooks
|
|
21
22
|
-----
|
|
@@ -230,15 +231,16 @@ def _warn_graph_changes(old: Graph, new: Graph, run_state: RunState) -> None:
|
|
|
230
231
|
|
|
231
232
|
|
|
232
233
|
class RunStatus(str, enum.Enum):
|
|
233
|
-
"""Lifecycle of a Runner. IDLE means "quiescent
|
|
234
|
-
|
|
235
|
-
states (ABORTED/CANCELLED/FAILED) stop
|
|
234
|
+
"""Lifecycle of a Runner. IDLE means "quiescent with nothing pending" --
|
|
235
|
+
an empty tick that still has pending work (armed starts or a True slot)
|
|
236
|
+
is FAILED instead. The terminal states (ABORTED/CANCELLED/FAILED) stop
|
|
237
|
+
further ticking."""
|
|
236
238
|
|
|
237
|
-
IDLE = "idle" # quiescent
|
|
239
|
+
IDLE = "idle" # quiescent, nothing pending (done, or never started)
|
|
238
240
|
RUNNING = "running" # a tick is in progress (transient, not persisted)
|
|
239
241
|
ABORTED = "aborted" # an infrastructure Failure occurred; halted
|
|
240
242
|
CANCELLED = "cancelled" # cancel() was called
|
|
241
|
-
FAILED = "failed" #
|
|
243
|
+
FAILED = "failed" # starved: work pending but nothing fireable
|
|
242
244
|
|
|
243
245
|
|
|
244
246
|
# Hook type aliases.
|
|
@@ -634,7 +636,11 @@ class Runner(_BaseRunner):
|
|
|
634
636
|
if aborted:
|
|
635
637
|
self.status = RunStatus.ABORTED
|
|
636
638
|
elif not firings:
|
|
637
|
-
|
|
639
|
+
# Empty tick is a fixpoint (sync barrier semantics): pending work
|
|
640
|
+
# with nothing fireable can never fire -> starved terminal.
|
|
641
|
+
self.status = (
|
|
642
|
+
RunStatus.FAILED if self._has_pending() else RunStatus.IDLE
|
|
643
|
+
)
|
|
638
644
|
else:
|
|
639
645
|
self.status = RunStatus.RUNNING
|
|
640
646
|
self._run_tick_end_hooks(self.tick_count - 1, firings)
|
|
@@ -325,7 +325,7 @@ class _ReadOnlyStateView:
|
|
|
325
325
|
|
|
326
326
|
class DictView(NodeView):
|
|
327
327
|
"""Deprecated legacy constructor shim: ``DictView(inputs, state, node)``
|
|
328
|
-
keeps
|
|
328
|
+
keeps legacy construction sites (tests, pre-bind engine hosts) working
|
|
329
329
|
on top of NodeView. Prefer NodeView / value mode."""
|
|
330
330
|
|
|
331
331
|
def __init__(self, inputs: dict[str, Resolved] | None, state: Any = None,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tickflow-py
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: A small Petri-style workflow control framework
|
|
5
5
|
Author: MountLynx
|
|
6
6
|
License: MIT
|
|
@@ -325,7 +325,8 @@ def call_llm(v):
|
|
|
325
325
|
|
|
326
326
|
- **`type="llm"`** (default): a logical/recoverable failure. The node's
|
|
327
327
|
out-edges write `False`, so downstream AND-joins don't fire (= "upstream
|
|
328
|
-
failed, skip downstream"). The run
|
|
328
|
+
failed, skip downstream"). The run keeps ticking — unless the skip
|
|
329
|
+
strands pending work, in which case it ends `FAILED` (see below).
|
|
329
330
|
- **`type="infrastructure"`**: an unrecoverable failure. Out-edges write
|
|
330
331
|
`False` **and** the runner enters `ABORTED`, halting all further ticks.
|
|
331
332
|
|
|
@@ -335,7 +336,9 @@ A `Failure` is still recorded in `RunState` and the audit log with
|
|
|
335
336
|
> **Important**: a failed node writes `False` to **all** out-edges —
|
|
336
337
|
> guarded edges are not evaluated. To implement controllable routing
|
|
337
338
|
> (e.g. retry on failure), have the body return a result dict and let the
|
|
338
|
-
> guard inspect the output value, rather than returning `Failure`.
|
|
339
|
+
> guard inspect the output value, rather than returning `Failure`. If the
|
|
340
|
+
> skip strands pending work (an AND-join whose other input already
|
|
341
|
+
> arrived), the run ends `FAILED` (starved) instead of `IDLE`.
|
|
339
342
|
|
|
340
343
|
### RunStatus
|
|
341
344
|
|
|
@@ -343,11 +346,11 @@ A `Failure` is still recorded in `RunState` and the audit log with
|
|
|
343
346
|
|
|
344
347
|
| Status | Meaning |
|
|
345
348
|
|--------|---------|
|
|
346
|
-
| `IDLE` | quiescent
|
|
349
|
+
| `IDLE` | quiescent with nothing pending (all work done, or never started) |
|
|
347
350
|
| `RUNNING` | a tick fired (transient; becomes IDLE/terminal next) |
|
|
348
351
|
| `ABORTED` | an infrastructure `Failure` occurred; halted |
|
|
349
352
|
| `CANCELLED` | `cancel()` was called; halted |
|
|
350
|
-
| `FAILED` | (
|
|
353
|
+
| `FAILED` | starved: work is pending (a True slot / armed start) but nothing is fireable; halted |
|
|
351
354
|
|
|
352
355
|
```python
|
|
353
356
|
rn.cancel("user requested") # -> CANCELLED; ticks become no-ops
|
|
@@ -595,7 +598,7 @@ tickflow/
|
|
|
595
598
|
views.py DictView, Resolved, Missing
|
|
596
599
|
persistence.py Backend protocol, JsonBackend, SqliteBackend, NullBackend
|
|
597
600
|
cli.py python -m tickflow ...
|
|
598
|
-
tests/
|
|
601
|
+
tests/ 25 files, 291 tests
|
|
599
602
|
examples/ 8 examples (6 graph + 2 Python scripts)
|
|
600
603
|
```
|
|
601
604
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|