@ewhauser/world-celld 0.3.2 → 0.4.0

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## 0.4.0 (2026-08-22)
6
+
7
+ ## What's Changed
8
+ * chore: test against celld v0.3.0 by @ewhauser in https://github.com/ewhauser/world-celld/pull/31
9
+ * feat: add configurable workflow retention by @ewhauser in https://github.com/ewhauser/world-celld/pull/33
10
+
11
+
12
+ **Full Changelog**: https://github.com/ewhauser/world-celld/compare/v0.3.2...v0.4.0
13
+
5
14
  ## 0.3.2 (2026-08-19)
6
15
 
7
16
  ## What's Changed
package/README.md CHANGED
@@ -75,8 +75,9 @@ requests. It must be reachable from every celld node.
75
75
 
76
76
  ## Deploy the worker
77
77
 
78
- Before deploying, you need a celld fleet, `esbuild` on `PATH`, and an object
79
- store that meets celld's conditional-write requirements. Refer to the
78
+ Before deploying, you need a celld v0.3.0 fleet, `esbuild` on `PATH`, and an
79
+ object store that meets celld's conditional-write requirements. v0.3.0 is the
80
+ currently tested runtime baseline. Refer to the
80
81
  [celld documentation](https://github.com/denoland/celld) for fleet and storage
81
82
  setup.
82
83
 
@@ -98,6 +99,7 @@ the same secret to the fleet and the application:
98
99
 
99
100
  ```sh
100
101
  CELLD_VAR_WORLD_SECRET="$CELLD_WORLD_SECRET" \
102
+ CELLD_VAR_WORKFLOW_RETENTION_MS=7776000000 \
101
103
  celld --bucket s3://my-cells-bucket \
102
104
  --listen 0.0.0.0:8080 \
103
105
  --internal-listen 10.0.0.12:8081 \
@@ -108,6 +110,9 @@ Use a secret manager rather than putting the value in `wrangler.jsonc`. Keep
108
110
  celld's internal listener on a trusted network; the World bearer token protects
109
111
  the worker RPC routes, not celld's administrative endpoints.
110
112
 
113
+ The example sets a fleet-wide maximum workflow age of 90 days. Leave
114
+ `WORKFLOW_RETENTION_MS` at `0` to disable that policy.
115
+
111
116
  More deployment detail is in [`celld-worker/README.md`](./celld-worker/README.md).
112
117
 
113
118
  ## How it works
@@ -118,6 +123,7 @@ Workflow application
118
123
  | authenticated HTTP RPC + binary stream batches
119
124
  v
120
125
  celld worker router
126
+ |-- scheduled hourly maximum-age retention discovery
121
127
  |-- WorkflowRunDO one cell per workflow run
122
128
  |-- RunCatalogDO 16 stable run-id shards; merged ordered listing
123
129
  |-- HookTokenDO 32 stable token-ownership shards
@@ -174,18 +180,47 @@ variable is shown below.
174
180
 
175
181
  The deployed worker also accepts these celld variables:
176
182
 
177
- | Variable | Default | Purpose |
178
- | --------------------------- | -------- | ---------------------------------------------------- |
179
- | `WORLD_SECRET` | none | Required bearer secret for RPC routes |
180
- | `WORKFLOW_CALLBACK_SECRET` | none | Sent with deliveries as `x-workflow-callback-secret` |
181
- | `QUEUE_MAX_ATTEMPTS` | `5` | Attempts before a message is dead-lettered |
182
- | `QUEUE_MAX_INFLIGHT` | `5` | Concurrent deliveries per queue cell (maximum `128`) |
183
- | `QUEUE_DELIVERY_TIMEOUT_MS` | `300000` | Callback timeout (maximum `300000`) |
183
+ | Variable | Default | Purpose |
184
+ | --------------------------------- | -------- | -------------------------------------------------------- |
185
+ | `WORLD_SECRET` | none | Required bearer secret for RPC routes |
186
+ | `WORKFLOW_CALLBACK_SECRET` | none | Sent with deliveries as `x-workflow-callback-secret` |
187
+ | `QUEUE_MAX_ATTEMPTS` | `5` | Attempts before a message is dead-lettered |
188
+ | `QUEUE_MAX_INFLIGHT` | `5` | Concurrent deliveries per queue cell (maximum `128`) |
189
+ | `QUEUE_DELIVERY_TIMEOUT_MS` | `300000` | Callback timeout (maximum `300000`) |
190
+ | `WORKFLOW_RETENTION_MS` | `0` | Maximum run age from creation; includes active runs |
191
+ | `WORKFLOW_RETENTION_BATCH_SIZE` | `128` | Runs admitted by each cron sweep (maximum `1000`) |
192
+ | `WORKFLOW_RETENTION_QUEUE_SHARDS` | `1` | Queue-shard fallback for runs created before this policy |
184
193
 
185
194
  `queueShards` is part of queue placement and is pinned when a queue cell is
186
195
  first used. Drain pending work before changing it.
187
196
 
188
- ## Terminal run retention
197
+ ## Workflow retention
198
+
199
+ ### Fleet-wide maximum age
200
+
201
+ Set the deployed worker's `WORKFLOW_RETENTION_MS` variable to expire every
202
+ workflow after a maximum age measured from `createdAt`. For example,
203
+ `7776000000` is 90 days. This policy applies to pending, running, completed,
204
+ failed, and cancelled runs.
205
+
206
+ The packaged worker declares an hourly UTC celld cron trigger. Each occurrence
207
+ scans one bounded creation-time catalog page and asks the authoritative run
208
+ cells to enforce the cutoff. A run cell immediately fences reads, writes, stream
209
+ activity, and queue work, removes its catalog entry, then finishes the existing
210
+ bounded stream, queue, and payload cleanup phases through its durable alarm.
211
+ Repeated cron invocations and alarm retries are idempotent.
212
+
213
+ One occurrence admits at most `WORKFLOW_RETENTION_BATCH_SIZE` runs (default
214
+ `128`, maximum `1000`). If the fleet was down or a shorter policy creates a
215
+ backlog, later occurrences continue with the next oldest entries. Edit
216
+ `triggers.crons` in the copied `celld-worker/wrangler.jsonc` if hourly discovery
217
+ does not provide the desired expiration resolution or catch-up rate.
218
+
219
+ New runs persist the application's `queueShards` value for complete queue
220
+ cleanup. `WORKFLOW_RETENTION_QUEUE_SHARDS` is the fallback for runs created
221
+ before that metadata existed and must match the placement used by those runs.
222
+
223
+ ### Terminal payload retention
189
224
 
190
225
  When `runRetentionMs` is greater than zero, a terminal transition atomically
191
226
  records the run's `expiredAt` and arms its cell alarm. The complete run, event,
@@ -219,7 +254,8 @@ await world.retention.rearm(runId); // recover a missed or abandoned alarm
219
254
 
220
255
  The retention deadline is pinned when the run becomes terminal. Changing the
221
256
  configuration affects newly terminal runs; call `schedule()` explicitly for
222
- an existing terminal run that has no cleanup record.
257
+ an existing terminal run that has no cleanup record. If terminal retention and
258
+ fleet-wide maximum age are both enabled, the earlier deadline wins.
223
259
 
224
260
  ## Operational notes
225
261
 
@@ -265,7 +301,7 @@ message reaches a successful callback, including forced `503` redeliveries. A
265
301
  second workload creates terminal runs with streams and delayed queue messages,
266
302
  then verifies complete payload cleanup without resurrection. Results include
267
303
  queue and cleanup throughput plus p50, p95, p99, and maximum latency and are
268
- saved under `.perf-results/`.
304
+ saved under `.perf-results/`. The harness currently pins celld v0.3.0.
269
305
 
270
306
  > MinIO Community is **not a supported celld production store**. It does not
271
307
  > implement the conditional writes celld needs for ownership fencing. This
@@ -284,7 +320,7 @@ and force every twentieth message through one `503` redelivery.
284
320
 
285
321
  #### Reference result
286
322
 
287
- The following directional baseline was recorded on August 15, 2026. MinIO and
323
+ The following directional baseline was recorded on August 21, 2026. MinIO and
288
324
  celld ran as native arm64 processes because Docker was unavailable on the test
289
325
  machine; container results will differ.
290
326
 
@@ -292,21 +328,25 @@ machine; container results will differ.
292
328
  | ----------- | -------------------------------------------------------------------------------------------------------- |
293
329
  | Machine | MacBook Pro (Mac15,8), Apple M3 Max, 16 cores (12 performance, 4 efficiency), 64 GB RAM |
294
330
  | OS | macOS 26.5.2 (25F84), arm64 |
295
- | Services | celld v0.2.1; MinIO RELEASE.2025-09-07T16-13-09Z |
331
+ | Services | celld v0.3.0; MinIO RELEASE.2025-09-07T16-13-09Z |
296
332
  | Workload | 1,000 messages; concurrency 32; 2 queue shards; 256-byte target payload; every 20th message retried once |
297
333
 
298
334
  | Metric | Result |
299
335
  | ----------------------- | --------------------------------------------------------------------------------: |
300
336
  | Delivery integrity | 1,000 accepted, 1,000 delivered, 0 missing, 0 duplicate successes, 0 dead letters |
301
337
  | Callback attempts | 1,050, including 50 forced redeliveries |
302
- | Enqueue throughput | 882.55 messages/s |
303
- | Delivery throughput | 808.81 messages/s |
304
- | Enqueue latency | p50 24.37 ms; p95 75.60 ms; p99 176.67 ms; max 200.36 ms |
305
- | All delivery latency | p50 53.95 ms; p95 167.86 ms; p99 210.84 ms; max 312.03 ms |
306
- | First-attempt latency | p50 52.55 ms; p95 166.35 ms; p99 209.80 ms; max 212.01 ms |
307
- | Retried-message latency | p50 82.52 ms; p95 262.63 ms; p99 312.03 ms; max 312.03 ms |
338
+ | Enqueue throughput | 865.66 messages/s |
339
+ | Delivery throughput | 794.60 messages/s |
340
+ | Enqueue latency | p50 26.06 ms; p95 70.72 ms; p99 146.59 ms; max 157.70 ms |
341
+ | All delivery latency | p50 65.05 ms; p95 184.47 ms; p99 225.10 ms; max 328.75 ms |
342
+ | First-attempt latency | p50 63.65 ms; p95 177.93 ms; p99 209.38 ms; max 226.86 ms |
343
+ | Retried-message latency | p50 114.81 ms; p95 286.35 ms; p99 328.75 ms; max 328.75 ms |
308
344
  | Final queue state | 0 pending, 0 in flight, 0 dead letters across both shards |
309
345
 
346
+ The retention workload in the same run tombstoned 100 of 100 terminal runs,
347
+ expired all 100 reads, deleted 400 payload keys, 100 streams, and 100 delayed
348
+ queue messages, and left both queue shards empty.
349
+
310
350
  Use these numbers as a smoke-test reference, not a portable performance
311
351
  guarantee. For regression tracking, compare repeated runs on the same machine
312
352
  and runtime configuration. Two shards gave the best latency balance for this
@@ -19,11 +19,33 @@ celld deploy ./workflow-world --bucket s3://my-cells-bucket
19
19
 
20
20
  Requirements:
21
21
 
22
+ - celld v0.3.0 (the currently tested runtime baseline).
22
23
  - `esbuild` on PATH (celld shells out to it).
23
24
  - A bucket with conditional-write support (celld's fencing requirement).
24
25
  - `WORLD_SECRET` injected at the node level (`CELLD_VAR_WORLD_SECRET=...`) —
25
26
  the router fails closed with 503 while it is empty.
26
27
 
28
+ ## Fleet-wide retention
29
+
30
+ The bundled `wrangler.jsonc` declares an hourly UTC cron trigger. It does no
31
+ catalog work by default. Set `CELLD_VAR_WORKFLOW_RETENTION_MS` on every node to
32
+ enable a maximum workflow age measured from run creation:
33
+
34
+ ```sh
35
+ CELLD_VAR_WORKFLOW_RETENTION_MS=7776000000 \
36
+ celld --bucket s3://my-cells-bucket
37
+ ```
38
+
39
+ `7776000000` is 90 days. The policy includes pending and running workflows as
40
+ well as terminal ones. Each cron occurrence admits at most
41
+ `WORKFLOW_RETENTION_BATCH_SIZE` runs (default `128`); the existing per-run alarm
42
+ state machine finishes bounded index, stream, queue, and payload cleanup.
43
+
44
+ New runs persist the application's `queueShards` placement. Set
45
+ `WORKFLOW_RETENTION_QUEUE_SHARDS` to the historical queue-shard count when
46
+ cleaning runs created before this worker version. Edit `triggers.crons` in the
47
+ copied config if hourly discovery is not the desired resolution.
48
+
27
49
  Point the app at any node's public listener:
28
50
 
29
51
  ```ts
@@ -28,6 +28,10 @@
28
28
  ],
29
29
  },
30
30
  ],
31
+ // Fleet-wide maximum-age retention is discovered hourly. The handler is a
32
+ // no-op while WORKFLOW_RETENTION_MS is "0". Change this expression if a
33
+ // different sweep cadence is required; celld cron schedules are UTC.
34
+ "triggers": { "crons": ["0 * * * *"] },
31
35
  "vars": {
32
36
  // REQUIRED: bearer secret for the world's RPC and binary stream surface.
33
37
  // Authenticated routes fail closed with 503 while this is empty. Inject the real value
@@ -35,6 +39,14 @@
35
39
  "WORLD_SECRET": "",
36
40
  // Optional: forwarded as x-workflow-callback-secret on queue deliveries.
37
41
  "WORKFLOW_CALLBACK_SECRET": "",
42
+ // Optional fleet-wide maximum workflow age, measured from run creation.
43
+ // Applies to pending, running, and terminal runs. "0" disables it.
44
+ "WORKFLOW_RETENTION_MS": "0",
45
+ // Maximum runs admitted to cleanup by one hourly sweep (1..1000).
46
+ "WORKFLOW_RETENTION_BATCH_SIZE": "128",
47
+ // Must match createCelldWorld({ queueShards }) so every queue shard is
48
+ // included in cleanup for active runs discovered by the sweep.
49
+ "WORKFLOW_RETENTION_QUEUE_SHARDS": "1",
38
50
  // Optional queue tuning (strings): QUEUE_MAX_ATTEMPTS, QUEUE_MAX_INFLIGHT,
39
51
  // QUEUE_DELIVERY_TIMEOUT_MS.
40
52
  },
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CreateEventParams, CreateEventRequest, Event, GetChunksOptions, Hook, RunCreatedEventRequest, Step, StreamChunksResponse, StreamInfoResponse, Streamer, TerminalWorkflowRunStatus, ValidQueueName, Wait, WorkflowRun, World } from "@workflow/world";
1
+ import { CreateEventParams, CreateEventRequest, Event, GetChunksOptions, Hook, RunCreatedEventRequest, Step, StreamChunksResponse, StreamInfoResponse, Streamer, TerminalWorkflowRunStatus, ValidQueueName, Wait, WorkflowRun, WorkflowRunStatus, World } from "@workflow/world";
2
2
  //#region src/retention.d.ts
3
3
  type CleanupPhase = 'retained' | 'index' | 'streams' | 'queues' | 'payload' | 'tombstoned';
4
4
  interface CleanupRecord {
@@ -6,8 +6,13 @@ interface CleanupRecord {
6
6
  runId: string;
7
7
  workflowName: string;
8
8
  createdAt: Date;
9
- completedAt: Date;
10
- terminalStatus: TerminalWorkflowRunStatus;
9
+ /** Last status observed when cleanup was scheduled. */
10
+ status?: WorkflowRunStatus;
11
+ /** Present when cleanup was scheduled for a terminal run. */
12
+ completedAt?: Date;
13
+ /** Retained for persisted terminal-retention records created before max-age cleanup. */
14
+ terminalStatus?: TerminalWorkflowRunStatus;
15
+ reason?: 'terminal-retention' | 'maximum-age' | 'manual';
11
16
  dueAt: Date;
12
17
  queueShards: number;
13
18
  phase: CleanupPhase;
@@ -24,8 +29,10 @@ interface CleanupRecord {
24
29
  interface RunTombstone {
25
30
  version: 1;
26
31
  runId: string;
27
- terminalStatus: TerminalWorkflowRunStatus;
28
- completedAt: Date;
32
+ /** Last status observed before the run expired. */
33
+ status?: WorkflowRunStatus;
34
+ completedAt?: Date;
35
+ terminalStatus?: TerminalWorkflowRunStatus;
29
36
  expiredAt: Date;
30
37
  tombstonedAt: Date;
31
38
  /** Final cleanup accounting retained inside the single authoritative record. */
@@ -357,6 +364,8 @@ interface QueueCellNamespace {
357
364
  interface IndexListOptions {
358
365
  prefix?: string;
359
366
  cursor?: string;
367
+ /** Exclusive upper bound for creation-time retention scans. */
368
+ end?: string;
360
369
  limit?: number;
361
370
  reverse?: boolean;
362
371
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/retention.ts","../src/apply-event.ts","../src/storage.ts","../src/stream-protocol.ts","../src/streamer.ts","../src/queue.ts","../src/indexes.ts","../src/config.ts","../src/index.ts"],"mappings":";;KAOY;UAEK;EACf;EACA;EACA;EACA,WAAW;EACX,aAAa;EACb,gBAAgB;EAChB,OAAO;EACP;EACA,OAAO;;EAEP;EACA;EACA;EACA,gBAAgB;EAChB,eAAe;EACf;EACA;EACA;;UAGe;EACf;EACA;EACA,gBAAgB;EAChB,aAAa;EACb,WAAW;EACX,cAAc;;EAEd,SAAS;;KAGC;KAEA,eAAe;EACrB;EAAU,OAAO;;EACjB;EAAW;EAAqB;EAAiB,WAAW;;UAEjD;EACf;EACA;;UAae;EACf;EACA,OAAO;;UAGQ;EACf;;UAGe;EACf;EACA;EACA,OAAO;EACP;;UAGe;EACf;;UAGe;EACf;;UAGe;;EAEf;EACA;;UAGe;;EAEf;;EAEA;;EAEA;EACA;;UAGe;EACf;EACA;;KAGU;;EAEV;;EAEI;;EAEA;;EAEA,SAAS;;UAIE;EACf;;UAGe;EACf;EACA;;;;UCyBe;;EAEf;EACA,MAAM,qBAAqB;;EAE3B,SAAS;;;;;EAKT;IAAgB;IAAe;;;EAE/B;;EAEA,UAAU;;KAGA;UAWK;EACf;EACA,MAAM;EACN;;EAEA;;EAEA;;UAGe;EACf;;EAEA,QAAQ;EACR,MAAM;EACN,OAAO;EACP,OAAO;EACP,OAAO;;EAEP;;EAEA,eAAe;IAAQ;IAAgB;;;EAEvC;IAAe;IAAsB,WAAW;;;EAEhD,cAAc;;EAEd,SAAS;;EAET;EACA;;EAEA;;EAEA;;KAGU,oBAAoB,oBAAoB;;;;;;;UCnKnC;EACf,WAAW,SAAS,oBAAoB,QAAQ;EAChD,sBAAsB;IACpB;IACA;IACA;MACE;IAAU;;EACd,sBAAsB,QADlB;EAEJ,UAAU,QAAQ,eAAe;EACjC,QAAQ,iBAAiB,QAAQ,eAAe;EAChD,SAAS,kBAAkB,QAAQ,eAAe;EAClD,WA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WAAW;;iBAE9C,iBAAiB,SAAS,mBAAmB"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/retention.ts","../src/apply-event.ts","../src/storage.ts","../src/stream-protocol.ts","../src/streamer.ts","../src/queue.ts","../src/indexes.ts","../src/config.ts","../src/index.ts"],"mappings":";;KAOY;UAEK;EACf;EACA;EACA;EACA,WAAW;;EAEX,SAAS;;EAET,cAAc;;EAEd,iBAAiB;EACjB;EACA,OAAO;EACP;EACA,OAAO;;EAEP;EACA;EACA;EACA,gBAAgB;EAChB,eAAe;EACf;EACA;EACA;;UAGe;EACf;EACA;;EAEA,SAAS;EACT,cAAc;EACd,iBAAiB;EACjB,WAAW;EACX,cAAc;;EAEd,SAAS;;KAGC;KAEA,eAAe;EACrB;EAAU,OAAO;;EACjB;EAAW;EAAqB;EAAiB,WAAW;;UAEjD;EACf;EACA;;UAae;EACf;EACA,OAAO;;UAGQ;EACf;;UAGe;EACf;EACA;EACA,OAAO;EACP;;UAGe;EACf;;UAGe;EACf;;UAGe;;EAEf;EACA;;UAGe;;EAEf;;EAEA;;EAEA;EACA;;UAGe;EACf;EACA;;KAGU;;EAEV;;EAEI;;EAEA;;EAEA,SAAS;;UAIE;EACf;;UAGe;EACf;EACA;;;;UCkBe;;EAEf;EACA,MAAM,qBAAqB;;EAE3B,SAAS;;;;;EAKT;IAAgB;IAAe;;;EAE/B;;EAEA,UAAU;;KAGA;UAWK;EACf;EACA,MAAM;EACN;;EAEA;;EAEA;;UAGe;EACf;;EAEA,QAAQ;EACR,MAAM;EACN,OAAO;EACP,OAAO;EACP,OAAO;;EAEP;;EAEA,eAAe;IAAQ;IAAgB;;;EAEvC;IAAe;IAAsB,WAAW;;;EAEhD,cAAc;;EAEd,SAAS;;EAET;EACA;;EAEA;;EAEA;;KAGU,oBAAoB,oBAAoB;;;;;;;UCnKnC;EACf,WAAW,SAAS,oBAAoB,QAAQ;EAChD,sBAAsB;IACpB;IACA;IACA;MACE;IAAU;;EACd,sBAAsB,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AQ;EAClC,SAAS,gBAAgB,QAAQ;EACjC,WAAW,gBAAgB,QAAQ;EACnC,MAAM,gBAAgB,QAAQ;;KAGpB,aAAa,QAAQ;EAAkB,WAAW;;iBAE9C,iBAAiB,SAAS,mBAAmB"}
package/dist/index.js CHANGED
@@ -5,6 +5,8 @@ import { setTimeout as setTimeout$1 } from "node:timers/promises";
5
5
  import { monotonicFactory } from "ulid";
6
6
  //#region src/config.ts
7
7
  function resolveConfig(config) {
8
+ const queueShards = config?.queueShards ?? 1;
9
+ if (!Number.isSafeInteger(queueShards) || queueShards < 1) throw new Error("world-celld: queueShards must be a positive safe integer");
8
10
  const retentionRaw = config?.runRetentionMs ?? process.env.CELLD_RUN_RETENTION_MS ?? 0;
9
11
  const runRetentionMs = typeof retentionRaw === "number" ? retentionRaw : Number.parseInt(retentionRaw, 10);
10
12
  if (!Number.isSafeInteger(runRetentionMs) || runRetentionMs < 0) throw new Error("world-celld: runRetentionMs must be a non-negative safe integer");
@@ -21,7 +23,7 @@ function resolveConfig(config) {
21
23
  env: config?.env,
22
24
  deploymentId: config?.deploymentId ?? process.env.CELLD_DEPLOYMENT_ID ?? "celld-default",
23
25
  baseUrl: config?.baseUrl,
24
- queueShards: config?.queueShards ?? 1,
26
+ queueShards,
25
27
  runRetentionMs,
26
28
  streamLongPollMs,
27
29
  streamFlushIntervalMs,