solid-objects 1.0.6 → 1.0.7

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 (71) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/broadcast-worker.d.ts +1 -0
  3. package/dist/broadcast-worker.d.ts.map +1 -1
  4. package/dist/broadcast-worker.js +10 -1
  5. package/dist/broadcast-worker.js.map +1 -1
  6. package/dist/configuration.d.ts +2 -0
  7. package/dist/configuration.d.ts.map +1 -1
  8. package/dist/configuration.js +24 -1
  9. package/dist/configuration.js.map +1 -1
  10. package/dist/doctor.js +1 -1
  11. package/dist/doctor.js.map +1 -1
  12. package/dist/due-work.d.ts +15 -0
  13. package/dist/due-work.d.ts.map +1 -0
  14. package/dist/due-work.js +124 -0
  15. package/dist/due-work.js.map +1 -0
  16. package/dist/effect-worker.d.ts +1 -0
  17. package/dist/effect-worker.d.ts.map +1 -1
  18. package/dist/effect-worker.js +10 -1
  19. package/dist/effect-worker.js.map +1 -1
  20. package/dist/errors.d.ts +14 -0
  21. package/dist/errors.d.ts.map +1 -1
  22. package/dist/errors.js +11 -0
  23. package/dist/errors.js.map +1 -1
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +1 -1
  27. package/dist/index.js.map +1 -1
  28. package/dist/local-signal.d.ts +15 -0
  29. package/dist/local-signal.d.ts.map +1 -0
  30. package/dist/local-signal.js +35 -0
  31. package/dist/local-signal.js.map +1 -0
  32. package/dist/redrive.d.ts +3 -0
  33. package/dist/redrive.d.ts.map +1 -1
  34. package/dist/redrive.js +30 -1
  35. package/dist/redrive.js.map +1 -1
  36. package/dist/reminder-scheduler.d.ts +1 -0
  37. package/dist/reminder-scheduler.d.ts.map +1 -1
  38. package/dist/reminder-scheduler.js +10 -1
  39. package/dist/reminder-scheduler.js.map +1 -1
  40. package/dist/repository.d.ts +8 -1
  41. package/dist/repository.d.ts.map +1 -1
  42. package/dist/repository.js +57 -21
  43. package/dist/repository.js.map +1 -1
  44. package/dist/runtime.d.ts +6 -0
  45. package/dist/runtime.d.ts.map +1 -1
  46. package/dist/runtime.js +50 -6
  47. package/dist/runtime.js.map +1 -1
  48. package/dist/single-owner.d.ts +17 -0
  49. package/dist/single-owner.d.ts.map +1 -0
  50. package/dist/single-owner.js +27 -0
  51. package/dist/single-owner.js.map +1 -0
  52. package/dist/version.d.ts +1 -1
  53. package/dist/version.js +1 -1
  54. package/dist/wake-up-selection.d.ts +1 -0
  55. package/dist/wake-up-selection.d.ts.map +1 -1
  56. package/dist/wake-up-selection.js +10 -0
  57. package/dist/wake-up-selection.js.map +1 -1
  58. package/dist/wall-clock-watch.d.ts +14 -0
  59. package/dist/wall-clock-watch.d.ts.map +1 -0
  60. package/dist/wall-clock-watch.js +35 -0
  61. package/dist/wall-clock-watch.js.map +1 -0
  62. package/dist/worker.d.ts +3 -0
  63. package/dist/worker.d.ts.map +1 -1
  64. package/dist/worker.js +29 -4
  65. package/dist/worker.js.map +1 -1
  66. package/docs/api.md +5 -3
  67. package/docs/configuration.md +92 -15
  68. package/docs/correctness.md +54 -3
  69. package/docs/errors-and-recovery.md +4 -0
  70. package/docs/operations.md +45 -5
  71. package/package.json +1 -1
package/dist/worker.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { randomUUID } from "./platform/uuid.js";
2
2
  import { ActorSetupFailed, ApplicationWriteForbidden, LostActivation, StateMigrationError, } from "./errors.js";
3
3
  import { PollingBackoff } from "./polling-backoff.js";
4
+ import { DueWait, idleWaitMilliseconds } from "./single-owner.js";
4
5
  import { yieldToEventLoop } from "./yield-to-event-loop.js";
5
6
  export class Worker {
6
7
  runtime;
@@ -10,6 +11,7 @@ export class Worker {
10
11
  stopping = false;
11
12
  activations = new Map();
12
13
  pollingBackoff;
14
+ dueWait = new DueWait();
13
15
  constructor(runtime, options = {}) {
14
16
  this.runtime = runtime;
15
17
  this.options = options;
@@ -139,7 +141,7 @@ export class Worker {
139
141
  continue;
140
142
  }
141
143
  const notified = await wakeUp.wait({
142
- timeoutMilliseconds: this.pollingBackoff.currentIntervalMilliseconds,
144
+ timeoutMilliseconds: await this.idleWaitMilliseconds(),
143
145
  signal,
144
146
  });
145
147
  if (notified === false)
@@ -176,7 +178,28 @@ export class Worker {
176
178
  });
177
179
  }
178
180
  }
181
+ async idleWaitMilliseconds() {
182
+ const databaseWait = await idleWaitMilliseconds({
183
+ settings: this.runtime.settings,
184
+ pollingIntervalMilliseconds: this.pollingBackoff.currentIntervalMilliseconds,
185
+ dueWait: this.dueWait,
186
+ untilDue: () => this.runtime.dueWork.untilActorWork({ processId: this.processId }),
187
+ });
188
+ if (!this.runtime.settings.singleOwner)
189
+ return databaseWait;
190
+ return Math.min(databaseWait, this.untilCachedActivationDue());
191
+ }
192
+ untilCachedActivationDue() {
193
+ let earliest = Number.POSITIVE_INFINITY;
194
+ for (const activation of this.activations.values()) {
195
+ const deactivateAt = activation.lastUsedAt + this.runtime.settings.idleDeactivationTimeoutMilliseconds;
196
+ earliest = Math.min(earliest, activation.renewAt, deactivateAt);
197
+ }
198
+ return Math.max(Math.ceil(earliest - performance.now()), 0);
199
+ }
179
200
  async ensureRegistered() {
201
+ if (this.registered && this.runtime.settings.singleOwner)
202
+ return;
180
203
  await this.runtime.repository.registerProcess(this.processId, "worker");
181
204
  this.registered = true;
182
205
  }
@@ -266,11 +289,13 @@ export function waitFor(milliseconds, signal) {
266
289
  if (signal?.aborted)
267
290
  return Promise.resolve();
268
291
  return new Promise((resolve) => {
269
- const timeout = setTimeout(resolve, milliseconds);
270
- signal?.addEventListener("abort", () => {
292
+ const finish = () => {
271
293
  clearTimeout(timeout);
294
+ signal?.removeEventListener("abort", finish);
272
295
  resolve();
273
- }, { once: true });
296
+ };
297
+ const timeout = setTimeout(finish, milliseconds);
298
+ signal?.addEventListener("abort", finish, { once: true });
274
299
  });
275
300
  }
276
301
  export async function withProcessHeartbeat(options) {
@@ -1 +1 @@
1
- {"version":3,"file":"worker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E,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAA;IAC9C,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACvB,MAAM,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,oCAAoC,EAAE,MAAM,CAAC,CAAA;QAC5E,IAAI,MAAM,CAAC,OAAO;YAAE,OAAM;QAC1B,IAAI,CAAC;YACH,MAAM,OAAO,CAAC,UAAU,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAA;QACtD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,UAAU,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,CAAA;YAC1F,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;gBAC3B,KAAK,EAAE,wCAAwC;gBAC/C,GAAG,UAAU;aACd,CAAC,CAAA;YACF,OAAO,CAAC,mBAAmB,CAAC,0BAA0B,EAAE,UAAU,CAAC,CAAA;QACrE,CAAC;IACH,CAAC;AACH,CAAC"}
package/docs/api.md CHANGED
@@ -793,11 +793,13 @@ The root exports `SolidObjectsError` and its supported subclasses:
793
793
  `ScheduleWithoutOperation`, `StateMigrationError`, `ApplicationWriteForbidden`, `UnknownEffect`, and
794
794
  `UnknownCommitAction`;
795
795
  - operational failures: `LostActivation`, `DatabaseDeadlineExceeded`,
796
- `UnknownDeadLetter`, `UnknownReminder`, `ReminderNotPaused`, and
797
- `UnsupportedDatabase`.
796
+ `UnknownDeadLetter`, `UnknownReminder`, `ReminderNotPaused`,
797
+ `UnsupportedDatabase`, and `SingleOwnerConflict`.
798
798
 
799
799
  `NonRetryableError` is the application subclassing point. `SyncTimeoutDetails`
800
- and `SyncTimeoutWaitingOn` type timeout diagnostics. See
800
+ and `SyncTimeoutWaitingOn` type timeout diagnostics. `SingleOwnerConflict`
801
+ carries one `SingleOwnerConflictProcess` for each live process row that stopped
802
+ a `singleOwner` runtime from starting. See
801
803
  [Errors and recovery](errors-and-recovery.md) before deciding what to catch.
802
804
 
803
805
  ## `solid-objects/database/sqlite`
@@ -65,19 +65,20 @@ as an instruction to divide the actor. See
65
65
 
66
66
  ## Runtime roles and supervision
67
67
 
68
- | Option | Default | Contract |
69
- | ------------------------------------------- | --------------: | ----------------------------------------------------------------- |
70
- | `workerCount` | `1` | Non-negative actor workers. |
71
- | `effectWorkerCount` | `1` | Non-negative effect workers. |
72
- | `broadcastWorkerCount` | `1` | Non-negative broadcast workers when realtime is enabled. |
73
- | `reminderSchedulerCount` | `1` | Non-negative reminder schedulers. |
74
- | `processHeartbeatIntervalMilliseconds` | `15_000` | Positive persisted heartbeat cadence. |
75
- | `processAliveThresholdMilliseconds` | `60_000` | Positive age after which an owner is stale. |
76
- | `shutdownTimeoutMilliseconds` | `15_000` | Positive shared graceful-shutdown budget. |
77
- | `supervisorRestartDelayMilliseconds` | `100` | Positive initial failed-role replacement delay. |
78
- | `supervisorMaximumRestartDelayMilliseconds` | `10_000` | Positive cap no smaller than the initial delay. |
79
- | `wakeUp` | `"automatic"` | A name or an adapter implementing `watch`, `notify`, and `close`. |
80
- | `logger` | console methods | Structured `debug`, `info`, `warn`, and `error` sink. |
68
+ | Option | Default | Contract |
69
+ | ------------------------------------------- | --------------: | ------------------------------------------------------------------- |
70
+ | `workerCount` | `1` | Non-negative actor workers. |
71
+ | `effectWorkerCount` | `1` | Non-negative effect workers. |
72
+ | `broadcastWorkerCount` | `1` | Non-negative broadcast workers when realtime is enabled. |
73
+ | `reminderSchedulerCount` | `1` | Non-negative reminder schedulers. |
74
+ | `processHeartbeatIntervalMilliseconds` | `15_000` | Positive persisted heartbeat cadence. |
75
+ | `processAliveThresholdMilliseconds` | `60_000` | Positive age after which an owner is stale. |
76
+ | `shutdownTimeoutMilliseconds` | `15_000` | Positive shared graceful-shutdown budget. |
77
+ | `supervisorRestartDelayMilliseconds` | `100` | Positive initial failed-role replacement delay. |
78
+ | `supervisorMaximumRestartDelayMilliseconds` | `10_000` | Positive cap no smaller than the initial delay. |
79
+ | `wakeUp` | `"automatic"` | A name or an adapter implementing `watch`, `notify`, and `close`. |
80
+ | `singleOwner` | `false` | `true` when this process is the only writer of its SQLite database. |
81
+ | `logger` | console methods | Structured `debug`, `info`, `warn`, and `error` sink. |
81
82
 
82
83
  Counts may be zero, but the complete configuration must leave at least one
83
84
  runtime role enabled. Broadcast workers are started only when `broadcast` or
@@ -90,7 +91,9 @@ Consecutive empty passes double it up to
90
91
  fixed cadence. A custom wake-up adapter must return `true` for a notification
91
92
  and `false` for a timeout. An older adapter that returns `void` remains
92
93
  compatible and keeps the fast cadence. Wake-ups reduce latency, while database
93
- polling remains the correctness path.
94
+ polling remains the correctness path. The one exception is
95
+ [`singleOwner`](#single-owner), which replaces polling with wake-ups and due
96
+ times.
94
97
 
95
98
  Busy SQL workers and testing drains give the event loop a turn between passes.
96
99
  In Node this lets timers and input run even with synchronous SQLite calls.
@@ -98,6 +101,79 @@ An instrumentation callback can abort `runtime.run()` before its next pass.
98
101
  This does not interrupt a synchronous handler: responsiveness is bounded by
99
102
  one pass, or by a single overlong handler that must return first.
100
103
 
104
+ ## Single owner
105
+
106
+ Set `singleOwner: true` when one process is the only writer of its SQLite
107
+ database, for example a daemon that embeds the runtime and holds its database
108
+ file. With the option, an idle runtime sends no query. The default is `false`,
109
+ and the default behavior does not change.
110
+
111
+ ```typescript
112
+ const runtime = createRuntime({
113
+ database: sqlite({ path: "app.sqlite" }),
114
+ singleOwner: true,
115
+ })
116
+ ```
117
+
118
+ With `singleOwner: true`, the runtime changes these behaviors:
119
+
120
+ - Each role waits for an in-process wake-up or for the next due time that the
121
+ database reports. A due time is, for example, the time of the next ready
122
+ message, effect, broadcast, reminder, or retry, the end of a lease, or the
123
+ time when the owner of a claim becomes stale. A role with nothing due waits
124
+ up to 24 hours and then reads its due time again.
125
+ - A write in this process that adds work or moves it earlier wakes the roles
126
+ that must react. A role that waits for a later due time then reads the new
127
+ due time.
128
+ - The actor worker renews a lease only while it holds a cached activation.
129
+ When idle deactivation releases the last activation, the worker stops waking
130
+ for leases.
131
+ - Each role writes its process row once at start and once at shutdown. A claim
132
+ also writes the row of the worker that claims, in the claim transaction, so
133
+ that running work always has a fresh owner. An empty pass writes nothing.
134
+ - No periodic dead-process cleanup runs, and
135
+ `deadProcessCleanupIntervalMilliseconds` has no effect. `run()` releases
136
+ stale process rows once, at start.
137
+ - A watch compares the wall clock with the process clock every 10 seconds.
138
+ Node timers stop while the computer sleeps, so after a sleep, or after a jump
139
+ of one second or more, every role reads its due time again. The watch sends
140
+ no query.
141
+ - When a due time is now or has passed and a claim still finds nothing, the
142
+ role tries again after 1 ms. A timer can end a few milliseconds before the
143
+ database clock reaches the due time, and this retry takes the work at once.
144
+ Each further retry doubles the wait, up to the polling interval, so stuck
145
+ work cannot spin. `pollingIntervalMilliseconds` and
146
+ `idlePollingIntervalMilliseconds` set only this limit.
147
+
148
+ Work that is active runs as before. A turn renews its lease, and an effect or a
149
+ broadcast sends its process heartbeat while it runs. Automatic retention still
150
+ runs at start and every `retentionIntervalMilliseconds`. Set that interval to
151
+ `0` to stop it, and prune with `runtime.retention.prune()` instead.
152
+
153
+ `run()` refuses to start with `SingleOwnerConflict` when another process row is
154
+ alive by the usual rule: the row is not stopped, and its heartbeat is newer
155
+ than `processAliveThresholdMilliseconds`. The error names each row and the time
156
+ at which the row becomes stale. The rows of the runtime's own synchronous
157
+ callers do not count.
158
+
159
+ `createRuntime()` refuses the option in these cases:
160
+
161
+ - The database is not SQLite. PostgreSQL and MySQL are servers that other
162
+ processes can reach. The runtime cannot know that it is the only writer, and
163
+ without polling a write from another process can wait up to 24 hours.
164
+ - `wakeUp` is `"postgresql"`, `"redis"`, or an adapter. A notification over a
165
+ connection can be lost when the connection fails, and the runtime cannot
166
+ prove that a custom adapter delivers every signal. Without polling, a lost
167
+ signal can delay work for up to 24 hours. With `"automatic"` or
168
+ `"in_process"`, the runtime uses in-process signalling and ignores
169
+ `SOLID_OBJECTS_REDIS_URL`.
170
+
171
+ Do not use the option with `sharedSqliteWasm`, because each tab runs its own
172
+ runtime against the shared database. See
173
+ [Correctness and delivery semantics](correctness.md#single-owner) for the
174
+ guarantee and its limits, and [Operations](operations.md#single-owner) for
175
+ monitoring.
176
+
101
177
  ## Retention and cleanup
102
178
 
103
179
  | Option | Default | Contract |
@@ -206,7 +282,8 @@ the files only when no process has the database open. An in-memory database
206
282
 
207
283
  `wakeUp` takes a name or an adapter, as `config.cache_store` does in Rails.
208
284
  `"automatic"` is the default. It prefers `SOLID_OBJECTS_REDIS_URL`, then
209
- PostgreSQL notifications, then polling. `"in_process"` opts out, `"postgresql"`
285
+ PostgreSQL notifications, then polling. With `singleOwner`, the runtime runs no
286
+ selection and uses in-process signalling. `"in_process"` opts out, `"postgresql"`
210
287
  and `"redis"` force one, and an unknown name throws rather than polls quietly.
211
288
 
212
289
  A requested adapter that the environment cannot provide polls instead and says
@@ -36,9 +36,10 @@
36
36
  - Observable outbox rows are claimed in actor revision order. Subscription
37
37
  sessions and browser clients reject duplicate or stale revisions within an
38
38
  incarnation, while a recreated actor starts a new revision sequence.
39
- - Wake-up notifications happen only after commit and never replace polling.
40
- Workers watch before claiming, so an in-process notification between an empty
41
- claim and the following wait is retained.
39
+ - Wake-up notifications happen only after commit and never replace polling,
40
+ except with [`singleOwner`](#single-owner). Workers watch before claiming, so
41
+ an in-process notification between an empty claim and the following wait is
42
+ retained.
42
43
  - Activation passes are bounded. Yielding changes ready-membership polling
43
44
  order only; it neither changes durable message sequence nor makes future work
44
45
  due early.
@@ -65,6 +66,56 @@
65
66
  delivery. A state change on an actor with payloads creates a revision
66
67
  broadcast, even when that actor declares no scalar observables.
67
68
 
69
+ ## Single owner
70
+
71
+ With `singleOwner: true`, an idle runtime sends no query, and it still runs all
72
+ work when the work arrives or comes due. This guarantee holds only while one
73
+ process writes the database.
74
+
75
+ The guarantee rests on these rules:
76
+
77
+ - Every write that adds work or moves it earlier happens in this process. After
78
+ the commit, the write notifies an in-process signal for each role that must
79
+ react. A host that enqueues with
80
+ `runtime.enqueueInternalMessageInTransaction()` must call
81
+ `runtime.announceInternalMessage()` after its commit, as it must without the
82
+ option. Without that call, the message waits for the next wake-up.
83
+ - A role watches the signal before it claims, so it cannot lose a notification
84
+ that arrives during a pass.
85
+ - After an empty pass, a role reads the earliest time at which a claim can take
86
+ something. The read uses the same conditions as the claims: the head of each
87
+ mailbox, lease ends, pending effects, broadcasts, and reminders, claims whose
88
+ owners become stale, and recovery timeouts. The role waits until that time,
89
+ or for at most 24 hours.
90
+ - A claim writes the row of the claiming worker in the claim transaction. A
91
+ worker that was idle for longer than `processAliveThresholdMilliseconds`
92
+ therefore never holds work under a stale row, and the alive rule protects
93
+ running work as it does without the option.
94
+
95
+ Fencing and at-least-once delivery do not change. Claims, activation leases,
96
+ the commit fence, retries, dead letters, and effect recovery use the same rows
97
+ and the same conditions.
98
+
99
+ The guarantee has these limits:
100
+
101
+ - One process only. A write from another process, for example a second
102
+ runtime, a script, or a command, does not wake this runtime. That work waits
103
+ for the next local wake-up or due time, for at most 24 hours.
104
+ - The start check reads the process rows once. It sees another writer only
105
+ while that writer's row is fresh, and an idle single owner does not refresh
106
+ its row. Two processes that start at the same moment can both pass the
107
+ check. Only an operating system lock, such as SQLite's exclusive locking
108
+ mode, keeps a second process out.
109
+ - A due time runs on a Node timer. A long synchronous handler delays the timer,
110
+ as it delays polling. Node timers stop while the computer sleeps. A watch
111
+ sees the jump of the wall clock within 10 seconds and makes every role read
112
+ its due time again, so work that came due during a sleep runs at most about
113
+ 10 seconds after the computer wakes.
114
+ - When a due time is now or has passed and a claim still finds nothing, for
115
+ example after an actor setup failure, the role retries after 1 ms and then
116
+ doubles the wait up to its polling interval. Stuck work is then retried at
117
+ the polling interval, as it is without the option.
118
+
68
119
  ## Limitations and non-goals
69
120
 
70
121
  - At-least-once execution means actor code may begin more than once. State and
@@ -83,6 +83,10 @@ stable public code and does not classify the operation as failed.
83
83
  lookup found no record.
84
84
  - `ReminderNotPaused` means only a completed reminder remains; schedule it
85
85
  again through its actor instead of resuming it.
86
+ - `SingleOwnerConflict` means a `singleOwner` runtime found another live
87
+ process row at start. Its `processes` list names each row and the time at
88
+ which the row becomes stale. Stop the other process, or wait until that time,
89
+ and start again.
86
90
 
87
91
  Realtime protocol validation uses `TypeError` for malformed subscription or
88
92
  browser envelopes. Server delivery failures are isolated to the session and
@@ -7,7 +7,8 @@ and work enqueued with `send` stays ready until some process runs the roles.
7
7
  A direct call or an explicit `sync` needs no running role, because the caller's
8
8
  own path executes it.
9
9
 
10
- Runtime roles use durable polling as the correctness fallback. Consecutive
10
+ Runtime roles use durable polling as the correctness fallback, unless the
11
+ runtime runs as a [single owner](#single-owner). Consecutive
11
12
  empty passes double each role's wait from `pollingIntervalMilliseconds` to
12
13
  `idlePollingIntervalMilliseconds`, which defaults to one second. Processed
13
14
  work and wake-up notifications reset the role to the fast interval. Actor
@@ -149,10 +150,10 @@ state from reconciliation code.
149
150
  The runtime automatically prunes expired message and stopped-process history
150
151
  once at startup and every `retentionIntervalMilliseconds`, which defaults to
151
152
  one hour. Stale process ownership is recovered independently every
152
- `deadProcessCleanupIntervalMilliseconds`, which defaults to one minute. Set an
153
- interval to zero to disable its scheduler. Failed passes emit metadata-only
154
- events and retry with bounded exponential backoff without stopping other
155
- runtime roles.
153
+ `deadProcessCleanupIntervalMilliseconds`, which defaults to one minute. A
154
+ single owner recovers it once, at start. Set an interval to zero to disable its
155
+ scheduler. Failed passes emit metadata-only events and retry with bounded
156
+ exponential backoff without stopping other runtime roles.
156
157
 
157
158
  Operators can also use `runtime.retention.preview()` and
158
159
  `runtime.retention.prune()`. Both calls require administration authorization;
@@ -228,6 +229,45 @@ Scheduling an existing actor operation for a different time emits
228
229
  `solid_objects.reminder.replaced` after the fenced actor commit. Scheduling it
229
230
  for the same time emits nothing.
230
231
 
232
+ ## Single owner
233
+
234
+ With [`singleOwner: true`](configuration.md#single-owner), an idle runtime sends
235
+ no query. Its roles wake for an in-process notification, for a due time that
236
+ the database reports, or after the wall clock jumps. Expect these differences
237
+ from the default:
238
+
239
+ - `runtime.administration.processes()` reports the rows of an idle single owner
240
+ as `stale`, because a role writes its row only at start, at shutdown, and
241
+ when it claims work. The `runtime` doctor check can report no live roles for
242
+ the same reason. Both are normal while the runtime is idle.
243
+ - The `wakeUp` doctor check passes with in-process signalling, because no other
244
+ process writes the database.
245
+ - `cleanup()` can mark the rows of an idle single owner `stopped`. The next
246
+ claim of each role writes its row again. An idle role holds no claim, so the
247
+ cleanup releases nothing.
248
+ - `currentPollingIntervalMilliseconds` and the
249
+ `solid_objects.polling.interval_changed` events describe only the retry of
250
+ due work that a claim cannot take.
251
+
252
+ `run()` refuses to start with `SingleOwnerConflict` when another process row is
253
+ alive. A process that stopped without cleanup stays alive until its heartbeat
254
+ is older than `processAliveThresholdMilliseconds`. The error gives that time
255
+ for each row. Stop the other process, or wait until that time, and start again.
256
+
257
+ The start check reads the process rows once. It sees another writer only while
258
+ that writer's row is fresh, and an idle single owner does not refresh its row.
259
+ For a guarantee that the operating system enforces, take an exclusive lock on
260
+ the file before the runtime writes to it:
261
+
262
+ ```typescript
263
+ const database = sqlite({ path: "app.sqlite" })
264
+ await database.connection((connection) => connection.run("PRAGMA locking_mode = EXCLUSIVE"))
265
+ ```
266
+
267
+ SQLite then holds the lock from the first write until the database closes. A
268
+ second process, including the `solid-objects` command for the same file, gets
269
+ `database is locked`.
270
+
231
271
  ## Dead letters, retry, and redrive
232
272
 
233
273
  A handler failure that exhausts its attempts becomes a dead letter.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-objects",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Fix race conditions across Node.js processes: ordered operations, expiring holds, and state that survives a restart, in your SQL database. A SQL-backed virtual actor library for TypeScript and Node.js.",
5
5
  "type": "module",
6
6
  "license": "MIT",