Skip to content

Commit 43ccd0e

Browse files
GottZclaude
andcommitted
fix(dream): quality score confidence filter + graph cleanup
UpdateQualityScore now only counts links with confidence >= 0.5, preventing noise links from inflating scores and triggering false canonical promotions. Cleanup: deleted 151 links below 0.5 confidence (43% false positive rate per audit). Recalculated all quality scores. Demoted 54 blocks from canonical back to knowledge (quality_score dropped below 0.8 threshold). Before: 350 links, 92 canonical, avg confidence 0.47 After: 199 links, 38 canonical, avg confidence 0.72 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3493d6b commit 43ccd0e

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

go/internal/dream/dream.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,17 +295,18 @@ func CleanupDanglingLinks(ctx context.Context, pool *pgxpool.Pool) (int, error)
295295

296296
// UpdateQualityScore adjusts a block's quality_score based on its dream link profile.
297297
// Formula: min(1.0, base + inbound_factor + outbound_factor + diversity_bonus).
298-
// Blocks without links keep their current score.
298+
// Only counts links with confidence >= 0.5 to prevent noise from inflating scores.
299+
// Blocks without qualifying links keep their current score.
299300
func UpdateQualityScore(ctx context.Context, pool *pgxpool.Pool, blockID string) error {
300301
_, err := pool.Exec(ctx,
301302
`UPDATE context_blocks SET quality_score = LEAST(1.0,
302303
0.3
303-
+ 0.1 * LEAST((SELECT count(*) FROM context_dream_links WHERE target_block_id = $1), 5)
304-
+ 0.05 * LEAST((SELECT count(*) FROM context_dream_links WHERE source_block_id = $1), 5)
305-
+ 0.15 * LEAST((SELECT count(DISTINCT relationship) FROM context_dream_links WHERE source_block_id = $1 OR target_block_id = $1), 4)
304+
+ 0.1 * LEAST((SELECT count(*) FROM context_dream_links WHERE target_block_id = $1 AND confidence >= 0.5), 5)
305+
+ 0.05 * LEAST((SELECT count(*) FROM context_dream_links WHERE source_block_id = $1 AND confidence >= 0.5), 5)
306+
+ 0.15 * LEAST((SELECT count(DISTINCT relationship) FROM context_dream_links WHERE (source_block_id = $1 OR target_block_id = $1) AND confidence >= 0.5), 4)
306307
)
307308
WHERE id = $1
308-
AND EXISTS (SELECT 1 FROM context_dream_links WHERE source_block_id = $1 OR target_block_id = $1)`,
309+
AND EXISTS (SELECT 1 FROM context_dream_links WHERE (source_block_id = $1 OR target_block_id = $1) AND confidence >= 0.5)`,
309310
blockID,
310311
)
311312
return err

0 commit comments

Comments
 (0)