docs: annotate Foundry source and deployment lifecycle in Chinese [skip ci]

This commit is contained in:
2026-11-16 17:52:11 +08:00
parent 30829eeb86
commit 1090591503
123 changed files with 1279 additions and 3 deletions
@@ -1,3 +1,4 @@
// 旧 headless 操作批次数据库回归:需要 PLATFORM_TEST_DATABASE_URL 指向隔离且已迁移测试库。
package platform
import (
@@ -17,6 +18,7 @@ import (
"testing"
)
// TestCanvasOperationsTransactions 检查应用/拒绝回执可恢复、同键同体重试、权限隔离及多画布批次整体回滚。
func TestCanvasOperationsTransactions(t *testing.T) {
dsn := os.Getenv("PLATFORM_TEST_DATABASE_URL")
if dsn == "" {
@@ -72,6 +74,7 @@ func TestCanvasOperationsTransactions(t *testing.T) {
Register(mux, db, map[string]string{project: "https://app.example.com/auth/callback"}, "https://api.example.com", nil)
path := "/projects/" + project + "/workspaces/" + workspace + "/materials/" + boards[0] + "/canvas/operations"
key := func(n int) string { return fmt.Sprintf("a0000000-0000-4000-8000-%012d", n) }
// do 执行真实路由,call 断言状态并解码,version 从数据库读取真实 canvas_version。
do := func(method, path, token string, input canvasOperationBatch) *httptest.ResponseRecorder {
encoded, _ := json.Marshal(input)
request := httptest.NewRequest(method, path, bytes.NewReader(encoded))
@@ -124,6 +127,7 @@ func TestCanvasOperationsTransactions(t *testing.T) {
t.Fatal("missing receipt must not claim terminal zero writes")
}
// Terminal zero-write responses must remain queryable and reserve their frozen body.
// 终局拒绝冻结原键和请求体,不能修正版本后沿用同一键让先前零效果变为实际执行。
stale := batch(3, 1)
rejected := call("POST", path, tokens[0], stale, 412)
proof := call("GET", path+"/"+key(3), tokens[0], canvasOperationBatch{}, 200)
@@ -135,6 +139,7 @@ func TestCanvasOperationsTransactions(t *testing.T) {
t.Fatal("rejected request performed a write")
}
// Concurrent exact retries serialize to one transaction and one version increment.
// 四条同键并发请求共享原回执,数据库版本只能前进一次。
concurrent := batch(4, 2)
var wait sync.WaitGroup
results := make(chan *httptest.ResponseRecorder, 4)
@@ -153,6 +158,7 @@ func TestCanvasOperationsTransactions(t *testing.T) {
t.Fatal("concurrent request executed more than once")
}
// A valid first participant and an invalid second participant produce no partial write.
// 首画布 patch 合法但次画布删除不存在节点,检查两者版本都不变且拒绝回执可查。
atomic := batch(5, 3)
atomic.ExpectedVersions[boards[1]] = 1
atomic.Operations = append(atomic.Operations, canvasOperation{ID: key(500), Type: "node.delete", CanvasID: boards[1], ElementID: "missing"})