-
Notifications
You must be signed in to change notification settings - Fork 6
feat(cli): add the stash-sql and stash-edge skills — raw-SQL predicates and the WASM entry #777
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
base: remove-v2
Are you sure you want to change the base?
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,56 @@ | ||
| --- | ||
| 'stash': minor | ||
| '@cipherstash/wizard': minor | ||
| '@cipherstash/stack': patch | ||
| --- | ||
|
|
||
| Two new bundled agent skills for the integrations that don't use an ORM — | ||
| `stash-sql` and `stash-edge` (#754). | ||
|
|
||
| Everything a raw-SQL or edge integration needed was reachable only from | ||
| `dist/*.d.ts` JSDoc, the Postgres catalog, or experiment: grepping the skills | ||
| `stash init` installs for `postgres-js|::jsonb::eql|sql.json|query_text_search` | ||
| returned a single hit, in an unrelated code comment. | ||
|
|
||
| **`stash-sql`** — hand-written SQL over `pg` / `postgres-js`, no ORM. The | ||
| column-domain-to-query-domain operator matrix (which of `=`, `<>`, `<`, `>=`, | ||
| `@@`, `@>` each encrypted domain accepts, and against which `eql_v3.query_*` | ||
| operand), the storage-vs-query payload distinction, per-driver parameter | ||
| binding, recipes for equality / free-text / range / `ORDER BY` / JSON | ||
| containment / JSON field selectors, and the `information_schema` drift check. | ||
| Two failure modes get their mechanism spelled out: pre-stringifying a payload | ||
| on postgres-js double-encodes it into a jsonb *string* scalar, tripping the | ||
| domain CHECK with a message naming neither JSON nor encoding; and leaving an | ||
| operand as bare `jsonb` silently selects a different operator overload — one | ||
| that coerces to the *storage* domain and so rejects the ciphertext-free query | ||
| term. | ||
|
|
||
| **`stash-edge`** — the `@cipherstash/stack/wasm-inline` entry for Deno, | ||
| Supabase Edge Functions, Cloudflare Workers, and Bun. Import specifier per | ||
| runtime, the four mandatory `CS_*` variables and minting them with | ||
| `stash env`, how the WASM client surface differs from the native typed client | ||
| (no `.audit()`, no `.withLockContext()`, per-item bulk shape, ESM-only), and | ||
| the auth-strategy `Result` that must be unwrapped before it reaches | ||
| `config.authStrategy`. | ||
|
|
||
| Both carry **the credential-identity rule**, a silent data-loss footgun now | ||
| also stated in `stash-cli` (under `env` and `encrypt backfill`) and | ||
| `stash-supabase`: EQL index terms derive from the ZeroKMS client key, so rows | ||
| written under one credential and queried under another decrypt correctly and | ||
| never match a query, with no error. | ||
|
|
||
| `stash-encryption` now states that the two entries' schema types **do not | ||
| interchange** — their column classes carry private fields, so TypeScript | ||
| compares them nominally and rejects a shared schema module in both directions. | ||
| It works at runtime, which makes a type assertion the tempting fix; the | ||
| guidance is to author the schema against exactly one entry instead. | ||
|
|
||
| `stash init` / `stash impl` handoffs and the `@cipherstash/wizard` skills | ||
| prompt install both skills for the `postgresql` and `supabase` integrations. | ||
| Drizzle and Prisma Next get cross-links from their own skills instead, since | ||
| those integrations emit correctly-typed operands themselves. | ||
|
|
||
| Also fixes the `@cipherstash/stack/wasm-inline` module JSDoc, which showed | ||
| `OidcFederationStrategy.create(...)`'s `Result` being passed straight to | ||
| `config.authStrategy` without unwrapping — the same JSDoc the raw-SQL surface | ||
| was being reverse-engineered from. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -417,6 +417,8 @@ import { index } from "drizzle-orm/pg-core" | |
|
|
||
| Run `ANALYZE <table>` after the migration applies — an expression index gathers no statistics at `CREATE INDEX` time. For when to create indexes during a rollout (after backfill, before switching reads), engagement rules, and `EXPLAIN` verification, see the `stash-indexing` skill. | ||
|
|
||
| > **Dropping to raw SQL?** `db.execute(sql\`…\`)` bypasses the operators this integration emits, so you own the operand casts yourself — an encrypted predicate needs its needle cast to the column's `eql_v3.query_*` domain, and the driver's parameter-binding rules differ between `pg` and `postgres-js`. The `stash-sql` skill is the reference for both. | ||
|
|
||
|
Comment on lines
+420
to
+421
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. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Avoid nested backticks inside this inline code span. Line 420 embeds a template literal inside an inline Markdown code span, triggering MD038 and risking incorrect rendering. Use a fenced TypeScript example or a placeholder such as 🧰 Tools🪛 markdownlint-cli2 (0.23.0)[warning] 420-420: Spaces inside code span elements (MD038, no-space-in-code) 🪛 SkillSpector (2.3.11)[warning] 27: [RP1] null: npx commands without a version suffix (e.g. Remediation: Pin the version: npx (MCP Rug Pull (RP1)) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||
| ## Migrating an Existing Column to Encrypted | ||
|
|
||
| The hard case: a Drizzle table that already exists in production with live data in a plaintext column you want to encrypt. You can't just change the column type — that would drop the data and break NOT NULL constraints. | ||
|
|
||
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.
📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift
Add example coverage and a documentation-site follow-up.
These changes alter the public
stash init/ wizard handoff workflow and introduce raw-SQL/WASM usage guidance. Add or update repository examples and explicitly track corresponding updates for the separately maintained documentation site.As per coding guidelines, “When public APIs or user-facing workflows change, update repository examples and flag that the separately maintained documentation site needs corresponding updates.”
🤖 Prompt for AI Agents
Source: Coding guidelines