feat(cli): per-column EQL v3 domain picker in stash schema build#755
Conversation
🦋 Changeset detectedLatest commit: 9bf2266 The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Warning Review limit reached
Next review available in: 27 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthrough
ChangesEQL v3 domain selection
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant SchemaBuild
participant Database
participant ClientGenerator
User->>SchemaBuild: start schema build
SchemaBuild->>Database: introspect tables and columns
Database-->>SchemaBuild: return PostgreSQL column metadata
SchemaBuild->>User: prompt for column domains
User-->>SchemaBuild: provide selected V3Domain values
SchemaBuild->>ClientGenerator: generate schemas with selected domains
ClientGenerator-->>User: output typed encryption client
Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.changeset/schema-build-v3-domain-picker.md:
- Around line 7-9: Revise the Boolean/Json capability descriptions in both
.changeset/schema-build-v3-domain-picker.md lines 7-9 and
skills/stash-cli/SKILL.md line 461: describe Boolean as storage-only, while
documenting Json’s encrypted-JSONB containment and selector query capabilities
instead of labeling it storage-only.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 6fb60892-bdab-4cb3-bb61-c075bbf44c67
📒 Files selected for processing (8)
.changeset/schema-build-v3-domain-picker.mdpackages/cli/src/commands/init/__tests__/utils-codegen.test.tspackages/cli/src/commands/init/lib/__tests__/build-flow.integration.test.tspackages/cli/src/commands/init/lib/__tests__/introspect.test.tspackages/cli/src/commands/init/lib/introspect.tspackages/cli/src/commands/init/types.tspackages/cli/src/commands/init/utils.tsskills/stash-cli/SKILL.md
- reuse computed candidateDomains in the picker via defaultDomain(options) - refresh stale InitState.schemas comment (search ops -> column domains) - drop non-null assertion in build-flow integration test
Json's v3 domain supports encrypted-JSONB containment + selector queries; only Boolean is storage-only. Fixes the changeset, the candidateDomains doc comment, and the schema build skill copy, which had lumped the two.
coderdan
left a comment
There was a problem hiding this comment.
Some minor suggestions but otherwise LGTM
Address PR #755 review (coderdan): - Picker hints now name the operators/functions each domain answers. Corrected two inaccurate reviewer suggestions: TextMatch uses the eql_v3.matches() function, not the FTS @@ operator; Json supports @> and -> (plus scalar compare/order at a selector path), not <@ / ->>. - Add a runtime drift guard asserting every domain the picker can offer is a real @cipherstash/stack/eql/v3 factory. Enforced by vitest (CI) because packages/cli has no tsc --noEmit step — a type-only alias is not checked. Answers the 'avoid drift' review point without deriving V3Domain from the 40-key types superset (which would over-widen the curated 13).
auxesis
left a comment
There was a problem hiding this comment.
Test coverage review — v3 domain picker
Strong coverage overall. The new candidateDomains, defaultDomain(DataType), the rewritten selectTableColumns loop (all three cancellation branches, single-domain skip, eql pre-selection), and the 13-domain codegen round-trip over both generators are well exercised. Three verified gaps remain, all clustered on the default the picker offers — the behaviour the changeset and skills/stash-cli/SKILL.md explicitly promise ("defaulting to the widest searchable domain"). None is a blocker; all are cheap to close with the mocks already in place.
Review stats
| Source | Raw | Survived |
|---|---|---|
| claude (claude-opus-4-8) [test-gap] | 2 | 2 |
| codex (gpt-5.5) [test-gap] | 2 | 2 |
Merged to 3 unique findings. Cross-model overlap: 1 kept finding (the picker initialValue gap) was corroborated by both models.
Additional findings not posted inline
None — all 3 kept findings are posted inline (under the 8-comment cap).
Out-of-scope notes raised by claude, not posted (pre-existing code the diff does not touch): the connection-failure and p.confirm cancel branches of buildSchemasFromDatabase (introspect.ts), and generateClientFromSchemas having no prisma-next/default case.
Address @auxesis review threads on PR #755: - assert the picker passes initialValue: defaultDomain(options) so the widest searchable domain is pre-selected (a regression to the narrowest otherwise passes the whole suite) - assert defaultDomain's candidate-list (array) overload returns the last value - cover the supabase codegen routing (shares the generic generator with postgresql; previously only postgresql/drizzle were exercised)
…gen switch Close the out-of-scope gaps noted (not posted inline) in the PR #755 review: - generateClientFromSchemas now handles every Integration: prisma-next throws a clear error instead of silently returning undefined, so the switch is total and a future integration can't fall through to undefined. - test buildSchemasFromDatabase's connection/introspection-failure branch (returns undefined, doesn't propagate) and the 'another table?' cancel branch (aborts, distinct from declining). Internal robustness + coverage only; prisma-next is unreachable from schema/build.ts (which produces only supabase|postgresql), so no user-observable behaviour change — no changeset.
What
Replaces the v2 capability-tuple column picker in
stash schema buildwith a per-column EQL v3 domain picker, and deletes theSearchOp/allSearchOps/v3DomainFactorybridge.Previously the introspect → pick → codegen path carried a v2
SearchOp[]tuple through an intermediateColumnDefand translated it to a v3 domain name at codegen time. This moves the domain decision up into the interactive picker — the user chooses a concrete v3 domain per column (candidates filtered by the column's Postgres type) — stores it directly onColumnDef, and has codegen read it verbatim.Why
Unblocks the EQL v2 removal (#707, #751): no v2 capability vocabulary remains in the
schema buildpath.Behaviour
TextSearch,IntegerOrd,TextEq, …) via aselectprompt, with capability-descriptive hints.string→TextSearch,number→IntegerOrd,date→DateOrd).boolean→Booleanandjson→Jsonare single storage-only domains, assigned without a prompt.pgTypeToDataType's coarse 5-type collapse is unchanged (out of scope: widening to the full numeric/date lattice).stash init/generatePlaceholderClient.Tests
introspect.test.ts—pgTypeToDataType,candidateDomains,defaultDomain, and the rewrittenselectTableColumns(every cancellation branch + eql-pre-selected path,@clack/promptsmocked).utils-codegen.test.ts— both generators, plus anit.eachround-trip over all 13V3Domainvalues; asserts nosearchOpsresidue.build-flow.integration.test.ts— realbuildSchemasFromDatabase→ realgenerateClientFromSchemaswith onlypgand@clack/promptsmocked (multi-table loop, early-exit, empty-schema edges).Verification
pnpm --filter stash build— clean, no type errorspnpm --filter stash test— 815 pass (56 files)pnpm run code:check— exit 0Docs / changeset
schema builddescription inskills/stash-cli/SKILL.mdto describe the domain picker.stashpatch changeset.Summary by CodeRabbit
schema buildnow assigns a specific encryption domain to each selected column.Summary by CodeRabbit
schema buildnow lets you select an encryption domain for each column.Summary by CodeRabbit
stash schema buildnow lets you choose an encryption domain for each selected column.