Skip to content

refactor(context): extract embed_prepass_dyn to eliminate inline duplication#4670

Merged
bug-ops merged 1 commit into
mainfrom
4646-embed-prepass-dedup
May 29, 2026
Merged

refactor(context): extract embed_prepass_dyn to eliminate inline duplication#4670
bug-ops merged 1 commit into
mainfrom
4646-embed-prepass-dedup

Conversation

@bug-ops

@bug-ops bug-ops commented May 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • Extracted private embed_prepass_dyn helper in crates/zeph-context/src/fidelity.rs to eliminate ~35 lines of duplicated concurrent embed pipeline logic between embed_prepass<F> and FidelityScorer::score_and_apply
  • Used two lightweight adapters (ClosureEmbed<F>, ProviderEmbed<'p>) to bridge the 'static bound gap without changing public API
  • Unified behavior: warn on embed_concurrency == 0, consistent warn for both embed errors and timeouts, single span name context.fidelity.embed_prepass

Test plan

  • cargo +nightly fmt --check — clean
  • cargo clippy --workspace --features desktop,ide,server,chat,pdf,scheduler -- -D warnings — 0 warnings
  • RUSTFLAGS="-D warnings" cargo check --workspace --all-targets --features desktop,ide,server,chat,pdf,scheduler --locked — clean
  • cargo nextest run --workspace --lib --bins — 10304/10304 PASS
  • cargo test --doc -p zeph-context — 23/23 PASS
  • No behavioral drift — all 9 embed_prepass_* tests and 25+ score_and_apply tests pass unchanged

Closes #4646

@github-actions github-actions Bot added rust Rust code changes refactor Code refactoring without functional changes size/M Medium PR (51-200 lines) labels May 29, 2026
@bug-ops bug-ops enabled auto-merge (squash) May 29, 2026 19:54
@bug-ops bug-ops force-pushed the 4646-embed-prepass-dedup branch from d414cf5 to 529f707 Compare May 29, 2026 19:54
…ication

The concurrent embed pipeline (~35 lines: filter, truncate, buffer_unordered,
timeout, error handling) was duplicated between the public embed_prepass<F>
and the inline block inside FidelityScorer::score_and_apply.

Introduce private embed_prepass_dyn that accepts &dyn LlmProviderDyn directly,
with two lightweight adapters (ClosureEmbed<F>, ProviderEmbed<'p>) so both
callers delegate to a single implementation.

Unified behavior:
- warn on embed_concurrency == 0 now emitted once in the shared helper
- both error and timeout arms use tracing::warn consistently
- span name context.fidelity.embed_prepass used in all callers

Closes #4646
@bug-ops bug-ops force-pushed the 4646-embed-prepass-dedup branch from 529f707 to ba56946 Compare May 29, 2026 20:02
@bug-ops bug-ops merged commit 3d0d193 into main May 29, 2026
32 checks passed
@bug-ops bug-ops deleted the 4646-embed-prepass-dedup branch May 29, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Code refactoring without functional changes rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(context): inline embed pre-pass in score_and_apply duplicates embed_prepass logic

1 participant