-
Notifications
You must be signed in to change notification settings - Fork 6
feat(cli): add the stash-postgres 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
Merged
Merged
feat(cli): add the stash-postgres and stash-edge skills — raw-SQL predicates and the WASM entry #777
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6581e73
feat(cli): add the stash-sql and stash-edge skills — raw-SQL predicat…
coderdan 3a085ed
refactor(skills): rename stash-sql to stash-postgres
coderdan 058ea33
docs(skills): scope stash-postgres against Proxy and cite EQL upstream
coderdan 3d12591
docs(skills): drop the usesProxy pointer from the stash-postgres Prox…
coderdan 3aa8a35
docs(skills): separate the database domain from its language mappings
coderdan 256ccce
docs(skills): send agents to EQL for the current type surface
coderdan cb6b32a
docs(skills): stop teaching native-entry bundling in the edge skill
coderdan 9a57509
docs(skills): correct the lock-context explanation in stash-edge
coderdan 0bee554
docs(skills): address CodeRabbit review on #777
coderdan 63cbc6d
docs(skills): reconcile the WASM entry surface after the rebase
coderdan 83b92a2
docs(skills,stack): document the wasm entry as having no lock context
coderdan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| --- | ||
| 'stash': minor | ||
| '@cipherstash/wizard': minor | ||
| '@cipherstash/stack': patch | ||
| --- | ||
|
|
||
| Two new bundled agent skills for the integrations that don't use an ORM — | ||
| `stash-postgres` 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-postgres`** — 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. It also scopes itself against the two things a hand-written-SQL reader | ||
| is otherwise left to infer: **CipherStash Proxy** (where you write plaintext | ||
| SQL and none of the skill applies — the `usesProxy` fork `stash init` already | ||
| asked about), and the provenance of the operator surface itself (the EQL | ||
| bundle from `cipherstash/encrypt-query-language`, version-checkable with | ||
| `SELECT eql_v3.version()`, and where operator gaps should be filed). Its | ||
| domain and operator tables are explicitly marked as a snapshot of a versioned | ||
| surface, with a ranked list of authorities to confirm current types against — | ||
| the EQL skill first, then the generated `@cipherstash/eql` types and install | ||
| SQL, both of which need only `node_modules` and no database. | ||
|
|
||
| **`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, a required | ||
| `table` argument on `decryptModel` / `bulkDecryptModels`, ESM-only), and the | ||
| auth-strategy `Result` that must be unwrapped before it reaches | ||
| `config.authStrategy`. | ||
|
|
||
| It also separates the two mechanisms behind identity-bound encryption, which | ||
| are routinely conflated — and which the source comment on the entry itself got | ||
| wrong. An auth strategy decides *who the client is*; a lock context decides | ||
| *which key the value is encrypted under*. Only the first exists on this entry, | ||
| so an `authStrategy` alone still writes values encrypted under the workspace | ||
| key, and the entry cannot read what the native one wrote under a lock context. | ||
| That is a silent read split between the two entries, and the skill says so | ||
| rather than leaving it to be discovered as a failed decrypt. | ||
|
|
||
| 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. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.