@fluidgrids/workflows 2026.1029.1 → 2026.1030.1

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.
Files changed (118) hide show
  1. package/README.md +112 -4
  2. package/dist/{activation-CESehfYi.d.cts → activation-DqUfpHzk.d.cts} +1 -1
  3. package/dist/{activation-BnVQMv9y.d.ts → activation-xpx1oWuo.d.ts} +1 -1
  4. package/dist/{chunk-MJ5TGYVG.js → chunk-2D3MYIIF.js} +969 -153
  5. package/dist/{chunk-2B37XAFQ.cjs → chunk-3U2NU7YC.cjs} +24 -11
  6. package/dist/{chunk-NEIUQASE.cjs → chunk-4QKB4ARC.cjs} +3 -3
  7. package/dist/{chunk-GBQ33SIZ.cjs → chunk-54FLQNUM.cjs} +12 -1
  8. package/dist/{chunk-2DDULZFM.js → chunk-5HIVIV53.js} +86 -75
  9. package/dist/chunk-5MFVJM76.js +1222 -0
  10. package/dist/{chunk-EWYADREB.cjs → chunk-672KMMBK.cjs} +2 -2
  11. package/dist/{chunk-KXJDRQ6G.js → chunk-6A2FGSUS.js} +22 -2
  12. package/dist/{chunk-OIX4O6UR.js → chunk-6OLN6BMB.js} +16 -3
  13. package/dist/{chunk-6FSHT5IL.js → chunk-7EZIANC7.js} +1 -1
  14. package/dist/chunk-A5SXCA62.cjs +93 -0
  15. package/dist/chunk-AC6ZEXVR.js +85 -0
  16. package/dist/{chunk-FWBRQWRX.js → chunk-AE5Q6ZAJ.js} +167 -10
  17. package/dist/{chunk-7ILGCUI6.js → chunk-C4F5KJTI.js} +142 -3
  18. package/dist/{chunk-WXXNCHUY.js → chunk-G5H32GIG.js} +1 -1
  19. package/dist/{chunk-OMY3CKUZ.cjs → chunk-GEQDGUGB.cjs} +1042 -226
  20. package/dist/{chunk-25BKWR2O.js → chunk-HCM7ZC7Q.js} +1 -1
  21. package/dist/{chunk-I47EENR4.cjs → chunk-HMZUGSMU.cjs} +673 -156
  22. package/dist/{chunk-NXFBVDOI.cjs → chunk-IQPXHQQQ.cjs} +8 -4
  23. package/dist/{chunk-RUQIMTN5.cjs → chunk-ISOIA7NV.cjs} +178 -15
  24. package/dist/chunk-JSC75O5C.cjs +167 -0
  25. package/dist/{chunk-BD7ZPG53.js → chunk-NWQ5WRLE.js} +10 -2
  26. package/dist/chunk-ODZ2IAR2.cjs +1247 -0
  27. package/dist/{chunk-FQSJI5NV.js → chunk-SR7TR5KX.js} +6 -2
  28. package/dist/{chunk-OKX3FYIM.cjs → chunk-TCTE7DX5.cjs} +3 -3
  29. package/dist/{chunk-3FIDHONL.cjs → chunk-TYF56RGB.cjs} +99 -80
  30. package/dist/{chunk-J3PYFGKA.cjs → chunk-VA4OFR72.cjs} +162 -4
  31. package/dist/chunk-VU5S5A7V.js +150 -0
  32. package/dist/{chunk-A36CCOWS.js → chunk-YEHR4NNE.js} +633 -128
  33. package/dist/{chunk-ELL2RBML.cjs → chunk-ZCGKGDCL.cjs} +23 -1
  34. package/dist/codegen/index.d.cts +2 -2
  35. package/dist/codegen/index.d.ts +2 -2
  36. package/dist/{collect-BTHjQaSp.d.ts → collect-6NIEufHd.d.ts} +20 -3
  37. package/dist/{collect-CSyOg5XC.d.cts → collect-CcTCKqx6.d.cts} +20 -3
  38. package/dist/{file-cgL9l9l8.d.cts → file-BxYpwjRQ.d.cts} +250 -15
  39. package/dist/{file-olQudcx5.d.ts → file-CFdPQJI9.d.ts} +250 -15
  40. package/dist/history/index.cjs +283 -106
  41. package/dist/history/index.d.cts +549 -10
  42. package/dist/history/index.d.ts +549 -10
  43. package/dist/history/index.js +5 -4
  44. package/dist/index.cjs +146 -53
  45. package/dist/index.d.cts +38 -14
  46. package/dist/index.d.ts +38 -14
  47. package/dist/index.js +6 -5
  48. package/dist/interceptors-CNcr2dlk.d.ts +159 -0
  49. package/dist/interceptors-CqkNZVfI.d.cts +159 -0
  50. package/dist/ir/index.cjs +339 -36
  51. package/dist/ir/index.d.cts +244 -8
  52. package/dist/ir/index.d.ts +244 -8
  53. package/dist/ir/index.js +306 -21
  54. package/dist/{lower-3S6PsqjJ.d.cts → lower-BtRfIW2A.d.cts} +23 -9
  55. package/dist/{lower-DmZpQ8hJ.d.ts → lower-CpsMFOFX.d.ts} +23 -9
  56. package/dist/{manifest-BJjrQt77.d.ts → manifest-D-I_twys.d.ts} +1 -1
  57. package/dist/{manifest-gRI2Q5Fj.d.cts → manifest-DahBQVM8.d.cts} +1 -1
  58. package/dist/node-evaluator-DGQDPSPI.cjs +24 -0
  59. package/dist/node-evaluator-LEEVD7H7.js +14 -0
  60. package/dist/payload-fields-BVRQn2yH.d.cts +122 -0
  61. package/dist/payload-fields-oOBWxDiG.d.ts +122 -0
  62. package/dist/quickjs/index.cjs +27 -27
  63. package/dist/quickjs/index.d.cts +6 -6
  64. package/dist/quickjs/index.d.ts +6 -6
  65. package/dist/quickjs/index.js +9 -9
  66. package/dist/roundtrip/index.cjs +72 -66
  67. package/dist/roundtrip/index.d.cts +25 -11
  68. package/dist/roundtrip/index.d.ts +25 -11
  69. package/dist/roundtrip/index.js +13 -11
  70. package/dist/runtime/index.cjs +19 -19
  71. package/dist/runtime/index.d.cts +139 -12
  72. package/dist/runtime/index.d.ts +139 -12
  73. package/dist/runtime/index.js +6 -6
  74. package/dist/testing/index.cjs +688 -121
  75. package/dist/testing/index.d.cts +174 -10
  76. package/dist/testing/index.d.ts +174 -10
  77. package/dist/testing/index.js +646 -82
  78. package/dist/{types-CnIOinoz.d.ts → types-Bv2i4cBX.d.cts} +126 -23
  79. package/dist/{types-CQKOhPTa.d.cts → types-DGx-b9eq.d.ts} +126 -23
  80. package/dist/{types-Bb2wRnJ5.d.cts → types-V7jEEUaL.d.cts} +1 -1
  81. package/dist/{types-Bb2wRnJ5.d.ts → types-V7jEEUaL.d.ts} +1 -1
  82. package/dist/{workflow-8uRU9rhL.d.ts → workflow-B18OeF7g.d.ts} +2 -2
  83. package/dist/{workflow-DWTPHFbt.d.ts → workflow-BGnv8SS6.d.ts} +261 -14
  84. package/dist/{workflow-CZOXUlQ5.d.cts → workflow-BJPFv3cp.d.cts} +2 -2
  85. package/dist/{workflow-O6e64ZcG.d.cts → workflow-DS32Gtws.d.cts} +261 -14
  86. package/fixtures/histories/activity-options-updated.history.json +159 -0
  87. package/fixtures/histories/activity-paused-unpaused.history.json +160 -0
  88. package/fixtures/histories/codec-opaque.history.json +229 -0
  89. package/fixtures/histories/dynamic-workflow.history.json +150 -0
  90. package/fixtures/histories/interceptor-headers.history.json +339 -0
  91. package/fixtures/histories/query-custom.history.json +213 -0
  92. package/fixtures/histories/query-default-handler.history.json +120 -0
  93. package/fixtures/histories/reset-forked-reapplied-signals.history.json +239 -0
  94. package/fixtures/histories/reset-reapplied-update-admitted.history.json +228 -0
  95. package/fixtures/histories/search-attributes-upserted.history.json +177 -0
  96. package/fixtures/histories/update-accepted-completed.history.json +45 -30
  97. package/fixtures/histories/update-default-handler.history.json +246 -0
  98. package/fixtures/histories/update-handler-awaits-activity.history.json +196 -0
  99. package/fixtures/histories/update-not-handled.history.json +138 -0
  100. package/fixtures/histories/update-rejected-no-event.history.json +190 -0
  101. package/fixtures/histories/update-with-start-admitted.history.json +150 -0
  102. package/fixtures/histories/user-activity-cancel.history.json +149 -0
  103. package/fixtures/histories/user-activity-retry.history.json +143 -0
  104. package/fixtures/histories/user-activity.history.json +149 -0
  105. package/package.json +1 -1
  106. package/schema/bridge-v2.schema.json +1062 -0
  107. package/schema/history-file.schema.json +255 -81
  108. package/schema/ir-v2.schema.json +246 -1
  109. package/schema/payload-fields.json +162 -0
  110. package/schema/run-event.schema.json +239 -80
  111. package/schema/workflow-command.schema.json +210 -84
  112. package/schema/workflow-task.schema.json +532 -167
  113. package/dist/chunk-6QPOJZT6.cjs +0 -1180
  114. package/dist/chunk-A2OHX3UQ.js +0 -1156
  115. package/dist/chunk-PWIUEWC3.js +0 -81
  116. package/dist/chunk-YHBVMOMK.cjs +0 -87
  117. package/dist/node-evaluator-SOADN23V.js +0 -14
  118. package/dist/node-evaluator-YGDEXK4U.cjs +0 -24
package/README.md CHANGED
@@ -226,9 +226,16 @@ export const refundOrder = workflow(
226
226
  `ctx.signalRun` / `ctx.signalParent` / `ctx.getRunHandle`, `ctx.sideEffect`,
227
227
  `ctx.patched` / `ctx.deprecatePatch`, `ctx.now` / `ctx.random` / `ctx.uuid`,
228
228
  `ctx.setCurrentDetails`, cancellation scopes, `ctx.saga()`, and the parity
229
- commands `ctx.upsertContext` and `ctx.continueAsNew`. User activities, user
230
- functions as local activities, custom queries, updates and search attributes
231
- are Phase C and fail the workflow task with `UNSUPPORTED_COMMAND`.
229
+ commands `ctx.upsertContext` and `ctx.continueAsNew`. User functions as
230
+ local activities are not run yet and fail the workflow task with
231
+ `UNSUPPORTED_COMMAND`.
232
+ - Since C-R1 (Phase C, `RUNTIME_RELEASE = 3`; each feature is enabled by the
233
+ service per workspace flag, see "Phase C" below): updates
234
+ (`ctx.handleUpdate(def, fn, { validate })`, `ctx.setDefaultUpdateHandler`),
235
+ custom queries (`ctx.handleQuery`, `ctx.setDefaultQueryHandler`),
236
+ `dynamicWorkflow`, user activities (`declareActivity`, `ctx.activity`),
237
+ `ctx.upsertSearchAttributes`, interceptors (`export const interceptors =
238
+ workflowInterceptors(...)`) with header propagation, and `ctx.sinks`.
232
239
  - Since R2 (the runtime release `RUNTIME_RELEASE = 2`):
233
240
  `ctx.localActivity(op, { args, retry, startToCloseTimeout, summary })` runs a
234
241
  short node call inside the workflow task (at most 30 s; the `ctx.run`
@@ -277,7 +284,8 @@ features)`, `isReliefCommand`, `PHASE_B_CORE_FEATURES`,
277
284
  (`ACTIVITY_NODE_ALLOWLIST`).
278
285
  - An `ApplicationError` (or any failure class, or a class listed in
279
286
  `failureErrorTypes`) fails the run; any other throw, a determinism violation
280
- or a Phase C call fails only the workflow task, which the engine retries.
287
+ or a user local activity fails only the workflow task, which the engine
288
+ retries.
281
289
  - A cancellation scope function receives a `ctx` bound to its scope; use it
282
290
  inside the function. The outer `ctx` joins the scope only while the function
283
291
  runs synchronously (`ctx.nonCancellable(() => ctx.run(...))` works), never
@@ -372,6 +380,106 @@ completed workflow task to exactly the commands it recorded, then does all of
372
380
  it again under `TZ=Asia/Kolkata`; `tests/histories.test.ts` adds the in-process
373
381
  replay. `--write` re-records.
374
382
 
383
+ ### Phase C (C-R1)
384
+
385
+ Every Phase C capability is written into the bundle's `code.features`
386
+ (`userActivity`, `updates`, `queries`, `searchAttributes`, `dynamic`,
387
+ `interceptors`) and into the command gate (`c.userActivity`, `c.updates`,
388
+ `c.searchAttributes`), so the service refuses it until the workspace's flag is
389
+ on (`CODE_FEATURE_FLAGS`, `PHASE_C_FEATURE_FLAGS`): `fluidgrids.run-control`
390
+ for updates, queries, dynamic workflows and interceptors,
391
+ `fluidgrids.search-attributes` for search attributes and
392
+ `fluidgrids.self-hosted-workers` for user activities. A bundle built before
393
+ C-R1 reports no runtime `capabilities` and the service does not deliver it
394
+ updates or custom queries.
395
+
396
+ ```ts
397
+ import { declareActivity, defineQuery, defineUpdate, workflow } from '@fluidgrids/workflows';
398
+
399
+ const charge = declareActivity<{ amount: number }, { id: string }>('billing.charge', {
400
+ taskQueue: 'payments',
401
+ });
402
+ const setAddress = defineUpdate<{ address: string }, { ok: boolean }>('setAddress');
403
+ const status = defineQuery<{ address: string }>('status');
404
+
405
+ export const order = workflow(
406
+ 'order',
407
+ { updates: [setAddress], queries: [status] },
408
+ async (ctx) => {
409
+ let address = '';
410
+ ctx.handleQuery(status, () => ({ address }));
411
+ ctx.handleUpdate(
412
+ setAddress,
413
+ (args) => {
414
+ address = args.address;
415
+ return { ok: true };
416
+ },
417
+ {
418
+ validate: (args) => {
419
+ if (!args.address) throw new Error('empty');
420
+ },
421
+ }
422
+ );
423
+ ctx.upsertSearchAttributes({ stage: 'charging' });
424
+ return ctx.activity(charge, { args: { amount: 10 }, startToCloseTimeout: '30s' });
425
+ }
426
+ );
427
+ ```
428
+
429
+ - Updates (05 §6, 11 §2.39): the lease delivers pending updates to a workflow
430
+ task (`request.updates`); the validator runs read-only and a rejection
431
+ writes nothing to history (`REJECT_UPDATE`); acceptance appends
432
+ `UPDATE_ACCEPTED` with the request and the handler's result or failure
433
+ `UPDATE_COMPLETED`. A replay re-delivers accepted updates after the
434
+ activation's inputs without their validators; `UPDATE_ADMITTED`
435
+ (update-with-start, reset) is delivered as an input and validated. An update
436
+ no handler takes by the end of its activation is rejected with
437
+ `UpdateNotHandled`.
438
+ - Queries run after the replay, read-only: a command, a sink call or a
439
+ side effect in a query handler (or an update validator) throws
440
+ `QueryHandlerSideEffect`. A name without a handler is answered with
441
+ `rejected: true`. Queries may also ride on a workflow task
442
+ (`request.queries`, CX8).
443
+ - `dynamicWorkflow(name, (ctx, workflowFn, input) => ...)` serves every
444
+ function name the bundle does not export (`code.exports.workflows["*"]`).
445
+ - `ctx.activity(declaration | name, options)` issues `SCHEDULE_ACTIVITY` of kind
446
+ `user` on the option's task queue, else the declaration's, else the run's;
447
+ `managed` refuses user activities. `implementActivity`, `defineActivity`
448
+ and `dynamicActivity` are for the worker: `lower()` reports
449
+ `durable.activityImplInBundle` when a workflow module pulls one into the
450
+ bundle. `ActivityPausedError` is what an activity throws after a heartbeat
451
+ reports `paused`.
452
+ - Query handlers and update validators are read-only: commands, sinks,
453
+ `ctx.random()`, `ctx.uuid()`, `Math.random()`, new patches and
454
+ `setCurrentDetails` throw `QueryHandlerSideEffect`, because validators do
455
+ not run again on replay.
456
+ - Interceptors (11 §2.10): a bundle's `interceptors` export runs only in a
457
+ task whose request lists `interceptors` in `features` (the workspace has
458
+ `fluidgrids.run-control` on); otherwise the task fails with
459
+ `UNSUPPORTED_COMMAND`. Inbound `execute`, `handleSignal`, `handleQuery`,
460
+ `validateUpdate`, `handleUpdate`; outbound `scheduleActivity`,
461
+ `scheduleLocalActivity`, `startTimer`, `startChild`, `signalRun`,
462
+ `cancelRun`, `sideEffect`, `continueAsNew`, `upsertSearchAttributes`,
463
+ `upsertContext`, `getLogAttributes`. Headers travel on starts, signals,
464
+ updates, activities, children and continue-as-new.
465
+ - `ctx.sinks.<sink>.<fn>(...args)` calls are returned once in the task result
466
+ (`sinkCalls`, at most 256), never on replay; managed runs ignore them.
467
+ - Contracts: `schema/bridge-v2.schema.json` (worker bridge protocol 2,
468
+ `validateBridgeFrame`) and `schema/payload-fields.json` (`PAYLOAD_FIELDS`,
469
+ the encoded payload form `{"$fgp":1, encoding, metadata, data}` and
470
+ `isEncodedPayload`). Failures nest through `cause`, so they are listed
471
+ apart (`FAILURE_FIELDS`, `COMMAND_FAILURE_FIELDS`): the payload of a failure
472
+ is its `details` at every level of the cause chain. Codecs call
473
+ `mapEventPayloads(type, payload, fn)` and `mapCommandPayloads(command, fn)`,
474
+ which apply both lists. The IR gains `internal:signal-run`,
475
+ `internal:set-search-attributes` and the schedule policy and spec fields
476
+ (`checkSchedulePolicy`; `startAt`, `endAt`, `excludeCalendars` in
477
+ `checkScheduleSpec`).
478
+ - Test environment: `update`, `startWithUpdate`, `query`, `reset`,
479
+ `registerActivity` / `mockActivity` with `completeActivityAsync`, search
480
+ attributes and headers at the start, `interceptors`,
481
+ `activityInterceptors` and `sinks`.
482
+
375
483
  ## Shared fixtures
376
484
 
377
485
  `fixtures/` holds the conformance fixtures shared with the Python SDK: every
@@ -1,4 +1,4 @@
1
- import { Z as RunEventRecord } from './types-CQKOhPTa.cjs';
1
+ import { R as RunEventRecord } from './types-Bv2i4cBX.cjs';
2
2
 
3
3
  /**
4
4
  * Split a history into activations (C-HIST, spec 04 §2).
@@ -1,4 +1,4 @@
1
- import { Z as RunEventRecord } from './types-CnIOinoz.js';
1
+ import { R as RunEventRecord } from './types-DGx-b9eq.js';
2
2
 
3
3
  /**
4
4
  * Split a history into activations (C-HIST, spec 04 §2).