refactor(core): decouple actors and remove workflow templates (#67)

Removes the deprecated `workflow_template` concept entirely across both backend API routers, internal logic handling within the `supervisory_node` and `consciousness_node`, and front-end components. Enables `consciousness_node` to work autonomously.

Also refactors core package structure to enforce the "one python package, one Ray Actor" architectural rule. `GlobalWorkflowManager`, `WorkflowRunningEngine`, `PostgresDatabase`, and `WorkerCluster` have been moved to their own top-level decoupled package directories with properly exported `__init__.py` modules. Test suites have been relocated and import paths updated across the system.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: zhaoxi826 <198742034+zhaoxi826@users.noreply.github.com>
This commit is contained in:
2026-05-06 15:05:47 +08:00
committed by GitHub
parent b3ea4cd8d9
commit 209ba45477
97 changed files with 1872 additions and 1498 deletions
@@ -0,0 +1,85 @@
import pytest
from unittest.mock import patch, MagicMock
import sys
import builtins
real_import = builtins.__import__
def mock_import(name, globals=None, locals=None, fromlist=(), level=0):
if name == "ray":
mock_ray = MagicMock()
def mock_remote(*args, **kwargs):
if len(args) == 1 and callable(args[0]):
return args[0]
def decorator(cls):
return cls
return decorator
mock_ray.remote = mock_remote
return mock_ray
return real_import(name, globals, locals, fromlist, level)
builtins.__import__ = mock_import
for mod in list(sys.modules.keys()):
if "pretor.core.postgres_database.postgres" in mod or "ray" in mod:
del sys.modules[mod]
from pretor.core.postgres_database.postgres import PostgresDatabase # noqa: E402
builtins.__import__ = real_import
@patch("pretor.core.postgres_database.postgres.create_async_engine")
@patch("pretor.core.postgres_database.postgres.sessionmaker")
@patch("pretor.core.postgres_database.postgres.AuthDatabase")
@patch("pretor.core.postgres_database.postgres.ProviderDatabase")
@patch("pretor.core.postgres_database.postgres.os.environ.get")
@pytest.mark.asyncio
async def test_postgres_database(
mock_env_get, mock_provider_db, mock_auth_db, mock_sessionmaker, mock_create_engine
):
def env_side_effect(key):
return {
"POSTGRES_USER": "testuser",
"POSTGRES_PASSWORD": "testpassword",
"POSTGRES_HOST": "localhost",
"POSTGRES_PORT": "5432",
"POSTGRES_DB": "testdb",
}.get(key)
mock_env_get.side_effect = env_side_effect
mock_engine = MagicMock()
mock_conn = MagicMock()
from unittest.mock import AsyncMock
mock_conn.run_sync = AsyncMock()
mock_begin_ctx = MagicMock()
mock_begin_ctx.__aenter__ = AsyncMock(return_value=mock_conn)
mock_begin_ctx.__aexit__ = AsyncMock()
mock_engine.begin.return_value = mock_begin_ctx
mock_create_engine.return_value = mock_engine
db = PostgresDatabase()
mock_create_engine.assert_called_once_with(
"postgresql+asyncpg://testuser:testpassword@localhost:5432/testdb", echo=True
)
mock_auth_db.assert_called_once()
mock_provider_db.assert_called_once()
mock_auth_db.return_value.get_user_authority = AsyncMock(return_value="test_auth")
with patch(
"pretor.core.postgres_database.postgres.SQLModel.metadata.create_all"
) as mock_create_all:
await db.init_db()
mock_conn.run_sync.assert_called_once_with(mock_create_all)
assert await db.get_user_authority(user_id="123") == "test_auth"
# noqa: E402