@proompteng/temporal-bun-sdk 0.7.1 → 0.9.0
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 +80 -544
- package/dist/agent-readiness.json +46 -0
- package/dist/production-readiness.json +93 -0
- package/dist/src/bin/lint-workflows-command.d.ts.map +1 -1
- package/dist/src/bin/lint-workflows-command.js +24 -2
- package/dist/src/bin/lint-workflows-command.js.map +1 -1
- package/dist/src/bin/temporal-bun.d.ts.map +1 -1
- package/dist/src/bin/temporal-bun.js +20 -5
- package/dist/src/bin/temporal-bun.js.map +1 -1
- 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/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 -0
- package/dist/src/workflow/guards.js.map +1 -1
- package/docs/agent-adoption-guide.md +61 -0
- package/docs/feature-matrix.md +31 -0
- package/docs/production-design.md +589 -0
- package/docs/production-readiness-implementation-plan.md +370 -0
- package/docs/release-runbook.md +48 -0
- package/docs/support-policy.md +76 -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,589 @@
|
|
|
1
|
+
# Temporal Bun SDK – Production-Ready Design
|
|
2
|
+
|
|
3
|
+
_Last updated: May 5, 2026_
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
This document is the single source of truth for operating
|
|
8
|
+
`@proompteng/temporal-bun-sdk` as a production npm package that can be trusted by
|
|
9
|
+
Temporal developers. It records what ships in `main`, the release gates that
|
|
10
|
+
must stay green, and the hardening backlog after the GA-critical runtime path.
|
|
11
|
+
The implementation plan for turning the current project-proven runtime into a
|
|
12
|
+
public default-choice library lives in
|
|
13
|
+
`docs/production-readiness-implementation-plan.md`.
|
|
14
|
+
|
|
15
|
+
## Bun-First Architecture Advantages
|
|
16
|
+
|
|
17
|
+
- **Single runtime, single language.** Workflows, activities, worker runtime, and tooling all execute inside Bun with Effect layers, so we avoid C-ABI bridges, reference-counted native handles, or “core” background threads. Scheduling, sticky cache eviction, and heartbeat aggregation share the same event loop, which keeps failure handling and telemetry consistent.
|
|
18
|
+
- **Zero workflow bundler constraints.** Because workflows run in the same runtime, we don’t need webpack-only bundles, module blacklists, or VM cache hacks. The CLI can still emit bundles for deployment, but local dev can import workflows/activities directly without rewriting entrypoints or duplicating payload converter wiring.
|
|
19
|
+
- **Direct telemetry plumbing.** Loggers, metrics, and tracing consumers plug into Effect services rather than going through gRPC proxies or shared heartbeat workers. This lets us emit structured observability data per task without extra polling loops and keeps configuration (logger sinks, OTLP exporters) co-located with the worker config.
|
|
20
|
+
- **Simpler lifecycle management.** Worker run/drain/shutdown flows are just Effect scopes with managed resources, so we don’t need special singleton installers, `NativeWorker` mirrors, or asynchronous “activation processor” threads. Graceful shutdown (drain → cancel → fail) is encoded once and reused in both CLI and embedding scenarios.
|
|
21
|
+
- **Determinism-friendly developer experience.** With workflows, activities, and data converters sharing the same dependency graph, we can enforce deterministic imports and snapshotting at build time, but developers still get Bun’s tooling (watch mode, test runner) without cross-language debugging.
|
|
22
|
+
|
|
23
|
+
## Current State Snapshot
|
|
24
|
+
|
|
25
|
+
The SDK is past the original Alpha/Beta planning phase. The public package has
|
|
26
|
+
shipped repeatedly on npm, the release workflow gates publishes with build,
|
|
27
|
+
format, unit, integration, and load checks, and `services/jangar` consumes the
|
|
28
|
+
Bun worker/client path in the deployed control-plane worker.
|
|
29
|
+
|
|
30
|
+
| Area | Status | Notes |
|
|
31
|
+
| ------------------ | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
32
|
+
| Workflow execution | **GA-critical done** | Deterministic command context, activity/timer/child/signal/continue-as-new intents, deterministic guard, replay ingestion, and real-history replay fixtures. |
|
|
33
|
+
| Worker runtime | **GA-critical done** | Sticky cache routing performs drift detection + healing; Effect-based scheduler, configurable concurrency, graceful shutdown, build-id routing, logging, metrics, and load harness. |
|
|
34
|
+
| Client | **GA-critical done** | Start/signal/query/cancel/update/describe namespace with Connect transport; effect-layered interceptors, retries, TLS/mTLS validation, Temporal Cloud Ops client, and typed helpers. |
|
|
35
|
+
| Activities | **GA-critical done** | Handler registry, AsyncLocalStorage context, cancellation propagation, heartbeats, retry policy adherence, failure categorisation, and integration coverage. |
|
|
36
|
+
| Tooling & docs | **Release ready** | CLI scaffolds workers, validates connectivity, runs replay/lint commands, builds Docker assets, and documents Temporal Cloud/TLS, schedules, replay, observability, and release flow. |
|
|
37
|
+
| Testing | **Release gated** | Unit suites, replay fixtures, Temporal CLI integration tests, worker load/perf checks, formatting, build, and npm provenance publishing gate releases. |
|
|
38
|
+
|
|
39
|
+
> **Production-readiness note:** The remaining adoption risk is no longer
|
|
40
|
+
> "Bun cannot load the official Node worker stack." This SDK does not depend on
|
|
41
|
+
> `@temporalio/worker`, Node-API native modules, `process.dlopen()`, or
|
|
42
|
+
> `worker_threads` for worker execution. The real external concern is trust:
|
|
43
|
+
> third-party support status, public proof of deterministic replay and soak/load
|
|
44
|
+
> behaviour, and clear operational docs for teams choosing a non-official SDK.
|
|
45
|
+
> `bun run verify:production` is the mechanical package-boundary gate: it fails
|
|
46
|
+
> if native bridge artifacts, official Node worker dependencies, or stale native
|
|
47
|
+
> Docker build paths re-enter the production package.
|
|
48
|
+
|
|
49
|
+
## Architecture Overview
|
|
50
|
+
|
|
51
|
+
- **Workflow Runtime (`src/workflow/*`)**
|
|
52
|
+
- _Shipped:_ Deterministic workflow context, command intents, determinism guard.
|
|
53
|
+
- _Release gate:_ History replay ingest, failure categorisation, command metadata (headers/memo/search attributes), workflow cache eviction strategy.
|
|
54
|
+
- **Worker Runtime (`src/worker/*`)**
|
|
55
|
+
- _Shipped:_ Single-threaded pollers, deterministic snapshot persistence per run.
|
|
56
|
+
- _Release gate:_ Configurable concurrency, sticky task queues, build-id routing, graceful shutdown with drain, heartbeat plumbing, metrics/logging hooks.
|
|
57
|
+
- **Client (`src/client.ts`)**
|
|
58
|
+
- _Shipped:_ Connect WorkflowService client with payload conversion, header normalisation, and effect-layered interceptors for retries/auth/metrics/tracing.
|
|
59
|
+
- _Release gate:_ TLS/auth hardening, memo/search attribute helpers, long-running operation ergonomics.
|
|
60
|
+
- **Activities (`src/activities/*`, `src/worker/activity-context.ts`)**
|
|
61
|
+
- _Shipped:_ AsyncLocalStorage-based context, cancellation surface.
|
|
62
|
+
- _Release gate:_ Heartbeat API, retry policy adherence, progress payload encoding, failure classification.
|
|
63
|
+
- **Tooling**
|
|
64
|
+
- CLI (`src/bin/temporal-bun.ts`) scaffolds projects; needs connectivity checks, history replay tooling, lint hooks.
|
|
65
|
+
- **Generated Protos (`src/proto/**`)\*\*
|
|
66
|
+
- Must stay synced with upstream Temporal releases; add automation for updates.
|
|
67
|
+
|
|
68
|
+
## Functional Roadmap
|
|
69
|
+
|
|
70
|
+
| Capability | Status | Acceptance Criteria | GA Critical? |
|
|
71
|
+
| ------------------ | -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ------------ |
|
|
72
|
+
| Command coverage | ✅ context + intents | Activities, timers, child workflows, signals, continue-as-new emit correct commands with metadata and retries. | Yes |
|
|
73
|
+
| History replay | ✅ ingestion + sticky cache | Worker hydrates history into determinism state, verifies commands, tolerates sticky cache eviction, exposes replay API. | Yes |
|
|
74
|
+
| Activity lifecycle | ✅ complete | Heartbeats, retries, cancellation reasons, eager activities. | Yes |
|
|
75
|
+
| Worker concurrency | ✅ scheduler + sticky queues | Configurable parallelism, sticky queues, build-id routing, per-namespace/task queue isolation. | Yes |
|
|
76
|
+
| Client resilience | ✅ complete | Retry policies, interceptors, TLS/mTLS test matrix, structured errors. | Yes |
|
|
77
|
+
| Diagnostics | ✅ logs + metrics (tracing next) | Effect-based logger + metrics exporters ship with worker/client runtimes; tracing hooks scheduled separately. | Yes |
|
|
78
|
+
| Testing & QA | ✅ replay + integration + load | Deterministic regression suite, integration tests with Temporal dev server, worker load/perf smoke tests, package-boundary verification. | Yes |
|
|
79
|
+
| Tooling | ✅ complete | CLI connectivity check, replay CLI, production boundary verification, proto regeneration script, API docs generator. | Yes |
|
|
80
|
+
| Documentation | ✅ complete | Architecture guide, workflow/activities best practices, migration guide, troubleshooting, accessibility for CLI. | Yes |
|
|
81
|
+
| Release operations | ✅ automated | Trusted release workflows (prepare/publish), release-please changelog automation, npm provenance publishing, support SLAs. | Yes |
|
|
82
|
+
|
|
83
|
+
Legend: ✅ complete, 🚧 in progress/planned.
|
|
84
|
+
|
|
85
|
+
## Work Breakdown & TODO Map
|
|
86
|
+
|
|
87
|
+
Each deliverable is tracked with a `TBS-xxx` identifier. New scaffolding and TODO
|
|
88
|
+
comments in the repository reference these IDs so multiple Codex runs can execute
|
|
89
|
+
in parallel without collisions.
|
|
90
|
+
|
|
91
|
+
| ID | Epic | Description | Primary Modules |
|
|
92
|
+
| ----------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
|
|
93
|
+
| **TBS-001** | History Replay | Build history ingestion, determinism snapshot persistence, mismatch diagnostics. | `src/workflow/replay.ts`, `src/worker/sticky-cache.ts`, `src/worker/runtime.ts` |
|
|
94
|
+
| **TBS-002** | Activity Lifecycle (✅) | Heartbeat helper wired to WorkflowService with retry/cancellation, local retry orchestration, enriched cancellation metadata. | `src/activities/lifecycle.ts`, `src/worker/activity-runtime.ts` |
|
|
95
|
+
| **TBS-003** | Worker Concurrency | Add scheduler for concurrent workflow/activity processors, sticky queues, build-id routing. | `src/worker/concurrency.ts`, `src/worker/runtime.ts` |
|
|
96
|
+
| **TBS-004** | Observability | Emit structured logs, metrics, and tracing hooks across client/worker. | `src/observability/logger.ts`, `src/observability/metrics.ts` |
|
|
97
|
+
| **TBS-005** | Client Resilience | Layered retries, interceptors, TLS/auth validation, memo/search helpers. | `src/client/interceptors.ts`, `src/client/retries.ts` |
|
|
98
|
+
| **TBS-006** | Integration Harness | Temporal dev-server automation, replay regression suite, load tests. | `tests/integration/harness.ts`, `tests/replay/*.ts` |
|
|
99
|
+
| **TBS-007** | CLI Tooling | `temporal-bun doctor`, `temporal-bun replay`, proto regeneration script. | `src/bin/temporal-bun.ts`, `scripts/proto/update-temporal-protos.ts` |
|
|
100
|
+
| **TBS-008** | Documentation & DX | Architecture guide, cookbook, migration path, CLI accessibility. | `apps/docs/content/docs/temporal-bun-sdk.mdx`, `docs/*` |
|
|
101
|
+
| **TBS-009** | Release Automation | CI workflows, changelog, signed publish, support policy artifacts. | `.github/workflows/temporal-bun-sdk.yml`, `packages/temporal-bun-sdk/CHANGELOG.md` |
|
|
102
|
+
| **TBS-010** | Effect Architecture | Migrate worker/client/config/runtime to Effect Layers, structured dependency injection, and fiber supervision. | `src/runtime/effect-layers.ts`, `src/worker/runtime.ts`, `src/client.ts`, `src/config.ts` |
|
|
103
|
+
| **TBS-011** | Payload Codec & Failure Converter | Layered DataConverter with ordered codecs (gzip + AES-GCM), structured failure converter, doctor validation, and observability hooks. | `src/common/payloads/**`, `src/client.ts`, `src/worker/runtime.ts`, `docs/*` |
|
|
104
|
+
|
|
105
|
+
> **Implementation rule:** Every work item must create or update code that carries
|
|
106
|
+
> a `// TODO(TBS-xxx): ...` marker. Leave stubs effect-safe and executable even
|
|
107
|
+
> before full implementation (e.g., return `Effect.fail` with descriptive
|
|
108
|
+
> placeholders).
|
|
109
|
+
|
|
110
|
+
## Execution Playbooks
|
|
111
|
+
|
|
112
|
+
Each playbook below describes the entry points, primary TODOs, recommended
|
|
113
|
+
Effect primitives, acceptance tests, and hand-offs so individual Codex instances
|
|
114
|
+
can contribute independently without re-planning.
|
|
115
|
+
|
|
116
|
+
### Effect-First Architecture Principles (TBS-010 umbrella)
|
|
117
|
+
|
|
118
|
+
- All long-running flows (polling, scheduling, replay, CLI commands) should be
|
|
119
|
+
expressed as `Effect` programs; avoid raw `async`/`await`.
|
|
120
|
+
- Dependencies (Temporal config, WorkflowService client, logger, metrics, sticky
|
|
121
|
+
cache, scheduler) should be provided via `Layer`/`Context`.
|
|
122
|
+
- Use `Scope` and supervised fibres for worker lifecycle management; no manual
|
|
123
|
+
`AbortController`.
|
|
124
|
+
- Logging/metrics must route through Effect services, not `console`.
|
|
125
|
+
- Configuration parsing should use `Schema` and `Effect.try` to surface errors
|
|
126
|
+
effectfully.
|
|
127
|
+
- Manual loops should leverage `Effect.repeat`, `Stream`, or `Queue` primitives
|
|
128
|
+
to gain back-pressure and cancellation.
|
|
129
|
+
|
|
130
|
+
#### Layered bootstrap modules
|
|
131
|
+
|
|
132
|
+
- `src/runtime/cli-layer.ts` merges the config, observability, and WorkflowService
|
|
133
|
+
layers for CLI tooling. `runTemporalCliEffect` executes arbitrary Effect
|
|
134
|
+
programs with Temporal env vars (doctor, replay, smoke tests) without
|
|
135
|
+
hand-wiring `loadTemporalConfig`.
|
|
136
|
+
- `src/runtime/worker-app.ts` composes config + observability + WorkflowService +
|
|
137
|
+
worker runtime layers and exposes `runWorkerApp`. Host apps can now start the
|
|
138
|
+
worker purely through `Effect.scoped` (no manual `createWorker` + `AbortController`).
|
|
139
|
+
|
|
140
|
+
### TBS-010 – Effect Architecture
|
|
141
|
+
|
|
142
|
+
- **Starting points**
|
|
143
|
+
- `src/runtime/effect-layers.ts` – declare shared `Layer`s for config, logger,
|
|
144
|
+
metrics, WorkflowService client, sticky cache, scheduler.
|
|
145
|
+
- `src/worker/runtime.ts` – refactor to consume layers instead of raw Promises.
|
|
146
|
+
- `src/client.ts` – expose construction via Effect Layer, adopt interceptors/retries.
|
|
147
|
+
- `src/config.ts` – convert loader to Effect + Schema validation.
|
|
148
|
+
- **Effect guidance**
|
|
149
|
+
- Use `Layer.scoped`/`Layer.effect` to manage resources (clients, transports).
|
|
150
|
+
- Replace manual `AbortController` with `Scope` and `Fiber` interruption.
|
|
151
|
+
- Propagate structured errors via `Effect.fail`.
|
|
152
|
+
- **Acceptance criteria**
|
|
153
|
+
1. Worker run/shutdown implemented as `Effect` programs (no raw `Promise` orchestration).
|
|
154
|
+
2. Config, logger, metrics, WorkflowService client available via `Layer`.
|
|
155
|
+
3. CLI and tests can bootstrap runtime by providing layers.
|
|
156
|
+
4. Documentation updated with Layer usage patterns.
|
|
157
|
+
- **Dependencies**
|
|
158
|
+
- Enables observability (TBS-004), concurrency (TBS-003), and client resilience (TBS-005) to plug into shared services.
|
|
159
|
+
|
|
160
|
+
### TBS-011 – Payload Codec & Failure Converter
|
|
161
|
+
|
|
162
|
+
- **Starting points**
|
|
163
|
+
- `src/common/payloads/*` – introduce ordered codec chain + failure converter wired through the Effect `DataConverter` layer.
|
|
164
|
+
- `src/config.ts` – schema + env parsing for `payloadCodecs` (`TEMPORAL_PAYLOAD_CODECS=gzip,aes-gcm`, `TEMPORAL_CODEC_AES_KEY`, optional `TEMPORAL_CODEC_AES_KEY_ID`).
|
|
165
|
+
- `src/client.ts`, `src/worker/runtime.ts` – resolve codec chain from config, expose metrics/logging around codec successes/failures.
|
|
166
|
+
- `src/bin/temporal-bun.ts` – doctor command validates codec configuration and reports chain summary.
|
|
167
|
+
- **Acceptance criteria**
|
|
168
|
+
1. Payload converter supports ordered codecs (gzip + AES-GCM built-in) with replay-safe envelopes; extension point for additional codecs.
|
|
169
|
+
2. Failure converter maps Temporal `Failure` messages to structured `TemporalFailureError` with details/cause decoded via codec pipeline.
|
|
170
|
+
3. Worker/client route all payloads (workflow args, activities, queries/updates, memo/search attributes, determinism markers) through the layered converter.
|
|
171
|
+
4. Observability: counters for codec encode/decode/errors and structured logging for misconfiguration; `temporal-bun doctor` surfaces codec chain and fails fast on invalid keys.
|
|
172
|
+
- **Operational notes**
|
|
173
|
+
- Default remains JSON-only; enable codecs via config/env to avoid breaking existing users.
|
|
174
|
+
- AES-GCM keys must be 128/192/256-bit (base64/hex); key IDs travel in payload metadata for rotation.
|
|
175
|
+
- Determinism: codecs wrap the entire payload proto, so workflow replay is safe as long as the codec chain remains stable for a given history.
|
|
176
|
+
|
|
177
|
+
### TBS-001 – History Replay & Sticky Cache
|
|
178
|
+
|
|
179
|
+
- **Status**: ✅ Completed (November 2025) — determinism replay ingestion, sticky cache eviction/metrics, and the integration + replay harnesses now live on `main`.
|
|
180
|
+
- **Starting points**
|
|
181
|
+
- `src/workflow/replay.ts` – implement `ingestWorkflowHistory` and
|
|
182
|
+
`diffDeterminismState`.
|
|
183
|
+
- `src/worker/sticky-cache.ts` – replace placeholder eviction strategy, expose metrics.
|
|
184
|
+
- `src/worker/runtime.ts` – wire cache into poll loop, use `ingestWorkflowHistory`
|
|
185
|
+
before executing tasks.
|
|
186
|
+
- **Effect guidance**
|
|
187
|
+
- Use `Effect.gen` and `Stream` to process histories incrementally if needed.
|
|
188
|
+
- Surface diagnostics through `Effect.fail` with rich error payloads.
|
|
189
|
+
- **Acceptance criteria**
|
|
190
|
+
1. Determinism state reconstructed from Temporal history (coverage includes timer,
|
|
191
|
+
activity, child workflow events).
|
|
192
|
+
2. Sticky cache persists state across multiple workflow tasks + evicts per policy.
|
|
193
|
+
3. Replay mismatch yields `WorkflowNondeterminismError` that includes event IDs
|
|
194
|
+
and mismatched command signatures.
|
|
195
|
+
4. Unit tests and dev-server scenario verifying behaviour. (Covered by `tests/workflow/replay.test.ts`, `tests/replay/fixtures.test.ts`, and `tests/integration/history-replay.test.ts`.)
|
|
196
|
+
- **Implementation notes**
|
|
197
|
+
- Determinism snapshots are persisted as `temporal-bun-sdk/determinism` record markers (schema v1) that bundle command history, random/time streams, and the last processed event id. The marker payload is stored via the configured `DataConverter`.
|
|
198
|
+
- `TEMPORAL_STICKY_CACHE_SIZE` and `TEMPORAL_STICKY_TTL_MS` control cache capacity and eviction; the sticky worker queue schedule-to-start timeout inherits from the TTL so increasing it lengthens deterministic affinity.
|
|
199
|
+
- `tests/integration/harness.ts` provides a Temporal CLI-backed harness that starts the dev server, executes workflows (`temporal workflow execute`), fetches JSON history (`temporal workflow show --output json`), and feeds the ingestion pipeline. Tests log a skip when the CLI is unavailable instead of failing hard.
|
|
200
|
+
- Sticky cache decisions are now instrumented with counters (`hits`, `misses`, `evictions`, `heal`) and structured logs so nondeterminism causes can be traced via `WorkflowNondeterminismError.details`.
|
|
201
|
+
- Replay fixtures live under `tests/replay/fixtures/*.json` with a dedicated harness (`tests/replay/fixtures.test.ts`) that locks determinism outputs to real histories. The capture/runbook lives in `docs/replay-runbook.md`.
|
|
202
|
+
- **Validation commands**
|
|
203
|
+
- `cd packages/temporal-bun-sdk && bun test tests/workflow/replay.test.ts`
|
|
204
|
+
- `cd packages/temporal-bun-sdk && bun test tests/replay/fixtures.test.ts`
|
|
205
|
+
- `cd packages/temporal-bun-sdk && bun test tests/integration/history-replay.test.ts`
|
|
206
|
+
|
|
207
|
+
- **Dependencies**
|
|
208
|
+
- Optional integration with TBS-004 for logging metrics.
|
|
209
|
+
- Provides determinism snapshot for TBS-003 scheduler.
|
|
210
|
+
|
|
211
|
+
### TBS-002 – Activity Lifecycle
|
|
212
|
+
|
|
213
|
+
- **Starting points**
|
|
214
|
+
- `src/activities/lifecycle.ts` – flesh out `registerHeartbeat` (wire to Temporal)
|
|
215
|
+
and `nextRetryDelay` (match Temporal retry spec).
|
|
216
|
+
- `src/worker/runtime.ts` – integrate heartbeats and retries when processing activity tasks.
|
|
217
|
+
- **Effect guidance**
|
|
218
|
+
- Wrap heartbeats in `Effect.retry` with exponential backoff aligned to server timeouts.
|
|
219
|
+
- Use `Effect.timeout` for heartbeat intervals, store state in `Ref`.
|
|
220
|
+
- **Acceptance criteria**
|
|
221
|
+
1. Heartbeat API emits to Temporal dev server and respects configured interval.
|
|
222
|
+
2. Retry logic honours `WorkflowRetryPolicy` (initial + max intervals, backoff coefficient,
|
|
223
|
+
non-retryable errors, attempt capping).
|
|
224
|
+
3. Cancellation semantics propagate reason/last heartbeat details to handlers.
|
|
225
|
+
4. Integration tests covering heartbeat timeout and retry exhaustion.
|
|
226
|
+
- **Dependencies**
|
|
227
|
+
- Exposes metrics/log hooks for TBS-004.
|
|
228
|
+
- Scheduler from TBS-003 can leverage retry/backoff outputs.
|
|
229
|
+
|
|
230
|
+
### TBS-003 – Worker Concurrency & Sticky Queues
|
|
231
|
+
|
|
232
|
+
- **Starting points**
|
|
233
|
+
- `src/worker/concurrency.ts` – expand scheduler, implement graceful shutdown,
|
|
234
|
+
integrate metrics.
|
|
235
|
+
- `src/worker/runtime.ts` – replace serial loops with scheduler enqueues, manage
|
|
236
|
+
sticky queue identities.
|
|
237
|
+
- **Effect guidance**
|
|
238
|
+
- Use `Queue`, `Semaphore`, or `Channel` for concurrency control.
|
|
239
|
+
- Manage fibre lifecycle with `Scope` for deterministic teardown.
|
|
240
|
+
- Coordinate with TBS-010 to ensure scheduler runs inside Effect Layer.
|
|
241
|
+
- **Acceptance criteria**
|
|
242
|
+
1. ✅ Configurable concurrency levels (workflow/activity) via config/env (`TEMPORAL_WORKFLOW_CONCURRENCY`, `TEMPORAL_ACTIVITY_CONCURRENCY`).
|
|
243
|
+
2. ✅ Sticky task affinity using cache (TBS-001) with eviction metrics and tunable size/TTL (`TEMPORAL_STICKY_CACHE_SIZE`, `TEMPORAL_STICKY_TTL_MS`).
|
|
244
|
+
3. ✅ Build-id routing respected when scheduling tasks (deployment name defaults to `<task-queue>-deployment`; build ID via `TEMPORAL_WORKER_BUILD_ID` or a derived value).
|
|
245
|
+
4. ✅ Graceful shutdown drains tasks; observability hooks from TBS-004 now emit lifecycle logs + metrics during drain.
|
|
246
|
+
5. ✅ Load/perf harness (`tests/integration/worker-load.test.ts` and `scripts/run-worker-load.ts`) saturates workflow + activity pollers, enforces throughput/poll-latency/sticky-cache thresholds, and emits `.artifacts/worker-load/{metrics.jsonl,report.json}` for CI review.
|
|
247
|
+
- **Dependencies**
|
|
248
|
+
- Consumes determinism cache (TBS-001), emits metrics for TBS-004.
|
|
249
|
+
|
|
250
|
+
- **Load/perf harness**
|
|
251
|
+
- CPU-heavy + I/O-heavy workflows live under `tests/integration/load/**` alongside the JSONL metrics aggregator. The harness starts the Temporal CLI dev server, creates `.artifacts/worker-load` per run, and collects sticky cache, poll latency, and throughput metrics via the worker runtime's file exporter.
|
|
252
|
+
- Local runs: `cd packages/temporal-bun-sdk && TEMPORAL_INTEGRATION_TESTS=1 bun test tests/integration/worker-load.test.ts` (Bun test runner) or `cd packages/temporal-bun-sdk && bun run test:load` (Bun CLI script).
|
|
253
|
+
- CI: `.github/workflows/temporal-bun-sdk.yml` now executes `cd packages/temporal-bun-sdk && bun run test:load` after the main suite and uploads the `.artifacts/worker-load/{metrics.jsonl,report.json,temporal-cli.log}` bundle for reviewers.
|
|
254
|
+
- Default knobs submit 36 workflows with a 100s completion budget and workflow/activity concurrency of 10/14; the Bun test adds a ~15s cushion over `TEMPORAL_LOAD_TEST_TIMEOUT_MS + TEMPORAL_LOAD_TEST_METRICS_FLUSH_MS` so that healthy runs finish well before the CI hard timeout while still exercising the scheduler.
|
|
255
|
+
|
|
256
|
+
### TBS-004 – Observability (Complete)
|
|
257
|
+
|
|
258
|
+
- **Highlights**
|
|
259
|
+
- Introduced logger/metrics layers with format/level controls, pluggable exporters, and shared helpers for counters/histograms.
|
|
260
|
+
- Worker and client runtimes consume the new services, emitting sticky cache, poll latency, heartbeat, and failure metrics while logging lifecycle events.
|
|
261
|
+
- `runTemporalCliEffect` wires config + observability layers so `temporal-bun doctor` validates env overrides, emits structured logs, and flushes exporter sinks without bespoke bootstrap.
|
|
262
|
+
- SDK docs and production design guidance cover the telemetry knobs and show the `bunx temporal-bun doctor --log-format=json --metrics=file:/tmp/metrics.json` validation path.
|
|
263
|
+
- **Effect guidance**
|
|
264
|
+
- Observability services are built with `Effect` so they can be composed or swapped (layers remain available for future TBS-010 work).
|
|
265
|
+
- Metrics exporters flush through `Effect` effects to avoid blocking shutdown.
|
|
266
|
+
- **Validation notes**
|
|
267
|
+
1. `cd packages/temporal-bun-sdk && bun test packages/temporal-bun-sdk/tests/**/*` now exercises the new observability unit/integration suites.
|
|
268
|
+
2. `cd packages/temporal-bun-sdk && bunx temporal-bun doctor --log-format=json --metrics=file:/tmp/metrics.json` confirms the documented configuration path and writes benchmark output.
|
|
269
|
+
|
|
270
|
+
### TBS-005 – Client Resilience
|
|
271
|
+
|
|
272
|
+
- **Starting points**
|
|
273
|
+
- `src/client/interceptors.ts`, `src/client/retries.ts`, integrate with `src/client.ts`.
|
|
274
|
+
- Add memo/search attribute helpers and TLS validation improvements.
|
|
275
|
+
- **Effect guidance**
|
|
276
|
+
- Compose retries using `withTemporalRetry`.
|
|
277
|
+
- Provide client access via Effect Layer (TBS-010).
|
|
278
|
+
- Expose interceptors as `Effect<Interceptor[]>`, applying logging/metrics.
|
|
279
|
+
- **Acceptance criteria**
|
|
280
|
+
1. Retries follow Temporal best practices and are configurable.
|
|
281
|
+
2. Interceptors provide logging, metrics, and custom header hooks.
|
|
282
|
+
3. TLS/auth path verifies cert chains, surfaces actionable errors.
|
|
283
|
+
4. Client API exposes helper methods for memo/search attributes.
|
|
284
|
+
|
|
285
|
+
### TBS-006 – Integration Harness & Replay Suite
|
|
286
|
+
|
|
287
|
+
- **Starting points**
|
|
288
|
+
- `tests/integration/harness.ts`, `tests/replay/`.
|
|
289
|
+
- Add Bun scripts to orchestrate Temporal dev server (CLI or docker-compose).
|
|
290
|
+
- **Effect guidance**
|
|
291
|
+
- Harness should use `Managed`/`Layer` for setup/teardown.
|
|
292
|
+
- Replay suite should re-use `ingestWorkflowHistory` to assert determinism.
|
|
293
|
+
- **Acceptance criteria**
|
|
294
|
+
1. CLI command (`bun test:integration` or similar) spins up dev server, runs scenarios.
|
|
295
|
+
2. Replay suite replays stored histories, fails on non-determinism.
|
|
296
|
+
3. Load test baseline recorded (CPU/memory/poll latency metrics).
|
|
297
|
+
|
|
298
|
+
### TBS-007 – CLI Tooling
|
|
299
|
+
|
|
300
|
+
- **Starting points**
|
|
301
|
+
- `src/bin/temporal-bun.ts` – add new subcommands.
|
|
302
|
+
- `scripts/update-temporal-protos.ts` – implement regeneration flow.
|
|
303
|
+
- **Effect guidance**
|
|
304
|
+
- Each CLI command should be effectful with proper exit codes (no raw `process.exit`); plug into Effect runtime (TBS-010).
|
|
305
|
+
- Use `Effect` to orchestrate external processes (`Bun.spawn`, `Effect.tryPromise`).
|
|
306
|
+
- **Acceptance criteria**
|
|
307
|
+
1. `temporal-bun doctor` validates config connectivity and prints diagnostics.
|
|
308
|
+
2. `temporal-bun replay` replays history files **and** live executions (Temporal CLI → WorkflowService fallback), reuses TBS-001 ingestion, emits metrics/logs/JSON summaries, and ships with unit + integration coverage.
|
|
309
|
+
3. Proto update script takes version argument and regenerates stubs idempotently.
|
|
310
|
+
|
|
311
|
+
### TBS-008 – Documentation & DX
|
|
312
|
+
|
|
313
|
+
- **Starting points**
|
|
314
|
+
- `apps/docs/content/docs/temporal-bun-sdk.mdx`, `docs/*`.
|
|
315
|
+
- Update example app to mirror deterministic APIs (`packages/temporal-bun-sdk-example`).
|
|
316
|
+
- **Acceptance criteria**
|
|
317
|
+
1. Architecture guide includes diagrams and determinism explanations.
|
|
318
|
+
2. Cookbook recipes for activities, timers, signals, updates, heartbeats.
|
|
319
|
+
3. Migration doc from Zig/Rust bridge.
|
|
320
|
+
4. CLI docs reflect new commands and accessibility considerations.
|
|
321
|
+
5. Example project README documents runtime prerequisites, configuration requirements,
|
|
322
|
+
and Effect usage expectations so consumers can adopt the SDK confidently.
|
|
323
|
+
- **Implementation notes (Nov 15, 2025)**
|
|
324
|
+
- `apps/docs/content/docs/temporal-bun-sdk.mdx` now anchors the docs hierarchy:
|
|
325
|
+
architecture overview, configuration, tutorials/recipes, CLI/tooling, and
|
|
326
|
+
troubleshooting/GA roadmap sections live on that page until navigation gains
|
|
327
|
+
discrete entries.
|
|
328
|
+
- CLI reference, proto regeneration notes, and replay/TLS troubleshooting
|
|
329
|
+
guidance were added so engineers no longer have to mine the README for
|
|
330
|
+
operational context.
|
|
331
|
+
- GA blockers called out in the public docs must stay in sync with this design
|
|
332
|
+
file; any time a TBS item ships, update both locations.
|
|
333
|
+
- **Open documentation work**
|
|
334
|
+
- Break the long-form MDX file into sub-pages once the docs nav supports it
|
|
335
|
+
(Overview, Tutorials, Configuration, CLI & Tooling, Troubleshooting, Release
|
|
336
|
+
Notes).
|
|
337
|
+
- Add diagrams/screenshots, cookbook snippets, and migration guidance per the
|
|
338
|
+
acceptance criteria above.
|
|
339
|
+
|
|
340
|
+
### TBS-009 – Release Automation
|
|
341
|
+
|
|
342
|
+
- **Status**: ✅ Completed on 2025-11-17. `temporal-bun-sdk.yml` now gates every
|
|
343
|
+
release via release-please, Oxfmt/unit/load suites, and npm trusted publishing
|
|
344
|
+
with provenance so `main` publishes are reproducible (v0.2.0 shipped through
|
|
345
|
+
the pipeline the same day).
|
|
346
|
+
- **Highlights**
|
|
347
|
+
- release-please prepare job opens the automated release PR, runs validation
|
|
348
|
+
suites against `release-please--branches--main--components--temporal-bun-sdk`,
|
|
349
|
+
and updates `CHANGELOG.md`/`package.json`.
|
|
350
|
+
- Publish job upgrades npm to ≥11.5, relies on GitHub OIDC trusted publishing
|
|
351
|
+
(no automation token), reenforces all tests/builds, and runs `npm publish
|
|
352
|
+
--provenance --tag <dist>`.
|
|
353
|
+
- `packages/temporal-bun-sdk/docs/release-runbook.md` documents the flow, while
|
|
354
|
+
the proto regeneration workflow keeps generated sources aligned with upstream.
|
|
355
|
+
- **Starting points**
|
|
356
|
+
- `.github/workflows/temporal-bun-sdk.yml` – dual-mode workflow: `prepare`
|
|
357
|
+
triggers release-please to open/update the release PR and run validation
|
|
358
|
+
suites; `publish` runs npm publish with provenance directly from `main`.
|
|
359
|
+
- `.github/workflows/temporal-bun-sdk-protos.yml` – standalone proto
|
|
360
|
+
regeneration job that creates a `chore/temporal-bun-sdk-proto-regen` PR when
|
|
361
|
+
upstream APIs change.
|
|
362
|
+
- `release-please-config.json` + `.release-please-manifest.json` – configure
|
|
363
|
+
release-please (`node` release type) for `packages/temporal-bun-sdk`.
|
|
364
|
+
- `packages/temporal-bun-sdk/CHANGELOG.md` – canonical changelog kept current
|
|
365
|
+
by release-please.
|
|
366
|
+
- **Acceptance criteria (met)**
|
|
367
|
+
1. The release workflow installs Node 24 + Bun, runs `bun install --frozen-lockfile`, executes `bunx oxfmt --check packages/temporal-bun-sdk`, `bun test`, `bun run test:load`, and `bun run build`. Any failure aborts the
|
|
368
|
+
publish.
|
|
369
|
+
2. release-please derives the semver bump from Conventional Commits, updates
|
|
370
|
+
`package.json`, and rewrites `CHANGELOG.md` inside the automated release PR.
|
|
371
|
+
3. Publishing uses GitHub OIDC + `npm publish --provenance --access public`
|
|
372
|
+
with a scoped automation token, and emits an attestation/SBOM artifact.
|
|
373
|
+
4. Prepare mode runs build/test/load suites against the release-please branch
|
|
374
|
+
(`release-please--branches--main--components--temporal-bun-sdk`) so the PR
|
|
375
|
+
contains validated artifacts, while the dedicated proto workflow keeps
|
|
376
|
+
generated sources in sync.
|
|
377
|
+
5. Publish mode exposes a `workflow_dispatch` dry-run path, references
|
|
378
|
+
`security@proompteng.ai` for disclosures, and requires maintainers to link
|
|
379
|
+
execution logs/artifacts before requesting review.
|
|
380
|
+
|
|
381
|
+
## Component Designs
|
|
382
|
+
|
|
383
|
+
### Workflow Runtime
|
|
384
|
+
|
|
385
|
+
1. **Deterministic context (shipped)**
|
|
386
|
+
- Command intents: `schedule-activity`, `start-timer`, `start-child-workflow`,
|
|
387
|
+
`signal-external-workflow`, `continue-as-new`.
|
|
388
|
+
- Determinism guard captures command history, `Math.random()` and `Date.now()`
|
|
389
|
+
usage for replay validation.
|
|
390
|
+
- Deterministic context is enforced for all workflows and cannot be disabled.
|
|
391
|
+
2. **Replay ingestion (GA critical, TBS-001)**
|
|
392
|
+
- Extract command history, random/time snapshots from Temporal history events.
|
|
393
|
+
- Maintain per-run snapshot (`namespace::workflowId::runId`) accessible across
|
|
394
|
+
polls and sticky cache transfers.
|
|
395
|
+
- Surface mismatch details via `WorkflowNondeterminismError` enriched with
|
|
396
|
+
event IDs.
|
|
397
|
+
3. **Command metadata & schema validation (TBS-001/TBS-005)**
|
|
398
|
+
- Enforce schema-based validation for headers, memo, search attributes, retry
|
|
399
|
+
policies, and backoffs.
|
|
400
|
+
- Provide helper layers for common patterns (timeouts, workflows-by-task queue).
|
|
401
|
+
4. **Workflow cache management**
|
|
402
|
+
- Implement LRU cache to retain determinism snapshots for sticky tasks; evict on
|
|
403
|
+
memory pressure with graceful degradation.
|
|
404
|
+
|
|
405
|
+
### Activity Execution
|
|
406
|
+
|
|
407
|
+
1. **Handler registration (shipped)**
|
|
408
|
+
- Map-based registry with AsyncLocalStorage context and cancellation support.
|
|
409
|
+
2. ✅ **Retries & heartbeats (TBS-002)**
|
|
410
|
+
- WorkerRuntime uses the lifecycle helper to emit throttled heartbeats via `RecordActivityTaskHeartbeat`, retry transient RPC failures, and propagate server-side cancellation through the `ActivityContext`.
|
|
411
|
+
- Local activity retries mirror the `WorkflowRetryPolicy` (initial/max interval, backoff coefficient, maximum attempts, non-retryable error types, schedule-to-close bounds) before surfacing a terminal failure flagged as non-retryable.
|
|
412
|
+
- `activityContext.heartbeat(...details)` is now available to user code; details and cancellation reasons flow into `RespondActivityTaskCanceled/Failed` for Temporal UI parity.
|
|
413
|
+
- Covered by `tests/activities/lifecycle.test.ts` and the Temporal CLI harness suite (`tests/integration/activity-lifecycle.integration.test.ts`) which exercises steady-state heartbeats, heartbeat timeouts, and retry exhaustion.
|
|
414
|
+
3. **Cancellation semantics**
|
|
415
|
+
- Distinguish graceful vs. failure cancellations, propagate context to handlers.
|
|
416
|
+
4. **Metrics and structured logging**
|
|
417
|
+
- Expose activity execution spans, attempt counts, and latencies.
|
|
418
|
+
|
|
419
|
+
### Worker Runtime
|
|
420
|
+
|
|
421
|
+
1. **Polling loops (shipped)**
|
|
422
|
+
- Workflow/activity poll loops with deterministic snapshot storage.
|
|
423
|
+
2. **Concurrency & sticky queues (GA critical, TBS-003)**
|
|
424
|
+
- Configurable poller counts, run-multiple workflows concurrently with safe
|
|
425
|
+
determinism state transitions.
|
|
426
|
+
- Sticky queue support with cache invalidation and eviction heuristics.
|
|
427
|
+
3. **Build-id routing**
|
|
428
|
+
- Respect Temporal build IDs and `taskQueue` versioning, with CLI configuration.
|
|
429
|
+
4. **Graceful shutdown**
|
|
430
|
+
- Drain in-flight work, respect `--graceful-shutdown-timeout`, expose `WorkerService` integrable with Effect layers.
|
|
431
|
+
5. **Observability**
|
|
432
|
+
- Structured logs (JSON), metrics (poll latency, task failures), optional tracing.
|
|
433
|
+
6. **Query-only tasks (shipped)**
|
|
434
|
+
- Detect `PollWorkflowTaskQueueResponse.query` and respond with `RespondQueryTaskCompleted` in a read-only executor mode (no new commands/timers/randomness/continue-as-new). Emits `temporal_worker_query_{started,completed,failed}_total` and `temporal_worker_query_latency_ms` metrics.
|
|
435
|
+
|
|
436
|
+
### Client Library
|
|
437
|
+
|
|
438
|
+
1. **Connect transport (shipped)**
|
|
439
|
+
- gRPC-over-HTTP/2 with TLS/mTLS support, metadata canonicalisation.
|
|
440
|
+
2. **Resilience features (GA critical, TBS-005)**
|
|
441
|
+
- Retry policies with jitter, idempotency keys, exponential backoff tuned to
|
|
442
|
+
Temporal best practices.
|
|
443
|
+
- Client interceptors for logging, auth, metrics.
|
|
444
|
+
3. **High-level APIs**
|
|
445
|
+
- Convenience handles for workflow and activity results, typed search attributes,
|
|
446
|
+
payload conversion hooks, streaming update support.
|
|
447
|
+
- Query helpers honour `QueryRejectCondition` and surface query failures when workers respond via `RespondQueryTaskCompleted`.
|
|
448
|
+
|
|
449
|
+
### Tooling & Automation
|
|
450
|
+
|
|
451
|
+
- **CLI (TBS-007)**
|
|
452
|
+
- Add `temporal-bun doctor` for connectivity validation.
|
|
453
|
+
- Add `temporal-bun replay` for history replay against workflows.
|
|
454
|
+
- Keep the production runtime Bun/TypeScript-only; native experiments must live outside the published package until they earn separate release gates.
|
|
455
|
+
- **Proto updates**
|
|
456
|
+
- Scripted `buf` regeneration with Temporal release cadence tracking.
|
|
457
|
+
- **Release automation**
|
|
458
|
+
- GitHub workflow for lint/test/build, version bump, changelog generation,
|
|
459
|
+
signed npm publish, provenance attestations.
|
|
460
|
+
|
|
461
|
+
### Documentation & Developer Experience
|
|
462
|
+
|
|
463
|
+
- Architecture guides, quickstarts, troubleshooting covering determinism,
|
|
464
|
+
payload converters, TLS, deployment recipes (Docker, serverless).
|
|
465
|
+
- API reference via `typedoc`.
|
|
466
|
+
- Migration path from the Rust/Zig bridge to pure TypeScript runtime.
|
|
467
|
+
- Example apps: update `packages/temporal-bun-sdk-example` to use deterministic
|
|
468
|
+
context primitives (`activities.schedule`, `timers.start`, `determinism.now`).
|
|
469
|
+
- Refresh `apps/docs/content/docs/temporal-bun-sdk.mdx` with: installation instructions, quickstart tutorials (worker + client), configuration guides, and release notes so new users can adopt the SDK confidently.
|
|
470
|
+
- Introduce a multi-page docs hierarchy (e.g., Overview, Installation, Tutorials, Configuration, Troubleshooting, Release Notes) and wire it into the docs navigation so content scales beyond a single monolithic page.
|
|
471
|
+
|
|
472
|
+
## Error Handling & Observability
|
|
473
|
+
|
|
474
|
+
- Map Connect/gRPC status codes to Temporal-specific error classes.
|
|
475
|
+
- Provide structured error types for workflow failures (application, timeout,
|
|
476
|
+
cancellation, deterministic).
|
|
477
|
+
- Integrate with Effect logging; expose `Logger` and `Metrics` interfaces for
|
|
478
|
+
host applications.
|
|
479
|
+
- Plan for OpenTelemetry metrics (`temporal.worker.poll_time`, `workflow.task.latency`)
|
|
480
|
+
and tracing instrumentation.
|
|
481
|
+
- Observability layers now back the worker/client runtimes; tracing hooks will piggyback on the same logger/metrics surfaces when ready.
|
|
482
|
+
|
|
483
|
+
## Configuration & Deployment
|
|
484
|
+
|
|
485
|
+
- `loadTemporalConfigEffect` (and the `TemporalConfigLayer`) already handle TLS, auth, task queue defaults, and worker identity configuration.
|
|
486
|
+
- GA tasks:
|
|
487
|
+
- Support external config files (JSON/TOML) with schema validation.
|
|
488
|
+
- Document environment variables for multi-namespace deployments.
|
|
489
|
+
- Provide Dockerfile templates with best practices (non-root, minimal image).
|
|
490
|
+
- Publish Helm/Knative snippets for worker deployment.
|
|
491
|
+
- Activity lifecycle knobs (`TEMPORAL_ACTIVITY_HEARTBEAT_INTERVAL_MS`, `TEMPORAL_ACTIVITY_HEARTBEAT_RPC_TIMEOUT_MS`) now control heartbeat cadence and RPC timeouts; defaults keep cadence < heartbeat timeout.
|
|
492
|
+
|
|
493
|
+
## Testing & Quality Strategy
|
|
494
|
+
|
|
495
|
+
1. **Unit tests (shipped + expand)**
|
|
496
|
+
- Maintain >90% coverage for command builders, determinism guard, config loader.
|
|
497
|
+
2. **Integration tests (GA critical)**
|
|
498
|
+
- Automated Temporal dev-server suite covering:
|
|
499
|
+
- Activity retries/heartbeats.
|
|
500
|
+
- Timers and signals.
|
|
501
|
+
- Child workflow failure propagation.
|
|
502
|
+
- Continue-as-new determinism.
|
|
503
|
+
- Build-id routing acceptance.
|
|
504
|
+
- Each major functionality (TBS-001 ↔ TBS-007) must add integration tests using the Temporal CLI available in the execution environment, ensuring end-to-end validation is part of every deliverable.
|
|
505
|
+
- `tests/integration/activity-lifecycle.integration.test.ts` exercises steady heartbeats, heartbeat timeout cancellation, and retry exhaustion with non-retryable errors via the CLI harness.
|
|
506
|
+
3. **Replay regression harness**
|
|
507
|
+
- Capture real histories, replay offline, ensure deterministic snapshots survive
|
|
508
|
+
worker restarts.
|
|
509
|
+
4. **Performance & soak testing**
|
|
510
|
+
- Stress test worker concurrency scaling, measure poll latency under load.
|
|
511
|
+
5. **CI pipeline**
|
|
512
|
+
- Bun tests, lint (Oxlint), formatting (`bunx oxfmt --check`), type-check (`bunx tsc --noEmit`), Temporal dev-server
|
|
513
|
+
smoke test, Docker build verification.
|
|
514
|
+
|
|
515
|
+
## Documentation Plan
|
|
516
|
+
|
|
517
|
+
- **Docs map** – Maintain a single-source MDX page (`apps/docs/content/docs/temporal-bun-sdk.mdx`) until
|
|
518
|
+
the docs nav exposes child routes. That page must always include: overview,
|
|
519
|
+
architecture, configuration & operations, tutorials/recipes, CLI/tooling, and
|
|
520
|
+
troubleshooting/GA roadmap sections. When nav support lands, split those
|
|
521
|
+
sections into dedicated pages and link them from the overview.
|
|
522
|
+
- **Determinism & architecture deep dives** – Document determinism markers,
|
|
523
|
+
sticky cache strategy, and Effect-based worker lifecycle (diagram + prose).
|
|
524
|
+
- **Cookbooks** – Provide runnable recipes for cron schedules, signal-with-start,
|
|
525
|
+
updates, heartbeats, local activities, and replay debugging. Reference the
|
|
526
|
+
example app for each recipe.
|
|
527
|
+
- **Migration guidance** – Call out differences between the historical Zig/Rust
|
|
528
|
+
bridge and the Bun/Effect runtime, including how to port payload converters
|
|
529
|
+
and TLS configuration.
|
|
530
|
+
- **CLI accessibility** – Audit output colors/ARIA hints for `temporal-bun`
|
|
531
|
+
commands; ensure `doctor`/`replay` support `--json` for screen-reader/CI use.
|
|
532
|
+
- **Release notes & changelog hooks** – Mirror each release entry on the docs
|
|
533
|
+
site (fed by release-please) with verification steps and upgrade notes now that
|
|
534
|
+
TBS-009 is live.
|
|
535
|
+
|
|
536
|
+
## Release & Support Plan
|
|
537
|
+
|
|
538
|
+
1. **Versioning (TBS-009) – ✅ shipped**
|
|
539
|
+
- Semantic versioning + release-please manifest drive RC/GA cadence.
|
|
540
|
+
2. **Changelog – ✅ automated**
|
|
541
|
+
- release-please rewrites `CHANGELOG.md` from Conventional Commits.
|
|
542
|
+
3. **Publishing – ✅ trusted**
|
|
543
|
+
- Signed npm publishes with provenance (GitHub OIDC trusted publishing).
|
|
544
|
+
4. **Support policy**
|
|
545
|
+
- Document security disclosure process, escalation contacts, and SLA for bug fixes.
|
|
546
|
+
|
|
547
|
+
## Risks & Mitigations
|
|
548
|
+
|
|
549
|
+
| Risk | Impact | Mitigation |
|
|
550
|
+
| ------------------------- | -------------------------------------- | ------------------------------------------------------------------------------------- |
|
|
551
|
+
| Determinism regressions | Workflow non-determinism in production | Replay harness, sticky cache eviction tests, deterministic guard validations. |
|
|
552
|
+
| Transport incompatibility | Bun HTTP/2 regressions | Continuous compatibility tests against Temporal Cloud and OSS releases. |
|
|
553
|
+
| Performance under load | Missed SLA on task latency | Profiling with CPU/network throttling, concurrency tuning, metrics dashboards. |
|
|
554
|
+
| Packaging regressions | Broken ESM/CJS consumers | Dual-package smoke tests (Bun, Node 20), tree-shaking tests, API lockfile. |
|
|
555
|
+
| Tooling drift | CLI/docs mismatched with runtime | Doc-driven development checklist; docs PR cannot merge without updated CLI behaviour. |
|
|
556
|
+
|
|
557
|
+
## GA Checklist & Next Steps
|
|
558
|
+
|
|
559
|
+
1. ✅ Deterministic workflow context and command intents.
|
|
560
|
+
2. ✅ History replay ingestion, sticky cache, determinism persistence tests.
|
|
561
|
+
3. ✅ Activity lifecycle completeness (heartbeats, retries, failure categorisation).
|
|
562
|
+
4. ✅ Worker concurrency, sticky queues, graceful shutdown polish.
|
|
563
|
+
5. ✅ Client retries/interceptors, TLS hardening.
|
|
564
|
+
6. ✅ Observability: logs, metrics, tracing hooks.
|
|
565
|
+
7. ✅ Temporal dev-server integration suite + replay regression harness.
|
|
566
|
+
8. ✅ Documentation overhaul (architecture, tutorials, troubleshooting).
|
|
567
|
+
9. ✅ Release automation: lint/test/build, versioning, changelog, npm publish pipeline.
|
|
568
|
+
10. ✅ Support & maintenance guide (issue triage and security policy).
|
|
569
|
+
|
|
570
|
+
This checklist gates each release. Every GA-critical item requires passing
|
|
571
|
+
integration tests, worker load checks, production boundary verification, and
|
|
572
|
+
updated documentation before the release train can proceed.
|
|
573
|
+
|
|
574
|
+
## Post-GA Enhancements
|
|
575
|
+
|
|
576
|
+
1. **Unified observability surface.** After GA, ship optional Effect-based logger/metrics/tracing layers that can target OTLP, Prometheus remote write, or Bun-native sinks without introducing bridge processes. This includes turning the current console/in-memory stubs into documented extension points.
|
|
577
|
+
2. **Advanced scheduling experiments.** Explore adaptive concurrency and resource-based tuning (e.g., CPU/memory-aware queue depth, workflow/activities priority lanes) built directly on top of our Effect scheduler—no external “tuner” components required.
|
|
578
|
+
3. **Workflow packaging ergonomics.** Provide first-class support for both source-based workflows (ideal for Bun) and ahead-of-time bundles (for Docker/serverless), with deterministic dependency analysis and optional linting to catch non-deterministic imports.
|
|
579
|
+
4. **Client ecosystem integration.** Layer in retries/interceptors/TLS hardening plus ergonomic helpers (memo/search attribute schemas, schedule builders) so Bun clients reach feature parity with worker capabilities and promote end-to-end TypeScript-only deployments.
|
|
580
|
+
5. **Operational tooling.** Extend the CLI with “doctor”, “replay”, and “profile” commands that leverage the single-runtime architecture to run deterministic replays, capture telemetry snapshots, and surface build-id/namespace health without relying on external binaries.
|
|
581
|
+
|
|
582
|
+
## Worker versioning note
|
|
583
|
+
|
|
584
|
+
When `WorkerVersioningMode.VERSIONED` is enabled, the worker includes deployment metadata (deployment name + build ID) in poll/response requests so the server can route workflow tasks to the correct build. The Bun SDK does not call the deprecated Build ID Compatibility APIs (Version Set-based “worker versioning v0.1”), since they may be disabled on some namespaces.
|
|
585
|
+
|
|
586
|
+
Operationally, this means:
|
|
587
|
+
|
|
588
|
+
- Existing workflow runs will remain pinned to the build ID that last completed a workflow task.
|
|
589
|
+
- Deploying a new build ID will not cause nondeterministic replay on older runs, but those older runs will require that the old build remains available (or that the workflow code is backward-compatible via `determinism.getVersion` / `determinism.patched`).
|