@git-stunts/git-cas 7.0.0 → 7.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 (55) hide show
  1. package/ARCHITECTURE.md +15 -0
  2. package/CHANGELOG.md +57 -0
  3. package/README.md +16 -4
  4. package/build-info.json +2 -2
  5. package/docs/API.md +111 -0
  6. package/docs/releases/v7.1.0.md +25 -0
  7. package/docs/releases/v7.2.0.md +15 -0
  8. package/index.d.ts +15 -0
  9. package/index.js +30 -0
  10. package/package.json +5 -3
  11. package/src/domain/errors/Codes.js +1 -0
  12. package/src/domain/errors/ReservationStorageError.js +9 -0
  13. package/src/domain/services/ReservationCustodyObjects.js +171 -0
  14. package/src/domain/services/ReservationCustodyStore.js +149 -0
  15. package/src/domain/services/ReservationIndex.js +241 -0
  16. package/src/domain/services/ReservationIndexNode.js +78 -0
  17. package/src/domain/services/ReservationLedger.js +326 -0
  18. package/src/domain/services/ReservationLedgerStore.js +141 -0
  19. package/src/domain/services/ReservationListing.js +40 -0
  20. package/src/domain/services/ReservationNamespace.d.ts +135 -0
  21. package/src/domain/services/ReservationNamespace.js +51 -0
  22. package/src/domain/services/ReservationNamespaceRegistry.js +89 -0
  23. package/src/domain/services/ReservationRecord.js +166 -0
  24. package/src/domain/services/ReservationScan.js +54 -0
  25. package/src/domain/value-objects/ReservationCursor.d.ts +11 -0
  26. package/src/domain/value-objects/ReservationCursor.js +31 -0
  27. package/src/domain/value-objects/ReservationCustodyDescriptor.js +47 -0
  28. package/src/domain/value-objects/ReservationCustodySnapshot.js +16 -0
  29. package/src/domain/value-objects/ReservationEvidence.js +26 -0
  30. package/src/domain/value-objects/ReservationEvidenceRead.js +22 -0
  31. package/src/domain/value-objects/ReservationEvidenceRoots.js +72 -0
  32. package/src/domain/value-objects/ReservationIndeterminate.js +17 -0
  33. package/src/domain/value-objects/ReservationInspection.js +21 -0
  34. package/src/domain/value-objects/ReservationKey.js +26 -0
  35. package/src/domain/value-objects/ReservationLedgerHeader.js +15 -0
  36. package/src/domain/value-objects/ReservationLedgerRefusal.js +21 -0
  37. package/src/domain/value-objects/ReservationLedgerSnapshot.js +27 -0
  38. package/src/domain/value-objects/ReservationListRequest.js +35 -0
  39. package/src/domain/value-objects/ReservationListUnavailable.js +17 -0
  40. package/src/domain/value-objects/ReservationOpenIndeterminate.js +15 -0
  41. package/src/domain/value-objects/ReservationOpenRefusal.js +14 -0
  42. package/src/domain/value-objects/ReservationPage.js +27 -0
  43. package/src/domain/value-objects/ReservationPolicy.js +24 -0
  44. package/src/domain/value-objects/ReservationRefusal.js +23 -0
  45. package/src/domain/value-objects/ReservationResult.js +27 -0
  46. package/src/domain/value-objects/ReservationSupport.js +22 -0
  47. package/src/infrastructure/adapters/GitRefAdapter.js +7 -0
  48. package/src/infrastructure/codecs/ReservationCustodyCodec.js +54 -0
  49. package/src/infrastructure/codecs/ReservationLedgerCodec.js +48 -0
  50. package/src/infrastructure/codecs/ReservationRecordCodec.js +54 -0
  51. package/src/package-version.js +1 -1
  52. package/src/ports/GitRefPort.js +11 -0
  53. package/src/ports/ReservationCustodyCodecPort.js +14 -0
  54. package/src/ports/ReservationLedgerCodecPort.js +14 -0
  55. package/src/ports/ReservationRecordCodecPort.js +14 -0
@@ -0,0 +1,149 @@
1
+ import GitRefPort from '../../ports/GitRefPort.js';
2
+ import CryptoPort from '../../ports/CryptoPort.js';
3
+ import ReservationCustodyObjects from './ReservationCustodyObjects.js';
4
+ import ReservationRecord from './ReservationRecord.js';
5
+ import ReservationKey from '../value-objects/ReservationKey.js';
6
+ import ReservationRefusal from '../value-objects/ReservationRefusal.js';
7
+ import InvalidOptionsError from '../errors/InvalidOptionsError.js';
8
+ import ReservationStorageError from '../errors/ReservationStorageError.js';
9
+ import { CasError, ErrorCodes } from '../errors/index.js';
10
+
11
+ /** Per-attempt pins; the ledger owner alone decides when a phase may be issued. */
12
+ export default class ReservationCustodyStore {
13
+ #objects;
14
+ #refs;
15
+ #crypto;
16
+
17
+ constructor({ objects, refs, crypto }) {
18
+ if (!(objects instanceof ReservationCustodyObjects) || !(refs instanceof GitRefPort) || !(crypto instanceof CryptoPort)) {
19
+ throw new InvalidOptionsError('Custody store requires immutable objects, refs and crypto');
20
+ }
21
+ this.namespace = objects.namespace;
22
+ this.#objects = objects;
23
+ this.#refs = refs;
24
+ this.#crypto = crypto;
25
+ Object.freeze(this);
26
+ }
27
+
28
+ async read(attempt) {
29
+ const posture = await this.#refs.inspectRef(await this.#ref(attempt));
30
+ if (posture?.symref !== null) {
31
+ throw new ReservationStorageError('Custody must use a direct ref');
32
+ }
33
+ if (posture.oid === null) {
34
+ return null;
35
+ }
36
+ const current = await this.#objects.read(posture.oid);
37
+ assertIdentity(attempt, current);
38
+ const original = current.descriptor.stage === 'preparation' ? current : await this.#original(attempt, current);
39
+ if (attempt.preparation !== null && original.revision !== attempt.preparation) {
40
+ throw new ReservationStorageError('Custody pin does not retain the original preparation');
41
+ }
42
+ return current;
43
+ }
44
+
45
+ async verify(attempt) {
46
+ if (attempt.preparation === null) {
47
+ throw new ReservationStorageError('This attempt has no prepared custody to verify');
48
+ }
49
+ const current = await this.read(attempt);
50
+ if (current === null || (attempt.settlement !== null && current.revision !== attempt.settlement)) {
51
+ throw new ReservationStorageError('Required reservation custody is missing or replaced');
52
+ }
53
+ return current;
54
+ }
55
+
56
+ async readEvidence(attempt, stage) {
57
+ await this.verify(attempt);
58
+ const revision = stage === 'preparation' ? attempt.preparation : attempt.settlement;
59
+ return await this.#objects.readEvidence(revision);
60
+ }
61
+
62
+ async prepare(attempt, evidence) {
63
+ const descriptor = await this.#objects.describe({ attempt, evidence });
64
+ let current = await this.read(attempt);
65
+ if (current === null) {
66
+ if (attempt.preparation !== null) {
67
+ throw new ReservationStorageError('Cannot recreate missing prepared custody');
68
+ }
69
+ const candidate = await this.#objects.write(descriptor);
70
+ current = await this.#install(attempt, { expected: null, candidate });
71
+ }
72
+ const original = current.descriptor.stage === 'preparation' ? current : await this.#original(attempt, current);
73
+ return original.descriptor.equals(descriptor) ? original : new ReservationRefusal('preparation-mismatch');
74
+ }
75
+
76
+ async settle(attempt, evidence) {
77
+ if (attempt.preparation === null) {
78
+ return new ReservationRefusal('not-prepared');
79
+ }
80
+ const descriptor = await this.#objects.describe({ attempt, evidence, preparation: attempt.preparation });
81
+ let current = await this.verify(attempt);
82
+ if (current.descriptor.stage === 'preparation') {
83
+ const candidate = await this.#objects.write(descriptor);
84
+ current = await this.#install(attempt, { expected: current.revision, candidate });
85
+ }
86
+ return current.descriptor.equals(descriptor) ? current : new ReservationRefusal('settlement-mismatch');
87
+ }
88
+
89
+ async discardCancelled(attempt) {
90
+ if (!(attempt instanceof ReservationRecord) || attempt.phase !== 'cancelled') {
91
+ throw new InvalidOptionsError('Only a persisted cancelled attempt may have its pin removed');
92
+ }
93
+ const current = await this.read(attempt);
94
+ if (current === null) {
95
+ return;
96
+ }
97
+ try {
98
+ await this.#refs.deleteRef({ ref: await this.#ref(attempt), expectedOldOid: current.revision });
99
+ } catch (writeError) {
100
+ if (await this.#recover(attempt, writeError) !== null) {
101
+ throw writeError;
102
+ }
103
+ }
104
+ }
105
+
106
+ async #install(attempt, { expected, candidate }) {
107
+ try {
108
+ await this.#refs.updateRef({ ref: await this.#ref(attempt), newOid: candidate.revision, expectedOldOid: expected });
109
+ return candidate;
110
+ } catch (writeError) {
111
+ const current = await this.#recover(attempt, writeError);
112
+ if (current === null || current.revision === expected) {
113
+ throw writeError;
114
+ }
115
+ return current;
116
+ }
117
+ }
118
+
119
+ async #recover(attempt, writeError) {
120
+ try {
121
+ return await this.read(attempt);
122
+ } catch (inspectionError) {
123
+ throw new CasError('Custody mutation and inspection failed', ErrorCodes.GIT_ERROR, { writeError, inspectionError });
124
+ }
125
+ }
126
+
127
+ async #original(attempt, settlement) {
128
+ const original = await this.#objects.read(settlement.descriptor.preparation);
129
+ assertIdentity(attempt, original);
130
+ if (original.descriptor.stage !== 'preparation') {
131
+ throw new ReservationStorageError('Settlement must retain a preparation, not another settlement');
132
+ }
133
+ return original;
134
+ }
135
+
136
+ async #ref(attempt) {
137
+ if (!(attempt instanceof ReservationRecord)) {
138
+ throw new InvalidOptionsError('Custody operations require a validated attempt');
139
+ }
140
+ const route = await new ReservationKey(attempt.key).route(this.#crypto);
141
+ return `refs/cas/reservation-custody/${this.namespace}/${route}`;
142
+ }
143
+ }
144
+
145
+ function assertIdentity(attempt, generation) {
146
+ if (generation.descriptor.key !== attempt.key || generation.descriptor.binding !== attempt.binding) {
147
+ throw new ReservationStorageError('Custody pin belongs to another attempt identity');
148
+ }
149
+ }
@@ -0,0 +1,241 @@
1
+ import GitPersistencePort from '../../ports/GitPersistencePort.js';
2
+ import CryptoPort from '../../ports/CryptoPort.js';
3
+ import ReservationRecordCodecPort, { RESERVATION_RECORD_MAX_BYTES } from '../../ports/ReservationRecordCodecPort.js';
4
+ import InvalidOptionsError from '../errors/InvalidOptionsError.js';
5
+ import ReservationStorageError from '../errors/ReservationStorageError.js';
6
+ import Oid from '../value-objects/Oid.js';
7
+ import ReservationKey from '../value-objects/ReservationKey.js';
8
+ import ReservationRecord from './ReservationRecord.js';
9
+ import ReservationIndexNode from './ReservationIndexNode.js';
10
+ import ReservationScan from './ReservationScan.js';
11
+
12
+ const NODE_BYTES = 2 * 1024;
13
+
14
+ /**
15
+ * Private immutable point index: a path-compressed hexadecimal trie over key
16
+ * routes. Each record sits at the shortest route prefix it shares with no
17
+ * other record, so a point read or update touches about log16(records) trees.
18
+ * A 7.1.0 index, which placed every record at full depth, reads and updates
19
+ * unchanged. It produces candidate trees, never publishes refs or admits
20
+ * capacity; the ledger owner enforces lifecycle and binding. Reads validate
21
+ * only the selected path, not every unvisited subtree.
22
+ */
23
+ export default class ReservationIndex {
24
+ #persistence;
25
+ #codec;
26
+ #crypto;
27
+
28
+ constructor({ persistence, codec, crypto }) {
29
+ if (!(persistence instanceof GitPersistencePort) || !(codec instanceof ReservationRecordCodecPort) ||
30
+ !(crypto instanceof CryptoPort)) {
31
+ throw new InvalidOptionsError('Reservation index requires persistence, record codec and crypto ports');
32
+ }
33
+ this.#persistence = persistence;
34
+ this.#codec = codec;
35
+ this.#crypto = crypto;
36
+ Object.freeze(this);
37
+ }
38
+
39
+ async get(root, key) {
40
+ const identity = new ReservationKey(key);
41
+ const route = await identity.route(this.#crypto);
42
+ const { nodes, leaf } = await this.#walk(root, route);
43
+ if (leaf === null) {
44
+ return null;
45
+ }
46
+ const record = await this.#readRecord(leaf);
47
+ if (record.key === identity.value) {
48
+ return record;
49
+ }
50
+ await this.#resident(record, route.slice(0, nodes.length), route);
51
+ return null;
52
+ }
53
+
54
+ async empty() {
55
+ return checkedOid(await this.#persistence.writeTree([]));
56
+ }
57
+
58
+ async scan(root, request) {
59
+ const scan = new ReservationScan(request);
60
+ const complete = await this.#scanNode({ oid: checkedOid(root), type: 'tree' }, '', scan);
61
+ if (!complete && scan.after === (request.cursor?.after ?? null)) {
62
+ throw new ReservationStorageError('Reservation traversal made no progress within its budget');
63
+ }
64
+ return scan.finish(complete);
65
+ }
66
+
67
+ async #scanNode(entry, prefix, scan) {
68
+ if (scan.skip(prefix)) {
69
+ return true;
70
+ }
71
+ if (!scan.visit()) {
72
+ return false;
73
+ }
74
+ if (entry.type === 'blob') {
75
+ await this.#scanRecord(entry.oid, prefix, scan);
76
+ return true;
77
+ }
78
+ const node = await this.#node(entry.oid, prefix.length);
79
+ if (prefix.length > 0 && node.entries.length === 0) {
80
+ throw new ReservationStorageError('Reservation index contains an empty internal branch');
81
+ }
82
+ for (const child of node.entries) {
83
+ if (!await this.#scanNode(child, prefix + child.name, scan)) {
84
+ return false;
85
+ }
86
+ }
87
+ return true;
88
+ }
89
+
90
+ async #scanRecord(oid, prefix, scan) {
91
+ const record = await this.#readRecord(oid);
92
+ const route = await this.#placed(record, prefix);
93
+ if (!scan.listed(route)) {
94
+ scan.accept(record, route);
95
+ }
96
+ }
97
+
98
+ async put(root, record) {
99
+ if (!(record instanceof ReservationRecord)) {
100
+ throw new InvalidOptionsError('Reservation index writes require a validated record');
101
+ }
102
+ const route = await new ReservationKey(record.key).route(this.#crypto);
103
+ const { nodes, leaf } = await this.#walk(root, route);
104
+ const depth = Math.max(nodes.length - 1, 0);
105
+ const displaced = leaf === null ? null : await this.#displaced(leaf, { record, route, depth });
106
+ const oid = await this.#writeRecord(record, root);
107
+ let child = { oid, type: 'blob' };
108
+ if (displaced !== null) {
109
+ child = await this.#split({ route, depth, child, displaced });
110
+ }
111
+ for (let at = depth; at >= 0; at--) {
112
+ const node = nodes[at] ?? this.#emptyNode(at, oid.length);
113
+ child = { oid: await this.#writeNode(node.withChild(route[at], child)), type: 'tree' };
114
+ }
115
+ return child.oid;
116
+ }
117
+
118
+ /** Returns the other record a new key must share a subtree with, or null for an update. */
119
+ async #displaced(leaf, { record, route, depth }) {
120
+ const resident = await this.#readRecord(leaf);
121
+ if (resident.key === record.key) {
122
+ return null;
123
+ }
124
+ const residentRoute = await this.#resident(resident, route.slice(0, depth + 1), route);
125
+ return { route: residentRoute, child: { oid: leaf, type: 'blob' } };
126
+ }
127
+
128
+ /** Pushes two records down to the first digit at which their routes part. */
129
+ async #split({ route, depth, child, displaced }) {
130
+ let fork = depth + 1;
131
+ while (route[fork] === displaced.route[fork]) {
132
+ fork++;
133
+ }
134
+ const oidLength = child.oid.length;
135
+ const pair = this.#emptyNode(fork, oidLength)
136
+ .withChild(route[fork], child)
137
+ .withChild(displaced.route[fork], displaced.child);
138
+ let subtree = { oid: await this.#writeNode(pair), type: 'tree' };
139
+ for (let at = fork - 1; at > depth; at--) {
140
+ const chain = this.#emptyNode(at, oidLength).withChild(route[at], subtree);
141
+ subtree = { oid: await this.#writeNode(chain), type: 'tree' };
142
+ }
143
+ return subtree;
144
+ }
145
+
146
+ async #writeRecord(record, root) {
147
+ const bytes = this.#codec.encode(record);
148
+ if (!(bytes instanceof Uint8Array) || bytes.length > RESERVATION_RECORD_MAX_BYTES) {
149
+ throw new ReservationStorageError('Encoded reservation record exceeds its byte limit');
150
+ }
151
+ const oid = checkedOid(await this.#persistence.writeBlob(bytes));
152
+ assertFormat(record, oid.length);
153
+ if (root !== null && root.length !== oid.length) {
154
+ throw new ReservationStorageError('Reservation update changed Git object format');
155
+ }
156
+ return oid;
157
+ }
158
+
159
+ async #writeNode(node) {
160
+ const oid = checkedOid(await this.#persistence.writeTree(node.toTreeLines()));
161
+ if (oid.length !== node.oidLength) {
162
+ throw new ReservationStorageError('Reservation tree writer changed Git object format');
163
+ }
164
+ return oid;
165
+ }
166
+
167
+ #emptyNode(depth, oidLength) {
168
+ return new ReservationIndexNode({ entries: [], depth, oidLength });
169
+ }
170
+
171
+ /** Walks the route until it reaches an empty slot or a record blob. */
172
+ async #walk(root, route) {
173
+ const nodes = [];
174
+ let entry = root === null ? null : { oid: checkedOid(root), type: 'tree' };
175
+ while (entry !== null && entry.type === 'tree') {
176
+ const node = await this.#node(entry.oid, nodes.length);
177
+ entry = node.child(route[nodes.length]);
178
+ nodes.push(node);
179
+ }
180
+ return { nodes, leaf: entry?.oid ?? null };
181
+ }
182
+
183
+ /**
184
+ * Proves that a record found on another key's route belongs there: its own
185
+ * route shares the walked prefix and differs from the sought route.
186
+ */
187
+ async #resident(record, prefix, route) {
188
+ const residentRoute = await this.#placed(record, prefix);
189
+ if (residentRoute === route) {
190
+ throw new ReservationStorageError('Reservation route resolves to another key');
191
+ }
192
+ return residentRoute;
193
+ }
194
+
195
+ async #placed(record, prefix) {
196
+ const route = await new ReservationKey(record.key).route(this.#crypto);
197
+ if (!route.startsWith(prefix)) {
198
+ throw new ReservationStorageError('Reservation record does not belong at its indexed route');
199
+ }
200
+ return route;
201
+ }
202
+
203
+ async #node(oid, depth) {
204
+ await this.#assertObject(oid, { type: 'tree', maxBytes: NODE_BYTES });
205
+ return new ReservationIndexNode({ entries: await this.#persistence.readTree(oid), depth, oidLength: oid.length });
206
+ }
207
+
208
+ async #readRecord(oid) {
209
+ await this.#assertObject(oid, { type: 'blob', maxBytes: RESERVATION_RECORD_MAX_BYTES });
210
+ const record = this.#codec.decode(await this.#persistence.readBlob(oid, RESERVATION_RECORD_MAX_BYTES));
211
+ if (!(record instanceof ReservationRecord)) {
212
+ throw new ReservationStorageError('Reservation route resolves to an invalid record');
213
+ }
214
+ assertFormat(record, oid.length);
215
+ return record;
216
+ }
217
+
218
+ async #assertObject(oid, { type, maxBytes }) {
219
+ const [actualType, size] = await Promise.all([
220
+ this.#persistence.readObjectType(oid), this.#persistence.readObjectSize(oid),
221
+ ]);
222
+ if (actualType !== type || !Number.isSafeInteger(size) || size < 0 || size > maxBytes) {
223
+ throw new ReservationStorageError('Reservation object type or byte bound is invalid', { oid, type, size });
224
+ }
225
+ }
226
+ }
227
+
228
+ function checkedOid(value) {
229
+ if (!Oid.isValid(value) || Oid.from(value).toString() !== value) {
230
+ throw new ReservationStorageError('Reservation index requires a canonical Git OID');
231
+ }
232
+ return value;
233
+ }
234
+
235
+ function assertFormat(record, oidLength) {
236
+ for (const oid of [record.preparation, record.settlement]) {
237
+ if (oid !== null && oid.length !== oidLength) {
238
+ throw new ReservationStorageError('Reservation evidence and index use different Git object formats');
239
+ }
240
+ }
241
+ }
@@ -0,0 +1,78 @@
1
+ import ReservationStorageError from '../errors/ReservationStorageError.js';
2
+ import Oid from '../value-objects/Oid.js';
3
+ import { RESERVATION_ROUTE_DIGITS } from '../value-objects/ReservationKey.js';
4
+
5
+ const FANOUT = 16;
6
+ const DIGIT = /^[0-9a-f]$/u;
7
+ const MODES = Object.freeze({ blob: '100644', tree: '040000' });
8
+
9
+ /**
10
+ * A bounded, ordered routing node. A record blob sits at the shortest route
11
+ * prefix that no other record shares, so a child above the final digit is a
12
+ * subtree or a record. A final-depth child is always a record.
13
+ */
14
+ export default class ReservationIndexNode {
15
+ #entries;
16
+
17
+ constructor({ entries, depth, oidLength }) {
18
+ assertShape(entries, depth, oidLength);
19
+ this.depth = depth;
20
+ this.oidLength = oidLength;
21
+ this.#entries = Object.freeze(entries.map((entry) => checkedEntry(entry, depth, oidLength)));
22
+ for (let i = 1; i < this.#entries.length; i++) {
23
+ if (this.#entries[i - 1].name >= this.#entries[i].name) {
24
+ throw new ReservationStorageError('Reservation node entries must be ordered and unique');
25
+ }
26
+ }
27
+ Object.freeze(this);
28
+ }
29
+
30
+ child(digit) {
31
+ return this.#entries.find((entry) => entry.name === digit) ?? null;
32
+ }
33
+
34
+ get entries() {
35
+ return this.#entries;
36
+ }
37
+
38
+ withChild(digit, { oid, type }) {
39
+ const entry = { name: digit, oid, type, mode: MODES[type] };
40
+ const entries = [...this.#entries.filter((item) => item.name !== digit), entry];
41
+ entries.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
42
+ return new ReservationIndexNode({ entries, depth: this.depth, oidLength: this.oidLength });
43
+ }
44
+
45
+ toTreeLines() {
46
+ return this.#entries.map((entry) => `${entry.mode} ${entry.type} ${entry.oid}\t${entry.name}`);
47
+ }
48
+ }
49
+
50
+ function assertShape(entries, depth, oidLength) {
51
+ if (!Array.isArray(entries) || entries.length > FANOUT) {
52
+ throw new ReservationStorageError('Reservation index fanout exceeds sixteen entries');
53
+ }
54
+ if (!Number.isInteger(depth) || depth < 0 || depth >= RESERVATION_ROUTE_DIGITS) {
55
+ throw new ReservationStorageError('Reservation index depth is invalid');
56
+ }
57
+ if (oidLength !== 40 && oidLength !== 64) {
58
+ throw new ReservationStorageError('Reservation index object format is invalid');
59
+ }
60
+ }
61
+
62
+ function checkedEntry(entry, depth, oidLength) {
63
+ assertRoutingName(entry);
64
+ const final = depth === RESERVATION_ROUTE_DIGITS - 1;
65
+ if ((entry.type !== 'blob' && (final || entry.type !== 'tree')) || entry.mode !== MODES[entry.type]) {
66
+ throw new ReservationStorageError('Reservation index entry type or mode is invalid');
67
+ }
68
+ if (!Oid.isValid(entry.oid) || entry.oid.length !== oidLength || Oid.from(entry.oid).toString() !== entry.oid) {
69
+ throw new ReservationStorageError('Reservation index entry OID is invalid');
70
+ }
71
+ return Object.freeze({ name: entry.name, mode: entry.mode, type: entry.type, oid: entry.oid });
72
+ }
73
+
74
+ function assertRoutingName(entry) {
75
+ if (entry === null || typeof entry !== 'object' || typeof entry.name !== 'string' || !DIGIT.test(entry.name)) {
76
+ throw new ReservationStorageError('Reservation index entry name is invalid');
77
+ }
78
+ }