@microdelta/history 0.0.0 → 0.1.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 +19 -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 +1058 -0
- package/dist/api/history.root.raw.beta.d.ts +393 -0
- package/dist/api/history.root.raw.public.d.ts +393 -0
- package/dist/api/history.root.raw.untrimmed.d.ts +1059 -0
- package/dist/api/history.shared.alpha.d.ts +1091 -0
- package/dist/api/history.shared.beta.d.ts +426 -0
- package/dist/api/history.shared.public.d.ts +426 -0
- package/dist/api/history.shared.untrimmed.d.ts +1092 -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 +339 -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 +69 -0
- package/dist/src/durable/errors.d.ts.map +1 -0
- package/dist/src/durable/errors.js +87 -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 +590 -0
- package/dist/src/durable/index.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/schema.d.ts +28 -0
- package/dist/src/durable/schema.d.ts.map +1 -0
- package/dist/src/durable/schema.js +266 -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 +592 -0
- package/dist/src/durable/selected-index.js.map +1 -0
- package/dist/src/index.d.ts +26 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +13 -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,1091 @@
|
|
|
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 writer fence under which the acceptance was recorded. */
|
|
160
|
+
readonly fence: number;
|
|
161
|
+
/** Resolution's acceptance evidence, decoded and frozen. */
|
|
162
|
+
readonly evidence: IVersionedRecord;
|
|
163
|
+
/** Exact results the verification followed, in recorded order. */
|
|
164
|
+
readonly dependencies: readonly ICompletedResultReference[];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Records that an existing completed result was accepted by a current
|
|
169
|
+
* verification. It needs writer ownership to write, but no attempt: a valid
|
|
170
|
+
* hit claims no execution. The evidence names the current dependencies the
|
|
171
|
+
* verification followed, which may differ from the original provenance.
|
|
172
|
+
* @alpha
|
|
173
|
+
*/
|
|
174
|
+
export declare interface IAcceptanceRequest {
|
|
175
|
+
/** The exact completed result that was accepted. */
|
|
176
|
+
readonly reference: ICompletedResultReference;
|
|
177
|
+
/** Resolution's versioned acceptance evidence. */
|
|
178
|
+
readonly evidence: IVersionedRecord;
|
|
179
|
+
/** Exact completed results the current verification followed. */
|
|
180
|
+
readonly dependencies: readonly ICompletedResultReference[];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** @alpha A path segment whose kind follows the container's operation semantics. */
|
|
184
|
+
export declare type IAddressSegment =
|
|
185
|
+
/** A literal string-keyed record lookup, including keys containing punctuation. */
|
|
186
|
+
{
|
|
187
|
+
readonly kind: 'property';
|
|
188
|
+
readonly key: string;
|
|
189
|
+
}
|
|
190
|
+
/** A positional array lookup; it does not designate a logical member identity. */
|
|
191
|
+
| {
|
|
192
|
+
readonly kind: 'index';
|
|
193
|
+
readonly index: number;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* One durable attempt as History records it. The attempt identity is issued
|
|
198
|
+
* from a store-wide counter that never reissues a value, including after
|
|
199
|
+
* abandonment or process death (PUB-003).
|
|
200
|
+
* @alpha
|
|
201
|
+
*/
|
|
202
|
+
export declare interface IAttemptRecord extends IAttemptRequest {
|
|
203
|
+
/** The never-reused store-wide attempt identity. */
|
|
204
|
+
readonly attemptId: number;
|
|
205
|
+
/** The current lifecycle state. */
|
|
206
|
+
readonly state: IAttemptState;
|
|
207
|
+
/** The fence of the lease that allocated this attempt. */
|
|
208
|
+
readonly allocatedFence: number;
|
|
209
|
+
/** The fence that completed, failed or interrupted it; null while incomplete. */
|
|
210
|
+
readonly endedFence: number | null;
|
|
211
|
+
/** The exact completed result, present only in the `completed` state. */
|
|
212
|
+
readonly result: ICompletedResultReference | null;
|
|
213
|
+
/** Owner-defined evidence of a failed or interrupted attempt, otherwise null. */
|
|
214
|
+
readonly outcome: IVersionedRecord | null;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Identifies one admitted execution for allocation or recovery. The attempt
|
|
219
|
+
* key is a stable caller-derived identity for exactly one execution, scoped by
|
|
220
|
+
* logical store, analysis, environment and subject; it is not a subject-level
|
|
221
|
+
* cache key. The intent digest is an opaque digest Resolution computes from
|
|
222
|
+
* the complete invocation it intends to run; History compares it only for
|
|
223
|
+
* exact equality, so a reused key with a different intent is a conflict.
|
|
224
|
+
* @alpha
|
|
225
|
+
*/
|
|
226
|
+
export declare interface IAttemptRequest extends IVersionedSubject {
|
|
227
|
+
/** The stable key of one admitted execution. */
|
|
228
|
+
readonly attemptKey: string;
|
|
229
|
+
/** Resolution's opaque digest of that execution's complete intent. */
|
|
230
|
+
readonly intentDigest: string;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Durable attempt lifecycle. `allocated` and `staged` are incomplete;
|
|
235
|
+
* `completed` produced exactly one published result; `failed` and
|
|
236
|
+
* `interrupted` ended without a result. Staged content is attempt evidence,
|
|
237
|
+
* never a completed result.
|
|
238
|
+
* @alpha
|
|
239
|
+
*/
|
|
240
|
+
export declare type IAttemptState = 'allocated' | 'staged' | 'completed' | 'failed' | 'interrupted';
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Reads the host's current wall-clock time. Each reading is one observation in
|
|
244
|
+
* whole UTC milliseconds since the Unix epoch, always a finite safe integer.
|
|
245
|
+
* Readings are not monotonic: the host clock can move backwards or jump
|
|
246
|
+
* forwards between readings, and the capability reports that movement
|
|
247
|
+
* unchanged. Deciding how such movement affects leases or other ownership is
|
|
248
|
+
* the consumer's policy, not the clock's.
|
|
249
|
+
* @alpha
|
|
250
|
+
*/
|
|
251
|
+
export declare interface IClockCapability {
|
|
252
|
+
/** Return the current UTC epoch time in whole milliseconds, or throw if the host cannot provide one. */
|
|
253
|
+
currentEpochMilliseconds(): number;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Framework metadata of one immutable completed result, readable without
|
|
258
|
+
* loading its author payload. Provenance and dependencies are the historical
|
|
259
|
+
* truth recorded at publication; later acceptance never rewrites them (RES-007).
|
|
260
|
+
* @alpha
|
|
261
|
+
*/
|
|
262
|
+
export declare interface ICompletedEnvelope extends IVersionedSubject {
|
|
263
|
+
/** The exact scoped reference of this result. */
|
|
264
|
+
readonly reference: ICompletedResultReference;
|
|
265
|
+
/** The attempt that produced this result; a result has exactly one. */
|
|
266
|
+
readonly attemptId: number;
|
|
267
|
+
/** Store-wide publication order; later publications have larger values. */
|
|
268
|
+
readonly publication: number;
|
|
269
|
+
/** The supported Value snapshot encoding of the stored payload. */
|
|
270
|
+
readonly encoding: 'MDS1';
|
|
271
|
+
/** Resolution's execution provenance, decoded and frozen. */
|
|
272
|
+
readonly provenance: IVersionedRecord;
|
|
273
|
+
/** Exact completed results this execution depended on, in recorded order. */
|
|
274
|
+
readonly dependencies: readonly ICompletedResultReference[];
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Optional capability for readers that can navigate one exact completed
|
|
279
|
+
* snapshot node by node, for lazy nested views. A navigation answer is the
|
|
280
|
+
* scalar value fact or the record/array shape at exactly the requested address;
|
|
281
|
+
* answering it must not read the root payload, a sibling or an unrequested
|
|
282
|
+
* descendant. Presence and key-order facts at nested addresses are answered by
|
|
283
|
+
* the same reader's {@link ICompletedResultReader.readSelected}. Every answer is
|
|
284
|
+
* synchronous: storage that can only load asynchronously cannot implement this
|
|
285
|
+
* capability. Scalar-only readers need not implement it.
|
|
286
|
+
* @alpha
|
|
287
|
+
*/
|
|
288
|
+
export declare interface ICompletedNavigationReader {
|
|
289
|
+
/** Navigate to exactly one node of this reference, never following a current pointer. */
|
|
290
|
+
readNode(reference: ICompletedResultReference, address: readonly IAddressSegment[]): ISelectedNode;
|
|
291
|
+
/**
|
|
292
|
+
* Return the complete supported data of one container subtree, only for an
|
|
293
|
+
* explicit output request. Record key order must be the snapshot's order.
|
|
294
|
+
*/
|
|
295
|
+
readSubtree(reference: ICompletedResultReference, address: readonly IAddressSegment[]): unknown;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Optional capability for readers that can supply an exact keyed projection as
|
|
300
|
+
* selected member values. Scalar readers do not need to implement projections.
|
|
301
|
+
* @alpha
|
|
302
|
+
*/
|
|
303
|
+
export declare interface ICompletedProjectionReader {
|
|
304
|
+
/** Read only the projection's requested address and keyed selected values. */
|
|
305
|
+
readProjection(reference: ICompletedResultReference, descriptor: IValueProjectionDescriptor): IValueProjectionFact;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Synchronous scalar access and fingerprint-only resolution for one exact
|
|
310
|
+
* completed snapshot. A compatible fingerprint answer must be backed by the
|
|
311
|
+
* same semantics as a selected read; resolving metadata never reads payload.
|
|
312
|
+
* @alpha
|
|
313
|
+
*/
|
|
314
|
+
export declare interface ICompletedResultReader {
|
|
315
|
+
/** Read the requested fact from exactly this reference, never from current. */
|
|
316
|
+
readSelected(reference: ICompletedResultReference, request: ISelectedReadRequest): ISelectedFact;
|
|
317
|
+
/** Resolve matching metadata only; unavailable metadata does not trigger a read. */
|
|
318
|
+
resolveFingerprint(reference: ICompletedResultReference, request: ISelectedFingerprintRequest): ISelectedFingerprintResolution;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* A caller-visible locator for one completed immutable snapshot. The opaque
|
|
323
|
+
* locator carries whatever analysis and environment scope its reader requires;
|
|
324
|
+
* it is never a payload or a request to follow a current pointer.
|
|
325
|
+
* @alpha
|
|
326
|
+
*/
|
|
327
|
+
export declare interface ICompletedResultReference {
|
|
328
|
+
/** Dispatches resolution to the completed-result contract. */
|
|
329
|
+
readonly kind: 'completed-result';
|
|
330
|
+
/** Opaque exact snapshot locator interpreted only by its injected reader. */
|
|
331
|
+
readonly locator: string;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Compatibility identity shape stored in scaffold rows. It does not establish
|
|
336
|
+
* target subject identity, binding correspondence, or collection semantics.
|
|
337
|
+
* @public
|
|
338
|
+
*/
|
|
339
|
+
export declare type Identity = {
|
|
340
|
+
kind: 'type';
|
|
341
|
+
type: string;
|
|
342
|
+
key: string;
|
|
343
|
+
} | {
|
|
344
|
+
kind: 'step';
|
|
345
|
+
name: string;
|
|
346
|
+
inputs: readonly Identity[];
|
|
347
|
+
} | {
|
|
348
|
+
kind: 'member';
|
|
349
|
+
of: Identity;
|
|
350
|
+
path: Path;
|
|
351
|
+
} | {
|
|
352
|
+
kind: 'collection';
|
|
353
|
+
step: string;
|
|
354
|
+
source: Identity;
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* History's durable authority over one logical store. Every mutation except
|
|
359
|
+
* acquisition requires the current writer lease and checks holder, fence and
|
|
360
|
+
* unexpired lease inside its own transaction. Exact reads never consult a
|
|
361
|
+
* current pointer, and a missing or wrong-scope reference is an integrity
|
|
362
|
+
* failure, never a miss to be repaired by recomputation.
|
|
363
|
+
*
|
|
364
|
+
* Clock policy: each holder operation evaluates time as the larger of the
|
|
365
|
+
* host reading and a persisted store-wide high-water, then persists that value,
|
|
366
|
+
* including when the operation is rejected. Backward host movement therefore
|
|
367
|
+
* delays expiry and a forward jump can expire a lease early; neither lets an
|
|
368
|
+
* old fence act after a successor acquires, because every successor receives a
|
|
369
|
+
* larger fence. A host reading that is not a nonnegative safe integer fails
|
|
370
|
+
* the operation without any change. This is a local single-file policy, not a
|
|
371
|
+
* distributed-time or liveness guarantee.
|
|
372
|
+
* @alpha
|
|
373
|
+
*/
|
|
374
|
+
export declare interface IDurableHistory {
|
|
375
|
+
/** The logical store identity this authority holds. */
|
|
376
|
+
readonly logicalStore: string;
|
|
377
|
+
/** Exact selected reads over completed results, answered from their generated index. */
|
|
378
|
+
readonly reader: ICompletedResultReader & ICompletedNavigationReader;
|
|
379
|
+
/** Acquire the single logical writer, or report the observed unexpired holder. */
|
|
380
|
+
acquireWriter(request: IWriterAcquisitionRequest): IWriterAcquisition;
|
|
381
|
+
/** Extend a still-valid lease; a stale or expired lease is rejected. */
|
|
382
|
+
renewWriter(lease: IWriterLease, leaseMilliseconds: number): IWriterLease;
|
|
383
|
+
/** End a still-valid lease without resetting the fence. */
|
|
384
|
+
releaseWriter(lease: IWriterLease): void;
|
|
385
|
+
/** Inspect the recorded holder, if any, without granting authority. */
|
|
386
|
+
currentWriter(): IWriterLease | undefined;
|
|
387
|
+
/**
|
|
388
|
+
* Durably allocate one attempt in its own commit before any staging. The
|
|
389
|
+
* same key with the same intent returns the existing attempt in whatever
|
|
390
|
+
* state it reached; the same key with a different intent or version rejects.
|
|
391
|
+
*/
|
|
392
|
+
allocateAttempt(lease: IWriterLease, request: IAttemptRequest): IAttemptRecord;
|
|
393
|
+
/** Persist candidate content for an allocated attempt without publishing it. */
|
|
394
|
+
stageAttempt(lease: IWriterLease, request: IStageRequest): IAttemptRecord;
|
|
395
|
+
/**
|
|
396
|
+
* In one commit, install the staged payload, its generated selected index
|
|
397
|
+
* and fingerprints, provenance, dependencies, the completed attempt state
|
|
398
|
+
* and the scoped current pointer. Publishing an already completed attempt
|
|
399
|
+
* returns its existing reference.
|
|
400
|
+
*/
|
|
401
|
+
publishAttempt(lease: IWriterLease, attemptId: number): ICompletedResultReference;
|
|
402
|
+
/** End an incomplete attempt as failed or interrupted, retaining its evidence. */
|
|
403
|
+
abandonAttempt(lease: IWriterLease, request: IAbandonRequest): IAttemptRecord;
|
|
404
|
+
/** Report what durably happened to one identified execution, read-only. */
|
|
405
|
+
recoverAttempt(request: IAttemptRequest): IRecoveryOutcome;
|
|
406
|
+
/** Completed results for one scoped subject and version, latest publication first. */
|
|
407
|
+
findCandidates(subject: IVersionedSubject): readonly ICompletedEnvelope[];
|
|
408
|
+
/** The scoped subject's latest publication, if any; never rewound by acceptance. */
|
|
409
|
+
readCurrent(subject: IScopedSubject): ICompletedResultReference | undefined;
|
|
410
|
+
/** Read one exact result's metadata without loading its payload. */
|
|
411
|
+
readEnvelope(reference: ICompletedResultReference): ICompletedEnvelope;
|
|
412
|
+
/** Regenerate and compare one exact result's index from its canonical payload. */
|
|
413
|
+
verifyResult(reference: ICompletedResultReference): IResultVerification;
|
|
414
|
+
/** Record a current acceptance of an existing result without touching it or the current pointer. */
|
|
415
|
+
recordAcceptance(lease: IWriterLease, request: IAcceptanceRequest): IAcceptanceRecord;
|
|
416
|
+
/** Acceptance records naming one exact result, in record order. */
|
|
417
|
+
readAcceptances(reference: ICompletedResultReference): readonly IAcceptanceRecord[];
|
|
418
|
+
/** Release the SQLite file; later calls fail. */
|
|
419
|
+
close(): void;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Host capabilities and identity for opening a durable History store. Node
|
|
424
|
+
* access stays behind the injected SQLite and clock capabilities. The logical
|
|
425
|
+
* store identity is independent of the file location: a moved file keeps its
|
|
426
|
+
* identity, and a file holding another logical store is rejected.
|
|
427
|
+
* @alpha
|
|
428
|
+
*/
|
|
429
|
+
export declare interface IDurableHistoryOptions {
|
|
430
|
+
/** Opens the persistent SQLite file; History owns every statement and schema. */
|
|
431
|
+
readonly sqlite: ISqliteCapability;
|
|
432
|
+
/** Supplies wall-clock observations for History's lease policy. */
|
|
433
|
+
readonly clock: IClockCapability;
|
|
434
|
+
/** Computes content fingerprints for the selected index. */
|
|
435
|
+
readonly sha256: ISha256Capability;
|
|
436
|
+
/** The host location of the SQLite file, passed only to `sqlite`. */
|
|
437
|
+
readonly location: string;
|
|
438
|
+
/** The logical store identity this file must hold, or is created to hold. */
|
|
439
|
+
readonly logicalStore: string;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* The analysis and environment that scope every subject, attempt and result
|
|
444
|
+
* within one logical store. The same subject text in another analysis or
|
|
445
|
+
* environment is a different scoped subject (RES-001/002). Both are complete
|
|
446
|
+
* opaque non-empty strings compared by exact equality.
|
|
447
|
+
* @alpha
|
|
448
|
+
*/
|
|
449
|
+
export declare interface IHistoryScope {
|
|
450
|
+
/** The analysis whose history this is. */
|
|
451
|
+
readonly analysis: string;
|
|
452
|
+
/** The logical environment within that analysis. */
|
|
453
|
+
readonly environment: string;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/** A patch attempted to modify an immutable address or managed CAS version. @public */
|
|
457
|
+
export declare class InvalidStorePatchError extends Error {
|
|
458
|
+
/** Identify a structurally forbidden patch before any columns are changed. @public */
|
|
459
|
+
constructor(message?: string);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/** @alpha A supported JavaScript observation operation with its own fact meaning. */
|
|
463
|
+
export declare type IOperation = 'value' | 'own' | 'membership' | 'length' | 'keys';
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Read-only recovery of one identified execution. Recovery reports what
|
|
467
|
+
* durably happened and never executes, publishes or records acceptance:
|
|
468
|
+
* `absent` means the key was never allocated in this scope, `incomplete` an
|
|
469
|
+
* allocated or staged attempt, `unsuccessful` a failed or interrupted one and
|
|
470
|
+
* `completed` the exact result that execution published.
|
|
471
|
+
* @alpha
|
|
472
|
+
*/
|
|
473
|
+
export declare type IRecoveryOutcome = {
|
|
474
|
+
readonly kind: 'absent';
|
|
475
|
+
} | {
|
|
476
|
+
readonly kind: 'incomplete';
|
|
477
|
+
readonly attempt: IAttemptRecord;
|
|
478
|
+
} | {
|
|
479
|
+
readonly kind: 'unsuccessful';
|
|
480
|
+
readonly attempt: IAttemptRecord;
|
|
481
|
+
} | {
|
|
482
|
+
readonly kind: 'completed';
|
|
483
|
+
readonly attempt: IAttemptRecord;
|
|
484
|
+
/** The exact result that this identified execution published. */
|
|
485
|
+
readonly reference: ICompletedResultReference;
|
|
486
|
+
};
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Result of regenerating a completed result's selected index from its stored
|
|
490
|
+
* canonical payload and comparing it with the stored index.
|
|
491
|
+
* @alpha
|
|
492
|
+
*/
|
|
493
|
+
export declare type IResultVerification = {
|
|
494
|
+
readonly kind: 'consistent';
|
|
495
|
+
} | {
|
|
496
|
+
readonly kind: 'inconsistent';
|
|
497
|
+
readonly detail: string;
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* One scoped subject: the author's complete opaque subject string inside its
|
|
502
|
+
* analysis/environment scope. History never derives, prefixes or reinterprets
|
|
503
|
+
* the subject; it identifies a history of work, not one exact result.
|
|
504
|
+
* @alpha
|
|
505
|
+
*/
|
|
506
|
+
export declare interface IScopedSubject extends IHistoryScope {
|
|
507
|
+
/** The author's complete subject string, compared by exact string equality. */
|
|
508
|
+
readonly subject: string;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* One immediate lookup result for a caller-supplied root, address, and
|
|
513
|
+
* operation. The fact may be the selected object reference itself, so it is
|
|
514
|
+
* neither a detached snapshot nor retained Tracking evidence. Tracking adds
|
|
515
|
+
* binding and capture relationships and decides what data to encode as evidence.
|
|
516
|
+
* @alpha
|
|
517
|
+
*/
|
|
518
|
+
export declare interface ISelectedFact {
|
|
519
|
+
/** The literal access whose result was selected. */
|
|
520
|
+
readonly operation: IOperation;
|
|
521
|
+
/** Ordered container-aware steps from the supplied root to the selected location. */
|
|
522
|
+
readonly address: readonly IAddressSegment[];
|
|
523
|
+
/** The selected value or structural fact; an object value remains the source reference. */
|
|
524
|
+
readonly fact: unknown;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Metadata lookup is scoped to the exact result reference and full requested
|
|
529
|
+
* selection. The encoding tag prevents an indexed digest from another semantic
|
|
530
|
+
* version being mistaken for this selection.
|
|
531
|
+
* @alpha
|
|
532
|
+
*/
|
|
533
|
+
export declare type ISelectedFingerprintRequest = {
|
|
534
|
+
readonly kind: 'selected';
|
|
535
|
+
readonly operation: IOperation;
|
|
536
|
+
readonly address: readonly IAddressSegment[];
|
|
537
|
+
readonly encoding: 'MDO1';
|
|
538
|
+
} | {
|
|
539
|
+
readonly kind: 'projection';
|
|
540
|
+
readonly descriptor: IValueProjectionDescriptor;
|
|
541
|
+
readonly encoding: 'MDP1';
|
|
542
|
+
} | {
|
|
543
|
+
readonly kind: 'materialized-output';
|
|
544
|
+
readonly address: readonly IAddressSegment[];
|
|
545
|
+
readonly encoding: 'MDS1';
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
/** Explicit results keep absent or incompatible metadata from implying equality. @alpha */
|
|
549
|
+
export declare type ISelectedFingerprintResolution = {
|
|
550
|
+
readonly kind: 'compatible';
|
|
551
|
+
readonly fingerprint: string;
|
|
552
|
+
} | {
|
|
553
|
+
readonly kind: 'unavailable';
|
|
554
|
+
} | {
|
|
555
|
+
readonly kind: 'incompatible';
|
|
556
|
+
} | {
|
|
557
|
+
readonly kind: 'ambiguous';
|
|
558
|
+
};
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* The kind of node that one exact structured address selects. A scalar leaf is
|
|
562
|
+
* its ordinary `value` selected fact. A record or array is described only by
|
|
563
|
+
* its container shape: navigating through a container is transport metadata for
|
|
564
|
+
* a lazy view, never a whole-object observation, so no member, identity or
|
|
565
|
+
* serialized subtree is implied. Array length is carried so a view need not ask
|
|
566
|
+
* again, but it becomes observation evidence only when a consumer reads it.
|
|
567
|
+
* Shapes are never placed inside {@link ISelectedFact.fact}.
|
|
568
|
+
* @alpha
|
|
569
|
+
*/
|
|
570
|
+
export declare type ISelectedNode =
|
|
571
|
+
/** A supported scalar (undefined, null, boolean, number or string) read at the address. */
|
|
572
|
+
{
|
|
573
|
+
readonly kind: 'scalar';
|
|
574
|
+
readonly selected: ISelectedFact;
|
|
575
|
+
}
|
|
576
|
+
/** A string-keyed plain-data record, possibly with a supported custom prototype chain. */
|
|
577
|
+
| {
|
|
578
|
+
readonly kind: 'record';
|
|
579
|
+
readonly address: readonly IAddressSegment[];
|
|
580
|
+
}
|
|
581
|
+
/** A standard array; `length` counts slots including holes. */
|
|
582
|
+
| {
|
|
583
|
+
readonly kind: 'array';
|
|
584
|
+
readonly address: readonly IAddressSegment[];
|
|
585
|
+
readonly length: number;
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
/** A selected Value-owned scalar fact requested at an exact retained address. @alpha */
|
|
589
|
+
export declare interface ISelectedReadRequest {
|
|
590
|
+
/** The literal operation whose fact is requested. */
|
|
591
|
+
readonly operation: IOperation;
|
|
592
|
+
/** Container-aware path within this selected result value. */
|
|
593
|
+
readonly address: readonly IAddressSegment[];
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Computes SHA-256 over the UTF-8 bytes of supplied canonical evidence.
|
|
598
|
+
* Machine supplies hashing only; callers define the meaning and framing of
|
|
599
|
+
* the input before it crosses this host boundary.
|
|
600
|
+
* @alpha
|
|
601
|
+
*/
|
|
602
|
+
export declare interface ISha256Capability {
|
|
603
|
+
/** Return the lowercase hexadecimal SHA-256 digest of the input text. */
|
|
604
|
+
sha256(input: string): string;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* Produces a synchronous detached copy of primitives, arrays, ordinary objects'
|
|
609
|
+
* enumerable string-keyed properties, Date, RegExp, Map, Set, ArrayBuffer, and
|
|
610
|
+
* typed-array/DataView contents. It preserves cycles and repeated references
|
|
611
|
+
* within one copy and isolates both input and returned snapshots. Functions,
|
|
612
|
+
* symbols, and raw SharedArrayBuffer values fail. Getters may run; nonenumerable
|
|
613
|
+
* and symbol-keyed properties and arbitrary class prototypes are not preserved.
|
|
614
|
+
* This contract defines neither durable encoding nor canonical identity. It is
|
|
615
|
+
* public because History's direct memory-store constructor requires injection.
|
|
616
|
+
* @public
|
|
617
|
+
*/
|
|
618
|
+
declare interface ISnapshotCapability {
|
|
619
|
+
/** Return a detached copy or throw before a caller mutates owned state. */
|
|
620
|
+
snapshot<T>(value: T): T;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Opens persistent local SQLite databases for a consumer that owns its own
|
|
625
|
+
* SQL and schema, such as History's durable authority. Opening fails for a
|
|
626
|
+
* directory, a missing parent directory, a file that is not a SQLite database,
|
|
627
|
+
* or a location that cannot hold a persistent write-ahead-logged database,
|
|
628
|
+
* including `:memory:` and the empty path. Opening never silently weakens the
|
|
629
|
+
* host's durable configuration.
|
|
630
|
+
* @alpha
|
|
631
|
+
*/
|
|
632
|
+
export declare interface ISqliteCapability {
|
|
633
|
+
/** Open or create the database file at `location` and return its owned connection. */
|
|
634
|
+
openSqlite(location: string): ISqliteConnection;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* An open connection to one persistent local SQLite database file. The caller
|
|
639
|
+
* that opened it owns it and must close it. The host selects durable
|
|
640
|
+
* configuration for every connection: write-ahead logging, FULL synchronous
|
|
641
|
+
* commits, enforced foreign keys and a bounded wait on a locked database.
|
|
642
|
+
* Callers supply every SQL statement and schema; the connection has no
|
|
643
|
+
* knowledge of what the tables mean.
|
|
644
|
+
*
|
|
645
|
+
* Transactions are synchronous, top-level and IMMEDIATE: the write lock is
|
|
646
|
+
* taken before the callback runs, the callback's writes commit together when
|
|
647
|
+
* it returns, and all of them roll back when it throws. Nesting is refused
|
|
648
|
+
* rather than given savepoint semantics. Calls through the connection or its
|
|
649
|
+
* statements made by asynchronous work that a callback left behind fail after
|
|
650
|
+
* the transaction ends. This protects only this connection's storage: it does
|
|
651
|
+
* not prevent other effects of that leftover JavaScript.
|
|
652
|
+
* @alpha
|
|
653
|
+
*/
|
|
654
|
+
export declare interface ISqliteConnection {
|
|
655
|
+
/** Execute SQL text that takes no bound values, such as schema statements. */
|
|
656
|
+
exec(sql: string): void;
|
|
657
|
+
/** Prepare one statement for repeated execution with bound values. */
|
|
658
|
+
prepare(sql: string): ISqliteStatement;
|
|
659
|
+
/**
|
|
660
|
+
* Run `operation` inside one IMMEDIATE transaction and return its result.
|
|
661
|
+
* A value thrown by `operation` rolls back every write and is rethrown
|
|
662
|
+
* unchanged. A Promise or thenable result, or a returned object or function
|
|
663
|
+
* whose `then` cannot be inspected, rolls back and fails with `TypeError`;
|
|
664
|
+
* an error raised while inspecting that `then` is not rethrown. A call made
|
|
665
|
+
* while this connection's transaction callback is running fails without
|
|
666
|
+
* invoking `operation`.
|
|
667
|
+
*/
|
|
668
|
+
transaction<T>(operation: () => T & ISqliteSynchronousResult<T>): T;
|
|
669
|
+
/**
|
|
670
|
+
* Release the database file. Closing again has no effect; any later use of
|
|
671
|
+
* the connection or its statements fails. Closing from inside a transaction
|
|
672
|
+
* callback fails, which rolls that transaction back if the failure propagates,
|
|
673
|
+
* and work that outlived a transaction callback cannot close the connection.
|
|
674
|
+
*/
|
|
675
|
+
close(): void;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* One result row keyed by result column name. Rows are transport data owned by
|
|
680
|
+
* the caller; they carry no driver type, prototype behavior or live link to
|
|
681
|
+
* stored content.
|
|
682
|
+
* @alpha
|
|
683
|
+
*/
|
|
684
|
+
export declare interface ISqliteRow {
|
|
685
|
+
/** The value SQLite returned for the named result column. */
|
|
686
|
+
readonly [column: string]: ISqliteValue;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* The only mutation fact a statement run reports. Row identifiers and other
|
|
691
|
+
* driver details stay inside the host.
|
|
692
|
+
* @alpha
|
|
693
|
+
*/
|
|
694
|
+
export declare interface ISqliteRunResult {
|
|
695
|
+
/** Rows inserted, updated or deleted directly by the statement. */
|
|
696
|
+
readonly changes: number;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* One prepared SQL statement bound to the connection that prepared it. Values
|
|
701
|
+
* are always bound positionally and never interpolated into SQL text. Every
|
|
702
|
+
* call fails once the owning connection is closed, and fails when it is made by
|
|
703
|
+
* work inherited from an already ended transaction callback.
|
|
704
|
+
* @alpha
|
|
705
|
+
*/
|
|
706
|
+
export declare interface ISqliteStatement {
|
|
707
|
+
/** Execute the statement for its effect and report how many rows changed. */
|
|
708
|
+
run(...values: readonly ISqliteValue[]): ISqliteRunResult;
|
|
709
|
+
/** Return the first result row, or `undefined` when the statement yields none. */
|
|
710
|
+
get(...values: readonly ISqliteValue[]): ISqliteRow | undefined;
|
|
711
|
+
/** Return every result row in the order SQLite produced them. */
|
|
712
|
+
all(...values: readonly ISqliteValue[]): readonly ISqliteRow[];
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Makes a transaction callback's return type unusable when it is, or may be, a
|
|
717
|
+
* Promise or other thenable. A transaction commits when its callback returns;
|
|
718
|
+
* an asynchronous callback would return before its awaited work, so such
|
|
719
|
+
* results are rejected at compile time and, independently, at runtime.
|
|
720
|
+
*
|
|
721
|
+
* Any union constituent with a callable `then` rejects the whole result, so
|
|
722
|
+
* `number | Promise<number>` is refused like `Promise<number>`. Results the
|
|
723
|
+
* compiler cannot classify, `any` and `unknown`, are left to the runtime check
|
|
724
|
+
* rather than rejecting ordinary untyped data.
|
|
725
|
+
* @alpha
|
|
726
|
+
*/
|
|
727
|
+
export declare type ISqliteSynchronousResult<T> = 0 extends 1 & T ? unknown : [Extract<T, {
|
|
728
|
+
readonly then: (...parameters: never[]) => unknown;
|
|
729
|
+
}>] extends [never] ? unknown : never;
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* One value that crosses the SQLite host boundary, either as a bound parameter
|
|
733
|
+
* or as a returned cell: text, a finite number, SQL NULL, or a BLOB copied into
|
|
734
|
+
* a plain `Uint8Array`. A returned INTEGER is exact because values outside the
|
|
735
|
+
* safe-integer range fail instead of being rounded. Booleans, bigints,
|
|
736
|
+
* `undefined`, non-finite numbers and objects are outside the domain and are
|
|
737
|
+
* refused at runtime even when a caller bypasses these types.
|
|
738
|
+
* @alpha
|
|
739
|
+
*/
|
|
740
|
+
export declare type ISqliteValue = string | number | null | Uint8Array;
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* Candidate content for an allocated attempt. The payload must be supported
|
|
744
|
+
* Value data with a record or array root; the provenance is Resolution's
|
|
745
|
+
* versioned record; dependencies are exact references to completed results in
|
|
746
|
+
* the same store and scope that this execution consumed.
|
|
747
|
+
* @alpha
|
|
748
|
+
*/
|
|
749
|
+
export declare interface IStageRequest {
|
|
750
|
+
/** The allocated attempt to stage. */
|
|
751
|
+
readonly attemptId: number;
|
|
752
|
+
/** The author result data, copied into canonical MDS1 form. */
|
|
753
|
+
readonly payload: unknown;
|
|
754
|
+
/** Resolution's execution provenance for this attempt. */
|
|
755
|
+
readonly provenance: IVersionedRecord;
|
|
756
|
+
/** Exact completed results this execution depends on, in the caller's order. */
|
|
757
|
+
readonly dependencies: readonly ICompletedResultReference[];
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
/**
|
|
761
|
+
* The Value-owned meaning of a selected keyed projection, independent of its
|
|
762
|
+
* composition binding or collection policy.
|
|
763
|
+
* @alpha
|
|
764
|
+
*/
|
|
765
|
+
export declare interface IValueProjectionDescriptor {
|
|
766
|
+
/** Relative path from each member to the selected value. */
|
|
767
|
+
readonly address: readonly IAddressSegment[];
|
|
768
|
+
/** Projection content selects member values, never member identity or presence. */
|
|
769
|
+
readonly operation: 'value';
|
|
770
|
+
/** States whether all members were promised or only an exact visited subset was read. */
|
|
771
|
+
readonly traversal: IValueProjectionTraversal;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* A content fact whose caller-owned binding remains outside Value's encoding.
|
|
776
|
+
* @alpha
|
|
777
|
+
*/
|
|
778
|
+
export declare interface IValueProjectionFact {
|
|
779
|
+
/** Selection and coverage whose meaning governs every supplied member value. */
|
|
780
|
+
readonly descriptor: IValueProjectionDescriptor;
|
|
781
|
+
/** Unique collection-scoped keys paired with their selected content; key order is not ordered consumption evidence. */
|
|
782
|
+
readonly members: readonly IValueProjectionMember[];
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* One unique stable member key and the selected supported value for that member.
|
|
787
|
+
* @alpha
|
|
788
|
+
*/
|
|
789
|
+
export declare type IValueProjectionMember = readonly [key: string, value: unknown];
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* Coverage semantics for one keyed projection. Exhaustive coverage is a source
|
|
793
|
+
* promise; a visited traversal retains the exact ordered set of observed keys.
|
|
794
|
+
* @alpha
|
|
795
|
+
*/
|
|
796
|
+
export declare type IValueProjectionTraversal = {
|
|
797
|
+
readonly kind: 'exhaustive';
|
|
798
|
+
readonly complete: true;
|
|
799
|
+
} | {
|
|
800
|
+
readonly kind: 'visited';
|
|
801
|
+
readonly complete: false;
|
|
802
|
+
readonly keys: readonly string[];
|
|
803
|
+
};
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* A versioned record whose meaning another owner defines, such as
|
|
807
|
+
* Resolution's execution provenance, current acceptance evidence or an
|
|
808
|
+
* attempt's failure evidence. History validates only that the format tag is a
|
|
809
|
+
* non-empty string, the format version is a positive safe integer and the
|
|
810
|
+
* content is supported Value data; it stores the content in canonical MDS1
|
|
811
|
+
* form and returns it decoded and frozen, never interpreting it.
|
|
812
|
+
* @alpha
|
|
813
|
+
*/
|
|
814
|
+
export declare interface IVersionedRecord {
|
|
815
|
+
/** The owner-defined format identity, for example a Resolution schema name. */
|
|
816
|
+
readonly format: string;
|
|
817
|
+
/** The owner-defined positive safe-integer version of that format. */
|
|
818
|
+
readonly formatVersion: number;
|
|
819
|
+
/** Supported Value data; its meaning belongs to the format's owner. */
|
|
820
|
+
readonly content: unknown;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* A scoped subject narrowed to one compatibility group (REUSE-008): a positive
|
|
825
|
+
* safe integer chosen by the author per memoized step. Candidate lookup filters
|
|
826
|
+
* by it before Resolution validates current evidence.
|
|
827
|
+
* @alpha
|
|
828
|
+
*/
|
|
829
|
+
export declare interface IVersionedSubject extends IScopedSubject {
|
|
830
|
+
/** The positive safe-integer compatibility group. */
|
|
831
|
+
readonly version: number;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
/**
|
|
835
|
+
* The outcome of asking for the single logical writer. `held` reports an
|
|
836
|
+
* observed unexpired holder, not a failed compare-and-swap (PUB-005), and
|
|
837
|
+
* grants nothing.
|
|
838
|
+
* @alpha
|
|
839
|
+
*/
|
|
840
|
+
export declare type IWriterAcquisition = {
|
|
841
|
+
/** The caller now owns the store's writer lease. */
|
|
842
|
+
readonly kind: 'acquired';
|
|
843
|
+
/** The new lease with its freshly issued fence. */
|
|
844
|
+
readonly lease: IWriterLease;
|
|
845
|
+
} | {
|
|
846
|
+
/** Another unexpired holder owns the store. */
|
|
847
|
+
readonly kind: 'held';
|
|
848
|
+
/** The observed holder identity. */
|
|
849
|
+
readonly holder: string;
|
|
850
|
+
/** When that holder's lease expires, in History's clock domain. */
|
|
851
|
+
readonly expiresAt: number;
|
|
852
|
+
};
|
|
853
|
+
|
|
854
|
+
/** A request for the writer lease. @alpha */
|
|
855
|
+
export declare interface IWriterAcquisitionRequest {
|
|
856
|
+
/** The opaque non-empty identity of the prospective holder. */
|
|
857
|
+
readonly holder: string;
|
|
858
|
+
/** Positive safe-integer lease duration in milliseconds. */
|
|
859
|
+
readonly leaseMilliseconds: number;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* Proof of current single-logical-writer ownership. The holder is an opaque
|
|
864
|
+
* caller identity; the fence is the store-wide token issued at acquisition,
|
|
865
|
+
* which only increases; `expiresAt` is the lease boundary in History's
|
|
866
|
+
* clock domain (epoch milliseconds). Presenting a lease authorizes storage
|
|
867
|
+
* mutation only while holder, fence and unexpired lease still match the durable
|
|
868
|
+
* writer state; it never authorizes author execution.
|
|
869
|
+
* @alpha
|
|
870
|
+
*/
|
|
871
|
+
export declare interface IWriterLease {
|
|
872
|
+
/** The opaque identity that acquired the lease. */
|
|
873
|
+
readonly holder: string;
|
|
874
|
+
/** The fencing token issued for this acquisition. */
|
|
875
|
+
readonly fence: number;
|
|
876
|
+
/** The first effective time at which the lease is no longer valid. */
|
|
877
|
+
readonly expiresAt: number;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
/** Options for the isolated, non-durable test backend. @public */
|
|
881
|
+
export declare interface MemoryStoreOptions {
|
|
882
|
+
/** Metadata compatibility identifier; the initial store format uses sha256. */
|
|
883
|
+
fingerprintAlgorithm?: string;
|
|
884
|
+
/* Excluded from this release type: _onValueRead */
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
/** An update targeted a generation that has never been inserted. @public */
|
|
888
|
+
export declare class MissingRowError extends Error {
|
|
889
|
+
/** Identify an absent update target; updates never implicitly insert. @public */
|
|
890
|
+
constructor(message?: string);
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
/**
|
|
894
|
+
* Open (creating when empty) the durable History store for one logical store.
|
|
895
|
+
* The file is rejected before any work unless it is empty or holds exactly
|
|
896
|
+
* this schema version for this logical store.
|
|
897
|
+
* @alpha
|
|
898
|
+
*/
|
|
899
|
+
export declare function openDurableHistory(options: IDurableHistoryOptions): IDurableHistory;
|
|
900
|
+
|
|
901
|
+
/** Observable call outcomes; an unmemoized named execution has no storage key. @public */
|
|
902
|
+
export declare type Outcome = {
|
|
903
|
+
kind: 'served';
|
|
904
|
+
key: ResultKey;
|
|
905
|
+
generation: number;
|
|
906
|
+
} | {
|
|
907
|
+
kind: 'executed';
|
|
908
|
+
key: ResultKey;
|
|
909
|
+
generation: number;
|
|
910
|
+
} | {
|
|
911
|
+
kind: 'checked';
|
|
912
|
+
key: ResultKey;
|
|
913
|
+
wouldExecute: boolean;
|
|
914
|
+
divergence?: Divergence;
|
|
915
|
+
} | {
|
|
916
|
+
kind: 'refused';
|
|
917
|
+
key: ResultKey;
|
|
918
|
+
reason: unknown;
|
|
919
|
+
} | {
|
|
920
|
+
kind: 'failed';
|
|
921
|
+
key: ResultKey;
|
|
922
|
+
error: unknown;
|
|
923
|
+
} | {
|
|
924
|
+
kind: 'abandoned';
|
|
925
|
+
key: ResultKey;
|
|
926
|
+
reason: 'error' | 'lease-expired' | 'refused';
|
|
927
|
+
} | {
|
|
928
|
+
kind: 'ran';
|
|
929
|
+
};
|
|
930
|
+
|
|
931
|
+
/** A legacy row-storage address, not the future structured semantic path. @public */
|
|
932
|
+
export declare type Path = string;
|
|
933
|
+
|
|
934
|
+
/** Legacy persisted read rows; target observation encoding remains undecided. @public */
|
|
935
|
+
export declare type RecordedRead = {
|
|
936
|
+
kind: 'field';
|
|
937
|
+
arg: number;
|
|
938
|
+
path: Path;
|
|
939
|
+
fingerprint: Fingerprint;
|
|
940
|
+
} | {
|
|
941
|
+
kind: 'whole';
|
|
942
|
+
arg: number;
|
|
943
|
+
fingerprint: Fingerprint;
|
|
944
|
+
} | {
|
|
945
|
+
kind: 'memo';
|
|
946
|
+
key: ResultKey;
|
|
947
|
+
generation: number;
|
|
948
|
+
};
|
|
949
|
+
|
|
950
|
+
/** Complete storage tuple. Backends must preserve boundaries between all three parts. @public */
|
|
951
|
+
export declare type ResultKey = {
|
|
952
|
+
step: string;
|
|
953
|
+
revision: number;
|
|
954
|
+
subjectHash: string;
|
|
955
|
+
};
|
|
956
|
+
|
|
957
|
+
/**
|
|
958
|
+
* A presented writer lease no longer matches the durable holder, fence or
|
|
959
|
+
* unexpired lease, so the mutation was rejected with no change other than the
|
|
960
|
+
* observed clock high-water (PUB-002).
|
|
961
|
+
* @alpha
|
|
962
|
+
*/
|
|
963
|
+
export declare class StaleWriterError extends Error {
|
|
964
|
+
/** Create a stale-ownership rejection with a diagnostic message. */
|
|
965
|
+
constructor(message: string);
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
/**
|
|
969
|
+
* Storage mechanism for independent rows, with linearizable subject CAS.
|
|
970
|
+
* All inputs and returned rows are detached snapshots: caller mutation cannot
|
|
971
|
+
* alter persisted data. Values may only change by inserting another generation.
|
|
972
|
+
* There is no transaction spanning these methods; callers must not infer atomic
|
|
973
|
+
* claim/generation publication from the per-row CAS guarantee.
|
|
974
|
+
* @public
|
|
975
|
+
*/
|
|
976
|
+
export declare interface Store {
|
|
977
|
+
/** Return detached format metadata; opening code must reject algorithm mismatches. */
|
|
978
|
+
meta(): Promise<StoreMetadata>;
|
|
979
|
+
/** Read a detached subject snapshot, or undefined for an absent tuple. */
|
|
980
|
+
getSubject(key: ResultKey): Promise<SubjectRow | undefined>;
|
|
981
|
+
/** Insert only; duplicate tuples reject, as do versions outside safe integers. */
|
|
982
|
+
putSubject(row: SubjectRow): Promise<void>;
|
|
983
|
+
/**
|
|
984
|
+
* Atomically apply a shallow column patch only when the stored version matches.
|
|
985
|
+
* Success increments that version once, even for an empty patch; a missing or
|
|
986
|
+
* stale row returns false without changes. Key/version properties reject at
|
|
987
|
+
* runtime, including extras passed from untyped JavaScript callers.
|
|
988
|
+
* An exhausted MAX_SAFE_INTEGER version rejects rather than reporting success
|
|
989
|
+
* without advancing the token. Neither rejection changes the stored row.
|
|
990
|
+
*/
|
|
991
|
+
casSubject(key: ResultKey, expectedVersion: number, patch: SubjectPatch): Promise<boolean>;
|
|
992
|
+
/** Read a detached generation, or undefined for an absent tuple. */
|
|
993
|
+
getGeneration(key: ResultKey, generation: number): Promise<GenerationRow | undefined>;
|
|
994
|
+
/** Return detached rows for exactly this complete key; ordering is unspecified. */
|
|
995
|
+
listGenerations(key: ResultKey): Promise<GenerationRow[]>;
|
|
996
|
+
/** Insert only; generation numbers are supplied, never allocated by storage. */
|
|
997
|
+
putGeneration(row: GenerationRow): Promise<void>;
|
|
998
|
+
/** Patch an existing row; missing tuples and attempts to change its key reject. */
|
|
999
|
+
updateGeneration(key: ResultKey, generation: number, patch: GenerationPatch): Promise<void>;
|
|
1000
|
+
/**
|
|
1001
|
+
* Insert an atomic batch of immutable fields. Duplicate addresses, within the
|
|
1002
|
+
* batch or already stored, reject the whole batch without inserting anything.
|
|
1003
|
+
* This proposed storage refinement enforces retained-value immutability.
|
|
1004
|
+
*/
|
|
1005
|
+
putFields(rows: FieldRow[]): Promise<void>;
|
|
1006
|
+
/** Return requested field snapshots; absent paths are omitted. */
|
|
1007
|
+
getFields(key: ResultKey, generation: number, paths: Path[]): Promise<FieldRow[]>;
|
|
1008
|
+
/** Return requested fingerprints without reading/deserializing any field value. */
|
|
1009
|
+
getFingerprints(key: ResultKey, generation: number, paths: Path[]): Promise<Map<Path, Fingerprint>>;
|
|
1010
|
+
/**
|
|
1011
|
+
* Query leases strictly less than now, oldest first, with at most limit rows.
|
|
1012
|
+
* Zero limit returns no rows. This query never sweeps or changes a claim.
|
|
1013
|
+
*/
|
|
1014
|
+
expiredClaims(now: number, limit: number): Promise<SubjectRow[]>;
|
|
1015
|
+
/** Release resources owned by this store. */
|
|
1016
|
+
close(): Promise<void>;
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
/**
|
|
1020
|
+
* Register reusable backend qualification tests for SA-1 through SA-7.
|
|
1021
|
+
* Register this from a Jest test module; the suite imports no concrete backend.
|
|
1022
|
+
* Mutation tests enforce rev 9's retained-value isolation at the storage seam.
|
|
1023
|
+
* This suite does not assert atomicity across subject, generation, and field rows:
|
|
1024
|
+
* the supplied Store contract does not provide that operation.
|
|
1025
|
+
* @public
|
|
1026
|
+
*/
|
|
1027
|
+
export declare function storeConformance(name: string, options: StoreConformanceOptions): void;
|
|
1028
|
+
|
|
1029
|
+
/**
|
|
1030
|
+
* Opens a fresh store for each test. The optional algorithm models persisted metadata
|
|
1031
|
+
* at open time; factories must reject a mismatch with their runtime algorithm.
|
|
1032
|
+
* Instrumentation is optional for third-party backends, but both shipped backends
|
|
1033
|
+
* must provide it to qualify SA-3 without relying on wall-clock timing.
|
|
1034
|
+
* @public
|
|
1035
|
+
*/
|
|
1036
|
+
export declare interface StoreConformanceOptions {
|
|
1037
|
+
create(options?: {
|
|
1038
|
+
fingerprintAlgorithm?: string;
|
|
1039
|
+
}): Store | Promise<Store>;
|
|
1040
|
+
fingerprintAlgorithm: string;
|
|
1041
|
+
probeValueReads?(store: Store): ValueReadProbe;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
/** Persisted format identifiers, checked before using a store's fingerprints. @public */
|
|
1045
|
+
export declare interface StoreMetadata {
|
|
1046
|
+
schemaVersion: number;
|
|
1047
|
+
fingerprintAlgorithm: string;
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
/** Legacy row subject shape; future author-supplied subject identity is separate. @public */
|
|
1051
|
+
export declare type Subject = Extract<Identity, {
|
|
1052
|
+
kind: 'step';
|
|
1053
|
+
}>;
|
|
1054
|
+
|
|
1055
|
+
/** Writable subject columns; the complete key and CAS token cannot be patched. @public */
|
|
1056
|
+
export declare type SubjectPatch = Partial<Omit<SubjectRow, 'key' | 'version'>>;
|
|
1057
|
+
|
|
1058
|
+
/**
|
|
1059
|
+
* One compare-and-set row per complete result key. Repository owns generation
|
|
1060
|
+
* meaning; claim owns lease meaning. Storage only preserves and patches columns.
|
|
1061
|
+
* @public
|
|
1062
|
+
*/
|
|
1063
|
+
export declare interface SubjectRow {
|
|
1064
|
+
key: ResultKey;
|
|
1065
|
+
subject: Subject;
|
|
1066
|
+
/** Nonnegative safe-integer CAS token, incremented once per successful CAS. */
|
|
1067
|
+
version: number;
|
|
1068
|
+
currentGeneration: number | null;
|
|
1069
|
+
claim: null | {
|
|
1070
|
+
generation: number;
|
|
1071
|
+
holder: string;
|
|
1072
|
+
leaseUntil: number;
|
|
1073
|
+
progress: {
|
|
1074
|
+
fingerprint: Fingerprint;
|
|
1075
|
+
value: unknown;
|
|
1076
|
+
} | null;
|
|
1077
|
+
};
|
|
1078
|
+
durations: number[];
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
/**
|
|
1082
|
+
* A backend's test-only counter at its actual value-read/deserialization boundary.
|
|
1083
|
+
* The suite resets it after insertion and verifies a positive control with getFields.
|
|
1084
|
+
* @public
|
|
1085
|
+
*/
|
|
1086
|
+
export declare interface ValueReadProbe {
|
|
1087
|
+
reset(): void;
|
|
1088
|
+
count(): number;
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
export { }
|