@git-stunts/git-cas 7.1.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.
- package/ARCHITECTURE.md +2 -2
- package/CHANGELOG.md +12 -2
- package/README.md +10 -5
- package/build-info.json +2 -2
- package/docs/API.md +3 -3
- package/docs/releases/v7.1.0.md +3 -5
- package/docs/releases/v7.2.0.md +15 -0
- package/package.json +3 -2
- package/src/domain/services/ReservationIndex.js +110 -38
- package/src/domain/services/ReservationIndexNode.js +14 -11
- package/src/domain/services/ReservationScan.js +5 -0
- package/src/package-version.js +1 -1
package/ARCHITECTURE.md
CHANGED
|
@@ -487,8 +487,8 @@ Its cursor is a position, not a pin: GC may make an older snapshot unavailable.
|
|
|
487
487
|
Point inspection observes ledger and custody separately; it makes no multi-ref
|
|
488
488
|
snapshot claim. See the [public contract](docs/API.md#durable-reservations)
|
|
489
489
|
and [cycle0063 design](https://github.com/git-stunts/git-cas/blob/4782052214269c72acc95f63191e89897059bb56/docs/design/0063-durable-reservations/durable-reservations.md).
|
|
490
|
-
The
|
|
491
|
-
|
|
490
|
+
The capability is published in v7.1.0; [#162](https://github.com/git-stunts/git-cas/issues/162)
|
|
491
|
+
retains release and registry-consumer evidence.
|
|
492
492
|
|
|
493
493
|
High-level retention, CacheSet, cache acquisition, ExpiringSet, and application
|
|
494
494
|
publication operations return generation-scoped retention evidence. Replacing
|
package/CHANGELOG.md
CHANGED
|
@@ -7,9 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
## [7.
|
|
10
|
+
## [7.2.0] — 2026-11-06
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
- The reservation index is now a path-compressed trie (#167). A record sits at
|
|
15
|
+
the shortest route prefix no other record shares, so a ledger update writes
|
|
16
|
+
one record blob and about log16(records) trees instead of 64. A 7.1.0 index
|
|
17
|
+
still reads and updates without migration. git-cas 7.1.0 refuses an index
|
|
18
|
+
written by this version as corrupt on read, list and recovery, so every
|
|
19
|
+
process that reads or writes a clone's reservation ledger must upgrade
|
|
20
|
+
together.
|
|
21
|
+
|
|
22
|
+
## [7.1.0] — 2026-11-02
|
|
13
23
|
|
|
14
24
|
### Added
|
|
15
25
|
|
package/README.md
CHANGED
|
@@ -58,12 +58,17 @@ and [release notes](./docs/releases/v7.0.0.md). This release requires
|
|
|
58
58
|
published Plumbing 3.3.3. [Release and registry evidence](https://github.com/git-stunts/git-cas/issues/154)
|
|
59
59
|
records its publication.
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
Published v7.1.0 adds [durable reservations](./docs/API.md#durable-reservations):
|
|
62
62
|
hard record-slot admission before an application effect, pinned evidence and
|
|
63
|
-
bounded recovery/inspection.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
bounded recovery/inspection. See the [release notes](./docs/releases/v7.1.0.md)
|
|
64
|
+
and [publication and fresh registry-consumer evidence](https://github.com/git-stunts/git-cas/issues/162).
|
|
65
|
+
The signed tag, npm gitHead and successful release workflow agree on `18f87dd`.
|
|
66
|
+
|
|
67
|
+
The v7.2.0 release candidate path-compresses the reservation index, so a ledger
|
|
68
|
+
update writes about log16(records) trees instead of 64. A 7.1.0 index still
|
|
69
|
+
reads and updates, but 7.1.0 refuses an index 7.2.0 has written; see the
|
|
70
|
+
[release notes](./docs/releases/v7.2.0.md) and
|
|
71
|
+
[#169](https://github.com/git-stunts/git-cas/issues/169).
|
|
67
72
|
|
|
68
73
|
The published v6.5.12 release bounds object-metadata requests so root sets with more than 1000 targets (936 for SHA-256) validate within Plumbing's cat-file request limits. Admission still rejects missing and mismatched targets before publication; see [v6.5.12 Release Notes](./docs/releases/v6.5.12.md).
|
|
69
74
|
|
package/build-info.json
CHANGED
package/docs/API.md
CHANGED
|
@@ -3649,9 +3649,9 @@ Different error codes include different metadata:
|
|
|
3649
3649
|
|
|
3650
3650
|
## Durable Reservations
|
|
3651
3651
|
|
|
3652
|
-
This API is
|
|
3653
|
-
|
|
3654
|
-
|
|
3652
|
+
This API is available in published v7.1.0 and is absent from v7.0.0.
|
|
3653
|
+
[Issue #162](https://github.com/git-stunts/git-cas/issues/162) retains publication
|
|
3654
|
+
and fresh registry-consumer verification.
|
|
3655
3655
|
|
|
3656
3656
|
`cas.reservations.open({ namespace, capacity: { unit: 'record-slot', limit } })`
|
|
3657
3657
|
installs or verifies an immutable namespace policy, including an empty ledger
|
package/docs/releases/v7.1.0.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# git-cas v7.1.0: durable reservation admission
|
|
2
2
|
|
|
3
|
-
This release
|
|
4
|
-
|
|
5
|
-
This candidate document claims no published 7.1.0 artifact.
|
|
3
|
+
This release adds `cas.reservations.open()` for applications that must reserve permanent record capacity before an irreversible effect. The implementation merged in [PR #158](https://github.com/git-stunts/git-cas/pull/158). [Issue #162](https://github.com/git-stunts/git-cas/issues/162) records the completed release gates, publication and fresh public-registry consumer verification. Signed tag `v7.1.0`, npm gitHead and the successful [release workflow](https://github.com/git-stunts/git-cas/actions/runs/41483019826) identify source `18f87ddb08857209d9e2e6ff30337515c0eaee4d`. The [GitHub Release](https://github.com/git-stunts/git-cas/releases/tag/v7.1.0) is published.
|
|
6
4
|
|
|
7
5
|
## Contract
|
|
8
6
|
|
|
@@ -22,6 +20,6 @@ Deno CI and release commands now install the frozen pnpm project graph and execu
|
|
|
22
20
|
|
|
23
21
|
The [implementation witnesses](https://github.com/git-stunts/git-cas/blob/4782052214269c72acc95f63191e89897059bb56/docs/design/0063-durable-reservations/witness/README.md) separate state-machine tests, selected corruption, native multi-process races, injected write-boundary failures, process death, reopen and real Git GC in SHA-1 and SHA-256 stores. The [finite cost witness](https://github.com/git-stunts/git-cas/blob/4782052214269c72acc95f63191e89897059bb56/docs/design/0063-durable-reservations/witness/native-cost.md) measures stores of 1, 17 and 129 attempts using 4 KiB pages. It does not claim universal constant memory or performance parity across runtimes.
|
|
24
22
|
|
|
25
|
-
PR #158's current-head hosted lint, unit and Node/Bun/Deno jobs passed. The maintainer explicitly authorized an admin merge after reviewer quota and file-count limits prevented independent approval. The [cycle retrospective](https://github.com/git-stunts/git-cas/blob/
|
|
23
|
+
PR #158's current-head hosted lint, unit and Node/Bun/Deno jobs passed. The maintainer explicitly authorized an admin merge after reviewer quota and file-count limits prevented independent approval. The [cycle retrospective](https://github.com/git-stunts/git-cas/blob/d50c77238e8b956fb70c2d51d2dcf9663c09c789/docs/method/retro/0063-durable-reservations/durable-reservations.md) preserves that distinction. All 14 release steps passed on merged main across separate runtime phases, with 8,265 passing test observations and 18 existing runtime-specific skips. The earlier combined-worker Deno failure remains recorded; fresh isolated Deno verification and the tagged release workflow passed. A fresh npm consumer verified lifecycle, refusal, original/final evidence, close/reopen and real Git GC in SHA-1 and SHA-256 stores. #162 retains both candidate and published artifact identities; they are separate builds.
|
|
26
24
|
|
|
27
|
-
git-warp must install
|
|
25
|
+
git-warp must install this published artifact before claiming adoption. WARP authorization, observation receipts, Coordinates and shared custody integration remain outside this storage release.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# git-cas v7.2.0: path-compressed reservation index
|
|
2
|
+
|
|
3
|
+
This release candidate makes each reservation ledger update write about log16(records) index trees instead of 64. The change merged in [PR #168](https://github.com/git-stunts/git-cas/pull/168) for [#167](https://github.com/git-stunts/git-cas/issues/167). [Issue #169](https://github.com/git-stunts/git-cas/issues/169) tracks release verification and publication. This document claims no published 7.2.0 artifact.
|
|
4
|
+
|
|
5
|
+
## Change
|
|
6
|
+
|
|
7
|
+
The reservation index was a 16-way trie with one tree per hex digit of a key's 64-digit route, so every record sat 64 trees deep and every update rewrote all 64. A record now sits at the shortest route prefix no other record shares. Inserting a key that meets another key's record pushes both down to the first digit where their routes differ. Sixty-four levels remain the worst case, so the documented listing and node bounds are unchanged.
|
|
8
|
+
|
|
9
|
+
Measured in a native repository after 400 prior records, one `reserve` wrote 68 objects under 7.1.0 and writes 7 under this release, in both SHA-1 and SHA-256 stores (`test/integration/reservation-index-cost.test.js`).
|
|
10
|
+
|
|
11
|
+
## Compatibility
|
|
12
|
+
|
|
13
|
+
The public API is unchanged. An index written by 7.1.0 places every record at full depth, which is a valid uncompressed trie: it reads, updates and lists without migration, and new keys branch off early.
|
|
14
|
+
|
|
15
|
+
git-cas 7.1.0 refuses an index written by this release as `RESERVATION_CORRUPT` on read, list and recovery. The failure is loud rather than silent, but every process that reads or writes a clone's reservation ledger must upgrade together, and downgrading after 7.2.0 has written a ledger is not supported.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@git-stunts/git-cas",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"description": "Content-addressed storage backed by Git's object database, with optional encryption and pluggable codecs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -59,7 +59,8 @@
|
|
|
59
59
|
"docs/releases/v6.5.11.md",
|
|
60
60
|
"docs/releases/v6.5.12.md",
|
|
61
61
|
"docs/releases/v7.0.0.md",
|
|
62
|
-
"docs/releases/v7.1.0.md"
|
|
62
|
+
"docs/releases/v7.1.0.md",
|
|
63
|
+
"docs/releases/v7.2.0.md"
|
|
63
64
|
],
|
|
64
65
|
"engines": {
|
|
65
66
|
"node": ">=22.0.0"
|
|
@@ -4,7 +4,7 @@ import ReservationRecordCodecPort, { RESERVATION_RECORD_MAX_BYTES } from '../../
|
|
|
4
4
|
import InvalidOptionsError from '../errors/InvalidOptionsError.js';
|
|
5
5
|
import ReservationStorageError from '../errors/ReservationStorageError.js';
|
|
6
6
|
import Oid from '../value-objects/Oid.js';
|
|
7
|
-
import ReservationKey
|
|
7
|
+
import ReservationKey from '../value-objects/ReservationKey.js';
|
|
8
8
|
import ReservationRecord from './ReservationRecord.js';
|
|
9
9
|
import ReservationIndexNode from './ReservationIndexNode.js';
|
|
10
10
|
import ReservationScan from './ReservationScan.js';
|
|
@@ -12,9 +12,13 @@ import ReservationScan from './ReservationScan.js';
|
|
|
12
12
|
const NODE_BYTES = 2 * 1024;
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* Private immutable point index
|
|
16
|
-
*
|
|
17
|
-
*
|
|
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.
|
|
18
22
|
*/
|
|
19
23
|
export default class ReservationIndex {
|
|
20
24
|
#persistence;
|
|
@@ -35,8 +39,16 @@ export default class ReservationIndex {
|
|
|
35
39
|
async get(root, key) {
|
|
36
40
|
const identity = new ReservationKey(key);
|
|
37
41
|
const route = await identity.route(this.#crypto);
|
|
38
|
-
const { leaf } = await this.#walk(root, route);
|
|
39
|
-
|
|
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;
|
|
40
52
|
}
|
|
41
53
|
|
|
42
54
|
async empty() {
|
|
@@ -45,87 +57,147 @@ export default class ReservationIndex {
|
|
|
45
57
|
|
|
46
58
|
async scan(root, request) {
|
|
47
59
|
const scan = new ReservationScan(request);
|
|
48
|
-
const complete = await this.#scanNode(checkedOid(root), '', scan);
|
|
60
|
+
const complete = await this.#scanNode({ oid: checkedOid(root), type: 'tree' }, '', scan);
|
|
49
61
|
if (!complete && scan.after === (request.cursor?.after ?? null)) {
|
|
50
62
|
throw new ReservationStorageError('Reservation traversal made no progress within its budget');
|
|
51
63
|
}
|
|
52
64
|
return scan.finish(complete);
|
|
53
65
|
}
|
|
54
66
|
|
|
55
|
-
async #scanNode(
|
|
67
|
+
async #scanNode(entry, prefix, scan) {
|
|
56
68
|
if (scan.skip(prefix)) {
|
|
57
69
|
return true;
|
|
58
70
|
}
|
|
59
71
|
if (!scan.visit()) {
|
|
60
72
|
return false;
|
|
61
73
|
}
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
if (await new ReservationKey(record.key).route(this.#crypto) !== prefix) {
|
|
65
|
-
throw new ReservationStorageError('Reservation record does not belong at its indexed route');
|
|
66
|
-
}
|
|
67
|
-
scan.accept(record, prefix);
|
|
74
|
+
if (entry.type === 'blob') {
|
|
75
|
+
await this.#scanRecord(entry.oid, prefix, scan);
|
|
68
76
|
return true;
|
|
69
77
|
}
|
|
70
|
-
const node = await this.#node(oid, prefix.length);
|
|
78
|
+
const node = await this.#node(entry.oid, prefix.length);
|
|
71
79
|
if (prefix.length > 0 && node.entries.length === 0) {
|
|
72
80
|
throw new ReservationStorageError('Reservation index contains an empty internal branch');
|
|
73
81
|
}
|
|
74
|
-
for (const
|
|
75
|
-
if (!await this.#scanNode(
|
|
82
|
+
for (const child of node.entries) {
|
|
83
|
+
if (!await this.#scanNode(child, prefix + child.name, scan)) {
|
|
76
84
|
return false;
|
|
77
85
|
}
|
|
78
86
|
}
|
|
79
87
|
return true;
|
|
80
88
|
}
|
|
81
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
|
+
|
|
82
98
|
async put(root, record) {
|
|
83
99
|
if (!(record instanceof ReservationRecord)) {
|
|
84
100
|
throw new InvalidOptionsError('Reservation index writes require a validated record');
|
|
85
101
|
}
|
|
86
102
|
const route = await new ReservationKey(record.key).route(this.#crypto);
|
|
87
103
|
const { nodes, leaf } = await this.#walk(root, route);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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) {
|
|
91
147
|
const bytes = this.#codec.encode(record);
|
|
92
148
|
if (!(bytes instanceof Uint8Array) || bytes.length > RESERVATION_RECORD_MAX_BYTES) {
|
|
93
149
|
throw new ReservationStorageError('Encoded reservation record exceeds its byte limit');
|
|
94
150
|
}
|
|
95
|
-
|
|
151
|
+
const oid = checkedOid(await this.#persistence.writeBlob(bytes));
|
|
96
152
|
assertFormat(record, oid.length);
|
|
97
153
|
if (root !== null && root.length !== oid.length) {
|
|
98
154
|
throw new ReservationStorageError('Reservation update changed Git object format');
|
|
99
155
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
oid = next;
|
|
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');
|
|
108
163
|
}
|
|
109
164
|
return oid;
|
|
110
165
|
}
|
|
111
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. */
|
|
112
172
|
async #walk(root, route) {
|
|
113
|
-
let oid = root === null ? null : checkedOid(root);
|
|
114
173
|
const nodes = [];
|
|
115
|
-
|
|
116
|
-
|
|
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]);
|
|
117
178
|
nodes.push(node);
|
|
118
|
-
oid = node.child(route[depth]);
|
|
119
179
|
}
|
|
120
|
-
return { nodes, leaf:
|
|
180
|
+
return { nodes, leaf: entry?.oid ?? null };
|
|
121
181
|
}
|
|
122
182
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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) {
|
|
126
190
|
throw new ReservationStorageError('Reservation route resolves to another key');
|
|
127
191
|
}
|
|
128
|
-
return
|
|
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;
|
|
129
201
|
}
|
|
130
202
|
|
|
131
203
|
async #node(oid, depth) {
|
|
@@ -4,8 +4,13 @@ import { RESERVATION_ROUTE_DIGITS } from '../value-objects/ReservationKey.js';
|
|
|
4
4
|
|
|
5
5
|
const FANOUT = 16;
|
|
6
6
|
const DIGIT = /^[0-9a-f]$/u;
|
|
7
|
+
const MODES = Object.freeze({ blob: '100644', tree: '040000' });
|
|
7
8
|
|
|
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
|
+
*/
|
|
9
14
|
export default class ReservationIndexNode {
|
|
10
15
|
#entries;
|
|
11
16
|
|
|
@@ -13,8 +18,7 @@ export default class ReservationIndexNode {
|
|
|
13
18
|
assertShape(entries, depth, oidLength);
|
|
14
19
|
this.depth = depth;
|
|
15
20
|
this.oidLength = oidLength;
|
|
16
|
-
|
|
17
|
-
this.#entries = Object.freeze(entries.map((entry) => checkedEntry(entry, type, oidLength)));
|
|
21
|
+
this.#entries = Object.freeze(entries.map((entry) => checkedEntry(entry, depth, oidLength)));
|
|
18
22
|
for (let i = 1; i < this.#entries.length; i++) {
|
|
19
23
|
if (this.#entries[i - 1].name >= this.#entries[i].name) {
|
|
20
24
|
throw new ReservationStorageError('Reservation node entries must be ordered and unique');
|
|
@@ -24,16 +28,15 @@ export default class ReservationIndexNode {
|
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
child(digit) {
|
|
27
|
-
return this.#entries.find((entry) => entry.name === digit)
|
|
31
|
+
return this.#entries.find((entry) => entry.name === digit) ?? null;
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
get entries() {
|
|
31
35
|
return this.#entries;
|
|
32
36
|
}
|
|
33
37
|
|
|
34
|
-
withChild(digit, oid) {
|
|
35
|
-
const
|
|
36
|
-
const entry = { name: digit, oid, type, mode: type === 'blob' ? '100644' : '040000' };
|
|
38
|
+
withChild(digit, { oid, type }) {
|
|
39
|
+
const entry = { name: digit, oid, type, mode: MODES[type] };
|
|
37
40
|
const entries = [...this.#entries.filter((item) => item.name !== digit), entry];
|
|
38
41
|
entries.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
39
42
|
return new ReservationIndexNode({ entries, depth: this.depth, oidLength: this.oidLength });
|
|
@@ -56,16 +59,16 @@ function assertShape(entries, depth, oidLength) {
|
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
61
|
|
|
59
|
-
function checkedEntry(entry,
|
|
62
|
+
function checkedEntry(entry, depth, oidLength) {
|
|
60
63
|
assertRoutingName(entry);
|
|
61
|
-
const
|
|
62
|
-
if (entry.type !== type || entry.mode !==
|
|
64
|
+
const final = depth === RESERVATION_ROUTE_DIGITS - 1;
|
|
65
|
+
if ((entry.type !== 'blob' && (final || entry.type !== 'tree')) || entry.mode !== MODES[entry.type]) {
|
|
63
66
|
throw new ReservationStorageError('Reservation index entry type or mode is invalid');
|
|
64
67
|
}
|
|
65
68
|
if (!Oid.isValid(entry.oid) || entry.oid.length !== oidLength || Oid.from(entry.oid).toString() !== entry.oid) {
|
|
66
69
|
throw new ReservationStorageError('Reservation index entry OID is invalid');
|
|
67
70
|
}
|
|
68
|
-
return Object.freeze({ name: entry.name, mode, type, oid: entry.oid });
|
|
71
|
+
return Object.freeze({ name: entry.name, mode: entry.mode, type: entry.type, oid: entry.oid });
|
|
69
72
|
}
|
|
70
73
|
|
|
71
74
|
function assertRoutingName(entry) {
|
|
@@ -22,6 +22,11 @@ export default class ReservationScan {
|
|
|
22
22
|
return this.#after !== null && prefix.padEnd(64, 'f') <= this.#after;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
/** A record above full depth can hold a route an earlier page already listed. */
|
|
26
|
+
listed(route) {
|
|
27
|
+
return this.#after !== null && route <= this.#after;
|
|
28
|
+
}
|
|
29
|
+
|
|
25
30
|
visit() {
|
|
26
31
|
if (this.#visited === this.#request.nodeBudget || this.#records.length === this.#request.limit) {
|
|
27
32
|
return false;
|
package/src/package-version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const PACKAGE_VERSION = '7.
|
|
1
|
+
export const PACKAGE_VERSION = '7.2.0';
|