Skip to content

Add onboarding helpers to the Rust SDK - #1785

Merged
zlareb1 merged 8 commits into
ClickHouse:mainfrom
yorkhellen:feat/rust-sdk-onboarding
Nov 30, 2026
Merged

zlareb1 merged 8 commits into
ClickHouse:mainfrom
yorkhellen:feat/rust-sdk-onboarding

Conversation

@yorkhellen

@yorkhellen yorkhellen commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Related: #52
Related: #1754

Changelog category

  • New Feature

Changelog entry

Rust clients can label calls by consumer, inspect token and operation role hints, and request the Loom guide and Mentor brief.

Why

A Rust application needs a way to fetch Loom instructions and usage advice without a plugin. The SDK also gives the application permission hints before it sends an operation.

Scope and risk

  • Empty builder org and namespace values preserve targets supplied in requests and otherwise leave supported defaults to the server. Blank namespaces are omitted so authenticated writes requiring a namespace fail validation instead of writing to a blank namespace. Blank agent names become sdk-rust:<program>; explicit names, including "-" and "*", are preserved.
  • .consumer(...) supplies a default when the operation body has no usable label. Label normalization follows the server's printable-character rule. The server's verified token claim takes precedence.
  • token_claims(), permissions(max_age), and can_call(op) provide advisory information. Namespace role hints exclude operations authorized on other scopes. A malformed role entry retains the scoped map's authority and produces an unknown hint; valid sibling entries remain usable. The server performs the actual authorization.
  • Async and blocking clients expose guide(), mentor(), and mentor_with_window(). These helpers issue requests only when called. A ten-second deadline covers the whole call, including HTTP attempts, retry backoff and pacing waits; expiration returns Error::Timeout.
  • The crate README and public SDK reference will be updated after the code merges and a crate release ships the methods.

Compatibility, rollout and rollback

  • Wire: no server request or response shape changes. Mentor helpers preserve the server's returned lookback window. The server cache correction is already merged in Keep Mentor profiles separate by lookback window #1754; older servers can still return a report cached for a different window.
  • SDK: Error::Timeout is a new variant of the non-exhaustive error enum. Its category is Dependency; retryable() returns false.
  • Operator steps: none. Applications that need a stable agent name should specify one.
  • Rollback: use the previous SDK. Existing rows retain the identity and consumer recorded at write time.

Tests

  • make format lint typecheck passes. Rust generation and fixture checks pass without drift.
  • Rust 1.84.1: cargo test --locked --all-targets --all-features, cargo test --locked --doc --all-features, cargo clippy --locked --all-targets --all-features -- -D warnings and RUSTDOCFLAGS="-D warnings" cargo doc --locked --no-deps --all-features pass. Stable doctests, Clippy and documentation also pass. Both toolchains pass 137 client tests and nine doctests.
  • Focused Rust generation, search-contract, release, CI-process, public-copy and documentation-link tests: 394 pass.
  • Stable cargo test --locked --all-targets passes with default features. The all-features run passes 137 client tests, including the six review regressions, and all library and generated contract tests. The unchanged software_factory_memory example test fails intermittently on the local macOS host with WouldBlock at its socket reader; an isolated rerun also fails there. The example's listener is nonblocking and its accepted socket is read without resetting blocking mode. Hosted Linux checks remain for CI.
  • The malformed-role regression returns Some(true) before the fix and None after it. Tests cover numeric, null, boolean, list, object and unknown string roles, plus a valid sibling namespace.
  • Guide and Mentor retry waits remain pending beyond eleven seconds before the fix. The corrected helpers return Error::Timeout at the ten-second deadline. Tests cover HTTP 503 with Retry-After: 60, HTTP 429 pacing with Retry-After: 12, and blocking retry backoff.
  • cargo package --locked --all-features builds the committed distributable crate; the release helper's provenance and license check passes.
  • Hosted workflows on 8a74384fe are running after maintainer approval. Lint and format pass; the four Rust matrices and other test jobs remain in progress.
  • A fresh independent review of all 13 changed files at 8a74384fe reports no verified P0–P3 findings. Its separate run passes 27 library tests, 137 client tests, nine doctests and 51 generator/search-contract tests.

Before the latest base merge, an SDK-only example ran against an isolated Loom server and ClickHouse with both Rust versions. It checked tokenless defaults, a read-only caller's real 403, consumer precedence in stored events, and separate Mentor lookback windows. That live scenario was not rerun after this merge.

AI assistance in the code

  • AI-generated: TRAE authored the changes and ran the checks above.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Local format, lint, type checks and focused tests pass. Full unit and integration checks remain for CI; the macOS example test failure is recorded above.
  • Generated Rust files are regenerated from the operation registry.
  • Commits are signed off.
  • I signed the Contributor License Agreement (CLA) if CLA assistant requested a signature.

Let applications label operation calls, inspect token claims and operation roles, and request the Loom guide or Mentor brief without installing a plugin.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
Namespace role hints exclude operations authorized on other scopes.
Consumer defaults survive labels the server removes, and Mentor helpers
preserve the server's reported window. Published documentation waits for
the crate release.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
@vercel

vercel Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Nov 30, 2026 12:41pm UTC
loom-telemetry Ready Ready Preview Nov 30, 2026 12:41pm UTC

Request Review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit d534051. Configure here.

Comment thread sdk/rust/src/client.rs Resolved
An empty namespace passes memory model validation and can reach a write
handler. Omitting it permits tokenless defaults and rejects authenticated
writes that need an explicit namespace. Explicit targets are preserved.
Executable suffix removal includes the dot and leaves suffix-free
platforms unchanged.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
Whitespace-only namespaces can reach write handlers without a namespace
authorization target. Omit them so required-field validation refuses the
write. Windows executable suffixes are case-insensitive; strip them
without changing the program name's casing.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
@zlareb1 zlareb1 self-assigned this Nov 30, 2026

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two focused tests reproduce the findings on this head. An invalid scoped role produces a positive write hint, and a retry delay holds the guide call past its startup timeout. The existing Rust suite passes with all features.

Comment thread sdk/rust/src/token.rs Resolved
Comment thread sdk/rust/src/client.rs Resolved

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three failures reproduce on the CI base without the Rust changes. The extraction field and sender census tests fail locally on both trees. They pass on current main with the two repairs applied. The attestation test fails at the same superseder assertion in both hosted runs. Its repair covers assertion order at equal standing and the separate lower-standing case.

Dropping malformed namespace roles lets flat writer claims produce a false
permission hint. Retain each scoped entry so its map stays authoritative.

Guide and Mentor calls have a ten-second deadline that includes retry and
pacing waits. Return Error::Timeout when that deadline expires.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The role-map tests preserve scoped authority for invalid values, including a map with no valid entry. All six onboarding regressions pass. They cover the whole-call deadline across retry and pacing waits and the blocking client. The generated Rust files match the registry.

@zlareb1
zlareb1 merged commit b3557e0 into ClickHouse:main Nov 30, 2026
73 checks passed
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.

2 participants