@microdelta/history 0.0.0 → 0.2.0
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 +30 -4
- package/dist/api/history.alpha.d.ts +3 -0
- package/dist/api/history.beta.d.ts +3 -0
- package/dist/api/history.conformance.store.alpha.d.ts +3 -0
- package/dist/api/history.conformance.store.beta.d.ts +3 -0
- package/dist/api/history.conformance.store.public.d.ts +3 -0
- package/dist/api/history.conformance.store.raw.alpha.d.ts +215 -0
- package/dist/api/history.conformance.store.raw.beta.d.ts +215 -0
- package/dist/api/history.conformance.store.raw.public.d.ts +215 -0
- package/dist/api/history.conformance.store.raw.untrimmed.d.ts +215 -0
- package/dist/api/history.conformance.store.untrimmed.d.ts +3 -0
- package/dist/api/history.public.d.ts +3 -0
- package/dist/api/history.root.raw.alpha.d.ts +1371 -0
- package/dist/api/history.root.raw.beta.d.ts +425 -0
- package/dist/api/history.root.raw.public.d.ts +425 -0
- package/dist/api/history.root.raw.untrimmed.d.ts +1372 -0
- package/dist/api/history.shared.alpha.d.ts +1402 -0
- package/dist/api/history.shared.beta.d.ts +456 -0
- package/dist/api/history.shared.public.d.ts +456 -0
- package/dist/api/history.shared.untrimmed.d.ts +1403 -0
- package/dist/api/history.untrimmed.d.ts +3 -0
- package/dist/api/tsdoc-metadata.json +11 -0
- package/dist/src/completed-results.d.ts +99 -0
- package/dist/src/completed-results.d.ts.map +1 -0
- package/dist/src/completed-results.js +2 -0
- package/dist/src/completed-results.js.map +1 -0
- package/dist/src/durable/contracts.d.ts +612 -0
- package/dist/src/durable/contracts.d.ts.map +1 -0
- package/dist/src/durable/contracts.js +2 -0
- package/dist/src/durable/contracts.js.map +1 -0
- package/dist/src/durable/errors.d.ts +94 -0
- package/dist/src/durable/errors.d.ts.map +1 -0
- package/dist/src/durable/errors.js +118 -0
- package/dist/src/durable/errors.js.map +1 -0
- package/dist/src/durable/index.d.ts +9 -0
- package/dist/src/durable/index.d.ts.map +1 -0
- package/dist/src/durable/index.js +770 -0
- package/dist/src/durable/index.js.map +1 -0
- package/dist/src/durable/journal.d.ts +53 -0
- package/dist/src/durable/journal.d.ts.map +1 -0
- package/dist/src/durable/journal.js +174 -0
- package/dist/src/durable/journal.js.map +1 -0
- package/dist/src/durable/locator.d.ts +31 -0
- package/dist/src/durable/locator.d.ts.map +1 -0
- package/dist/src/durable/locator.js +50 -0
- package/dist/src/durable/locator.js.map +1 -0
- package/dist/src/durable/records.d.ts +40 -0
- package/dist/src/durable/records.d.ts.map +1 -0
- package/dist/src/durable/records.js +74 -0
- package/dist/src/durable/records.js.map +1 -0
- package/dist/src/durable/schema.d.ts +37 -0
- package/dist/src/durable/schema.d.ts.map +1 -0
- package/dist/src/durable/schema.js +335 -0
- package/dist/src/durable/schema.js.map +1 -0
- package/dist/src/durable/selected-index.d.ts +94 -0
- package/dist/src/durable/selected-index.d.ts.map +1 -0
- package/dist/src/durable/selected-index.js +594 -0
- package/dist/src/durable/selected-index.js.map +1 -0
- package/dist/src/index.d.ts +28 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +15 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/store/index.d.ts +128 -0
- package/dist/src/store/index.d.ts.map +1 -0
- package/dist/src/store/index.js +33 -0
- package/dist/src/store/index.js.map +1 -0
- package/dist/src/store/memory/index.d.ts +24 -0
- package/dist/src/store/memory/index.d.ts.map +1 -0
- package/dist/src/store/memory/index.js +162 -0
- package/dist/src/store/memory/index.js.map +1 -0
- package/dist/src/types.d.ts +100 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/test/conformance/store/index.d.ts +34 -0
- package/dist/test/conformance/store/index.d.ts.map +1 -0
- package/dist/test/conformance/store/index.js +368 -0
- package/dist/test/conformance/store/index.js.map +1 -0
- package/package.json +48 -8
|
@@ -0,0 +1,1402 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One declaration identity contains History's root and Store conformance APIs.
|
|
3
|
+
* This build-only entry does not define a runtime module or add conformance
|
|
4
|
+
* behavior to the public root export.
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* An attempt key is already bound to a different execution intent, version
|
|
10
|
+
* or scoped subject. The key identifies one execution; it cannot serve another.
|
|
11
|
+
* @alpha
|
|
12
|
+
*/
|
|
13
|
+
export declare class AttemptConflictError extends Error {
|
|
14
|
+
/** Create an execution-identity conflict with a diagnostic message. */
|
|
15
|
+
constructor(message: string);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A lifecycle operation was requested from a state that does not permit it,
|
|
20
|
+
* such as staging a completed attempt or publishing one that was never staged.
|
|
21
|
+
* @alpha
|
|
22
|
+
*/
|
|
23
|
+
export declare class AttemptStateError extends Error {
|
|
24
|
+
/** Create an invalid-transition rejection with a diagnostic message. */
|
|
25
|
+
constructor(message: string);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Create a memory Store with linearizable CAS in a single JavaScript isolate.
|
|
30
|
+
* Each mutation snapshots its arguments before checking and changing the maps;
|
|
31
|
+
* the qualifying check and write have no await or caller callback between them.
|
|
32
|
+
* Values and fingerprints have separate indexes, so verification never touches
|
|
33
|
+
* payloads. The injected snapshot capability owns its supported value domain
|
|
34
|
+
* and failure behavior. This is a test backend, not durable or shared across
|
|
35
|
+
* processes.
|
|
36
|
+
*
|
|
37
|
+
* Only row storage is implemented here. Publication across multiple rows,
|
|
38
|
+
* generation allocation, lease ownership, and reclamation belong to higher layers.
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
export declare function createMemoryStore(capability: ISnapshotCapability, options?: MemoryStoreOptions): Store;
|
|
42
|
+
|
|
43
|
+
/** The first observed difference in a persisted read or a nested verification. @public */
|
|
44
|
+
export declare type Divergence = {
|
|
45
|
+
read: RecordedRead;
|
|
46
|
+
was: Fingerprint;
|
|
47
|
+
now: Fingerprint | 'missing';
|
|
48
|
+
} | {
|
|
49
|
+
read: Extract<RecordedRead, {
|
|
50
|
+
kind: 'memo';
|
|
51
|
+
}>;
|
|
52
|
+
nested: Divergence;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/** Insert-only storage encountered an existing complete tuple. @public */
|
|
56
|
+
export declare class DuplicateRowError extends Error {
|
|
57
|
+
/** Identify an insert conflict without modifying the retained row. @public */
|
|
58
|
+
constructor(message?: string);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** An immutable value node and its caller-computed fingerprint. @public */
|
|
62
|
+
export declare interface FieldRow {
|
|
63
|
+
key: ResultKey;
|
|
64
|
+
generation: number;
|
|
65
|
+
path: Path;
|
|
66
|
+
fingerprint: Fingerprint;
|
|
67
|
+
value: unknown;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Compatibility shapes for the scaffold row Store. Their names and string paths
|
|
72
|
+
* describe that storage port, not the target Value Semantics or identity model.
|
|
73
|
+
*/
|
|
74
|
+
/** Opaque, stable, hex-encoded content digest; equality is string equality. @public */
|
|
75
|
+
export declare type Fingerprint = string & {
|
|
76
|
+
readonly __fp: unique symbol;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/** Stored fingerprints cannot be compared with this runtime's algorithm. @public */
|
|
80
|
+
export declare class FingerprintAlgorithmMismatchError extends Error {
|
|
81
|
+
/** Name both identifiers so migrations are explicit rather than silent misses. @public */
|
|
82
|
+
constructor(storedAlgorithm: string, runtimeAlgorithm: string);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Writable generation columns; tuple identity cannot change after insertion. @public */
|
|
86
|
+
export declare type GenerationPatch = Partial<Omit<GenerationRow, 'key' | 'generation'>>;
|
|
87
|
+
|
|
88
|
+
/** A retained attempt, with lifecycle and numbering supplied by its caller. @public */
|
|
89
|
+
export declare interface GenerationRow {
|
|
90
|
+
key: ResultKey;
|
|
91
|
+
generation: number;
|
|
92
|
+
state: GenerationState;
|
|
93
|
+
reads: RecordedRead[];
|
|
94
|
+
identity: Identity | undefined;
|
|
95
|
+
startedAt: number;
|
|
96
|
+
endedAt: number | null;
|
|
97
|
+
cost: Record<string, number>;
|
|
98
|
+
arrival: string;
|
|
99
|
+
abandonReason?: 'error' | 'lease-expired' | 'refused';
|
|
100
|
+
error?: {
|
|
101
|
+
message: string;
|
|
102
|
+
stack?: string;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Retained lifecycle states interpreted by repository and claim, not by storage. @public */
|
|
107
|
+
export declare type GenerationState = 'claimed' | 'current' | 'superseded' | 'abandoned';
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The injected clock failed to produce a nonnegative safe-integer epoch
|
|
111
|
+
* millisecond reading, so the time-dependent operation was refused unchanged.
|
|
112
|
+
* @alpha
|
|
113
|
+
*/
|
|
114
|
+
export declare class HistoryClockError extends Error {
|
|
115
|
+
/** Create a clock refusal with a diagnostic message. */
|
|
116
|
+
constructor(message: string);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* The store's contents contradict History's invariants or the caller's exact
|
|
121
|
+
* reference: a malformed, missing or wrong-scope reference, a dangling
|
|
122
|
+
* dependency, or index/payload content that does not match its digests.
|
|
123
|
+
* History never repairs such a failure by following a current pointer or
|
|
124
|
+
* recomputing.
|
|
125
|
+
* @alpha
|
|
126
|
+
*/
|
|
127
|
+
export declare class HistoryIntegrityError extends Error {
|
|
128
|
+
/** Create an integrity failure with a diagnostic message. */
|
|
129
|
+
constructor(message: string);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* The SQLite file does not hold exactly History's supported schema for the
|
|
134
|
+
* requested logical store: unknown, incomplete, foreign or differently
|
|
135
|
+
* versioned storage is rejected before any work rather than migrated by guess.
|
|
136
|
+
* @alpha
|
|
137
|
+
*/
|
|
138
|
+
export declare class HistorySchemaError extends Error {
|
|
139
|
+
/** Create a schema rejection with a diagnostic message. */
|
|
140
|
+
constructor(message: string);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Ends an incomplete attempt without a result, preserving its evidence. @alpha */
|
|
144
|
+
export declare interface IAbandonRequest {
|
|
145
|
+
/** The incomplete attempt to end. */
|
|
146
|
+
readonly attemptId: number;
|
|
147
|
+
/** Whether execution failed or was interrupted. */
|
|
148
|
+
readonly outcome: 'failed' | 'interrupted';
|
|
149
|
+
/** Owner-defined evidence of what happened. */
|
|
150
|
+
readonly evidence: IVersionedRecord;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** One immutable current-acceptance record, separate from the result it names. @alpha */
|
|
154
|
+
export declare interface IAcceptanceRecord {
|
|
155
|
+
/** Store-wide never-reused acceptance identity, increasing in record order. */
|
|
156
|
+
readonly acceptanceId: number;
|
|
157
|
+
/** The accepted exact result. */
|
|
158
|
+
readonly reference: ICompletedResultReference;
|
|
159
|
+
/** The environment namespace whose verification recorded this acceptance. */
|
|
160
|
+
readonly environment: string;
|
|
161
|
+
/** The writer fence under which the acceptance was recorded. */
|
|
162
|
+
readonly fence: number;
|
|
163
|
+
/** Resolution's acceptance evidence, decoded and frozen. */
|
|
164
|
+
readonly evidence: IVersionedRecord;
|
|
165
|
+
/** Exact results the verification followed, in recorded order. */
|
|
166
|
+
readonly dependencies: readonly ICompletedResultReference[];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Records that an existing completed result was accepted by a current
|
|
171
|
+
* verification. It needs writer ownership to write, but no attempt: a valid
|
|
172
|
+
* hit claims no execution. The evidence names the current dependencies the
|
|
173
|
+
* verification followed, which may differ from the original provenance.
|
|
174
|
+
* @alpha
|
|
175
|
+
*/
|
|
176
|
+
export declare interface IAcceptanceRequest {
|
|
177
|
+
/** The exact completed result that was accepted. */
|
|
178
|
+
readonly reference: ICompletedResultReference;
|
|
179
|
+
/** Resolution's versioned acceptance evidence. */
|
|
180
|
+
readonly evidence: IVersionedRecord;
|
|
181
|
+
/**
|
|
182
|
+
* Exact completed results the current verification followed. Each must be
|
|
183
|
+
* admissible in the accepting environment: published there, or named by a
|
|
184
|
+
* promotion into it.
|
|
185
|
+
*/
|
|
186
|
+
readonly dependencies: readonly ICompletedResultReference[];
|
|
187
|
+
/**
|
|
188
|
+
* The environment, within the result's analysis, whose current verification
|
|
189
|
+
* accepted the result. It is always explicit and never inferred from the
|
|
190
|
+
* reference: the caller names its own run environment. It may be the
|
|
191
|
+
* environment that published the result, or another environment into which
|
|
192
|
+
* a recorded promotion admits the result. The acceptance then belongs to
|
|
193
|
+
* that environment's namespace alone and never satisfies a lookup in any
|
|
194
|
+
* other environment.
|
|
195
|
+
*/
|
|
196
|
+
readonly environment: string;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** @alpha A path segment whose kind follows the container's operation semantics. */
|
|
200
|
+
export declare type IAddressSegment =
|
|
201
|
+
/** A literal string-keyed record lookup, including keys containing punctuation. */
|
|
202
|
+
{
|
|
203
|
+
readonly kind: 'property';
|
|
204
|
+
readonly key: string;
|
|
205
|
+
}
|
|
206
|
+
/** A positional array lookup; it does not designate a logical member identity. */
|
|
207
|
+
| {
|
|
208
|
+
readonly kind: 'index';
|
|
209
|
+
readonly index: number;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* One durable attempt as History records it. The attempt identity is issued
|
|
214
|
+
* from a store-wide counter that never reissues a value, including after
|
|
215
|
+
* abandonment or process death (PUB-003).
|
|
216
|
+
* @alpha
|
|
217
|
+
*/
|
|
218
|
+
export declare interface IAttemptRecord extends IAttemptRequest {
|
|
219
|
+
/** The never-reused store-wide attempt identity. */
|
|
220
|
+
readonly attemptId: number;
|
|
221
|
+
/** The current lifecycle state. */
|
|
222
|
+
readonly state: IAttemptState;
|
|
223
|
+
/** The fence of the lease that allocated this attempt. */
|
|
224
|
+
readonly allocatedFence: number;
|
|
225
|
+
/** The fence that completed, failed or interrupted it; null while incomplete. */
|
|
226
|
+
readonly endedFence: number | null;
|
|
227
|
+
/** The exact completed result, present only in the `completed` state. */
|
|
228
|
+
readonly result: ICompletedResultReference | null;
|
|
229
|
+
/** Owner-defined evidence of a failed or interrupted attempt, otherwise null. */
|
|
230
|
+
readonly outcome: IVersionedRecord | null;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Identifies one admitted execution for allocation or recovery. The attempt
|
|
235
|
+
* key is a stable caller-derived identity for exactly one execution, scoped by
|
|
236
|
+
* logical store, analysis, environment and subject; it is not a subject-level
|
|
237
|
+
* cache key. The intent digest is an opaque digest Resolution computes from
|
|
238
|
+
* the complete invocation it intends to run; History compares it only for
|
|
239
|
+
* exact equality, so a reused key with a different intent is a conflict.
|
|
240
|
+
* @alpha
|
|
241
|
+
*/
|
|
242
|
+
export declare interface IAttemptRequest extends IVersionedSubject {
|
|
243
|
+
/** The stable key of one admitted execution. */
|
|
244
|
+
readonly attemptKey: string;
|
|
245
|
+
/** Resolution's opaque digest of that execution's complete intent. */
|
|
246
|
+
readonly intentDigest: string;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Durable attempt lifecycle. `allocated` and `staged` are incomplete;
|
|
251
|
+
* `completed` produced exactly one published result; `failed` and
|
|
252
|
+
* `interrupted` ended without a result. Staged content is attempt evidence,
|
|
253
|
+
* never a completed result.
|
|
254
|
+
* @alpha
|
|
255
|
+
*/
|
|
256
|
+
export declare type IAttemptState = 'allocated' | 'staged' | 'completed' | 'failed' | 'interrupted';
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Reads the host's current wall-clock time. Each reading is one observation in
|
|
260
|
+
* whole UTC milliseconds since the Unix epoch, always a finite safe integer.
|
|
261
|
+
* Readings are not monotonic: the host clock can move backwards or jump
|
|
262
|
+
* forwards between readings, and the capability reports that movement
|
|
263
|
+
* unchanged. Deciding how such movement affects leases or other ownership is
|
|
264
|
+
* the consumer's policy, not the clock's.
|
|
265
|
+
* @alpha
|
|
266
|
+
*/
|
|
267
|
+
export declare interface IClockCapability {
|
|
268
|
+
/** Return the current UTC epoch time in whole milliseconds, or throw if the host cannot provide one. */
|
|
269
|
+
currentEpochMilliseconds(): number;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Framework metadata of one immutable completed result, readable without
|
|
274
|
+
* loading its author payload. Provenance and dependencies are the historical
|
|
275
|
+
* truth recorded at publication; later acceptance never rewrites them (RES-007).
|
|
276
|
+
* @alpha
|
|
277
|
+
*/
|
|
278
|
+
export declare interface ICompletedEnvelope extends IVersionedSubject {
|
|
279
|
+
/** The exact scoped reference of this result. */
|
|
280
|
+
readonly reference: ICompletedResultReference;
|
|
281
|
+
/** The attempt that produced this result; a result has exactly one. */
|
|
282
|
+
readonly attemptId: number;
|
|
283
|
+
/** Store-wide publication order; later publications have larger values. */
|
|
284
|
+
readonly publication: number;
|
|
285
|
+
/** The supported Value snapshot encoding of the stored payload. */
|
|
286
|
+
readonly encoding: 'MDS1';
|
|
287
|
+
/** Resolution's execution provenance, decoded and frozen. */
|
|
288
|
+
readonly provenance: IVersionedRecord;
|
|
289
|
+
/** Exact completed results this execution depended on, in recorded order. */
|
|
290
|
+
readonly dependencies: readonly ICompletedResultReference[];
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Optional capability for readers that can navigate one exact completed
|
|
295
|
+
* snapshot node by node, for lazy nested views. A navigation answer is the
|
|
296
|
+
* scalar value fact or the record/array shape at exactly the requested address;
|
|
297
|
+
* answering it must not read the root payload, a sibling or an unrequested
|
|
298
|
+
* descendant. Presence and key-order facts at nested addresses are answered by
|
|
299
|
+
* the same reader's {@link ICompletedResultReader.readSelected}. Every answer is
|
|
300
|
+
* synchronous: storage that can only load asynchronously cannot implement this
|
|
301
|
+
* capability. Scalar-only readers need not implement it.
|
|
302
|
+
* @alpha
|
|
303
|
+
*/
|
|
304
|
+
export declare interface ICompletedNavigationReader {
|
|
305
|
+
/** Navigate to exactly one node of this reference, never following a current pointer. */
|
|
306
|
+
readNode(reference: ICompletedResultReference, address: readonly IAddressSegment[]): ISelectedNode;
|
|
307
|
+
/**
|
|
308
|
+
* Return the complete supported data of one container subtree, only for an
|
|
309
|
+
* explicit output request. Record key order must be the snapshot's order.
|
|
310
|
+
*/
|
|
311
|
+
readSubtree(reference: ICompletedResultReference, address: readonly IAddressSegment[]): unknown;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Optional capability for readers that can supply an exact keyed projection as
|
|
316
|
+
* selected member values. Scalar readers do not need to implement projections.
|
|
317
|
+
* @alpha
|
|
318
|
+
*/
|
|
319
|
+
export declare interface ICompletedProjectionReader {
|
|
320
|
+
/** Read only the projection's requested address and keyed selected values. */
|
|
321
|
+
readProjection(reference: ICompletedResultReference, descriptor: IValueProjectionDescriptor): IValueProjectionFact;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Synchronous scalar access and fingerprint-only resolution for one exact
|
|
326
|
+
* completed snapshot. A compatible fingerprint answer must be backed by the
|
|
327
|
+
* same semantics as a selected read; resolving metadata never reads payload.
|
|
328
|
+
* @alpha
|
|
329
|
+
*/
|
|
330
|
+
export declare interface ICompletedResultReader {
|
|
331
|
+
/** Read the requested fact from exactly this reference, never from current. */
|
|
332
|
+
readSelected(reference: ICompletedResultReference, request: ISelectedReadRequest): ISelectedFact;
|
|
333
|
+
/** Resolve matching metadata only; unavailable metadata does not trigger a read. */
|
|
334
|
+
resolveFingerprint(reference: ICompletedResultReference, request: ISelectedFingerprintRequest): ISelectedFingerprintResolution;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* A caller-visible locator for one completed immutable snapshot. The opaque
|
|
339
|
+
* locator carries whatever analysis and environment scope its reader requires;
|
|
340
|
+
* it is never a payload or a request to follow a current pointer.
|
|
341
|
+
* @alpha
|
|
342
|
+
*/
|
|
343
|
+
export declare interface ICompletedResultReference {
|
|
344
|
+
/** Dispatches resolution to the completed-result contract. */
|
|
345
|
+
readonly kind: 'completed-result';
|
|
346
|
+
/** Opaque exact snapshot locator interpreted only by its injected reader. */
|
|
347
|
+
readonly locator: string;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Compatibility identity shape stored in scaffold rows. It does not establish
|
|
352
|
+
* target subject identity, binding correspondence, or collection semantics.
|
|
353
|
+
* @public
|
|
354
|
+
*/
|
|
355
|
+
export declare type Identity = {
|
|
356
|
+
kind: 'type';
|
|
357
|
+
type: string;
|
|
358
|
+
key: string;
|
|
359
|
+
} | {
|
|
360
|
+
kind: 'step';
|
|
361
|
+
name: string;
|
|
362
|
+
inputs: readonly Identity[];
|
|
363
|
+
} | {
|
|
364
|
+
kind: 'member';
|
|
365
|
+
of: Identity;
|
|
366
|
+
path: Path;
|
|
367
|
+
} | {
|
|
368
|
+
kind: 'collection';
|
|
369
|
+
step: string;
|
|
370
|
+
source: Identity;
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* History's durable authority over one logical store. Every mutation except
|
|
375
|
+
* acquisition requires the current writer lease and checks holder, fence and
|
|
376
|
+
* unexpired lease inside its own transaction. Exact reads never consult a
|
|
377
|
+
* current pointer, and a missing or wrong-scope reference is an integrity
|
|
378
|
+
* failure, never a miss to be repaired by recomputation.
|
|
379
|
+
*
|
|
380
|
+
* Clock policy: each holder operation evaluates time as the larger of the
|
|
381
|
+
* host reading and a persisted store-wide high-water, then persists that value,
|
|
382
|
+
* including when the operation is rejected. Backward host movement therefore
|
|
383
|
+
* delays expiry and a forward jump can expire a lease early; neither lets an
|
|
384
|
+
* old fence act after a successor acquires, because every successor receives a
|
|
385
|
+
* larger fence. A host reading that is not a nonnegative safe integer fails
|
|
386
|
+
* the operation without any change. This is a local single-file policy, not a
|
|
387
|
+
* distributed-time or liveness guarantee.
|
|
388
|
+
*
|
|
389
|
+
* Storage contention: every mutation, including acquisition, is one IMMEDIATE
|
|
390
|
+
* SQLite transaction. When another connection, possibly in another process,
|
|
391
|
+
* holds SQLite's write lock past the host's bounded busy wait, nothing
|
|
392
|
+
* changes. Acquisition and renewal, the lease operations a waiter repeats,
|
|
393
|
+
* report it as their `contended` outcome ({@link IWriterContention}), so
|
|
394
|
+
* contention is never mistaken for ownership or staleness (PUB-005). Any other
|
|
395
|
+
* operation fails with Machine's `SqliteBusyError`. Whether to try again is
|
|
396
|
+
* always the caller's policy, never History's.
|
|
397
|
+
* @alpha
|
|
398
|
+
*/
|
|
399
|
+
export declare interface IDurableHistory {
|
|
400
|
+
/** The logical store identity this authority holds. */
|
|
401
|
+
readonly logicalStore: string;
|
|
402
|
+
/** Exact selected reads over completed results, answered from their generated index. */
|
|
403
|
+
readonly reader: ICompletedResultReader & ICompletedNavigationReader;
|
|
404
|
+
/**
|
|
405
|
+
* Acquire the single logical writer, or report the observed unexpired
|
|
406
|
+
* holder, or report storage contention with the recorded writer. Any other
|
|
407
|
+
* failure, such as damaged storage or an unusable clock, is thrown.
|
|
408
|
+
*/
|
|
409
|
+
acquireWriter(request: IWriterAcquisitionRequest): IWriterAcquisition;
|
|
410
|
+
/**
|
|
411
|
+
* Extend a still-valid lease, or report storage contention, which leaves the
|
|
412
|
+
* lease as it was. A stale or expired lease is rejected with
|
|
413
|
+
* `StaleWriterError`. Only the expiry changes: the durable fence is left as
|
|
414
|
+
* it is, never rewritten from the presented lease.
|
|
415
|
+
*/
|
|
416
|
+
renewWriter(lease: IWriterLease, leaseMilliseconds: number): IWriterRenewal;
|
|
417
|
+
/** End a still-valid lease; the durable fence is left as it is, so the next grant still advances it. */
|
|
418
|
+
releaseWriter(lease: IWriterLease): void;
|
|
419
|
+
/** Inspect the recorded holder, if any, without granting authority. */
|
|
420
|
+
currentWriter(): IWriterLease | undefined;
|
|
421
|
+
/**
|
|
422
|
+
* Durably allocate one attempt in its own commit before any staging. The
|
|
423
|
+
* same key with the same intent returns the existing attempt in whatever
|
|
424
|
+
* state it reached; the same key with a different intent or version rejects.
|
|
425
|
+
*/
|
|
426
|
+
allocateAttempt(lease: IWriterLease, request: IAttemptRequest): IAttemptRecord;
|
|
427
|
+
/** Persist candidate content for an allocated attempt without publishing it. */
|
|
428
|
+
stageAttempt(lease: IWriterLease, request: IStageRequest): IAttemptRecord;
|
|
429
|
+
/**
|
|
430
|
+
* In one commit, install the staged payload, its generated selected index
|
|
431
|
+
* and fingerprints, provenance, dependencies, the completed attempt state
|
|
432
|
+
* and the scoped current pointer. Publishing an already completed attempt
|
|
433
|
+
* returns its existing reference.
|
|
434
|
+
*/
|
|
435
|
+
publishAttempt(lease: IWriterLease, attemptId: number): ICompletedResultReference;
|
|
436
|
+
/** End an incomplete attempt as failed or interrupted, retaining its evidence. */
|
|
437
|
+
abandonAttempt(lease: IWriterLease, request: IAbandonRequest): IAttemptRecord;
|
|
438
|
+
/** Report what durably happened to one identified execution, read-only. */
|
|
439
|
+
recoverAttempt(request: IAttemptRequest): IRecoveryOutcome;
|
|
440
|
+
/**
|
|
441
|
+
* Completed results admissible for one scoped subject and version, latest
|
|
442
|
+
* publication first: those published in the subject's environment and those
|
|
443
|
+
* a recorded promotion admits into it. A promoted result keeps its own exact
|
|
444
|
+
* reference and envelope scope; nothing from any other environment appears.
|
|
445
|
+
*/
|
|
446
|
+
findCandidates(subject: IVersionedSubject): readonly ICompletedEnvelope[];
|
|
447
|
+
/**
|
|
448
|
+
* The scoped subject's latest publication in its own environment, if any;
|
|
449
|
+
* never rewound by acceptance and never moved by a promotion.
|
|
450
|
+
*/
|
|
451
|
+
readCurrent(subject: IScopedSubject): ICompletedResultReference | undefined;
|
|
452
|
+
/** Read one exact result's metadata without loading its payload. */
|
|
453
|
+
readEnvelope(reference: ICompletedResultReference): ICompletedEnvelope;
|
|
454
|
+
/** Regenerate and compare one exact result's index from its canonical payload. */
|
|
455
|
+
verifyResult(reference: ICompletedResultReference): IResultVerification;
|
|
456
|
+
/** Record a current acceptance of an existing result without touching it or the current pointer. */
|
|
457
|
+
recordAcceptance(lease: IWriterLease, request: IAcceptanceRequest): IAcceptanceRecord;
|
|
458
|
+
/**
|
|
459
|
+
* Acceptance records naming one exact result that were recorded in the
|
|
460
|
+
* named environment, in record order. The environment is always explicit:
|
|
461
|
+
* the publishing environment, or one a promotion admits the result into.
|
|
462
|
+
*/
|
|
463
|
+
readAcceptances(reference: ICompletedResultReference, environment: string): readonly IAcceptanceRecord[];
|
|
464
|
+
/**
|
|
465
|
+
* In one commit, record a promotion that admits exact results of other
|
|
466
|
+
* environments into the target environment. Nothing already recorded changes.
|
|
467
|
+
*/
|
|
468
|
+
promoteResults(lease: IWriterLease, request: IPromotionRequest): IPromotionRecord;
|
|
469
|
+
/** Promotion records into one environment, in record order. */
|
|
470
|
+
readPromotions(query: IPromotionQuery): readonly IPromotionRecord[];
|
|
471
|
+
/**
|
|
472
|
+
* Open Run Supervision's operation journal over this store, bound to the
|
|
473
|
+
* declared record formats and versions. The port shares this authority's
|
|
474
|
+
* connection, writer lease and lifetime.
|
|
475
|
+
*/
|
|
476
|
+
openJournal(declaration: IJournalDeclaration): IOperationJournal;
|
|
477
|
+
/** Release the SQLite file; later calls fail. */
|
|
478
|
+
close(): void;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Host capabilities and identity for opening a durable History store. Node
|
|
483
|
+
* access stays behind the injected SQLite and clock capabilities. The logical
|
|
484
|
+
* store identity is independent of the file location: a moved file keeps its
|
|
485
|
+
* identity, and a file holding another logical store is rejected.
|
|
486
|
+
* @alpha
|
|
487
|
+
*/
|
|
488
|
+
export declare interface IDurableHistoryOptions {
|
|
489
|
+
/** Opens the persistent SQLite file; History owns every statement and schema. */
|
|
490
|
+
readonly sqlite: ISqliteCapability;
|
|
491
|
+
/** Supplies wall-clock observations for History's lease policy. */
|
|
492
|
+
readonly clock: IClockCapability;
|
|
493
|
+
/** Computes content fingerprints for the selected index. */
|
|
494
|
+
readonly sha256: ISha256Capability;
|
|
495
|
+
/** The host location of the SQLite file, passed only to `sqlite`. */
|
|
496
|
+
readonly location: string;
|
|
497
|
+
/** The logical store identity this file must hold, or is created to hold. */
|
|
498
|
+
readonly logicalStore: string;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* The analysis and environment that scope every subject, attempt and result
|
|
503
|
+
* within one logical store. The same subject text in another analysis or
|
|
504
|
+
* environment is a different scoped subject (RES-001/002). Both are complete
|
|
505
|
+
* opaque non-empty strings compared by exact equality. An environment is a
|
|
506
|
+
* namespace within one store (RUN-017): a trial and a production run of the
|
|
507
|
+
* same analysis use different environments of the same file, selected per
|
|
508
|
+
* call rather than process-wide.
|
|
509
|
+
* @alpha
|
|
510
|
+
*/
|
|
511
|
+
export declare interface IHistoryScope {
|
|
512
|
+
/** The analysis whose history this is. */
|
|
513
|
+
readonly analysis: string;
|
|
514
|
+
/** The logical environment within that analysis. */
|
|
515
|
+
readonly environment: string;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Locates one journal record: its environment namespace, owner-named
|
|
520
|
+
* collection and owner-defined key. The record's identity is exactly this
|
|
521
|
+
* address; its format tag may change between revisions only by
|
|
522
|
+
* compare-and-set.
|
|
523
|
+
* @alpha
|
|
524
|
+
*/
|
|
525
|
+
export declare interface IJournalAddress extends IHistoryScope {
|
|
526
|
+
/** The owner-named non-empty collection, such as Supervision's operations. */
|
|
527
|
+
readonly collection: string;
|
|
528
|
+
/** The owner-defined non-empty key, unique within the namespace and collection. */
|
|
529
|
+
readonly key: string;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* One atomic journal commit in one environment namespace: every write lands
|
|
534
|
+
* in the same transaction, or none does.
|
|
535
|
+
* @alpha
|
|
536
|
+
*/
|
|
537
|
+
export declare interface IJournalCommit extends IHistoryScope {
|
|
538
|
+
/** At least one write, each collection and key pair at most once. */
|
|
539
|
+
readonly writes: readonly IJournalWrite[];
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* The formats a journal port is bound to. A stored record of an undeclared
|
|
544
|
+
* format or version is refused rather than returned or overwritten, so a
|
|
545
|
+
* caller never acts on, or clobbers, a record it does not understand.
|
|
546
|
+
* @alpha
|
|
547
|
+
*/
|
|
548
|
+
export declare interface IJournalDeclaration {
|
|
549
|
+
/** At least one declared format, each format named once. */
|
|
550
|
+
readonly formats: readonly IJournalFormat[];
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* One owner-defined journal record format and the exact format versions a
|
|
555
|
+
* journal port can read and write. A format is only a record's version tag:
|
|
556
|
+
* it never identifies a record or its collection. History compares the tag
|
|
557
|
+
* and versions for exact equality and never interprets the content.
|
|
558
|
+
* @alpha
|
|
559
|
+
*/
|
|
560
|
+
export declare interface IJournalFormat {
|
|
561
|
+
/** The owner-defined non-empty format identity. */
|
|
562
|
+
readonly format: string;
|
|
563
|
+
/** The positive safe-integer versions of that format this port understands. */
|
|
564
|
+
readonly versions: readonly number[];
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* Selects every record of one collection in one environment namespace.
|
|
569
|
+
* @alpha
|
|
570
|
+
*/
|
|
571
|
+
export declare interface IJournalQuery extends IHistoryScope {
|
|
572
|
+
/** The owner-named collection to list. */
|
|
573
|
+
readonly collection: string;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* One immutable revision of a journal record. Revisions of an address start
|
|
578
|
+
* at 1 and increase by one per committed write; earlier revisions are retained
|
|
579
|
+
* and never rewritten.
|
|
580
|
+
* @alpha
|
|
581
|
+
*/
|
|
582
|
+
export declare interface IJournalRecord extends IHistoryScope {
|
|
583
|
+
/** The owner-named collection. */
|
|
584
|
+
readonly collection: string;
|
|
585
|
+
/** The owner-defined key. */
|
|
586
|
+
readonly key: string;
|
|
587
|
+
/** This revision's number within its address, starting at 1. */
|
|
588
|
+
readonly revision: number;
|
|
589
|
+
/** Store-wide never-reused journal write identity, increasing in commit order. */
|
|
590
|
+
readonly sequence: number;
|
|
591
|
+
/** The writer fence under which this revision was committed. */
|
|
592
|
+
readonly fence: number;
|
|
593
|
+
/** The owner-defined record, decoded and frozen, with this revision's version tag. */
|
|
594
|
+
readonly record: IVersionedRecord;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* One compare-and-set write of a journal commit. The expected revision is the
|
|
599
|
+
* revision the caller last read at this address; `0` asserts that the key has
|
|
600
|
+
* never been written in the collection, under any format. The record's
|
|
601
|
+
* format and version are its version tag and must be declared by the port.
|
|
602
|
+
* @alpha
|
|
603
|
+
*/
|
|
604
|
+
export declare interface IJournalWrite {
|
|
605
|
+
/** The owner-named non-empty collection. */
|
|
606
|
+
readonly collection: string;
|
|
607
|
+
/** The owner-defined non-empty key. */
|
|
608
|
+
readonly key: string;
|
|
609
|
+
/** The current revision the write replaces, or `0` for a new key. */
|
|
610
|
+
readonly expectedRevision: number;
|
|
611
|
+
/** The new owner-defined record. */
|
|
612
|
+
readonly record: IVersionedRecord;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
/** A patch attempted to modify an immutable address or managed CAS version. @public */
|
|
616
|
+
export declare class InvalidStorePatchError extends Error {
|
|
617
|
+
/** Identify a structurally forbidden patch before any columns are changed. @public */
|
|
618
|
+
constructor(message?: string);
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* A supported observation operation with its own fact meaning. `container-kind`
|
|
623
|
+
* answers record, array or scalar without consuming any container member or
|
|
624
|
+
* scalar content; ordinary scalar reads still retain their literal values.
|
|
625
|
+
* @alpha
|
|
626
|
+
*/
|
|
627
|
+
export declare type IOperation = 'value' | 'own' | 'membership' | 'length' | 'keys' | 'container-kind';
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* Run Supervision's operation journal, stored by History (RUN-011/012). It
|
|
631
|
+
* keeps owner-defined operation and deferral records, such as an intent
|
|
632
|
+
* committed before a send or a "not before" deferral, atomically and under
|
|
633
|
+
* writer fencing, without interpreting them: History owns only namespacing,
|
|
634
|
+
* collections, revisions, fencing and the declared-version check. A commit
|
|
635
|
+
* needs the current writer lease and checks holder, fence and unexpired lease
|
|
636
|
+
* in the same transaction as its compare-and-set checks and writes; reads
|
|
637
|
+
* need no lease and never see an uncommitted write.
|
|
638
|
+
* @alpha
|
|
639
|
+
*/
|
|
640
|
+
export declare interface IOperationJournal {
|
|
641
|
+
/** The frozen formats and versions this port was opened with. */
|
|
642
|
+
readonly formats: readonly IJournalFormat[];
|
|
643
|
+
/**
|
|
644
|
+
* Commit every write in one transaction. The whole commit is refused,
|
|
645
|
+
* unchanged, for a stale lease, an undeclared format or version, a current
|
|
646
|
+
* revision whose stored format or version this port does not understand
|
|
647
|
+
* (checked first, since such a caller cannot have read it), or an expected
|
|
648
|
+
* revision that is not the address's current revision.
|
|
649
|
+
*/
|
|
650
|
+
commit(lease: IWriterLease, request: IJournalCommit): readonly IJournalRecord[];
|
|
651
|
+
/** The current revision at one address, or undefined if the key was never written there. */
|
|
652
|
+
read(address: IJournalAddress): IJournalRecord | undefined;
|
|
653
|
+
/** The current revision of every key in one collection, in order of first write. */
|
|
654
|
+
list(query: IJournalQuery): readonly IJournalRecord[];
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* Selects promotion records into one target environment, optionally only
|
|
659
|
+
* those naming one exact result.
|
|
660
|
+
* @alpha
|
|
661
|
+
*/
|
|
662
|
+
export declare interface IPromotionQuery {
|
|
663
|
+
/** The analysis and environment whose admitting promotions to read. */
|
|
664
|
+
readonly target: IHistoryScope;
|
|
665
|
+
/** When present, only promotions that name this exact result. */
|
|
666
|
+
readonly reference?: ICompletedResultReference;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* One immutable promotion record. It admits the named results as candidates,
|
|
671
|
+
* dependencies and acceptance targets in its target environment and changes
|
|
672
|
+
* nothing else: each result keeps its exact reference, envelope, provenance
|
|
673
|
+
* and acceptances, and no current head moves in any environment. The target
|
|
674
|
+
* environment's later verifications record their own acceptances.
|
|
675
|
+
* @alpha
|
|
676
|
+
*/
|
|
677
|
+
export declare interface IPromotionRecord {
|
|
678
|
+
/** Store-wide never-reused promotion identity, increasing in record order. */
|
|
679
|
+
readonly promotionId: number;
|
|
680
|
+
/** The analysis and environment the results were admitted into. */
|
|
681
|
+
readonly target: IHistoryScope;
|
|
682
|
+
/** The writer fence under which the promotion was recorded. */
|
|
683
|
+
readonly fence: number;
|
|
684
|
+
/** The promoter's evidence, decoded and frozen. */
|
|
685
|
+
readonly evidence: IVersionedRecord;
|
|
686
|
+
/** The admitted exact results, each in its own publishing scope, in recorded order. */
|
|
687
|
+
readonly references: readonly ICompletedResultReference[];
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* Asks History to admit exact completed results of other environments into
|
|
692
|
+
* one target environment of the same analysis (RUN-017). A trial result
|
|
693
|
+
* satisfies a production lookup only through such a recorded promotion. The
|
|
694
|
+
* target names where the results are admitted; each reference keeps naming
|
|
695
|
+
* its own publishing environment. The evidence is the promoter's versioned
|
|
696
|
+
* record of who promoted what and why; History stores it opaquely.
|
|
697
|
+
* @alpha
|
|
698
|
+
*/
|
|
699
|
+
export declare interface IPromotionRequest {
|
|
700
|
+
/** The analysis and environment the results are admitted into. */
|
|
701
|
+
readonly target: IHistoryScope;
|
|
702
|
+
/**
|
|
703
|
+
* Distinct exact completed results of the target's analysis, none published
|
|
704
|
+
* in the target environment, in the promoter's order.
|
|
705
|
+
*/
|
|
706
|
+
readonly references: readonly ICompletedResultReference[];
|
|
707
|
+
/** The promoter's versioned evidence for this promotion. */
|
|
708
|
+
readonly evidence: IVersionedRecord;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* Read-only recovery of one identified execution. Recovery reports what
|
|
713
|
+
* durably happened and never executes, publishes or records acceptance:
|
|
714
|
+
* `absent` means the key was never allocated in this scope, `incomplete` an
|
|
715
|
+
* allocated or staged attempt, `unsuccessful` a failed or interrupted one and
|
|
716
|
+
* `completed` the exact result that execution published.
|
|
717
|
+
* @alpha
|
|
718
|
+
*/
|
|
719
|
+
export declare type IRecoveryOutcome = {
|
|
720
|
+
readonly kind: 'absent';
|
|
721
|
+
} | {
|
|
722
|
+
readonly kind: 'incomplete';
|
|
723
|
+
readonly attempt: IAttemptRecord;
|
|
724
|
+
} | {
|
|
725
|
+
readonly kind: 'unsuccessful';
|
|
726
|
+
readonly attempt: IAttemptRecord;
|
|
727
|
+
} | {
|
|
728
|
+
readonly kind: 'completed';
|
|
729
|
+
readonly attempt: IAttemptRecord;
|
|
730
|
+
/** The exact result that this identified execution published. */
|
|
731
|
+
readonly reference: ICompletedResultReference;
|
|
732
|
+
};
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Result of regenerating a completed result's selected index from its stored
|
|
736
|
+
* canonical payload and comparing it with the stored index.
|
|
737
|
+
* @alpha
|
|
738
|
+
*/
|
|
739
|
+
export declare type IResultVerification = {
|
|
740
|
+
readonly kind: 'consistent';
|
|
741
|
+
} | {
|
|
742
|
+
readonly kind: 'inconsistent';
|
|
743
|
+
readonly detail: string;
|
|
744
|
+
};
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* One scoped subject: the author's complete opaque subject string inside its
|
|
748
|
+
* analysis/environment scope. History never derives, prefixes or reinterprets
|
|
749
|
+
* the subject; it identifies a history of work, not one exact result.
|
|
750
|
+
* @alpha
|
|
751
|
+
*/
|
|
752
|
+
export declare interface IScopedSubject extends IHistoryScope {
|
|
753
|
+
/** The author's complete subject string, compared by exact string equality. */
|
|
754
|
+
readonly subject: string;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* One immediate lookup result for a caller-supplied root, address, and
|
|
759
|
+
* operation. The fact may be the selected object reference itself, so it is
|
|
760
|
+
* neither a detached snapshot nor retained Tracking evidence. Tracking adds
|
|
761
|
+
* binding and capture relationships and decides what data to encode as evidence.
|
|
762
|
+
* @alpha
|
|
763
|
+
*/
|
|
764
|
+
export declare interface ISelectedFact {
|
|
765
|
+
/** The literal access whose result was selected. */
|
|
766
|
+
readonly operation: IOperation;
|
|
767
|
+
/** Ordered container-aware steps from the supplied root to the selected location. */
|
|
768
|
+
readonly address: readonly IAddressSegment[];
|
|
769
|
+
/** The selected value or structural fact; an object value remains the source reference. */
|
|
770
|
+
readonly fact: unknown;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* Metadata lookup is scoped to the exact result reference and full requested
|
|
775
|
+
* selection. The encoding tag prevents an indexed digest from another semantic
|
|
776
|
+
* version being mistaken for this selection.
|
|
777
|
+
* @alpha
|
|
778
|
+
*/
|
|
779
|
+
export declare type ISelectedFingerprintRequest = {
|
|
780
|
+
readonly kind: 'selected';
|
|
781
|
+
readonly operation: IOperation;
|
|
782
|
+
readonly address: readonly IAddressSegment[];
|
|
783
|
+
readonly encoding: 'MDO1';
|
|
784
|
+
} | {
|
|
785
|
+
readonly kind: 'projection';
|
|
786
|
+
readonly descriptor: IValueProjectionDescriptor;
|
|
787
|
+
readonly encoding: 'MDP1';
|
|
788
|
+
} | {
|
|
789
|
+
readonly kind: 'materialized-output';
|
|
790
|
+
readonly address: readonly IAddressSegment[];
|
|
791
|
+
readonly encoding: 'MDS1';
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
/** Explicit results keep absent or incompatible metadata from implying equality. @alpha */
|
|
795
|
+
export declare type ISelectedFingerprintResolution = {
|
|
796
|
+
readonly kind: 'compatible';
|
|
797
|
+
readonly fingerprint: string;
|
|
798
|
+
} | {
|
|
799
|
+
readonly kind: 'unavailable';
|
|
800
|
+
} | {
|
|
801
|
+
readonly kind: 'incompatible';
|
|
802
|
+
} | {
|
|
803
|
+
readonly kind: 'ambiguous';
|
|
804
|
+
};
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* The kind of node that one exact structured address selects. A scalar leaf is
|
|
808
|
+
* its ordinary `value` selected fact. A record or array is described only by
|
|
809
|
+
* its container shape: navigating through a container is transport metadata for
|
|
810
|
+
* a lazy view, never a whole-object observation, so no member, identity or
|
|
811
|
+
* serialized subtree is implied. Array length is carried so a view need not ask
|
|
812
|
+
* again, but it becomes observation evidence only when a consumer reads it.
|
|
813
|
+
* Shape envelopes are never placed inside {@link ISelectedFact.fact}; Tracking
|
|
814
|
+
* may separately observe the bounded `container-kind` discriminant.
|
|
815
|
+
* @alpha
|
|
816
|
+
*/
|
|
817
|
+
export declare type ISelectedNode =
|
|
818
|
+
/** A supported scalar (undefined, null, boolean, number or string) read at the address. */
|
|
819
|
+
{
|
|
820
|
+
readonly kind: 'scalar';
|
|
821
|
+
readonly selected: ISelectedFact;
|
|
822
|
+
}
|
|
823
|
+
/** A string-keyed plain-data record, possibly with a supported custom prototype chain. */
|
|
824
|
+
| {
|
|
825
|
+
readonly kind: 'record';
|
|
826
|
+
readonly address: readonly IAddressSegment[];
|
|
827
|
+
}
|
|
828
|
+
/** A standard array; `length` counts slots including holes. */
|
|
829
|
+
| {
|
|
830
|
+
readonly kind: 'array';
|
|
831
|
+
readonly address: readonly IAddressSegment[];
|
|
832
|
+
readonly length: number;
|
|
833
|
+
};
|
|
834
|
+
|
|
835
|
+
/** A selected Value-owned scalar fact requested at an exact retained address. @alpha */
|
|
836
|
+
export declare interface ISelectedReadRequest {
|
|
837
|
+
/** The literal operation whose fact is requested. */
|
|
838
|
+
readonly operation: IOperation;
|
|
839
|
+
/** Container-aware path within this selected result value. */
|
|
840
|
+
readonly address: readonly IAddressSegment[];
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* Computes SHA-256 over the UTF-8 bytes of supplied canonical evidence.
|
|
845
|
+
* Machine supplies hashing only; callers define the meaning and framing of
|
|
846
|
+
* the input before it crosses this host boundary.
|
|
847
|
+
* @alpha
|
|
848
|
+
*/
|
|
849
|
+
export declare interface ISha256Capability {
|
|
850
|
+
/** Return the lowercase hexadecimal SHA-256 digest of the input text. */
|
|
851
|
+
sha256(input: string): string;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* Produces a synchronous detached copy of primitives, arrays, ordinary objects'
|
|
856
|
+
* enumerable string-keyed properties, Date, RegExp, Map, Set, ArrayBuffer, and
|
|
857
|
+
* typed-array/DataView contents. It preserves cycles and repeated references
|
|
858
|
+
* within one copy and isolates both input and returned snapshots. Functions,
|
|
859
|
+
* symbols, and raw SharedArrayBuffer values fail. Getters may run; nonenumerable
|
|
860
|
+
* and symbol-keyed properties and arbitrary class prototypes are not preserved.
|
|
861
|
+
* This contract defines neither durable encoding nor canonical identity. It is
|
|
862
|
+
* public because History's direct memory-store constructor requires injection.
|
|
863
|
+
* @public
|
|
864
|
+
*/
|
|
865
|
+
declare interface ISnapshotCapability {
|
|
866
|
+
/** Return a detached copy or throw before a caller mutates owned state. */
|
|
867
|
+
snapshot<T>(value: T): T;
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* Opens persistent local SQLite databases for a consumer that owns its own
|
|
872
|
+
* SQL and schema, such as History's durable authority. Opening fails for a
|
|
873
|
+
* directory, a missing parent directory, a file that is not a SQLite database,
|
|
874
|
+
* or a location that cannot hold a persistent write-ahead-logged database,
|
|
875
|
+
* including `:memory:` and the empty path. Opening never silently weakens the
|
|
876
|
+
* host's durable configuration. Processes that open one new store at the same
|
|
877
|
+
* time all succeed within the bounded busy wait or fail with `SqliteBusyError`.
|
|
878
|
+
* @alpha
|
|
879
|
+
*/
|
|
880
|
+
export declare interface ISqliteCapability {
|
|
881
|
+
/** Open or create the database file at `location` and return its owned connection. */
|
|
882
|
+
openSqlite(location: string): ISqliteConnection;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* An open connection to one persistent local SQLite database file. The caller
|
|
887
|
+
* that opened it owns it and must close it. The host selects durable
|
|
888
|
+
* configuration for every connection: write-ahead logging, FULL synchronous
|
|
889
|
+
* commits, enforced foreign keys and a bounded wait on a locked database.
|
|
890
|
+
* Callers supply every SQL statement and schema; the connection has no
|
|
891
|
+
* knowledge of what the tables mean. A statement, exec or transaction that
|
|
892
|
+
* cannot get a lock within the bounded wait fails with `SqliteBusyError`.
|
|
893
|
+
*
|
|
894
|
+
* Transactions are synchronous, top-level and IMMEDIATE: the write lock is
|
|
895
|
+
* taken before the callback runs, the callback's writes commit together when
|
|
896
|
+
* it returns, and all of them roll back when it throws. Nesting is refused
|
|
897
|
+
* rather than given savepoint semantics. Calls through the connection or its
|
|
898
|
+
* statements made by asynchronous work that a callback left behind fail after
|
|
899
|
+
* the transaction ends. This protects only this connection's storage: it does
|
|
900
|
+
* not prevent other effects of that leftover JavaScript.
|
|
901
|
+
* @alpha
|
|
902
|
+
*/
|
|
903
|
+
export declare interface ISqliteConnection {
|
|
904
|
+
/** Execute SQL text that takes no bound values, such as schema statements. */
|
|
905
|
+
exec(sql: string): void;
|
|
906
|
+
/** Prepare one statement for repeated execution with bound values. */
|
|
907
|
+
prepare(sql: string): ISqliteStatement;
|
|
908
|
+
/**
|
|
909
|
+
* Run `operation` inside one IMMEDIATE transaction and return its result.
|
|
910
|
+
* A value thrown by `operation` rolls back every write and is rethrown
|
|
911
|
+
* unchanged. A Promise or thenable result, or a returned object or function
|
|
912
|
+
* whose `then` cannot be inspected, rolls back and fails with `TypeError`;
|
|
913
|
+
* an error raised while inspecting that `then` is not rethrown. A call made
|
|
914
|
+
* while this connection's transaction callback is running fails without
|
|
915
|
+
* invoking `operation`.
|
|
916
|
+
*/
|
|
917
|
+
transaction<T>(operation: () => T & ISqliteSynchronousResult<T>): T;
|
|
918
|
+
/**
|
|
919
|
+
* Release the database file. Closing again has no effect; any later use of
|
|
920
|
+
* the connection or its statements fails. Closing from inside a transaction
|
|
921
|
+
* callback fails, which rolls that transaction back if the failure propagates,
|
|
922
|
+
* and work that outlived a transaction callback cannot close the connection.
|
|
923
|
+
*/
|
|
924
|
+
close(): void;
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* One result row keyed by result column name. Rows are transport data owned by
|
|
929
|
+
* the caller; they carry no driver type, prototype behavior or live link to
|
|
930
|
+
* stored content.
|
|
931
|
+
* @alpha
|
|
932
|
+
*/
|
|
933
|
+
export declare interface ISqliteRow {
|
|
934
|
+
/** The value SQLite returned for the named result column. */
|
|
935
|
+
readonly [column: string]: ISqliteValue;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
/**
|
|
939
|
+
* The only mutation fact a statement run reports. Row identifiers and other
|
|
940
|
+
* driver details stay inside the host.
|
|
941
|
+
* @alpha
|
|
942
|
+
*/
|
|
943
|
+
export declare interface ISqliteRunResult {
|
|
944
|
+
/** Rows inserted, updated or deleted directly by the statement. */
|
|
945
|
+
readonly changes: number;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
/**
|
|
949
|
+
* One prepared SQL statement bound to the connection that prepared it. Values
|
|
950
|
+
* are always bound positionally and never interpolated into SQL text. Every
|
|
951
|
+
* call fails once the owning connection is closed, and fails when it is made by
|
|
952
|
+
* work inherited from an already ended transaction callback.
|
|
953
|
+
* @alpha
|
|
954
|
+
*/
|
|
955
|
+
export declare interface ISqliteStatement {
|
|
956
|
+
/** Execute the statement for its effect and report how many rows changed. */
|
|
957
|
+
run(...values: readonly ISqliteValue[]): ISqliteRunResult;
|
|
958
|
+
/** Return the first result row, or `undefined` when the statement yields none. */
|
|
959
|
+
get(...values: readonly ISqliteValue[]): ISqliteRow | undefined;
|
|
960
|
+
/** Return every result row in the order SQLite produced them. */
|
|
961
|
+
all(...values: readonly ISqliteValue[]): readonly ISqliteRow[];
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
/**
|
|
965
|
+
* Makes a transaction callback's return type unusable when it is, or may be, a
|
|
966
|
+
* Promise or other thenable. A transaction commits when its callback returns;
|
|
967
|
+
* an asynchronous callback would return before its awaited work, so such
|
|
968
|
+
* results are rejected at compile time and, independently, at runtime.
|
|
969
|
+
*
|
|
970
|
+
* Any union constituent with a callable `then` rejects the whole result, so
|
|
971
|
+
* `number | Promise<number>` is refused like `Promise<number>`. Results the
|
|
972
|
+
* compiler cannot classify, `any` and `unknown`, are left to the runtime check
|
|
973
|
+
* rather than rejecting ordinary untyped data.
|
|
974
|
+
* @alpha
|
|
975
|
+
*/
|
|
976
|
+
export declare type ISqliteSynchronousResult<T> = 0 extends 1 & T ? unknown : [Extract<T, {
|
|
977
|
+
readonly then: (...parameters: never[]) => unknown;
|
|
978
|
+
}>] extends [never] ? unknown : never;
|
|
979
|
+
|
|
980
|
+
/**
|
|
981
|
+
* One value that crosses the SQLite host boundary, either as a bound parameter
|
|
982
|
+
* or as a returned cell: text, a finite number, SQL NULL, or a BLOB copied into
|
|
983
|
+
* a plain `Uint8Array`. A returned INTEGER is exact because values outside the
|
|
984
|
+
* safe-integer range fail instead of being rounded. Booleans, bigints,
|
|
985
|
+
* `undefined`, non-finite numbers and objects are outside the domain and are
|
|
986
|
+
* refused at runtime even when a caller bypasses these types.
|
|
987
|
+
* @alpha
|
|
988
|
+
*/
|
|
989
|
+
export declare type ISqliteValue = string | number | null | Uint8Array;
|
|
990
|
+
|
|
991
|
+
/**
|
|
992
|
+
* Candidate content for an allocated attempt. The payload must be supported
|
|
993
|
+
* Value data with a record or array root; the provenance is Resolution's
|
|
994
|
+
* versioned record; dependencies are exact references to completed results in
|
|
995
|
+
* the same store and scope that this execution consumed.
|
|
996
|
+
* @alpha
|
|
997
|
+
*/
|
|
998
|
+
export declare interface IStageRequest {
|
|
999
|
+
/** The allocated attempt to stage. */
|
|
1000
|
+
readonly attemptId: number;
|
|
1001
|
+
/** The author result data, copied into canonical MDS1 form. */
|
|
1002
|
+
readonly payload: unknown;
|
|
1003
|
+
/** Resolution's execution provenance for this attempt. */
|
|
1004
|
+
readonly provenance: IVersionedRecord;
|
|
1005
|
+
/** Exact completed results this execution depends on, in the caller's order. */
|
|
1006
|
+
readonly dependencies: readonly ICompletedResultReference[];
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
/**
|
|
1010
|
+
* The Value-owned meaning of a selected keyed projection, independent of its
|
|
1011
|
+
* composition binding or collection policy.
|
|
1012
|
+
* @alpha
|
|
1013
|
+
*/
|
|
1014
|
+
export declare interface IValueProjectionDescriptor {
|
|
1015
|
+
/** Relative path from each member to the selected value. */
|
|
1016
|
+
readonly address: readonly IAddressSegment[];
|
|
1017
|
+
/** Projection content selects member values, never member identity or presence. */
|
|
1018
|
+
readonly operation: 'value';
|
|
1019
|
+
/** States whether all members were promised or only an exact visited subset was read. */
|
|
1020
|
+
readonly traversal: IValueProjectionTraversal;
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
/**
|
|
1024
|
+
* A content fact whose caller-owned binding remains outside Value's encoding.
|
|
1025
|
+
* @alpha
|
|
1026
|
+
*/
|
|
1027
|
+
export declare interface IValueProjectionFact {
|
|
1028
|
+
/** Selection and coverage whose meaning governs every supplied member value. */
|
|
1029
|
+
readonly descriptor: IValueProjectionDescriptor;
|
|
1030
|
+
/** Unique collection-scoped keys paired with their selected content; key order is not ordered consumption evidence. */
|
|
1031
|
+
readonly members: readonly IValueProjectionMember[];
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
/**
|
|
1035
|
+
* One unique stable member key and the selected supported value for that member.
|
|
1036
|
+
* @alpha
|
|
1037
|
+
*/
|
|
1038
|
+
export declare type IValueProjectionMember = readonly [key: string, value: unknown];
|
|
1039
|
+
|
|
1040
|
+
/**
|
|
1041
|
+
* Coverage semantics for one keyed projection. Exhaustive coverage is a source
|
|
1042
|
+
* promise; a visited traversal retains the exact ordered set of observed keys.
|
|
1043
|
+
* @alpha
|
|
1044
|
+
*/
|
|
1045
|
+
export declare type IValueProjectionTraversal = {
|
|
1046
|
+
readonly kind: 'exhaustive';
|
|
1047
|
+
readonly complete: true;
|
|
1048
|
+
} | {
|
|
1049
|
+
readonly kind: 'visited';
|
|
1050
|
+
readonly complete: false;
|
|
1051
|
+
readonly keys: readonly string[];
|
|
1052
|
+
};
|
|
1053
|
+
|
|
1054
|
+
/**
|
|
1055
|
+
* A versioned record whose meaning another owner defines, such as
|
|
1056
|
+
* Resolution's execution provenance, current acceptance evidence or an
|
|
1057
|
+
* attempt's failure evidence. History validates only that the format tag is a
|
|
1058
|
+
* non-empty string, the format version is a positive safe integer and the
|
|
1059
|
+
* content is supported Value data; it stores the content in canonical MDS1
|
|
1060
|
+
* form and returns it decoded and frozen, never interpreting it.
|
|
1061
|
+
* @alpha
|
|
1062
|
+
*/
|
|
1063
|
+
export declare interface IVersionedRecord {
|
|
1064
|
+
/** The owner-defined format identity, for example a Resolution schema name. */
|
|
1065
|
+
readonly format: string;
|
|
1066
|
+
/** The owner-defined positive safe-integer version of that format. */
|
|
1067
|
+
readonly formatVersion: number;
|
|
1068
|
+
/** Supported Value data; its meaning belongs to the format's owner. */
|
|
1069
|
+
readonly content: unknown;
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
/**
|
|
1073
|
+
* A scoped subject narrowed to one compatibility group (REUSE-008): a positive
|
|
1074
|
+
* safe integer chosen by the author per memoized step. Candidate lookup filters
|
|
1075
|
+
* by it before Resolution validates current evidence.
|
|
1076
|
+
* @alpha
|
|
1077
|
+
*/
|
|
1078
|
+
export declare interface IVersionedSubject extends IScopedSubject {
|
|
1079
|
+
/** The positive safe-integer compatibility group. */
|
|
1080
|
+
readonly version: number;
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
/**
|
|
1084
|
+
* The outcome of asking for the single logical writer. `held` reports an
|
|
1085
|
+
* observed unexpired holder, not a failed compare-and-swap (PUB-005), and
|
|
1086
|
+
* grants nothing; `contended` reports that storage was too busy to decide.
|
|
1087
|
+
* @alpha
|
|
1088
|
+
*/
|
|
1089
|
+
export declare type IWriterAcquisition = {
|
|
1090
|
+
/** The caller now owns the store's writer lease. */
|
|
1091
|
+
readonly kind: 'acquired';
|
|
1092
|
+
/** The new lease with its freshly issued fence. */
|
|
1093
|
+
readonly lease: IWriterLease;
|
|
1094
|
+
} | {
|
|
1095
|
+
/** Another unexpired holder owns the store. */
|
|
1096
|
+
readonly kind: 'held';
|
|
1097
|
+
/** The observed holder identity. */
|
|
1098
|
+
readonly holder: string;
|
|
1099
|
+
/** When that holder's lease expires, in History's clock domain. */
|
|
1100
|
+
readonly expiresAt: number;
|
|
1101
|
+
} | IWriterContention;
|
|
1102
|
+
|
|
1103
|
+
/** A request for the writer lease. @alpha */
|
|
1104
|
+
export declare interface IWriterAcquisitionRequest {
|
|
1105
|
+
/** The opaque non-empty identity of the prospective holder. */
|
|
1106
|
+
readonly holder: string;
|
|
1107
|
+
/** Positive safe-integer lease duration in milliseconds. */
|
|
1108
|
+
readonly leaseMilliseconds: number;
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
/**
|
|
1112
|
+
* Storage contention on a lease operation: another connection, possibly in
|
|
1113
|
+
* another process, held SQLite's write lock past the host's bounded busy wait,
|
|
1114
|
+
* so History could not decide and changed nothing, not even the clock
|
|
1115
|
+
* high-water. It is a fact about storage, never about ownership (PUB-005): it
|
|
1116
|
+
* neither grants nor refuses, and whether to try again is the caller's policy.
|
|
1117
|
+
* @alpha
|
|
1118
|
+
*/
|
|
1119
|
+
export declare interface IWriterContention {
|
|
1120
|
+
/** History could not take SQLite's write lock in time. */
|
|
1121
|
+
readonly kind: 'contended';
|
|
1122
|
+
/**
|
|
1123
|
+
* The writer recorded at that moment, read without the write lock: its
|
|
1124
|
+
* holder, fence and expiry as stored, whether or not the lease has expired.
|
|
1125
|
+
* Undefined when no holder is recorded, or when that read was itself busy;
|
|
1126
|
+
* History never guesses a holder.
|
|
1127
|
+
*/
|
|
1128
|
+
readonly writer: IWriterLease | undefined;
|
|
1129
|
+
/** The host's diagnostic of the contention; it carries no stored values. */
|
|
1130
|
+
readonly detail: string;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
/**
|
|
1134
|
+
* Proof of current single-logical-writer ownership. The holder is an opaque
|
|
1135
|
+
* caller identity; the fence is the store-wide token issued at acquisition,
|
|
1136
|
+
* which only increases; `expiresAt` is the lease boundary in History's
|
|
1137
|
+
* clock domain (epoch milliseconds). Presenting a lease authorizes storage
|
|
1138
|
+
* mutation only while holder, fence and unexpired lease still match the durable
|
|
1139
|
+
* writer state; it never authorizes author execution.
|
|
1140
|
+
* @alpha
|
|
1141
|
+
*/
|
|
1142
|
+
export declare interface IWriterLease {
|
|
1143
|
+
/** The opaque identity that acquired the lease. */
|
|
1144
|
+
readonly holder: string;
|
|
1145
|
+
/** The fencing token issued for this acquisition. */
|
|
1146
|
+
readonly fence: number;
|
|
1147
|
+
/** The first effective time at which the lease is no longer valid. */
|
|
1148
|
+
readonly expiresAt: number;
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
/**
|
|
1152
|
+
* The outcome of renewing a lease the caller holds: `renewed` with the later
|
|
1153
|
+
* expiry, or `contended` when storage was too busy to decide, in which case
|
|
1154
|
+
* the lease is exactly as it was and is neither renewed nor refused. A stale
|
|
1155
|
+
* or expired lease is not an outcome but a refusal (`StaleWriterError`).
|
|
1156
|
+
* @alpha
|
|
1157
|
+
*/
|
|
1158
|
+
export declare type IWriterRenewal = {
|
|
1159
|
+
/** The lease was extended. */
|
|
1160
|
+
readonly kind: 'renewed';
|
|
1161
|
+
/** The same holder and fence with the new expiry. */
|
|
1162
|
+
readonly lease: IWriterLease;
|
|
1163
|
+
} | IWriterContention;
|
|
1164
|
+
|
|
1165
|
+
/**
|
|
1166
|
+
* A journal commit's compare-and-set expectation does not hold: the presented
|
|
1167
|
+
* expected revision is not the key's current revision (a new-key expectation
|
|
1168
|
+
* met an existing key, or an update met a later or absent revision). The
|
|
1169
|
+
* whole commit was rolled back unchanged; the caller must re-read before
|
|
1170
|
+
* deciding again.
|
|
1171
|
+
* @alpha
|
|
1172
|
+
*/
|
|
1173
|
+
export declare class JournalConflictError extends Error {
|
|
1174
|
+
/** Create a compare-and-set rejection with a diagnostic message. */
|
|
1175
|
+
constructor(message: string);
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
/**
|
|
1179
|
+
* A journal record's format or format version is not one the journal port
|
|
1180
|
+
* declared. On a write the record is refused; on a read or list the stored
|
|
1181
|
+
* record is refused rather than returned; a commit over a current revision of
|
|
1182
|
+
* an undeclared version is refused rather than overwriting it. History never
|
|
1183
|
+
* interprets or converts the content of another format version.
|
|
1184
|
+
* @alpha
|
|
1185
|
+
*/
|
|
1186
|
+
export declare class JournalVersionError extends Error {
|
|
1187
|
+
/** Create an undeclared-version refusal with a diagnostic message. */
|
|
1188
|
+
constructor(message: string);
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
/** Options for the isolated, non-durable test backend. @public */
|
|
1192
|
+
export declare interface MemoryStoreOptions {
|
|
1193
|
+
/** Metadata compatibility identifier; the initial store format uses sha256. */
|
|
1194
|
+
fingerprintAlgorithm?: string;
|
|
1195
|
+
/* Excluded from this release type: _onValueRead */
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
/** An update targeted a generation that has never been inserted. @public */
|
|
1199
|
+
export declare class MissingRowError extends Error {
|
|
1200
|
+
/** Identify an absent update target; updates never implicitly insert. @public */
|
|
1201
|
+
constructor(message?: string);
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
/**
|
|
1205
|
+
* Open (creating when empty) the durable History store for one logical store.
|
|
1206
|
+
* The file is rejected before any work unless it is empty or holds exactly
|
|
1207
|
+
* this schema version for this logical store.
|
|
1208
|
+
* @alpha
|
|
1209
|
+
*/
|
|
1210
|
+
export declare function openDurableHistory(options: IDurableHistoryOptions): IDurableHistory;
|
|
1211
|
+
|
|
1212
|
+
/** Observable call outcomes; an unmemoized named execution has no storage key. @public */
|
|
1213
|
+
export declare type Outcome = {
|
|
1214
|
+
kind: 'served';
|
|
1215
|
+
key: ResultKey;
|
|
1216
|
+
generation: number;
|
|
1217
|
+
} | {
|
|
1218
|
+
kind: 'executed';
|
|
1219
|
+
key: ResultKey;
|
|
1220
|
+
generation: number;
|
|
1221
|
+
} | {
|
|
1222
|
+
kind: 'checked';
|
|
1223
|
+
key: ResultKey;
|
|
1224
|
+
wouldExecute: boolean;
|
|
1225
|
+
divergence?: Divergence;
|
|
1226
|
+
} | {
|
|
1227
|
+
kind: 'refused';
|
|
1228
|
+
key: ResultKey;
|
|
1229
|
+
reason: unknown;
|
|
1230
|
+
} | {
|
|
1231
|
+
kind: 'failed';
|
|
1232
|
+
key: ResultKey;
|
|
1233
|
+
error: unknown;
|
|
1234
|
+
} | {
|
|
1235
|
+
kind: 'abandoned';
|
|
1236
|
+
key: ResultKey;
|
|
1237
|
+
reason: 'error' | 'lease-expired' | 'refused';
|
|
1238
|
+
} | {
|
|
1239
|
+
kind: 'ran';
|
|
1240
|
+
};
|
|
1241
|
+
|
|
1242
|
+
/** A legacy row-storage address, not the future structured semantic path. @public */
|
|
1243
|
+
export declare type Path = string;
|
|
1244
|
+
|
|
1245
|
+
/** Legacy persisted read rows; target observation encoding remains undecided. @public */
|
|
1246
|
+
export declare type RecordedRead = {
|
|
1247
|
+
kind: 'field';
|
|
1248
|
+
arg: number;
|
|
1249
|
+
path: Path;
|
|
1250
|
+
fingerprint: Fingerprint;
|
|
1251
|
+
} | {
|
|
1252
|
+
kind: 'whole';
|
|
1253
|
+
arg: number;
|
|
1254
|
+
fingerprint: Fingerprint;
|
|
1255
|
+
} | {
|
|
1256
|
+
kind: 'memo';
|
|
1257
|
+
key: ResultKey;
|
|
1258
|
+
generation: number;
|
|
1259
|
+
};
|
|
1260
|
+
|
|
1261
|
+
/** Complete storage tuple. Backends must preserve boundaries between all three parts. @public */
|
|
1262
|
+
export declare type ResultKey = {
|
|
1263
|
+
step: string;
|
|
1264
|
+
revision: number;
|
|
1265
|
+
subjectHash: string;
|
|
1266
|
+
};
|
|
1267
|
+
|
|
1268
|
+
/**
|
|
1269
|
+
* A presented writer lease no longer matches the durable holder, fence or
|
|
1270
|
+
* unexpired lease, so the mutation was rejected with no change other than the
|
|
1271
|
+
* observed clock high-water (PUB-002).
|
|
1272
|
+
* @alpha
|
|
1273
|
+
*/
|
|
1274
|
+
export declare class StaleWriterError extends Error {
|
|
1275
|
+
/** Create a stale-ownership rejection with a diagnostic message. */
|
|
1276
|
+
constructor(message: string);
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
/**
|
|
1280
|
+
* Storage mechanism for independent rows, with linearizable subject CAS.
|
|
1281
|
+
* All inputs and returned rows are detached snapshots: caller mutation cannot
|
|
1282
|
+
* alter persisted data. Values may only change by inserting another generation.
|
|
1283
|
+
* There is no transaction spanning these methods; callers must not infer atomic
|
|
1284
|
+
* claim/generation publication from the per-row CAS guarantee.
|
|
1285
|
+
* @public
|
|
1286
|
+
*/
|
|
1287
|
+
export declare interface Store {
|
|
1288
|
+
/** Return detached format metadata; opening code must reject algorithm mismatches. */
|
|
1289
|
+
meta(): Promise<StoreMetadata>;
|
|
1290
|
+
/** Read a detached subject snapshot, or undefined for an absent tuple. */
|
|
1291
|
+
getSubject(key: ResultKey): Promise<SubjectRow | undefined>;
|
|
1292
|
+
/** Insert only; duplicate tuples reject, as do versions outside safe integers. */
|
|
1293
|
+
putSubject(row: SubjectRow): Promise<void>;
|
|
1294
|
+
/**
|
|
1295
|
+
* Atomically apply a shallow column patch only when the stored version matches.
|
|
1296
|
+
* Success increments that version once, even for an empty patch; a missing or
|
|
1297
|
+
* stale row returns false without changes. Key/version properties reject at
|
|
1298
|
+
* runtime, including extras passed from untyped JavaScript callers.
|
|
1299
|
+
* An exhausted MAX_SAFE_INTEGER version rejects rather than reporting success
|
|
1300
|
+
* without advancing the token. Neither rejection changes the stored row.
|
|
1301
|
+
*/
|
|
1302
|
+
casSubject(key: ResultKey, expectedVersion: number, patch: SubjectPatch): Promise<boolean>;
|
|
1303
|
+
/** Read a detached generation, or undefined for an absent tuple. */
|
|
1304
|
+
getGeneration(key: ResultKey, generation: number): Promise<GenerationRow | undefined>;
|
|
1305
|
+
/** Return detached rows for exactly this complete key; ordering is unspecified. */
|
|
1306
|
+
listGenerations(key: ResultKey): Promise<GenerationRow[]>;
|
|
1307
|
+
/** Insert only; generation numbers are supplied, never allocated by storage. */
|
|
1308
|
+
putGeneration(row: GenerationRow): Promise<void>;
|
|
1309
|
+
/** Patch an existing row; missing tuples and attempts to change its key reject. */
|
|
1310
|
+
updateGeneration(key: ResultKey, generation: number, patch: GenerationPatch): Promise<void>;
|
|
1311
|
+
/**
|
|
1312
|
+
* Insert an atomic batch of immutable fields. Duplicate addresses, within the
|
|
1313
|
+
* batch or already stored, reject the whole batch without inserting anything.
|
|
1314
|
+
* This proposed storage refinement enforces retained-value immutability.
|
|
1315
|
+
*/
|
|
1316
|
+
putFields(rows: FieldRow[]): Promise<void>;
|
|
1317
|
+
/** Return requested field snapshots; absent paths are omitted. */
|
|
1318
|
+
getFields(key: ResultKey, generation: number, paths: Path[]): Promise<FieldRow[]>;
|
|
1319
|
+
/** Return requested fingerprints without reading/deserializing any field value. */
|
|
1320
|
+
getFingerprints(key: ResultKey, generation: number, paths: Path[]): Promise<Map<Path, Fingerprint>>;
|
|
1321
|
+
/**
|
|
1322
|
+
* Query leases strictly less than now, oldest first, with at most limit rows.
|
|
1323
|
+
* Zero limit returns no rows. This query never sweeps or changes a claim.
|
|
1324
|
+
*/
|
|
1325
|
+
expiredClaims(now: number, limit: number): Promise<SubjectRow[]>;
|
|
1326
|
+
/** Release resources owned by this store. */
|
|
1327
|
+
close(): Promise<void>;
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
/**
|
|
1331
|
+
* Register reusable backend qualification tests for SA-1 through SA-7.
|
|
1332
|
+
* Register this from a Jest test module; the suite imports no concrete backend.
|
|
1333
|
+
* Mutation tests enforce rev 9's retained-value isolation at the storage seam.
|
|
1334
|
+
* This suite does not assert atomicity across subject, generation, and field rows:
|
|
1335
|
+
* the supplied Store contract does not provide that operation.
|
|
1336
|
+
* @public
|
|
1337
|
+
*/
|
|
1338
|
+
export declare function storeConformance(name: string, options: StoreConformanceOptions): void;
|
|
1339
|
+
|
|
1340
|
+
/**
|
|
1341
|
+
* Opens a fresh store for each test. The optional algorithm models persisted metadata
|
|
1342
|
+
* at open time; factories must reject a mismatch with their runtime algorithm.
|
|
1343
|
+
* Instrumentation is optional for third-party backends, but both shipped backends
|
|
1344
|
+
* must provide it to qualify SA-3 without relying on wall-clock timing.
|
|
1345
|
+
* @public
|
|
1346
|
+
*/
|
|
1347
|
+
export declare interface StoreConformanceOptions {
|
|
1348
|
+
create(options?: {
|
|
1349
|
+
fingerprintAlgorithm?: string;
|
|
1350
|
+
}): Store | Promise<Store>;
|
|
1351
|
+
fingerprintAlgorithm: string;
|
|
1352
|
+
probeValueReads?(store: Store): ValueReadProbe;
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
/** Persisted format identifiers, checked before using a store's fingerprints. @public */
|
|
1356
|
+
export declare interface StoreMetadata {
|
|
1357
|
+
schemaVersion: number;
|
|
1358
|
+
fingerprintAlgorithm: string;
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
/** Legacy row subject shape; future author-supplied subject identity is separate. @public */
|
|
1362
|
+
export declare type Subject = Extract<Identity, {
|
|
1363
|
+
kind: 'step';
|
|
1364
|
+
}>;
|
|
1365
|
+
|
|
1366
|
+
/** Writable subject columns; the complete key and CAS token cannot be patched. @public */
|
|
1367
|
+
export declare type SubjectPatch = Partial<Omit<SubjectRow, 'key' | 'version'>>;
|
|
1368
|
+
|
|
1369
|
+
/**
|
|
1370
|
+
* One compare-and-set row per complete result key. Repository owns generation
|
|
1371
|
+
* meaning; claim owns lease meaning. Storage only preserves and patches columns.
|
|
1372
|
+
* @public
|
|
1373
|
+
*/
|
|
1374
|
+
export declare interface SubjectRow {
|
|
1375
|
+
key: ResultKey;
|
|
1376
|
+
subject: Subject;
|
|
1377
|
+
/** Nonnegative safe-integer CAS token, incremented once per successful CAS. */
|
|
1378
|
+
version: number;
|
|
1379
|
+
currentGeneration: number | null;
|
|
1380
|
+
claim: null | {
|
|
1381
|
+
generation: number;
|
|
1382
|
+
holder: string;
|
|
1383
|
+
leaseUntil: number;
|
|
1384
|
+
progress: {
|
|
1385
|
+
fingerprint: Fingerprint;
|
|
1386
|
+
value: unknown;
|
|
1387
|
+
} | null;
|
|
1388
|
+
};
|
|
1389
|
+
durations: number[];
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
/**
|
|
1393
|
+
* A backend's test-only counter at its actual value-read/deserialization boundary.
|
|
1394
|
+
* The suite resets it after insertion and verifies a positive control with getFields.
|
|
1395
|
+
* @public
|
|
1396
|
+
*/
|
|
1397
|
+
export declare interface ValueReadProbe {
|
|
1398
|
+
reset(): void;
|
|
1399
|
+
count(): number;
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
export { }
|