Skip to content

Expose typed Go methods for Loom operations - #1750

Merged
zlareb1 merged 12 commits into
ClickHouse:mainfrom
yorkhellen:feat/go-sdk-generated-types
Nov 30, 2026
Merged

zlareb1 merged 12 commits into
ClickHouse:mainfrom
yorkhellen:feat/go-sdk-generated-types

Conversation

@yorkhellen

@yorkhellen yorkhellen commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Related: #51

Changelog category

  • New Feature

Changelog entry

The Go SDK provides typed methods for every registered operation. Callers can use methods such as client.Context.Pack, client.WorkingMemory.Get, and client.Knowledge.Add from the loom package.

Why

Go callers need a typed way to call Loom operations without assembling HTTP requests. The operation registry generates the methods and their request and response types. make lint checks both generated files for drift.

Scope and risk

The grouped methods share the existing HTTP transport, authentication, and error handling. The generated memory methods accept if_match_sha256. Client-wide user and session defaults, automatic idempotency keys, and retries that honor Retry-After remain follow-up work. The SDK does not add client-side session protection.

Collection and namespace management calls and namespace-scoped extraction policies require an explicit target namespace. Key updates search across agents unless the caller sets an agent filter. Grouped methods omit unconfigured optional identity fields and preserve required identity fields for server validation. History omits an unspecified agent so Loom can reject a scoped request that needs one. Conflict rows and pagination use unsigned 64-bit versions.

Compatibility, rollout and rollback

  • Wire: no server operation, field, or default changes. The existing Go Set, Get, Search, and Delete signatures stay the same.
  • Operator steps: none.
  • Rollback: revert the PR to remove the generated Go API and drift check. No migrations or stored data changes.
  • The public Go SDK guide will add the grouped methods after the next SDK release.

Tests

  • go build ./..., go vet ./..., and go test -race ./... in sdk/go on Go 1.22.12 and 1.27.4.
  • make lint typecheck and focused generator, documentation, and repository instruction tests. Request tests cover explicit namespace targets, omitted agent filters, required and optional identity fields, and conflict pagination above 2^63.
  • Ran the runbook example against Loom and ClickHouse from a separate Go module. It checked that the context pack contained the knowledge document and working memory block it had just written.
  • Formatting checks pass for the changed files. The full make format-check reports the same Biome difference in docs/pages/adoption.astro on main. Hosted CI is pending.

AI assistance in the code

  • AI-generated with TRAE. Local verification is listed above.

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

Checklist

  • The Go generator produces both generated files, and --check passes.
  • The description names the wire changes and operator steps.
  • Public copy checks pass.
  • Branch commits are signed off.
  • I signed the Contributor License Agreement (CLA) if CLA assistant requested a signature.

Note

Medium Risk
Large generated client surface with nuanced identity, namespace, and nullable-field semantics; no server wire changes, but incorrect defaults could cause wrong-scope writes if misused.

Overview
Adds sdk_go_gen so the operation registry generates sdk/go/wire/models.gen.go and sdk/go/client.gen.go, with make lint and CI enforcing --check via Go 1.27.4 / gofmt. Contributor docs, devcontainer, and wire-op checklists now list this generator beside the other SDK codegen steps.

The Go Client is refactored around shared clientTransport and grouped services (for example client.Context.Pack, client.Knowledge.Add, client.Code.Repos). Handwritten pieces add Option / WithInput / Ptr / Some / Null, namespace guardrails for management calls, HTTP response metadata on outputs, and examples plus broad unit tests. Existing memory convenience APIs in memory.go are unchanged on the wire.

Reviewed by Cursor Bugbot for commit fd07bb8. Bugbot is set up for automated code reviews on this repo. Configure here.

Give Go callers typed requests and responses for every registered operation. Check the generated package in lint and CI so changes to the HTTP contract require regeneration.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
Generate the client methods and root package types from the operation registry. Keep authentication, request handling and the existing memory methods in the shared client.

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

vercel Bot commented Nov 29, 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 29, 2026 1:00pm UTC
loom-telemetry Ready Ready Preview Nov 29, 2026 1:00pm UTC

Request Review

@yorkhellen
yorkhellen marked this pull request as ready for review November 29, 2026 10:29
@zlareb1 zlareb1 self-assigned this Nov 29, 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.

The generated methods can supply an omitted write target and cannot represent the full conflict cursor range. Both cases reproduced in Go tests against the generated SDK.

Comment thread scripts/codegen/sdk_go_gen.py Resolved
Comment thread scripts/codegen/sdk_go_gen.py 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.

The format job reports the same docs/pages/adoption.astro assignment on this merge and clean main. The pinned formatter passes on that file with the tracked repair. Failed job · Repair #1706

@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 715e073. Configure here.

Comment thread scripts/codegen/sdk_go_gen.py Resolved
…ed-types

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

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
Require a named collection or namespace for management calls and keep a key update unfiltered unless the caller names an agent. Omit blank required scope fields while preserving HTTP org resolution. Use uint64 for conflict versions so the next-page cursor can round-trip.

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

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
HTTP validates required identity strings before it fills the optional scope. Keep those keys for calls such as context.pack that need to distinguish an empty agent from a missing one. Require namespace management and extraction policy calls to name the object they manage.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
A user- or session-scoped history call has no single-user agent default. Omit an unspecified agent so the required-field check runs instead of querying rows with an empty writer.

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 prior collection-delete, memory-update and conflict-cursor findings are fixed. The focused Go request test still sends an agent selector that the caller omitted from memory.clear. The generated SDK also needs an explicit namespace for rollback writes and a typed snapshot-to-restore path.

Comment thread scripts/codegen/sdk_go_gen.py Resolved
Comment thread sdk/go/client.gen.go Resolved
Comment thread scripts/codegen/sdk_go_gen.py Resolved
Keep omitted memory clear selectors unset, require a named namespace for rollback writes, and share the snapshot payload with restore.

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

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 SDK preserves an omitted clear selector, requires a named namespace to apply a rollback, and passes the typed snapshot payload directly to restore. The Go tests, generator checks, and six code-generation tests pass.

@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 sender census reports the same stale plugin client fingerprints on this CI merge and on clean main. The test passes locally with both fingerprint repairs. PR job · Main job · Plugin repair #1773 · SDK repair #1706

The extraction classification test also fails on main because changed_files has no content classification. PR job · Repair #1747

@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 tunable-constant gate flags the same duplicate coverage limit on this head and on clean main. The coverage repair keeps the store's existing bounds. PR job · Main job · Coverage repair #1722

The adoption directory test fails on this head and on clean main because ClickHouse expires its fixed snapshot rows. The repair derives fixture dates from UTC. PR job · Main job · Adoption repair #1740

@zlareb1
zlareb1 merged commit 9542ca8 into ClickHouse:main Nov 30, 2026
73 of 78 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