feat(library): 生产发布授权与同步/恢复编排,worker 接线
build / build (push) Successful in 1m19s

为什么:同步入口此前只会拒绝;授权、预备份、四类写入、验证与失败恢复都没有代码。
本轮把编排与授权实现出来,真实生产执行仍按授权闸口关闭。

- internal/libraryrelease:预备份 → 数据库/资源/索引/Wiki → 验证 → 失败恢复;
  授权过期/目标不符/快照不符/参数变化在动生产前拒绝;恢复失败单独上报。
- 迁移 000067 library_release_authorizations(目标+快照+参数摘要+有效期,可撤销)。
- POST/GET /api/v1/library/authorizations 与 /{id}/revoke,仅管理员签发,5–1440 分钟。
- worker library.sync 接编排:先闸口再授权,阶段落库,只有编排成功才标成功。
- 生产目标适配器未配置时显式失败(不返回零值状态),预备份存储同。
- overview 返回授权状态,页面"生产保护与恢复"显示签发人与有效期。
- 验收矩阵区分"已实现·隔离测试通过"与"真实执行未授权"。
This commit is contained in:
姚章浩
2026-10-28 15:11:27 +08:00
parent f91359f881
commit 7b8cc0384b
22 changed files with 1288 additions and 46 deletions
+127
View File
@@ -1025,6 +1025,133 @@
}
}
},
"/api/v1/library/authorizations": {
"get": {
"tags": [
"Runtime"
],
"operationId": "listLibraryAuthorizations",
"summary": "列出该目标的生产发布授权(含签发人、有效期与撤销状态)",
"parameters": [
{
"name": "scope",
"in": "query",
"required": false,
"schema": {
"type": "string",
"enum": [
"internal",
"external"
]
}
}
],
"responses": {
"200": {
"$ref": "#/components/responses/Envelope"
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"500": {
"$ref": "#/components/responses/InternalError"
}
}
},
"post": {
"tags": [
"Runtime"
],
"operationId": "createLibraryAuthorization",
"summary": "管理员签发生产发布授权:绑定目标+快照+参数摘要+有效期(5–1440 分钟),换快照或换参数即失效",
"responses": {
"201": {
"description": "已记录授权"
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"403": {
"description": "仅管理员可签发"
},
"500": {
"$ref": "#/components/responses/InternalError"
},
"503": {
"description": "授权存储不可用"
}
},
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": false,
"required": [
"scope",
"snapshot_id",
"expires_in_minutes"
],
"properties": {
"scope": {
"type": "string",
"enum": [
"internal",
"external"
]
},
"snapshot_id": {
"type": "string"
},
"expires_in_minutes": {
"type": "integer",
"minimum": 5,
"maximum": 1440
}
}
}
}
}
}
}
},
"/api/v1/library/authorizations/{id}/revoke": {
"post": {
"tags": [
"Runtime"
],
"operationId": "revokeLibraryAuthorization",
"summary": "撤销一份生产发布授权(仅管理员);撤销后同一目标快照不能再启动同步",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"$ref": "#/components/responses/Envelope"
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"403": {
"description": "仅管理员可撤销"
},
"409": {
"description": "授权不存在或已撤销"
},
"500": {
"$ref": "#/components/responses/InternalError"
}
}
}
},
"/api/v1/library/syncs": {
"post": {
"tags": [