Skip to content

feat(lip): wire up stream_context, query_expansion, explain_match#212

Open
SimplyLiz wants to merge 1 commit intodevelopfrom
feat/lip-utilization-9.1
Open

feat(lip): wire up stream_context, query_expansion, explain_match#212
SimplyLiz wants to merge 1 commit intodevelopfrom
feat/lip-utilization-9.1

Conversation

@SimplyLiz
Copy link
Copy Markdown
Owner

Summary

Addresses the correctness gaps and under-utilisation findings from the CKB 9.1.0 / LIP integration review. All four items landed in one PR because the utilisation wins share plumbing (handshake + `lipSupports` gate) that's cheaper to ship together.

Correctness (both flagged by the review):

  • `lipFileURI` now normalises absolute paths and `file://`-prefixed inputs instead of producing `file:///repo//abs/path` if a backend ever returns one (`internal/query/lip_ranker.go`).
  • `Handshake` runs once on startup; `supported_messages` is stashed on the Engine so we can gate v2.0+ calls on the actual daemon capabilities.

Utilisation (the top-3 high-ROI wins from the review):

  1. `stream_context` → `explainFile.facts.related` — LIP ranks symbols relevant to the whole file within a 2048-token budget; CKB returns the top 10 with per-symbol relevance + token cost. First streaming RPC in the LIP client — new transport (`internal/lip/stream_context.go`) reads N `symbol_info` frames + `end_stream` terminator.
  2. `query_expansion` → `SearchSymbols` FTS path — short queries (≤ 2 tokens) get up to 5 related terms appended before FTS5. "auth" → "authenticate authorization principal…". Longer queries pass through.
  3. `explain_match` → semantic fallback hits — `SemanticSearchWithLIPExplained` attaches up to 2 ranked chunks per hit (top 5 hits, line ranges + text + score). Bare file URLs become auditable citations.

All three gate on `lipSupports()` so older daemons fall through cleanly instead of eating round-trips.

Test plan

  • `go test ./internal/lip/... ./internal/query/...` — all green
  • `go build ./...` + `go vet ./...`
  • New unit tests for `StreamContext`: happy path, daemon-down, error-frame abort
  • Manual against a running LIP 2.1.0 daemon: `ckb explainFile internal/query/engine.go` — confirm `facts.related` populated
  • Manual: `ckb searchSymbols auth` — confirm expansion fires (log shows expanded query string)
  • Manual: force a LIP semantic fallback and confirm each hit carries `semanticEvidence` chunks

🤖 Generated with Claude Code

Closes the correctness and utilisation gaps found in the CKB 9.1.0
review.

Correctness:
- lipFileURI now handles absolute paths and already-prefixed file://
  URIs instead of naively joining them with repoRoot.
- Handshake runs once on engine startup; its supported_messages list
  drives Engine.lipSupports(), the gate for v2.0+ RPCs against older
  daemons. Daemon version + supported_messages length are logged.

Utilisation (three high-ROI LIP RPCs we were not using):

- stream_context (v2.1) → explainFile now attaches a ranked list of
  semantically-related symbols (top 10 within a 2048-token budget) to
  the response's facts.related field. New streaming transport in
  internal/lip/stream_context.go reads N symbol_info frames + the
  end_stream terminator — the previous LIP client was unary-only.

- query_expansion (v1.6) → SearchSymbols expands ≤ 2-token queries with
  up to 5 related terms before FTS5. Recovers recall on
  vocabulary-mismatch misses without touching precision on compound
  queries.

- explain_match (v2.0) → SemanticSearchWithLIPExplained attaches up to
  two ranked chunks per semantic hit (top 5 hits, line ranges + text +
  score), letting the caller cite specific lines instead of a bare
  file URL.

All three are gated on the handshake's supported_messages so clients
talking to older daemons fall through to the legacy paths cleanly.

Tests: unit coverage for StreamContext happy path, daemon-down, and
error-frame abort. Existing lip_health, lip_ranker, and query tests
still pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

🟢 Change Impact Analysis

Metric Value
Risk Level LOW 🟢
Files Changed 11
Symbols Changed 10
Directly Affected 0
Transitively Affected 0

Blast Radius: 0 modules, 0 files, 0 unique callers

📝 Changed Symbols (10)
Symbol File Type Confidence
CHANGELOG.md CHANGELOG.md modified 30%
internal/lip/client.go internal/lip/client.go modified 30%
internal/lip/stream_context.go internal/lip/stream_context.go added 30%
internal/query/engine.go internal/query/engine.go modified 30%
internal/query/lip_health.go internal/query/lip_health.go modified 30%
internal/query/lip_ranker.go internal/query/lip_ranker.go modified 30%
internal/query/lip_stream_context.go internal/query/lip_stream_context.go added 30%
internal/query/navigation.go internal/query/navigation.go modified 30%
internal/query/query_expansion.go internal/query/query_expansion.go added 30%
internal/query/symbols.go internal/query/symbols.go modified 30%

Recommendations

  • ℹ️ coverage: 10 symbols have low mapping confidence. Index may be stale.
    • Action: Run 'ckb index' to refresh the SCIP index

Generated by CKB

@github-actions
Copy link
Copy Markdown

CKB Analysis

Risk Files +650 -6 Modules

🎯 10 changed → 0 affected · 🔥 7 hotspots · 📊 4 complex · 💣 1 blast · 📚 197 stale

Risk factors: Medium-sized PR with 11 files • Moderate churn: 656 lines changed • Touches 7 hotspot(s)

👥 Suggested: @lisa.welsch1985@gmail.com (91%), @talantyyr@gmail.com (9%), @lisa@tastehub.io (55%)

Metric Value
Impact Analysis 10 symbols → 0 affected 🟢
Doc Coverage 6.598984771573605% ⚠️
Complexity 4 violations ⚠️
Coupling 0 gaps
Blast Radius 0 modules, 0 files
Index indexed (0s) 🆕
🎯 Change Impact Analysis · 🟢 LOW · 10 changed → 0 affected
Metric Value
Symbols Changed 10
Directly Affected 0
Transitively Affected 0
Modules in Blast Radius 0
Files in Blast Radius 0

Symbols changed in this PR:

Recommendations:

  • ℹ️ 10 symbols have low mapping confidence. Index may be stale.
    • Action: Run 'ckb index' to refresh the SCIP index
💣 Blast radius · 0 symbols · 1 tests · 0 consumers

Tests that may break:

  • internal/lip/stream_context_test.go
🔥 Hotspots · 7 volatile files
File Churn Score
CHANGELOG.md 13.95
internal/lip/client.go 8.90
internal/query/engine.go 7.06
internal/query/lip_health.go 7.18
internal/query/lip_ranker.go 9.01
internal/query/navigation.go 9.01
internal/query/symbols.go 9.66
📦 Modules · 1 at risk
Module Files
🟡 internal/query 7
📊 Complexity · 4 violations
File Cyclomatic Cognitive
internal/lip/stream_context.go ⚠️ 17 ⚠️ 37
internal/query/lip_ranker.go ⚠️ 18 ⚠️ 34
internal/query/navigation.go ⚠️ 59 ⚠️ 181
internal/query/symbols.go ⚠️ 86 ⚠️ 228
💡 Quick wins · 10 suggestions
📚 Stale docs · 197 broken references

Generated by CKB · Run details

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 15, 2026

Codecov Report

❌ Patch coverage is 43.33333% with 102 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/query/lip_ranker.go 7.4% 23 Missing and 2 partials ⚠️
internal/query/lip_stream_context.go 12.0% 22 Missing ⚠️
internal/query/query_expansion.go 26.0% 16 Missing and 1 partial ⚠️
internal/query/lip_health.go 37.5% 13 Missing and 2 partials ⚠️
internal/lip/stream_context.go 78.1% 9 Missing and 5 partials ⚠️
internal/query/navigation.go 28.5% 4 Missing and 1 partial ⚠️
internal/query/symbols.go 33.3% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #212    +/-   ##
========================================
  Coverage     43.3%   43.3%            
========================================
  Files          527     530     +3     
  Lines        81325   81501   +176     
========================================
+ Hits         35241   35327    +86     
- Misses       43614   43697    +83     
- Partials      2470    2477     +7     
Flag Coverage Δ
unit 43.3% <43.3%> (+<0.1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown

CKB Review: 🟡 WARN — 76/100

11 files (+656 changes) · 3 modules · go

Changes 11 files across 3 modules (go). 25 new bug pattern(s) (11 pre-existing filtered).

Check Status Detail
bug-patterns 🟡 WARN 25 new bug pattern(s) (11 pre-existing filtered)
test-gaps ℹ️ INFO 44 untested function(s) in changed files (showing top 10)
hotspots ℹ️ INFO 7 hotspot file(s) touched
blast-radius ℹ️ INFO No symbols with callers in changes
unwired ✅ PASS All exported symbols are reachable from entrypoints
comment-drift ✅ PASS No comment/code drift detected
secrets ✅ PASS No secrets detected
format-consistency ✅ PASS No format consistency issues
dead-code ✅ PASS No dead code in changed files
risk ✅ PASS Risk score: 0.60 (medium)
breaking ✅ PASS No breaking API changes
coupling ✅ PASS No missing co-change files
complexity ✅ PASS +19 cyclomatic complexity across 4 file(s)
health ✅ PASS 2 file(s) degraded, 0 improved (avg -0.6)
tests ✅ PASS 7 test(s) cover the changes
layers ⚪ SKIP Cartographer not compiled in this build
arch-health ⚪ SKIP Cartographer not compiled in this build

Top Risks

  • 25 new bug pattern(s) (11 pre-existing filtered)
Findings (5 actionable, 17 informational)
Severity File Finding
🟡 internal/query/lip_health.go:99 Discarded return value from 'Lock' which likely returns an error
ℹ️ internal/lip/stream_context.go:81 'err' shadowed — redeclared with := at depth 1 (outer declaration at line 62)
ℹ️ internal/lip/stream_context.go:87 'err' shadowed — redeclared with := at depth 1 (outer declaration at line 62)
ℹ️ internal/query/lip_health.go Complexity 6→13 (+7 cyclomatic) in probeHandshake()
ℹ️ internal/query/lip_ranker.go Complexity 55→65 (+10 cyclomatic) in buildSeedCentroid()
Code Health — 2 degraded

Degraded:

File Before After Delta Grade Confidence
internal/query/lip_health.go 90 88 -2 A→B 100%
internal/query/lip_ranker.go 63 61 -2 C→C 100%

^1 File could not be parsed by tree-sitter

New files: 4 (avg health: 76)

2 degraded · 0 improved · avg -0.6

Estimated review: ~205min (complex)

Reviewers: lisa.welsch1985 (91%) · talantyyr (9%) · lisa (55%)

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