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 @@
// 模型/协议纯回归:用内存对象与 recorder 验证身份、原子变更或流传输契约,不访问真实数据库。
package platform
import (
@@ -9,6 +10,7 @@ import (
"testing"
)
// streamRecords 把 recorder 内每行 JSON 转为断言对象;用例中的小记录不需要增大 Scanner 缺省预算。
func streamRecords(t *testing.T, writer *httptest.ResponseRecorder) []response {
t.Helper()
var records []response
@@ -25,6 +27,8 @@ func streamRecords(t *testing.T, writer *httptest.ResponseRecorder) []response {
}
return records
}
// TestCanonicalModelStreamFramesAndSnapshot 用超过两个批次的元素验证 header/批次/complete 分帧,token、序号、墓碑和全元素 owner 清单必须一致且无重复漏项。
func TestCanonicalModelStreamFramesAndSnapshot(t *testing.T) {
model := modelTestDocument()
for i := 0; i < 129; i++ {
@@ -80,15 +84,19 @@ func TestCanonicalModelStreamFramesAndSnapshot(t *testing.T) {
}
}
// cancelStreamWriter 在首个 flush 后取消请求,用于验证已开始流的中途停止语义。
type cancelStreamWriter struct {
*httptest.ResponseRecorder
cancel context.CancelFunc
}
// Flush 先模拟实际输出,再取消,使下一次编码检测到上下文结束。
func (writer cancelStreamWriter) Flush() {
writer.ResponseRecorder.Flush()
writer.cancel()
}
// TestCanonicalModelStreamCancellationNeverClaimsCompletion 第一次 Flush 即取消上下文,验证仅发 header,不能追加 complete 或假成功尾记录。
func TestCanonicalModelStreamCancellationNeverClaimsCompletion(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
@@ -100,6 +108,7 @@ func TestCanonicalModelStreamCancellationNeverClaimsCompletion(t *testing.T) {
}
}
// TestCanonicalModelStreamDeclaresDirectScopeCountsIncludingEmptyCanvases 验证每个 scope 只计直接成员且显式保留零元素画布,未知 owner 必须在首次 Flush 前拒绝。
func TestCanonicalModelStreamDeclaresDirectScopeCountsIncludingEmptyCanvases(t *testing.T) {
model := modelTestDocument()
empty, nested := modelTestID(41), modelTestID(42)
@@ -124,6 +133,7 @@ func TestCanonicalModelStreamDeclaresDirectScopeCountsIncludingEmptyCanvases(t *
}
}
// TestCanonicalModelStreamRejectsAmbiguousIdentityManifest 构造空或重复内部元素 ID,验证不发布有歧义的身份清单,返回 500 且未开始流。
func TestCanonicalModelStreamRejectsAmbiguousIdentityManifest(t *testing.T) {
for _, id := range []string{"", "a"} {
model := modelTestDocument()