@earendil-works/pi-durable 1.3.0 → 1.5.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.
Files changed (257) hide show
  1. package/CHANGELOG.md +227 -0
  2. package/README.md +287 -82
  3. package/dist/codemode/codemode.d.ts +4 -4
  4. package/dist/codemode/codemode.d.ts.map +1 -1
  5. package/dist/codemode/codemode.js +21 -16
  6. package/dist/codemode/codemode.js.map +1 -1
  7. package/dist/codemode/models.d.ts.map +1 -1
  8. package/dist/codemode/models.js +6 -4
  9. package/dist/codemode/models.js.map +1 -1
  10. package/dist/documents.d.ts +1 -1
  11. package/dist/documents.d.ts.map +1 -1
  12. package/dist/documents.js.map +1 -1
  13. package/dist/env/index.d.ts +12 -10
  14. package/dist/env/index.d.ts.map +1 -1
  15. package/dist/env/index.js.map +1 -1
  16. package/dist/env/node-watch.d.ts +3 -3
  17. package/dist/env/node-watch.d.ts.map +1 -1
  18. package/dist/env/node-watch.js +18 -16
  19. package/dist/env/node-watch.js.map +1 -1
  20. package/dist/env/node.d.ts +2 -2
  21. package/dist/env/node.d.ts.map +1 -1
  22. package/dist/env/node.js +12 -4
  23. package/dist/env/node.js.map +1 -1
  24. package/dist/errors.d.ts +18 -2
  25. package/dist/errors.d.ts.map +1 -1
  26. package/dist/errors.js +26 -3
  27. package/dist/errors.js.map +1 -1
  28. package/dist/harness/agent.d.ts +13 -2
  29. package/dist/harness/agent.d.ts.map +1 -1
  30. package/dist/harness/agent.js +48 -6
  31. package/dist/harness/agent.js.map +1 -1
  32. package/dist/harness/compaction.d.ts +3 -1
  33. package/dist/harness/compaction.d.ts.map +1 -1
  34. package/dist/harness/compaction.js +38 -6
  35. package/dist/harness/compaction.js.map +1 -1
  36. package/dist/harness/context.d.ts +23 -7
  37. package/dist/harness/context.d.ts.map +1 -1
  38. package/dist/harness/context.js +71 -25
  39. package/dist/harness/context.js.map +1 -1
  40. package/dist/harness/define.d.ts +7 -3
  41. package/dist/harness/define.d.ts.map +1 -1
  42. package/dist/harness/define.js +4 -0
  43. package/dist/harness/define.js.map +1 -1
  44. package/dist/harness/generation.d.ts +38 -5
  45. package/dist/harness/generation.d.ts.map +1 -1
  46. package/dist/harness/generation.js +497 -108
  47. package/dist/harness/generation.js.map +1 -1
  48. package/dist/harness/harness.d.ts +7 -2
  49. package/dist/harness/harness.d.ts.map +1 -1
  50. package/dist/harness/harness.js +147 -57
  51. package/dist/harness/harness.js.map +1 -1
  52. package/dist/harness/inbox.d.ts +7 -3
  53. package/dist/harness/inbox.d.ts.map +1 -1
  54. package/dist/harness/inbox.js +7 -4
  55. package/dist/harness/inbox.js.map +1 -1
  56. package/dist/harness/json.d.ts +20 -4
  57. package/dist/harness/json.d.ts.map +1 -1
  58. package/dist/harness/json.js +23 -5
  59. package/dist/harness/json.js.map +1 -1
  60. package/dist/harness/live.d.ts +122 -16
  61. package/dist/harness/live.d.ts.map +1 -1
  62. package/dist/harness/live.js +93 -12
  63. package/dist/harness/live.js.map +1 -1
  64. package/dist/harness/partial-changes.d.ts +54 -0
  65. package/dist/harness/partial-changes.d.ts.map +1 -0
  66. package/dist/harness/partial-changes.js +162 -0
  67. package/dist/harness/partial-changes.js.map +1 -0
  68. package/dist/harness/prompt.d.ts +1 -1
  69. package/dist/harness/prompt.d.ts.map +1 -1
  70. package/dist/harness/prompt.js +1 -1
  71. package/dist/harness/prompt.js.map +1 -1
  72. package/dist/harness/registry-reader.d.ts +11 -0
  73. package/dist/harness/registry-reader.d.ts.map +1 -0
  74. package/dist/harness/registry-reader.js +25 -0
  75. package/dist/harness/registry-reader.js.map +1 -0
  76. package/dist/harness/scheduler.d.ts +86 -14
  77. package/dist/harness/scheduler.d.ts.map +1 -1
  78. package/dist/harness/scheduler.js +1459 -369
  79. package/dist/harness/scheduler.js.map +1 -1
  80. package/dist/harness/submissions.d.ts +23 -11
  81. package/dist/harness/submissions.d.ts.map +1 -1
  82. package/dist/harness/submissions.js +104 -36
  83. package/dist/harness/submissions.js.map +1 -1
  84. package/dist/harness/task-graph.d.ts +28 -8
  85. package/dist/harness/task-graph.d.ts.map +1 -1
  86. package/dist/harness/task-graph.js +85 -36
  87. package/dist/harness/task-graph.js.map +1 -1
  88. package/dist/harness/telemetry.d.ts +307 -0
  89. package/dist/harness/telemetry.d.ts.map +1 -0
  90. package/dist/harness/telemetry.js +136 -0
  91. package/dist/harness/telemetry.js.map +1 -0
  92. package/dist/harness/tool.d.ts +2 -0
  93. package/dist/harness/tool.d.ts.map +1 -1
  94. package/dist/harness/tool.js +223 -61
  95. package/dist/harness/tool.js.map +1 -1
  96. package/dist/harness/transcript.d.ts +72 -0
  97. package/dist/harness/transcript.d.ts.map +1 -0
  98. package/dist/harness/transcript.js +264 -0
  99. package/dist/harness/transcript.js.map +1 -0
  100. package/dist/harness/types.d.ts +302 -48
  101. package/dist/harness/types.d.ts.map +1 -1
  102. package/dist/harness/types.js.map +1 -1
  103. package/dist/harness/util.d.ts +7 -1
  104. package/dist/harness/util.d.ts.map +1 -1
  105. package/dist/harness/util.js +13 -0
  106. package/dist/harness/util.js.map +1 -1
  107. package/dist/harness/view.d.ts +43 -22
  108. package/dist/harness/view.d.ts.map +1 -1
  109. package/dist/harness/view.js +130 -71
  110. package/dist/harness/view.js.map +1 -1
  111. package/dist/index.d.ts +13 -9
  112. package/dist/index.d.ts.map +1 -1
  113. package/dist/index.js +7 -5
  114. package/dist/index.js.map +1 -1
  115. package/dist/search.d.ts +19 -3
  116. package/dist/search.d.ts.map +1 -1
  117. package/dist/search.js +107 -44
  118. package/dist/search.js.map +1 -1
  119. package/dist/session/cached-storage.d.ts +71 -0
  120. package/dist/session/cached-storage.d.ts.map +1 -0
  121. package/dist/session/cached-storage.js +269 -0
  122. package/dist/session/cached-storage.js.map +1 -0
  123. package/dist/session/conversation-tails.d.ts +33 -0
  124. package/dist/session/conversation-tails.d.ts.map +1 -0
  125. package/dist/session/conversation-tails.js +101 -0
  126. package/dist/session/conversation-tails.js.map +1 -0
  127. package/dist/session/keys.d.ts +68 -0
  128. package/dist/session/keys.d.ts.map +1 -0
  129. package/dist/session/keys.js +161 -0
  130. package/dist/session/keys.js.map +1 -0
  131. package/dist/session/session.d.ts +181 -29
  132. package/dist/session/session.d.ts.map +1 -1
  133. package/dist/session/session.js +1073 -183
  134. package/dist/session/session.js.map +1 -1
  135. package/dist/session/transaction.d.ts +86 -4
  136. package/dist/session/transaction.d.ts.map +1 -1
  137. package/dist/session/transaction.js +250 -38
  138. package/dist/session/transaction.js.map +1 -1
  139. package/dist/session/writer.d.ts +74 -0
  140. package/dist/session/writer.d.ts.map +1 -0
  141. package/dist/session/writer.js +294 -0
  142. package/dist/session/writer.js.map +1 -0
  143. package/dist/storage/indexeddb.d.ts +68 -0
  144. package/dist/storage/indexeddb.d.ts.map +1 -0
  145. package/dist/storage/indexeddb.js +881 -0
  146. package/dist/storage/indexeddb.js.map +1 -0
  147. package/dist/storage/jsonl/storage.d.ts +30 -2
  148. package/dist/storage/jsonl/storage.d.ts.map +1 -1
  149. package/dist/storage/jsonl/storage.js +88 -24
  150. package/dist/storage/jsonl/storage.js.map +1 -1
  151. package/dist/storage/memory.d.ts +7 -2
  152. package/dist/storage/memory.d.ts.map +1 -1
  153. package/dist/storage/memory.js +29 -3
  154. package/dist/storage/memory.js.map +1 -1
  155. package/dist/storage/sqlite/cloudflare.d.ts +2 -51
  156. package/dist/storage/sqlite/cloudflare.d.ts.map +1 -1
  157. package/dist/storage/sqlite/cloudflare.js +2 -133
  158. package/dist/storage/sqlite/cloudflare.js.map +1 -1
  159. package/dist/storage/sqlite/database.d.ts +1 -36
  160. package/dist/storage/sqlite/database.d.ts.map +1 -1
  161. package/dist/storage/sqlite/database.js.map +1 -1
  162. package/dist/storage/sqlite/index.d.ts +1 -1
  163. package/dist/storage/sqlite/index.d.ts.map +1 -1
  164. package/dist/storage/sqlite/index.js.map +1 -1
  165. package/dist/storage/sqlite/migrations.d.ts +2 -5
  166. package/dist/storage/sqlite/migrations.d.ts.map +1 -1
  167. package/dist/storage/sqlite/migrations.js +28 -28
  168. package/dist/storage/sqlite/migrations.js.map +1 -1
  169. package/dist/storage/sqlite/node.d.ts +2 -37
  170. package/dist/storage/sqlite/node.d.ts.map +1 -1
  171. package/dist/storage/sqlite/node.js +3 -174
  172. package/dist/storage/sqlite/node.js.map +1 -1
  173. package/dist/storage/sqlite/schema.d.ts +1 -3
  174. package/dist/storage/sqlite/schema.d.ts.map +1 -1
  175. package/dist/storage/sqlite/schema.js +2 -9
  176. package/dist/storage/sqlite/schema.js.map +1 -1
  177. package/dist/storage/sqlite/storage.d.ts +15 -3
  178. package/dist/storage/sqlite/storage.d.ts.map +1 -1
  179. package/dist/storage/sqlite/storage.js +110 -36
  180. package/dist/storage/sqlite/storage.js.map +1 -1
  181. package/dist/storage/store/commit.d.ts +33 -0
  182. package/dist/storage/store/commit.d.ts.map +1 -0
  183. package/dist/storage/store/commit.js +286 -0
  184. package/dist/storage/store/commit.js.map +1 -0
  185. package/dist/storage/store/documents.d.ts +43 -0
  186. package/dist/storage/store/documents.d.ts.map +1 -0
  187. package/dist/storage/store/documents.js +102 -0
  188. package/dist/storage/store/documents.js.map +1 -0
  189. package/dist/storage/store/index.d.ts +2 -0
  190. package/dist/storage/store/index.d.ts.map +1 -0
  191. package/dist/storage/store/index.js +2 -0
  192. package/dist/storage/store/index.js.map +1 -0
  193. package/dist/storage/store/queries.d.ts +49 -0
  194. package/dist/storage/store/queries.d.ts.map +1 -0
  195. package/dist/storage/store/queries.js +93 -0
  196. package/dist/storage/store/queries.js.map +1 -0
  197. package/dist/storage/store/storage.d.ts +59 -0
  198. package/dist/storage/store/storage.d.ts.map +1 -0
  199. package/dist/storage/store/storage.js +438 -0
  200. package/dist/storage/store/storage.js.map +1 -0
  201. package/dist/storage/store/tables.d.ts +54 -0
  202. package/dist/storage/store/tables.d.ts.map +1 -0
  203. package/dist/storage/store/tables.js +108 -0
  204. package/dist/storage/store/tables.js.map +1 -0
  205. package/dist/testing/commit-writes.d.ts +5 -0
  206. package/dist/testing/commit-writes.d.ts.map +1 -0
  207. package/dist/testing/commit-writes.js +12 -0
  208. package/dist/testing/commit-writes.js.map +1 -0
  209. package/dist/testing/env-conformance.js +7 -7
  210. package/dist/testing/env-conformance.js.map +1 -1
  211. package/dist/testing/index.d.ts +1 -0
  212. package/dist/testing/index.d.ts.map +1 -1
  213. package/dist/testing/index.js +1 -0
  214. package/dist/testing/index.js.map +1 -1
  215. package/dist/testing/storage-benchmark.d.ts.map +1 -1
  216. package/dist/testing/storage-benchmark.js +18 -17
  217. package/dist/testing/storage-benchmark.js.map +1 -1
  218. package/dist/testing/storage-conformance.d.ts.map +1 -1
  219. package/dist/testing/storage-conformance.js +369 -67
  220. package/dist/testing/storage-conformance.js.map +1 -1
  221. package/dist/timers.d.ts +21 -0
  222. package/dist/timers.d.ts.map +1 -0
  223. package/dist/timers.js +72 -0
  224. package/dist/timers.js.map +1 -0
  225. package/dist/tool-search/tool-search.d.ts +6 -12
  226. package/dist/tool-search/tool-search.d.ts.map +1 -1
  227. package/dist/tool-search/tool-search.js +7 -7
  228. package/dist/tool-search/tool-search.js.map +1 -1
  229. package/dist/tools/bash.d.ts +12 -12
  230. package/dist/tools/bash.d.ts.map +1 -1
  231. package/dist/tools/bash.js +16 -15
  232. package/dist/tools/bash.js.map +1 -1
  233. package/dist/tools/edit.d.ts +7 -7
  234. package/dist/tools/edit.d.ts.map +1 -1
  235. package/dist/tools/edit.js +9 -9
  236. package/dist/tools/edit.js.map +1 -1
  237. package/dist/tools/index.d.ts +32 -32
  238. package/dist/tools/read.d.ts +6 -6
  239. package/dist/tools/read.d.ts.map +1 -1
  240. package/dist/tools/read.js +19 -8
  241. package/dist/tools/read.js.map +1 -1
  242. package/dist/tools/write.d.ts +4 -4
  243. package/dist/tools/write.d.ts.map +1 -1
  244. package/dist/tools/write.js +5 -5
  245. package/dist/tools/write.js.map +1 -1
  246. package/dist/types.d.ts +331 -64
  247. package/dist/types.d.ts.map +1 -1
  248. package/dist/types.js.map +1 -1
  249. package/package.json +27 -10
  250. package/dist/harness/events.d.ts +0 -186
  251. package/dist/harness/events.d.ts.map +0 -1
  252. package/dist/harness/events.js +0 -373
  253. package/dist/harness/events.js.map +0 -1
  254. package/dist/session/observation.d.ts +0 -42
  255. package/dist/session/observation.d.ts.map +0 -1
  256. package/dist/session/observation.js +0 -281
  257. package/dist/session/observation.js.map +0 -1
@@ -3,9 +3,18 @@ import type { Models } from "@earendil-works/pi-ai";
3
3
  import type { ExecutionEnv } from "../env/index.ts";
4
4
  import type { SessionImpl } from "../session/session.ts";
5
5
  import type { Transaction } from "../session/transaction.ts";
6
- import type { ConversationId, Storage, TaskId, TaskOutcome, TaskRecord } from "../types.ts";
7
- import type { Agent, ConversationHandle, HarnessInspection, RegistryReader, RegistrySnapshot, Settings, SettledTask, TaskInspection } from "./types.ts";
6
+ import type { Timers } from "../timers.ts";
7
+ import type { ConversationId, ReportInfo, Storage, StorageWrite, TaskId, TaskOutcome, TaskRecord, TaskState } from "../types.ts";
8
+ import type { Agent, ConversationHandle, HarnessInspection, HarnessOptions, RegistryReader, RegistrySnapshot, Settings, SettledTask, TaskInspection, Wake } from "./types.ts";
8
9
  type AnyTaskRecord = TaskRecord<JsonValue, JsonValue, JsonValue>;
10
+ /** What `blockedReason()` reads of a task: the task graph keeps only this of each record. */
11
+ export type BlockedSubject = Pick<AnyTaskRecord, "id" | "kind" | "version" | "abortRequested" | "abortReason"> & {
12
+ readonly status: TaskState<JsonValue, JsonValue>["status"];
13
+ };
14
+ /** The part of a record `blockedReason()` reads. */
15
+ export declare function blockedSubject(record: AnyTaskRecord): BlockedSubject;
16
+ /** Why a task cannot be reserved: no registered definition can take it. Derived from the registry. */
17
+ export type BlockedReason = "missing_task" | "task_too_old" | "migration_failed";
9
18
  /** Terminal outcomes the scheduler writes without running task code. */
10
19
  export type SchedulerOutcome = Extract<TaskOutcome<JsonValue>, {
11
20
  readonly status: "faulted" | "orphaned";
@@ -16,10 +25,12 @@ export type InvocationBinding = {
16
25
  check(): void;
17
26
  };
18
27
  export type TaskSchedulerOptions = {
28
+ readonly telemetry?: HarnessOptions["telemetry"];
19
29
  readonly session: SessionImpl;
20
30
  readonly storage: Storage;
21
31
  readonly registry: RegistryReader;
22
- readonly models: Models;
32
+ /** The host's current model access (`HarnessOptions.models`); read at each access. */
33
+ readonly models: () => Models;
23
34
  /** Resolve a conversation's agent against a snapshot; the runtime calls it at most once per phase. */
24
35
  readonly agent: (conversationId: ConversationId, snapshot: RegistrySnapshot, context: Context) => Promise<Agent>;
25
36
  /** Resolve the settings; read at each access. */
@@ -27,7 +38,18 @@ export type TaskSchedulerOptions = {
27
38
  /** Build a conversation's environment with `HarnessOptions.env`. */
28
39
  readonly env: (conversationId: ConversationId, context: Context) => Promise<ExecutionEnv | undefined>;
29
40
  readonly now: () => number;
30
- readonly report: (error: unknown) => void;
41
+ /** `HarnessOptions.onWake`: replaces the timer for sleeping tasks. */
42
+ readonly onWake: ((wake: Wake) => void) | undefined;
43
+ /** The host's timers (`HarnessOptions.setTimer`). */
44
+ readonly timers: Timers;
45
+ /** While closing, on the line after admitted commits settle, write what the callback returns straight to Storage. */
46
+ readonly writeAtClose: (writes: () => readonly StorageWrite[]) => Promise<void>;
47
+ readonly report: (error: unknown, info: ReportInfo, context?: Context) => void;
48
+ /**
49
+ * Task kinds whose run phases end the task themselves once it was cut off `settings.restartLimit` times (the
50
+ * built-in tasks, from `TaskRecord.restarts`); the scheduler ends a task of any other kind `faulted` instead.
51
+ */
52
+ readonly limitsRestarts: (kind: string) => boolean;
31
53
  /** Harness cleanup staged in the commit that makes an outcome the scheduler wrote itself terminal. */
32
54
  readonly settleOutcome: (tx: Transaction, record: AnyTaskRecord, outcome: SchedulerOutcome) => Promise<void>;
33
55
  /** Withdraw a conversation's queued inputs, for conversation abort and abort cascades. */
@@ -36,12 +58,18 @@ export type TaskSchedulerOptions = {
36
58
  readonly conversation: (id: ConversationId, binding: InvocationBinding, context: Context) => Promise<ConversationHandle | undefined>;
37
59
  /** Context for scheduler commits and invocations; carries no caller cancellation. */
38
60
  readonly context: Context;
61
+ /**
62
+ * `HarnessOptions.readOnly`: open loads live tasks as committed, `running` ones included, and the scheduler never
63
+ * commits, runs anything, or asks for a wakeup.
64
+ */
65
+ readonly readOnly?: boolean;
39
66
  };
40
67
  /**
41
68
  * Durable task scheduler of one Harness.
42
69
  *
43
- * `#live` mirrors every committed non-terminal task record: pending, running, waiting, and completing. The synchronous
44
- * commit listener updates it on the Session line, so code running on the line reads exactly the committed state from it.
70
+ * `#live` mirrors every committed non-terminal task record: pending, running, waiting, sleeping, and completing. The
71
+ * synchronous commit listener updates it on the Session line, so code running on the line reads exactly the committed
72
+ * state from it.
45
73
  *
46
74
  * Tasks and conversations form one ownership tree (spec §5.5): a task's parent is its owner task, or its conversation;
47
75
  * a conversation's parent is its owner task, if any. Walks up that tree decide what reaches one task: a cancelling
@@ -54,20 +82,47 @@ export type TaskSchedulerOptions = {
54
82
  * later below a dropped node finds it unknown and loads its chain from storage again.
55
83
  *
56
84
  * Invariant: every task transition is decided and written by one callback serialized on the Session line. That covers
57
- * reservation, marks, runtime commits, finalization, and the synchronous step before each phase, which applies the
58
- * precedence rules and writes a fault or handover. Handlers and joins run off the line. An invocation ends inside the
59
- * step that decides its end, so a runtime commit it queued either lands before that decision or is rejected.
85
+ * reservation, marks, runtime commits, finalization, and the step before each phase, which applies the precedence rules
86
+ * and writes a fault or handover. Handlers and joins run off the line. An invocation ends inside the step that decides
87
+ * its end, so a runtime commit it queued either lands before that decision or is rejected.
88
+ *
89
+ * Decisions stay serialized; their storage overlaps (group commit). The Session stores the commits of several jobs in
90
+ * one call while the line runs on, and this memory changes only as each commit is published. So every decision reads
91
+ * it in a decision region (`#region()`): synchronous, recording the keys it reads (a task's record, the live work below
92
+ * a node, the cancellation intent set), staging nothing; when one of them has an unpublished writer, the region waits
93
+ * for its publication and runs again, and only a region that read nothing unpublished is applied. Every commit writes
94
+ * the memberships its task changes alter (`membershipKeys()`), so a walk that a pending commit would change waits.
60
95
  */
61
96
  export declare class TaskScheduler {
62
97
  #private;
63
98
  constructor(options: TaskSchedulerOptions);
64
- /** Load live tasks and change surviving `running` tasks back to `pending`. Dispatches nothing. */
99
+ /**
100
+ * Load live tasks and change surviving `running` tasks back to `pending`, counting the restart. Dispatches nothing;
101
+ * a task cut off `settings.restartLimit` times ends when it is next reserved. Read-only, it only loads them: a
102
+ * `running` task stays as committed, running in another process.
103
+ */
65
104
  open(context: Context): Promise<void>;
66
- /** Enable scheduling. Idempotent; the kick does nothing once closing. */
105
+ /**
106
+ * Enable scheduling, and make sleeping tasks that are due runnable: a host wakeup, such as an alarm, calls this.
107
+ * Idempotent; the kick does nothing once closing.
108
+ */
67
109
  resume(): void;
68
110
  /**
69
- * Signal every invocation and wait for them; writes nothing. Close calls this after every close listener has run, so
70
- * waits, watches, and streams a task holds end with the Session's reason, not as cancelled by its signal.
111
+ * Why a live task cannot run here, if it cannot: its definition is missing, too old, or failed to migrate. A running
112
+ * task, an abort-marked one, and one holding its outcome are never blocked.
113
+ */
114
+ blockedReason(record: BlockedSubject): BlockedReason | undefined;
115
+ /** Call `listener` when blocked reasons may have changed without a commit: a registry change or a failed migration. */
116
+ subscribeBlocked(listener: () => void): () => void;
117
+ /**
118
+ * When the Session next needs a process: `active` while some task can run now or is running, `at` for the earliest
119
+ * sleep not yet due. Synchronous, from memory; a task whose chain is not loaded yet counts as it would alone.
120
+ */
121
+ wake(): Wake;
122
+ /**
123
+ * Signal every invocation and wait for them, then write the tasks they ran back as `pending` (`writeAtClose`), as a
124
+ * close is not a crash. Close calls this after every close listener has run, so waits, watches, and streams a task
125
+ * holds end with the Session's reason, not as cancelled by its signal.
71
126
  */
72
127
  join(): Promise<void>;
73
128
  /**
@@ -90,8 +145,23 @@ export declare class TaskScheduler {
90
145
  * crosses background boundaries, and the wait also covers every task it reached.
91
146
  */
92
147
  abortConversation(conversationId: ConversationId, background: boolean, context: Context): Promise<void>;
148
+ /**
149
+ * The ownership memberships a commit's task and conversation changes write (group commit §4.2), at its admission on
150
+ * the line: for each task created or made terminal, every node from its parent up to and including the nearest live
151
+ * task, or the root conversation, and then the roots too, conservatively, as a pending end may unlist the root a
152
+ * creation finds listed; for each conversation created under a task, that task; and the intent set when
153
+ * a change sets, upgrades, or clears a mark or a held or ended outcome other than `completed`. Loads the chains it
154
+ * walks; the nodes it installs stay until the commit is published.
155
+ */
156
+ membershipKeys(tx: Transaction): readonly string[] | Promise<readonly string[]>;
93
157
  /** Sizes of the ownership indexes, for tests that bound the scheduler's memory. */
94
- get indexSizes(): Readonly<Record<"live" | "settled" | "edges" | "below" | "roots" | "unloaded" | "dropQueue", number>>;
158
+ get indexSizes(): Readonly<Record<"live" | "settled" | "edges" | "below" | "roots" | "unloaded" | "dropQueue" | "pins", number>>;
159
+ /**
160
+ * The kept contexts' idle state, for tests (a diagnostic, computed on demand): how many are kept and how many are
161
+ * idle, how many disagree with a full recompute (an idle period without `#idle()`, or `#idle()` without one; an
162
+ * expiry order that differs from the idle periods, or is not sorted), and how many idle checks covered every scope.
163
+ */
164
+ get idleState(): Readonly<Record<"contexts" | "idleContexts" | "idleMismatches" | "fullIdleChecks", number>>;
95
165
  /**
96
166
  * Scheduling state and every live task with its derived state, read on the Session line. Runs no task code: a
97
167
  * pending migration shows as `ready` with `migrates`, and only a migration the scheduler already tried, or one that
@@ -102,5 +172,7 @@ export declare class TaskScheduler {
102
172
  tasks: TaskInspection[];
103
173
  }>;
104
174
  }
175
+ /** `state`, marked as ending its task for crashes (`task_interrupted` with `message`), whatever its outcome. */
176
+ export declare function endedByCrashes<T extends object>(state: T, message: string): T;
105
177
  export {};
106
178
  //# sourceMappingURL=scheduler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../../src/harness/scheduler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC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