Fix 12 documentation accuracy issues across API reference, foundations, and AI docs#1200
Fix 12 documentation accuracy issues across API reference, foundations, and AI docs#1200johnlindquist wants to merge 5 commits into
Conversation
Update docs examples that referenced outdated or incorrect APIs. This fixes cancellation usage in get-world, stream import path and run return access in streaming, clarifies stream wording in starting-workflows, and removes fetch from Node.js core module examples. Verified: node -e '...docs snippet verification passed' (requested old/new snippets checked in 4 files) How to test: run the same node assertion command from repo root to confirm snippets. Swarm-Agent: codex-core-docs
Correct World interface docs to include close() and getEncryptionKeyForRun() overloads, and clarify their runtime behavior. Update Streamer runId types to string, add writeToStreamMulti(), and document it as an optional batching optimization. Also fix package references from @workflow-worlds/postgres to @workflow/world-postgres. Verified: pnpm biome check docs/content/docs/deploying/building-a-world.mdx docs/content/docs/deploying/index.mdx (fails because Biome config ignores *.mdx paths) Verified: node <<'NODE' ... scoped assertions on docs/content/docs/deploying/building-a-world.mdx and docs/content/docs/deploying/index.mdx (pass) Swarm-Agent: codex-world-interface
Align code examples across AI docs by renaming the tools export, fixing import snippets, restoring a missing logical OR, adding missing RetryableError import context, and repairing a broken highlight annotation.
Verified: git diff --check -- docs/content/docs/ai/index.mdx docs/content/docs/ai/sleep-and-delays.mdx docs/content/docs/ai/resumable-streams.mdx
Verified: set -euo pipefail; rg -n "export const flightBookingTools = \\{" docs/content/docs/ai/index.mdx; rg -n "import \\{ flightBookingTools \\} from \"@/ai/tools\";" docs/content/docs/ai/index.mdx; rg -n "import \\{ sleep \\} from \"workflow\";" docs/content/docs/ai/sleep-and-delays.mdx; rg -n "tool-checkBaggageAllowance\" \\|\\|" docs/content/docs/ai/sleep-and-delays.mdx; rg -n "part.type === \"tool-sleep\"" docs/content/docs/ai/sleep-and-delays.mdx; rg -n "import \\{ RetryableError \\} from \"workflow\";" docs/content/docs/ai/sleep-and-delays.mdx; rg -n "headers: \\{ // \\[!code highlight\\]" docs/content/docs/ai/resumable-streams.mdx
Swarm-Agent: codex-ai-docs
Update three docs files to fix a malformed code-highlight annotation,\nclarify Astro directory wording, and correct npx behavior wording.\n\nVerified: set -e; rg assertions for old/new strings in all 3 files (pass)\nVerified: git diff --check -- docs/content/docs/errors/start-invalid-workflow-function.mdx docs/content/docs/getting-started/astro.mdx docs/content/docs/observability/index.mdx (pass)\nVerified: npx -y prettier@3 --check docs/content/docs/errors/start-invalid-workflow-function.mdx docs/content/docs/getting-started/astro.mdx docs/content/docs/observability/index.mdx (fails: pre-existing formatting style mismatch in docs)\nSwarm-Agent: codex-misc-fixes
📊 Benchmark Results
workflow with no steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) | Express workflow with 1 step💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) | Express workflow with 10 sequential steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Express | Next.js (Turbopack) workflow with 25 sequential steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Express | Nitro workflow with 50 sequential steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express | Nitro | Next.js (Turbopack) Promise.all with 10 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express | Nitro | Next.js (Turbopack) Promise.all with 25 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) | Express Promise.all with 50 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Express | Next.js (Turbopack) Promise.race with 10 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Next.js (Turbopack) | Express | Nitro Promise.race with 25 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) | Express Promise.race with 50 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) | Express Stream Benchmarks (includes TTFB metrics)workflow with stream💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express | Next.js (Turbopack) | Nitro SummaryFastest Framework by WorldWinner determined by most benchmark wins
Fastest World by FrameworkWinner determined by most benchmark wins
Column Definitions
Worlds:
|
|
🧪 E2E Test Results❌ Some tests failed Summary
❌ Failed Tests🐘 Local Postgres (1 failed)astro-stable (1 failed):
🌍 Community Worlds (45 failed)turso (45 failed):
Details by Category✅ ▲ Vercel Production
✅ 💻 Local Development
✅ 📦 Local Production
❌ 🐘 Local Postgres
✅ 🪟 Windows
❌ 🌍 Community Worlds
✅ 📋 Other
❌ Some E2E test jobs failed:
Check the workflow run for details. |
The first overload of events.create() accepts string | null, not just null. Clients can provide their own runId for run_created events.
|
|
||
| ```typescript lineNumbers | ||
| import { getWorld } from "workflow/runtime"; | ||
| import { getWorld, cancelRun } from "@workflow/core/runtime"; |
There was a problem hiding this comment.
nah the correct way to programmatically cancel a run is await getRun(runId).cancel() - not cancelRun from world. We don't adequately document it though so good call on making this. We should include an example in getRun api reference for cancelling a run so that it's searchable by AI. right now it's not well documented
Also users should almost never be importing from @workflow/core for normal usage. workflow/api should be what people use for normal behavior. using getWorld is an advanced/low level features that will break often as we change things around and not meant to be relied on
There was a problem hiding this comment.
using getWorld is an advanced/low level features that will break often as we change things around and not meant to be relied on
At least once we actually have a different way of querying the same data, which we won't for a while? In which case it wouldn't hurt to document. Users could already be relying on it
There was a problem hiding this comment.
I don't think we should document it and then have to support it
There was a problem hiding this comment.
also like I said, for now the fix is simple. we have run.cancel(). let's document that instead of telling people to use @workflow/core/runtime which is never meant to be user facing
we shouldn't document and recommend cancelRun from @workflow/core/runtime. it should be run.cancel
pranaygp
left a comment
There was a problem hiding this comment.
Good docs audit overall — most fixes here are correct and helpful. The interface updates, typo fixes, run.returnValue, import path corrections, and flightBookingTools rename are all verified against the source.
The main blocker is the cancelRun change (already discussed in the thread) — it needs to use the public API instead of an internal module.
|
|
||
| ```typescript lineNumbers | ||
| import { getWorld } from "workflow/runtime"; | ||
| import { getWorld, cancelRun } from "@workflow/core/runtime"; |
There was a problem hiding this comment.
As pranaygp noted in the earlier thread, this should use the public API:
import { getRun } from "workflow/runtime";
export async function POST(req: Request) {
const { runId } = await req.json();
// ...
const run = getRun(runId);
await run.cancel();
return Response.json({ status: "cancelled" });
}cancelRun from @workflow/core/runtime is an internal function — users should never import from @workflow/core directly. getRun(runId).cancel() is the supported public API for this (exported from workflow/runtime).
| events: { | ||
| // Create a new workflow run (runId must be null - server generates it) | ||
| create(runId: null, data: RunCreatedEventRequest, params?: CreateEventParams): Promise<EventResult>; | ||
| // Create a new workflow run (runId may be client-provided or null for server generation) |
There was a problem hiding this comment.
Nit: The source code doc comment (interfaces.ts:130) says: "The runId may be provided by the client or left as null for the server to generate." Consider matching this wording exactly for consistency between source and docs.
| @@ -34,10 +34,13 @@ A World connects workflows to the infrastructure that powers them. The World int | |||
| ```typescript | |||
| interface World extends Storage, Queue, Streamer { | |||
| start?(): Promise<void>; | |||
There was a problem hiding this comment.
Verified: the close?() and getEncryptionKeyForRun?() additions match the actual World interface in packages/world/src/interfaces.ts exactly. 👍
Cherry-picked 6 still-needed fixes from #1200 that aren't covered by this audit PR or #1516: - Fix npx workflow description (observability) - Remove fetch from restricted modules list (errors) - Fix package name @workflow-worlds/postgres → @workflow/world-postgres (deploying) - Fix stream wording (foundations/starting-workflows) - Fix import path simple → simple-streaming (foundations/streaming) - Add close(), getEncryptionKeyForRun(), writeToStreamMulti() to World interface, update create() and streamer signatures (deploying/building-a-world)
|
Closing — fixes have been dispositioned:
No content lost. |
Cherry-picked 6 still-needed fixes from #1200 that aren't covered by this audit PR or #1516: - Fix npx workflow description (observability) - Remove fetch from restricted modules list (errors) - Fix package name @workflow-worlds/postgres → @workflow/world-postgres (deploying) - Fix stream wording (foundations/starting-workflows) - Fix import path simple → simple-streaming (foundations/streaming) - Add close(), getEncryptionKeyForRun(), writeToStreamMulti() to World interface, update create() and streamer signatures (deploying/building-a-world)
Cherry-picked 6 still-needed fixes from #1200 that aren't covered by this audit PR or #1516: - Fix npx workflow description (observability) - Remove fetch from restricted modules list (errors) - Fix package name @workflow-worlds/postgres → @workflow/world-postgres (deploying) - Fix stream wording (foundations/starting-workflows) - Fix import path simple → simple-streaming (foundations/streaming) - Add close(), getEncryptionKeyForRun(), writeToStreamMulti() to World interface, update create() and streamer signatures (deploying/building-a-world)
* docs: clarify Next monorepo setup Prevent confusion when Next.js apps live below the repository root and workflow code imports sibling workspace packages. This documents the output tracing root requirement at the point where users configure withWorkflow, so monorepo setups follow the same working patterns as the shipped Next.js integration instead of failing due to unresolved workspace imports. Ploop-Iter: 1 * ploop: iteration 2 checkpoint Automated checkpoint commit. Ploop-Iter: 2 * ploop: iteration 3 checkpoint Automated checkpoint commit. Ploop-Iter: 3 * docs: audit recent documentation coverage Capture recent workflow documentation updates so the public docs and package guidance stay aligned with the implementation and current docs-typecheck behavior. Ploop-Iter: 1 * docs: align docs-typecheck docs Document the current docs verification contract so contributors do not assume JavaScript examples are type-checked when only TypeScript snippets are enforced today. Add regression coverage around the README language and framework integration guidance to keep those docs aligned with the implemented Next.js and docs-typecheck behavior as future changes land. Ploop-Iter: 2 * docs: add start() troubleshooting guidance Document the most common causes of the invalid workflow function error so users can resolve start() failures from the API docs and Next.js setup flow without having to infer build-time requirements from runtime behavior. Keep the new troubleshooting page aligned with the shipped runtime message and add regression coverage so future wording or cross-link changes do not silently break that guidance. Ploop-Iter: 3 * docs: align NestJS setup docs Document both supported NestJS module formats and add a regression check so the getting-started guide stays aligned with the package README as the integration evolves. Ploop-Iter: 1 * docs: tighten NestJS CommonJS guidance Keep the NestJS getting-started guide consistent across the ESM and CommonJS paths so readers do not mix module settings or import styles mid-setup. Strengthen the docs regression coverage around the later guide sections so future edits are more likely to preserve the supported CommonJS path documented in the package README. Ploop-Iter: 2 * docs: align docs with recent workflow guidance Document the recently added troubleshooting and observability patterns so the public docs stay aligned with the behavior users now encounter in practice. This keeps the NestJS guide, workflow API reference, and docs regression coverage in sync with the runtime-facing guidance from recent changes. Ploop-Iter: 3 * docs: audit docs coverage Why: keep the docs aligned with recent API and runtime behavior changes so examples and reference pages don’t drift from the supported surface. Ploop-Iter: 1 * test: add docs audit guards Add regression coverage for doc surfaces that are easy to drift from implementation so docs audits catch mismatches early and keep published guidance aligned with the supported API surface. Ploop-Iter: 2 * docs: add docs audit guards Keep new observability and server-testing guidance anchored to machine-readable interfaces so follow-up implementation changes do not silently drift away from the documented agent and automation patterns. Ploop-Iter: 3 * docs: align observability troubleshooting guidance Keep the docs consistent so users get the same guidance when debugging hook token collisions and correlating workflow events with platform logs. This prevents the event-sourcing reference from drifting away from the observability and error docs, and adds guard tests to catch regressions. Ploop-Iter: 1 * Remove the unreferenced image file img-a-clean-minimal-technical-architecture-d-2026-02-27T14-07-52-1.png from the repo root, workbench/fastify/public/index.html (a Nitro example mistakenly placed in the fastify workbench by a ploop checkpoint), all .claude/worktrees/* submodule references, and all 15 string-presence audit guard tests in packages/docs-typecheck/src/__tests__/ (they only assert keyword presence, not semantic correctness). None of these belong in the docs audit PR. * Address all PR #1466 review feedback from VaguelySerious, pranaygp, and ijjk: 1. Remove the "Machine-Readable Surfaces" section from docs/content/docs/observability/index.mdx (reviewers say it's unnecessary and already in world docs) 2. Remove all @skip-typecheck annotations from durable-agent.mdx (8) and server-based.mdx (1) — types exist in built packages/ai/dist after pnpm build 3. In durable-agent.mdx, change "machine-readable tool activity" to "tool call details" in the stream() return description 4. In durable-agent.mdx "Aborting Long-Running Streams" section, add a warning callout that abortSignal is not yet supported (blocked by #1301), recommend timeout instead 5. In event-sourcing.mdx, update requestId description: "On Vercel, requestId is the platform request ID when available. Other worlds are not expected to provide a requestId." 6. In get-world.mdx, change "user-friendly names from the machine-readable workflowName field" to "human-readable names from the workflowName field" 7. In start-invalid-workflow-function.mdx, add "// Does NOT work" comment above the bad example line 8. In with-workflow.mdx: reframe outputFileTracingRoot as a workaround (Next.js auto-detects by default per ijjk); change options description from "control local development behavior" to "configure the Next.js integration"; scope the callout to "workflows.local options only affect local development" 9. Drop the withWorkflow() options callout from docs/content/docs/getting-started/next.mdx 10. Remove the Next.js-specific outputFileTracingRoot callout from framework-integrations.mdx 11. Add a Troubleshooting section with the start() invalid-workflow-function error to all 9 non-Next getting-started guides (astro, express, fastify, hono, nestjs, nitro, nuxt, sveltekit, vite), each with framework-appropriate config check in point 2 * docs: absorb unique accuracy fixes from PR #1200 Cherry-picked 6 still-needed fixes from #1200 that aren't covered by this audit PR or #1516: - Fix npx workflow description (observability) - Remove fetch from restricted modules list (errors) - Fix package name @workflow-worlds/postgres → @workflow/world-postgres (deploying) - Fix stream wording (foundations/starting-workflows) - Fix import path simple → simple-streaming (foundations/streaming) - Add close(), getEncryptionKeyForRun(), writeToStreamMulti() to World interface, update create() and streamer signatures (deploying/building-a-world) * docs: address review feedback on March docs audit - durable-agent.mdx: "structured tool activity" → "tool call information" per VaguelySerious's suggestion - next.mdx: drop monorepo callout from getting-started per pranaygp (too much context too early; info is in withWorkflow API ref) * docs: fix 2 typecheck failures in encryption and nestjs guides - encryption.mdx: add skip-typecheck for interface signature block (getEncryptionKeyForRun overloads are not runnable code) - nestjs.mdx: add skip-typecheck for WorkflowModule.forRoot config snippet (fragment inside callout, full import shown above) Verified: pnpm vitest run passes 300/300 in docs-typecheck.
* docs: clarify Next monorepo setup Prevent confusion when Next.js apps live below the repository root and workflow code imports sibling workspace packages. This documents the output tracing root requirement at the point where users configure withWorkflow, so monorepo setups follow the same working patterns as the shipped Next.js integration instead of failing due to unresolved workspace imports. Ploop-Iter: 1 * ploop: iteration 2 checkpoint Automated checkpoint commit. Ploop-Iter: 2 * ploop: iteration 3 checkpoint Automated checkpoint commit. Ploop-Iter: 3 * docs: audit recent documentation coverage Capture recent workflow documentation updates so the public docs and package guidance stay aligned with the implementation and current docs-typecheck behavior. Ploop-Iter: 1 * docs: align docs-typecheck docs Document the current docs verification contract so contributors do not assume JavaScript examples are type-checked when only TypeScript snippets are enforced today. Add regression coverage around the README language and framework integration guidance to keep those docs aligned with the implemented Next.js and docs-typecheck behavior as future changes land. Ploop-Iter: 2 * docs: add start() troubleshooting guidance Document the most common causes of the invalid workflow function error so users can resolve start() failures from the API docs and Next.js setup flow without having to infer build-time requirements from runtime behavior. Keep the new troubleshooting page aligned with the shipped runtime message and add regression coverage so future wording or cross-link changes do not silently break that guidance. Ploop-Iter: 3 * docs: align NestJS setup docs Document both supported NestJS module formats and add a regression check so the getting-started guide stays aligned with the package README as the integration evolves. Ploop-Iter: 1 * docs: tighten NestJS CommonJS guidance Keep the NestJS getting-started guide consistent across the ESM and CommonJS paths so readers do not mix module settings or import styles mid-setup. Strengthen the docs regression coverage around the later guide sections so future edits are more likely to preserve the supported CommonJS path documented in the package README. Ploop-Iter: 2 * docs: align docs with recent workflow guidance Document the recently added troubleshooting and observability patterns so the public docs stay aligned with the behavior users now encounter in practice. This keeps the NestJS guide, workflow API reference, and docs regression coverage in sync with the runtime-facing guidance from recent changes. Ploop-Iter: 3 * docs: audit docs coverage Why: keep the docs aligned with recent API and runtime behavior changes so examples and reference pages don’t drift from the supported surface. Ploop-Iter: 1 * test: add docs audit guards Add regression coverage for doc surfaces that are easy to drift from implementation so docs audits catch mismatches early and keep published guidance aligned with the supported API surface. Ploop-Iter: 2 * docs: add docs audit guards Keep new observability and server-testing guidance anchored to machine-readable interfaces so follow-up implementation changes do not silently drift away from the documented agent and automation patterns. Ploop-Iter: 3 * docs: align observability troubleshooting guidance Keep the docs consistent so users get the same guidance when debugging hook token collisions and correlating workflow events with platform logs. This prevents the event-sourcing reference from drifting away from the observability and error docs, and adds guard tests to catch regressions. Ploop-Iter: 1 * Remove the unreferenced image file img-a-clean-minimal-technical-architecture-d-2026-02-27T14-07-52-1.png from the repo root, workbench/fastify/public/index.html (a Nitro example mistakenly placed in the fastify workbench by a ploop checkpoint), all .claude/worktrees/* submodule references, and all 15 string-presence audit guard tests in packages/docs-typecheck/src/__tests__/ (they only assert keyword presence, not semantic correctness). None of these belong in the docs audit PR. * Address all PR #1466 review feedback from VaguelySerious, pranaygp, and ijjk: 1. Remove the "Machine-Readable Surfaces" section from docs/content/docs/observability/index.mdx (reviewers say it's unnecessary and already in world docs) 2. Remove all @skip-typecheck annotations from durable-agent.mdx (8) and server-based.mdx (1) — types exist in built packages/ai/dist after pnpm build 3. In durable-agent.mdx, change "machine-readable tool activity" to "tool call details" in the stream() return description 4. In durable-agent.mdx "Aborting Long-Running Streams" section, add a warning callout that abortSignal is not yet supported (blocked by #1301), recommend timeout instead 5. In event-sourcing.mdx, update requestId description: "On Vercel, requestId is the platform request ID when available. Other worlds are not expected to provide a requestId." 6. In get-world.mdx, change "user-friendly names from the machine-readable workflowName field" to "human-readable names from the workflowName field" 7. In start-invalid-workflow-function.mdx, add "// Does NOT work" comment above the bad example line 8. In with-workflow.mdx: reframe outputFileTracingRoot as a workaround (Next.js auto-detects by default per ijjk); change options description from "control local development behavior" to "configure the Next.js integration"; scope the callout to "workflows.local options only affect local development" 9. Drop the withWorkflow() options callout from docs/content/docs/getting-started/next.mdx 10. Remove the Next.js-specific outputFileTracingRoot callout from framework-integrations.mdx 11. Add a Troubleshooting section with the start() invalid-workflow-function error to all 9 non-Next getting-started guides (astro, express, fastify, hono, nestjs, nitro, nuxt, sveltekit, vite), each with framework-appropriate config check in point 2 * docs: absorb unique accuracy fixes from PR #1200 Cherry-picked 6 still-needed fixes from #1200 that aren't covered by this audit PR or #1516: - Fix npx workflow description (observability) - Remove fetch from restricted modules list (errors) - Fix package name @workflow-worlds/postgres → @workflow/world-postgres (deploying) - Fix stream wording (foundations/starting-workflows) - Fix import path simple → simple-streaming (foundations/streaming) - Add close(), getEncryptionKeyForRun(), writeToStreamMulti() to World interface, update create() and streamer signatures (deploying/building-a-world) * docs: address review feedback on March docs audit - durable-agent.mdx: "structured tool activity" → "tool call information" per VaguelySerious's suggestion - next.mdx: drop monorepo callout from getting-started per pranaygp (too much context too early; info is in withWorkflow API ref) * docs: fix 2 typecheck failures in encryption and nestjs guides - encryption.mdx: add skip-typecheck for interface signature block (getEncryptionKeyForRun overloads are not runnable code) - nestjs.mdx: add skip-typecheck for WorkflowModule.forRoot config snippet (fragment inside callout, full import shown above) Verified: pnpm vitest run passes 300/300 in docs-typecheck.
Summary
Fixes validated documentation issues found during a comprehensive docs audit:
world.runs.cancel()ingetWorldexamples — replaced withcancelRun()from@workflow/core/runtimesimplevssimple-streaming) and replace nonexistentrun.result()withrun.returnValueclose?()andgetEncryptionKeyForRun?()to World, fixrunIdtype fromstring | Promise<string>tostringin Streamer, add missingwriteToStreamMulti?method@workflow-worlds/postgres→@workflow/world-postgres)toolsvsflightBookingTools), remove unusedgetWritableimport, fix missing||operator, add missingRetryableErrorimport, fix broken highlight annotation[!code highlight}typo, correct "Vite root directory" → "Astro project root directory", fix inaccuratenpx"install globally" claim, removefetchfrom Node.js core modules listTest plan
workflowexportsgetWorldcancel example uses correctcancelRunAPIpackages/world/src/interfaces.ts