Skip to content

Fix semantic sidecarPath rerank eligibility and evidence lexical score correctness#30

Merged
HiveForensicsAI merged 1 commit intocodex/implement-optional-local-semantic-rerankingfrom
codex/fix-correctness-issues-in-semantic-rerank-feature
Mar 18, 2026
Merged

Fix semantic sidecarPath rerank eligibility and evidence lexical score correctness#30
HiveForensicsAI merged 1 commit intocodex/implement-optional-local-semantic-rerankingfrom
codex/fix-correctness-issues-in-semantic-rerank-feature

Conversation

@HiveForensicsAI
Copy link
Copy Markdown
Contributor

Motivation

  • Ensure semantic.sidecarPath actually enables semantic reranking when callers provide only a sidecar (no embedded pack.semantic).
  • Preserve original lexical retrieval scores so evidence.lexicalScore is not overwritten by post-rerank blended scores, maintaining explainability and telemetry integrity.
  • Add minimal validation and parsing for sidecarPath inputs to avoid silent no-ops from malformed inputs.

Description

  • Wire semantic.sidecarPath into runtime option resolution by adding resolveSemanticSidecar and using it to populate semanticOpts.sidecar, allowing reranks to proceed when pack.semantic is absent; this supports inline JSON and data: URLs and includes a decodeBase64 helper. (modified packages/core/src/query.ts)
  • Validate semantic.sidecarPath type in validateSemanticQueryOptions to surface invalid callers early. (modified packages/core/src/query.ts)
  • Preserve pre-rerank lexical scores by capturing originalLexicalScores before any semantic rerank and use those preserved values for evidence.lexicalScore, while semanticScore and blendedScore continue to come from rerank outputs. (modified packages/core/src/query.ts)
  • Update the sidecar rerank test to exercise semantic.sidecarPath (instead of passing semantic.sidecar) and add two regression tests: one verifying evidence score semantics after rerank and one ensuring lexical-only evidence remains unchanged. (modified packages/core/scripts/test.mjs)
  • Changes are intentionally localized to the semantic rerank path and tests to avoid broad refactors.

Testing

  • Ran the package test suite with npm run test --workspace @knolo/core. (all tests executed)
  • Result: All tests passed. (output: All tests passed.)
  • New/updated tests include sidecar-path-only rerank coverage and evidence correctness checks for hybrid and lexical-only flows in packages/core/scripts/test.mjs.

Codex Task

@HiveForensicsAI HiveForensicsAI merged commit 7a89155 into codex/implement-optional-local-semantic-reranking Mar 18, 2026
0 of 2 checks passed
@HiveForensicsAI HiveForensicsAI deleted the codex/fix-correctness-issues-in-semantic-rerank-feature branch March 18, 2026 15:21
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +457 to +458
if (raw.startsWith("{")) {
return parseSidecar(raw);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@HiveForensicsAI HiveForensicsAI added enhancement New feature or request bug Something isn't working and removed codex labels Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants