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