Fix semantic sidecarPath rerank eligibility and evidence lexical score correctness#30
Conversation
7a89155
into
codex/implement-optional-local-semantic-reranking
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f4a87c17cd
ℹ️ 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".
| if (raw.startsWith("{")) { | ||
| return parseSidecar(raw); |
There was a problem hiding this comment.
Validate parsed sidecar payload before reranking
If semantic.sidecarPath contains JSON that passes parseSidecar's minimal checks but is missing required fields (for example, no blocks array), this function still returns it and semantic reranking later crashes with an opaque Cannot read properties of undefined (reading 'find') from rerankCandidates. This is reproducible whenever semantic rerank is enabled/forced with such input, and it should fail fast here with a clear query(...) validation error instead of a downstream TypeError.
Useful? React with 👍 / 👎.
Motivation
semantic.sidecarPathactually enables semantic reranking when callers provide only a sidecar (no embeddedpack.semantic).evidence.lexicalScoreis not overwritten by post-rerank blended scores, maintaining explainability and telemetry integrity.sidecarPathinputs to avoid silent no-ops from malformed inputs.Description
semantic.sidecarPathinto runtime option resolution by addingresolveSemanticSidecarand using it to populatesemanticOpts.sidecar, allowing reranks to proceed whenpack.semanticis absent; this supports inline JSON anddata:URLs and includes adecodeBase64helper. (modifiedpackages/core/src/query.ts)semantic.sidecarPathtype invalidateSemanticQueryOptionsto surface invalid callers early. (modifiedpackages/core/src/query.ts)originalLexicalScoresbefore any semantic rerank and use those preserved values forevidence.lexicalScore, whilesemanticScoreandblendedScorecontinue to come from rerank outputs. (modifiedpackages/core/src/query.ts)semantic.sidecarPath(instead of passingsemantic.sidecar) and add two regression tests: one verifying evidence score semantics after rerank and one ensuring lexical-only evidence remains unchanged. (modifiedpackages/core/scripts/test.mjs)Testing
npm run test --workspace @knolo/core. (all tests executed)All tests passed.)packages/core/scripts/test.mjs.Codex Task