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,5 @@
// 真实 PostgreSQL 回归需要 RESEARCH_TEST_DATABASE_URL 指向预装语料 fixture 的可丢弃测试库。
// 缺少该变量时跳过;测试包含写入拒绝检查,不能指向生产数据库。
package research
import (
@@ -14,6 +16,7 @@ import (
_ "github.com/jackc/pgx/v5/stdlib"
)
// integrationRepository 每个用例打开独立连接池并注册关闭及二十秒 context 清理,不创建 fixture schema。
func integrationRepository(t *testing.T) (*PostgresRepository, context.Context) {
t.Helper()
dsn := os.Getenv("RESEARCH_TEST_DATABASE_URL")
@@ -35,6 +38,7 @@ func integrationRepository(t *testing.T) (*PostgresRepository, context.Context)
return repository, ctx
}
// paperIDs 提取展示顺序,便于断言 SQL 查询和游标返回的 ID 序列。
func paperIDs(papers []Paper) []string {
ids := []string{}
for _, paper := range papers {
@@ -43,6 +47,7 @@ func paperIDs(papers []Paper) []string {
return ids
}
// TestPostgresPageSearchAndFilters 使用已发布 fixture 验证 SQL 排序、全文与作者检索、主题交集和参数绑定,检查主题命名空间。
func TestPostgresPageSearchAndFilters(t *testing.T) {
r, ctx := integrationRepository(t)
if err := r.Check(ctx); err != nil {
@@ -77,6 +82,7 @@ func TestPostgresPageSearchAndFilters(t *testing.T) {
}
}
// TestPostgresMetadataPreservesEvidence 验证原文、作者、来源、DOI 优先级与最新决策证据,保留可空字段和缺失论文语义。
func TestPostgresMetadataPreservesEvidence(t *testing.T) {
r, ctx := integrationRepository(t)
p, err := r.Get(ctx, 1)
@@ -111,6 +117,7 @@ func TestPostgresMetadataPreservesEvidence(t *testing.T) {
}
}
// TestPostgresCorpusIsReadOnlyAndHTTPWorks 检查事务隔离与资源选项;实际尝试写入须被数据库权限拒绝,再经 HTTP 验证真实 SQL 响应。
func TestPostgresCorpusIsReadOnlyAndHTTPWorks(t *testing.T) {
r, ctx := integrationRepository(t)
tx, err := r.begin(ctx)
@@ -153,6 +160,7 @@ func TestPostgresCorpusIsReadOnlyAndHTTPWorks(t *testing.T) {
}
}
// TestPostgresPublishedTextCodec 通过编码 fixture 检查论文、作者、评论和 HTTP JSON 均还原控制字符,并可继续搜索。
func TestPostgresPublishedTextCodec(t *testing.T) {
legacy, ctx := integrationRepository(t)
r, err := NewPostgresRepository(legacy.db, "research_encoded_fixture")
@@ -182,6 +190,7 @@ func TestPostgresPublishedTextCodec(t *testing.T) {
}
}
// TestPostgresCursorsTraverseBothDirections 按每页一条遍历两种排序,每步反向读取前页,防止游标循环并拒绝换筛选复用。
func TestPostgresCursorsTraverseBothDirections(t *testing.T) {
r, ctx := integrationRepository(t)
for _, sort := range []string{"recent", "title"} {
@@ -231,6 +240,7 @@ func TestPostgresCursorsTraverseBothDirections(t *testing.T) {
}
}
// TestPostgresEncodedTitleCursors 在转义标题库中逐页遍历,验证游标保留数据库排序键,不因展示文本解码而改变顺序。
func TestPostgresEncodedTitleCursors(t *testing.T) {
legacy, ctx := integrationRepository(t)
r, err := NewPostgresRepository(legacy.db, "research_encoded_fixture")
@@ -264,6 +274,7 @@ func TestPostgresEncodedTitleCursors(t *testing.T) {
}
}
// TestPostgresBoundedProbeDoesNotTruncateSparseMatches 用跨越探测窗口的稀疏 ID 和三种页大小验证检索回退不漏项,并检查反向跨空档分页。
func TestPostgresBoundedProbeDoesNotTruncateSparseMatches(t *testing.T) {
legacy, ctx := integrationRepository(t)
r, err := NewPostgresRepository(legacy.db, "research_sparse_fixture")
@@ -310,6 +321,7 @@ func TestPostgresBoundedProbeDoesNotTruncateSparseMatches(t *testing.T) {
}
}
// TestPostgresTopicCursorSkipsDuplicateEvidence 验证多个来源产生的重复标签证据不会重复返回论文,且主题游标可双向跨页。
func TestPostgresTopicCursorSkipsDuplicateEvidence(t *testing.T) {
legacy, ctx := integrationRepository(t)
r, err := NewPostgresRepository(legacy.db, "research_sparse_fixture")