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 .claude/rules/wire-ops.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ paths:
- `server/operations/base.py` defines `Operation`, `Role` and `grant_rank`; `server/transport/mcp_primer.py` renders the primer and answers `prompts/*` / `resources/*`; `server/observability/budgets.py::effective_budget_ms` resolves each op's latency budget (runtime and per-consumer overrides).
- Nothing below `server/transport/` imports it (`tests/unit/test_transport_layering.py`), and `package_contract_allowlist.txt` only shrinks: fix the import, never add an exception.
- Models in `server/<domain>/api/models_<group>.py` import no handler; the `Operation` and its `OPERATIONS` entry live in `ops_<group>.py`. `server/operations/registry.py` imports each list, and the handler in `server/<domain>/app/` imports its models at module top. Transports discover ops from the registry; a change that edits transport code to add an op is in the wrong place.
- After any op or field change: `python -m scripts.codegen.<gen>` for `sdk_py_gen`, `sdk_py_client_gen`, `sdk_ts_gen`, `sdk_rb_gen`, `sdk_rust_gen`, `sdk_rust_gen --fixtures`, `docs_reference`, `op_reach_census`. Generated SDK files are never edited by hand.
- After any op or field change: `python -m scripts.codegen.<gen>` for `sdk_py_gen`, `sdk_py_client_gen`, `sdk_ts_gen`, `sdk_rb_gen`, `sdk_rust_gen`, `sdk_rust_gen --fixtures`, `sdk_go_gen`, `docs_reference`, `op_reach_census`. Generated SDK files are never edited by hand.
- Whether an agent calls `memory.set` or `memory.pin` is the model's judgement from the tool description (`server/transport/mcp_descriptions.py`), not a pattern match: change the wording, not a regex.
- A field description is what a model reads when it calls the tool: one sentence on what the value does, its unit and its default.
- The default MCP `tools/list` has a token ceiling (`test_mcp_listing_budget.py`); a new tool joins the default listing only when an agent needs it without asking.
Expand Down
2 changes: 1 addition & 1 deletion .claude/skills/loom-change/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Find the row for the change, read its guide before the first edit, and finish it

| Change | Guide | Also in the same PR |
| --- | --- | --- |
| Wire op (new, renamed, removed field) | [adding-an-operation](../../../docs/development/adding-an-operation.md) | `python -m scripts.codegen.sdk_py_gen`, `.sdk_py_client_gen`, `.sdk_ts_gen`, `.sdk_rb_gen`, `.sdk_rust_gen`, `.sdk_rust_gen --fixtures`, `.docs_reference`, `.op_reach_census`; unit test + integration test for a read or write path; MCP listing budget if it is listed by default; its dashboard control, or a `NOT_IN_DASHBOARD` reason in `server/operations/dashboard.py` |
| Wire op (new, renamed, removed field) | [adding-an-operation](../../../docs/development/adding-an-operation.md) | `python -m scripts.codegen.sdk_py_gen`, `.sdk_py_client_gen`, `.sdk_ts_gen`, `.sdk_rb_gen`, `.sdk_rust_gen`, `.sdk_rust_gen --fixtures`, `.sdk_go_gen`, `.docs_reference`, `.op_reach_census`; unit test + integration test for a read or write path; MCP listing budget if it is listed by default; its dashboard control, or a `NOT_IN_DASHBOARD` reason in `server/operations/dashboard.py` |
| Table or column | [adding-a-table](../../../docs/development/adding-a-table.md) | migration + `make schema-dump`; RMT row builders; `loom.memory_versions` + its view for a `loom.memory` column; erasure step + census row, or a `NO_MEMORY_CONTENT` / `STEP_ONLY_TABLES` entry with its reason; a new table's row in `docs/architecture/storage-layout.md`, its Today cell when the engine, sort key, partition key or TTL changes, its Erasure cell when its census classification changes, its row removed when the table is dropped (with the dump pending, the row test fails until it lands) |
| Migration | [migrations](../../../docs/development/migrations.md) | next free number on current `origin/main`; additive only; `make schema-dump` on a private ClickHouse (with none at hand, leave `schemas/schema.sql` unchanged and report the dump as pending; never hand-edit it); written values N-1 tolerates ([rolling upgrades](../../../docs/architecture/rolling-upgrades.md)), `make test-mixed-version` |
| Setting | [extending-loom](../../../docs/development/extending-loom.md#add-a-setting) | field in its area's section of `server/settings/catalog.py` (models in `Models`) with a comment on what it controls and its values; `python -m scripts.codegen.settings_reference`, `.settings_schema` and `.settings_example`; read as `settings.<field>`; a rename or removal follows the [settings rule](../../rules/settings.md) |
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/source/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM python:3.12-slim@sha256:a6e34c598f2467ed0e9a8d349809fcd8b5c603269512df273a0
COPY --from=ghcr.io/astral-sh/uv:0.12.2@sha256:069a51314a7bb6031777a9273205fe1b0b19e914ef418207d1338b268df641dd /uv /usr/local/bin/uv

ARG CONTRIBUTOR_UID=1000
RUN apt-get update && apt-get install -y --no-install-recommends build-essential ca-certificates git rustfmt \
RUN apt-get update && apt-get install -y --no-install-recommends build-essential ca-certificates git golang-go rustfmt \
&& useradd --create-home --uid "$CONTRIBUTOR_UID" developer \
&& mkdir /venv && chown developer:developer /venv

Expand Down
4 changes: 2 additions & 2 deletions .devcontainer/source/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Use a task-specific checkout to investigate a small defect, write its regression and
send a reviewable contribution. This configuration builds a Python source environment
with pinned base and installer images, the repository's dependency lock and a private
virtualenv. It installs compiler dependencies and `rustfmt` for the Rust SDK generator
checks in `make lint`, and runs a focused unit check. It starts
virtualenv. It installs compiler dependencies, `gofmt` and `rustfmt` for the SDK
generator checks in `make lint`, and runs a focused unit check. It starts
no Loom service, database or provider, and exposes no port.

Select **Loom source contribution** when reopening the checkout in a development
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ jobs:
run: |
python scripts/codegen/sdk_rust_gen.py --check
python scripts/codegen/sdk_rust_gen.py --fixtures --check
- name: Install Go formatter for generated contracts
uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
with:
go-version: "1.27.4"
cache: false
- name: generated Go contracts are current
run: python scripts/codegen/sdk_go_gen.py --check
- name: ruff format
run: ruff format --check .
# The Python SDK's op table, TypedDicts and per-op client are generated
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ lint:
$(PYTHON) scripts/codegen/sdk_rb_gen.py --check
$(PYTHON) scripts/codegen/sdk_rust_gen.py --check
$(PYTHON) scripts/codegen/sdk_rust_gen.py --fixtures --check
$(PYTHON) scripts/codegen/sdk_go_gen.py --check
$(PYTHON) scripts/codegen/agent_plugin_sync.py --check
$(PYTHON) scripts/codegen/settings_reference.py --check
$(PYTHON) scripts/codegen/settings_schema.py --check
Expand Down
1 change: 1 addition & 0 deletions docs/development/adding-an-operation.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ python scripts/codegen/sdk_ts_gen.py # sdk/typescript/src/
python scripts/codegen/sdk_rb_gen.py # sdk/ruby/lib/clickhouse/loom/generated/*.rb
python scripts/codegen/sdk_rust_gen.py # Rust wire models, methods and registry contracts
python scripts/codegen/sdk_rust_gen.py --fixtures # Rust schema mapping contracts
python scripts/codegen/sdk_go_gen.py # Go wire models and grouped client methods
python scripts/codegen/op_reach_census.py --write-manifest # server/operations/reach_manifest.py
python scripts/codegen/docs_reference.py # generated regions of docs/reference/*.md
make format
Expand Down
30 changes: 30 additions & 0 deletions docs/development/code-generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ ruff formatting, an atomic write, and the write-or-check protocol).
| `sdk_ts_gen.py` | `sdk/typescript/src/generated/ops.ts`: one interface per model, the `OPS` table, the `OpMap` type | `server.operations.registry.ALL_OPERATIONS` (the models' JSON Schemas) | yes |
| `sdk_rb_gen.py` | `sdk/ruby/lib/clickhouse/loom/generated/`: `ops.rb` (the `OPS` table, one class per op group, one method per op) and `errors.rb` (one `Error` subclass per server code) | `server.operations.registry.ALL_OPERATIONS`; the error codes as `docs_reference.py` collects them | yes |
| `sdk_rust_gen.py` | `sdk/rust/src/wire_models.rs`: serde contracts, constructors, setters, request `send` methods and replay declarations | the full registry, Pydantic schemas and collection defaults; names and numeric types are defined in the generator | yes |
| `sdk_go_gen.py` | `sdk/go/wire/models.gen.go`: Go request and response types; `sdk/go/client.gen.go`: grouped Go methods and root package aliases | the registry's Pydantic input and output models | yes |
| `agent_plugin_sync.py` | the Codex plugin's copies of the hook scripts (`hooks/*.mjs`), the shared library (`lib/*.mjs`), the skills and the listing icon (`assets/`), byte-identical with the executable bit | `integrations/claude-code-plugin/` | yes |
| `settings_reference.py` | the generated [configuration reference](../reference/configuration.md) | `server/settings/catalog.py`: each field's env var, type, default, and the comment above it | yes |
| `settings_schema.py` | `schemas/loom-settings.schema.json`, the JSON Schema of the YAML settings file | the settings fields' types, bounds, defaults and comments, secrets left out | yes |
Expand Down Expand Up @@ -66,6 +67,35 @@ segment, the method the rest with `.` joined, snake_case in Python
`tests/unit/test_sdk_parity.py` fails when the two op tables, or the two method names of
any op, differ.

### sdk_go_gen

The `wire` package contains `<Operation>Input` and `<Operation>Output` types.
The root package exposes aliases for these types and groups the generated
methods by the first segment of the operation name. The methods share the
handwritten HTTP transport. Regeneration needs the server's Python
dependencies and `gofmt` on `PATH`. The check compares both generated files:

```bash
python scripts/codegen/sdk_go_gen.py
python scripts/codegen/sdk_go_gen.py --check
```

Optional fields with a concrete non-nullable type use pointers. A nil pointer
omits the field; a pointer to `false`, `0` or an empty slice sends that value.
Optional nullable fields with a concrete type use
`wire.Optional[T]`: its zero value omits the field, `wire.Null[T]()` sends JSON
`null`, and `wire.Some(value)` sends a value. Decoding into a fresh struct
preserves all three states. `Get` reads a concrete value and `IsNull` tests
for explicit null. Open values and unions with different JSON types use
`json.RawMessage`. The server validates enum values and applies request
defaults. Top-level responses include the HTTP fields `ignored_args`,
`did_you_mean` and `mirrored` when the server sends them. Go skips other
unknown keys when decoding into a struct.

The schema hash tracks literal defaults and static factory defaults. Factories
that compute defaults from other request fields run on the server; the
generator does not hash their behavior.

### sdk_rust_gen

The Rust SDK commits serde models and async and blocking methods for every
Expand Down
1 change: 1 addition & 0 deletions docs/development/local-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This page sets up a checkout for working on Loom's code. To evaluate Loom withou
- **Docker** with Compose 2.34 or later (the dev compose file pulls ClickHouse daily),
for ClickHouse and the stacks.
- **Node 22** (the version CI uses) for the dashboard and the TypeScript SDK.
- **Go** with `gofmt` on `PATH` for the Go SDK generator check in `make lint`.
- **rustfmt** on `PATH` for the Rust SDK generator checks in `make lint`.
Install with `sudo apt-get install rustfmt` on Debian/Ubuntu. With rustup,
use `rustup toolchain install 1.84.1 --profile minimal --component rustfmt`
Expand Down
4 changes: 3 additions & 1 deletion docs/reference/go-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ The SDK returns a redirect as `*loom.Error` when the HTTP client has no custom `

## Handle errors and deadlines

Pass a `context.Context` to each operation. The SDK leaves retries to the caller. For an HTTP error, use `errors.As` to read `*loom.Error` and match on `Code`. Use `Retryable` and `RetryAfter` when deciding whether to retry. When present, `RequestID` identifies the request in server logs. Check the [HTTP idempotency contract](http-api.md#idempotency) before resending writes whose outcome is unknown.
The SDK leaves retries to the caller. For an HTTP error, use `errors.As` to read `*loom.Error` and match on `Code`. Use `Retryable` and `RetryAfter` when deciding whether to retry. When present, `RequestID` identifies the request in server logs.

A timeout does not tell you whether a write took effect. Check the [HTTP idempotency contract](http-api.md#idempotency) before resending writes whose outcome is unknown.

Use the [HTTP API](http-api.md), [Python SDK](python-sdk.md), or [TypeScript SDK](typescript-sdk.md) for Loom operations beyond the Go client's memory methods. See the [Go source](https://github.com/ClickHouse/loom/tree/main/sdk/go) for the client and tests.
Loading
Loading