Skip to content

fix: keep index on lock timeout, release server slot on panic, send CLI auth token - #1320

Merged
ajianaz merged 2 commits into
developfrom
fix/index-lock-and-cli-auth
Oct 7, 2026
Merged

ajianaz merged 2 commits into
developfrom
fix/index-lock-and-cli-auth

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

What

  • uteke-core: a vector-index lock timeout is now Error::Lock; open() no longer deletes the index/.keys files on lock or IO errors (falls back to an in-memory index rebuilt from SQLite). VectorIndex::insert mutates its key maps only after engine.add succeeds. Index and .keys writes are fsynced before rename. delete_by_ids/deprecate_by_ids are chunked (500) in one transaction.
  • uteke-server: request slot released via RAII guard, handler wrapped in catch_unwind (500 on panic), poisoned Uteke mutex is recovered instead of failing every later request.
  • uteke-cli: routing via server forwards UTEKE_AUTH_TOKEN as a bearer token (loopback targets only).

Why

High + medium findings from the review of v0.19.1 — see #1318. A CLI that waited out the 30s lock timeout could unlink the live server's index; one handler panic wedged the server permanently; enabling server auth broke CLI routing with 401s.

Testing

  • cargo clippy --workspace --all-targets clean; cargo test -p uteke-core -p uteke-cli -p uteke-server passes.
  • New tests: bulk ops with 1200 ids (over the 999 param limit), loopback detection for token forwarding.
  • Not covered by automated tests: lock-timeout path (30s) and handler-panic path — reviewed manually.

Out of scope (tracked in #1318 as follow-ups): debounced index saves, atomic document upsert, vecq compaction, load-time index consistency check.

Refs #1318 (High items + subset of Medium; the issue stays open for the follow-ups).

🤖 Generated with Claude Code

…LI auth token

- core: lock timeout is Error::Lock; open() no longer deletes index files on lock/IO errors
- core: VectorIndex::insert only mutates key maps after engine.add succeeds
- core: fsync index and keys sidecar before rename
- core: chunk delete_by_ids/deprecate_by_ids (SQLite param limit)
- server: RAII slot guard, catch_unwind, recover poisoned mutex
- cli: forward UTEKE_AUTH_TOKEN (loopback only) when routing via server

Refs #1318

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@ajianaz ajianaz added bug Something isn't working priority:high Fix in next release labels Oct 7, 2026
Comment thread crates/uteke-cli/src/commands/server.rs Outdated
assert!(is_loopback_url("http://127.0.0.1:8767"));
assert!(is_loopback_url("http://localhost:8767"));
assert!(is_loopback_url("http://[::1]:8767"));
assert!(!is_loopback_url("http://evil.example:8767"));
Comment thread crates/uteke-core/src/memory/bulk.rs Outdated
.map(|i| format!("?{i}"))
.collect::<Vec<_>>()
.join(",");
let sql = format!("DELETE FROM memories WHERE id IN ({placeholders})");
@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

- cli: is_loopback_url uses a real URL parser (rejects userinfo tricks like 127.0.0.1:80@evil)
- core: delete_by_ids/deprecate_by_ids use one json_each(?) parameter instead of dynamic IN lists

Refs #1318

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working priority:high Fix in next release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants