mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-04 23:17:20 +08:00
refactor: register event delivery contracts
This commit is contained in:
@@ -803,6 +803,7 @@ def collect_runtime_baseline() -> dict[str, Any]:
|
||||
"run_module": collect_run_module_contracts(),
|
||||
"module_method_specs": collect_module_method_specs(),
|
||||
"events": collect_event_contracts(),
|
||||
"event_specs": collect_event_specs(),
|
||||
"sdk_exports": collect_sdk_exports(),
|
||||
"compat_manifest": collect_compat_manifest(),
|
||||
}
|
||||
@@ -824,6 +825,33 @@ def collect_module_method_specs() -> dict[str, Any]:
|
||||
sys.modules.pop(spec.name, None)
|
||||
|
||||
|
||||
def collect_event_specs() -> dict[str, Any]:
|
||||
"""收集全部 enum 事件的稳定 payload、可见性与可靠性登记。"""
|
||||
project_root = str(PROJECT_ROOT)
|
||||
inserted = project_root not in sys.path
|
||||
if inserted:
|
||||
sys.path.insert(0, project_root)
|
||||
try:
|
||||
from app.runtime.event.contracts import EVENT_CONTRACTS
|
||||
finally:
|
||||
if inserted:
|
||||
sys.path.remove(project_root)
|
||||
|
||||
return {
|
||||
contract.event_name: {
|
||||
"payload_contract": contract.payload_contract,
|
||||
"mode": contract.mode,
|
||||
"visibility": contract.visibility.value,
|
||||
"delivery": contract.delivery.value,
|
||||
"error_behavior": contract.error_behavior.value,
|
||||
"ordering": contract.ordering,
|
||||
"sensitive_fields": list(contract.sensitive_fields),
|
||||
"legacy_reason": contract.legacy_reason,
|
||||
}
|
||||
for contract in EVENT_CONTRACTS.values()
|
||||
}
|
||||
|
||||
|
||||
def collect_runtime_diagnostics() -> dict[str, Any]:
|
||||
"""生成带当前源码行号的运行契约诊断视图,不写入语义 fixture。"""
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user