Skip to content

chore(rivetkit): make execute generic#4231

Closed
NathanFlurry wants to merge 1 commit into02-18-chore_update_workflow_queues_apifrom
02-19-chore_rivetkit_make_execute_generic
Closed

chore(rivetkit): make execute generic#4231
NathanFlurry wants to merge 1 commit into02-18-chore_update_workflow_queues_apifrom
02-19-chore_rivetkit_make_execute_generic

Conversation

@NathanFlurry
Copy link
Member

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@railway-app railway-app bot temporarily deployed to rivet-frontend / rivet-pr-4231 February 19, 2026 08:12 Destroyed
@railway-app
Copy link

railway-app bot commented Feb 19, 2026

🚅 Deployed to the rivet-pr-4231 environment in rivet-frontend

Service Status Web Updated (UTC)
ladle ❌ Build Failed (View Logs) Web Feb 19, 2026 at 10:40 pm
frontend-cloud ❌ Build Failed (View Logs) Web Feb 19, 2026 at 7:23 pm
frontend-inspector ❌ Build Failed (View Logs) Web Feb 19, 2026 at 7:23 pm
website 😴 Sleeping (View Logs) Web Feb 19, 2026 at 8:24 am
mcp-hub ✅ Success (View Logs) Web Feb 19, 2026 at 8:13 am

Copy link
Member Author

NathanFlurry commented Feb 19, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add the label merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 19, 2026

More templates

@rivetkit/cloudflare-workers

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/cloudflare-workers@4231

@rivetkit/framework-base

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/framework-base@4231

@rivetkit/next-js

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/next-js@4231

@rivetkit/react

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/react@4231

rivetkit

pnpm add https://pkg.pr.new/rivet-dev/rivet/rivetkit@4231

@rivetkit/sql-loader

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/sql-loader@4231

@rivetkit/sqlite-vfs

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/sqlite-vfs@4231

@rivetkit/traces

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/traces@4231

@rivetkit/workflow-engine

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/workflow-engine@4231

@rivetkit/virtual-websocket

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/virtual-websocket@4231

@rivetkit/engine-runner

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/engine-runner@4231

@rivetkit/engine-runner-protocol

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/engine-runner-protocol@4231

commit: 886fc35

@claude
Copy link

claude bot commented Feb 19, 2026

PR Review: chore(rivetkit): make execute generic

This PR makes the c.db.execute method generic so callers can specify the row type (e.g., execute<{ id: number }>(...)) instead of using post-hoc as type assertions. The change is clean and idiomatic TypeScript.


Positive Changes

Generic API over type assertions: Replacing (await c.db.execute(...)) as Array<{ id: number }> with await c.db.execute<{ id: number }>(...) is strictly better style. Type assertions bypass the type checker at the call site; generic inference keeps the type parameter explicit and correctly typed.

Drizzle execute implementation fix: The old drizzle path called callback(query, args, "all"), which returned positional row arrays (unknown[][]) based on how createProxyCallback is written (the comment even says "drizzle's mapResultRow accesses rows by column index (positional arrays)"). But the fixture code accessed rows as objects (results[0].id, results[0].value), so this was likely broken at runtime. The new implementation explicitly maps rows to objects via column names, consistent with src/db/mod.ts. This looks like a real bug fix bundled into this PR.

Workflow context variable fix (workflow.ts): The fix from actorLoopCtx to loopCtx inside the "access-step" step handler is correct. The step callback should operate on its own step context, not the outer actor loop context. The added loopCtx.client<typeof registry>() typing is also an improvement.

Type test: The actor-types.test.ts addition that uses expectTypeOf to validate execute<{ foo: string }>() returns Array<{ foo: string }> is a good compile-time guard.


Issues and Observations

1. The drizzle behavior change deserves a callout

The switch from callback(query, args, "all") to waDb.query / waDb.exec directly is a meaningful implementation change that the PR description does not mention. If this fixes a runtime bug (returning positional arrays instead of objects), that should be called out explicitly in the PR description. It also bypasses the createProxyCallback layer, so any future changes to that proxy will not affect the raw execute path.

2. SQL injection in test fixtures (pre-existing)

The fixtures extensively use interpolated string SQL:

`INSERT INTO test_data (value, payload, created_at) VALUES ('${value}', ''  , ${Date.now()})`

This is pre-existing and these are test-only fixtures, so the risk is low. But since the execute API already supports parameterized queries (...args path), updating fixtures to use placeholders would make them better examples of how the API should be used in production.

3. Inconsistency in null-safety between files (pre-existing)

In actor-db-raw.ts, rawSelectCount uses results[0].count without optional chaining, while actor-db-drizzle.ts uses results[0]?.count ?? 0. COUNT(*) always returns exactly one row so this will not crash, but the divergence between the two files is a minor inconsistency worth aligning.

4. Type safety note

Both the old as Array<{ id: number }> and the new execute<{ id: number }>() are compile-time-only assertions with no runtime validation. This is expected TypeScript behavior and the new form is strictly more idiomatic, but worth understanding: the generic parameter does not add any runtime type guarantee over what was there before.


Summary

The primary change (making execute generic) is correct and improves the API. The drizzle implementation change and the workflow.ts context fix are meaningful runtime fixes that should be mentioned in the PR description. No blocking issues.

@NathanFlurry NathanFlurry force-pushed the 02-19-chore_rivetkit_make_execute_generic branch from 67d48b3 to 6451b96 Compare February 19, 2026 19:20
@railway-app railway-app bot temporarily deployed to rivet-frontend / rivet-pr-4231 February 19, 2026 19:20 Destroyed
@NathanFlurry NathanFlurry force-pushed the 02-19-chore_rivetkit_make_execute_generic branch from 6451b96 to 928d2d6 Compare February 19, 2026 19:40
@NathanFlurry NathanFlurry force-pushed the 02-18-chore_update_workflow_queues_api branch from 480b364 to b9a7d4c Compare February 19, 2026 19:40
@railway-app railway-app bot temporarily deployed to rivet-frontend / rivet-pr-4231 February 19, 2026 19:40 Destroyed
@NathanFlurry NathanFlurry force-pushed the 02-19-chore_rivetkit_make_execute_generic branch from 928d2d6 to 886fc35 Compare February 19, 2026 19:54
@NathanFlurry NathanFlurry force-pushed the 02-18-chore_update_workflow_queues_api branch from b9a7d4c to 67f79b0 Compare February 19, 2026 19:54
@railway-app railway-app bot temporarily deployed to rivet-frontend / rivet-pr-4231 February 19, 2026 19:54 Destroyed
@NathanFlurry NathanFlurry force-pushed the 02-18-chore_update_workflow_queues_api branch from 67f79b0 to 8400de3 Compare February 19, 2026 22:12
@NathanFlurry NathanFlurry force-pushed the 02-19-chore_rivetkit_make_execute_generic branch from 886fc35 to 549a3a7 Compare February 19, 2026 22:12
@railway-app railway-app bot temporarily deployed to rivet-frontend / rivet-pr-4231 February 19, 2026 22:12 Destroyed
@NathanFlurry NathanFlurry mentioned this pull request Feb 19, 2026
11 tasks
@NathanFlurry NathanFlurry force-pushed the 02-19-chore_rivetkit_make_execute_generic branch from 549a3a7 to 886fc35 Compare February 19, 2026 22:39
@NathanFlurry NathanFlurry force-pushed the 02-18-chore_update_workflow_queues_api branch from 8400de3 to 67f79b0 Compare February 19, 2026 22:40
@graphite-app
Copy link
Contributor

graphite-app bot commented Feb 19, 2026

Merge activity

  • Feb 19, 10:44 PM UTC: NathanFlurry added this pull request to the Graphite merge queue.
  • Feb 19, 10:45 PM UTC: CI is running for this pull request on a draft pull request (#4238) due to your merge queue CI optimization settings.
  • Feb 19, 10:45 PM UTC: Merged by the Graphite merge queue via draft PR: #4238.

graphite-app bot pushed a commit that referenced this pull request Feb 19, 2026
# Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

## Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update

## How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

## Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
@graphite-app graphite-app bot closed this Feb 19, 2026
@graphite-app graphite-app bot deleted the 02-19-chore_rivetkit_make_execute_generic branch February 19, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments