@amalgm/shell 0.1.164-main.42043846733 → 0.1.164-main.42054328268
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/entity-grant-watch.d.ts +4 -5
- package/dist/entity-grant-watch.js +11 -41
- package/dist/entity-grant-watch.js.map +1 -1
- package/dist/native/cloud-files.node +0 -0
- package/dist/native/windows-fs.node +0 -0
- package/dist/user-ground-host.d.ts +10 -0
- package/dist/user-ground-host.js +35 -3
- package/dist/user-ground-host.js.map +1 -1
- package/dist/wire-join.d.ts +19 -0
- package/dist/wire-join.js +54 -0
- package/dist/wire-join.js.map +1 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +4 -4
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The one watch this computer keeps on its own grant signal. The authority
|
|
3
|
-
* holds a watch per socket, so a dropped wire ends it. The watch is asked
|
|
4
|
-
* the
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* background: a computer with no network starts, and joins when one returns.
|
|
3
|
+
* holds a watch per socket, so a dropped wire ends it. The watch is asked on
|
|
4
|
+
* every join of the wire (wire-join.ts), and what the gap hid (at start,
|
|
5
|
+
* everything) is read again by saying "gap" only after the new watch stands,
|
|
6
|
+
* so no signal falls between.
|
|
8
7
|
*/
|
|
9
8
|
import type { EntityAccessWirePort, GrantSignal } from "./entity-access-wire.js";
|
|
10
9
|
export declare function watchGrantSignals(wire: EntityAccessWirePort, listener: (signal: GrantSignal) => void): () => void;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The one watch this computer keeps on its own grant signal. The authority
|
|
3
|
-
* holds a watch per socket, so a dropped wire ends it. The watch is asked
|
|
4
|
-
* the
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* background: a computer with no network starts, and joins when one returns.
|
|
3
|
+
* holds a watch per socket, so a dropped wire ends it. The watch is asked on
|
|
4
|
+
* every join of the wire (wire-join.ts), and what the gap hid (at start,
|
|
5
|
+
* everything) is read again by saying "gap" only after the new watch stands,
|
|
6
|
+
* so no signal falls between.
|
|
8
7
|
*/
|
|
9
|
-
import {
|
|
8
|
+
import { askOnEveryJoin } from "./wire-join.js";
|
|
10
9
|
const isGrantFrame = (frame) => typeof frame === "object" && frame !== null && frame.type === "entity.grant.changed";
|
|
11
10
|
export function watchGrantSignals(wire, listener) {
|
|
12
|
-
const ask = () => wire.request({ type: "entity.access.watch" }, ["entity.access.watching"]);
|
|
13
11
|
const stopFrames = wire.onFrame((frame) => {
|
|
14
12
|
if (!isGrantFrame(frame))
|
|
15
13
|
return;
|
|
@@ -18,42 +16,14 @@ export function watchGrantSignals(wire, listener) {
|
|
|
18
16
|
revoked: frame.revoked === true,
|
|
19
17
|
});
|
|
20
18
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (joining) {
|
|
27
|
-
droppedAgain = true;
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
joining = true;
|
|
31
|
-
let delay = ENTITY_RECORD_RETRY_BASE_MS;
|
|
32
|
-
while (!stopped) {
|
|
33
|
-
droppedAgain = false;
|
|
34
|
-
const answered = await ask().then(() => true, () => false);
|
|
35
|
-
if (answered && !droppedAgain)
|
|
36
|
-
break;
|
|
37
|
-
if (answered)
|
|
38
|
-
continue;
|
|
39
|
-
await new Promise((resolve) => {
|
|
40
|
-
retry = setTimeout(resolve, delay);
|
|
41
|
-
retry.unref();
|
|
42
|
-
});
|
|
43
|
-
delay = Math.min(delay * 2, ENTITY_RECORD_RETRY_MAX_MS);
|
|
44
|
-
}
|
|
45
|
-
joining = false;
|
|
46
|
-
if (!stopped)
|
|
47
|
-
listener({ entityId: null, revoked: false });
|
|
48
|
-
};
|
|
49
|
-
const stopDrops = wire.onDisconnect(() => void join());
|
|
50
|
-
void join();
|
|
19
|
+
const stopJoins = askOnEveryJoin({
|
|
20
|
+
onDisconnect: (heard) => wire.onDisconnect(heard),
|
|
21
|
+
ask: () => wire.request({ type: "entity.access.watch" }, ["entity.access.watching"]),
|
|
22
|
+
answered: () => listener({ entityId: null, revoked: false }),
|
|
23
|
+
});
|
|
51
24
|
return () => {
|
|
52
|
-
|
|
53
|
-
if (retry)
|
|
54
|
-
clearTimeout(retry);
|
|
25
|
+
stopJoins();
|
|
55
26
|
stopFrames();
|
|
56
|
-
stopDrops();
|
|
57
27
|
};
|
|
58
28
|
}
|
|
59
29
|
//# sourceMappingURL=entity-grant-watch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-grant-watch.js","sourceRoot":"","sources":["../src/entity-grant-watch.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"entity-grant-watch.js","sourceRoot":"","sources":["../src/entity-grant-watch.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,YAAY,GAAG,CAAC,KAAc,EAAuD,EAAE,CAC3F,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAK,KAA4B,CAAC,IAAI,KAAK,sBAAsB,CAAC;AAE/G,MAAM,UAAU,iBAAiB,CAC/B,IAA0B,EAC1B,QAAuC;IAEvC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACxC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;YAAE,OAAO;QACjC,QAAQ,CAAC;YACP,QAAQ,EAAE,OAAO,KAAK,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI;YACtE,OAAO,EAAE,KAAK,CAAC,OAAO,KAAK,IAAI;SAChC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,cAAc,CAAC;QAC/B,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;QACjD,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,EAAE,CAAC,wBAAwB,CAAC,CAAC;QACpF,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;KAC7D,CAAC,CAAC;IACH,OAAO,GAAG,EAAE;QACV,SAAS,EAAE,CAAC;QACZ,UAAU,EAAE,CAAC;IACf,CAAC,CAAC;AACJ,CAAC"}
|
|
Binary file
|
|
Binary file
|
|
@@ -303,6 +303,7 @@ export declare class UserGroundHost {
|
|
|
303
303
|
private constructLedger;
|
|
304
304
|
private constructDoor;
|
|
305
305
|
private releaseGrantWatch;
|
|
306
|
+
private releaseHeadWatch;
|
|
306
307
|
private applyRail;
|
|
307
308
|
private applyHost;
|
|
308
309
|
/** The last placement of accepted declarations (reference-placement.ts);
|
|
@@ -434,6 +435,9 @@ export declare class UserGroundHost {
|
|
|
434
435
|
/** Records arrived, or these entities' O rows changed: every map reads
|
|
435
436
|
* the received prefix again and takes each entity where it stands now. */
|
|
436
437
|
private wakeDriveMaps;
|
|
438
|
+
/** What every map lists may have changed at no new position: each loads
|
|
439
|
+
* again. */
|
|
440
|
+
private reloadDriveMaps;
|
|
437
441
|
private closeDriveMaps;
|
|
438
442
|
private wakeObservedApply;
|
|
439
443
|
/** A Detect dependency is a request, never a hope. It is made in the same
|
|
@@ -885,6 +889,12 @@ export declare class UserGroundHost {
|
|
|
885
889
|
* rows standing now: a later one is its Register's, which submits and
|
|
886
890
|
* places it itself. */
|
|
887
891
|
private resolveLeftDeclarations;
|
|
892
|
+
/** A Register on another computer publishes only the graph head, which no
|
|
893
|
+
* delivery announces, and placed ground reads no head to start. So the
|
|
894
|
+
* head is read in the background once ready and on every join of the wire
|
|
895
|
+
* (wire-join.ts), and a newer one reloads the drive (keepGraphHead). A
|
|
896
|
+
* computer that stays connected hears the next one at its next join. */
|
|
897
|
+
private watchGraphHead;
|
|
888
898
|
/** AV: the authority's current head H plus every accepted result Receive
|
|
889
899
|
* has delivered after its watermark M. The head is read fresh, because a
|
|
890
900
|
* graph-head commit is never an entity delivery. `beyond` is a delivery a
|
package/dist/user-ground-host.js
CHANGED
|
@@ -79,6 +79,7 @@ import { beginGroundWait, GroundCoordinator, GroundEffectCrossedError, GroundFoo
|
|
|
79
79
|
import { physicalPath } from "./sync-address.js";
|
|
80
80
|
import { readAcceptedTail } from "./accepted-tail.js";
|
|
81
81
|
import { readDeliveryReceipt, readGraphBasis, readNewestGraphHead } from "./graph-heads.js";
|
|
82
|
+
import { askOnEveryJoin } from "./wire-join.js";
|
|
82
83
|
import { AcceptedFold } from "./accepted-fold.js";
|
|
83
84
|
import { journaledDeclaration, readDeclarationJournal } from "./declaration-journal.js";
|
|
84
85
|
import { acceptedView, derivePublication } from "./graph-publication.js";
|
|
@@ -258,6 +259,7 @@ export class UserGroundHost {
|
|
|
258
259
|
constructLedger = null;
|
|
259
260
|
constructDoor = null;
|
|
260
261
|
releaseGrantWatch = null;
|
|
262
|
+
releaseHeadWatch = null;
|
|
261
263
|
applyRail = null;
|
|
262
264
|
applyHost = null;
|
|
263
265
|
/** The last placement of accepted declarations (reference-placement.ts);
|
|
@@ -485,6 +487,7 @@ export class UserGroundHost {
|
|
|
485
487
|
// before the stop still owes its way in core, which it holds W until
|
|
486
488
|
// placed.
|
|
487
489
|
this.resolveLeftDeclarations(this.activeIdentity, this.authorityId);
|
|
490
|
+
this.watchGraphHead(this.activeIdentity, this.authorityId);
|
|
488
491
|
// Native rings collected while convergence was establishing Watch
|
|
489
492
|
// coverage are ordinary evidence, not a startup exception. They get
|
|
490
493
|
// one Detect generation now that Apply recovery is authoritative.
|
|
@@ -708,6 +711,13 @@ export class UserGroundHost {
|
|
|
708
711
|
void map.refresh(uuids).catch((error) => this.options.onBackgroundError?.(error));
|
|
709
712
|
}
|
|
710
713
|
}
|
|
714
|
+
/** What every map lists may have changed at no new position: each loads
|
|
715
|
+
* again. */
|
|
716
|
+
reloadDriveMaps() {
|
|
717
|
+
for (const map of this.driveMaps.values())
|
|
718
|
+
map.drop();
|
|
719
|
+
this.wakeDriveMaps();
|
|
720
|
+
}
|
|
711
721
|
closeDriveMaps() {
|
|
712
722
|
for (const map of this.driveMaps.values())
|
|
713
723
|
map.drop();
|
|
@@ -1989,9 +1999,7 @@ export class UserGroundHost {
|
|
|
1989
1999
|
this.applyRail?.capabilityChanged();
|
|
1990
2000
|
this.applyRail?.localStateChanged();
|
|
1991
2001
|
// An Add admits a whole root's rows at once: every map loads again.
|
|
1992
|
-
|
|
1993
|
-
map.drop();
|
|
1994
|
-
this.wakeDriveMaps();
|
|
2002
|
+
this.reloadDriveMaps();
|
|
1995
2003
|
}
|
|
1996
2004
|
async startRecordRail(identity) {
|
|
1997
2005
|
if (!this.authorityId)
|
|
@@ -2425,6 +2433,8 @@ export class UserGroundHost {
|
|
|
2425
2433
|
await attempt(() => this.ownedWire?.dispose());
|
|
2426
2434
|
this.releaseGrantWatch?.();
|
|
2427
2435
|
this.releaseGrantWatch = null;
|
|
2436
|
+
this.releaseHeadWatch?.();
|
|
2437
|
+
this.releaseHeadWatch = null;
|
|
2428
2438
|
this.entityAccess = null;
|
|
2429
2439
|
this.constructLedger = null;
|
|
2430
2440
|
this.constructDoor = null;
|
|
@@ -2870,6 +2880,8 @@ export class UserGroundHost {
|
|
|
2870
2880
|
async keepGraphHead(frame, head) {
|
|
2871
2881
|
if (head.graph.checksum() !== head.checksum)
|
|
2872
2882
|
throw new Error("cloud registry head does not match its checksum");
|
|
2883
|
+
const database = groundDatabase(this.databasePath());
|
|
2884
|
+
const newest = readNewestGraphHead(database, head.resourceId)?.checksum;
|
|
2873
2885
|
await save(this.databasePath(), "record.keepGraphHead", {
|
|
2874
2886
|
authorityId: head.resourceId,
|
|
2875
2887
|
deliveryWatermark: head.deliveryWatermark,
|
|
@@ -2877,6 +2889,10 @@ export class UserGroundHost {
|
|
|
2877
2889
|
snapshot: Buffer.from(String(frame.snapshot_b64 || ""), "base64"),
|
|
2878
2890
|
checksum: head.checksum,
|
|
2879
2891
|
});
|
|
2892
|
+
// A head the drive reads moved with no delivery (a Register sends none),
|
|
2893
|
+
// so no position wakes the maps.
|
|
2894
|
+
if (readNewestGraphHead(database, head.resourceId)?.checksum !== newest)
|
|
2895
|
+
this.reloadDriveMaps();
|
|
2880
2896
|
}
|
|
2881
2897
|
/** The authority's stored snapshot as this machine's graph. A head is held
|
|
2882
2898
|
* lazily — no page is read until an operation asks for a root — and every
|
|
@@ -5135,6 +5151,22 @@ export class UserGroundHost {
|
|
|
5135
5151
|
};
|
|
5136
5152
|
attempt();
|
|
5137
5153
|
}
|
|
5154
|
+
/** A Register on another computer publishes only the graph head, which no
|
|
5155
|
+
* delivery announces, and placed ground reads no head to start. So the
|
|
5156
|
+
* head is read in the background once ready and on every join of the wire
|
|
5157
|
+
* (wire-join.ts), and a newer one reloads the drive (keepGraphHead). A
|
|
5158
|
+
* computer that stays connected hears the next one at its next join. */
|
|
5159
|
+
watchGraphHead(identity, resourceId) {
|
|
5160
|
+
this.releaseHeadWatch = askOnEveryJoin({
|
|
5161
|
+
onDisconnect: (heard) => this.wire.onDisconnect(heard),
|
|
5162
|
+
ask: () => this.operation(() => this.readHead(identity, resourceId, { kind: "none" })),
|
|
5163
|
+
failed: (error) => {
|
|
5164
|
+
if (this.closing || this.wire.signal.aborted)
|
|
5165
|
+
return;
|
|
5166
|
+
this.options.onBackgroundError?.(error instanceof Error ? error : new Error(String(error)));
|
|
5167
|
+
},
|
|
5168
|
+
});
|
|
5169
|
+
}
|
|
5138
5170
|
/** AV: the authority's current head H plus every accepted result Receive
|
|
5139
5171
|
* has delivered after its watermark M. The head is read fresh, because a
|
|
5140
5172
|
* graph-head commit is never an entity delivery. `beyond` is a delivery a
|