@caupulican/pi-adaptative 0.86.3 → 0.86.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/core/agent-paths.d.ts +13 -0
  3. package/dist/core/agent-paths.d.ts.map +1 -1
  4. package/dist/core/agent-paths.js +23 -0
  5. package/dist/core/agent-paths.js.map +1 -1
  6. package/dist/core/autonomy/bounded-completion.d.ts +7 -0
  7. package/dist/core/autonomy/bounded-completion.d.ts.map +1 -1
  8. package/dist/core/autonomy/bounded-completion.js +12 -4
  9. package/dist/core/autonomy/bounded-completion.js.map +1 -1
  10. package/dist/core/autonomy/lane-tool-surface.d.ts +2 -0
  11. package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
  12. package/dist/core/autonomy/lane-tool-surface.js +6 -3
  13. package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
  14. package/dist/core/autonomy/subagent-prompt.js +1 -1
  15. package/dist/core/autonomy/subagent-prompt.js.map +1 -1
  16. package/dist/core/background-lane-controller.d.ts +25 -2
  17. package/dist/core/background-lane-controller.d.ts.map +1 -1
  18. package/dist/core/background-lane-controller.js +67 -0
  19. package/dist/core/background-lane-controller.js.map +1 -1
  20. package/dist/core/delegation/replay-safe-mailbox-bounds.d.ts +4 -0
  21. package/dist/core/delegation/replay-safe-mailbox-bounds.d.ts.map +1 -0
  22. package/dist/core/delegation/replay-safe-mailbox-bounds.js +20 -0
  23. package/dist/core/delegation/replay-safe-mailbox-bounds.js.map +1 -0
  24. package/dist/core/delegation/sanitized-context-fork.d.ts +25 -0
  25. package/dist/core/delegation/sanitized-context-fork.d.ts.map +1 -0
  26. package/dist/core/delegation/sanitized-context-fork.js +299 -0
  27. package/dist/core/delegation/sanitized-context-fork.js.map +1 -0
  28. package/dist/core/delegation/session-root-mailbox.d.ts +75 -0
  29. package/dist/core/delegation/session-root-mailbox.d.ts.map +1 -0
  30. package/dist/core/delegation/session-root-mailbox.js +627 -0
  31. package/dist/core/delegation/session-root-mailbox.js.map +1 -0
  32. package/dist/core/delegation/worker-agent-control-coordinator.d.ts +102 -9
  33. package/dist/core/delegation/worker-agent-control-coordinator.d.ts.map +1 -1
  34. package/dist/core/delegation/worker-agent-control-coordinator.js +1307 -125
  35. package/dist/core/delegation/worker-agent-control-coordinator.js.map +1 -1
  36. package/dist/core/delegation/worker-agent-control.d.ts +183 -8
  37. package/dist/core/delegation/worker-agent-control.d.ts.map +1 -1
  38. package/dist/core/delegation/worker-agent-control.js +778 -48
  39. package/dist/core/delegation/worker-agent-control.js.map +1 -1
  40. package/dist/core/delegation/worker-attempt-executor.d.ts +9 -0
  41. package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
  42. package/dist/core/delegation/worker-attempt-executor.js +479 -214
  43. package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
  44. package/dist/core/delegation/worker-authority-resolver.d.ts +9 -0
  45. package/dist/core/delegation/worker-authority-resolver.d.ts.map +1 -1
  46. package/dist/core/delegation/worker-authority-resolver.js +21 -2
  47. package/dist/core/delegation/worker-authority-resolver.js.map +1 -1
  48. package/dist/core/delegation/worker-context-fork-store.d.ts +71 -0
  49. package/dist/core/delegation/worker-context-fork-store.d.ts.map +1 -0
  50. package/dist/core/delegation/worker-context-fork-store.js +437 -0
  51. package/dist/core/delegation/worker-context-fork-store.js.map +1 -0
  52. package/dist/core/delegation/worker-context-inheritance-policy.d.ts +18 -0
  53. package/dist/core/delegation/worker-context-inheritance-policy.d.ts.map +1 -0
  54. package/dist/core/delegation/worker-context-inheritance-policy.js +28 -0
  55. package/dist/core/delegation/worker-context-inheritance-policy.js.map +1 -0
  56. package/dist/core/delegation/worker-conversation-revision.d.ts +31 -0
  57. package/dist/core/delegation/worker-conversation-revision.d.ts.map +1 -0
  58. package/dist/core/delegation/worker-conversation-revision.js +203 -0
  59. package/dist/core/delegation/worker-conversation-revision.js.map +1 -0
  60. package/dist/core/delegation/worker-conversation-store.d.ts +130 -18
  61. package/dist/core/delegation/worker-conversation-store.d.ts.map +1 -1
  62. package/dist/core/delegation/worker-conversation-store.js +1263 -79
  63. package/dist/core/delegation/worker-conversation-store.js.map +1 -1
  64. package/dist/core/delegation/worker-delegation-controller.d.ts +29 -2
  65. package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
  66. package/dist/core/delegation/worker-delegation-controller.js +625 -111
  67. package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
  68. package/dist/core/delegation/worker-delegation-request.d.ts +2 -0
  69. package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -1
  70. package/dist/core/delegation/worker-delegation-request.js.map +1 -1
  71. package/dist/core/delegation/worker-dispatch-scheduler.d.ts +20 -1
  72. package/dist/core/delegation/worker-dispatch-scheduler.d.ts.map +1 -1
  73. package/dist/core/delegation/worker-dispatch-scheduler.js +210 -37
  74. package/dist/core/delegation/worker-dispatch-scheduler.js.map +1 -1
  75. package/dist/core/delegation/worker-fleet-limits.d.ts +38 -0
  76. package/dist/core/delegation/worker-fleet-limits.d.ts.map +1 -0
  77. package/dist/core/delegation/worker-fleet-limits.js +113 -0
  78. package/dist/core/delegation/worker-fleet-limits.js.map +1 -0
  79. package/dist/core/delegation/worker-lane-projection.d.ts +1 -0
  80. package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -1
  81. package/dist/core/delegation/worker-lane-projection.js +6 -2
  82. package/dist/core/delegation/worker-lane-projection.js.map +1 -1
  83. package/dist/core/delegation/worker-lifecycle.d.ts +20 -3
  84. package/dist/core/delegation/worker-lifecycle.d.ts.map +1 -1
  85. package/dist/core/delegation/worker-lifecycle.js +42 -18
  86. package/dist/core/delegation/worker-lifecycle.js.map +1 -1
  87. package/dist/core/delegation/worker-notification-coordinator.d.ts +4 -0
  88. package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -1
  89. package/dist/core/delegation/worker-notification-coordinator.js +45 -4
  90. package/dist/core/delegation/worker-notification-coordinator.js.map +1 -1
  91. package/dist/core/delegation/worker-provider-turn-protocol.d.ts +50 -0
  92. package/dist/core/delegation/worker-provider-turn-protocol.d.ts.map +1 -0
  93. package/dist/core/delegation/worker-provider-turn-protocol.js +185 -0
  94. package/dist/core/delegation/worker-provider-turn-protocol.js.map +1 -0
  95. package/dist/core/delegation/worker-recovery-coordinator.d.ts +45 -4
  96. package/dist/core/delegation/worker-recovery-coordinator.d.ts.map +1 -1
  97. package/dist/core/delegation/worker-recovery-coordinator.js +223 -17
  98. package/dist/core/delegation/worker-recovery-coordinator.js.map +1 -1
  99. package/dist/core/delegation/worker-retry-policy.d.ts +36 -0
  100. package/dist/core/delegation/worker-retry-policy.d.ts.map +1 -0
  101. package/dist/core/delegation/worker-retry-policy.js +41 -0
  102. package/dist/core/delegation/worker-retry-policy.js.map +1 -0
  103. package/dist/core/delegation/worker-runner.d.ts +3 -1
  104. package/dist/core/delegation/worker-runner.d.ts.map +1 -1
  105. package/dist/core/delegation/worker-runner.js +4 -2
  106. package/dist/core/delegation/worker-runner.js.map +1 -1
  107. package/dist/core/delegation/worker-task-view.d.ts +43 -0
  108. package/dist/core/delegation/worker-task-view.d.ts.map +1 -0
  109. package/dist/core/delegation/worker-task-view.js +194 -0
  110. package/dist/core/delegation/worker-task-view.js.map +1 -0
  111. package/dist/core/delegation/worker-terminal-handoff-coordinator.d.ts +55 -0
  112. package/dist/core/delegation/worker-terminal-handoff-coordinator.d.ts.map +1 -0
  113. package/dist/core/delegation/worker-terminal-handoff-coordinator.js +179 -0
  114. package/dist/core/delegation/worker-terminal-handoff-coordinator.js.map +1 -0
  115. package/dist/core/delegation/worker-tree-budget-coordinator.d.ts +2 -2
  116. package/dist/core/delegation/worker-tree-budget-coordinator.d.ts.map +1 -1
  117. package/dist/core/delegation/worker-tree-budget-coordinator.js +12 -46
  118. package/dist/core/delegation/worker-tree-budget-coordinator.js.map +1 -1
  119. package/dist/core/keybindings.d.ts +10 -0
  120. package/dist/core/keybindings.d.ts.map +1 -1
  121. package/dist/core/keybindings.js +2 -0
  122. package/dist/core/keybindings.js.map +1 -1
  123. package/dist/core/orchestration/attempt-ordering.d.ts +9 -0
  124. package/dist/core/orchestration/attempt-ordering.d.ts.map +1 -0
  125. package/dist/core/orchestration/attempt-ordering.js +29 -0
  126. package/dist/core/orchestration/attempt-ordering.js.map +1 -0
  127. package/dist/core/orchestration/capability-gateway.d.ts +19 -0
  128. package/dist/core/orchestration/capability-gateway.d.ts.map +1 -1
  129. package/dist/core/orchestration/capability-gateway.js +19 -2
  130. package/dist/core/orchestration/capability-gateway.js.map +1 -1
  131. package/dist/core/orchestration/contracts.d.ts +43 -3
  132. package/dist/core/orchestration/contracts.d.ts.map +1 -1
  133. package/dist/core/orchestration/contracts.js +24 -0
  134. package/dist/core/orchestration/contracts.js.map +1 -1
  135. package/dist/core/orchestration/delegation-ledger.d.ts +8 -3
  136. package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -1
  137. package/dist/core/orchestration/delegation-ledger.js +148 -55
  138. package/dist/core/orchestration/delegation-ledger.js.map +1 -1
  139. package/dist/core/orchestration/event-store.d.ts +6 -3
  140. package/dist/core/orchestration/event-store.d.ts.map +1 -1
  141. package/dist/core/orchestration/event-store.js +228 -30
  142. package/dist/core/orchestration/event-store.js.map +1 -1
  143. package/dist/core/orchestration/task-runtime-codecs.d.ts +31 -0
  144. package/dist/core/orchestration/task-runtime-codecs.d.ts.map +1 -0
  145. package/dist/core/orchestration/task-runtime-codecs.js +1471 -0
  146. package/dist/core/orchestration/task-runtime-codecs.js.map +1 -0
  147. package/dist/core/orchestration/task-runtime-projection.d.ts +30 -0
  148. package/dist/core/orchestration/task-runtime-projection.d.ts.map +1 -0
  149. package/dist/core/orchestration/task-runtime-projection.js +340 -0
  150. package/dist/core/orchestration/task-runtime-projection.js.map +1 -0
  151. package/dist/core/orchestration/task-runtime-reducer.d.ts +38 -0
  152. package/dist/core/orchestration/task-runtime-reducer.d.ts.map +1 -0
  153. package/dist/core/orchestration/task-runtime-reducer.js +1270 -0
  154. package/dist/core/orchestration/task-runtime-reducer.js.map +1 -0
  155. package/dist/core/orchestration/task-runtime-state.d.ts +142 -0
  156. package/dist/core/orchestration/task-runtime-state.d.ts.map +1 -0
  157. package/dist/core/orchestration/task-runtime-state.js +14 -0
  158. package/dist/core/orchestration/task-runtime-state.js.map +1 -0
  159. package/dist/core/orchestration/task-runtime.d.ts +44 -98
  160. package/dist/core/orchestration/task-runtime.d.ts.map +1 -1
  161. package/dist/core/orchestration/task-runtime.js +357 -1113
  162. package/dist/core/orchestration/task-runtime.js.map +1 -1
  163. package/dist/core/orchestration/worker-context-fork-reference.d.ts +20 -0
  164. package/dist/core/orchestration/worker-context-fork-reference.d.ts.map +1 -0
  165. package/dist/core/orchestration/worker-context-fork-reference.js +53 -0
  166. package/dist/core/orchestration/worker-context-fork-reference.js.map +1 -0
  167. package/dist/core/research/research-runner.d.ts +2 -0
  168. package/dist/core/research/research-runner.d.ts.map +1 -1
  169. package/dist/core/research/research-runner.js +1 -0
  170. package/dist/core/research/research-runner.js.map +1 -1
  171. package/dist/core/runtime-builder.d.ts.map +1 -1
  172. package/dist/core/runtime-builder.js +8 -0
  173. package/dist/core/runtime-builder.js.map +1 -1
  174. package/dist/core/secrets/credential-project.d.ts.map +1 -1
  175. package/dist/core/secrets/credential-project.js +24 -2
  176. package/dist/core/secrets/credential-project.js.map +1 -1
  177. package/dist/core/security/secret-text.d.ts +3 -0
  178. package/dist/core/security/secret-text.d.ts.map +1 -1
  179. package/dist/core/security/secret-text.js +15 -0
  180. package/dist/core/security/secret-text.js.map +1 -1
  181. package/dist/core/settings-manager.d.ts +3 -0
  182. package/dist/core/settings-manager.d.ts.map +1 -1
  183. package/dist/core/settings-manager.js +160 -8
  184. package/dist/core/settings-manager.js.map +1 -1
  185. package/dist/core/tools/delegate.d.ts +31 -4
  186. package/dist/core/tools/delegate.d.ts.map +1 -1
  187. package/dist/core/tools/delegate.js +749 -103
  188. package/dist/core/tools/delegate.js.map +1 -1
  189. package/dist/main.d.ts.map +1 -1
  190. package/dist/main.js +1 -0
  191. package/dist/main.js.map +1 -1
  192. package/dist/modes/interactive/components/activity-lane.d.ts +5 -0
  193. package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -1
  194. package/dist/modes/interactive/components/activity-lane.js +133 -49
  195. package/dist/modes/interactive/components/activity-lane.js.map +1 -1
  196. package/dist/modes/interactive/components/agents-overlay.d.ts +40 -0
  197. package/dist/modes/interactive/components/agents-overlay.d.ts.map +1 -0
  198. package/dist/modes/interactive/components/agents-overlay.js +153 -0
  199. package/dist/modes/interactive/components/agents-overlay.js.map +1 -0
  200. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  201. package/dist/modes/interactive/components/settings-selector.js +18 -13
  202. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  203. package/dist/modes/interactive/interactive-event-controller.d.ts +1 -1
  204. package/dist/modes/interactive/interactive-event-controller.d.ts.map +1 -1
  205. package/dist/modes/interactive/interactive-event-controller.js +6 -3
  206. package/dist/modes/interactive/interactive-event-controller.js.map +1 -1
  207. package/dist/modes/interactive/interactive-mode.d.ts +5 -0
  208. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  209. package/dist/modes/interactive/interactive-mode.js +51 -0
  210. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  211. package/dist/modes/interactive/key-handlers.d.ts +1 -0
  212. package/dist/modes/interactive/key-handlers.d.ts.map +1 -1
  213. package/dist/modes/interactive/key-handlers.js +1 -0
  214. package/dist/modes/interactive/key-handlers.js.map +1 -1
  215. package/docs/harness-architecture.md +61 -17
  216. package/docs/settings.md +17 -9
  217. package/docs/worker-profiles.md +6 -2
  218. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  219. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  220. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  221. package/examples/extensions/sandbox/package-lock.json +2 -2
  222. package/examples/extensions/sandbox/package.json +1 -1
  223. package/examples/extensions/with-deps/package-lock.json +2 -2
  224. package/examples/extensions/with-deps/package.json +1 -1
  225. package/npm-shrinkwrap.json +12 -12
  226. package/package.json +4 -4
@@ -0,0 +1,340 @@
1
+ import { MAX_ORCHESTRATION_AGENT_BINDINGS, MAX_ORCHESTRATION_APPROVALS, MAX_ORCHESTRATION_ATTEMPTS, MAX_ORCHESTRATION_CHECKPOINT_SUMMARY_LENGTH, MAX_ORCHESTRATION_CHECKPOINTS, MAX_ORCHESTRATION_COLLECTION_LENGTH, MAX_ORCHESTRATION_EVIDENCE, MAX_ORCHESTRATION_IDENTIFIER_LENGTH, MAX_ORCHESTRATION_NOTIFICATIONS, MAX_ORCHESTRATION_OBJECTIVE_EVIDENCE, MAX_ORCHESTRATION_OBJECTIVES, MAX_ORCHESTRATION_PROJECTION_BYTES, MAX_ORCHESTRATION_RETAINED_RECORD_BYTES, MAX_ORCHESTRATION_TASKS, } from "./contracts.js";
2
+ import { DurableTaskRuntimeError, } from "./task-runtime-state.js";
3
+ export function emptyProjection() {
4
+ return {
5
+ lastOrdinal: 0,
6
+ agents: {},
7
+ objectives: {},
8
+ tasks: {},
9
+ attempts: {},
10
+ checkpoints: {},
11
+ approvals: {},
12
+ notifications: {},
13
+ };
14
+ }
15
+ export const PROJECTION_RECORD_FIELDS = [
16
+ "agents",
17
+ "objectives",
18
+ "tasks",
19
+ "attempts",
20
+ "checkpoints",
21
+ "approvals",
22
+ "notifications",
23
+ ];
24
+ const projectionSerializedByteCache = new WeakMap();
25
+ const retainedRecordSerializedByteCache = new WeakMap();
26
+ function serializedJsonBytes(value, label) {
27
+ let serialized;
28
+ try {
29
+ serialized = JSON.stringify(value);
30
+ }
31
+ catch (error) {
32
+ throw new DurableTaskRuntimeError(`${label} is not serializable: ${error instanceof Error ? error.message : String(error)}`);
33
+ }
34
+ if (serialized === undefined)
35
+ throw new DurableTaskRuntimeError(`${label} is not serializable.`);
36
+ return Buffer.byteLength(serialized, "utf8");
37
+ }
38
+ function retainedRecordSerializedBytes(value, label) {
39
+ if (!value || typeof value !== "object") {
40
+ throw new DurableTaskRuntimeError(`${label} retained record is invalid.`);
41
+ }
42
+ const cached = retainedRecordSerializedByteCache.get(value);
43
+ if (cached !== undefined)
44
+ return cached;
45
+ const bytes = serializedJsonBytes(value, label);
46
+ if (bytes > MAX_ORCHESTRATION_RETAINED_RECORD_BYTES) {
47
+ throw new DurableTaskRuntimeError(`${label} retained record exceeds its ${MAX_ORCHESTRATION_RETAINED_RECORD_BYTES}-byte limit.`);
48
+ }
49
+ retainedRecordSerializedByteCache.set(value, bytes);
50
+ return bytes;
51
+ }
52
+ function retainedRecordKeyBytes(key, label) {
53
+ if (!key || key.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH) {
54
+ throw new DurableTaskRuntimeError(`${label} retained record key exceeds its identifier bound.`);
55
+ }
56
+ return serializedJsonBytes(key, `${label} retained record key`);
57
+ }
58
+ function emptyProjectionSerializedBytes(lastOrdinal) {
59
+ return serializedJsonBytes({
60
+ lastOrdinal,
61
+ agents: {},
62
+ objectives: {},
63
+ tasks: {},
64
+ attempts: {},
65
+ checkpoints: {},
66
+ approvals: {},
67
+ notifications: {},
68
+ }, "Orchestration projection");
69
+ }
70
+ /** Compute once for snapshots/external projections; reducer-produced projections carry a delta cache. */
71
+ export function projectionSerializedBytes(projection) {
72
+ const cached = projectionSerializedByteCache.get(projection);
73
+ if (cached !== undefined)
74
+ return cached;
75
+ const expectedFields = new Set(["lastOrdinal", ...PROJECTION_RECORD_FIELDS]);
76
+ const unsupported = Object.keys(projection).find((field) => !expectedFields.has(field));
77
+ if (unsupported)
78
+ throw new DurableTaskRuntimeError(`Orchestration projection.${unsupported} is unsupported.`);
79
+ let bytes = emptyProjectionSerializedBytes(projection.lastOrdinal);
80
+ for (const field of PROJECTION_RECORD_FIELDS) {
81
+ let entryCount = 0;
82
+ for (const [key, value] of Object.entries(projection[field])) {
83
+ bytes +=
84
+ (entryCount > 0 ? 1 : 0) +
85
+ retainedRecordKeyBytes(key, `Orchestration projection.${field}.${key}`) +
86
+ 1 +
87
+ retainedRecordSerializedBytes(value, `Orchestration projection.${field}.${key}`);
88
+ entryCount += 1;
89
+ if (bytes > MAX_ORCHESTRATION_PROJECTION_BYTES) {
90
+ throw new DurableTaskRuntimeError(`Orchestration projection exceeds its ${MAX_ORCHESTRATION_PROJECTION_BYTES}-byte limit.`);
91
+ }
92
+ }
93
+ }
94
+ projectionSerializedByteCache.set(projection, bytes);
95
+ return bytes;
96
+ }
97
+ export function assertProjectionRecordReplacementWithinLimits(projection, field, key, value) {
98
+ const label = `Orchestration projection.${field}.${key}`;
99
+ const current = projection[field][key];
100
+ const nextRecordBytes = retainedRecordSerializedBytes(value, label);
101
+ const currentRecordBytes = current ? retainedRecordSerializedBytes(current, label) : 0;
102
+ const insertionBytes = current
103
+ ? 0
104
+ : retainedRecordKeyBytes(key, label) + 1 + (countRecordEntries(projection[field]) > 0 ? 1 : 0);
105
+ if (projectionSerializedBytes(projection) + insertionBytes + nextRecordBytes - currentRecordBytes >
106
+ MAX_ORCHESTRATION_PROJECTION_BYTES) {
107
+ throw new DurableTaskRuntimeError(`Orchestration projection exceeds its ${MAX_ORCHESTRATION_PROJECTION_BYTES}-byte limit.`);
108
+ }
109
+ }
110
+ export class ProjectionByteTracker {
111
+ constructor(source) {
112
+ this.entryCounts = new Map();
113
+ this.source = source;
114
+ this.bytes = projectionSerializedBytes(source);
115
+ }
116
+ track(field, target) {
117
+ this.entryCounts.set(field, countRecordEntries(target));
118
+ return new Proxy(target, {
119
+ set: (record, property, value) => {
120
+ if (typeof property !== "string") {
121
+ throw new DurableTaskRuntimeError(`Orchestration projection.${field} record key is invalid.`);
122
+ }
123
+ const label = `Orchestration projection.${field}.${property}`;
124
+ const exists = Object.hasOwn(record, property);
125
+ const nextRecordBytes = retainedRecordSerializedBytes(value, label);
126
+ const previousRecordBytes = exists ? retainedRecordSerializedBytes(record[property], label) : 0;
127
+ const keyAndSeparatorBytes = exists
128
+ ? 0
129
+ : retainedRecordKeyBytes(property, label) + 1 + ((this.entryCounts.get(field) ?? 0) > 0 ? 1 : 0);
130
+ const nextBytes = this.bytes + keyAndSeparatorBytes + nextRecordBytes - previousRecordBytes;
131
+ if (nextBytes > MAX_ORCHESTRATION_PROJECTION_BYTES) {
132
+ throw new DurableTaskRuntimeError(`Orchestration projection exceeds its ${MAX_ORCHESTRATION_PROJECTION_BYTES}-byte limit.`);
133
+ }
134
+ Reflect.set(record, property, value);
135
+ this.bytes = nextBytes;
136
+ if (!exists)
137
+ this.entryCounts.set(field, (this.entryCounts.get(field) ?? 0) + 1);
138
+ return true;
139
+ },
140
+ });
141
+ }
142
+ finish(nextOrdinal) {
143
+ this.bytes +=
144
+ serializedJsonBytes(nextOrdinal, "Orchestration projection ordinal") -
145
+ serializedJsonBytes(this.source.lastOrdinal, "Orchestration projection ordinal");
146
+ if (this.bytes > MAX_ORCHESTRATION_PROJECTION_BYTES) {
147
+ throw new DurableTaskRuntimeError(`Orchestration projection exceeds its ${MAX_ORCHESTRATION_PROJECTION_BYTES}-byte limit.`);
148
+ }
149
+ return this.bytes;
150
+ }
151
+ }
152
+ export function cloneProjection(state) {
153
+ return structuredClone(state);
154
+ }
155
+ export function record(value, label) {
156
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
157
+ throw new DurableTaskRuntimeError(`${label} is not an object.`);
158
+ }
159
+ return value;
160
+ }
161
+ export function exactRecord(value, label, allowedFields) {
162
+ const parsed = record(value, label);
163
+ const unsupported = Object.keys(parsed).find((field) => !allowedFields.includes(field));
164
+ if (unsupported)
165
+ throw new DurableTaskRuntimeError(`${label}.${unsupported} is unsupported.`);
166
+ return parsed;
167
+ }
168
+ export function assertRecordWithinLimit(values, limit, label) {
169
+ let count = 0;
170
+ for (const key in values) {
171
+ if (!Object.hasOwn(values, key))
172
+ continue;
173
+ count += 1;
174
+ if (count > limit) {
175
+ throw new DurableTaskRuntimeError(`Orchestration ${label} limit (${limit}) exceeded.`);
176
+ }
177
+ }
178
+ }
179
+ export function assertRecordHasCapacity(values, limit, label) {
180
+ let count = 0;
181
+ for (const key in values) {
182
+ if (!Object.hasOwn(values, key))
183
+ continue;
184
+ count += 1;
185
+ if (count >= limit) {
186
+ throw new DurableTaskRuntimeError(`Orchestration ${label} limit (${limit}) reached.`);
187
+ }
188
+ }
189
+ }
190
+ export function assertIdentifierListHasCapacity(values, limit, label) {
191
+ if (values.length >= limit) {
192
+ throw new DurableTaskRuntimeError(`Orchestration ${label} limit (${limit}) reached.`);
193
+ }
194
+ }
195
+ export function assertObjectiveEvidenceHasCapacity(objectives, objective) {
196
+ if (objective.evidence.length >= MAX_ORCHESTRATION_OBJECTIVE_EVIDENCE) {
197
+ throw new DurableTaskRuntimeError(`Orchestration objective evidence limit (${MAX_ORCHESTRATION_OBJECTIVE_EVIDENCE}) reached.`);
198
+ }
199
+ let count = 0;
200
+ for (const objectiveId in objectives) {
201
+ if (!Object.hasOwn(objectives, objectiveId))
202
+ continue;
203
+ count += objectives[objectiveId]?.evidence.length ?? 0;
204
+ if (count >= MAX_ORCHESTRATION_EVIDENCE) {
205
+ throw new DurableTaskRuntimeError(`Orchestration evidence limit (${MAX_ORCHESTRATION_EVIDENCE}) reached.`);
206
+ }
207
+ }
208
+ }
209
+ export function assertBoundedIdentifierList(value, limit, label) {
210
+ if (!Array.isArray(value) || value.length > limit) {
211
+ throw new DurableTaskRuntimeError(`${label} exceeds its retained collection limit (${limit}).`);
212
+ }
213
+ const identities = new Set();
214
+ for (const entry of value) {
215
+ if (typeof entry !== "string" ||
216
+ entry.length === 0 ||
217
+ entry.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||
218
+ identities.has(entry)) {
219
+ throw new DurableTaskRuntimeError(`${label} must contain unique bounded identifiers.`);
220
+ }
221
+ identities.add(entry);
222
+ }
223
+ }
224
+ export function retainedIdentifierArray(value, limit, label) {
225
+ assertBoundedIdentifierList(value, limit, label);
226
+ return [...value];
227
+ }
228
+ export function assertRetainedProjectionNestedCollections(objectives, tasks, attempts, checkpoints, label) {
229
+ let evidenceCount = 0;
230
+ for (const objectiveId in objectives) {
231
+ if (!Object.hasOwn(objectives, objectiveId))
232
+ continue;
233
+ const objective = record(objectives[objectiveId], `${label}.objectives.${objectiveId}`);
234
+ assertBoundedIdentifierList(objective.taskIds, MAX_ORCHESTRATION_TASKS, `${label}.objectives.${objectiveId}.taskIds`);
235
+ if (!Array.isArray(objective.evidence)) {
236
+ throw new DurableTaskRuntimeError(`${label}.objectives.${objectiveId}.evidence must be an array.`);
237
+ }
238
+ if (objective.evidence.length > MAX_ORCHESTRATION_OBJECTIVE_EVIDENCE) {
239
+ throw new DurableTaskRuntimeError(`Orchestration objective evidence limit (${MAX_ORCHESTRATION_OBJECTIVE_EVIDENCE}) exceeded.`);
240
+ }
241
+ evidenceCount += objective.evidence.length;
242
+ if (evidenceCount > MAX_ORCHESTRATION_EVIDENCE) {
243
+ throw new DurableTaskRuntimeError(`Orchestration evidence limit (${MAX_ORCHESTRATION_EVIDENCE}) exceeded.`);
244
+ }
245
+ }
246
+ for (const taskId in tasks) {
247
+ if (!Object.hasOwn(tasks, taskId))
248
+ continue;
249
+ const task = record(tasks[taskId], `${label}.tasks.${taskId}`);
250
+ assertBoundedIdentifierList(task.attemptIds, MAX_ORCHESTRATION_ATTEMPTS, `${label}.tasks.${taskId}.attemptIds`);
251
+ }
252
+ for (const attemptId in attempts) {
253
+ if (!Object.hasOwn(attempts, attemptId))
254
+ continue;
255
+ const attempt = record(attempts[attemptId], `${label}.attempts.${attemptId}`);
256
+ assertBoundedIdentifierList(attempt.checkpointIds, MAX_ORCHESTRATION_CHECKPOINTS, `${label}.attempts.${attemptId}.checkpointIds`);
257
+ }
258
+ for (const checkpointId in checkpoints) {
259
+ if (!Object.hasOwn(checkpoints, checkpointId))
260
+ continue;
261
+ const checkpoint = record(checkpoints[checkpointId], `${label}.checkpoints.${checkpointId}`);
262
+ const summary = checkpoint.summary;
263
+ if (typeof summary !== "string" || summary.length === 0) {
264
+ throw new DurableTaskRuntimeError(`${label}.checkpoints.${checkpointId}.summary is required.`);
265
+ }
266
+ if (summary.length > MAX_ORCHESTRATION_CHECKPOINT_SUMMARY_LENGTH) {
267
+ throw new DurableTaskRuntimeError(`${label}.checkpoints.${checkpointId}.summary exceeds its durable size bound.`);
268
+ }
269
+ assertBoundedIdentifierList(checkpoint.artifactIds, MAX_ORCHESTRATION_COLLECTION_LENGTH, `${label}.checkpoints.${checkpointId}.artifactIds`);
270
+ assertBoundedIdentifierList(checkpoint.evidenceIds, MAX_ORCHESTRATION_COLLECTION_LENGTH, `${label}.checkpoints.${checkpointId}.evidenceIds`);
271
+ }
272
+ return evidenceCount;
273
+ }
274
+ export function assertProjectionWithinLimits(projection) {
275
+ assertRecordWithinLimit(projection.agents, MAX_ORCHESTRATION_AGENT_BINDINGS, "agent binding");
276
+ assertRecordWithinLimit(projection.objectives, MAX_ORCHESTRATION_OBJECTIVES, "objective");
277
+ assertRecordWithinLimit(projection.tasks, MAX_ORCHESTRATION_TASKS, "task");
278
+ assertRecordWithinLimit(projection.attempts, MAX_ORCHESTRATION_ATTEMPTS, "attempt");
279
+ assertRecordWithinLimit(projection.checkpoints, MAX_ORCHESTRATION_CHECKPOINTS, "checkpoint");
280
+ assertRecordWithinLimit(projection.approvals, MAX_ORCHESTRATION_APPROVALS, "approval");
281
+ assertRecordWithinLimit(projection.notifications, MAX_ORCHESTRATION_NOTIFICATIONS, "notification");
282
+ assertRetainedProjectionNestedCollections(projection.objectives, projection.tasks, projection.attempts, projection.checkpoints, "orchestration projection");
283
+ projectionSerializedBytes(projection);
284
+ }
285
+ function countRecordEntries(values) {
286
+ let count = 0;
287
+ for (const key in values) {
288
+ if (Object.hasOwn(values, key))
289
+ count += 1;
290
+ }
291
+ return count;
292
+ }
293
+ export function projectionCapacity(projection) {
294
+ const evidence = assertRetainedProjectionNestedCollections(projection.objectives, projection.tasks, projection.attempts, projection.checkpoints, "orchestration projection");
295
+ const counts = {
296
+ agents: countRecordEntries(projection.agents),
297
+ objectives: countRecordEntries(projection.objectives),
298
+ tasks: countRecordEntries(projection.tasks),
299
+ attempts: countRecordEntries(projection.attempts),
300
+ checkpoints: countRecordEntries(projection.checkpoints),
301
+ approvals: countRecordEntries(projection.approvals),
302
+ notifications: countRecordEntries(projection.notifications),
303
+ evidence,
304
+ };
305
+ const limits = {
306
+ agents: MAX_ORCHESTRATION_AGENT_BINDINGS,
307
+ objectives: MAX_ORCHESTRATION_OBJECTIVES,
308
+ tasks: MAX_ORCHESTRATION_TASKS,
309
+ attempts: MAX_ORCHESTRATION_ATTEMPTS,
310
+ checkpoints: MAX_ORCHESTRATION_CHECKPOINTS,
311
+ approvals: MAX_ORCHESTRATION_APPROVALS,
312
+ notifications: MAX_ORCHESTRATION_NOTIFICATIONS,
313
+ evidence: MAX_ORCHESTRATION_EVIDENCE,
314
+ };
315
+ return {
316
+ counts,
317
+ limits,
318
+ headroom: {
319
+ agents: limits.agents - counts.agents,
320
+ objectives: limits.objectives - counts.objectives,
321
+ tasks: limits.tasks - counts.tasks,
322
+ attempts: limits.attempts - counts.attempts,
323
+ checkpoints: limits.checkpoints - counts.checkpoints,
324
+ approvals: limits.approvals - counts.approvals,
325
+ notifications: limits.notifications - counts.notifications,
326
+ evidence: limits.evidence - counts.evidence,
327
+ },
328
+ };
329
+ }
330
+ export function requestedProjectionSlots(value, label) {
331
+ const slots = value ?? 0;
332
+ if (!Number.isSafeInteger(slots) || slots < 0) {
333
+ throw new DurableTaskRuntimeError(`${label} projection slots must be a non-negative safe integer.`);
334
+ }
335
+ return slots;
336
+ }
337
+ export function cacheProjectionSerializedBytes(projection, bytes) {
338
+ projectionSerializedByteCache.set(projection, bytes);
339
+ }
340
+ //# sourceMappingURL=task-runtime-projection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-runtime-projection.js","sourceRoot":"","sources":["../../../src/core/orchestration/task-runtime-projection.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,gCAAgC,EA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MAAM,CAAC,QAAQ;YAC3C,WAAW,EAAE,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW;YACpD,SAAS,EAAE,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS;YAC9C,aAAa,EAAE,MAAM,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa;YAC1D,QAAQ,EAAE,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ;SAC3C;KACD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,KAAyB,EAAE,KAAa;IAChF,MAAM,KAAK,GAAG,KAAK,IAAI,CAAC,CAAC;IACzB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,uBAAuB,CAAC,GAAG,KAAK,wDAAwD,CAAC,CAAC;IACrG,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,MAAM,UAAU,8BAA8B,CAAC,UAAiC,EAAE,KAAa;IAC9F,6BAA6B,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AACtD,CAAC","sourcesContent":["import {\n\tMAX_ORCHESTRATION_AGENT_BINDINGS,\n\tMAX_ORCHESTRATION_APPROVALS,\n\tMAX_ORCHESTRATION_ATTEMPTS,\n\tMAX_ORCHESTRATION_CHECKPOINT_SUMMARY_LENGTH,\n\tMAX_ORCHESTRATION_CHECKPOINTS,\n\tMAX_ORCHESTRATION_COLLECTION_LENGTH,\n\tMAX_ORCHESTRATION_EVIDENCE,\n\tMAX_ORCHESTRATION_IDENTIFIER_LENGTH,\n\tMAX_ORCHESTRATION_NOTIFICATIONS,\n\tMAX_ORCHESTRATION_OBJECTIVE_EVIDENCE,\n\tMAX_ORCHESTRATION_OBJECTIVES,\n\tMAX_ORCHESTRATION_PROJECTION_BYTES,\n\tMAX_ORCHESTRATION_RETAINED_RECORD_BYTES,\n\tMAX_ORCHESTRATION_TASKS,\n} from \"./contracts.ts\";\nimport {\n\tDurableTaskRuntimeError,\n\ttype ObjectiveRuntimeState,\n\ttype OrchestrationProjectionCapacity,\n\ttype TaskRuntimeProjection,\n} from \"./task-runtime-state.ts\";\n\nexport function emptyProjection(): TaskRuntimeProjection {\n\treturn {\n\t\tlastOrdinal: 0,\n\t\tagents: {},\n\t\tobjectives: {},\n\t\ttasks: {},\n\t\tattempts: {},\n\t\tcheckpoints: {},\n\t\tapprovals: {},\n\t\tnotifications: {},\n\t};\n}\n\nexport const PROJECTION_RECORD_FIELDS = [\n\t\"agents\",\n\t\"objectives\",\n\t\"tasks\",\n\t\"attempts\",\n\t\"checkpoints\",\n\t\"approvals\",\n\t\"notifications\",\n] as const;\n\nexport type ProjectionRecordField = (typeof PROJECTION_RECORD_FIELDS)[number];\n\nconst projectionSerializedByteCache = new WeakMap<TaskRuntimeProjection, number>();\nconst retainedRecordSerializedByteCache = new WeakMap<object, number>();\n\nfunction serializedJsonBytes(value: unknown, label: string): number {\n\tlet serialized: string | undefined;\n\ttry {\n\t\tserialized = JSON.stringify(value);\n\t} catch (error) {\n\t\tthrow new DurableTaskRuntimeError(\n\t\t\t`${label} is not serializable: ${error instanceof Error ? error.message : String(error)}`,\n\t\t);\n\t}\n\tif (serialized === undefined) throw new DurableTaskRuntimeError(`${label} is not serializable.`);\n\treturn Buffer.byteLength(serialized, \"utf8\");\n}\n\nfunction retainedRecordSerializedBytes(value: unknown, label: string): number {\n\tif (!value || typeof value !== \"object\") {\n\t\tthrow new DurableTaskRuntimeError(`${label} retained record is invalid.`);\n\t}\n\tconst cached = retainedRecordSerializedByteCache.get(value);\n\tif (cached !== undefined) return cached;\n\tconst bytes = serializedJsonBytes(value, label);\n\tif (bytes > MAX_ORCHESTRATION_RETAINED_RECORD_BYTES) {\n\t\tthrow new DurableTaskRuntimeError(\n\t\t\t`${label} retained record exceeds its ${MAX_ORCHESTRATION_RETAINED_RECORD_BYTES}-byte limit.`,\n\t\t);\n\t}\n\tretainedRecordSerializedByteCache.set(value, bytes);\n\treturn bytes;\n}\n\nfunction retainedRecordKeyBytes(key: string, label: string): number {\n\tif (!key || key.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH) {\n\t\tthrow new DurableTaskRuntimeError(`${label} retained record key exceeds its identifier bound.`);\n\t}\n\treturn serializedJsonBytes(key, `${label} retained record key`);\n}\n\nfunction emptyProjectionSerializedBytes(lastOrdinal: number): number {\n\treturn serializedJsonBytes(\n\t\t{\n\t\t\tlastOrdinal,\n\t\t\tagents: {},\n\t\t\tobjectives: {},\n\t\t\ttasks: {},\n\t\t\tattempts: {},\n\t\t\tcheckpoints: {},\n\t\t\tapprovals: {},\n\t\t\tnotifications: {},\n\t\t},\n\t\t\"Orchestration projection\",\n\t);\n}\n\n/** Compute once for snapshots/external projections; reducer-produced projections carry a delta cache. */\nexport function projectionSerializedBytes(projection: TaskRuntimeProjection): number {\n\tconst cached = projectionSerializedByteCache.get(projection);\n\tif (cached !== undefined) return cached;\n\tconst expectedFields = new Set<string>([\"lastOrdinal\", ...PROJECTION_RECORD_FIELDS]);\n\tconst unsupported = Object.keys(projection).find((field) => !expectedFields.has(field));\n\tif (unsupported) throw new DurableTaskRuntimeError(`Orchestration projection.${unsupported} is unsupported.`);\n\tlet bytes = emptyProjectionSerializedBytes(projection.lastOrdinal);\n\tfor (const field of PROJECTION_RECORD_FIELDS) {\n\t\tlet entryCount = 0;\n\t\tfor (const [key, value] of Object.entries(projection[field])) {\n\t\t\tbytes +=\n\t\t\t\t(entryCount > 0 ? 1 : 0) +\n\t\t\t\tretainedRecordKeyBytes(key, `Orchestration projection.${field}.${key}`) +\n\t\t\t\t1 +\n\t\t\t\tretainedRecordSerializedBytes(value, `Orchestration projection.${field}.${key}`);\n\t\t\tentryCount += 1;\n\t\t\tif (bytes > MAX_ORCHESTRATION_PROJECTION_BYTES) {\n\t\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t\t`Orchestration projection exceeds its ${MAX_ORCHESTRATION_PROJECTION_BYTES}-byte limit.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\tprojectionSerializedByteCache.set(projection, bytes);\n\treturn bytes;\n}\n\nexport function assertProjectionRecordReplacementWithinLimits(\n\tprojection: TaskRuntimeProjection,\n\tfield: ProjectionRecordField,\n\tkey: string,\n\tvalue: object,\n): void {\n\tconst label = `Orchestration projection.${field}.${key}`;\n\tconst current = projection[field][key];\n\tconst nextRecordBytes = retainedRecordSerializedBytes(value, label);\n\tconst currentRecordBytes = current ? retainedRecordSerializedBytes(current, label) : 0;\n\tconst insertionBytes = current\n\t\t? 0\n\t\t: retainedRecordKeyBytes(key, label) + 1 + (countRecordEntries(projection[field]) > 0 ? 1 : 0);\n\tif (\n\t\tprojectionSerializedBytes(projection) + insertionBytes + nextRecordBytes - currentRecordBytes >\n\t\tMAX_ORCHESTRATION_PROJECTION_BYTES\n\t) {\n\t\tthrow new DurableTaskRuntimeError(\n\t\t\t`Orchestration projection exceeds its ${MAX_ORCHESTRATION_PROJECTION_BYTES}-byte limit.`,\n\t\t);\n\t}\n}\n\nexport class ProjectionByteTracker {\n\tprivate bytes: number;\n\tprivate readonly entryCounts = new Map<ProjectionRecordField, number>();\n\tprivate readonly source: TaskRuntimeProjection;\n\n\tconstructor(source: TaskRuntimeProjection) {\n\t\tthis.source = source;\n\t\tthis.bytes = projectionSerializedBytes(source);\n\t}\n\n\ttrack<Value>(field: ProjectionRecordField, target: Record<string, Value>): Record<string, Value> {\n\t\tthis.entryCounts.set(field, countRecordEntries(target));\n\t\treturn new Proxy(target, {\n\t\t\tset: (record, property, value) => {\n\t\t\t\tif (typeof property !== \"string\") {\n\t\t\t\t\tthrow new DurableTaskRuntimeError(`Orchestration projection.${field} record key is invalid.`);\n\t\t\t\t}\n\t\t\t\tconst label = `Orchestration projection.${field}.${property}`;\n\t\t\t\tconst exists = Object.hasOwn(record, property);\n\t\t\t\tconst nextRecordBytes = retainedRecordSerializedBytes(value, label);\n\t\t\t\tconst previousRecordBytes = exists ? retainedRecordSerializedBytes(record[property], label) : 0;\n\t\t\t\tconst keyAndSeparatorBytes = exists\n\t\t\t\t\t? 0\n\t\t\t\t\t: retainedRecordKeyBytes(property, label) + 1 + ((this.entryCounts.get(field) ?? 0) > 0 ? 1 : 0);\n\t\t\t\tconst nextBytes = this.bytes + keyAndSeparatorBytes + nextRecordBytes - previousRecordBytes;\n\t\t\t\tif (nextBytes > MAX_ORCHESTRATION_PROJECTION_BYTES) {\n\t\t\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t\t\t`Orchestration projection exceeds its ${MAX_ORCHESTRATION_PROJECTION_BYTES}-byte limit.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tReflect.set(record, property, value);\n\t\t\t\tthis.bytes = nextBytes;\n\t\t\t\tif (!exists) this.entryCounts.set(field, (this.entryCounts.get(field) ?? 0) + 1);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t});\n\t}\n\n\tfinish(nextOrdinal: number): number {\n\t\tthis.bytes +=\n\t\t\tserializedJsonBytes(nextOrdinal, \"Orchestration projection ordinal\") -\n\t\t\tserializedJsonBytes(this.source.lastOrdinal, \"Orchestration projection ordinal\");\n\t\tif (this.bytes > MAX_ORCHESTRATION_PROJECTION_BYTES) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`Orchestration projection exceeds its ${MAX_ORCHESTRATION_PROJECTION_BYTES}-byte limit.`,\n\t\t\t);\n\t\t}\n\t\treturn this.bytes;\n\t}\n}\n\nexport function cloneProjection(state: TaskRuntimeProjection): TaskRuntimeProjection {\n\treturn structuredClone(state);\n}\n\nexport function record(value: unknown, label: string): Record<string, unknown> {\n\tif (!value || typeof value !== \"object\" || Array.isArray(value)) {\n\t\tthrow new DurableTaskRuntimeError(`${label} is not an object.`);\n\t}\n\treturn value as Record<string, unknown>;\n}\n\nexport function exactRecord(value: unknown, label: string, allowedFields: readonly string[]): Record<string, unknown> {\n\tconst parsed = record(value, label);\n\tconst unsupported = Object.keys(parsed).find((field) => !allowedFields.includes(field));\n\tif (unsupported) throw new DurableTaskRuntimeError(`${label}.${unsupported} is unsupported.`);\n\treturn parsed;\n}\n\nexport function assertRecordWithinLimit(values: Readonly<Record<string, unknown>>, limit: number, label: string): void {\n\tlet count = 0;\n\tfor (const key in values) {\n\t\tif (!Object.hasOwn(values, key)) continue;\n\t\tcount += 1;\n\t\tif (count > limit) {\n\t\t\tthrow new DurableTaskRuntimeError(`Orchestration ${label} limit (${limit}) exceeded.`);\n\t\t}\n\t}\n}\n\nexport function assertRecordHasCapacity(values: Readonly<Record<string, unknown>>, limit: number, label: string): void {\n\tlet count = 0;\n\tfor (const key in values) {\n\t\tif (!Object.hasOwn(values, key)) continue;\n\t\tcount += 1;\n\t\tif (count >= limit) {\n\t\t\tthrow new DurableTaskRuntimeError(`Orchestration ${label} limit (${limit}) reached.`);\n\t\t}\n\t}\n}\n\nexport function assertIdentifierListHasCapacity(values: readonly string[], limit: number, label: string): void {\n\tif (values.length >= limit) {\n\t\tthrow new DurableTaskRuntimeError(`Orchestration ${label} limit (${limit}) reached.`);\n\t}\n}\n\nexport function assertObjectiveEvidenceHasCapacity(\n\tobjectives: Readonly<Record<string, ObjectiveRuntimeState>>,\n\tobjective: ObjectiveRuntimeState,\n): void {\n\tif (objective.evidence.length >= MAX_ORCHESTRATION_OBJECTIVE_EVIDENCE) {\n\t\tthrow new DurableTaskRuntimeError(\n\t\t\t`Orchestration objective evidence limit (${MAX_ORCHESTRATION_OBJECTIVE_EVIDENCE}) reached.`,\n\t\t);\n\t}\n\tlet count = 0;\n\tfor (const objectiveId in objectives) {\n\t\tif (!Object.hasOwn(objectives, objectiveId)) continue;\n\t\tcount += objectives[objectiveId]?.evidence.length ?? 0;\n\t\tif (count >= MAX_ORCHESTRATION_EVIDENCE) {\n\t\t\tthrow new DurableTaskRuntimeError(`Orchestration evidence limit (${MAX_ORCHESTRATION_EVIDENCE}) reached.`);\n\t\t}\n\t}\n}\n\nexport function assertBoundedIdentifierList(\n\tvalue: unknown,\n\tlimit: number,\n\tlabel: string,\n): asserts value is readonly string[] {\n\tif (!Array.isArray(value) || value.length > limit) {\n\t\tthrow new DurableTaskRuntimeError(`${label} exceeds its retained collection limit (${limit}).`);\n\t}\n\tconst identities = new Set<string>();\n\tfor (const entry of value) {\n\t\tif (\n\t\t\ttypeof entry !== \"string\" ||\n\t\t\tentry.length === 0 ||\n\t\t\tentry.length > MAX_ORCHESTRATION_IDENTIFIER_LENGTH ||\n\t\t\tidentities.has(entry)\n\t\t) {\n\t\t\tthrow new DurableTaskRuntimeError(`${label} must contain unique bounded identifiers.`);\n\t\t}\n\t\tidentities.add(entry);\n\t}\n}\n\nexport function retainedIdentifierArray(value: unknown, limit: number, label: string): string[] {\n\tassertBoundedIdentifierList(value, limit, label);\n\treturn [...value];\n}\n\nexport function assertRetainedProjectionNestedCollections(\n\tobjectives: Readonly<Record<string, unknown>>,\n\ttasks: Readonly<Record<string, unknown>>,\n\tattempts: Readonly<Record<string, unknown>>,\n\tcheckpoints: Readonly<Record<string, unknown>>,\n\tlabel: string,\n): number {\n\tlet evidenceCount = 0;\n\tfor (const objectiveId in objectives) {\n\t\tif (!Object.hasOwn(objectives, objectiveId)) continue;\n\t\tconst objective = record(objectives[objectiveId], `${label}.objectives.${objectiveId}`);\n\t\tassertBoundedIdentifierList(\n\t\t\tobjective.taskIds,\n\t\t\tMAX_ORCHESTRATION_TASKS,\n\t\t\t`${label}.objectives.${objectiveId}.taskIds`,\n\t\t);\n\t\tif (!Array.isArray(objective.evidence)) {\n\t\t\tthrow new DurableTaskRuntimeError(`${label}.objectives.${objectiveId}.evidence must be an array.`);\n\t\t}\n\t\tif (objective.evidence.length > MAX_ORCHESTRATION_OBJECTIVE_EVIDENCE) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`Orchestration objective evidence limit (${MAX_ORCHESTRATION_OBJECTIVE_EVIDENCE}) exceeded.`,\n\t\t\t);\n\t\t}\n\t\tevidenceCount += objective.evidence.length;\n\t\tif (evidenceCount > MAX_ORCHESTRATION_EVIDENCE) {\n\t\t\tthrow new DurableTaskRuntimeError(`Orchestration evidence limit (${MAX_ORCHESTRATION_EVIDENCE}) exceeded.`);\n\t\t}\n\t}\n\tfor (const taskId in tasks) {\n\t\tif (!Object.hasOwn(tasks, taskId)) continue;\n\t\tconst task = record(tasks[taskId], `${label}.tasks.${taskId}`);\n\t\tassertBoundedIdentifierList(task.attemptIds, MAX_ORCHESTRATION_ATTEMPTS, `${label}.tasks.${taskId}.attemptIds`);\n\t}\n\tfor (const attemptId in attempts) {\n\t\tif (!Object.hasOwn(attempts, attemptId)) continue;\n\t\tconst attempt = record(attempts[attemptId], `${label}.attempts.${attemptId}`);\n\t\tassertBoundedIdentifierList(\n\t\t\tattempt.checkpointIds,\n\t\t\tMAX_ORCHESTRATION_CHECKPOINTS,\n\t\t\t`${label}.attempts.${attemptId}.checkpointIds`,\n\t\t);\n\t}\n\tfor (const checkpointId in checkpoints) {\n\t\tif (!Object.hasOwn(checkpoints, checkpointId)) continue;\n\t\tconst checkpoint = record(checkpoints[checkpointId], `${label}.checkpoints.${checkpointId}`);\n\t\tconst summary = checkpoint.summary;\n\t\tif (typeof summary !== \"string\" || summary.length === 0) {\n\t\t\tthrow new DurableTaskRuntimeError(`${label}.checkpoints.${checkpointId}.summary is required.`);\n\t\t}\n\t\tif (summary.length > MAX_ORCHESTRATION_CHECKPOINT_SUMMARY_LENGTH) {\n\t\t\tthrow new DurableTaskRuntimeError(\n\t\t\t\t`${label}.checkpoints.${checkpointId}.summary exceeds its durable size bound.`,\n\t\t\t);\n\t\t}\n\t\tassertBoundedIdentifierList(\n\t\t\tcheckpoint.artifactIds,\n\t\t\tMAX_ORCHESTRATION_COLLECTION_LENGTH,\n\t\t\t`${label}.checkpoints.${checkpointId}.artifactIds`,\n\t\t);\n\t\tassertBoundedIdentifierList(\n\t\t\tcheckpoint.evidenceIds,\n\t\t\tMAX_ORCHESTRATION_COLLECTION_LENGTH,\n\t\t\t`${label}.checkpoints.${checkpointId}.evidenceIds`,\n\t\t);\n\t}\n\treturn evidenceCount;\n}\n\nexport function assertProjectionWithinLimits(projection: TaskRuntimeProjection): void {\n\tassertRecordWithinLimit(projection.agents, MAX_ORCHESTRATION_AGENT_BINDINGS, \"agent binding\");\n\tassertRecordWithinLimit(projection.objectives, MAX_ORCHESTRATION_OBJECTIVES, \"objective\");\n\tassertRecordWithinLimit(projection.tasks, MAX_ORCHESTRATION_TASKS, \"task\");\n\tassertRecordWithinLimit(projection.attempts, MAX_ORCHESTRATION_ATTEMPTS, \"attempt\");\n\tassertRecordWithinLimit(projection.checkpoints, MAX_ORCHESTRATION_CHECKPOINTS, \"checkpoint\");\n\tassertRecordWithinLimit(projection.approvals, MAX_ORCHESTRATION_APPROVALS, \"approval\");\n\tassertRecordWithinLimit(projection.notifications, MAX_ORCHESTRATION_NOTIFICATIONS, \"notification\");\n\tassertRetainedProjectionNestedCollections(\n\t\tprojection.objectives,\n\t\tprojection.tasks,\n\t\tprojection.attempts,\n\t\tprojection.checkpoints,\n\t\t\"orchestration projection\",\n\t);\n\tprojectionSerializedBytes(projection);\n}\n\nfunction countRecordEntries(values: Readonly<Record<string, unknown>>): number {\n\tlet count = 0;\n\tfor (const key in values) {\n\t\tif (Object.hasOwn(values, key)) count += 1;\n\t}\n\treturn count;\n}\n\nexport function projectionCapacity(projection: TaskRuntimeProjection): OrchestrationProjectionCapacity {\n\tconst evidence = assertRetainedProjectionNestedCollections(\n\t\tprojection.objectives,\n\t\tprojection.tasks,\n\t\tprojection.attempts,\n\t\tprojection.checkpoints,\n\t\t\"orchestration projection\",\n\t);\n\tconst counts = {\n\t\tagents: countRecordEntries(projection.agents),\n\t\tobjectives: countRecordEntries(projection.objectives),\n\t\ttasks: countRecordEntries(projection.tasks),\n\t\tattempts: countRecordEntries(projection.attempts),\n\t\tcheckpoints: countRecordEntries(projection.checkpoints),\n\t\tapprovals: countRecordEntries(projection.approvals),\n\t\tnotifications: countRecordEntries(projection.notifications),\n\t\tevidence,\n\t};\n\tconst limits = {\n\t\tagents: MAX_ORCHESTRATION_AGENT_BINDINGS,\n\t\tobjectives: MAX_ORCHESTRATION_OBJECTIVES,\n\t\ttasks: MAX_ORCHESTRATION_TASKS,\n\t\tattempts: MAX_ORCHESTRATION_ATTEMPTS,\n\t\tcheckpoints: MAX_ORCHESTRATION_CHECKPOINTS,\n\t\tapprovals: MAX_ORCHESTRATION_APPROVALS,\n\t\tnotifications: MAX_ORCHESTRATION_NOTIFICATIONS,\n\t\tevidence: MAX_ORCHESTRATION_EVIDENCE,\n\t};\n\treturn {\n\t\tcounts,\n\t\tlimits,\n\t\theadroom: {\n\t\t\tagents: limits.agents - counts.agents,\n\t\t\tobjectives: limits.objectives - counts.objectives,\n\t\t\ttasks: limits.tasks - counts.tasks,\n\t\t\tattempts: limits.attempts - counts.attempts,\n\t\t\tcheckpoints: limits.checkpoints - counts.checkpoints,\n\t\t\tapprovals: limits.approvals - counts.approvals,\n\t\t\tnotifications: limits.notifications - counts.notifications,\n\t\t\tevidence: limits.evidence - counts.evidence,\n\t\t},\n\t};\n}\n\nexport function requestedProjectionSlots(value: number | undefined, label: string): number {\n\tconst slots = value ?? 0;\n\tif (!Number.isSafeInteger(slots) || slots < 0) {\n\t\tthrow new DurableTaskRuntimeError(`${label} projection slots must be a non-negative safe integer.`);\n\t}\n\treturn slots;\n}\n\nexport function cacheProjectionSerializedBytes(projection: TaskRuntimeProjection, bytes: number): void {\n\tprojectionSerializedByteCache.set(projection, bytes);\n}\n"]}
@@ -0,0 +1,38 @@
1
+ import { type AgentBindingContract, type ApprovalRequestContract, type ApprovalResolutionContract, type AttemptCheckpoint, type AttemptLease, type ExecutionGrant, type ObjectiveContract, type ObjectiveStatus, type OrchestrationEvent, type WorkerResultContract } from "./contracts.ts";
2
+ import { type ApprovalRuntimeState, type AttemptDispatchReadiness, type AttemptRuntimeState, type TaskRuntimeProjection, type TaskRuntimeState } from "./task-runtime-state.ts";
3
+ export type ObjectiveCompletionPolicy = "task_evidence" | "owner_evidence" | "owner_override";
4
+ export declare function assertObjectiveStatusTransition(state: TaskRuntimeProjection, objectiveId: string, target: ObjectiveStatus, completionPolicy?: ObjectiveCompletionPolicy): void;
5
+ /** One authoritative guard shared by command admission and durable event replay. */
6
+ export declare function assertAgentRetirementEligible(state: TaskRuntimeProjection, agentId: string): AgentBindingContract;
7
+ export declare function assertAgentNotRetired(agent: AgentBindingContract, transition: string): void;
8
+ export declare function attemptDispatchReadiness(state: TaskRuntimeProjection, attempt: AttemptRuntimeState): AttemptDispatchReadiness;
9
+ export declare function activeTaskAttempt(state: TaskRuntimeProjection, task: TaskRuntimeState): AttemptRuntimeState | undefined;
10
+ export declare function assertTaskAttemptBudgetForState(task: TaskRuntimeState, objective: ObjectiveContract): void;
11
+ export declare function requireActiveObjectiveForAttemptInProjection(state: TaskRuntimeProjection, attempt: AttemptRuntimeState): ObjectiveContract;
12
+ export declare function assertRetryBackoffElapsedAt(attempt: AttemptRuntimeState, atMs: number): void;
13
+ export declare function assertAttemptFinishTransition(state: TaskRuntimeProjection, aggregateId: string, result: WorkerResultContract, occurredAt: string): {
14
+ attempt: AttemptRuntimeState;
15
+ task: TaskRuntimeState;
16
+ };
17
+ export declare function assertAttemptGrantTransition(state: TaskRuntimeProjection, aggregateId: string, attemptId: string, grant: ExecutionGrant): AttemptRuntimeState;
18
+ export declare function assertAttemptLeaseTransition(state: TaskRuntimeProjection, aggregateId: string, lease: AttemptLease, agentId: string | undefined, occurredAt: string): AttemptRuntimeState;
19
+ export declare function assertAttemptStartTransition(state: TaskRuntimeProjection, aggregateId: string, attemptId: string, leaseId: string, fencingToken: number, occurredAt: string): AttemptRuntimeState;
20
+ export declare function assertAttemptCheckpointTransition(state: TaskRuntimeProjection, aggregateId: string, checkpoint: AttemptCheckpoint, leaseId: string, occurredAt: string): AttemptRuntimeState;
21
+ export declare function assertApprovalRequestTransition(state: TaskRuntimeProjection, aggregateId: string, approval: ApprovalRequestContract): void;
22
+ export declare function assertApprovalResolutionTransition(state: TaskRuntimeProjection, aggregateId: string, resolution: ApprovalResolutionContract): ApprovalRuntimeState;
23
+ export declare function assertNotificationTarget(state: TaskRuntimeProjection, objectiveId: string, attemptId: string | undefined): void;
24
+ export interface VerificationTransitionInput {
25
+ taskId: string;
26
+ verifierTaskId: string;
27
+ verifierAttemptId: string;
28
+ verdict: "accepted" | "rejected" | "inconclusive";
29
+ reasonCode: string;
30
+ }
31
+ export declare function assertTaskFailureTransition(state: TaskRuntimeProjection, aggregateId: string, taskId: string, reasonCode: string): TaskRuntimeState;
32
+ export declare function assertVerificationTransition(state: TaskRuntimeProjection, aggregateId: string, args: VerificationTransitionInput): {
33
+ subject: TaskRuntimeState;
34
+ verifierAttempt: AttemptRuntimeState;
35
+ };
36
+ export declare function reduceOrchestrationEvent(projection: TaskRuntimeProjection, event: OrchestrationEvent): TaskRuntimeProjection;
37
+ export declare function projectOrchestrationEvents(events: readonly OrchestrationEvent[]): TaskRuntimeProjection;
38
+ //# sourceMappingURL=task-runtime-reducer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-runtime-reducer.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/task-runtime-reducer.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,EAC/B,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAGjB,KAAK,cAAc,EAQnB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EAEpB,KAAK,kBAAkB,EAIvB,KAAK,oBAAoB,EACzB,MAAM,gBAAgB,CAAC;AA8BxB,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EAKxB,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EAErB,MAAM,yBAAyB,CAAC;AAuDjC,MAAM,MAAM,yBAAyB,GAAG,eAAe,GAAG,gBA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