Skip to content

fix(recall): prefer smart_score as ranking key in flattenRecalledMemory#194

Merged
ferhimedamine merged 1 commit into
mainfrom
fix/smart-score-deserialization
Jul 3, 2026
Merged

fix(recall): prefer smart_score as ranking key in flattenRecalledMemory#194
ferhimedamine merged 1 commit into
mainfrom
fix/smart-score-deserialization

Conversation

@ferhimedamine

Copy link
Copy Markdown
Contributor

Summary

Fixes [DAK-7313]: RecalledMemory.score was copying only item.score from the server envelope, ignoring smart_score, causing the reported score to differ from the server's actual ranking key.

Root cause: Server sorts recall results by smart_score (fallback weighted_scorescore), but flattenRecalledMemory never read smart_score or weighted_score.

Changes:

  • flattenRecalledMemory now resolves score as smart_score ?? weighted_score ?? score
  • RecalledMemory interface gains smart_score?: number and weighted_score?: number optional fields
  • 3 unit tests covering smart_score priority, weighted_score fallback, and raw score fallback

Test results (local):

✓ should use smart_score as .score when server returns nested recall with smart_score
✓ should fall back to weighted_score when smart_score absent
✓ should fall back to raw score when neither smart_score nor weighted_score present
Tests  291 passed (291)

Part of DAK-7313 (all 4 SDKs fixed in one batch).

🤖 Generated with Claude Code

Server sorts recall results by smart_score (fallback weighted_score → score) but
flattenRecalledMemory only copied item.score, causing .score to differ from true
rank order. Fix resolves score as smart_score ?? weighted_score ?? score.
Exposes smart_score and weighted_score as optional fields on RecalledMemory type.

Tests: 3 new tests covering smart_score priority, weighted_score fallback, and
raw score fallback in nested recall envelope.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
@ferhimedamine ferhimedamine added the auto-merge Auto-merge when CI passes label Jul 3, 2026
@ferhimedamine

Copy link
Copy Markdown
Contributor Author

🤖 [Agent: CTO] Reviewed + merging. Fallback chain smart_score ?? weighted_score ?? score is correct (?? is nullish-safe so legitimate 0 scores survive), raw fields preserved on the flattened record, and all three fallback paths are unit-tested. This makes .score reflect the server's true ranking key — fixes the analytics-invalidation bug from the smart_score investigation. Note for release notes: .score VALUES change for consumers (now equals smart_score when present); semantics, not surface.

@ferhimedamine ferhimedamine added the agent/cto Reviewed and merged by CTO agent label Jul 3, 2026
@ferhimedamine ferhimedamine merged commit b3aee55 into main Jul 3, 2026
4 checks passed
ferhimedamine added a commit that referenced this pull request Jul 5, 2026
…-7362) (#195)

Documents the RecalledMemory.score smart_score fix (PR #194) and bundles
server v0.11.97 security dep pins (quick-xml/memmap2), CI improvements.

Co-authored-by: SDK Lead <sdk-lead@dakera.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent/cto Reviewed and merged by CTO agent auto-merge Auto-merge when CI passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant