fix: persist coverage reference count
This commit is contained in:
@@ -31,13 +31,13 @@ func (s *Store) SaveCoverageDecision(ctx context.Context, d coverage.Decision) e
|
||||
|
||||
var persistedDecisionID string
|
||||
err = tx.QueryRow(ctx, `INSERT INTO coverage_decisions
|
||||
(id, tenant_key, channel, turn_id, evaluator_version, verdict, reason_code, top_score)
|
||||
VALUES($1,$2,$3,$4,$5,$6,$7,$8)
|
||||
(id, tenant_key, channel, turn_id, evaluator_version, verdict, reason_code, reference_count, top_score)
|
||||
VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9)
|
||||
ON CONFLICT (tenant_key, channel, turn_id)
|
||||
DO UPDATE SET id=coverage_decisions.id
|
||||
RETURNING id`,
|
||||
decisionID, d.TenantKey, d.Channel, d.TurnID,
|
||||
d.EvaluatorVersion, d.Verdict, d.ReasonCode, d.TopScore).Scan(&persistedDecisionID)
|
||||
d.EvaluatorVersion, d.Verdict, d.ReasonCode, d.ReferenceCount, d.TopScore).Scan(&persistedDecisionID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("coverage insert decision: %w", err)
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ func TestCoverageRepoInsertsIntoCoverageDecisions(t *testing.T) {
|
||||
|
||||
requiredCols := []string{
|
||||
"id", "tenant_key", "channel", "turn_id",
|
||||
"evaluator_version", "verdict", "reason_code", "top_score",
|
||||
"evaluator_version", "verdict", "reason_code", "reference_count", "top_score",
|
||||
}
|
||||
upper := strings.ToUpper(found)
|
||||
for _, col := range requiredCols {
|
||||
@@ -174,6 +174,9 @@ func TestCoverageRepoSavesTenantChannelTurnScope(t *testing.T) {
|
||||
if !strings.Contains(src, "d.TenantKey") || !strings.Contains(src, "d.Channel") || !strings.Contains(src, "d.TurnID") {
|
||||
t.Error("SaveCoverageDecision must use d.TenantKey, d.Channel, d.TurnID for tenant/channel/turn scope")
|
||||
}
|
||||
if !strings.Contains(src, "d.ReferenceCount") {
|
||||
t.Error("SaveCoverageDecision must persist d.ReferenceCount")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCoverageRepoNilSafe(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user