8d838d9cb4
build / build (push) Successful in 1m45s
执行时真实时钟与持久授权回读(撤销/过期即停并保留预备份)、写集合写前落盘、 租约与 attempt 身份、恢复队列与原发送身份分离、成功收尾必须释放维护后再登记终态。
27 lines
1.0 KiB
Go
27 lines
1.0 KiB
Go
package postgres
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"knowledge-governance/internal/governance"
|
|
)
|
|
|
|
// Query the source identity before applying LIMIT: target/prebackup events and
|
|
// other source instances can never push the candidate out of a history window.
|
|
func (s *Store) LibrarySourceCandidate(ctx context.Context, scope, sourceID string) (governance.LibraryVersion, bool, error) {
|
|
if sourceID == "" {
|
|
return governance.LibraryVersion{}, false, errors.New("source identity required")
|
|
}
|
|
rows, err := s.db.Query(ctx, `SELECT id,scope,kind,snapshot_id,version_label,source_job_id,operation_id,attempt_epoch,evidence,created_by,created_at,superseded_at
|
|
FROM library_versions WHERE scope=$1 AND kind='test_sealed' AND evidence->>'source_id'=$2
|
|
ORDER BY created_at DESC,id DESC LIMIT 1`, scope, sourceID)
|
|
if err != nil {
|
|
return governance.LibraryVersion{}, false, err
|
|
}
|
|
items, err := scanLibraryVersions(rows, 1)
|
|
if err != nil || len(items) == 0 {
|
|
return governance.LibraryVersion{}, false, err
|
|
}
|
|
return items[0], true, nil
|
|
}
|