@adonis-agora/durable 0.54.0 → 0.54.2

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 (66) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/dist/assets/spa/assets/index-9kO8tWjg.js +16 -0
  3. package/dist/assets/spa/assets/index-9kO8tWjg.js.map +1 -0
  4. package/dist/assets/spa/index.html +1 -1
  5. package/dist/src/buffered-child-signals.d.ts +20 -4
  6. package/dist/src/buffered-child-signals.d.ts.map +1 -1
  7. package/dist/src/buffered-child-signals.js +207 -63
  8. package/dist/src/buffered-child-signals.js.map +1 -1
  9. package/dist/src/codec-state-store.d.ts +10 -1
  10. package/dist/src/codec-state-store.d.ts.map +1 -1
  11. package/dist/src/codec-state-store.js +32 -0
  12. package/dist/src/codec-state-store.js.map +1 -1
  13. package/dist/src/commands/worker.d.ts +2 -1
  14. package/dist/src/commands/worker.d.ts.map +1 -1
  15. package/dist/src/commands/worker.js +44 -3
  16. package/dist/src/commands/worker.js.map +1 -1
  17. package/dist/src/dashboard/index.d.ts +1 -1
  18. package/dist/src/dashboard/index.js +1 -1
  19. package/dist/src/engine.d.ts +69 -8
  20. package/dist/src/engine.d.ts.map +1 -1
  21. package/dist/src/engine.js +248 -53
  22. package/dist/src/engine.js.map +1 -1
  23. package/dist/src/index.d.ts +1 -1
  24. package/dist/src/index.js +1 -1
  25. package/dist/src/interfaces.d.ts +47 -0
  26. package/dist/src/interfaces.d.ts.map +1 -1
  27. package/dist/src/interfaces.js.map +1 -1
  28. package/dist/src/stores/lucid-mappers.d.ts +6 -1
  29. package/dist/src/stores/lucid-mappers.d.ts.map +1 -1
  30. package/dist/src/stores/lucid-mappers.js +41 -0
  31. package/dist/src/stores/lucid-mappers.js.map +1 -1
  32. package/dist/src/stores/lucid.d.ts +4 -1
  33. package/dist/src/stores/lucid.d.ts.map +1 -1
  34. package/dist/src/stores/lucid.js +148 -37
  35. package/dist/src/stores/lucid.js.map +1 -1
  36. package/dist/src/testing/in-memory-state-store.d.ts +4 -1
  37. package/dist/src/testing/in-memory-state-store.d.ts.map +1 -1
  38. package/dist/src/testing/in-memory-state-store.js +29 -0
  39. package/dist/src/testing/in-memory-state-store.js.map +1 -1
  40. package/dist/src/testing-kit/run-dispatch-contract.d.ts.map +1 -1
  41. package/dist/src/testing-kit/run-dispatch-contract.js +12 -3
  42. package/dist/src/testing-kit/run-dispatch-contract.js.map +1 -1
  43. package/dist/src/testing-kit/state-store-conformance.d.ts +6 -0
  44. package/dist/src/testing-kit/state-store-conformance.d.ts.map +1 -1
  45. package/dist/src/testing-kit/state-store-conformance.js +230 -0
  46. package/dist/src/testing-kit/state-store-conformance.js.map +1 -1
  47. package/dist/src/transports/adaptive-concurrency.d.ts +2 -0
  48. package/dist/src/transports/adaptive-concurrency.d.ts.map +1 -1
  49. package/dist/src/transports/adaptive-concurrency.js +39 -9
  50. package/dist/src/transports/adaptive-concurrency.js.map +1 -1
  51. package/dist/src/transports/bullmq/bullmq-transport.d.ts.map +1 -1
  52. package/dist/src/transports/bullmq/bullmq-transport.js +8 -4
  53. package/dist/src/transports/bullmq/bullmq-transport.js.map +1 -1
  54. package/dist/src/transports/bullmq/deps.d.ts.map +1 -1
  55. package/dist/src/transports/bullmq/deps.js +18 -1
  56. package/dist/src/transports/bullmq/deps.js.map +1 -1
  57. package/dist/src/transports/db.js +4 -4
  58. package/dist/src/transports/db.js.map +1 -1
  59. package/dist/src/transports/queue.d.ts.map +1 -1
  60. package/dist/src/transports/queue.js +8 -4
  61. package/dist/src/transports/queue.js.map +1 -1
  62. package/package.json +2 -2
  63. package/skills/durable-reliability/SKILL.md +2 -1
  64. package/skills/durable-transports-stores/SKILL.md +15 -2
  65. package/dist/assets/spa/assets/index-BEk3-95l.js +0 -16
  66. package/dist/assets/spa/assets/index-BEk3-95l.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,95 @@
1
1
  # @adonis-agora/durable
2
2
 
3
+ ## 0.54.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#409](https://github.com/DavideCarvalho/adonis-agora-durable/pull/409) [`902f12e`](https://github.com/DavideCarvalho/adonis-agora-durable/commit/902f12e9a6ca97d24e36e11e6ad819ef8137cfac) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - A `bullmq` connection given as options with a `url` (`{ url: 'redis://…' }`) now reaches that Redis
8
+ from every client. BullMQ read the URL for the queues, but ioredis ignores `url`, so the pub/sub and
9
+ heartbeat clients connected to 127.0.0.1:6379 instead: step heartbeats, run replies and tenant
10
+ events were lost, or went to another Redis. Keys set beside the `url` (a `tls` with a CA, a `db`) are kept over the ones the URL implies.
11
+
12
+ - [#409](https://github.com/DavideCarvalho/adonis-agora-durable/pull/409) [`6433ee6`](https://github.com/DavideCarvalho/adonis-agora-durable/commit/6433ee6af00a052c46daf9fcbb93dcc059e54c25) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - The adaptive step concurrency no longer collapses to one on fast steps.
13
+
14
+ The controller read latency jitter as queuing: its baseline is the fastest completion of the
15
+ window, and for 1–5 ms steps p50 sits several times above it with nothing queued, so it shrank to
16
+ one or two at a time. p50 may now reach twice the baseline plus 5 ms before it counts as queuing.
17
+ Growth doubles the limit until the first back-off, then adds √limit a tick (it added one every 2 s);
18
+ until that first back-off, growth is re-decided after each limit's worth of settled steps instead of
19
+ waiting for the 2 s tick.
20
+ Step durations are timed with `performance.now()` instead of whole milliseconds. Same decisions as
21
+ the Aviary controller.
22
+
23
+ - [#409](https://github.com/DavideCarvalho/adonis-agora-durable/pull/409) [`ad5f847`](https://github.com/DavideCarvalho/adonis-agora-durable/commit/ad5f847e9d60576ed35d108ad496ea20f5eaa3f3) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - The check a turn makes after suspending on a step, whether that step already settled, is a `COUNT`
24
+ where the store has `countCheckpoints`. It read the step's whole row, so every turn of a
25
+ conversation read back the input of the LLM step it had just sent.
26
+
27
+ - [#409](https://github.com/DavideCarvalho/adonis-agora-durable/pull/409) [`d9ec346`](https://github.com/DavideCarvalho/adonis-agora-durable/commit/d9ec34637d03d95f9b1f62c825bad0501ebed671) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - A turn no longer reads the input of every step its run has completed.
28
+
29
+ Each turn of a run starts by reading the run's checkpoints, and read every column of every row,
30
+ including the `input` of every completed step, which replaying a completed step never uses. Stores
31
+ can now implement the optional `listCheckpointsForReplay(runId)`: `listCheckpoints`, except that a
32
+ `completed` row comes back without its `input`, left out of the query. A `pending`, `running` or
33
+ `failed` row keeps it, for a re-dispatch or a retry. The engine reads a turn (and a remote
34
+ workflow's history) through it, and falls back to `listCheckpoints` on a store without it; the run
35
+ detail, `durable:runs` and `engine.listCheckpoints` still read every input. The Lucid store, the
36
+ in-memory store and `CodecStateStore` implement it: the 20th turn of a run whose steps carry
37
+ 100 KB inputs read 2.2 MB on Postgres and MySQL, and now reads about 200 KB, the same as its first.
38
+
39
+ - [#409](https://github.com/DavideCarvalho/adonis-agora-durable/pull/409) [`7490c16`](https://github.com/DavideCarvalho/adonis-agora-durable/commit/7490c16f73ead4cab7e1b34986d2d342db5bddde) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - A worker result's settle no longer reads the step's input. It reads the step's row through the new
40
+ optional `StateStore.getCheckpointsForSettle`, `getCheckpoints` without `input`, left out of the
41
+ query itself; the engine uses it only when the store also has `settleCheckpointsIfPending`. The Lucid
42
+ and in-memory stores implement it, `CodecStateStore` decodes what it returns, and the store contract
43
+ checks it when a store has it. With the re-check by count, a turn of a conversation over 100 KB-input
44
+ steps reads about 2 KB of checkpoints where it read about 200 KB.
45
+
46
+ - [#409](https://github.com/DavideCarvalho/adonis-agora-durable/pull/409) [`9104008`](https://github.com/DavideCarvalho/adonis-agora-durable/commit/910400813e56ade2488de368e10a24fa64e9ec2c) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - A worker result settles its step without rewriting the step's `input`.
47
+
48
+ The engine wrote a settled step's whole checkpoint row again, so a step with a large input (an
49
+ agent's LLM step carries its whole prompt) had that input written twice: once when it was
50
+ dispatched, once when its result landed. Stores can now implement the optional
51
+ `settleCheckpointsIfPending(settlements)`, which writes only the columns a result changes
52
+ (`status`, `output`, `error`, `events`, `startedAt`, `finishedAt`) while the row is still `pending`,
53
+ with the same claim as `saveCheckpointsIfPending`. The engine settles every result through it, and
54
+ writes whole rows as before on a store without it. The Lucid store, the in-memory store and
55
+ `CodecStateStore` implement it: settling a step with a 100 KB input wrote about 100 KB of
56
+ checkpoint row on Postgres, MySQL and SQLite, and now writes about 40 bytes.
57
+
58
+ - [#409](https://github.com/DavideCarvalho/adonis-agora-durable/pull/409) [`2fb0651`](https://github.com/DavideCarvalho/adonis-agora-durable/commit/2fb06516c80266a53535d312b259f87c0ff59dd5) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - A result that lands right after the turn that sent its step suspended resumes the run once. The
59
+ instance that settles a step and resumes its run now remembers it for a lease, and the suspended
60
+ turn's re-check of that step, which found it settled and resumed the run again, leaves it to that
61
+ resume. A remote workflow's re-check, whose decision may postdate that resume, and a re-check on any
62
+ other instance still re-drive the run.
63
+
64
+ - [#409](https://github.com/DavideCarvalho/adonis-agora-durable/pull/409) [`eaf342e`](https://github.com/DavideCarvalho/adonis-agora-durable/commit/eaf342e979cb99faeb54d4e01d22de4c29d01a07) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - A wide step fan no longer slows down on its way out and while its steps run.
65
+
66
+ The `bullmq` and `queue` transports grouped a fan's tasks by queue by copying the group on every
67
+ task, so sending 150k steps took over a minute; it is linear now. The Lucid store's batched settle
68
+ grouped its rows the same way.
69
+
70
+ Every step's worker beats once when it picks the step up, and each beat was written to the step's
71
+ checkpoint at once: a 40k fan made 40k concurrent `UPDATE`s that took the store's connections from
72
+ the fan's results. Beats are now written one at a time, a newer beat of a step replaces its queued
73
+ one, and a step whose result arrives first never has its beat written. A 40k fan over BullMQ and
74
+ MySQL went from 46 s to 13 s.
75
+
76
+ With `remoteRedispatchMs` set, a fan's steps are written with their lease already stamped and the
77
+ run parks on it; a pickup beat on the instance that sent the fan no longer reads the step and
78
+ rewrites its lease. The same 40k fan went from 50 s to 14 s.
79
+
80
+ ## 0.54.1
81
+
82
+ ### Patch Changes
83
+
84
+ - [#405](https://github.com/DavideCarvalho/adonis-agora-durable/pull/405) [`d09f5fd`](https://github.com/DavideCarvalho/adonis-agora-durable/commit/d09f5fd4a5afbcd76673a1c6e0f8ac8a41d9f897) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - The buffered-signal sweep no longer costs one checkpoint read per buffered row, and no longer holds up the worker tick.
85
+
86
+ - Each page is decided set-based: one `getRuns` for every parent in it (a gone or finished parent's rows go without a checkpoint read), then one `getCheckpoints` by primary key per live parent, at the seqs the child ids name (`<p>.all.<first>.<i>` at `first + i`, its fold at `first`; wave `k` of a fan in waves folds at `first + k * W`; `<p>.child.<n>` at `n`). A read by name is left only for ids that name no seq, once per parent per page.
87
+ - A sweep call stops after 250 ms of wall-clock time and the next resumes where it stopped. It never runs concurrently with itself.
88
+ - The worker loop (`node ace durable:work` and the embedded worker) starts the sweep beside the tick instead of awaiting it inside, so a slow sweep does not delay the schedules, retention and stalled phases or the next `runPending`. Shutdown waits for a sweep in flight within the drain budget. A failure of the sweep is reported by the next tick.
89
+ - The write-path check of whether a child's completion needs buffering is `getRun` plus one keyed `getCheckpoints`.
90
+
91
+ On MySQL with a 40k-child parent and ~42k buffered rows, one sweep tick went from 2,012 statements to 15–20.
92
+
3
93
  ## 0.54.0
4
94
 
5
95
  ### Minor Changes