perf(delivery): use bounded native cold restore copies

This commit is contained in:
2026-10-28 12:11:53 +08:00
parent 9f4a8c9a68
commit 8d7f651ddc
24 changed files with 2911 additions and 19 deletions
+11
View File
@@ -38,3 +38,14 @@ Coordinator 必须在事务锁内核对当前租约及状态规则,并将结
Python/Rust 的 `manifest_bytes` 输出同一 UTF-8 JSON:递归排序对象键,无额外空白/换行。
清单摘要是这些确切字节的 SHA-256,不能使用数据库 JSONB 的输出顺序或任意 prettify 后的字节。
共享 `canonical-manifest.v1.txt` 为合成示例的字节验收,平台内部响应复用这些序列化字节。
## 离线恢复字节复制协议
`restore-io-request/reply` v1 用于 Python 恢复操作器与 Sandbox 的 `kf-restore-io`。
共享 37 项合法/非法元数据样例在 `tests/fixtures/restore-io/examples.json`。
请求仅含固定域内规范文件名、既有 OS 身份/模式、字节数和摘要;不接受源/目标宿主路径、
命令或服务操作。每行请求最多 256 KiB、回复 64 KiB;重复/未知字段、严格整数违规及
总量/批次/状态不一致均拒绝。单批至多 256 文件、64 MiB,较大单文件独占批次且不超过
256 MiB;整个已验证清单至多 98304 文件、12 GiB。接收端仍独立核对固定 Root 单元、
真实限额、只读备份卷与停止的写入者。`execution_verified` 始终为 false;复制回复
不能证明业务恢复、正常就绪、判题或恢复时间目标。Schema 描述结构,跨字段规则需模型校验。
@@ -0,0 +1,75 @@
{
"$id": "urn:kf-oj:restore-io-reply:v1",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"additionalProperties": false,
"properties": {
"batch_id": {
"maximum": 98304,
"minimum": 0,
"title": "Batch Id",
"type": "integer"
},
"error": {
"enum": [
"none",
"protocol",
"guard",
"deadline",
"filesystem",
"bytes",
"identity"
],
"title": "Error",
"type": "string"
},
"execution_verified": {
"const": false,
"title": "Execution Verified",
"type": "boolean"
},
"kind": {
"const": "restore.io.reply",
"title": "Kind",
"type": "string"
},
"schema_version": {
"const": 1,
"title": "Schema Version",
"type": "integer"
},
"stage": {
"enum": [
"opened",
"verified",
"finished",
"refused"
],
"title": "Stage",
"type": "string"
},
"verified_files": {
"maximum": 98304,
"minimum": 0,
"title": "Verified Files",
"type": "integer"
},
"verified_logical_bytes": {
"maximum": 12884901888,
"minimum": 0,
"title": "Verified Logical Bytes",
"type": "integer"
}
},
"required": [
"schema_version",
"kind",
"stage",
"batch_id",
"verified_files",
"verified_logical_bytes",
"execution_verified",
"error"
],
"title": "RestoreIOReply",
"type": "object"
}
@@ -0,0 +1,187 @@
{
"$defs": {
"Batch": {
"additionalProperties": false,
"properties": {
"batch_id": {
"maximum": 98304,
"minimum": 1,
"title": "Batch Id",
"type": "integer"
},
"files": {
"items": {
"$ref": "#/$defs/RestoreFile"
},
"maxItems": 256,
"minItems": 1,
"title": "Files",
"type": "array"
},
"kind": {
"const": "restore.io.batch",
"title": "Kind",
"type": "string"
},
"schema_version": {
"const": 1,
"title": "Schema Version",
"type": "integer"
}
},
"required": [
"schema_version",
"kind",
"batch_id",
"files"
],
"title": "Batch",
"type": "object"
},
"Finish": {
"additionalProperties": false,
"properties": {
"kind": {
"const": "restore.io.finish",
"title": "Kind",
"type": "string"
},
"schema_version": {
"const": 1,
"title": "Schema Version",
"type": "integer"
}
},
"required": [
"schema_version",
"kind"
],
"title": "Finish",
"type": "object"
},
"Open": {
"additionalProperties": false,
"properties": {
"backup_id": {
"pattern": "^bk-[0-9a-f]{32}$",
"title": "Backup Id",
"type": "string"
},
"deadline_monotonic_ns": {
"maximum": 9223372036854775807,
"minimum": 1,
"title": "Deadline Monotonic Ns",
"type": "integer"
},
"expected_files": {
"maximum": 98304,
"minimum": 1,
"title": "Expected Files",
"type": "integer"
},
"expected_logical_bytes": {
"maximum": 12884901888,
"minimum": 0,
"title": "Expected Logical Bytes",
"type": "integer"
},
"kind": {
"const": "restore.io.open",
"title": "Kind",
"type": "string"
},
"recovery_id": {
"pattern": "^rr-[0-9a-f]{32}$",
"title": "Recovery Id",
"type": "string"
},
"schema_version": {
"const": 1,
"title": "Schema Version",
"type": "integer"
}
},
"required": [
"schema_version",
"kind",
"backup_id",
"recovery_id",
"expected_files",
"expected_logical_bytes",
"deadline_monotonic_ns"
],
"title": "Open",
"type": "object"
},
"RestoreFile": {
"additionalProperties": false,
"properties": {
"bytes": {
"maximum": 268435456,
"minimum": 0,
"title": "Bytes",
"type": "integer"
},
"gid": {
"maximum": 1205,
"minimum": 0,
"title": "Gid",
"type": "integer"
},
"mode": {
"title": "Mode",
"type": "integer"
},
"path": {
"maxLength": 512,
"minLength": 1,
"title": "Path",
"type": "string"
},
"sha256": {
"pattern": "^[0-9a-f]{64}$",
"title": "Sha256",
"type": "string"
},
"uid": {
"maximum": 1205,
"minimum": 0,
"title": "Uid",
"type": "integer"
}
},
"required": [
"path",
"uid",
"gid",
"mode",
"bytes",
"sha256"
],
"title": "RestoreFile",
"type": "object"
}
},
"$id": "urn:kf-oj:restore-io-request:v1",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"discriminator": {
"mapping": {
"restore.io.batch": "#/$defs/Batch",
"restore.io.finish": "#/$defs/Finish",
"restore.io.open": "#/$defs/Open"
},
"propertyName": "kind"
},
"oneOf": [
{
"$ref": "#/$defs/Open"
},
{
"$ref": "#/$defs/Batch"
},
{
"$ref": "#/$defs/Finish"
}
],
"title": "RestoreIORequest"
}