feat(lip): push-driven health via long-lived subscribe#210
Merged
feat(lip): push-driven health via long-lived subscribe#210
Conversation
CKB used to re-probe IndexStatus on a 60 s TTL every time the rerank path checked whether the LIP index was mixed-models. The LIP daemon has pushed IndexChanged frames to all active sessions since v1.5.0, so the polling was pure debt. New internal/lip/subscribe.go opens a long-lived connection, pings IndexStatus every 3 s to flush the daemon's broadcast channel (the session loop drains queued pushes only after writing a response), reads every frame in a loop, and routes index_changed and index_status by type tag. Reconnects with exponential backoff to 30 s on daemon drop. Engine owns one subscriber, started in NewEngine and cancelled in Close. The cached availability/mixed flags are now written by the subscriber, not the query path — lipSemanticAvailable is lock-free RLock+read, no RPC. Worst-case staleness for the rerank gate drops from 60 s to ~3 s. Tests rewritten: the fake daemon now serves multiple requests per connection and tests wait for the first health frame before asserting, plus a new TestLipSubscriber_ReusesSingleConnection verifies the hot path issues zero requests. Also: CHANGELOG entries for #208 and #209 which landed on develop without one. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🟢 Change Impact Analysis
Blast Radius: 0 modules, 0 files, 0 unique callers Generated by CKB |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #210 +/- ##
========================================
Coverage 43.2% 43.3%
========================================
Files 526 527 +1
Lines 81200 81317 +117
========================================
+ Hits 35114 35242 +128
+ Misses 43622 43604 -18
- Partials 2464 2471 +7
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:
|
Had a package-level init() that printed cartographer version on import under the cartographer build tag — not a test, and leaked output into unrelated test runs when the tag was enabled. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CKB Review: ✅ PASS — 87/1004 files (+37 changes) · 3 modules ·
Change Breakdown
Code HealthEstimated review: ~26min (moderate) Reviewers: lisa.welsch1985 (100%) · talantyyr (50%) · lisa (75%) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
IndexStatuswith a long-lived subscriber that consumes the daemon's existingindex_changedpushes (LIP v1.5.0+)internal/lip/subscribe.go: one connection, pingsindex_statusevery 3 s to flush the daemon's broadcast channel, reads every frame, reconnects with exponential backoff (cap 30 s)Engine.lipSemanticAvailable()is now lock-free — no RPC, no dial, no TTL check — so the rerank gate is free on the hot path. Worst-case staleness drops from 60 s to ~3 sdevelopwithout entriesWhy push not poll
The LIP daemon broadcasts
IndexChanged { indexed_files, affected_uris }to every active session after each upsert (session.rs:279). CKB's client was unary-only so we couldn't consume them — we polled instead. The daemon only drains queued pushes after writing a response (noselect!between the read and the broadcast channel), so the subscriber still has to issue a cheap request on a ticker; the request doubles as the health probe that feeds the mixed-models gate.Test plan
go test ./internal/query/... ./internal/lip/...go build -o ckb ./cmd/ckbgo vet ./...TestLipSubscriber_ReusesSingleConnectionverifieslipSemanticAvailabletriggers zero extra daemon requestsckb mcpagainst a live LIP daemon, confirmckb doctorstill readsMixedModelscorrectly and the rerank gate flips within ~3 s oflip index rebuildlipSemanticAvailableflips to false within one ping🤖 Generated with Claude Code