@spine-event-engine/storage-mysql 2.0.0-snapshot.22 → 2.0.0-snapshot.24
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/README.md +9 -5
- package/REFERENCE.md +59 -18
- package/dist/mysql/agent-execution.d.ts +276 -0
- package/dist/mysql/agent-execution.d.ts.map +1 -0
- package/dist/mysql/agent-execution.js +630 -0
- package/dist/mysql/agent-execution.js.map +1 -0
- package/dist/mysql/agent-history.d.ts +104 -0
- package/dist/mysql/agent-history.d.ts.map +1 -0
- package/dist/mysql/agent-history.js +212 -0
- package/dist/mysql/agent-history.js.map +1 -0
- package/dist/mysql/agent-transaction.d.ts +50 -0
- package/dist/mysql/agent-transaction.d.ts.map +1 -0
- package/dist/mysql/{entity-commit.js → agent-transaction.js} +18 -45
- package/dist/mysql/agent-transaction.js.map +1 -0
- package/dist/mysql/entity-history.d.ts +44 -35
- package/dist/mysql/entity-history.d.ts.map +1 -1
- package/dist/mysql/entity-history.js +282 -84
- package/dist/mysql/entity-history.js.map +1 -1
- package/dist/mysql/errors.d.ts +3 -2
- package/dist/mysql/errors.d.ts.map +1 -1
- package/dist/mysql/errors.js +3 -2
- package/dist/mysql/errors.js.map +1 -1
- package/dist/mysql/record-storage.d.ts +100 -38
- package/dist/mysql/record-storage.d.ts.map +1 -1
- package/dist/mysql/record-storage.js +287 -165
- package/dist/mysql/record-storage.js.map +1 -1
- package/dist/mysql/storage-factory.d.ts +20 -3
- package/dist/mysql/storage-factory.d.ts.map +1 -1
- package/dist/mysql/storage-factory.js +231 -57
- package/dist/mysql/storage-factory.js.map +1 -1
- package/dist/mysql/table-resolver.d.ts +6 -0
- package/dist/mysql/table-resolver.d.ts.map +1 -1
- package/dist/mysql/table-resolver.js +18 -11
- package/dist/mysql/table-resolver.js.map +1 -1
- package/dist/mysql/table-spec.d.ts +13 -0
- package/dist/mysql/table-spec.d.ts.map +1 -1
- package/dist/mysql/table-spec.js +81 -1
- package/dist/mysql/table-spec.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/dist/mysql/delivery-cleanup.d.ts +0 -37
- package/dist/mysql/delivery-cleanup.d.ts.map +0 -1
- package/dist/mysql/delivery-cleanup.js +0 -108
- package/dist/mysql/delivery-cleanup.js.map +0 -1
- package/dist/mysql/entity-commit.d.ts +0 -79
- package/dist/mysql/entity-commit.d.ts.map +0 -1
- package/dist/mysql/entity-commit.js.map +0 -1
package/README.md
CHANGED
|
@@ -11,10 +11,14 @@ record schemas, and a reachable MySQL database.
|
|
|
11
11
|
For database requirements, query limits, lifecycle, and error details, see
|
|
12
12
|
[REFERENCE documentation for agents](REFERENCE.md).
|
|
13
13
|
|
|
14
|
+
For an application using Agents, this provider keeps the Agent's accepted
|
|
15
|
+
work and recorded interactions across restarts. Use InnoDB for Agent repositories;
|
|
16
|
+
see the [coding-agent reference](REFERENCE.md) for database requirements.
|
|
17
|
+
|
|
14
18
|
## 💡 Why use it?
|
|
15
19
|
|
|
16
20
|
- ✅ Stores Spine records durably in a MySQL database.
|
|
17
|
-
- ✅ Manages a bounded `mysql2` connection pool
|
|
21
|
+
- ✅ Manages a bounded `mysql2` connection pool and atomic single-record conditions.
|
|
18
22
|
- ✅ Supports declared-column filters, sorting, offsets, limits, and
|
|
19
23
|
continuations.
|
|
20
24
|
- ✅ Keeps adapter tables private behind the common `RecordStorage` API.
|
|
@@ -114,10 +118,10 @@ pnpm typecheck:build
|
|
|
114
118
|
## ✨ Supported records and queries
|
|
115
119
|
|
|
116
120
|
The adapter performs record CRUD, payload-based compare-and-set, named-column
|
|
117
|
-
queries, sort order, offsets, limits, and keyset continuations.
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
+
queries, sort order, offsets, limits, and keyset continuations. Batches and
|
|
122
|
+
Entity commits use independent ordered records on InnoDB, MyISAM, and Aria.
|
|
123
|
+
A failed operation can leave its completed prefix; an identical Entity retry
|
|
124
|
+
reuses prepared versions and Event IDs. It supports primitive and structured
|
|
121
125
|
storage IDs. Declared columns support strings, booleans, integral Protobuf
|
|
122
126
|
numbers, enums, bytes, messages, `Timestamp`, and `Version`. Spine JVM JDBC
|
|
123
127
|
does not support `float` or `double` record columns, so this adapter rejects
|
package/REFERENCE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @spine-event-engine/storage-mysql reference
|
|
2
2
|
|
|
3
|
-
This reference is for agents configuring the supported MySQL storage adapter.
|
|
3
|
+
This reference is for coding agents configuring the supported MySQL storage adapter.
|
|
4
4
|
|
|
5
5
|
## Public entry point
|
|
6
6
|
|
|
@@ -62,17 +62,19 @@ complete generated `TenantId` on each operation and routes it to its configured
|
|
|
62
62
|
database. Bounded Context names are diagnostic only and never partition rows,
|
|
63
63
|
tables, locks, or queries.
|
|
64
64
|
|
|
65
|
-
Each Entity source and history family has an independent table.
|
|
66
|
-
|
|
65
|
+
Each Entity source and history family has an independent table. Top-level
|
|
66
|
+
provider error messages and public responses omit connection URLs,
|
|
67
|
+
credentials, and driver details. The original driver failure remains available
|
|
68
|
+
as the internal `cause`; do not expose it in public responses or unfiltered
|
|
69
|
+
logs.
|
|
67
70
|
|
|
68
71
|
## Records and queries
|
|
69
72
|
|
|
70
|
-
CRUD operations use normal statements. Payload-based compare-and-set uses
|
|
71
|
-
|
|
72
|
-
`writeAll` encodes
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
identical retry. Repeated storage slots in a batch leave the last entry as the
|
|
73
|
+
CRUD operations use normal statements. Payload-based compare-and-set uses
|
|
74
|
+
atomic conditional statements for one storage slot on InnoDB, MyISAM, and Aria.
|
|
75
|
+
`writeAll` encodes input first and writes entries in input order; a later failure
|
|
76
|
+
leaves completed rows in place on every engine. Repeated storage slots in a
|
|
77
|
+
batch leave the last completed entry as the
|
|
76
78
|
stored value. IDs are declared as generated message IDs or the supported
|
|
77
79
|
primitive `string`, `int32`, and `int64` kinds. Primitive IDs use native MySQL
|
|
78
80
|
values; message IDs use their reversible stringifier, compact Proto JSON by
|
|
@@ -121,21 +123,60 @@ acquired.
|
|
|
121
123
|
## Entity history seam
|
|
122
124
|
|
|
123
125
|
The provider/framework Entity handle returns current records plus immutable
|
|
124
|
-
state and event history. It is not a remote application history API. State
|
|
125
|
-
|
|
126
|
+
state and event history. It is not a remote application history API. State and
|
|
127
|
+
diagnostic append use immutable per-record insertion. Trim and truncate use
|
|
126
128
|
fixed-size chunks. A failed chunk can leave earlier chunks durable, so callers
|
|
127
129
|
retry maintenance. Current-record and history actions are separate calls, not
|
|
128
130
|
one cross-storage transaction.
|
|
129
131
|
|
|
130
|
-
The internal
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
operations remain separate
|
|
132
|
+
The internal Entity commit port writes state history, diagnostic Events,
|
|
133
|
+
framework delivery Events, then current state as independent records. A failure
|
|
134
|
+
can leave a completed prefix on every engine. One classified deadlock retry
|
|
135
|
+
replays captured input with unchanged versions and Event IDs. Standalone
|
|
136
|
+
history operations remain separate; a delivery Event alone does not prove the
|
|
137
|
+
current-state write completed.
|
|
138
|
+
|
|
139
|
+
## Agent history
|
|
140
|
+
|
|
141
|
+
The provider-only Agent history handle stores original complete
|
|
142
|
+
`AgentHistoryEntry` bytes and full repository scope in one `agent_history`
|
|
143
|
+
record family per tenant database. SHA-256 digests provide bounded physical
|
|
144
|
+
record IDs and indexed scope/conversation keys; reads also compare the full
|
|
145
|
+
state type, Agent key, and selected conversation key with binary equality.
|
|
146
|
+
Three validated InnoDB B-tree indexes cover scope plus full order, scope plus
|
|
147
|
+
category plus full order, and scope plus conversation digest plus full order.
|
|
148
|
+
The `VARBINARY(2944)` order column fits the 3,072-byte InnoDB composite-index
|
|
149
|
+
budget with two 64-byte digests; category uses 12 bytes. Its value encodes the
|
|
150
|
+
complete Timestamp, category, and unsigned UTF-8 record ID. Longer values
|
|
151
|
+
reject before storage rather than using a prefix index. Existing prefix,
|
|
152
|
+
misordered, or otherwise incompatible same-name indexes reject when the handle
|
|
153
|
+
opens. Pages use bounded native SQL chunks and sum serialized entry bytes; a
|
|
154
|
+
fetched chunk can be larger than the returned byte budget.
|
|
155
|
+
|
|
156
|
+
## Agent execution
|
|
157
|
+
|
|
158
|
+
Agent execution conformance is exercised with MySQL 5.7 and 8.4, and MariaDB 11.4.
|
|
159
|
+
|
|
160
|
+
Agent repositories require InnoDB. The execution handle rejects a nontransactional
|
|
161
|
+
engine before accepting Agent work; the existing engine choices for other Entity
|
|
162
|
+
families are unchanged. Execution and per-instance pending records use complete
|
|
163
|
+
binary ordering keys and validated composite indexes.
|
|
164
|
+
|
|
165
|
+
One connection transaction checks the claim and initial Entity Version, then
|
|
166
|
+
writes state, mandatory history, preferences and outgoing Command obligations. Emitted
|
|
167
|
+
domain Events enter immutable Agent history and are handed to the normal EventBus
|
|
168
|
+
after completion without a saved delivery phase. Connection
|
|
169
|
+
binding is scoped to that asynchronous operation. Encoded execution,
|
|
170
|
+
per-instance, and Agent history records must each fit the 65,535-byte BLOB limit. The runtime must
|
|
171
|
+
check its response reservation against the provider limits before inference.
|
|
172
|
+
Reopening a factory can read the saved work. No transaction remains open during
|
|
173
|
+
a model request.
|
|
135
174
|
|
|
136
175
|
`MysqlStorageSchemaError` reports incompatible layouts,
|
|
137
176
|
`MysqlStorageDataError` reports stored bytes that cannot be decoded, and
|
|
138
177
|
`MysqlStorageOperationError` reports sanitized bounds, query, collision, and
|
|
139
178
|
driver-operation failures. Custom creation uses `useOperationFactory()`; its
|
|
140
|
-
resolved `MysqlTableSpec` has the same native column types and
|
|
141
|
-
as default DDL
|
|
179
|
+
resolved `MysqlTableSpec` has the same native column types and family-specific
|
|
180
|
+
naming as default DDL. A grouped family uses its explicit grouped override or
|
|
181
|
+
grouped default; an ungrouped family uses its explicit record override or
|
|
182
|
+
ungrouped default. An ungrouped override never aliases a grouped family.
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { type Message } from "@bufbuild/protobuf";
|
|
2
|
+
import type { Timestamp } from "@bufbuild/protobuf/wkt";
|
|
3
|
+
import type { CommandId, Event, EventId } from "@spine-event-engine/proto";
|
|
4
|
+
import { type AgentAcceptedInvocation, type AgentExecutionHead, type AgentExecutionRecord, type AgentInvocationKey } from "@spine-event-engine/proto/generated/spine/server/agent/execution_record_pb.js";
|
|
5
|
+
import type { AgentHistoryRecord } from "@spine-event-engine/proto/generated/spine/server/agent/history_record_pb.js";
|
|
6
|
+
import { type AgentExecutionStorage, type AgentExecutionCapacity, type AgentExecutionStorageInput, type AgentExecutionClaim, type AgentExecutionUpdate, type AgentExecutionComplete, type AgentPendingRead, type AgentPendingPage } from "@spine-event-engine/storage/provider";
|
|
7
|
+
import { MysqlAgentTransaction } from "./agent-transaction.js";
|
|
8
|
+
import { MysqlEntityStorage } from "./entity-history.js";
|
|
9
|
+
import { MysqlRecordStorage } from "./record-storage.js";
|
|
10
|
+
/**
|
|
11
|
+
* Native records that participate in every Agent execution transaction.
|
|
12
|
+
*
|
|
13
|
+
* @typeParam I Typed entity identifier.
|
|
14
|
+
* @typeParam S Generated Entity state.
|
|
15
|
+
*/
|
|
16
|
+
interface ExecutionRows<I, S extends Message> {
|
|
17
|
+
readonly invocation: MysqlRecordStorage<string, AgentExecutionRecord>;
|
|
18
|
+
readonly head: MysqlRecordStorage<string, AgentExecutionHead>;
|
|
19
|
+
readonly history: MysqlRecordStorage<string, AgentHistoryRecord>;
|
|
20
|
+
readonly entity: MysqlEntityStorage<I, S>;
|
|
21
|
+
readonly events: MysqlRecordStorage<EventId, Event>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Persists Agent claims and evidence through one required InnoDB transaction.
|
|
25
|
+
*
|
|
26
|
+
* @typeParam I Typed Agent identifier.
|
|
27
|
+
* @typeParam S Generated Agent state.
|
|
28
|
+
*/
|
|
29
|
+
export declare class MysqlAgentExecution<I, S extends Message> implements AgentExecutionStorage<I, S> {
|
|
30
|
+
#private;
|
|
31
|
+
private readonly input;
|
|
32
|
+
private readonly rows;
|
|
33
|
+
private readonly coordinator;
|
|
34
|
+
/**
|
|
35
|
+
* Native BLOB row limits for complete internal Protobuf wrappers.
|
|
36
|
+
*/
|
|
37
|
+
readonly capacity: Required<Pick<AgentExecutionCapacity, "executionRecordBytes" | "executionHeadBytes" | "historyRecordBytes">>;
|
|
38
|
+
/**
|
|
39
|
+
* Binds tenant-scoped record families and the native transaction coordinator.
|
|
40
|
+
*
|
|
41
|
+
* @param coordinator Native transaction coordinator.
|
|
42
|
+
* @param input Requested fenced execution change.
|
|
43
|
+
* @param rows Provider record handles bound to the tenant.
|
|
44
|
+
*/
|
|
45
|
+
constructor(input: AgentExecutionStorageInput<I, S>, rows: ExecutionRows<I, S>, coordinator: MysqlAgentTransaction);
|
|
46
|
+
/**
|
|
47
|
+
* Persists original accepted work once under the per-instance row lock.
|
|
48
|
+
*
|
|
49
|
+
* @param accepted Original accepted signal and selected bindings.
|
|
50
|
+
* @returns Persisted invocation with the original accepted facts.
|
|
51
|
+
*/
|
|
52
|
+
admit(accepted: AgentAcceptedInvocation): Promise<AgentExecutionRecord>;
|
|
53
|
+
/**
|
|
54
|
+
* Reads one bounded page from complete native pending indexes.
|
|
55
|
+
*
|
|
56
|
+
* @param request Bounded pending-page request.
|
|
57
|
+
* @returns Bounded eligible work and continuation cursor.
|
|
58
|
+
*/
|
|
59
|
+
pending(request: AgentPendingRead): Promise<AgentPendingPage>;
|
|
60
|
+
/**
|
|
61
|
+
* Builds the indexed native query for one fixed eligibility cutoff.
|
|
62
|
+
*
|
|
63
|
+
* @param request Bounded pending-page request.
|
|
64
|
+
* @param asOf Fixed provider-time eligibility cutoff.
|
|
65
|
+
* @returns Native SQL and exact bound values.
|
|
66
|
+
*/
|
|
67
|
+
private pendingQuery;
|
|
68
|
+
/**
|
|
69
|
+
* Reads one complete invocation after provider reconstruction.
|
|
70
|
+
*
|
|
71
|
+
* @param key Original Agent invocation identity.
|
|
72
|
+
* @returns Complete stored invocation when present.
|
|
73
|
+
*/
|
|
74
|
+
read(key: AgentInvocationKey): Promise<AgentExecutionRecord | undefined>;
|
|
75
|
+
/**
|
|
76
|
+
* Acquires earliest unresolved work and records the current exclusive token.
|
|
77
|
+
*
|
|
78
|
+
* @param expiresAt Requested future lease expiry.
|
|
79
|
+
* @param key Original Agent invocation identity.
|
|
80
|
+
* @param token Exclusive claim token.
|
|
81
|
+
* @returns Claimed work and preferences when eligible.
|
|
82
|
+
*/
|
|
83
|
+
claim(key: AgentInvocationKey, token: string, expiresAt: Timestamp): Promise<AgentExecutionClaim | undefined>;
|
|
84
|
+
/**
|
|
85
|
+
* Checks the locked instance and writes one current lease.
|
|
86
|
+
*
|
|
87
|
+
* @param key Original Agent invocation identity.
|
|
88
|
+
* @param token New exclusive claim token.
|
|
89
|
+
* @param expiresAt Requested future lease expiry.
|
|
90
|
+
* @returns Claimed record and preferences when eligible.
|
|
91
|
+
*/
|
|
92
|
+
private claimLocked;
|
|
93
|
+
/**
|
|
94
|
+
* Checks the current head and earliest same-instance source.
|
|
95
|
+
*
|
|
96
|
+
* @param head Per-instance pending and lease record.
|
|
97
|
+
* @param key Original Agent invocation identity.
|
|
98
|
+
* @param now Fresh time read in the locked transaction.
|
|
99
|
+
* @returns Whether this invocation may receive the next lease.
|
|
100
|
+
*/
|
|
101
|
+
private eligibleClaim;
|
|
102
|
+
/**
|
|
103
|
+
* Updates a still-live token under a fresh transaction clock.
|
|
104
|
+
*
|
|
105
|
+
* @param expiresAt Requested future lease expiry.
|
|
106
|
+
* @param key Original Agent invocation identity.
|
|
107
|
+
* @param token Exclusive claim token.
|
|
108
|
+
* @returns Whether the current lease was extended.
|
|
109
|
+
*/
|
|
110
|
+
renew(key: AgentInvocationKey, token: string, expiresAt: Timestamp): Promise<boolean>;
|
|
111
|
+
/**
|
|
112
|
+
* Persists a journal update and its immutable history under one transaction.
|
|
113
|
+
*
|
|
114
|
+
* @param input Requested fenced execution change.
|
|
115
|
+
* @returns Completion after fenced evidence is persisted.
|
|
116
|
+
*/
|
|
117
|
+
update(input: AgentExecutionUpdate): Promise<void>;
|
|
118
|
+
/**
|
|
119
|
+
* Commits state, history, preferences and outgoing obligations together.
|
|
120
|
+
*
|
|
121
|
+
* @param input Requested fenced execution change.
|
|
122
|
+
* @returns Completion after conditional Entity and evidence commit.
|
|
123
|
+
*/
|
|
124
|
+
complete(input: AgentExecutionComplete<I, S>): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Marks original outgoing IDs delivered under the still-current token.
|
|
127
|
+
*
|
|
128
|
+
* @param expectedRecordBytes Exact prior execution record bytes.
|
|
129
|
+
* @param key Original Agent invocation identity.
|
|
130
|
+
* @param signals Original outgoing signal identities.
|
|
131
|
+
* @param token Exclusive claim token.
|
|
132
|
+
* @returns Completion after original output IDs are marked delivered.
|
|
133
|
+
*/
|
|
134
|
+
markDelivered(key: AgentInvocationKey, token: string, expectedRecordBytes: Uint8Array, signals: readonly CommandId[]): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Marks exact saved output IDs within the current per-instance transaction.
|
|
137
|
+
*
|
|
138
|
+
* @param key Original Agent invocation identity.
|
|
139
|
+
* @param token Current exclusive claim token.
|
|
140
|
+
* @param expectedRecordBytes Exact prior execution record bytes.
|
|
141
|
+
* @param signals Original accepted output IDs.
|
|
142
|
+
* @returns Completion after persisted output status is updated.
|
|
143
|
+
*/
|
|
144
|
+
private deliverLocked;
|
|
145
|
+
/**
|
|
146
|
+
* Closes record handles without deleting accepted work.
|
|
147
|
+
*/
|
|
148
|
+
close(): void;
|
|
149
|
+
/**
|
|
150
|
+
* Prepares existing record families and verifies complete binary indexes.
|
|
151
|
+
*
|
|
152
|
+
* @returns Completion after provider capabilities are checked.
|
|
153
|
+
*/
|
|
154
|
+
private ready;
|
|
155
|
+
/**
|
|
156
|
+
* Prepares every table before transactions and checks the native indexes.
|
|
157
|
+
*
|
|
158
|
+
* @returns Completion after native tables and indexes are prepared.
|
|
159
|
+
*/
|
|
160
|
+
private initialize;
|
|
161
|
+
/**
|
|
162
|
+
* Executes all record-family work on one required InnoDB connection.
|
|
163
|
+
*
|
|
164
|
+
* @param key Original Agent invocation identity.
|
|
165
|
+
* @param work Operation executed inside the transaction.
|
|
166
|
+
* @returns Callback result after the native transaction commits.
|
|
167
|
+
* @typeParam T Result returned by the transaction callback.
|
|
168
|
+
*/
|
|
169
|
+
private transaction;
|
|
170
|
+
/**
|
|
171
|
+
* Reads a head under the transaction lock and verifies the full scope.
|
|
172
|
+
*
|
|
173
|
+
* @param key Original Agent invocation identity.
|
|
174
|
+
* @returns Per-instance head when present.
|
|
175
|
+
*/
|
|
176
|
+
private currentHead;
|
|
177
|
+
/**
|
|
178
|
+
* Reads the invocation under the transaction lock and verifies its identity.
|
|
179
|
+
*
|
|
180
|
+
* @param key Original Agent invocation identity.
|
|
181
|
+
* @returns Stored invocation when present.
|
|
182
|
+
*/
|
|
183
|
+
private existing;
|
|
184
|
+
/**
|
|
185
|
+
* Rejects a physical digest collision on an invocation row.
|
|
186
|
+
*
|
|
187
|
+
* @param found Stored record read in this transaction.
|
|
188
|
+
* @param key Original Agent invocation identity.
|
|
189
|
+
*/
|
|
190
|
+
private checkIdentity;
|
|
191
|
+
/**
|
|
192
|
+
* Checks this is the earliest unresolved invocation in the full scope.
|
|
193
|
+
*
|
|
194
|
+
* @param key Original Agent invocation identity.
|
|
195
|
+
* @returns Whether this invocation is earliest unresolved work.
|
|
196
|
+
*/
|
|
197
|
+
private earliest;
|
|
198
|
+
/**
|
|
199
|
+
* Reads at most two native rows for each unresolved status.
|
|
200
|
+
*
|
|
201
|
+
* @param exclude Invocation omitted while selecting the successor.
|
|
202
|
+
* @param key Original Agent invocation identity.
|
|
203
|
+
* @returns Earliest unresolved invocation when present.
|
|
204
|
+
*/
|
|
205
|
+
private successor;
|
|
206
|
+
/**
|
|
207
|
+
* Adds an earlier source while retaining the prior eligibility value.
|
|
208
|
+
*
|
|
209
|
+
* @param head Per-instance pending and lease record.
|
|
210
|
+
* @param record Persisted Agent execution record.
|
|
211
|
+
*/
|
|
212
|
+
private offerCandidate;
|
|
213
|
+
/**
|
|
214
|
+
* Updates terminal work to the next same-instance source in one transaction.
|
|
215
|
+
*
|
|
216
|
+
* @param head Per-instance pending and lease record.
|
|
217
|
+
* @param key Original Agent invocation identity.
|
|
218
|
+
* @param order Original Inbox order.
|
|
219
|
+
* @returns Completion after updating the next pending head.
|
|
220
|
+
*/
|
|
221
|
+
private advanceCandidate;
|
|
222
|
+
/**
|
|
223
|
+
* Reads the current claim with fresh Time inside the native transaction.
|
|
224
|
+
*
|
|
225
|
+
* @param key Original Agent invocation identity.
|
|
226
|
+
* @param token Exclusive claim token.
|
|
227
|
+
* @returns Current record and head if the token remains valid.
|
|
228
|
+
*/
|
|
229
|
+
private claimed;
|
|
230
|
+
/**
|
|
231
|
+
* Checks exact prior bytes and preserves immutable source facts.
|
|
232
|
+
*
|
|
233
|
+
* @param checkNext Whether to validate the proposed next record.
|
|
234
|
+
* @param input Requested fenced execution change.
|
|
235
|
+
* @returns Current fenced record and head.
|
|
236
|
+
*/
|
|
237
|
+
private expected;
|
|
238
|
+
/**
|
|
239
|
+
* Prepares immutable history records under the same fenced transaction.
|
|
240
|
+
*
|
|
241
|
+
* @param entries Immutable history entries to append.
|
|
242
|
+
* @param key Original Agent invocation identity.
|
|
243
|
+
* @returns Completion after immutable history is appended.
|
|
244
|
+
*/
|
|
245
|
+
private appendHistory;
|
|
246
|
+
/**
|
|
247
|
+
* Rejects a changed initial Version and applies Entity rows in this transaction.
|
|
248
|
+
*
|
|
249
|
+
* @param expectedVersion Expected current Entity Version.
|
|
250
|
+
* @param input Requested fenced execution change.
|
|
251
|
+
* @returns Completion after conditional Entity state and Version write.
|
|
252
|
+
*/
|
|
253
|
+
private completeEntity;
|
|
254
|
+
/**
|
|
255
|
+
* Checks exactly one Version advance or a no-op completion.
|
|
256
|
+
*
|
|
257
|
+
* @param input Requested fenced execution change.
|
|
258
|
+
* @param prior Previously persisted execution record.
|
|
259
|
+
* @returns Expected initial Entity Version.
|
|
260
|
+
*/
|
|
261
|
+
private validateCompletion;
|
|
262
|
+
/**
|
|
263
|
+
* Rejects values outside the full InnoDB index or record payload budget.
|
|
264
|
+
*
|
|
265
|
+
* @param record Persisted Agent execution record.
|
|
266
|
+
*/
|
|
267
|
+
private validateRecord;
|
|
268
|
+
/**
|
|
269
|
+
* Checks complete indexed discovery and native record payload budgets.
|
|
270
|
+
*
|
|
271
|
+
* @param head Per-instance pending and lease record.
|
|
272
|
+
*/
|
|
273
|
+
private validateHead;
|
|
274
|
+
}
|
|
275
|
+
export {};
|
|
276
|
+
//# sourceMappingURL=agent-execution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-execution.d.ts","sourceRoot":"","sources":["../../src/mysql/agent-execution.ts"],"names":[],"mappings":"AAcA,OAAO,EAAoB,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAE3E,OAAO,EAIL,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACxB,MAAM,+EAA+E,CAAC;AACvF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6EAA6E,CAAC;AACtH,OAAO,EAML,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,kBAAkB,E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