octopus-live-engine 1.0.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.
Files changed (38) hide show
  1. octopus_live_engine-1.0.0/.gitignore +62 -0
  2. octopus_live_engine-1.0.0/LICENSE +21 -0
  3. octopus_live_engine-1.0.0/PKG-INFO +80 -0
  4. octopus_live_engine-1.0.0/README.md +46 -0
  5. octopus_live_engine-1.0.0/pyproject.toml +51 -0
  6. octopus_live_engine-1.0.0/run_multilang_tests.py +76 -0
  7. octopus_live_engine-1.0.0/src/octopus_live/__init__.py +87 -0
  8. octopus_live_engine-1.0.0/src/octopus_live/adapters/inbound/rest_router.py +648 -0
  9. octopus_live_engine-1.0.0/src/octopus_live/adapters/inbound/visualizer_html.py +228 -0
  10. octopus_live_engine-1.0.0/src/octopus_live/adapters/inbound/workflow_visualizer.py +6038 -0
  11. octopus_live_engine-1.0.0/src/octopus_live/adapters/outbound/callable_executor.py +58 -0
  12. octopus_live_engine-1.0.0/src/octopus_live/adapters/outbound/duckdb_store.py +209 -0
  13. octopus_live_engine-1.0.0/src/octopus_live/adapters/outbound/in_memory_store.py +66 -0
  14. octopus_live_engine-1.0.0/src/octopus_live/adapters/outbound/redis_store.py +220 -0
  15. octopus_live_engine-1.0.0/src/octopus_live/adapters/outbound/relational_store.py +820 -0
  16. octopus_live_engine-1.0.0/src/octopus_live/adapters/outbound/sqlite_store.py +280 -0
  17. octopus_live_engine-1.0.0/src/octopus_live/adapters/outbound/store_factory.py +78 -0
  18. octopus_live_engine-1.0.0/src/octopus_live/adapters/outbound/temporal_replicator.py +354 -0
  19. octopus_live_engine-1.0.0/src/octopus_live/adapters/outbound/yaml_repository.py +431 -0
  20. octopus_live_engine-1.0.0/src/octopus_live/core_backend.py +408 -0
  21. octopus_live_engine-1.0.0/src/octopus_live/domain/models/models.py +267 -0
  22. octopus_live_engine-1.0.0/src/octopus_live/domain/ports/inbound.py +57 -0
  23. octopus_live_engine-1.0.0/src/octopus_live/domain/ports/outbound.py +52 -0
  24. octopus_live_engine-1.0.0/src/octopus_live/domain/services/condition_evaluator.py +576 -0
  25. octopus_live_engine-1.0.0/src/octopus_live/domain/services/idempotency_manager.py +23 -0
  26. octopus_live_engine-1.0.0/src/octopus_live/domain/services/masking_service.py +58 -0
  27. octopus_live_engine-1.0.0/src/octopus_live/domain/services/middleware.py +1646 -0
  28. octopus_live_engine-1.0.0/src/octopus_live/domain/services/pipeline_manager.py +687 -0
  29. octopus_live_engine-1.0.0/src/octopus_live/domain/services/replication_manager.py +53 -0
  30. octopus_live_engine-1.0.0/src/octopus_live/domain/services/saga_manager.py +34 -0
  31. octopus_live_engine-1.0.0/src/octopus_live/engine.py +955 -0
  32. octopus_live_engine-1.0.0/tests/test_condition_evaluator.py +72 -0
  33. octopus_live_engine-1.0.0/tests/test_core_backend.py +615 -0
  34. octopus_live_engine-1.0.0/tests/test_live_engine.py +688 -0
  35. octopus_live_engine-1.0.0/tests/test_middleware.py +774 -0
  36. octopus_live_engine-1.0.0/tests/trigger_test_failure.py +79 -0
  37. octopus_live_engine-1.0.0/tests/visualizer_failure_verification.robot +45 -0
  38. octopus_live_engine-1.0.0/uv.lock +450 -0
@@ -0,0 +1,62 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ .pytest_cache/
6
+ *.egg-info/
7
+ dist/
8
+ build/
9
+
10
+ # Go
11
+ vendor/
12
+ *.exe
13
+ *.test
14
+ *.out
15
+
16
+ # .NET
17
+ bin/
18
+ obj/
19
+ *.user
20
+ *.suo
21
+
22
+ # Java
23
+ target/
24
+ *.class
25
+ .mvn/
26
+ *.log
27
+
28
+ # OS
29
+ .DS_Store
30
+ Thumbs.db
31
+
32
+ # Build output of the Go examples (rebuild with go build)
33
+ /examples/go/auth_portal_api/auth_portal_api
34
+ /examples/go/auth_portal_api/auth_portal_server
35
+ /examples/go/auth_portal_api/main
36
+ /examples/go/auth_portal_api/server
37
+ /examples/go/order_fulfillment_api/server
38
+ /examples/go/durable_temporal_saga_api/durable_saga_server
39
+ /examples/go/durable_temporal_saga_api/durable_temporal_saga_api
40
+ /examples/go/hybrid_payment_api/hybrid_payment_api
41
+ /examples/go/order_fulfillment_api/order_fulfillment_api
42
+ /examples/go/todo_api/todo_api
43
+
44
+ # Build output of the Go conformance runner
45
+ /core/conformance/runners/go/octopus-conformance-go
46
+
47
+ # Build output of the Rust examples (rebuild with cargo build)
48
+ /examples/rust/*/server
49
+
50
+ # Runtime data and robot output of the Rust and saga examples
51
+ /examples/rust/*/data/
52
+ /examples/rust/*/results/
53
+ /examples/go/durable_temporal_saga_api/robot_reports/
54
+
55
+ # Runtime data of example runs
56
+ *.sqlite
57
+ *.sqlite-shm
58
+ *.sqlite-wal
59
+
60
+ # macOS
61
+ /Library/
62
+ .DS_Store
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Katamba Martin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,80 @@
1
+ Metadata-Version: 2.5
2
+ Name: octopus-live-engine
3
+ Version: 1.0.0
4
+ Summary: OCTOPUS Live Engine - Zero-Dependency In-Memory Synchronous Workflow Runtime & Visualizer
5
+ Project-URL: Homepage, https://github.com/martinkatamba/octopus_live_engine
6
+ Project-URL: Source, https://github.com/martinkatamba/octopus_live_engine
7
+ Project-URL: Issues, https://github.com/martinkatamba/octopus_live_engine/issues
8
+ Author: Katamba Martin
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: fastapi,orchestration,saga,visualizer,workflow
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Framework :: FastAPI
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
21
+ Requires-Python: >=3.11
22
+ Requires-Dist: fastapi>=0.110.0
23
+ Requires-Dist: pydantic>=2.6.0
24
+ Requires-Dist: pyyaml>=6.0
25
+ Requires-Dist: sse-starlette>=2.0.0
26
+ Requires-Dist: uvicorn>=0.28.0
27
+ Provides-Extra: core
28
+ Requires-Dist: octopus-core==0.1.0; extra == 'core'
29
+ Provides-Extra: dev
30
+ Requires-Dist: httpx>=0.27.0; extra == 'dev'
31
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
32
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
33
+ Description-Content-Type: text/markdown
34
+
35
+ # OCTOPUS Live Engine (Python)
36
+
37
+ Runs OCTOPUS YAML workflow blueprints inside your process, behind FastAPI: no Temporal server, worker or queue. It suits request-reply APIs that answer from memory, such as fraud scoring, tax and pricing, or login flows.
38
+
39
+ - Steps with conditions, loops, jumps, retries, timeouts and saga compensation.
40
+ - Declarative middlewares: API key, HS256 JWT, IP allow-list, rate limit, payload validation, caching and audit.
41
+ - An interactive visualizer at `/visualizer`, and live events per job at `/stream/<job_id>`.
42
+ - Jobs in memory, or in Redis, Postgres, MySQL, SQL Server or SQLite.
43
+
44
+ ## Install
45
+
46
+ ```sh
47
+ pip install "octopus-live-engine[core]"
48
+ ```
49
+
50
+ The `core` extra installs `octopus-core`, the engine's native core, which the SDK uses whenever it is installed. Without it the SDK runs its own Python engine. Python 3.11 or later.
51
+
52
+ ## Use
53
+
54
+ ```python
55
+ from octopus_live import OctopusLiveEngine
56
+
57
+ engine = OctopusLiveEngine()
58
+
59
+ @engine.activity("CalculateTax")
60
+ def calculate_tax(payload):
61
+ amount = payload.get("amount", 0.0)
62
+ return {"tax": amount * 0.15, "total": amount * 1.15}
63
+
64
+ engine.load_blueprints_from_directory("./config")
65
+
66
+ # Run a workflow in the request...
67
+ result = await engine.execute_sync("order_tax_pipeline", {"amount": 200.0})
68
+ print(result.data)
69
+
70
+ # ...or serve every workflow over HTTP, with the visualizer.
71
+ engine.start_server(port=8001)
72
+ ```
73
+
74
+ Every workflow is then served under `/api/v1.0.0/<workflow>`: `POST /execute` runs it in the request, and `POST /initiate` returns a job ID and runs it in the background.
75
+
76
+ The blueprint format, middlewares and visualizer are documented in the [OCTOPUS Live Engine repository](https://github.com/martinkatamba/octopus_live_engine).
77
+
78
+ ## Licence
79
+
80
+ MIT; see `LICENSE`.
@@ -0,0 +1,46 @@
1
+ # OCTOPUS Live Engine (Python)
2
+
3
+ Runs OCTOPUS YAML workflow blueprints inside your process, behind FastAPI: no Temporal server, worker or queue. It suits request-reply APIs that answer from memory, such as fraud scoring, tax and pricing, or login flows.
4
+
5
+ - Steps with conditions, loops, jumps, retries, timeouts and saga compensation.
6
+ - Declarative middlewares: API key, HS256 JWT, IP allow-list, rate limit, payload validation, caching and audit.
7
+ - An interactive visualizer at `/visualizer`, and live events per job at `/stream/<job_id>`.
8
+ - Jobs in memory, or in Redis, Postgres, MySQL, SQL Server or SQLite.
9
+
10
+ ## Install
11
+
12
+ ```sh
13
+ pip install "octopus-live-engine[core]"
14
+ ```
15
+
16
+ The `core` extra installs `octopus-core`, the engine's native core, which the SDK uses whenever it is installed. Without it the SDK runs its own Python engine. Python 3.11 or later.
17
+
18
+ ## Use
19
+
20
+ ```python
21
+ from octopus_live import OctopusLiveEngine
22
+
23
+ engine = OctopusLiveEngine()
24
+
25
+ @engine.activity("CalculateTax")
26
+ def calculate_tax(payload):
27
+ amount = payload.get("amount", 0.0)
28
+ return {"tax": amount * 0.15, "total": amount * 1.15}
29
+
30
+ engine.load_blueprints_from_directory("./config")
31
+
32
+ # Run a workflow in the request...
33
+ result = await engine.execute_sync("order_tax_pipeline", {"amount": 200.0})
34
+ print(result.data)
35
+
36
+ # ...or serve every workflow over HTTP, with the visualizer.
37
+ engine.start_server(port=8001)
38
+ ```
39
+
40
+ Every workflow is then served under `/api/v1.0.0/<workflow>`: `POST /execute` runs it in the request, and `POST /initiate` returns a job ID and runs it in the background.
41
+
42
+ The blueprint format, middlewares and visualizer are documented in the [OCTOPUS Live Engine repository](https://github.com/martinkatamba/octopus_live_engine).
43
+
44
+ ## Licence
45
+
46
+ MIT; see `LICENSE`.
@@ -0,0 +1,51 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.27"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "octopus-live-engine"
7
+ version = "1.0.0"
8
+ description = "OCTOPUS Live Engine - Zero-Dependency In-Memory Synchronous Workflow Runtime & Visualizer"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "Katamba Martin" }]
14
+ keywords = ["workflow", "orchestration", "saga", "fastapi", "visualizer"]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Framework :: FastAPI",
18
+ "Intended Audience :: Developers",
19
+ "Operating System :: OS Independent",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Topic :: Software Development :: Libraries :: Application Frameworks",
25
+ ]
26
+ dependencies = [
27
+ "fastapi>=0.110.0",
28
+ "uvicorn>=0.28.0",
29
+ "pydantic>=2.6.0",
30
+ "pyyaml>=6.0",
31
+ "sse-starlette>=2.0.0"
32
+ ]
33
+
34
+ [project.urls]
35
+ Homepage = "https://github.com/martinkatamba/octopus_live_engine"
36
+ Source = "https://github.com/martinkatamba/octopus_live_engine"
37
+ Issues = "https://github.com/martinkatamba/octopus_live_engine/issues"
38
+
39
+ [project.optional-dependencies]
40
+ # The Rust engine core: OctopusLiveEngine(engine="core") or OCTOPUS_LIVE_ENGINE=core.
41
+ core = [
42
+ "octopus-core==0.1.0"
43
+ ]
44
+ dev = [
45
+ "pytest>=8.0.0",
46
+ "httpx>=0.27.0",
47
+ "pytest-asyncio>=0.23.0"
48
+ ]
49
+
50
+ [tool.hatch.build.targets.wheel]
51
+ packages = ["src/octopus_live"]
@@ -0,0 +1,76 @@
1
+ import asyncio
2
+ import os
3
+ import sys
4
+ import time
5
+ import json
6
+ import httpx
7
+
8
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "src")))
9
+
10
+ import importlib.util
11
+ spec = importlib.util.spec_from_file_location("auth_portal_server", os.path.join(os.path.dirname(__file__), "../examples/python/auth_portal_api/server.py"))
12
+ auth_portal_server = importlib.util.module_from_spec(spec)
13
+ spec.loader.exec_module(auth_portal_server)
14
+ app = auth_portal_server.app
15
+ engine = auth_portal_server.engine
16
+
17
+
18
+ async def test_python():
19
+ print("šŸ ==================== [PYTHON ENGINE TESTS] ====================")
20
+ transport = httpx.ASGITransport(app=app)
21
+ async with httpx.AsyncClient(transport=transport, base_url="http://test") as client:
22
+ # 1. Login Success
23
+ job_login_ok = f"python-login-success-{int(time.time()*1000)}"
24
+ print(f"\n[Python] 1. POST /auth/login (Job ID: {job_login_ok})")
25
+ res1 = await client.post(
26
+ "/api/v1.0.0/customer_auth_portal/auth/login",
27
+ json={"username": "sarah_vip", "password": "password123"},
28
+ headers={"X-Job-ID": job_login_ok}
29
+ )
30
+ assert res1.status_code == 200, f"Failed: {res1.text}"
31
+ data1 = res1.json()
32
+ token = data1["access_token"]
33
+ print(f" Status: {res1.status_code} OK | User: {data1.get('user_id')} | Tier: {data1.get('customer_tier')}")
34
+
35
+ # 2. VIP Checkout (Protected + Claims + 20% Discount Branch)
36
+ job_checkout = f"python-checkout-vip-{int(time.time()*1000)}"
37
+ print(f"\n[Python] 2. POST /cart/checkout (Job ID: {job_checkout})")
38
+ res2 = await client.post(
39
+ "/api/v1.0.0/customer_auth_portal/cart/checkout",
40
+ json={
41
+ "cart_id": "cart_py_001",
42
+ "items": [{"sku": "SONY-WH1000XM5", "description": "VIP Headphones", "quantity": 2, "unit_price": 400.0}]
43
+ },
44
+ headers={"Authorization": f"Bearer {token}", "X-Job-ID": job_checkout}
45
+ )
46
+ assert res2.status_code == 200, f"Failed: {res2.text}"
47
+ data2 = res2.json()
48
+ print(f" Status: {res2.status_code} OK | Subtotal: ${data2['subtotal']} | Final: ${data2['final_total']} | Tier: {data2['pricing_tier']}")
49
+
50
+ # 3. Login Failure (Wrong password -> LogSecurityAuditViolation)
51
+ job_login_fail = f"python-login-fail-{int(time.time()*1000)}"
52
+ print(f"\n[Python] 3. POST /auth/login (Login Failure, Job ID: {job_login_fail})")
53
+ res3 = await client.post(
54
+ "/api/v1.0.0/customer_auth_portal/auth/login",
55
+ json={"username": "sarah_vip", "password": "WRONG_PASSWORD_XYZ"},
56
+ headers={"X-Job-ID": job_login_fail}
57
+ )
58
+ assert res3.status_code == 401, f"Expected 401, got {res3.status_code}"
59
+ print(f" Status: {res3.status_code} Unauthorized | Detail: {res3.json().get('detail')}")
60
+
61
+ # Flush background replication and allow Temporal worker to process queue
62
+ if engine.replication_manager:
63
+ await engine.replication_manager.flush()
64
+ await asyncio.sleep(2.0)
65
+
66
+ # Check recorded traces for the failed login
67
+ st = await engine.get_execution_state(job_login_fail)
68
+ print(f"\n[Python] Execution Traces for {job_login_fail}:")
69
+ for t in (st.traces if st else []):
70
+ print(f" • Step: {t.step_id} | Activity: {t.activity_name} | Status: {t.status} | Output: {t.output_payload}")
71
+
72
+ print("\nāœ… [PYTHON ENGINE] All tests PASSED successfully!\n")
73
+
74
+
75
+ if __name__ == "__main__":
76
+ asyncio.run(test_python())
@@ -0,0 +1,87 @@
1
+ from .adapters.outbound.duckdb_store import DuckDbStateStore
2
+ from .adapters.outbound.in_memory_store import InMemoryStateStore
3
+ from .adapters.outbound.redis_store import RedisStateStore
4
+ from .adapters.outbound.sqlite_store import SqliteStateStore
5
+ from .adapters.outbound.store_factory import StoreFactory
6
+ from .adapters.outbound.temporal_replicator import TemporalReplicator
7
+ from .domain.models.models import (
8
+ BaseWorkflowPayload,
9
+ BaseWorkflowResponse,
10
+ ExecutionState,
11
+ ExecutionStatus,
12
+ MiddlewareConfig,
13
+ MiddlewareExceptionConfig,
14
+ StepCondition,
15
+ StepExecutionTrace,
16
+ WorkflowBlueprint,
17
+ WorkflowStep,
18
+ )
19
+ from .domain.ports.inbound import ILiveWorkflowUseCase, IVisualizerUseCase
20
+ from .domain.ports.outbound import IActivityExecutor, IBlueprintRepository, IStateStore
21
+ from .domain.services.middleware import (
22
+ ApiKeyAuthMiddleware,
23
+ BearerAuthAndClaimsMiddleware,
24
+ CorrelationIdMiddleware,
25
+ InvalidApiKeyException,
26
+ InvalidClaimException,
27
+ IpAccessDenied,
28
+ IpWhitelistMiddleware,
29
+ LiveMiddleware,
30
+ OctopusMiddlewareException,
31
+ RateLimitExceeded,
32
+ RateLimitMiddleware,
33
+ RedisCacheMiddleware,
34
+ ResponseAuditMiddleware,
35
+ RoleAuthorizationMiddleware,
36
+ UserNotAuthenticated,
37
+ UserNotAuthorized,
38
+ )
39
+ from .domain.services.pipeline_manager import PipelineManager
40
+ from .domain.services.replication_manager import DurableReplicationManager
41
+ from .engine import OctopusLiveEngine
42
+
43
+ LiveEngine = OctopusLiveEngine
44
+
45
+ __all__ = [
46
+ "OctopusLiveEngine",
47
+ "LiveEngine",
48
+ "PipelineManager",
49
+ "DurableReplicationManager",
50
+ "StoreFactory",
51
+ "InMemoryStateStore",
52
+ "SqliteStateStore",
53
+ "DuckDbStateStore",
54
+ "RedisStateStore",
55
+ "TemporalReplicator",
56
+ "WorkflowBlueprint",
57
+ "WorkflowStep",
58
+ "StepCondition",
59
+ "MiddlewareConfig",
60
+ "MiddlewareExceptionConfig",
61
+ "LiveMiddleware",
62
+ "BearerAuthAndClaimsMiddleware",
63
+ "ApiKeyAuthMiddleware",
64
+ "RoleAuthorizationMiddleware",
65
+ "CorrelationIdMiddleware",
66
+ "RateLimitMiddleware",
67
+ "IpWhitelistMiddleware",
68
+ "RedisCacheMiddleware",
69
+ "ResponseAuditMiddleware",
70
+ "OctopusMiddlewareException",
71
+ "UserNotAuthenticated",
72
+ "UserNotAuthorized",
73
+ "InvalidApiKeyException",
74
+ "RateLimitExceeded",
75
+ "InvalidClaimException",
76
+ "IpAccessDenied",
77
+ "ExecutionState",
78
+ "ExecutionStatus",
79
+ "StepExecutionTrace",
80
+ "BaseWorkflowPayload",
81
+ "BaseWorkflowResponse",
82
+ "ILiveWorkflowUseCase",
83
+ "IVisualizerUseCase",
84
+ "IActivityExecutor",
85
+ "IBlueprintRepository",
86
+ "IStateStore",
87
+ ]