refactor: close plugin shutdown mutation races

This commit is contained in:
jxxghp
2026-08-23 21:55:22 +08:00
parent eb36e6be91
commit 820582ab12
16 changed files with 904 additions and 399 deletions
+13 -2
View File
@@ -13,8 +13,8 @@
"runtime_to_db": [],
"workflow_to_db": []
},
"edge_count": 6514,
"edge_sha256": "eda9bc500158baa80dc5013eb4e409aa57cb70446e59a52b7e782cb9c58f9c34",
"edge_count": 6525,
"edge_sha256": "72b9416b5309bb51768b95b3c9da4b167242c3bc3f27d4e561a3f097267ca6a0",
"edges": [
"app -> app.runtime",
"app -> app.runtime.compat",
@@ -281,6 +281,7 @@
"app.agent.middleware.skills -> app.agent.middleware",
"app.agent.middleware.skills -> app.agent.middleware.utils",
"app.agent.middleware.skills -> app.agent.policy",
"app.agent.middleware.skills -> app.agent.policy.sanitizer",
"app.agent.middleware.skills -> app.agent.skills",
"app.agent.middleware.skills -> app.agent.skills.metadata",
"app.agent.middleware.skills -> app.agent.tools",
@@ -309,6 +310,7 @@
"app.agent.middleware.summarization -> app.runtime.log",
"app.agent.middleware.tool_selection -> app.agent",
"app.agent.middleware.tool_selection -> app.agent.llm",
"app.agent.middleware.tool_selection -> app.agent.llm.helper",
"app.agent.middleware.tool_selection -> app.agent.tools",
"app.agent.middleware.tool_selection -> app.agent.tools.tags",
"app.agent.middleware.tool_selection -> app.runtime",
@@ -435,6 +437,7 @@
"app.agent.tools.base -> app.schemas.types",
"app.agent.tools.catalog -> app.agent",
"app.agent.tools.catalog -> app.agent.policy",
"app.agent.tools.catalog -> app.agent.policy.contracts",
"app.agent.tools.factory -> app.agent",
"app.agent.tools.factory -> app.agent.llm",
"app.agent.tools.factory -> app.agent.llm.capability",
@@ -883,6 +886,7 @@
"app.agent.tools.impl.query_doctor_report -> app.agent.tools.base",
"app.agent.tools.impl.query_doctor_report -> app.agent.tools.tags",
"app.agent.tools.impl.query_doctor_report -> app.doctor",
"app.agent.tools.impl.query_doctor_report -> app.doctor.runner",
"app.agent.tools.impl.query_doctor_report -> app.runtime",
"app.agent.tools.impl.query_doctor_report -> app.runtime.log",
"app.agent.tools.impl.query_download_tasks -> app.agent",
@@ -1471,6 +1475,8 @@
"app.agent.tools.impl.update_system_settings -> app.agent.tools.tags",
"app.agent.tools.impl.update_system_settings -> app.application",
"app.agent.tools.impl.update_system_settings -> app.application.configuration",
"app.agent.tools.impl.update_system_settings -> app.application.plugin",
"app.agent.tools.impl.update_system_settings -> app.application.plugin.runtime",
"app.agent.tools.impl.update_system_settings -> app.runtime",
"app.agent.tools.impl.update_system_settings -> app.runtime.events",
"app.agent.tools.impl.update_system_settings -> app.runtime.log",
@@ -2261,6 +2267,8 @@
"app.api.endpoints.system -> app.application.messaging.message",
"app.api.endpoints.system -> app.application.module",
"app.api.endpoints.system -> app.application.network",
"app.api.endpoints.system -> app.application.plugin",
"app.api.endpoints.system -> app.application.plugin.runtime",
"app.api.endpoints.system -> app.application.rules",
"app.api.endpoints.system -> app.application.scheduling",
"app.api.endpoints.system -> app.application.security",
@@ -2287,6 +2295,7 @@
"app.api.endpoints.system -> app.schemas",
"app.api.endpoints.system -> app.schemas.common",
"app.api.endpoints.system -> app.schemas.event",
"app.api.endpoints.system -> app.schemas.exception",
"app.api.endpoints.system -> app.schemas.response",
"app.api.endpoints.system -> app.schemas.system",
"app.api.endpoints.system -> app.schemas.token",
@@ -2688,6 +2697,8 @@
"app.application.plugin.install -> app.runtime.log",
"app.application.plugin.install -> app.schemas",
"app.application.plugin.install -> app.schemas.exception",
"app.application.plugin.runtime -> app.schemas",
"app.application.plugin.runtime -> app.schemas.types",
"app.application.recognition -> app.application",
"app.application.recognition -> app.application.configuration",
"app.application.recognition -> app.schemas",
+118 -116
View File
@@ -1,41 +1,41 @@
{
"schema_version": 2,
"generated_at": "2026-08-23T11:06:42.858188+00:00",
"generated_at": "2026-08-23T13:47:08.442528+00:00",
"platform": "macOS-26.5.2-arm64-arm-64bit-Mach-O",
"python": "3.14.3",
"repeat": 3,
"targets": {
"app.startup.lifecycle": {
"loaded_app_module_count": 362,
"max_ms": 1022.231,
"median_ms": 976.39,
"min_ms": 967.395,
"loaded_app_module_count": 367,
"max_ms": 1591.175,
"median_ms": 1049.37,
"min_ms": 1022.351,
"samples_ms": [
1022.231,
967.395,
976.39
1591.175,
1049.37,
1022.351
]
},
"app.factory": {
"loaded_app_module_count": 374,
"max_ms": 989.21,
"median_ms": 980.605,
"min_ms": 951.564,
"loaded_app_module_count": 379,
"max_ms": 1198.166,
"median_ms": 1083.805,
"min_ms": 1009.309,
"samples_ms": [
980.605,
989.21,
951.564
1009.309,
1198.166,
1083.805
]
},
"app.main": {
"loaded_app_module_count": 376,
"max_ms": 1114.04,
"median_ms": 1088.251,
"min_ms": 1080.26,
"loaded_app_module_count": 381,
"max_ms": 1229.477,
"median_ms": 1179.859,
"min_ms": 1129.055,
"samples_ms": [
1080.26,
1088.251,
1114.04
1129.055,
1179.859,
1229.477
]
}
},
@@ -46,26 +46,26 @@
"samples": [
{
"mode": "normal",
"enabled_component_count": 21,
"startup_ms": 0.619,
"full_lifespan_ms": 0.806,
"enabled_component_count": 23,
"startup_ms": 0.64,
"full_lifespan_ms": 0.805,
"stage_ms": {
"后台任务登记器": 0.075,
"数据库准备": 0.037,
"HTTP 基础能力": 0.031,
"后台任务登记器": 0.079,
"数据库准备": 0.039,
"HTTP 基础能力": 0.029,
"领域依赖装配": 0.027,
"数据库引擎预热": 0.024,
"数据库连接预算": 0.025,
"路由": 0.022,
"模块服务": 0.024,
"插件备份恢复": 0.021,
"插件": 0.02,
"定时器": 0.023,
"监控器": 0.021,
"待处理整理回放": 0.019,
"命令服务": 0.022,
"工作流": 0.022,
"插件同步与启动收尾": 0.034
"数据库连接预算": 0.023,
"路由": 0.023,
"模块服务": 0.021,
"插件备份恢复": 0.024,
"插件": 0.021,
"定时器": 0.026,
"监控器": 0.022,
"待处理整理回放": 0.025,
"命令服务": 0.025,
"工作流": 0.021,
"插件同步与启动收尾": 0.037
},
"threads_before": 2,
"threads_started": 2,
@@ -77,26 +77,26 @@
},
{
"mode": "normal",
"enabled_component_count": 21,
"startup_ms": 0.628,
"enabled_component_count": 23,
"startup_ms": 0.652,
"full_lifespan_ms": 0.808,
"stage_ms": {
"后台任务登记器": 0.073,
"数据库准备": 0.037,
"HTTP 基础能力": 0.039,
"领域依赖装配": 0.027,
"数据库引擎预热": 0.025,
"数据库连接预算": 0.025,
"后台任务登记器": 0.079,
"数据库准备": 0.039,
"HTTP 基础能力": 0.033,
"领域依赖装配": 0.029,
"数据库引擎预热": 0.026,
"数据库连接预算": 0.021,
"路由": 0.022,
"模块服务": 0.022,
"模块服务": 0.023,
"插件备份恢复": 0.021,
"插件": 0.02,
"定时器": 0.024,
"监控器": 0.022,
"待处理整理回放": 0.029,
"命令服务": 0.02,
"工作流": 0.021,
"插件同步与启动收尾": 0.032
"插件": 0.022,
"定时器": 0.026,
"监控器": 0.023,
"待处理整理回放": 0.024,
"命令服务": 0.023,
"工作流": 0.025,
"插件同步与启动收尾": 0.035
},
"threads_before": 2,
"threads_started": 2,
@@ -108,26 +108,26 @@
},
{
"mode": "normal",
"enabled_component_count": 21,
"startup_ms": 0.664,
"full_lifespan_ms": 0.863,
"enabled_component_count": 23,
"startup_ms": 0.739,
"full_lifespan_ms": 0.944,
"stage_ms": {
"后台任务登记器": 0.083,
"数据库准备": 0.047,
"HTTP 基础能力": 0.036,
"后台任务登记器": 0.087,
"数据库准备": 0.037,
"HTTP 基础能力": 0.029,
"领域依赖装配": 0.028,
"数据库引擎预热": 0.029,
"数据库连接预算": 0.025,
"路由": 0.026,
"模块服务": 0.025,
"插件备份恢复": 0.025,
"插件": 0.028,
"定时器": 0.026,
"监控器": 0.021,
"待处理整理回放": 0.021,
"命令服务": 0.024,
"工作流": 0.021,
"插件同步与启动收尾": 0.036
"数据库引擎预热": 0.024,
"数据库连接预算": 0.021,
"路由": 0.02,
"模块服务": 0.02,
"插件备份恢复": 0.024,
"插件": 0.019,
"定时器": 0.025,
"监控器": 0.054,
"待处理整理回放": 0.041,
"命令服务": 0.034,
"工作流": 0.025,
"插件同步与启动收尾": 0.037
},
"threads_before": 2,
"threads_started": 2,
@@ -138,9 +138,9 @@
"database_connections_started": 0
}
],
"median_startup_ms": 0.628,
"median_startup_ms": 0.652,
"median_full_lifespan_ms": 0.808,
"enabled_component_count": 21,
"enabled_component_count": 23,
"enabled_components": [
"后台任务登记器",
"数据库准备",
@@ -157,6 +157,8 @@
"监控器",
"整理后台服务",
"AI智能体会话",
"插件事件入口",
"事件尾任务结算",
"插件后台服务",
"事件投递屏障",
"待处理整理回放",
@@ -170,42 +172,18 @@
{
"mode": "safe",
"enabled_component_count": 11,
"startup_ms": 0.464,
"full_lifespan_ms": 0.637,
"startup_ms": 0.475,
"full_lifespan_ms": 0.619,
"stage_ms": {
"后台任务登记器": 0.074,
"后台任务登记器": 0.079,
"数据库准备": 0.038,
"HTTP 基础能力": 0.03,
"领域依赖装配": 0.029,
"数据库引擎预热": 0.026,
"数据库连接预算": 0.025,
"路由": 0.024,
"模块服务": 0.024,
"插件同步与启动收尾": 0.033
},
"threads_before": 2,
"threads_started": 2,
"threads_after": 2,
"tasks_before": 1,
"tasks_started": 2,
"tasks_after": 1,
"database_connections_started": 0
},
{
"mode": "safe",
"enabled_component_count": 11,
"startup_ms": 0.451,
"full_lifespan_ms": 0.624,
"stage_ms": {
"后台任务登记器": 0.073,
"数据库准备": 0.035,
"HTTP 基础能力": 0.028,
"领域依赖装配": 0.027,
"领域依赖装配": 0.028,
"数据库引擎预热": 0.024,
"数据库连接预算": 0.023,
"路由": 0.023,
"模块服务": 0.02,
"插件同步与启动收尾": 0.031
"模块服务": 0.022,
"插件同步与启动收尾": 0.036
},
"threads_before": 2,
"threads_started": 2,
@@ -218,18 +196,42 @@
{
"mode": "safe",
"enabled_component_count": 11,
"startup_ms": 0.477,
"full_lifespan_ms": 0.661,
"startup_ms": 0.493,
"full_lifespan_ms": 0.676,
"stage_ms": {
"后台任务登记器": 0.081,
"数据库准备": 0.05,
"后台任务登记器": 0.089,
"数据库准备": 0.037,
"HTTP 基础能力": 0.035,
"领域依赖装配": 0.03,
"数据库引擎预热": 0.026,
"数据库连接预算": 0.024,
"领域依赖装配": 0.028,
"数据库引擎预热": 0.025,
"数据库连接预算": 0.021,
"路由": 0.025,
"模块服务": 0.023,
"插件同步与启动收尾": 0.062
},
"threads_before": 2,
"threads_started": 2,
"threads_after": 2,
"tasks_before": 1,
"tasks_started": 2,
"tasks_after": 1,
"database_connections_started": 0
},
{
"mode": "safe",
"enabled_component_count": 11,
"startup_ms": 0.464,
"full_lifespan_ms": 0.638,
"stage_ms": {
"后台任务登记器": 0.075,
"数据库准备": 0.036,
"HTTP 基础能力": 0.028,
"领域依赖装配": 0.028,
"数据库引擎预热": 0.023,
"数据库连接预算": 0.022,
"路由": 0.024,
"模块服务": 0.02,
"插件同步与启动收尾": 0.026
"模块服务": 0.021,
"插件同步与启动收尾": 0.057
},
"threads_before": 2,
"threads_started": 2,
@@ -240,8 +242,8 @@
"database_connections_started": 0
}
],
"median_startup_ms": 0.464,
"median_full_lifespan_ms": 0.637,
"median_startup_ms": 0.475,
"median_full_lifespan_ms": 0.638,
"enabled_component_count": 11,
"enabled_components": [
"后台任务登记器",