docs(workflow): add deterministic execution requirement#81
Closed
Mistat wants to merge 1 commit into
Closed
Conversation
Document the suspend/resume execution model and the requirement that job code must be deterministic when using .trigger(). Include examples of correct and incorrect usage patterns (loops, timestamps, external API calls) to help users avoid argument hash mismatch errors. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
anukiransolur
approved these changes
Apr 9, 2026
toiroakr
reviewed
Apr 9, 2026
Comment on lines
+135
to
+146
| ```typescript | ||
| // ❌ Bad: non-deterministic — argument changes between executions | ||
| await processJob.trigger({ timestamp: Date.now() }); | ||
| ``` | ||
|
|
||
| ```typescript | ||
| // ❌ Bad: non-deterministic — external data may change between executions | ||
| const items = await fetch("https://api.example.com/items").then((r) => r.json()); | ||
| for (const item of items) { | ||
| await processItem.trigger({ id: item.id }); | ||
| } | ||
| ``` |
Contributor
There was a problem hiding this comment.
I thought it might be even better if there were examples of how to rewrite the "bad" examples.
// ❌ Bad: non-deterministic — argument changes between executions
await processJob.trigger({ timestamp: Date.now() });↓
// ✅ OK: call Date.now() in separated job
const timestamp = await timestampJob.trigger();
await processJob.trigger({ timestamp });// ❌ Bad: non-deterministic — external data may change between executions
const items = await fetch("https://api.example.com/items").then((r) => r.json());
for (const item of items) {
await processItem.trigger({ id: item.id });
}↓
// ✅ OK: call fetch("https://api.example.com/items").then((r) => r.json()); in separated job
const items = await fetchItemsJob.trigger();
for (const item of items) {
await processItem.trigger({ id: item.id });
}
Contributor
|
This change will be added in SDK repository 945 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
.trigger()uses a suspend/resume execution model and job code must be deterministicDate.now(), external API responses) cause argument hash mismatch errorsBackground
The Rust runtime (
service/function/runtime/src/engine/ops/job.rsinplatform-core-services) enforces deterministic execution by verifyingarg_hashon resume. This critical constraint was not documented, risking users encountering unclear errors.Test plan
🤖 Generated with Claude Code