@proompteng/temporal-bun-sdk 0.8.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -0
- package/dist/agent-readiness.json +214 -0
- package/dist/production-readiness.json +274 -0
- package/dist/src/bin/lint-workflows-command.d.ts.map +1 -1
- package/dist/src/bin/lint-workflows-command.js +24 -3
- package/dist/src/bin/lint-workflows-command.js.map +1 -1
- package/dist/src/bin/temporal-bun.js +3 -3
- package/dist/src/otel/sdk-trace.d.ts.map +1 -1
- package/dist/src/otel/sdk-trace.js +5 -0
- package/dist/src/otel/sdk-trace.js.map +1 -1
- package/dist/src/worker/runtime.d.ts.map +1 -1
- package/dist/src/worker/runtime.js +0 -1
- package/dist/src/worker/runtime.js.map +1 -1
- package/dist/src/workflow/executor.d.ts.map +1 -1
- package/dist/src/workflow/executor.js +41 -6
- package/dist/src/workflow/executor.js.map +1 -1
- package/dist/src/workflow/guards.d.ts.map +1 -1
- package/dist/src/workflow/guards.js +15 -12
- package/dist/src/workflow/guards.js.map +1 -1
- package/docs/agent-adoption-guide.md +75 -0
- package/docs/feature-matrix.md +33 -0
- package/docs/production-design.md +589 -0
- package/docs/production-readiness-implementation-plan.md +371 -0
- package/docs/release-runbook.md +48 -0
- package/docs/semantic-readiness.md +79 -0
- package/docs/support-policy.md +79 -0
- package/docs/temporal-ci-cluster-requirement.md +36 -0
- package/docs/workflow-updates.md +107 -0
- package/package.json +21 -17
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Temporal Bun SDK – Workflow Update Support
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Temporal Workflow Updates let callers send strongly typed, low-latency mutations to running workflows without relying on signals/queries. This document captures the design and operational considerations for the Bun SDK implementation.
|
|
6
|
+
|
|
7
|
+
## Components
|
|
8
|
+
|
|
9
|
+
### Client surface
|
|
10
|
+
|
|
11
|
+
- `TemporalWorkflowClient.workflow.update()` issues `UpdateWorkflowExecutionRequest` RPCs.
|
|
12
|
+
- Helper APIs (`getUpdateHandle`, `awaitUpdate`, `cancelUpdate`) let services resume or cancel pending updates.
|
|
13
|
+
- Update calls inherit the standard call options (`retryPolicy`, `timeoutMs`, `headers`, `signal`).
|
|
14
|
+
- `workflow.update` assigns an idempotent `updateId` (callers can override it) and defaults to waiting until the update is **accepted**; `waitForStage` can be set to `'admitted' | 'accepted' | 'completed'`.
|
|
15
|
+
- `workflow.awaitUpdate` defaults to waiting until the update is **completed** when no `waitForStage` is provided, matching Temporal's server-side default.
|
|
16
|
+
- The client records per-update AbortControllers so cancelling an update (or aborting a request) cleans up pending polls appropriately.
|
|
17
|
+
|
|
18
|
+
### Workflow runtime
|
|
19
|
+
|
|
20
|
+
- Workflows register update handlers via `defineWorkflowUpdates` and `workflowContext.updates.register`.
|
|
21
|
+
- `WorkflowExecutor` passes incoming invocations through Effect Schema validators, records update determinism entries for `admitted`, `accepted`, `rejected`, and `completed` stages, and surfaces dispatch metadata (acceptance/rejection/completion) to the worker runtime.
|
|
22
|
+
|
|
23
|
+
### Worker runtime
|
|
24
|
+
|
|
25
|
+
- `collectWorkflowUpdates` reads `PollWorkflowTaskQueueResponse.messages`, decoding `temporal.api.update.v1.Request` payloads into invocation structs.
|
|
26
|
+
- `WorkflowExecutor` runs registered handlers deterministically; `buildUpdateProtocolMessages` translates dispatches into protocol `Acceptance`, `Rejection`, and `Response` messages and attaches them to `RespondWorkflowTaskCompleted`.
|
|
27
|
+
- Scheduler fairness: update protocol messages piggyback on workflow tasks, so updates share the workflow concurrency lane. Most updates are short-lived RPCs, but long-running handler code should be treated like normal workflow code (no async side-effects, deterministic behavior).
|
|
28
|
+
|
|
29
|
+
### Determinism & replay
|
|
30
|
+
|
|
31
|
+
- `WorkflowDeterminismState` now tracks update lifecycle entries. Replay ingestion consumes `WORKFLOW_EXECUTION_UPDATE_*` history events; sticky cache snapshots include sequencing/event IDs so drift detection works out of the box.
|
|
32
|
+
- Determinism markers encode update state alongside command history; if markers are missing, replay reconstructs update entries from history.
|
|
33
|
+
|
|
34
|
+
## Operational guidance
|
|
35
|
+
|
|
36
|
+
### Configuration
|
|
37
|
+
|
|
38
|
+
- Ensure workers poll `messages` on workflow tasks. The SDK already passes `messages` through; if you implement your own poller, include protocol message handling.
|
|
39
|
+
- Temporal server version must include Workflow Update GA (Cloud and ≥1.22 server builds).
|
|
40
|
+
- When running against dev clusters (`temporal server start-dev`), enable updates via `temporal server start-dev --enable-workflow-updates` if required.
|
|
41
|
+
|
|
42
|
+
### Metrics & observability
|
|
43
|
+
|
|
44
|
+
- Worker logs include update dispatch outcomes at `debug` level; promote them to structured logs if you need audit trails.
|
|
45
|
+
- Determinism mismatches will now mention update entries (kind = 'update'), helping you debug cases where the worker admitted/rejected updates differently from history.
|
|
46
|
+
|
|
47
|
+
### Rollout plan
|
|
48
|
+
|
|
49
|
+
- Deploy the SDK update to a staging namespace first; verify `workflow.update` calls succeed and determinism markers continue to sync.
|
|
50
|
+
- Monitor worker logs for `workflow update message missing identifiers` or `failed to decode workflow update request`; those indicate mismatched protocol payloads.
|
|
51
|
+
- If you need to disable updates temporarily, skip calling `workflow.update` and leave registered handlers in place; they are no-ops when no update protocol messages arrive.
|
|
52
|
+
|
|
53
|
+
## Quick reference
|
|
54
|
+
|
|
55
|
+
### Registering updates
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import { defineWorkflow, defineWorkflowUpdates } from '@proompteng/temporal-bun-sdk/workflow'
|
|
59
|
+
import * as Schema from 'effect/Schema'
|
|
60
|
+
|
|
61
|
+
const updates = defineWorkflowUpdates([
|
|
62
|
+
{
|
|
63
|
+
name: 'setCounter',
|
|
64
|
+
input: Schema.Number,
|
|
65
|
+
handler: async ({ info }, value: number) => {
|
|
66
|
+
console.log('Update from', info.workflowId, 'value', value)
|
|
67
|
+
return value
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
])
|
|
71
|
+
|
|
72
|
+
export const counterWorkflow = defineWorkflow(
|
|
73
|
+
'counterWorkflow',
|
|
74
|
+
Schema.Number,
|
|
75
|
+
({ input, updates }) => {
|
|
76
|
+
let count = input
|
|
77
|
+
|
|
78
|
+
updates.register(updates[0], async (_ctx, value) => {
|
|
79
|
+
count = value
|
|
80
|
+
return count
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
return Effect.sync(() => count)
|
|
84
|
+
},
|
|
85
|
+
{ updates },
|
|
86
|
+
)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Invoking updates
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
const result = await client.workflow.update(handle, {
|
|
93
|
+
updateName: 'setCounter',
|
|
94
|
+
args: [42],
|
|
95
|
+
waitForStage: 'completed',
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
if (result.outcome?.status === 'success') {
|
|
99
|
+
console.log('Counter updated to', result.outcome.result)
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Monitoring
|
|
104
|
+
|
|
105
|
+
- Use `temporal workflow update` CLI commands or Cloud UI to inspect update states.
|
|
106
|
+
- Worker logs emitted when decoding protocol messages: enable `LOG_LEVEL=debug` if you need to trace update routing.
|
|
107
|
+
- Determinism mismatches now show `kind: 'update'` entries referencing update IDs.
|
package/package.json
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proompteng/temporal-bun-sdk",
|
|
3
|
+
"version": "0.9.1",
|
|
3
4
|
"description": "Temporal SDK for Bun with workers, client, replay tooling, and Temporal Cloud/TLS support.",
|
|
4
|
-
"version": "0.8.0",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"homepage": "https://docs.proompteng.ai/docs/temporal-bun-sdk",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "https://github.com/proompteng/lab.git",
|
|
10
|
-
"directory": "packages/temporal-bun-sdk"
|
|
11
|
-
},
|
|
12
5
|
"keywords": [
|
|
13
|
-
"temporal",
|
|
14
6
|
"bun",
|
|
15
|
-
"workflow",
|
|
16
|
-
"worker",
|
|
17
7
|
"client",
|
|
18
8
|
"durable-execution",
|
|
19
|
-
"
|
|
9
|
+
"effect",
|
|
20
10
|
"grpc",
|
|
11
|
+
"temporal",
|
|
12
|
+
"temporal-cloud",
|
|
21
13
|
"typescript",
|
|
22
|
-
"
|
|
14
|
+
"worker",
|
|
15
|
+
"workflow"
|
|
23
16
|
],
|
|
17
|
+
"homepage": "https://docs.proompteng.ai/docs/temporal-bun-sdk",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/proompteng/lab.git",
|
|
22
|
+
"directory": "packages/temporal-bun-sdk"
|
|
23
|
+
},
|
|
24
24
|
"bin": {
|
|
25
25
|
"temporal-bun": "./dist/src/bin/temporal-bun.js",
|
|
26
26
|
"temporal-bun-skill": "./dist/src/bin/temporal-bun-skill.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"files": [
|
|
30
30
|
"dist",
|
|
31
|
-
"
|
|
31
|
+
"docs",
|
|
32
32
|
"skills",
|
|
33
33
|
"README.md"
|
|
34
34
|
],
|
|
@@ -80,11 +80,15 @@
|
|
|
80
80
|
"prepare": "tsc --project tsconfig.json --pretty false",
|
|
81
81
|
"test": "bun test",
|
|
82
82
|
"test:load": "bun scripts/run-worker-load.ts",
|
|
83
|
+
"test:soak": "bun scripts/run-worker-soak.ts",
|
|
84
|
+
"evidence:production": "bun scripts/collect-production-evidence.ts",
|
|
85
|
+
"verify:replay-corpus": "bun scripts/verify-replay-corpus.ts",
|
|
83
86
|
"test:coverage": "bun test --coverage",
|
|
87
|
+
"verify:production": "bun run evidence:production && bun test tests/packaging/manifest-packaging.test.ts",
|
|
84
88
|
"start:worker": "bun run dist/src/bin/start-worker.js",
|
|
85
89
|
"temporal:start": "bun scripts/start-temporal-cli.ts",
|
|
86
90
|
"temporal:stop": "bun scripts/stop-temporal-cli.ts",
|
|
87
|
-
"prepack": "bun run build",
|
|
91
|
+
"prepack": "bun run build && bun run evidence:production",
|
|
88
92
|
"lint:oxlint": "oxlint --config ../../.oxlintrc.json .",
|
|
89
93
|
"lint:oxlint:type": "oxlint --config ../../.oxlintrc.json --type-aware --tsconfig ./tsconfig.oxlint.json --ignore-pattern tests ."
|
|
90
94
|
},
|
|
@@ -98,9 +102,9 @@
|
|
|
98
102
|
},
|
|
99
103
|
"devDependencies": {
|
|
100
104
|
"@types/node": "^22.7.5",
|
|
101
|
-
"bun-types": "^1.3.
|
|
105
|
+
"bun-types": "^1.3.13"
|
|
102
106
|
},
|
|
103
107
|
"engines": {
|
|
104
|
-
"bun": ">=1.3.
|
|
108
|
+
"bun": ">=1.3.13"
|
|
105
109
|
}
|
|
106
110
|
}
|