@earendil-works/pi-durable 1.5.0 → 1.5.1
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 +18 -0
- package/README.md +17 -4
- package/dist/codemode/codemode.d.ts +2 -1
- package/dist/codemode/codemode.d.ts.map +1 -1
- package/dist/codemode/codemode.js +1 -37
- package/dist/codemode/codemode.js.map +1 -1
- package/dist/codemode/models.d.ts +2 -1
- package/dist/codemode/models.d.ts.map +1 -1
- package/dist/codemode/models.js.map +1 -1
- package/dist/documents.d.ts +1 -1
- package/dist/documents.d.ts.map +1 -1
- package/dist/documents.js +1 -1
- package/dist/documents.js.map +1 -1
- package/dist/entries.d.ts +1 -1
- package/dist/entries.d.ts.map +1 -1
- package/dist/entries.js.map +1 -1
- package/dist/env/index.d.ts +1 -1
- package/dist/env/index.d.ts.map +1 -1
- package/dist/env/index.js.map +1 -1
- package/dist/env/node-watch.d.ts +1 -1
- package/dist/env/node-watch.d.ts.map +1 -1
- package/dist/env/node-watch.js.map +1 -1
- package/dist/env/node.d.ts +1 -1
- package/dist/env/node.d.ts.map +1 -1
- package/dist/env/node.js.map +1 -1
- package/dist/harness/agent.d.ts.map +1 -1
- package/dist/harness/agent.js +27 -1
- package/dist/harness/agent.js.map +1 -1
- package/dist/harness/compaction.d.ts +8 -3
- package/dist/harness/compaction.d.ts.map +1 -1
- package/dist/harness/compaction.js +21 -9
- package/dist/harness/compaction.js.map +1 -1
- package/dist/harness/context.d.ts +1 -1
- package/dist/harness/context.d.ts.map +1 -1
- package/dist/harness/context.js.map +1 -1
- package/dist/harness/define.d.ts +1 -1
- package/dist/harness/define.d.ts.map +1 -1
- package/dist/harness/define.js.map +1 -1
- package/dist/harness/generation.d.ts +1 -1
- package/dist/harness/generation.d.ts.map +1 -1
- package/dist/harness/generation.js +6 -4
- package/dist/harness/generation.js.map +1 -1
- package/dist/harness/harness.d.ts +1 -1
- package/dist/harness/harness.d.ts.map +1 -1
- package/dist/harness/harness.js.map +1 -1
- package/dist/harness/inbox.d.ts +2 -1
- package/dist/harness/inbox.d.ts.map +1 -1
- package/dist/harness/inbox.js +1 -1
- package/dist/harness/inbox.js.map +1 -1
- package/dist/harness/json.d.ts +1 -1
- package/dist/harness/json.d.ts.map +1 -1
- package/dist/harness/json.js.map +1 -1
- package/dist/harness/live.d.ts +2 -1
- package/dist/harness/live.d.ts.map +1 -1
- package/dist/harness/live.js.map +1 -1
- package/dist/harness/partial-changes.d.ts +1 -1
- package/dist/harness/partial-changes.d.ts.map +1 -1
- package/dist/harness/partial-changes.js +1 -0
- package/dist/harness/partial-changes.js.map +1 -1
- package/dist/harness/prompt.d.ts +1 -1
- package/dist/harness/prompt.d.ts.map +1 -1
- package/dist/harness/prompt.js.map +1 -1
- package/dist/harness/provider.d.ts +1 -1
- package/dist/harness/provider.d.ts.map +1 -1
- package/dist/harness/provider.js.map +1 -1
- package/dist/harness/registry-reader.d.ts +1 -1
- package/dist/harness/registry-reader.d.ts.map +1 -1
- package/dist/harness/registry-reader.js.map +1 -1
- package/dist/harness/scheduler.d.ts +2 -1
- package/dist/harness/scheduler.d.ts.map +1 -1
- package/dist/harness/scheduler.js +42 -13
- package/dist/harness/scheduler.js.map +1 -1
- package/dist/harness/submissions.d.ts +1 -1
- package/dist/harness/submissions.d.ts.map +1 -1
- package/dist/harness/submissions.js +1 -1
- package/dist/harness/submissions.js.map +1 -1
- package/dist/harness/task-graph.d.ts +3 -1
- package/dist/harness/task-graph.d.ts.map +1 -1
- package/dist/harness/task-graph.js +1 -1
- package/dist/harness/task-graph.js.map +1 -1
- package/dist/harness/tool.d.ts +1 -1
- package/dist/harness/tool.d.ts.map +1 -1
- package/dist/harness/tool.js +1 -1
- package/dist/harness/tool.js.map +1 -1
- package/dist/harness/transcript.d.ts +1 -1
- package/dist/harness/transcript.d.ts.map +1 -1
- package/dist/harness/transcript.js.map +1 -1
- package/dist/harness/types.d.ts +21 -4
- package/dist/harness/types.d.ts.map +1 -1
- package/dist/harness/types.js.map +1 -1
- package/dist/harness/usage.d.ts +2 -1
- package/dist/harness/usage.d.ts.map +1 -1
- package/dist/harness/usage.js +1 -1
- package/dist/harness/usage.js.map +1 -1
- package/dist/harness/util.d.ts +1 -1
- package/dist/harness/util.d.ts.map +1 -1
- package/dist/harness/util.js.map +1 -1
- package/dist/harness/view.d.ts +2 -1
- package/dist/harness/view.d.ts.map +1 -1
- package/dist/harness/view.js +1 -1
- package/dist/harness/view.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/session/cached-storage.d.ts +2 -1
- package/dist/session/cached-storage.d.ts.map +1 -1
- package/dist/session/cached-storage.js.map +1 -1
- package/dist/session/forks.d.ts +1 -1
- package/dist/session/forks.d.ts.map +1 -1
- package/dist/session/forks.js.map +1 -1
- package/dist/session/keys.d.ts +2 -1
- package/dist/session/keys.d.ts.map +1 -1
- package/dist/session/keys.js.map +1 -1
- package/dist/session/session.d.ts +3 -1
- package/dist/session/session.d.ts.map +1 -1
- package/dist/session/session.js +1 -1
- package/dist/session/session.js.map +1 -1
- package/dist/session/transaction.d.ts +4 -3
- package/dist/session/transaction.d.ts.map +1 -1
- package/dist/session/transaction.js +3 -3
- package/dist/session/transaction.js.map +1 -1
- package/dist/session/writer.d.ts +1 -1
- package/dist/session/writer.d.ts.map +1 -1
- package/dist/session/writer.js.map +1 -1
- package/dist/storage/indexeddb.d.ts +2 -1
- package/dist/storage/indexeddb.d.ts.map +1 -1
- package/dist/storage/indexeddb.js.map +1 -1
- package/dist/storage/jsonl/index.d.ts +1 -1
- package/dist/storage/jsonl/index.d.ts.map +1 -1
- package/dist/storage/jsonl/index.js +1 -1
- package/dist/storage/jsonl/index.js.map +1 -1
- package/dist/storage/jsonl/node.d.ts +3 -3
- package/dist/storage/jsonl/node.d.ts.map +1 -1
- package/dist/storage/jsonl/node.js +2 -2
- package/dist/storage/jsonl/node.js.map +1 -1
- package/dist/storage/jsonl/storage.d.ts +32 -3
- package/dist/storage/jsonl/storage.d.ts.map +1 -1
- package/dist/storage/jsonl/storage.js +70 -19
- package/dist/storage/jsonl/storage.js.map +1 -1
- package/dist/storage/memory.d.ts +2 -1
- package/dist/storage/memory.d.ts.map +1 -1
- package/dist/storage/memory.js.map +1 -1
- package/dist/storage/sqlite/commit.d.ts +52 -0
- package/dist/storage/sqlite/commit.d.ts.map +1 -0
- package/dist/storage/sqlite/commit.js +371 -0
- package/dist/storage/sqlite/commit.js.map +1 -0
- package/dist/storage/sqlite/rows.d.ts +33 -0
- package/dist/storage/sqlite/rows.d.ts.map +1 -0
- package/dist/storage/sqlite/rows.js +53 -0
- package/dist/storage/sqlite/rows.js.map +1 -0
- package/dist/storage/sqlite/statements.d.ts +13 -0
- package/dist/storage/sqlite/statements.d.ts.map +1 -0
- package/dist/storage/sqlite/statements.js +88 -0
- package/dist/storage/sqlite/statements.js.map +1 -0
- package/dist/storage/sqlite/storage.d.ts +12 -11
- package/dist/storage/sqlite/storage.d.ts.map +1 -1
- package/dist/storage/sqlite/storage.js +44 -259
- package/dist/storage/sqlite/storage.js.map +1 -1
- package/dist/storage/store/commit.d.ts +2 -2
- package/dist/storage/store/commit.d.ts.map +1 -1
- package/dist/storage/store/commit.js +1 -1
- package/dist/storage/store/commit.js.map +1 -1
- package/dist/storage/store/documents.d.ts +1 -1
- package/dist/storage/store/documents.d.ts.map +1 -1
- package/dist/storage/store/documents.js +1 -1
- package/dist/storage/store/documents.js.map +1 -1
- package/dist/storage/store/queries.d.ts +2 -2
- package/dist/storage/store/queries.d.ts.map +1 -1
- package/dist/storage/store/queries.js.map +1 -1
- package/dist/storage/store/storage.d.ts +3 -2
- package/dist/storage/store/storage.d.ts.map +1 -1
- package/dist/storage/store/storage.js +1 -1
- package/dist/storage/store/storage.js.map +1 -1
- package/dist/storage/store/tables.d.ts +31 -31
- package/dist/storage/store/tables.d.ts.map +1 -1
- package/dist/storage/store/tables.js +1 -1
- package/dist/storage/store/tables.js.map +1 -1
- package/dist/testing/commit-writes.d.ts +1 -1
- package/dist/testing/commit-writes.d.ts.map +1 -1
- package/dist/testing/commit-writes.js.map +1 -1
- package/dist/testing/env-conformance.js.map +1 -1
- package/dist/testing/storage-benchmark.js.map +1 -1
- package/dist/testing/storage-conformance.js.map +1 -1
- package/dist/tool-search/tool-search.d.ts +2 -2
- package/dist/tool-search/tool-search.d.ts.map +1 -1
- package/dist/tool-search/tool-search.js +18 -6
- package/dist/tool-search/tool-search.js.map +1 -1
- package/dist/tools/bash.d.ts +1 -1
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js.map +1 -1
- package/dist/tools/file-mutation-queue.d.ts +1 -1
- package/dist/tools/file-mutation-queue.d.ts.map +1 -1
- package/dist/tools/file-mutation-queue.js.map +1 -1
- package/dist/tools/path-utils.d.ts +1 -1
- package/dist/tools/path-utils.d.ts.map +1 -1
- package/dist/tools/path-utils.js.map +1 -1
- package/dist/tools/read.js.map +1 -1
- package/dist/types.d.ts +6 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../../src/harness/scheduler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,QAAQ,EAAkB,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACrH,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEzD,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,GAEtB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,UAAU,EAAE,QAAQ,EAAE,SAA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MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAC5D,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC3F,CAAC","sourcesContent":["import { type Context, copyJson, type JsonValue } from \"@earendil-works/chord\";\nimport { awaitWithContext, withAbortSignal, withoutAbortSignal, withTelemetry } from \"@earendil-works/chord/context\";\nimport { ownedSlice } from \"@earendil-works/chord/delta\";\nimport type { Models } from \"@earendil-works/pi-ai\";\nimport {\n\tcreateTypedMetrics,\n\tcreateTypedSpanStarter,\n\tNOOP_TELEMETRY_CONTEXT,\n\tNOOP_TELEMETRY_METRICS,\n\ttype TelemetryCarrier,\n} from \"@earendil-works/pi-telemetry\";\nimport type { ExecutionEnv } from \"../env/index.ts\";\nimport { errorMessage, ReadOnlySession } from \"../errors.ts\";\nimport { ALL_KEYS, conversationKey, INTENT_KEY, ownedKey, ROOTS_KEY, taskKey } from \"../session/keys.ts\";\nimport type { ObservedCommit, SessionImpl } from \"../session/session.ts\";\nimport type { Transaction } from \"../session/transaction.ts\";\nimport type { Timers } from \"../timers.ts\";\nimport type {\n\tCommitOptions,\n\tConversationId,\n\tConversationRecord,\n\tDocumentWatch,\n\tEntryId,\n\tEntryRecord,\n\tHookRunner,\n\tJsonObject,\n\tNextTaskState,\n\tReportInfo,\n\tReportTask,\n\tRunningTask,\n\tStorage,\n\tStorageWrite,\n\tTaskDefinition,\n\tTaskId,\n\tTaskOutcome,\n\tTaskOutcomeError,\n\tTaskRecord,\n\tTaskRuntime,\n\tTaskState,\n} from \"../types.ts\";\nimport { agentHooks, DEFAULT_RESTART_LIMIT } from \"./agent.ts\";\nimport { advanceRange, type ContextRange, rangeEntry, readContextFrom } from \"./context.ts\";\nimport { DURABLE_TELEMETRY_SCHEMA } from \"./telemetry.ts\";\nimport type {\n\tAgent,\n\tAnyTask,\n\tConversationHandle,\n\tHarnessInspection,\n\tHarnessOptions,\n\tRegistryReader,\n\tRegistrySnapshot,\n\tSettings,\n\tSettledTask,\n\tTaskInspection,\n\tWake,\n} from \"./types.ts\";\nimport { closedError, conversationEntries, optionalExtension, scanAll, Waiters } from \"./util.ts\";\n\ntype AnyTaskRecord = TaskRecord<JsonValue, JsonValue, JsonValue>;\n/** A record that can still run code: pending, running, waiting, or sleeping. */\ntype RunnableTaskRecord = Extract<\n\tAnyTaskRecord,\n\t{ readonly state: { readonly status: \"pending\" | \"running\" | \"waiting\" | \"sleeping\" } }\n>;\ntype Checkpoint = { readonly phase: string; readonly attempt?: number };\ntype ErasedDefinition = TaskDefinition<JsonValue, Checkpoint, JsonValue, object>;\ntype ErasedRuntime = TaskRuntime<JsonValue, Checkpoint, JsonValue, object>;\ntype ErasedRunningTask = RunningTask<JsonValue, Checkpoint, JsonValue>;\n\nconst SCAN_PAGE_SIZE = 256;\nconst NO_KEYS: readonly string[] = [];\nconst LIVE_STATUSES = [\"pending\", \"running\", \"waiting\", \"sleeping\", \"completing\"] as const;\n\n/** What `blockedReason()` reads of a task: the task graph keeps only this of each record. */\nexport type BlockedSubject = Pick<AnyTaskRecord, \"id\" | \"kind\" | \"version\" | \"abortRequested\" | \"abortReason\"> & {\n\treadonly status: TaskState<JsonValue, JsonValue>[\"status\"];\n};\n\n/** The part of a record `blockedReason()` reads. */\nexport function blockedSubject(record: AnyTaskRecord): BlockedSubject {\n\treturn {\n\t\tid: record.id,\n\t\tkind: record.kind,\n\t\tversion: record.version,\n\t\tabortRequested: record.abortRequested,\n\t\t...(record.abortReason === undefined ? {} : { abortReason: record.abortReason }),\n\t\tstatus: record.state.status,\n\t};\n}\n\n/** Why a task cannot be reserved: no registered definition can take it. Derived from the registry. */\nexport type BlockedReason = \"missing_task\" | \"task_too_old\" | \"migration_failed\";\n\ntype Resolution =\n\t| { readonly kind: \"ready\"; readonly task: AnyTask; readonly record: RunnableTaskRecord }\n\t| { readonly kind: \"blocked\"; readonly reason: BlockedReason };\n\n/** A definition that can take a record, or why none can; deciding it runs no task code. */\ntype Fit =\n\t| { readonly task: AnyTask; readonly migrates: boolean }\n\t| { readonly reason: BlockedReason; readonly error?: unknown };\n\n/** One in-memory execution of a task in run or abort mode. */\ntype Invocation = {\n\treadonly taskId: TaskId;\n\treadonly kind: string;\n\t/** The extension that installed the definition this invocation runs, as of its reservation; none for a built-in. */\n\treadonly extension: string | undefined;\n\treadonly conversationId: ConversationId;\n\treadonly mode: \"run\" | \"abort\";\n\treadonly controller: AbortController;\n\tlinks?: readonly TelemetryCarrier[];\n\t/** Context passed to handlers; cancelled by `controller`. */\n\tcontext: Context;\n\t/** Keeps the terminal state available after it leaves the live index. Released when the invocation finishes. */\n\trecord?: TaskRecord<JsonValue, Checkpoint, JsonValue>;\n\tfault?: Extract<TaskOutcome<JsonValue>, { readonly status: \"faulted\" }>;\n\t/** Watches acquired through the runtime; stopped at invocation end. */\n\treadonly watches: Set<DocumentWatch<JsonObject>>;\n\t/** Timers armed through the runtime; disarmed at invocation end. */\n\treadonly timers: Set<() => void>;\n\tended: boolean;\n\treadonly done: Promise<void>;\n\treadonly finish: () => void;\n};\n\n/** What a runtime reads for the phase handler it serves: the phase's snapshot and task, and its lazily resolved agent. */\ntype Phase = {\n\treadonly snapshot: () => RegistrySnapshot;\n\treadonly task: () => AnyTask;\n\tagent: Promise<Agent> | undefined;\n};\n\ntype Reservation = {\n\treadonly invocation: Invocation;\n\treadonly task: AnyTask;\n\treadonly snapshot: RegistrySnapshot;\n};\n\n/** Replacement definition already reported as unable to take over, per invocation. */\ntype ReportedTask = { readonly task: AnyTask | undefined } | undefined;\n\n/** Outcome of the phase that just returned, judged by the next step. */\ntype PhaseResult = { readonly checkpoint: Checkpoint; readonly failure?: { readonly error: unknown } };\n\n/**\n * Step decision, made in a decision region: continue with the next phase, end the invocation, or end it by writing\n * `faulted`.\n */\ntype StepPlan =\n\t| { readonly kind: \"continue\" | \"progress\" | \"end\" | \"cascade\" }\n\t| { readonly kind: \"fault\"; readonly error: unknown };\n\n/** Continue with the next phase, the first one. */\nconst CONTINUE: StepPlan = { kind: \"continue\" };\n/** Rule 5: the phase made durable progress; `#progress()` decides once the decision stands. */\nconst PROGRESS: StepPlan = { kind: \"progress\" };\n/** End the invocation without a write. */\nconst END: StepPlan = { kind: \"end\" };\n/** End it: an owner's cancellation intent reaches it before its cascade did; schedule the cascade. */\nconst CASCADE: StepPlan = { kind: \"cascade\" };\n\n/** Terminal outcomes the scheduler writes without running task code. */\nexport type SchedulerOutcome = Extract<TaskOutcome<JsonValue>, { readonly status: \"faulted\" | \"orphaned\" }>;\n\n/** An invocation a conversation handle is bound to: its signal, and a check that throws once it ended. */\nexport type InvocationBinding = { readonly signal: AbortSignal; check(): void };\n\n/** The immutable ownership fields of a task. */\ntype TaskNode = Pick<AnyTaskRecord, \"conversationId\" | \"owner\" | \"background\">;\n\n/** Where a walk up the ownership tree continues: an owner task, or a conversation. */\ntype Up = { readonly task: TaskId } | { readonly conversation: ConversationId };\n\n/** One step of a walk up: an owner task with its node, a conversation, or an owner edge that is not loaded yet. */\ntype Step =\n\t| { readonly task: TaskId; readonly node: TaskNode }\n\t| { readonly conversation: ConversationId }\n\t| { readonly unknown: true };\n\n/** Candidate records a commit staged; they override committed records in ownership walks. */\ntype Overlay = {\n\treadonly tasks: ReadonlyMap<TaskId, AnyTaskRecord>;\n\treadonly edges: ReadonlyMap<ConversationId, TaskId | null>;\n\t/** Links to the staged tasks `#below` does not list, by parent node, for walks down; built at first use. */\n\tlinks?: ReadonlyMap<Node, ReadonlySet<Node>>;\n};\n\n/** Tasks a finalize pass has made terminal in its commit so far. */\ntype Finalized = { has(id: TaskId): boolean };\n\n/** A node of the downward index: a task, or a conversation as `c<id>`. */\ntype Node = TaskId | `c${number}`;\n\nfunction conversationNode(id: ConversationId): Node {\n\treturn `c${id}`;\n}\n\nfunction conversationOf(node: `c${number}`): ConversationId {\n\treturn Number(node.slice(1)) as ConversationId;\n}\n\n/** The node a task hangs from: its owner task, or its conversation. */\nfunction parentNode(node: TaskNode): Node {\n\treturn node.owner ?? conversationNode(node.conversationId);\n}\n\n/** Where ordinary ownership traversal starts: one conversation, or every ownerless conversation. */\ntype Scope = { readonly conversation: ConversationId } | { readonly roots: true };\n\nexport type TaskSchedulerOptions = {\n\treadonly telemetry?: HarnessOptions[\"telemetry\"];\n\treadonly session: SessionImpl;\n\treadonly storage: Storage;\n\treadonly registry: RegistryReader;\n\t/** The host's current model access (`HarnessOptions.models`); read at each access. */\n\treadonly models: () => Models;\n\t/** Resolve a conversation's agent against a snapshot; the runtime calls it at most once per phase. */\n\treadonly agent: (conversationId: ConversationId, snapshot: RegistrySnapshot, context: Context) => Promise<Agent>;\n\t/** Resolve the settings; read at each access. */\n\treadonly settings: () => Settings;\n\t/** Build a conversation's environment with `HarnessOptions.env`. */\n\treadonly env: (conversationId: ConversationId, context: Context) => Promise<ExecutionEnv | undefined>;\n\treadonly now: () => number;\n\t/** `HarnessOptions.onWake`: replaces the timer for sleeping tasks. */\n\treadonly onWake: ((wake: Wake) => void) | undefined;\n\t/** The host's timers (`HarnessOptions.setTimer`). */\n\treadonly timers: Timers;\n\t/** While closing, on the line after admitted commits settle, write what the callback returns straight to Storage. */\n\treadonly writeAtClose: (writes: () => readonly StorageWrite[]) => Promise<void>;\n\treadonly report: (error: unknown, info: ReportInfo, context?: Context) => void;\n\t/**\n\t * Task kinds whose run phases end the task themselves once it was cut off `settings.restartLimit` times (the\n\t * built-in tasks, from `TaskRecord.restarts`); the scheduler ends a task of any other kind `faulted` instead.\n\t */\n\treadonly limitsRestarts: (kind: string) => boolean;\n\t/** Harness cleanup staged in the commit that makes an outcome the scheduler wrote itself terminal. */\n\treadonly settleOutcome: (tx: Transaction, record: AnyTaskRecord, outcome: SchedulerOutcome) => Promise<void>;\n\t/** Withdraw a conversation's queued inputs, for conversation abort and abort cascades. */\n\treadonly withdrawInputs: (tx: Transaction, conversationId: ConversationId) => Promise<void>;\n\t/** Invocation-bound handle of an existing conversation, for task runtimes and tools. */\n\treadonly conversation: (\n\t\tid: ConversationId,\n\t\tbinding: InvocationBinding,\n\t\tcontext: Context,\n\t) => Promise<ConversationHandle | undefined>;\n\t/** Context for scheduler commits and invocations; carries no caller cancellation. */\n\treadonly context: Context;\n\t/**\n\t * `HarnessOptions.readOnly`: open loads live tasks as committed, `running` ones included, and the scheduler never\n\t * commits, runs anything, or asks for a wakeup.\n\t */\n\treadonly readOnly?: boolean;\n};\n\n/**\n * Durable task scheduler of one Harness.\n *\n * `#live` mirrors every committed non-terminal task record: pending, running, waiting, sleeping, and completing. The\n * synchronous commit listener updates it on the Session line, so code running on the line reads exactly the committed\n * state from it.\n *\n * Tasks and conversations form one ownership tree (spec §5.5): a task's parent is its owner task, or its conversation;\n * a conversation's parent is its owner task, if any. Walks up that tree decide what reaches one task: a cancelling\n * owner, a scope. `#below` lists the tree downward around live work, so what lies below one node is a walk down from\n * it: a task's live ordinary owned work, which holds its outcome as `completing` and delays its abort handler, a\n * scope's tasks, a cascade's reach. No pass visits every live task; the sets below hold each pass's candidates.\n *\n * The ownership indexes are bounded by live work: an owner edge and an ended task's ownership fields are kept only while\n * something is listed below them in `#below`, so only the chains above live tasks are known, whole. Work that appears\n * later below a dropped node finds it unknown and loads its chain from storage again.\n *\n * Invariant: every task transition is decided and written by one callback serialized on the Session line. That covers\n * reservation, marks, runtime commits, finalization, and the step before each phase, which applies the precedence rules\n * and writes a fault or handover. Handlers and joins run off the line. An invocation ends inside the step that decides\n * its end, so a runtime commit it queued either lands before that decision or is rejected.\n *\n * Decisions stay serialized; their storage overlaps (group commit). The Session stores the commits of several jobs in\n * one call while the line runs on, and this memory changes only as each commit is published. So every decision reads\n * it in a decision region (`#region()`): synchronous, recording the keys it reads (a task's record, the live work below\n * a node, the cancellation intent set), staging nothing; when one of them has an unpublished writer, the region waits\n * for its publication and runs again, and only a region that read nothing unpublished is applied. Every commit writes\n * the memberships its task changes alter (`membershipKeys()`), so a walk that a pending commit would change waits.\n */\nexport class TaskScheduler {\n\treadonly #telemetry: NonNullable<HarnessOptions[\"telemetry\"]>;\n\treadonly #activeMetric;\n\treadonly #durationMetric;\n\treadonly #resumed = new Set<TaskId>();\n\treadonly #session: SessionImpl;\n\treadonly #storage: Storage;\n\treadonly #registry: RegistryReader;\n\treadonly #models: () => Models;\n\treadonly #agent: TaskSchedulerOptions[\"agent\"];\n\treadonly #settings: TaskSchedulerOptions[\"settings\"];\n\treadonly #env: TaskSchedulerOptions[\"env\"];\n\treadonly #now: () => number;\n\treadonly #onWake: ((wake: Wake) => void) | undefined;\n\treadonly #timers: Timers;\n\treadonly #writeAtClose: (writes: () => readonly StorageWrite[]) => Promise<void>;\n\treadonly #report: (error: unknown, info: ReportInfo, context?: Context) => void;\n\treadonly #settleOutcome: TaskSchedulerOptions[\"settleOutcome\"];\n\treadonly #limitsRestarts: TaskSchedulerOptions[\"limitsRestarts\"];\n\treadonly #withdrawInputs: TaskSchedulerOptions[\"withdrawInputs\"];\n\treadonly #conversation: TaskSchedulerOptions[\"conversation\"];\n\treadonly #context: Context;\n\treadonly #live = new Map<TaskId, AnyTaskRecord>();\n\t/**\n\t * Context range last read through a task runtime, per conversation: a later read, by any of its tasks, scans only\n\t * newer entries. `idleSince` is the Harness time it was first seen idle. Derived and never persisted; dropped at the\n\t * first idle check after `settings.contextRetentionMs` of idleness, and at close.\n\t */\n\treadonly #contexts = new Map<\n\t\tConversationId,\n\t\t{ range: ContextRange; idleSince: number | undefined; expiresAt?: number }\n\t>();\n\t/**\n\t * The idle kept contexts by `idleSince`, oldest first: the expiry order, so neither an expiry nor finding the next one\n\t * scans `#contexts`. Kept sorted also when the Harness clock goes back (see `#markIdle`).\n\t */\n\treadonly #idleOrder = new Map<ConversationId, number>();\n\t/** At least the newest `idleSince` in `#idleOrder` (drops do not lower it): an older one added means the clock went back. */\n\t#idleNewest = Number.NEGATIVE_INFINITY;\n\t/**\n\t * A chain load resolved what `#idle()` treats as unknown for a live task whose chain is not loaded, which can make a\n\t * scope idle without a task change below it; the next idle check then covers every scope.\n\t */\n\t#unknownsChanged = false;\n\t/** Idle checks that covered every scope (`idleState`, a test diagnostic). */\n\t#fullIdleChecks = 0;\n\t/** Background timer for the earliest expiry of an idle context, unless the host declined it (see `#scheduleExpiry`). */\n\t#expiry: { readonly at: number; readonly disarm: () => void } | undefined;\n\treadonly #invocations = new Map<TaskId, Invocation>();\n\treadonly #taskWaiters = new Waiters<TaskId, SettledTask<JsonValue>>();\n\t/** Idle waiters by conversation; `undefined` waits for the whole Harness. */\n\treadonly #idleWaiters = new Waiters<ConversationId | undefined, void>();\n\t/** Definition whose migration failed per task; retried only once the registry resolves another definition. */\n\treadonly #failedMigrations = new Map<TaskId, { readonly task: AnyTask; readonly error: unknown }>();\n\t/** Owner task of each known conversation, `null` when ownerless. */\n\treadonly #edges = new Map<ConversationId, TaskId | null>();\n\t/** Ownership fields of the known terminal tasks, which walks pass through. */\n\treadonly #settled = new Map<TaskId, TaskNode>();\n\t/**\n\t * Ended tasks and conversations found unneeded, dropped by `#sweep()` at the end of the commit's publication unless\n\t * needed again by then: a chain load installs nodes before the work below them is listed.\n\t */\n\treadonly #dropQueue = new Set<Node>();\n\t/**\n\t * The tree downward around live work: each node's child nodes that are live tasks or have nodes listed below them.\n\t * A conversation's parent is its owner task; ownerless ones with work are in `#roots`.\n\t */\n\treadonly #below = new Map<Node, Set<Node>>();\n\treadonly #roots = new Set<ConversationId>();\n\t/** Known tasks whose chain may not be loaded; every other known task's chain is, and stays, loaded. */\n\treadonly #unloaded = new Set<TaskId>();\n\t/** Live tasks with cancellation intent, the sources of abort cascades (spec §5.4). */\n\treadonly #intent = new Set<TaskId>();\n\t/** Live tasks that are not `completing`, the candidates of a reservation pass; ones found waiting leave it. */\n\treadonly #runnable = new Set<TaskId>();\n\t/** `completing` tasks the next finalize pass checks: those that started holding, and holders of ended work. */\n\treadonly #finalizeChecks = new Set<TaskId>();\n\t/** Live waiting tasks by each task in their `on`. */\n\treadonly #waiters = new Map<TaskId, Set<TaskId>>();\n\t/**\n\t * `failFast` waiters the next reconcile checks for a failed task in `on`: at open, when they start waiting, and when\n\t * one of their tasks fails.\n\t */\n\treadonly #failFastChecks = new Set<TaskId>();\n\t/**\n\t * Live tasks with `abandonOnRestart` found at open, from an earlier Harness. The first reservation pass abort-marks\n\t * them with reason `restart`, so nothing of them or below them runs a phase again.\n\t */\n\treadonly #abandoned = new Set<TaskId>();\n\t/** Sleeping live tasks, due or not: the candidates of `#wakeDue()`. */\n\treadonly #sleeping = new Set<TaskId>();\n\t/** Timer for the earliest sleep, without `onWake` while scheduling runs. */\n\t#timer: { readonly at: number; readonly disarm: () => void } | undefined;\n\t/** Last value given to `onWake`, so an unchanged one is not repeated. */\n\t#lastWake: Wake | undefined;\n\t#wakeScheduled = false;\n\treadonly #blockedListeners = new Set<() => void>();\n\t/** A registry snapshot that threw for the task graph was reported; it is read per record, so only once. */\n\t#snapshotReported = false;\n\t#reconcileScheduled = false;\n\t/** Reconcile passes underway with work (they may overlap): their commits finalize held outcomes and mark cascades. */\n\t#reconcilingWork = 0;\n\t#sweepScheduled = false;\n\t/**\n\t * Nodes chain loads installed for jobs whose commits are not published yet, with how many such jobs: the sweep keeps\n\t * them, as work a pending commit creates below them needs them.\n\t */\n\treadonly #pins = new Map<Node, number>();\n\t/** Keys the decision region underway reads (`#region()`); set only while one runs. */\n\t#reading: Set<string> | undefined;\n\t#cascadePending = false;\n\t#unsubscribeRegistry: () => void = () => {};\n\t#enabled = false;\n\treadonly #readOnly: boolean;\n\t#closing = false;\n\t#dirty = false;\n\t#draining = false;\n\n\tconstructor(options: TaskSchedulerOptions) {\n\t\tthis.#telemetry = options.telemetry ?? NOOP_TELEMETRY_CONTEXT;\n\t\tconst metrics = createTypedMetrics(this.#telemetry.metrics ?? NOOP_TELEMETRY_METRICS, [DURABLE_TELEMETRY_SCHEMA]);\n\t\tthis.#activeMetric = metrics.upDownCounter(\"pi.durable.tasks.active\");\n\t\tthis.#durationMetric = metrics.histogram(\"pi.durable.phase.duration\");\n\t\tthis.#session = options.session;\n\t\tthis.#storage = options.storage;\n\t\tthis.#registry = options.registry;\n\t\tthis.#models = options.models;\n\t\tthis.#agent = options.agent;\n\t\tthis.#settings = options.settings;\n\t\tthis.#env = options.env;\n\t\tthis.#now = options.now;\n\t\tthis.#onWake = options.onWake;\n\t\tthis.#timers = options.timers;\n\t\tthis.#writeAtClose = options.writeAtClose;\n\t\tthis.#report = options.report;\n\t\tthis.#settleOutcome = options.settleOutcome;\n\t\tthis.#limitsRestarts = options.limitsRestarts;\n\t\tthis.#withdrawInputs = options.withdrawInputs;\n\t\tthis.#conversation = options.conversation;\n\t\tthis.#context = options.context;\n\t\tthis.#readOnly = options.readOnly === true;\n\t}\n\n\t/**\n\t * Load live tasks and change surviving `running` tasks back to `pending`, counting the restart. Dispatches nothing;\n\t * a task cut off `settings.restartLimit` times ends when it is next reserved. Read-only, it only loads them: a\n\t * `running` task stays as committed, running in another process.\n\t */\n\tasync open(context: Context): Promise<void> {\n\t\tthis.#session.followCommits((publication) => this.#observe(publication));\n\t\tthis.#session.subscribeClose(() => this.#seal());\n\t\tthis.#unsubscribeRegistry = this.#registry.subscribe(() => {\n\t\t\tthis.#notifyBlocked();\n\t\t\tthis.#kick();\n\t\t});\n\t\tawait this.#session.commitWith(async (tx) => {\n\t\t\tawait this.#published();\n\t\t\t// Every table read before the first write.\n\t\t\tconst scans = [];\n\t\t\tfor (const status of LIVE_STATUSES) {\n\t\t\t\tscans.push(await scanAll((cursor) => tx.scanTasks({ status }, SCAN_PAGE_SIZE, cursor)));\n\t\t\t}\n\t\t\tfor (const records of scans) {\n\t\t\t\tfor (const record of records) {\n\t\t\t\t\tthis.#track(undefined, record);\n\t\t\t\t\tthis.#resumed.add(record.id);\n\t\t\t\t\tif (this.#readOnly) continue;\n\t\t\t\t\tif (record.abandonOnRestart === true) this.#abandoned.add(record.id);\n\t\t\t\t\tif (record.state.status === \"running\") {\n\t\t\t\t\t\tconst restarts = (record.restarts ?? 0) + 1;\n\t\t\t\t\t\tconst pending = withState(record, { status: \"pending\", checkpoint: record.state.checkpoint });\n\t\t\t\t\t\ttx.setTask({ ...pending, restarts } as AnyTaskRecord);\n\t\t\t\t\t}\n\t\t\t\t\tif (record.state.status === \"waiting\" && record.state.policy === \"failFast\") {\n\t\t\t\t\t\tthis.#failFastChecks.add(record.id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}, context);\n\t\tif (this.#readOnly) return;\n\t\t// Derive abort marks a crash left unapplied below cancelled owners, and finalize held outcomes.\n\t\tthis.#cascadePending = true;\n\t\tthis.#scheduleReconcile();\n\t\tthis.#scheduleWake();\n\t}\n\n\t/**\n\t * Enable scheduling, and make sleeping tasks that are due runnable: a host wakeup, such as an alarm, calls this.\n\t * Idempotent; the kick does nothing once closing.\n\t */\n\tresume(): void {\n\t\tif (this.#readOnly) throw new ReadOnlySession(\"running tasks\");\n\t\tthis.#enabled = true;\n\t\tthis.#wakeDue();\n\t\tthis.#kick();\n\t}\n\n\t/**\n\t * Why a live task cannot run here, if it cannot: its definition is missing, too old, or failed to migrate. A running\n\t * task, an abort-marked one, and one holding its outcome are never blocked.\n\t */\n\tblockedReason(record: BlockedSubject): BlockedReason | undefined {\n\t\tconst status = record.status;\n\t\tif (status === \"running\" || status === \"completing\" || status === \"terminal\") return undefined;\n\t\t// An abort request runs its handler or orphans the task; a `restart` mark waits for the definition, blocked.\n\t\tif (record.abortRequested && record.abortReason === undefined) return undefined;\n\t\tlet snapshot: RegistrySnapshot;\n\t\ttry {\n\t\t\tsnapshot = this.#registry.snapshot();\n\t\t} catch (error) {\n\t\t\tif (!this.#snapshotReported) this.#report(error, REGISTRY);\n\t\t\tthis.#snapshotReported = true;\n\t\t\treturn undefined;\n\t\t}\n\t\tconst fit = this.#fit(record, snapshot.task(record.kind));\n\t\tif (\"reason\" in fit) return fit.reason;\n\t\treturn fit.migrates && fit.task.definition.migrate === undefined ? \"migration_failed\" : undefined;\n\t}\n\n\t/** Call `listener` when blocked reasons may have changed without a commit: a registry change or a failed migration. */\n\tsubscribeBlocked(listener: () => void): () => void {\n\t\tthis.#blockedListeners.add(listener);\n\t\treturn () => this.#blockedListeners.delete(listener);\n\t}\n\n\t/**\n\t * When the Session next needs a process: `active` while some task can run now or is running, `at` for the earliest\n\t * sleep not yet due. Synchronous, from memory; a task whose chain is not loaded yet counts as it would alone.\n\t */\n\twake(): Wake {\n\t\t// A read-only Harness runs nothing, so it never needs a process.\n\t\tif (this.#readOnly) return { active: false };\n\t\tconst now = this.#now();\n\t\t// A reconcile pass with work to do is work too: it finalizes held outcomes and marks cascades, at open as\n\t\t// recovery. A process that dies before it lands must be woken again. A pass with nothing to do is not.\n\t\tconst active =\n\t\t\tthis.#invocations.size > 0 || this.#reconcilingWork > 0 || this.#reconcileWork() || this.#runsNow(now);\n\t\t// The earliest sleep not yet due: only `#sleeping` holds sleeping tasks, so no pass visits every live task.\n\t\tlet at: number | undefined;\n\t\tfor (const id of this.#sleeping) {\n\t\t\tconst record = this.#live.get(id);\n\t\t\tconst state = record?.state;\n\t\t\tif (state?.status === \"sleeping\" && !record!.abortRequested && state.until > now) {\n\t\t\t\tat = at === undefined ? state.until : Math.min(at, state.until);\n\t\t\t}\n\t\t}\n\t\treturn at === undefined ? { active } : { active, at };\n\t}\n\n\t/** Whether a live task can run now: the scan `wake()` needs only while no invocation runs. */\n\t#runsNow(now: number): boolean {\n\t\tlet snapshot: RegistrySnapshot | undefined;\n\t\tlet snapshotFailed = false;\n\t\tfor (const record of this.#live.values()) {\n\t\t\tconst state = record.state;\n\t\t\tif (state.status === \"completing\") continue;\n\t\t\tif (state.status === \"waiting\" && !record.abortRequested && state.on.some((id) => this.#live.has(id)))\n\t\t\t\tcontinue;\n\t\t\tif (state.status === \"sleeping\" && !record.abortRequested && state.until > now) continue;\n\t\t\t// An abort invocation waits for the live work below it, which counts itself.\n\t\t\tif (record.abortRequested && this.#waitingOn(record, true).length > 0) continue;\n\t\t\t// A task no definition can take waits for a registry change, except an abort-marked one, which is orphaned.\n\t\t\tif (!record.abortRequested || record.abortReason !== undefined) {\n\t\t\t\tif (snapshot === undefined && !snapshotFailed) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tsnapshot = this.#registry.snapshot();\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tsnapshotFailed = true;\n\t\t\t\t\t\tthis.#report(error, REGISTRY);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (snapshot !== undefined && \"reason\" in this.#fit(record, snapshot.task(record.kind))) continue;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Signal every invocation and wait for them, then write the tasks they ran back as `pending` (`writeAtClose`), as a\n\t * close is not a crash. Close calls this after every close listener has run, so waits, watches, and streams a task\n\t * holds end with the Session's reason, not as cancelled by its signal.\n\t */\n\tasync join(): Promise<void> {\n\t\tconst stopped = [...this.#invocations.values()];\n\t\tfor (const invocation of stopped) invocation.controller.abort();\n\t\tawait Promise.allSettled(stopped.map((invocation) => invocation.done));\n\t\tif (stopped.length === 0) return;\n\t\t// A close is not a crash: a task it stopped is `pending` again, so the next open counts no restart for it. Read\n\t\t// on the line after commits admitted before the seal, such as an abort mark, so the write keeps them. A failure\n\t\t// leaves them `running`, counted as if cut off; the Storage guard fails the Session and reports it.\n\t\tawait this.#writeAtClose(() =>\n\t\t\tstopped.flatMap((invocation) => {\n\t\t\t\tconst record = this.#live.get(invocation.taskId);\n\t\t\t\tif (record?.state.status !== \"running\") return [];\n\t\t\t\tconst value = withState(record, { status: \"pending\", checkpoint: record.state.checkpoint });\n\t\t\t\treturn [{ type: \"task\", value } as const];\n\t\t\t}),\n\t\t).catch(() => {});\n\t}\n\n\t/**\n\t * Commit the abort mark, or settle a task that no registered definition can take as `orphaned` when nothing it owns\n\t * is live, then join the run invocation seen on the line; the commit listener signalled it. The abort invocation\n\t * starts once the task's ordinary owned work is gone. A `completing` task is only marked. A request replaces a\n\t * `restart` mark, so a task abandoned after a restart that waits for its definition is orphaned; with `keepRestart`,\n\t * as for an owner's own cleanup, such a task keeps its mark and waits on.\n\t */\n\tasync abort(id: TaskId, context: Context, keepRestart = false): Promise<\"marked\" | \"terminal\"> {\n\t\tconst marked = await this.#session.commitWith(async (tx) => {\n\t\t\tconst current = await tx.task(id);\n\t\t\tif (current === undefined) throw new Error(`Task ${id} does not exist`);\n\t\t\tif (current.state.status === \"terminal\") return { result: \"terminal\" as const };\n\t\t\tconst invocation = this.#invocations.get(id);\n\t\t\t// A restart-marked task has no run invocation; it only waits for its abort.\n\t\t\tif (keepRestart && current.abortReason === \"restart\") return { result: \"marked\" as const };\n\t\t\tif (invocation === undefined && current.state.status !== \"completing\") {\n\t\t\t\tawait this.#loadScopes(false);\n\t\t\t\tconst owns = await this.#region(() => this.#hasOwnedLive(id), this.#reloadScopes);\n\t\t\t\t// Resolved once that decision stands, as it may run `migrate`.\n\t\t\t\tconst resolution = owns\n\t\t\t\t\t? undefined\n\t\t\t\t\t: this.#resolve(current as RunnableTaskRecord, this.#registry.snapshot());\n\t\t\t\tif (resolution?.kind === \"blocked\") {\n\t\t\t\t\tawait this.#terminate(tx, current, { status: \"orphaned\", reason: resolution.reason });\n\t\t\t\t\treturn { result: \"marked\" as const };\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!current.abortRequested || current.abortReason !== undefined) tx.setTask(withAbortMark(current));\n\t\t\treturn { result: \"marked\" as const, run: invocation?.mode === \"run\" ? invocation : undefined };\n\t\t}, context);\n\t\t// The commit listener signalled the run; join it. A run that ignores its signal can outlive a failed Session,\n\t\t// which ends the wait instead.\n\t\tif (marked.run !== undefined) {\n\t\t\tawait awaitWithContext(Promise.race([marked.run.done, this.#session.failed]), context);\n\t\t}\n\t\treturn marked.result;\n\t}\n\n\tasync waitForTask(id: TaskId, context: Context): Promise<SettledTask<JsonValue>> {\n\t\t// Check and register on the line so no terminal publication falls between them.\n\t\tconst found = await this.#session.readOnLine(async (storage) => {\n\t\t\tif (this.#closing) throw closedError(this.#session);\n\t\t\tif (await this.#region(() => this.#liveRecord(id) !== undefined)) {\n\t\t\t\treturn { promise: this.#taskWaiters.add(id, context) };\n\t\t\t}\n\t\t\tconst record = await storage.task(id, context);\n\t\t\tif (record === undefined) throw new Error(`Task ${id} does not exist`);\n\t\t\treturn { promise: Promise.resolve(record as SettledTask<JsonValue>) };\n\t\t});\n\t\treturn found.promise;\n\t}\n\n\t/**\n\t * Resolve when ordinary traversal from the conversation, or from every ownerless conversation, reaches no live\n\t * non-background task.\n\t */\n\twaitForIdle(conversationId: ConversationId | undefined, context: Context): Promise<void> {\n\t\tif (this.#closing) return Promise.reject(closedError(this.#session));\n\t\tif (this.#idle(conversationId)) return Promise.resolve();\n\t\tthis.#scheduleReconcile();\n\t\treturn this.#idleWaiters.add(conversationId, context);\n\t}\n\n\t/**\n\t * `Conversation.abort()`: in one commit, withdraw the queued inputs and mark every live non-background task that\n\t * ordinary traversal from the conversation reaches; resolves once the scope is idle. With `background`, traversal\n\t * crosses background boundaries, and the wait also covers every task it reached.\n\t */\n\tasync abortConversation(conversationId: ConversationId, background: boolean, context: Context): Promise<void> {\n\t\tconst reached = await this.#session.commitWith(async (tx) => {\n\t\t\tawait this.#published();\n\t\t\tconst queued = await this.#loadScopes(true);\n\t\t\tconst scope = { conversation: conversationId };\n\t\t\tconst reached: TaskId[] = [];\n\t\t\tconst walk = this.#walkDown(conversationNode(conversationId), { crossBackground: background });\n\t\t\tfor (const { node, live } of walk) {\n\t\t\t\tif (live === undefined || (node.background && !background)) continue;\n\t\t\t\treached.push(live.id);\n\t\t\t\tif (!live.abortRequested || live.abortReason !== undefined) tx.setTask(withAbortMark(live));\n\t\t\t}\n\t\t\tfor (const id of queued) {\n\t\t\t\tif (this.#inScope({ conversation: id }, scope, background) === true) await this.#withdrawInputs(tx, id);\n\t\t\t}\n\t\t\treturn reached;\n\t\t}, context);\n\t\tif (background) for (const id of reached) await this.waitForTask(id, context);\n\t\tawait this.waitForIdle(conversationId, context);\n\t}\n\n\t/**\n\t * The ownership memberships a commit's task and conversation changes write (group commit §4.2), at its admission on\n\t * the line: for each task created or made terminal, every node from its parent up to and including the nearest live\n\t * task, or the root conversation, and then the roots too, conservatively, as a pending end may unlist the root a\n\t * creation finds listed; for each conversation created under a task, that task; and the intent set when\n\t * a change sets, upgrades, or clears a mark or a held or ended outcome other than `completed`. Loads the chains it\n\t * walks; the nodes it installs stay until the commit is published.\n\t */\n\tmembershipKeys(tx: Transaction): readonly string[] | Promise<readonly string[]> {\n\t\tconst tasks = tx.stagedTasks();\n\t\tconst conversations = tx.stagedConversations();\n\t\tif (tasks.length === 0 && conversations.every((record) => record.owner === undefined)) return NO_KEYS;\n\t\treturn this.#membershipKeys(tx, tasks, conversations);\n\t}\n\n\tasync #membershipKeys(\n\t\ttx: Transaction,\n\t\ttasks: readonly AnyTaskRecord[],\n\t\tconversations: readonly ConversationRecord[],\n\t): Promise<readonly string[]> {\n\t\tconst keys = new Set<string>();\n\t\tconst overlay = overlayOf(tx);\n\t\tconst created = new Set(tx.createdTaskIds());\n\t\tconst reached = new Map<string, ConversationId | undefined>();\n\t\tfor (const record of tasks) {\n\t\t\tif (intentChanges(this.#live.get(record.id), record)) keys.add(INTENT_KEY);\n\t\t\tif (!created.has(record.id) && record.state.status !== \"terminal\") continue;\n\t\t\tawait this.#loadChain(parentOf(record), overlay);\n\t\t\tif ((await this.#chainKeys(parentNode(record), overlay, keys, reached)) !== undefined) keys.add(ROOTS_KEY);\n\t\t}\n\t\tfor (const conversation of conversations) {\n\t\t\tconst owner = conversation.owner?.taskId;\n\t\t\tif (owner === undefined) continue;\n\t\t\tawait this.#loadChain({ task: owner }, overlay);\n\t\t\tawait this.#chainKeys(owner, overlay, keys, reached);\n\t\t}\n\t\treturn [...keys];\n\t}\n\n\t/**\n\t * Add the memberships from `start` up to and including the nearest live task, or the root conversation, which it\n\t * returns. `reached` keeps, per node walked, where its walk ended, so a chain several tasks of a commit share is\n\t * walked once. Whether an ancestor is live can change under a pending commit, so it is read after a touch of the\n\t * ancestor's record: a pending end must not stop the chain early. Ownership fields are immutable, so not keyed.\n\t */\n\tasync #chainKeys(\n\t\tstart: Node,\n\t\toverlay: Overlay,\n\t\tkeys: Set<string>,\n\t\treached: Map<string, ConversationId | undefined>,\n\t): Promise<ConversationId | undefined> {\n\t\tconst walked: string[] = [];\n\t\tlet root: ConversationId | undefined;\n\t\tlet node: Node | null | undefined = start;\n\t\twhile (node !== undefined && node !== null) {\n\t\t\tconst key = ownedKey(node);\n\t\t\t// Walked up from here already, for another task of the commit.\n\t\t\tif (reached.has(key)) {\n\t\t\t\troot = reached.get(key);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tkeys.add(key);\n\t\t\twalked.push(key);\n\t\t\tif (typeof node === \"string\") {\n\t\t\t\tconst conversation = conversationOf(node);\n\t\t\t\tnode = this.#edge(conversation, overlay);\n\t\t\t\tif (node === null) root = conversation;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet record: AnyTaskRecord | undefined = overlay.tasks.get(node);\n\t\t\tif (record === undefined) {\n\t\t\t\tconst gate = this.#session.touch(taskKey(node));\n\t\t\t\tif (gate !== undefined) {\n\t\t\t\t\tawait gate;\n\t\t\t\t\t// It may have ended meanwhile, and its node been swept: load the chain above it again.\n\t\t\t\t\tawait this.#loadChain({ task: node }, overlay);\n\t\t\t\t}\n\t\t\t\trecord = this.#live.get(node);\n\t\t\t}\n\t\t\tif (record !== undefined && record.state.status !== \"terminal\") break;\n\t\t\tconst above: TaskNode | undefined = record ?? this.#settled.get(node);\n\t\t\tnode = above === undefined ? undefined : parentNode(above);\n\t\t}\n\t\tfor (const key of walked) reached.set(key, root);\n\t\treturn root;\n\t}\n\n\t// ─── Scheduling ────────────────────────────────────────────────────────\n\n\t#observe(publication: ObservedCommit): void {\n\t\t// A commit held in memory changes documents only.\n\t\tif (publication.kind === \"memory\") return;\n\t\tthis.#advanceContexts(publication);\n\t\tconst updated: AnyTaskRecord[] = [];\n\t\tconst failed: TaskId[] = [];\n\t\tlet changed = false;\n\t\t// The conversations whose idleness the commit's task changes can change; undefined when a chain is not known.\n\t\tlet dirty: Set<ConversationId> | undefined = new Set();\n\t\t// Edges first, so the tasks a commit creates in a new conversation hang from it.\n\t\tfor (const change of publication.changes) {\n\t\t\tif (change.type === \"conversation\" && !this.#edges.has(change.value.id)) {\n\t\t\t\tthis.#setEdge(change.value.id, change.value.owner?.taskId ?? null);\n\t\t\t}\n\t\t}\n\t\tfor (const change of publication.changes) {\n\t\t\tif (change.type !== \"task\") continue;\n\t\t\tchanged = true;\n\t\t\tconst record = change.value;\n\t\t\tconst previous = this.#live.get(record.id);\n\t\t\tif (failedOutcome(record) && (previous === undefined || !failedOutcome(previous))) failed.push(record.id);\n\t\t\tthis.#track(previous, record);\n\t\t\t// Idleness counts live tasks, so only a task that became live or ended can change it. Collected before `#sweep()`,\n\t\t\t// which may forget the chain of a task that ended.\n\t\t\tconst liveness = previous === undefined || record.state.status === \"terminal\";\n\t\t\tif (liveness && dirty !== undefined && !this.#addScopesAbove(record, dirty)) dirty = undefined;\n\t\t\tif (record.state.status === \"terminal\") {\n\t\t\t\tthis.#failedMigrations.delete(record.id);\n\t\t\t\tthis.#failFastChecks.delete(record.id);\n\t\t\t\tthis.#taskWaiters.resolve(record.id, record as SettledTask<JsonValue>);\n\t\t\t\t// Its owner may finalize now.\n\t\t\t\tthis.#scheduleReconcile();\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (record.abortRequested && previous?.abortRequested !== true) {\n\t\t\t\tthis.#cascadePending = true;\n\t\t\t\t// Signal a run invocation of the newly marked task; its next step ends it. Abort listeners are task code, which\n\t\t\t\t// never runs inside a publication: the signal follows in a microtask, after host commit listeners.\n\t\t\t\tconst invocation = this.#invocations.get(record.id);\n\t\t\t\tif (invocation?.mode === \"run\") queueMicrotask(() => invocation.controller.abort());\n\t\t\t}\n\t\t\t// A request replacing a `restart` mark upgrades the marks of the work below.\n\t\t\tif (previous?.abortReason !== undefined && record.abortReason === undefined) this.#cascadePending = true;\n\t\t\tconst status = record.state.status;\n\t\t\tif (status === \"completing\" && previous?.state.status !== \"completing\") {\n\t\t\t\tif (cancellationIntent(record)) this.#cascadePending = true;\n\t\t\t\tthis.#scheduleReconcile();\n\t\t\t}\n\t\t\tif (status === \"waiting\" && record.state.policy === \"failFast\" && previous?.state.status !== \"waiting\") {\n\t\t\t\tthis.#failFastChecks.add(record.id);\n\t\t\t\tthis.#scheduleReconcile();\n\t\t\t}\n\t\t\t// Its owners and place never change: what is above it is checked once, when it becomes live.\n\t\t\tif (previous === undefined) updated.push(record);\n\t\t}\n\t\tfor (const id of failed) {\n\t\t\tfor (const waiter of this.#waiters.get(id) ?? []) {\n\t\t\t\tconst state = this.#live.get(waiter)?.state;\n\t\t\t\tif (state?.status === \"waiting\" && state.policy === \"failFast\") {\n\t\t\t\t\tthis.#failFastChecks.add(waiter);\n\t\t\t\t\tthis.#scheduleReconcile();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const change of publication.changes) {\n\t\t\t// A queued input below a cancelled owner is withdrawn, even after its cascade.\n\t\t\tif (change.type !== \"submission\" || change.value.status !== \"queued\" || change.value.type !== \"input\")\n\t\t\t\tcontinue;\n\t\t\t// Only an owner with cancellation intent withdraws it; a later intent's mark runs the cascade then.\n\t\t\tif (this.#intent.size === 0) continue;\n\t\t\tconst conversation = change.value.conversationId;\n\t\t\tif (!this.#known(conversationNode(conversation)) || this.#belowCancelled({ conversation })) {\n\t\t\t\tthis.#cascadePending = true;\n\t\t\t}\n\t\t}\n\t\tfor (const record of updated) {\n\t\t\t// Work created below a cancelled owner, even after its cascade, is aborted too.\n\t\t\tif (this.#unloaded.has(record.id)) this.#scheduleReconcile();\n\t\t\telse if (!record.background && !record.abortRequested && this.#belowCancelled(parentOf(record))) {\n\t\t\t\tthis.#cascadePending = true;\n\t\t\t}\n\t\t}\n\t\t// A cascade that a reservation or step found pending runs with the next commit of any kind.\n\t\tif (this.#cascadePending) this.#scheduleReconcile();\n\t\tthis.#sweep();\n\t\tif (!changed) return;\n\t\tthis.#settleIdle(dirty);\n\t\tthis.#kick();\n\t}\n\n\t/**\n\t * Add the conversations above `record` to `scopes`: those whose idleness a change of it can change. False when a node\n\t * on the way up is not known. A conversation already in `scopes` has everything above it there too.\n\t */\n\t#addScopesAbove(record: AnyTaskRecord, scopes: Set<ConversationId>): boolean {\n\t\tfor (const step of this.#above(parentOf(record))) {\n\t\t\tif (\"unknown\" in step) return false;\n\t\t\tif (!(\"conversation\" in step)) continue;\n\t\t\tif (scopes.has(step.conversation)) return true;\n\t\t\tscopes.add(step.conversation);\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Extend each kept context range with the entries a stored commit appended to its conversation, so a later read\n\t * needs no Storage scan. Entries are published in ID order.\n\t */\n\t#advanceContexts(publication: Extract<ObservedCommit, { readonly kind: \"stored\" }>): void {\n\t\tif (this.#contexts.size === 0) return;\n\t\tlet appended: Map<ConversationId, EntryRecord[]> | undefined;\n\t\tfor (const change of publication.changes) {\n\t\t\tif (change.type !== \"entry\" || !this.#contexts.has(change.value.conversationId)) continue;\n\t\t\tappended ??= new Map();\n\t\t\tconst entries = appended.get(change.value.conversationId);\n\t\t\tif (entries === undefined) appended.set(change.value.conversationId, [change.value]);\n\t\t\telse entries.push(change.value);\n\t\t}\n\t\tif (appended === undefined) return;\n\t\tfor (const [conversationId, entries] of appended) {\n\t\t\tconst kept = this.#contexts.get(conversationId)!;\n\t\t\t// An idle range past its retention is dropped here too: entry-only commits do not run `#settleIdle()`, and a\n\t\t\t// host may decline the expiry timer. `expiresAt` was fixed when it went idle, so no settings are read here.\n\t\t\tif (kept.idleSince !== undefined && kept.expiresAt !== undefined && kept.expiresAt <= this.#now()) {\n\t\t\t\tthis.#dropContext(conversationId);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst range = advanceRange(kept.range, entries);\n\t\t\tif (range === undefined) this.#dropContext(conversationId);\n\t\t\telse kept.range = range;\n\t\t}\n\t}\n\n\t/**\n\t * `settings.contextRetentionMs`, or 0 when the host's settings throw. Kept contexts are only a cache, so dropping them\n\t * is safe, while a throw here would escape commit listeners, reconciliation, and the expiry timer.\n\t */\n\t#contextRetentionMs(): number {\n\t\ttry {\n\t\t\treturn this.#settings().contextRetentionMs;\n\t\t} catch (error) {\n\t\t\tthis.#report(error, SETTINGS);\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\t/**\n\t * After task changes below the conversations in `scopes` (every conversation when undefined): resolve their idle\n\t * waiters and the Harness-wide ones, drop the kept contexts whose idle period passed the retention, then start or end\n\t * the idle periods of the kept contexts in `scopes`. A task change can change the idleness only of the conversations\n\t * above it, so no check visits every conversation.\n\t */\n\t#settleIdle(scopes: ReadonlySet<ConversationId> | undefined): void {\n\t\tconst all = scopes === undefined || this.#unknownsChanged;\n\t\tthis.#unknownsChanged = false;\n\t\tif (all) this.#fullIdleChecks++;\n\t\tthis.#resolveIdleWaiters(all ? undefined : scopes);\n\t\tconst now = this.#now();\n\t\tconst retention = this.#contextRetentionMs();\n\t\t// Expired first: a context past its retention is dropped even when the same commit makes it busy again.\n\t\tthis.#expireContexts(now, retention);\n\t\tfor (const conversationId of all ? [...this.#contexts.keys()] : scopes) {\n\t\t\tconst kept = this.#contexts.get(conversationId);\n\t\t\tif (kept === undefined) continue;\n\t\t\tif (!this.#idle(conversationId)) {\n\t\t\t\tif (kept.idleSince === undefined) continue;\n\t\t\t\tkept.idleSince = undefined;\n\t\t\t\tthis.#idleOrder.delete(conversationId);\n\t\t\t} else if (retention <= 0) {\n\t\t\t\tthis.#dropContext(conversationId);\n\t\t\t} else if (kept.idleSince === undefined) {\n\t\t\t\tkept.idleSince = now;\n\t\t\t\tkept.expiresAt = now + retention;\n\t\t\t\tthis.#markIdle(conversationId, now);\n\t\t\t}\n\t\t}\n\t\tthis.#scheduleExpiry();\n\t}\n\n\t/** Resolve the idle waiters of the conversations in `scopes` (all when undefined) and the Harness-wide ones. */\n\t#resolveIdleWaiters(scopes: ReadonlySet<ConversationId> | undefined): void {\n\t\tfor (const conversationId of this.#idleWaiters.keys()) {\n\t\t\tif (conversationId !== undefined && scopes !== undefined && !scopes.has(conversationId)) continue;\n\t\t\tif (this.#idle(conversationId)) this.#idleWaiters.resolve(conversationId);\n\t\t}\n\t}\n\n\t/**\n\t * Drop the kept contexts idle for at least `retention`, oldest first, with the retention setting of now; with no\n\t * retention, every idle one, also those whose idle period a clock that went back makes start after now.\n\t */\n\t#expireContexts(now: number, retention: number): void {\n\t\tfor (const [conversationId, idleSince] of this.#idleOrder) {\n\t\t\tif (retention > 0 && now - idleSince < retention) return;\n\t\t\tthis.#dropContext(conversationId);\n\t\t}\n\t}\n\n\t/**\n\t * Start the idle period of a kept context in the expiry order. An idle period older than the newest one kept, which\n\t * a clock that went back starts, sorts the order again, and the newest is taken from what is kept then.\n\t */\n\t#markIdle(conversationId: ConversationId, idleSince: number): void {\n\t\tthis.#idleOrder.delete(conversationId);\n\t\tthis.#idleOrder.set(conversationId, idleSince);\n\t\tif (this.#idleOrder.size === 1 || idleSince >= this.#idleNewest) {\n\t\t\tthis.#idleNewest = idleSince;\n\t\t\treturn;\n\t\t}\n\t\tconst sorted = [...this.#idleOrder].sort((a, b) => a[1] - b[1]);\n\t\tthis.#idleOrder.clear();\n\t\tfor (const [id, since] of sorted) this.#idleOrder.set(id, since);\n\t\tthis.#idleNewest = sorted.at(-1)![1];\n\t}\n\n\t/** Forget a kept context, idle or not, and its place in the expiry order. */\n\t#dropContext(conversationId: ConversationId): void {\n\t\tthis.#contexts.delete(conversationId);\n\t\tthis.#idleOrder.delete(conversationId);\n\t}\n\n\t/**\n\t * Drop the expired contexts when the earliest idle context expires, on a background timer, which never keeps the\n\t * process alive. Where the host declines it, as the default does in Cloudflare Workers, none is kept: a pending timer\n\t * could keep a Durable Object from being evicted, and eviction frees the contexts. There, task changes alone check\n\t * expiry.\n\t */\n\t#scheduleExpiry(): void {\n\t\tconst oldest = this.#idleOrder.values().next();\n\t\tconst at = oldest.done === true ? undefined : oldest.value + this.#contextRetentionMs();\n\t\tif (this.#expiry !== undefined && this.#expiry.at === at) return;\n\t\tthis.#expiry?.disarm();\n\t\tthis.#expiry = undefined;\n\t\tif (at === undefined || this.#closing) return;\n\t\tconst disarm = this.#timers.background(() => {\n\t\t\tthis.#expiry = undefined;\n\t\t\tthis.#expireContexts(this.#now(), this.#contextRetentionMs());\n\t\t\tthis.#scheduleExpiry();\n\t\t}, at - this.#now());\n\t\tif (disarm !== undefined) this.#expiry = { at, disarm };\n\t}\n\n\t// ─── Ownership ───────────────────────────────────────────────────────────\n\n\t#scheduleReconcile(): void {\n\t\t// A read-only reconcile could only fail: what it writes is refused, and its own commits fail the Session.\n\t\tif (this.#reconcileScheduled || this.#closing || this.#readOnly) return;\n\t\tthis.#reconcileScheduled = true;\n\t\tqueueMicrotask(() => void this.#reconcile());\n\t}\n\n\t/**\n\t * One commit that applies what committed records imply: abort marks below live owners with cancellation intent\n\t * (spec §5.4), `failFast` marks (spec §5.5), withdrawn queued inputs below cancelled owners, and the final terminal\n\t * record of every `completing` task whose ordinary owned work is gone. The durable records are the intent, so this\n\t * also repairs whatever a crash left unapplied. Resolves idle waiters that the loaded edges decide.\n\t */\n\tasync #reconcile(): Promise<void> {\n\t\tthis.#reconcileScheduled = false;\n\t\tconst work = this.#reconcileWork();\n\t\tif (work) this.#reconcilingWork++;\n\t\ttry {\n\t\t\tawait this.#session.commitInternal(async (tx) => {\n\t\t\t\tif (this.#closing) return;\n\t\t\t\t// A cascade scans the queued inputs, which waits for every unpublished commit: a request made before the scan\n\t\t\t\t// is covered by it, and none is published while the job holds the line after it.\n\t\t\t\tconst cascade = this.#cascadePending;\n\t\t\t\tconst queued = await this.#loadScopes(cascade);\n\t\t\t\tif (cascade) this.#cascadePending = false;\n\t\t\t\tconst marks = await this.#marks();\n\t\t\t\tfor (const { record, reason } of marks.values()) tx.setTask(withAbortMark(record, reason));\n\t\t\t\tconst withdrawn = await this.#region(\n\t\t\t\t\t() => queued.filter((id) => this.#belowCancelled({ conversation: id })),\n\t\t\t\t\tthis.#reloadScopes,\n\t\t\t\t);\n\t\t\t\tfor (const id of withdrawn) await this.#withdrawInputs(tx, id);\n\t\t\t\tawait this.#finalize(tx);\n\t\t\t}, this.#context);\n\t\t} catch (error) {\n\t\t\t// No extension code runs in this commit: a throw is a storage failure, a host callback, or a bug. None is fixed by\n\t\t\t// running the pass again, so it fails the Session, which reports it.\n\t\t\tthis.#failSession(error);\n\t\t}\n\t\tif (work) this.#reconcilingWork--;\n\t\tthis.#scheduleWake();\n\t\t// Its commit's task changes were settled at their publication; a waiter that asked for this pass checks again, and\n\t\t// what its chain loads resolved can make any scope idle.\n\t\tif (this.#unknownsChanged) {\n\t\t\tthis.#settleIdle(undefined);\n\t\t\treturn;\n\t\t}\n\t\tthis.#resolveIdleWaiters(undefined);\n\t\t// A pass checks expiry too, for hosts that decline the expiry timer.\n\t\tthis.#expireContexts(this.#now(), this.#contextRetentionMs());\n\t\tthis.#scheduleExpiry();\n\t}\n\n\t/**\n\t * The abort marks committed records imply (spec §5.4, §5.5): every live foreground task below a live owner with\n\t * cancellation intent, which is its nearest one (a walk down from each owner with intent does not enter another,\n\t * whose own walk covers what is below it), and every other live task in the `on` of a `failFast` waiter one of whose\n\t * tasks failed. A cascade from an abandoned owner passes its `restart` reason on; any other intent marks, or upgrades\n\t * a `restart` mark, as a request. Collected first, so a request wins over a `restart` mark of the same pass. Derived\n\t * again on every pass, as loading edges can reveal a cancelled owner. Takes the `failFast` checks once its decision\n\t * stands.\n\t */\n\tasync #marks(): Promise<Map<TaskId, { readonly record: AnyTaskRecord; readonly reason: \"restart\" | undefined }>> {\n\t\t// Terminal tasks in a checked `on`, read from Storage: each one's outcome is final.\n\t\tconst ended = new Map<TaskId, AnyTaskRecord | null>();\n\t\tfor (;;) {\n\t\t\tconst plan = await this.#region(() => this.#planMarks(ended), this.#reloadScopes);\n\t\t\tif (\"missing\" in plan) {\n\t\t\t\tfor (const id of plan.missing)\n\t\t\t\t\tended.set(id, (await this.#session.lineStorage.task(id, this.#context)) ?? null);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfor (const id of plan.checked) this.#failFastChecks.delete(id);\n\t\t\treturn plan.marks;\n\t\t}\n\t}\n\n\t/** `#marks()`' decision region; the `failFast` members it needs from Storage first, when `ended` lacks them. */\n\t#planMarks(ended: ReadonlyMap<TaskId, AnyTaskRecord | null>):\n\t\t| { readonly missing: readonly TaskId[] }\n\t\t| {\n\t\t\t\treadonly marks: Map<TaskId, { readonly record: AnyTaskRecord; readonly reason: \"restart\" | undefined }>;\n\t\t\t\treadonly checked: readonly TaskId[];\n\t\t } {\n\t\tconst marks = new Map<TaskId, { readonly record: AnyTaskRecord; readonly reason: \"restart\" | undefined }>();\n\t\t// A mark rewrites the whole record, so the record it copies is read as a task record, keyed: a commit of the task\n\t\t// that is not published yet makes the region wait and run again, rather than stage a mark over a stale checkpoint.\n\t\tconst mark = (found: AnyTaskRecord, reason: \"restart\" | undefined): void => {\n\t\t\tconst record = this.#liveRecord(found.id)!;\n\t\t\tconst staged = marks.get(record.id);\n\t\t\tif (staged !== undefined && staged.reason === undefined) return;\n\t\t\tif (record.abortRequested && (record.abortReason === undefined || reason !== undefined)) return;\n\t\t\tmarks.set(record.id, { record, reason });\n\t\t};\n\t\tthis.#record(INTENT_KEY);\n\t\tfor (const id of this.#intent) {\n\t\t\tconst owner = this.#liveRecord(id)!;\n\t\t\t// Only an owner abandoned after a restart, and nothing else, passes its reason on.\n\t\t\tconst restart = owner.abortReason === \"restart\" && !failedOutcome(owner);\n\t\t\tfor (const { node, live } of this.#walkDown(id, { enter: (below) => !this.#intent.has(below) })) {\n\t\t\t\tif (live !== undefined && !node.background) mark(live, restart ? \"restart\" : undefined);\n\t\t\t}\n\t\t}\n\t\tconst checked = [...this.#failFastChecks];\n\t\tconst missing: TaskId[] = [];\n\t\tfor (const id of checked) {\n\t\t\tconst waiter = this.#liveRecord(id);\n\t\t\tif (waiter?.state.status !== \"waiting\") continue;\n\t\t\tlet failed = false;\n\t\t\tfor (const member of waiter.state.on) {\n\t\t\t\tconst record = this.#liveRecord(member) ?? ended.get(member);\n\t\t\t\tif (record === undefined) missing.push(member);\n\t\t\t\telse if (record !== null && failedOutcome(record)) failed = true;\n\t\t\t}\n\t\t\tif (!failed) continue;\n\t\t\t// Every other live task: the failed one keeps its own outcome.\n\t\t\tfor (const member of waiter.state.on) {\n\t\t\t\tconst record = this.#liveRecord(member);\n\t\t\t\tif (record !== undefined && !failedOutcome(record)) mark(record, undefined);\n\t\t\t}\n\t\t}\n\t\treturn missing.length > 0 ? { missing } : { marks, checked };\n\t}\n\n\t/** Whether a reconcile pass would have work: a cascade to derive, held outcomes to check, or `failFast` waits. */\n\t#reconcileWork(): boolean {\n\t\treturn this.#cascadePending || this.#finalizeChecks.size > 0 || this.#failFastChecks.size > 0;\n\t}\n\n\t/**\n\t * Write the terminal record of every `completing` task without live ordinary owned work. Finalizing one can free its\n\t * owner, so this repeats over the commit's candidates until nothing changes. A held scheduler outcome gets its\n\t * Harness cleanup here. In rounds, one decision region each: the holders the tasks of one round free are checked once,\n\t * in the next, so a holder of many tasks that end together is walked once, not once per task. The first round takes\n\t * the `completing` tasks to check once its decision stands.\n\t */\n\tasync #finalize(tx: Transaction): Promise<void> {\n\t\tconst done = new Set<TaskId>();\n\t\t// The commit's candidates, kept in step with the terminal records each round stages.\n\t\tconst overlay = overlayOf(tx);\n\t\tlet round: readonly TaskId[] | undefined;\n\t\tfor (;;) {\n\t\t\tconst ids = round;\n\t\t\tconst plan = await this.#region(\n\t\t\t\t() => this.#planRound(ids ?? [...this.#finalizeChecks], overlay, done),\n\t\t\t\tthis.#reloadScopes,\n\t\t\t);\n\t\t\tif (ids === undefined) this.#finalizeChecks.clear();\n\t\t\tfor (const { record, terminal } of plan.finalized) {\n\t\t\t\ttx.setTask(terminal);\n\t\t\t\t(overlay.tasks as Map<TaskId, AnyTaskRecord>).set(record.id, terminal);\n\t\t\t\tdone.add(record.id);\n\t\t\t\tconst outcome = (record.state as { readonly outcome: TaskOutcome<JsonValue> }).outcome;\n\t\t\t\t// REMINDER: only the scheduler writes `faulted` and `orphaned` (spec §5.4); their cleanup waits for this commit.\n\t\t\t\tif (outcome.status === \"faulted\" || outcome.status === \"orphaned\") {\n\t\t\t\t\tawait this.#settleOutcome(tx, record, outcome);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (plan.next.length === 0) return;\n\t\t\tround = plan.next;\n\t\t}\n\t}\n\n\t/**\n\t * One finalize round's decision: which of `ids` are `completing` without live ordinary owned work below them, in the\n\t * commit's candidates with the round's own finalizations applied in order, and the holders above them to check next.\n\t * Tasks finalized have no live work below them, so walks down skip them. It applies the round's terminal records to\n\t * `overlay` while it decides and takes them back before it returns, so a run again starts from the same candidates.\n\t */\n\t#planRound(\n\t\tids: readonly TaskId[],\n\t\toverlay: Overlay,\n\t\tfinalized: ReadonlySet<TaskId>,\n\t): {\n\t\treadonly finalized: readonly { readonly record: AnyTaskRecord; readonly terminal: AnyTaskRecord }[];\n\t\treadonly next: readonly TaskId[];\n\t} {\n\t\tconst tasks = overlay.tasks as Map<TaskId, AnyTaskRecord>;\n\t\t// The tasks finalized so far, earlier rounds' and this one's, without copying the former.\n\t\tconst round = new Set<TaskId>();\n\t\tconst done = { has: (id: TaskId) => round.has(id) || finalized.has(id) };\n\t\tconst ended: { readonly record: AnyTaskRecord; readonly terminal: AnyTaskRecord; readonly staged: boolean }[] =\n\t\t\t[];\n\t\tconst next = new Set<TaskId>();\n\t\ttry {\n\t\t\tfor (const id of ids) {\n\t\t\t\tconst staged = tasks.get(id);\n\t\t\t\tconst record = staged ?? this.#liveRecord(id);\n\t\t\t\tif (record?.state.status !== \"completing\" || done.has(id)) continue;\n\t\t\t\tif (this.#hasOwnedLive(id, overlay, done)) continue;\n\t\t\t\tconst terminal = withState(record, { status: \"terminal\", outcome: record.state.outcome });\n\t\t\t\ttasks.set(id, terminal);\n\t\t\t\tround.add(id);\n\t\t\t\tended.push({ record, terminal, staged: staged !== undefined });\n\t\t\t\tconst above = this.#nearestLiveAbove(record, overlay);\n\t\t\t\tif (above?.state.status === \"completing\") next.add(above.id);\n\t\t\t}\n\t\t} finally {\n\t\t\tfor (const { record, staged } of ended) {\n\t\t\t\tif (staged) tasks.set(record.id, record);\n\t\t\t\telse tasks.delete(record.id);\n\t\t\t}\n\t\t}\n\t\treturn { finalized: ended, next: [...next] };\n\t}\n\n\t/**\n\t * Load the owner chains of the tasks in `#unloaded` and, with `queued`, of every conversation with queued inputs,\n\t * on the Session line; returns the latter. Reads through the line's Storage, so it may run inside a commit callback.\n\t */\n\tasync #loadScopes(queued: boolean): Promise<ConversationId[]> {\n\t\tfor (const id of [...this.#unloaded]) {\n\t\t\t// An earlier load in this loop may have passed it.\n\t\t\tif (this.#unloaded.has(id)) await this.#loadChain({ task: id });\n\t\t}\n\t\tif (!queued) return [];\n\t\t// A scan, which cannot be keyed: it waits for every unpublished commit.\n\t\tconst submissions = await scanAll((cursor) =>\n\t\t\tthis.#session.lineStorage.scanSubmissions({ status: \"queued\" }, SCAN_PAGE_SIZE, cursor, this.#context),\n\t\t);\n\t\tconst inputs = submissions.filter((submission) => submission.type === \"input\");\n\t\tconst conversations = [...new Set(inputs.map((submission) => submission.conversationId))];\n\t\tfor (const id of conversations) await this.#loadChain({ conversation: id });\n\t\treturn conversations;\n\t}\n\n\t/**\n\t * Load the owner edges and task nodes from `start` up to its ownerless root. A known task outside `#unloaded` ends the\n\t * walk, as its chain is loaded; the `#unloaded` tasks passed have a loaded chain afterwards. Loading a node can reveal\n\t * a cancelled owner, so it makes the next reconcile derive cascade marks. The nodes it installs stay until the job's\n\t * commit is published (`#pin()`).\n\t */\n\tasync #loadChain(start: Up, overlay?: Overlay): Promise<void> {\n\t\tconst passed: TaskId[] = [];\n\t\tlet installed = false;\n\t\tlet at: Up | undefined = start;\n\t\ttry {\n\t\t\twhile (at !== undefined) {\n\t\t\t\tif (\"task\" in at) {\n\t\t\t\t\tconst id: TaskId = at.task;\n\t\t\t\t\tlet node: TaskNode | undefined = this.#live.get(id) ?? this.#settled.get(id);\n\t\t\t\t\t// Created in this commit: the load from its own record covers what is above it.\n\t\t\t\t\tif (node === undefined && overlay?.tasks.has(id) === true) break;\n\t\t\t\t\tif (node !== undefined && !this.#unloaded.has(id)) break;\n\t\t\t\t\tif (node === undefined) {\n\t\t\t\t\t\t// Through the line's Storage: a task whose creation or end is not published yet waits for it.\n\t\t\t\t\t\tconst record = await this.#session.lineStorage.task(id, this.#context);\n\t\t\t\t\t\tif (record === undefined) return;\n\t\t\t\t\t\tnode = nodeOf(record);\n\t\t\t\t\t\tif (record.state.status === \"terminal\") {\n\t\t\t\t\t\t\tthis.#settle(id, node);\n\t\t\t\t\t\t\tthis.#pin(id);\n\t\t\t\t\t\t\tinstalled = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// A loaded node can reveal a cancelling owner: the next reconcile derives marks again.\n\t\t\t\t\t\tthis.#scheduleReconcile();\n\t\t\t\t\t}\n\t\t\t\t\tpassed.push(id);\n\t\t\t\t\tat = parentOf(node);\n\t\t\t\t} else {\n\t\t\t\t\tlet edge = this.#edge(at.conversation, overlay);\n\t\t\t\t\tif (edge === undefined) {\n\t\t\t\t\t\t// Through the line's Storage: a conversation whose creation is not published yet waits for it, so a missing\n\t\t\t\t\t\t// record is never mistaken for an ownerless one.\n\t\t\t\t\t\tconst record = await this.#session.lineStorage.conversation(at.conversation, this.#context);\n\t\t\t\t\t\tedge = record?.owner?.taskId ?? null;\n\t\t\t\t\t\tthis.#setEdge(at.conversation, edge);\n\t\t\t\t\t\tthis.#pin(conversationNode(at.conversation));\n\t\t\t\t\t\tinstalled = true;\n\t\t\t\t\t\t// A loaded node can reveal a cancelling owner: the next reconcile derives marks again.\n\t\t\t\t\t\tthis.#scheduleReconcile();\n\t\t\t\t\t}\n\t\t\t\t\tat = edge === null ? undefined : { task: edge };\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\t// `#idle()` counts a live task whose chain is not loaded as inside every scope it may be in: what this load\n\t\t\t// resolved, also when it stopped early, can make such a scope idle without a task change below it.\n\t\t\tif (passed.some((id) => this.#live.has(id)) || (installed && this.#liveUnloaded())) {\n\t\t\t\tthis.#unknownsChanged = true;\n\t\t\t\t// A waiter such a task held is checked again at the pass's end, also when this load was not a reconcile's.\n\t\t\t\tthis.#scheduleReconcile();\n\t\t\t}\n\t\t}\n\t\tfor (const id of passed) this.#unloaded.delete(id);\n\t}\n\n\t/** Whether a live task's chain is not loaded yet: one `#idle()` counts as inside every scope it may be in. */\n\t#liveUnloaded(): boolean {\n\t\tfor (const id of this.#unloaded) if (this.#live.has(id)) return true;\n\t\treturn false;\n\t}\n\n\t#setEdge(conversationId: ConversationId, owner: TaskId | null): void {\n\t\tthis.#edges.set(conversationId, owner);\n\t\t// The conversation now hangs from its owner, or is a root; with nothing below it, it waits for the sweep.\n\t\tthis.#relist(conversationNode(conversationId));\n\t\tthis.#dropIfUnneeded(conversationNode(conversationId));\n\t}\n\n\t/** Know a terminal task a chain load read, so walks pass through it; its own chain is not loaded yet. */\n\t#settle(id: TaskId, node: TaskNode): void {\n\t\tthis.#settled.set(id, node);\n\t\tthis.#unloaded.add(id);\n\t\tthis.#relist(id);\n\t\tthis.#dropIfUnneeded(id);\n\t}\n\n\t/** Queue an ended task or a conversation for the sweep when nothing is listed below it. */\n\t#dropIfUnneeded(node: Node): void {\n\t\tif (typeof node !== \"string\" && this.#live.has(node)) return;\n\t\tif (this.#below.has(node)) return;\n\t\tthis.#dropQueue.add(node);\n\t\tthis.#scheduleSweep();\n\t}\n\n\t/**\n\t * Sweep in a job of its own on the Session line, after the operation underway: a rejected commit, one with nothing to\n\t * write, and a read publish nothing, so the sweep at the end of `#observe` would not run for what they loaded.\n\t */\n\t#scheduleSweep(): void {\n\t\tif (this.#sweepScheduled || this.#closing) return;\n\t\tthis.#sweepScheduled = true;\n\t\tthis.#session\n\t\t\t.readOnLine(async () => {\n\t\t\t\tthis.#sweepScheduled = false;\n\t\t\t\tthis.#sweep();\n\t\t\t})\n\t\t\t// Rejected only once the Session is closing or failed, when nothing is kept anyway.\n\t\t\t.catch(() => {});\n\t}\n\n\t/**\n\t * Drop the queued nodes that are still unneeded: not live, nothing listed below. Runs once a publication is fully\n\t * tracked, and as a job of its own on the line, never inside an operation: work a commit creates below a chain its\n\t * own callback loaded keeps that chain. A flat loop: unlisting already queued every node on the way up that lost its\n\t * last listed node.\n\t */\n\t#sweep(): void {\n\t\tfor (const node of this.#dropQueue) {\n\t\t\t// Queued again once its pins go.\n\t\t\tif (this.#below.has(node) || this.#pins.has(node)) continue;\n\t\t\tif (typeof node === \"string\") {\n\t\t\t\tthis.#edges.delete(conversationOf(node));\n\t\t\t\tthis.#roots.delete(conversationOf(node));\n\t\t\t} else if (!this.#live.has(node)) {\n\t\t\t\tthis.#settled.delete(node);\n\t\t\t\tthis.#unloaded.delete(node);\n\t\t\t}\n\t\t}\n\t\tthis.#dropQueue.clear();\n\t}\n\n\t/**\n\t * Run `decide`, a decision region (group commit §6): synchronous, reading scheduler memory and recording the keys it\n\t * reads, staging nothing and changing no scheduler state. When a key it read has an unpublished writer, its result,\n\t * or its error, is dropped: once that writer is published, `refresh` reloads what the region needs and it runs\n\t * again. A waiting job holds the line, so unpublished writes only shrink, and the runs converge. What a region read\n\t * that had no unpublished writer gets none for the rest of the job, so its result stands while the job applies it.\n\t */\n\tasync #region<T>(decide: () => T, refresh?: () => Promise<unknown>): Promise<T> {\n\t\tfor (;;) {\n\t\t\tconst keys = new Set<string>();\n\t\t\tthis.#reading = keys;\n\t\t\tlet result: { readonly value: T } | { readonly error: unknown };\n\t\t\ttry {\n\t\t\t\tresult = { value: decide() };\n\t\t\t} catch (error) {\n\t\t\t\tresult = { error };\n\t\t\t} finally {\n\t\t\t\tthis.#reading = undefined;\n\t\t\t}\n\t\t\tconst gates: Promise<void>[] = [];\n\t\t\tfor (const key of keys) {\n\t\t\t\tconst gate = this.#session.touch(key);\n\t\t\t\tif (gate !== undefined) gates.push(gate);\n\t\t\t}\n\t\t\tif (gates.length === 0) {\n\t\t\t\tif (\"error\" in result) throw result.error;\n\t\t\t\treturn result.value;\n\t\t\t}\n\t\t\tawait Promise.all(gates);\n\t\t\tawait refresh?.();\n\t\t}\n\t}\n\n\t/** Load the chains a region walks, again after it waited: what was published meanwhile may list new work. */\n\treadonly #reloadScopes = (): Promise<unknown> => this.#loadScopes(false);\n\n\t/** In a decision region, note that it reads `key`; anywhere else, nothing. */\n\t#record(key: string): void {\n\t\tthis.#reading?.add(key);\n\t}\n\n\t/** A live task's committed record, read by a decision region. */\n\t#liveRecord(id: TaskId): AnyTaskRecord | undefined {\n\t\tthis.#record(taskKey(id));\n\t\treturn this.#live.get(id);\n\t}\n\n\t/**\n\t * Keep `node`, which a chain load of the job on the line installed, until that job's commit is published or fails:\n\t * work it creates below the node needs it, and the sweep would drop it as unneeded before then.\n\t */\n\t#pin(node: Node): void {\n\t\tthis.#pins.set(node, (this.#pins.get(node) ?? 0) + 1);\n\t\tthis.#session.onJobEnd(() => {\n\t\t\tconst count = this.#pins.get(node)! - 1;\n\t\t\tif (count > 0) {\n\t\t\t\tthis.#pins.set(node, count);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.#pins.delete(node);\n\t\t\tthis.#dropIfUnneeded(node);\n\t\t});\n\t}\n\n\t/**\n\t * Bring the scheduler's sets in line with a task's committed record. A task that ended may free the nearest live task\n\t * above it: one holding its outcome finalizes, an abort-marked one runs its abort handler; its waiters may run.\n\t */\n\t#track(previous: AnyTaskRecord | undefined, record: AnyTaskRecord): void {\n\t\tconst id = record.id;\n\t\tconst invocation = this.#invocations.get(id);\n\t\tif (invocation !== undefined) invocation.record = record as TaskRecord<JsonValue, Checkpoint, JsonValue>;\n\t\tif (record.state.status === \"terminal\") {\n\t\t\tif (previous !== undefined && !this.#closing) this.#countActive(-1, record.kind);\n\t\t\tthis.#resumed.delete(id);\n\t\t} else if (previous === undefined && !this.#closing) {\n\t\t\tthis.#countActive(1, record.kind);\n\t\t}\n\t\tif (previous?.state.status === \"waiting\") for (const on of previous.state.on) deleteFrom(this.#waiters, on, id);\n\t\tif (record.state.status === \"terminal\") {\n\t\t\tconst node = nodeOf(record);\n\t\t\tthis.#live.delete(id);\n\t\t\tthis.#sleeping.delete(id);\n\t\t\tthis.#intent.delete(id);\n\t\t\tthis.#runnable.delete(id);\n\t\t\tthis.#finalizeChecks.delete(id);\n\t\t\tthis.#settled.set(id, node);\n\t\t\t// Before anything is forgotten: the walk up to the task it held passes the ended tasks between them. Its chain is\n\t\t\t// loaded, as every commit that ends a task loads the chains of `#unloaded` first.\n\t\t\tthis.#release(node);\n\t\t\tfor (const waiter of this.#waiters.get(id) ?? []) this.#runnable.add(waiter);\n\t\t\tthis.#relist(id);\n\t\t\tthis.#dropIfUnneeded(id);\n\t\t\treturn;\n\t\t}\n\t\tthis.#live.set(id, record);\n\t\tif (previous === undefined) {\n\t\t\tif (!this.#known(parentNode(record))) this.#unloaded.add(id);\n\t\t\tthis.#relist(id);\n\t\t}\n\t\tif (cancellationIntent(record)) this.#intent.add(id);\n\t\telse this.#intent.delete(id);\n\t\tif (record.state.status === \"completing\") {\n\t\t\tthis.#runnable.delete(id);\n\t\t\tthis.#finalizeChecks.add(id);\n\t\t} else {\n\t\t\tthis.#runnable.add(id);\n\t\t}\n\t\tif (record.state.status === \"waiting\") for (const on of record.state.on) addTo(this.#waiters, on, id);\n\t\tif (record.state.status === \"sleeping\") this.#sleeping.add(id);\n\t\telse this.#sleeping.delete(id);\n\t}\n\n\t/** The nearest live task above ended ordinary work may be free now: one holding its outcome, or an aborting one. */\n\t#release(node: TaskNode, overlay?: Overlay): AnyTaskRecord | undefined {\n\t\tconst above = this.#nearestLiveAbove(node, overlay);\n\t\tif (above?.state.status === \"completing\") this.#finalizeChecks.add(above.id);\n\t\telse if (above?.abortRequested === true) this.#runnable.add(above.id);\n\t\treturn above;\n\t}\n\n\t/**\n\t * List `start` under its parent node in `#below` while it is a live task or has nodes listed below it, and unlist it\n\t * otherwise; then its parent, as far up as that changes. So `#below` holds exactly the tree around live work; a\n\t * parent that loses its last listed node is queued for the sweep. A loop, as ownership chains can be deeper than the\n\t * call stack.\n\t */\n\t#relist(start: Node): void {\n\t\tlet node: Node = start;\n\t\tfor (;;) {\n\t\t\tconst needed = (typeof node !== \"string\" && this.#live.has(node)) || this.#below.has(node);\n\t\t\tlet parent: Node | null | undefined;\n\t\t\tif (typeof node === \"string\") {\n\t\t\t\tparent = this.#edges.get(conversationOf(node));\n\t\t\t} else {\n\t\t\t\tconst known = this.#live.get(node) ?? this.#settled.get(node);\n\t\t\t\tif (known === undefined) return;\n\t\t\t\tparent = parentNode(known);\n\t\t\t}\n\t\t\tif (parent === undefined) return;\n\t\t\tif (parent === null) {\n\t\t\t\tconst root = conversationOf(node as `c${number}`);\n\t\t\t\tif (needed) this.#roots.add(root);\n\t\t\t\telse this.#roots.delete(root);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ((this.#below.get(parent)?.has(node) === true) === needed) return;\n\t\t\tif (needed) {\n\t\t\t\tconst first = !this.#below.has(parent);\n\t\t\t\taddTo(this.#below, parent, node);\n\t\t\t\tif (!first) return;\n\t\t\t} else {\n\t\t\t\tdeleteFrom(this.#below, parent, node);\n\t\t\t\tif (this.#below.has(parent)) return;\n\t\t\t\tthis.#dropIfUnneeded(parent);\n\t\t\t}\n\t\t\tnode = parent;\n\t\t}\n\t}\n\n\t/**\n\t * The nearest live task above ended ordinary work `node`, in the overlay's view: the one that work held, if any. Work\n\t * at or below a background task holds nothing above it.\n\t */\n\t#nearestLiveAbove(node: TaskNode, overlay?: Overlay): AnyTaskRecord | undefined {\n\t\tthis.#record(INTENT_KEY);\n\t\tfor (let current = node; !current.background; ) {\n\t\t\tconst owner = current.owner ?? this.#edge(current.conversationId, overlay);\n\t\t\tif (owner === undefined || owner === null) return undefined;\n\t\t\tconst record = overlay?.tasks.get(owner) ?? this.#liveRecord(owner);\n\t\t\tif (record !== undefined && record.state.status !== \"terminal\") return record;\n\t\t\tconst above = record ?? this.#settled.get(owner);\n\t\t\tif (above === undefined) return undefined;\n\t\t\tcurrent = above;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/** Whether the chain above `node` is loaded, without walking: known tasks outside `#unloaded` have a loaded chain. */\n\t#known(node: Node): boolean {\n\t\tif (typeof node !== \"string\") {\n\t\t\treturn (this.#live.has(node) || this.#settled.has(node)) && !this.#unloaded.has(node);\n\t\t}\n\t\tconst owner = this.#edges.get(conversationOf(node));\n\t\treturn owner === null || (owner !== undefined && this.#known(owner));\n\t}\n\n\t/** Owner task of a conversation, `null` when ownerless, `undefined` while not loaded. */\n\t#edge(id: ConversationId, overlay?: Overlay): TaskId | null | undefined {\n\t\tif (overlay?.edges.has(id) === true) return overlay.edges.get(id);\n\t\tthis.#record(conversationKey(id));\n\t\treturn this.#edges.get(id);\n\t}\n\n\t#node(id: TaskId, overlay?: Overlay): TaskNode | undefined {\n\t\treturn overlay?.tasks.get(id) ?? this.#live.get(id) ?? this.#settled.get(id);\n\t}\n\n\t/** Walk up from `start`: owner tasks and conversations, ending at an ownerless root or an edge not loaded yet. */\n\t*#above(start: Up, overlay?: Overlay): Generator<Step> {\n\t\tlet at: Up | undefined = start;\n\t\twhile (at !== undefined) {\n\t\t\tif (\"task\" in at) {\n\t\t\t\tconst node = this.#node(at.task, overlay);\n\t\t\t\tif (node === undefined) {\n\t\t\t\t\tyield { unknown: true };\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tyield { task: at.task, node };\n\t\t\t\tat = parentOf(node);\n\t\t\t} else {\n\t\t\t\tyield { conversation: at.conversation };\n\t\t\t\tconst edge = this.#edge(at.conversation, overlay);\n\t\t\t\tif (edge === undefined) {\n\t\t\t\t\tyield { unknown: true };\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tat = edge === null ? undefined : { task: edge };\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * The tasks below `start` that a walk down reaches: those `#below` lists and, under an overlay, the commit's new tasks,\n\t * with its candidates in place of committed records. Background tasks are reached but not entered, unless\n\t * `crossBackground`, and neither are the tasks `enter` rejects. A loop, as chains can be deeper than the call stack.\n\t */\n\t*#walkDown(\n\t\tstart: Node,\n\t\toptions: {\n\t\t\treadonly overlay?: Overlay;\n\t\t\treadonly crossBackground?: boolean;\n\t\t\treadonly enter?: (id: TaskId) => boolean;\n\t\t} = {},\n\t): Generator<{ readonly id: TaskId; readonly node: TaskNode; readonly live: AnyTaskRecord | undefined }> {\n\t\tconst { overlay, crossBackground = false, enter } = options;\n\t\tconst links = overlay === undefined ? undefined : this.#links(overlay);\n\t\tconst pending: Node[] = [start];\n\t\tfor (let at = pending.pop(); at !== undefined; at = pending.pop()) {\n\t\t\tthis.#record(ownedKey(at));\n\t\t\tfor (const children of [this.#below.get(at), links?.get(at)]) {\n\t\t\t\tfor (const child of children ?? []) {\n\t\t\t\t\tif (typeof child === \"string\") {\n\t\t\t\t\t\tpending.push(child);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tconst record = overlay?.tasks.get(child) ?? this.#live.get(child);\n\t\t\t\t\tconst node = record ?? this.#settled.get(child);\n\t\t\t\t\tif (node === undefined) continue;\n\t\t\t\t\tconst live = record !== undefined && record.state.status !== \"terminal\" ? record : undefined;\n\t\t\t\t\tyield { id: child, node, live };\n\t\t\t\t\tif ((crossBackground || !node.background) && (enter === undefined || enter(child))) pending.push(child);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * The links walks down need for the commit's new tasks: each one under its parent node, then each node above it that\n\t * `#below` does not list yet, until one it lists, a live task (always listed), or the chain's end.\n\t */\n\t#links(overlay: Overlay): ReadonlyMap<Node, ReadonlySet<Node>> {\n\t\tif (overlay.links !== undefined) return overlay.links;\n\t\tconst links = new Map<Node, Set<Node>>();\n\t\tfor (const record of overlay.tasks.values()) {\n\t\t\tif (this.#live.has(record.id) || this.#settled.has(record.id)) continue;\n\t\t\tlet child: Node = record.id;\n\t\t\tlet parent: Node | null | undefined = parentNode(record);\n\t\t\twhile (parent !== undefined && parent !== null && links.get(parent)?.has(child) !== true) {\n\t\t\t\taddTo(links, parent, child);\n\t\t\t\tif (typeof parent !== \"string\" && (this.#live.has(parent) || overlay.tasks.has(parent))) break;\n\t\t\t\tlet above: Node | null | undefined;\n\t\t\t\tif (typeof parent === \"string\") {\n\t\t\t\t\tabove = this.#edge(conversationOf(parent), overlay);\n\t\t\t\t} else {\n\t\t\t\t\tconst fields = this.#settled.get(parent);\n\t\t\t\t\tabove = fields === undefined ? undefined : parentNode(fields);\n\t\t\t\t}\n\t\t\t\tif (above !== undefined && above !== null && this.#below.get(above)?.has(parent) === true) break;\n\t\t\t\tchild = parent;\n\t\t\t\tparent = above;\n\t\t\t}\n\t\t}\n\t\toverlay.links = links;\n\t\treturn links;\n\t}\n\n\t/**\n\t * The live ordinary owned work of `owner` (spec §5.5): the live non-background tasks below it that a walk down reaches\n\t * without entering a background task; with `first`, only the first. Candidates in `overlay` replace committed records;\n\t * the walk does not enter tasks in `done`, which have none. Owner chains must be loaded.\n\t */\n\t#ownedLive(\n\t\towner: TaskId,\n\t\toptions: { readonly overlay?: Overlay; readonly first?: boolean; readonly done?: Finalized } = {},\n\t): TaskId[] {\n\t\tconst { overlay, first = false, done } = options;\n\t\tconst found: TaskId[] = [];\n\t\tconst walk = this.#walkDown(owner, {\n\t\t\t...(overlay === undefined ? {} : { overlay }),\n\t\t\t...(done === undefined ? {} : { enter: (id: TaskId) => !done.has(id) }),\n\t\t});\n\t\tfor (const { id, node, live } of walk) {\n\t\t\tif (live === undefined || node.background) continue;\n\t\t\tfound.push(id);\n\t\t\tif (first) break;\n\t\t}\n\t\treturn found;\n\t}\n\n\t#hasOwnedLive(owner: TaskId, overlay?: Overlay, done?: Finalized): boolean {\n\t\tconst options = {\n\t\t\tfirst: true,\n\t\t\t...(overlay === undefined ? {} : { overlay }),\n\t\t\t...(done === undefined ? {} : { done }),\n\t\t};\n\t\treturn this.#ownedLive(owner, options).length > 0;\n\t}\n\n\t/**\n\t * Whether ordinary traversal from `scope` reaches `start`: walking up reaches the scope's conversation, or an\n\t * ownerless one for `roots`, without crossing a background owner, unless `crossBackground`. `undefined` while an\n\t * edge is not loaded.\n\t */\n\t#inScope(start: Up, scope: Scope, crossBackground = false): boolean | undefined {\n\t\tthis.#record(INTENT_KEY);\n\t\tfor (const step of this.#above(start)) {\n\t\t\tif (\"unknown\" in step) return undefined;\n\t\t\tif (\"conversation\" in step) {\n\t\t\t\tif (\"conversation\" in scope && step.conversation === scope.conversation) return true;\n\t\t\t} else if (step.node.background && !crossBackground) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn \"roots\" in scope;\n\t}\n\n\t/**\n\t * Whether a live owner's cancellation intent reaches `start`: walking up finds an owner with intent before a\n\t * background owner without it. Terminal owners never cascade (spec §5.4).\n\t */\n\t#belowCancelled(start: Up): boolean {\n\t\treturn this.#cancellingOwner(start) !== undefined;\n\t}\n\n\t/** The nearest live owner above `start` whose cancellation intent reaches it, if any; see `#belowCancelled`. */\n\t#cancellingOwner(start: Up): AnyTaskRecord | undefined {\n\t\tthis.#record(INTENT_KEY);\n\t\t// Nothing cancels, the common case: no walk.\n\t\tif (this.#intent.size === 0) return undefined;\n\t\tfor (const step of this.#above(start)) {\n\t\t\tif (\"unknown\" in step) return undefined;\n\t\t\tif (!(\"task\" in step)) continue;\n\t\t\tconst live = this.#live.get(step.task);\n\t\t\tif (live !== undefined && cancellationIntent(live)) return live;\n\t\t\tif (step.node.background) return undefined;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Count a task in or out of `pi.durable.tasks.active`. Commit observers count at a commit's publication, which must not\n\t * throw, so a throwing adapter is reported.\n\t */\n\t#countActive(delta: 1 | -1, kind: string): void {\n\t\ttry {\n\t\t\tthis.#activeMetric.add(delta, { task: kind });\n\t\t} catch (error) {\n\t\t\tthis.#report(error, TELEMETRY);\n\t\t}\n\t}\n\n\t/** Fail the Session, which reports it, for a throw in one of the scheduler's own commits; ignored once closing. */\n\t#failSession(error: unknown, context?: Context): void {\n\t\tif (!this.#closing) this.#session.fail(error, context);\n\t}\n\n\t/** Close listener: runs synchronously once admission is sealed, before `join()`, or when the Session fails. */\n\t#seal(): void {\n\t\tfor (const record of this.#live.values()) this.#countActive(-1, record.kind);\n\t\tthis.#resumed.clear();\n\t\tthis.#closing = true;\n\t\ttry {\n\t\t\tthis.#unsubscribeRegistry();\n\t\t} catch (error) {\n\t\t\tthis.#report(error, REGISTRY);\n\t\t}\n\t\tconst error = closedError(this.#session);\n\t\tthis.#taskWaiters.rejectAll(error);\n\t\tthis.#idleWaiters.rejectAll(error);\n\t\tthis.#contexts.clear();\n\t\tthis.#idleOrder.clear();\n\t\tthis.#expiry?.disarm();\n\t\tthis.#expiry = undefined;\n\t\tthis.#timer?.disarm();\n\t\tthis.#timer = undefined;\n\t}\n\n\t/**\n\t * Recompute the wake in a microtask the line never waits for, with no order relative to host commit listeners (one\n\t * already queued serves later changes too): arm the built-in timer, or tell `onWake` of a change.\n\t */\n\t#scheduleWake(): void {\n\t\tif (this.#wakeScheduled || this.#closing || this.#readOnly) return;\n\t\tthis.#wakeScheduled = true;\n\t\tqueueMicrotask(() => {\n\t\t\tthis.#wakeScheduled = false;\n\t\t\tif (this.#closing) return;\n\t\t\tconst wake = this.wake();\n\t\t\tif (this.#onWake === undefined) {\n\t\t\t\tthis.#armTimer(this.#enabled ? wake.at : undefined);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst last = this.#lastWake;\n\t\t\tif (last !== undefined && last.active === wake.active && last.at === wake.at) return;\n\t\t\ttry {\n\t\t\t\tthis.#onWake(wake);\n\t\t\t\t// Only a delivered wake counts: after a throw, the next change or kick offers it again.\n\t\t\t\tthis.#lastWake = wake;\n\t\t\t} catch (error) {\n\t\t\t\tthis.#report(error, ON_WAKE);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Keep the timer for the earliest sleep. It keeps the process alive, unlike the context expiry timer: a process with a\n\t * sleeping task has work left, such as a retry backoff. Rechecks the clock when it fires, so a wake before `until`\n\t * only arms it again.\n\t */\n\t#armTimer(at: number | undefined): void {\n\t\tif (this.#timer !== undefined && this.#timer.at === at) return;\n\t\tthis.#timer?.disarm();\n\t\tthis.#timer = undefined;\n\t\tif (at === undefined || this.#closing) return;\n\t\tconst disarm = this.#timers.foreground(() => {\n\t\t\tthis.#timer = undefined;\n\t\t\tthis.#wakeDue();\n\t\t\tthis.#kick();\n\t\t}, at - this.#now());\n\t\tthis.#timer = { at, disarm };\n\t}\n\n\t/** Make every sleeping task whose time has come a reservation candidate. */\n\t#wakeDue(): void {\n\t\tfor (const id of this.#sleeping) {\n\t\t\tconst record = this.#live.get(id);\n\t\t\tif (record !== undefined && !this.#notDue(record)) this.#runnable.add(id);\n\t\t}\n\t}\n\n\t/**\n\t * The report info of a task's failure, with the extension that installed its definition: the code that failed is\n\t * that extension's. Built-in tasks have none.\n\t */\n\t/** What a report about `task`'s own code says of it: the task, and the extension that installed its definition. */\n\t#aboutTask(task: {\n\t\treadonly taskId: TaskId;\n\t\treadonly kind: string;\n\t\treadonly conversationId: ConversationId;\n\t\t/** The installer of the definition whose code ran (an invocation's); absent: the current one's. */\n\t\treadonly extension?: string | undefined;\n\t}): { readonly task: ReportTask; readonly extension?: string } {\n\t\tlet extension: string | undefined;\n\t\tif (\"extension\" in task) extension = task.extension;\n\t\telse {\n\t\t\ttry {\n\t\t\t\tconst snapshot = this.#registry.snapshot();\n\t\t\t\textension = installerOf(snapshot, snapshot.task(task.kind));\n\t\t\t} catch {\n\t\t\t\t// A registry that throws is reported where it is read for scheduling; a report goes out without the name.\n\t\t\t}\n\t\t}\n\t\treturn { task: reportTask(task), ...optionalExtension(extension) };\n\t}\n\n\t/** `settings.restartLimit`, or the default when the host's settings throw. */\n\t#restartLimit(): number {\n\t\ttry {\n\t\t\treturn this.#settings().restartLimit;\n\t\t} catch (error) {\n\t\t\tthis.#report(error, SETTINGS);\n\t\t\treturn DEFAULT_RESTART_LIMIT;\n\t\t}\n\t}\n\n\t#notifyBlocked(): void {\n\t\tfor (const listener of [...this.#blockedListeners]) {\n\t\t\ttry {\n\t\t\t\tlistener();\n\t\t\t} catch (error) {\n\t\t\t\tthis.#report(error, { kind: \"listener_error\" });\n\t\t\t}\n\t\t}\n\t}\n\n\t/** A sleep whose `until` the clock has not reached; an abort mark ends a sleep. */\n\t#notDue(\n\t\trecord: AnyTaskRecord,\n\t): record is AnyTaskRecord & { readonly state: { readonly status: \"sleeping\"; readonly until: number } } {\n\t\tconst state = record.state;\n\t\treturn state.status === \"sleeping\" && !record.abortRequested && state.until > this.#now();\n\t}\n\n\t#kick(): void {\n\t\tthis.#scheduleWake();\n\t\tthis.#dirty = true;\n\t\tif (this.#draining || !this.#enabled || this.#closing) return;\n\t\tthis.#draining = true;\n\t\t// Never commit synchronously from a commit or registry listener.\n\t\tqueueMicrotask(() => void this.#drain());\n\t}\n\n\tasync #drain(): Promise<void> {\n\t\ttry {\n\t\t\twhile (this.#dirty && this.#enabled && !this.#closing) {\n\t\t\t\tthis.#dirty = false;\n\t\t\t\tfor (const reservation of await this.#reserve()) this.#start(reservation);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// As in `#reconcile()`: the reservation commit runs no extension code.\n\t\t\tthis.#failSession(error);\n\t\t} finally {\n\t\t\tthis.#draining = false;\n\t\t\t// A wakeup that arrived after the loop's last check still needs its pass.\n\t\t\tif (this.#dirty) this.#kick();\n\t\t}\n\t}\n\n\t/**\n\t * Reserve every eligible task in one commit; orphan abort-marked tasks no definition can take, unless abandoned after\n\t * a restart. The first pass after open only abort-marks the abandoned tasks, so later passes see the marks.\n\t */\n\tasync #reserve(): Promise<Reservation[]> {\n\t\tconst reservations: Reservation[] = [];\n\t\tconst faulted: { readonly record: AnyTaskRecord; readonly message: string }[] = [];\n\t\tlet abandoned: TaskId[] = [];\n\t\ttry {\n\t\t\tawait this.#session.commitInternal(async (tx) => {\n\t\t\t\tif (!this.#enabled || this.#closing) return;\n\t\t\t\tif (this.#abandoned.size > 0) {\n\t\t\t\t\tconst ids = [...this.#abandoned];\n\t\t\t\t\tconst unmarked = await this.#region(() =>\n\t\t\t\t\t\tids\n\t\t\t\t\t\t\t.map((id) => this.#liveRecord(id))\n\t\t\t\t\t\t\t.filter((record) => record !== undefined && !record.abortRequested),\n\t\t\t\t\t);\n\t\t\t\t\tfor (const record of unmarked) tx.setTask(withAbortMark(record!, \"restart\"));\n\t\t\t\t\tabandoned = ids;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tawait this.#loadScopes(false);\n\t\t\t\t// Every pass picks up sleeps whose time has come: a pass started by any change may be the first to run after\n\t\t\t\t// a deadline, and the wake it schedules no longer keeps a timer for a due sleep.\n\t\t\t\tthis.#wakeDue();\n\t\t\t\tconst plan = await this.#region(() => this.#planReservation(), this.#reloadScopes);\n\t\t\t\tfor (const id of plan.dropped) this.#runnable.delete(id);\n\t\t\t\t// Work below an owner with cancellation intent waits for its cascade mark instead of running a phase; schedule\n\t\t\t\t// the cascade, which may not have run yet.\n\t\t\t\tif (plan.cascade) {\n\t\t\t\t\tthis.#cascadePending = true;\n\t\t\t\t\tthis.#scheduleReconcile();\n\t\t\t\t}\n\t\t\t\t// Taken once per pass, and only when some task is a candidate.\n\t\t\t\tlet snapshot: RegistrySnapshot | undefined;\n\t\t\t\tfor (const record of plan.ready) {\n\t\t\t\t\tconst id = record.id;\n\t\t\t\t\tconst mode = record.abortRequested ? \"abort\" : \"run\";\n\t\t\t\t\t// Work cut off `restartLimit` times in a row would run forever: an abort handler, or a phase of a kind that\n\t\t\t\t\t// does not end itself at the limit, ends the task `faulted` instead.\n\t\t\t\t\t// The settings are read only for a task that was cut off at all.\n\t\t\t\t\tconst cutOff = record.restarts !== undefined && record.restarts >= this.#restartLimit();\n\t\t\t\t\tif (cutOff && (mode === \"abort\" || !this.#limitsRestarts(record.kind))) {\n\t\t\t\t\t\tconst message =\n\t\t\t\t\t\t\tmode === \"abort\"\n\t\t\t\t\t\t\t\t? `Abort handler of task ${id} (${record.kind}) was cut off ${record.restarts} times`\n\t\t\t\t\t\t\t\t: `Task ${id} (${record.kind}) was cut off ${record.restarts} times without progress`;\n\t\t\t\t\t\tawait this.#terminate(tx, record, {\n\t\t\t\t\t\t\tstatus: \"faulted\",\n\t\t\t\t\t\t\terror: { message, detail: { reason: \"restart_limit\" } },\n\t\t\t\t\t\t});\n\t\t\t\t\t\tfaulted.push({ record, message });\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tsnapshot ??= this.#registry.snapshot();\n\t\t\t\t\tconst resolution = this.#resolve(record, snapshot);\n\t\t\t\t\tif (resolution.kind === \"blocked\") {\n\t\t\t\t\t\t// An abandoned task waits for its definition, so its abort handler can clean up.\n\t\t\t\t\t\tif (mode === \"abort\" && record.abortReason === undefined) {\n\t\t\t\t\t\t\tawait this.#terminate(tx, record, { status: \"orphaned\", reason: resolution.reason });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (resolution.record !== record || record.state.status !== \"running\") {\n\t\t\t\t\t\ttx.setTask(\n\t\t\t\t\t\t\twithState(resolution.record, {\n\t\t\t\t\t\t\t\tstatus: \"running\",\n\t\t\t\t\t\t\t\tcheckpoint: resolution.record.state.checkpoint,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\t// Registered on the line, so marks and later reservations see it and close joins it; `#end` makes it a\n\t\t\t\t\t// candidate again.\n\t\t\t\t\tthis.#runnable.delete(id);\n\t\t\t\t\tconst invocation = this.#createInvocation(record, mode, installerOf(snapshot, resolution.task));\n\t\t\t\t\treservations.push({ invocation, task: resolution.task, snapshot });\n\t\t\t\t}\n\t\t\t}, this.#context);\n\t\t} catch (error) {\n\t\t\tfor (const { invocation } of reservations) {\n\t\t\t\tthis.#invocations.delete(invocation.taskId);\n\t\t\t\tthis.#runnable.add(invocation.taskId);\n\t\t\t\tinvocation.finish();\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t\tfor (const { record, message } of faulted) {\n\t\t\tthis.#report(new Error(message), {\n\t\t\t\tkind: \"task_faulted\",\n\t\t\t\t...this.#aboutTask(recordTask(record)),\n\t\t\t\treason: \"restart_limit\",\n\t\t\t});\n\t\t}\n\t\t// Marked, or already marked or gone: done with them. Reserve again, now seeing the marks.\n\t\tfor (const id of abandoned) this.#abandoned.delete(id);\n\t\tif (abandoned.length > 0) this.#dirty = true;\n\t\treturn reservations;\n\t}\n\n\t/**\n\t * A reservation pass's decision region: the candidates it drops (gone, holding, waiting, asleep, or with an\n\t * invocation), whether one waits for a cascade, and the runnable records to resolve. Iterating the candidates is not\n\t * keyed: a pass that misses a task a pending commit makes runnable only delays it, as does skipping one with an\n\t * invocation without reading its record, or a waiter's check whether what it waits on is still live.\n\t */\n\t#planReservation(): {\n\t\treadonly dropped: readonly TaskId[];\n\t\treadonly cascade: boolean;\n\t\treadonly ready: readonly RunnableTaskRecord[];\n\t} {\n\t\tconst dropped: TaskId[] = [];\n\t\tconst ready: RunnableTaskRecord[] = [];\n\t\tlet cascade = false;\n\t\tfor (const id of this.#runnable) {\n\t\t\tif (this.#invocations.has(id)) {\n\t\t\t\tdropped.push(id);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst record = this.#liveRecord(id);\n\t\t\t// It returns once what it waits for ends, its record changes, or the work below it ends; a sleep at the first pass\n\t\t\t// after its time comes, which the timer, `resume()`, or any change starts.\n\t\t\tif (\n\t\t\t\trecord === undefined ||\n\t\t\t\trecord.state.status === \"completing\" ||\n\t\t\t\tthis.#waitingOn(record, true).length > 0 ||\n\t\t\t\tthis.#notDue(record)\n\t\t\t) {\n\t\t\t\tdropped.push(id);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!record.abortRequested && !record.background && this.#belowCancelled(parentOf(record))) {\n\t\t\t\tcascade = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tready.push(record as RunnableTaskRecord);\n\t\t}\n\t\treturn { dropped, cascade, ready };\n\t}\n\n\t/**\n\t * Live tasks a task waits for before its next invocation: its live ordinary owned work when abort-marked, since\n\t * abort runs bottom-up, otherwise the live part of the `on` of a wait.\n\t */\n\t#waitingOn(record: AnyTaskRecord, first = false): readonly TaskId[] {\n\t\tif (record.abortRequested) return this.#ownedLive(record.id, { first });\n\t\tif (record.state.status !== \"waiting\") return [];\n\t\tif (!first) return record.state.on.filter((id) => this.#live.has(id));\n\t\tconst live = record.state.on.find((id) => this.#live.has(id));\n\t\treturn live === undefined ? [] : [live];\n\t}\n\n\t/** Resolve the record's definition by kind, migrating an older stored version. */\n\t#resolve(record: RunnableTaskRecord, snapshot: RegistrySnapshot): Resolution {\n\t\tconst fit = this.#fit(record, snapshot.task(record.kind));\n\t\tif (\"reason\" in fit) return { kind: \"blocked\", reason: fit.reason };\n\t\tif (!fit.migrates) return { kind: \"ready\", task: fit.task, record };\n\t\tconst definition = erased(fit.task);\n\t\ttry {\n\t\t\tif (definition.migrate === undefined) throw missingMigration(record, definition);\n\t\t\tconst migrated = definition.migrate(record.input, record.state.checkpoint, record.version);\n\t\t\tconst state = { ...record.state, checkpoint: copyJson(migrated.checkpoint) };\n\t\t\tconst migratedRecord = { ...record, version: definition.version, input: copyJson(migrated.input), state };\n\t\t\treturn { kind: \"ready\", task: fit.task, record: migratedRecord as RunnableTaskRecord };\n\t\t} catch (error) {\n\t\t\tthis.#failedMigrations.set(record.id, { task: fit.task, error });\n\t\t\t// Blocked now without a commit: the graph and the host's wake must hear it.\n\t\t\tqueueMicrotask(() => this.#notifyBlocked());\n\t\t\tthis.#scheduleWake();\n\t\t\tconst extension = installerOf(snapshot, fit.task);\n\t\t\tthis.#report(error, { kind: \"migration_failed\", ...this.#aboutTask({ ...recordTask(record), extension }) });\n\t\t\treturn { kind: \"blocked\", reason: \"migration_failed\" };\n\t\t}\n\t}\n\n\t#fit(record: Pick<AnyTaskRecord, \"id\" | \"version\">, task: AnyTask | undefined): Fit {\n\t\tif (task === undefined) return { reason: \"missing_task\" };\n\t\tconst version = task.definition.version;\n\t\tif (version === record.version) return { task, migrates: false };\n\t\tif (version < record.version) return { reason: \"task_too_old\" };\n\t\tconst failed = this.#failedMigrations.get(record.id);\n\t\tif (failed?.task === task) return { reason: \"migration_failed\", error: failed.error };\n\t\treturn { task, migrates: true };\n\t}\n\n\t/** Sizes of the ownership indexes, for tests that bound the scheduler's memory. */\n\tget indexSizes(): Readonly<\n\t\tRecord<\"live\" | \"settled\" | \"edges\" | \"below\" | \"roots\" | \"unloaded\" | \"dropQueue\" | \"pins\", number>\n\t> {\n\t\tlet below = 0;\n\t\tfor (const children of this.#below.values()) below += children.size;\n\t\treturn {\n\t\t\tlive: this.#live.size,\n\t\t\tsettled: this.#settled.size,\n\t\t\tedges: this.#edges.size,\n\t\t\tbelow,\n\t\t\troots: this.#roots.size,\n\t\t\tunloaded: this.#unloaded.size,\n\t\t\tdropQueue: this.#dropQueue.size,\n\t\t\tpins: this.#pins.size,\n\t\t};\n\t}\n\n\t/**\n\t * The kept contexts' idle state, for tests (a diagnostic, computed on demand): how many are kept and how many are\n\t * idle, how many disagree with a full recompute (an idle period without `#idle()`, or `#idle()` without one; an\n\t * expiry order that differs from the idle periods, or is not sorted), and how many idle checks covered every scope.\n\t */\n\tget idleState(): Readonly<Record<\"contexts\" | \"idleContexts\" | \"idleMismatches\" | \"fullIdleChecks\", number>> {\n\t\tlet mismatches = 0;\n\t\tlet idle = 0;\n\t\tfor (const [conversationId, kept] of this.#contexts) {\n\t\t\tif (kept.idleSince !== undefined) idle++;\n\t\t\tif ((kept.idleSince !== undefined) !== this.#idle(conversationId)) mismatches++;\n\t\t\tif (this.#idleOrder.get(conversationId) !== kept.idleSince) mismatches++;\n\t\t}\n\t\tlet previous = Number.NEGATIVE_INFINITY;\n\t\tfor (const [conversationId, idleSince] of this.#idleOrder) {\n\t\t\tif (idleSince < previous || this.#contexts.get(conversationId)?.idleSince !== idleSince) mismatches++;\n\t\t\tprevious = idleSince;\n\t\t}\n\t\treturn {\n\t\t\tcontexts: this.#contexts.size,\n\t\t\tidleContexts: idle,\n\t\t\tidleMismatches: mismatches,\n\t\t\tfullIdleChecks: this.#fullIdleChecks,\n\t\t};\n\t}\n\n\t/**\n\t * Scheduling state and every live task with its derived state, read on the Session line. Runs no task code: a\n\t * pending migration shows as `ready` with `migrates`, and only a migration the scheduler already tried, or one that\n\t * cannot exist, shows as failed.\n\t */\n\tasync inspect(\n\t\tsnapshot: RegistrySnapshot,\n\t): Promise<{ scheduling: HarnessInspection[\"scheduling\"]; tasks: TaskInspection[] }> {\n\t\tawait this.#published();\n\t\tawait this.#loadScopes(false);\n\t\tconst tasks: TaskInspection[] = [];\n\t\tfor (const record of this.#live.values()) tasks.push({ record, state: this.#inspectTask(record, snapshot) });\n\t\tconst scheduling = this.#closing ? \"closing\" : this.#enabled ? \"running\" : \"paused\";\n\t\treturn { scheduling, tasks };\n\t}\n\n\t#inspectTask(record: AnyTaskRecord, snapshot: RegistrySnapshot): TaskInspection[\"state\"] {\n\t\tif (this.#invocations.has(record.id)) return { kind: \"running\" };\n\t\tif (record.state.status === \"completing\") return { kind: \"completing\" };\n\t\tconst on = this.#waitingOn(record);\n\t\tif (on.length > 0) return { kind: \"waiting\", on };\n\t\tif (this.#notDue(record)) return { kind: \"sleeping\", until: record.state.until };\n\t\tconst fit = this.#fit(record, snapshot.task(record.kind));\n\t\tif (\"reason\" in fit) return { kind: \"blocked\", ...fit };\n\t\tif (fit.migrates && fit.task.definition.migrate === undefined) {\n\t\t\treturn { kind: \"blocked\", reason: \"migration_failed\", error: missingMigration(record, erased(fit.task)) };\n\t\t}\n\t\treturn { kind: \"pending\", migrates: fit.migrates };\n\t}\n\n\t#createInvocation(record: RunnableTaskRecord, mode: \"run\" | \"abort\", extension: string | undefined): Invocation {\n\t\tconst controller = new AbortController();\n\t\tconst { promise: done, resolve: finish } = Promise.withResolvers<void>();\n\t\tconst invocation: Invocation = {\n\t\t\ttaskId: record.id,\n\t\t\tkind: record.kind,\n\t\t\textension,\n\t\t\tconversationId: record.conversationId,\n\t\t\tmode,\n\t\t\tcontroller,\n\t\t\tlinks: record.startedAt === undefined ? record.links : undefined,\n\t\t\tcontext: withAbortSignal(controller.signal, this.#context),\n\t\t\trecord: record as TaskRecord<JsonValue, Checkpoint, JsonValue>,\n\t\t\twatches: new Set(),\n\t\t\ttimers: new Set(),\n\t\t\tended: false,\n\t\t\tdone,\n\t\t\tfinish: () => finish(),\n\t\t};\n\t\tthis.#invocations.set(record.id, invocation);\n\t\treturn invocation;\n\t}\n\n\t#start(reservation: Reservation): void {\n\t\tconst invocation = reservation.invocation;\n\t\tvoid (async () => {\n\t\t\ttry {\n\t\t\t\tif (invocation.mode === \"run\") await this.#run(reservation);\n\t\t\t\telse await this.#runAbort(reservation);\n\t\t\t} catch (error) {\n\t\t\t\tthis.#report(error, { kind: \"task_error\", ...this.#aboutTask(invocation) }, invocation.context);\n\t\t\t} finally {\n\t\t\t\tthis.#end(invocation);\n\t\t\t\tinvocation.record = undefined;\n\t\t\t\tinvocation.links = undefined;\n\t\t\t\tinvocation.fault = undefined;\n\t\t\t\tinvocation.finish();\n\t\t\t\tthis.#kick();\n\t\t\t}\n\t\t})();\n\t}\n\n\t/** Run phase handlers, each preceded by a step that decides on the line whether the invocation continues. */\n\tasync #run(reservation: Reservation): Promise<void> {\n\t\tconst invocation = reservation.invocation;\n\t\tconst state = { task: reservation.task, snapshot: reservation.snapshot, reported: undefined as ReportedTask };\n\t\tconst phase: Phase = { snapshot: () => state.snapshot, task: () => state.task, agent: undefined };\n\t\tconst runtime = this.#runtime(invocation, phase);\n\t\tconst progress = (tx: Transaction, current: ErasedRunningTask) =>\n\t\t\tthis.#progress(tx, current, state, invocation.extension, invocation.context);\n\t\tlet current = await this.#step(invocation, (task) => this.#rules(task, undefined), progress);\n\t\twhile (current !== undefined && !this.#closing) {\n\t\t\tconst task = current;\n\t\t\tcurrent = await this.#phase(invocation, task, async () => {\n\t\t\t\tconst checkpoint = task.state.checkpoint;\n\t\t\t\t// Each phase handler resolves its agent afresh, at first use.\n\t\t\t\tphase.agent = undefined;\n\t\t\t\tlet previous: PhaseResult;\n\t\t\t\ttry {\n\t\t\t\t\tawait erased(state.task).phases[checkpoint.phase]!(task, runtime, invocation.context);\n\t\t\t\t\tprevious = { checkpoint };\n\t\t\t\t} catch (error) {\n\t\t\t\t\tprevious = { checkpoint, failure: { error } };\n\t\t\t\t}\n\t\t\t\treturn this.#step(invocation, (next) => this.#rules(next, previous), progress);\n\t\t\t});\n\t\t}\n\t}\n\n\t/** A phase owns its decision commit, not the next handler, a durable wait, or recovery. */\n\t#phase<T>(invocation: Invocation, task: ErasedRunningTask, run: () => Promise<T>): Promise<T> {\n\t\tconst parent =\n\t\t\ttask.trace === undefined\n\t\t\t\t? this.#telemetry\n\t\t\t\t: (this.#telemetry.propagation?.extract(task.trace) ?? this.#telemetry);\n\t\tconst checkpoint = task.state.checkpoint;\n\t\tconst attempt = checkpoint.attempt;\n\t\tconst resumed = this.#resumed.delete(task.id);\n\t\treturn createTypedSpanStarter(parent, [DURABLE_TELEMETRY_SCHEMA])(\n\t\t\t\"pi.durable.phase\",\n\t\t\t{\n\t\t\t\t\"task.id\": task.id,\n\t\t\t\t\"task.name\": task.kind,\n\t\t\t\tphase: checkpoint.phase,\n\t\t\t\tkind: invocation.mode,\n\t\t\t\tresumed,\n\t\t\t\t...(attempt === undefined ? {} : { attempt }),\n\t\t\t},\n\t\t\tasync (span) => {\n\t\t\t\tif (span.propagation !== undefined && invocation.links !== undefined) {\n\t\t\t\t\tfor (const carrier of invocation.links) span.addLink({ context: span.propagation.extract(carrier) });\n\t\t\t\t}\n\t\t\t\tconst previous = invocation.context;\n\t\t\t\tinvocation.context = withTelemetry(span, previous);\n\t\t\t\tconst started = performance.now();\n\t\t\t\ttry {\n\t\t\t\t\treturn await run();\n\t\t\t\t} finally {\n\t\t\t\t\tinvocation.context = previous;\n\t\t\t\t\tconst state = invocation.record!.state;\n\t\t\t\t\tconst terminal =\n\t\t\t\t\t\tinvocation.fault ??\n\t\t\t\t\t\t(state.status === \"terminal\" || state.status === \"completing\" ? state.outcome : undefined);\n\t\t\t\t\tconst outcome =\n\t\t\t\t\t\tterminal !== undefined\n\t\t\t\t\t\t\t? terminal.status === \"completed\"\n\t\t\t\t\t\t\t\t? \"done\"\n\t\t\t\t\t\t\t\t: terminal.status === \"aborted\"\n\t\t\t\t\t\t\t\t\t? \"aborted\"\n\t\t\t\t\t\t\t\t\t: \"faulted\"\n\t\t\t\t\t\t\t: state.status === \"waiting\" || state.status === \"sleeping\"\n\t\t\t\t\t\t\t\t? state.status\n\t\t\t\t\t\t\t\t: invocation.ended || this.#closing\n\t\t\t\t\t\t\t\t\t? \"aborted\"\n\t\t\t\t\t\t\t\t\t: `next=${state.checkpoint!.phase}`;\n\t\t\t\t\tspan.setAttributes({ outcome });\n\t\t\t\t\tif (terminal?.status === \"faulted\" || terminal?.status === \"failed\" || terminal?.status === \"orphaned\") {\n\t\t\t\t\t\tconst message = terminal.status === \"orphaned\" ? terminal.reason : terminal.error.message;\n\t\t\t\t\t\tspan.setStatus({\n\t\t\t\t\t\t\tstatus: \"error\",\n\t\t\t\t\t\t\terror: { name: `task_${terminal.status}`, message: ownedSlice(message, 0, 500) },\n\t\t\t\t\t\t});\n\t\t\t\t\t} else if (outcome === \"aborted\") {\n\t\t\t\t\t\tspan.setStatus({ status: \"ok\" });\n\t\t\t\t\t}\n\t\t\t\t\tthis.#durationMetric.record(\n\t\t\t\t\t\tperformance.now() - started,\n\t\t\t\t\t\t{ task: task.kind, phase: checkpoint.phase, outcome },\n\t\t\t\t\t\tspan,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * Precedence rules for a run invocation, a decision region of its step. Rules 1 (terminal, `completing`, `waiting`, or\n\t * `sleeping`) and 2 (closing) are applied by `#step`. Progress (rule 5) is decided by `#progress()` once the decision\n\t * stands, as it takes a registry snapshot.\n\t */\n\t#rules(current: ErasedRunningTask, previous: PhaseResult | undefined): StepPlan {\n\t\t// 3. abort mark: end; a fresh abort invocation starts once the task's ordinary owned work is gone.\n\t\tif (current.abortRequested) return END;\n\t\t// An owner's cancellation intent ends it too, before its cascade marks it; reservation then holds it back.\n\t\tif (!current.background && this.#belowCancelled(parentOf(current))) return CASCADE;\n\t\tif (previous === undefined) return CONTINUE;\n\t\t// 4. uncaught error.\n\t\tif (previous.failure !== undefined) return { kind: \"fault\", error: previous.failure.error };\n\t\t// 6. no durable progress.\n\t\tif (jsonEqual(current.state.checkpoint, previous.checkpoint)) {\n\t\t\tconst message = `Task ${current.kind} phase ${previous.checkpoint.phase} returned without durable progress`;\n\t\t\treturn { kind: \"fault\", error: new Error(message) };\n\t\t}\n\t\treturn PROGRESS;\n\t}\n\n\t/**\n\t * Rule 5, progress: refresh the snapshot; hand over to a replacement definition that can take the task, writing it\n\t * back as `pending`, or keep running under the old one, reported once per resolved definition. Returns whether the\n\t * invocation continues.\n\t */\n\t#progress(\n\t\ttx: Transaction,\n\t\tcurrent: ErasedRunningTask,\n\t\tstate: { task: AnyTask; snapshot: RegistrySnapshot; reported: ReportedTask },\n\t\textension: string | undefined,\n\t\tcontext: Context,\n\t): boolean {\n\t\tstate.snapshot = this.#registry.snapshot();\n\t\tconst next = state.snapshot.task(current.kind);\n\t\tif (next === state.task) return true;\n\t\tif (next !== undefined && canReserve(next, current)) {\n\t\t\ttx.setTask(withState(current, { status: \"pending\", checkpoint: current.state.checkpoint }));\n\t\t\treturn false;\n\t\t}\n\t\tif (state.reported === undefined || state.reported.task !== next) {\n\t\t\tstate.reported = { task: next };\n\t\t\tthis.#report(\n\t\t\t\tnew Error(`Task ${current.id} keeps running under its old ${current.kind} definition`),\n\t\t\t\t{\n\t\t\t\t\tkind: \"task_outdated\",\n\t\t\t\t\t...this.#aboutTask({ ...recordTask(current), extension }),\n\t\t\t\t\treason: outdatedReason(next, current),\n\t\t\t\t},\n\t\t\t\tcontext,\n\t\t\t);\n\t\t}\n\t\treturn true;\n\t}\n\n\t/** Run the abort handler once; rules 1, 2, and 4 apply, and returning without an outcome faults. */\n\tasync #runAbort(reservation: Reservation): Promise<void> {\n\t\tconst invocation = reservation.invocation;\n\t\tconst current = this.#live.get(invocation.taskId) as ErasedRunningTask | undefined;\n\t\tif (current === undefined || this.#closing) return;\n\t\tawait this.#phase(invocation, current, async () => {\n\t\t\tlet failure: { readonly error: unknown } | undefined;\n\t\t\ttry {\n\t\t\t\tconst phase: Phase = {\n\t\t\t\t\tsnapshot: () => reservation.snapshot,\n\t\t\t\t\ttask: () => reservation.task,\n\t\t\t\t\tagent: undefined,\n\t\t\t\t};\n\t\t\t\tconst runtime = this.#runtime(invocation, phase);\n\t\t\t\tawait erased(reservation.task).abort(current, runtime, invocation.context);\n\t\t\t} catch (error) {\n\t\t\t\tfailure = { error };\n\t\t\t}\n\t\t\tconst message = `Abort handler of task ${invocation.taskId} returned without a terminal outcome`;\n\t\t\tawait this.#step(invocation, () => ({ kind: \"fault\", error: failure?.error ?? new Error(message) }));\n\t\t});\n\t}\n\n\t/**\n\t * One decision on the Session line, before a phase: a decision region (`#region()`) that reads the task's record. A\n\t * task that is no longer running (rule 1: terminal, `completing`, `waiting`, or `sleeping`) or a closing Harness (rule\n\t * 2) ends the invocation without a write; otherwise `plan` decides, and a decision that stands is applied: the\n\t * invocation continues, with `progress` for rule 5, or ends, with a fault written. Ending happens inside the callback,\n\t * before a fault's Harness cleanup. A rejected step, such as admission after close, also ends the invocation. Its\n\t * outcome goes to the invocation only, so it is a scheduler commit (`commitInternal()`).\n\t */\n\tasync #step(\n\t\tinvocation: Invocation,\n\t\tplan: (current: ErasedRunningTask) => StepPlan,\n\t\tprogress?: (tx: Transaction, current: ErasedRunningTask) => boolean,\n\t): Promise<ErasedRunningTask | undefined> {\n\t\tlet fault: { readonly error: unknown } | undefined;\n\t\ttry {\n\t\t\tconst continued = await this.#session.commitInternal(async (tx) => {\n\t\t\t\tconst decided = await this.#region(() => {\n\t\t\t\t\tconst found = this.#liveRecord(invocation.taskId);\n\t\t\t\t\tif (found?.state.status !== \"running\" || this.#closing) return { plan: END };\n\t\t\t\t\tconst current = found as ErasedRunningTask;\n\t\t\t\t\treturn { current, plan: plan(current) };\n\t\t\t\t});\n\t\t\t\tconst { current } = decided;\n\t\t\t\tconst step = decided.plan;\n\t\t\t\tif (step.kind === \"continue\") return current;\n\t\t\t\tif (step.kind === \"progress\" && progress!(tx, current!)) return current;\n\t\t\t\tthis.#end(invocation);\n\t\t\t\tif (step.kind === \"cascade\") {\n\t\t\t\t\tthis.#cascadePending = true;\n\t\t\t\t\tthis.#scheduleReconcile();\n\t\t\t\t}\n\t\t\t\tif (step.kind === \"fault\") {\n\t\t\t\t\tfault = { error: step.error };\n\t\t\t\t\tconst message = errorMessage(step.error);\n\t\t\t\t\tinvocation.fault = { status: \"faulted\", error: { message } };\n\t\t\t\t\tawait this.#terminate(tx, current!, invocation.fault);\n\t\t\t\t}\n\t\t\t\treturn undefined;\n\t\t\t}, withoutAbortSignal(invocation.context));\n\t\t\t// Reported once the fault is durable: a host may count it, for example toward a breaker.\n\t\t\tif (fault !== undefined)\n\t\t\t\tthis.#report(\n\t\t\t\t\tfault.error,\n\t\t\t\t\t{ kind: \"task_faulted\", ...this.#aboutTask(invocation), reason: \"threw\" },\n\t\t\t\t\tinvocation.context,\n\t\t\t\t);\n\t\t\treturn continued;\n\t\t} catch (error) {\n\t\t\t// The step writes the scheduler's own decision, a fault or a terminal record; a throw there would otherwise\n\t\t\t// leave the task running, to be reserved and run again.\n\t\t\tthis.#end(invocation);\n\t\t\tthis.#failSession(error, invocation.context);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t/**\n\t * Write an outcome the scheduler decided. While the task's ordinary owned work is live it holds as `completing` and\n\t * its Harness cleanup waits for the final commit (spec §5.5, rule 4); otherwise it is terminal with its cleanup.\n\t */\n\tasync #terminate(tx: Transaction, record: AnyTaskRecord, outcome: SchedulerOutcome): Promise<void> {\n\t\tawait this.#loadScopes(false);\n\t\tif (await this.#region(() => this.#hasOwnedLive(record.id, overlayOf(tx)), this.#reloadScopes)) {\n\t\t\ttx.setTask(withState(record, { status: \"completing\", outcome }));\n\t\t\treturn;\n\t\t}\n\t\ttx.setTask(withState(record, { status: \"terminal\", outcome }));\n\t\tawait this.#settleOutcome(tx, record, outcome);\n\t}\n\n\t/**\n\t * Replace a running task's state with what it committed. A terminal state holds as `completing` while ordinary owned\n\t * work is live, judged on the commit's candidates, so work the same commit creates below the task counts. A wait is\n\t * validated first.\n\t */\n\tasync #commitState(\n\t\ttx: Transaction,\n\t\tinvocation: Invocation,\n\t\tcurrent: ErasedRunningTask,\n\t\tnext: NextTaskState<Checkpoint, JsonValue>,\n\t): Promise<void> {\n\t\tif (next.status === \"waiting\") await this.#validateWait(tx, invocation, current, next.on, next.policy);\n\t\tif (next.status === \"sleeping\") validateSleep(invocation, current.id, next.until);\n\t\tif (next.status === \"terminal\") {\n\t\t\tconst overlay = overlayOf(tx);\n\t\t\tawait this.#loadScopes(false);\n\t\t\tfor (const record of overlay.tasks.values()) await this.#loadChain(parentOf(record), overlay);\n\t\t\tif (await this.#region(() => this.#hasOwnedLive(current.id, overlayOf(tx)), this.#reloadScopes)) {\n\t\t\t\ttx.setTask(withState(progressed(current), { status: \"completing\", outcome: next.outcome }));\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t// A state the task committed that differs from its current one is progress: its restart count starts over. The\n\t\t// same checkpoint committed again, for example as intent before an effect, is not.\n\t\tconst same = jsonEqual(current.state as unknown as JsonValue, next as unknown as JsonValue);\n\t\ttx.setTask(withState(same ? current : progressed(current), next));\n\t}\n\n\t/**\n\t * A wait names existing tasks, and `failFast` only tasks the waiter owns. It may not close a cycle in the wait-for\n\t * graph, whose edges run from each task to what it waits on and to its live ordinary owned work (spec §5.5); waiting\n\t * on itself or on an owner holding it are the shortest such cycles. An abort handler cannot wait.\n\t *\n\t * Invariant: the wait-for graph is acyclic. Only a wait adds an edge between existing tasks, as a new task has only\n\t * incoming edges, so checking each wait maintains it.\n\t */\n\tasync #validateWait(\n\t\ttx: Transaction,\n\t\tinvocation: Invocation,\n\t\tcurrent: ErasedRunningTask,\n\t\ton: readonly TaskId[],\n\t\tpolicy: string,\n\t): Promise<void> {\n\t\tif (invocation.mode === \"abort\") throw new Error(`Abort handler of task ${current.id} cannot wait`);\n\t\t// Owned work is found by walks down, which need the chains of every live task loaded.\n\t\tawait this.#loadScopes(false);\n\t\t// Tasks in `on` that are not live, read from Storage: terminal, or missing.\n\t\tconst ended = new Map<TaskId, AnyTaskRecord | null>();\n\t\tfor (;;) {\n\t\t\tconst checked = await this.#region(\n\t\t\t\t() => this.#checkWait(current, on, policy, overlayOf(tx), ended),\n\t\t\t\tthis.#reloadScopes,\n\t\t\t);\n\t\t\tif (checked === undefined) return;\n\t\t\tif (\"missing\" in checked) {\n\t\t\t\tfor (const id of checked.missing)\n\t\t\t\t\tended.set(id, (await this.#session.lineStorage.task(id, this.#context)) ?? null);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthrow checked.error;\n\t\t}\n\t}\n\n\t/**\n\t * `#validateWait()`'s decision region: why the wait is refused, `undefined` when it may be stored, or the tasks in\n\t * `on` it needs from Storage first, when `ended` lacks them.\n\t */\n\t#checkWait(\n\t\tcurrent: ErasedRunningTask,\n\t\ton: readonly TaskId[],\n\t\tpolicy: string,\n\t\toverlay: Overlay,\n\t\tended: ReadonlyMap<TaskId, AnyTaskRecord | null>,\n\t): { readonly missing: readonly TaskId[] } | { readonly error: Error } | undefined {\n\t\tconst targets: TaskId[] = [];\n\t\tconst missing: TaskId[] = [];\n\t\tfor (const id of on) {\n\t\t\tconst member = overlay.tasks.get(id) ?? this.#liveRecord(id) ?? ended.get(id);\n\t\t\tif (member === undefined) {\n\t\t\t\tmissing.push(id);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (member === null) return { error: new Error(`Task ${id} does not exist`) };\n\t\t\tif (policy === \"failFast\" && member.owner !== current.id) {\n\t\t\t\treturn { error: new Error(`Task ${current.id} can wait failFast only on tasks it owns; ${id} is not one`) };\n\t\t\t}\n\t\t\t// A live child already holds the waiter (task-owned tasks are never background): waiting on it adds no edge. A\n\t\t\t// terminal task has no edges.\n\t\t\tif (member.state.status !== \"terminal\" && member.owner !== current.id) targets.push(id);\n\t\t}\n\t\tif (missing.length > 0) return { missing };\n\t\tif (targets.length === 0) return undefined;\n\t\tconst cycle = this.#waitCycle(current.id, targets, overlay);\n\t\tif (cycle === undefined) return undefined;\n\t\treturn {\n\t\t\terror: new Error(\n\t\t\t\t`Task ${current.id} cannot wait on ${cycle[0]}: ${[current.id, ...cycle].join(\" -> \")} is a wait cycle`,\n\t\t\t),\n\t\t};\n\t}\n\n\t/**\n\t * The path from a member of `on` back to `task` in the wait-for graph, if the wait would close a cycle (spec §5.1).\n\t * An edge X -> Y means X cannot settle before Y: Y is in the `on` of waiting X that is not abort-marked, or Y is live\n\t * ordinary owned work of X, which holds X as `completing`. Each task is visited once and each subtree walked once,\n\t * so a check is bounded by the live work it reaches. Part of a decision region: it records every record it reads.\n\t * Owned work is found by walks down, which need the chains of every live task loaded.\n\t */\n\t#waitCycle(task: TaskId, on: readonly TaskId[], overlay: Overlay): TaskId[] | undefined {\n\t\tconst from = new Map<TaskId, TaskId | undefined>();\n\t\tconst walked = new Set<TaskId>();\n\t\tconst pending: TaskId[] = [];\n\t\tconst reach = (id: TaskId, via: TaskId | undefined) => {\n\t\t\tif (from.has(id)) return;\n\t\t\tfrom.set(id, via);\n\t\t\tpending.push(id);\n\t\t};\n\t\tconst path = (end: TaskId): TaskId[] => {\n\t\t\tconst steps: TaskId[] = [];\n\t\t\tfor (let at: TaskId | undefined = end; at !== undefined; at = from.get(at)) steps.unshift(at);\n\t\t\treturn steps;\n\t\t};\n\t\tfor (const id of on) reach(id, undefined);\n\t\tfor (let id = pending.pop(); id !== undefined; id = pending.pop()) {\n\t\t\tif (id === task) return path(id);\n\t\t\tconst record = overlay.tasks.get(id) ?? this.#liveRecord(id);\n\t\t\tif (record === undefined || record.state.status === \"terminal\") continue;\n\t\t\t// An abort-marked task waits only for its owned work, as abort runs bottom-up (`#waitingOn`).\n\t\t\tif (record.state.status === \"waiting\" && !record.abortRequested) {\n\t\t\t\tfor (const member of record.state.on) reach(member, id);\n\t\t\t}\n\t\t\tif (walked.has(id)) continue;\n\t\t\twalked.add(id);\n\t\t\t// Below a walked task the walk does not go again: its own walk covered what lies below.\n\t\t\tconst found: TaskId[] = [];\n\t\t\tconst walk = this.#walkDown(id, { overlay, enter: (below) => !walked.has(below) });\n\t\t\tfor (const { id: below, node, live } of walk) {\n\t\t\t\tif (live === undefined || node.background) continue;\n\t\t\t\tfound.push(below);\n\t\t\t\treach(below, id);\n\t\t\t}\n\t\t\tfor (const below of found) walked.add(below);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/** End an invocation: its runtime operations reject from now on, its signal aborts, its watches stop, and its task is free. */\n\t#end(invocation: Invocation): void {\n\t\tif (invocation.ended) return;\n\t\tinvocation.ended = true;\n\t\tif (this.#invocations.get(invocation.taskId) === invocation) {\n\t\t\tthis.#invocations.delete(invocation.taskId);\n\t\t\tif (this.#live.has(invocation.taskId)) this.#runnable.add(invocation.taskId);\n\t\t}\n\t\tfor (const watch of invocation.watches) void watch.stop();\n\t\tfor (const disarm of invocation.timers) disarm();\n\t\tinvocation.timers.clear();\n\t\t// Pending waits bound to the invocation, such as a tool's waitForTask(), reject with it.\n\t\tinvocation.controller.abort(endedError(invocation));\n\t}\n\n\t/** No live non-background task in the scope; a task whose owner edges are not loaded yet counts as inside. */\n\t#idle(conversationId: ConversationId | undefined): boolean {\n\t\tconst scope: Scope = conversationId === undefined ? { roots: true } : { conversation: conversationId };\n\t\t// In a decision region, global idle reads the roots it starts from.\n\t\tif (conversationId === undefined) this.#record(ROOTS_KEY);\n\t\t// Tasks whose chain is not loaded are not listed below their scope yet; one counts as inside unless its walk up\n\t\t// decides otherwise.\n\t\tfor (const id of this.#unloaded) {\n\t\t\tconst record = this.#live.get(id);\n\t\t\tif (record !== undefined && !record.background && this.#inScope(parentOf(record), scope) !== false)\n\t\t\t\treturn false;\n\t\t}\n\t\tconst starts = conversationId === undefined ? this.#roots : [conversationId];\n\t\tfor (const start of starts) {\n\t\t\tfor (const { node, live } of this.#walkDown(conversationNode(start))) {\n\t\t\t\tif (live !== undefined && !node.background) return false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t// ─── Invocation runtime ──────────────────────────────────────────────────\n\n\t#runtime(invocation: Invocation, phase: Phase): ErasedRuntime {\n\t\t// Resolved at most once per phase handler, at first use, with the invocation's context; fixed for the phase.\n\t\tconst agent = (): Promise<Agent> => {\n\t\t\tif (invocation.ended) return Promise.reject(endedError(invocation));\n\t\t\tif (phase.agent === undefined) {\n\t\t\t\tphase.agent = this.#agent(invocation.conversationId, phase.snapshot(), invocation.context);\n\t\t\t\t// A caller that stops waiting must not leave the shared resolution's failure unobserved.\n\t\t\t\tphase.agent.catch(() => {});\n\t\t\t}\n\t\t\treturn phase.agent;\n\t\t};\n\t\tconst hooks: HookRunner<Record<string, unknown>> = {\n\t\t\teach: async (name, invoke) => {\n\t\t\t\tfor (const { extension, handlers } of agentHooks(await agent(), phase.task().definition.name)) {\n\t\t\t\t\tconst handler = (handlers as Record<string, unknown>)[name];\n\t\t\t\t\tif (typeof handler !== \"function\") continue;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait invoke(handler.bind(handlers));\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (invocation.controller.signal.aborted) throw error;\n\t\t\t\t\t\tthis.#report(\n\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t{ kind: \"extension_error\", extension, task: reportTask(invocation) },\n\t\t\t\t\t\t\tinvocation.context,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t\tconst settings = this.#settings;\n\t\tconst models = this.#models;\n\t\treturn {\n\t\t\ttaskId: invocation.taskId as TaskId<JsonValue>,\n\t\t\tconversationId: invocation.conversationId,\n\t\t\tsignal: invocation.controller.signal,\n\t\t\tget models() {\n\t\t\t\treturn models();\n\t\t\t},\n\t\t\tagent: (context) =>\n\t\t\t\tinvocation.ended ? Promise.reject(endedError(invocation)) : awaitWithContext(agent(), context),\n\t\t\tget settings() {\n\t\t\t\treturn settings();\n\t\t\t},\n\t\t\tenv: (context) => this.#read(invocation, () => this.#env(invocation.conversationId, context)),\n\t\t\thooks: hooks as ErasedRuntime[\"hooks\"],\n\t\t\tget registry() {\n\t\t\t\treturn phase.snapshot();\n\t\t\t},\n\t\t\tcommit: async (change, context, options) => {\n\t\t\t\tlet checkpoint: string | undefined;\n\t\t\t\tlet interrupted:\n\t\t\t\t\t| {\n\t\t\t\t\t\t\treadonly message: string;\n\t\t\t\t\t\t\treadonly reason: \"restart_limit\" | \"interrupted\";\n\t\t\t\t\t\t\treadonly restarts: number;\n\t\t\t\t\t }\n\t\t\t\t\t| undefined;\n\t\t\t\tawait this.#gated(\n\t\t\t\t\tinvocation,\n\t\t\t\t\tasync (tx, current) => {\n\t\t\t\t\t\tconst next = await change(tx, current);\n\t\t\t\t\t\tif (next !== undefined) await this.#commitState(tx, invocation, current, next);\n\t\t\t\t\t\tif (next?.status === \"running\" && current.state.checkpoint.phase !== next.checkpoint.phase) {\n\t\t\t\t\t\t\tcheckpoint = next.checkpoint.phase;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// A task that ends for crashes says so (`task_interrupted`), so a host keeps a crash-loop signal.\n\t\t\t\t\t\tif (next?.status === \"terminal\") {\n\t\t\t\t\t\t\tconst restarts = current.restarts ?? 0;\n\t\t\t\t\t\t\tconst reason = next.outcome.status === \"failed\" ? interruptionOf(next.outcome.error) : undefined;\n\t\t\t\t\t\t\tif (reason !== undefined && next.outcome.status === \"failed\") {\n\t\t\t\t\t\t\t\tinterrupted = { message: next.outcome.error.message, reason, restarts };\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// A task that ended for crashes with another outcome says so itself, as a generation whose run\n\t\t\t\t\t\t\t\t// answered ends `completed` without its after-run tasks.\n\t\t\t\t\t\t\t\tconst message = endedByCrashesStates.get(next);\n\t\t\t\t\t\t\t\tif (message !== undefined) interrupted = { message, reason: \"restart_limit\", restarts };\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tcontext,\n\t\t\t\t\toptions,\n\t\t\t\t);\n\t\t\t\tif (interrupted !== undefined) {\n\t\t\t\t\tthis.#report(\n\t\t\t\t\t\tnew Error(interrupted.message),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkind: \"task_interrupted\",\n\t\t\t\t\t\t\t...this.#aboutTask(invocation),\n\t\t\t\t\t\t\treason: interrupted.reason,\n\t\t\t\t\t\t\trestarts: interrupted.restarts,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tinvocation.context,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (checkpoint !== undefined) {\n\t\t\t\t\tinvocation.context.telemetry.addEvent(\"pi.durable.checkpoint\", {\n\t\t\t\t\t\tphase: checkpoint,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\t\t\tmemo: ((name: string, ...rest: readonly unknown[]) => {\n\t\t\t\tif (rest.length === 1) {\n\t\t\t\t\treturn this.#read(invocation, async () => memoOf(this.#live.get(invocation.taskId), name));\n\t\t\t\t}\n\t\t\t\tconst candidate = rest[0] as JsonValue;\n\t\t\t\treturn this.#gated(\n\t\t\t\t\tinvocation,\n\t\t\t\t\t(tx, current) => {\n\t\t\t\t\t\tconst winner = memoOf(current, name);\n\t\t\t\t\t\tif (winner !== undefined) return winner;\n\t\t\t\t\t\ttx.setTask({ ...current, memos: { ...current.memos, [name]: candidate } } as AnyTaskRecord);\n\t\t\t\t\t\treturn candidate;\n\t\t\t\t\t},\n\t\t\t\t\trest[1] as Context,\n\t\t\t\t);\n\t\t\t}) as ErasedRuntime[\"memo\"],\n\t\t\tsleepUntil: (until, checkpoint, context) =>\n\t\t\t\tthis.#gated(\n\t\t\t\t\tinvocation,\n\t\t\t\t\t(tx, current) => this.#commitState(tx, invocation, current, { status: \"sleeping\", checkpoint, until }),\n\t\t\t\t\tcontext,\n\t\t\t\t),\n\t\t\twatchDoc: ((...args: readonly unknown[]) => this.#watchDoc(invocation, args)) as ErasedRuntime[\"watchDoc\"],\n\t\t\tsnapshot: ((...args: readonly unknown[]) =>\n\t\t\t\tthis.#read(invocation, () =>\n\t\t\t\t\tsessionMethod(this.#session, \"snapshot\")(...args),\n\t\t\t\t)) as ErasedRuntime[\"snapshot\"],\n\t\t\tsnapshotAsOf: ((...args: readonly unknown[]) =>\n\t\t\t\tthis.#read(invocation, () =>\n\t\t\t\t\tsessionMethod(this.#session, \"snapshotAsOf\")(...args),\n\t\t\t\t)) as ErasedRuntime[\"snapshotAsOf\"],\n\t\t\tgetTask: ((id: TaskId, context: Context) =>\n\t\t\t\tthis.#read(invocation, () =>\n\t\t\t\t\tthis.#session.readOnLine((storage) => storage.task(id, context)),\n\t\t\t\t)) as ErasedRuntime[\"getTask\"],\n\t\t\twaitForTask: ((id: TaskId, context: Context) =>\n\t\t\t\tthis.#read(invocation, () =>\n\t\t\t\t\tthis.waitForTask(id, withAbortSignal(invocation.controller.signal, context)),\n\t\t\t\t)) as ErasedRuntime[\"waitForTask\"],\n\t\t\townedTasks: (context) =>\n\t\t\t\tthis.#read(invocation, () =>\n\t\t\t\t\tthis.#session.readOnLine(async () => {\n\t\t\t\t\t\t// The step that ends the invocation may have run on the line before this.\n\t\t\t\t\t\tif (invocation.ended) throw endedError(invocation);\n\t\t\t\t\t\tcontext.abortSignal?.throwIfAborted();\n\t\t\t\t\t\t// Every live task is listed under its parent node, its owner task when it has one.\n\t\t\t\t\t\tconst owned = await this.#region(() => {\n\t\t\t\t\t\t\tthis.#record(ownedKey(invocation.taskId));\n\t\t\t\t\t\t\tconst records: AnyTaskRecord[] = [];\n\t\t\t\t\t\t\tfor (const node of this.#below.get(invocation.taskId) ?? []) {\n\t\t\t\t\t\t\t\tconst record = typeof node === \"string\" ? undefined : this.#liveRecord(node);\n\t\t\t\t\t\t\t\tif (record?.owner === invocation.taskId) records.push(record);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn records;\n\t\t\t\t\t\t});\n\t\t\t\t\t\t// Copies, as from storage: the scheduler reads its own.\n\t\t\t\t\t\treturn owned\n\t\t\t\t\t\t\t.sort((a, b) => a.id - b.id)\n\t\t\t\t\t\t\t.map((record) => copyJson(record as unknown as JsonValue) as unknown as AnyTaskRecord);\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\tabortOwned: (id, context) =>\n\t\t\t\tthis.#read(invocation, async () => {\n\t\t\t\t\tconst bound = withAbortSignal(invocation.controller.signal, context);\n\t\t\t\t\tconst record = await this.#session.readOnLine((storage) => storage.task(id, bound));\n\t\t\t\t\tif (record?.owner !== invocation.taskId) {\n\t\t\t\t\t\tthrow new Error(`Task ${id} is not owned by task ${invocation.taskId}`);\n\t\t\t\t\t}\n\t\t\t\t\tif (record.state.status === \"terminal\") return;\n\t\t\t\t\tawait this.abort(id, bound, true);\n\t\t\t\t\tawait this.waitForTask(id, bound);\n\t\t\t\t}),\n\t\t\toutcomes: ((ids: readonly TaskId[], context: Context) =>\n\t\t\t\tthis.#read(invocation, () =>\n\t\t\t\t\tthis.#session.readOnLine(async (storage) => {\n\t\t\t\t\t\tconst outcomes: TaskOutcome<JsonValue>[] = [];\n\t\t\t\t\t\tfor (const id of ids) {\n\t\t\t\t\t\t\tconst state = (await storage.task(id, context))?.state;\n\t\t\t\t\t\t\tif (state?.status !== \"terminal\") throw new Error(`Task ${id} is not terminal`);\n\t\t\t\t\t\t\toutcomes.push(state.outcome);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn outcomes;\n\t\t\t\t\t}),\n\t\t\t\t)) as ErasedRuntime[\"outcomes\"],\n\t\t\tconversation: (id, context) =>\n\t\t\t\tthis.#read(invocation, () =>\n\t\t\t\t\tthis.#conversation(\n\t\t\t\t\t\tid,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsignal: invocation.controller.signal,\n\t\t\t\t\t\t\tcheck: () => {\n\t\t\t\t\t\t\t\tif (invocation.ended) throw endedError(invocation);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\tentry: ((...args: readonly unknown[]) => {\n\t\t\t\tconst [token, id, context] =\n\t\t\t\t\targs.length === 2\n\t\t\t\t\t\t? [undefined, args[0] as EntryId, args[1] as Context]\n\t\t\t\t\t\t: [args[0] as { readonly kind: string }, args[1] as EntryId, args[2] as Context];\n\t\t\t\treturn this.#read(invocation, async () => {\n\t\t\t\t\t// An entry of the conversation's kept context range is committed and visible: no Storage read.\n\t\t\t\t\tconst kept = this.#contexts.get(invocation.conversationId);\n\t\t\t\t\tconst entry =\n\t\t\t\t\t\t(kept === undefined ? undefined : rangeEntry(kept.range, id)) ??\n\t\t\t\t\t\t(await this.#session.readOnLine((storage) => storage.entry(invocation.conversationId, id, context)))\n\t\t\t\t\t\t\t?.entry;\n\t\t\t\t\treturn token === undefined || entry?.kind === token.kind ? entry : undefined;\n\t\t\t\t});\n\t\t\t}) as ErasedRuntime[\"entry\"],\n\t\t\tentries: (query, limit, cursor, context) =>\n\t\t\t\tthis.#read(invocation, () =>\n\t\t\t\t\tthis.#session.readOnLine((storage) =>\n\t\t\t\t\t\tstorage.scanEntries(conversationEntries(invocation.conversationId, query), limit, cursor, context),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\tcontext: (conversationId, context, options) =>\n\t\t\t\tthis.#read(invocation, async () => {\n\t\t\t\t\tconst read = await readContextFrom(\n\t\t\t\t\t\tthis.#session,\n\t\t\t\t\t\tthis.#storage,\n\t\t\t\t\t\tconversationId,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\toptions?.at,\n\t\t\t\t\t\tthis.#contexts.get(conversationId)?.range,\n\t\t\t\t\t);\n\t\t\t\t\tconst { view } = read;\n\t\t\t\t\t// Checked again here, synchronously up to the install below: a commit published since the read returned\n\t\t\t\t\t// was not seen by `#advanceContexts`, so a range that missed it must not be advanced.\n\t\t\t\t\tconst range =\n\t\t\t\t\t\tread.range?.current === true &&\n\t\t\t\t\t\tthis.#session.knownLatestEntryId(conversationId) !== read.range.bounds.tail\n\t\t\t\t\t\t\t? { ...read.range, current: false }\n\t\t\t\t\t\t\t: read.range;\n\t\t\t\t\t// Keep it unless the invocation ended or a concurrent read already kept a newer range.\n\t\t\t\t\tconst kept = this.#contexts.get(conversationId);\n\t\t\t\t\tif (\n\t\t\t\t\t\trange !== undefined &&\n\t\t\t\t\t\t!this.#closing &&\n\t\t\t\t\t\t!invocation.ended &&\n\t\t\t\t\t\t(kept === undefined || kept.range.bounds.tail <= range.bounds.tail)\n\t\t\t\t\t) {\n\t\t\t\t\t\t// A read of another, idle conversation starts or continues its retention period.\n\t\t\t\t\t\tif (!this.#idle(conversationId)) {\n\t\t\t\t\t\t\tthis.#contexts.set(conversationId, { range, idleSince: undefined });\n\t\t\t\t\t\t\tthis.#idleOrder.delete(conversationId);\n\t\t\t\t\t\t} else if (this.#contextRetentionMs() > 0) {\n\t\t\t\t\t\t\t// An idle period that already started keeps its expiry and its place; a new one starts now.\n\t\t\t\t\t\t\tconst idleSince = kept?.idleSince ?? this.#now();\n\t\t\t\t\t\t\tconst expiresAt =\n\t\t\t\t\t\t\t\tkept?.idleSince !== undefined && kept.expiresAt !== undefined\n\t\t\t\t\t\t\t\t\t? kept.expiresAt\n\t\t\t\t\t\t\t\t\t: idleSince + this.#contextRetentionMs();\n\t\t\t\t\t\t\tthis.#contexts.set(conversationId, { range, idleSince, expiresAt });\n\t\t\t\t\t\t\tif (kept?.idleSince === undefined) this.#markIdle(conversationId, idleSince);\n\t\t\t\t\t\t\tthis.#scheduleExpiry();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn view;\n\t\t\t\t}),\n\t\t\tnow: () => {\n\t\t\t\tif (invocation.ended) throw endedError(invocation);\n\t\t\t\treturn this.#now();\n\t\t\t},\n\t\t\tsetTimer: (callback, delayMs) => {\n\t\t\t\t// An ended invocation's timers never fire.\n\t\t\t\tif (invocation.ended) return () => {};\n\t\t\t\tconst disarm = this.#timers.foreground(() => {\n\t\t\t\t\tinvocation.timers.delete(disarm);\n\t\t\t\t\tif (!invocation.ended) callback();\n\t\t\t\t}, delayMs);\n\t\t\t\tinvocation.timers.add(disarm);\n\t\t\t\treturn () => {\n\t\t\t\t\tinvocation.timers.delete(disarm);\n\t\t\t\t\tdisarm();\n\t\t\t\t};\n\t\t\t},\n\t\t\treport: (error, from) => {\n\t\t\t\tif (invocation.ended) throw endedError(invocation);\n\t\t\t\t// The task's own failure names the task's extension; any other names whose code failed, if anyone's.\n\t\t\t\tconst task = reportTask(invocation);\n\t\t\t\tthis.#report(\n\t\t\t\t\terror,\n\t\t\t\t\tfrom === undefined\n\t\t\t\t\t\t? { kind: \"task_error\", ...this.#aboutTask(invocation) }\n\t\t\t\t\t\t: from.kind === \"extension\"\n\t\t\t\t\t\t\t? { kind: \"extension_error\", task, ...optionalExtension(from.extension) }\n\t\t\t\t\t\t\t: { kind: \"host_error\", callback: from.callback, task },\n\t\t\t\t\tinvocation.context,\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * On the line: wait until every commit admitted before is published, for a decision that reads what cannot be keyed,\n\t * every live task (open, inspection) or every task a conversation abort reaches.\n\t */\n\tasync #published(): Promise<void> {\n\t\tconst gate = this.#session.touch(ALL_KEYS);\n\t\tif (gate !== undefined) await gate;\n\t}\n\n\t/** Run a committed-state read unless the invocation has ended. */\n\tasync #read<T>(invocation: Invocation, read: () => Promise<T>): Promise<T> {\n\t\tif (invocation.ended) throw endedError(invocation);\n\t\treturn read();\n\t}\n\n\t/** Commit after rereading the task on the line and gating the invocation. */\n\t#gated<T>(\n\t\tinvocation: Invocation,\n\t\tchange: (tx: Transaction, current: ErasedRunningTask) => T | Promise<T>,\n\t\tcontext: Context,\n\t\toptions?: CommitOptions,\n\t): Promise<T> {\n\t\tif (invocation.ended) return Promise.reject(endedError(invocation));\n\t\treturn this.#session.commitWith(\n\t\t\tasync (tx) => {\n\t\t\t\tif (invocation.ended) throw endedError(invocation);\n\t\t\t\tif (this.#closing) throw closedError(this.#session);\n\t\t\t\tconst current = await this.#region(() => {\n\t\t\t\t\tconst found = this.#liveRecord(invocation.taskId);\n\t\t\t\t\tif (found === undefined) throw new Error(`Task ${invocation.taskId} is terminal`);\n\t\t\t\t\tif (found.state.status !== \"running\")\n\t\t\t\t\t\tthrow new Error(`Task ${invocation.taskId} is ${found.state.status}`);\n\t\t\t\t\tif (invocation.mode === \"run\" && found.abortRequested) {\n\t\t\t\t\t\tthrow new Error(`Task ${invocation.taskId} has a durable abort mark`);\n\t\t\t\t\t}\n\t\t\t\t\treturn found as ErasedRunningTask;\n\t\t\t\t});\n\t\t\t\t// The step that ends it may have run while the region waited.\n\t\t\t\tif (invocation.ended) throw endedError(invocation);\n\t\t\t\treturn change(tx, current);\n\t\t\t},\n\t\t\tcontext,\n\t\t\t{ conversationId: invocation.conversationId, taskId: invocation.taskId },\n\t\t\toptions,\n\t\t);\n\t}\n\n\tasync #watchDoc(invocation: Invocation, args: readonly unknown[]): Promise<DocumentWatch<JsonObject> | undefined> {\n\t\tif (invocation.ended) throw endedError(invocation);\n\t\tconst watch = (await sessionMethod(this.#session, \"watchDoc\")(...args)) as DocumentWatch<JsonObject> | undefined;\n\t\tif (watch === undefined) return undefined;\n\t\tif (invocation.ended) {\n\t\t\tvoid watch.stop();\n\t\t\tthrow endedError(invocation);\n\t\t}\n\t\tinvocation.watches.add(watch);\n\t\tvoid watch.closed.then(() => invocation.watches.delete(watch));\n\t\treturn watch;\n\t}\n}\n\nconst REGISTRY: ReportInfo = { kind: \"host_error\", callback: \"registry\" };\nconst SETTINGS: ReportInfo = { kind: \"host_error\", callback: \"settings\" };\nconst ON_WAKE: ReportInfo = { kind: \"host_error\", callback: \"onWake\" };\nconst TELEMETRY: ReportInfo = { kind: \"host_error\", callback: \"telemetry\" };\n\n/** The extension that installed `task` in `snapshot`, the last one that lists it; none for a built-in task. */\nfunction installerOf(snapshot: RegistrySnapshot, task: AnyTask | undefined): string | undefined {\n\tif (task === undefined) return undefined;\n\treturn snapshot.installed().findLast((installed) => installed.tasks?.includes(task) === true)?.name;\n}\n\n/** The report info of a failure of a task. */\nfunction reportTask(task: {\n\treadonly taskId: TaskId;\n\treadonly kind: string;\n\treadonly conversationId: ConversationId;\n}): ReportTask {\n\treturn { id: task.taskId, kind: task.kind, conversationId: task.conversationId };\n}\n\n/** A stored task's identity, as an invocation names it. */\nfunction recordTask(record: Pick<AnyTaskRecord, \"id\" | \"kind\" | \"conversationId\">) {\n\treturn { taskId: record.id, kind: record.kind, conversationId: record.conversationId };\n}\n\n/**\n * The record with an abort mark: `restart` for an abandonment; without a reason, a request, which replaces `restart`.\n * The restart count starts over: it now counts cut-offs of the abort handler.\n */\n/** Why a failed outcome's error says crashes ended the task (`detail.reason`), if it does. */\n/**\n * Terminal states a built-in task commits because it was cut off `settings.restartLimit` times, when their outcome does\n * not say so (a failure with detail `{ reason: \"restart_limit\" }` does), with the message the scheduler reports them\n * `task_interrupted` with. Keyed by the state object the task returns, so nothing is added to the stored state.\n */\nconst endedByCrashesStates = new WeakMap<object, string>();\n\n/** `state`, marked as ending its task for crashes (`task_interrupted` with `message`), whatever its outcome. */\nexport function endedByCrashes<T extends object>(state: T, message: string): T {\n\tendedByCrashesStates.set(state, message);\n\treturn state;\n}\n\nfunction interruptionOf(error: TaskOutcomeError): \"restart_limit\" | \"interrupted\" | undefined {\n\tconst detail = error.detail;\n\tif (typeof detail !== \"object\" || detail === null || !(\"reason\" in detail)) return undefined;\n\treturn detail.reason === \"restart_limit\" || detail.reason === \"interrupted\" ? detail.reason : undefined;\n}\n\nfunction withAbortMark(record: AnyTaskRecord, reason?: \"restart\"): AnyTaskRecord {\n\tconst { abortReason: _reason, restarts: _restarts, ...rest } = record;\n\treturn { ...rest, abortRequested: true, ...(reason === undefined ? {} : { abortReason: reason }) } as AnyTaskRecord;\n}\n\n/** A live owner's durable cancellation intent: its abort mark, or a held outcome other than `completed`. */\nfunction cancellationIntent(record: AnyTaskRecord): boolean {\n\treturn record.state.status !== \"terminal\" && (record.abortRequested || failedOutcome(record));\n}\n\n/**\n * Whether replacing `previous` (absent: a new task) with `next` changes the cancellation intent set or what it means: a\n * mark set, upgraded, or cleared, or a held or ended outcome other than `completed`.\n */\nfunction intentChanges(previous: AnyTaskRecord | undefined, next: AnyTaskRecord): boolean {\n\treturn (\n\t\t(previous?.abortRequested ?? false) !== next.abortRequested ||\n\t\tprevious?.abortReason !== next.abortReason ||\n\t\t(previous !== undefined && failedOutcome(previous)) !== failedOutcome(next) ||\n\t\t(previous !== undefined && cancellationIntent(previous)) !== cancellationIntent(next)\n\t);\n}\n\n/** Whether the record holds or ends with an outcome other than `completed`. */\nfunction failedOutcome(record: AnyTaskRecord): boolean {\n\tconst state = record.state;\n\treturn (state.status === \"completing\" || state.status === \"terminal\") && state.outcome.status !== \"completed\";\n}\n\nfunction parentOf(node: TaskNode): Up {\n\treturn node.owner !== undefined ? { task: node.owner } : { conversation: node.conversationId };\n}\n\nfunction nodeOf(record: AnyTaskRecord): TaskNode {\n\treturn {\n\t\tconversationId: record.conversationId,\n\t\t...(record.owner === undefined ? {} : { owner: record.owner }),\n\t\tbackground: record.background,\n\t};\n}\n\nfunction overlayOf(tx: Transaction): Overlay {\n\tconst tasks = new Map(tx.stagedTasks().map((record) => [record.id, record]));\n\tconst edges = new Map(tx.stagedConversations().map((record) => [record.id, record.owner?.taskId ?? null]));\n\treturn { tasks, edges };\n}\n\nfunction addTo<K, V>(map: Map<K, Set<V>>, key: K, value: V): void {\n\tconst values = map.get(key);\n\tif (values === undefined) map.set(key, new Set([value]));\n\telse values.add(value);\n}\n\nfunction deleteFrom<K, V>(map: Map<K, Set<V>>, key: K, value: V): void {\n\tconst values = map.get(key);\n\tif (values === undefined) return;\n\tvalues.delete(value);\n\tif (values.size === 0) map.delete(key);\n}\n\n/** Own memo entry only; memo names such as `toString` must not resolve to inherited properties. */\nfunction memoOf(record: AnyTaskRecord | undefined, name: string): JsonValue | undefined {\n\tconst memos = record?.memos;\n\treturn memos !== undefined && Object.hasOwn(memos, name) ? memos[name] : undefined;\n}\n\n/** Overloaded Session method bound for forwarding an argument list unchanged. */\nfunction sessionMethod(\n\tsession: SessionImpl,\n\tname: \"snapshot\" | \"snapshotAsOf\" | \"watchDoc\",\n): (...args: readonly unknown[]) => Promise<unknown> {\n\treturn (session[name] as (...args: readonly unknown[]) => Promise<unknown>).bind(session);\n}\n\nfunction missingMigration(record: AnyTaskRecord, definition: ErasedDefinition): Error {\n\treturn new Error(`Task ${record.kind} version ${definition.version} has no migration from ${record.version}`);\n}\n\nfunction erased(task: AnyTask): ErasedDefinition {\n\treturn task.definition as unknown as ErasedDefinition;\n}\n\nfunction endedError(invocation: Invocation): Error {\n\treturn new Error(`Task ${invocation.taskId} invocation has ended`);\n}\n\n/** The record without its restart count, as after a state the task committed. */\nfunction progressed(record: AnyTaskRecord): AnyTaskRecord {\n\tif (record.restarts === undefined) return record;\n\tconst { restarts: _restarts, ...rest } = record;\n\treturn rest as AnyTaskRecord;\n}\n\n/** Replace a live record's state; memos and the restart count disappear once an outcome is decided. */\nfunction withState(record: AnyTaskRecord, state: TaskState<JsonValue, JsonValue>): AnyTaskRecord {\n\tif (state.status !== \"terminal\" && state.status !== \"completing\") return { ...record, state } as AnyTaskRecord;\n\tconst { memos: _memos, restarts: _restarts, ...rest } = record;\n\treturn { ...rest, state };\n}\n\n/** Whether a definition can take the task at reservation: same version, or newer with a migration. */\n/**\n * Why a replacement definition cannot take a running task, in `#fit()`'s words: none is registered, it is older than\n * the task, or it is newer without a `migrate`.\n */\nfunction outdatedReason(task: AnyTask | undefined, record: AnyTaskRecord): BlockedReason {\n\tif (task === undefined) return \"missing_task\";\n\treturn task.definition.version < record.version ? \"task_too_old\" : \"migration_failed\";\n}\n\nfunction canReserve(task: AnyTask, record: AnyTaskRecord): boolean {\n\tconst definition = task.definition;\n\treturn (\n\t\tdefinition.version === record.version || (definition.version > record.version && definition.migrate !== undefined)\n\t);\n}\n\n/** A sleep's `until` is a time on the Harness clock; an abort handler cannot sleep. */\nfunction validateSleep(invocation: Invocation, task: TaskId, until: number): void {\n\tif (invocation.mode === \"abort\") throw new Error(`Abort handler of task ${task} cannot sleep`);\n\tif (typeof until !== \"number\" || !Number.isFinite(until) || until < 0) {\n\t\tthrow new Error(`Task ${task} cannot sleep until ${until}: not a time in milliseconds`);\n\t}\n}\n\n/** Structural equality of two JSON values; object key order is ignored. */\nfunction jsonEqual(left: JsonValue | undefined, right: JsonValue | undefined): boolean {\n\tif (left === right) return true;\n\tif (typeof left !== \"object\" || typeof right !== \"object\" || left === null || right === null) return false;\n\tif (Array.isArray(left) || Array.isArray(right)) {\n\t\tif (!Array.isArray(left) || !Array.isArray(right) || left.length !== right.length) return false;\n\t\treturn left.every((value, index) => jsonEqual(value, right[index]));\n\t}\n\tconst keys = Object.keys(left);\n\tif (keys.length !== Object.keys(right).length) return false;\n\treturn keys.every((key) => Object.hasOwn(right, key) && jsonEqual(left[key], right[key]));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../../src/harness/scheduler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AAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAC5D,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC3F,CAAC","sourcesContent":["import {\n\tawaitWithContext,\n\ttype Context,\n\twithAbortSignal,\n\twithoutAbortSignal,\n\twithTelemetry,\n} from \"@earendil-works/chord/context\";\nimport { ownedSlice } from \"@earendil-works/chord/delta\";\nimport { copyJson, type JsonValue } from \"@earendil-works/chord/json\";\nimport type { Models } from \"@earendil-works/pi-ai\";\nimport {\n\tcreateTypedMetrics,\n\tcreateTypedSpanStarter,\n\tNOOP_TELEMETRY_CONTEXT,\n\tNOOP_TELEMETRY_METRICS,\n\ttype TelemetryCarrier,\n} from \"@earendil-works/pi-telemetry\";\nimport type { ExecutionEnv } from \"../env/index.ts\";\nimport { errorMessage, ReadOnlySession } from \"../errors.ts\";\nimport { ALL_KEYS, conversationKey, INTENT_KEY, ownedKey, ROOTS_KEY, taskKey } from \"../session/keys.ts\";\nimport type { ObservedCommit, SessionImpl } from \"../session/session.ts\";\nimport type { Transaction } from \"../session/transaction.ts\";\nimport type { Timers } from \"../timers.ts\";\nimport type {\n\tCommitOptions,\n\tConversationId,\n\tConversationRecord,\n\tDocumentWatch,\n\tEntryId,\n\tEntryRecord,\n\tHookRunner,\n\tJsonObject,\n\tNextTaskState,\n\tReportInfo,\n\tReportTask,\n\tRunningTask,\n\tStorage,\n\tStorageWrite,\n\tTaskDefinition,\n\tTaskId,\n\tTaskOutcome,\n\tTaskOutcomeError,\n\tTaskRecord,\n\tTaskRuntime,\n\tTaskState,\n} from \"../types.ts\";\nimport { agentHooks, DEFAULT_RESTART_LIMIT } from \"./agent.ts\";\nimport { advanceRange, type ContextRange, rangeEntry, readContextFrom } from \"./context.ts\";\nimport { DURABLE_TELEMETRY_SCHEMA } from \"./telemetry.ts\";\nimport type {\n\tAgent,\n\tAnyTask,\n\tConversationHandle,\n\tHarnessInspection,\n\tHarnessOptions,\n\tRegistryReader,\n\tRegistrySnapshot,\n\tSettings,\n\tSettledTask,\n\tTaskInspection,\n\tWake,\n} from \"./types.ts\";\nimport { closedError, conversationEntries, optionalExtension, scanAll, Waiters } from \"./util.ts\";\n\ntype AnyTaskRecord = TaskRecord<JsonValue, JsonValue, JsonValue>;\n/** A record that can still run code: pending, running, waiting, or sleeping. */\ntype RunnableTaskRecord = Extract<\n\tAnyTaskRecord,\n\t{ readonly state: { readonly status: \"pending\" | \"running\" | \"waiting\" | \"sleeping\" } }\n>;\ntype Checkpoint = { readonly phase: string; readonly attempt?: number };\ntype ErasedDefinition = TaskDefinition<JsonValue, Checkpoint, JsonValue, object>;\ntype ErasedRuntime = TaskRuntime<JsonValue, Checkpoint, JsonValue, object>;\ntype ErasedRunningTask = RunningTask<JsonValue, Checkpoint, JsonValue>;\n\nconst SCAN_PAGE_SIZE = 256;\nconst NO_KEYS: readonly string[] = [];\nconst LIVE_STATUSES = [\"pending\", \"running\", \"waiting\", \"sleeping\", \"completing\"] as const;\n\n/** What `blockedReason()` reads of a task: the task graph keeps only this of each record. */\nexport type BlockedSubject = Pick<AnyTaskRecord, \"id\" | \"kind\" | \"version\" | \"abortRequested\" | \"abortReason\"> & {\n\treadonly status: TaskState<JsonValue, JsonValue>[\"status\"];\n};\n\n/** The part of a record `blockedReason()` reads. */\nexport function blockedSubject(record: AnyTaskRecord): BlockedSubject {\n\treturn {\n\t\tid: record.id,\n\t\tkind: record.kind,\n\t\tversion: record.version,\n\t\tabortRequested: record.abortRequested,\n\t\t...(record.abortReason === undefined ? {} : { abortReason: record.abortReason }),\n\t\tstatus: record.state.status,\n\t};\n}\n\n/** Why a task cannot be reserved: no registered definition can take it. Derived from the registry. */\nexport type BlockedReason = \"missing_task\" | \"task_too_old\" | \"migration_failed\";\n\ntype Resolution =\n\t| { readonly kind: \"ready\"; readonly task: AnyTask; readonly record: RunnableTaskRecord }\n\t| { readonly kind: \"blocked\"; readonly reason: BlockedReason };\n\n/** A definition that can take a record, or why none can; deciding it runs no task code. */\ntype Fit =\n\t| { readonly task: AnyTask; readonly migrates: boolean }\n\t| { readonly reason: BlockedReason; readonly error?: unknown };\n\n/** One in-memory execution of a task in run or abort mode. */\ntype Invocation = {\n\treadonly taskId: TaskId;\n\treadonly kind: string;\n\t/** The extension that installed the definition this invocation runs, as of its reservation; none for a built-in. */\n\treadonly extension: string | undefined;\n\treadonly conversationId: ConversationId;\n\treadonly mode: \"run\" | \"abort\";\n\treadonly controller: AbortController;\n\tlinks?: readonly TelemetryCarrier[];\n\t/** Context passed to handlers; cancelled by `controller`. */\n\tcontext: Context;\n\t/** Keeps the terminal state available after it leaves the live index. Released when the invocation finishes. */\n\trecord?: TaskRecord<JsonValue, Checkpoint, JsonValue>;\n\tfault?: Extract<TaskOutcome<JsonValue>, { readonly status: \"faulted\" }>;\n\t/** Watches acquired through the runtime; stopped at invocation end. */\n\treadonly watches: Set<DocumentWatch<JsonObject>>;\n\t/** Timers armed through the runtime; disarmed at invocation end. */\n\treadonly timers: Set<() => void>;\n\tended: boolean;\n\treadonly done: Promise<void>;\n\treadonly finish: () => void;\n};\n\n/** What a runtime reads for the phase handler it serves: the phase's snapshot and task, and its lazily resolved agent. */\ntype Phase = {\n\treadonly snapshot: () => RegistrySnapshot;\n\treadonly task: () => AnyTask;\n\tagent: Promise<Agent> | undefined;\n};\n\ntype Reservation = {\n\treadonly invocation: Invocation;\n\treadonly task: AnyTask;\n\treadonly snapshot: RegistrySnapshot;\n};\n\n/** Replacement definition already reported as unable to take over, per invocation. */\ntype ReportedTask = { readonly task: AnyTask | undefined } | undefined;\n\n/** Outcome of the phase that just returned, judged by the next step. */\ntype PhaseResult = { readonly checkpoint: Checkpoint; readonly failure?: { readonly error: unknown } };\n\n/**\n * Step decision, made in a decision region: continue with the next phase, end the invocation, or end it by writing\n * `faulted`.\n */\ntype StepPlan =\n\t| { readonly kind: \"continue\" | \"progress\" | \"end\" | \"cascade\" }\n\t| { readonly kind: \"fault\"; readonly error: unknown };\n\n/** Continue with the next phase, the first one. */\nconst CONTINUE: StepPlan = { kind: \"continue\" };\n/** Rule 5: the phase made durable progress; `#progress()` decides once the decision stands. */\nconst PROGRESS: StepPlan = { kind: \"progress\" };\n/** End the invocation without a write. */\nconst END: StepPlan = { kind: \"end\" };\n/** End it: an owner's cancellation intent reaches it before its cascade did; schedule the cascade. */\nconst CASCADE: StepPlan = { kind: \"cascade\" };\n\n/** Terminal outcomes the scheduler writes without running task code. */\nexport type SchedulerOutcome = Extract<TaskOutcome<JsonValue>, { readonly status: \"faulted\" | \"orphaned\" }>;\n\n/** An invocation a conversation handle is bound to: its signal, and a check that throws once it ended. */\nexport type InvocationBinding = { readonly signal: AbortSignal; check(): void };\n\n/** The immutable ownership fields of a task. */\ntype TaskNode = Pick<AnyTaskRecord, \"conversationId\" | \"owner\" | \"background\">;\n\n/** Where a walk up the ownership tree continues: an owner task, or a conversation. */\ntype Up = { readonly task: TaskId } | { readonly conversation: ConversationId };\n\n/** One step of a walk up: an owner task with its node, a conversation, or an owner edge that is not loaded yet. */\ntype Step =\n\t| { readonly task: TaskId; readonly node: TaskNode }\n\t| { readonly conversation: ConversationId }\n\t| { readonly unknown: true };\n\n/** Candidate records a commit staged; they override committed records in ownership walks. */\ntype Overlay = {\n\treadonly tasks: ReadonlyMap<TaskId, AnyTaskRecord>;\n\treadonly edges: ReadonlyMap<ConversationId, TaskId | null>;\n\t/** Links to the staged tasks `#below` does not list, by parent node, for walks down; built at first use. */\n\tlinks?: ReadonlyMap<Node, ReadonlySet<Node>>;\n};\n\n/** Tasks a finalize pass has made terminal in its commit so far. */\ntype Finalized = { has(id: TaskId): boolean };\n\n/** A node of the downward index: a task, or a conversation as `c<id>`. */\ntype Node = TaskId | `c${number}`;\n\nfunction conversationNode(id: ConversationId): Node {\n\treturn `c${id}`;\n}\n\nfunction conversationOf(node: `c${number}`): ConversationId {\n\treturn Number(node.slice(1)) as ConversationId;\n}\n\n/** The node a task hangs from: its owner task, or its conversation. */\nfunction parentNode(node: TaskNode): Node {\n\treturn node.owner ?? conversationNode(node.conversationId);\n}\n\n/** Where ordinary ownership traversal starts: one conversation, or every ownerless conversation. */\ntype Scope = { readonly conversation: ConversationId } | { readonly roots: true };\n\nexport type TaskSchedulerOptions = {\n\treadonly telemetry?: HarnessOptions[\"telemetry\"];\n\treadonly session: SessionImpl;\n\treadonly storage: Storage;\n\treadonly registry: RegistryReader;\n\t/** The host's current model access (`HarnessOptions.models`); read at each access. */\n\treadonly models: () => Models;\n\t/** Resolve a conversation's agent against a snapshot; the runtime calls it at most once per phase. */\n\treadonly agent: (conversationId: ConversationId, snapshot: RegistrySnapshot, context: Context) => Promise<Agent>;\n\t/** Resolve the settings; read at each access. */\n\treadonly settings: () => Settings;\n\t/** Build a conversation's environment with `HarnessOptions.env`. */\n\treadonly env: (conversationId: ConversationId, context: Context) => Promise<ExecutionEnv | undefined>;\n\treadonly now: () => number;\n\t/** `HarnessOptions.onWake`: replaces the timer for sleeping tasks. */\n\treadonly onWake: ((wake: Wake) => void) | undefined;\n\t/** The host's timers (`HarnessOptions.setTimer`). */\n\treadonly timers: Timers;\n\t/** While closing, on the line after admitted commits settle, write what the callback returns straight to Storage. */\n\treadonly writeAtClose: (writes: () => readonly StorageWrite[]) => Promise<void>;\n\treadonly report: (error: unknown, info: ReportInfo, context?: Context) => void;\n\t/**\n\t * Task kinds whose run phases end the task themselves once it was cut off `settings.restartLimit` times (the\n\t * built-in tasks, from `TaskRecord.restarts`); the scheduler ends a task of any other kind `faulted` instead.\n\t */\n\treadonly limitsRestarts: (kind: string) => boolean;\n\t/** Harness cleanup staged in the commit that makes an outcome the scheduler wrote itself terminal. */\n\treadonly settleOutcome: (tx: Transaction, record: AnyTaskRecord, outcome: SchedulerOutcome) => Promise<void>;\n\t/** Withdraw a conversation's queued inputs, for conversation abort and abort cascades. */\n\treadonly withdrawInputs: (tx: Transaction, conversationId: ConversationId) => Promise<void>;\n\t/** Invocation-bound handle of an existing conversation, for task runtimes and tools. */\n\treadonly conversation: (\n\t\tid: ConversationId,\n\t\tbinding: InvocationBinding,\n\t\tcontext: Context,\n\t) => Promise<ConversationHandle | undefined>;\n\t/** Context for scheduler commits and invocations; carries no caller cancellation. */\n\treadonly context: Context;\n\t/**\n\t * `HarnessOptions.readOnly`: open loads live tasks as committed, `running` ones included, and the scheduler never\n\t * commits, runs anything, or asks for a wakeup.\n\t */\n\treadonly readOnly?: boolean;\n};\n\n/** A reservation pass's decision (`#planReservation()`). */\ninterface ReservationPlan {\n\treadonly dropped: readonly TaskId[];\n\treadonly cascade: boolean;\n\treadonly ready: readonly RunnableTaskRecord[];\n}\n\n/**\n * Durable task scheduler of one Harness.\n *\n * `#live` mirrors every committed non-terminal task record: pending, running, waiting, sleeping, and completing. The\n * synchronous commit listener updates it on the Session line, so code running on the line reads exactly the committed\n * state from it.\n *\n * Tasks and conversations form one ownership tree (spec §5.5): a task's parent is its owner task, or its conversation;\n * a conversation's parent is its owner task, if any. Walks up that tree decide what reaches one task: a cancelling\n * owner, a scope. `#below` lists the tree downward around live work, so what lies below one node is a walk down from\n * it: a task's live ordinary owned work, which holds its outcome as `completing` and delays its abort handler, a\n * scope's tasks, a cascade's reach. No pass visits every live task; the sets below hold each pass's candidates.\n *\n * The ownership indexes are bounded by live work: an owner edge and an ended task's ownership fields are kept only while\n * something is listed below them in `#below`, so only the chains above live tasks are known, whole. Work that appears\n * later below a dropped node finds it unknown and loads its chain from storage again.\n *\n * Invariant: every task transition is decided and written by one callback serialized on the Session line. That covers\n * reservation, marks, runtime commits, finalization, and the step before each phase, which applies the precedence rules\n * and writes a fault or handover. Handlers and joins run off the line. An invocation ends inside the step that decides\n * its end, so a runtime commit it queued either lands before that decision or is rejected.\n *\n * Decisions stay serialized; their storage overlaps (group commit). The Session stores the commits of several jobs in\n * one call while the line runs on, and this memory changes only as each commit is published. So every decision reads\n * it in a decision region (`#region()`): synchronous, recording the keys it reads (a task's record, the live work below\n * a node, the cancellation intent set), staging nothing; when one of them has an unpublished writer, the region waits\n * for its publication and runs again, and only a region that read nothing unpublished is applied. Every commit writes\n * the memberships its task changes alter (`membershipKeys()`), so a walk that a pending commit would change waits.\n */\nexport class TaskScheduler {\n\treadonly #telemetry: NonNullable<HarnessOptions[\"telemetry\"]>;\n\treadonly #activeMetric;\n\treadonly #durationMetric;\n\treadonly #resumed = new Set<TaskId>();\n\treadonly #session: SessionImpl;\n\treadonly #storage: Storage;\n\treadonly #registry: RegistryReader;\n\treadonly #models: () => Models;\n\treadonly #agent: TaskSchedulerOptions[\"agent\"];\n\treadonly #settings: TaskSchedulerOptions[\"settings\"];\n\treadonly #env: TaskSchedulerOptions[\"env\"];\n\treadonly #now: () => number;\n\treadonly #onWake: ((wake: Wake) => void) | undefined;\n\treadonly #timers: Timers;\n\treadonly #writeAtClose: (writes: () => readonly StorageWrite[]) => Promise<void>;\n\treadonly #report: (error: unknown, info: ReportInfo, context?: Context) => void;\n\treadonly #settleOutcome: TaskSchedulerOptions[\"settleOutcome\"];\n\treadonly #limitsRestarts: TaskSchedulerOptions[\"limitsRestarts\"];\n\treadonly #withdrawInputs: TaskSchedulerOptions[\"withdrawInputs\"];\n\treadonly #conversation: TaskSchedulerOptions[\"conversation\"];\n\treadonly #context: Context;\n\treadonly #live = new Map<TaskId, AnyTaskRecord>();\n\t/**\n\t * Context range last read through a task runtime, per conversation: a later read, by any of its tasks, scans only\n\t * newer entries. `idleSince` is the Harness time it was first seen idle. Derived and never persisted; dropped at the\n\t * first idle check after `settings.contextRetentionMs` of idleness, and at close.\n\t */\n\treadonly #contexts = new Map<\n\t\tConversationId,\n\t\t{ range: ContextRange; idleSince: number | undefined; expiresAt?: number }\n\t>();\n\t/**\n\t * The idle kept contexts by `idleSince`, oldest first: the expiry order, so neither an expiry nor finding the next one\n\t * scans `#contexts`. Kept sorted also when the Harness clock goes back (see `#markIdle`).\n\t */\n\treadonly #idleOrder = new Map<ConversationId, number>();\n\t/** At least the newest `idleSince` in `#idleOrder` (drops do not lower it): an older one added means the clock went back. */\n\t#idleNewest = Number.NEGATIVE_INFINITY;\n\t/**\n\t * A chain load resolved what `#idle()` treats as unknown for a live task whose chain is not loaded, which can make a\n\t * scope idle without a task change below it; the next idle check then covers every scope.\n\t */\n\t#unknownsChanged = false;\n\t/** Idle checks that covered every scope (`idleState`, a test diagnostic). */\n\t#fullIdleChecks = 0;\n\t/** Background timer for the earliest expiry of an idle context, unless the host declined it (see `#scheduleExpiry`). */\n\t#expiry: { readonly at: number; readonly disarm: () => void } | undefined;\n\treadonly #invocations = new Map<TaskId, Invocation>();\n\treadonly #taskWaiters = new Waiters<TaskId, SettledTask<JsonValue>>();\n\t/** Idle waiters by conversation; `undefined` waits for the whole Harness. */\n\treadonly #idleWaiters = new Waiters<ConversationId | undefined, void>();\n\t/** Definition whose migration failed per task; retried only once the registry resolves another definition. */\n\treadonly #failedMigrations = new Map<TaskId, { readonly task: AnyTask; readonly error: unknown }>();\n\t/** Owner task of each known conversation, `null` when ownerless. */\n\treadonly #edges = new Map<ConversationId, TaskId | null>();\n\t/** Ownership fields of the known terminal tasks, which walks pass through. */\n\treadonly #settled = new Map<TaskId, TaskNode>();\n\t/**\n\t * Ended tasks and conversations found unneeded, dropped by `#sweep()` at the end of the commit's publication unless\n\t * needed again by then: a chain load installs nodes before the work below them is listed.\n\t */\n\treadonly #dropQueue = new Set<Node>();\n\t/**\n\t * The tree downward around live work: each node's child nodes that are live tasks or have nodes listed below them.\n\t * A conversation's parent is its owner task; ownerless ones with work are in `#roots`.\n\t */\n\treadonly #below = new Map<Node, Set<Node>>();\n\treadonly #roots = new Set<ConversationId>();\n\t/** Known tasks whose chain may not be loaded; every other known task's chain is, and stays, loaded. */\n\treadonly #unloaded = new Set<TaskId>();\n\t/** Live tasks with cancellation intent, the sources of abort cascades (spec §5.4). */\n\treadonly #intent = new Set<TaskId>();\n\t/**\n\t * Live tasks that are not `completing`, the candidates of a reservation pass; ones found waiting leave it. A pass\n\t * takes the set while it plans, so a task made a candidate meanwhile is not dropped by its stale decision.\n\t */\n\t#runnable = new Set<TaskId>();\n\t/**\n\t * `completing` tasks the next finalize pass checks: those that started holding, and holders of ended work. A pass\n\t * takes them before it plans, so a check asked for meanwhile stays for the next pass.\n\t */\n\treadonly #finalizeChecks = new Set<TaskId>();\n\t/** Live waiting tasks by each task in their `on`. */\n\treadonly #waiters = new Map<TaskId, Set<TaskId>>();\n\t/**\n\t * `failFast` waiters the next reconcile checks for a failed task in `on`: at open, when they start waiting, and when\n\t * one of their tasks fails.\n\t */\n\treadonly #failFastChecks = new Set<TaskId>();\n\t/**\n\t * Live tasks with `abandonOnRestart` found at open, from an earlier Harness. The first reservation pass abort-marks\n\t * them with reason `restart`, so nothing of them or below them runs a phase again.\n\t */\n\treadonly #abandoned = new Set<TaskId>();\n\t/** Sleeping live tasks, due or not: the candidates of `#wakeDue()`. */\n\treadonly #sleeping = new Set<TaskId>();\n\t/** Timer for the earliest sleep, without `onWake` while scheduling runs. */\n\t#timer: { readonly at: number; readonly disarm: () => void } | undefined;\n\t/** Last value given to `onWake`, so an unchanged one is not repeated. */\n\t#lastWake: Wake | undefined;\n\t#wakeScheduled = false;\n\treadonly #blockedListeners = new Set<() => void>();\n\t/** A registry snapshot that threw for the task graph was reported; it is read per record, so only once. */\n\t#snapshotReported = false;\n\t#reconcileScheduled = false;\n\t/** Reconcile passes underway with work (they may overlap): their commits finalize held outcomes and mark cascades. */\n\t#reconcilingWork = 0;\n\t#sweepScheduled = false;\n\t/**\n\t * Nodes chain loads installed for jobs whose commits are not published yet, with how many such jobs: the sweep keeps\n\t * them, as work a pending commit creates below them needs them.\n\t */\n\treadonly #pins = new Map<Node, number>();\n\t/** Keys the decision region underway reads (`#region()`); set only while one runs. */\n\t#reading: Set<string> | undefined;\n\t#cascadePending = false;\n\t#unsubscribeRegistry: () => void = () => {};\n\t#enabled = false;\n\treadonly #readOnly: boolean;\n\t#closing = false;\n\t#dirty = false;\n\t#draining = false;\n\n\tconstructor(options: TaskSchedulerOptions) {\n\t\tthis.#telemetry = options.telemetry ?? NOOP_TELEMETRY_CONTEXT;\n\t\tconst metrics = createTypedMetrics(this.#telemetry.metrics ?? NOOP_TELEMETRY_METRICS, [DURABLE_TELEMETRY_SCHEMA]);\n\t\tthis.#activeMetric = metrics.upDownCounter(\"pi.durable.tasks.active\");\n\t\tthis.#durationMetric = metrics.histogram(\"pi.durable.phase.duration\");\n\t\tthis.#session = options.session;\n\t\tthis.#storage = options.storage;\n\t\tthis.#registry = options.registry;\n\t\tthis.#models = options.models;\n\t\tthis.#agent = options.agent;\n\t\tthis.#settings = options.settings;\n\t\tthis.#env = options.env;\n\t\tthis.#now = options.now;\n\t\tthis.#onWake = options.onWake;\n\t\tthis.#timers = options.timers;\n\t\tthis.#writeAtClose = options.writeAtClose;\n\t\tthis.#report = options.report;\n\t\tthis.#settleOutcome = options.settleOutcome;\n\t\tthis.#limitsRestarts = options.limitsRestarts;\n\t\tthis.#withdrawInputs = options.withdrawInputs;\n\t\tthis.#conversation = options.conversation;\n\t\tthis.#context = options.context;\n\t\tthis.#readOnly = options.readOnly === true;\n\t}\n\n\t/**\n\t * Load live tasks and change surviving `running` tasks back to `pending`, counting the restart. Dispatches nothing;\n\t * a task cut off `settings.restartLimit` times ends when it is next reserved. Read-only, it only loads them: a\n\t * `running` task stays as committed, running in another process.\n\t */\n\tasync open(context: Context): Promise<void> {\n\t\tthis.#session.followCommits((publication) => this.#observe(publication));\n\t\tthis.#session.subscribeClose(() => this.#seal());\n\t\tthis.#unsubscribeRegistry = this.#registry.subscribe(() => {\n\t\t\tthis.#notifyBlocked();\n\t\t\tthis.#kick();\n\t\t});\n\t\tawait this.#session.commitWith(async (tx) => {\n\t\t\tawait this.#published();\n\t\t\t// Every table read before the first write.\n\t\t\tconst scans = [];\n\t\t\tfor (const status of LIVE_STATUSES) {\n\t\t\t\tscans.push(await scanAll((cursor) => tx.scanTasks({ status }, SCAN_PAGE_SIZE, cursor)));\n\t\t\t}\n\t\t\tfor (const records of scans) {\n\t\t\t\tfor (const record of records) {\n\t\t\t\t\tthis.#track(undefined, record);\n\t\t\t\t\tthis.#resumed.add(record.id);\n\t\t\t\t\tif (this.#readOnly) continue;\n\t\t\t\t\tif (record.abandonOnRestart === true) this.#abandoned.add(record.id);\n\t\t\t\t\tif (record.state.status === \"running\") {\n\t\t\t\t\t\tconst restarts = (record.restarts ?? 0) + 1;\n\t\t\t\t\t\tconst pending = withState(record, { status: \"pending\", checkpoint: record.state.checkpoint });\n\t\t\t\t\t\ttx.setTask({ ...pending, restarts } as AnyTaskRecord);\n\t\t\t\t\t}\n\t\t\t\t\tif (record.state.status === \"waiting\" && record.state.policy === \"failFast\") {\n\t\t\t\t\t\tthis.#failFastChecks.add(record.id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}, context);\n\t\tif (this.#readOnly) return;\n\t\t// Derive abort marks a crash left unapplied below cancelled owners, and finalize held outcomes.\n\t\tthis.#cascadePending = true;\n\t\tthis.#scheduleReconcile();\n\t\tthis.#scheduleWake();\n\t}\n\n\t/**\n\t * Enable scheduling, and make sleeping tasks that are due runnable: a host wakeup, such as an alarm, calls this.\n\t * Idempotent; the kick does nothing once closing.\n\t */\n\tresume(): void {\n\t\tif (this.#readOnly) throw new ReadOnlySession(\"running tasks\");\n\t\tthis.#enabled = true;\n\t\tthis.#wakeDue();\n\t\tthis.#kick();\n\t}\n\n\t/**\n\t * Why a live task cannot run here, if it cannot: its definition is missing, too old, or failed to migrate. A running\n\t * task, an abort-marked one, and one holding its outcome are never blocked.\n\t */\n\tblockedReason(record: BlockedSubject): BlockedReason | undefined {\n\t\tconst status = record.status;\n\t\tif (status === \"running\" || status === \"completing\" || status === \"terminal\") return undefined;\n\t\t// An abort request runs its handler or orphans the task; a `restart` mark waits for the definition, blocked.\n\t\tif (record.abortRequested && record.abortReason === undefined) return undefined;\n\t\tlet snapshot: RegistrySnapshot;\n\t\ttry {\n\t\t\tsnapshot = this.#registry.snapshot();\n\t\t} catch (error) {\n\t\t\tif (!this.#snapshotReported) this.#report(error, REGISTRY);\n\t\t\tthis.#snapshotReported = true;\n\t\t\treturn undefined;\n\t\t}\n\t\tconst fit = this.#fit(record, snapshot.task(record.kind));\n\t\tif (\"reason\" in fit) return fit.reason;\n\t\treturn fit.migrates && fit.task.definition.migrate === undefined ? \"migration_failed\" : undefined;\n\t}\n\n\t/** Call `listener` when blocked reasons may have changed without a commit: a registry change or a failed migration. */\n\tsubscribeBlocked(listener: () => void): () => void {\n\t\tthis.#blockedListeners.add(listener);\n\t\treturn () => this.#blockedListeners.delete(listener);\n\t}\n\n\t/**\n\t * When the Session next needs a process: `active` while some task can run now or is running, `at` for the earliest\n\t * sleep not yet due. Synchronous, from memory; a task whose chain is not loaded yet counts as it would alone.\n\t */\n\twake(): Wake {\n\t\t// A read-only Harness runs nothing, so it never needs a process.\n\t\tif (this.#readOnly) return { active: false };\n\t\tconst now = this.#now();\n\t\t// A reconcile pass with work to do is work too: it finalizes held outcomes and marks cascades, at open as\n\t\t// recovery. A process that dies before it lands must be woken again. A pass with nothing to do is not.\n\t\tconst active =\n\t\t\tthis.#invocations.size > 0 || this.#reconcilingWork > 0 || this.#reconcileWork() || this.#runsNow(now);\n\t\t// The earliest sleep not yet due: only `#sleeping` holds sleeping tasks, so no pass visits every live task.\n\t\tlet at: number | undefined;\n\t\tfor (const id of this.#sleeping) {\n\t\t\tconst record = this.#live.get(id);\n\t\t\tconst state = record?.state;\n\t\t\tif (state?.status === \"sleeping\" && !record!.abortRequested && state.until > now) {\n\t\t\t\tat = at === undefined ? state.until : Math.min(at, state.until);\n\t\t\t}\n\t\t}\n\t\treturn at === undefined ? { active } : { active, at };\n\t}\n\n\t/** Whether a live task can run now: the scan `wake()` needs only while no invocation runs. */\n\t#runsNow(now: number): boolean {\n\t\tlet snapshot: RegistrySnapshot | undefined;\n\t\tlet snapshotFailed = false;\n\t\tfor (const record of this.#live.values()) {\n\t\t\tconst state = record.state;\n\t\t\tif (state.status === \"completing\") continue;\n\t\t\tif (state.status === \"waiting\" && !record.abortRequested && state.on.some((id) => this.#live.has(id)))\n\t\t\t\tcontinue;\n\t\t\tif (state.status === \"sleeping\" && !record.abortRequested && state.until > now) continue;\n\t\t\t// An abort invocation waits for the live work below it, which counts itself.\n\t\t\tif (record.abortRequested && this.#waitingOn(record, true).length > 0) continue;\n\t\t\t// A task no definition can take waits for a registry change, except an abort-marked one, which is orphaned.\n\t\t\tif (!record.abortRequested || record.abortReason !== undefined) {\n\t\t\t\tif (snapshot === undefined && !snapshotFailed) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tsnapshot = this.#registry.snapshot();\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tsnapshotFailed = true;\n\t\t\t\t\t\tthis.#report(error, REGISTRY);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (snapshot !== undefined && \"reason\" in this.#fit(record, snapshot.task(record.kind))) continue;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Signal every invocation and wait for them, then write the tasks they ran back as `pending` (`writeAtClose`), as a\n\t * close is not a crash. Close calls this after every close listener has run, so waits, watches, and streams a task\n\t * holds end with the Session's reason, not as cancelled by its signal.\n\t */\n\tasync join(): Promise<void> {\n\t\tconst stopped = [...this.#invocations.values()];\n\t\tfor (const invocation of stopped) invocation.controller.abort();\n\t\tawait Promise.allSettled(stopped.map((invocation) => invocation.done));\n\t\tif (stopped.length === 0) return;\n\t\t// A close is not a crash: a task it stopped is `pending` again, so the next open counts no restart for it. Read\n\t\t// on the line after commits admitted before the seal, such as an abort mark, so the write keeps them. A failure\n\t\t// leaves them `running`, counted as if cut off; the Storage guard fails the Session and reports it.\n\t\tawait this.#writeAtClose(() =>\n\t\t\tstopped.flatMap((invocation) => {\n\t\t\t\tconst record = this.#live.get(invocation.taskId);\n\t\t\t\tif (record?.state.status !== \"running\") return [];\n\t\t\t\tconst value = withState(record, { status: \"pending\", checkpoint: record.state.checkpoint });\n\t\t\t\treturn [{ type: \"task\", value } as const];\n\t\t\t}),\n\t\t).catch(() => {});\n\t}\n\n\t/**\n\t * Commit the abort mark, or settle a task that no registered definition can take as `orphaned` when nothing it owns\n\t * is live, then join the run invocation seen on the line; the commit listener signalled it. The abort invocation\n\t * starts once the task's ordinary owned work is gone. A `completing` task is only marked. A request replaces a\n\t * `restart` mark, so a task abandoned after a restart that waits for its definition is orphaned; with `keepRestart`,\n\t * as for an owner's own cleanup, such a task keeps its mark and waits on.\n\t */\n\tasync abort(id: TaskId, context: Context, keepRestart = false): Promise<\"marked\" | \"terminal\"> {\n\t\tconst marked = await this.#session.commitWith(async (tx) => {\n\t\t\tconst current = await tx.task(id);\n\t\t\tif (current === undefined) throw new Error(`Task ${id} does not exist`);\n\t\t\tif (current.state.status === \"terminal\") return { result: \"terminal\" as const };\n\t\t\tconst invocation = this.#invocations.get(id);\n\t\t\t// A restart-marked task has no run invocation; it only waits for its abort.\n\t\t\tif (keepRestart && current.abortReason === \"restart\") return { result: \"marked\" as const };\n\t\t\tif (invocation === undefined && current.state.status !== \"completing\") {\n\t\t\t\tawait this.#loadScopes(false);\n\t\t\t\tconst owns = await this.#region(() => this.#hasOwnedLive(id), this.#reloadScopes);\n\t\t\t\t// Resolved once that decision stands, as it may run `migrate`.\n\t\t\t\tconst resolution = owns\n\t\t\t\t\t? undefined\n\t\t\t\t\t: this.#resolve(current as RunnableTaskRecord, this.#registry.snapshot());\n\t\t\t\tif (resolution?.kind === \"blocked\") {\n\t\t\t\t\tawait this.#terminate(tx, current, { status: \"orphaned\", reason: resolution.reason });\n\t\t\t\t\treturn { result: \"marked\" as const };\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!current.abortRequested || current.abortReason !== undefined) tx.setTask(withAbortMark(current));\n\t\t\treturn { result: \"marked\" as const, run: invocation?.mode === \"run\" ? invocation : undefined };\n\t\t}, context);\n\t\t// The commit listener signalled the run; join it. A run that ignores its signal can outlive a failed Session,\n\t\t// which ends the wait instead.\n\t\tif (marked.run !== undefined) {\n\t\t\tawait awaitWithContext(Promise.race([marked.run.done, this.#session.failed]), context);\n\t\t}\n\t\treturn marked.result;\n\t}\n\n\tasync waitForTask(id: TaskId, context: Context): Promise<SettledTask<JsonValue>> {\n\t\t// Check and register on the line so no terminal publication falls between them.\n\t\tconst found = await this.#session.readOnLine(async (storage) => {\n\t\t\tif (this.#closing) throw closedError(this.#session);\n\t\t\tif (await this.#region(() => this.#liveRecord(id) !== undefined)) {\n\t\t\t\treturn { promise: this.#taskWaiters.add(id, context) };\n\t\t\t}\n\t\t\tconst record = await storage.task(id, context);\n\t\t\tif (record === undefined) throw new Error(`Task ${id} does not exist`);\n\t\t\treturn { promise: Promise.resolve(record as SettledTask<JsonValue>) };\n\t\t});\n\t\treturn found.promise;\n\t}\n\n\t/**\n\t * Resolve when ordinary traversal from the conversation, or from every ownerless conversation, reaches no live\n\t * non-background task.\n\t */\n\twaitForIdle(conversationId: ConversationId | undefined, context: Context): Promise<void> {\n\t\tif (this.#closing) return Promise.reject(closedError(this.#session));\n\t\tif (this.#idle(conversationId)) return Promise.resolve();\n\t\tthis.#scheduleReconcile();\n\t\treturn this.#idleWaiters.add(conversationId, context);\n\t}\n\n\t/**\n\t * `Conversation.abort()`: in one commit, withdraw the queued inputs and mark every live non-background task that\n\t * ordinary traversal from the conversation reaches; resolves once the scope is idle. With `background`, traversal\n\t * crosses background boundaries, and the wait also covers every task it reached.\n\t */\n\tasync abortConversation(conversationId: ConversationId, background: boolean, context: Context): Promise<void> {\n\t\tconst reached = await this.#session.commitWith(async (tx) => {\n\t\t\tawait this.#published();\n\t\t\tconst queued = await this.#loadScopes(true);\n\t\t\tconst scope = { conversation: conversationId };\n\t\t\tconst reached: TaskId[] = [];\n\t\t\tconst walk = this.#walkDown(conversationNode(conversationId), { crossBackground: background });\n\t\t\tfor (const { node, live } of walk) {\n\t\t\t\tif (live === undefined || (node.background && !background)) continue;\n\t\t\t\treached.push(live.id);\n\t\t\t\tif (!live.abortRequested || live.abortReason !== undefined) tx.setTask(withAbortMark(live));\n\t\t\t}\n\t\t\tfor (const id of queued) {\n\t\t\t\tif (this.#inScope({ conversation: id }, scope, background) === true) await this.#withdrawInputs(tx, id);\n\t\t\t}\n\t\t\treturn reached;\n\t\t}, context);\n\t\tif (background) for (const id of reached) await this.waitForTask(id, context);\n\t\tawait this.waitForIdle(conversationId, context);\n\t}\n\n\t/**\n\t * The ownership memberships a commit's task and conversation changes write (group commit §4.2), at its admission on\n\t * the line: for each task created or made terminal, every node from its parent up to and including the nearest live\n\t * task, or the root conversation, and then the roots too, conservatively, as a pending end may unlist the root a\n\t * creation finds listed; for each conversation created under a task, that task; and the intent set when\n\t * a change sets, upgrades, or clears a mark or a held or ended outcome other than `completed`. Loads the chains it\n\t * walks; the nodes it installs stay until the commit is published.\n\t */\n\tmembershipKeys(tx: Transaction): readonly string[] | Promise<readonly string[]> {\n\t\tconst tasks = tx.stagedTasks();\n\t\tconst conversations = tx.stagedConversations();\n\t\tif (tasks.length === 0 && conversations.every((record) => record.owner === undefined)) return NO_KEYS;\n\t\treturn this.#membershipKeys(tx, tasks, conversations);\n\t}\n\n\tasync #membershipKeys(\n\t\ttx: Transaction,\n\t\ttasks: readonly AnyTaskRecord[],\n\t\tconversations: readonly ConversationRecord[],\n\t): Promise<readonly string[]> {\n\t\tconst keys = new Set<string>();\n\t\tconst overlay = overlayOf(tx);\n\t\tconst created = new Set(tx.createdTaskIds());\n\t\tconst reached = new Map<string, ConversationId | undefined>();\n\t\tfor (const record of tasks) {\n\t\t\tif (intentChanges(this.#live.get(record.id), record)) keys.add(INTENT_KEY);\n\t\t\tif (!created.has(record.id) && record.state.status !== \"terminal\") continue;\n\t\t\tawait this.#loadChain(parentOf(record), overlay);\n\t\t\tif ((await this.#chainKeys(parentNode(record), overlay, keys, reached)) !== undefined) keys.add(ROOTS_KEY);\n\t\t}\n\t\tfor (const conversation of conversations) {\n\t\t\tconst owner = conversation.owner?.taskId;\n\t\t\tif (owner === undefined) continue;\n\t\t\tawait this.#loadChain({ task: owner }, overlay);\n\t\t\tawait this.#chainKeys(owner, overlay, keys, reached);\n\t\t}\n\t\treturn [...keys];\n\t}\n\n\t/**\n\t * Add the memberships from `start` up to and including the nearest live task, or the root conversation, which it\n\t * returns. `reached` keeps, per node walked, where its walk ended, so a chain several tasks of a commit share is\n\t * walked once. Whether an ancestor is live can change under a pending commit, so it is read after a touch of the\n\t * ancestor's record: a pending end must not stop the chain early. Ownership fields are immutable, so not keyed.\n\t */\n\tasync #chainKeys(\n\t\tstart: Node,\n\t\toverlay: Overlay,\n\t\tkeys: Set<string>,\n\t\treached: Map<string, ConversationId | undefined>,\n\t): Promise<ConversationId | undefined> {\n\t\tconst walked: string[] = [];\n\t\tlet root: ConversationId | undefined;\n\t\tlet node: Node | null | undefined = start;\n\t\twhile (node !== undefined && node !== null) {\n\t\t\tconst key = ownedKey(node);\n\t\t\t// Walked up from here already, for another task of the commit.\n\t\t\tif (reached.has(key)) {\n\t\t\t\troot = reached.get(key);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tkeys.add(key);\n\t\t\twalked.push(key);\n\t\t\tif (typeof node === \"string\") {\n\t\t\t\tconst conversation = conversationOf(node);\n\t\t\t\tnode = this.#edge(conversation, overlay);\n\t\t\t\tif (node === null) root = conversation;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet record: AnyTaskRecord | undefined = overlay.tasks.get(node);\n\t\t\tif (record === undefined) {\n\t\t\t\tconst gate = this.#session.touch(taskKey(node));\n\t\t\t\tif (gate !== undefined) {\n\t\t\t\t\tawait gate;\n\t\t\t\t\t// It may have ended meanwhile, and its node been swept: load the chain above it again.\n\t\t\t\t\tawait this.#loadChain({ task: node }, overlay);\n\t\t\t\t}\n\t\t\t\trecord = this.#live.get(node);\n\t\t\t}\n\t\t\tif (record !== undefined && record.state.status !== \"terminal\") break;\n\t\t\tconst above: TaskNode | undefined = record ?? this.#settled.get(node);\n\t\t\tnode = above === undefined ? undefined : parentNode(above);\n\t\t}\n\t\tfor (const key of walked) reached.set(key, root);\n\t\treturn root;\n\t}\n\n\t// ─── Scheduling ────────────────────────────────────────────────────────\n\n\t#observe(publication: ObservedCommit): void {\n\t\t// A commit held in memory changes documents only.\n\t\tif (publication.kind === \"memory\") return;\n\t\tthis.#advanceContexts(publication);\n\t\tconst updated: AnyTaskRecord[] = [];\n\t\tconst failed: TaskId[] = [];\n\t\tlet changed = false;\n\t\t// The conversations whose idleness the commit's task changes can change; undefined when a chain is not known.\n\t\tlet dirty: Set<ConversationId> | undefined = new Set();\n\t\t// Edges first, so the tasks a commit creates in a new conversation hang from it.\n\t\tfor (const change of publication.changes) {\n\t\t\tif (change.type === \"conversation\" && !this.#edges.has(change.value.id)) {\n\t\t\t\tthis.#setEdge(change.value.id, change.value.owner?.taskId ?? null);\n\t\t\t}\n\t\t}\n\t\tfor (const change of publication.changes) {\n\t\t\tif (change.type !== \"task\") continue;\n\t\t\tchanged = true;\n\t\t\tconst record = change.value;\n\t\t\tconst previous = this.#live.get(record.id);\n\t\t\tif (failedOutcome(record) && (previous === undefined || !failedOutcome(previous))) failed.push(record.id);\n\t\t\tthis.#track(previous, record);\n\t\t\t// Idleness counts live tasks, so only a task that became live or ended can change it. Collected before `#sweep()`,\n\t\t\t// which may forget the chain of a task that ended.\n\t\t\tconst liveness = previous === undefined || record.state.status === \"terminal\";\n\t\t\tif (liveness && dirty !== undefined && !this.#addScopesAbove(record, dirty)) dirty = undefined;\n\t\t\tif (record.state.status === \"terminal\") {\n\t\t\t\tthis.#failedMigrations.delete(record.id);\n\t\t\t\tthis.#failFastChecks.delete(record.id);\n\t\t\t\tthis.#taskWaiters.resolve(record.id, record as SettledTask<JsonValue>);\n\t\t\t\t// Its owner may finalize now.\n\t\t\t\tthis.#scheduleReconcile();\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (record.abortRequested && previous?.abortRequested !== true) {\n\t\t\t\tthis.#cascadePending = true;\n\t\t\t\t// Signal a run invocation of the newly marked task; its next step ends it. Abort listeners are task code, which\n\t\t\t\t// never runs inside a publication: the signal follows in a microtask, after host commit listeners.\n\t\t\t\tconst invocation = this.#invocations.get(record.id);\n\t\t\t\tif (invocation?.mode === \"run\") queueMicrotask(() => invocation.controller.abort());\n\t\t\t}\n\t\t\t// A request replacing a `restart` mark upgrades the marks of the work below.\n\t\t\tif (previous?.abortReason !== undefined && record.abortReason === undefined) this.#cascadePending = true;\n\t\t\tconst status = record.state.status;\n\t\t\tif (status === \"completing\" && previous?.state.status !== \"completing\") {\n\t\t\t\tif (cancellationIntent(record)) this.#cascadePending = true;\n\t\t\t\tthis.#scheduleReconcile();\n\t\t\t}\n\t\t\tif (status === \"waiting\" && record.state.policy === \"failFast\" && previous?.state.status !== \"waiting\") {\n\t\t\t\tthis.#failFastChecks.add(record.id);\n\t\t\t\tthis.#scheduleReconcile();\n\t\t\t}\n\t\t\t// Its owners and place never change: what is above it is checked once, when it becomes live.\n\t\t\tif (previous === undefined) updated.push(record);\n\t\t}\n\t\tfor (const id of failed) {\n\t\t\tfor (const waiter of this.#waiters.get(id) ?? []) {\n\t\t\t\tconst state = this.#live.get(waiter)?.state;\n\t\t\t\tif (state?.status === \"waiting\" && state.policy === \"failFast\") {\n\t\t\t\t\tthis.#failFastChecks.add(waiter);\n\t\t\t\t\tthis.#scheduleReconcile();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const change of publication.changes) {\n\t\t\t// A queued input below a cancelled owner is withdrawn, even after its cascade.\n\t\t\tif (change.type !== \"submission\" || change.value.status !== \"queued\" || change.value.type !== \"input\")\n\t\t\t\tcontinue;\n\t\t\t// Only an owner with cancellation intent withdraws it; a later intent's mark runs the cascade then.\n\t\t\tif (this.#intent.size === 0) continue;\n\t\t\tconst conversation = change.value.conversationId;\n\t\t\tif (!this.#known(conversationNode(conversation)) || this.#belowCancelled({ conversation })) {\n\t\t\t\tthis.#cascadePending = true;\n\t\t\t}\n\t\t}\n\t\tfor (const record of updated) {\n\t\t\t// Work created below a cancelled owner, even after its cascade, is aborted too.\n\t\t\tif (this.#unloaded.has(record.id)) this.#scheduleReconcile();\n\t\t\telse if (!record.background && !record.abortRequested && this.#belowCancelled(parentOf(record))) {\n\t\t\t\tthis.#cascadePending = true;\n\t\t\t}\n\t\t}\n\t\t// A cascade that a reservation or step found pending runs with the next commit of any kind.\n\t\tif (this.#cascadePending) this.#scheduleReconcile();\n\t\tthis.#sweep();\n\t\tif (!changed) return;\n\t\tthis.#settleIdle(dirty);\n\t\tthis.#kick();\n\t}\n\n\t/**\n\t * Add the conversations above `record` to `scopes`: those whose idleness a change of it can change. False when a node\n\t * on the way up is not known. A conversation already in `scopes` has everything above it there too.\n\t */\n\t#addScopesAbove(record: AnyTaskRecord, scopes: Set<ConversationId>): boolean {\n\t\tfor (const step of this.#above(parentOf(record))) {\n\t\t\tif (\"unknown\" in step) return false;\n\t\t\tif (!(\"conversation\" in step)) continue;\n\t\t\tif (scopes.has(step.conversation)) return true;\n\t\t\tscopes.add(step.conversation);\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Extend each kept context range with the entries a stored commit appended to its conversation, so a later read\n\t * needs no Storage scan. Entries are published in ID order.\n\t */\n\t#advanceContexts(publication: Extract<ObservedCommit, { readonly kind: \"stored\" }>): void {\n\t\tif (this.#contexts.size === 0) return;\n\t\tlet appended: Map<ConversationId, EntryRecord[]> | undefined;\n\t\tfor (const change of publication.changes) {\n\t\t\tif (change.type !== \"entry\" || !this.#contexts.has(change.value.conversationId)) continue;\n\t\t\tappended ??= new Map();\n\t\t\tconst entries = appended.get(change.value.conversationId);\n\t\t\tif (entries === undefined) appended.set(change.value.conversationId, [change.value]);\n\t\t\telse entries.push(change.value);\n\t\t}\n\t\tif (appended === undefined) return;\n\t\tfor (const [conversationId, entries] of appended) {\n\t\t\tconst kept = this.#contexts.get(conversationId)!;\n\t\t\t// An idle range past its retention is dropped here too: entry-only commits do not run `#settleIdle()`, and a\n\t\t\t// host may decline the expiry timer. `expiresAt` was fixed when it went idle, so no settings are read here.\n\t\t\tif (kept.idleSince !== undefined && kept.expiresAt !== undefined && kept.expiresAt <= this.#now()) {\n\t\t\t\tthis.#dropContext(conversationId);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst range = advanceRange(kept.range, entries);\n\t\t\tif (range === undefined) this.#dropContext(conversationId);\n\t\t\telse kept.range = range;\n\t\t}\n\t}\n\n\t/**\n\t * `settings.contextRetentionMs`, or 0 when the host's settings throw. Kept contexts are only a cache, so dropping them\n\t * is safe, while a throw here would escape commit listeners, reconciliation, and the expiry timer.\n\t */\n\t#contextRetentionMs(): number {\n\t\ttry {\n\t\t\treturn this.#settings().contextRetentionMs;\n\t\t} catch (error) {\n\t\t\tthis.#report(error, SETTINGS);\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\t/**\n\t * After task changes below the conversations in `scopes` (every conversation when undefined): resolve their idle\n\t * waiters and the Harness-wide ones, drop the kept contexts whose idle period passed the retention, then start or end\n\t * the idle periods of the kept contexts in `scopes`. A task change can change the idleness only of the conversations\n\t * above it, so no check visits every conversation.\n\t */\n\t#settleIdle(scopes: ReadonlySet<ConversationId> | undefined): void {\n\t\tconst all = scopes === undefined || this.#unknownsChanged;\n\t\tthis.#unknownsChanged = false;\n\t\tif (all) this.#fullIdleChecks++;\n\t\tthis.#resolveIdleWaiters(all ? undefined : scopes);\n\t\tconst now = this.#now();\n\t\tconst retention = this.#contextRetentionMs();\n\t\t// Expired first: a context past its retention is dropped even when the same commit makes it busy again.\n\t\tthis.#expireContexts(now, retention);\n\t\tfor (const conversationId of all ? [...this.#contexts.keys()] : scopes) {\n\t\t\tconst kept = this.#contexts.get(conversationId);\n\t\t\tif (kept === undefined) continue;\n\t\t\tif (!this.#idle(conversationId)) {\n\t\t\t\tif (kept.idleSince === undefined) continue;\n\t\t\t\tkept.idleSince = undefined;\n\t\t\t\tthis.#idleOrder.delete(conversationId);\n\t\t\t} else if (retention <= 0) {\n\t\t\t\tthis.#dropContext(conversationId);\n\t\t\t} else if (kept.idleSince === undefined) {\n\t\t\t\tkept.idleSince = now;\n\t\t\t\tkept.expiresAt = now + retention;\n\t\t\t\tthis.#markIdle(conversationId, now);\n\t\t\t}\n\t\t}\n\t\tthis.#scheduleExpiry();\n\t}\n\n\t/** Resolve the idle waiters of the conversations in `scopes` (all when undefined) and the Harness-wide ones. */\n\t#resolveIdleWaiters(scopes: ReadonlySet<ConversationId> | undefined): void {\n\t\tfor (const conversationId of this.#idleWaiters.keys()) {\n\t\t\tif (conversationId !== undefined && scopes !== undefined && !scopes.has(conversationId)) continue;\n\t\t\tif (this.#idle(conversationId)) this.#idleWaiters.resolve(conversationId);\n\t\t}\n\t}\n\n\t/**\n\t * Drop the kept contexts idle for at least `retention`, oldest first, with the retention setting of now; with no\n\t * retention, every idle one, also those whose idle period a clock that went back makes start after now.\n\t */\n\t#expireContexts(now: number, retention: number): void {\n\t\tfor (const [conversationId, idleSince] of this.#idleOrder) {\n\t\t\tif (retention > 0 && now - idleSince < retention) return;\n\t\t\tthis.#dropContext(conversationId);\n\t\t}\n\t}\n\n\t/**\n\t * Start the idle period of a kept context in the expiry order. An idle period older than the newest one kept, which\n\t * a clock that went back starts, sorts the order again, and the newest is taken from what is kept then.\n\t */\n\t#markIdle(conversationId: ConversationId, idleSince: number): void {\n\t\tthis.#idleOrder.delete(conversationId);\n\t\tthis.#idleOrder.set(conversationId, idleSince);\n\t\tif (this.#idleOrder.size === 1 || idleSince >= this.#idleNewest) {\n\t\t\tthis.#idleNewest = idleSince;\n\t\t\treturn;\n\t\t}\n\t\tconst sorted = [...this.#idleOrder].sort((a, b) => a[1] - b[1]);\n\t\tthis.#idleOrder.clear();\n\t\tfor (const [id, since] of sorted) this.#idleOrder.set(id, since);\n\t\tthis.#idleNewest = sorted.at(-1)![1];\n\t}\n\n\t/** Forget a kept context, idle or not, and its place in the expiry order. */\n\t#dropContext(conversationId: ConversationId): void {\n\t\tthis.#contexts.delete(conversationId);\n\t\tthis.#idleOrder.delete(conversationId);\n\t}\n\n\t/**\n\t * Drop the expired contexts when the earliest idle context expires, on a background timer, which never keeps the\n\t * process alive. Where the host declines it, as the default does in Cloudflare Workers, none is kept: a pending timer\n\t * could keep a Durable Object from being evicted, and eviction frees the contexts. There, task changes alone check\n\t * expiry.\n\t */\n\t#scheduleExpiry(): void {\n\t\tconst oldest = this.#idleOrder.values().next();\n\t\tconst at = oldest.done === true ? undefined : oldest.value + this.#contextRetentionMs();\n\t\tif (this.#expiry !== undefined && this.#expiry.at === at) return;\n\t\tthis.#expiry?.disarm();\n\t\tthis.#expiry = undefined;\n\t\tif (at === undefined || this.#closing) return;\n\t\tconst disarm = this.#timers.background(() => {\n\t\t\tthis.#expiry = undefined;\n\t\t\tthis.#expireContexts(this.#now(), this.#contextRetentionMs());\n\t\t\tthis.#scheduleExpiry();\n\t\t}, at - this.#now());\n\t\tif (disarm !== undefined) this.#expiry = { at, disarm };\n\t}\n\n\t// ─── Ownership ───────────────────────────────────────────────────────────\n\n\t#scheduleReconcile(): void {\n\t\t// A read-only reconcile could only fail: what it writes is refused, and its own commits fail the Session.\n\t\tif (this.#reconcileScheduled || this.#closing || this.#readOnly) return;\n\t\tthis.#reconcileScheduled = true;\n\t\tqueueMicrotask(() => void this.#reconcile());\n\t}\n\n\t/**\n\t * One commit that applies what committed records imply: abort marks below live owners with cancellation intent\n\t * (spec §5.4), `failFast` marks (spec §5.5), withdrawn queued inputs below cancelled owners, and the final terminal\n\t * record of every `completing` task whose ordinary owned work is gone. The durable records are the intent, so this\n\t * also repairs whatever a crash left unapplied. Resolves idle waiters that the loaded edges decide.\n\t */\n\tasync #reconcile(): Promise<void> {\n\t\tthis.#reconcileScheduled = false;\n\t\tconst work = this.#reconcileWork();\n\t\tif (work) this.#reconcilingWork++;\n\t\ttry {\n\t\t\tawait this.#session.commitInternal(async (tx) => {\n\t\t\t\tif (this.#closing) return;\n\t\t\t\t// A cascade scans the queued inputs, which waits for every unpublished commit: a request made before the scan\n\t\t\t\t// is covered by it, and none is published while the job holds the line after it.\n\t\t\t\tconst cascade = this.#cascadePending;\n\t\t\t\tconst queued = await this.#loadScopes(cascade);\n\t\t\t\tif (cascade) this.#cascadePending = false;\n\t\t\t\tconst marks = await this.#marks();\n\t\t\t\tfor (const { record, reason } of marks.values()) tx.setTask(withAbortMark(record, reason));\n\t\t\t\tconst withdrawn = await this.#region(\n\t\t\t\t\t() => queued.filter((id) => this.#belowCancelled({ conversation: id })),\n\t\t\t\t\tthis.#reloadScopes,\n\t\t\t\t);\n\t\t\t\tfor (const id of withdrawn) await this.#withdrawInputs(tx, id);\n\t\t\t\tawait this.#finalize(tx);\n\t\t\t}, this.#context);\n\t\t} catch (error) {\n\t\t\t// No extension code runs in this commit: a throw is a storage failure, a host callback, or a bug. None is fixed by\n\t\t\t// running the pass again, so it fails the Session, which reports it.\n\t\t\tthis.#failSession(error);\n\t\t}\n\t\tif (work) this.#reconcilingWork--;\n\t\tthis.#scheduleWake();\n\t\t// Its commit's task changes were settled at their publication; a waiter that asked for this pass checks again, and\n\t\t// what its chain loads resolved can make any scope idle.\n\t\tif (this.#unknownsChanged) {\n\t\t\tthis.#settleIdle(undefined);\n\t\t\treturn;\n\t\t}\n\t\tthis.#resolveIdleWaiters(undefined);\n\t\t// A pass checks expiry too, for hosts that decline the expiry timer.\n\t\tthis.#expireContexts(this.#now(), this.#contextRetentionMs());\n\t\tthis.#scheduleExpiry();\n\t}\n\n\t/**\n\t * The abort marks committed records imply (spec §5.4, §5.5): every live foreground task below a live owner with\n\t * cancellation intent, which is its nearest one (a walk down from each owner with intent does not enter another,\n\t * whose own walk covers what is below it), and every other live task in the `on` of a `failFast` waiter one of whose\n\t * tasks failed. A cascade from an abandoned owner passes its `restart` reason on; any other intent marks, or upgrades\n\t * a `restart` mark, as a request. Collected first, so a request wins over a `restart` mark of the same pass. Derived\n\t * again on every pass, as loading edges can reveal a cancelled owner. Takes the `failFast` checks once its decision\n\t * stands.\n\t */\n\tasync #marks(): Promise<Map<TaskId, { readonly record: AnyTaskRecord; readonly reason: \"restart\" | undefined }>> {\n\t\t// Terminal tasks in a checked `on`, read from Storage: each one's outcome is final.\n\t\tconst ended = new Map<TaskId, AnyTaskRecord | null>();\n\t\tfor (;;) {\n\t\t\tconst plan = await this.#region(() => this.#planMarks(ended), this.#reloadScopes);\n\t\t\tif (\"missing\" in plan) {\n\t\t\t\tfor (const id of plan.missing)\n\t\t\t\t\tended.set(id, (await this.#session.lineStorage.task(id, this.#context)) ?? null);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfor (const id of plan.checked) this.#failFastChecks.delete(id);\n\t\t\treturn plan.marks;\n\t\t}\n\t}\n\n\t/** `#marks()`' decision region; the `failFast` members it needs from Storage first, when `ended` lacks them. */\n\t#planMarks(ended: ReadonlyMap<TaskId, AnyTaskRecord | null>):\n\t\t| { readonly missing: readonly TaskId[] }\n\t\t| {\n\t\t\t\treadonly marks: Map<TaskId, { readonly record: AnyTaskRecord; readonly reason: \"restart\" | undefined }>;\n\t\t\t\treadonly checked: readonly TaskId[];\n\t\t } {\n\t\tconst marks = new Map<TaskId, { readonly record: AnyTaskRecord; readonly reason: \"restart\" | undefined }>();\n\t\t// A mark rewrites the whole record, so the record it copies is read as a task record, keyed: a commit of the task\n\t\t// that is not published yet makes the region wait and run again, rather than stage a mark over a stale checkpoint.\n\t\tconst mark = (found: AnyTaskRecord, reason: \"restart\" | undefined): void => {\n\t\t\tconst record = this.#liveRecord(found.id)!;\n\t\t\tconst staged = marks.get(record.id);\n\t\t\tif (staged !== undefined && staged.reason === undefined) return;\n\t\t\tif (record.abortRequested && (record.abortReason === undefined || reason !== undefined)) return;\n\t\t\tmarks.set(record.id, { record, reason });\n\t\t};\n\t\tthis.#record(INTENT_KEY);\n\t\tfor (const id of this.#intent) {\n\t\t\tconst owner = this.#liveRecord(id)!;\n\t\t\t// Only an owner abandoned after a restart, and nothing else, passes its reason on.\n\t\t\tconst restart = owner.abortReason === \"restart\" && !failedOutcome(owner);\n\t\t\tfor (const { node, live } of this.#walkDown(id, { enter: (below) => !this.#intent.has(below) })) {\n\t\t\t\tif (live !== undefined && !node.background) mark(live, restart ? \"restart\" : undefined);\n\t\t\t}\n\t\t}\n\t\tconst checked = [...this.#failFastChecks];\n\t\tconst missing: TaskId[] = [];\n\t\tfor (const id of checked) {\n\t\t\tconst waiter = this.#liveRecord(id);\n\t\t\tif (waiter?.state.status !== \"waiting\") continue;\n\t\t\tlet failed = false;\n\t\t\tfor (const member of waiter.state.on) {\n\t\t\t\tconst record = this.#liveRecord(member) ?? ended.get(member);\n\t\t\t\tif (record === undefined) missing.push(member);\n\t\t\t\telse if (record !== null && failedOutcome(record)) failed = true;\n\t\t\t}\n\t\t\tif (!failed) continue;\n\t\t\t// Every other live task: the failed one keeps its own outcome.\n\t\t\tfor (const member of waiter.state.on) {\n\t\t\t\tconst record = this.#liveRecord(member);\n\t\t\t\tif (record !== undefined && !failedOutcome(record)) mark(record, undefined);\n\t\t\t}\n\t\t}\n\t\treturn missing.length > 0 ? { missing } : { marks, checked };\n\t}\n\n\t/** Whether a reconcile pass would have work: a cascade to derive, held outcomes to check, or `failFast` waits. */\n\t#reconcileWork(): boolean {\n\t\treturn this.#cascadePending || this.#finalizeChecks.size > 0 || this.#failFastChecks.size > 0;\n\t}\n\n\t/**\n\t * Write the terminal record of every `completing` task without live ordinary owned work. Finalizing one can free its\n\t * owner, so this repeats over the commit's candidates until nothing changes. A held scheduler outcome gets its\n\t * Harness cleanup here. In rounds, one decision region each: the holders the tasks of one round free are checked once,\n\t * in the next, so a holder of many tasks that end together is walked once, not once per task. The first round takes\n\t * the `completing` tasks to check once its decision stands.\n\t */\n\tasync #finalize(tx: Transaction): Promise<void> {\n\t\tconst done = new Set<TaskId>();\n\t\t// The commit's candidates, kept in step with the terminal records each round stages.\n\t\tconst overlay = overlayOf(tx);\n\t\tlet round: readonly TaskId[] = [...this.#finalizeChecks];\n\t\tthis.#finalizeChecks.clear();\n\t\tfor (;;) {\n\t\t\tconst ids = round;\n\t\t\tconst plan = await this.#region(() => this.#planRound(ids, overlay, done), this.#reloadScopes);\n\t\t\tfor (const { record, terminal } of plan.finalized) {\n\t\t\t\ttx.setTask(terminal);\n\t\t\t\t(overlay.tasks as Map<TaskId, AnyTaskRecord>).set(record.id, terminal);\n\t\t\t\tdone.add(record.id);\n\t\t\t\tconst outcome = (record.state as { readonly outcome: TaskOutcome<JsonValue> }).outcome;\n\t\t\t\t// REMINDER: only the scheduler writes `faulted` and `orphaned` (spec §5.4); their cleanup waits for this commit.\n\t\t\t\tif (outcome.status === \"faulted\" || outcome.status === \"orphaned\") {\n\t\t\t\t\tawait this.#settleOutcome(tx, record, outcome);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (plan.next.length === 0) return;\n\t\t\tround = plan.next;\n\t\t}\n\t}\n\n\t/**\n\t * One finalize round's decision: which of `ids` are `completing` without live ordinary owned work below them, in the\n\t * commit's candidates with the round's own finalizations applied in order, and the holders above them to check next.\n\t * Tasks finalized have no live work below them, so walks down skip them. It applies the round's terminal records to\n\t * `overlay` while it decides and takes them back before it returns, so a run again starts from the same candidates.\n\t */\n\t#planRound(\n\t\tids: readonly TaskId[],\n\t\toverlay: Overlay,\n\t\tfinalized: ReadonlySet<TaskId>,\n\t): {\n\t\treadonly finalized: readonly { readonly record: AnyTaskRecord; readonly terminal: AnyTaskRecord }[];\n\t\treadonly next: readonly TaskId[];\n\t} {\n\t\tconst tasks = overlay.tasks as Map<TaskId, AnyTaskRecord>;\n\t\t// The tasks finalized so far, earlier rounds' and this one's, without copying the former.\n\t\tconst round = new Set<TaskId>();\n\t\tconst done = { has: (id: TaskId) => round.has(id) || finalized.has(id) };\n\t\tconst ended: { readonly record: AnyTaskRecord; readonly terminal: AnyTaskRecord; readonly staged: boolean }[] =\n\t\t\t[];\n\t\tconst next = new Set<TaskId>();\n\t\ttry {\n\t\t\tfor (const id of ids) {\n\t\t\t\tconst staged = tasks.get(id);\n\t\t\t\tconst record = staged ?? this.#liveRecord(id);\n\t\t\t\tif (record?.state.status !== \"completing\" || done.has(id)) continue;\n\t\t\t\tif (this.#hasOwnedLive(id, overlay, done)) continue;\n\t\t\t\tconst terminal = withState(record, { status: \"terminal\", outcome: record.state.outcome });\n\t\t\t\ttasks.set(id, terminal);\n\t\t\t\tround.add(id);\n\t\t\t\tended.push({ record, terminal, staged: staged !== undefined });\n\t\t\t\tconst above = this.#nearestLiveAbove(record, overlay);\n\t\t\t\tif (above?.state.status === \"completing\") next.add(above.id);\n\t\t\t}\n\t\t} finally {\n\t\t\tfor (const { record, staged } of ended) {\n\t\t\t\tif (staged) tasks.set(record.id, record);\n\t\t\t\telse tasks.delete(record.id);\n\t\t\t}\n\t\t}\n\t\treturn { finalized: ended, next: [...next] };\n\t}\n\n\t/**\n\t * Load the owner chains of the tasks in `#unloaded` and, with `queued`, of every conversation with queued inputs,\n\t * on the Session line; returns the latter. Reads through the line's Storage, so it may run inside a commit callback.\n\t */\n\tasync #loadScopes(queued: boolean): Promise<ConversationId[]> {\n\t\tfor (const id of [...this.#unloaded]) {\n\t\t\t// An earlier load in this loop may have passed it.\n\t\t\tif (this.#unloaded.has(id)) await this.#loadChain({ task: id });\n\t\t}\n\t\tif (!queued) return [];\n\t\t// A scan, which cannot be keyed: it waits for every unpublished commit.\n\t\tconst submissions = await scanAll((cursor) =>\n\t\t\tthis.#session.lineStorage.scanSubmissions({ status: \"queued\" }, SCAN_PAGE_SIZE, cursor, this.#context),\n\t\t);\n\t\tconst inputs = submissions.filter((submission) => submission.type === \"input\");\n\t\tconst conversations = [...new Set(inputs.map((submission) => submission.conversationId))];\n\t\tfor (const id of conversations) await this.#loadChain({ conversation: id });\n\t\treturn conversations;\n\t}\n\n\t/**\n\t * Load the owner edges and task nodes from `start` up to its ownerless root. A known task outside `#unloaded` ends the\n\t * walk, as its chain is loaded; the `#unloaded` tasks passed have a loaded chain afterwards. Loading a node can reveal\n\t * a cancelled owner, so it makes the next reconcile derive cascade marks. The nodes it installs stay until the job's\n\t * commit is published (`#pin()`).\n\t */\n\tasync #loadChain(start: Up, overlay?: Overlay): Promise<void> {\n\t\tconst passed: TaskId[] = [];\n\t\tlet installed = false;\n\t\tlet at: Up | undefined = start;\n\t\ttry {\n\t\t\twhile (at !== undefined) {\n\t\t\t\tif (\"task\" in at) {\n\t\t\t\t\tconst id: TaskId = at.task;\n\t\t\t\t\tlet node: TaskNode | undefined = this.#live.get(id) ?? this.#settled.get(id);\n\t\t\t\t\t// Created in this commit: the load from its own record covers what is above it.\n\t\t\t\t\tif (node === undefined && overlay?.tasks.has(id) === true) break;\n\t\t\t\t\tif (node !== undefined && !this.#unloaded.has(id)) break;\n\t\t\t\t\tif (node === undefined) {\n\t\t\t\t\t\t// Through the line's Storage: a task whose creation or end is not published yet waits for it.\n\t\t\t\t\t\tconst record = await this.#session.lineStorage.task(id, this.#context);\n\t\t\t\t\t\tif (record === undefined) return;\n\t\t\t\t\t\tnode = nodeOf(record);\n\t\t\t\t\t\tif (record.state.status === \"terminal\") {\n\t\t\t\t\t\t\tthis.#settle(id, node);\n\t\t\t\t\t\t\tthis.#pin(id);\n\t\t\t\t\t\t\tinstalled = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// A loaded node can reveal a cancelling owner: the next reconcile derives marks again.\n\t\t\t\t\t\tthis.#scheduleReconcile();\n\t\t\t\t\t}\n\t\t\t\t\tpassed.push(id);\n\t\t\t\t\tat = parentOf(node);\n\t\t\t\t} else {\n\t\t\t\t\tlet edge = this.#edge(at.conversation, overlay);\n\t\t\t\t\tif (edge === undefined) {\n\t\t\t\t\t\t// Through the line's Storage: a conversation whose creation is not published yet waits for it, so a missing\n\t\t\t\t\t\t// record is never mistaken for an ownerless one.\n\t\t\t\t\t\tconst record = await this.#session.lineStorage.conversation(at.conversation, this.#context);\n\t\t\t\t\t\tedge = record?.owner?.taskId ?? null;\n\t\t\t\t\t\tthis.#setEdge(at.conversation, edge);\n\t\t\t\t\t\tthis.#pin(conversationNode(at.conversation));\n\t\t\t\t\t\tinstalled = true;\n\t\t\t\t\t\t// A loaded node can reveal a cancelling owner: the next reconcile derives marks again.\n\t\t\t\t\t\tthis.#scheduleReconcile();\n\t\t\t\t\t}\n\t\t\t\t\tat = edge === null ? undefined : { task: edge };\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\t// `#idle()` counts a live task whose chain is not loaded as inside every scope it may be in: what this load\n\t\t\t// resolved, also when it stopped early, can make such a scope idle without a task change below it.\n\t\t\tif (passed.some((id) => this.#live.has(id)) || (installed && this.#liveUnloaded())) {\n\t\t\t\tthis.#unknownsChanged = true;\n\t\t\t\t// A waiter such a task held is checked again at the pass's end, also when this load was not a reconcile's.\n\t\t\t\tthis.#scheduleReconcile();\n\t\t\t}\n\t\t}\n\t\tfor (const id of passed) this.#unloaded.delete(id);\n\t}\n\n\t/** Whether a live task's chain is not loaded yet: one `#idle()` counts as inside every scope it may be in. */\n\t#liveUnloaded(): boolean {\n\t\tfor (const id of this.#unloaded) if (this.#live.has(id)) return true;\n\t\treturn false;\n\t}\n\n\t#setEdge(conversationId: ConversationId, owner: TaskId | null): void {\n\t\tthis.#edges.set(conversationId, owner);\n\t\t// The conversation now hangs from its owner, or is a root; with nothing below it, it waits for the sweep.\n\t\tthis.#relist(conversationNode(conversationId));\n\t\tthis.#dropIfUnneeded(conversationNode(conversationId));\n\t}\n\n\t/** Know a terminal task a chain load read, so walks pass through it; its own chain is not loaded yet. */\n\t#settle(id: TaskId, node: TaskNode): void {\n\t\tthis.#settled.set(id, node);\n\t\tthis.#unloaded.add(id);\n\t\tthis.#relist(id);\n\t\tthis.#dropIfUnneeded(id);\n\t}\n\n\t/** Queue an ended task or a conversation for the sweep when nothing is listed below it. */\n\t#dropIfUnneeded(node: Node): void {\n\t\tif (typeof node !== \"string\" && this.#live.has(node)) return;\n\t\tif (this.#below.has(node)) return;\n\t\tthis.#dropQueue.add(node);\n\t\tthis.#scheduleSweep();\n\t}\n\n\t/**\n\t * Sweep in a job of its own on the Session line, after the operation underway: a rejected commit, one with nothing to\n\t * write, and a read publish nothing, so the sweep at the end of `#observe` would not run for what they loaded.\n\t */\n\t#scheduleSweep(): void {\n\t\tif (this.#sweepScheduled || this.#closing) return;\n\t\tthis.#sweepScheduled = true;\n\t\tthis.#session\n\t\t\t.readOnLine(async () => {\n\t\t\t\tthis.#sweepScheduled = false;\n\t\t\t\tthis.#sweep();\n\t\t\t})\n\t\t\t// Rejected only once the Session is closing or failed, when nothing is kept anyway.\n\t\t\t.catch(() => {});\n\t}\n\n\t/**\n\t * Drop the queued nodes that are still unneeded: not live, nothing listed below. Runs once a publication is fully\n\t * tracked, and as a job of its own on the line, never inside an operation: work a commit creates below a chain its\n\t * own callback loaded keeps that chain. A flat loop: unlisting already queued every node on the way up that lost its\n\t * last listed node.\n\t */\n\t#sweep(): void {\n\t\tfor (const node of this.#dropQueue) {\n\t\t\t// Queued again once its pins go.\n\t\t\tif (this.#below.has(node) || this.#pins.has(node)) continue;\n\t\t\tif (typeof node === \"string\") {\n\t\t\t\tthis.#edges.delete(conversationOf(node));\n\t\t\t\tthis.#roots.delete(conversationOf(node));\n\t\t\t} else if (!this.#live.has(node)) {\n\t\t\t\tthis.#settled.delete(node);\n\t\t\t\tthis.#unloaded.delete(node);\n\t\t\t}\n\t\t}\n\t\tthis.#dropQueue.clear();\n\t}\n\n\t/**\n\t * Run `decide`, a decision region (group commit §6): synchronous, reading scheduler memory and recording the keys it\n\t * reads, staging nothing and changing no scheduler state. When a key it read has an unpublished writer, its result,\n\t * or its error, is dropped: once that writer is published, `refresh` reloads what the region needs and it runs\n\t * again. A waiting job holds the line, so unpublished writes only shrink, and the runs converge. What a region read\n\t * that had no unpublished writer gets none for the rest of the job, so its result stands while the job applies it.\n\t */\n\tasync #region<T>(decide: () => T, refresh?: () => Promise<unknown>): Promise<T> {\n\t\tfor (;;) {\n\t\t\tconst keys = new Set<string>();\n\t\t\tthis.#reading = keys;\n\t\t\tlet result: { readonly value: T } | { readonly error: unknown };\n\t\t\ttry {\n\t\t\t\tresult = { value: decide() };\n\t\t\t} catch (error) {\n\t\t\t\tresult = { error };\n\t\t\t} finally {\n\t\t\t\tthis.#reading = undefined;\n\t\t\t}\n\t\t\tconst gates: Promise<void>[] = [];\n\t\t\tfor (const key of keys) {\n\t\t\t\tconst gate = this.#session.touch(key);\n\t\t\t\tif (gate !== undefined) gates.push(gate);\n\t\t\t}\n\t\t\tif (gates.length === 0) {\n\t\t\t\tif (\"error\" in result) throw result.error;\n\t\t\t\treturn result.value;\n\t\t\t}\n\t\t\tawait Promise.all(gates);\n\t\t\tawait refresh?.();\n\t\t}\n\t}\n\n\t/** Load the chains a region walks, again after it waited: what was published meanwhile may list new work. */\n\treadonly #reloadScopes = (): Promise<unknown> => this.#loadScopes(false);\n\n\t/** In a decision region, note that it reads `key`; anywhere else, nothing. */\n\t#record(key: string): void {\n\t\tthis.#reading?.add(key);\n\t}\n\n\t/** A live task's committed record, read by a decision region. */\n\t#liveRecord(id: TaskId): AnyTaskRecord | undefined {\n\t\tthis.#record(taskKey(id));\n\t\treturn this.#live.get(id);\n\t}\n\n\t/**\n\t * Keep `node`, which a chain load of the job on the line installed, until that job's commit is published or fails:\n\t * work it creates below the node needs it, and the sweep would drop it as unneeded before then.\n\t */\n\t#pin(node: Node): void {\n\t\tthis.#pins.set(node, (this.#pins.get(node) ?? 0) + 1);\n\t\tthis.#session.onJobEnd(() => {\n\t\t\tconst count = this.#pins.get(node)! - 1;\n\t\t\tif (count > 0) {\n\t\t\t\tthis.#pins.set(node, count);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.#pins.delete(node);\n\t\t\tthis.#dropIfUnneeded(node);\n\t\t});\n\t}\n\n\t/**\n\t * Bring the scheduler's sets in line with a task's committed record. A task that ended may free the nearest live task\n\t * above it: one holding its outcome finalizes, an abort-marked one runs its abort handler; its waiters may run.\n\t */\n\t#track(previous: AnyTaskRecord | undefined, record: AnyTaskRecord): void {\n\t\tconst id = record.id;\n\t\tconst invocation = this.#invocations.get(id);\n\t\tif (invocation !== undefined) invocation.record = record as TaskRecord<JsonValue, Checkpoint, JsonValue>;\n\t\tif (record.state.status === \"terminal\") {\n\t\t\tif (previous !== undefined && !this.#closing) this.#countActive(-1, record.kind);\n\t\t\tthis.#resumed.delete(id);\n\t\t} else if (previous === undefined && !this.#closing) {\n\t\t\tthis.#countActive(1, record.kind);\n\t\t}\n\t\tif (previous?.state.status === \"waiting\") for (const on of previous.state.on) deleteFrom(this.#waiters, on, id);\n\t\tif (record.state.status === \"terminal\") {\n\t\t\tconst node = nodeOf(record);\n\t\t\tthis.#live.delete(id);\n\t\t\tthis.#sleeping.delete(id);\n\t\t\tthis.#intent.delete(id);\n\t\t\tthis.#runnable.delete(id);\n\t\t\tthis.#finalizeChecks.delete(id);\n\t\t\tthis.#settled.set(id, node);\n\t\t\t// Before anything is forgotten: the walk up to the task it held passes the ended tasks between them. Its chain is\n\t\t\t// loaded, as every commit that ends a task loads the chains of `#unloaded` first.\n\t\t\tthis.#release(node);\n\t\t\tfor (const waiter of this.#waiters.get(id) ?? []) this.#runnable.add(waiter);\n\t\t\tthis.#relist(id);\n\t\t\tthis.#dropIfUnneeded(id);\n\t\t\treturn;\n\t\t}\n\t\tthis.#live.set(id, record);\n\t\tif (previous === undefined) {\n\t\t\tif (!this.#known(parentNode(record))) this.#unloaded.add(id);\n\t\t\tthis.#relist(id);\n\t\t}\n\t\tif (cancellationIntent(record)) this.#intent.add(id);\n\t\telse this.#intent.delete(id);\n\t\tif (record.state.status === \"completing\") {\n\t\t\tthis.#runnable.delete(id);\n\t\t\tthis.#finalizeChecks.add(id);\n\t\t} else {\n\t\t\tthis.#runnable.add(id);\n\t\t}\n\t\tif (record.state.status === \"waiting\") for (const on of record.state.on) addTo(this.#waiters, on, id);\n\t\tif (record.state.status === \"sleeping\") this.#sleeping.add(id);\n\t\telse this.#sleeping.delete(id);\n\t}\n\n\t/** The nearest live task above ended ordinary work may be free now: one holding its outcome, or an aborting one. */\n\t#release(node: TaskNode, overlay?: Overlay): AnyTaskRecord | undefined {\n\t\tconst above = this.#nearestLiveAbove(node, overlay);\n\t\tif (above?.state.status === \"completing\") this.#finalizeChecks.add(above.id);\n\t\telse if (above?.abortRequested === true) this.#runnable.add(above.id);\n\t\treturn above;\n\t}\n\n\t/**\n\t * List `start` under its parent node in `#below` while it is a live task or has nodes listed below it, and unlist it\n\t * otherwise; then its parent, as far up as that changes. So `#below` holds exactly the tree around live work; a\n\t * parent that loses its last listed node is queued for the sweep. A loop, as ownership chains can be deeper than the\n\t * call stack.\n\t */\n\t#relist(start: Node): void {\n\t\tlet node: Node = start;\n\t\tfor (;;) {\n\t\t\tconst needed = (typeof node !== \"string\" && this.#live.has(node)) || this.#below.has(node);\n\t\t\tlet parent: Node | null | undefined;\n\t\t\tif (typeof node === \"string\") {\n\t\t\t\tparent = this.#edges.get(conversationOf(node));\n\t\t\t} else {\n\t\t\t\tconst known = this.#live.get(node) ?? this.#settled.get(node);\n\t\t\t\tif (known === undefined) return;\n\t\t\t\tparent = parentNode(known);\n\t\t\t}\n\t\t\tif (parent === undefined) return;\n\t\t\tif (parent === null) {\n\t\t\t\tconst root = conversationOf(node as `c${number}`);\n\t\t\t\tif (needed) this.#roots.add(root);\n\t\t\t\telse this.#roots.delete(root);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ((this.#below.get(parent)?.has(node) === true) === needed) return;\n\t\t\tif (needed) {\n\t\t\t\tconst first = !this.#below.has(parent);\n\t\t\t\taddTo(this.#below, parent, node);\n\t\t\t\tif (!first) return;\n\t\t\t} else {\n\t\t\t\tdeleteFrom(this.#below, parent, node);\n\t\t\t\tif (this.#below.has(parent)) return;\n\t\t\t\tthis.#dropIfUnneeded(parent);\n\t\t\t}\n\t\t\tnode = parent;\n\t\t}\n\t}\n\n\t/**\n\t * The nearest live task above ended ordinary work `node`, in the overlay's view: the one that work held, if any. Work\n\t * at or below a background task holds nothing above it.\n\t */\n\t#nearestLiveAbove(node: TaskNode, overlay?: Overlay): AnyTaskRecord | undefined {\n\t\tthis.#record(INTENT_KEY);\n\t\tfor (let current = node; !current.background; ) {\n\t\t\tconst owner = current.owner ?? this.#edge(current.conversationId, overlay);\n\t\t\tif (owner === undefined || owner === null) return undefined;\n\t\t\tconst record = overlay?.tasks.get(owner) ?? this.#liveRecord(owner);\n\t\t\tif (record !== undefined && record.state.status !== \"terminal\") return record;\n\t\t\tconst above = record ?? this.#settled.get(owner);\n\t\t\tif (above === undefined) return undefined;\n\t\t\tcurrent = above;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/** Whether the chain above `node` is loaded, without walking: known tasks outside `#unloaded` have a loaded chain. */\n\t#known(node: Node): boolean {\n\t\tif (typeof node !== \"string\") {\n\t\t\treturn (this.#live.has(node) || this.#settled.has(node)) && !this.#unloaded.has(node);\n\t\t}\n\t\tconst owner = this.#edges.get(conversationOf(node));\n\t\treturn owner === null || (owner !== undefined && this.#known(owner));\n\t}\n\n\t/** Owner task of a conversation, `null` when ownerless, `undefined` while not loaded. */\n\t#edge(id: ConversationId, overlay?: Overlay): TaskId | null | undefined {\n\t\tif (overlay?.edges.has(id) === true) return overlay.edges.get(id);\n\t\tthis.#record(conversationKey(id));\n\t\treturn this.#edges.get(id);\n\t}\n\n\t#node(id: TaskId, overlay?: Overlay): TaskNode | undefined {\n\t\treturn overlay?.tasks.get(id) ?? this.#live.get(id) ?? this.#settled.get(id);\n\t}\n\n\t/** Walk up from `start`: owner tasks and conversations, ending at an ownerless root or an edge not loaded yet. */\n\t*#above(start: Up, overlay?: Overlay): Generator<Step> {\n\t\tlet at: Up | undefined = start;\n\t\twhile (at !== undefined) {\n\t\t\tif (\"task\" in at) {\n\t\t\t\tconst node = this.#node(at.task, overlay);\n\t\t\t\tif (node === undefined) {\n\t\t\t\t\tyield { unknown: true };\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tyield { task: at.task, node };\n\t\t\t\tat = parentOf(node);\n\t\t\t} else {\n\t\t\t\tyield { conversation: at.conversation };\n\t\t\t\tconst edge = this.#edge(at.conversation, overlay);\n\t\t\t\tif (edge === undefined) {\n\t\t\t\t\tyield { unknown: true };\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tat = edge === null ? undefined : { task: edge };\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * The tasks below `start` that a walk down reaches: those `#below` lists and, under an overlay, the commit's new tasks,\n\t * with its candidates in place of committed records. Background tasks are reached but not entered, unless\n\t * `crossBackground`, and neither are the tasks `enter` rejects. A loop, as chains can be deeper than the call stack.\n\t */\n\t*#walkDown(\n\t\tstart: Node,\n\t\toptions: {\n\t\t\treadonly overlay?: Overlay;\n\t\t\treadonly crossBackground?: boolean;\n\t\t\treadonly enter?: (id: TaskId) => boolean;\n\t\t} = {},\n\t): Generator<{ readonly id: TaskId; readonly node: TaskNode; readonly live: AnyTaskRecord | undefined }> {\n\t\tconst { overlay, crossBackground = false, enter } = options;\n\t\tconst links = overlay === undefined ? undefined : this.#links(overlay);\n\t\tconst pending: Node[] = [start];\n\t\tfor (let at = pending.pop(); at !== undefined; at = pending.pop()) {\n\t\t\tthis.#record(ownedKey(at));\n\t\t\tfor (const children of [this.#below.get(at), links?.get(at)]) {\n\t\t\t\tfor (const child of children ?? []) {\n\t\t\t\t\tif (typeof child === \"string\") {\n\t\t\t\t\t\tpending.push(child);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tconst record = overlay?.tasks.get(child) ?? this.#live.get(child);\n\t\t\t\t\tconst node = record ?? this.#settled.get(child);\n\t\t\t\t\tif (node === undefined) continue;\n\t\t\t\t\tconst live = record !== undefined && record.state.status !== \"terminal\" ? record : undefined;\n\t\t\t\t\tyield { id: child, node, live };\n\t\t\t\t\tif ((crossBackground || !node.background) && (enter === undefined || enter(child))) pending.push(child);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * The links walks down need for the commit's new tasks: each one under its parent node, then each node above it that\n\t * `#below` does not list yet, until one it lists, a live task (always listed), or the chain's end.\n\t */\n\t#links(overlay: Overlay): ReadonlyMap<Node, ReadonlySet<Node>> {\n\t\tif (overlay.links !== undefined) return overlay.links;\n\t\tconst links = new Map<Node, Set<Node>>();\n\t\tfor (const record of overlay.tasks.values()) {\n\t\t\tif (this.#live.has(record.id) || this.#settled.has(record.id)) continue;\n\t\t\tlet child: Node = record.id;\n\t\t\tlet parent: Node | null | undefined = parentNode(record);\n\t\t\twhile (parent !== undefined && parent !== null && links.get(parent)?.has(child) !== true) {\n\t\t\t\taddTo(links, parent, child);\n\t\t\t\tif (typeof parent !== \"string\" && (this.#live.has(parent) || overlay.tasks.has(parent))) break;\n\t\t\t\tlet above: Node | null | undefined;\n\t\t\t\tif (typeof parent === \"string\") {\n\t\t\t\t\tabove = this.#edge(conversationOf(parent), overlay);\n\t\t\t\t} else {\n\t\t\t\t\tconst fields = this.#settled.get(parent);\n\t\t\t\t\tabove = fields === undefined ? undefined : parentNode(fields);\n\t\t\t\t}\n\t\t\t\tif (above !== undefined && above !== null && this.#below.get(above)?.has(parent) === true) break;\n\t\t\t\tchild = parent;\n\t\t\t\tparent = above;\n\t\t\t}\n\t\t}\n\t\toverlay.links = links;\n\t\treturn links;\n\t}\n\n\t/**\n\t * The live ordinary owned work of `owner` (spec §5.5): the live non-background tasks below it that a walk down reaches\n\t * without entering a background task; with `first`, only the first. Candidates in `overlay` replace committed records;\n\t * the walk does not enter tasks in `done`, which have none. Owner chains must be loaded.\n\t */\n\t#ownedLive(\n\t\towner: TaskId,\n\t\toptions: { readonly overlay?: Overlay; readonly first?: boolean; readonly done?: Finalized } = {},\n\t): TaskId[] {\n\t\tconst { overlay, first = false, done } = options;\n\t\tconst found: TaskId[] = [];\n\t\tconst walk = this.#walkDown(owner, {\n\t\t\t...(overlay === undefined ? {} : { overlay }),\n\t\t\t...(done === undefined ? {} : { enter: (id: TaskId) => !done.has(id) }),\n\t\t});\n\t\tfor (const { id, node, live } of walk) {\n\t\t\tif (live === undefined || node.background) continue;\n\t\t\tfound.push(id);\n\t\t\tif (first) break;\n\t\t}\n\t\treturn found;\n\t}\n\n\t#hasOwnedLive(owner: TaskId, overlay?: Overlay, done?: Finalized): boolean {\n\t\tconst options = {\n\t\t\tfirst: true,\n\t\t\t...(overlay === undefined ? {} : { overlay }),\n\t\t\t...(done === undefined ? {} : { done }),\n\t\t};\n\t\treturn this.#ownedLive(owner, options).length > 0;\n\t}\n\n\t/**\n\t * Whether ordinary traversal from `scope` reaches `start`: walking up reaches the scope's conversation, or an\n\t * ownerless one for `roots`, without crossing a background owner, unless `crossBackground`. `undefined` while an\n\t * edge is not loaded.\n\t */\n\t#inScope(start: Up, scope: Scope, crossBackground = false): boolean | undefined {\n\t\tthis.#record(INTENT_KEY);\n\t\tfor (const step of this.#above(start)) {\n\t\t\tif (\"unknown\" in step) return undefined;\n\t\t\tif (\"conversation\" in step) {\n\t\t\t\tif (\"conversation\" in scope && step.conversation === scope.conversation) return true;\n\t\t\t} else if (step.node.background && !crossBackground) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn \"roots\" in scope;\n\t}\n\n\t/**\n\t * Whether a live owner's cancellation intent reaches `start`: walking up finds an owner with intent before a\n\t * background owner without it. Terminal owners never cascade (spec §5.4).\n\t */\n\t#belowCancelled(start: Up): boolean {\n\t\treturn this.#cancellingOwner(start) !== undefined;\n\t}\n\n\t/** The nearest live owner above `start` whose cancellation intent reaches it, if any; see `#belowCancelled`. */\n\t#cancellingOwner(start: Up): AnyTaskRecord | undefined {\n\t\tthis.#record(INTENT_KEY);\n\t\t// Nothing cancels, the common case: no walk.\n\t\tif (this.#intent.size === 0) return undefined;\n\t\tfor (const step of this.#above(start)) {\n\t\t\tif (\"unknown\" in step) return undefined;\n\t\t\tif (!(\"task\" in step)) continue;\n\t\t\tconst live = this.#live.get(step.task);\n\t\t\tif (live !== undefined && cancellationIntent(live)) return live;\n\t\t\tif (step.node.background) return undefined;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Count a task in or out of `pi.durable.tasks.active`. Commit observers count at a commit's publication, which must not\n\t * throw, so a throwing adapter is reported.\n\t */\n\t#countActive(delta: 1 | -1, kind: string): void {\n\t\ttry {\n\t\t\tthis.#activeMetric.add(delta, { task: kind });\n\t\t} catch (error) {\n\t\t\tthis.#report(error, TELEMETRY);\n\t\t}\n\t}\n\n\t/** Fail the Session, which reports it, for a throw in one of the scheduler's own commits; ignored once closing. */\n\t#failSession(error: unknown, context?: Context): void {\n\t\tif (!this.#closing) this.#session.fail(error, context);\n\t}\n\n\t/** Close listener: runs synchronously once admission is sealed, before `join()`, or when the Session fails. */\n\t#seal(): void {\n\t\tfor (const record of this.#live.values()) this.#countActive(-1, record.kind);\n\t\tthis.#resumed.clear();\n\t\tthis.#closing = true;\n\t\ttry {\n\t\t\tthis.#unsubscribeRegistry();\n\t\t} catch (error) {\n\t\t\tthis.#report(error, REGISTRY);\n\t\t}\n\t\tconst error = closedError(this.#session);\n\t\tthis.#taskWaiters.rejectAll(error);\n\t\tthis.#idleWaiters.rejectAll(error);\n\t\tthis.#contexts.clear();\n\t\tthis.#idleOrder.clear();\n\t\tthis.#expiry?.disarm();\n\t\tthis.#expiry = undefined;\n\t\tthis.#timer?.disarm();\n\t\tthis.#timer = undefined;\n\t}\n\n\t/**\n\t * Recompute the wake in a microtask the line never waits for, with no order relative to host commit listeners (one\n\t * already queued serves later changes too): arm the built-in timer, or tell `onWake` of a change.\n\t */\n\t#scheduleWake(): void {\n\t\tif (this.#wakeScheduled || this.#closing || this.#readOnly) return;\n\t\tthis.#wakeScheduled = true;\n\t\tqueueMicrotask(() => {\n\t\t\tthis.#wakeScheduled = false;\n\t\t\tif (this.#closing) return;\n\t\t\tconst wake = this.wake();\n\t\t\tif (this.#onWake === undefined) {\n\t\t\t\tthis.#armTimer(this.#enabled ? wake.at : undefined);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst last = this.#lastWake;\n\t\t\tif (last !== undefined && last.active === wake.active && last.at === wake.at) return;\n\t\t\ttry {\n\t\t\t\tthis.#onWake(wake);\n\t\t\t\t// Only a delivered wake counts: after a throw, the next change or kick offers it again.\n\t\t\t\tthis.#lastWake = wake;\n\t\t\t} catch (error) {\n\t\t\t\tthis.#report(error, ON_WAKE);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Keep the timer for the earliest sleep. It keeps the process alive, unlike the context expiry timer: a process with a\n\t * sleeping task has work left, such as a retry backoff. Rechecks the clock when it fires, so a wake before `until`\n\t * only arms it again.\n\t */\n\t#armTimer(at: number | undefined): void {\n\t\tif (this.#timer !== undefined && this.#timer.at === at) return;\n\t\tthis.#timer?.disarm();\n\t\tthis.#timer = undefined;\n\t\tif (at === undefined || this.#closing) return;\n\t\tconst disarm = this.#timers.foreground(() => {\n\t\t\tthis.#timer = undefined;\n\t\t\tthis.#wakeDue();\n\t\t\tthis.#kick();\n\t\t}, at - this.#now());\n\t\tthis.#timer = { at, disarm };\n\t}\n\n\t/** Make every sleeping task whose time has come a reservation candidate. */\n\t#wakeDue(): void {\n\t\tfor (const id of this.#sleeping) {\n\t\t\tconst record = this.#live.get(id);\n\t\t\tif (record !== undefined && !this.#notDue(record)) this.#runnable.add(id);\n\t\t}\n\t}\n\n\t/**\n\t * The report info of a task's failure, with the extension that installed its definition: the code that failed is\n\t * that extension's. Built-in tasks have none.\n\t */\n\t/** What a report about `task`'s own code says of it: the task, and the extension that installed its definition. */\n\t#aboutTask(task: {\n\t\treadonly taskId: TaskId;\n\t\treadonly kind: string;\n\t\treadonly conversationId: ConversationId;\n\t\t/** The installer of the definition whose code ran (an invocation's); absent: the current one's. */\n\t\treadonly extension?: string | undefined;\n\t}): { readonly task: ReportTask; readonly extension?: string } {\n\t\tlet extension: string | undefined;\n\t\tif (\"extension\" in task) extension = task.extension;\n\t\telse {\n\t\t\ttry {\n\t\t\t\tconst snapshot = this.#registry.snapshot();\n\t\t\t\textension = installerOf(snapshot, snapshot.task(task.kind));\n\t\t\t} catch {\n\t\t\t\t// A registry that throws is reported where it is read for scheduling; a report goes out without the name.\n\t\t\t}\n\t\t}\n\t\treturn { task: reportTask(task), ...optionalExtension(extension) };\n\t}\n\n\t/** `settings.restartLimit`, or the default when the host's settings throw. */\n\t#restartLimit(): number {\n\t\ttry {\n\t\t\treturn this.#settings().restartLimit;\n\t\t} catch (error) {\n\t\t\tthis.#report(error, SETTINGS);\n\t\t\treturn DEFAULT_RESTART_LIMIT;\n\t\t}\n\t}\n\n\t#notifyBlocked(): void {\n\t\tfor (const listener of [...this.#blockedListeners]) {\n\t\t\ttry {\n\t\t\t\tlistener();\n\t\t\t} catch (error) {\n\t\t\t\tthis.#report(error, { kind: \"listener_error\" });\n\t\t\t}\n\t\t}\n\t}\n\n\t/** A sleep whose `until` the clock has not reached; an abort mark ends a sleep. */\n\t#notDue(\n\t\trecord: AnyTaskRecord,\n\t): record is AnyTaskRecord & { readonly state: { readonly status: \"sleeping\"; readonly until: number } } {\n\t\tconst state = record.state;\n\t\treturn state.status === \"sleeping\" && !record.abortRequested && state.until > this.#now();\n\t}\n\n\t#kick(): void {\n\t\tthis.#scheduleWake();\n\t\tthis.#dirty = true;\n\t\tif (this.#draining || !this.#enabled || this.#closing) return;\n\t\tthis.#draining = true;\n\t\t// Never commit synchronously from a commit or registry listener.\n\t\tqueueMicrotask(() => void this.#drain());\n\t}\n\n\tasync #drain(): Promise<void> {\n\t\ttry {\n\t\t\twhile (this.#dirty && this.#enabled && !this.#closing) {\n\t\t\t\tthis.#dirty = false;\n\t\t\t\tfor (const reservation of await this.#reserve()) this.#start(reservation);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\t// As in `#reconcile()`: the reservation commit runs no extension code.\n\t\t\tthis.#failSession(error);\n\t\t} finally {\n\t\t\tthis.#draining = false;\n\t\t\t// A wakeup that arrived after the loop's last check still needs its pass.\n\t\t\tif (this.#dirty) this.#kick();\n\t\t}\n\t}\n\n\t/**\n\t * Reserve every eligible task in one commit; orphan abort-marked tasks no definition can take, unless abandoned after\n\t * a restart. The first pass after open only abort-marks the abandoned tasks, so later passes see the marks.\n\t */\n\tasync #reserve(): Promise<Reservation[]> {\n\t\tconst reservations: Reservation[] = [];\n\t\tconst faulted: { readonly record: AnyTaskRecord; readonly message: string }[] = [];\n\t\tlet abandoned: TaskId[] = [];\n\t\ttry {\n\t\t\tawait this.#session.commitInternal(async (tx) => {\n\t\t\t\tif (!this.#enabled || this.#closing) return;\n\t\t\t\tif (this.#abandoned.size > 0) {\n\t\t\t\t\tconst ids = [...this.#abandoned];\n\t\t\t\t\tconst unmarked = await this.#region(() =>\n\t\t\t\t\t\tids\n\t\t\t\t\t\t\t.map((id) => this.#liveRecord(id))\n\t\t\t\t\t\t\t.filter((record) => record !== undefined && !record.abortRequested),\n\t\t\t\t\t);\n\t\t\t\t\tfor (const record of unmarked) tx.setTask(withAbortMark(record!, \"restart\"));\n\t\t\t\t\tabandoned = ids;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tawait this.#loadScopes(false);\n\t\t\t\t// Every pass picks up sleeps whose time has come: a pass started by any change may be the first to run after\n\t\t\t\t// a deadline, and the wake it schedules no longer keeps a timer for a due sleep.\n\t\t\t\tthis.#wakeDue();\n\t\t\t\tconst plan = await this.#planCandidates();\n\t\t\t\t// Work below an owner with cancellation intent waits for its cascade mark instead of running a phase; schedule\n\t\t\t\t// the cascade, which may not have run yet.\n\t\t\t\tif (plan.cascade) {\n\t\t\t\t\tthis.#cascadePending = true;\n\t\t\t\t\tthis.#scheduleReconcile();\n\t\t\t\t}\n\t\t\t\t// Taken once per pass, and only when some task is a candidate.\n\t\t\t\tlet snapshot: RegistrySnapshot | undefined;\n\t\t\t\tfor (const record of plan.ready) {\n\t\t\t\t\tconst id = record.id;\n\t\t\t\t\tconst mode = record.abortRequested ? \"abort\" : \"run\";\n\t\t\t\t\t// Work cut off `restartLimit` times in a row would run forever: an abort handler, or a phase of a kind that\n\t\t\t\t\t// does not end itself at the limit, ends the task `faulted` instead.\n\t\t\t\t\t// The settings are read only for a task that was cut off at all.\n\t\t\t\t\tconst cutOff = record.restarts !== undefined && record.restarts >= this.#restartLimit();\n\t\t\t\t\tif (cutOff && (mode === \"abort\" || !this.#limitsRestarts(record.kind))) {\n\t\t\t\t\t\tconst message =\n\t\t\t\t\t\t\tmode === \"abort\"\n\t\t\t\t\t\t\t\t? `Abort handler of task ${id} (${record.kind}) was cut off ${record.restarts} times`\n\t\t\t\t\t\t\t\t: `Task ${id} (${record.kind}) was cut off ${record.restarts} times without progress`;\n\t\t\t\t\t\tawait this.#terminate(tx, record, {\n\t\t\t\t\t\t\tstatus: \"faulted\",\n\t\t\t\t\t\t\terror: { message, detail: { reason: \"restart_limit\" } },\n\t\t\t\t\t\t});\n\t\t\t\t\t\tfaulted.push({ record, message });\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tsnapshot ??= this.#registry.snapshot();\n\t\t\t\t\tconst resolution = this.#resolve(record, snapshot);\n\t\t\t\t\tif (resolution.kind === \"blocked\") {\n\t\t\t\t\t\t// An abandoned task waits for its definition, so its abort handler can clean up.\n\t\t\t\t\t\tif (mode === \"abort\" && record.abortReason === undefined) {\n\t\t\t\t\t\t\tawait this.#terminate(tx, record, { status: \"orphaned\", reason: resolution.reason });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (resolution.record !== record || record.state.status !== \"running\") {\n\t\t\t\t\t\ttx.setTask(\n\t\t\t\t\t\t\twithState(resolution.record, {\n\t\t\t\t\t\t\t\tstatus: \"running\",\n\t\t\t\t\t\t\t\tcheckpoint: resolution.record.state.checkpoint,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\t// Registered on the line, so marks and later reservations see it and close joins it; `#end` makes it a\n\t\t\t\t\t// candidate again.\n\t\t\t\t\tthis.#runnable.delete(id);\n\t\t\t\t\tconst invocation = this.#createInvocation(record, mode, installerOf(snapshot, resolution.task));\n\t\t\t\t\treservations.push({ invocation, task: resolution.task, snapshot });\n\t\t\t\t}\n\t\t\t}, this.#context);\n\t\t} catch (error) {\n\t\t\tfor (const { invocation } of reservations) {\n\t\t\t\tthis.#invocations.delete(invocation.taskId);\n\t\t\t\tthis.#runnable.add(invocation.taskId);\n\t\t\t\tinvocation.finish();\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t\tfor (const { record, message } of faulted) {\n\t\t\tthis.#report(new Error(message), {\n\t\t\t\tkind: \"task_faulted\",\n\t\t\t\t...this.#aboutTask(recordTask(record)),\n\t\t\t\treason: \"restart_limit\",\n\t\t\t});\n\t\t}\n\t\t// Marked, or already marked or gone: done with them. Reserve again, now seeing the marks.\n\t\tfor (const id of abandoned) this.#abandoned.delete(id);\n\t\tif (abandoned.length > 0) this.#dirty = true;\n\t\treturn reservations;\n\t}\n\n\t/**\n\t * Plan a reservation pass over the candidates, taken out of `#runnable` while it plans: a task made a candidate\n\t * meanwhile, such as a waiter whose last task ended, lands in the fresh set, so the pass's decision to drop it cannot\n\t * erase that. The candidates not dropped go back in front of the fresh set, unless they ended or hold meanwhile.\n\t */\n\tasync #planCandidates(): Promise<ReservationPlan> {\n\t\tconst candidates = this.#runnable;\n\t\tthis.#runnable = new Set();\n\t\tlet dropped: ReadonlySet<TaskId> = new Set();\n\t\ttry {\n\t\t\tconst plan = await this.#region(() => this.#planReservation(candidates), this.#reloadScopes);\n\t\t\tdropped = new Set(plan.dropped);\n\t\t\treturn plan;\n\t\t} finally {\n\t\t\tconst merged = new Set<TaskId>();\n\t\t\tfor (const id of candidates) {\n\t\t\t\tconst status = this.#live.get(id)?.state.status;\n\t\t\t\tif (!dropped.has(id) && status !== undefined && status !== \"completing\") merged.add(id);\n\t\t\t}\n\t\t\tfor (const id of this.#runnable) merged.add(id);\n\t\t\tthis.#runnable = merged;\n\t\t}\n\t}\n\n\t/**\n\t * A reservation pass's decision region: the candidates it drops (gone, holding, waiting, asleep, or with an\n\t * invocation), whether one waits for a cascade, and the runnable records to resolve. Iterating the candidates is not\n\t * keyed: a pass that misses a task a pending commit makes runnable only delays it, as does skipping one with an\n\t * invocation without reading its record, or a waiter's check whether what it waits on is still live.\n\t */\n\t#planReservation(candidates: ReadonlySet<TaskId>): ReservationPlan {\n\t\tconst dropped: TaskId[] = [];\n\t\tconst ready: RunnableTaskRecord[] = [];\n\t\tlet cascade = false;\n\t\tfor (const id of candidates) {\n\t\t\tif (this.#invocations.has(id)) {\n\t\t\t\tdropped.push(id);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst record = this.#liveRecord(id);\n\t\t\t// It returns once what it waits for ends, its record changes, or the work below it ends; a sleep at the first pass\n\t\t\t// after its time comes, which the timer, `resume()`, or any change starts.\n\t\t\tif (\n\t\t\t\trecord === undefined ||\n\t\t\t\trecord.state.status === \"completing\" ||\n\t\t\t\tthis.#waitingOn(record, true).length > 0 ||\n\t\t\t\tthis.#notDue(record)\n\t\t\t) {\n\t\t\t\tdropped.push(id);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!record.abortRequested && !record.background && this.#belowCancelled(parentOf(record))) {\n\t\t\t\tcascade = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tready.push(record as RunnableTaskRecord);\n\t\t}\n\t\treturn { dropped, cascade, ready };\n\t}\n\n\t/**\n\t * Live tasks a task waits for before its next invocation: its live ordinary owned work when abort-marked, since\n\t * abort runs bottom-up, otherwise the live part of the `on` of a wait.\n\t */\n\t#waitingOn(record: AnyTaskRecord, first = false): readonly TaskId[] {\n\t\tif (record.abortRequested) return this.#ownedLive(record.id, { first });\n\t\tif (record.state.status !== \"waiting\") return [];\n\t\tif (!first) return record.state.on.filter((id) => this.#live.has(id));\n\t\tconst live = record.state.on.find((id) => this.#live.has(id));\n\t\treturn live === undefined ? [] : [live];\n\t}\n\n\t/** Resolve the record's definition by kind, migrating an older stored version. */\n\t#resolve(record: RunnableTaskRecord, snapshot: RegistrySnapshot): Resolution {\n\t\tconst fit = this.#fit(record, snapshot.task(record.kind));\n\t\tif (\"reason\" in fit) return { kind: \"blocked\", reason: fit.reason };\n\t\tif (!fit.migrates) return { kind: \"ready\", task: fit.task, record };\n\t\tconst definition = erased(fit.task);\n\t\ttry {\n\t\t\tif (definition.migrate === undefined) throw missingMigration(record, definition);\n\t\t\tconst migrated = definition.migrate(record.input, record.state.checkpoint, record.version);\n\t\t\tconst state = { ...record.state, checkpoint: copyJson(migrated.checkpoint) };\n\t\t\tconst migratedRecord = { ...record, version: definition.version, input: copyJson(migrated.input), state };\n\t\t\treturn { kind: \"ready\", task: fit.task, record: migratedRecord as RunnableTaskRecord };\n\t\t} catch (error) {\n\t\t\tthis.#failedMigrations.set(record.id, { task: fit.task, error });\n\t\t\t// Blocked now without a commit: the graph and the host's wake must hear it.\n\t\t\tqueueMicrotask(() => this.#notifyBlocked());\n\t\t\tthis.#scheduleWake();\n\t\t\tconst extension = installerOf(snapshot, fit.task);\n\t\t\tthis.#report(error, { kind: \"migration_failed\", ...this.#aboutTask({ ...recordTask(record), extension }) });\n\t\t\treturn { kind: \"blocked\", reason: \"migration_failed\" };\n\t\t}\n\t}\n\n\t#fit(record: Pick<AnyTaskRecord, \"id\" | \"version\">, task: AnyTask | undefined): Fit {\n\t\tif (task === undefined) return { reason: \"missing_task\" };\n\t\tconst version = task.definition.version;\n\t\tif (version === record.version) return { task, migrates: false };\n\t\tif (version < record.version) return { reason: \"task_too_old\" };\n\t\tconst failed = this.#failedMigrations.get(record.id);\n\t\tif (failed?.task === task) return { reason: \"migration_failed\", error: failed.error };\n\t\treturn { task, migrates: true };\n\t}\n\n\t/** Sizes of the ownership indexes, for tests that bound the scheduler's memory. */\n\tget indexSizes(): Readonly<\n\t\tRecord<\"live\" | \"settled\" | \"edges\" | \"below\" | \"roots\" | \"unloaded\" | \"dropQueue\" | \"pins\", number>\n\t> {\n\t\tlet below = 0;\n\t\tfor (const children of this.#below.values()) below += children.size;\n\t\treturn {\n\t\t\tlive: this.#live.size,\n\t\t\tsettled: this.#settled.size,\n\t\t\tedges: this.#edges.size,\n\t\t\tbelow,\n\t\t\troots: this.#roots.size,\n\t\t\tunloaded: this.#unloaded.size,\n\t\t\tdropQueue: this.#dropQueue.size,\n\t\t\tpins: this.#pins.size,\n\t\t};\n\t}\n\n\t/**\n\t * The kept contexts' idle state, for tests (a diagnostic, computed on demand): how many are kept and how many are\n\t * idle, how many disagree with a full recompute (an idle period without `#idle()`, or `#idle()` without one; an\n\t * expiry order that differs from the idle periods, or is not sorted), and how many idle checks covered every scope.\n\t */\n\tget idleState(): Readonly<Record<\"contexts\" | \"idleContexts\" | \"idleMismatches\" | \"fullIdleChecks\", number>> {\n\t\tlet mismatches = 0;\n\t\tlet idle = 0;\n\t\tfor (const [conversationId, kept] of this.#contexts) {\n\t\t\tif (kept.idleSince !== undefined) idle++;\n\t\t\tif ((kept.idleSince !== undefined) !== this.#idle(conversationId)) mismatches++;\n\t\t\tif (this.#idleOrder.get(conversationId) !== kept.idleSince) mismatches++;\n\t\t}\n\t\tlet previous = Number.NEGATIVE_INFINITY;\n\t\tfor (const [conversationId, idleSince] of this.#idleOrder) {\n\t\t\tif (idleSince < previous || this.#contexts.get(conversationId)?.idleSince !== idleSince) mismatches++;\n\t\t\tprevious = idleSince;\n\t\t}\n\t\treturn {\n\t\t\tcontexts: this.#contexts.size,\n\t\t\tidleContexts: idle,\n\t\t\tidleMismatches: mismatches,\n\t\t\tfullIdleChecks: this.#fullIdleChecks,\n\t\t};\n\t}\n\n\t/**\n\t * Scheduling state and every live task with its derived state, read on the Session line. Runs no task code: a\n\t * pending migration shows as `ready` with `migrates`, and only a migration the scheduler already tried, or one that\n\t * cannot exist, shows as failed.\n\t */\n\tasync inspect(\n\t\tsnapshot: RegistrySnapshot,\n\t): Promise<{ scheduling: HarnessInspection[\"scheduling\"]; tasks: TaskInspection[] }> {\n\t\tawait this.#published();\n\t\tawait this.#loadScopes(false);\n\t\tconst tasks: TaskInspection[] = [];\n\t\tfor (const record of this.#live.values()) tasks.push({ record, state: this.#inspectTask(record, snapshot) });\n\t\tconst scheduling = this.#closing ? \"closing\" : this.#enabled ? \"running\" : \"paused\";\n\t\treturn { scheduling, tasks };\n\t}\n\n\t#inspectTask(record: AnyTaskRecord, snapshot: RegistrySnapshot): TaskInspection[\"state\"] {\n\t\tif (this.#invocations.has(record.id)) return { kind: \"running\" };\n\t\tif (record.state.status === \"completing\") return { kind: \"completing\" };\n\t\tconst on = this.#waitingOn(record);\n\t\tif (on.length > 0) return { kind: \"waiting\", on };\n\t\tif (this.#notDue(record)) return { kind: \"sleeping\", until: record.state.until };\n\t\tconst fit = this.#fit(record, snapshot.task(record.kind));\n\t\tif (\"reason\" in fit) return { kind: \"blocked\", ...fit };\n\t\tif (fit.migrates && fit.task.definition.migrate === undefined) {\n\t\t\treturn { kind: \"blocked\", reason: \"migration_failed\", error: missingMigration(record, erased(fit.task)) };\n\t\t}\n\t\treturn { kind: \"pending\", migrates: fit.migrates };\n\t}\n\n\t#createInvocation(record: RunnableTaskRecord, mode: \"run\" | \"abort\", extension: string | undefined): Invocation {\n\t\tconst controller = new AbortController();\n\t\tconst { promise: done, resolve: finish } = Promise.withResolvers<void>();\n\t\tconst invocation: Invocation = {\n\t\t\ttaskId: record.id,\n\t\t\tkind: record.kind,\n\t\t\textension,\n\t\t\tconversationId: record.conversationId,\n\t\t\tmode,\n\t\t\tcontroller,\n\t\t\tlinks: record.startedAt === undefined ? record.links : undefined,\n\t\t\tcontext: withAbortSignal(controller.signal, this.#context),\n\t\t\trecord: record as TaskRecord<JsonValue, Checkpoint, JsonValue>,\n\t\t\twatches: new Set(),\n\t\t\ttimers: new Set(),\n\t\t\tended: false,\n\t\t\tdone,\n\t\t\tfinish: () => finish(),\n\t\t};\n\t\tthis.#invocations.set(record.id, invocation);\n\t\treturn invocation;\n\t}\n\n\t#start(reservation: Reservation): void {\n\t\tconst invocation = reservation.invocation;\n\t\tvoid (async () => {\n\t\t\ttry {\n\t\t\t\tif (invocation.mode === \"run\") await this.#run(reservation);\n\t\t\t\telse await this.#runAbort(reservation);\n\t\t\t} catch (error) {\n\t\t\t\tthis.#report(error, { kind: \"task_error\", ...this.#aboutTask(invocation) }, invocation.context);\n\t\t\t} finally {\n\t\t\t\tthis.#end(invocation);\n\t\t\t\tinvocation.record = undefined;\n\t\t\t\tinvocation.links = undefined;\n\t\t\t\tinvocation.fault = undefined;\n\t\t\t\tinvocation.finish();\n\t\t\t\tthis.#kick();\n\t\t\t}\n\t\t})();\n\t}\n\n\t/** Run phase handlers, each preceded by a step that decides on the line whether the invocation continues. */\n\tasync #run(reservation: Reservation): Promise<void> {\n\t\tconst invocation = reservation.invocation;\n\t\tconst state = { task: reservation.task, snapshot: reservation.snapshot, reported: undefined as ReportedTask };\n\t\tconst phase: Phase = { snapshot: () => state.snapshot, task: () => state.task, agent: undefined };\n\t\tconst runtime = this.#runtime(invocation, phase);\n\t\tconst progress = (tx: Transaction, current: ErasedRunningTask) =>\n\t\t\tthis.#progress(tx, current, state, invocation.extension, invocation.context);\n\t\tlet current = await this.#step(invocation, (task) => this.#rules(task, undefined), progress);\n\t\twhile (current !== undefined && !this.#closing) {\n\t\t\tconst task = current;\n\t\t\tcurrent = await this.#phase(invocation, task, async () => {\n\t\t\t\tconst checkpoint = task.state.checkpoint;\n\t\t\t\t// Each phase handler resolves its agent afresh, at first use.\n\t\t\t\tphase.agent = undefined;\n\t\t\t\tlet previous: PhaseResult;\n\t\t\t\ttry {\n\t\t\t\t\tawait erased(state.task).phases[checkpoint.phase]!(task, runtime, invocation.context);\n\t\t\t\t\tprevious = { checkpoint };\n\t\t\t\t} catch (error) {\n\t\t\t\t\tprevious = { checkpoint, failure: { error } };\n\t\t\t\t}\n\t\t\t\treturn this.#step(invocation, (next) => this.#rules(next, previous), progress);\n\t\t\t});\n\t\t}\n\t}\n\n\t/** A phase owns its decision commit, not the next handler, a durable wait, or recovery. */\n\t#phase<T>(invocation: Invocation, task: ErasedRunningTask, run: () => Promise<T>): Promise<T> {\n\t\tconst parent =\n\t\t\ttask.trace === undefined\n\t\t\t\t? this.#telemetry\n\t\t\t\t: (this.#telemetry.propagation?.extract(task.trace) ?? this.#telemetry);\n\t\tconst checkpoint = task.state.checkpoint;\n\t\tconst attempt = checkpoint.attempt;\n\t\tconst resumed = this.#resumed.delete(task.id);\n\t\treturn createTypedSpanStarter(parent, [DURABLE_TELEMETRY_SCHEMA])(\n\t\t\t\"pi.durable.phase\",\n\t\t\t{\n\t\t\t\t\"task.id\": task.id,\n\t\t\t\t\"task.name\": task.kind,\n\t\t\t\tphase: checkpoint.phase,\n\t\t\t\tkind: invocation.mode,\n\t\t\t\tresumed,\n\t\t\t\t...(attempt === undefined ? {} : { attempt }),\n\t\t\t},\n\t\t\tasync (span) => {\n\t\t\t\tif (span.propagation !== undefined && invocation.links !== undefined) {\n\t\t\t\t\tfor (const carrier of invocation.links) span.addLink({ context: span.propagation.extract(carrier) });\n\t\t\t\t}\n\t\t\t\tconst previous = invocation.context;\n\t\t\t\tinvocation.context = withTelemetry(span, previous);\n\t\t\t\tconst started = performance.now();\n\t\t\t\ttry {\n\t\t\t\t\treturn await run();\n\t\t\t\t} finally {\n\t\t\t\t\tinvocation.context = previous;\n\t\t\t\t\tconst state = invocation.record!.state;\n\t\t\t\t\tconst terminal =\n\t\t\t\t\t\tinvocation.fault ??\n\t\t\t\t\t\t(state.status === \"terminal\" || state.status === \"completing\" ? state.outcome : undefined);\n\t\t\t\t\tconst outcome =\n\t\t\t\t\t\tterminal !== undefined\n\t\t\t\t\t\t\t? terminal.status === \"completed\"\n\t\t\t\t\t\t\t\t? \"done\"\n\t\t\t\t\t\t\t\t: terminal.status === \"aborted\"\n\t\t\t\t\t\t\t\t\t? \"aborted\"\n\t\t\t\t\t\t\t\t\t: \"faulted\"\n\t\t\t\t\t\t\t: state.status === \"waiting\" || state.status === \"sleeping\"\n\t\t\t\t\t\t\t\t? state.status\n\t\t\t\t\t\t\t\t: invocation.ended || this.#closing\n\t\t\t\t\t\t\t\t\t? \"aborted\"\n\t\t\t\t\t\t\t\t\t: `next=${state.checkpoint!.phase}`;\n\t\t\t\t\tspan.setAttributes({ outcome });\n\t\t\t\t\tif (terminal?.status === \"faulted\" || terminal?.status === \"failed\" || terminal?.status === \"orphaned\") {\n\t\t\t\t\t\tconst message = terminal.status === \"orphaned\" ? terminal.reason : terminal.error.message;\n\t\t\t\t\t\tspan.setStatus({\n\t\t\t\t\t\t\tstatus: \"error\",\n\t\t\t\t\t\t\terror: { name: `task_${terminal.status}`, message: ownedSlice(message, 0, 500) },\n\t\t\t\t\t\t});\n\t\t\t\t\t} else if (outcome === \"aborted\") {\n\t\t\t\t\t\tspan.setStatus({ status: \"ok\" });\n\t\t\t\t\t}\n\t\t\t\t\tthis.#durationMetric.record(\n\t\t\t\t\t\tperformance.now() - started,\n\t\t\t\t\t\t{ task: task.kind, phase: checkpoint.phase, outcome },\n\t\t\t\t\t\tspan,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * Precedence rules for a run invocation, a decision region of its step. Rules 1 (terminal, `completing`, `waiting`, or\n\t * `sleeping`) and 2 (closing) are applied by `#step`. Progress (rule 5) is decided by `#progress()` once the decision\n\t * stands, as it takes a registry snapshot.\n\t */\n\t#rules(current: ErasedRunningTask, previous: PhaseResult | undefined): StepPlan {\n\t\t// 3. abort mark: end; a fresh abort invocation starts once the task's ordinary owned work is gone.\n\t\tif (current.abortRequested) return END;\n\t\t// An owner's cancellation intent ends it too, before its cascade marks it; reservation then holds it back.\n\t\tif (!current.background && this.#belowCancelled(parentOf(current))) return CASCADE;\n\t\tif (previous === undefined) return CONTINUE;\n\t\t// 4. uncaught error.\n\t\tif (previous.failure !== undefined) return { kind: \"fault\", error: previous.failure.error };\n\t\t// 6. no durable progress.\n\t\tif (jsonEqual(current.state.checkpoint, previous.checkpoint)) {\n\t\t\tconst message = `Task ${current.kind} phase ${previous.checkpoint.phase} returned without durable progress`;\n\t\t\treturn { kind: \"fault\", error: new Error(message) };\n\t\t}\n\t\treturn PROGRESS;\n\t}\n\n\t/**\n\t * Rule 5, progress: refresh the snapshot; hand over to a replacement definition that can take the task, writing it\n\t * back as `pending`, or keep running under the old one, reported once per resolved definition. Returns whether the\n\t * invocation continues.\n\t */\n\t#progress(\n\t\ttx: Transaction,\n\t\tcurrent: ErasedRunningTask,\n\t\tstate: { task: AnyTask; snapshot: RegistrySnapshot; reported: ReportedTask },\n\t\textension: string | undefined,\n\t\tcontext: Context,\n\t): boolean {\n\t\tstate.snapshot = this.#registry.snapshot();\n\t\tconst next = state.snapshot.task(current.kind);\n\t\tif (next === state.task) return true;\n\t\tif (next !== undefined && canReserve(next, current)) {\n\t\t\ttx.setTask(withState(current, { status: \"pending\", checkpoint: current.state.checkpoint }));\n\t\t\treturn false;\n\t\t}\n\t\tif (state.reported === undefined || state.reported.task !== next) {\n\t\t\tstate.reported = { task: next };\n\t\t\tthis.#report(\n\t\t\t\tnew Error(`Task ${current.id} keeps running under its old ${current.kind} definition`),\n\t\t\t\t{\n\t\t\t\t\tkind: \"task_outdated\",\n\t\t\t\t\t...this.#aboutTask({ ...recordTask(current), extension }),\n\t\t\t\t\treason: outdatedReason(next, current),\n\t\t\t\t},\n\t\t\t\tcontext,\n\t\t\t);\n\t\t}\n\t\treturn true;\n\t}\n\n\t/** Run the abort handler once; rules 1, 2, and 4 apply, and returning without an outcome faults. */\n\tasync #runAbort(reservation: Reservation): Promise<void> {\n\t\tconst invocation = reservation.invocation;\n\t\tconst current = this.#live.get(invocation.taskId) as ErasedRunningTask | undefined;\n\t\tif (current === undefined || this.#closing) return;\n\t\tawait this.#phase(invocation, current, async () => {\n\t\t\tlet failure: { readonly error: unknown } | undefined;\n\t\t\ttry {\n\t\t\t\tconst phase: Phase = {\n\t\t\t\t\tsnapshot: () => reservation.snapshot,\n\t\t\t\t\ttask: () => reservation.task,\n\t\t\t\t\tagent: undefined,\n\t\t\t\t};\n\t\t\t\tconst runtime = this.#runtime(invocation, phase);\n\t\t\t\tawait erased(reservation.task).abort(current, runtime, invocation.context);\n\t\t\t} catch (error) {\n\t\t\t\tfailure = { error };\n\t\t\t}\n\t\t\tconst message = `Abort handler of task ${invocation.taskId} returned without a terminal outcome`;\n\t\t\tawait this.#step(invocation, () => ({ kind: \"fault\", error: failure?.error ?? new Error(message) }));\n\t\t});\n\t}\n\n\t/**\n\t * One decision on the Session line, before a phase: a decision region (`#region()`) that reads the task's record. A\n\t * task that is no longer running (rule 1: terminal, `completing`, `waiting`, or `sleeping`) or a closing Harness (rule\n\t * 2) ends the invocation without a write; otherwise `plan` decides, and a decision that stands is applied: the\n\t * invocation continues, with `progress` for rule 5, or ends, with a fault written. Ending happens inside the callback,\n\t * before a fault's Harness cleanup. A rejected step, such as admission after close, also ends the invocation. Its\n\t * outcome goes to the invocation only, so it is a scheduler commit (`commitInternal()`).\n\t */\n\tasync #step(\n\t\tinvocation: Invocation,\n\t\tplan: (current: ErasedRunningTask) => StepPlan,\n\t\tprogress?: (tx: Transaction, current: ErasedRunningTask) => boolean,\n\t): Promise<ErasedRunningTask | undefined> {\n\t\tlet fault: { readonly error: unknown } | undefined;\n\t\ttry {\n\t\t\tconst continued = await this.#session.commitInternal(async (tx) => {\n\t\t\t\tconst decided = await this.#region(() => {\n\t\t\t\t\tconst found = this.#liveRecord(invocation.taskId);\n\t\t\t\t\tif (found?.state.status !== \"running\" || this.#closing) return { plan: END };\n\t\t\t\t\tconst current = found as ErasedRunningTask;\n\t\t\t\t\treturn { current, plan: plan(current) };\n\t\t\t\t});\n\t\t\t\tconst { current } = decided;\n\t\t\t\tconst step = decided.plan;\n\t\t\t\tif (step.kind === \"continue\") return current;\n\t\t\t\tif (step.kind === \"progress\" && progress!(tx, current!)) return current;\n\t\t\t\tthis.#end(invocation);\n\t\t\t\tif (step.kind === \"cascade\") {\n\t\t\t\t\tthis.#cascadePending = true;\n\t\t\t\t\tthis.#scheduleReconcile();\n\t\t\t\t}\n\t\t\t\tif (step.kind === \"fault\") {\n\t\t\t\t\tfault = { error: step.error };\n\t\t\t\t\tconst message = errorMessage(step.error);\n\t\t\t\t\tinvocation.fault = { status: \"faulted\", error: { message } };\n\t\t\t\t\tawait this.#terminate(tx, current!, invocation.fault);\n\t\t\t\t}\n\t\t\t\treturn undefined;\n\t\t\t}, withoutAbortSignal(invocation.context));\n\t\t\t// Reported once the fault is durable: a host may count it, for example toward a breaker.\n\t\t\tif (fault !== undefined)\n\t\t\t\tthis.#report(\n\t\t\t\t\tfault.error,\n\t\t\t\t\t{ kind: \"task_faulted\", ...this.#aboutTask(invocation), reason: \"threw\" },\n\t\t\t\t\tinvocation.context,\n\t\t\t\t);\n\t\t\treturn continued;\n\t\t} catch (error) {\n\t\t\t// The step writes the scheduler's own decision, a fault or a terminal record; a throw there would otherwise\n\t\t\t// leave the task running, to be reserved and run again.\n\t\t\tthis.#end(invocation);\n\t\t\tthis.#failSession(error, invocation.context);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t/**\n\t * Write an outcome the scheduler decided. While the task's ordinary owned work is live it holds as `completing` and\n\t * its Harness cleanup waits for the final commit (spec §5.5, rule 4); otherwise it is terminal with its cleanup.\n\t */\n\tasync #terminate(tx: Transaction, record: AnyTaskRecord, outcome: SchedulerOutcome): Promise<void> {\n\t\tawait this.#loadScopes(false);\n\t\tif (await this.#region(() => this.#hasOwnedLive(record.id, overlayOf(tx)), this.#reloadScopes)) {\n\t\t\ttx.setTask(withState(record, { status: \"completing\", outcome }));\n\t\t\treturn;\n\t\t}\n\t\ttx.setTask(withState(record, { status: \"terminal\", outcome }));\n\t\tawait this.#settleOutcome(tx, record, outcome);\n\t}\n\n\t/**\n\t * Replace a running task's state with what it committed. A terminal state holds as `completing` while ordinary owned\n\t * work is live, judged on the commit's candidates, so work the same commit creates below the task counts. A wait is\n\t * validated first.\n\t */\n\tasync #commitState(\n\t\ttx: Transaction,\n\t\tinvocation: Invocation,\n\t\tcurrent: ErasedRunningTask,\n\t\tnext: NextTaskState<Checkpoint, JsonValue>,\n\t): Promise<void> {\n\t\tif (next.status === \"waiting\") await this.#validateWait(tx, invocation, current, next.on, next.policy);\n\t\tif (next.status === \"sleeping\") validateSleep(invocation, current.id, next.until);\n\t\tif (next.status === \"terminal\") {\n\t\t\tconst overlay = overlayOf(tx);\n\t\t\tawait this.#loadScopes(false);\n\t\t\tfor (const record of overlay.tasks.values()) await this.#loadChain(parentOf(record), overlay);\n\t\t\tif (await this.#region(() => this.#hasOwnedLive(current.id, overlayOf(tx)), this.#reloadScopes)) {\n\t\t\t\ttx.setTask(withState(progressed(current), { status: \"completing\", outcome: next.outcome }));\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t// A state the task committed that differs from its current one is progress: its restart count starts over. The\n\t\t// same checkpoint committed again, for example as intent before an effect, is not.\n\t\tconst same = jsonEqual(current.state as unknown as JsonValue, next as unknown as JsonValue);\n\t\ttx.setTask(withState(same ? current : progressed(current), next));\n\t}\n\n\t/**\n\t * A wait names existing tasks, and `failFast` only tasks the waiter owns. It may not close a cycle in the wait-for\n\t * graph, whose edges run from each task to what it waits on and to its live ordinary owned work (spec §5.5); waiting\n\t * on itself or on an owner holding it are the shortest such cycles. An abort handler cannot wait.\n\t *\n\t * Invariant: the wait-for graph is acyclic. Only a wait adds an edge between existing tasks, as a new task has only\n\t * incoming edges, so checking each wait maintains it.\n\t */\n\tasync #validateWait(\n\t\ttx: Transaction,\n\t\tinvocation: Invocation,\n\t\tcurrent: ErasedRunningTask,\n\t\ton: readonly TaskId[],\n\t\tpolicy: string,\n\t): Promise<void> {\n\t\tif (invocation.mode === \"abort\") throw new Error(`Abort handler of task ${current.id} cannot wait`);\n\t\t// Owned work is found by walks down, which need the chains of every live task loaded.\n\t\tawait this.#loadScopes(false);\n\t\t// Tasks in `on` that are not live, read from Storage: terminal, or missing.\n\t\tconst ended = new Map<TaskId, AnyTaskRecord | null>();\n\t\tfor (;;) {\n\t\t\tconst checked = await this.#region(\n\t\t\t\t() => this.#checkWait(current, on, policy, overlayOf(tx), ended),\n\t\t\t\tthis.#reloadScopes,\n\t\t\t);\n\t\t\tif (checked === undefined) return;\n\t\t\tif (\"missing\" in checked) {\n\t\t\t\tfor (const id of checked.missing)\n\t\t\t\t\tended.set(id, (await this.#session.lineStorage.task(id, this.#context)) ?? null);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthrow checked.error;\n\t\t}\n\t}\n\n\t/**\n\t * `#validateWait()`'s decision region: why the wait is refused, `undefined` when it may be stored, or the tasks in\n\t * `on` it needs from Storage first, when `ended` lacks them.\n\t */\n\t#checkWait(\n\t\tcurrent: ErasedRunningTask,\n\t\ton: readonly TaskId[],\n\t\tpolicy: string,\n\t\toverlay: Overlay,\n\t\tended: ReadonlyMap<TaskId, AnyTaskRecord | null>,\n\t): { readonly missing: readonly TaskId[] } | { readonly error: Error } | undefined {\n\t\tconst targets: TaskId[] = [];\n\t\tconst missing: TaskId[] = [];\n\t\tfor (const id of on) {\n\t\t\tconst member = overlay.tasks.get(id) ?? this.#liveRecord(id) ?? ended.get(id);\n\t\t\tif (member === undefined) {\n\t\t\t\tmissing.push(id);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (member === null) return { error: new Error(`Task ${id} does not exist`) };\n\t\t\tif (policy === \"failFast\" && member.owner !== current.id) {\n\t\t\t\treturn { error: new Error(`Task ${current.id} can wait failFast only on tasks it owns; ${id} is not one`) };\n\t\t\t}\n\t\t\t// A live child already holds the waiter (task-owned tasks are never background): waiting on it adds no edge. A\n\t\t\t// terminal task has no edges.\n\t\t\tif (member.state.status !== \"terminal\" && member.owner !== current.id) targets.push(id);\n\t\t}\n\t\tif (missing.length > 0) return { missing };\n\t\tif (targets.length === 0) return undefined;\n\t\tconst cycle = this.#waitCycle(current.id, targets, overlay);\n\t\tif (cycle === undefined) return undefined;\n\t\treturn {\n\t\t\terror: new Error(\n\t\t\t\t`Task ${current.id} cannot wait on ${cycle[0]}: ${[current.id, ...cycle].join(\" -> \")} is a wait cycle`,\n\t\t\t),\n\t\t};\n\t}\n\n\t/**\n\t * The path from a member of `on` back to `task` in the wait-for graph, if the wait would close a cycle (spec §5.1).\n\t * An edge X -> Y means X cannot settle before Y: Y is in the `on` of waiting X that is not abort-marked, or Y is live\n\t * ordinary owned work of X, which holds X as `completing`. Each task is visited once and each subtree walked once,\n\t * so a check is bounded by the live work it reaches. Part of a decision region: it records every record it reads.\n\t * Owned work is found by walks down, which need the chains of every live task loaded.\n\t */\n\t#waitCycle(task: TaskId, on: readonly TaskId[], overlay: Overlay): TaskId[] | undefined {\n\t\tconst from = new Map<TaskId, TaskId | undefined>();\n\t\tconst walked = new Set<TaskId>();\n\t\tconst pending: TaskId[] = [];\n\t\tconst reach = (id: TaskId, via: TaskId | undefined) => {\n\t\t\tif (from.has(id)) return;\n\t\t\tfrom.set(id, via);\n\t\t\tpending.push(id);\n\t\t};\n\t\tconst path = (end: TaskId): TaskId[] => {\n\t\t\tconst steps: TaskId[] = [];\n\t\t\tfor (let at: TaskId | undefined = end; at !== undefined; at = from.get(at)) steps.unshift(at);\n\t\t\treturn steps;\n\t\t};\n\t\tfor (const id of on) reach(id, undefined);\n\t\tfor (let id = pending.pop(); id !== undefined; id = pending.pop()) {\n\t\t\tif (id === task) return path(id);\n\t\t\tconst record = overlay.tasks.get(id) ?? this.#liveRecord(id);\n\t\t\tif (record === undefined || record.state.status === \"terminal\") continue;\n\t\t\t// An abort-marked task waits only for its owned work, as abort runs bottom-up (`#waitingOn`).\n\t\t\tif (record.state.status === \"waiting\" && !record.abortRequested) {\n\t\t\t\tfor (const member of record.state.on) reach(member, id);\n\t\t\t}\n\t\t\tif (walked.has(id)) continue;\n\t\t\twalked.add(id);\n\t\t\t// Below a walked task the walk does not go again: its own walk covered what lies below.\n\t\t\tconst found: TaskId[] = [];\n\t\t\tconst walk = this.#walkDown(id, { overlay, enter: (below) => !walked.has(below) });\n\t\t\tfor (const { id: below, node, live } of walk) {\n\t\t\t\tif (live === undefined || node.background) continue;\n\t\t\t\tfound.push(below);\n\t\t\t\treach(below, id);\n\t\t\t}\n\t\t\tfor (const below of found) walked.add(below);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/** End an invocation: its runtime operations reject from now on, its signal aborts, its watches stop, and its task is free. */\n\t#end(invocation: Invocation): void {\n\t\tif (invocation.ended) return;\n\t\tinvocation.ended = true;\n\t\tif (this.#invocations.get(invocation.taskId) === invocation) {\n\t\t\tthis.#invocations.delete(invocation.taskId);\n\t\t\tif (this.#live.has(invocation.taskId)) this.#runnable.add(invocation.taskId);\n\t\t}\n\t\tfor (const watch of invocation.watches) void watch.stop();\n\t\tfor (const disarm of invocation.timers) disarm();\n\t\tinvocation.timers.clear();\n\t\t// Pending waits bound to the invocation, such as a tool's waitForTask(), reject with it.\n\t\tinvocation.controller.abort(endedError(invocation));\n\t}\n\n\t/** No live non-background task in the scope; a task whose owner edges are not loaded yet counts as inside. */\n\t#idle(conversationId: ConversationId | undefined): boolean {\n\t\tconst scope: Scope = conversationId === undefined ? { roots: true } : { conversation: conversationId };\n\t\t// In a decision region, global idle reads the roots it starts from.\n\t\tif (conversationId === undefined) this.#record(ROOTS_KEY);\n\t\t// Tasks whose chain is not loaded are not listed below their scope yet; one counts as inside unless its walk up\n\t\t// decides otherwise.\n\t\tfor (const id of this.#unloaded) {\n\t\t\tconst record = this.#live.get(id);\n\t\t\tif (record !== undefined && !record.background && this.#inScope(parentOf(record), scope) !== false)\n\t\t\t\treturn false;\n\t\t}\n\t\tconst starts = conversationId === undefined ? this.#roots : [conversationId];\n\t\tfor (const start of starts) {\n\t\t\tfor (const { node, live } of this.#walkDown(conversationNode(start))) {\n\t\t\t\tif (live !== undefined && !node.background) return false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\t// ─── Invocation runtime ──────────────────────────────────────────────────\n\n\t#runtime(invocation: Invocation, phase: Phase): ErasedRuntime {\n\t\t// Resolved at most once per phase handler, at first use, with the invocation's context; fixed for the phase.\n\t\tconst agent = (): Promise<Agent> => {\n\t\t\tif (invocation.ended) return Promise.reject(endedError(invocation));\n\t\t\tif (phase.agent === undefined) {\n\t\t\t\tphase.agent = this.#agent(invocation.conversationId, phase.snapshot(), invocation.context);\n\t\t\t\t// A caller that stops waiting must not leave the shared resolution's failure unobserved.\n\t\t\t\tphase.agent.catch(() => {});\n\t\t\t}\n\t\t\treturn phase.agent;\n\t\t};\n\t\tconst hooks: HookRunner<Record<string, unknown>> = {\n\t\t\teach: async (name, invoke) => {\n\t\t\t\tfor (const { extension, handlers } of agentHooks(await agent(), phase.task().definition.name)) {\n\t\t\t\t\tconst handler = (handlers as Record<string, unknown>)[name];\n\t\t\t\t\tif (typeof handler !== \"function\") continue;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait invoke(handler.bind(handlers));\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (invocation.controller.signal.aborted) throw error;\n\t\t\t\t\t\tthis.#report(\n\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t{ kind: \"extension_error\", extension, task: reportTask(invocation) },\n\t\t\t\t\t\t\tinvocation.context,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t\tconst settings = this.#settings;\n\t\tconst models = this.#models;\n\t\treturn {\n\t\t\ttaskId: invocation.taskId as TaskId<JsonValue>,\n\t\t\tconversationId: invocation.conversationId,\n\t\t\tsignal: invocation.controller.signal,\n\t\t\tget models() {\n\t\t\t\treturn models();\n\t\t\t},\n\t\t\tagent: (context) =>\n\t\t\t\tinvocation.ended ? Promise.reject(endedError(invocation)) : awaitWithContext(agent(), context),\n\t\t\tget settings() {\n\t\t\t\treturn settings();\n\t\t\t},\n\t\t\tenv: (context) => this.#read(invocation, () => this.#env(invocation.conversationId, context)),\n\t\t\thooks: hooks as ErasedRuntime[\"hooks\"],\n\t\t\tget registry() {\n\t\t\t\treturn phase.snapshot();\n\t\t\t},\n\t\t\tcommit: async (change, context, options) => {\n\t\t\t\tlet checkpoint: string | undefined;\n\t\t\t\tlet interrupted:\n\t\t\t\t\t| {\n\t\t\t\t\t\t\treadonly message: string;\n\t\t\t\t\t\t\treadonly reason: \"restart_limit\" | \"interrupted\";\n\t\t\t\t\t\t\treadonly restarts: number;\n\t\t\t\t\t }\n\t\t\t\t\t| undefined;\n\t\t\t\tawait this.#gated(\n\t\t\t\t\tinvocation,\n\t\t\t\t\tasync (tx, current) => {\n\t\t\t\t\t\tconst next = await change(tx, current);\n\t\t\t\t\t\tif (next !== undefined) await this.#commitState(tx, invocation, current, next);\n\t\t\t\t\t\tif (next?.status === \"running\" && current.state.checkpoint.phase !== next.checkpoint.phase) {\n\t\t\t\t\t\t\tcheckpoint = next.checkpoint.phase;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// A task that ends for crashes says so (`task_interrupted`), so a host keeps a crash-loop signal.\n\t\t\t\t\t\tif (next?.status === \"terminal\") {\n\t\t\t\t\t\t\tconst restarts = current.restarts ?? 0;\n\t\t\t\t\t\t\tconst reason = next.outcome.status === \"failed\" ? interruptionOf(next.outcome.error) : undefined;\n\t\t\t\t\t\t\tif (reason !== undefined && next.outcome.status === \"failed\") {\n\t\t\t\t\t\t\t\tinterrupted = { message: next.outcome.error.message, reason, restarts };\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// A task that ended for crashes with another outcome says so itself, as a generation whose run\n\t\t\t\t\t\t\t\t// answered ends `completed` without its after-run tasks.\n\t\t\t\t\t\t\t\tconst message = endedByCrashesStates.get(next);\n\t\t\t\t\t\t\t\tif (message !== undefined) interrupted = { message, reason: \"restart_limit\", restarts };\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tcontext,\n\t\t\t\t\toptions,\n\t\t\t\t);\n\t\t\t\tif (interrupted !== undefined) {\n\t\t\t\t\tthis.#report(\n\t\t\t\t\t\tnew Error(interrupted.message),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tkind: \"task_interrupted\",\n\t\t\t\t\t\t\t...this.#aboutTask(invocation),\n\t\t\t\t\t\t\treason: interrupted.reason,\n\t\t\t\t\t\t\trestarts: interrupted.restarts,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tinvocation.context,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (checkpoint !== undefined) {\n\t\t\t\t\tinvocation.context.telemetry.addEvent(\"pi.durable.checkpoint\", {\n\t\t\t\t\t\tphase: checkpoint,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\t\t\tmemo: ((name: string, ...rest: readonly unknown[]) => {\n\t\t\t\tif (rest.length === 1) {\n\t\t\t\t\treturn this.#read(invocation, async () => memoOf(this.#live.get(invocation.taskId), name));\n\t\t\t\t}\n\t\t\t\tconst candidate = rest[0] as JsonValue;\n\t\t\t\treturn this.#gated(\n\t\t\t\t\tinvocation,\n\t\t\t\t\t(tx, current) => {\n\t\t\t\t\t\tconst winner = memoOf(current, name);\n\t\t\t\t\t\tif (winner !== undefined) return winner;\n\t\t\t\t\t\ttx.setTask({ ...current, memos: { ...current.memos, [name]: candidate } } as AnyTaskRecord);\n\t\t\t\t\t\treturn candidate;\n\t\t\t\t\t},\n\t\t\t\t\trest[1] as Context,\n\t\t\t\t);\n\t\t\t}) as ErasedRuntime[\"memo\"],\n\t\t\tsleepUntil: (until, checkpoint, context) =>\n\t\t\t\tthis.#gated(\n\t\t\t\t\tinvocation,\n\t\t\t\t\t(tx, current) => this.#commitState(tx, invocation, current, { status: \"sleeping\", checkpoint, until }),\n\t\t\t\t\tcontext,\n\t\t\t\t),\n\t\t\twatchDoc: ((...args: readonly unknown[]) => this.#watchDoc(invocation, args)) as ErasedRuntime[\"watchDoc\"],\n\t\t\tsnapshot: ((...args: readonly unknown[]) =>\n\t\t\t\tthis.#read(invocation, () =>\n\t\t\t\t\tsessionMethod(this.#session, \"snapshot\")(...args),\n\t\t\t\t)) as ErasedRuntime[\"snapshot\"],\n\t\t\tsnapshotAsOf: ((...args: readonly unknown[]) =>\n\t\t\t\tthis.#read(invocation, () =>\n\t\t\t\t\tsessionMethod(this.#session, \"snapshotAsOf\")(...args),\n\t\t\t\t)) as ErasedRuntime[\"snapshotAsOf\"],\n\t\t\tgetTask: ((id: TaskId, context: Context) =>\n\t\t\t\tthis.#read(invocation, () =>\n\t\t\t\t\tthis.#session.readOnLine((storage) => storage.task(id, context)),\n\t\t\t\t)) as ErasedRuntime[\"getTask\"],\n\t\t\twaitForTask: ((id: TaskId, context: Context) =>\n\t\t\t\tthis.#read(invocation, () =>\n\t\t\t\t\tthis.waitForTask(id, withAbortSignal(invocation.controller.signal, context)),\n\t\t\t\t)) as ErasedRuntime[\"waitForTask\"],\n\t\t\townedTasks: (context) =>\n\t\t\t\tthis.#read(invocation, () =>\n\t\t\t\t\tthis.#session.readOnLine(async () => {\n\t\t\t\t\t\t// The step that ends the invocation may have run on the line before this.\n\t\t\t\t\t\tif (invocation.ended) throw endedError(invocation);\n\t\t\t\t\t\tcontext.abortSignal?.throwIfAborted();\n\t\t\t\t\t\t// Every live task is listed under its parent node, its owner task when it has one.\n\t\t\t\t\t\tconst owned = await this.#region(() => {\n\t\t\t\t\t\t\tthis.#record(ownedKey(invocation.taskId));\n\t\t\t\t\t\t\tconst records: AnyTaskRecord[] = [];\n\t\t\t\t\t\t\tfor (const node of this.#below.get(invocation.taskId) ?? []) {\n\t\t\t\t\t\t\t\tconst record = typeof node === \"string\" ? undefined : this.#liveRecord(node);\n\t\t\t\t\t\t\t\tif (record?.owner === invocation.taskId) records.push(record);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn records;\n\t\t\t\t\t\t});\n\t\t\t\t\t\t// Copies, as from storage: the scheduler reads its own.\n\t\t\t\t\t\treturn owned\n\t\t\t\t\t\t\t.sort((a, b) => a.id - b.id)\n\t\t\t\t\t\t\t.map((record) => copyJson(record as unknown as JsonValue) as unknown as AnyTaskRecord);\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\tabortOwned: (id, context) =>\n\t\t\t\tthis.#read(invocation, async () => {\n\t\t\t\t\tconst bound = withAbortSignal(invocation.controller.signal, context);\n\t\t\t\t\tconst record = await this.#session.readOnLine((storage) => storage.task(id, bound));\n\t\t\t\t\tif (record?.owner !== invocation.taskId) {\n\t\t\t\t\t\tthrow new Error(`Task ${id} is not owned by task ${invocation.taskId}`);\n\t\t\t\t\t}\n\t\t\t\t\tif (record.state.status === \"terminal\") return;\n\t\t\t\t\tawait this.abort(id, bound, true);\n\t\t\t\t\tawait this.waitForTask(id, bound);\n\t\t\t\t}),\n\t\t\toutcomes: ((ids: readonly TaskId[], context: Context) =>\n\t\t\t\tthis.#read(invocation, () =>\n\t\t\t\t\tthis.#session.readOnLine(async (storage) => {\n\t\t\t\t\t\tconst outcomes: TaskOutcome<JsonValue>[] = [];\n\t\t\t\t\t\tfor (const id of ids) {\n\t\t\t\t\t\t\tconst state = (await storage.task(id, context))?.state;\n\t\t\t\t\t\t\tif (state?.status !== \"terminal\") throw new Error(`Task ${id} is not terminal`);\n\t\t\t\t\t\t\toutcomes.push(state.outcome);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn outcomes;\n\t\t\t\t\t}),\n\t\t\t\t)) as ErasedRuntime[\"outcomes\"],\n\t\t\tconversation: (id, context) =>\n\t\t\t\tthis.#read(invocation, () =>\n\t\t\t\t\tthis.#conversation(\n\t\t\t\t\t\tid,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tsignal: invocation.controller.signal,\n\t\t\t\t\t\t\tcheck: () => {\n\t\t\t\t\t\t\t\tif (invocation.ended) throw endedError(invocation);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\tentry: ((...args: readonly unknown[]) => {\n\t\t\t\tconst [token, id, context] =\n\t\t\t\t\targs.length === 2\n\t\t\t\t\t\t? [undefined, args[0] as EntryId, args[1] as Context]\n\t\t\t\t\t\t: [args[0] as { readonly kind: string }, args[1] as EntryId, args[2] as Context];\n\t\t\t\treturn this.#read(invocation, async () => {\n\t\t\t\t\t// An entry of the conversation's kept context range is committed and visible: no Storage read.\n\t\t\t\t\tconst kept = this.#contexts.get(invocation.conversationId);\n\t\t\t\t\tconst entry =\n\t\t\t\t\t\t(kept === undefined ? undefined : rangeEntry(kept.range, id)) ??\n\t\t\t\t\t\t(await this.#session.readOnLine((storage) => storage.entry(invocation.conversationId, id, context)))\n\t\t\t\t\t\t\t?.entry;\n\t\t\t\t\treturn token === undefined || entry?.kind === token.kind ? entry : undefined;\n\t\t\t\t});\n\t\t\t}) as ErasedRuntime[\"entry\"],\n\t\t\tentries: (query, limit, cursor, context) =>\n\t\t\t\tthis.#read(invocation, () =>\n\t\t\t\t\tthis.#session.readOnLine((storage) =>\n\t\t\t\t\t\tstorage.scanEntries(conversationEntries(invocation.conversationId, query), limit, cursor, context),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\tcontext: (conversationId, context, options) =>\n\t\t\t\tthis.#read(invocation, async () => {\n\t\t\t\t\tconst read = await readContextFrom(\n\t\t\t\t\t\tthis.#session,\n\t\t\t\t\t\tthis.#storage,\n\t\t\t\t\t\tconversationId,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\toptions?.at,\n\t\t\t\t\t\tthis.#contexts.get(conversationId)?.range,\n\t\t\t\t\t);\n\t\t\t\t\tconst { view } = read;\n\t\t\t\t\t// Checked again here, synchronously up to the install below: a commit published since the read returned\n\t\t\t\t\t// was not seen by `#advanceContexts`, so a range that missed it must not be advanced.\n\t\t\t\t\tconst range =\n\t\t\t\t\t\tread.range?.current === true &&\n\t\t\t\t\t\tthis.#session.knownLatestEntryId(conversationId) !== read.range.bounds.tail\n\t\t\t\t\t\t\t? { ...read.range, current: false }\n\t\t\t\t\t\t\t: read.range;\n\t\t\t\t\t// Keep it unless the invocation ended or a concurrent read already kept a newer range.\n\t\t\t\t\tconst kept = this.#contexts.get(conversationId);\n\t\t\t\t\tif (\n\t\t\t\t\t\trange !== undefined &&\n\t\t\t\t\t\t!this.#closing &&\n\t\t\t\t\t\t!invocation.ended &&\n\t\t\t\t\t\t(kept === undefined || kept.range.bounds.tail <= range.bounds.tail)\n\t\t\t\t\t) {\n\t\t\t\t\t\t// A read of another, idle conversation starts or continues its retention period.\n\t\t\t\t\t\tif (!this.#idle(conversationId)) {\n\t\t\t\t\t\t\tthis.#contexts.set(conversationId, { range, idleSince: undefined });\n\t\t\t\t\t\t\tthis.#idleOrder.delete(conversationId);\n\t\t\t\t\t\t} else if (this.#contextRetentionMs() > 0) {\n\t\t\t\t\t\t\t// An idle period that already started keeps its expiry and its place; a new one starts now.\n\t\t\t\t\t\t\tconst idleSince = kept?.idleSince ?? this.#now();\n\t\t\t\t\t\t\tconst expiresAt =\n\t\t\t\t\t\t\t\tkept?.idleSince !== undefined && kept.expiresAt !== undefined\n\t\t\t\t\t\t\t\t\t? kept.expiresAt\n\t\t\t\t\t\t\t\t\t: idleSince + this.#contextRetentionMs();\n\t\t\t\t\t\t\tthis.#contexts.set(conversationId, { range, idleSince, expiresAt });\n\t\t\t\t\t\t\tif (kept?.idleSince === undefined) this.#markIdle(conversationId, idleSince);\n\t\t\t\t\t\t\tthis.#scheduleExpiry();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn view;\n\t\t\t\t}),\n\t\t\tnow: () => {\n\t\t\t\tif (invocation.ended) throw endedError(invocation);\n\t\t\t\treturn this.#now();\n\t\t\t},\n\t\t\tsetTimer: (callback, delayMs) => {\n\t\t\t\t// An ended invocation's timers never fire.\n\t\t\t\tif (invocation.ended) return () => {};\n\t\t\t\tconst disarm = this.#timers.foreground(() => {\n\t\t\t\t\tinvocation.timers.delete(disarm);\n\t\t\t\t\tif (!invocation.ended) callback();\n\t\t\t\t}, delayMs);\n\t\t\t\tinvocation.timers.add(disarm);\n\t\t\t\treturn () => {\n\t\t\t\t\tinvocation.timers.delete(disarm);\n\t\t\t\t\tdisarm();\n\t\t\t\t};\n\t\t\t},\n\t\t\treport: (error, from) => {\n\t\t\t\tif (invocation.ended) throw endedError(invocation);\n\t\t\t\t// The task's own failure names the task's extension; any other names whose code failed, if anyone's.\n\t\t\t\tconst task = reportTask(invocation);\n\t\t\t\tthis.#report(\n\t\t\t\t\terror,\n\t\t\t\t\tfrom === undefined\n\t\t\t\t\t\t? { kind: \"task_error\", ...this.#aboutTask(invocation) }\n\t\t\t\t\t\t: from.kind === \"extension\"\n\t\t\t\t\t\t\t? { kind: \"extension_error\", task, ...optionalExtension(from.extension) }\n\t\t\t\t\t\t\t: { kind: \"host_error\", callback: from.callback, task },\n\t\t\t\t\tinvocation.context,\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * On the line: wait until every commit admitted before is published, for a decision that reads what cannot be keyed,\n\t * every live task (open, inspection) or every task a conversation abort reaches.\n\t */\n\tasync #published(): Promise<void> {\n\t\tconst gate = this.#session.touch(ALL_KEYS);\n\t\tif (gate !== undefined) await gate;\n\t}\n\n\t/** Run a committed-state read unless the invocation has ended. */\n\tasync #read<T>(invocation: Invocation, read: () => Promise<T>): Promise<T> {\n\t\tif (invocation.ended) throw endedError(invocation);\n\t\treturn read();\n\t}\n\n\t/** Commit after rereading the task on the line and gating the invocation. */\n\t#gated<T>(\n\t\tinvocation: Invocation,\n\t\tchange: (tx: Transaction, current: ErasedRunningTask) => T | Promise<T>,\n\t\tcontext: Context,\n\t\toptions?: CommitOptions,\n\t): Promise<T> {\n\t\tif (invocation.ended) return Promise.reject(endedError(invocation));\n\t\treturn this.#session.commitWith(\n\t\t\tasync (tx) => {\n\t\t\t\tif (invocation.ended) throw endedError(invocation);\n\t\t\t\tif (this.#closing) throw closedError(this.#session);\n\t\t\t\tconst current = await this.#region(() => {\n\t\t\t\t\tconst found = this.#liveRecord(invocation.taskId);\n\t\t\t\t\tif (found === undefined) throw new Error(`Task ${invocation.taskId} is terminal`);\n\t\t\t\t\tif (found.state.status !== \"running\")\n\t\t\t\t\t\tthrow new Error(`Task ${invocation.taskId} is ${found.state.status}`);\n\t\t\t\t\tif (invocation.mode === \"run\" && found.abortRequested) {\n\t\t\t\t\t\tthrow new Error(`Task ${invocation.taskId} has a durable abort mark`);\n\t\t\t\t\t}\n\t\t\t\t\treturn found as ErasedRunningTask;\n\t\t\t\t});\n\t\t\t\t// The step that ends it may have run while the region waited.\n\t\t\t\tif (invocation.ended) throw endedError(invocation);\n\t\t\t\treturn change(tx, current);\n\t\t\t},\n\t\t\tcontext,\n\t\t\t{ conversationId: invocation.conversationId, taskId: invocation.taskId },\n\t\t\toptions,\n\t\t);\n\t}\n\n\tasync #watchDoc(invocation: Invocation, args: readonly unknown[]): Promise<DocumentWatch<JsonObject> | undefined> {\n\t\tif (invocation.ended) throw endedError(invocation);\n\t\tconst watch = (await sessionMethod(this.#session, \"watchDoc\")(...args)) as DocumentWatch<JsonObject> | undefined;\n\t\tif (watch === undefined) return undefined;\n\t\tif (invocation.ended) {\n\t\t\tvoid watch.stop();\n\t\t\tthrow endedError(invocation);\n\t\t}\n\t\tinvocation.watches.add(watch);\n\t\tvoid watch.closed.then(() => invocation.watches.delete(watch));\n\t\treturn watch;\n\t}\n}\n\nconst REGISTRY: ReportInfo = { kind: \"host_error\", callback: \"registry\" };\nconst SETTINGS: ReportInfo = { kind: \"host_error\", callback: \"settings\" };\nconst ON_WAKE: ReportInfo = { kind: \"host_error\", callback: \"onWake\" };\nconst TELEMETRY: ReportInfo = { kind: \"host_error\", callback: \"telemetry\" };\n\n/** The extension that installed `task` in `snapshot`, the last one that lists it; none for a built-in task. */\nfunction installerOf(snapshot: RegistrySnapshot, task: AnyTask | undefined): string | undefined {\n\tif (task === undefined) return undefined;\n\treturn snapshot.installed().findLast((installed) => installed.tasks?.includes(task) === true)?.name;\n}\n\n/** The report info of a failure of a task. */\nfunction reportTask(task: {\n\treadonly taskId: TaskId;\n\treadonly kind: string;\n\treadonly conversationId: ConversationId;\n}): ReportTask {\n\treturn { id: task.taskId, kind: task.kind, conversationId: task.conversationId };\n}\n\n/** A stored task's identity, as an invocation names it. */\nfunction recordTask(record: Pick<AnyTaskRecord, \"id\" | \"kind\" | \"conversationId\">) {\n\treturn { taskId: record.id, kind: record.kind, conversationId: record.conversationId };\n}\n\n/**\n * The record with an abort mark: `restart` for an abandonment; without a reason, a request, which replaces `restart`.\n * The restart count starts over: it now counts cut-offs of the abort handler.\n */\n/** Why a failed outcome's error says crashes ended the task (`detail.reason`), if it does. */\n/**\n * Terminal states a built-in task commits because it was cut off `settings.restartLimit` times, when their outcome does\n * not say so (a failure with detail `{ reason: \"restart_limit\" }` does), with the message the scheduler reports them\n * `task_interrupted` with. Keyed by the state object the task returns, so nothing is added to the stored state.\n */\nconst endedByCrashesStates = new WeakMap<object, string>();\n\n/** `state`, marked as ending its task for crashes (`task_interrupted` with `message`), whatever its outcome. */\nexport function endedByCrashes<T extends object>(state: T, message: string): T {\n\tendedByCrashesStates.set(state, message);\n\treturn state;\n}\n\nfunction interruptionOf(error: TaskOutcomeError): \"restart_limit\" | \"interrupted\" | undefined {\n\tconst detail = error.detail;\n\tif (typeof detail !== \"object\" || detail === null || !(\"reason\" in detail)) return undefined;\n\treturn detail.reason === \"restart_limit\" || detail.reason === \"interrupted\" ? detail.reason : undefined;\n}\n\nfunction withAbortMark(record: AnyTaskRecord, reason?: \"restart\"): AnyTaskRecord {\n\tconst { abortReason: _reason, restarts: _restarts, ...rest } = record;\n\treturn { ...rest, abortRequested: true, ...(reason === undefined ? {} : { abortReason: reason }) } as AnyTaskRecord;\n}\n\n/** A live owner's durable cancellation intent: its abort mark, or a held outcome other than `completed`. */\nfunction cancellationIntent(record: AnyTaskRecord): boolean {\n\treturn record.state.status !== \"terminal\" && (record.abortRequested || failedOutcome(record));\n}\n\n/**\n * Whether replacing `previous` (absent: a new task) with `next` changes the cancellation intent set or what it means: a\n * mark set, upgraded, or cleared, or a held or ended outcome other than `completed`.\n */\nfunction intentChanges(previous: AnyTaskRecord | undefined, next: AnyTaskRecord): boolean {\n\treturn (\n\t\t(previous?.abortRequested ?? false) !== next.abortRequested ||\n\t\tprevious?.abortReason !== next.abortReason ||\n\t\t(previous !== undefined && failedOutcome(previous)) !== failedOutcome(next) ||\n\t\t(previous !== undefined && cancellationIntent(previous)) !== cancellationIntent(next)\n\t);\n}\n\n/** Whether the record holds or ends with an outcome other than `completed`. */\nfunction failedOutcome(record: AnyTaskRecord): boolean {\n\tconst state = record.state;\n\treturn (state.status === \"completing\" || state.status === \"terminal\") && state.outcome.status !== \"completed\";\n}\n\nfunction parentOf(node: TaskNode): Up {\n\treturn node.owner !== undefined ? { task: node.owner } : { conversation: node.conversationId };\n}\n\nfunction nodeOf(record: AnyTaskRecord): TaskNode {\n\treturn {\n\t\tconversationId: record.conversationId,\n\t\t...(record.owner === undefined ? {} : { owner: record.owner }),\n\t\tbackground: record.background,\n\t};\n}\n\nfunction overlayOf(tx: Transaction): Overlay {\n\tconst tasks = new Map(tx.stagedTasks().map((record) => [record.id, record]));\n\tconst edges = new Map(tx.stagedConversations().map((record) => [record.id, record.owner?.taskId ?? null]));\n\treturn { tasks, edges };\n}\n\nfunction addTo<K, V>(map: Map<K, Set<V>>, key: K, value: V): void {\n\tconst values = map.get(key);\n\tif (values === undefined) map.set(key, new Set([value]));\n\telse values.add(value);\n}\n\nfunction deleteFrom<K, V>(map: Map<K, Set<V>>, key: K, value: V): void {\n\tconst values = map.get(key);\n\tif (values === undefined) return;\n\tvalues.delete(value);\n\tif (values.size === 0) map.delete(key);\n}\n\n/** Own memo entry only; memo names such as `toString` must not resolve to inherited properties. */\nfunction memoOf(record: AnyTaskRecord | undefined, name: string): JsonValue | undefined {\n\tconst memos = record?.memos;\n\treturn memos !== undefined && Object.hasOwn(memos, name) ? memos[name] : undefined;\n}\n\n/** Overloaded Session method bound for forwarding an argument list unchanged. */\nfunction sessionMethod(\n\tsession: SessionImpl,\n\tname: \"snapshot\" | \"snapshotAsOf\" | \"watchDoc\",\n): (...args: readonly unknown[]) => Promise<unknown> {\n\treturn (session[name] as (...args: readonly unknown[]) => Promise<unknown>).bind(session);\n}\n\nfunction missingMigration(record: AnyTaskRecord, definition: ErasedDefinition): Error {\n\treturn new Error(`Task ${record.kind} version ${definition.version} has no migration from ${record.version}`);\n}\n\nfunction erased(task: AnyTask): ErasedDefinition {\n\treturn task.definition as unknown as ErasedDefinition;\n}\n\nfunction endedError(invocation: Invocation): Error {\n\treturn new Error(`Task ${invocation.taskId} invocation has ended`);\n}\n\n/** The record without its restart count, as after a state the task committed. */\nfunction progressed(record: AnyTaskRecord): AnyTaskRecord {\n\tif (record.restarts === undefined) return record;\n\tconst { restarts: _restarts, ...rest } = record;\n\treturn rest as AnyTaskRecord;\n}\n\n/** Replace a live record's state; memos and the restart count disappear once an outcome is decided. */\nfunction withState(record: AnyTaskRecord, state: TaskState<JsonValue, JsonValue>): AnyTaskRecord {\n\tif (state.status !== \"terminal\" && state.status !== \"completing\") return { ...record, state } as AnyTaskRecord;\n\tconst { memos: _memos, restarts: _restarts, ...rest } = record;\n\treturn { ...rest, state };\n}\n\n/** Whether a definition can take the task at reservation: same version, or newer with a migration. */\n/**\n * Why a replacement definition cannot take a running task, in `#fit()`'s words: none is registered, it is older than\n * the task, or it is newer without a `migrate`.\n */\nfunction outdatedReason(task: AnyTask | undefined, record: AnyTaskRecord): BlockedReason {\n\tif (task === undefined) return \"missing_task\";\n\treturn task.definition.version < record.version ? \"task_too_old\" : \"migration_failed\";\n}\n\nfunction canReserve(task: AnyTask, record: AnyTaskRecord): boolean {\n\tconst definition = task.definition;\n\treturn (\n\t\tdefinition.version === record.version || (definition.version > record.version && definition.migrate !== undefined)\n\t);\n}\n\n/** A sleep's `until` is a time on the Harness clock; an abort handler cannot sleep. */\nfunction validateSleep(invocation: Invocation, task: TaskId, until: number): void {\n\tif (invocation.mode === \"abort\") throw new Error(`Abort handler of task ${task} cannot sleep`);\n\tif (typeof until !== \"number\" || !Number.isFinite(until) || until < 0) {\n\t\tthrow new Error(`Task ${task} cannot sleep until ${until}: not a time in milliseconds`);\n\t}\n}\n\n/** Structural equality of two JSON values; object key order is ignored. */\nfunction jsonEqual(left: JsonValue | undefined, right: JsonValue | undefined): boolean {\n\tif (left === right) return true;\n\tif (typeof left !== \"object\" || typeof right !== \"object\" || left === null || right === null) return false;\n\tif (Array.isArray(left) || Array.isArray(right)) {\n\t\tif (!Array.isArray(left) || !Array.isArray(right) || left.length !== right.length) return false;\n\t\treturn left.every((value, index) => jsonEqual(value, right[index]));\n\t}\n\tconst keys = Object.keys(left);\n\tif (keys.length !== Object.keys(right).length) return false;\n\treturn keys.every((key) => Object.hasOwn(right, key) && jsonEqual(left[key], right[key]));\n}\n"]}
|