Files
knowledge-governance/internal/releaseadapter/v071/library_preflight.go
T
姚章浩 c2402947a9
build / build (push) Successful in 1m26s
feat(library): 死信按精确指纹解除,保留上游记录
上游 task_dead_letters 没有解决标记,purge/DELETE 会销毁"失败过"的唯一证据。
治理侧新增解除记录(迁移 073):绑定实时行逐字节指纹、重放引用、源侧观测摘要与
操作人;行被改过、重放后又出现新死信、源侧未结清都不命中,封存照旧阻断。
指纹先压紧空白再摘要,避免 PG to_jsonb::text 与 json.Marshal 的空白差异。

试过:go test ./internal/{librarydeadletter,libraryagent,httpapi,releaseadapter/v071,
platform/postgres},make verify 15 项全绿。
2026-10-29 06:55:13 +08:00

53 lines
2.2 KiB
Go

package v071
import (
"context"
"github.com/jackc/pgx/v5/pgxpool"
"knowledge-governance/internal/librarysnapshot"
)
// Operator preflight surface. These wrappers expose the *same* checks used by
// the capture path so an operator command can inspect a real source without
// sealing an artifact, stopping a writer, or writing anything. They add no new
// acceptance rule: a preflight which passes here is still only a candidate.
//
// Nothing here authorizes publication: artifact-acceptance-v1 still requires
// snapshot-bound content, question/answer and performance acceptance, and
// production release remains a separate, double-gated decision.
// LibrarySourceSettled reports whether the whole source database has finished
// recorded processing. It is the identical query CaptureLibrary enforces before
// and inside the maintenance window.
func LibrarySourceSettled(ctx context.Context, db *pgxpool.Pool) error {
return checkLibrarySourceSettlement(ctx, db)
}
// LibrarySourceSettledWithReleases 是同一检查,但带上治理平台已审计的精确死信解除
// 指纹:只有逐字节命中的行不再阻断。
func LibrarySourceSettledWithReleases(ctx context.Context, db *pgxpool.Pool, released []string) error {
return checkLibrarySourceSettlementReleased(ctx, db, released)
}
// ValidateLibraryCandidateForPreflight runs the candidate validator used by
// ArchiveLibraryCandidate (identity, bidirectional content coverage, generated
// question coverage, resources and digests) without archiving anything.
func ValidateLibraryCandidateForPreflight(identity PostgresIdentity, pg PostgresSnapshot, es SearchSnapshot) error {
return validateLibraryCandidate(identity, pg, es)
}
// LibraryContentTables is the stable list of PostgreSQL tables a library
// snapshot must contain, so an operator view does not hard-code table names.
func LibraryContentTables() []string {
names := make([]string, 0, len(libraryContentQueries)+1)
names = append(names, "resources")
for _, entry := range libraryContentQueries {
names = append(names, entry.name)
}
return names
}
// LibrarySnapshotCompatibility is the archive-level compatibility contract.
type LibrarySnapshotCompatibility = librarysnapshot.Compatibility