4b3aaff321
治理侧保存输入观测版本、自动复检及人工复核历史,输入变化失效、版本冲突和幂等重放不覆盖人工记录。批量质量数量使用完整筛选元数据,未采集原文不伪造快照,延迟旧扫描不回退新输入。 验证:全仓 make verify 退出码0,Go656及前端253通过;五包竞态、源/组织/质量隔离PG、真实只读源和隔离网页读回复核通过。默认91个可选集成跳过不计通过。未接AI模型,不写DobotAI源库,未推送、未合并、未部署。
51 lines
1.4 KiB
Go
51 lines
1.4 KiB
Go
package dobotaiops
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"time"
|
|
)
|
|
|
|
type QualityScope struct {
|
|
Keys []QualityKey
|
|
AsOf time.Time
|
|
}
|
|
|
|
func (c *Client) ReadQualityScope(ctx context.Context, query RecordQuery) (QualityScope, error) {
|
|
if err := c.validateQueryWindow(query.Window); err != nil {
|
|
return QualityScope{}, err
|
|
}
|
|
if query.Cursor != "" {
|
|
return QualityScope{}, ErrInvalidQuery
|
|
}
|
|
pattern, err := recordKeywordPattern(query.Keyword)
|
|
if err != nil {
|
|
return QualityScope{}, err
|
|
}
|
|
result := QualityScope{Keys: []QualityKey{}}
|
|
err = c.withReadOnlyTx(ctx, func(ctx context.Context, q querier) error {
|
|
if q.QueryRow(ctx, "SELECT transaction_timestamp()").Scan(&result.AsOf) != nil {
|
|
return ErrUnavailable
|
|
}
|
|
rows, err := q.Query(ctx, recordsBaseSQL+` SELECT id,quality_hash,strpos(payload->>'answer',$5)>0,(payload->'source_coverage')::text FROM records WHERE `+recordFilterSQL+` ORDER BY id LIMIT 5001`, query.Window.TenantKey, query.Window.Start, query.Window.End, pattern, noPublishedMarker)
|
|
if err != nil {
|
|
return ErrUnavailable
|
|
}
|
|
defer rows.Close()
|
|
for rows.Next() {
|
|
var key QualityKey
|
|
var raw string
|
|
if rows.Scan(&key.ID, &key.InputHash, &key.Marker, &raw) != nil || json.Unmarshal([]byte(raw), &key.Source) != nil {
|
|
return ErrUnavailable
|
|
}
|
|
if len(result.Keys) >= 5000 {
|
|
return ErrInvalidQuery
|
|
}
|
|
key.ObservedAt = result.AsOf
|
|
result.Keys = append(result.Keys, key)
|
|
}
|
|
return rows.Err()
|
|
})
|
|
return result, err
|
|
}
|