Skip to content

fix(recall): prefer smart_score as ranking key in RecalledMemory#139

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

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

Conversation

@ferhimedamine

Copy link
Copy Markdown
Contributor

Summary

Fixes [DAK-7313]: RecalledMemory.Score was reading only the raw score field, 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 recalledMemoryWire only had a Score field and UnmarshalJSON set r.Score = wire.Score unconditionally.

Changes:

  • recalledMemoryWire gains SmartScore *float32 and WeightedScore *float32
  • RecalledMemory gains SmartScore *float32 and WeightedScore *float32 exported fields
  • UnmarshalJSON resolves Score as smart_score ?? weighted_score ?? score
  • 4 unit tests covering all fallback paths and flat-format decode

Test results (local, via Docker golang:1.23):

--- PASS: TestRecalledMemory_SmartScorePriority (0.00s)
--- PASS: TestRecalledMemory_WeightedScoreFallback (0.00s)
--- PASS: TestRecalledMemory_RawScoreFallback (0.00s)
--- PASS: TestRecalledMemory_FlatFormatScore (0.00s)
PASS ok github.com/dakera-ai/dakera-go 0.006s

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

🤖 Generated with Claude Code

…rshalJSON

Server sorts recall results by smart_score (fallback weighted_score → score) but
recalledMemoryWire only decoded the raw score field, causing Score to differ from
actual rank order. Fix adds SmartScore and WeightedScore to wire struct and
RecalledMemory, resolving Score = smart_score ?? weighted_score ?? score.

Tests: 4 unit tests covering all fallback paths and flat-format decode.

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. Pointer-typed optional wire fields with explicit switch fallback (smart_score → weighted_score → score) is idiomatic and preserves flat-format compatibility; all three paths unit-tested. Same release-note caveat as the sibling SDK PRs: .score values now track the server's actual ranking key.

@ferhimedamine ferhimedamine added the agent/cto CTO agent reviewed label Jul 3, 2026
@ferhimedamine ferhimedamine merged commit 3106fc0 into main Jul 3, 2026
6 checks passed
ferhimedamine added a commit that referenced this pull request Jul 5, 2026
Documents v0.11.99 RecalledMemory.Score smart_score fix (PR #139) and
v0.11.100 server v0.11.97 security dep pins (quick-xml/memmap2), CI improvements.

Co-authored-by: Dakera CTO <cto@dakera.ai>
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 CTO agent reviewed auto-merge Auto-merge when CI passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant