loom-core 0.1.6__tar.gz → 0.1.8__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.
- {loom_core-0.1.6 → loom_core-0.1.8}/PKG-INFO +1 -1
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/core/context.py +6 -5
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/core/logger.py +2 -1
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/core/state.py +3 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom_core.egg-info/PKG-INFO +1 -1
- {loom_core-0.1.6 → loom_core-0.1.8}/pyproject.toml +1 -1
- {loom_core-0.1.6 → loom_core-0.1.8}/LICENSE +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/MANIFEST.in +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/QUICKSTART.md +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/README.md +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/__init__.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/cli/__init__.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/cli/cli.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/common/activity.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/common/config.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/common/errors.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/common/workflow.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/core/__init__.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/core/compiled.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/core/engine.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/core/handle.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/core/runner.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/core/worker.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/core/workflow.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/database/__init__.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/database/db.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/decorators/__init__.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/decorators/activity.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/decorators/workflow.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/lib/progress.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/lib/utils.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/migrations/down/001_setup_pragma.sql +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/migrations/down/002_create_workflows.sql +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/migrations/down/003.create_events.sql +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/migrations/down/004.create_tasks.sql +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/migrations/down/005.create_indexes.sql +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/migrations/down/006_auto_update_triggers.sql +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/migrations/down/007_create_logs.sql +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/migrations/up/001_setup_pragma.sql +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/migrations/up/002_create_workflows.sql +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/migrations/up/003_create_events.sql +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/migrations/up/004_create_tasks.sql +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/migrations/up/005_create_indexes.sql +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/migrations/up/006_auto_update_triggers.sql +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/migrations/up/007_create_logs.sql +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/schemas/__init__.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/schemas/activity.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/schemas/database.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/schemas/events.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/schemas/tasks.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom/schemas/workflow.py +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom_core.egg-info/SOURCES.txt +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom_core.egg-info/dependency_links.txt +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom_core.egg-info/entry_points.txt +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom_core.egg-info/requires.txt +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/loom_core.egg-info/top_level.txt +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/setup.cfg +0 -0
- {loom_core-0.1.6 → loom_core-0.1.8}/setup.py +0 -0
|
@@ -37,6 +37,7 @@ class WorkflowContext(Generic[InputT, StateT]):
|
|
|
37
37
|
state: StateProxy[InputT, StateT]
|
|
38
38
|
cursor: int = 0
|
|
39
39
|
logger: WorkflowLogger
|
|
40
|
+
_original_history_length: int # Track original history size for replay detection
|
|
40
41
|
|
|
41
42
|
def __init__(
|
|
42
43
|
self, id: str, input: InputT, history: List[Event], state: StateT
|
|
@@ -52,6 +53,7 @@ class WorkflowContext(Generic[InputT, StateT]):
|
|
|
52
53
|
self.id = id
|
|
53
54
|
self.input = input
|
|
54
55
|
self.history = history
|
|
56
|
+
self._original_history_length = len(history) # Remember original size
|
|
55
57
|
self.state = StateProxy(self, state)
|
|
56
58
|
self.logger = WorkflowLogger(self)
|
|
57
59
|
|
|
@@ -108,14 +110,13 @@ class WorkflowContext(Generic[InputT, StateT]):
|
|
|
108
110
|
|
|
109
111
|
@property
|
|
110
112
|
def is_replaying(self) -> bool:
|
|
111
|
-
"""Check if the workflow is currently replaying events.
|
|
113
|
+
"""Check if the workflow is currently replaying old events.
|
|
112
114
|
|
|
113
115
|
Returns:
|
|
114
|
-
True if
|
|
116
|
+
True if replaying historical events, False if executing new logic
|
|
115
117
|
"""
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
@property
|
|
118
|
+
# We're replaying if we haven't consumed all the original events yet
|
|
119
|
+
return self.cursor < self._original_history_length
|
|
119
120
|
def is_at_end_of_history(self) -> bool:
|
|
120
121
|
"""Check if we've consumed all events in history.
|
|
121
122
|
|
|
@@ -40,10 +40,11 @@ class WorkflowLogger:
|
|
|
40
40
|
self._log("DEBUG", msg)
|
|
41
41
|
|
|
42
42
|
def _log(self, level: str, msg: str):
|
|
43
|
+
# Only suppress logging if we're actually replaying historical events
|
|
43
44
|
if self._ctx.is_replaying:
|
|
44
45
|
return
|
|
45
46
|
|
|
46
|
-
self._std_logger.info(f"{msg}")
|
|
47
|
+
self._std_logger.info(f"[{self._ctx.id[:8]}] {msg}")
|
|
47
48
|
asyncio.create_task(self._write_log_to_db(level, msg))
|
|
48
49
|
|
|
49
50
|
async def _write_log_to_db(self, level: str, msg: str):
|
|
@@ -32,6 +32,7 @@ class StateProxy(Generic[InputT, StateT]):
|
|
|
32
32
|
event = self._ctx._peek()
|
|
33
33
|
if event and event["type"] == "STATE_SET" and event["payload"]["key"] == name:
|
|
34
34
|
self._ctx._consume()
|
|
35
|
+
self._data[name] = value
|
|
35
36
|
return
|
|
36
37
|
|
|
37
38
|
event = ("STATE_SET", {"key": name, "value": value})
|
|
@@ -56,6 +57,8 @@ class StateProxy(Generic[InputT, StateT]):
|
|
|
56
57
|
payload = event["payload"]
|
|
57
58
|
if set(payload["values"].keys()) == set(updaters.keys()):
|
|
58
59
|
self._ctx._consume()
|
|
60
|
+
for key, value in payload["values"].items():
|
|
61
|
+
self._data[key] = value
|
|
59
62
|
return
|
|
60
63
|
new_values = {}
|
|
61
64
|
|
|
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
|
|
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
|