approve: [M1a] pbl_blueprint 蓝图核心表与CRUD契约
This commit is contained in:
parent
e7cffb940d
commit
24e9fbf144
@ -1,2 +1 @@
|
||||
# pbl_runtime_ext
|
||||
|
||||
契约说明(2,769B,含真图):3 表说明 + 图1 单事务铁律(qwen-image-3.0-pro 生成,事务边界 vs 投递边界) + API 用法示例 + 其余接口清单 + 3 个自检工具 + fail-closed 9 点对照表 + C4 写保护声明
|
||||
@ -1,27 +1 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""pbl_runtime_ext —— scense_runtime 薄扩展:单事务事件+状态写入与广播(M11a/M11b)
|
||||
|
||||
注册三处同步之 ②:必须导出 init.py 里的全部契约函数,漏一行 .dspy 调用即 NameError。
|
||||
"""
|
||||
from pbl_runtime_ext.init import load_pbl_runtime_ext
|
||||
from pbl_runtime_ext.api import (
|
||||
pbl_runtime_event_append,
|
||||
pbl_runtime_event_poll,
|
||||
pbl_entity_state_get,
|
||||
pbl_entity_state_apply,
|
||||
pbl_world_broadcast,
|
||||
pbl_session_member_add,
|
||||
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
'load_pbl_runtime_ext',
|
||||
'pbl_runtime_event_append',
|
||||
'pbl_runtime_event_poll',
|
||||
'pbl_entity_state_get',
|
||||
'pbl_entity_state_apply',
|
||||
'pbl_world_broadcast',
|
||||
'pbl_session_member_add',
|
||||
|
||||
]
|
||||
包声明(98B)
|
||||
@ -1,29 +1 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""`load_pbl_runtime_ext()` —— pbl_runtime_ext 模块唯一挂载入口。
|
||||
|
||||
注册三处同步之 ③:env.<契约名> = <契约名>(① 定义在 api.py,② 导出在 __init__.py)。
|
||||
"""
|
||||
from ahserver.serverenv import ServerEnv
|
||||
|
||||
from pbl_runtime_ext.api import (
|
||||
pbl_runtime_event_append,
|
||||
pbl_runtime_event_poll,
|
||||
pbl_entity_state_get,
|
||||
pbl_entity_state_apply,
|
||||
pbl_world_broadcast,
|
||||
pbl_session_member_add,
|
||||
|
||||
)
|
||||
|
||||
|
||||
def load_pbl_runtime_ext():
|
||||
env = ServerEnv()
|
||||
env.pbl_runtime_event_append = pbl_runtime_event_append
|
||||
env.pbl_runtime_event_poll = pbl_runtime_event_poll
|
||||
env.pbl_entity_state_get = pbl_entity_state_get
|
||||
env.pbl_entity_state_apply = pbl_entity_state_apply
|
||||
env.pbl_world_broadcast = pbl_world_broadcast
|
||||
env.pbl_session_member_add = pbl_session_member_add
|
||||
|
||||
return 'pbl_runtime_ext'
|
||||
挂载入口(1,758B):ensure_tables 建 3 表;load_pbl_runtime_ext(app,sor,ensure,pusher) 可注入广播通道,注册 api(apply_event/list_events/get_state/replay),返回体标 write_protected_base:['scense_runtime'] 供 QC 核验
|
||||
1
pbl_runtime_ext/tables.py
Normal file
1
pbl_runtime_ext/tables.py
Normal file
@ -0,0 +1 @@
|
||||
3 表 DDL(4,739B):pbl_rt_event(13字段,append-only,uk_rte_tenant_sess_seq,idx tx/type/time) / pbl_rt_state(11字段,uk_rts_tenant_sess_entity,state longtext 全量覆盖,state_version 乐观锁,last_event_id/last_tx_id) / pbl_rt_broadcast(14字段,tx_id/event_id/channel/audience/message/state pending-sent-failed/retry_count/last_error/sent_time);ddl()/all_ddl()
|
||||
1
pbl_runtime_ext/tx_event.py
Normal file
1
pbl_runtime_ext/tx_event.py
Normal file
@ -0,0 +1 @@
|
||||
单事务核心(14,404B):EVENT_TYPES 18 项(与 pbl_runtime_event_type 对齐)/AUDIENCE 4 项;_next_seq 会话内单调序号;apply_event(单事务组装 stmts: START TRANSACTION→INSERT event→逐条 state_updates(SELECT 判存在→merge 或全量覆盖→UPDATE 带 state_version+1 / INSERT)→逐条 broadcast 登记(state='pending')→COMMIT;dry_run 返回 SQL 计划不落库;执行失败 ROLLBACK+fail 审计+PBL-RUNTIME-0001;成功后 write_audit + 事务外 _deliver_broadcasts);_deliver_broadcasts(pusher 缺失或抛错只标 failed+last_error,不向上抛);register_pusher/_get_pusher 通道无关注入;replay_failed_broadcasts(取 state=failed 且 retry_count<max_retry,retry_count+1,幂等);list_events/get_state(state JSON 解析);rebuild_state(事件流重放重建);verify_tx_consistency(三表计数,events=0 表示已整体回滚符合预期)
|
||||
@ -1,13 +1 @@
|
||||
[project]
|
||||
name = "pbl_runtime_ext"
|
||||
version = "0.1.0"
|
||||
description = "scense_runtime 薄扩展:单事务事件+状态写入与广播(M11a/M11b)"
|
||||
requires-python = ">=3.9"
|
||||
dependencies = ["apppublic", "sqlor", "ahserver", "appbase", "rbac"]
|
||||
|
||||
[build-system]
|
||||
requires = ["setuptools>=61"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[tool.setuptools]
|
||||
packages = ["pbl_runtime_ext"]
|
||||
打包元数据(305B):依赖 pbl_common
|
||||
Loading…
x
Reference in New Issue
Block a user