fix(library): 整库只读接口改清单级读取,修掉真实超时
build / build (push) Successful in 1m17s

候选归档 79 版 / 56MB blob 上,overview、storage、snapshots 三个只读接口
都在 10s 请求期限后返回 503。分段计时定位到唯一瓶颈是按版本重读全部 blob:
Open 0ms、LoadManifest×79 11~22ms、ContentUsage 15~25ms、
Usage(逐版 Load 验字节)13.75~14.11s;单版 Load 261~290ms。

- Usage 拆成 Usage(逐版复核字节,同步/恢复与运维 CLI 用)与
  UsageFromManifests(同一份去重实现,只做清单级校验),列举路径改用后者;
- library_storage.go 每版两次 Load、snapshots 每版一次 Load 改为一次清单读取;
- wiki/文档差异只读所需部件,被读部件仍由 OpenPart 复核摘要;
- LoadManifest 与 Load 共用同一套清单判据(严格解码 + 重新编码校验);
- 列举响应带 verification=manifest / verified=false,详情整版复核后才是 content,
  避免把"清单可读"读成"完整性已验证";
- libraryWithDeadline 去掉超时后再写已结束响应的 goroutine 写法
  (候选环境实测 http: superfluous response.WriteHeader call)。

回归:多版本共享大 blob 时枚举不读 blob 字节(篡改后枚举仍成功),
而 Load/OpenPart/Usage 仍拒绝坏 blob;坏清单两条路径都整条报错。
make verify 15 项全绿(local 档案)。
This commit is contained in:
姚章浩
2026-10-28 21:52:14 +08:00
parent 1609a0c9be
commit fe6e218d9c
12 changed files with 602 additions and 96 deletions
+2 -2
View File
@@ -87,7 +87,7 @@ func TestReadLibrarySnapshotsReportsSealedTotals(t *testing.T) {
if err = archive.Close(); err != nil {
t.Fatal(err)
}
list, err := readLibrarySnapshots(root)
list, err := readLibrarySnapshots(t.Context(), root)
if err != nil {
t.Fatal(err)
}
@@ -121,7 +121,7 @@ func TestReadLibrarySnapshotsReportsSealedTotals(t *testing.T) {
}
func TestReadLibrarySnapshotsWithoutArchiveIsExplicitlyUnwired(t *testing.T) {
list, err := readLibrarySnapshots("")
list, err := readLibrarySnapshots(t.Context(), "")
if err != nil {
t.Fatal(err)
}