Skip to content

feat(workflow-world): dual-engine workflows — Vercel SDK 'world' (Postgres/MongoDB) behind WorkflowKit#112

Merged
Killian-Aidalinfo merged 21 commits into
mainfrom
feat/workflow-world-engine
Jun 2, 2026
Merged

feat(workflow-world): dual-engine workflows — Vercel SDK 'world' (Postgres/MongoDB) behind WorkflowKit#112
Killian-Aidalinfo merged 21 commits into
mainfrom
feat/workflow-world-engine

Conversation

@Killian-Aidalinfo

Copy link
Copy Markdown
Collaborator

Résumé

Ajoute un second moteur de workflow à ai-kit : le moteur "world" (Vercel Workflow SDK, persistance durable Postgres/MongoDB) à côté du moteur legacy en mémoire, exposé via une façade unifiée WorkflowKit (défaut : legacy).

import { WorkflowKit } from '@ai_kit/core';

const kit = new WorkflowKit({ engine: 'world', world: { type: 'postgres', url } });
await kit.start();
const handle = await kit.run(myWorldWorkflow, [arg]);
await kit.stop();

Contenu

  • @ai_kit/core — façade WorkflowKit (engine legacy|world, start/stop/run, validation), contrat d'adapter, exports publics. Lazy-load du package world via specifier variable + seam de test → aucune dépendance dure sur le SDK Vercel.
  • @ai_kit/workflow-world (nouveau package optionnel) — createWorldAdapter (injection programmatique : createWorld + setWorld + start(fn,args,{world})), mapping worlds.ts, helpers de typage WorldStep/WorldWorkflow, README, docker-compose de test.

Décisions clés

  • Injection programmatique (pas de variables d'env) → supprime le gotcha d'ordre des env.
  • Spike "directive-in-arrow" → verdict type-only : le compilo Vercel n'instrumente pas les arrows passées à un wrapper, donc pas de defineWorldStep runtime ; on fournit les types WorldStep/WorldWorkflow et l'utilisateur écrit une liaison top-level avec la directive "use step" / "use workflow".
  • Contrat dupliqué localement dans le package world (au lieu d'importer de core) → casse un cycle de build pnpm ; types structurellement identiques.
  • Backends world en peerDependencies optionnelles → "pay-for-what-you-use".
  • Provisioning Postgres requis avant 1er run (npx workflow-postgres-setup) — documenté.

Vérification

  • Tests unitaires @ai_kit/workflow-world : 15 passed (+2 intégration skip par défaut)
  • Tests @ai_kit/core (kit + workflows) : 36 passed — sans régression
  • Tests @ai_kit/server (gated CI) : 19 passed
  • Builds workflow-world / core / server : verts
  • Intégration réelle (Docker) : Postgres ✅ et MongoDB ✅ (lifecycle start/stop validé end-to-end)

Docs

  • Design : docs/superpowers/specs/2026-06-02-workflow-world-engine-design.md
  • Plan d'implémentation : docs/superpowers/plans/2026-06-02-workflow-world-engine.md
  • Notes SDK + spike : docs/superpowers/notes/2026-06-02-vercel-sdk-signatures.md

Notes

  • Le moteur legacy est inchangé ; aucun utilisateur legacy ne tire les dépendances Vercel.
  • Le SDK Vercel impose une étape de build (Nitro) + un worker long-vivant côté app hôte (documenté dans le spec §5).

🤖 Generated with Claude Code

Killian-Aidalinfo and others added 21 commits June 2, 2026 17:37
Spec: dual-engine workflows (legacy in-memory + Vercel SDK 'world' backed
by self-hosted Postgres/MongoDB) behind a thin WorkflowKit facade.
Plan: TDD, optional @ai_kit/workflow-world package, blocking spike on
directive-in-arrow detection, mocked unit tests + opt-in docker-compose
integration tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…pping

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ction

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…rld backends

Addresses code review: stop() releases injection before close, run() guards
uninitialized world, world backends moved to optional peerDependencies, minor
cleanups (loaders lookup, jobPrefix guard).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…kflow)

Per spike verdict 2: directives are only detected on top-level bindings, so no
runtime defineWorldStep wrapper is shipped; types document the required form.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…TS, types)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Define the WorldConfig/WorldEngineAdapter/WorldRunHandle contract locally in
workflow-world (src/contract.ts) instead of importing from @ai_kit/core. A
peerDependency does not guarantee build order under pnpm, so the install-time
prepare build of workflow-world failed to resolve @ai_kit/core's freshly-cleaned
dist. workflow-world is consumed BY core (dynamically), never the reverse, so it
needs no dependency on core. Also drop the core->workflow-world devDependency
(it created a dev/peer cycle); core keeps workflow-world as an optional peer.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…acy+world)

Lazy-loads the optional @ai_kit/workflow-world via a variable-specifier import
behind a test seam, so core has no hard dependency on it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds docker-compose.test.yml (postgres:16 + mongo:7 with healthchecks) and
db:up/db:down/test:integration scripts for opt-in integration tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Skipped by default; run via 'pnpm run db:up && pnpm run test:integration'.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… document it

The postgres world requires a one-time schema setup ('workflow-postgres-setup')
before use; the integration test now runs it as a subprocess (the CLI calls
process.exit, so it can't run in-process under vitest). Validated end-to-end
against real postgres:16 and mongo:7. README documents the provisioning step.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…it (EN+FR)

Adds a 'World engine (durable workflows)' guide and a WorkflowKit API-reference
page in both English and French, registered in docs.json. The English pages are
sourced by @ai_kit/mcp-docs, so the MCP docs server serves them to AI tools too.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… workflow-world publish CI

- @ai_kit/core 1.3.1 -> 1.4.0 (new WorkflowKit facade / world engine)
- @ai_kit/mcp-docs 1.0.6 -> 1.0.7 (rebundles the new world-engine docs)
- @ai_kit/workflow-world stays 0.1.0 (initial release)
- add .github/workflows/release-workflow-world.yml (mirrors release-rag.yml:
  publishes on push to main touching packages/workflow-world/package.json)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Killian-Aidalinfo
Killian-Aidalinfo changed the base branch from dev to main June 2, 2026 17:54
@Killian-Aidalinfo
Killian-Aidalinfo merged commit 2d1ccbe into main Jun 2, 2026
2 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