Skip to content

Add runtime deadlines and observability#13

Merged
tannerlinsley merged 5 commits into
mainfrom
taren/runtime-deadlines-observability
Jul 21, 2026
Merged

Add runtime deadlines and observability#13
tannerlinsley merged 5 commits into
mainfrom
taren/runtime-deadlines-observability

Conversation

@tannerlinsley

@tannerlinsley tannerlinsley commented Jul 21, 2026

Copy link
Copy Markdown
Member

What changed

  • add runtime deadlines and maximum drive durations across start, signal, approval, and sweep execution
  • expose deadline helpers under ctx.runtime and automatically yield before fresh durable work when the remaining budget is low
  • persist cooperative yields as timer waits, release run leases, and resume them on a later sweep
  • make timer delivery identities include the durable operation ID
  • add OpenTelemetry spans for runtime operations, durable store calls, and fresh step execution
  • document runtime budgets and observability

Why

Applications currently have to hand-roll wall-clock checks and arbitrary queue batch sizes to avoid host execution limits. The runtime should own that policy and checkpoint cleanly without treating a yield as an error.

The timer identity change prevents sequential waits at the same timestamp from reusing an already-consumed signal delivery ID.

Impact

Existing workflows remain unbounded unless a runtime deadline or maximum duration is supplied. Step timeouts remain independent. Official context fields are grouped under the reserved runtime namespace.

Verification

  • pnpm test:ci
  • 116 workflow-core tests
  • 41 workflow-runtime tests
  • Postgres and Cloudflare D1 store suites
  • host adapter type checks and builds
  • docs link verification

Summary by CodeRabbit

  • New Features
    • Added OpenTelemetry tracing across workflow runtime operations, durable store calls, and step execution, with configurable tracing options and privacy-safe span data.
    • Introduced runtime deadline/budget controls and cooperative yielding via ctx.runtime (including helpers to check remaining time and pause/resume execution).
  • Documentation
    • Expanded observability and runtime docs, including tracing configuration and deadline/yield semantics.
  • Tests
    • Added coverage for tracing behavior/privacy and deadline/yield pause/resume behavior.
  • Releases
    • Patch version updates across workflow core, runtime, and supported adapters.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1f8c23bf-97f4-4a6f-a9ff-741817f55a85

📥 Commits

Reviewing files that changed from the base of the PR and between e6ad72a and 70ced3c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • packages/workflow-core/package.json
  • packages/workflow-core/src/telemetry.ts
  • packages/workflow-core/tests/telemetry.test.ts
  • packages/workflow-runtime/package.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/workflow-core/src/telemetry.ts

📝 Walkthrough

Walkthrough

Adds OpenTelemetry tracing and deadline-aware cooperative yielding to workflow core and runtime execution. New runtime context helpers, durable yield timers, telemetry exports, store spans, sweep budgeting, tests, documentation, and package release metadata are included.

Changes

Runtime observability and cooperative execution

Layer / File(s) Summary
Telemetry contracts and implementation
packages/workflow-core/src/telemetry.ts, packages/workflow-core/src/index.ts, packages/workflow-runtime/src/index.ts
Adds configurable OpenTelemetry spans, safe attributes, exception handling, disabled tracing, metadata mapping, and public telemetry exports.
Engine runtime budgeting and yielding
packages/workflow-core/src/types.ts, packages/workflow-core/src/engine/run-workflow.ts
Adds runtime deadline helpers, explicit and automatic durable yielding, yield timing controls, and step attempt tracing.
Runtime driver integration
packages/workflow-runtime/src/types.ts, packages/workflow-runtime/src/runtime-driver.ts, packages/workflow-runtime/src/run-store-adapter.ts
Threads telemetry and deadline controls through run, signal, approval, timer, and sweep paths while tracing store operations and synchronizing yielded runs.
Validation, documentation, and release metadata
packages/workflow-core/tests/*, packages/workflow-runtime/tests/*, docs/*, .changeset/*, packages/*/package.json
Adds telemetry and deadline/yield coverage, documents configuration and runtime behavior, updates observability navigation, and records package version changes.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant RuntimeDriver
  participant RunStore
  participant WorkflowEngine
  participant WorkflowTelemetry
  participant TimerStore
  RuntimeDriver->>WorkflowTelemetry: start runtime or sweep span
  RuntimeDriver->>RunStore: claim and load workflow state
  RuntimeDriver->>WorkflowEngine: drive workflow with deadline
  WorkflowEngine->>WorkflowTelemetry: record step spans and attempt events
  WorkflowEngine->>TimerStore: schedule durable yield continuation
  RuntimeDriver->>RunStore: synchronize timers and release lease
Loading

Possibly related PRs

  • TanStack/workflow#9: Both changes modify workflow engine runtime context and reserved-field handling.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the change well, but it omits the required checklist and release impact template sections. Rename the first section to Changes and add the required Checklist and Release Impact sections with the requested checkboxes.
Docstring Coverage ⚠️ Warning Docstring coverage is 2.38% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main addition of runtime deadlines and observability.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch taren/runtime-deadlines-observability

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

2 package(s) bumped directly, 6 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/workflow-core 0.0.3 → 0.0.4 Changeset
@tanstack/workflow-runtime 0.0.2 → 0.0.3 Changeset
@tanstack/workflow-cloudflare 0.0.2 → 0.0.3 Dependent
@tanstack/workflow-netlify 0.0.3 → 0.0.4 Dependent
@tanstack/workflow-railway 0.0.2 → 0.0.3 Dependent
@tanstack/workflow-store-cloudflare-d1 0.0.3 → 0.0.4 Dependent
@tanstack/workflow-store-drizzle-postgres 0.0.4 → 0.0.5 Dependent
@tanstack/workflow-vercel 0.0.3 → 0.0.4 Dependent

@pkg-pr-new

pkg-pr-new Bot commented Jul 21, 2026

Copy link
Copy Markdown
More templates

@tanstack/react-template

npm i https://pkg.pr.new/TanStack/workflow/@tanstack/react-template@13

@tanstack/react-template-devtools

npm i https://pkg.pr.new/TanStack/workflow/@tanstack/react-template-devtools@13

@tanstack/solid-template

npm i https://pkg.pr.new/TanStack/workflow/@tanstack/solid-template@13

@tanstack/solid-template-devtools

npm i https://pkg.pr.new/TanStack/workflow/@tanstack/solid-template-devtools@13

@tanstack/template

npm i https://pkg.pr.new/TanStack/workflow/@tanstack/template@13

@tanstack/template-devtools

npm i https://pkg.pr.new/TanStack/workflow/@tanstack/template-devtools@13

@tanstack/workflow-cloudflare

npm i https://pkg.pr.new/TanStack/workflow/@tanstack/workflow-cloudflare@13

@tanstack/workflow-core

npm i https://pkg.pr.new/TanStack/workflow/@tanstack/workflow-core@13

@tanstack/workflow-netlify

npm i https://pkg.pr.new/TanStack/workflow/@tanstack/workflow-netlify@13

@tanstack/workflow-railway

npm i https://pkg.pr.new/TanStack/workflow/@tanstack/workflow-railway@13

@tanstack/workflow-runtime

npm i https://pkg.pr.new/TanStack/workflow/@tanstack/workflow-runtime@13

@tanstack/workflow-store-cloudflare-d1

npm i https://pkg.pr.new/TanStack/workflow/@tanstack/workflow-store-cloudflare-d1@13

@tanstack/workflow-store-drizzle-postgres

npm i https://pkg.pr.new/TanStack/workflow/@tanstack/workflow-store-drizzle-postgres@13

@tanstack/workflow-vercel

npm i https://pkg.pr.new/TanStack/workflow/@tanstack/workflow-vercel@13

commit: 70ced3c

@socket-security

socket-security Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​opentelemetry/​api@​1.9.110010010086100

View full report

@tannerlinsley
tannerlinsley marked this pull request as ready for review July 21, 2026 05:40
@tannerlinsley
tannerlinsley requested a review from a team as a code owner July 21, 2026 05:40

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/workflow-core/package.json (1)

58-58: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Move @opentelemetry/api to peerDependencies. These published libraries should not ship their own copy of the OpenTelemetry API; keep it in peerDependencies (and devDependencies for local builds/tests) in both package manifests so the host app’s tracer provider stays visible.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/workflow-core/package.json` at line 58, Move `@opentelemetry/api` from
dependencies to both peerDependencies and devDependencies in
packages/workflow-core/package.json and packages/workflow-runtime/package.json,
preserving the existing version range so local builds/tests can resolve it while
published packages reuse the host application’s API instance.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/workflow-core/src/telemetry.ts`:
- Around line 175-179: Update startActiveSpan to always pass
trace.wrapSpanContext(INVALID_SPAN_CONTEXT) to the callback when telemetry is
disabled, instead of falling back to trace.getActiveSpan(). Preserve the
existing async callback execution and return behavior.

---

Nitpick comments:
In `@packages/workflow-core/package.json`:
- Line 58: Move `@opentelemetry/api` from dependencies to both peerDependencies
and devDependencies in packages/workflow-core/package.json and
packages/workflow-runtime/package.json, preserving the existing version range so
local builds/tests can resolve it while published packages reuse the host
application’s API instance.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 84578070-b222-4200-aa41-89968015bfa9

📥 Commits

Reviewing files that changed from the base of the PR and between 602cdec and bdd7f68.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (27)
  • .changeset/calm-clocks-yield.md
  • .changeset/metal-shoes-observe.md
  • docs/api/runtime.md
  • docs/concepts/primitives.md
  • docs/config.json
  • docs/cookbook/index.md
  • docs/guide/index.md
  • docs/guide/observability.md
  • packages/workflow-cloudflare/package.json
  • packages/workflow-core/package.json
  • packages/workflow-core/src/engine/run-workflow.ts
  • packages/workflow-core/src/index.ts
  • packages/workflow-core/src/telemetry.ts
  • packages/workflow-core/src/types.ts
  • packages/workflow-core/tests/telemetry.test.ts
  • packages/workflow-netlify/package.json
  • packages/workflow-railway/package.json
  • packages/workflow-runtime/package.json
  • packages/workflow-runtime/src/index.ts
  • packages/workflow-runtime/src/run-store-adapter.ts
  • packages/workflow-runtime/src/runtime-driver.ts
  • packages/workflow-runtime/src/types.ts
  • packages/workflow-runtime/tests/runtime-driver.test.ts
  • packages/workflow-runtime/tests/telemetry.test.ts
  • packages/workflow-store-cloudflare-d1/package.json
  • packages/workflow-store-drizzle-postgres/package.json
  • packages/workflow-vercel/package.json

Comment thread packages/workflow-core/src/telemetry.ts
@tannerlinsley
tannerlinsley merged commit 87340c8 into main Jul 21, 2026
9 of 10 checks passed
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