@pikku/core 0.12.133 → 0.12.135

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 (46) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/function/compensation-name.d.ts +4 -0
  3. package/dist/function/compensation-name.js +6 -0
  4. package/dist/function/function-meta.types.d.ts +2 -0
  5. package/dist/function/function-runner.js +17 -0
  6. package/dist/function/functions.types.d.ts +7 -0
  7. package/dist/testing/service-tests/queued-workflow-harness.d.ts +61 -0
  8. package/dist/testing/service-tests/queued-workflow-harness.js +151 -0
  9. package/dist/testing/service-tests/workflow-compensation-queued-tests.d.ts +11 -0
  10. package/dist/testing/service-tests/workflow-compensation-queued-tests.js +683 -0
  11. package/dist/testing/service-tests.d.ts +4 -0
  12. package/dist/testing/service-tests.js +4 -0
  13. package/dist/utils/hmac.d.ts +0 -33
  14. package/dist/utils/hmac.js +0 -61
  15. package/dist/wirings/rpc/rpc-runner.js +21 -1
  16. package/dist/wirings/trigger/webhook-source-runner.js +17 -10
  17. package/dist/wirings/trigger/webhook-source.types.d.ts +4 -3
  18. package/dist/wirings/workflow/dsl/workflow-dsl.types.d.ts +38 -6
  19. package/dist/wirings/workflow/graph/graph-node.d.ts +2 -1
  20. package/dist/wirings/workflow/graph/graph-node.js +2 -1
  21. package/dist/wirings/workflow/graph/graph-runner.d.ts +1 -1
  22. package/dist/wirings/workflow/graph/graph-runner.js +104 -67
  23. package/dist/wirings/workflow/graph/graph-validation.js +2 -2
  24. package/dist/wirings/workflow/graph/workflow-graph.types.d.ts +20 -1
  25. package/dist/wirings/workflow/index.d.ts +1 -1
  26. package/dist/wirings/workflow/pikku-workflow-service.d.ts +13 -0
  27. package/dist/wirings/workflow/pikku-workflow-service.js +113 -143
  28. package/dist/wirings/workflow/run-timeline.d.ts +2 -0
  29. package/dist/wirings/workflow/run-timeline.js +3 -0
  30. package/dist/wirings/workflow/workflow-child-step.d.ts +17 -0
  31. package/dist/wirings/workflow/workflow-child-step.js +31 -0
  32. package/dist/wirings/workflow/workflow-compensation.d.ts +68 -0
  33. package/dist/wirings/workflow/workflow-compensation.js +282 -0
  34. package/dist/wirings/workflow/workflow-constants.d.ts +5 -0
  35. package/dist/wirings/workflow/workflow-constants.js +9 -0
  36. package/dist/wirings/workflow/workflow-dsl-pass.d.ts +12 -0
  37. package/dist/wirings/workflow/workflow-dsl-pass.js +75 -0
  38. package/dist/wirings/workflow/workflow-queue-routing.js +3 -3
  39. package/dist/wirings/workflow/workflow-run-status.js +13 -1
  40. package/dist/wirings/workflow/workflow-status-stream.js +2 -0
  41. package/dist/wirings/workflow/workflow-unwind-plan.d.ts +38 -0
  42. package/dist/wirings/workflow/workflow-unwind-plan.js +120 -0
  43. package/dist/wirings/workflow/workflow.types.d.ts +9 -2
  44. package/knowledge/decisions/internals/workflow-step-compensation-runs-as-its-own-durable-step.md +21 -18
  45. package/package.json +1 -1
  46. package/src/public-surface.json +0 -1
@@ -1,26 +1,29 @@
1
1
  ---
2
2
  type: decision
3
- title: A step's compensation handler runs as a durable step of its own, and never compensates itself
4
- description: A refund or rollback must not fire twice on replay, so `onError` is recorded as `<step>:onError` with retries disabled
3
+ title: A step's compensation runs as a durable step of its own, declared on the function
4
+ description: A refund or rollback must not fire twice on replay, so it is recorded as `<step>:compensate`; `onError` is gone
5
5
  tags: workflow
6
6
  ---
7
7
 
8
- # A step's compensation handler runs as a durable step of its own, and never compensates itself
8
+ # A step's compensation runs as a durable step of its own, declared on the function
9
9
 
10
- `runStepCompensation` in `pikku-workflow-service.ts` invokes a failed step's
11
- `onError` RPC through `rpcStep` under the name `<stepName>:onError` rather than
12
- calling it directly. Durability is the point: a compensation handler is
13
- typically a refund or a rollback, and a bare invoke would fire again on every
14
- replay that walks past the failed step. Recorded as a step, the second replay
15
- finds it `succeeded` and returns the cached result.
10
+ A function declares `compensate` inline on `pikkuFunc`. When a workflow unwinds,
11
+ `driveUnwind` (`workflow-compensation.ts`) runs it as the step
12
+ `<step>:compensate` through the same RPC path as a forward step. Durability is
13
+ the point: a compensation is typically a refund or a rollback, and a bare invoke
14
+ would fire again on every replay. Recorded as a step, a second pass finds it
15
+ `succeeded` and returns the cached result. It uses the forward step's retry
16
+ defaults, and a compensation cannot itself be compensated.
16
17
 
17
- It runs with `{ retries: 0 }` and its own `onError` is deliberately not
18
- forwarded — a compensation handler cannot itself compensate. `onError` mirrors a
19
- graph node's: the handler receives `{ error: { message } }`, and the original
20
- error is still thrown afterwards, so the workflow fails either way. This is
21
- compensation, not recovery.
18
+ `runPikkuFunc` and the RPC resolver derive the `<id>:compensate` function from
19
+ the forward config lazily, so nothing extra is registered, and it is never
20
+ exposed. What to undo, and in what order, is decided by the pure `planUnwind`
21
+ from the recorded step rows — never from in-memory state, so a crash mid-unwind
22
+ resumes at the next compensation.
22
23
 
23
- **What this rules out:** invoking the `onError` RPC inline "since it's just
24
- cleanup", giving it the workflow's default retry count, chaining a second
25
- `onError` onto it, or swallowing the original error because the handler
26
- succeeded.
24
+ `onError` (DSL option and graph node field) was removed. Graph nodes recover
25
+ with `recover`, which takes precedence over compensation.
26
+
27
+ **What this rules out:** invoking the compensation inline "since it's just
28
+ cleanup", compensating a compensation, a second unwind of a settled run, and
29
+ swallowing the original failure because a handler succeeded.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pikku/core",
3
- "version": "0.12.133",
3
+ "version": "0.12.135",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/pikkujs/pikku.git",
@@ -532,7 +532,6 @@
532
532
  "wrapDEK"
533
533
  ],
534
534
  "./hmac": [
535
- "WebhookSigningSecret",
536
535
  "hmacDigest",
537
536
  "hmacSha256Hex",
538
537
  "timingSafeStringEqual",