@superbee/core 0.2.0-pre.3 → 0.2.0-pre.4
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/dist/governed-body-write.d.ts +99 -0
- package/dist/governed-body-write.d.ts.map +1 -0
- package/dist/governed-body-write.js +244 -0
- package/dist/governed-body-write.js.map +1 -0
- package/dist/index.d.ts +9 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/indexeddb-backend.d.ts +4 -5
- package/dist/indexeddb-backend.d.ts.map +1 -1
- package/dist/indexeddb-backend.js +211 -113
- package/dist/indexeddb-backend.js.map +1 -1
- package/dist/journaled-backend.d.ts +85 -8
- package/dist/journaled-backend.d.ts.map +1 -1
- package/dist/journaled-backend.js +198 -5
- package/dist/journaled-backend.js.map +1 -1
- package/dist/remote-backend.d.ts +9 -54
- package/dist/remote-backend.d.ts.map +1 -1
- package/dist/remote-backend.js +13 -173
- package/dist/remote-backend.js.map +1 -1
- package/dist/remote-error.d.ts +22 -0
- package/dist/remote-error.d.ts.map +1 -0
- package/dist/remote-error.js +29 -0
- package/dist/remote-error.js.map +1 -0
- package/dist/remote-parsers.d.ts +86 -0
- package/dist/remote-parsers.d.ts.map +1 -0
- package/dist/remote-parsers.js +181 -0
- package/dist/remote-parsers.js.map +1 -0
- package/dist/remote.d.ts +5 -2
- package/dist/remote.d.ts.map +1 -1
- package/dist/remote.js +5 -1
- package/dist/remote.js.map +1 -1
- package/dist/uncertain-write.d.ts +4 -2
- package/dist/uncertain-write.d.ts.map +1 -1
- package/dist/uncertain-write.js +6 -3
- package/dist/uncertain-write.js.map +1 -1
- package/package.json +5 -1
|
@@ -32,9 +32,10 @@
|
|
|
32
32
|
* holding intent between the refusal and the rewrite.
|
|
33
33
|
* - `resolveIntents` on either journaled mutation requires document CAS and the exact complete
|
|
34
34
|
* unsettled target journal. It retires those records atomically with the document, meta, and
|
|
35
|
-
* optional replacement intent, leaving acknowledged history untouched. Recovery may retire
|
|
36
|
-
*
|
|
37
|
-
*
|
|
35
|
+
* optional replacement intent, leaving acknowledged history untouched. Recovery may retire a
|
|
36
|
+
* chain whose head is a recorded conflict or refusal, with conflicted, refused, and
|
|
37
|
+
* never-attempted pending successors behind it, never uncertain delivery. The caller
|
|
38
|
+
* preserves recovery evidence in meta; retirement does not assert remote acceptance.
|
|
38
39
|
* - {@link JournaledBackend.readWithJournal} is ONE snapshot: the document, every intent
|
|
39
40
|
* targeting it, and the named meta rows, read in one readonly transaction, so a write in
|
|
40
41
|
* another realm between separate reads can never show a caller a document of one moment
|
|
@@ -55,6 +56,71 @@
|
|
|
55
56
|
*/
|
|
56
57
|
import type { OperationIntent, OperationState } from "./uncertain-write.js";
|
|
57
58
|
import type { ConceptId, DeleteOptions, OkfDocument, ReadResult, StorageBackend, Version, WriteOptions } from "./types.js";
|
|
59
|
+
/** Presence is independent of value: a stored undefined is not an absent row. */
|
|
60
|
+
export type MetaExpectation = {
|
|
61
|
+
present: false;
|
|
62
|
+
} | {
|
|
63
|
+
present: true;
|
|
64
|
+
value: unknown;
|
|
65
|
+
};
|
|
66
|
+
/** A complete target snapshot and the explicitly named metadata premises for a mutation. */
|
|
67
|
+
export interface JournalGuard {
|
|
68
|
+
target: ConceptId;
|
|
69
|
+
document: {
|
|
70
|
+
version: Version;
|
|
71
|
+
raw: string;
|
|
72
|
+
} | null;
|
|
73
|
+
intents: IntentRecord[];
|
|
74
|
+
meta: {
|
|
75
|
+
key: string;
|
|
76
|
+
expected: MetaExpectation;
|
|
77
|
+
}[];
|
|
78
|
+
}
|
|
79
|
+
/** A full snapshot or metadata admission premise changed; nothing was written. */
|
|
80
|
+
export declare class JournalGuardConflict extends Error {
|
|
81
|
+
readonly name = "JournalGuardConflict";
|
|
82
|
+
readonly target: string;
|
|
83
|
+
constructor(target: string);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Guard values are acyclic plain records, arrays, and primitive values (including undefined).
|
|
87
|
+
* Symbols, accessors, functions, and objects with other prototypes are refused. This restriction
|
|
88
|
+
* applies only to guarded operations; the unguarded metadata store remains opaque.
|
|
89
|
+
*/
|
|
90
|
+
export declare function captureJournalValue<T>(value: T): T;
|
|
91
|
+
export declare function captureJournalGuard(value: JournalGuard, target?: ConceptId): JournalGuard;
|
|
92
|
+
/** Only omission or undefined selects the unguarded compatibility path. */
|
|
93
|
+
export declare function captureJournalGuardOption(options: {
|
|
94
|
+
guard?: JournalGuard;
|
|
95
|
+
}, target?: ConceptId): JournalGuard | undefined;
|
|
96
|
+
/** Compare all target records, including acknowledged history, and exact named row presence. */
|
|
97
|
+
export declare function assertJournalGuard(expected: JournalGuard, current: JournalGuard): void;
|
|
98
|
+
export interface IntentUpdateOptions {
|
|
99
|
+
meta?: MetaRecord[];
|
|
100
|
+
guard?: JournalGuard;
|
|
101
|
+
/** Replaces persisted content without authoring metadata changes; requires a full guard. */
|
|
102
|
+
document?: OkfDocument;
|
|
103
|
+
}
|
|
104
|
+
export interface MetaWriteOptions {
|
|
105
|
+
expected?: MetaExpectation;
|
|
106
|
+
/** Admission succeeds only when the entire journal is empty, in the same transaction. */
|
|
107
|
+
requireEmptyJournal?: boolean;
|
|
108
|
+
}
|
|
109
|
+
/** Capture guarded updates before any asynchronous adapter work and protect original history. */
|
|
110
|
+
export declare function captureIntentUpdate(patch: IntentPatch, options: IntentUpdateOptions): {
|
|
111
|
+
patch: IntentPatch;
|
|
112
|
+
options: IntentUpdateOptions;
|
|
113
|
+
};
|
|
114
|
+
export declare function captureMetaWrite(options: MetaWriteOptions): MetaWriteOptions;
|
|
115
|
+
export declare function assertMetaWrite(key: string, options: MetaWriteOptions, actual: MetaExpectation, intents: readonly IntentRecord[]): void;
|
|
116
|
+
/** Metadata removal is admitted only with an explicit full-snapshot premise. */
|
|
117
|
+
export declare function assertJournalMetaChanges(guard: JournalGuard | undefined, puts: readonly MetaRecord[], removals: readonly string[] | undefined): void;
|
|
118
|
+
/** A guarded write owns one target and creates a globally fresh journal identity. */
|
|
119
|
+
export declare function assertJournalIntentChanges(guard: JournalGuard | undefined, existingIdentity: IntentRecord | undefined, superseded: IntentRecord | undefined): void;
|
|
120
|
+
/** Capture write options while retaining the existing synchronous metadata producer. */
|
|
121
|
+
export declare function captureJournalWriteOptions(options: JournaledWriteOptions): JournaledWriteOptions;
|
|
122
|
+
/** Capture every guarded deletion branch before evaluating held or absent state. */
|
|
123
|
+
export declare function captureJournalDeleteOptions(target: ConceptId, options: JournaledDeleteOptions): JournaledDeleteOptions;
|
|
58
124
|
/**
|
|
59
125
|
* An intent's journal state was not the one the caller expected, or the intent is gone. Settling
|
|
60
126
|
* and superseding are compare-and-swap operations on the intent's own record so two realms (a
|
|
@@ -119,10 +185,19 @@ export declare class JournalSnapshotConflict extends Error {
|
|
|
119
185
|
constructor(target: ConceptId);
|
|
120
186
|
}
|
|
121
187
|
export declare function assertJournalResolutionOptions(target: ConceptId, options: JournaledWriteOptions | JournaledDeleteOptions): void;
|
|
122
|
-
/**
|
|
188
|
+
/**
|
|
189
|
+
* Compare full records, not only state: a changed outcome or retry is new recovery evidence.
|
|
190
|
+
* The head of the set (its lowest sequence) must hold a recorded terminal answer, `conflict` or
|
|
191
|
+
* `refused`; every later row must be `conflict`, `refused` or never-attempted `pending`. An
|
|
192
|
+
* `unknown`, `in_flight` or attempted `pending` head is uncertain delivery and stays refused.
|
|
193
|
+
*/
|
|
123
194
|
export declare function assertJournalSnapshot(target: ConceptId, expected: IntentRecord[], current: IntentRecord[], freshRequestId?: string): void;
|
|
124
195
|
/** Options for {@link JournaledBackend.writeJournaled}. */
|
|
125
196
|
export interface JournaledWriteOptions extends WriteOptions {
|
|
197
|
+
/** Full document, journal, and named metadata CAS, evaluated before any mutation. */
|
|
198
|
+
guard?: JournalGuard;
|
|
199
|
+
/** Remove named metadata in the guarded write; keys must not also be put by this write. */
|
|
200
|
+
removeMeta?: readonly string[];
|
|
126
201
|
/** Retire this exact complete unsettled target snapshot atomically with document and meta writes. */
|
|
127
202
|
resolveIntents?: {
|
|
128
203
|
expected: IntentRecord[];
|
|
@@ -150,6 +225,8 @@ export interface JournaledWriteOptions extends WriteOptions {
|
|
|
150
225
|
}
|
|
151
226
|
/** Options for {@link JournaledBackend.deleteJournaled}. */
|
|
152
227
|
export interface JournaledDeleteOptions extends DeleteOptions {
|
|
228
|
+
/** Compare the full target and named metadata before any deleted, absent, or held outcome. */
|
|
229
|
+
guard?: JournalGuard;
|
|
153
230
|
/** As write recovery; requires document CAS even when the target is absent. */
|
|
154
231
|
resolveIntents?: {
|
|
155
232
|
expected: IntentRecord[];
|
|
@@ -208,6 +285,8 @@ export type IntentPatch = Partial<Omit<IntentRecord, "requestId" | "sequence" |
|
|
|
208
285
|
* rows, with the transaction and compare-and-swap guarantees stated in this module's header.
|
|
209
286
|
*/
|
|
210
287
|
export interface JournaledBackend extends StorageBackend {
|
|
288
|
+
/** All guarded writes, updates, replacements, and metadata admission share atomic CAS. */
|
|
289
|
+
readonly journalSnapshotCas?: true;
|
|
211
290
|
/**
|
|
212
291
|
* One transaction over documents, intents, and meta: the document compare-and-swap of
|
|
213
292
|
* `write`, plus (optionally) deleting a superseded intent, recording a new intent for the
|
|
@@ -251,10 +330,8 @@ export interface JournaledBackend extends StorageBackend {
|
|
|
251
330
|
* `expectedState`, together with any meta rows, in one transaction. A different state or a
|
|
252
331
|
* missing record rejects with {@link IntentStateConflict} and writes nothing.
|
|
253
332
|
*/
|
|
254
|
-
updateIntent(requestId: string, expectedState: OperationState, patch: IntentPatch, options?:
|
|
255
|
-
meta?: MetaRecord[];
|
|
256
|
-
}): Promise<IntentRecord>;
|
|
333
|
+
updateIntent(requestId: string, expectedState: OperationState, patch: IntentPatch, options?: IntentUpdateOptions): Promise<IntentRecord>;
|
|
257
334
|
readMeta<T = unknown>(key: string): Promise<T | undefined>;
|
|
258
|
-
writeMeta(key: string, value: unknown): Promise<void>;
|
|
335
|
+
writeMeta(key: string, value: unknown, options?: MetaWriteOptions): Promise<void>;
|
|
259
336
|
}
|
|
260
337
|
//# sourceMappingURL=journaled-backend.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"journaled-backend.d.ts","sourceRoot":"","sources":["../src/journaled-backend.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"journaled-backend.d.ts","sourceRoot":"","sources":["../src/journaled-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG3H,iFAAiF;AACjF,MAAM,MAAM,eAAe,GAAG;IAAE,OAAO,EAAE,KAAK,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAErF,4FAA4F;AAC5F,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,SAAS,CAAC;IAClB,QAAQ,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACnD,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,eAAe,CAAA;KAAE,EAAE,CAAC;CACpD;AAED,kFAAkF;AAClF,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,SAAkB,IAAI,0BAA0B;IAChD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBACZ,MAAM,EAAE,MAAM;CAI3B;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAA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AC,CAAC;IAEzF,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC,CAAC;IAEjE;;;;OAIG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAEzI,QAAQ,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAE3D,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnF"}
|
|
@@ -32,9 +32,10 @@
|
|
|
32
32
|
* holding intent between the refusal and the rewrite.
|
|
33
33
|
* - `resolveIntents` on either journaled mutation requires document CAS and the exact complete
|
|
34
34
|
* unsettled target journal. It retires those records atomically with the document, meta, and
|
|
35
|
-
* optional replacement intent, leaving acknowledged history untouched. Recovery may retire
|
|
36
|
-
*
|
|
37
|
-
*
|
|
35
|
+
* optional replacement intent, leaving acknowledged history untouched. Recovery may retire a
|
|
36
|
+
* chain whose head is a recorded conflict or refusal, with conflicted, refused, and
|
|
37
|
+
* never-attempted pending successors behind it, never uncertain delivery. The caller
|
|
38
|
+
* preserves recovery evidence in meta; retirement does not assert remote acceptance.
|
|
38
39
|
* - {@link JournaledBackend.readWithJournal} is ONE snapshot: the document, every intent
|
|
39
40
|
* targeting it, and the named meta rows, read in one readonly transaction, so a write in
|
|
40
41
|
* another realm between separate reads can never show a caller a document of one moment
|
|
@@ -53,6 +54,192 @@
|
|
|
53
54
|
* the shipping implementation; a test-only in-memory adapter proves the seam is not a
|
|
54
55
|
* description of that one class.
|
|
55
56
|
*/
|
|
57
|
+
import { assertSafeConceptId } from "./paths.js";
|
|
58
|
+
/** A full snapshot or metadata admission premise changed; nothing was written. */
|
|
59
|
+
export class JournalGuardConflict extends Error {
|
|
60
|
+
name = "JournalGuardConflict";
|
|
61
|
+
target;
|
|
62
|
+
constructor(target) {
|
|
63
|
+
super(`journal guard for '${target}' does not match or is invalid`);
|
|
64
|
+
this.target = target;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Guard values are acyclic plain records, arrays, and primitive values (including undefined).
|
|
69
|
+
* Symbols, accessors, functions, and objects with other prototypes are refused. This restriction
|
|
70
|
+
* applies only to guarded operations; the unguarded metadata store remains opaque.
|
|
71
|
+
*/
|
|
72
|
+
export function captureJournalValue(value) {
|
|
73
|
+
const ancestors = new Set();
|
|
74
|
+
const check = (entry) => {
|
|
75
|
+
if (typeof entry === "function" || typeof entry === "symbol")
|
|
76
|
+
throw new JournalGuardConflict("value");
|
|
77
|
+
if (entry === null || typeof entry !== "object")
|
|
78
|
+
return;
|
|
79
|
+
if (ancestors.has(entry) || (!Array.isArray(entry) && Object.getPrototypeOf(entry) !== Object.prototype && Object.getPrototypeOf(entry) !== null))
|
|
80
|
+
throw new JournalGuardConflict("value");
|
|
81
|
+
ancestors.add(entry);
|
|
82
|
+
for (const key of Reflect.ownKeys(entry)) {
|
|
83
|
+
if (typeof key !== "string")
|
|
84
|
+
throw new JournalGuardConflict("value");
|
|
85
|
+
const descriptor = Object.getOwnPropertyDescriptor(entry, key);
|
|
86
|
+
if (!("value" in descriptor) || (!descriptor.enumerable && !(Array.isArray(entry) && key === "length")))
|
|
87
|
+
throw new JournalGuardConflict("value");
|
|
88
|
+
check(descriptor.value);
|
|
89
|
+
}
|
|
90
|
+
ancestors.delete(entry);
|
|
91
|
+
};
|
|
92
|
+
check(value);
|
|
93
|
+
return structuredClone(value);
|
|
94
|
+
}
|
|
95
|
+
function equalJournalValue(a, b) {
|
|
96
|
+
if (Object.is(a, b))
|
|
97
|
+
return true;
|
|
98
|
+
if (!a || !b || typeof a !== "object" || typeof b !== "object" || Array.isArray(a) !== Array.isArray(b))
|
|
99
|
+
return false;
|
|
100
|
+
if (Array.isArray(a) && a.length !== b.length)
|
|
101
|
+
return false;
|
|
102
|
+
const keys = Object.keys(a);
|
|
103
|
+
return keys.length === Object.keys(b).length && keys.every(key => Object.hasOwn(b, key) && equalJournalValue(a[key], b[key]));
|
|
104
|
+
}
|
|
105
|
+
function assertMetaExpectation(value) {
|
|
106
|
+
if (!value || typeof value !== "object" || typeof value.present !== "boolean" ||
|
|
107
|
+
!equalJournalValue(Object.keys(value).sort(), (value.present ? ["present", "value"] : ["present"]).sort()))
|
|
108
|
+
throw new JournalGuardConflict("meta");
|
|
109
|
+
}
|
|
110
|
+
export function captureJournalGuard(value, target) {
|
|
111
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
112
|
+
throw new JournalGuardConflict(target ?? "guard");
|
|
113
|
+
const guard = captureJournalValue(value);
|
|
114
|
+
if (typeof guard.target !== "string")
|
|
115
|
+
throw new JournalGuardConflict(target ?? "guard");
|
|
116
|
+
target ??= guard.target;
|
|
117
|
+
assertSafeConceptId(guard.target);
|
|
118
|
+
if (guard.target !== target || !Array.isArray(guard.intents) || !Array.isArray(guard.meta) ||
|
|
119
|
+
(guard.document !== null && (!guard.document || typeof guard.document.version !== "string" || typeof guard.document.raw !== "string")))
|
|
120
|
+
throw new JournalGuardConflict(target);
|
|
121
|
+
const requests = new Set(), sequences = new Set(), keys = new Set();
|
|
122
|
+
for (const row of guard.intents) {
|
|
123
|
+
if (!row || row.target !== target || typeof row.requestId !== "string" || requests.has(row.requestId) || !Number.isSafeInteger(row.sequence) || sequences.has(row.sequence))
|
|
124
|
+
throw new JournalGuardConflict(target);
|
|
125
|
+
requests.add(row.requestId);
|
|
126
|
+
sequences.add(row.sequence);
|
|
127
|
+
}
|
|
128
|
+
for (const row of guard.meta) {
|
|
129
|
+
if (!row || typeof row.key !== "string" || keys.has(row.key))
|
|
130
|
+
throw new JournalGuardConflict(target);
|
|
131
|
+
keys.add(row.key);
|
|
132
|
+
assertMetaExpectation(row.expected);
|
|
133
|
+
}
|
|
134
|
+
return guard;
|
|
135
|
+
}
|
|
136
|
+
/** Only omission or undefined selects the unguarded compatibility path. */
|
|
137
|
+
export function captureJournalGuardOption(options, target) {
|
|
138
|
+
const descriptor = Object.getOwnPropertyDescriptor(options, "guard");
|
|
139
|
+
if (!descriptor) {
|
|
140
|
+
if ("guard" in options)
|
|
141
|
+
throw new JournalGuardConflict(target ?? "guard");
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
if (!("value" in descriptor))
|
|
145
|
+
throw new JournalGuardConflict(target ?? "guard");
|
|
146
|
+
return descriptor.value === undefined ? undefined : captureJournalGuard(descriptor.value, target);
|
|
147
|
+
}
|
|
148
|
+
/** Compare all target records, including acknowledged history, and exact named row presence. */
|
|
149
|
+
export function assertJournalGuard(expected, current) {
|
|
150
|
+
const a = captureJournalGuard(expected), b = captureJournalGuard(current, a.target);
|
|
151
|
+
a.intents.sort((x, y) => x.sequence - y.sequence);
|
|
152
|
+
b.intents.sort((x, y) => x.sequence - y.sequence);
|
|
153
|
+
a.meta.sort((x, y) => x.key.localeCompare(y.key));
|
|
154
|
+
b.meta.sort((x, y) => x.key.localeCompare(y.key));
|
|
155
|
+
if (!equalJournalValue(a, b))
|
|
156
|
+
throw new JournalGuardConflict(a.target);
|
|
157
|
+
}
|
|
158
|
+
/** Capture guarded updates before any asynchronous adapter work and protect original history. */
|
|
159
|
+
export function captureIntentUpdate(patch, options) {
|
|
160
|
+
const guard = captureJournalGuardOption(options);
|
|
161
|
+
if (guard !== undefined)
|
|
162
|
+
captureJournalValue({ patch, options });
|
|
163
|
+
if (options.document && guard === undefined)
|
|
164
|
+
throw new JournalGuardConflict(options.document.id);
|
|
165
|
+
const captured = structuredClone({ patch, options });
|
|
166
|
+
if (guard !== undefined) {
|
|
167
|
+
captured.options.guard = guard;
|
|
168
|
+
const mutable = new Set(["state", "attempts", "acknowledgedVersion", "remote", "refusal", "finding", "updatedAt"]);
|
|
169
|
+
if (Object.keys(patch).some(key => !mutable.has(key)) || (captured.options.document && captured.options.document.id !== captured.options.guard.target))
|
|
170
|
+
throw new JournalGuardConflict(captured.options.guard.target);
|
|
171
|
+
assertJournalMetaChanges(captured.options.guard, captured.options.meta ?? [], undefined);
|
|
172
|
+
}
|
|
173
|
+
return captured;
|
|
174
|
+
}
|
|
175
|
+
export function captureMetaWrite(options) {
|
|
176
|
+
const result = captureJournalValue(options);
|
|
177
|
+
if (Object.hasOwn(result, "expected"))
|
|
178
|
+
assertMetaExpectation(result.expected);
|
|
179
|
+
if (result.requireEmptyJournal !== undefined && typeof result.requireEmptyJournal !== "boolean")
|
|
180
|
+
throw new JournalGuardConflict("meta");
|
|
181
|
+
return result;
|
|
182
|
+
}
|
|
183
|
+
export function assertMetaWrite(key, options, actual, intents) {
|
|
184
|
+
if (options.expected !== undefined && !equalJournalValue(captureJournalValue(options.expected), captureJournalValue(actual)))
|
|
185
|
+
throw new JournalGuardConflict(key);
|
|
186
|
+
if (options.requireEmptyJournal && intents.length !== 0)
|
|
187
|
+
throw new JournalGuardConflict(key);
|
|
188
|
+
}
|
|
189
|
+
/** Metadata removal is admitted only with an explicit full-snapshot premise. */
|
|
190
|
+
export function assertJournalMetaChanges(guard, puts, removals) {
|
|
191
|
+
if (guard) {
|
|
192
|
+
captureJournalValue(puts);
|
|
193
|
+
if (puts.some(row => !guard.meta.some(expected => expected.key === row.key)))
|
|
194
|
+
throw new JournalGuardConflict(guard.target);
|
|
195
|
+
}
|
|
196
|
+
if (removals === undefined)
|
|
197
|
+
return;
|
|
198
|
+
if (!guard || !Array.isArray(removals) || removals.some(key => typeof key !== "string") || new Set(removals).size !== removals.length ||
|
|
199
|
+
removals.some(key => puts.some(row => row.key === key) || !guard.meta.some(expected => expected.key === key)))
|
|
200
|
+
throw new JournalGuardConflict(guard?.target ?? "meta");
|
|
201
|
+
}
|
|
202
|
+
/** A guarded write owns one target and creates a globally fresh journal identity. */
|
|
203
|
+
export function assertJournalIntentChanges(guard, existingIdentity, superseded) {
|
|
204
|
+
if (guard && (existingIdentity !== undefined || (superseded !== undefined && superseded.target !== guard.target)))
|
|
205
|
+
throw new JournalGuardConflict(guard.target);
|
|
206
|
+
}
|
|
207
|
+
/** Capture write options while retaining the existing synchronous metadata producer. */
|
|
208
|
+
export function captureJournalWriteOptions(options) {
|
|
209
|
+
const descriptors = Object.getOwnPropertyDescriptors(options);
|
|
210
|
+
const data = {};
|
|
211
|
+
let producer;
|
|
212
|
+
for (const key of Reflect.ownKeys(options)) {
|
|
213
|
+
if (typeof key !== "string")
|
|
214
|
+
throw new JournalGuardConflict("options");
|
|
215
|
+
const descriptor = descriptors[key];
|
|
216
|
+
if (!("value" in descriptor) || !descriptor.enumerable)
|
|
217
|
+
throw new JournalGuardConflict("options");
|
|
218
|
+
if (key === "meta" && typeof descriptor.value === "function")
|
|
219
|
+
producer = descriptor.value;
|
|
220
|
+
else
|
|
221
|
+
data[key] = descriptor.value;
|
|
222
|
+
}
|
|
223
|
+
const captured = captureJournalValue(data);
|
|
224
|
+
if (producer)
|
|
225
|
+
captured.meta = producer;
|
|
226
|
+
return captured;
|
|
227
|
+
}
|
|
228
|
+
/** Capture every guarded deletion branch before evaluating held or absent state. */
|
|
229
|
+
export function captureJournalDeleteOptions(target, options) {
|
|
230
|
+
const guard = captureJournalGuardOption(options, target);
|
|
231
|
+
if (guard === undefined)
|
|
232
|
+
return options;
|
|
233
|
+
const captured = captureJournalValue(options);
|
|
234
|
+
captured.guard = guard;
|
|
235
|
+
assertJournalMetaChanges(guard, captured.meta ?? [], captured.removeMeta);
|
|
236
|
+
if (captured.onHeld !== undefined) {
|
|
237
|
+
if (!captured.onHeld || !Array.isArray(captured.onHeld.meta))
|
|
238
|
+
throw new JournalGuardConflict(target);
|
|
239
|
+
assertJournalMetaChanges(guard, captured.onHeld.meta, undefined);
|
|
240
|
+
}
|
|
241
|
+
return captured;
|
|
242
|
+
}
|
|
56
243
|
/**
|
|
57
244
|
* An intent's journal state was not the one the caller expected, or the intent is gone. Settling
|
|
58
245
|
* and superseding are compare-and-swap operations on the intent's own record so two realms (a
|
|
@@ -108,7 +295,12 @@ export function assertJournalResolutionOptions(target, options) {
|
|
|
108
295
|
throw new JournalSnapshotConflict(target);
|
|
109
296
|
}
|
|
110
297
|
}
|
|
111
|
-
/**
|
|
298
|
+
/**
|
|
299
|
+
* Compare full records, not only state: a changed outcome or retry is new recovery evidence.
|
|
300
|
+
* The head of the set (its lowest sequence) must hold a recorded terminal answer, `conflict` or
|
|
301
|
+
* `refused`; every later row must be `conflict`, `refused` or never-attempted `pending`. An
|
|
302
|
+
* `unknown`, `in_flight` or attempted `pending` head is uncertain delivery and stays refused.
|
|
303
|
+
*/
|
|
112
304
|
export function assertJournalSnapshot(target, expected, current, freshRequestId) {
|
|
113
305
|
const equal = (a, b) => {
|
|
114
306
|
if (Object.is(a, b))
|
|
@@ -121,8 +313,9 @@ export function assertJournalSnapshot(target, expected, current, freshRequestId)
|
|
|
121
313
|
};
|
|
122
314
|
const actual = current.filter(row => row.target === target && row.state !== "acknowledged");
|
|
123
315
|
const ids = new Set(expected.map(row => row.requestId));
|
|
316
|
+
const head = expected.reduce((lowest, row) => lowest === undefined || row.sequence < lowest.sequence ? row : lowest, undefined);
|
|
124
317
|
if ((freshRequestId !== undefined && current.some(row => row.requestId === freshRequestId)) ||
|
|
125
|
-
ids.size !== expected.length || actual.length !== expected.length || !
|
|
318
|
+
ids.size !== expected.length || actual.length !== expected.length || head === undefined || !(head.state === "conflict" || head.state === "refused") ||
|
|
126
319
|
expected.some(row => row.target !== target || !(row.state === "conflict" || row.state === "refused" || (row.state === "pending" && row.attempts === 0))) ||
|
|
127
320
|
expected.some(row => !equal(row, actual.find(candidate => candidate.requestId === row.requestId)))) {
|
|
128
321
|
throw new JournalSnapshotConflict(target);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"journaled-backend.js","sourceRoot":"","sources":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,QAAQ,CAAC,MAAM,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,KAAK,UAAU,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC;QACnJ,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,KAAK,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,KAAK,UAAU,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,GAAG,CAAC,KAAK,KAAK,SAAS,IAAI,GAAG,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC;QACxJ,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,SAAS,KAAK,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;QACvG,MAAM,IAAI,uBAAuB,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC"}
|
package/dist/remote-backend.d.ts
CHANGED
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
* This module touches NO filesystem and parses NO markdown — like {@link MemoryBackend},
|
|
41
41
|
* it proves the engine leaks no assumptions beyond the {@link StorageBackend} contract.
|
|
42
42
|
*/
|
|
43
|
-
import { type
|
|
43
|
+
import { type HeadsResult, type RemoteSnapshot } from "./remote-parsers.js";
|
|
44
44
|
import { type Outcome } from "./uncertain-write.js";
|
|
45
|
-
import type { BlobKey, ConceptId, DeleteOptions,
|
|
45
|
+
import type { BlobKey, ConceptId, DeleteOptions, HeadResult, OkfDocument, QueryFilter, ReadBlobResult, ReadResult, ReservedFilename, ReservedReadResult, StorageBackend, Version, VersionInfo, WriteOptions } from "./types.js";
|
|
46
46
|
/**
|
|
47
47
|
* An injectable fetch-like transport: given a `Request`, resolve a `Response`. This
|
|
48
48
|
* is exactly the shape {@link createRouter} (in `@superbee/server`) returns,
|
|
@@ -75,20 +75,7 @@ export interface RemoteBackendOptions {
|
|
|
75
75
|
*/
|
|
76
76
|
maxRetries?: number;
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
* A non-2xx wire response that is neither a `404` (ENOENT-shaped) nor a `412`
|
|
80
|
-
* ({@link VersionConflict}) — the generic case, carrying the error envelope's `code` alongside
|
|
81
|
-
* the raw HTTP `status`, so a caller can distinguish e.g.
|
|
82
|
-
* `AUTH_REQUIRED` (401, an unauthenticated/misconfigured `--remote`) from `RUNTIME` (5xx, a
|
|
83
|
-
* genuine server-side bug) instead of both collapsing into a generically-classified `Error`.
|
|
84
|
-
*/
|
|
85
|
-
export declare class RemoteError extends Error {
|
|
86
|
-
/** The envelope's `code` field, or a status-derived guess when the envelope is missing/unparseable. */
|
|
87
|
-
readonly code: string;
|
|
88
|
-
/** The raw HTTP status that produced this error. */
|
|
89
|
-
readonly status: number;
|
|
90
|
-
constructor(message: string, code: string, status: number, cause?: unknown);
|
|
91
|
-
}
|
|
78
|
+
export { RemoteError } from "./remote-error.js";
|
|
92
79
|
/** The deployment-scoped capability booleans a wire authority reports (`docs/WIRE-PROTOCOL.md`). */
|
|
93
80
|
export interface WireCapabilities {
|
|
94
81
|
history: boolean;
|
|
@@ -108,38 +95,6 @@ export interface HeadsOptions {
|
|
|
108
95
|
/** A digest from an earlier `heads` or `snapshot` answer; the authority answers `304` when it still holds it. */
|
|
109
96
|
ifNoneMatch?: string;
|
|
110
97
|
}
|
|
111
|
-
/** A `200` from `GET /heads`: every document id and version, and the digest over them. */
|
|
112
|
-
export interface HeadsResult {
|
|
113
|
-
digest: string;
|
|
114
|
-
heads: DocumentHead[];
|
|
115
|
-
}
|
|
116
|
-
/** The snapshot's first line: how many documents follow and the digest `heads` would return for this state. */
|
|
117
|
-
export interface SnapshotHeader {
|
|
118
|
-
count: number;
|
|
119
|
-
digest: string;
|
|
120
|
-
}
|
|
121
|
-
/** One `doc` line of a snapshot. */
|
|
122
|
-
export interface SnapshotDocument {
|
|
123
|
-
id: ConceptId;
|
|
124
|
-
version: Version;
|
|
125
|
-
frontmatter: Frontmatter;
|
|
126
|
-
body: string;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* A snapshot as {@link RemoteBackend.snapshot} hands it over: the header, already parsed, and
|
|
130
|
-
* the documents as they stream. Iterating `docs` to completion is the completeness signal: the
|
|
131
|
-
* loop ends only after the `end` line arrived with the announced count and the digest recomputed
|
|
132
|
-
* over the received `{ id, version }` rows equals the header's, and it throws
|
|
133
|
-
* `SNAPSHOT_TRUNCATED` (the body ended or failed first) or `SNAPSHOT_DIGEST_MISMATCH` (the body
|
|
134
|
-
* was whole but describes a state the header did not announce) otherwise, so a consumer that
|
|
135
|
-
* writes batches as they arrive has one control path and never needs to inspect a terminator
|
|
136
|
-
* or a digest itself. A consumer records the header digest as matched only after the loop
|
|
137
|
-
* ended normally.
|
|
138
|
-
*/
|
|
139
|
-
export interface RemoteSnapshot {
|
|
140
|
-
header: SnapshotHeader;
|
|
141
|
-
docs: AsyncIterable<SnapshotDocument>;
|
|
142
|
-
}
|
|
143
98
|
/**
|
|
144
99
|
* The client half of the wire-protocol v0 contract: implements {@link StorageBackend}
|
|
145
100
|
* over HTTP against a `@superbee/server` instance (or any conformant
|
|
@@ -176,10 +131,9 @@ export declare class RemoteBackend implements StorageBackend {
|
|
|
176
131
|
* `200` is diffed against the caller's own copy: an id missing from `heads` was deleted, a
|
|
177
132
|
* differing version changed. A `200` without a well-formed digest, whose `count` and rows
|
|
178
133
|
* disagree, or whose rows digest by the documented recipe to something other than the served
|
|
179
|
-
* digest, is rejected rather than trusted
|
|
180
|
-
* `
|
|
181
|
-
*
|
|
182
|
-
* diffed as a mass deletion. Not part of the {@link StorageBackend} seam.
|
|
134
|
+
* digest, is rejected rather than trusted ({@link parseHeadsAnswer} owns that admission), as
|
|
135
|
+
* is a `304` to a request that sent no `ifNoneMatch`. Not part of the {@link StorageBackend}
|
|
136
|
+
* seam.
|
|
183
137
|
*/
|
|
184
138
|
heads(options?: HeadsOptions): Promise<HeadsResult | null>;
|
|
185
139
|
/**
|
|
@@ -188,8 +142,9 @@ export declare class RemoteBackend implements StorageBackend {
|
|
|
188
142
|
* the documents then stream through {@link RemoteSnapshot.docs}. Transient retry applies only
|
|
189
143
|
* to obtaining the response: a body cut mid-stream is reported to the consumer as
|
|
190
144
|
* `SNAPSHOT_TRUNCATED`, a whole body whose heads do not digest to the header's announcement as
|
|
191
|
-
* `SNAPSHOT_DIGEST_MISMATCH
|
|
192
|
-
* not part of a snapshot. Not part of the
|
|
145
|
+
* `SNAPSHOT_DIGEST_MISMATCH` ({@link readSnapshotStream} owns the grammar), and re-requesting
|
|
146
|
+
* is the consumer's decision. Reserved files are not part of a snapshot. Not part of the
|
|
147
|
+
* {@link StorageBackend} seam.
|
|
193
148
|
*/
|
|
194
149
|
snapshot(): Promise<RemoteSnapshot>;
|
|
195
150
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-backend.d.ts","sourceRoot":"","sources":["../src/remote-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;
|
|
1
|
+
{"version":3,"file":"remote-backend.d.ts","sourceRoot":"","sources":["../src/remote-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAMH,OAAO,EAA4D,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEtI,OAAO,EAAqB,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEvE,OAAO,KAAK,EACV,OAAO,EACP,SAAS,EACT,aAAa,EAEb,UAAU,EACV,WAAW,EACX,WAAW,EACX,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,WAAW,EACX,YAAY,E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