feat: centroid routing endpoint — SetCentroids/with_route, error reasons, content-hash verification#14
Draft
couragehong wants to merge 6 commits into
Conversation
runed never dials the index engine, but inserts need a plaintext IVF cluster assignment computed next to the embedding. The centroid set is relayed runespace -> vault -> rune-mcp -> here: - SetCentroids (client-stream): header + id-ordered batches, validated against the daemon's embedding dim, installed atomically, persisted to $RUNED_HOME/cache (gob, atomic rename) so restarts skip the re-push. - Embed/EmbedBatch with_route: responses carry cluster_id and the centroid_set_version the assignment was routed against; requests fail fast with FAILED_PRECONDITION until a set is loaded. - Info exposes centroid_set_version so callers can detect staleness. - internal/route: max-inner-product assignment (lowest-id ties), mirroring runespace-go-sdk's insert routing exactly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Embed/EmbedBatch return FAILED_PRECONDITION for two opposite conditions:
the model is still loading (wait and retry the same call) vs no centroid
set is loaded (push one via SetCentroids, then retry — §9.2 C4). Clients
could only tell them apart by parsing the human message, and rune-mcp
misdiagnosed the bootstrap window as the centroid case: it fired a
pointless resync and surfaced a non-retryable error for a condition that
heals itself in ~30s (first capture after a machine reboot hits this).
Attach an ErrorInfo{reason, domain} detail — BOOTSTRAPPING or
NO_CENTROID_SET — the same pattern runespace uses for its error reasons.
The status code and message are unchanged, so the transport-level
non-retry decision (see TestServer_EmbedFailsBeforeBackendSet) and old
clients are unaffected; new clients branch on the reason.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Port the engine's exact version recipe (sha256 over dim LE, nlist LE, preset+NUL, float32 bits LE in id order — runespace/internal/cluster/ centroid.go computeVersion) as route.ComputeVersion, and add VerifyVersion to recompute it against the relayed Version tag. Verification runs at exactly two entry points, never per-Embed: C2 SetCentroids receipt -> InvalidArgument on mismatch C5 gob cache Load -> 'route: cache verify' error on bitrot Requires the new 'string preset = 4' header field (the missing hash ingredient). Empty preset = legacy sender -> verification skipped. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
perf(backend): trim llama-server flags for the embedding-only workload
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014oTj8KKuD2q3feKTaqh81Y
…LabInc#15, approved) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014oTj8KKuD2q3feKTaqh81Y
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.
요약
runed를 centroid 라우팅의 로컬 종점으로 만드는 배선 + 에러 reason 표준화 + centroid 무결성 재검산.
SetCentroids스트림 수신 +Embed(with_route)가 cluster_id·centroid_set_version 반환 +internal/route(Assign, gob Persist/Load, 부팅 시 캐시 복원)FAILED_PRECONDITION두 상황에 ErrorInfo reason 부착(BOOTSTRAPPING/NO_CENTROID_SET) — 클라이언트가 모델 로딩 대기와 centroid 재주입을 구분 가능. 코드·메시지 불변이라 구클라이언트 무영향, 전송 계층 비재시도 결정 유지route.ComputeVersion(엔진 recipe의 byte-identical 포트: dim LE + nlist LE + preset + NUL + float32 bits LE)로 수신 시(C2, 불일치→InvalidArgument)와 gob 캐시 Load 시(C5, "cache verify" 에러) 두 시점에 content-hash 검증. preset 빈 값(구 송신자)이면 스킵 — 배포 순서 자유CentroidSetHeader.preset = 4검증
🤖 Generated with Claude Code