These files show the Go SDK from the plan builder design as complete programs.
The SDK does not exist yet, so this code does not build in this repository.
The module path is example.com/app.
What each file shows
Each directory has a README.md that walks through its code.
The file the rules give for the protobuf message, and a store that uses it
The users example uses TextEq, which is the one EQL type the engine produces today.
What was checked
Claim
Status
Every Go file type-checks
Run. go vet ./... passes against a stub of the SDK. The stub is not in this repository, and it has signatures only.
The policy example compiles against real protobuf code
Run. buf v1.50.0 and protoc-gen-go wrote internal/pb/, and go vet passes.
A field added to the protobuf message does not stop the build
Run. It builds, as the plan says: CI finds that change.
The protobuf source reads the field options, and the rules run
Not run. Neither the source nor the generator exists.
A change to a tagged struct, a model or a type in another package stops the build
Run. Each change fails go build with "cannot convert".
sqlc's row struct converts to the generated type
Run. The conversions in users/sqlcstore.go compile against real sqlc output.
A struct from another package with an unexported field cannot convert
Run, with sync.Once.
A generated file from another version does not compile
Run. A file that names an unknown version constant fails go build.
The files stashgen writes
Not run. stashgen does not exist, and the five _stash.go files are written by hand.
The SDK can be built with these signatures
Not run.
The record fixture
Not run. It does not exist.
The guest returns an EQL value for a field with encrypt_into
Not run. The target form and the dispatch do not exist.
stashgen checks a declaration with the embedded guest
Not run.
The code works with a database, GORM or pgx
Not run. Nothing here has connected to a database.
The EQL types, and the value the guest returns for them
Not run. eql-codegen does not write Go yet, and the examples use a stub of eql.TextEq.
The steps in "Use the SDK"
Not run. Nobody has followed them.
Generate the protobuf package
The protobuf package was generated with buf v1.50.0 and protoc-gen-go.
Run buf generate in proto/ to generate it again.
Generate the sqlc package
The sqlc package was generated with sqlc v1.31.1.
Run sqlc generate in sqlc/ to generate it again.
Use sqlc with EQL columns
Three rules apply when a column has an EQL type:
Give sqlc a file that declares the domains.
sqlc cannot parse the EQL install bundle, because it rejects function overloads that differ only by text and text[].
The file sqlc/eql-domains.sql declares each domain as jsonb, and the database still gets the real bundle from stash eql install.
Spell a db_type override exactly as the schema spells the type.public.eql_v3_text_eq and eql_v3_text_eq are two different spellings to sqlc.
An override with the other spelling matches nothing, and the column becomes interface{}.
Cast a query parameter once, straight to the query domain.
sqlc types a parameter by its first cast.
$1::eql_v3.query_text_eq gets the override type, and $1::jsonb::eql_v3.query_text_eq gets json.RawMessage.