Skip to content

fix(agentflare-store): embedding write/read endianness mismatch - #256

Merged
getappz merged 1 commit into
masterfrom
fix/agentflare-store-embedding-endianness
Jul 18, 2026
Merged

fix(agentflare-store): embedding write/read endianness mismatch#256
getappz merged 1 commit into
masterfrom
fix/agentflare-store-embedding-endianness

Conversation

@getappz

@getappz getappz commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

Test plan

  • cargo test -p agentflare-store — 33/33 passing, including new embedding_bytes_are_stored_little_endian regression test (asserts the actual on-disk byte layout, not just the round trip)
  • cargo build --workspace --all-features — clean

Summary by CodeRabbit

  • Bug Fixes

    • Improved embedding storage consistency by ensuring values use a standardized byte order.
    • Prevented potential compatibility issues when reading stored embedding data across different system architectures.
  • Tests

    • Added coverage verifying that embedding bytes are stored in the expected format.

doc_set_embedding wrote via bytemuck::cast_slice (native-endian) while
doc_get_embedding/doc_vec_search read back with hardcoded f32::from_le_bytes.
Matched by accident on little-endian hosts, not guaranteed by the code.
Flagged in item #148's review, never applied.

Write side now builds bytes explicitly via f32::to_le_bytes, matching the
read side. Adds a regression test asserting the on-disk byte layout, not
just the round trip (which passed before too, on any LE host).
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5a689999-105b-4c1f-aba5-726b34fc37d1

📥 Commits

Reviewing files that changed from the base of the PR and between 6cda051 and ba0ea17.

📒 Files selected for processing (1)
  • crates/agentflare-store/src/documents.rs

📝 Walkthrough

Walkthrough

Embedding persistence now converts each f32 to explicit little-endian bytes instead of relying on native-endian slice casting. A regression test verifies the raw bytes stored in store_docs_vec.

Changes

Embedding storage

Layer / File(s) Summary
Embedding serialization and regression test
crates/agentflare-store/src/documents.rs
doc_set_embedding writes explicit little-endian bytes for each embedding value, and a regression test verifies the persisted byte representation.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly names the core fix: correcting embedding write/read endianness in agentflare-store.
Description check ✅ Passed The description covers the summary and test plan; the reviewer notes section is missing, but the PR is still mostly complete.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/agentflare-store-embedding-endianness

Comment @coderabbitai help to get the list of available commands.

@getappz
getappz merged commit ab3b0b5 into master Jul 18, 2026
18 checks passed
@getappz
getappz deleted the fix/agentflare-store-embedding-endianness branch July 18, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant