Make artifact and media metadata first-class server records

Artifact and media metadata were previously reconstructed from job result
refs and JSON sidecar files. This change regularizes metadata into SQLite,
keeps filesystem blobs in place, and preserves backward compatibility via
lazy fallback and backfill from existing job refs and JSON metadata.

Constraint: Blob storage remains on the local filesystem in this phase
Rejected: Migrate blobs into SQLite | larger scope and worse operational profile for current media sizes
Rejected: Hard cutover without fallback | unsafe for historical data already on the test server
Confidence: medium
Scope-risk: moderate
Directive: Treat SQLite as the metadata source of truth; JSON sidecars are compatibility fallback only
Tested: go test ./...; deployed to test server 101.42.99.35; verified /v1/artifacts, /v1/artifacts/:id, signed media URL 200, unsigned content 401
Not-tested: Full historical backfill sweep over all existing artifact rows under production-sized data volume
This commit is contained in:
wtgoku
2026-04-18 23:06:34 +08:00
parent 07fd1ad0a7
commit d0318292c1
12 changed files with 1303 additions and 75 deletions
+9 -2
View File
@@ -47,7 +47,14 @@
### `GET /v1/media/:id/content`
读取稳定内容 URL。这个接口默认允许匿名 GET,以便模型提供商可以直接 fetch。
读取稳定内容 URL。
当前语义改为:
- 元数据接口仍然要求登录态,并要求 media 属于当前用户
- 内容 URL 使用短期签名 query 参数作为 capability URL
- 外部模型可以直接 fetch 已签名的 URL,不需要 bearer session
- 裸的 `/content` 路径默认不可直接匿名读取
## Artifact 行为变化
@@ -120,7 +127,7 @@ V1 的本地开发版不引入 S3/R2/OSS,而是用本地文件系统:
## 后续阶段
后续如果要走生产化路线,可以保持接口不变,只把存储实现替换成对象存储:
后续如果要走生产化路线,可以保持接口不变,只把签名 URL 和存储实现替换成对象存储:
- 本地 `media/blobs/` -> S3 / R2 / OSS / COS
- metadata JSON -> 独立 media table 或对象存储元数据