Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ SDK](./docs/getting-started/first-agent.md), are covered there too.
| Integration | What it connects |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
| [Claude Code](./docs/features/integrations/claude-code.md), [Codex](./docs/features/integrations/codex.md), [Cursor](./docs/features/integrations/cursor.md) and [other MCP clients](./docs/features/integrations/mcp-clients.md) ([all integrations](./docs/features/integrations/index.md)) | Memory and code intelligence in your existing agent workflow. |
| [Python](./docs/reference/python-sdk.md), [TypeScript](./docs/reference/typescript-sdk.md), [Rust](./sdk/rust/README.md), [Go](./sdk/go/README.md), [.NET](./sdk/dotnet/README.md) and [HTTP](./docs/reference/operations.md) | Your own agents and applications. |
| [Python](./docs/reference/python-sdk.md), [TypeScript](./docs/reference/typescript-sdk.md), [Rust](./docs/reference/rust-sdk.md), [Go](./sdk/go/README.md), [.NET](./sdk/dotnet/README.md) and [HTTP](./docs/reference/operations.md) | Your own agents and applications. |
| [Langfuse](./docs/features/integrations/langfuse.md) | Request traces, model costs, retrieval scores and prompt-version attribution. |
| [ClickStack / HyperDX](./docs/features/integrations/clickstack.md) | OpenTelemetry traces, logs and metrics in ClickHouse. |

Expand Down
4 changes: 4 additions & 0 deletions docs/development/repository-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ What every top-level directory holds, where a concern lives inside `server/`, th
| `AGENTS.md`, `CLAUDE.md` | the instructions every coding agent reads; `CLAUDE.md` imports `AGENTS.md` |
| `.claude/`, `.agents/skills/` | the agents' skills, path-scoped rules, the read-only reviewer subagent and its hook, and project permission settings; `.agents/skills/` links each skill for Codex |

`sdk/rust/` holds the Rust SDK, published as `clickhouse-loom` on crates.io with an
independent version: async and optional blocking clients, generated contracts and
examples.

## Inside server/

`server/` is organised by domain. A request enters through a transport, is dispatched by
Expand Down
5 changes: 2 additions & 3 deletions docs/getting-started/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ description: See how Loom stores searchable memory, documents, and code for agen
Loom is a server that stores memory, documents, conversations, an entity graph and a
code index for AI agents, as rows in ClickHouse, with
[Postgres](../operations/postgres.md) as an option for live memory and knowledge state.
Agents and people reach it over MCP, HTTP, the Python and TypeScript SDKs, the
[Rust SDK](https://github.com/ClickHouse/loom/blob/main/sdk/rust/README.md), and the
dashboard. It is Apache-2.0. This page helps you decide whether it fits.
Agents and people reach it over MCP, HTTP, the Python, TypeScript and Rust SDKs,
and the dashboard. It is Apache-2.0. This page helps you decide whether it fits.

## What it does

Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,11 @@ cargo add clickhouse-loom
To install from source, clone this repository and run
`cargo add clickhouse-loom --path ../loom/sdk/rust`, adjusting the path to your
clone. Installation and client configuration are in the
[Rust SDK installation](https://github.com/ClickHouse/loom/blob/main/sdk/rust/README.md#install).
[Rust SDK installation](../reference/rust-sdk.md#install).

The client surfaces are in the [Python SDK](../reference/python-sdk.md) and
[TypeScript SDK](../reference/typescript-sdk.md) references, and the
[Rust SDK usage](https://github.com/ClickHouse/loom/blob/main/sdk/rust/README.md#use).
[Rust SDK](../reference/rust-sdk.md) reference.

## 6. First memory from a coding agent

Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/whats-included.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ Python, TypeScript and Rust SDKs, and the `loom` CLI:
[Frameworks](../features/integrations/frameworks.md) ·
[HTTP API](../reference/http-api.md) · [Python SDK](../reference/python-sdk.md) ·
[TypeScript SDK](../reference/typescript-sdk.md) ·
[Rust SDK](https://github.com/ClickHouse/loom/blob/main/sdk/rust/README.md) · [CLI](../reference/cli.md).
[Rust SDK](../reference/rust-sdk.md) · [CLI](../reference/cli.md).
2 changes: 1 addition & 1 deletion docs/reference/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Contributors can read how to update these pages in [Code generation](../developm
| [Python SDK](./python-sdk.md) | Install, construction, calling ops, typed shapes, sessions and tools, framework adapters, errors, retries. |
| [TypeScript SDK](./typescript-sdk.md) | Install, clients and options, typed ops, sessions and tools, pagination, the Strands adapter, errors, retries. |
| [Go SDK](./go-sdk.md) | Install, save and recall agent memory, configure a team connection, and handle timeouts and errors. |
| [Rust SDK](./rust-sdk.md) | Install, async and blocking clients, generated contracts, identity, call options, errors and retries. |
| [Rust SDK](./rust-sdk.md) | Install, async and blocking clients, stored login renewal, generated contracts, routes, identity, call options, errors and retries. |
| [Environment variables](./environment.md) | Variables read outside the settings model: provider keys, the image, compose files, the CLI, the SDKs and the operator scripts. |
| [SQL surface](./sql-surface.md) | The read-only `sql_v1_*` views over a tenant's data: columns, compatibility rule, what they withhold, freshness, `loom sql-access`. |
| [Extractor contract](./extractor-contract.md) | Version 1 of the HTTP contract an extractor service serves: capabilities, extraction, error codes, the artifact's fields and rules. |
Expand Down
72 changes: 53 additions & 19 deletions docs/reference/rust-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ crates.io installation. The SDK source supports Rust 1.85+, but resolved
dependencies can require a newer toolchain. The library leaves dependency locking
to the application; commit your application's `Cargo.lock`.

The `0.1.2` crate provides `request` and `request_json` in both clients.
HTTPS connections negotiate HTTP/2 over ALPN, with a fallback to HTTP/1.1.
Plain HTTP uses HTTP/1.1.
The SDK has its own version in the
Expand All @@ -27,9 +26,10 @@ See the [operation reference](operations.md) for the server's current contracts.

## Save and read memory

For the local single-user server, org `dev`, namespace `local` and an empty token
match the quickstart. This async example uses the application's existing Tokio
runtime with `macros` and `rt-multi-thread` enabled:
For the local single-user server, org `dev` and namespace `local` match the
quickstart. For unauthenticated requests, no environment token, matching stored
login or legacy token may be present. This async example uses the application's
existing Tokio runtime with `macros` and `rt-multi-thread` enabled:

```rust
use clickhouse_loom::{Client, SearchRequest, SetRequest};
Expand All @@ -38,7 +38,6 @@ use clickhouse_loom::{Client, SearchRequest, SetRequest};
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::builder("dev", "local", "rust-agent")
.base_url("http://localhost:7777")
.api_key("")
.build()?;
let saved = client.set(
SetRequest::new("deploy_window", "Deploy Tue/Thu")
Expand Down Expand Up @@ -70,7 +69,8 @@ before using results as evidence.
## Configure a team connection

Obtain a writer token for your org and namespace through **Settings → Tokens**
or your operator. The builder reads `LOOM_BASE_URL` and `LOOM_API_KEY`:
or your operator. The builder reads `LOOM_BASE_URL` and `LOOM_API_KEY` when no
explicit server or credential source takes precedence:

```rust
use clickhouse_loom::Client;
Expand All @@ -82,11 +82,46 @@ let client = Client::builder("my-org", "my-namespace", "rust-agent")
```

Set those environment variables in the process that runs your application.
Explicit `.base_url(...)` and `.api_key(...)` override them; `.api_key("")`
disables authorization. Empty environment values are unset. Without a server
address the default is `http://localhost:7777`; without a token the SDK sends
no Authorization header. `LOOM_ORG` and `LOOM_NAMESPACE` are example conventions,
not variables read by the client builder.
A nonempty `.api_key(...)` overrides `LOOM_API_KEY`. You can also use a stored
login:

```bash
loom login --profile team
```

```rust
use clickhouse_loom::Client;

let client = Client::builder("my-org", "my-namespace", "rust-agent")
.profile("team")
.build()?;
let memory = client.get("preference").await?;
println!("found={}", memory.found);
```

The profile supplies its server and rotating tokens. `.credential_provider(...)`
accepts application-owned credentials. Configure only one explicit credential
source.

Without an explicit source or a nonempty `LOOM_API_KEY`, the SDK looks for the
`LOOM_PROFILE` profile (default `default`) matching the selected server, then
the legacy token file. `.api_key("")` and empty environment values do not turn
off this discovery. No resolved credential means no Authorization header.
An explicit `.base_url(...)` wins over a profile or provider's server, but must
match its binding. Otherwise that server takes precedence over `LOOM_BASE_URL`;
the default remains `http://localhost:7777`.

Stored login renews an access token when it has at most 60 seconds left. If
renewal is temporarily unavailable, an unexpired token that has not been rejected
can still be used; otherwise, the call returns retryable `Error::Credentials`.
A revoked refresh token requires `loom login` again. On HTTP 401, the SDK asks
the provider to replace the rejected token and resends once only if it changed.
Fixed API keys are not refreshed. These rules apply to both clients and to routes
outside the op registry. See the
[authentication contract](https://github.com/ClickHouse/loom/blob/main/sdk/rust/README.md#authentication)
for credential precedence and renewal failures.
`LOOM_ORG` and `LOOM_NAMESPACE` are example conventions, not variables read by
the client builder.

Org and the addressed namespace remain bound to the client. Bound identity
fills declared caller and authorship fields. Reads with explicit row selectors
Expand Down Expand Up @@ -128,15 +163,15 @@ preserve omitted fields as `None`.

The SDK also provides `Client::call<T>` for dotted operation names and JSON
objects. Known operations retain generated identity and retry policies.
Unknown operations receive bound org and namespace, and retry only connection
failures before dispatch. The server authorizes every call.
Unknown operations receive bound org and namespace. The retry policy can resend
them after connection failures before dispatch or responses proving the handler
never ran, such as HTTP 408 or `AUTH_UNAVAILABLE`. The server authorizes every call.

## Routes outside the op registry

The SDK from this repository provides `request` and `request_json` for routes
Both clients provide `request` and `request_json` for routes
outside the operation registry, such as `/v1/whoami` and `/v1/knowledge.upload`.
For a crates.io install, check the `Client` API for your version on
[docs.rs](https://docs.rs/clickhouse-loom). A `RouteRequest` carries the method,
A `RouteRequest` carries the method,
a path on the server the client is bound to, query parameters and a JSON or raw
body, all sent as given:

Expand Down Expand Up @@ -227,16 +262,15 @@ use clickhouse_loom::blocking::Client;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::builder("dev", "local", "rust-agent")
.base_url("http://localhost:7777")
.api_key("")
.build()?;
println!("found={}", client.get("deploy_window")?.found);
Ok(())
}
```

The blocking client owns a runtime thread and offers the same generated
operations and call options. When built from this repository, it also offers
routes outside the operation registry. Call it from an ordinary OS thread.
operations, call options and routes outside the operation registry.
Call it from an ordinary OS thread.
Calling from a thread entered into Tokio returns `Error::Configuration`.

## Capabilities and examples
Expand Down
16 changes: 7 additions & 9 deletions sdk/rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,6 @@ when recall credit was not disclosed. An omitted risk label is empty in
`SearchHit.governed` and `SearchResponse.term_leg`; `retrieval_risk` describes the
other hits.

The typed error methods and retry behavior below are available in `0.1.2`.

```rust
use clickhouse_loom::Error;

Expand Down Expand Up @@ -487,8 +485,8 @@ and a cumulative `X-Loom-Retry-Count` starting at 0.
A final transport failure may follow a committed write. An independent call
generates a different idempotency key; read the result before submitting it again.
`Client` is `Clone`, `Send` and `Sync`. Clones share the HTTP connection pool
and rate state and can make concurrent calls. When built from this repository,
the SDK negotiates HTTP/2 over ALPN for `https` connections and falls back to
and rate state and can make concurrent calls. The SDK negotiates HTTP/2 over
ALPN for `https` connections and falls back to
HTTP/1.1. Plain `http` uses HTTP/1.1. Dropping a call future or applying an
external timeout stops requests, retry sleeps and pacing sleeps in that future.
There are no detached retry tasks. Cancellation does not roll back a write or
Expand Down Expand Up @@ -533,7 +531,7 @@ The server validates fields and authorizes every operation.

## Routes outside the op registry

The SDK built from this repository provides `request` and `request_json` for
The SDK provides `request` and `request_json` for
routes outside the registry, such as `/v1/whoami`,
`/v1/me/service_accounts.create` and `/v1/knowledge.upload`:

Expand Down Expand Up @@ -616,11 +614,10 @@ methods without `.await`.

## Blocking calls

Enable the feature in the consuming application's `Cargo.toml`:
Enable the feature in the consuming application:

```toml
[dependencies]
clickhouse-loom = { path = "/path/to/loom/sdk/rust", features = ["blocking"] }
```bash
cargo add clickhouse-loom --features blocking
```

```rust
Expand Down Expand Up @@ -652,6 +649,7 @@ the call sequence, output and cleanup for each program:
| [memory.rs](examples/memory.rs) | Save → read → lexical search → delete → confirm absence |
| [operations.rs](examples/operations.rs) | Async memory, knowledge and context calls, per-call options, metadata and request `send` |
| [blocking.rs](examples/blocking.rs) | The memory, knowledge and context flow with the blocking client |
| [renew_login.rs](examples/renew_login.rs) | Read memory using a stored login profile and its renewal credentials |
| [agent_memory.rs](examples/agent_memory.rs) | Travel recall and grounded answers |
| [document_search.rs](examples/document_search.rs) | Document citations and off-topic abstention |
| [code_lookup.rs](examples/code_lookup.rs) | Selected code lookup with bounded evidence |
Expand Down
Loading