cmvr-visual/backend/app/domain/execution.py
zhanghao 88cf14d794 feat: consolidate story studio and editable automatic production
Restructure backend and frontend modules; add story, library, and editor schema migrations.

Support editable automatic production, manual confirmation modes, account and user lifecycle management, compact container scrolling, consistent forms, and per-task result previews.

Update inference and TTS scheduling, deployment guidance, and regression coverage; remove obsolete standalone pages and temporary acceptance artifacts.
2026-11-14 14:07:26 +08:00

28 lines
819 B
Python

"""执行结果与任务阶段上下文,不引入 HTTP、数据库或适配器。"""
from __future__ import annotations
from contextvars import ContextVar
from dataclasses import dataclass
from pathlib import Path
from typing import Awaitable, Callable
PhaseCallback = Callable[[str, str], Awaitable[None]]
# ContextVar 按 asyncio 任务隔离;共享同一对象让媒体与 HTTP 阶段使用同一准入边界。
current_phase_callback: ContextVar[PhaseCallback | None] = ContextVar(
"current_phase_callback", default=None
)
async def enter_phase(phase_key: str, resource_pool: str) -> None:
callback = current_phase_callback.get()
if callback is not None:
await callback(phase_key, resource_pool)
@dataclass
class CpuResult:
outputs: list[Path]
result: dict
metadata: dict