Repository navigation
feat(eql): build the eql_v4 bundle beside eql_v3 #1161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@cipherstash/eql': patch | ||
| --- | ||
|
|
||
| `eql_v3.lints()` now judges only EQL's own `public.eql_v3_*` domains. It used to take every `jsonb` domain in `public`, so a database with another set of encrypted domains installed beside EQL v3 got thousands of false `inlinability_*` errors from the self-check. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| #!/usr/bin/env bash | ||
| #MISE description="DB-free self-test for the v4 isolation gate (clean passes, small and wholesale leaks fail)" | ||
| set -euo pipefail | ||
| REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" | ||
| cd "$REPO_ROOT" | ||
| tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT | ||
|
|
||
| gate() { bash tasks/test/verify_no_v3_in_v4.sh "$@" >/dev/null 2>&1; } | ||
|
|
||
| # CLEAN: names eql_v4, checks version 4, names nothing from v3. | ||
| printf "CREATE SCHEMA eql_v4;\nCHECK (VALUE->>'v' = '4');\n" > "$tmp/clean.sql" | ||
| gate "$tmp/clean.sql" || { echo "FAIL: clean v4 bundle rejected"; exit 1; } | ||
| echo "ok: clean v4 bundle accepted" | ||
|
|
||
| # ONE stray reference. | ||
| printf "CREATE SCHEMA eql_v4;\nSELECT eql_v3.eq_term(x);\n" > "$tmp/one.sql" | ||
| if gate "$tmp/one.sql"; then echo "FAIL: one eql_v3 reference accepted"; exit 1; fi | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The negative cases only check that the gate exits non-zero. The gate exits 2 on bad input (missing or empty file, wrong path) and 1 on a real leak. If the gate crashes, every "rejected" case still passes and only the clean case can fail. Assert exit status 1 specifically. Generated by Claude Code |
||
| echo "ok: one eql_v3 reference rejected" | ||
|
|
||
| # WHOLESALE leak: far more matching lines than a pipe buffer holds. A | ||
| # `grep | head` check under pipefail read this as no leak (SIGPIPE). | ||
| { | ||
| echo "CREATE SCHEMA eql_v4;" | ||
| for i in $(seq 1 20000); do echo "SELECT eql_v3_internal.f$i(eql_v4.g());"; done | ||
| } > "$tmp/wholesale.sql" | ||
| if gate "$tmp/wholesale.sql"; then echo "FAIL: wholesale eql_v3 leak accepted"; exit 1; fi | ||
| echo "ok: wholesale eql_v3 leak rejected" | ||
|
|
||
| # The version check, wholesale too. | ||
| { | ||
| echo "CREATE SCHEMA eql_v4;" | ||
| for i in $(seq 1 20000); do echo "CHECK (VALUE->>'v' = '3');"; done | ||
| } > "$tmp/version.sql" | ||
| if gate "$tmp/version.sql"; then echo "FAIL: wholesale version-3 checks accepted"; exit 1; fi | ||
| echo "ok: wholesale version-3 checks rejected" | ||
|
|
||
| # NON-VACUITY: a file that never names eql_v4 is not a v4 render. | ||
| printf "SELECT 1;\n" > "$tmp/none.sql" | ||
| if gate "$tmp/none.sql"; then echo "FAIL: non-v4 render accepted"; exit 1; fi | ||
| echo "ok: non-v4 render rejected" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| #!/usr/bin/env bash | ||
| #MISE description="Assert the eql_v4 installer and uninstaller name nothing from eql_v3 (DB-free)" | ||
| # | ||
| # ADR-0002 installs one SQL source under two names, so a column's domain says | ||
| # which engine produced its terms. That holds only while the v4 bundle is v3's | ||
| # SQL with EVERY name and version changed. A stray eql_v3 reference installs | ||
| # cleanly and then quietly compares v4 data with v3 terms, or casts a v4 payload | ||
| # to a v3 domain. | ||
| # | ||
| # `eql-codegen render` already refuses a literal eql_v3 in the source. This | ||
| # checks the built artefact, so it also catches a build step that splices text | ||
| # in around the renderer. | ||
| # | ||
| # Usage: verify_no_v3_in_v4.sh [file...] (exit 1 on a leak, 2 on bad input) | ||
| # With no arguments it checks the v4 installer and uninstaller in release/. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" | ||
| cd "$REPO_ROOT" | ||
|
|
||
| if [[ $# -eq 0 ]]; then | ||
| set -- release/cipherstash-encrypt-v4.sql release/cipherstash-encrypt-v4-uninstall.sql | ||
| fi | ||
|
|
||
| # Capture matches before printing them. `grep | head -5` under pipefail is | ||
| # false whenever grep has more output than the pipe holds: head exits, grep | ||
| # dies of SIGPIPE, and a wholesale leak read as no leak at all. | ||
| report() { | ||
| local f=$1 what=$2 hits=$3 | ||
| sed -n "1,5s|^|$f:|p" <<<"$hits" | ||
| echo "ERROR: $f $what (first 5 shown)" >&2 | ||
| fail=1 | ||
| } | ||
|
|
||
| fail=0 | ||
| for f in "$@"; do | ||
| if [[ ! -s "$f" ]]; then | ||
| echo "ERROR: $f missing or empty — run 'mise run build' first" >&2 | ||
| exit 2 | ||
| fi | ||
| # Non-vacuity: a v4 bundle that never names eql_v4 was not rendered as v4. | ||
| if ! grep -q 'eql_v4' "$f"; then | ||
| echo "ERROR: $f never names eql_v4 — not a v4 render" >&2 | ||
| fail=1 | ||
| fi | ||
| if hits=$(grep -n 'eql_v3' "$f"); then | ||
| report "$f" "names eql_v3" "$hits" | ||
| fi | ||
| # The domain CHECKs compare the payload version. Any v3 comparison left in | ||
| # the v4 bundle would admit v3 payloads into v4 columns. | ||
| if hits=$(grep -nE "'v'[[:space:]]*=[[:space:]]*'3'" "$f"); then | ||
| report "$f" "checks for payload version 3" "$hits" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The version check matches only the literal Generated by Claude Code |
||
| fi | ||
| done | ||
|
|
||
| if [[ $fail -ne 0 ]]; then | ||
| echo "v4 isolation gate FAILED" >&2 | ||
| exit 1 | ||
| fi | ||
| echo "v4 isolation gate OK ($# files)" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The v4 installer is covered by few of the v3 checks.
verify_installer_complete.sh(mise.toml) runs only againstcipherstash-encrypt.sql.sync-lockstep-versions.mjsandprepare-bindings-assets.shonly hash and manifest the v3 installer and uninstaller. The symbol-order check is skipped for v4. A truncated or stale v4 bundle could therefore pass every check. Either extend these checks to v4 or state that v4 is internal-only for now.Generated by Claude Code