"""§7 B 阶段:Storage 落 PG。

入口:
    from core.storage import get_engine, session_scope
    from core.storage.models import User, Task, Message

ZCBOT_DB_URL 环境变量必填(本地连测试 / staging PG;SaaS 连生产 PG)。
未设置时 get_engine() 抛 RuntimeError 并指引设置。
users 行由 web auth 入口按需 INSERT,storage 层不再 bootstrap 任何固定 user。
"""
from .engine import (
    get_engine,
    session_scope,
)
from .usage import (
    record_chat_usage,
    record_empty_response,
    record_malformed_tool_call,
    record_salvaged_tool_call,
)
from .utils import (
    NoSubtaskError,
    check_no_subtask,
    ensure_local_task_row,
    get_task,
    update_task,
    upsert_task,
)

__all__ = [
    "NoSubtaskError",
    "check_no_subtask",
    "ensure_local_task_row",
    "get_engine",
    "get_task",
    "record_chat_usage",
    "record_empty_response",
    "record_malformed_tool_call",
    "record_salvaged_tool_call",
    "session_scope",
    "update_task",
    "upsert_task",
]
