Add optional Ollama-backed semantic sidecar reranking (lexical-first, additive)#29
Add optional Ollama-backed semantic sidecar reranking (lexical-first, additive)#29HiveForensicsAI wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b8ac727f6d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| function shouldRerankWithSemantic(pack: Pack, opts: ResolvedSemanticOpts, confidence: number): boolean { | ||
| if (!opts.enabled || opts.mode !== "rerank") return false; | ||
| if (!pack.semantic) return false; | ||
| if (!pack.semantic && !opts.sidecar) return false; |
There was a problem hiding this comment.
Wire semantic.sidecarPath into rerank eligibility
query() accepts semantic.sidecarPath, but semantic rerank is gated by if (!pack.semantic && !opts.sidecar) return false and the function never resolves sidecarPath into opts.sidecar. In practice, callers that pass only sidecarPath (with semantic.enabled, queryEmbedding, and even force) silently fall back to lexical-only retrieval, so the new option does not actually enable sidecar reranking.
Useful? React with 👍 / 👎.
| namespace: pack.namespaces?.[r.blockId] ?? undefined, | ||
| evidence: { | ||
| retrieval: retrievalMode, | ||
| lexicalScore: r.score, |
There was a problem hiding this comment.
Preserve pre-rerank score in evidence.lexicalScore
When semantic reranking runs, prelim is replaced with blended/semantic scores, but evidence.lexicalScore is still assigned from r.score here. That means hybrid results report reranked scores as "lexical" scores, which corrupts explainability/telemetry and any downstream logic that uses lexical confidence when semantic rerank is enabled.
Useful? React with 👍 / 👎.
Motivation
.knolopack format.Description
packages/core/src/semantic/withtypes.ts,cosine.ts,sidecar.ts,provider.ts, andrerank.tsimplementing provider interfaces, normalization/cosine utilities, sidecar serialization/validation, and lexical-topN reranking/blending.query()API and validation to acceptsemanticoptions (sidecar/provider/topN/minLexConfidence/blend/etc.) and attached per-hitevidencefields (retrieval,lexicalScore,semanticScore,blendedScore,modelId) while preserving the default lexical-first behavior.@knolo/semantic-ollamathat implementsEmbeddingProviderwith batching, timeouts, and clear errors, and added CLI sidecar commands in theknolobinary:semantic:index,semantic:inspect, andsemantic:validate.Testing
npm run build --workspace @knolo/coreandnpm run build --workspace @knolo/semantic-ollamaand both builds succeeded.npm run test --workspace @knolo/coreand all tests passed (includingtestSemanticSidecarRerankAndValidationandtestCosineHelpers).npm run test --workspace @knolo/cliand all CLI tests passed (includingsemantic:validatesuccess/failure cases).knolo semantic:index/semantic:inspect/semantic:validateflows via unit tests that exercise sidecar creation/inspection/validation.Codex Task