Skip to content

feat: centroid routing endpoint — SetCentroids/with_route, error reasons, content-hash verification#14

Draft
couragehong wants to merge 6 commits into
CryptoLabInc:release/v1.0.0from
couragehong:runespace-integration-test
Draft

feat: centroid routing endpoint — SetCentroids/with_route, error reasons, content-hash verification#14
couragehong wants to merge 6 commits into
CryptoLabInc:release/v1.0.0from
couragehong:runespace-integration-test

Conversation

@couragehong

Copy link
Copy Markdown
Contributor

요약

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 재주입을 구분 가능. 코드·메시지 불변이라 구클라이언트 무영향, 전송 계층 비재시도 결정 유지
  • sha 재검산: route.ComputeVersion(엔진 recipe의 byte-identical 포트: dim LE + nlist LE + preset + NUL + float32 bits LE)로 수신 시(C2, 불일치→InvalidArgument)와 gob 캐시 Load 시(C5, "cache verify" 에러) 두 시점에 content-hash 검증. preset 빈 값(구 송신자)이면 스킵 — 배포 순서 자유
  • proto: CentroidSetHeader.preset = 4

검증

  • 단위: recipe 골든(독립 수제 바이트 조립 대조), 손상 검출, 레거시 스킵, gob bit-flip Load 거부
  • 실스택: 부트 릴레이 push가 곧 두 구현의 해시 recipe parity 실증(레시피 어긋나면 push 즉사) — preset="IP1", 재계산 sha256 == 엔진 version 일치 확인

🤖 Generated with Claude Code

couragehong and others added 6 commits July 11, 2026 13:05
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
@esifea esifea changed the base branch from main to release/v1.0.0 July 14, 2026 07:34
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