@spine-event-engine/storage 2.0.0-snapshot.24 → 2.0.0-snapshot.25

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 (100) hide show
  1. package/README.md +12 -3
  2. package/REFERENCE.md +76 -68
  3. package/dist/entity/agent-history-record-spec.d.ts +8 -0
  4. package/dist/entity/agent-history-record-spec.d.ts.map +1 -1
  5. package/dist/entity/agent-history-record-spec.js +12 -1
  6. package/dist/entity/agent-history-record-spec.js.map +1 -1
  7. package/dist/entity/agent-history.d.ts +25 -0
  8. package/dist/entity/agent-history.d.ts.map +1 -1
  9. package/dist/entity/agent-history.js.map +1 -1
  10. package/dist/entity/history-conformance.d.ts +38 -8
  11. package/dist/entity/history-conformance.d.ts.map +1 -1
  12. package/dist/entity/history-conformance.js +103 -58
  13. package/dist/entity/history-conformance.js.map +1 -1
  14. package/dist/event/event-store.d.ts +51 -3
  15. package/dist/event/event-store.d.ts.map +1 -1
  16. package/dist/event/event-store.js +171 -27
  17. package/dist/event/event-store.js.map +1 -1
  18. package/dist/internal/agent-model-preferences.d.ts +76 -0
  19. package/dist/internal/agent-model-preferences.d.ts.map +1 -0
  20. package/dist/internal/agent-model-preferences.js +133 -0
  21. package/dist/internal/agent-model-preferences.js.map +1 -0
  22. package/dist/internal/entity-commit.d.ts +64 -8
  23. package/dist/internal/entity-commit.d.ts.map +1 -1
  24. package/dist/internal/entity-commit.js.map +1 -1
  25. package/dist/internal/entity-history.d.ts +1 -7
  26. package/dist/internal/entity-history.d.ts.map +1 -1
  27. package/dist/internal/entity-history.js +0 -5
  28. package/dist/internal/entity-history.js.map +1 -1
  29. package/dist/internal/event-store.d.ts +1 -1
  30. package/dist/internal/event-store.d.ts.map +1 -1
  31. package/dist/internal/event-store.js +1 -1
  32. package/dist/internal/event-store.js.map +1 -1
  33. package/dist/internal/storage-preparation.d.ts +88 -0
  34. package/dist/internal/storage-preparation.d.ts.map +1 -0
  35. package/dist/internal/storage-preparation.js +41 -0
  36. package/dist/internal/storage-preparation.js.map +1 -0
  37. package/dist/internal/tenancy.d.ts +7 -0
  38. package/dist/internal/tenancy.d.ts.map +1 -1
  39. package/dist/memory/in-memory-agent-history.d.ts.map +1 -1
  40. package/dist/memory/in-memory-agent-history.js +22 -7
  41. package/dist/memory/in-memory-agent-history.js.map +1 -1
  42. package/dist/memory/in-memory-entity-commit.d.ts +154 -21
  43. package/dist/memory/in-memory-entity-commit.d.ts.map +1 -1
  44. package/dist/memory/in-memory-entity-commit.js +396 -60
  45. package/dist/memory/in-memory-entity-commit.js.map +1 -1
  46. package/dist/memory/in-memory-entity-history.d.ts.map +1 -1
  47. package/dist/memory/in-memory-entity-history.js +4 -3
  48. package/dist/memory/in-memory-entity-history.js.map +1 -1
  49. package/dist/memory/in-memory-storage-backend.d.ts +33 -1
  50. package/dist/memory/in-memory-storage-backend.d.ts.map +1 -1
  51. package/dist/memory/in-memory-storage-backend.js +118 -1
  52. package/dist/memory/in-memory-storage-backend.js.map +1 -1
  53. package/dist/memory/in-memory-storage-factory.d.ts +71 -12
  54. package/dist/memory/in-memory-storage-factory.d.ts.map +1 -1
  55. package/dist/memory/in-memory-storage-factory.js +199 -25
  56. package/dist/memory/in-memory-storage-factory.js.map +1 -1
  57. package/dist/provider.d.ts +2 -0
  58. package/dist/provider.d.ts.map +1 -1
  59. package/dist/provider.js +2 -0
  60. package/dist/provider.js.map +1 -1
  61. package/dist/storage/storage-factory.d.ts +27 -4
  62. package/dist/storage/storage-factory.d.ts.map +1 -1
  63. package/dist/storage/storage-factory.js +30 -1
  64. package/dist/storage/storage-factory.js.map +1 -1
  65. package/dist/storage/storage.d.ts +2 -1
  66. package/dist/storage/storage.d.ts.map +1 -1
  67. package/dist/tsconfig.tsbuildinfo +1 -1
  68. package/package.json +3 -3
  69. package/dist/entity/agent-execution-record-spec.d.ts +0 -87
  70. package/dist/entity/agent-execution-record-spec.d.ts.map +0 -1
  71. package/dist/entity/agent-execution-record-spec.js +0 -230
  72. package/dist/entity/agent-execution-record-spec.js.map +0 -1
  73. package/dist/entity/agent-execution-sizes.d.ts +0 -30
  74. package/dist/entity/agent-execution-sizes.d.ts.map +0 -1
  75. package/dist/entity/agent-execution-sizes.js +0 -51
  76. package/dist/entity/agent-execution-sizes.js.map +0 -1
  77. package/dist/entity/agent-execution-transitions.d.ts +0 -72
  78. package/dist/entity/agent-execution-transitions.d.ts.map +0 -1
  79. package/dist/entity/agent-execution-transitions.js +0 -165
  80. package/dist/entity/agent-execution-transitions.js.map +0 -1
  81. package/dist/entity/agent-execution-values.d.ts +0 -143
  82. package/dist/entity/agent-execution-values.d.ts.map +0 -1
  83. package/dist/entity/agent-execution-values.js +0 -251
  84. package/dist/entity/agent-execution-values.js.map +0 -1
  85. package/dist/entity/agent-execution.d.ts +0 -235
  86. package/dist/entity/agent-execution.d.ts.map +0 -1
  87. package/dist/entity/agent-execution.js +0 -15
  88. package/dist/entity/agent-execution.js.map +0 -1
  89. package/dist/internal/agent-execution.d.ts +0 -51
  90. package/dist/internal/agent-execution.d.ts.map +0 -1
  91. package/dist/internal/agent-execution.js +0 -53
  92. package/dist/internal/agent-execution.js.map +0 -1
  93. package/dist/memory/agent-execution-head-index.d.ts +0 -52
  94. package/dist/memory/agent-execution-head-index.d.ts.map +0 -1
  95. package/dist/memory/agent-execution-head-index.js +0 -91
  96. package/dist/memory/agent-execution-head-index.js.map +0 -1
  97. package/dist/memory/in-memory-agent-execution.d.ts +0 -21
  98. package/dist/memory/in-memory-agent-execution.d.ts.map +0 -1
  99. package/dist/memory/in-memory-agent-execution.js +0 -587
  100. package/dist/memory/in-memory-agent-execution.js.map +0 -1
@@ -1,587 +0,0 @@
1
- /*
2
- * Copyright 2026, CodeMatters. All rights reserved.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5
- * in compliance with the License. You may obtain a copy of the License at
6
- *
7
- * https://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software distributed under the License
10
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11
- * or implied. See the License for the specific language governing permissions and limitations under
12
- * the License.
13
- */
14
- import { clone, create, toBinary } from "@bufbuild/protobuf";
15
- import { Time } from "@spine-event-engine/core";
16
- import { ModelPreferenceSchema } from "@spine-event-engine/proto/agent";
17
- import { AgentExecutionHeadSchema, AgentExecutionRecordSchema, AgentInvocationStatus, } from "@spine-event-engine/proto/generated/spine/server/agent/execution_record_pb.js";
18
- import { TenantBoundary } from "../internal/tenancy.js";
19
- import { AgentExecutionRecords } from "../entity/agent-execution-record-spec.js";
20
- import { AgentExecutionTransitions } from "../entity/agent-execution-transitions.js";
21
- import { AgentExecutionValues } from "../entity/agent-execution-values.js";
22
- import { AgentHistoryIndex } from "./agent-history-index.js";
23
- import { AgentHistoryMutationQueue } from "./agent-history-mutation-queue.js";
24
- import { MemoryPendingHeadIndex } from "./agent-execution-head-index.js";
25
- import { InMemoryStorageBackend } from "./in-memory-storage-backend.js";
26
- import { KeyedSerialQueue } from "./in-memory-entity-history.js";
27
- import { EntityCommitStorageFactories } from "../internal/entity-commit.js";
28
- import { MemoryEntityCommitStorage } from "./in-memory-entity-commit.js";
29
- const utf8 = new globalThis.TextEncoder();
30
- /**
31
- * Opens a shared in-memory execution family within a complete tenant boundary.
32
- */
33
- export const MemoryAgentExecution = {
34
- /**
35
- * Opens a closeable Agent execution handle.
36
- *
37
- * @typeParam I Typed Agent identifier.
38
- * @typeParam S Generated Agent state.
39
- * @param backend Shared memory backend.
40
- * @param factory Storage factory supplying Entity commits.
41
- * @param input Agent repository and state type.
42
- * @returns Closeable provider handle.
43
- */
44
- open(backend, factory, input) {
45
- const tenant = TenantBoundary.of(input.entity.context);
46
- const state = InMemoryStorageBackend.bind(backend, "entity", tenant, `agent-execution:${input.stateType}`, () => ({
47
- records: new Map(),
48
- heads: new Map(),
49
- unresolved: new Map(),
50
- pending: new MemoryPendingHeadIndex(),
51
- queue: new KeyedSerialQueue(),
52
- historyQueue: AgentHistoryMutationQueue.bind(backend, tenant),
53
- history: InMemoryStorageBackend.bind(backend, "entity", tenant, `agent-history:${input.stateType}`, () => new Map()),
54
- }));
55
- return new MemoryAgentExecutionHandle(state, factory, input);
56
- },
57
- };
58
- /**
59
- * Serializes Agent execution mutations against one shared memory backend.
60
- *
61
- * @typeParam I Typed Agent identifier.
62
- * @typeParam S Generated Agent state.
63
- */
64
- class MemoryAgentExecutionHandle {
65
- state;
66
- factory;
67
- input;
68
- #open = true;
69
- /**
70
- * Memory storage has no provider-imposed serialized row limit.
71
- */
72
- capacity = Object.freeze({});
73
- /**
74
- * Binds shared execution state and existing Entity commit facilities.
75
- *
76
- * @param state Tenant execution records and lock.
77
- * @param factory Existing storage factory.
78
- * @param input Agent repository layout.
79
- */
80
- constructor(state, factory, input) {
81
- this.state = state;
82
- this.factory = factory;
83
- this.input = input;
84
- }
85
- /**
86
- * Persists immutable accepted work, including exact original signal bytes.
87
- *
88
- * @param accepted Complete source envelope and handler bindings.
89
- * @returns Detached accepted record.
90
- */
91
- admit(accepted) {
92
- this.requireOpen();
93
- const scope = this.scope(accepted.key);
94
- return this.state.queue.run(scope, () => {
95
- this.requireOpen();
96
- const key = this.key(accepted.key);
97
- const prior = this.state.records.get(key);
98
- if (prior !== undefined) {
99
- if (!AgentExecutionValues.sameAccepted(prior.accepted, accepted))
100
- throw new Error("Agent execution admission conflicts with immutable source facts.");
101
- return AgentExecutionValues.cloneRecord(prior);
102
- }
103
- const record = create(AgentExecutionRecordSchema, {
104
- accepted,
105
- status: AgentInvocationStatus.AGENT_INVOCATION_ACCEPTED,
106
- });
107
- this.state.records.set(key, AgentExecutionValues.cloneRecord(record));
108
- if (!this.state.heads.has(scope))
109
- this.state.heads.set(scope, create(AgentExecutionHeadSchema, {
110
- scope: AgentExecutionValues.require(accepted.key).scope,
111
- }));
112
- this.addUnresolved(scope, key);
113
- this.selectCandidate(scope);
114
- return AgentExecutionValues.cloneRecord(record);
115
- });
116
- }
117
- /**
118
- * Returns bounded unresolved records in acceptance order.
119
- *
120
- * @param request Complete continuation and count.
121
- * @returns Detached page.
122
- */
123
- pending(request) {
124
- this.requireOpen();
125
- if (!Number.isSafeInteger(request.count) || request.count <= 0)
126
- throw new RangeError("Agent pending count must be a positive safe integer.");
127
- const asOf = request.after?.asOf ?? Time.currentTime();
128
- const after = request.after?.key;
129
- if (after !== undefined && after.scope.stateType !== this.input.stateType)
130
- throw new TypeError("Agent pending continuation belongs to another state type.");
131
- const encoded = after === undefined
132
- ? undefined
133
- : AgentExecutionRecords.pendingKey(after.eligibleAt, after.scope);
134
- const examined = this.state.pending.page(encoded, asOf, request.count);
135
- const observed = examined.slice(0, request.count);
136
- const records = observed.flatMap(({ head }) => {
137
- const record = head.pending === undefined ? undefined : this.state.records.get(this.key(head.pending));
138
- return record === undefined ? [] : [AgentExecutionValues.cloneRecord(record)];
139
- });
140
- const last = observed.at(-1)?.head;
141
- return Promise.resolve({
142
- records,
143
- ...(last?.scope === undefined || last.eligibleAt === undefined
144
- ? {}
145
- : { after: { asOf, key: { scope: last.scope, eligibleAt: last.eligibleAt } } }),
146
- hasMore: examined.length > request.count,
147
- });
148
- }
149
- /**
150
- * Reads one complete detached execution record.
151
- *
152
- * @param key Original source and Agent instance key.
153
- * @returns Stored record if present.
154
- */
155
- read(key) {
156
- this.requireOpen();
157
- const record = this.state.records.get(this.key(key));
158
- return Promise.resolve(record === undefined ? undefined : AgentExecutionValues.cloneRecord(record));
159
- }
160
- /**
161
- * Acquires the earliest unresolved same-instance invocation.
162
- *
163
- * @param key Original source and Agent instance key.
164
- * @param token New exclusive token.
165
- * @param expiresAt Requested expiry.
166
- * @returns Claimed record and current preferences if eligible.
167
- */
168
- claim(key, token, expiresAt) {
169
- this.requireOpen();
170
- const scope = this.scope(key);
171
- return this.state.queue.run(scope, () => this.claimLocked(key, token, expiresAt));
172
- }
173
- /**
174
- * Updates the same token before its previous expiry.
175
- *
176
- * @param key Original source and Agent instance key.
177
- * @param token Existing exclusive token.
178
- * @param expiresAt Requested later expiry.
179
- * @returns Whether renewal succeeded.
180
- */
181
- renew(key, token, expiresAt) {
182
- this.requireOpen();
183
- const scope = this.scope(key);
184
- return this.state.queue.run(scope, () => {
185
- const record = this.requireClaim(key, token);
186
- if (record === undefined ||
187
- AgentExecutionValues.compareTime(expiresAt, AgentExecutionValues.require(record.claimExpiresAt)) <= 0)
188
- return false;
189
- record.claimExpiresAt = expiresAt;
190
- const head = this.head(scope);
191
- head.claimExpiresAt = expiresAt;
192
- head.eligibleAt = expiresAt;
193
- this.state.pending.set(scope, head);
194
- return true;
195
- });
196
- }
197
- /**
198
- * Writes fenced journal and history changes under one memory lock.
199
- *
200
- * @param input Expected record, next record and history entries.
201
- * @returns Completion after fenced evidence is persisted.
202
- */
203
- update(input) {
204
- this.requireOpen();
205
- const scope = this.scope(input.key);
206
- return this.state.queue.run(scope, () => this.state.historyQueue.run(AgentExecutionValues.require(input.key.scope).agentKey, () => {
207
- const prior = this.checkExpected(input);
208
- AgentExecutionTransitions.assertUpdate(prior, input.next);
209
- const staged = this.stageHistory(input.key, input.historyEntries ?? []);
210
- const next = AgentExecutionValues.cloneRecord(input.next);
211
- staged?.apply();
212
- this.state.records.set(this.key(input.key), next);
213
- if (staged !== undefined)
214
- this.state.history.set(AgentExecutionValues.require(input.key.scope).agentKey, staged.index);
215
- if (input.next.status === AgentInvocationStatus.AGENT_INVOCATION_TERMINATED)
216
- this.release(scope, input.key);
217
- }));
218
- }
219
- /**
220
- * Executes one fenced completion with existing Entity commit facilities.
221
- *
222
- * @param input Complete transition and expected execution record.
223
- * @returns Completion after conditional Entity and evidence commit.
224
- */
225
- complete(input) {
226
- this.requireOpen();
227
- const scope = this.scope(input.key);
228
- return this.state.queue.run(scope, () => this.state.historyQueue.run(AgentExecutionValues.require(input.key.scope).agentKey, () => this.completeLocked(input, scope)));
229
- }
230
- /**
231
- * Applies the conditional Entity transition and prepared execution publication.
232
- *
233
- * @param input Requested fenced execution change.
234
- * @param scope Generated state type and Agent key.
235
- * @returns Completion after Entity and execution evidence commit.
236
- */
237
- async completeLocked(input, scope) {
238
- const prior = this.checkExpected(input);
239
- if (prior.status !== AgentInvocationStatus.AGENT_INVOCATION_ACTIVE)
240
- throw new Error("Agent completion requires a prior active invocation.");
241
- AgentExecutionTransitions.assertCompletion(input.next);
242
- const expectedVersion = this.validateCompletion(input);
243
- const staged = this.stageHistory(input.key, input.historyEntries ?? []);
244
- const entityId = this.input.entity.id.unpack(AgentExecutionValues.require(AgentExecutionValues.require(input.next.accepted).recipientId));
245
- if (entityId === undefined)
246
- throw new TypeError("Agent execution recipient ID has the wrong type.");
247
- const commits = EntityCommitStorageFactories.create(this.factory, this.input.entity);
248
- if (!(commits instanceof MemoryEntityCommitStorage))
249
- throw new Error("Memory Agent execution requires its memory Entity commit coordinator.");
250
- try {
251
- await commits.commitAgentConditional(this.input.entity, entityId, expectedVersion, input.entityCommit, this.publication(input, scope, staged));
252
- }
253
- finally {
254
- commits.close();
255
- }
256
- }
257
- /**
258
- * Validates completion status and one-version/no-op relationship.
259
- *
260
- * @param input Requested fenced execution change.
261
- * @returns Expected initial Entity Version.
262
- */
263
- validateCompletion(input) {
264
- const result = input.next.completion;
265
- if (result?.initialVersion === undefined || result.resultingVersion === undefined)
266
- throw new TypeError("Agent completion requires initial and resulting Entity Versions.");
267
- if (input.next.status !== AgentInvocationStatus.AGENT_INVOCATION_COMPLETED &&
268
- input.next.status !== AgentInvocationStatus.AGENT_INVOCATION_COMPLETED_PENDING_COMMANDS)
269
- throw new TypeError("Agent completion requires a completed execution status.");
270
- const initial = result.initialVersion.number;
271
- const final = result.resultingVersion.number;
272
- if (input.entityCommit === undefined
273
- ? final !== initial
274
- : final !== initial + 1 || input.entityCommit.next.version?.number !== final)
275
- throw new Error("Agent completion must commit exactly one Version or a no-op.");
276
- return initial;
277
- }
278
- /**
279
- * Prepares execution, preference and history replacements with restoration.
280
- *
281
- * @param input Requested fenced execution change.
282
- * @param scope Generated state type and Agent key.
283
- * @param staged Rows staged for the native transaction.
284
- * @returns Prepared state and history publication callback.
285
- */
286
- publication(input, scope, staged) {
287
- const key = this.key(input.key);
288
- const historyKey = AgentExecutionValues.require(input.key.scope).agentKey;
289
- const prior = this.state.records.get(key);
290
- const priorHistory = this.state.history.get(historyKey);
291
- const priorHead = create(AgentExecutionHeadSchema, this.head(scope));
292
- const priorUnresolved = [...(this.state.unresolved.get(scope) ?? [])];
293
- return {
294
- apply: () => {
295
- staged?.apply();
296
- this.state.records.set(key, AgentExecutionValues.cloneRecord(input.next));
297
- if (staged !== undefined)
298
- this.state.history.set(historyKey, staged.index);
299
- this.head(scope).preferences = AgentExecutionValues.require(input.next.completion).preferences.map((item) => clone(ModelPreferenceSchema, item));
300
- if (input.next.status === AgentInvocationStatus.AGENT_INVOCATION_COMPLETED)
301
- this.release(scope, input.key);
302
- else
303
- this.state.pending.set(scope, this.head(scope));
304
- },
305
- restore: () => {
306
- staged?.restore();
307
- if (prior === undefined)
308
- this.state.records.delete(key);
309
- else
310
- this.state.records.set(key, prior);
311
- if (priorHistory === undefined)
312
- this.state.history.delete(historyKey);
313
- else
314
- this.state.history.set(historyKey, priorHistory);
315
- this.state.heads.set(scope, priorHead);
316
- this.state.unresolved.set(scope, priorUnresolved);
317
- this.state.pending.set(scope, priorHead);
318
- },
319
- };
320
- }
321
- /**
322
- * Marks original signal IDs delivered without replaying handlers.
323
- *
324
- * @param key Original source and Agent instance key.
325
- * @param token Current exclusive token.
326
- * @param expectedRecordBytes Exact previously read record.
327
- * @param signals Original delivered message IDs.
328
- * @returns Completion after original output IDs are marked delivered.
329
- */
330
- markDelivered(key, token, expectedRecordBytes, signals) {
331
- this.requireOpen();
332
- const scope = this.scope(key);
333
- return this.state.queue.run(scope, () => {
334
- const record = this.requireClaim(key, token);
335
- if (record === undefined ||
336
- !AgentExecutionValues.sameBytes(toBinary(AgentExecutionRecordSchema, record), expectedRecordBytes))
337
- throw new Error("Agent execution claim or expected record is no longer current.");
338
- if (record.completion === undefined)
339
- throw new Error("Agent execution has no completed output.");
340
- AgentExecutionTransitions.assertDelivery(record, signals);
341
- for (const signal of signals)
342
- AgentExecutionValues.markSignal(AgentExecutionValues.requiredCompletion(record), signal);
343
- if (record.completion.commands.every((item) => item.delivered)) {
344
- record.status = AgentInvocationStatus.AGENT_INVOCATION_COMPLETED;
345
- this.release(scope, key);
346
- }
347
- });
348
- }
349
- /**
350
- * Closes this handle without deleting backend records.
351
- */
352
- close() {
353
- this.#open = false;
354
- }
355
- /**
356
- * Rejects operations after handle closure.
357
- */
358
- requireOpen() {
359
- if (!this.#open)
360
- throw new Error("Agent execution storage handle is closed.");
361
- }
362
- /**
363
- * Reads and validates the full Agent instance scope.
364
- *
365
- * @param key Original Agent invocation identity.
366
- * @returns Complete encoded Agent instance scope.
367
- */
368
- scope(key) {
369
- if (key?.scope?.stateType !== this.input.stateType || !key.scope.agentKey)
370
- throw new TypeError("Agent execution requires the configured state type and Agent key.");
371
- return JSON.stringify([key.scope.stateType, key.scope.agentKey]);
372
- }
373
- /**
374
- * Encodes the original typed signal identity without an Inbox row ID.
375
- *
376
- * @param key Original Agent invocation identity.
377
- * @returns Complete encoded invocation identity.
378
- */
379
- key(key) {
380
- const scope = this.scope(key);
381
- const signal = key?.sourceSignal?.id;
382
- if (signal?.case === undefined ||
383
- (signal.case === "command" ? !signal.value.uuid : !signal.value.value))
384
- throw new TypeError("Agent execution requires an original Command or Event ID.");
385
- return JSON.stringify([
386
- scope,
387
- signal.case,
388
- signal.case === "command" ? signal.value.uuid : signal.value.value,
389
- ]);
390
- }
391
- /**
392
- * Reads or creates the per-instance claim and preference row.
393
- *
394
- * @param scope Generated state type and Agent key.
395
- * @returns Per-instance head when present.
396
- */
397
- head(scope) {
398
- const head = this.state.heads.get(scope);
399
- if (head === undefined)
400
- throw new Error("Agent execution head is missing.");
401
- return head;
402
- }
403
- /**
404
- * Checks fresh Time and exact token after the instance lock is acquired.
405
- *
406
- * @param key Original Agent invocation identity.
407
- * @param token Exclusive claim token.
408
- * @returns Current claimed record when the token is valid.
409
- */
410
- requireClaim(key, token) {
411
- const record = this.state.records.get(this.key(key));
412
- const head = this.head(this.scope(key));
413
- const now = Time.currentTime();
414
- if (!token ||
415
- record?.claimToken !== token ||
416
- head.claimToken !== token ||
417
- record.claimExpiresAt === undefined ||
418
- AgentExecutionValues.compareTime(record.claimExpiresAt, now) <= 0)
419
- return undefined;
420
- return record;
421
- }
422
- /**
423
- * Checks the immutable read image before any state or history mutation.
424
- *
425
- * @param input Requested fenced execution change.
426
- * @returns Current record after exact-byte validation.
427
- */
428
- checkExpected(input) {
429
- const prior = this.requireClaim(input.key, input.token);
430
- if (prior === undefined ||
431
- !AgentExecutionValues.sameBytes(toBinary(AgentExecutionRecordSchema, prior), input.expectedRecordBytes))
432
- throw new Error("Agent execution claim or expected record is no longer current.");
433
- if (!AgentExecutionValues.sameAccepted(prior.accepted, input.next.accepted))
434
- throw new Error("Agent execution cannot change immutable accepted source facts.");
435
- return prior;
436
- }
437
- /**
438
- * Prepares immutable history rows before publishing any mutation.
439
- *
440
- * @param entries Immutable history entries to append.
441
- * @param key Original Agent invocation identity.
442
- * @returns Staged immutable history index when entries are present.
443
- */
444
- stageHistory(key, entries) {
445
- if (entries.length === 0)
446
- return undefined;
447
- const agentKey = AgentExecutionValues.require(key.scope).agentKey;
448
- return (this.state.history.get(agentKey) ?? new AgentHistoryIndex()).withEntries(entries);
449
- }
450
- /**
451
- * Clears a resolved invocation's claim so its next signal can run.
452
- *
453
- * @param key Original Agent invocation identity.
454
- * @param scope Generated state type and Agent key.
455
- */
456
- release(scope, key) {
457
- const head = this.head(scope);
458
- head.active = undefined;
459
- head.claimToken = "";
460
- head.claimExpiresAt = undefined;
461
- head.lastResolved = this.state.records.get(this.key(key))?.accepted?.order;
462
- const unresolved = this.state.unresolved.get(scope) ?? [];
463
- this.state.unresolved.set(scope, unresolved.filter((item) => item !== this.key(key)));
464
- this.selectCandidate(scope);
465
- }
466
- /**
467
- * Acquires only the earliest unresolved work for one Agent instance.
468
- *
469
- * @param expiresAt Requested future lease expiry.
470
- * @param key Original Agent invocation identity.
471
- * @param token Exclusive claim token.
472
- * @returns Claimed record and preferences when eligible.
473
- */
474
- claimLocked(key, token, expiresAt) {
475
- this.requireOpen();
476
- const now = Time.currentTime();
477
- if (!token || AgentExecutionValues.compareTime(expiresAt, now) <= 0)
478
- throw new TypeError("Agent claim requires a future expiry and token.");
479
- const scope = this.scope(key);
480
- const record = this.state.records.get(this.key(key));
481
- if (record === undefined || !AgentExecutionValues.isPending(record, now))
482
- return undefined;
483
- const head = this.head(scope);
484
- if (head.pending === undefined || this.key(head.pending) !== this.key(key))
485
- return undefined;
486
- if (head.active !== undefined &&
487
- head.claimExpiresAt !== undefined &&
488
- AgentExecutionValues.compareTime(head.claimExpiresAt, now) > 0)
489
- return undefined;
490
- record.claimToken = token;
491
- record.claimExpiresAt = expiresAt;
492
- if (record.status === AgentInvocationStatus.AGENT_INVOCATION_ACCEPTED)
493
- record.status = AgentInvocationStatus.AGENT_INVOCATION_ACTIVE;
494
- head.active = key;
495
- head.claimToken = token;
496
- head.claimExpiresAt = expiresAt;
497
- head.eligibleAt = expiresAt;
498
- this.state.pending.set(scope, head);
499
- return {
500
- record: AgentExecutionValues.cloneRecord(record),
501
- preferences: head.preferences.map((item) => clone(ModelPreferenceSchema, item)),
502
- };
503
- }
504
- /**
505
- * Adds one unresolved source in original Inbox order.
506
- *
507
- * @param key Original Agent invocation identity.
508
- * @param scope Generated state type and Agent key.
509
- */
510
- addUnresolved(scope, key) {
511
- const keys = this.state.unresolved.get(scope) ?? [];
512
- keys.push(key);
513
- keys.sort((left, right) => compareRecords(AgentExecutionValues.require(this.state.records.get(left)), AgentExecutionValues.require(this.state.records.get(right))));
514
- this.state.unresolved.set(scope, keys);
515
- }
516
- /**
517
- * Updates the discoverable head while retaining every invocation row.
518
- *
519
- * @param scope Generated state type and Agent key.
520
- */
521
- selectCandidate(scope) {
522
- const head = this.head(scope);
523
- const key = this.state.unresolved.get(scope)?.[0];
524
- const record = key === undefined ? undefined : this.state.records.get(key);
525
- const prior = head.pending === undefined ? undefined : this.key(head.pending);
526
- if (record === undefined) {
527
- head.pending = undefined;
528
- head.pendingOrder = undefined;
529
- head.eligibleAt = undefined;
530
- }
531
- else {
532
- head.pending = AgentExecutionValues.require(record.accepted).key;
533
- head.pendingOrder = AgentExecutionValues.require(record.accepted).order;
534
- if (prior !== key || head.eligibleAt === undefined)
535
- head.eligibleAt = head.active === undefined ? Time.currentTime() : head.claimExpiresAt;
536
- }
537
- this.state.pending.set(scope, head);
538
- }
539
- }
540
- /**
541
- * Orders by complete Inbox time, version, source signal and Agent scope.
542
- */
543
- function compareRecords(left, right) {
544
- const order = compareOrder(AgentExecutionValues.requiredOrder(left), AgentExecutionValues.requiredOrder(right));
545
- if (order !== 0)
546
- return order;
547
- return compareScope(AgentExecutionValues.requiredScope(AgentExecutionValues.requiredInvocation(left)), AgentExecutionValues.requiredScope(AgentExecutionValues.requiredInvocation(right)));
548
- }
549
- /**
550
- * Compares complete Inbox ordering fields without locale collation.
551
- */
552
- function compareOrder(left, right) {
553
- const time = AgentExecutionValues.compareTime(AgentExecutionValues.require(left.receivedAt), AgentExecutionValues.require(right.receivedAt));
554
- if (time !== 0)
555
- return time;
556
- if (left.inboxVersion !== right.inboxVersion)
557
- return left.inboxVersion < right.inboxVersion ? -1 : 1;
558
- return compareSignal(AgentExecutionValues.require(left.sourceSignal), AgentExecutionValues.require(right.sourceSignal));
559
- }
560
- /**
561
- * Compares full original source IDs by UTF-8 bytes.
562
- */
563
- function compareSignal(left, right) {
564
- if (left.id.case === undefined || right.id.case === undefined)
565
- throw new TypeError("Agent Inbox order requires typed source IDs.");
566
- const first = left.id.case === "command" ? `0${left.id.value.uuid}` : `1${left.id.value.value}`;
567
- const second = right.id.case === "command" ? `0${right.id.value.uuid}` : `1${right.id.value.value}`;
568
- return compareUtf8(first, second);
569
- }
570
- /**
571
- * Compares full Agent scope, including state type and canonical ID.
572
- */
573
- function compareScope(left, right) {
574
- return compareUtf8(left.stateType, right.stateType) || compareUtf8(left.agentKey, right.agentKey);
575
- }
576
- /**
577
- * Compares UTF-8 bytes using native binary order.
578
- */
579
- function compareUtf8(left, right) {
580
- const a = utf8.encode(left);
581
- const b = utf8.encode(right);
582
- for (let i = 0; i < Math.min(a.length, b.length); i++)
583
- if (a[i] !== b[i])
584
- return AgentExecutionValues.require(a[i]) - AgentExecutionValues.require(b[i]);
585
- return a.length - b.length;
586
- }
587
- //# sourceMappingURL=in-memory-agent-execution.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"in-memory-agent-execution.js","sourceRoot":"","sources":["../../src/memory/in-memory-agent-execution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAgB,MAAM,oBAAoB,CAAC;AAE3E,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAEhD,OAAO,EAAE,qBAAqB,EAA0B,MAAM,iCAAiC,CAAC;AAChG,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,qBAAqB,GAOtB,MAAM,+EAA+E,CAAC;AAWvF,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAE,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAA2B,MAAM,0BAA0B,CAAC;AACtF,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,g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