M11b-2a: resolve root-package spec compliance (drop repo-root __init__.py forwarding package)
QC #3: modules/world_sync/__init__.py made the module REPO ROOT a Python package, violating module-development-spec (mymodule/ = repo root, mymodule/mymodule/ = package). Host wiring verified to resolve to the INNER package, so the root forwarding table is dead weight: - apps/scense/app/scense.py:50 from world_sync.init import load_world_sync - apps/yuanjing/app/yuanjing.py:66 __import__(f'{module}.init', ...) Both parse world_sync/init.py with sys.path=<repo root>; neither uses the root package. Re-verified after deletion: py_compile OK for all .py; import closure 0-broken from both sys.path=modules/ and sys.path=modules/world_sync/ (import world_sync / from world_sync.init import load_world_sync / 4 contract APIs; __all__ len=62 MISSING=[]). pyproject packages.find needs no tightening: with the root package gone, where=['.'] include=['world_sync*'] discovers exactly one package. Unrelated pre-existing WIP scripts/validate_models_json.py (M11b-2b-A) intentionally excluded from this commit via pathspec.
This commit is contained in:
parent
01941aa1bd
commit
9f97d58dba
156
__init__.py
156
__init__.py
@ -1,156 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""world_sync 模块仓库根包(对外统一导出面,纯转发,无第二份实现)。
|
||||
|
||||
三层接线(M11b-2a 收口,响应 QC #2/#3)
|
||||
======================================
|
||||
- ``world_sync.world_sync.init``:**① 实现 + ③ env 注册** ——
|
||||
``load_world_sync(server_env=None, conn_factory=None)`` 与 ``env.xxx = xxx`` 登记;
|
||||
- ``world_sync.world_sync.__init__``:**② 导出** —— ``from .init import load_world_sync, ...``;
|
||||
- 本文件(仓库根包):把内层包的能力原样转发到模块级 API,**不再自带任何 ``load_world_sync``
|
||||
定义**,使「实现 / 导出 / env 注册」三处指向同一真源。
|
||||
|
||||
两种加载路径都可用(取决于 sys.path 落点):
|
||||
``import world_sync; world_sync.load_world_sync()``(sys.path 含 ``modules/``)
|
||||
与 ``from world_sync import load_world_sync``(pip install -e 本仓库,包目录即 ``world_sync/``)。
|
||||
|
||||
铁律:本包不硬编码库名(取库名走 ``ServerEnv().get_module_dbname('world_sync')``),
|
||||
不在导入期建立任何数据库连接(连接工厂缺失时由写入调用点 fail-closed 抛异常)。
|
||||
"""
|
||||
|
||||
from .world_sync import (
|
||||
# 挂载入口(唯一实现位于 world_sync/init.py)
|
||||
load_world_sync,
|
||||
# 模块元信息
|
||||
MODULE_NAME,
|
||||
MODULE_VERSION,
|
||||
MODULE_TABLES,
|
||||
SERVER_ENV_CONN_FACTORY_KEYS,
|
||||
SERVER_ENV_KEYS,
|
||||
# 既有 CRUD
|
||||
list_world_syncs,
|
||||
get_world_sync,
|
||||
create_world_sync,
|
||||
update_world_sync,
|
||||
delete_world_sync,
|
||||
execute_world_sync,
|
||||
# M11b-1 表注册(只读元数据)
|
||||
module_tables,
|
||||
get_table_schema,
|
||||
load_table_model,
|
||||
pbl_runtime_event_schema,
|
||||
pbl_runtime_event_partitions,
|
||||
# M11b-2 写入 / 读取契约
|
||||
write_event_with_state,
|
||||
read_entity_state,
|
||||
configure_runtime_writer,
|
||||
get_runtime_writer,
|
||||
build_runtime_write_plan,
|
||||
runtime_write_percentile,
|
||||
runtime_write_dialect_name,
|
||||
runtime_write_ddl,
|
||||
# 工厂 / 方言 / 常量
|
||||
resolve_conn_factory,
|
||||
build_sqlite_conn_factory,
|
||||
build_mysql_conn_factory,
|
||||
build_conn_factory_from_pools,
|
||||
host_conn_factory,
|
||||
load_db_config,
|
||||
module_conf_dir,
|
||||
detect_dialect,
|
||||
ddl_for,
|
||||
percentile,
|
||||
EVENT_TABLE,
|
||||
STATE_TABLE,
|
||||
DIALECT_MYSQL,
|
||||
DIALECT_SQLITE,
|
||||
DEFAULT_EVENT_TYPE,
|
||||
DEFAULT_SOURCE,
|
||||
EVENT_REQUIRED,
|
||||
STATE_KEY_COLUMNS,
|
||||
POOL_KEYS,
|
||||
ENV_NAME_KEYS,
|
||||
new_event_id,
|
||||
new_event_uid,
|
||||
utc_now_text,
|
||||
# 异常族(fail-closed,含 M11b-2a 语义别名)
|
||||
PblRuntimeError,
|
||||
TxConfigError,
|
||||
ConnFactoryNotConfigured,
|
||||
EventWriteError,
|
||||
StateWriteError,
|
||||
ConcurrentStateConflict,
|
||||
TxAbortError,
|
||||
RuntimeWriteError,
|
||||
InvalidWriteRequest,
|
||||
ConnectionUnavailable,
|
||||
TransactionAborted,
|
||||
# 宿主基础包可用性(自检用)
|
||||
HOST_DEPS_AVAILABLE,
|
||||
HOST_DEPS_ERROR,
|
||||
HostDepsNotAvailable,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"load_world_sync",
|
||||
"MODULE_NAME",
|
||||
"MODULE_VERSION",
|
||||
"MODULE_TABLES",
|
||||
"SERVER_ENV_CONN_FACTORY_KEYS",
|
||||
"SERVER_ENV_KEYS",
|
||||
"list_world_syncs",
|
||||
"get_world_sync",
|
||||
"create_world_sync",
|
||||
"update_world_sync",
|
||||
"delete_world_sync",
|
||||
"execute_world_sync",
|
||||
"module_tables",
|
||||
"get_table_schema",
|
||||
"load_table_model",
|
||||
"pbl_runtime_event_schema",
|
||||
"pbl_runtime_event_partitions",
|
||||
"write_event_with_state",
|
||||
"read_entity_state",
|
||||
"configure_runtime_writer",
|
||||
"get_runtime_writer",
|
||||
"build_runtime_write_plan",
|
||||
"runtime_write_percentile",
|
||||
"runtime_write_dialect_name",
|
||||
"runtime_write_ddl",
|
||||
"resolve_conn_factory",
|
||||
"build_sqlite_conn_factory",
|
||||
"build_mysql_conn_factory",
|
||||
"build_conn_factory_from_pools",
|
||||
"host_conn_factory",
|
||||
"load_db_config",
|
||||
"module_conf_dir",
|
||||
"detect_dialect",
|
||||
"ddl_for",
|
||||
"percentile",
|
||||
"EVENT_TABLE",
|
||||
"STATE_TABLE",
|
||||
"DIALECT_MYSQL",
|
||||
"DIALECT_SQLITE",
|
||||
"DEFAULT_EVENT_TYPE",
|
||||
"DEFAULT_SOURCE",
|
||||
"EVENT_REQUIRED",
|
||||
"STATE_KEY_COLUMNS",
|
||||
"POOL_KEYS",
|
||||
"ENV_NAME_KEYS",
|
||||
"new_event_id",
|
||||
"new_event_uid",
|
||||
"utc_now_text",
|
||||
"PblRuntimeError",
|
||||
"TxConfigError",
|
||||
"ConnFactoryNotConfigured",
|
||||
"EventWriteError",
|
||||
"StateWriteError",
|
||||
"ConcurrentStateConflict",
|
||||
"TxAbortError",
|
||||
"RuntimeWriteError",
|
||||
"InvalidWriteRequest",
|
||||
"ConnectionUnavailable",
|
||||
"TransactionAborted",
|
||||
"HOST_DEPS_AVAILABLE",
|
||||
"HOST_DEPS_ERROR",
|
||||
"HostDepsNotAvailable",
|
||||
]
|
||||
Loading…
x
Reference in New Issue
Block a user