From 4c8843c93e0c517207ba72c2bc820a5c0d0c67a7 Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Fri, 27 Nov 2026 16:00:57 +1100 Subject: [PATCH 1/4] docs(golang): keep contributor detail out of exported doc comments pkg.go.dev shows the doc comments on exported names. Several named Rust crates and types, the engine's internal exports, and the storage format. A user of the SDK cannot act on those. Each comment now says what the name does and which errors it returns. The contributor detail moved to ordinary comments in the function body or above the doc comment. The comment on encrypt/eql.Types is generated, so the generator in eql-codegen changed with it. Only comment lines changed. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CtEQzxj55RUn35dkbhdwQk --- languages/golang/CHANGELOG.md | 8 ++++ languages/golang/auth/errors.go | 4 +- languages/golang/auth/oauth2.go | 2 +- languages/golang/auth/store.go | 26 +++++++----- languages/golang/auth/strategy.go | 28 +++++++++---- languages/golang/auth/token.go | 10 +++-- languages/golang/auth/transport.go | 2 +- languages/golang/encrypt/audit.go | 7 ++-- languages/golang/encrypt/cipher.go | 15 +++---- languages/golang/encrypt/ciphertext.go | 33 ++++++++------- languages/golang/encrypt/client.go | 20 +++++---- languages/golang/encrypt/credentials.go | 18 ++++---- languages/golang/encrypt/eql/eql.go | 9 ++-- languages/golang/encrypt/eql/eql_gen.go | 8 ++-- languages/golang/encrypt/errors.go | 21 ++++++---- .../golang/encrypt/gensupport/declaration.go | 41 +++++++++++-------- languages/golang/encrypt/json.go | 4 +- languages/golang/encrypt/keyset.go | 12 +++--- languages/golang/encrypt/options.go | 4 +- languages/golang/encrypt/term.go | 21 ++++++---- languages/golang/stashgen/declaration.go | 12 +++--- languages/golang/stashgen/engine.go | 17 ++++---- packages/eql/crates/eql-codegen/src/go_eql.rs | 8 ++-- 23 files changed, 197 insertions(+), 133 deletions(-) diff --git a/languages/golang/CHANGELOG.md b/languages/golang/CHANGELOG.md index 6833efd306..ef5726c1b2 100644 --- a/languages/golang/CHANGELOG.md +++ b/languages/golang/CHANGELOG.md @@ -22,6 +22,14 @@ and `languages/golang/encrypt/encrypttest/vX.Y.Z` on the same commit. `[16]byte` (`github.com/google/uuid.UUID`, say), which is converted to one. `stashgen` does not yet map a Go type to it. +### Changed + +- The doc comments on exported names in `encrypt`, `encrypt/eql`, + `encrypt/gensupport`, `auth`, and `stashgen` now say what each name does + and which errors it returns. The Rust crate and type names, the + engine's internal exports, and the storage format moved to ordinary code + comments. pkg.go.dev does not show those comments. Only comments changed. + ## [0.1.0-rc.7] - 2026-11-25 ### Upgrading from rc.6 diff --git a/languages/golang/auth/errors.go b/languages/golang/auth/errors.go index 72fc2a7d0a..58af1d5a5e 100644 --- a/languages/golang/auth/errors.go +++ b/languages/golang/auth/errors.go @@ -92,7 +92,7 @@ var ( type Diagnostic = guest.Diagnostic // Cause is one error in a [Diagnostic]'s cause chain: a Code and a Message. -// A cause from a library outside the stack crates has no Code, and its -// Message is a description the guest vouches for, never that library's own +// A cause from a library the SDK uses, outside its own code, has no Code. +// Its Message is a description the guest writes, never that library's own // text. type Cause = guest.Cause diff --git a/languages/golang/auth/oauth2.go b/languages/golang/auth/oauth2.go index be7f83b01b..a5c920b803 100644 --- a/languages/golang/auth/oauth2.go +++ b/languages/golang/auth/oauth2.go @@ -8,7 +8,7 @@ import ( ) // OAuth2TokenSource adapts an existing x/oauth2 provider to OIDCProvider. -// Its AccessToken is read afresh whenever the Rust federation strategy asks. +// Its AccessToken is read again each time the federation strategy asks. func OAuth2TokenSource(source oauth2.TokenSource) OIDCProvider { return OIDCProviderFunc(func(context.Context) (string, error) { if source == nil { diff --git a/languages/golang/auth/store.go b/languages/golang/auth/store.go index a06bbc3101..45366c1253 100644 --- a/languages/golang/auth/store.go +++ b/languages/golang/auth/store.go @@ -86,9 +86,10 @@ type root struct { cleanup runtime.Cleanup } -// Resolve opens the profile directory the Rust crate would: CS_CONFIG_PATH -// when set and not blank, else ~/.cipherstash. The directory must exist; -// `stash auth login` creates it. +// Resolve opens the developer profile directory: CS_CONFIG_PATH when set +// and not blank, else ~/.cipherstash. The directory must exist; +// `stash auth login` creates it. A directory that is missing, or is not a +// directory, is [ErrNoProfile]. func Resolve(ctx context.Context, opts ...Option) (*ProfileStore, error) { // Blankness is tested on the trimmed value and the value itself is // used, as ProfileStore::resolve does: a directory named with a space @@ -123,9 +124,10 @@ func Open(ctx context.Context, dir string, opts ...Option) (*ProfileStore, error // [ProfileStore.AccessKey] and [ProfileStore.OIDC] — where there is none to // open: CI, a container, a server authenticating by federation. Every // profile read on it fails with ErrNoProfile, and [ProfileStore.Auto] on it -// is the environment's access key or ErrNotAuthenticated, as stack-auth's -// AutoStrategy is with no profile store. +// is the environment's access key or ErrNotAuthenticated. func OpenWithoutProfile(ctx context.Context, opts ...Option) (*ProfileStore, error) { + // Auto here behaves as stack-auth's AutoStrategy does with no profile + // store. return open(ctx, "", opts) } @@ -367,12 +369,16 @@ func (s *ProfileStore) CurrentWorkspaceStore(ctx context.Context) (*ProfileStore return s.WorkspaceStore(ctx, id) } -// LockPath is the host path of the lock file the Rust crate takes for -// filename in this store: a sibling `..lock`. Nothing is created -// or locked. DeviceSession holds this lock across the guest's refresh call; -// the guest cannot lock under WASI. This package never composes a profile -// path itself. +// LockPath is the host path of the lock file that guards filename in this +// store: a sibling `..lock`. Nothing is created or locked. +// [ProfileStore.DeviceSession] holds this lock while it refreshes a token, +// and the CLI takes the same lock. A filename that is empty, "." or "..", +// or that contains a path separator, is [ErrInvalidFilename]. func (s *ProfileStore) LockPath(ctx context.Context, filename string) (string, error) { + // The lock file is the one the stack-profile crate takes. Go holds the + // lock across the guest's refresh call, because the guest cannot lock + // under WASI. This package never composes a profile path itself. + // // The guest validates the filename as the crate does, against the // guest's separator, which is `/`. The host's is checked here: on // Windows a backslash passes the guest and would become a separator diff --git a/languages/golang/auth/strategy.go b/languages/golang/auth/strategy.go index 5d7f4ab8f4..51df896c37 100644 --- a/languages/golang/auth/strategy.go +++ b/languages/golang/auth/strategy.go @@ -46,8 +46,8 @@ func strategyConfig(opts []StrategyOption) strategyOptions { return o } -// Strategy is a Rust stack-auth strategy retained inside the credential -// guest: the source of the bearer token encrypt.NewCredentials takes. +// Strategy is an auth strategy held inside the credential guest: the +// source of the bearer token encrypt.NewCredentials takes. // Close drops its cached credential; closing the parent profile closes all // its strategies. It is the caller's to close: an encrypt client that // was given it asks it for tokens but never closes it, so it must stay open @@ -77,9 +77,12 @@ func (s *ProfileStore) newStrategy(ctx context.Context, config any, device bool) return &Strategy{store: s, handle: string(out), device: device}, nil } -// AccessKey constructs stack-auth's access-key strategy for crn. The key -// stays in the guest after construction; it is not sent on each Token call. +// AccessKey constructs the access-key strategy for the workspace crn: it +// exchanges key for a token. The key stays in the guest after +// construction; it is not sent on each Token call. An empty crn or key is +// [ErrConfig]. func (s *ProfileStore) AccessKey(ctx context.Context, crn, key string, opts ...StrategyOption) (*Strategy, error) { + // This is stack-auth's access-key strategy. if crn == "" || key == "" { return nil, ErrConfig } @@ -92,7 +95,7 @@ func (s *ProfileStore) AccessKey(ctx context.Context, crn, key string, opts ...S }{"access_key", crn, key, o.baseURL}, false) } -// OIDC constructs stack-auth's federation strategy. provider is called on +// OIDC constructs the OIDC federation strategy. provider is called on // every Token call for the IdP JWT of the user that call is for; the // strategy keeps one CTS token per distinct JWT and mints a new one only // for a JWT that has no unexpired token. [WithCacheCapacity] sets how many @@ -100,6 +103,7 @@ func (s *ProfileStore) AccessKey(ctx context.Context, crn, key string, opts ...S // [ErrConfig]; [ProfileStore.OIDCWithDetectedWorkspace] finds the workspace // instead. func (s *ProfileStore) OIDC(ctx context.Context, crn string, provider OIDCProvider, opts ...StrategyOption) (*Strategy, error) { + // This is stack-auth's federation strategy. if crn == "" || provider == nil { return nil, ErrConfig } @@ -191,8 +195,8 @@ func (s *ProfileStore) detectWorkspaceCRN(ctx context.Context) (string, error) { } // DeviceSession uses this workspace store's auth.json. Fresh tokens are read -// without a lock. A refresh takes the same cross-process lock as the Rust -// CLI, then the guest re-reads and saves before the lock is released. +// without a lock. A refresh takes the same cross-process lock as the CLI, +// then the guest re-reads and saves before the lock is released. func (s *ProfileStore) DeviceSession(ctx context.Context, opts ...StrategyOption) (*Strategy, error) { if s.dir == guestRoot { return nil, ErrConfig @@ -205,9 +209,15 @@ func (s *ProfileStore) DeviceSession(ctx context.Context, opts ...StrategyOption }{"device_session", s.dir, o.baseURL}, true) } -// Auto follows stack-auth's detection order against the Go host's -// environment: access key first, then the current workspace's device token. +// Auto picks a strategy from the environment and the profile. When +// CS_CLIENT_ACCESS_KEY is set, it is [ProfileStore.AccessKey] for the +// workspace CS_WORKSPACE_CRN names. Otherwise it is +// [ProfileStore.DeviceSession] for the current workspace's saved token. +// An access key without CS_WORKSPACE_CRN is [ErrConfig]. No current +// workspace, or no saved token, is [ErrNotAuthenticated]. func (s *ProfileStore) Auto(ctx context.Context, opts ...StrategyOption) (*Strategy, error) { + // The order is stack-auth's AutoStrategy order, read from the Go host's + // environment because the guest has none. crn, crnSet := os.LookupEnv("CS_WORKSPACE_CRN") if crnSet { _, err := s.callArgs(ctx, func(i *instance) api.Function { return i.authValidateCRN }, guest.BufArg([]byte(crn))) diff --git a/languages/golang/auth/token.go b/languages/golang/auth/token.go index 3e9825d6ca..a9f305e924 100644 --- a/languages/golang/auth/token.go +++ b/languages/golang/auth/token.go @@ -11,8 +11,8 @@ import ( ) // Token is the stored access token, as auth.json holds it and -// [ProfileStore.Token] reads it through the Rust crate's own type. The -// refresh token is not in it: the guest handles refresh through a Strategy. +// [ProfileStore.Token] reads it. The refresh token is not in it: a +// [Strategy] refreshes the token. type Token struct { // AccessToken is the bearer credential. AccessToken string @@ -30,9 +30,11 @@ type Token struct { DeviceInstanceID string } +// For contributors: Usable is the stack-auth crate's is_usable, not its is_expired, which +// subtracts a refresh-ahead margin that belongs to refreshing. + // Usable reports whether the token is still usable at now: before its real -// expiry. The Rust crate's is_usable, not its is_expired, which subtracts a -// refresh-ahead margin that belongs to refreshing. +// expiry. It subtracts no margin for an early refresh. func (t Token) Usable(now time.Time) bool { return now.Before(t.ExpiresAt) } // Token reads auth.json in this store (a workspace store; the root holds diff --git a/languages/golang/auth/transport.go b/languages/golang/auth/transport.go index b5c6295a96..9f5730c2b5 100644 --- a/languages/golang/auth/transport.go +++ b/languages/golang/auth/transport.go @@ -17,7 +17,7 @@ import ( ) // OIDCProvider supplies the identity-provider JWT of the user a call is -// for. The Rust federation strategy asks on every Strategy.Token call: the +// for. The federation strategy asks on every Strategy.Token call: the // JWT is how it tells one user from another, and it keeps one CTS token per // distinct JWT, exchanging a JWT only when it has no unexpired CTS token. // So a server that serves many users through one client must return the diff --git a/languages/golang/encrypt/audit.go b/languages/golang/encrypt/audit.go index 6aa93df97e..9904d5959d 100644 --- a/languages/golang/encrypt/audit.go +++ b/languages/golang/encrypt/audit.go @@ -13,6 +13,9 @@ import ( "github.com/cipherstash/stack/languages/golang/internal/record" ) +// For contributors: AuditMetadata is the Rust crate's AuditMetadata, and +// the unverified context of the ZeroKMS protocol. + // AuditMetadata is facts about a call that ZeroKMS writes to its audit log. // // Every Encrypt and Decrypt asks ZeroKMS for data keys. ZeroKMS logs each @@ -28,9 +31,7 @@ import ( // Text("request_id", requestID) // people, err := users.Decrypt(ctx, cipher.Audit(metadata), rows) // -// Audit metadata is optional. A cipher without it sends none. It is the -// Rust crate's AuditMetadata, and the unverified context of the ZeroKMS -// protocol. +// Audit metadata is optional. A cipher without it sends none. // // # Rules // diff --git a/languages/golang/encrypt/cipher.go b/languages/golang/encrypt/cipher.go index 6f4a1b77ab..43d433dc72 100644 --- a/languages/golang/encrypt/cipher.go +++ b/languages/golang/encrypt/cipher.go @@ -47,13 +47,13 @@ func (cph *Cipher) Client() *Client { return cph.client } // Keyset is the selector this cipher is bound to. func (cph *Cipher) Keyset() KeysetSelector { return cph.keyset } -// KeysetID resolves the cipher's keyset to its id: Rust's -// KeysetCipher::keyset_id, and in Go the one explicit resolution point, -// since a Cipher is made without a request. The first use of a name or id -// on the client is one ZeroKMS round trip, later uses come from the -// guest's cache; the default keyset never makes a request. Use it at boot -// to validate a tenant's keyset and learn its id. +// KeysetID resolves the cipher's keyset to its id. Making a Cipher sends no +// request, so this is the one call that resolves a keyset on its own. The +// first use of a name or id on the client is one ZeroKMS round trip, later +// uses come from the guest's cache; the default keyset never makes a +// request. Use it at boot to validate a tenant's keyset and learn its id. func (cph *Cipher) KeysetID(ctx context.Context) (KeysetID, error) { + // Rust's KeysetCipher::keyset_id. return cph.client.resolveKeyset(ctx, cph.keyset) } @@ -158,7 +158,7 @@ func ownedParts(parts []any) []any { // Context returns a cipher that names the context every row through it is // under, for a type whose context is one of its own fields (a field tagged -// `context_field`): the Rust chain's `.context(..)`. Through such a cipher, +// `context_field`). Through such a cipher, // Decrypt checks each row's stored context field against the label before // any key is retrieved and refuses a row that names another with // [ErrContextMismatch]; Encrypt refuses a value whose context field says @@ -171,6 +171,7 @@ func ownedParts(parts []any) []any { // The label is segments separated by '/', such as "tenants/acme"; one that // is not a plain label is reported by the first call, as ErrEncoding. func (cph *Cipher) Context(label string) *Cipher { + // The Rust chain's `.context(..)`. next := cph.copy() next.context = label if _, err := record.ParseContext(label); err != nil && next.err == nil { diff --git a/languages/golang/encrypt/ciphertext.go b/languages/golang/encrypt/ciphertext.go index fb1f5e13db..da740051d6 100644 --- a/languages/golang/encrypt/ciphertext.go +++ b/languages/golang/encrypt/ciphertext.go @@ -7,24 +7,27 @@ import ( "github.com/cipherstash/vitaminc/bindings/go/vcffi" ) -// Ciphertext is one sealed field as a database column holds it: the frozen -// stack-encrypt leaf encoding (version, keyset id, IV, ZeroKMS tag, -// ciphertext). A generated type holds one for each field sealed in separate -// columns, beside that field's terms. It is a distinct type from vitaminc's -// own leaf on purpose: a stack-encrypt leaf is not decryptable by -// vitaminc-encrypt and must never scan or marshal where one belongs. +// For contributors: a Ciphertext is the frozen stack-encrypt leaf encoding +// (version, keyset id, IV, ZeroKMS tag, ciphertext). It is a distinct type +// from vitaminc's own leaf on purpose: a stack-encrypt leaf is not +// decryptable by vitaminc-encrypt and must never scan or marshal where one +// belongs. A sealed field seals as vitaminc's tagged leaf, which a Rust +// record opens when its field is a Value (not a bare u32 or String). An +// opaque struct crosses the binding as one storage blob and is one leaf. + +// Ciphertext is one sealed field as a database column holds it. The bytes +// are a fixed encoding that later releases still read; treat them as +// opaque. A generated type holds one for each field sealed in separate +// columns, beside that field's terms. // // A sealed field is one scalar — a string, a number, a bool or a []byte, or // a type defined over one, or a pointer to either, whose nil is sealed as a -// null as long as a value or stored as SQL NULL — and seals as vitaminc's -// tagged leaf, which a -// Rust record opens when its field is a Value (not a bare u32 or String). A -// struct, slice or map is not a Ciphertext field. It seals as part of an -// opaque struct, which crosses as one storage blob and is one leaf, or as a -// JSON document in a field that names an EQL type which holds one -// (encrypt_into=Json or encrypt_into=JsonSearch). stashgen refuses it -// anywhere else, because the engine would seal it as a tree of leaves and a -// column holds one. +// null as long as a value or stored as SQL NULL. A struct, slice or map is +// not a Ciphertext field. It seals as part of an opaque struct, which is +// stored as one value in one column, or as a JSON document in a field that +// names an EQL type which holds one (encrypt_into=Json or +// encrypt_into=JsonSearch). stashgen refuses it anywhere else, because the +// engine would seal it as many values and a column holds one. type Ciphertext []byte // Value implements driver.Valuer, binding the leaf as a byte column. diff --git a/languages/golang/encrypt/client.go b/languages/golang/encrypt/client.go index 0d17c1527b..dd4ef8303a 100644 --- a/languages/golang/encrypt/client.go +++ b/languages/golang/encrypt/client.go @@ -445,26 +445,28 @@ func (c *Client) release() error { return err } -// Keyset binds the client to one keyset, by name or by id: Rust's -// StackCipher::keyset. No request is made here — Go has no await, so the -// keyset is resolved by the guest on the cipher's first use (and cached), +// Keyset binds the client to one keyset, by name or by id. No request is +// made here: the keyset is resolved on the cipher's first use, and cached, // which makes a Cipher cheap to make per call, per tenant or per request. -// [Cipher.KeysetID] is the explicit resolution point. A nil selector gives a -// cipher whose every call fails with [ErrEncoding]; the default keyset is +// [Cipher.KeysetID] resolves it on its own. A nil selector gives a cipher +// whose every call fails with [ErrEncoding]; the default keyset is // [Client.DefaultKeyset]. func (c *Client) Keyset(sel KeysetSelector) *Cipher { + // Rust's StackCipher::keyset. Go has no await, so the guest resolves + // the keyset on the cipher's first use. if sel == nil { return &Cipher{client: c, keyset: defaultKeyset{}, err: fmt.Errorf("%w: Client.Keyset(nil); the default keyset is Client.DefaultKeyset", ErrEncoding)} } return &Cipher{client: c, keyset: sel} } +// For contributors: DefaultKeyset is Rust's StackCipher::default_keyset. + // DefaultKeyset binds the client to its default keyset — the one a ZeroKMS // administrator set for this client, which is what naming no keyset -// resolves to: Rust's StackCipher::default_keyset. Loaded at NewClient, so -// using it never touches ZeroKMS. There is no way to redefine it from here; -// which keyset is the default is the server's to say. Any other keyset is -// [Client.Keyset]. +// resolves to. Loaded at NewClient, so using it never touches ZeroKMS. +// There is no way to redefine it from here; which keyset is the default is +// the server's to say. Any other keyset is [Client.Keyset]. func (c *Client) DefaultKeyset() *Cipher { return &Cipher{client: c, keyset: defaultKeyset{}} } // resolveKeyset asks the guest for a selector's keyset id: the first use diff --git a/languages/golang/encrypt/credentials.go b/languages/golang/encrypt/credentials.go index bb5c2eec0b..b3129817b0 100644 --- a/languages/golang/encrypt/credentials.go +++ b/languages/golang/encrypt/credentials.go @@ -22,7 +22,7 @@ import ( // and hands the key to the guest. // // [AutoCredentials] is the default: the environment, then the developer -// profile, in the Rust client's order. [AccessKeyCredentials] takes four +// profile, in that order. [AccessKeyCredentials] takes four // values from a struct the program fills, with no fallback. [NewCredentials] // takes a client id, a client key, and a strategy explicitly. [OIDCFederation] // exchanges a token from an identity provider for a CipherStash token, and @@ -182,13 +182,17 @@ const ( // the first that is set decides, and CS_VITUR_HOST is the legacy name. var envZeroKMSHost = []string{"CS_ZEROKMS_HOST", "CS_VITUR_HOST"} +// For contributors: AutoCredentials follows stack-encrypt's +// StackCipher::with_detected_credentials(), and the token follows +// stack-auth's AutoStrategy order. + // AutoCredentials is [Credentials] from the environment first, then the -// developer profile `stash auth login` writes — the order the Rust client -// (stack-encrypt's StackCipher::with_detected_credentials()) resolves them -// in, so one set of variables configures a service in either language: +// developer profile `stash auth login` writes. The Rust SDK resolves them +// in the same order, so one set of variables configures a service in +// either language: // -// - The token, by stack-auth's AutoStrategy order: CS_CLIENT_ACCESS_KEY -// (with CS_WORKSPACE_CRN, which is then required) exchanged for a token; +// - The token: CS_CLIENT_ACCESS_KEY (with CS_WORKSPACE_CRN, which is +// then required) exchanged for a token; // else the current workspace's stored device session, refreshed under // the same cross-process lock as the CLI. CS_CTS_HOST overrides the // authentication endpoint. @@ -199,7 +203,7 @@ var envZeroKMSHost = []string{"CS_ZEROKMS_HOST", "CS_VITUR_HOST"} // // The profile is CS_CONFIG_PATH, else ~/.cipherstash; a profile that cannot // be opened is not an error — an environment-only deployment has none — it -// just leaves the environment as the only source, as the Rust client does. +// just leaves the environment as the only source. // Nothing found in either place is [ErrNoCredentials], and when the profile // would have been consulted, that error says why it could not be: a // directory that does not exist, one that cannot be read, a path that is diff --git a/languages/golang/encrypt/eql/eql.go b/languages/golang/encrypt/eql/eql.go index 76d49448e8..a4d9c16561 100644 --- a/languages/golang/encrypt/eql/eql.go +++ b/languages/golang/encrypt/eql/eql.go @@ -38,9 +38,12 @@ import ( "log/slog" ) -// Type is one EQL type as the catalog describes it: what stashgen learns -// from the engine's se_targets export, in Go. Name is the engine's name, -// the value of encrypt_into; GoName is the type's name in this package. +// For contributors: Type is what stashgen learns from the engine's +// se_targets export, in Go. + +// Type is one EQL type as the catalog describes it. Name is the engine's +// name, the value of encrypt_into; GoName is the type's name in this +// package. type Type struct { // Name is the type's name across languages, and the engine's: TextEq. Name string diff --git a/languages/golang/encrypt/eql/eql_gen.go b/languages/golang/encrypt/eql/eql_gen.go index ec9c9cecde..cbd0065069 100644 --- a/languages/golang/encrypt/eql/eql_gen.go +++ b/languages/golang/encrypt/eql/eql_gen.go @@ -8,10 +8,10 @@ import ( "log/slog" ) -// Types is every EQL type the catalog has, in catalog order: what the -// engine's se_targets export lists, as Go. Producible says whether the -// engine produces the type today; stashgen refuses encrypt_into for one -// it does not, with the Reason. +// Types is every EQL type the catalog has, in catalog order. +// Producible says whether the engine produces the type today; +// stashgen refuses encrypt_into for one it does not, with the +// Reason. var Types = []Type{ {Name: "Integer", GoName: "Integer", Family: "integer", Suffix: "", Plaintext: "int32", SQLDomain: "public.eql_v4_integer", Indexes: nil, Query: "", QuerySQLDomain: "", Producible: true, Reason: ""}, {Name: "IntegerEq", GoName: "IntegerEq", Family: "integer", Suffix: "Eq", Plaintext: "int32", SQLDomain: "public.eql_v4_integer_eq", Indexes: []string{"eq"}, Query: "IntegerEqQuery", QuerySQLDomain: "eql_v4.query_integer_eq", Producible: true, Reason: ""}, diff --git a/languages/golang/encrypt/errors.go b/languages/golang/encrypt/errors.go index 15b9dc9313..3c73aa4f2d 100644 --- a/languages/golang/encrypt/errors.go +++ b/languages/golang/encrypt/errors.go @@ -69,12 +69,18 @@ var ( ErrMemoryLock = guest.ErrMemoryLock ) -// ErrStorageVersion is an opaque struct sealed as a storage blob of a -// version this release does not read: a later release wrote it. Its error -// wraps [ErrEncoding] too. It is vcffi.ErrUnsupportedVersion, named here so -// a program can check for it without importing vitaminc's bindings. +// For contributors: ErrStorageVersion is vcffi.ErrUnsupportedVersion, named +// here so a program can check for it without importing vitaminc's bindings. + +// ErrStorageVersion is an opaque struct stored in a format version this +// release does not read: a later release wrote it. Open it with that +// release or a later one. Its error wraps [ErrEncoding] too. var ErrStorageVersion = vcffi.ErrUnsupportedVersion +// For contributors: a guest built before the detail existed returns the +// bare sentinel, with no Diagnostic. Package encrypt always runs the guest +// it embeds, so only an old build in a checkout does that. + // Diagnostic is the full error behind a failure the guest reports, beside // the kind: every such failure is a *Diagnostic wrapping one of the // sentinels above, so errors.Is matches the kind and errors.As reads the @@ -102,14 +108,13 @@ var ErrStorageVersion = vcffi.ErrUnsupportedVersion // // Errors the client raises itself carry none: a closed client ([ErrState]), // a guest that did not return, [ErrMemoryLock], and an argument refused -// before it reached the guest. A guest built before the detail existed -// returns the bare sentinel too. +// before it reached the guest. // // It is the same type as auth.Diagnostic, by identity. type Diagnostic = guest.Diagnostic // Cause is one error in a [Diagnostic]'s cause chain: a Code and a Message. -// A cause from a library outside the stack crates has no Code, and its -// Message is a description the guest vouches for, never that library's own +// A cause from a library the SDK uses, outside its own code, has no Code. +// Its Message is a description the guest writes, never that library's own // text. type Cause = guest.Cause diff --git a/languages/golang/encrypt/gensupport/declaration.go b/languages/golang/encrypt/gensupport/declaration.go index 5ceb7ae8b7..3047e3ae82 100644 --- a/languages/golang/encrypt/gensupport/declaration.go +++ b/languages/golang/encrypt/gensupport/declaration.go @@ -10,14 +10,18 @@ import ( "github.com/cipherstash/stack/languages/golang/internal/record" ) -// Kind is a field's wire type: the data form of the Rust chain's `::`, -// chosen by stashgen from the field's Go type. It decides the terms a field -// derives; every field seals as vitaminc's tagged leaf whatever its kind, -// which a Rust record opens when its field is a Value. Every sealed field has a -// scalar kind: stashgen refuses a struct, slice or map outside an opaque -// struct, and an opaque struct seals as Bytes (one storage blob). Untyped -// names a field with no declared type; generated code never writes it, and -// the engine refuses a plan whose indexed field has no type. +// For contributors: Kind is the data form of the Rust chain's `::`. +// Every field seals as vitaminc's tagged leaf whatever its kind, which a +// Rust record opens when its field is a Value. An opaque struct crosses as +// one storage blob. + +// Kind is a field's wire type, chosen by stashgen from the field's Go type. +// It decides the terms a field derives; the ciphertext has the same format +// whatever the kind. Every sealed field has a scalar kind: stashgen refuses a +// struct, slice or map outside an opaque struct, and an opaque struct seals +// as Bytes. Untyped names a field with no declared type; generated code +// never writes it, and the engine refuses a plan whose indexed field has no +// type. type Kind string // The kinds. Each Go integer type has the kind of its own width: int8 is @@ -49,7 +53,7 @@ const ( Timestamp Kind = "timestamp" String Kind = "string" Bytes Kind = "bytes" - // UUID is a UUID: sixteen bytes under vitaminc's uuid logical type. + // UUID is a UUID: sixteen bytes. // Its value is a vcvalue.UUID, or a value of any type whose underlying // type is [16]byte (github.com/google/uuid.UUID, say), which is // converted to one. @@ -61,13 +65,15 @@ const ( JSON Kind = "json" ) +// For contributors: an opaque struct crosses the binding as one storage +// blob (vitaminc's storage profile, version 1), because the engine seals a +// composite value as a tree of leaves, and an opaque struct is one column. + // OpaqueField is the one field of an opaque declaration: the whole struct, -// sealed as one value under /value. The struct crosses the binding -// as one storage blob (vitaminc's storage profile, version 1) — the engine -// seals a composite value as a tree of leaves, and an opaque struct is one -// column. A field of a struct, map or slice type that names an EQL type -// holding a JSON document is the other way one is stored as one column. A value an earlier release sealed is a JSON document, which -// [Opaque] still reads. +// sealed as one value under /value and stored in one column. A +// field of a struct, map or slice type that names an EQL type holding a +// JSON document is the other way one is stored as one column. A value an +// earlier release sealed is a JSON document, which [Opaque] still reads. const OpaqueField = "value" type verb uint8 @@ -309,10 +315,11 @@ func (d Declaration) Err() error { return d.err } // Contexts asks the engine which contexts this declaration's fields are // sealed and indexed under, before any key is requested: one line per field, // then one indented line with its context, such as "email\n context: users / -// email\n". The text is [encrypt.Checker.Contexts]'s, and the same as a Rust -// record's contexts() for the same declaration. A test pins it with +// email\n". The text is [encrypt.Checker.Contexts]'s. A test pins it with // encrypttest.AssertContexts. func (d Declaration) Contexts(ctx context.Context, checker *encrypt.Checker) (string, error) { + // The text is the same as a Rust record's contexts() for the same + // declaration. plan, err := d.plan() if err != nil { return "", err diff --git a/languages/golang/encrypt/json.go b/languages/golang/encrypt/json.go index 20d6e110ac..3a5df26876 100644 --- a/languages/golang/encrypt/json.go +++ b/languages/golang/encrypt/json.go @@ -17,8 +17,8 @@ import ( ) // JSONOpen opens the rows that a read of a JSON document field returned. -// It calls the guest's se_json_open, and checks the rows against the -// request that prepared the read. The request is +// It checks the rows against the request that prepared the read. The +// request is // `{"operation": "selector" | "subtree", "path", "wildcard_bound"}`. The // rows argument has one group per database row: // diff --git a/languages/golang/encrypt/keyset.go b/languages/golang/encrypt/keyset.go index 39e9f40dd2..d860649967 100644 --- a/languages/golang/encrypt/keyset.go +++ b/languages/golang/encrypt/keyset.go @@ -7,11 +7,13 @@ import ( "github.com/cipherstash/vitaminc/bindings/go/vcffi" ) -// KeysetSelector names the keyset a call binds to, as Rust's IdentifiedBy -// does: [KeysetName] or [KeysetID]. Every variant is spelled, there is no -// empty-string or nil sentinel; the default keyset is not a selector but -// [Client.DefaultKeyset], exactly as it is a method and not an IdentifiedBy -// variant in Rust. Names follow ZeroKMS's rules +// For contributors: KeysetSelector is Rust's IdentifiedBy. The default +// keyset is a method, not an IdentifiedBy variant, in both languages. + +// KeysetSelector names the keyset a call binds to: [KeysetName] or +// [KeysetID]. Every variant is spelled, there is no empty-string or nil +// sentinel; the default keyset is not a selector but +// [Client.DefaultKeyset]. Names follow ZeroKMS's rules // (non-empty, at most 64 bytes, of A-Z a-z 0-9 _ - /), checked by the // guest before any request is made; ZeroKMS itself never issues a // UUID-shaped name, so a name and an id cannot be confused. diff --git a/languages/golang/encrypt/options.go b/languages/golang/encrypt/options.go index fc006af266..7f15cdef25 100644 --- a/languages/golang/encrypt/options.go +++ b/languages/golang/encrypt/options.go @@ -48,8 +48,10 @@ func WithCredentials(c Credentials) ClientOption { } // WithKeysetCacheSize sets how many keysets beyond the default the guest -// keeps loaded. Zero means the crate default (1024); negative is refused. +// keeps loaded. Zero means the default, 1024. NewClient refuses a negative +// size with [ErrEncoding]. func WithKeysetCacheSize(n int) ClientOption { + // The default of 1024 is the stack-encrypt crate's. return func(o *clientOptions) { o.keysetCacheSize = n } } diff --git a/languages/golang/encrypt/term.go b/languages/golang/encrypt/term.go index 1699e80a31..579c8c65ce 100644 --- a/languages/golang/encrypt/term.go +++ b/languages/golang/encrypt/term.go @@ -10,10 +10,12 @@ import ( "github.com/cipherstash/stack/languages/golang/internal/record" ) +// For contributors: the index words are the Rust API's words for the same +// behaviour. + // Index is one index on a field, as a generated declaration names it: -// [Equality], [Ore], [Ope], [Match] or [JSON]. The words are the Rust API's -// words for the same behaviour, and a declaration in any language spells -// them the same way. +// [Equality], [Ore], [Ope], [Match] or [JSON]. A declaration in any +// language spells them the same way. type Index interface { // Output is the index's wire key. Output() record.Output @@ -131,13 +133,14 @@ func (t MatchTerm) Positions() ([]uint16, error) { // as an EQL type, which the database compares correctly. type OreTerm []byte -// Compare orders two ORE terms as their plaintexts: -1, 0 or +1. Ports the -// CLLW comparison of the Rust crate (constant time over the term bytes): -// at the first differing byte the two sides share the PRF block, so they -// differ by exactly the plaintext bit, and the side one greater is the -// greater plaintext. Terms of different lengths (strings, byte slices) -// compare on their common prefix, then the shorter is less. +// Compare orders two ORE terms as their plaintexts: -1, 0 or +1. It runs in +// constant time over the term bytes. Terms of different lengths (strings, +// byte slices) compare on their common prefix, then the shorter is less. func (t OreTerm) Compare(other OreTerm) int { + // This ports the CLLW comparison of the Rust crate: at the first + // differing byte the two sides share the PRF block, so they differ by + // exactly the plaintext bit, and the side one greater is the greater + // plaintext. return compareCLLW(t, other) } diff --git a/languages/golang/stashgen/declaration.go b/languages/golang/stashgen/declaration.go index 245357583a..d4b18aee8c 100644 --- a/languages/golang/stashgen/declaration.go +++ b/languages/golang/stashgen/declaration.go @@ -184,7 +184,9 @@ func (o Option) String() string { return o.Key + "=" + o.Value } -// IndexName is the tag word for an index. The words are the Rust API's. +// For contributors: the index words are the Rust API's. + +// IndexName is the tag word for an index. type IndexName string // The index names. @@ -194,10 +196,10 @@ const ( IndexOre IndexName = "ore" IndexOpe IndexName = "ope" IndexJSON IndexName = "json" - // IndexOreBlock is block ORE (ore-rs's 6-bit schemes): the index of an - // EQL type's ORE term (`ob`), TextOrdOre's and IntegerOrdOre's. It is - // not a tag word: a field reaches it by naming such an EQL type - // (encrypt_into=), and indexNames leaves it out. + // IndexOreBlock is block ORE (order-revealing encryption): the index of + // an EQL type's ORE term, TextOrdOre's and IntegerOrdOre's. It is not a + // tag word: a field reaches it by naming such an EQL type + // (encrypt_into=). IndexOreBlock IndexName = "ore_block" ) diff --git a/languages/golang/stashgen/engine.go b/languages/golang/stashgen/engine.go index 8b3db53ed1..a1ab3f6b71 100644 --- a/languages/golang/stashgen/engine.go +++ b/languages/golang/stashgen/engine.go @@ -9,14 +9,16 @@ import ( "github.com/cipherstash/stack/languages/golang/internal/record" ) -// Engine answers the generator's questions about what the Rust engine can do. +// For contributors: [GuestEngine] asks the guest through its se_plan_check, +// se_targets and se_operators exports. + +// Engine answers the generator's questions about what the engine can do. // The generator holds no copy of the engine's rules: every refusal about an // index, an EQL type or a field type comes from here, and so does every // operator a field's query methods name. // -// [GuestEngine] is the SDK's implementation: the WASI guest that package -// encrypt embeds, asked through se_plan_check, se_targets and -// se_operators. +// [GuestEngine] is the SDK's implementation: the engine that package +// encrypt embeds. type Engine interface { // EQLTypes lists the EQL types the engine can produce: each name, its // plaintext kind, its indexes and its query type. @@ -72,10 +74,11 @@ type EQLType struct { wire record.Kind } -// GuestEngine is the engine the SDK embeds: the WASI guest in package -// encrypt, asked through its se_plan_check and se_targets exports. It holds -// no credentials and makes no request. Close it when done. +// GuestEngine is the engine the SDK embeds, in package encrypt. It holds no +// credentials and makes no request. Close it when done. It returns the +// error of [encrypt.NewChecker] when that fails. func GuestEngine(ctx context.Context) (Engine, error) { + // The guest answers through its se_plan_check and se_targets exports. checker, err := encrypt.NewChecker(ctx) if err != nil { return nil, err diff --git a/packages/eql/crates/eql-codegen/src/go_eql.rs b/packages/eql/crates/eql-codegen/src/go_eql.rs index 6484b2d972..3366078705 100644 --- a/packages/eql/crates/eql-codegen/src/go_eql.rs +++ b/packages/eql/crates/eql-codegen/src/go_eql.rs @@ -133,10 +133,10 @@ pub fn render_go_eql() -> String { "{GO_GENERATED_MARKER}\n\npackage eql\n\nimport (\n\t\"database/sql/driver\"\n\t\"fmt\"\n\t\"log/slog\"\n)\n" ); out.push_str( - "// Types is every EQL type the catalog has, in catalog order: what the\n\ - // engine's se_targets export lists, as Go. Producible says whether the\n\ - // engine produces the type today; stashgen refuses encrypt_into for one\n\ - // it does not, with the Reason.\n\ + "// Types is every EQL type the catalog has, in catalog order.\n\ + // Producible says whether the engine produces the type today;\n\ + // stashgen refuses encrypt_into for one it does not, with the\n\ + // Reason.\n\ var Types = []Type{\n", ); for row in &rows { From 081358ed8cfd1cf997ad973c60827456677b4b7c Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Fri, 27 Nov 2026 16:49:04 +1100 Subject: [PATCH 2/4] docs(golang): say how to close GuestEngine and what Keyset(nil) refuses The GuestEngine comment told callers to close the engine, but Engine has no Close method. It now says to assert io.Closer. The Keyset comment said every call through a cipher from a nil selector fails. KeysetID does not check that error, and returns the default keyset's id. The comment now says so. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CtEQzxj55RUn35dkbhdwQk --- languages/golang/encrypt/client.go | 5 +++-- languages/golang/stashgen/engine.go | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/languages/golang/encrypt/client.go b/languages/golang/encrypt/client.go index dd4ef8303a..53caf8f481 100644 --- a/languages/golang/encrypt/client.go +++ b/languages/golang/encrypt/client.go @@ -449,8 +449,9 @@ func (c *Client) release() error { // made here: the keyset is resolved on the cipher's first use, and cached, // which makes a Cipher cheap to make per call, per tenant or per request. // [Cipher.KeysetID] resolves it on its own. A nil selector gives a cipher -// whose every call fails with [ErrEncoding]; the default keyset is -// [Client.DefaultKeyset]. +// whose encrypt, decrypt and query calls fail with [ErrEncoding]. Its +// KeysetID does not fail: it returns the default keyset's id. The default +// keyset is [Client.DefaultKeyset]. func (c *Client) Keyset(sel KeysetSelector) *Cipher { // Rust's StackCipher::keyset. Go has no await, so the guest resolves // the keyset on the cipher's first use. diff --git a/languages/golang/stashgen/engine.go b/languages/golang/stashgen/engine.go index a1ab3f6b71..7dd61eb693 100644 --- a/languages/golang/stashgen/engine.go +++ b/languages/golang/stashgen/engine.go @@ -75,8 +75,10 @@ type EQLType struct { } // GuestEngine is the engine the SDK embeds, in package encrypt. It holds no -// credentials and makes no request. Close it when done. It returns the -// error of [encrypt.NewChecker] when that fails. +// credentials and makes no request. The returned engine is an [io.Closer]: +// close it when done, with a type assertion, as in +// `if c, ok := e.(io.Closer); ok { defer c.Close() }`. It returns the error +// of [encrypt.NewChecker] when that fails. func GuestEngine(ctx context.Context) (Engine, error) { // The guest answers through its se_plan_check and se_targets exports. checker, err := encrypt.NewChecker(ctx) From fb982aae98ef16099d00fde19434a71b3be24132 Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Fri, 27 Nov 2026 16:53:21 +1100 Subject: [PATCH 3/4] docs(golang): drop a test file name from the NewClient example pkg.go.dev shows the comments in ExampleNewClient. One named live_test.go, a file in the repository that a user of the module does not have. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CtEQzxj55RUn35dkbhdwQk --- languages/golang/encrypt/guest_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages/golang/encrypt/guest_test.go b/languages/golang/encrypt/guest_test.go index 32c87ccb67..d04915188d 100644 --- a/languages/golang/encrypt/guest_test.go +++ b/languages/golang/encrypt/guest_test.go @@ -1108,7 +1108,7 @@ func TestEachRequestIsOneStep(t *testing.T) { func ExampleNewClient() { // With no options, NewClient uses AutoCredentials. To supply the // credentials yourself, the token comes from an auth strategy — - // here an access key; live_test.go has a real round trip. The caller + // here an access key. The caller // opened the store and the strategy, and closes them after the client. ctx := context.Background() err := func() error { From 66d72712651d5e058f747e6a8e1f855b66db21c5 Mon Sep 17 00:00:00 2001 From: Lindsay Holmwood Date: Fri, 27 Nov 2026 17:04:26 +1100 Subject: [PATCH 4/4] docs(golang): complete the error lists and the eql package comment From review: - auth.Resolve, OpenWithoutProfile, ProfileStore.Auto and LockPath now list every case the code refuses. - Ciphertext says when a nil pointer is sealed and when it is SQL NULL. - stashgen.IndexName says again that every language spells the tag words the same way. - The encrypt/eql package comment no longer names ADR-0007 or the mise task that generates eql_gen.go. That detail moved to a comment after the package clause. - Two moved notes are wrapped and completed. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CtEQzxj55RUn35dkbhdwQk --- languages/golang/auth/store.go | 12 ++++++++---- languages/golang/auth/strategy.go | 5 +++-- languages/golang/auth/token.go | 5 +++-- languages/golang/encrypt/ciphertext.go | 7 +++++-- languages/golang/encrypt/eql/eql.go | 17 ++++++++++------- languages/golang/stashgen/declaration.go | 3 ++- languages/golang/stashgen/engine.go | 3 ++- 7 files changed, 33 insertions(+), 19 deletions(-) diff --git a/languages/golang/auth/store.go b/languages/golang/auth/store.go index 45366c1253..dd7cdc5eb5 100644 --- a/languages/golang/auth/store.go +++ b/languages/golang/auth/store.go @@ -88,8 +88,9 @@ type root struct { // Resolve opens the developer profile directory: CS_CONFIG_PATH when set // and not blank, else ~/.cipherstash. The directory must exist; -// `stash auth login` creates it. A directory that is missing, or is not a -// directory, is [ErrNoProfile]. +// `stash auth login` creates it. A directory that cannot be found or +// opened, or is not a directory, is [ErrNoProfile]. So is a missing home +// directory when CS_CONFIG_PATH is unset. func Resolve(ctx context.Context, opts ...Option) (*ProfileStore, error) { // Blankness is tested on the trimmed value and the value itself is // used, as ProfileStore::resolve does: a directory named with a space @@ -124,7 +125,9 @@ func Open(ctx context.Context, dir string, opts ...Option) (*ProfileStore, error // [ProfileStore.AccessKey] and [ProfileStore.OIDC] — where there is none to // open: CI, a container, a server authenticating by federation. Every // profile read on it fails with ErrNoProfile, and [ProfileStore.Auto] on it -// is the environment's access key or ErrNotAuthenticated. +// is the environment's access key or ErrNotAuthenticated. Auto returns +// ErrConfig for an access key without CS_WORKSPACE_CRN, or for a +// CS_WORKSPACE_CRN that is not a CRN. func OpenWithoutProfile(ctx context.Context, opts ...Option) (*ProfileStore, error) { // Auto here behaves as stack-auth's AutoStrategy does with no profile // store. @@ -373,7 +376,8 @@ func (s *ProfileStore) CurrentWorkspaceStore(ctx context.Context) (*ProfileStore // store: a sibling `..lock`. Nothing is created or locked. // [ProfileStore.DeviceSession] holds this lock while it refreshes a token, // and the CLI takes the same lock. A filename that is empty, "." or "..", -// or that contains a path separator, is [ErrInvalidFilename]. +// or that contains `/` or `\`, is [ErrInvalidFilename], on every platform. +// So is a name whose lock file would not be directly in this store. func (s *ProfileStore) LockPath(ctx context.Context, filename string) (string, error) { // The lock file is the one the stack-profile crate takes. Go holds the // lock across the guest's refresh call, because the guest cannot lock diff --git a/languages/golang/auth/strategy.go b/languages/golang/auth/strategy.go index 51df896c37..0a6f0cfd74 100644 --- a/languages/golang/auth/strategy.go +++ b/languages/golang/auth/strategy.go @@ -213,8 +213,9 @@ func (s *ProfileStore) DeviceSession(ctx context.Context, opts ...StrategyOption // CS_CLIENT_ACCESS_KEY is set, it is [ProfileStore.AccessKey] for the // workspace CS_WORKSPACE_CRN names. Otherwise it is // [ProfileStore.DeviceSession] for the current workspace's saved token. -// An access key without CS_WORKSPACE_CRN is [ErrConfig]. No current -// workspace, or no saved token, is [ErrNotAuthenticated]. +// An access key without CS_WORKSPACE_CRN is [ErrConfig], and so is a +// CS_WORKSPACE_CRN that is set but is not a CRN, with or without an access +// key. No current workspace, or no saved token, is [ErrNotAuthenticated]. func (s *ProfileStore) Auto(ctx context.Context, opts ...StrategyOption) (*Strategy, error) { // The order is stack-auth's AutoStrategy order, read from the Go host's // environment because the guest has none. diff --git a/languages/golang/auth/token.go b/languages/golang/auth/token.go index a9f305e924..9c593579cd 100644 --- a/languages/golang/auth/token.go +++ b/languages/golang/auth/token.go @@ -30,8 +30,9 @@ type Token struct { DeviceInstanceID string } -// For contributors: Usable is the stack-auth crate's is_usable, not its is_expired, which -// subtracts a refresh-ahead margin that belongs to refreshing. +// For contributors: Usable is the stack-auth crate's is_usable, not its +// is_expired, which subtracts a refresh-ahead margin that belongs to +// refreshing. // Usable reports whether the token is still usable at now: before its real // expiry. It subtracts no margin for an early refresh. diff --git a/languages/golang/encrypt/ciphertext.go b/languages/golang/encrypt/ciphertext.go index da740051d6..b186848fdc 100644 --- a/languages/golang/encrypt/ciphertext.go +++ b/languages/golang/encrypt/ciphertext.go @@ -21,8 +21,11 @@ import ( // columns, beside that field's terms. // // A sealed field is one scalar — a string, a number, a bool or a []byte, or -// a type defined over one, or a pointer to either, whose nil is sealed as a -// null as long as a value or stored as SQL NULL. A struct, slice or map is +// a type defined over one, or a pointer to either. A nil pointer is sealed +// as a null the same length as a value. With the `null=sql` tag it is +// stored as SQL NULL instead, and stashgen requires that tag for a type of +// variable width or a field with an index other than equality. A struct, +// slice or map is // not a Ciphertext field. It seals as part of an opaque struct, which is // stored as one value in one column, or as a JSON document in a field that // names an EQL type which holds one (encrypt_into=Json or diff --git a/languages/golang/encrypt/eql/eql.go b/languages/golang/encrypt/eql/eql.go index a4d9c16561..c84d4aa582 100644 --- a/languages/golang/encrypt/eql/eql.go +++ b/languages/golang/encrypt/eql/eql.go @@ -5,8 +5,8 @@ // A field with `stash:"email,encrypt_into=TextEq"` is an [TextEq] in the // generated encrypted type, and its Fields entry's Eq returns a // [TextEqQuery]. The guest builds every value: generated code stores what -// the guest returns and never assembles an EQL value itself (ADR-0007, -// amended 2026-10-06). Each type implements driver.Valuer and sql.Scanner +// the guest returns and never assembles an EQL value itself. Each type +// implements driver.Valuer and sql.Scanner // for one column, and json.Marshaler, which writes the value as the JSON // it is. It prints (fmt.Stringer, fmt.Formatter, for every verb) and logs // (slog.LogValuer) as its type's name and never its bytes, so fmt.Sprint @@ -22,13 +22,16 @@ // an EQL type imports this package, so a program with EQL types runs the // build that has them and a program without runs the smaller one. // -// The types and the [Types] table are generated from the EQL catalog by -// eql-codegen (`mise run types:generate` in packages/eql); eql_gen.go is -// committed and drift-gated. [Types] says which types the engine produces -// today; every other type is listed with the reason it cannot be produced -// yet, and stashgen refuses it. +// The types and the [Types] table are generated from the EQL catalog. +// [Types] says which types the engine produces today; every other type is +// listed with the reason it cannot be produced yet, and stashgen refuses it. package eql +// For contributors: that the guest builds every EQL value is ADR-0007, +// amended 2026-10-06. eql-codegen writes eql_gen.go from the catalog +// (`mise run types:generate` in packages/eql); the file is committed and +// drift-gated. + import ( "database/sql/driver" "encoding/json" diff --git a/languages/golang/stashgen/declaration.go b/languages/golang/stashgen/declaration.go index d4b18aee8c..53137a8e32 100644 --- a/languages/golang/stashgen/declaration.go +++ b/languages/golang/stashgen/declaration.go @@ -186,7 +186,8 @@ func (o Option) String() string { // For contributors: the index words are the Rust API's. -// IndexName is the tag word for an index. +// IndexName is the tag word for an index. A declaration in any language +// spells it the same way. type IndexName string // The index names. diff --git a/languages/golang/stashgen/engine.go b/languages/golang/stashgen/engine.go index 7dd61eb693..3129233297 100644 --- a/languages/golang/stashgen/engine.go +++ b/languages/golang/stashgen/engine.go @@ -80,7 +80,8 @@ type EQLType struct { // `if c, ok := e.(io.Closer); ok { defer c.Close() }`. It returns the error // of [encrypt.NewChecker] when that fails. func GuestEngine(ctx context.Context) (Engine, error) { - // The guest answers through its se_plan_check and se_targets exports. + // The guest answers through its se_plan_check, se_targets and + // se_operators exports. checker, err := encrypt.NewChecker(ctx) if err != nil { return nil, err