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:
agent.develop 2026-09-20 18:31:16 +08:00
parent 01941aa1bd
commit 9f97d58dba

View File

@ -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",
]