Repository navigation
test(golang): run the Go SDK rows and queries through EQL v4 in PostgreSQL - #1291
Conversation
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Mutation testing (cargo-mutants,
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
freshtonic
left a comment
There was a problem hiding this comment.
Approved. This is a real round-trip and query test. It checks the exact rows for =, <, <=, >, >= and @@. It checks EQL's own refusal for operators that a type does not answer. It also checks decryption after the jsonb round trip through PostgreSQL.
What I checked
- In the
eql-postgresCI log, all 32 types andTestQueriesRunAgainstPostgresshow--- PASS. Nothing skipped. - EQL is installed from the tree (
mise -C packages/eql run build, thencipherstash-encrypt-v4.sql). It does not come from a registry pin. - The new path filters cover the
#MISE sourcesoftasks/build.sh. - The test skips only when
DATABASE_URLis not set. It fails wheneql_v4is missing. The CI task turns a skip into a failure. The job gets noCS_*secrets.
There are two small hardening points inline. Neither one blocks the merge.
039a665 to
02e49dc
Compare
…tgreSQL Nothing in CI ran the path a Go program takes: rows the Go SDK stores in EQL columns, found by queries the Go SDK derives, through EQL's operators. encrypt/postgres_test.go stores terms in bytea columns with no EQL, and the Rust encryption suite runs EQL in PostgreSQL but derives its own queries, so a change that put Go and the SQL out of step failed nowhere (#1289). TestEQLTypesRoundTripAndQueryInPostgres walks eql.Types, the table generated from the EQL catalog, and for every type the engine produces declares a field of it at run time through gensupport, stores four rows in a column of its domain, and runs each query its indexes answer (=, <, <=, >, >= and @@) through the operand domain, asserting the exact rows. A type with no query for an operator must be refused with EQL's own error. The rows are read back from PostgreSQL, which stores jsonb re-serialised, and opened. A type whose plaintext or index the test has no case for fails rather than skipping, so a type the engine starts producing is covered or loudly not. With DATABASE_URL set and no eql_v4 schema it fails: a skip reads the same as a pass. CI runs it in a new eql-postgres job in tests-golang.yml, after wasi-check and on its guests, against postgres:17 with the bundle `mise run build` writes from the tree, through the new `mise run go:test:postgres` task (also the local entry point, against EQL_TEST_DATABASE_URL). The task fails if either PostgreSQL test skips. The existing bytea test moves there with it, since its database now carries EQL. The workflow's filters gain EQL's SQL sources and the codegen that writes the bundle. `eql_v4.between` is not covered: the Go SDK derives no EQL range term yet (Range on an EQL ordered field is refused by the engine), so there is no Go query to run through it. Closes #1289 Claude-Session: https://claude.ai/code/session_01XQN1QpaWVDGjHEg39KEJF3
next now produces the ten block ORE types (IntegerOrdOre, TextSearchOre and the rest), and the test fails on an index it has no query for, as it is meant to. ore_block answers lt, lte, gt and gte, as ore and ope do. All 49 producible types pass against PostgreSQL 17. Claude-Session: https://claude.ai/code/session_01XQN1QpaWVDGjHEg39KEJF3
9d8769f to
0986a92
Compare
…ad back short From review. go test -run with a pattern that matches nothing prints "no tests to run" and PASS, so a renamed test left the job green: the task now requires each test's own --- PASS line. The test also checks rows.Err() after reading the stored rows back, and that it opened as many rows as it stored, so a short read or decrypt cannot check fewer rows and pass. Claude-Session: https://claude.ai/code/session_01XQN1QpaWVDGjHEg39KEJF3
Optional fields are what #1298 is for, and nothing ran a stored nil through EQL in PostgreSQL. Each type now gets a fifth row with no value, stored as the engine requires for it. A type of fixed width with no index or equality alone stores a sealed null (17 types): its c must be as long as a value's, EqNull must find it and only it, and IS NULL must find nothing. Text and every ordered or match type store SQL NULL (32 types): IS NULL finds it, and no value query does. The nil row opens as nil. Breaking the length check and the EqNull check on purpose fails all 17 and all 8 types they cover. Claude-Session: https://claude.ai/code/session_01XQN1QpaWVDGjHEg39KEJF3
|
Follow-up filed: #1343, random-value order tests through PostgreSQL. The fixed values here can miss a comparator that is wrong only for some inputs. |
Summary
The Go SDK (
languages/golang/encrypt) is what the pilot customer runs. A Go program stores encrypted rows in EQL columns: EQL (Encrypt Query Language) is the SQL library we install into PostgreSQL as theeql_v4schema, with one column type per EQL type and the operators that compare encrypted search terms. The program then finds those rows with queries the Go SDK derives.Nothing in CI ran that path. This PR adds a Go test that does, for every EQL type the engine can produce, and a CI job that runs it against PostgreSQL 17 with the EQL v4 bundle built from this branch.
Stacked on #1290; the base will move to
nextwhen that merges.Changes
languages/golang/encrypt/eql_postgres_test.go:TestEQLTypesRoundTripAndQueryInPostgres. It walkseql.Types, the table generated from the EQL catalog. For each producible type (32 onnext) it declares a field of that type at run time throughgensupport, then:=,<,<=,>,>=,@@) and asserts the exact rows found;A type whose plaintext kind or index has no case in the test fails rather than skipping, so a type the engine starts producing is either covered or loudly not.
If
DATABASE_URLis set buteql_v4isn't installed there, the test fails with "EQL v4 is not installed in DATABASE_URL" rather than skipping.mise run go:test:postgres: builds the EQL v4 bundle from the tree (packages/eql,mise run build), installs it intoEQL_TEST_DATABASE_URL, and runs both Go PostgreSQL tests. It fails if either one skips..github/workflows/tests-golang.yml:eql-postgresjob runs afterwasi-check. It uses the deterministic test guests that job already builds and checksums (the guests are the Rust engine compiled to WebAssembly), and runs the task above against apostgres:17service.TestQueriesRunAgainstPostgres) moves there too. Its database now carries EQL, andwasi-check's plain Postgres service is gone.AGENTS.md: the CI summary names the new job and the local task.Verification
postgres:17container with the tree's v4 bundle: all 32 producible types pass, andTestQueriesRunAgainstPostgrespasses alongside.<failed exactly the 13 ordered types.DATABASE_URLpointing at a database without EQL, the test fails with the message above. WithDATABASE_URLunset, it skips, as it will on the macOS and Windows jobs.mise run go:test:postgrespassed. With the plain deterministic guest not built, it failed on the skip, as intended.go vetandgolangci-lint(0 issues) are clean.pnpm run test:scriptspasses (80 files, 1409 passed; this coverscrates-ci.test.mjsfor the new task's CI caller and the EQL workflow guards).actionlintis clean.Related
Review notes
eql_v4.between. The Go SDK can't derive an EQL range term yet: asking for a range on an EQL ordered field returns "the field's type does not answer the operator". So there is no Go query to run throughbetween. When the SDK gains it, the test needs a case for the range index.…OrdOretypes are not producible onnext, so the test skips them througheql.Types. They'll be covered automatically once feat(eql)!: produce the block ORE EQL v4 types through ore-rs 6-bit block ORE #1280 makes them producible, with no change here.https://claude.ai/code/session_01XQN1QpaWVDGjHEg39KEJF3