fix(sdk): decode FffGrepMatch and FffScore with the real C layout in fff-node and fff-bun - #891
Conversation
…fff-node and fff-bun
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (9)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change adds C accessors for ChangesScore and grep FFI
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to The supplied evidence identifies no remaining issue that should delay merging. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The changed interfaces expose score data already present in native search results. The SDK changes align decoding with the native layout, and no new security boundary or sensitive-data path was identified. Downstream compatibility and runtime behavior remain partly unverified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes #888.
Both SDKs read
FffGrepMatch/FffScoreby hand-declared layout, and both drifted from the#[repr(C)]structs incrates/fff-c/src/ffi_types.rs. Rust never writes struct padding, so the misread fields came back as whatever the allocator left there — dirty on glibc most of the time, zero on macOS, so it only showed on Linux.fuzzy_scoredeclaredDataType.U32for a Cu16, shiftinghas_fuzzy_score/is_binary/is_definition2 bytes into padding. Plain-text hits came backisBinary: true; consumers filtering on it silently dropped results.path_alignment_bonus(in the C struct since feat: Correct bonuses for actual path prefix #372) missing from the decoder, soexactMatchwas read from its low byte —falseon everyexact_filenamematch.SC_EXACT = 32pointed atpath_alignment_bonus.Score.pathAlignmentBonusis now exposed inpackages/shared/fff-api.tsfor both SDKs.fff_score_get_*accessors tofff-c(FffScorewas the only exported struct without them); header regenerated.exactMatch === trueon exact filename hits, noisBinary/isDefinition/fuzzyScoreon plain-text grep, and u16-rangefuzzyScorein fuzzy mode — each fails againstmain.Decoding stays a single struct read per element; no latency change.
Summary by CodeRabbit
New Features
Bug Fixes