@sorbetai/runtime 0.0.0-stage → 0.1.0-alpha.16
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/LICENSE +21 -0
- package/README.md +87 -2
- package/dist/contracts-CFmBr0LI.d.ts +12107 -0
- package/dist/index.d.ts +4230 -0
- package/dist/index.js +12915 -0
- package/dist/index.js.map +1 -0
- package/dist/node.d.ts +200 -0
- package/dist/node.js +1878 -0
- package/dist/node.js.map +1 -0
- package/dist/observation-DyvvxD35.js +2713 -0
- package/dist/observation-DyvvxD35.js.map +1 -0
- package/package.json +52 -3
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { $ as UnitReader, At as JournalWrite, Ct as JournalPage, Et as JournalStore, G as UnitFact, O as RuntimeObservationPort, Ot as JournalSubscription, Tt as JournalReadOptions, V as OpenedUnitStore, X as UnitOpenOptions, Y as UnitInspectionPage, at as JournalRecoveryFact, bt as JournalFact, ht as JournalAppendOptions, kt as JournalSubscriptionOptions, tt as UnitStore } from "./contracts-CFmBr0LI.js";
|
|
2
|
+
import * as s from "@earendil-works/pi-schema";
|
|
3
|
+
import "@sorbetai/schema";
|
|
4
|
+
import "@sorbetai/context";
|
|
5
|
+
import { ArtifactRef, ArtifactStore } from "@sorbetai/artifacts";
|
|
6
|
+
|
|
7
|
+
//#region src/journal/jsonl-store.d.ts
|
|
8
|
+
interface JsonlJournalStoreOptions {
|
|
9
|
+
readonly observation?: RuntimeObservationPort;
|
|
10
|
+
readonly artifactStore?: ArtifactStore;
|
|
11
|
+
readonly inlineStringBytes?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Reads a synchronized complete-frame prefix without acquiring writer ownership or
|
|
15
|
+
* repairing a torn tail. By default, visibility does not imply durability.
|
|
16
|
+
* `sync` flushes the same open file after reading its fixed byte prefix and fails if
|
|
17
|
+
* flushing is unavailable. It requires write access but never changes file bytes.
|
|
18
|
+
* This establishes file durability, not acknowledgement by the source writer;
|
|
19
|
+
* directory durability and filesystem guarantees remain platform-dependent.
|
|
20
|
+
*/
|
|
21
|
+
declare function readJsonlJournal(filePath: string, options?: Pick<JsonlJournalStoreOptions, 'artifactStore'> & {
|
|
22
|
+
readonly durability?: 'observed' | 'sync';
|
|
23
|
+
}): Promise<readonly JournalFact[]>;
|
|
24
|
+
interface JsonlJournalReaderOptions extends Pick<JsonlJournalStoreOptions, 'artifactStore'> {
|
|
25
|
+
readonly durability?: 'observed' | 'sync';
|
|
26
|
+
/** History (default) detects duplicate fact IDs across the whole prefix. Page retention
|
|
27
|
+
* bounds forward-only diagnostic memory independently of history length; it detects
|
|
28
|
+
* duplicates only within each page and does not certify global identity uniqueness. */
|
|
29
|
+
readonly indexRetention?: 'history' | 'page';
|
|
30
|
+
/** Bounds the retained identity/offset index; exceeding it fails without advancing the cursor. */
|
|
31
|
+
readonly maxIndexedFacts?: number;
|
|
32
|
+
/** UTF-8 cursor bytes plus 64 charged bytes per locator/frame; not an OS heap measurement. */
|
|
33
|
+
readonly maxIndexedBytes?: number;
|
|
34
|
+
}
|
|
35
|
+
interface JsonlJournalIncrementalPage extends JournalPage {
|
|
36
|
+
readonly sessionId?: string;
|
|
37
|
+
readonly throughSequence: number;
|
|
38
|
+
readonly fileBytes: number;
|
|
39
|
+
readonly indexedFacts: number;
|
|
40
|
+
readonly indexedBytes: number;
|
|
41
|
+
readonly incompleteTail: boolean;
|
|
42
|
+
readonly durability: 'observed' | 'sync';
|
|
43
|
+
}
|
|
44
|
+
interface JsonlJournalRecoveryPage extends Omit<JsonlJournalIncrementalPage, 'facts'> {
|
|
45
|
+
/** Validated lifecycle identities; payload content and artifact availability are unverified. */
|
|
46
|
+
readonly facts: readonly JournalRecoveryFact[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Incremental read-only observer of an append-only file. Complete historical frames
|
|
50
|
+
* must remain immutable. No writer lease, tail repair or execution recovery occurs.
|
|
51
|
+
* Atomic frames may exceed the requested fact limit by at most one frame. Call close()
|
|
52
|
+
* to release its bounded identity/offset index. Replacement/truncation requires a new
|
|
53
|
+
* reader; an incomplete tail remains unread until it forms a complete valid frame.
|
|
54
|
+
*/
|
|
55
|
+
declare class JsonlJournalReader {
|
|
56
|
+
#private;
|
|
57
|
+
private constructor();
|
|
58
|
+
static open(filePath: string, options?: JsonlJournalReaderOptions): Promise<JsonlJournalReader>;
|
|
59
|
+
read(options?: {
|
|
60
|
+
readonly limit?: number;
|
|
61
|
+
}): Promise<JsonlJournalIncrementalPage>;
|
|
62
|
+
/** Reads lifecycle identities without hydrating any externalized content. This
|
|
63
|
+
* validates frames, positions and required recovery IDs, not full payload health.
|
|
64
|
+
* Externalized correlation IDs are unavailable rather than guessed. The frame
|
|
65
|
+
* ceiling bounds inline JSON before decoding and preserves bytes/cursor on failure. */
|
|
66
|
+
readRecovery(options?: {
|
|
67
|
+
readonly limit?: number;
|
|
68
|
+
readonly maxFrameBytes?: number;
|
|
69
|
+
/** Aggregate UTF-8 lifecycle identities per fact; defaults to 1 KiB. */
|
|
70
|
+
readonly maxIdentityBytes?: number;
|
|
71
|
+
readonly signal?: AbortSignal;
|
|
72
|
+
}): Promise<JsonlJournalRecoveryPage>;
|
|
73
|
+
close(): Promise<void>;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* File-backed, single-session Journal with durable append-before-apply semantics.
|
|
77
|
+
* The store holds exclusive writer ownership from open through close. Reopen
|
|
78
|
+
* validates physical frames and rebuilds an offset ledger; reads decode typed
|
|
79
|
+
* payloads from their source frames.
|
|
80
|
+
*/
|
|
81
|
+
declare class JsonlJournalStore implements JournalStore {
|
|
82
|
+
#private;
|
|
83
|
+
private constructor();
|
|
84
|
+
static open(filePath: string, options?: JsonlJournalStoreOptions): Promise<JsonlJournalStore>;
|
|
85
|
+
get filePath(): string;
|
|
86
|
+
get sessionId(): string | undefined;
|
|
87
|
+
appendBatch(inputs: readonly [JournalWrite, ...JournalWrite[]], options: JournalAppendOptions): Promise<void>;
|
|
88
|
+
append(input: JournalWrite, options: JournalAppendOptions): Promise<void>;
|
|
89
|
+
read(sessionId: string, options?: JournalReadOptions): Promise<JournalPage>;
|
|
90
|
+
subscribe(sessionId: string, options?: JournalSubscriptionOptions): JournalSubscription;
|
|
91
|
+
close(): Promise<void>;
|
|
92
|
+
}
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/journal/writer-lease.d.ts
|
|
95
|
+
interface JournalWriterLease {
|
|
96
|
+
release(): void;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Excludes legacy writers while an offline importer reads their immutable prefix.
|
|
100
|
+
* Acquiring creates only the mutex file; it never repairs or creates the Journal.
|
|
101
|
+
* The parent directory must exist. Release after all source reads have completed.
|
|
102
|
+
*/
|
|
103
|
+
declare function acquireJournalWriterLease(journalFilePath: string): Promise<JournalWriterLease>;
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region src/journal/offloaded-fact.d.ts
|
|
106
|
+
/**
|
|
107
|
+
* Bounded least-recently-used memory of published payload strings. One Tool result is
|
|
108
|
+
* recorded as several facts (Effect, Signal, Task settlement), so the same body would
|
|
109
|
+
* otherwise be published as a separate Artifact for every fact that mentions it.
|
|
110
|
+
*/
|
|
111
|
+
declare class ExternalizedStringReuse {
|
|
112
|
+
#private;
|
|
113
|
+
readonly maxBytes: number;
|
|
114
|
+
constructor(maxBytes?: number);
|
|
115
|
+
take(text: string): ArtifactRef | undefined;
|
|
116
|
+
remember(text: string, ref: ArtifactRef): void;
|
|
117
|
+
}
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/journal/unit/frame.d.ts
|
|
120
|
+
|
|
121
|
+
interface UnitEncodingOptions {
|
|
122
|
+
readonly artifactStore?: ArtifactStore;
|
|
123
|
+
readonly inlineStringBytes?: number;
|
|
124
|
+
readonly stringReuse?: ExternalizedStringReuse;
|
|
125
|
+
}
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/journal/unit/jsonl.d.ts
|
|
128
|
+
interface JsonlUnitStoreOptions extends UnitEncodingOptions {
|
|
129
|
+
readonly filePath: string;
|
|
130
|
+
readonly unitId: string;
|
|
131
|
+
}
|
|
132
|
+
/** One tree per file. Fact bodies stay on disk; the opened store indexes frame positions. */
|
|
133
|
+
declare class JsonlUnitStore implements UnitStore {
|
|
134
|
+
#private;
|
|
135
|
+
constructor(options: JsonlUnitStoreOptions);
|
|
136
|
+
/** Diagnostic scan with a transaction decoding budget; never claims a writer. */
|
|
137
|
+
inspect(options?: {
|
|
138
|
+
readonly sessionId?: string;
|
|
139
|
+
readonly signal?: AbortSignal;
|
|
140
|
+
readonly unitKinds?: readonly UnitFact['kind'][];
|
|
141
|
+
}): AsyncGenerator<UnitInspectionPage>;
|
|
142
|
+
/** Complete lifecycle scan without diagnostic budgets or historical content hydration. */
|
|
143
|
+
readRecovery(options: {
|
|
144
|
+
readonly sessionId: string;
|
|
145
|
+
readonly signal?: AbortSignal;
|
|
146
|
+
}): AsyncGenerator<UnitInspectionPage>;
|
|
147
|
+
open(options?: UnitOpenOptions): Promise<OpenedUnitStore>;
|
|
148
|
+
/**
|
|
149
|
+
* Pins a complete observed prefix without writer ownership or tail repair.
|
|
150
|
+
* `sync` persists that prefix before returning, for forks that must outlive source loss.
|
|
151
|
+
*/
|
|
152
|
+
openReader(options?: {
|
|
153
|
+
readonly durability?: 'observed' | 'sync';
|
|
154
|
+
}): Promise<UnitReader>;
|
|
155
|
+
}
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/journal/unit/seal.d.ts
|
|
158
|
+
declare const SealedUnitManifestSchema: s.Schema<{
|
|
159
|
+
format: "sorbet.unit.sealed";
|
|
160
|
+
storageVersion: 1;
|
|
161
|
+
codec: "brotli";
|
|
162
|
+
journalBytes: number;
|
|
163
|
+
sealedBytes: number;
|
|
164
|
+
sealedAt: string;
|
|
165
|
+
}>;
|
|
166
|
+
type SealedUnitManifest = s.Static<typeof SealedUnitManifestSchema>;
|
|
167
|
+
/**
|
|
168
|
+
* A sealed Unit keeps the complete committed Journal in one irreversible encoding. Nothing is
|
|
169
|
+
* dropped: sealing compresses the exact committed bytes, and unsealing restores them byte for
|
|
170
|
+
* byte. `unit.jsonl` stays authoritative while it exists, so an interrupted seal is repaired by
|
|
171
|
+
* discarding the incomplete seal rather than by trusting it.
|
|
172
|
+
*/
|
|
173
|
+
interface SealedUnitLayout {
|
|
174
|
+
readonly journalPath: string;
|
|
175
|
+
readonly sealedPath: string;
|
|
176
|
+
readonly manifestPath: string;
|
|
177
|
+
}
|
|
178
|
+
declare function sealedUnitLayout(journalPath: string): SealedUnitLayout;
|
|
179
|
+
declare function readSealedUnitManifest(journalPath: string): Promise<SealedUnitManifest | undefined>;
|
|
180
|
+
declare function isUnitSealed(journalPath: string): Promise<boolean>;
|
|
181
|
+
interface SealUnitResult {
|
|
182
|
+
readonly manifest: SealedUnitManifest;
|
|
183
|
+
readonly journalBytes: number;
|
|
184
|
+
readonly sealedBytes: number;
|
|
185
|
+
}
|
|
186
|
+
/** Compresses a closed Unit's committed Journal and verifies the result before replacing it. */
|
|
187
|
+
declare function sealUnit(journalPath: string, options?: {
|
|
188
|
+
readonly now?: () => Date;
|
|
189
|
+
}): Promise<SealUnitResult>;
|
|
190
|
+
/** Restores a sealed Unit to its exact committed bytes. A present Journal wins over any seal. */
|
|
191
|
+
declare function unsealUnit(journalPath: string, options?: {
|
|
192
|
+
readonly discardJournal?: boolean;
|
|
193
|
+
}): Promise<{
|
|
194
|
+
readonly restored: boolean;
|
|
195
|
+
}>;
|
|
196
|
+
/** Removes a seal that cannot be trusted because the Journal it describes is still present. */
|
|
197
|
+
declare function discardIncompleteSeal(journalPath: string): Promise<void>;
|
|
198
|
+
//#endregion
|
|
199
|
+
export { JournalWriterLease, JsonlJournalIncrementalPage, JsonlJournalReader, JsonlJournalReaderOptions, JsonlJournalRecoveryPage, JsonlJournalStore, JsonlJournalStoreOptions, JsonlUnitStore, JsonlUnitStoreOptions, SealUnitResult, SealedUnitLayout, SealedUnitManifest, acquireJournalWriterLease, discardIncompleteSeal, isUnitSealed, readJsonlJournal, readSealedUnitManifest, sealUnit, sealedUnitLayout, unsealUnit };
|
|
200
|
+
//# sourceMappingURL=node.d.ts.map
|