refactor: type storage value contracts

This commit is contained in:
jxxghp
2026-08-24 01:35:42 +08:00
parent e359bbace9
commit bb80c10a0b
3 changed files with 67 additions and 23 deletions
+48 -23
View File
@@ -2476,16 +2476,19 @@
"version": 1
},
"any_files": {
"aggregation": "legacy",
"aggregation": "first_non_empty",
"error_policy": "isolate_provider",
"execution": "sync_or_async",
"family": "storage",
"input_contract": "StorageKeywordArguments",
"input_contract": "StorageAnyFilesRequest",
"plugin_short_circuit": true,
"public_to_plugins": true,
"required_parameters": [],
"result_contract": "StorageProviderResult",
"result_shape": "any",
"required_parameters": [
"extensions",
"fileitem"
],
"result_contract": "bool | None",
"result_shape": "boolean",
"supports_async": true,
"supports_sync": true,
"timeout_policy": "caller_budget",
@@ -3576,15 +3579,18 @@
"version": 1
},
"create_folder": {
"aggregation": "legacy",
"aggregation": "first_non_empty",
"error_policy": "isolate_provider",
"execution": "sync_or_async",
"family": "storage",
"input_contract": "StorageKeywordArguments",
"input_contract": "StorageCreateFolderRequest",
"plugin_short_circuit": true,
"public_to_plugins": true,
"required_parameters": [],
"result_contract": "StorageProviderResult",
"required_parameters": [
"fileitem",
"name"
],
"result_contract": "FileItem | None",
"result_shape": "any",
"supports_async": true,
"supports_sync": true,
@@ -3592,16 +3598,18 @@
"version": 1
},
"delete_file": {
"aggregation": "legacy",
"aggregation": "first_non_empty",
"error_policy": "isolate_provider",
"execution": "sync_or_async",
"family": "storage",
"input_contract": "StorageKeywordArguments",
"input_contract": "StorageDeleteRequest",
"plugin_short_circuit": true,
"public_to_plugins": true,
"required_parameters": [],
"result_contract": "StorageProviderResult",
"result_shape": "any",
"required_parameters": [
"fileitem"
],
"result_contract": "bool | None",
"result_shape": "boolean",
"supports_async": true,
"supports_sync": true,
"timeout_policy": "caller_budget",
@@ -4405,16 +4413,18 @@
"version": 1
},
"media_files": {
"aggregation": "legacy",
"aggregation": "ordered_list_merge",
"error_policy": "isolate_provider",
"execution": "sync_or_async",
"family": "storage",
"input_contract": "StorageKeywordArguments",
"input_contract": "MediaFilesRequest",
"plugin_short_circuit": true,
"public_to_plugins": true,
"required_parameters": [],
"result_contract": "StorageProviderResult",
"result_shape": "any",
"required_parameters": [
"mediainfo"
],
"result_contract": "list[FileItem]",
"result_shape": "list",
"supports_async": true,
"supports_sync": true,
"timeout_policy": "caller_budget",
@@ -5707,15 +5717,30 @@
"version": 1
},
"transfer": {
"aggregation": "legacy",
"aggregation": "first_non_empty",
"error_policy": "isolate_provider",
"execution": "sync_or_async",
"family": "storage",
"input_contract": "StorageKeywordArguments",
"input_contract": "TransferRequest",
"plugin_short_circuit": true,
"public_to_plugins": true,
"required_parameters": [],
"result_contract": "StorageProviderResult",
"required_parameters": [
"episodes_info",
"fileitem",
"library_category_folder",
"library_type_folder",
"mediainfo",
"meta",
"preview",
"scrape",
"source_oper",
"target_directory",
"target_oper",
"target_path",
"target_storage",
"transfer_type"
],
"result_contract": "TransferInfo | None",
"result_shape": "any",
"supports_async": true,
"supports_sync": true,
+14
View File
@@ -189,6 +189,20 @@ def test_media_server_contracts_distinguish_streams_lists_and_scalar_routes() ->
assert items.result_shape is ModuleResultShape.ANY
def test_storage_value_contracts_use_explicit_provider_semantics() -> None:
"""存储值查询和动作应停止 legacy 接力,仅文件清单合并 provider 结果。"""
for method in ("any_files", "create_folder", "delete_file", "transfer"):
contract = get_module_method_contract(method)
assert contract.family == "storage"
assert contract.aggregation is ModuleResultAggregation.FIRST_NON_EMPTY
assert contract.required_parameters
media_files = get_module_method_contract("media_files")
assert media_files.aggregation is ModuleResultAggregation.ORDERED_LIST_MERGE
assert media_files.result_shape is ModuleResultShape.LIST
assert media_files.required_parameters == ("mediainfo",)
def test_heterogeneous_torrent_files_result_remains_legacy_compatible() -> None:
"""下载器文件集合尚未归一前不得声明虚假的列表聚合语义。"""
contract = get_module_method_contract("torrent_files")