@caupulican/pi-adaptative 0.90.2 → 0.90.4
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 +35 -0
- package/dist/core/agent-session-contracts.d.ts +2 -0
- package/dist/core/agent-session-contracts.d.ts.map +1 -1
- package/dist/core/agent-session-contracts.js.map +1 -1
- package/dist/core/autonomy/bounded-completion.d.ts +10 -1
- package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
- package/dist/core/autonomy/bounded-completion.js +24 -2
- package/dist/core/autonomy/bounded-completion.js.map +1 -1
- package/dist/core/autonomy/lane-tracker.d.ts +1 -1
- package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tracker.js +9 -1
- package/dist/core/autonomy/lane-tracker.js.map +1 -1
- package/dist/core/background-lane-controller.d.ts +1 -3
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/compaction-controller.d.ts.map +1 -1
- package/dist/core/compaction-controller.js +0 -1
- package/dist/core/compaction-controller.js.map +1 -1
- package/dist/core/delegation/managed-lane-controller.d.ts.map +1 -1
- package/dist/core/delegation/managed-lane-controller.js +5 -1
- package/dist/core/delegation/managed-lane-controller.js.map +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.d.ts +8 -1
- package/dist/core/delegation/worker-agent-control-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-agent-control-coordinator.js +94 -36
- package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-agent-control.d.ts +1 -0
- package/dist/core/delegation/worker-agent-control.d.ts.map +1 -1
- package/dist/core/delegation/worker-agent-control.js.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.js +7 -2
- package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
- package/dist/core/delegation/worker-authority-resolver.d.ts.map +1 -1
- package/dist/core/delegation/worker-authority-resolver.js +26 -3
- package/dist/core/delegation/worker-authority-resolver.js.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.d.ts +7 -4
- package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.js +110 -27
- package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
- package/dist/core/delegation/worker-fleet-limits.d.ts +9 -2
- package/dist/core/delegation/worker-fleet-limits.d.ts.map +1 -1
- package/dist/core/delegation/worker-fleet-limits.js +39 -3
- package/dist/core/delegation/worker-fleet-limits.js.map +1 -1
- package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -1
- package/dist/core/delegation/worker-lane-projection.js +4 -0
- package/dist/core/delegation/worker-lane-projection.js.map +1 -1
- package/dist/core/delegation/worker-lease-heartbeat.d.ts +16 -0
- package/dist/core/delegation/worker-lease-heartbeat.d.ts.map +1 -0
- package/dist/core/delegation/worker-lease-heartbeat.js +37 -0
- package/dist/core/delegation/worker-lease-heartbeat.js.map +1 -0
- package/dist/core/delegation/worker-lifecycle.d.ts +1 -0
- package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -1
- package/dist/core/delegation/worker-lifecycle.js +6 -0
- package/dist/core/delegation/worker-lifecycle.js.map +1 -1
- package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-notification-coordinator.js +2 -1
- package/dist/core/delegation/worker-notification-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-runner.js +2 -2
- package/dist/core/delegation/worker-runner.js.map +1 -1
- package/dist/core/delegation/worker-terminal-handoff-coordinator.d.ts +1 -0
- package/dist/core/delegation/worker-terminal-handoff-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-terminal-handoff-coordinator.js +1 -0
- package/dist/core/delegation/worker-terminal-handoff-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-tree-budget-coordinator.d.ts +4 -2
- package/dist/core/delegation/worker-tree-budget-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-tree-budget-coordinator.js +10 -2
- package/dist/core/delegation/worker-tree-budget-coordinator.js.map +1 -1
- package/dist/core/delegation/worker-write-reservation-coordinator.d.ts +14 -0
- package/dist/core/delegation/worker-write-reservation-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-write-reservation-coordinator.js +121 -33
- package/dist/core/delegation/worker-write-reservation-coordinator.js.map +1 -1
- package/dist/core/foreground-terminal-handoff-controller.d.ts +5 -0
- package/dist/core/foreground-terminal-handoff-controller.d.ts.map +1 -1
- package/dist/core/foreground-terminal-handoff-controller.js +28 -12
- package/dist/core/foreground-terminal-handoff-controller.js.map +1 -1
- package/dist/core/orchestration/capability-gateway.d.ts +2 -1
- package/dist/core/orchestration/capability-gateway.d.ts.map +1 -1
- package/dist/core/orchestration/capability-gateway.js +9 -2
- package/dist/core/orchestration/capability-gateway.js.map +1 -1
- package/dist/core/orchestration/contracts.d.ts +16 -1
- package/dist/core/orchestration/contracts.d.ts.map +1 -1
- package/dist/core/orchestration/contracts.js +5 -0
- package/dist/core/orchestration/contracts.js.map +1 -1
- package/dist/core/orchestration/profile-registry.d.ts.map +1 -1
- package/dist/core/orchestration/profile-registry.js +38 -1
- package/dist/core/orchestration/profile-registry.js.map +1 -1
- package/dist/core/orchestration/risk-budget.d.ts +10 -0
- package/dist/core/orchestration/risk-budget.d.ts.map +1 -1
- package/dist/core/orchestration/risk-budget.js +14 -0
- package/dist/core/orchestration/risk-budget.js.map +1 -1
- package/dist/core/orchestration/task-runtime-reducer.d.ts +1 -0
- package/dist/core/orchestration/task-runtime-reducer.d.ts.map +1 -1
- package/dist/core/orchestration/task-runtime-reducer.js +34 -0
- package/dist/core/orchestration/task-runtime-reducer.js.map +1 -1
- package/dist/core/orchestration/task-runtime.d.ts +1 -0
- package/dist/core/orchestration/task-runtime.d.ts.map +1 -1
- package/dist/core/orchestration/task-runtime.js +24 -1
- package/dist/core/orchestration/task-runtime.js.map +1 -1
- package/dist/core/provider-prompt-contracts.d.ts.map +1 -1
- package/dist/core/provider-prompt-contracts.js +2 -1
- package/dist/core/provider-prompt-contracts.js.map +1 -1
- package/dist/core/reflection-controller.d.ts.map +1 -1
- package/dist/core/reflection-controller.js +8 -1
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/settings-manager.d.ts +2 -2
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +2 -2
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/tools/bash.d.ts +3 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +13 -2
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/delegate-status.d.ts +1 -0
- package/dist/core/tools/delegate-status.d.ts.map +1 -1
- package/dist/core/tools/delegate-status.js +19 -1
- package/dist/core/tools/delegate-status.js.map +1 -1
- package/dist/core/tools/delegate.d.ts +9 -1
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +198 -64
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +14 -1
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/file-failure-recovery.d.ts +3 -0
- package/dist/core/tools/file-failure-recovery.d.ts.map +1 -1
- package/dist/core/tools/file-failure-recovery.js +11 -0
- package/dist/core/tools/file-failure-recovery.js.map +1 -1
- package/dist/core/tools/orchestration-panel.d.ts +1 -1
- package/dist/core/tools/orchestration-panel.d.ts.map +1 -1
- package/dist/core/tools/orchestration-panel.js +1 -0
- package/dist/core/tools/orchestration-panel.js.map +1 -1
- package/dist/core/tools/profile-writer.d.ts.map +1 -1
- package/dist/core/tools/profile-writer.js +2 -8
- package/dist/core/tools/profile-writer.js.map +1 -1
- package/dist/core/tools/search-command-guard.d.ts.map +1 -1
- package/dist/core/tools/search-command-guard.js +10 -3
- package/dist/core/tools/search-command-guard.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +10 -1
- package/dist/core/tools/write.js.map +1 -1
- package/dist/modes/interactive/components/activity-lane.d.ts +1 -1
- package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -1
- package/dist/modes/interactive/components/activity-lane.js +11 -2
- package/dist/modes/interactive/components/activity-lane.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +1 -1
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/utils/shell.d.ts +2 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +3 -1
- package/dist/utils/shell.js.map +1 -1
- package/docs/harness-architecture.md +6 -3
- package/docs/settings.md +8 -6
- package/docs/tool-repair.md +1 -1
- package/docs/worker-profiles.md +2 -2
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +4 -4
|
@@ -58,6 +58,7 @@ export declare class DurableTaskRuntime {
|
|
|
58
58
|
bindAttemptGrant(attemptId: string, grant: ExecutionGrant): AttemptRuntimeState;
|
|
59
59
|
leaseAttempt(attemptId: string, ownerId: string, ttlMs: number, agentId?: string): AttemptLease;
|
|
60
60
|
startAttempt(attemptId: string, leaseId: string, fencingToken: number): AttemptRuntimeState;
|
|
61
|
+
renewAttemptLease(attemptId: string, leaseId: string, fencingToken: number, ttlMs: number): AttemptLease;
|
|
61
62
|
checkpointAttempt(args: {
|
|
62
63
|
attemptId: string;
|
|
63
64
|
leaseId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-runtime.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/task-runtime.ts"],"names":[],"mappings":"AAIA,OAAO,EACN,KAAK,oBAAoB,EAGzB,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAE5B,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EASnB,KAAK,iBAAiB,EAGtB,KAAK,4BAA4B,EAEjC,KAAK,YAAY,EAEjB,KAAK,oBAAoB,EACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,uBAAuB,EAAsC,MAAM,kBAAkB,CAAC;AA6BpG,OAAO,
|
|
1
|
+
{"version":3,"file":"task-runtime.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/task-runtime.ts"],"names":[],"mappings":"AAIA,OAAO,EACN,KAAK,oBAAoB,EAGzB,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAE5B,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EASnB,KAAK,iBAAiB,EAGtB,KAAK,4BAA4B,EAEjC,KAAK,YAAY,EAEjB,KAAK,oBAAoB,EACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,uBAAuB,EAAsC,MAAM,kBAAkB,CAAC;AA6BpG,OAAO,EAuBN,KAAK,2BAA2B,EAChC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EAEpB,KAAK,wBAAwB,EAE7B,KAAK,+BAA+B,EACpC,KAAK,sCAAsC,EAC3C,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EAErB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EACN,0BAA0B,EAC1B,w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GS, MAX_ORCHESTRATION_APPROVALS, MAX_ORCH
|
|
|
5
5
|
import { OrchestrationSnapshotRequiredError } from "./event-store.js";
|
|
6
6
|
import { approvalFromPayload, assertAcceptanceCriteria, assertReferencedAcceptanceCriteriaRetained, assertRiskBudget, checkpointSummary, dispatchFromValue, dispatchIdentifier, dispatchIdentifierArray, executionGrantFromValue, MAX_DATE_EPOCH_MS, projectionFromSnapshot, retryStateFromValue, taskFromValue, usageFromPayload, validateTaskContractForState, validateTaskDependencyIds, } from "./task-runtime-codecs.js";
|
|
7
7
|
import { assertBoundedIdentifierList, assertIdentifierListHasCapacity, assertObjectiveEvidenceHasCapacity, assertProjectionRecordReplacementWithinLimits, assertRecordHasCapacity, cloneProjection, projectionCapacity, requestedProjectionSlots, } from "./task-runtime-projection.js";
|
|
8
|
-
import { activeTaskAttempt, assertAgentNotRetired, assertAgentRetirementEligible, assertApprovalRequestTransition, assertApprovalResolutionTransition, assertAttemptCheckpointTransition, assertAttemptFinishTransition, assertAttemptGrantTransition, assertAttemptLeaseTransition, assertAttemptStartTransition, assertNotificationTarget, assertObjectiveStatusTransition, assertRetryBackoffElapsedAt, assertTaskAttemptBudgetForState, assertTaskFailureTransition, assertVerificationTransition, attemptDispatchReadiness, projectOrchestrationEvents, reduceOrchestrationEvent, requireActiveObjectiveForAttemptInProjection, } from "./task-runtime-reducer.js";
|
|
8
|
+
import { activeTaskAttempt, assertAgentNotRetired, assertAgentRetirementEligible, assertApprovalRequestTransition, assertApprovalResolutionTransition, assertAttemptCheckpointTransition, assertAttemptFinishTransition, assertAttemptGrantTransition, assertAttemptLeaseRenewalTransition, assertAttemptLeaseTransition, assertAttemptStartTransition, assertNotificationTarget, assertObjectiveStatusTransition, assertRetryBackoffElapsedAt, assertTaskAttemptBudgetForState, assertTaskFailureTransition, assertVerificationTransition, attemptDispatchReadiness, projectOrchestrationEvents, reduceOrchestrationEvent, requireActiveObjectiveForAttemptInProjection, } from "./task-runtime-reducer.js";
|
|
9
9
|
import { DurableTaskRuntimeError, terminalAttemptStatus, } from "./task-runtime-state.js";
|
|
10
10
|
export { validateTaskDependencyIds } from "./task-runtime-codecs.js";
|
|
11
11
|
export { projectOrchestrationEvents, reduceOrchestrationEvent, } from "./task-runtime-reducer.js";
|
|
@@ -458,6 +458,29 @@ export class DurableTaskRuntime {
|
|
|
458
458
|
});
|
|
459
459
|
return structuredClone(this.state.attempts[attemptId]);
|
|
460
460
|
}
|
|
461
|
+
renewAttemptLease(attemptId, leaseId, fencingToken, ttlMs) {
|
|
462
|
+
this.refresh();
|
|
463
|
+
const attempt = this.requireLiveLease(attemptId, leaseId, fencingToken);
|
|
464
|
+
if (attempt.status !== "leased" && attempt.status !== "running") {
|
|
465
|
+
throw new DurableTaskRuntimeError(`Attempt '${attemptId}' cannot renew from '${attempt.status}'.`);
|
|
466
|
+
}
|
|
467
|
+
if (!Number.isFinite(ttlMs) || ttlMs <= 0)
|
|
468
|
+
throw new DurableTaskRuntimeError("Lease TTL must be positive.");
|
|
469
|
+
const renewedAtMs = this.now();
|
|
470
|
+
const expiresAtMs = renewedAtMs + Math.min(ttlMs, MAX_DATE_EPOCH_MS - renewedAtMs);
|
|
471
|
+
if (expiresAtMs <= Date.parse(attempt.lease.expiresAt))
|
|
472
|
+
return structuredClone(attempt.lease);
|
|
473
|
+
const expiresAt = new Date(expiresAtMs).toISOString();
|
|
474
|
+
assertAttemptLeaseRenewalTransition(this.state, attemptId, attemptId, leaseId, fencingToken, expiresAt, this.nowIso());
|
|
475
|
+
this.commit({
|
|
476
|
+
type: "attempt.lease_renewed",
|
|
477
|
+
aggregateId: attemptId,
|
|
478
|
+
actor: "runtime",
|
|
479
|
+
idempotencyKey: `attempt-lease-renewed:${leaseId}:${expiresAt}`,
|
|
480
|
+
payload: toJsonObject({ attemptId, leaseId, fencingToken, expiresAt }),
|
|
481
|
+
});
|
|
482
|
+
return structuredClone(this.state.attempts[attemptId].lease);
|
|
483
|
+
}
|
|
461
484
|
checkpointAttempt(args) {
|
|
462
485
|
this.refresh();
|
|
463
486
|
const attempt = this.requireLiveLease(args.attemptId, args.leaseId, args.fencingToken);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-runtime.js","sourceRoot":"","sources":["../../../src/core/orchestration/task-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAYN,gCAAgC,EAChC,2BAA2B,EAC3B,0BAA0B,EAC1B,6BAA6B,EAC7B,+BAA+B,EAC/B,oCAAoC,EACpC,4BAA4B,EAC5B,uBAAuB,EAGvB,4BAA4B,EAI5B,YAAY,GAEZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAgC,kCAAkC,EAAE,MAAM,kBAAkB,CAAC;AACpG,OAAO,EACN,mBAAmB,EACnB,wBAAwB,EACxB,0CAA0C,EAC1C,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,EACvB,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,EACnB,aAAa,EACb,gBAAgB,EAChB,4BAA4B,EAC5B,yBAAyB,GACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,2BAA2B,EAC3B,+BAA+B,EAC/B,kCAAkC,EAClC,6CAA6C,EAC7C,uBAAuB,EACvB,eAAe,EACf,kBAAkB,EAClB,wBAAwB,GACxB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,iBAAiB,EACjB,qBAAqB,EACrB,6BAA6B,EAC7B,+BAA+B,EAC/B,kCAAkC,EAClC,iCAAiC,EACjC,6BAA6B,EAC7B,4BAA4B,EAC5B,4BAA4B,EAC5B,4BAA4B,EAC5B,wBAAwB,EACxB,+BAA+B,EAC/B,2BAA2B,EAC3B,+BAA+B,EAC/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ACb,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAC3C,CAAC;CACD","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { isDeepStrictEqual } from \"node:util\";\nimport type { JsonObject } from \"../autonomy/contracts.ts\";\nimport { createAgentIdentity } from \"./agent-resume.ts\";\nimport {\n\ttype AgentBindingContract,\n\ttype AgentIdentityContract,\n\ttype AppendOrchestrationEventInput,\n\ttype ApprovalOutcome,\n\ttype ApprovalRequestContract,\n\ttype ApprovalResolutionContract,\n\ttype AttemptCheckpoint,\n\ttype AttemptLease,\n\ttype AttemptRetryState,\n\ttype EvidenceContract,\n\ttype ExecutionGrant,\n\tMAX_ORCHESTRATION_AGENT_BINDINGS,\n\tMAX_ORCHESTRATION_APPROVALS,\n\tMAX_ORCHESTRATION_ATTEMPTS,\n\tMAX_ORCHESTRATION_CHECKPOINTS,\n\tMAX_ORCHESTRATION_NOTIFICATIONS,\n\tMAX_ORCHESTRATION_OBJECTIVE_EVIDENCE,\n\tMAX_ORCHESTRATION_OBJECTIVES,\n\tMAX_ORCHESTRATION_TASKS,\n\ttype ObjectiveContract,\n\ttype ObjectiveStatus,\n\tORCHESTRATION_SCHEMA_VERSION,\n\ttype OrchestrationDispatchRequest,\n\ttype OrchestrationEvent,\n\ttype TaskContract,\n\ttoJsonObject,\n\ttype WorkerResultContract,\n} from \"./contracts.ts\";\nimport { type OrchestrationEventStore, OrchestrationSnapshotRequiredError } from \"./event-store.ts\";\nimport {\n\tapprovalFromPayload,\n\tassertAcceptanceCriteria,\n\tassertReferencedAcceptanceCriteriaRetained,\n\tassertRiskBudget,\n\tcheckpointSummary,\n\tdispatchFromValue,\n\tdispatchIdentifier,\n\tdispatchIdentifierArray,\n\texecutionGrantFromValue,\n\tMAX_DATE_EPOCH_MS,\n\tprojectionFromSnapshot,\n\tretryStateFromValue,\n\ttaskFromValue,\n\tusageFromPayload,\n\tvalidateTaskContractForState,\n\tvalidateTaskDependencyIds,\n} from \"./task-runtime-codecs.ts\";\nimport {\n\tassertBoundedIdentifierList,\n\tassertIdentifierListHasCapacity,\n\tassertObjectiveEvidenceHasCapacity,\n\tassertProjectionRecordReplacementWithinLimits,\n\tassertRecordHasCapacity,\n\tcloneProjection,\n\tprojectionCapacity,\n\trequestedProjectionSlots,\n} from \"./task-runtime-projection.ts\";\nimport {\n\tactiveTaskAttempt,\n\tassertAgentNotRetired,\n\tassertAgentRetirementEligible,\n\tassertApprovalRequestTransition,\n\tassertApprovalResolutionTransition,\n\tassertAttemptCheckpointTransition,\n\tassertAttemptFinishTransition,\n\tassertAttemptGrantTransition,\n\tassertAttemptLeaseTransition,\n\tassertAttemptStartTransition,\n\tassertNotificationTarget,\n\tassertObjectiveStatusTransition,\n\tassertRetryBackoffElapsedAt,\n\tassertTaskAttemptBudgetForState,\n\tassertTaskFailureTransition,\n\tassertVerificationTransition,\n\tattemptDispatchReadiness,\n\ttype ObjectiveCompletionPolicy,\n\tprojectOrchestrationEvents,\n\treduceOrchestrationEvent,\n\trequireActiveObjectiveForAttemptInProjection,\n\ttype VerificationTransitionInput,\n} from \"./task-runtime-reducer.ts\";\nimport {\n\ttype ApprovalRuntimeState,\n\ttype AttemptDispatchReadiness,\n\ttype AttemptRuntimeState,\n\ttype CreateObjectiveInput,\n\ttype CreateTaskInput,\n\tDurableTaskRuntimeError,\n\ttype NotificationRuntimeState,\n\ttype ObjectiveRuntimeState,\n\ttype OrchestrationProjectionCapacity,\n\ttype OrchestrationProjectionHeadroomRequest,\n\ttype PreparedTaskAttempt,\n\ttype RegisterAgentInput,\n\ttype TaskRuntimeProjection,\n\ttype TaskRuntimeState,\n\tterminalAttemptStatus,\n} from \"./task-runtime-state.ts\";\n\nexport { validateTaskDependencyIds } from \"./task-runtime-codecs.ts\";\nexport {\n\tprojectOrchestrationEvents,\n\treduceOrchestrationEvent,\n} from \"./task-runtime-reducer.ts\";\nexport {\n\ttype ApprovalRuntimeState,\n\ttype AttemptDispatchReadiness,\n\ttype AttemptRuntimeState,\n\ttype CreateObjectiveInput,\n\ttype CreateTaskInput,\n\tDurableTaskRuntimeError,\n\ttype NotificationRuntimeState,\n\ttype ObjectiveRuntimeState,\n\ttype OrchestrationProjectionCapacity,\n\ttype OrchestrationProjectionHeadroomRequest,\n\ttype OrchestrationProjectionSlotCounts,\n\ttype PreparedTaskAttempt,\n\ttype RegisterAgentInput,\n\ttype TaskRuntimeProjection,\n\ttype TaskRuntimeState,\n} from \"./task-runtime-state.ts\";\n\nexport interface DurableTaskRuntimeOptions {\n\tstore: OrchestrationEventStore;\n\tnow?: () => number;\n\tcreateId?: () => string;\n}\n\nexport class DurableTaskRuntime {\n\tprivate readonly store: OrchestrationEventStore;\n\tprivate readonly now: () => number;\n\tprivate readonly createId: () => string;\n\tprivate state: TaskRuntimeProjection;\n\n\tconstructor(options: DurableTaskRuntimeOptions) {\n\t\tthis.store = options.store;\n\t\tthis.now = options.now ?? (() => Date.now());\n\t\tthis.createId = options.createId ?? randomUUID;\n\t\tconst snapshot = this.store.readProjectionSnapshot();\n\t\tif (snapshot) {\n\t\t\tthis.state = projectionFromSnapshot(snapshot.projection, snapshot.throughOrdinal);\n\t\t} else {\n\t\t\tconst events = this.store.readAll();\n\t\t\t// Compaction may install a baseline between the first snapshot read and readAll(). In that\n\t\t\t// case readAll() returns only the new tail, which must be applied to that baseline rather\n\t\t\t// than projected as a standalone history.\n\t\t\tconst snapshotAfterRead = this.store.readProjectionSnapshot();\n\t\t\tthis.state = snapshotAfterRead\n\t\t\t\t? events\n\t\t\t\t\t\t.filter((event) => event.ordinal > snapshotAfterRead.throughOrdinal)\n\t\t\t\t\t\t.reduce(\n\t\t\t\t\t\t\treduceOrchestrationEvent,\n\t\t\t\t\t\t\tprojectionFromSnapshot(snapshotAfterRead.projection, snapshotAfterRead.throughOrdinal),\n\t\t\t\t\t\t)\n\t\t\t\t: projectOrchestrationEvents(events);\n\t\t}\n\t\tthis.refresh();\n\t}\n\n\tgetSnapshot(): TaskRuntimeProjection {\n\t\tthis.refresh();\n\t\treturn cloneProjection(this.state);\n\t}\n\n\t/** Read-only retained-record counts and remaining lifetime slots for orchestration admission. */\n\tgetProjectionCapacity(): OrchestrationProjectionCapacity {\n\t\tthis.refresh();\n\t\treturn projectionCapacity(this.state);\n\t}\n\n\t/**\n\t * Preflight every record needed by a multi-event operation before its first append. Callers use\n\t * this to reserve implementation and mandatory-verifier task/attempt pairs atomically.\n\t */\n\tassertProjectionHeadroom(required: OrchestrationProjectionHeadroomRequest): OrchestrationProjectionCapacity {\n\t\tthis.refresh();\n\t\tconst capacity = projectionCapacity(this.state);\n\t\tconst agents = requestedProjectionSlots(required.agents, \"Agent binding\");\n\t\tconst objectives = requestedProjectionSlots(required.objectives, \"Objective\");\n\t\tconst tasks = requestedProjectionSlots(required.tasks, \"Task\");\n\t\tconst attempts = requestedProjectionSlots(required.attempts, \"Attempt\");\n\t\tconst checkpoints = requestedProjectionSlots(required.checkpoints, \"Checkpoint\");\n\t\tconst approvals = requestedProjectionSlots(required.approvals, \"Approval\");\n\t\tconst notifications = requestedProjectionSlots(required.notifications, \"Notification\");\n\t\tconst evidence = requestedProjectionSlots(required.evidence, \"Evidence\");\n\t\tif (agents > capacity.headroom.agents) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`Orchestration agent binding limit (${capacity.limits.agents}) lacks ${agents} required slots.`,\n\t\t\t);\n\t\t}\n\t\tif (tasks > capacity.headroom.tasks) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`Orchestration task limit (${capacity.limits.tasks}) lacks ${tasks} required slots.`,\n\t\t\t);\n\t\t}\n\t\tif (attempts > capacity.headroom.attempts) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`Orchestration attempt limit (${capacity.limits.attempts}) lacks ${attempts} required slots.`,\n\t\t\t);\n\t\t}\n\t\tif (objectives > capacity.headroom.objectives) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`Orchestration objective limit (${capacity.limits.objectives}) lacks ${objectives} required slots.`,\n\t\t\t);\n\t\t}\n\t\tif (checkpoints > capacity.headroom.checkpoints) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`Orchestration checkpoint limit (${capacity.limits.checkpoints}) lacks ${checkpoints} required slots.`,\n\t\t\t);\n\t\t}\n\t\tif (approvals > capacity.headroom.approvals) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`Orchestration approval limit (${capacity.limits.approvals}) lacks ${approvals} required slots.`,\n\t\t\t);\n\t\t}\n\t\tif (notifications > capacity.headroom.notifications) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`Orchestration notification limit (${capacity.limits.notifications}) lacks ${notifications} required slots.`,\n\t\t\t);\n\t\t}\n\t\tif (evidence > capacity.headroom.evidence) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`Orchestration evidence limit (${capacity.limits.evidence}) lacks ${evidence} required slots.`,\n\t\t\t);\n\t\t}\n\t\treturn capacity;\n\t}\n\n\t/**\n\t * Preflight the idempotent evidence batch for one objective before synchronizing any member.\n\t * The objective may be absent when its creation is part of the same compound operation.\n\t */\n\tassertObjectiveEvidenceHeadroom(objectiveId: string, evidenceIds: readonly string[]): number {\n\t\tthis.refresh();\n\t\tassertBoundedIdentifierList(evidenceIds, MAX_ORCHESTRATION_OBJECTIVE_EVIDENCE, \"Objective evidence ids\");\n\t\tconst objective = this.state.objectives[objectiveId];\n\t\tconst existingIds = new Set(objective?.evidence.map((evidence) => evidence.evidenceId) ?? []);\n\t\tlet required = 0;\n\t\tfor (const evidenceId of evidenceIds) {\n\t\t\tif (!existingIds.has(evidenceId)) required += 1;\n\t\t}\n\t\tif ((objective?.evidence.length ?? 0) + required > MAX_ORCHESTRATION_OBJECTIVE_EVIDENCE) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`Orchestration objective evidence limit (${MAX_ORCHESTRATION_OBJECTIVE_EVIDENCE}) lacks ${required} required slots.`,\n\t\t\t);\n\t\t}\n\t\tconst capacity = projectionCapacity(this.state);\n\t\tif (required > capacity.headroom.evidence) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`Orchestration evidence limit (${capacity.limits.evidence}) lacks ${required} required slots.`,\n\t\t\t);\n\t\t}\n\t\treturn required;\n\t}\n\n\t/**\n\t * Preflight the final retained objective record for a multi-event owner synchronization. This\n\t * validates the objective metadata and the complete idempotently merged evidence batch before\n\t * ensureObjective can append the first event, so a later byte rejection cannot leave a prefix.\n\t */\n\tassertObjectiveSynchronizationHeadroom(\n\t\tinput: CreateObjectiveInput & { objectiveId: string },\n\t\tevidence: readonly EvidenceContract[],\n\t): void {\n\t\tthis.refresh();\n\t\tconst objectiveId = dispatchIdentifier(input.objectiveId, \"objective.objectiveId\");\n\t\tconst current = this.state.objectives[objectiveId];\n\t\tconst requiredEvidence = this.assertObjectiveEvidenceHeadroom(\n\t\t\tobjectiveId,\n\t\t\tevidence.map((item) => item.evidenceId),\n\t\t);\n\t\tthis.assertProjectionHeadroom({ objectives: current ? 0 : 1, evidence: requiredEvidence });\n\t\tassertRiskBudget(input.riskBudget, \"objective.riskBudget\");\n\t\tconst acceptanceCriteria = structuredClone(input.acceptanceCriteria ?? []);\n\t\tassertAcceptanceCriteria(acceptanceCriteria);\n\t\tconst title = input.title.trim();\n\t\tconst description = input.description.trim();\n\t\tif (!title || !description) throw new DurableTaskRuntimeError(\"Objective title and description are required.\");\n\t\tconst now = this.nowIso();\n\t\tconst objective: ObjectiveContract = current\n\t\t\t? {\n\t\t\t\t\t...current.objective,\n\t\t\t\t\ttitle,\n\t\t\t\t\tdescription,\n\t\t\t\t\tconstraints: [...(input.constraints ?? [])],\n\t\t\t\t\tacceptanceCriteria,\n\t\t\t\t\triskBudget: { ...(input.riskBudget ?? {}) },\n\t\t\t\t\tupdatedAt: now,\n\t\t\t\t}\n\t\t\t: {\n\t\t\t\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\t\t\t\tobjectiveId,\n\t\t\t\t\ttitle,\n\t\t\t\t\tdescription,\n\t\t\t\t\tstatus: \"active\",\n\t\t\t\t\tconstraints: [...(input.constraints ?? [])],\n\t\t\t\t\tacceptanceCriteria,\n\t\t\t\t\triskBudget: { ...(input.riskBudget ?? {}) },\n\t\t\t\t\tcreatedAt: now,\n\t\t\t\t\tupdatedAt: now,\n\t\t\t\t};\n\t\tif (current) {\n\t\t\tassertReferencedAcceptanceCriteriaRetained(this.state.tasks, current, acceptanceCriteria);\n\t\t}\n\n\t\tconst mergedEvidence = current?.evidence.map((item) => structuredClone(item)) ?? [];\n\t\tconst evidenceById = new Map(mergedEvidence.map((item) => [item.evidenceId, item]));\n\t\tfor (const item of evidence) {\n\t\t\tconst evidenceId = dispatchIdentifier(item.evidenceId, \"objective evidence.evidenceId\");\n\t\t\tif (!item.summary.trim() || !item.createdAt.trim()) {\n\t\t\t\tthrow new DurableTaskRuntimeError(\"Objective evidence requires an id, summary, and creation time.\");\n\t\t\t}\n\t\t\tif (item.criterionId && !objective.acceptanceCriteria.some((criterion) => criterion.id === item.criterionId)) {\n\t\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t\t`Objective evidence references unknown acceptance criterion '${item.criterionId}'.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst existing = evidenceById.get(evidenceId);\n\t\t\tif (existing) {\n\t\t\t\tif (!isDeepStrictEqual(existing, item)) {\n\t\t\t\t\tthrow new DurableTaskRuntimeError(`Objective evidence '${evidenceId}' has conflicting content.`);\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst retained = structuredClone(item);\n\t\t\tmergedEvidence.push(retained);\n\t\t\tevidenceById.set(evidenceId, retained);\n\t\t}\n\t\tassertProjectionRecordReplacementWithinLimits(this.state, \"objectives\", objectiveId, {\n\t\t\tobjective,\n\t\t\ttaskIds: current?.taskIds ?? [],\n\t\t\tevidence: mergedEvidence,\n\t\t});\n\t}\n\n\tregisterAgent(input: RegisterAgentInput): AgentBindingContract {\n\t\tthis.refresh();\n\t\tconst now = this.nowIso();\n\t\tlet identity: AgentIdentityContract;\n\t\ttry {\n\t\t\tidentity = createAgentIdentity(input.agentId ?? `agent-${this.createId()}`, input.resumeContext);\n\t\t} catch (error) {\n\t\t\tthrow new DurableTaskRuntimeError(error instanceof Error ? error.message : String(error));\n\t\t}\n\t\tconst parentAgentId = input.parentAgentId?.trim();\n\t\tconst parent = parentAgentId ? this.state.agents[parentAgentId] : undefined;\n\t\tif (parentAgentId && !parent) {\n\t\t\tthrow new DurableTaskRuntimeError(`Unknown parent agent '${parentAgentId}'.`);\n\t\t}\n\t\tif (parent?.status === \"retired\") {\n\t\t\tthrow new DurableTaskRuntimeError(`Parent agent '${parentAgentId}' is retired.`);\n\t\t}\n\t\tconst depth = parent ? parent.depth + 1 : 0;\n\t\tif (!Number.isSafeInteger(depth)) {\n\t\t\tthrow new DurableTaskRuntimeError(\"Agent lineage depth exceeds the durable numeric range.\");\n\t\t}\n\t\tconst agent: AgentBindingContract = {\n\t\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\t\t...identity,\n\t\t\t...(parent ? { parentAgentId: parent.agentId } : {}),\n\t\t\trootAgentId: parent?.rootAgentId ?? identity.agentId,\n\t\t\tdepth,\n\t\t\trole: input.role,\n\t\t\tstatus: \"registered\",\n\t\t\tcreatedAt: now,\n\t\t\tupdatedAt: now,\n\t\t};\n\t\tif (this.state.agents[agent.agentId])\n\t\t\tthrow new DurableTaskRuntimeError(`Agent '${agent.agentId}' already exists.`);\n\t\tassertRecordHasCapacity(this.state.agents, MAX_ORCHESTRATION_AGENT_BINDINGS, \"agent binding\");\n\t\tthis.commit({\n\t\t\ttype: \"agent.registered\",\n\t\t\taggregateId: agent.agentId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `agent-registered:${agent.agentId}`,\n\t\t\tpayload: toJsonObject({ agent }),\n\t\t});\n\t\treturn structuredClone(agent);\n\t}\n\n\t/**\n\t * Retire one idle persistent identity without deleting its binding, lineage, transcript pointers,\n\t * or attempt history. A repeated call is inert and returns the durable retired binding.\n\t */\n\tretireAgent(agentId: string): AgentBindingContract {\n\t\tthis.refresh();\n\t\tconst normalizedAgentId = dispatchIdentifier(agentId.trim(), \"agentId\");\n\t\tconst agent = assertAgentRetirementEligible(this.state, normalizedAgentId);\n\t\tif (agent.status === \"retired\") return structuredClone(agent);\n\t\tthis.commit({\n\t\t\ttype: \"agent.retired\",\n\t\t\taggregateId: normalizedAgentId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `agent-retired:${normalizedAgentId}`,\n\t\t\tpayload: toJsonObject({ agentId: normalizedAgentId }),\n\t\t});\n\t\treturn structuredClone(this.state.agents[normalizedAgentId]!);\n\t}\n\n\tcreateObjective(input: CreateObjectiveInput): ObjectiveContract {\n\t\tthis.refresh();\n\t\tassertRiskBudget(input.riskBudget, \"objective.riskBudget\");\n\t\tconst now = this.nowIso();\n\t\tconst objective: ObjectiveContract = {\n\t\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\t\tobjectiveId: input.objectiveId ?? `objective-${this.createId()}`,\n\t\t\ttitle: input.title.trim(),\n\t\t\tdescription: input.description.trim(),\n\t\t\tstatus: \"active\",\n\t\t\tconstraints: [...(input.constraints ?? [])],\n\t\t\tacceptanceCriteria: structuredClone(input.acceptanceCriteria ?? []),\n\t\t\triskBudget: { ...(input.riskBudget ?? {}) },\n\t\t\tcreatedAt: now,\n\t\t\tupdatedAt: now,\n\t\t};\n\t\tif (!objective.title || !objective.description)\n\t\t\tthrow new DurableTaskRuntimeError(\"Objective title and description are required.\");\n\t\tassertAcceptanceCriteria(objective.acceptanceCriteria);\n\t\tif (this.state.objectives[objective.objectiveId]) {\n\t\t\tthrow new DurableTaskRuntimeError(`Objective '${objective.objectiveId}' already exists.`);\n\t\t}\n\t\tassertRecordHasCapacity(this.state.objectives, MAX_ORCHESTRATION_OBJECTIVES, \"objective\");\n\t\tthis.commit({\n\t\t\ttype: \"objective.created\",\n\t\t\taggregateId: objective.objectiveId,\n\t\t\tactor: \"kernel\",\n\t\t\tidempotencyKey: `objective-created:${objective.objectiveId}`,\n\t\t\tpayload: toJsonObject({ objective }),\n\t\t});\n\t\treturn structuredClone(objective);\n\t}\n\n\t/** Create or synchronize owner-authored objective metadata without disturbing lifecycle or task state. */\n\tensureObjective(input: CreateObjectiveInput & { objectiveId: string }): ObjectiveContract {\n\t\tthis.refresh();\n\t\tconst current = this.state.objectives[input.objectiveId];\n\t\tif (!current) return this.createObjective(input);\n\t\tassertRiskBudget(input.riskBudget, \"objective.riskBudget\");\n\t\tconst acceptanceCriteria = structuredClone(input.acceptanceCriteria ?? []);\n\t\tassertAcceptanceCriteria(acceptanceCriteria);\n\t\tconst nextFields = {\n\t\t\ttitle: input.title.trim(),\n\t\t\tdescription: input.description.trim(),\n\t\t\tconstraints: [...(input.constraints ?? [])],\n\t\t\tacceptanceCriteria,\n\t\t\triskBudget: { ...(input.riskBudget ?? {}) },\n\t\t};\n\t\tif (!nextFields.title || !nextFields.description) {\n\t\t\tthrow new DurableTaskRuntimeError(\"Objective title and description are required.\");\n\t\t}\n\t\tconst currentFields = {\n\t\t\ttitle: current.objective.title,\n\t\t\tdescription: current.objective.description,\n\t\t\tconstraints: current.objective.constraints,\n\t\t\tacceptanceCriteria: current.objective.acceptanceCriteria,\n\t\t\triskBudget: current.objective.riskBudget,\n\t\t};\n\t\tif (isDeepStrictEqual(currentFields, nextFields)) return structuredClone(current.objective);\n\n\t\tassertReferencedAcceptanceCriteriaRetained(this.state.tasks, current, acceptanceCriteria);\n\t\tconst objective: ObjectiveContract = {\n\t\t\t...current.objective,\n\t\t\t...nextFields,\n\t\t\tupdatedAt: this.nowIso(),\n\t\t};\n\t\tthis.commit({\n\t\t\ttype: \"objective.updated\",\n\t\t\taggregateId: objective.objectiveId,\n\t\t\tactor: \"kernel\",\n\t\t\tpayload: toJsonObject({ objective }),\n\t\t});\n\t\treturn structuredClone(objective);\n\t}\n\n\trecordObjectiveEvidence(objectiveId: string, evidence: EvidenceContract): EvidenceContract {\n\t\tthis.refresh();\n\t\tconst objective = this.requireObjective(objectiveId);\n\t\tconst existing = objective.evidence.find((candidate) => candidate.evidenceId === evidence.evidenceId);\n\t\tif (existing) {\n\t\t\tif (!isDeepStrictEqual(existing, evidence)) {\n\t\t\t\tthrow new DurableTaskRuntimeError(`Objective evidence '${evidence.evidenceId}' has conflicting content.`);\n\t\t\t}\n\t\t\treturn structuredClone(existing);\n\t\t}\n\t\tif (!evidence.evidenceId.trim() || !evidence.summary.trim() || !evidence.createdAt.trim()) {\n\t\t\tthrow new DurableTaskRuntimeError(\"Objective evidence requires an id, summary, and creation time.\");\n\t\t}\n\t\tif (\n\t\t\tevidence.criterionId &&\n\t\t\t!objective.objective.acceptanceCriteria.some((criterion) => criterion.id === evidence.criterionId)\n\t\t) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`Objective evidence references unknown acceptance criterion '${evidence.criterionId}'.`,\n\t\t\t);\n\t\t}\n\t\tassertObjectiveEvidenceHasCapacity(this.state.objectives, objective);\n\t\tthis.commit({\n\t\t\ttype: \"objective.evidence_recorded\",\n\t\t\taggregateId: objectiveId,\n\t\t\tactor: \"kernel\",\n\t\t\tidempotencyKey: `objective-evidence-recorded:${objectiveId}:${evidence.evidenceId}`,\n\t\t\tpayload: toJsonObject({ evidence }),\n\t\t});\n\t\treturn structuredClone(evidence);\n\t}\n\n\tcreateTask(input: CreateTaskInput): TaskContract {\n\t\tthis.refresh();\n\t\tconst { task, objectiveState } = this.buildTask(input);\n\t\tassertRecordHasCapacity(this.state.tasks, MAX_ORCHESTRATION_TASKS, \"task\");\n\t\tassertIdentifierListHasCapacity(objectiveState.taskIds, MAX_ORCHESTRATION_TASKS, \"objective task list\");\n\t\tthis.commit({\n\t\t\ttype: \"task.created\",\n\t\t\taggregateId: task.objectiveId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `task-created:${task.taskId}`,\n\t\t\tpayload: toJsonObject({ task }),\n\t\t});\n\t\treturn structuredClone(this.state.tasks[task.taskId]!.task);\n\t}\n\n\t/** Atomically create a new task and its first queued attempt in one durable transition. */\n\tprepareTaskAttempt(\n\t\tinput: CreateTaskInput,\n\t\tdispatch: OrchestrationDispatchRequest,\n\t\tgrantId?: string,\n\t): PreparedTaskAttempt {\n\t\tthis.refresh();\n\t\tconst { task, objectiveState } = this.buildTask(input);\n\t\tconst taskState: TaskRuntimeState = { task, attemptIds: [] };\n\t\tconst normalizedDispatch = this.normalizeDispatchForTask(taskState, dispatch);\n\t\tthis.assertTaskAttemptBudget(taskState, objectiveState.objective);\n\t\tassertRecordHasCapacity(this.state.tasks, MAX_ORCHESTRATION_TASKS, \"task\");\n\t\tassertIdentifierListHasCapacity(objectiveState.taskIds, MAX_ORCHESTRATION_TASKS, \"objective task list\");\n\t\tassertRecordHasCapacity(this.state.attempts, MAX_ORCHESTRATION_ATTEMPTS, \"attempt\");\n\t\tconst attemptId = `attempt-${this.createId()}`;\n\t\tthis.commit({\n\t\t\ttype: \"task.attempt_prepared\",\n\t\t\taggregateId: task.taskId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `task-attempt-prepared:${task.taskId}:${attemptId}`,\n\t\t\tpayload: toJsonObject({\n\t\t\t\ttask,\n\t\t\t\tattemptId,\n\t\t\t\ttaskId: task.taskId,\n\t\t\t\tdispatch: normalizedDispatch,\n\t\t\t\t...(grantId ? { grantId } : {}),\n\t\t\t}),\n\t\t});\n\t\treturn {\n\t\t\ttask: structuredClone(this.state.tasks[task.taskId]!.task),\n\t\t\tattempt: structuredClone(this.state.attempts[attemptId]!),\n\t\t};\n\t}\n\n\tqueueAttempt(taskId: string, dispatch: OrchestrationDispatchRequest, grantId?: string): AttemptRuntimeState {\n\t\tthis.refresh();\n\t\tconst task = this.requireDispatchableTask(taskId);\n\t\tconst pendingApproval = this.pendingApprovalForTask(taskId);\n\t\tif (pendingApproval) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`Task '${taskId}' is awaiting approval '${pendingApproval.request.approvalId}'.`,\n\t\t\t);\n\t\t}\n\t\tconst normalizedDispatch = this.normalizeDispatchForTask(task, dispatch);\n\t\tthis.assertTaskAttemptBudget(task, this.state.objectives[task.task.objectiveId]!.objective);\n\t\tassertRecordHasCapacity(this.state.attempts, MAX_ORCHESTRATION_ATTEMPTS, \"attempt\");\n\t\tassertIdentifierListHasCapacity(task.attemptIds, MAX_ORCHESTRATION_ATTEMPTS, \"task attempt list\");\n\t\tconst attemptId = `attempt-${this.createId()}`;\n\t\tthis.commit({\n\t\t\ttype: \"attempt.queued\",\n\t\t\taggregateId: taskId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `attempt-queued:${attemptId}`,\n\t\t\tpayload: toJsonObject({ attemptId, taskId, dispatch: normalizedDispatch, ...(grantId ? { grantId } : {}) }),\n\t\t});\n\t\treturn structuredClone(this.state.attempts[attemptId]!);\n\t}\n\n\t/** Read-only controller seam for deciding whether one durable queued or suspended attempt may run. */\n\tgetAttemptDispatchReadiness(attemptId: string): AttemptDispatchReadiness {\n\t\tthis.refresh();\n\t\treturn structuredClone(attemptDispatchReadiness(this.state, this.requireAttempt(attemptId)));\n\t}\n\n\tbindAttemptGrant(attemptId: string, grant: ExecutionGrant): AttemptRuntimeState {\n\t\tthis.refresh();\n\t\tconst normalizedGrant = executionGrantFromValue(grant, \"grant\");\n\t\tconst attempt = assertAttemptGrantTransition(this.state, attemptId, attemptId, normalizedGrant);\n\t\tif (attempt.grantId === normalizedGrant.grantId) {\n\t\t\tif (attempt.grant && !isDeepStrictEqual(attempt.grant, normalizedGrant)) {\n\t\t\t\tthrow new DurableTaskRuntimeError(`Attempt '${attemptId}' grant has conflicting content.`);\n\t\t\t}\n\t\t\treturn structuredClone(attempt);\n\t\t}\n\t\tif (attempt.grantId) throw new DurableTaskRuntimeError(`Attempt '${attemptId}' already has a different grant.`);\n\t\tthis.commit({\n\t\t\ttype: \"attempt.grant_bound\",\n\t\t\taggregateId: attemptId,\n\t\t\tactor: \"policy\",\n\t\t\tidempotencyKey: `attempt-grant-bound:${attemptId}:${normalizedGrant.grantId}`,\n\t\t\tpayload: toJsonObject({ attemptId, grant: normalizedGrant }),\n\t\t});\n\t\treturn structuredClone(this.state.attempts[attemptId]!);\n\t}\n\n\tleaseAttempt(attemptId: string, ownerId: string, ttlMs: number, agentId?: string): AttemptLease {\n\t\tthis.refresh();\n\t\tconst attempt = this.requireAttempt(attemptId);\n\t\tconst lease = this.issueLease(attempt, ownerId, ttlMs);\n\t\tassertAttemptLeaseTransition(this.state, attemptId, lease, agentId, this.nowIso());\n\t\tthis.commit({\n\t\t\ttype: \"attempt.leased\",\n\t\t\taggregateId: attemptId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `attempt-leased:${lease.leaseId}`,\n\t\t\tpayload: toJsonObject({ lease, ...(agentId ? { agentId } : {}) }),\n\t\t});\n\t\treturn structuredClone(lease);\n\t}\n\n\tstartAttempt(attemptId: string, leaseId: string, fencingToken: number): AttemptRuntimeState {\n\t\tthis.refresh();\n\t\tassertAttemptStartTransition(this.state, attemptId, attemptId, leaseId, fencingToken, this.nowIso());\n\t\tthis.commit({\n\t\t\ttype: \"attempt.started\",\n\t\t\taggregateId: attemptId,\n\t\t\tactor: \"worker\",\n\t\t\tidempotencyKey: `attempt-started:${attemptId}:${fencingToken}`,\n\t\t\tpayload: toJsonObject({ attemptId, leaseId, fencingToken }),\n\t\t});\n\t\treturn structuredClone(this.state.attempts[attemptId]!);\n\t}\n\n\tcheckpointAttempt(args: {\n\t\tattemptId: string;\n\t\tleaseId: string;\n\t\tfencingToken: number;\n\t\tsummary: string;\n\t\tartifactIds?: readonly string[];\n\t\tevidenceIds?: readonly string[];\n\t\tusage?: AttemptCheckpoint[\"usage\"];\n\t}): AttemptCheckpoint {\n\t\tthis.refresh();\n\t\tconst attempt = this.requireLiveLease(args.attemptId, args.leaseId, args.fencingToken);\n\t\tif (attempt.status !== \"running\")\n\t\t\tthrow new DurableTaskRuntimeError(`Attempt '${args.attemptId}' is not running.`);\n\t\tconst summary = checkpointSummary(args.summary, \"checkpoint.summary\");\n\t\tconst artifactIds = dispatchIdentifierArray(args.artifactIds ?? [], \"checkpoint.artifactIds\");\n\t\tconst evidenceIds = dispatchIdentifierArray(args.evidenceIds ?? [], \"checkpoint.evidenceIds\");\n\t\tassertIdentifierListHasCapacity(attempt.checkpointIds, MAX_ORCHESTRATION_CHECKPOINTS, \"attempt checkpoint list\");\n\t\tassertRecordHasCapacity(this.state.checkpoints, MAX_ORCHESTRATION_CHECKPOINTS, \"checkpoint\");\n\t\tconst checkpoint: AttemptCheckpoint = {\n\t\t\tcheckpointId: `checkpoint-${this.createId()}`,\n\t\t\tattemptId: args.attemptId,\n\t\t\tfencingToken: args.fencingToken,\n\t\t\tsummary,\n\t\t\tartifactIds,\n\t\t\tevidenceIds,\n\t\t\t...(args.usage ? { usage: usageFromPayload(args.usage, \"checkpoint.usage\") } : {}),\n\t\t\tcreatedAt: this.nowIso(),\n\t\t};\n\t\tassertAttemptCheckpointTransition(this.state, args.attemptId, checkpoint, args.leaseId, this.nowIso());\n\t\tthis.commit({\n\t\t\ttype: \"attempt.checkpointed\",\n\t\t\taggregateId: args.attemptId,\n\t\t\tactor: \"worker\",\n\t\t\tidempotencyKey: `attempt-checkpointed:${checkpoint.checkpointId}`,\n\t\t\tpayload: toJsonObject({ checkpoint, leaseId: args.leaseId }),\n\t\t});\n\t\treturn structuredClone(checkpoint);\n\t}\n\n\tfinishAttempt(result: WorkerResultContract): AttemptRuntimeState {\n\t\tthis.refresh();\n\t\tassertAttemptFinishTransition(this.state, result.attemptId, result, this.nowIso());\n\t\tthis.commit({\n\t\t\ttype: \"attempt.finished\",\n\t\t\taggregateId: result.attemptId,\n\t\t\tactor: \"worker\",\n\t\t\tidempotencyKey: `attempt-finished:${result.resultId}`,\n\t\t\tpayload: toJsonObject({ result }),\n\t\t});\n\t\treturn structuredClone(this.state.attempts[result.attemptId]!);\n\t}\n\n\tfinishVerification(args: VerificationTransitionInput): TaskRuntimeState {\n\t\tthis.refresh();\n\t\tassertVerificationTransition(this.state, args.taskId, args);\n\t\tthis.commit({\n\t\t\ttype: \"task.verification_finished\",\n\t\t\taggregateId: args.taskId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `task-verification-finished:${args.taskId}:${args.verifierAttemptId}`,\n\t\t\tpayload: toJsonObject({ ...args, reasonCode: args.reasonCode.trim() }),\n\t\t});\n\t\treturn structuredClone(this.state.tasks[args.taskId]!);\n\t}\n\n\tcancelAttempt(attemptId: string, reasonCode: string): AttemptRuntimeState {\n\t\tthis.refresh();\n\t\tconst attempt = this.requireAttempt(attemptId);\n\t\tif (terminalAttemptStatus(attempt.status)) return structuredClone(attempt);\n\t\tif (!reasonCode.trim()) throw new DurableTaskRuntimeError(\"Cancellation reason is required.\");\n\t\tthis.commit({\n\t\t\ttype: \"attempt.cancelled\",\n\t\t\taggregateId: attemptId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `attempt-cancelled:${attemptId}`,\n\t\t\tpayload: toJsonObject({ attemptId, reasonCode: reasonCode.trim() }),\n\t\t});\n\t\treturn structuredClone(this.state.attempts[attemptId]!);\n\t}\n\n\t/**\n\t * The only runtime suspension transition. Callers must present the exact current owner and lease\n\t * fence; liveness/restart policy stays outside this deterministic runtime.\n\t */\n\tsuspendBoundAttempt(args: {\n\t\tattemptId: string;\n\t\townerId: string;\n\t\tleaseId: string;\n\t\tfencingToken: number;\n\t\treasonCode: string;\n\t\tretry?: AttemptRetryState;\n\t}): AttemptRuntimeState {\n\t\tthis.refresh();\n\t\tconst attempt = this.requireAttempt(args.attemptId);\n\t\tif (!attempt.agentId || !attempt.lease || ![\"leased\", \"running\"].includes(attempt.status)) {\n\t\t\tthrow new DurableTaskRuntimeError(`Attempt '${args.attemptId}' is not a live agent-bound attempt.`);\n\t\t}\n\t\tif (attempt.lease.ownerId !== args.ownerId) {\n\t\t\tthrow new DurableTaskRuntimeError(`Attempt '${args.attemptId}' is not owned by '${args.ownerId}'.`);\n\t\t}\n\t\tif (attempt.lease.leaseId !== args.leaseId || attempt.lease.fencingToken !== args.fencingToken) {\n\t\t\tthrow new DurableTaskRuntimeError(`Attempt '${args.attemptId}' lease or fencing token is stale.`);\n\t\t}\n\t\tif (!args.reasonCode.trim()) throw new DurableTaskRuntimeError(\"Suspension reason is required.\");\n\t\tconst retry = args.retry ? retryStateFromValue(args.retry, \"attempt.suspended.retry\") : undefined;\n\t\tif (retry) {\n\t\t\tif (retry.retriesUsed !== (attempt.retry?.retriesUsed ?? 0) + 1) {\n\t\t\t\tthrow new DurableTaskRuntimeError(`Attempt '${args.attemptId}' retry count is not monotonic.`);\n\t\t\t}\n\t\t\tif (Date.parse(retry.notBefore) <= this.now()) {\n\t\t\t\tthrow new DurableTaskRuntimeError(\"Retry not-before deadline must be in the future.\");\n\t\t\t}\n\t\t}\n\t\tthis.commit({\n\t\t\ttype: \"attempt.suspended\",\n\t\t\taggregateId: args.attemptId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `attempt-suspended:${args.attemptId}:${args.leaseId}:${args.fencingToken}`,\n\t\t\tpayload: toJsonObject({\n\t\t\t\tattemptId: args.attemptId,\n\t\t\t\tleaseId: args.leaseId,\n\t\t\t\tfencingToken: args.fencingToken,\n\t\t\t\treasonCode: args.reasonCode.trim(),\n\t\t\t\t...(retry ? { retry } : {}),\n\t\t\t}),\n\t\t});\n\t\treturn structuredClone(this.state.attempts[args.attemptId]!);\n\t}\n\n\tfailTask(taskId: string, reasonCode: string): TaskContract {\n\t\tthis.refresh();\n\t\tconst task = this.state.tasks[taskId];\n\t\tif (!task) throw new DurableTaskRuntimeError(`Unknown task '${taskId}'.`);\n\t\tif ([\"completed\", \"failed\", \"cancelled\"].includes(task.task.status)) return structuredClone(task.task);\n\t\tassertTaskFailureTransition(this.state, taskId, taskId, reasonCode);\n\t\tthis.commit({\n\t\t\ttype: \"task.failed\",\n\t\t\taggregateId: taskId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `task-failed:${taskId}:${reasonCode.trim()}`,\n\t\t\tpayload: toJsonObject({ taskId, reasonCode: reasonCode.trim() }),\n\t\t});\n\t\treturn structuredClone(this.state.tasks[taskId]!.task);\n\t}\n\n\t/**\n\t * Recover unbound in-process work after a process restart. A completion has no resumable model\n\t * transcript, so its old lease is fenced and the task becomes dispatchable for a fresh attempt.\n\t * Agent-bound attempts are intentionally excluded: those must wake the same logical agent.\n\t */\n\trecoverInterruptedUnboundAttempts(shouldRecover: (attempt: AttemptRuntimeState) => boolean = () => true): string[] {\n\t\tthis.refresh();\n\t\tconst recovered: string[] = [];\n\t\tfor (const attempt of Object.values(this.state.attempts)) {\n\t\t\tif (\n\t\t\t\t(attempt.status !== \"leased\" && attempt.status !== \"running\") ||\n\t\t\t\tattempt.agentId ||\n\t\t\t\t!shouldRecover(attempt)\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthis.commit({\n\t\t\t\ttype: \"attempt.lease_expired\",\n\t\t\t\taggregateId: attempt.attemptId,\n\t\t\t\tactor: \"runtime\",\n\t\t\t\tidempotencyKey: `attempt-process-interrupted:${attempt.attemptId}:${attempt.lease?.leaseId ?? \"none\"}`,\n\t\t\t\tpayload: toJsonObject({\n\t\t\t\t\tattemptId: attempt.attemptId,\n\t\t\t\t\t...(attempt.lease ? { leaseId: attempt.lease.leaseId, fencingToken: attempt.lease.fencingToken } : {}),\n\t\t\t\t\treasonCode: \"worker_process_interrupted\",\n\t\t\t\t}),\n\t\t\t});\n\t\t\trecovered.push(attempt.attemptId);\n\t\t}\n\t\treturn recovered;\n\t}\n\n\texpireLeases(at = this.now()): string[] {\n\t\tthis.refresh();\n\t\tconst expired: string[] = [];\n\t\tfor (const attempt of Object.values(this.state.attempts)) {\n\t\t\tif ((attempt.status !== \"leased\" && attempt.status !== \"running\") || !attempt.lease) continue;\n\t\t\tif (Date.parse(attempt.lease.expiresAt) > at) continue;\n\t\t\tthis.commit({\n\t\t\t\ttype: attempt.agentId ? \"attempt.suspended\" : \"attempt.lease_expired\",\n\t\t\t\taggregateId: attempt.attemptId,\n\t\t\t\tactor: \"runtime\",\n\t\t\t\tidempotencyKey: `attempt-lease-expired:${attempt.lease.leaseId}`,\n\t\t\t\tpayload: toJsonObject({\n\t\t\t\t\tattemptId: attempt.attemptId,\n\t\t\t\t\tleaseId: attempt.lease.leaseId,\n\t\t\t\t\tfencingToken: attempt.lease.fencingToken,\n\t\t\t\t}),\n\t\t\t});\n\t\t\texpired.push(attempt.attemptId);\n\t\t}\n\t\treturn expired;\n\t}\n\n\trequestAgentResume(agentId: string, attemptId: string): AgentBindingContract {\n\t\tthis.refresh();\n\t\tconst agent = this.state.agents[agentId];\n\t\tif (!agent) throw new DurableTaskRuntimeError(`Unknown agent '${agentId}'.`);\n\t\tassertAgentNotRetired(agent, \"request resume\");\n\t\tconst attempt = this.requireAttempt(attemptId);\n\t\tif (attempt.status !== \"suspended\" || attempt.agentId !== agentId || agent.activeAttemptId !== attemptId) {\n\t\t\tthrow new DurableTaskRuntimeError(`Agent '${agentId}' cannot resume suspended attempt '${attemptId}'.`);\n\t\t}\n\t\tthis.assertRetryBackoffElapsed(attempt);\n\t\tthis.requireActiveObjectiveForAttempt(attempt);\n\t\tif (agent.status === \"resuming\") return structuredClone(agent);\n\t\tif (agent.status !== \"suspended\") throw new DurableTaskRuntimeError(`Agent '${agentId}' is not suspended.`);\n\t\tthis.commit({\n\t\t\ttype: \"agent.resume_requested\",\n\t\t\taggregateId: agentId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `agent-resume-requested:${agentId}:${this.state.lastOrdinal}`,\n\t\t\tpayload: toJsonObject({ agentId, attemptId }),\n\t\t});\n\t\treturn structuredClone(this.state.agents[agentId]!);\n\t}\n\n\t/** Read-only guard used before changing agent state; resumeAttempt repeats it authoritatively. */\n\tassertAttemptReadyForResume(attemptId: string): void {\n\t\tthis.refresh();\n\t\tthis.assertRetryBackoffElapsed(this.requireAttempt(attemptId));\n\t}\n\n\tresumeAttempt(attemptId: string, agentId: string, ttlMs: number, ownerId = agentId): AttemptLease {\n\t\tthis.refresh();\n\t\tconst attempt = this.requireAttempt(attemptId);\n\t\tconst agent = this.state.agents[agentId];\n\t\tif (attempt.status !== \"suspended\" || attempt.agentId !== agentId) {\n\t\t\tthrow new DurableTaskRuntimeError(`Attempt '${attemptId}' is not suspended for agent '${agentId}'.`);\n\t\t}\n\t\tif (!agent || agent.status !== \"resuming\")\n\t\t\tthrow new DurableTaskRuntimeError(`Agent '${agentId}' is not resuming.`);\n\t\tthis.assertRetryBackoffElapsed(attempt);\n\t\tthis.requireActiveObjectiveForAttempt(attempt);\n\t\tconst lease = this.issueLease(attempt, ownerId, ttlMs);\n\t\tthis.commit({\n\t\t\ttype: \"attempt.resumed\",\n\t\t\taggregateId: attemptId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `attempt-resumed:${lease.leaseId}`,\n\t\t\tpayload: toJsonObject({ agentId, lease }),\n\t\t});\n\t\treturn structuredClone(lease);\n\t}\n\n\tpauseObjective(objectiveId: string): void {\n\t\tthis.transitionObjective(objectiveId, \"objective.paused\", \"paused\");\n\t}\n\n\tresumeObjective(objectiveId: string): void {\n\t\tthis.transitionObjective(objectiveId, \"objective.resumed\", \"active\");\n\t}\n\n\tcancelObjective(objectiveId: string): void {\n\t\tthis.transitionObjective(objectiveId, \"objective.cancelled\", \"cancelled\");\n\t}\n\n\tcompleteObjective(objectiveId: string): void {\n\t\tthis.transitionObjective(objectiveId, \"objective.completed\", \"completed\", {\n\t\t\tcompletionPolicy: \"task_evidence\",\n\t\t});\n\t}\n\n\tcompleteObjectiveFromOwner(objectiveId: string, acceptanceOverride: boolean): void {\n\t\tthis.refresh();\n\t\tconst objective = this.requireObjective(objectiveId);\n\t\tif (objective.objective.status === \"completed\") return;\n\t\tif (objective.objective.status === \"cancelled\") {\n\t\t\tthrow new DurableTaskRuntimeError(`Objective '${objectiveId}' is terminal.`);\n\t\t}\n\t\tthis.transitionObjective(objectiveId, \"objective.completed\", \"completed\", {\n\t\t\tcompletionPolicy: acceptanceOverride ? \"owner_override\" : \"owner_evidence\",\n\t\t});\n\t}\n\n\trequestApproval(approval: ApprovalRequestContract): ApprovalRuntimeState {\n\t\tthis.refresh();\n\t\tconst normalized = approvalFromPayload(toJsonObject({ approval }));\n\t\tconst existing = this.state.approvals[normalized.approvalId];\n\t\tif (existing) {\n\t\t\tif (!isDeepStrictEqual(existing.request, normalized)) {\n\t\t\t\tthrow new DurableTaskRuntimeError(`Approval id '${normalized.approvalId}' has conflicting content.`);\n\t\t\t}\n\t\t\treturn structuredClone(existing);\n\t\t}\n\t\tassertApprovalRequestTransition(\n\t\t\tthis.state,\n\t\t\tnormalized.attemptId ?? normalized.taskId ?? normalized.objectiveId,\n\t\t\tnormalized,\n\t\t);\n\t\tassertRecordHasCapacity(this.state.approvals, MAX_ORCHESTRATION_APPROVALS, \"approval\");\n\t\tassertRecordHasCapacity(this.state.notifications, MAX_ORCHESTRATION_NOTIFICATIONS, \"notification\");\n\t\tthis.commit({\n\t\t\ttype: \"approval.requested\",\n\t\t\taggregateId: normalized.attemptId ?? normalized.taskId ?? normalized.objectiveId,\n\t\t\tactor: \"policy\",\n\t\t\tidempotencyKey: `approval-requested:${normalized.approvalId}`,\n\t\t\tpayload: toJsonObject({ approval: normalized }),\n\t\t});\n\t\treturn structuredClone(this.state.approvals[normalized.approvalId]!);\n\t}\n\n\tresolveApproval(approvalId: string, outcome: ApprovalOutcome, reasonCode: string): ApprovalRuntimeState {\n\t\tthis.refresh();\n\t\tconst approval = this.state.approvals[approvalId];\n\t\tif (!approval) throw new DurableTaskRuntimeError(`Unknown approval '${approvalId}'.`);\n\t\tif (approval.status !== \"pending\") {\n\t\t\tif (approval.status === outcome) return structuredClone(approval);\n\t\t\tthrow new DurableTaskRuntimeError(`Approval '${approvalId}' was already ${approval.status}.`);\n\t\t}\n\t\tif (outcome !== \"approved\" && outcome !== \"rejected\") {\n\t\t\tthrow new DurableTaskRuntimeError(`Unknown approval outcome '${String(outcome)}'.`);\n\t\t}\n\t\tif (!reasonCode.trim()) throw new DurableTaskRuntimeError(\"Approval resolution reason is required.\");\n\t\tconst resolution: ApprovalResolutionContract = {\n\t\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\t\tapprovalId,\n\t\t\toutcome,\n\t\t\treasonCode: reasonCode.trim(),\n\t\t\tresolvedAt: this.nowIso(),\n\t\t};\n\t\tassertApprovalResolutionTransition(\n\t\t\tthis.state,\n\t\t\tapproval.request.attemptId ?? approval.request.taskId ?? approval.request.objectiveId,\n\t\t\tresolution,\n\t\t);\n\t\tthis.commit({\n\t\t\ttype: \"approval.resolved\",\n\t\t\taggregateId: approval.request.attemptId ?? approval.request.taskId ?? approval.request.objectiveId,\n\t\t\tactor: \"human\",\n\t\t\tidempotencyKey: `approval-resolved:${approvalId}`,\n\t\t\tpayload: toJsonObject({ resolution }),\n\t\t});\n\t\treturn structuredClone(this.state.approvals[approvalId]!);\n\t}\n\n\tenqueueNotification(args: {\n\t\tnotificationId?: string;\n\t\tobjectiveId: string;\n\t\tattemptId?: string;\n\t\tmessage: string;\n\t}): NotificationRuntimeState {\n\t\tthis.refresh();\n\t\tassertNotificationTarget(this.state, args.objectiveId, args.attemptId);\n\t\tconst notificationId = args.notificationId ?? `notification-${this.createId()}`;\n\t\tconst existing = this.state.notifications[notificationId];\n\t\tif (existing) {\n\t\t\tif (\n\t\t\t\texisting.objectiveId !== args.objectiveId ||\n\t\t\t\texisting.attemptId !== args.attemptId ||\n\t\t\t\texisting.message !== args.message\n\t\t\t) {\n\t\t\t\tthrow new DurableTaskRuntimeError(`Notification id '${notificationId}' has conflicting content.`);\n\t\t\t}\n\t\t\treturn structuredClone(existing);\n\t\t}\n\t\tassertRecordHasCapacity(this.state.notifications, MAX_ORCHESTRATION_NOTIFICATIONS, \"notification\");\n\t\tthis.commit({\n\t\t\ttype: \"notification.enqueued\",\n\t\t\taggregateId: args.objectiveId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `notification-enqueued:${notificationId}`,\n\t\t\tpayload: toJsonObject({ ...args, notificationId }),\n\t\t});\n\t\treturn structuredClone(this.state.notifications[notificationId]!);\n\t}\n\n\tmarkNotificationDelivered(notificationId: string): NotificationRuntimeState {\n\t\tthis.refresh();\n\t\tconst notification = this.state.notifications[notificationId];\n\t\tif (!notification) throw new DurableTaskRuntimeError(`Unknown notification '${notificationId}'.`);\n\t\tif (notification.status === \"delivered\") return structuredClone(notification);\n\t\tthis.commit({\n\t\t\ttype: \"notification.delivered\",\n\t\t\taggregateId: notification.objectiveId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `notification-delivered:${notificationId}`,\n\t\t\tpayload: toJsonObject({ notificationId }),\n\t\t});\n\t\treturn structuredClone(this.state.notifications[notificationId]!);\n\t}\n\n\tprivate buildTask(input: CreateTaskInput): { task: TaskContract; objectiveState: ObjectiveRuntimeState } {\n\t\tassertRiskBudget(input.riskBudget, \"task.riskBudget\");\n\t\tconst objectiveState = this.state.objectives[input.objectiveId];\n\t\tif (!objectiveState) throw new DurableTaskRuntimeError(`Unknown objective '${input.objectiveId}'.`);\n\t\tif (objectiveState.objective.status !== \"active\") {\n\t\t\tthrow new DurableTaskRuntimeError(`Objective '${input.objectiveId}' is not active.`);\n\t\t}\n\t\tconst dependsOn = validateTaskDependencyIds(this.state.tasks, input.objectiveId, input.dependsOn);\n\t\tconst acceptanceCriterionIds = [...new Set(input.acceptanceCriterionIds ?? [])];\n\t\tconst now = this.nowIso();\n\t\tconst task = taskFromValue(\n\t\t\t{\n\t\t\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\t\t\ttaskId: input.taskId ?? `task-${this.createId()}`,\n\t\t\t\tobjectiveId: input.objectiveId,\n\t\t\t\ttitle: input.title.trim(),\n\t\t\t\tdescription: input.description.trim(),\n\t\t\t\trole: input.role,\n\t\t\t\tstatus: dependsOn.length === 0 ? \"ready\" : \"pending\",\n\t\t\t\tdependsOn,\n\t\t\t\trequiredCapabilities: [...new Set(input.requiredCapabilities ?? [])],\n\t\t\t\tacceptanceCriterionIds,\n\t\t\t\t...(input.verificationOfTaskId ? { verificationOfTaskId: input.verificationOfTaskId } : {}),\n\t\t\t\triskBudget: { ...(input.riskBudget ?? {}) },\n\t\t\t\tcreatedAt: now,\n\t\t\t\tupdatedAt: now,\n\t\t\t},\n\t\t\t\"task\",\n\t\t);\n\t\tif (this.state.tasks[task.taskId]) throw new DurableTaskRuntimeError(`Task '${task.taskId}' already exists.`);\n\t\tvalidateTaskContractForState(this.state, task, `Task '${task.taskId}'`);\n\t\treturn { task, objectiveState };\n\t}\n\n\tprivate normalizeDispatchForTask(\n\t\ttask: TaskRuntimeState,\n\t\tdispatch: OrchestrationDispatchRequest,\n\t): OrchestrationDispatchRequest {\n\t\tconst normalizedDispatch = dispatchFromValue(dispatch, \"dispatch\");\n\t\tif (normalizedDispatch.taskId !== task.task.taskId) {\n\t\t\tthrow new DurableTaskRuntimeError(\"Dispatch taskId does not match the queued task.\");\n\t\t}\n\t\tif (\n\t\t\tnormalizedDispatch.executionContract &&\n\t\t\t(normalizedDispatch.executionContract.worker.profile.profileId !== normalizedDispatch.profileId ||\n\t\t\t\tnormalizedDispatch.executionContract.worker.profile.role !== task.task.role)\n\t\t) {\n\t\t\tthrow new DurableTaskRuntimeError(\"Execution contract does not match the dispatch profile and task role.\");\n\t\t}\n\t\treturn normalizedDispatch;\n\t}\n\n\tprivate assertTaskAttemptBudget(task: TaskRuntimeState, objective: ObjectiveContract): void {\n\t\tassertTaskAttemptBudgetForState(task, objective);\n\t}\n\n\tprivate transitionObjective(\n\t\tobjectiveId: string,\n\t\ttype: \"objective.paused\" | \"objective.resumed\" | \"objective.cancelled\" | \"objective.completed\",\n\t\ttarget: ObjectiveStatus,\n\t\tpayload: JsonObject = {},\n\t): void {\n\t\tthis.refresh();\n\t\tconst objective = this.requireObjective(objectiveId);\n\t\tif (objective.objective.status === target) return;\n\t\tassertObjectiveStatusTransition(\n\t\t\tthis.state,\n\t\t\tobjectiveId,\n\t\t\ttarget,\n\t\t\ttype === \"objective.completed\"\n\t\t\t\t? (payload.completionPolicy as ObjectiveCompletionPolicy | undefined)\n\t\t\t\t: undefined,\n\t\t);\n\t\tthis.commit({\n\t\t\ttype,\n\t\t\taggregateId: objectiveId,\n\t\t\tactor: \"human\",\n\t\t\tidempotencyKey: `${type}:${objectiveId}:${this.state.lastOrdinal}`,\n\t\t\tpayload,\n\t\t});\n\t}\n\n\tprivate requireObjective(objectiveId: string): ObjectiveRuntimeState {\n\t\tconst objective = this.state.objectives[objectiveId];\n\t\tif (!objective) throw new DurableTaskRuntimeError(`Unknown objective '${objectiveId}'.`);\n\t\treturn objective;\n\t}\n\n\tprivate requireDispatchableTask(taskId: string): TaskRuntimeState {\n\t\tconst task = this.state.tasks[taskId];\n\t\tif (!task) throw new DurableTaskRuntimeError(`Unknown task '${taskId}'.`);\n\t\tconst objective = this.requireObjective(task.task.objectiveId);\n\t\tif (objective.objective.status !== \"active\") {\n\t\t\tthrow new DurableTaskRuntimeError(`Objective '${objective.objective.objectiveId}' is not active.`);\n\t\t}\n\t\tif (![\"pending\", \"ready\", \"blocked\", \"failed\"].includes(task.task.status)) {\n\t\t\tthrow new DurableTaskRuntimeError(`Task '${taskId}' is not dispatchable from '${task.task.status}'.`);\n\t\t}\n\t\tconst active = activeTaskAttempt(this.state, task);\n\t\tif (active) {\n\t\t\tthrow new DurableTaskRuntimeError(`Task '${taskId}' already owns active attempt '${active.attemptId}'.`);\n\t\t}\n\t\treturn task;\n\t}\n\n\tprivate requireAttempt(attemptId: string): AttemptRuntimeState {\n\t\tconst attempt = this.state.attempts[attemptId];\n\t\tif (!attempt) throw new DurableTaskRuntimeError(`Unknown attempt '${attemptId}'.`);\n\t\treturn attempt;\n\t}\n\n\tprivate issueLease(attempt: AttemptRuntimeState, ownerId: string, ttlMs: number): AttemptLease {\n\t\tif (!Number.isFinite(ttlMs) || ttlMs <= 0) throw new DurableTaskRuntimeError(\"Lease TTL must be positive.\");\n\t\tconst issuedAtMs = this.now();\n\t\tconst expiresAtMs = issuedAtMs + Math.min(ttlMs, MAX_DATE_EPOCH_MS - issuedAtMs);\n\t\treturn {\n\t\t\tleaseId: `lease-${this.createId()}`,\n\t\t\tattemptId: attempt.attemptId,\n\t\t\townerId,\n\t\t\tfencingToken: (attempt.lease?.fencingToken ?? 0) + 1,\n\t\t\tissuedAt: new Date(issuedAtMs).toISOString(),\n\t\t\texpiresAt: new Date(expiresAtMs).toISOString(),\n\t\t};\n\t}\n\n\tprivate pendingApprovalForTask(taskId: string): ApprovalRuntimeState | undefined {\n\t\tconst task = this.state.tasks[taskId];\n\t\tif (!task) return undefined;\n\t\treturn Object.values(this.state.approvals).find(\n\t\t\t(approval) =>\n\t\t\t\tapproval.status === \"pending\" &&\n\t\t\t\tapproval.request.attemptId === undefined &&\n\t\t\t\tapproval.request.objectiveId === task.task.objectiveId &&\n\t\t\t\t(approval.request.taskId === undefined || approval.request.taskId === taskId),\n\t\t);\n\t}\n\n\tprivate requireActiveObjectiveForAttempt(attempt: AttemptRuntimeState): void {\n\t\trequireActiveObjectiveForAttemptInProjection(this.state, attempt);\n\t}\n\n\tprivate assertRetryBackoffElapsed(attempt: AttemptRuntimeState): void {\n\t\tassertRetryBackoffElapsedAt(attempt, this.now());\n\t}\n\n\tprivate requireLiveLease(attemptId: string, leaseId: string, fencingToken: number): AttemptRuntimeState {\n\t\tconst attempt = this.requireAttempt(attemptId);\n\t\tif (!attempt.lease || attempt.lease.leaseId !== leaseId || attempt.lease.fencingToken !== fencingToken) {\n\t\t\tthrow new DurableTaskRuntimeError(`Attempt '${attemptId}' lease or fencing token is stale.`);\n\t\t}\n\t\tif (Date.parse(attempt.lease.expiresAt) <= this.now()) {\n\t\t\tthrow new DurableTaskRuntimeError(`Attempt '${attemptId}' lease expired.`);\n\t\t}\n\t\treturn attempt;\n\t}\n\n\tprivate refresh(): void {\n\t\tlet events: OrchestrationEvent[];\n\t\ttry {\n\t\t\tevents = this.store.readAfter(this.state.lastOrdinal);\n\t\t} catch (error) {\n\t\t\tif (!(error instanceof OrchestrationSnapshotRequiredError)) throw error;\n\t\t\tconst snapshot = this.store.readProjectionSnapshot();\n\t\t\tif (!snapshot || snapshot.throughOrdinal < error.throughOrdinal) {\n\t\t\t\tthrow new DurableTaskRuntimeError(\"Required orchestration projection snapshot is unavailable.\");\n\t\t\t}\n\t\t\tthis.state = projectionFromSnapshot(snapshot.projection, snapshot.throughOrdinal);\n\t\t\tevents = this.store.readAfter(this.state.lastOrdinal);\n\t\t}\n\t\tfor (const event of events) {\n\t\t\tthis.state = reduceOrchestrationEvent(this.state, event);\n\t\t}\n\t\tthis.compactCurrentProjection();\n\t}\n\n\tprivate commit(input: AppendOrchestrationEventInput): void {\n\t\tthis.compactCurrentProjection();\n\t\tlet admittedProjection: TaskRuntimeProjection | undefined;\n\t\tconst event = this.store.append(input, {\n\t\t\texpectedLastOrdinal: this.state.lastOrdinal,\n\t\t\tvalidateBeforeCommit: (candidate) => {\n\t\t\t\tif (candidate.ordinal > this.state.lastOrdinal) {\n\t\t\t\t\tadmittedProjection = reduceOrchestrationEvent(this.state, candidate);\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t\tif (admittedProjection) {\n\t\t\tthis.state = admittedProjection;\n\t\t\treturn;\n\t\t}\n\t\t// Exact idempotent replay can return an older event after another writer committed a\n\t\t// contiguous suffix. Adopt through readAfter so no intervening ordinal is skipped. Test stores\n\t\t// that do not execute append admission still fall back to reducing their returned next event.\n\t\tif (event.ordinal > this.state.lastOrdinal) this.refresh();\n\t\tif (event.ordinal > this.state.lastOrdinal) this.state = reduceOrchestrationEvent(this.state, event);\n\t}\n\n\tprivate compactCurrentProjection(): void {\n\t\tif (this.state.lastOrdinal > 0) {\n\t\t\tthis.store.compactIfNeeded(this.state.lastOrdinal, () => toJsonObject(this.state));\n\t\t}\n\t}\n\n\tprivate nowIso(): string {\n\t\treturn new Date(this.now()).toISOString();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"task-runtime.js","sourceRoot":"","sources":["../../../src/core/orchestration/task-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAYN,gCAAgC,EAChC,2BAA2B,EAC3B,0BAA0B,EAC1B,6BAA6B,EAC7B,+BAA+B,EAC/B,oCAAoC,EACpC,4BAA4B,EAC5B,uBAAuB,EAGvB,4BAA4B,EAI5B,YAAY,GAEZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAgC,kCAAkC,EAAE,MAAM,kBAAkB,CAAC;AACpG,OAAO,EACN,mBAAmB,EACnB,wBAAwB,EACxB,0CAA0C,EAC1C,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,EACvB,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,EACnB,aAAa,EACb,gBAAgB,EAChB,4BAA4B,EAC5B,yBAAyB,GACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,2BAA2B,EAC3B,+BAA+B,EAC/B,kCAAkC,EAClC,6CAA6C,EAC7C,uBAAuB,EACvB,eAAe,EACf,kBAAkB,EAClB,wBAAwB,GACxB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,iBAAiB,EACjB,qBAAqB,EACrB,6BAA6B,EAC7B,+BAA+B,EAC/B,kCAAkC,EAClC,iCAAiC,EACjC,6BAA6B,EAC7B,4BAA4B,EAC5B,mC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CAAC;IAEO,wBAAwB;QAC/B,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,CAAC,EAAE,CAAC;YAChC,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QACpF,CAAC;IACF,CAAC;IAEO,MAAM;QACb,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAC3C,CAAC;CACD","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { isDeepStrictEqual } from \"node:util\";\nimport type { JsonObject } from \"../autonomy/contracts.ts\";\nimport { createAgentIdentity } from \"./agent-resume.ts\";\nimport {\n\ttype AgentBindingContract,\n\ttype AgentIdentityContract,\n\ttype AppendOrchestrationEventInput,\n\ttype ApprovalOutcome,\n\ttype ApprovalRequestContract,\n\ttype ApprovalResolutionContract,\n\ttype AttemptCheckpoint,\n\ttype AttemptLease,\n\ttype AttemptRetryState,\n\ttype EvidenceContract,\n\ttype ExecutionGrant,\n\tMAX_ORCHESTRATION_AGENT_BINDINGS,\n\tMAX_ORCHESTRATION_APPROVALS,\n\tMAX_ORCHESTRATION_ATTEMPTS,\n\tMAX_ORCHESTRATION_CHECKPOINTS,\n\tMAX_ORCHESTRATION_NOTIFICATIONS,\n\tMAX_ORCHESTRATION_OBJECTIVE_EVIDENCE,\n\tMAX_ORCHESTRATION_OBJECTIVES,\n\tMAX_ORCHESTRATION_TASKS,\n\ttype ObjectiveContract,\n\ttype ObjectiveStatus,\n\tORCHESTRATION_SCHEMA_VERSION,\n\ttype OrchestrationDispatchRequest,\n\ttype OrchestrationEvent,\n\ttype TaskContract,\n\ttoJsonObject,\n\ttype WorkerResultContract,\n} from \"./contracts.ts\";\nimport { type OrchestrationEventStore, OrchestrationSnapshotRequiredError } from \"./event-store.ts\";\nimport {\n\tapprovalFromPayload,\n\tassertAcceptanceCriteria,\n\tassertReferencedAcceptanceCriteriaRetained,\n\tassertRiskBudget,\n\tcheckpointSummary,\n\tdispatchFromValue,\n\tdispatchIdentifier,\n\tdispatchIdentifierArray,\n\texecutionGrantFromValue,\n\tMAX_DATE_EPOCH_MS,\n\tprojectionFromSnapshot,\n\tretryStateFromValue,\n\ttaskFromValue,\n\tusageFromPayload,\n\tvalidateTaskContractForState,\n\tvalidateTaskDependencyIds,\n} from \"./task-runtime-codecs.ts\";\nimport {\n\tassertBoundedIdentifierList,\n\tassertIdentifierListHasCapacity,\n\tassertObjectiveEvidenceHasCapacity,\n\tassertProjectionRecordReplacementWithinLimits,\n\tassertRecordHasCapacity,\n\tcloneProjection,\n\tprojectionCapacity,\n\trequestedProjectionSlots,\n} from \"./task-runtime-projection.ts\";\nimport {\n\tactiveTaskAttempt,\n\tassertAgentNotRetired,\n\tassertAgentRetirementEligible,\n\tassertApprovalRequestTransition,\n\tassertApprovalResolutionTransition,\n\tassertAttemptCheckpointTransition,\n\tassertAttemptFinishTransition,\n\tassertAttemptGrantTransition,\n\tassertAttemptLeaseRenewalTransition,\n\tassertAttemptLeaseTransition,\n\tassertAttemptStartTransition,\n\tassertNotificationTarget,\n\tassertObjectiveStatusTransition,\n\tassertRetryBackoffElapsedAt,\n\tassertTaskAttemptBudgetForState,\n\tassertTaskFailureTransition,\n\tassertVerificationTransition,\n\tattemptDispatchReadiness,\n\ttype ObjectiveCompletionPolicy,\n\tprojectOrchestrationEvents,\n\treduceOrchestrationEvent,\n\trequireActiveObjectiveForAttemptInProjection,\n\ttype VerificationTransitionInput,\n} from \"./task-runtime-reducer.ts\";\nimport {\n\ttype ApprovalRuntimeState,\n\ttype AttemptDispatchReadiness,\n\ttype AttemptRuntimeState,\n\ttype CreateObjectiveInput,\n\ttype CreateTaskInput,\n\tDurableTaskRuntimeError,\n\ttype NotificationRuntimeState,\n\ttype ObjectiveRuntimeState,\n\ttype OrchestrationProjectionCapacity,\n\ttype OrchestrationProjectionHeadroomRequest,\n\ttype PreparedTaskAttempt,\n\ttype RegisterAgentInput,\n\ttype TaskRuntimeProjection,\n\ttype TaskRuntimeState,\n\tterminalAttemptStatus,\n} from \"./task-runtime-state.ts\";\n\nexport { validateTaskDependencyIds } from \"./task-runtime-codecs.ts\";\nexport {\n\tprojectOrchestrationEvents,\n\treduceOrchestrationEvent,\n} from \"./task-runtime-reducer.ts\";\nexport {\n\ttype ApprovalRuntimeState,\n\ttype AttemptDispatchReadiness,\n\ttype AttemptRuntimeState,\n\ttype CreateObjectiveInput,\n\ttype CreateTaskInput,\n\tDurableTaskRuntimeError,\n\ttype NotificationRuntimeState,\n\ttype ObjectiveRuntimeState,\n\ttype OrchestrationProjectionCapacity,\n\ttype OrchestrationProjectionHeadroomRequest,\n\ttype OrchestrationProjectionSlotCounts,\n\ttype PreparedTaskAttempt,\n\ttype RegisterAgentInput,\n\ttype TaskRuntimeProjection,\n\ttype TaskRuntimeState,\n} from \"./task-runtime-state.ts\";\n\nexport interface DurableTaskRuntimeOptions {\n\tstore: OrchestrationEventStore;\n\tnow?: () => number;\n\tcreateId?: () => string;\n}\n\nexport class DurableTaskRuntime {\n\tprivate readonly store: OrchestrationEventStore;\n\tprivate readonly now: () => number;\n\tprivate readonly createId: () => string;\n\tprivate state: TaskRuntimeProjection;\n\n\tconstructor(options: DurableTaskRuntimeOptions) {\n\t\tthis.store = options.store;\n\t\tthis.now = options.now ?? (() => Date.now());\n\t\tthis.createId = options.createId ?? randomUUID;\n\t\tconst snapshot = this.store.readProjectionSnapshot();\n\t\tif (snapshot) {\n\t\t\tthis.state = projectionFromSnapshot(snapshot.projection, snapshot.throughOrdinal);\n\t\t} else {\n\t\t\tconst events = this.store.readAll();\n\t\t\t// Compaction may install a baseline between the first snapshot read and readAll(). In that\n\t\t\t// case readAll() returns only the new tail, which must be applied to that baseline rather\n\t\t\t// than projected as a standalone history.\n\t\t\tconst snapshotAfterRead = this.store.readProjectionSnapshot();\n\t\t\tthis.state = snapshotAfterRead\n\t\t\t\t? events\n\t\t\t\t\t\t.filter((event) => event.ordinal > snapshotAfterRead.throughOrdinal)\n\t\t\t\t\t\t.reduce(\n\t\t\t\t\t\t\treduceOrchestrationEvent,\n\t\t\t\t\t\t\tprojectionFromSnapshot(snapshotAfterRead.projection, snapshotAfterRead.throughOrdinal),\n\t\t\t\t\t\t)\n\t\t\t\t: projectOrchestrationEvents(events);\n\t\t}\n\t\tthis.refresh();\n\t}\n\n\tgetSnapshot(): TaskRuntimeProjection {\n\t\tthis.refresh();\n\t\treturn cloneProjection(this.state);\n\t}\n\n\t/** Read-only retained-record counts and remaining lifetime slots for orchestration admission. */\n\tgetProjectionCapacity(): OrchestrationProjectionCapacity {\n\t\tthis.refresh();\n\t\treturn projectionCapacity(this.state);\n\t}\n\n\t/**\n\t * Preflight every record needed by a multi-event operation before its first append. Callers use\n\t * this to reserve implementation and mandatory-verifier task/attempt pairs atomically.\n\t */\n\tassertProjectionHeadroom(required: OrchestrationProjectionHeadroomRequest): OrchestrationProjectionCapacity {\n\t\tthis.refresh();\n\t\tconst capacity = projectionCapacity(this.state);\n\t\tconst agents = requestedProjectionSlots(required.agents, \"Agent binding\");\n\t\tconst objectives = requestedProjectionSlots(required.objectives, \"Objective\");\n\t\tconst tasks = requestedProjectionSlots(required.tasks, \"Task\");\n\t\tconst attempts = requestedProjectionSlots(required.attempts, \"Attempt\");\n\t\tconst checkpoints = requestedProjectionSlots(required.checkpoints, \"Checkpoint\");\n\t\tconst approvals = requestedProjectionSlots(required.approvals, \"Approval\");\n\t\tconst notifications = requestedProjectionSlots(required.notifications, \"Notification\");\n\t\tconst evidence = requestedProjectionSlots(required.evidence, \"Evidence\");\n\t\tif (agents > capacity.headroom.agents) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`Orchestration agent binding limit (${capacity.limits.agents}) lacks ${agents} required slots.`,\n\t\t\t);\n\t\t}\n\t\tif (tasks > capacity.headroom.tasks) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`Orchestration task limit (${capacity.limits.tasks}) lacks ${tasks} required slots.`,\n\t\t\t);\n\t\t}\n\t\tif (attempts > capacity.headroom.attempts) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`Orchestration attempt limit (${capacity.limits.attempts}) lacks ${attempts} required slots.`,\n\t\t\t);\n\t\t}\n\t\tif (objectives > capacity.headroom.objectives) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`Orchestration objective limit (${capacity.limits.objectives}) lacks ${objectives} required slots.`,\n\t\t\t);\n\t\t}\n\t\tif (checkpoints > capacity.headroom.checkpoints) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`Orchestration checkpoint limit (${capacity.limits.checkpoints}) lacks ${checkpoints} required slots.`,\n\t\t\t);\n\t\t}\n\t\tif (approvals > capacity.headroom.approvals) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`Orchestration approval limit (${capacity.limits.approvals}) lacks ${approvals} required slots.`,\n\t\t\t);\n\t\t}\n\t\tif (notifications > capacity.headroom.notifications) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`Orchestration notification limit (${capacity.limits.notifications}) lacks ${notifications} required slots.`,\n\t\t\t);\n\t\t}\n\t\tif (evidence > capacity.headroom.evidence) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`Orchestration evidence limit (${capacity.limits.evidence}) lacks ${evidence} required slots.`,\n\t\t\t);\n\t\t}\n\t\treturn capacity;\n\t}\n\n\t/**\n\t * Preflight the idempotent evidence batch for one objective before synchronizing any member.\n\t * The objective may be absent when its creation is part of the same compound operation.\n\t */\n\tassertObjectiveEvidenceHeadroom(objectiveId: string, evidenceIds: readonly string[]): number {\n\t\tthis.refresh();\n\t\tassertBoundedIdentifierList(evidenceIds, MAX_ORCHESTRATION_OBJECTIVE_EVIDENCE, \"Objective evidence ids\");\n\t\tconst objective = this.state.objectives[objectiveId];\n\t\tconst existingIds = new Set(objective?.evidence.map((evidence) => evidence.evidenceId) ?? []);\n\t\tlet required = 0;\n\t\tfor (const evidenceId of evidenceIds) {\n\t\t\tif (!existingIds.has(evidenceId)) required += 1;\n\t\t}\n\t\tif ((objective?.evidence.length ?? 0) + required > MAX_ORCHESTRATION_OBJECTIVE_EVIDENCE) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`Orchestration objective evidence limit (${MAX_ORCHESTRATION_OBJECTIVE_EVIDENCE}) lacks ${required} required slots.`,\n\t\t\t);\n\t\t}\n\t\tconst capacity = projectionCapacity(this.state);\n\t\tif (required > capacity.headroom.evidence) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`Orchestration evidence limit (${capacity.limits.evidence}) lacks ${required} required slots.`,\n\t\t\t);\n\t\t}\n\t\treturn required;\n\t}\n\n\t/**\n\t * Preflight the final retained objective record for a multi-event owner synchronization. This\n\t * validates the objective metadata and the complete idempotently merged evidence batch before\n\t * ensureObjective can append the first event, so a later byte rejection cannot leave a prefix.\n\t */\n\tassertObjectiveSynchronizationHeadroom(\n\t\tinput: CreateObjectiveInput & { objectiveId: string },\n\t\tevidence: readonly EvidenceContract[],\n\t): void {\n\t\tthis.refresh();\n\t\tconst objectiveId = dispatchIdentifier(input.objectiveId, \"objective.objectiveId\");\n\t\tconst current = this.state.objectives[objectiveId];\n\t\tconst requiredEvidence = this.assertObjectiveEvidenceHeadroom(\n\t\t\tobjectiveId,\n\t\t\tevidence.map((item) => item.evidenceId),\n\t\t);\n\t\tthis.assertProjectionHeadroom({ objectives: current ? 0 : 1, evidence: requiredEvidence });\n\t\tassertRiskBudget(input.riskBudget, \"objective.riskBudget\");\n\t\tconst acceptanceCriteria = structuredClone(input.acceptanceCriteria ?? []);\n\t\tassertAcceptanceCriteria(acceptanceCriteria);\n\t\tconst title = input.title.trim();\n\t\tconst description = input.description.trim();\n\t\tif (!title || !description) throw new DurableTaskRuntimeError(\"Objective title and description are required.\");\n\t\tconst now = this.nowIso();\n\t\tconst objective: ObjectiveContract = current\n\t\t\t? {\n\t\t\t\t\t...current.objective,\n\t\t\t\t\ttitle,\n\t\t\t\t\tdescription,\n\t\t\t\t\tconstraints: [...(input.constraints ?? [])],\n\t\t\t\t\tacceptanceCriteria,\n\t\t\t\t\triskBudget: { ...(input.riskBudget ?? {}) },\n\t\t\t\t\tupdatedAt: now,\n\t\t\t\t}\n\t\t\t: {\n\t\t\t\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\t\t\t\tobjectiveId,\n\t\t\t\t\ttitle,\n\t\t\t\t\tdescription,\n\t\t\t\t\tstatus: \"active\",\n\t\t\t\t\tconstraints: [...(input.constraints ?? [])],\n\t\t\t\t\tacceptanceCriteria,\n\t\t\t\t\triskBudget: { ...(input.riskBudget ?? {}) },\n\t\t\t\t\tcreatedAt: now,\n\t\t\t\t\tupdatedAt: now,\n\t\t\t\t};\n\t\tif (current) {\n\t\t\tassertReferencedAcceptanceCriteriaRetained(this.state.tasks, current, acceptanceCriteria);\n\t\t}\n\n\t\tconst mergedEvidence = current?.evidence.map((item) => structuredClone(item)) ?? [];\n\t\tconst evidenceById = new Map(mergedEvidence.map((item) => [item.evidenceId, item]));\n\t\tfor (const item of evidence) {\n\t\t\tconst evidenceId = dispatchIdentifier(item.evidenceId, \"objective evidence.evidenceId\");\n\t\t\tif (!item.summary.trim() || !item.createdAt.trim()) {\n\t\t\t\tthrow new DurableTaskRuntimeError(\"Objective evidence requires an id, summary, and creation time.\");\n\t\t\t}\n\t\t\tif (item.criterionId && !objective.acceptanceCriteria.some((criterion) => criterion.id === item.criterionId)) {\n\t\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t\t`Objective evidence references unknown acceptance criterion '${item.criterionId}'.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst existing = evidenceById.get(evidenceId);\n\t\t\tif (existing) {\n\t\t\t\tif (!isDeepStrictEqual(existing, item)) {\n\t\t\t\t\tthrow new DurableTaskRuntimeError(`Objective evidence '${evidenceId}' has conflicting content.`);\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst retained = structuredClone(item);\n\t\t\tmergedEvidence.push(retained);\n\t\t\tevidenceById.set(evidenceId, retained);\n\t\t}\n\t\tassertProjectionRecordReplacementWithinLimits(this.state, \"objectives\", objectiveId, {\n\t\t\tobjective,\n\t\t\ttaskIds: current?.taskIds ?? [],\n\t\t\tevidence: mergedEvidence,\n\t\t});\n\t}\n\n\tregisterAgent(input: RegisterAgentInput): AgentBindingContract {\n\t\tthis.refresh();\n\t\tconst now = this.nowIso();\n\t\tlet identity: AgentIdentityContract;\n\t\ttry {\n\t\t\tidentity = createAgentIdentity(input.agentId ?? `agent-${this.createId()}`, input.resumeContext);\n\t\t} catch (error) {\n\t\t\tthrow new DurableTaskRuntimeError(error instanceof Error ? error.message : String(error));\n\t\t}\n\t\tconst parentAgentId = input.parentAgentId?.trim();\n\t\tconst parent = parentAgentId ? this.state.agents[parentAgentId] : undefined;\n\t\tif (parentAgentId && !parent) {\n\t\t\tthrow new DurableTaskRuntimeError(`Unknown parent agent '${parentAgentId}'.`);\n\t\t}\n\t\tif (parent?.status === \"retired\") {\n\t\t\tthrow new DurableTaskRuntimeError(`Parent agent '${parentAgentId}' is retired.`);\n\t\t}\n\t\tconst depth = parent ? parent.depth + 1 : 0;\n\t\tif (!Number.isSafeInteger(depth)) {\n\t\t\tthrow new DurableTaskRuntimeError(\"Agent lineage depth exceeds the durable numeric range.\");\n\t\t}\n\t\tconst agent: AgentBindingContract = {\n\t\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\t\t...identity,\n\t\t\t...(parent ? { parentAgentId: parent.agentId } : {}),\n\t\t\trootAgentId: parent?.rootAgentId ?? identity.agentId,\n\t\t\tdepth,\n\t\t\trole: input.role,\n\t\t\tstatus: \"registered\",\n\t\t\tcreatedAt: now,\n\t\t\tupdatedAt: now,\n\t\t};\n\t\tif (this.state.agents[agent.agentId])\n\t\t\tthrow new DurableTaskRuntimeError(`Agent '${agent.agentId}' already exists.`);\n\t\tassertRecordHasCapacity(this.state.agents, MAX_ORCHESTRATION_AGENT_BINDINGS, \"agent binding\");\n\t\tthis.commit({\n\t\t\ttype: \"agent.registered\",\n\t\t\taggregateId: agent.agentId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `agent-registered:${agent.agentId}`,\n\t\t\tpayload: toJsonObject({ agent }),\n\t\t});\n\t\treturn structuredClone(agent);\n\t}\n\n\t/**\n\t * Retire one idle persistent identity without deleting its binding, lineage, transcript pointers,\n\t * or attempt history. A repeated call is inert and returns the durable retired binding.\n\t */\n\tretireAgent(agentId: string): AgentBindingContract {\n\t\tthis.refresh();\n\t\tconst normalizedAgentId = dispatchIdentifier(agentId.trim(), \"agentId\");\n\t\tconst agent = assertAgentRetirementEligible(this.state, normalizedAgentId);\n\t\tif (agent.status === \"retired\") return structuredClone(agent);\n\t\tthis.commit({\n\t\t\ttype: \"agent.retired\",\n\t\t\taggregateId: normalizedAgentId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `agent-retired:${normalizedAgentId}`,\n\t\t\tpayload: toJsonObject({ agentId: normalizedAgentId }),\n\t\t});\n\t\treturn structuredClone(this.state.agents[normalizedAgentId]!);\n\t}\n\n\tcreateObjective(input: CreateObjectiveInput): ObjectiveContract {\n\t\tthis.refresh();\n\t\tassertRiskBudget(input.riskBudget, \"objective.riskBudget\");\n\t\tconst now = this.nowIso();\n\t\tconst objective: ObjectiveContract = {\n\t\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\t\tobjectiveId: input.objectiveId ?? `objective-${this.createId()}`,\n\t\t\ttitle: input.title.trim(),\n\t\t\tdescription: input.description.trim(),\n\t\t\tstatus: \"active\",\n\t\t\tconstraints: [...(input.constraints ?? [])],\n\t\t\tacceptanceCriteria: structuredClone(input.acceptanceCriteria ?? []),\n\t\t\triskBudget: { ...(input.riskBudget ?? {}) },\n\t\t\tcreatedAt: now,\n\t\t\tupdatedAt: now,\n\t\t};\n\t\tif (!objective.title || !objective.description)\n\t\t\tthrow new DurableTaskRuntimeError(\"Objective title and description are required.\");\n\t\tassertAcceptanceCriteria(objective.acceptanceCriteria);\n\t\tif (this.state.objectives[objective.objectiveId]) {\n\t\t\tthrow new DurableTaskRuntimeError(`Objective '${objective.objectiveId}' already exists.`);\n\t\t}\n\t\tassertRecordHasCapacity(this.state.objectives, MAX_ORCHESTRATION_OBJECTIVES, \"objective\");\n\t\tthis.commit({\n\t\t\ttype: \"objective.created\",\n\t\t\taggregateId: objective.objectiveId,\n\t\t\tactor: \"kernel\",\n\t\t\tidempotencyKey: `objective-created:${objective.objectiveId}`,\n\t\t\tpayload: toJsonObject({ objective }),\n\t\t});\n\t\treturn structuredClone(objective);\n\t}\n\n\t/** Create or synchronize owner-authored objective metadata without disturbing lifecycle or task state. */\n\tensureObjective(input: CreateObjectiveInput & { objectiveId: string }): ObjectiveContract {\n\t\tthis.refresh();\n\t\tconst current = this.state.objectives[input.objectiveId];\n\t\tif (!current) return this.createObjective(input);\n\t\tassertRiskBudget(input.riskBudget, \"objective.riskBudget\");\n\t\tconst acceptanceCriteria = structuredClone(input.acceptanceCriteria ?? []);\n\t\tassertAcceptanceCriteria(acceptanceCriteria);\n\t\tconst nextFields = {\n\t\t\ttitle: input.title.trim(),\n\t\t\tdescription: input.description.trim(),\n\t\t\tconstraints: [...(input.constraints ?? [])],\n\t\t\tacceptanceCriteria,\n\t\t\triskBudget: { ...(input.riskBudget ?? {}) },\n\t\t};\n\t\tif (!nextFields.title || !nextFields.description) {\n\t\t\tthrow new DurableTaskRuntimeError(\"Objective title and description are required.\");\n\t\t}\n\t\tconst currentFields = {\n\t\t\ttitle: current.objective.title,\n\t\t\tdescription: current.objective.description,\n\t\t\tconstraints: current.objective.constraints,\n\t\t\tacceptanceCriteria: current.objective.acceptanceCriteria,\n\t\t\triskBudget: current.objective.riskBudget,\n\t\t};\n\t\tif (isDeepStrictEqual(currentFields, nextFields)) return structuredClone(current.objective);\n\n\t\tassertReferencedAcceptanceCriteriaRetained(this.state.tasks, current, acceptanceCriteria);\n\t\tconst objective: ObjectiveContract = {\n\t\t\t...current.objective,\n\t\t\t...nextFields,\n\t\t\tupdatedAt: this.nowIso(),\n\t\t};\n\t\tthis.commit({\n\t\t\ttype: \"objective.updated\",\n\t\t\taggregateId: objective.objectiveId,\n\t\t\tactor: \"kernel\",\n\t\t\tpayload: toJsonObject({ objective }),\n\t\t});\n\t\treturn structuredClone(objective);\n\t}\n\n\trecordObjectiveEvidence(objectiveId: string, evidence: EvidenceContract): EvidenceContract {\n\t\tthis.refresh();\n\t\tconst objective = this.requireObjective(objectiveId);\n\t\tconst existing = objective.evidence.find((candidate) => candidate.evidenceId === evidence.evidenceId);\n\t\tif (existing) {\n\t\t\tif (!isDeepStrictEqual(existing, evidence)) {\n\t\t\t\tthrow new DurableTaskRuntimeError(`Objective evidence '${evidence.evidenceId}' has conflicting content.`);\n\t\t\t}\n\t\t\treturn structuredClone(existing);\n\t\t}\n\t\tif (!evidence.evidenceId.trim() || !evidence.summary.trim() || !evidence.createdAt.trim()) {\n\t\t\tthrow new DurableTaskRuntimeError(\"Objective evidence requires an id, summary, and creation time.\");\n\t\t}\n\t\tif (\n\t\t\tevidence.criterionId &&\n\t\t\t!objective.objective.acceptanceCriteria.some((criterion) => criterion.id === evidence.criterionId)\n\t\t) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`Objective evidence references unknown acceptance criterion '${evidence.criterionId}'.`,\n\t\t\t);\n\t\t}\n\t\tassertObjectiveEvidenceHasCapacity(this.state.objectives, objective);\n\t\tthis.commit({\n\t\t\ttype: \"objective.evidence_recorded\",\n\t\t\taggregateId: objectiveId,\n\t\t\tactor: \"kernel\",\n\t\t\tidempotencyKey: `objective-evidence-recorded:${objectiveId}:${evidence.evidenceId}`,\n\t\t\tpayload: toJsonObject({ evidence }),\n\t\t});\n\t\treturn structuredClone(evidence);\n\t}\n\n\tcreateTask(input: CreateTaskInput): TaskContract {\n\t\tthis.refresh();\n\t\tconst { task, objectiveState } = this.buildTask(input);\n\t\tassertRecordHasCapacity(this.state.tasks, MAX_ORCHESTRATION_TASKS, \"task\");\n\t\tassertIdentifierListHasCapacity(objectiveState.taskIds, MAX_ORCHESTRATION_TASKS, \"objective task list\");\n\t\tthis.commit({\n\t\t\ttype: \"task.created\",\n\t\t\taggregateId: task.objectiveId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `task-created:${task.taskId}`,\n\t\t\tpayload: toJsonObject({ task }),\n\t\t});\n\t\treturn structuredClone(this.state.tasks[task.taskId]!.task);\n\t}\n\n\t/** Atomically create a new task and its first queued attempt in one durable transition. */\n\tprepareTaskAttempt(\n\t\tinput: CreateTaskInput,\n\t\tdispatch: OrchestrationDispatchRequest,\n\t\tgrantId?: string,\n\t): PreparedTaskAttempt {\n\t\tthis.refresh();\n\t\tconst { task, objectiveState } = this.buildTask(input);\n\t\tconst taskState: TaskRuntimeState = { task, attemptIds: [] };\n\t\tconst normalizedDispatch = this.normalizeDispatchForTask(taskState, dispatch);\n\t\tthis.assertTaskAttemptBudget(taskState, objectiveState.objective);\n\t\tassertRecordHasCapacity(this.state.tasks, MAX_ORCHESTRATION_TASKS, \"task\");\n\t\tassertIdentifierListHasCapacity(objectiveState.taskIds, MAX_ORCHESTRATION_TASKS, \"objective task list\");\n\t\tassertRecordHasCapacity(this.state.attempts, MAX_ORCHESTRATION_ATTEMPTS, \"attempt\");\n\t\tconst attemptId = `attempt-${this.createId()}`;\n\t\tthis.commit({\n\t\t\ttype: \"task.attempt_prepared\",\n\t\t\taggregateId: task.taskId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `task-attempt-prepared:${task.taskId}:${attemptId}`,\n\t\t\tpayload: toJsonObject({\n\t\t\t\ttask,\n\t\t\t\tattemptId,\n\t\t\t\ttaskId: task.taskId,\n\t\t\t\tdispatch: normalizedDispatch,\n\t\t\t\t...(grantId ? { grantId } : {}),\n\t\t\t}),\n\t\t});\n\t\treturn {\n\t\t\ttask: structuredClone(this.state.tasks[task.taskId]!.task),\n\t\t\tattempt: structuredClone(this.state.attempts[attemptId]!),\n\t\t};\n\t}\n\n\tqueueAttempt(taskId: string, dispatch: OrchestrationDispatchRequest, grantId?: string): AttemptRuntimeState {\n\t\tthis.refresh();\n\t\tconst task = this.requireDispatchableTask(taskId);\n\t\tconst pendingApproval = this.pendingApprovalForTask(taskId);\n\t\tif (pendingApproval) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`Task '${taskId}' is awaiting approval '${pendingApproval.request.approvalId}'.`,\n\t\t\t);\n\t\t}\n\t\tconst normalizedDispatch = this.normalizeDispatchForTask(task, dispatch);\n\t\tthis.assertTaskAttemptBudget(task, this.state.objectives[task.task.objectiveId]!.objective);\n\t\tassertRecordHasCapacity(this.state.attempts, MAX_ORCHESTRATION_ATTEMPTS, \"attempt\");\n\t\tassertIdentifierListHasCapacity(task.attemptIds, MAX_ORCHESTRATION_ATTEMPTS, \"task attempt list\");\n\t\tconst attemptId = `attempt-${this.createId()}`;\n\t\tthis.commit({\n\t\t\ttype: \"attempt.queued\",\n\t\t\taggregateId: taskId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `attempt-queued:${attemptId}`,\n\t\t\tpayload: toJsonObject({ attemptId, taskId, dispatch: normalizedDispatch, ...(grantId ? { grantId } : {}) }),\n\t\t});\n\t\treturn structuredClone(this.state.attempts[attemptId]!);\n\t}\n\n\t/** Read-only controller seam for deciding whether one durable queued or suspended attempt may run. */\n\tgetAttemptDispatchReadiness(attemptId: string): AttemptDispatchReadiness {\n\t\tthis.refresh();\n\t\treturn structuredClone(attemptDispatchReadiness(this.state, this.requireAttempt(attemptId)));\n\t}\n\n\tbindAttemptGrant(attemptId: string, grant: ExecutionGrant): AttemptRuntimeState {\n\t\tthis.refresh();\n\t\tconst normalizedGrant = executionGrantFromValue(grant, \"grant\");\n\t\tconst attempt = assertAttemptGrantTransition(this.state, attemptId, attemptId, normalizedGrant);\n\t\tif (attempt.grantId === normalizedGrant.grantId) {\n\t\t\tif (attempt.grant && !isDeepStrictEqual(attempt.grant, normalizedGrant)) {\n\t\t\t\tthrow new DurableTaskRuntimeError(`Attempt '${attemptId}' grant has conflicting content.`);\n\t\t\t}\n\t\t\treturn structuredClone(attempt);\n\t\t}\n\t\tif (attempt.grantId) throw new DurableTaskRuntimeError(`Attempt '${attemptId}' already has a different grant.`);\n\t\tthis.commit({\n\t\t\ttype: \"attempt.grant_bound\",\n\t\t\taggregateId: attemptId,\n\t\t\tactor: \"policy\",\n\t\t\tidempotencyKey: `attempt-grant-bound:${attemptId}:${normalizedGrant.grantId}`,\n\t\t\tpayload: toJsonObject({ attemptId, grant: normalizedGrant }),\n\t\t});\n\t\treturn structuredClone(this.state.attempts[attemptId]!);\n\t}\n\n\tleaseAttempt(attemptId: string, ownerId: string, ttlMs: number, agentId?: string): AttemptLease {\n\t\tthis.refresh();\n\t\tconst attempt = this.requireAttempt(attemptId);\n\t\tconst lease = this.issueLease(attempt, ownerId, ttlMs);\n\t\tassertAttemptLeaseTransition(this.state, attemptId, lease, agentId, this.nowIso());\n\t\tthis.commit({\n\t\t\ttype: \"attempt.leased\",\n\t\t\taggregateId: attemptId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `attempt-leased:${lease.leaseId}`,\n\t\t\tpayload: toJsonObject({ lease, ...(agentId ? { agentId } : {}) }),\n\t\t});\n\t\treturn structuredClone(lease);\n\t}\n\n\tstartAttempt(attemptId: string, leaseId: string, fencingToken: number): AttemptRuntimeState {\n\t\tthis.refresh();\n\t\tassertAttemptStartTransition(this.state, attemptId, attemptId, leaseId, fencingToken, this.nowIso());\n\t\tthis.commit({\n\t\t\ttype: \"attempt.started\",\n\t\t\taggregateId: attemptId,\n\t\t\tactor: \"worker\",\n\t\t\tidempotencyKey: `attempt-started:${attemptId}:${fencingToken}`,\n\t\t\tpayload: toJsonObject({ attemptId, leaseId, fencingToken }),\n\t\t});\n\t\treturn structuredClone(this.state.attempts[attemptId]!);\n\t}\n\n\trenewAttemptLease(attemptId: string, leaseId: string, fencingToken: number, ttlMs: number): AttemptLease {\n\t\tthis.refresh();\n\t\tconst attempt = this.requireLiveLease(attemptId, leaseId, fencingToken);\n\t\tif (attempt.status !== \"leased\" && attempt.status !== \"running\") {\n\t\t\tthrow new DurableTaskRuntimeError(`Attempt '${attemptId}' cannot renew from '${attempt.status}'.`);\n\t\t}\n\t\tif (!Number.isFinite(ttlMs) || ttlMs <= 0) throw new DurableTaskRuntimeError(\"Lease TTL must be positive.\");\n\t\tconst renewedAtMs = this.now();\n\t\tconst expiresAtMs = renewedAtMs + Math.min(ttlMs, MAX_DATE_EPOCH_MS - renewedAtMs);\n\t\tif (expiresAtMs <= Date.parse(attempt.lease!.expiresAt)) return structuredClone(attempt.lease!);\n\t\tconst expiresAt = new Date(expiresAtMs).toISOString();\n\t\tassertAttemptLeaseRenewalTransition(\n\t\t\tthis.state,\n\t\t\tattemptId,\n\t\t\tattemptId,\n\t\t\tleaseId,\n\t\t\tfencingToken,\n\t\t\texpiresAt,\n\t\t\tthis.nowIso(),\n\t\t);\n\t\tthis.commit({\n\t\t\ttype: \"attempt.lease_renewed\",\n\t\t\taggregateId: attemptId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `attempt-lease-renewed:${leaseId}:${expiresAt}`,\n\t\t\tpayload: toJsonObject({ attemptId, leaseId, fencingToken, expiresAt }),\n\t\t});\n\t\treturn structuredClone(this.state.attempts[attemptId]!.lease!);\n\t}\n\n\tcheckpointAttempt(args: {\n\t\tattemptId: string;\n\t\tleaseId: string;\n\t\tfencingToken: number;\n\t\tsummary: string;\n\t\tartifactIds?: readonly string[];\n\t\tevidenceIds?: readonly string[];\n\t\tusage?: AttemptCheckpoint[\"usage\"];\n\t}): AttemptCheckpoint {\n\t\tthis.refresh();\n\t\tconst attempt = this.requireLiveLease(args.attemptId, args.leaseId, args.fencingToken);\n\t\tif (attempt.status !== \"running\")\n\t\t\tthrow new DurableTaskRuntimeError(`Attempt '${args.attemptId}' is not running.`);\n\t\tconst summary = checkpointSummary(args.summary, \"checkpoint.summary\");\n\t\tconst artifactIds = dispatchIdentifierArray(args.artifactIds ?? [], \"checkpoint.artifactIds\");\n\t\tconst evidenceIds = dispatchIdentifierArray(args.evidenceIds ?? [], \"checkpoint.evidenceIds\");\n\t\tassertIdentifierListHasCapacity(attempt.checkpointIds, MAX_ORCHESTRATION_CHECKPOINTS, \"attempt checkpoint list\");\n\t\tassertRecordHasCapacity(this.state.checkpoints, MAX_ORCHESTRATION_CHECKPOINTS, \"checkpoint\");\n\t\tconst checkpoint: AttemptCheckpoint = {\n\t\t\tcheckpointId: `checkpoint-${this.createId()}`,\n\t\t\tattemptId: args.attemptId,\n\t\t\tfencingToken: args.fencingToken,\n\t\t\tsummary,\n\t\t\tartifactIds,\n\t\t\tevidenceIds,\n\t\t\t...(args.usage ? { usage: usageFromPayload(args.usage, \"checkpoint.usage\") } : {}),\n\t\t\tcreatedAt: this.nowIso(),\n\t\t};\n\t\tassertAttemptCheckpointTransition(this.state, args.attemptId, checkpoint, args.leaseId, this.nowIso());\n\t\tthis.commit({\n\t\t\ttype: \"attempt.checkpointed\",\n\t\t\taggregateId: args.attemptId,\n\t\t\tactor: \"worker\",\n\t\t\tidempotencyKey: `attempt-checkpointed:${checkpoint.checkpointId}`,\n\t\t\tpayload: toJsonObject({ checkpoint, leaseId: args.leaseId }),\n\t\t});\n\t\treturn structuredClone(checkpoint);\n\t}\n\n\tfinishAttempt(result: WorkerResultContract): AttemptRuntimeState {\n\t\tthis.refresh();\n\t\tassertAttemptFinishTransition(this.state, result.attemptId, result, this.nowIso());\n\t\tthis.commit({\n\t\t\ttype: \"attempt.finished\",\n\t\t\taggregateId: result.attemptId,\n\t\t\tactor: \"worker\",\n\t\t\tidempotencyKey: `attempt-finished:${result.resultId}`,\n\t\t\tpayload: toJsonObject({ result }),\n\t\t});\n\t\treturn structuredClone(this.state.attempts[result.attemptId]!);\n\t}\n\n\tfinishVerification(args: VerificationTransitionInput): TaskRuntimeState {\n\t\tthis.refresh();\n\t\tassertVerificationTransition(this.state, args.taskId, args);\n\t\tthis.commit({\n\t\t\ttype: \"task.verification_finished\",\n\t\t\taggregateId: args.taskId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `task-verification-finished:${args.taskId}:${args.verifierAttemptId}`,\n\t\t\tpayload: toJsonObject({ ...args, reasonCode: args.reasonCode.trim() }),\n\t\t});\n\t\treturn structuredClone(this.state.tasks[args.taskId]!);\n\t}\n\n\tcancelAttempt(attemptId: string, reasonCode: string): AttemptRuntimeState {\n\t\tthis.refresh();\n\t\tconst attempt = this.requireAttempt(attemptId);\n\t\tif (terminalAttemptStatus(attempt.status)) return structuredClone(attempt);\n\t\tif (!reasonCode.trim()) throw new DurableTaskRuntimeError(\"Cancellation reason is required.\");\n\t\tthis.commit({\n\t\t\ttype: \"attempt.cancelled\",\n\t\t\taggregateId: attemptId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `attempt-cancelled:${attemptId}`,\n\t\t\tpayload: toJsonObject({ attemptId, reasonCode: reasonCode.trim() }),\n\t\t});\n\t\treturn structuredClone(this.state.attempts[attemptId]!);\n\t}\n\n\t/**\n\t * The only runtime suspension transition. Callers must present the exact current owner and lease\n\t * fence; liveness/restart policy stays outside this deterministic runtime.\n\t */\n\tsuspendBoundAttempt(args: {\n\t\tattemptId: string;\n\t\townerId: string;\n\t\tleaseId: string;\n\t\tfencingToken: number;\n\t\treasonCode: string;\n\t\tretry?: AttemptRetryState;\n\t}): AttemptRuntimeState {\n\t\tthis.refresh();\n\t\tconst attempt = this.requireAttempt(args.attemptId);\n\t\tif (!attempt.agentId || !attempt.lease || ![\"leased\", \"running\"].includes(attempt.status)) {\n\t\t\tthrow new DurableTaskRuntimeError(`Attempt '${args.attemptId}' is not a live agent-bound attempt.`);\n\t\t}\n\t\tif (attempt.lease.ownerId !== args.ownerId) {\n\t\t\tthrow new DurableTaskRuntimeError(`Attempt '${args.attemptId}' is not owned by '${args.ownerId}'.`);\n\t\t}\n\t\tif (attempt.lease.leaseId !== args.leaseId || attempt.lease.fencingToken !== args.fencingToken) {\n\t\t\tthrow new DurableTaskRuntimeError(`Attempt '${args.attemptId}' lease or fencing token is stale.`);\n\t\t}\n\t\tif (!args.reasonCode.trim()) throw new DurableTaskRuntimeError(\"Suspension reason is required.\");\n\t\tconst retry = args.retry ? retryStateFromValue(args.retry, \"attempt.suspended.retry\") : undefined;\n\t\tif (retry) {\n\t\t\tif (retry.retriesUsed !== (attempt.retry?.retriesUsed ?? 0) + 1) {\n\t\t\t\tthrow new DurableTaskRuntimeError(`Attempt '${args.attemptId}' retry count is not monotonic.`);\n\t\t\t}\n\t\t\tif (Date.parse(retry.notBefore) <= this.now()) {\n\t\t\t\tthrow new DurableTaskRuntimeError(\"Retry not-before deadline must be in the future.\");\n\t\t\t}\n\t\t}\n\t\tthis.commit({\n\t\t\ttype: \"attempt.suspended\",\n\t\t\taggregateId: args.attemptId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `attempt-suspended:${args.attemptId}:${args.leaseId}:${args.fencingToken}`,\n\t\t\tpayload: toJsonObject({\n\t\t\t\tattemptId: args.attemptId,\n\t\t\t\tleaseId: args.leaseId,\n\t\t\t\tfencingToken: args.fencingToken,\n\t\t\t\treasonCode: args.reasonCode.trim(),\n\t\t\t\t...(retry ? { retry } : {}),\n\t\t\t}),\n\t\t});\n\t\treturn structuredClone(this.state.attempts[args.attemptId]!);\n\t}\n\n\tfailTask(taskId: string, reasonCode: string): TaskContract {\n\t\tthis.refresh();\n\t\tconst task = this.state.tasks[taskId];\n\t\tif (!task) throw new DurableTaskRuntimeError(`Unknown task '${taskId}'.`);\n\t\tif ([\"completed\", \"failed\", \"cancelled\"].includes(task.task.status)) return structuredClone(task.task);\n\t\tassertTaskFailureTransition(this.state, taskId, taskId, reasonCode);\n\t\tthis.commit({\n\t\t\ttype: \"task.failed\",\n\t\t\taggregateId: taskId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `task-failed:${taskId}:${reasonCode.trim()}`,\n\t\t\tpayload: toJsonObject({ taskId, reasonCode: reasonCode.trim() }),\n\t\t});\n\t\treturn structuredClone(this.state.tasks[taskId]!.task);\n\t}\n\n\t/**\n\t * Recover unbound in-process work after a process restart. A completion has no resumable model\n\t * transcript, so its old lease is fenced and the task becomes dispatchable for a fresh attempt.\n\t * Agent-bound attempts are intentionally excluded: those must wake the same logical agent.\n\t */\n\trecoverInterruptedUnboundAttempts(shouldRecover: (attempt: AttemptRuntimeState) => boolean = () => true): string[] {\n\t\tthis.refresh();\n\t\tconst recovered: string[] = [];\n\t\tfor (const attempt of Object.values(this.state.attempts)) {\n\t\t\tif (\n\t\t\t\t(attempt.status !== \"leased\" && attempt.status !== \"running\") ||\n\t\t\t\tattempt.agentId ||\n\t\t\t\t!shouldRecover(attempt)\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthis.commit({\n\t\t\t\ttype: \"attempt.lease_expired\",\n\t\t\t\taggregateId: attempt.attemptId,\n\t\t\t\tactor: \"runtime\",\n\t\t\t\tidempotencyKey: `attempt-process-interrupted:${attempt.attemptId}:${attempt.lease?.leaseId ?? \"none\"}`,\n\t\t\t\tpayload: toJsonObject({\n\t\t\t\t\tattemptId: attempt.attemptId,\n\t\t\t\t\t...(attempt.lease ? { leaseId: attempt.lease.leaseId, fencingToken: attempt.lease.fencingToken } : {}),\n\t\t\t\t\treasonCode: \"worker_process_interrupted\",\n\t\t\t\t}),\n\t\t\t});\n\t\t\trecovered.push(attempt.attemptId);\n\t\t}\n\t\treturn recovered;\n\t}\n\n\texpireLeases(at = this.now()): string[] {\n\t\tthis.refresh();\n\t\tconst expired: string[] = [];\n\t\tfor (const attempt of Object.values(this.state.attempts)) {\n\t\t\tif ((attempt.status !== \"leased\" && attempt.status !== \"running\") || !attempt.lease) continue;\n\t\t\tif (Date.parse(attempt.lease.expiresAt) > at) continue;\n\t\t\tthis.commit({\n\t\t\t\ttype: attempt.agentId ? \"attempt.suspended\" : \"attempt.lease_expired\",\n\t\t\t\taggregateId: attempt.attemptId,\n\t\t\t\tactor: \"runtime\",\n\t\t\t\tidempotencyKey: `attempt-lease-expired:${attempt.lease.leaseId}`,\n\t\t\t\tpayload: toJsonObject({\n\t\t\t\t\tattemptId: attempt.attemptId,\n\t\t\t\t\tleaseId: attempt.lease.leaseId,\n\t\t\t\t\tfencingToken: attempt.lease.fencingToken,\n\t\t\t\t}),\n\t\t\t});\n\t\t\texpired.push(attempt.attemptId);\n\t\t}\n\t\treturn expired;\n\t}\n\n\trequestAgentResume(agentId: string, attemptId: string): AgentBindingContract {\n\t\tthis.refresh();\n\t\tconst agent = this.state.agents[agentId];\n\t\tif (!agent) throw new DurableTaskRuntimeError(`Unknown agent '${agentId}'.`);\n\t\tassertAgentNotRetired(agent, \"request resume\");\n\t\tconst attempt = this.requireAttempt(attemptId);\n\t\tif (attempt.status !== \"suspended\" || attempt.agentId !== agentId || agent.activeAttemptId !== attemptId) {\n\t\t\tthrow new DurableTaskRuntimeError(`Agent '${agentId}' cannot resume suspended attempt '${attemptId}'.`);\n\t\t}\n\t\tthis.assertRetryBackoffElapsed(attempt);\n\t\tthis.requireActiveObjectiveForAttempt(attempt);\n\t\tif (agent.status === \"resuming\") return structuredClone(agent);\n\t\tif (agent.status !== \"suspended\") throw new DurableTaskRuntimeError(`Agent '${agentId}' is not suspended.`);\n\t\tthis.commit({\n\t\t\ttype: \"agent.resume_requested\",\n\t\t\taggregateId: agentId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `agent-resume-requested:${agentId}:${this.state.lastOrdinal}`,\n\t\t\tpayload: toJsonObject({ agentId, attemptId }),\n\t\t});\n\t\treturn structuredClone(this.state.agents[agentId]!);\n\t}\n\n\t/** Read-only guard used before changing agent state; resumeAttempt repeats it authoritatively. */\n\tassertAttemptReadyForResume(attemptId: string): void {\n\t\tthis.refresh();\n\t\tthis.assertRetryBackoffElapsed(this.requireAttempt(attemptId));\n\t}\n\n\tresumeAttempt(attemptId: string, agentId: string, ttlMs: number, ownerId = agentId): AttemptLease {\n\t\tthis.refresh();\n\t\tconst attempt = this.requireAttempt(attemptId);\n\t\tconst agent = this.state.agents[agentId];\n\t\tif (attempt.status !== \"suspended\" || attempt.agentId !== agentId) {\n\t\t\tthrow new DurableTaskRuntimeError(`Attempt '${attemptId}' is not suspended for agent '${agentId}'.`);\n\t\t}\n\t\tif (!agent || agent.status !== \"resuming\")\n\t\t\tthrow new DurableTaskRuntimeError(`Agent '${agentId}' is not resuming.`);\n\t\tthis.assertRetryBackoffElapsed(attempt);\n\t\tthis.requireActiveObjectiveForAttempt(attempt);\n\t\tconst lease = this.issueLease(attempt, ownerId, ttlMs);\n\t\tthis.commit({\n\t\t\ttype: \"attempt.resumed\",\n\t\t\taggregateId: attemptId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `attempt-resumed:${lease.leaseId}`,\n\t\t\tpayload: toJsonObject({ agentId, lease }),\n\t\t});\n\t\treturn structuredClone(lease);\n\t}\n\n\tpauseObjective(objectiveId: string): void {\n\t\tthis.transitionObjective(objectiveId, \"objective.paused\", \"paused\");\n\t}\n\n\tresumeObjective(objectiveId: string): void {\n\t\tthis.transitionObjective(objectiveId, \"objective.resumed\", \"active\");\n\t}\n\n\tcancelObjective(objectiveId: string): void {\n\t\tthis.transitionObjective(objectiveId, \"objective.cancelled\", \"cancelled\");\n\t}\n\n\tcompleteObjective(objectiveId: string): void {\n\t\tthis.transitionObjective(objectiveId, \"objective.completed\", \"completed\", {\n\t\t\tcompletionPolicy: \"task_evidence\",\n\t\t});\n\t}\n\n\tcompleteObjectiveFromOwner(objectiveId: string, acceptanceOverride: boolean): void {\n\t\tthis.refresh();\n\t\tconst objective = this.requireObjective(objectiveId);\n\t\tif (objective.objective.status === \"completed\") return;\n\t\tif (objective.objective.status === \"cancelled\") {\n\t\t\tthrow new DurableTaskRuntimeError(`Objective '${objectiveId}' is terminal.`);\n\t\t}\n\t\tthis.transitionObjective(objectiveId, \"objective.completed\", \"completed\", {\n\t\t\tcompletionPolicy: acceptanceOverride ? \"owner_override\" : \"owner_evidence\",\n\t\t});\n\t}\n\n\trequestApproval(approval: ApprovalRequestContract): ApprovalRuntimeState {\n\t\tthis.refresh();\n\t\tconst normalized = approvalFromPayload(toJsonObject({ approval }));\n\t\tconst existing = this.state.approvals[normalized.approvalId];\n\t\tif (existing) {\n\t\t\tif (!isDeepStrictEqual(existing.request, normalized)) {\n\t\t\t\tthrow new DurableTaskRuntimeError(`Approval id '${normalized.approvalId}' has conflicting content.`);\n\t\t\t}\n\t\t\treturn structuredClone(existing);\n\t\t}\n\t\tassertApprovalRequestTransition(\n\t\t\tthis.state,\n\t\t\tnormalized.attemptId ?? normalized.taskId ?? normalized.objectiveId,\n\t\t\tnormalized,\n\t\t);\n\t\tassertRecordHasCapacity(this.state.approvals, MAX_ORCHESTRATION_APPROVALS, \"approval\");\n\t\tassertRecordHasCapacity(this.state.notifications, MAX_ORCHESTRATION_NOTIFICATIONS, \"notification\");\n\t\tthis.commit({\n\t\t\ttype: \"approval.requested\",\n\t\t\taggregateId: normalized.attemptId ?? normalized.taskId ?? normalized.objectiveId,\n\t\t\tactor: \"policy\",\n\t\t\tidempotencyKey: `approval-requested:${normalized.approvalId}`,\n\t\t\tpayload: toJsonObject({ approval: normalized }),\n\t\t});\n\t\treturn structuredClone(this.state.approvals[normalized.approvalId]!);\n\t}\n\n\tresolveApproval(approvalId: string, outcome: ApprovalOutcome, reasonCode: string): ApprovalRuntimeState {\n\t\tthis.refresh();\n\t\tconst approval = this.state.approvals[approvalId];\n\t\tif (!approval) throw new DurableTaskRuntimeError(`Unknown approval '${approvalId}'.`);\n\t\tif (approval.status !== \"pending\") {\n\t\t\tif (approval.status === outcome) return structuredClone(approval);\n\t\t\tthrow new DurableTaskRuntimeError(`Approval '${approvalId}' was already ${approval.status}.`);\n\t\t}\n\t\tif (outcome !== \"approved\" && outcome !== \"rejected\") {\n\t\t\tthrow new DurableTaskRuntimeError(`Unknown approval outcome '${String(outcome)}'.`);\n\t\t}\n\t\tif (!reasonCode.trim()) throw new DurableTaskRuntimeError(\"Approval resolution reason is required.\");\n\t\tconst resolution: ApprovalResolutionContract = {\n\t\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\t\tapprovalId,\n\t\t\toutcome,\n\t\t\treasonCode: reasonCode.trim(),\n\t\t\tresolvedAt: this.nowIso(),\n\t\t};\n\t\tassertApprovalResolutionTransition(\n\t\t\tthis.state,\n\t\t\tapproval.request.attemptId ?? approval.request.taskId ?? approval.request.objectiveId,\n\t\t\tresolution,\n\t\t);\n\t\tthis.commit({\n\t\t\ttype: \"approval.resolved\",\n\t\t\taggregateId: approval.request.attemptId ?? approval.request.taskId ?? approval.request.objectiveId,\n\t\t\tactor: \"human\",\n\t\t\tidempotencyKey: `approval-resolved:${approvalId}`,\n\t\t\tpayload: toJsonObject({ resolution }),\n\t\t});\n\t\treturn structuredClone(this.state.approvals[approvalId]!);\n\t}\n\n\tenqueueNotification(args: {\n\t\tnotificationId?: string;\n\t\tobjectiveId: string;\n\t\tattemptId?: string;\n\t\tmessage: string;\n\t}): NotificationRuntimeState {\n\t\tthis.refresh();\n\t\tassertNotificationTarget(this.state, args.objectiveId, args.attemptId);\n\t\tconst notificationId = args.notificationId ?? `notification-${this.createId()}`;\n\t\tconst existing = this.state.notifications[notificationId];\n\t\tif (existing) {\n\t\t\tif (\n\t\t\t\texisting.objectiveId !== args.objectiveId ||\n\t\t\t\texisting.attemptId !== args.attemptId ||\n\t\t\t\texisting.message !== args.message\n\t\t\t) {\n\t\t\t\tthrow new DurableTaskRuntimeError(`Notification id '${notificationId}' has conflicting content.`);\n\t\t\t}\n\t\t\treturn structuredClone(existing);\n\t\t}\n\t\tassertRecordHasCapacity(this.state.notifications, MAX_ORCHESTRATION_NOTIFICATIONS, \"notification\");\n\t\tthis.commit({\n\t\t\ttype: \"notification.enqueued\",\n\t\t\taggregateId: args.objectiveId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `notification-enqueued:${notificationId}`,\n\t\t\tpayload: toJsonObject({ ...args, notificationId }),\n\t\t});\n\t\treturn structuredClone(this.state.notifications[notificationId]!);\n\t}\n\n\tmarkNotificationDelivered(notificationId: string): NotificationRuntimeState {\n\t\tthis.refresh();\n\t\tconst notification = this.state.notifications[notificationId];\n\t\tif (!notification) throw new DurableTaskRuntimeError(`Unknown notification '${notificationId}'.`);\n\t\tif (notification.status === \"delivered\") return structuredClone(notification);\n\t\tthis.commit({\n\t\t\ttype: \"notification.delivered\",\n\t\t\taggregateId: notification.objectiveId,\n\t\t\tactor: \"runtime\",\n\t\t\tidempotencyKey: `notification-delivered:${notificationId}`,\n\t\t\tpayload: toJsonObject({ notificationId }),\n\t\t});\n\t\treturn structuredClone(this.state.notifications[notificationId]!);\n\t}\n\n\tprivate buildTask(input: CreateTaskInput): { task: TaskContract; objectiveState: ObjectiveRuntimeState } {\n\t\tassertRiskBudget(input.riskBudget, \"task.riskBudget\");\n\t\tconst objectiveState = this.state.objectives[input.objectiveId];\n\t\tif (!objectiveState) throw new DurableTaskRuntimeError(`Unknown objective '${input.objectiveId}'.`);\n\t\tif (objectiveState.objective.status !== \"active\") {\n\t\t\tthrow new DurableTaskRuntimeError(`Objective '${input.objectiveId}' is not active.`);\n\t\t}\n\t\tconst dependsOn = validateTaskDependencyIds(this.state.tasks, input.objectiveId, input.dependsOn);\n\t\tconst acceptanceCriterionIds = [...new Set(input.acceptanceCriterionIds ?? [])];\n\t\tconst now = this.nowIso();\n\t\tconst task = taskFromValue(\n\t\t\t{\n\t\t\t\tschemaVersion: ORCHESTRATION_SCHEMA_VERSION,\n\t\t\t\ttaskId: input.taskId ?? `task-${this.createId()}`,\n\t\t\t\tobjectiveId: input.objectiveId,\n\t\t\t\ttitle: input.title.trim(),\n\t\t\t\tdescription: input.description.trim(),\n\t\t\t\trole: input.role,\n\t\t\t\tstatus: dependsOn.length === 0 ? \"ready\" : \"pending\",\n\t\t\t\tdependsOn,\n\t\t\t\trequiredCapabilities: [...new Set(input.requiredCapabilities ?? [])],\n\t\t\t\tacceptanceCriterionIds,\n\t\t\t\t...(input.verificationOfTaskId ? { verificationOfTaskId: input.verificationOfTaskId } : {}),\n\t\t\t\triskBudget: { ...(input.riskBudget ?? {}) },\n\t\t\t\tcreatedAt: now,\n\t\t\t\tupdatedAt: now,\n\t\t\t},\n\t\t\t\"task\",\n\t\t);\n\t\tif (this.state.tasks[task.taskId]) throw new DurableTaskRuntimeError(`Task '${task.taskId}' already exists.`);\n\t\tvalidateTaskContractForState(this.state, task, `Task '${task.taskId}'`);\n\t\treturn { task, objectiveState };\n\t}\n\n\tprivate normalizeDispatchForTask(\n\t\ttask: TaskRuntimeState,\n\t\tdispatch: OrchestrationDispatchRequest,\n\t): OrchestrationDispatchRequest {\n\t\tconst normalizedDispatch = dispatchFromValue(dispatch, \"dispatch\");\n\t\tif (normalizedDispatch.taskId !== task.task.taskId) {\n\t\t\tthrow new DurableTaskRuntimeError(\"Dispatch taskId does not match the queued task.\");\n\t\t}\n\t\tif (\n\t\t\tnormalizedDispatch.executionContract &&\n\t\t\t(normalizedDispatch.executionContract.worker.profile.profileId !== normalizedDispatch.profileId ||\n\t\t\t\tnormalizedDispatch.executionContract.worker.profile.role !== task.task.role)\n\t\t) {\n\t\t\tthrow new DurableTaskRuntimeError(\"Execution contract does not match the dispatch profile and task role.\");\n\t\t}\n\t\treturn normalizedDispatch;\n\t}\n\n\tprivate assertTaskAttemptBudget(task: TaskRuntimeState, objective: ObjectiveContract): void {\n\t\tassertTaskAttemptBudgetForState(task, objective);\n\t}\n\n\tprivate transitionObjective(\n\t\tobjectiveId: string,\n\t\ttype: \"objective.paused\" | \"objective.resumed\" | \"objective.cancelled\" | \"objective.completed\",\n\t\ttarget: ObjectiveStatus,\n\t\tpayload: JsonObject = {},\n\t): void {\n\t\tthis.refresh();\n\t\tconst objective = this.requireObjective(objectiveId);\n\t\tif (objective.objective.status === target) return;\n\t\tassertObjectiveStatusTransition(\n\t\t\tthis.state,\n\t\t\tobjectiveId,\n\t\t\ttarget,\n\t\t\ttype === \"objective.completed\"\n\t\t\t\t? (payload.completionPolicy as ObjectiveCompletionPolicy | undefined)\n\t\t\t\t: undefined,\n\t\t);\n\t\tthis.commit({\n\t\t\ttype,\n\t\t\taggregateId: objectiveId,\n\t\t\tactor: \"human\",\n\t\t\tidempotencyKey: `${type}:${objectiveId}:${this.state.lastOrdinal}`,\n\t\t\tpayload,\n\t\t});\n\t}\n\n\tprivate requireObjective(objectiveId: string): ObjectiveRuntimeState {\n\t\tconst objective = this.state.objectives[objectiveId];\n\t\tif (!objective) throw new DurableTaskRuntimeError(`Unknown objective '${objectiveId}'.`);\n\t\treturn objective;\n\t}\n\n\tprivate requireDispatchableTask(taskId: string): TaskRuntimeState {\n\t\tconst task = this.state.tasks[taskId];\n\t\tif (!task) throw new DurableTaskRuntimeError(`Unknown task '${taskId}'.`);\n\t\tconst objective = this.requireObjective(task.task.objectiveId);\n\t\tif (objective.objective.status !== \"active\") {\n\t\t\tthrow new DurableTaskRuntimeError(`Objective '${objective.objective.objectiveId}' is not active.`);\n\t\t}\n\t\tif (![\"pending\", \"ready\", \"blocked\", \"failed\"].includes(task.task.status)) {\n\t\t\tthrow new DurableTaskRuntimeError(`Task '${taskId}' is not dispatchable from '${task.task.status}'.`);\n\t\t}\n\t\tconst active = activeTaskAttempt(this.state, task);\n\t\tif (active) {\n\t\t\tthrow new DurableTaskRuntimeError(`Task '${taskId}' already owns active attempt '${active.attemptId}'.`);\n\t\t}\n\t\treturn task;\n\t}\n\n\tprivate requireAttempt(attemptId: string): AttemptRuntimeState {\n\t\tconst attempt = this.state.attempts[attemptId];\n\t\tif (!attempt) throw new DurableTaskRuntimeError(`Unknown attempt '${attemptId}'.`);\n\t\treturn attempt;\n\t}\n\n\tprivate issueLease(attempt: AttemptRuntimeState, ownerId: string, ttlMs: number): AttemptLease {\n\t\tif (!Number.isFinite(ttlMs) || ttlMs <= 0) throw new DurableTaskRuntimeError(\"Lease TTL must be positive.\");\n\t\tconst issuedAtMs = this.now();\n\t\tconst expiresAtMs = issuedAtMs + Math.min(ttlMs, MAX_DATE_EPOCH_MS - issuedAtMs);\n\t\treturn {\n\t\t\tleaseId: `lease-${this.createId()}`,\n\t\t\tattemptId: attempt.attemptId,\n\t\t\townerId,\n\t\t\tfencingToken: (attempt.lease?.fencingToken ?? 0) + 1,\n\t\t\tissuedAt: new Date(issuedAtMs).toISOString(),\n\t\t\texpiresAt: new Date(expiresAtMs).toISOString(),\n\t\t};\n\t}\n\n\tprivate pendingApprovalForTask(taskId: string): ApprovalRuntimeState | undefined {\n\t\tconst task = this.state.tasks[taskId];\n\t\tif (!task) return undefined;\n\t\treturn Object.values(this.state.approvals).find(\n\t\t\t(approval) =>\n\t\t\t\tapproval.status === \"pending\" &&\n\t\t\t\tapproval.request.attemptId === undefined &&\n\t\t\t\tapproval.request.objectiveId === task.task.objectiveId &&\n\t\t\t\t(approval.request.taskId === undefined || approval.request.taskId === taskId),\n\t\t);\n\t}\n\n\tprivate requireActiveObjectiveForAttempt(attempt: AttemptRuntimeState): void {\n\t\trequireActiveObjectiveForAttemptInProjection(this.state, attempt);\n\t}\n\n\tprivate assertRetryBackoffElapsed(attempt: AttemptRuntimeState): void {\n\t\tassertRetryBackoffElapsedAt(attempt, this.now());\n\t}\n\n\tprivate requireLiveLease(attemptId: string, leaseId: string, fencingToken: number): AttemptRuntimeState {\n\t\tconst attempt = this.requireAttempt(attemptId);\n\t\tif (!attempt.lease || attempt.lease.leaseId !== leaseId || attempt.lease.fencingToken !== fencingToken) {\n\t\t\tthrow new DurableTaskRuntimeError(`Attempt '${attemptId}' lease or fencing token is stale.`);\n\t\t}\n\t\tif (Date.parse(attempt.lease.expiresAt) <= this.now()) {\n\t\t\tthrow new DurableTaskRuntimeError(`Attempt '${attemptId}' lease expired.`);\n\t\t}\n\t\treturn attempt;\n\t}\n\n\tprivate refresh(): void {\n\t\tlet events: OrchestrationEvent[];\n\t\ttry {\n\t\t\tevents = this.store.readAfter(this.state.lastOrdinal);\n\t\t} catch (error) {\n\t\t\tif (!(error instanceof OrchestrationSnapshotRequiredError)) throw error;\n\t\t\tconst snapshot = this.store.readProjectionSnapshot();\n\t\t\tif (!snapshot || snapshot.throughOrdinal < error.throughOrdinal) {\n\t\t\t\tthrow new DurableTaskRuntimeError(\"Required orchestration projection snapshot is unavailable.\");\n\t\t\t}\n\t\t\tthis.state = projectionFromSnapshot(snapshot.projection, snapshot.throughOrdinal);\n\t\t\tevents = this.store.readAfter(this.state.lastOrdinal);\n\t\t}\n\t\tfor (const event of events) {\n\t\t\tthis.state = reduceOrchestrationEvent(this.state, event);\n\t\t}\n\t\tthis.compactCurrentProjection();\n\t}\n\n\tprivate commit(input: AppendOrchestrationEventInput): void {\n\t\tthis.compactCurrentProjection();\n\t\tlet admittedProjection: TaskRuntimeProjection | undefined;\n\t\tconst event = this.store.append(input, {\n\t\t\texpectedLastOrdinal: this.state.lastOrdinal,\n\t\t\tvalidateBeforeCommit: (candidate) => {\n\t\t\t\tif (candidate.ordinal > this.state.lastOrdinal) {\n\t\t\t\t\tadmittedProjection = reduceOrchestrationEvent(this.state, candidate);\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t\tif (admittedProjection) {\n\t\t\tthis.state = admittedProjection;\n\t\t\treturn;\n\t\t}\n\t\t// Exact idempotent replay can return an older event after another writer committed a\n\t\t// contiguous suffix. Adopt through readAfter so no intervening ordinal is skipped. Test stores\n\t\t// that do not execute append admission still fall back to reducing their returned next event.\n\t\tif (event.ordinal > this.state.lastOrdinal) this.refresh();\n\t\tif (event.ordinal > this.state.lastOrdinal) this.state = reduceOrchestrationEvent(this.state, event);\n\t}\n\n\tprivate compactCurrentProjection(): void {\n\t\tif (this.state.lastOrdinal > 0) {\n\t\t\tthis.store.compactIfNeeded(this.state.lastOrdinal, () => toJsonObject(this.state));\n\t\t}\n\t}\n\n\tprivate nowIso(): string {\n\t\treturn new Date(this.now()).toISOString();\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-prompt-contracts.d.ts","sourceRoot":"","sources":["../../src/core/provider-prompt-contracts.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,2BAA2B,QAO5B,CAAC;AAEb,eAAO,MAAM,mBAAmB,4kBAQwL,CAAC;AAEzN,eAAO,MAAM,6BAA6B,QAI9B,CAAC;AAEb,eAAO,MAAM,gCAAgC,QAIjC,CAAC;AAEb,eAAO,MAAM,wCAAwC,QAGzC,CAAC;AAEb,eAAO,MAAM,2BAA2B,QAM5B,CAAC;AAEb,eAAO,MAAM,gCAAgC,QAKjC,CAAC;AAEb,eAAO,MAAM,yBAAyB,QAM1B,CAAC;AAEb,eAAO,MAAM,0BAA0B,QAI3B,CAAC;AAEb,eAAO,MAAM,6BAA6B,QAG9B,CAAC;AAEb,eAAO,MAAM,4BAA4B,oJACyG,CAAC;AAEnJ,eAAO,MAAM,wBAAwB,QAoBzB,CAAC;AAEb,eAAO,MAAM,sBAAsB,sBAAsB,CAAC;AAC1D,eAAO,MAAM,8BAA8B,QAGhC,CAAC;AAEZ,eAAO,MAAM,uBAAuB,4MACsK,CAAC;AAE3M,wFAAwF;AACxF,wBAAgB,uBAAuB,CAAC,YAAY,EAAE;IACrD,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"provider-prompt-contracts.d.ts","sourceRoot":"","sources":["../../src/core/provider-prompt-contracts.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,2BAA2B,QAO5B,CAAC;AAEb,eAAO,MAAM,mBAAmB,4kBAQwL,CAAC;AAEzN,eAAO,MAAM,6BAA6B,QAI9B,CAAC;AAEb,eAAO,MAAM,gCAAgC,QAIjC,CAAC;AAEb,eAAO,MAAM,wCAAwC,QAGzC,CAAC;AAEb,eAAO,MAAM,2BAA2B,QAM5B,CAAC;AAEb,eAAO,MAAM,gCAAgC,QAKjC,CAAC;AAEb,eAAO,MAAM,yBAAyB,QAM1B,CAAC;AAEb,eAAO,MAAM,0BAA0B,QAI3B,CAAC;AAEb,eAAO,MAAM,6BAA6B,QAG9B,CAAC;AAEb,eAAO,MAAM,4BAA4B,oJACyG,CAAC;AAEnJ,eAAO,MAAM,wBAAwB,QAoBzB,CAAC;AAEb,eAAO,MAAM,sBAAsB,sBAAsB,CAAC;AAC1D,eAAO,MAAM,8BAA8B,QAGhC,CAAC;AAEZ,eAAO,MAAM,uBAAuB,4MACsK,CAAC;AAE3M,wFAAwF;AACxF,wBAAgB,uBAAuB,CAAC,YAAY,EAAE;IACrD,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB,GAAG,MAAM,CAyBT;AAED,wBAAgB,yBAAyB,CAAC,aAAa,EAAE,MAAM,EAAE,YAAY,GAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,MAAM,CAQlH;AAED,eAAO,MAAM,yBAAyB,QAA4D,CAAC;AACnG,eAAO,MAAM,+BAA+B,QAA2D,CAAC;AACxG,eAAO,MAAM,kCAAkC,QAA2D,CAAC"}
|
|
@@ -98,7 +98,8 @@ export function buildWorkerSystemPrompt(capabilities) {
|
|
|
98
98
|
? '{"summary":"<what you did>","status":"completed"|"blocked","blockers":[],"findings":[{"summary":"<finding>","confidence":<0..1>}],"actions":[{"op":"write","path":"<relative path>","content":"<full file content>"},{"op":"edit","path":"<relative path>","old":"<exact text>","new":"<replacement>"}]}'
|
|
99
99
|
: '{"summary":"<what you concluded>","status":"completed"|"blocked","blockers":["<failure or missing authority>"],"findings":[{"summary":"<one concrete finding>","confidence":<0..1>}]}';
|
|
100
100
|
return [
|
|
101
|
-
"Autonomous durable-tree worker; use
|
|
101
|
+
"Autonomous durable-tree worker; use tools. Host enforces grant.",
|
|
102
|
+
"CAVEMAN MODE - MANDATORY: Inherited parent history is context only. Execute only the latest TASK envelope. Parent-owned orchestration stays parent-owned; delegate only when that TASK explicitly assigns delegation.",
|
|
102
103
|
...(capabilities.delegate
|
|
103
104
|
? [
|
|
104
105
|
"Delegate within host depth/child/session/queue bounds; coordinate via list/transcript/messages. Host owns concurrency, budgets, leases, cycles, cancellation.",
|