Skip to content

Conversation

@NathanFlurry
Copy link
Member

No description provided.

@vercel
Copy link

vercel bot commented Jan 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
rivetkit-serverless Error Error Jan 6, 2026 2:31am
3 Skipped Deployments
Project Deployment Review Updated (UTC)
rivet-cloud Ignored Ignored Jan 6, 2026 2:31am
rivet-inspector Ignored Ignored Preview Jan 6, 2026 2:31am
rivet-site Ignored Ignored Preview Jan 6, 2026 2:31am

Copy link
Member Author

NathanFlurry commented Jan 2, 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.

@claude
Copy link

claude bot commented Jan 2, 2026

PR Review: Add support for find_workflows

Summary

This PR adds a batched version of find_workflow called find_workflows that allows finding multiple workflows by (name, tags) pairs in a single database transaction. The implementation follows the existing pattern and adds the method to all context types.


Issues Found

🔴 Critical: Metrics API Inconsistency (line 1022)

The new find_workflows method uses a different metrics API than the existing find_workflow method:

  • Old method (line 992-994): Uses .with_label_values(&[workflow_name]).observe(dt)
  • New method (line 1022): Uses .record(dt, &[KeyValue::new("workflow_name", "batch")])

Impact: This inconsistency suggests either:

  1. A migration is in progress between two metrics libraries
  2. An unintentional mixing of APIs that will cause runtime issues

Recommendation: Use the same metrics API as the existing find_workflow method for consistency:

metrics::FIND_WORKFLOWS_DURATION
    .with_label_values(&["batch"])  // or perhaps "multiple"
    .observe(dt);

🟡 Performance: Concurrent vs Sequential Execution

The implementation runs all queries concurrently within a single transaction:

let futures = queries.iter().map(|(workflow_name, tags)| {
    self.find_workflow_inner(workflow_name, tags, &tx)
});
try_join_all(futures).await

Concern: Each find_workflow_inner call performs a streaming query that iterates through database entries (lines 378-410). Running these concurrently within the same transaction may:

  • Not provide significant performance benefits if the database serializes access
  • Potentially increase transaction contention
  • Make it harder to reason about transaction lifecycle

Questions:

  • Have you benchmarked this approach vs sequential execution?
  • Does UniversalDB support concurrent operations within a single transaction effectively?

Alternative consideration: If performance is critical, consider documenting the expected use case and query count limits.


🟡 Code Quality: Missing Documentation

The doc comments are identical across all context types but lack important details:

/// Finds the first incomplete workflow for each (name, tags) pair in a single batch transaction.

Recommended additions:

/// Finds the first incomplete workflow for each (name, tags) pair in a single batch transaction.
///
/// Returns a vector of optional workflow IDs in the same order as the input queries.
/// `None` is returned for queries where no matching workflow was found.
///
/// # Arguments
/// * `queries` - Slice of (workflow_name, tags) pairs to search for
///
/// # Example
/// ```ignore
/// let queries = [
///     ("my-workflow", json\!({"env": "prod"})),
///     ("other-workflow", json\!({"region": "us-east"})),
/// ];
/// let results = ctx.find_workflows(&queries).await?;
/// ```

🟢 Minor: Return Value Documentation

While the return type Vec<Option<Id>> is clear from the signature, it's not immediately obvious that:

  • The order matches the input order
  • None indicates no workflow found (vs an error)

Consider adding a comment or example showing this behavior.


Positive Observations

Consistent API design - The method is added to all context types (Activity, Operation, Standalone, Test)

Proper instrumentation - Uses #[tracing::instrument(skip_all)] for observability

Transaction safety - Correctly uses a single transaction for all queries, ensuring consistency

Error handling - Properly propagates errors with context

Code reuse - Leverages existing find_workflow_inner logic


Test Coverage

⚠️ No tests found for the new find_workflows method.

Recommendation: Add integration tests covering:

  1. Multiple queries returning all Some values
  2. Mixed results with some None values
  3. Empty query array
  4. Order preservation of results
  5. Transaction rollback behavior on error

Example test location: engine/packages/gasoline/tests/workflows/find_workflows_test.rs


Security & Performance

✅ No obvious security concerns
✅ No SQL injection risks (using parameterized queries)
✅ Proper use of database transaction for ACID guarantees


Recommendations Summary

  1. Fix metrics API inconsistency (critical)
  2. Add comprehensive documentation with examples
  3. Add integration tests for the new functionality
  4. Consider documenting performance characteristics and intended use cases
  5. Verify concurrent query execution is optimal for UniversalDB

Conclusion

The implementation is solid and follows existing patterns well. The main concern is the metrics API inconsistency which should be resolved before merging. Adding tests and better documentation would significantly improve the PR quality.

@jog1t jog1t force-pushed the 12-23-chore_docs_document_abort_signal branch from ee5f7b8 to 9f0dc33 Compare January 2, 2026 23:33
@jog1t jog1t force-pushed the 01-02-chore_gas_add_support_for_find_workflows_ branch from d3bc69d to 79307ef Compare January 2, 2026 23:33
@NathanFlurry NathanFlurry force-pushed the 12-23-chore_docs_document_abort_signal branch from 9f0dc33 to ee5f7b8 Compare January 2, 2026 23:59
@NathanFlurry NathanFlurry force-pushed the 01-02-chore_gas_add_support_for_find_workflows_ branch from 79307ef to d3bc69d Compare January 2, 2026 23:59
@jog1t jog1t force-pushed the 12-23-chore_docs_document_abort_signal branch from ee5f7b8 to 9f0dc33 Compare January 3, 2026 00:05
@jog1t jog1t force-pushed the 01-02-chore_gas_add_support_for_find_workflows_ branch from d3bc69d to 79307ef Compare January 3, 2026 00:05
@NathanFlurry NathanFlurry force-pushed the 12-23-chore_docs_document_abort_signal branch from 9f0dc33 to ee5f7b8 Compare January 5, 2026 02:45
@NathanFlurry NathanFlurry force-pushed the 01-02-chore_gas_add_support_for_find_workflows_ branch from 79307ef to d3bc69d Compare January 5, 2026 02:45
@NathanFlurry NathanFlurry force-pushed the 12-23-chore_docs_document_abort_signal branch from ee5f7b8 to ba521fc Compare January 5, 2026 18:22
@NathanFlurry NathanFlurry force-pushed the 01-02-chore_gas_add_support_for_find_workflows_ branch from d3bc69d to c16bf7b Compare January 5, 2026 18:22
Comment on lines +1031 to +1022
let dt = start_instant.elapsed().as_secs_f64();
metrics::FIND_WORKFLOWS_DURATION.record(dt, &[KeyValue::new("workflow_name", "batch")]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: should be its own metric

@NathanFlurry NathanFlurry force-pushed the 12-23-chore_docs_document_abort_signal branch from ba521fc to 0c18a0d Compare January 6, 2026 02:04
@NathanFlurry NathanFlurry force-pushed the 01-02-chore_gas_add_support_for_find_workflows_ branch from c16bf7b to 3040686 Compare January 6, 2026 02:04
@graphite-app
Copy link
Contributor

graphite-app bot commented Jan 6, 2026

Merge activity

@NathanFlurry NathanFlurry force-pushed the 01-02-chore_gas_add_support_for_find_workflows_ branch from 3e3a986 to daf1f12 Compare January 6, 2026 02:30
@NathanFlurry NathanFlurry force-pushed the 12-23-chore_docs_document_abort_signal branch from 7b5297c to 59e5e07 Compare January 6, 2026 02:30
graphite-app bot pushed a commit that referenced this pull request Jan 6, 2026
@graphite-app graphite-app bot closed this Jan 6, 2026
@graphite-app graphite-app bot deleted the 01-02-chore_gas_add_support_for_find_workflows_ branch January 6, 2026 02:32
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.

3 participants