Skip to content

feat(dbos): pin the workflow application version to stop deploy-induced stranding - #4143

Merged
tlgimenes merged 9 commits into
mainfrom
feat/pin-dbos-app-version
Jun 25, 2026
Merged

tlgimenes merged 9 commits into
mainfrom
feat/pin-dbos-app-version

Conversation

@tlgimenes

@tlgimenes tlgimenes commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem

DBOS leaves the application version at its SDK default: an MD5 of the source (fn.toString()) of every registered workflow, plus the SDK version. Because the server ships bundled, that hash changes on nearly every deploy. DBOS workflow recovery is version-scoped, so when the hash changes, in-flight workflows of the old version have no executor able to resume them — they strand.

This bit production: a deploy landed mid-run, the long-polling threadGateWorkflow (per-thread concurrency=1, ~1h poll, no workflow_timeout_ms) was stranded PENDING on the old version, permanently holding its thread's partition slot, so every later message on that thread sat ENQUEUED forever ("accepted and queued"). Conductor reported recovery … : ok for the dead executor, but the new-version executors logged No workflows to recover from application version <new> and skipped the old rows. All 11 registered workflows are subject to the same mechanism.

Fix

Pin the application version to a hand-maintained constant (modeled on the existing LINK_PROTOCOL_VERSION apparatus), so compatible deploys stop changing it. Recovery now spans deploys; the version moves only on a deliberate bump.

  1. apps/mesh/src/dbos/workflow-version.ts — DBOS_WORKFLOW_VERSION = "1" with a bump-rule doc: bump only when a registered workflow's durable step sequence changes incompatibly (add/remove/reorder a step, change a step's recorded I/O); do not bump for logic inside a step, non-workflow code, or comments.
  2. apps/mesh/src/dbos/config.ts — a pure, unit-tested buildDbosConfig() that injects applicationVersion: DBOS_WORKFLOW_VERSION, wired into index.ts's DBOS.setConfig(...). The only behavioral change to setConfig is the added field (every other field is byte-identical).
  3. Tripwire comments at all 11 DBOS.registerWorkflow( sites (8 files) pointing to the constant, so an edit in any domain surfaces the bump obligation.
  4. Source-hash guard (workflow-source-guard.ts + .snapshot.json + scripts/update-workflow-source-snapshot.ts) — a unit test that auto-discovers workflow source files and fails when any changes, with a re-baseline-or-bump message. Conservative (file-level, over-triggers safely; never silently misses a standard-form registration).

The version is global across all 11 workflows by design — DBOS has no per-workflow version, and a global pin makes every workflow deploy-stable, not just thread-gate.

Cutover (one-time)

The first deploy carrying applicationVersion="1" strands whatever is in-flight on the previous hash version one last time (expected; no "1" executor existed when they started). Clear leftovers via the DBOS cancel procedure already used for the stranded thread-gates, or leave them for a future reaper. After cutover, the version only changes on a deliberate bump.

Note: under DBOS Cloud (DBOS__CLOUD=true) the SDK ignores applicationVersion and uses its own env-supplied version. This repo self-hosts and sets neither DBOS__CLOUD nor DBOS__APPVERSION, so the pin takes effect (documented in workflow-version.ts).

Testing

  • All unit (TDD): bun test apps/mesh/src/dbos/ → 11 pass. Covers the constant, buildDbosConfig (incl. field parity + listenQueues present/absent), and the guard (pure-comparison fixtures + the real-files snapshot check).
  • Verified the guard actually trips: appending a line to a workflow file fails the guard with the exact remediation message, then reverts clean.
  • fmt/lint clean; check shows only a pre-existing unrelated AJV error in packages/mcp-utils.

Out of scope

A stranded-workflow reaper/reconciler (the "mop up after stranding" complement) and per-workflow versioning (impossible — the version is global).

🤖 Generated with Claude Code


Summary by cubic

Pins the DBOS application version to a manual constant to stop deploys from stranding in‑flight workflows, adds a guard that forces a version decision when workflow sources change, and logs the effective version on boot for easy verification.

  • New Features

    • DBOS_WORKFLOW_VERSION = "1"; bump only when a workflow’s durable step sequence changes.
    • New buildDbosConfig() injects applicationVersion (all other config fields unchanged) and is now used by DBOS.setConfig(...).
    • Tripwire comments at all DBOS.registerWorkflow( call sites to surface the bump obligation.
    • Source-hash guard with snapshot and script (apps/mesh/scripts/update-workflow-source-snapshot.ts) to detect workflow-source drift; unit tests included.
    • Re-baselined workflow-source-guard.snapshot.json after main’s feat(decopilot): split web research into web_search + deep_research #4134 changed step internals in automations/dbos-workflow.ts and harnesses/decopilot/background-tool-workflow.ts; recovery-compatible, so no version bump.
    • After DBOS.launch(), log the effective application version on boot (expect "1"; a 32‑char hash indicates the pin was bypassed via env/Cloud).
    • Cleanup: dropped unused exports flagged by knip; guard internals remain module‑private.
  • Migration

    • First deploy on "1" will leave prior-version runs stranded; cancel via the existing DBOS cancel procedure.
    • Re-baseline on safe edits: bun apps/mesh/scripts/update-workflow-source-snapshot.ts. If step sequence changes, bump the version first, then re-baseline.
    • Note: when DBOS__CLOUD=true, the SDK uses its env version and ignores the pin; for self-hosting here, the pin applies.

Written for commit 78cf05b. Summary will update on new commits.

Review in cubic

@tlgimenes
tlgimenes enabled auto-merge (squash) June 25, 2026 20:28
tlgimenes and others added 3 commits June 25, 2026 17:31
main's #4134 (split web_research into web_search + deep_research) changed
two registered-workflow files — automations/dbos-workflow.ts and
harnesses/decopilot/background-tool-workflow.ts — entirely inside existing
step bodies (no DBOS.runStep added or reordered). Recovery-compatible, so
no DBOS_WORKFLOW_VERSION bump; just re-baseline the source-hash snapshot.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@tlgimenes
tlgimenes merged commit fad1b2b into main Jun 25, 2026
15 checks passed
@tlgimenes
tlgimenes deleted the feat/pin-dbos-app-version branch June 25, 2026 20:49
decocms Bot pushed a commit that referenced this pull request Jun 25, 2026
PR: #4143 feat(dbos): pin the workflow application version to stop deploy-induced stranding
Bump type: minor

- decocms (apps/mesh/package.json): 3.60.1 -> 3.61.0

Deploy-Scope: server
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