Skip to content

chore(retrieval,history,recall): review fixes and test coverage [skip-tag]#41

Merged
lIang70 merged 2 commits into
mainfrom
chore/retrieval-history-recall-review-fixes
Apr 24, 2026
Merged

chore(retrieval,history,recall): review fixes and test coverage [skip-tag]#41
lIang70 merged 2 commits into
mainfrom
chore/retrieval-history-recall-review-fixes

Conversation

@lIang70

@lIang70 lIang70 commented Apr 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Apply review fixes across sdk/retrieval, sdk/history, and sdk/recall, plus the supporting tests. This is a maintenance batch with no release-relevant API changes — [skip-tag] is set in the title so auto-tag.yml's patch bumper does not roll a tag for this merge.

retrieval — high priority correctness

  • HybridShortCircuit forwards Debug. Previously SearchRequest.Debug was dropped on the native-hybrid path; backends that honour Capabilities.Debug now receive it and the pipeline merges their SearchExecution into the response so callers observe one consistent explanation regardless of which path ran.
  • Stable lane order. Pipeline.Run emits SearchExecution.Lanes by well-known LaneKey first, then lexical, so dashboards / golden tests don't flake from Go map iteration order.
  • pickFinalish no longer aliases Reranked / Fused. Lifting now shallow-copies, so in-place rescoring stages (BM25Boost, TimeDecay, EntityBoost, ...) cannot retroactively corrupt earlier snapshots.
  • BM25Boost uses ±Inf seeds for clearer min/max semantics.
  • MemoryIndex.Search drops MinScore on the hybrid (RRF) branch. RRF scores live on a different scale than raw BM25/cosine; SearchRequest.MinScore now documents the single-modality contract. Hybrid filtering should use pipeline.ScoreThreshold.
  • Removed dead liftRecall short-circuit guard; LTM factory expresses the "BM25 is a boost, not a recall expander" rule via a clearer addBM25Boost local.

retrieval — small but visible

  • normalizeJSONish coerces every numeric kind to float64Filter.Eq{"score": 5} now matches metadata decoded as float64(5).
  • PartialError reports only failing rows; empty form is now stable.
  • journal.Wrap projects the inner backend's optional sub-interfaces (DocGetter / Filterable / DeletableByFilter / Droppable / Iterable / Snapshottable / Hybridable / Vectorizable) and fans bulk DeleteByFilter / Drop into per-doc OpDelete events so the audit log stays complete.
  • EmbedQuery cache gains MaxEntries (default 1024) with TTL-aware eviction; -1 disables caching.
  • Entity recall lane scores by overlap count (was constant 1.0), giving WeightedFusion / RRF a real signal.
  • stages_rerank.go switches to math.Sqrt; the hand-rolled Newton iteration is gone.
  • types.go documents every Filter field and the reserved _content key.
  • sdkx/retrieval/{postgres,sqlite}: List doc notes the in-memory scan cost and points bulk export at Iterate; the new offset >= len(all) guard short-circuits stale page tokens.

history / recall

  • history.{compactor,store,tools,archive,doc} — same review pass: refines compactor coordination, adds dedicated coordinator / token / tools tests, folds deprecated knobs into a focused deprecated.go surface.
  • recall.{recall,save,sweeper,merger,memory,telemetry} — introduces namespace_registry as the single authority for ns → backend lookup, hardens save / sweep semantics, surfaces telemetry counters.
  • Adds regression tests for explain output, save context, sweep, and merger so the contract surface is locked in.

Tests added

  • retrieval: errors_test.go, filter_match_test.go, explain_test.go, plus pipeline/{stages_boost,stages_query,pipeline}_test.go additions for lane-order stability, hybrid Debug forwarding, and pickFinalish isolation; journal/wrap_test.go covers sub-interface delegation and bulk-delete journaling.
  • history: coordinator_test.go, store_test.go, summary_store_test.go, token_test.go, tools_test.go.
  • recall: merger_test.go, namespace_registry_test.go, recall_explain_test.go, save_context_test.go, sweeper_test.go, test_helpers_regression_test.go.

Test plan

  • go vet ./sdk/... ./sdkx/...
  • go test ./sdk/... ./sdkx/...
  • CI green

Made with Cursor

lIang70 added 2 commits April 24, 2026 15:17
…-tag]

Apply fixes surfaced during a focused review of `sdk/retrieval`, plus the
parallel `sdk/history` and `sdk/recall` follow-ups that share the same
explanation / capability surface. No release-relevant API changes — kept
under [skip-tag] so the per-module patch bumper does not roll a tag for
this maintenance batch.

retrieval (high-priority correctness)
- HybridShortCircuit now forwards SearchRequest.Debug into HybridRequest
  and merges the backend's SearchExecution into the pipeline's response
  so callers observe one consistent explanation regardless of the
  short-circuit path.
- Pipeline.Run emits SearchExecution.Lanes in a deterministic order
  (well-known LaneKeys first, then lexical) to keep dashboards / golden
  tests stable across runs.
- pickFinalish now shallow-copies when lifting Reranked/Fused into Final
  so downstream in-place mutators (BM25Boost, TimeDecay, EntityBoost,
  ...) cannot retroactively corrupt the snapshots the caller can still
  inspect.
- BM25Boost initialises min/max with +/-Inf for clearer intent and
  removes the i==0 special case.
- MemoryIndex.Search drops MinScore on the hybrid (RRF) branch — RRF
  scores live on a different scale than raw BM25/cosine — and
  SearchRequest.MinScore documents the single-modality contract.
- liftRecall sheds dead ShortCircuit guard; LTM factory expresses the
  "BM25 is a boost, not a recall expander" rule via an addBM25Boost
  local for readability.

retrieval (small but visible)
- normalizeJSONish coerces every numeric kind to float64 so
  Filter.Eq{"score": 5} matches metadata decoded as float64(5).
- PartialError reports only failing rows and emits a stable empty form.
- journal.Wrap exposes the inner backend's optional sub-interfaces
  (DocGetter / Filterable / DeletableByFilter / Droppable / Iterable /
  Snapshottable / Hybridable / Vectorizable) and fans bulk
  DeleteByFilter / Drop into per-doc OpDelete events so the audit log
  stays complete.
- EmbedQuery cache gains MaxEntries (default 1024) with TTL-aware
  eviction; pass -1 to disable caching outright.
- Entity recall lane scores by overlap count instead of constant 1.0,
  giving WeightedFusion / RRF a real signal.
- pipeline/stages_rerank.go switches to math.Sqrt; rerank stages drop
  the hand-rolled Newton iteration.
- types.go documents every Filter field and the reserved "_content" key.
- sdkx/retrieval/{postgres,sqlite}: List doc notes the in-memory scan
  cost and points bulk export at Iterate; the new offset >= len(all)
  guard short-circuits stale page tokens.

history / recall
- history.{compactor,store,tools,archive,doc}: same review pass —
  refines compactor coordination, adds dedicated coordinator /
  token / tools tests, and folds deprecated knobs into a focused
  deprecated.go surface.
- recall.{recall,save,sweeper,merger,memory,telemetry}: introduces
  namespace_registry as the single authority for ns -> backend lookup,
  hardens save / sweep semantics, and surfaces telemetry counters.
- Adds regression tests for explain output, save context, sweep, and
  merger so the contract surface is locked in.

tests
- New: retrieval/{errors,filter_match,explain}_test.go,
  pipeline/{stages_boost,stages_query,pipeline}_test.go additions for
  lane-order stability, hybrid Debug forwarding, and pickFinalish
  isolation; journal/wrap_test.go covers sub-interface delegation and
  bulk-delete journaling.
- New: history/{coordinator,store,summary_store,token,tools}_test.go;
  recall/{merger,namespace_registry,recall_explain,save_context,
  sweeper,test_helpers_regression}_test.go.

Verified: go vet ./sdk/... ./sdkx/... and go test ./sdk/... ./sdkx/...
both pass on the work tree.

Made-with: Cursor
…our [skip-tag]

The test's clock closure captured a local `now` variable that the
recall worker goroutine read while the test goroutine wrote it
between Save calls, which CI's -race build flagged. Wrap the value
in atomic.Pointer[time.Time] so reads from the worker and writes
from the test are synchronised.

Made-with: Cursor
@lIang70
lIang70 merged commit 0a21508 into main Apr 24, 2026
9 checks passed
@lIang70
lIang70 deleted the chore/retrieval-history-recall-review-fixes branch April 24, 2026 07:25
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