agent-comms 9.1.0 → 9.1.2
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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +1 -1
- package/dist/bridges/user/web/request-handling.d.ts +26 -0
- package/dist/bridges/user/web/request-handling.d.ts.map +1 -0
- package/dist/bridges/user/web/request-handling.js +92 -0
- package/dist/bridges/user/web/request-handling.js.map +1 -0
- package/dist/bridges/user/web/server.d.ts +4 -0
- package/dist/bridges/user/web/server.d.ts.map +1 -1
- package/dist/bridges/user/web/server.js +88 -53
- package/dist/bridges/user/web/server.js.map +1 -1
- package/dist/bridges/user/web/web-access.d.ts.map +1 -1
- package/dist/bridges/user/web/web-access.js +14 -1
- package/dist/bridges/user/web/web-access.js.map +1 -1
- package/dist/bridges/user/web/web-assets.d.ts +2 -1
- package/dist/bridges/user/web/web-assets.d.ts.map +1 -1
- package/dist/bridges/user/web/web-assets.js +2 -2
- package/dist/bridges/user/web/web-assets.js.map +1 -1
- package/dist/bridges/user/web/web-console-static.d.ts.map +1 -1
- package/dist/bridges/user/web/web-console-static.js +34 -22
- package/dist/bridges/user/web/web-console-static.js.map +1 -1
- package/dist/core/coordinator-role.d.ts +15 -2
- package/dist/core/coordinator-role.d.ts.map +1 -1
- package/dist/core/coordinator-role.js +109 -11
- package/dist/core/coordinator-role.js.map +1 -1
- package/dist/core/detached-work.d.ts +14 -0
- package/dist/core/detached-work.d.ts.map +1 -0
- package/dist/core/detached-work.js +40 -0
- package/dist/core/detached-work.js.map +1 -0
- package/dist/core/election-sessions.d.ts.map +1 -1
- package/dist/core/election-sessions.js +6 -6
- package/dist/core/election-sessions.js.map +1 -1
- package/dist/core/hub-session.d.ts +10 -1
- package/dist/core/hub-session.d.ts.map +1 -1
- package/dist/core/hub-session.js +34 -32
- package/dist/core/hub-session.js.map +1 -1
- package/dist/core/message-limits.d.ts +14 -0
- package/dist/core/message-limits.d.ts.map +1 -0
- package/dist/core/message-limits.js +22 -0
- package/dist/core/message-limits.js.map +1 -0
- package/dist/core/peer-lifecycle.d.ts +2 -0
- package/dist/core/peer-lifecycle.d.ts.map +1 -1
- package/dist/core/peer-lifecycle.js +9 -4
- package/dist/core/peer-lifecycle.js.map +1 -1
- package/dist/core/pending-connection.d.ts +20 -1
- package/dist/core/pending-connection.d.ts.map +1 -1
- package/dist/core/pending-connection.js +27 -0
- package/dist/core/pending-connection.js.map +1 -1
- package/dist/core/relay-server.d.ts +15 -1
- package/dist/core/relay-server.d.ts.map +1 -1
- package/dist/core/relay-server.js +70 -16
- package/dist/core/relay-server.js.map +1 -1
- package/dist/core/room-router.d.ts.map +1 -1
- package/dist/core/room-router.js +31 -10
- package/dist/core/room-router.js.map +1 -1
- package/dist/core/tool.d.ts.map +1 -1
- package/dist/core/tool.js +3 -0
- package/dist/core/tool.js.map +1 -1
- package/dist/core/transport-events.d.ts.map +1 -1
- package/dist/core/transport-events.js +9 -5
- package/dist/core/transport-events.js.map +1 -1
- package/dist/core/wire-mesh-transport.d.ts +2 -2
- package/dist/core/wire-mesh-transport.d.ts.map +1 -1
- package/dist/core/wire-mesh-transport.js +96 -115
- package/dist/core/wire-mesh-transport.js.map +1 -1
- package/package.json +1 -1
- package/src/bridges/user/web/request-handling.ts +118 -0
- package/src/bridges/user/web/server.ts +109 -54
- package/src/bridges/user/web/web-access.ts +14 -1
- package/src/bridges/user/web/web-assets.ts +7 -3
- package/src/bridges/user/web/web-console-static.ts +34 -26
- package/src/core/coordinator-role.ts +126 -7
- package/src/core/detached-work.ts +55 -0
- package/src/core/election-sessions.ts +8 -4
- package/src/core/hub-session.ts +63 -41
- package/src/core/message-limits.ts +29 -0
- package/src/core/peer-lifecycle.ts +10 -4
- package/src/core/pending-connection.ts +48 -1
- package/src/core/relay-server.ts +110 -23
- package/src/core/room-router.ts +36 -9
- package/src/core/tool.ts +3 -0
- package/src/core/transport-events.ts +9 -5
- package/src/core/w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,4XAA4X;AAC5X,MAAM,UAAU,UAAU,CACxB,MAA2D,EAC3D,aAEI,EAAE,CAAC,iBAAiB;IAExB,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACpC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,aAAa,CAAC;QACrE,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,EAAE,CAAC;YACpD,KAAK,MAAM,KAAK,IAAI,SAAS,IAAI,EAAE,EAAE,CAAC;gBACpC,IAAI,KAAK,CAAC,QAAQ,IAAI,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;oBAAE,SAAS;gBAClE,IAAI,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM;oBAAE,SAAS;gBAClD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;IACH,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,KAAK,CAAC,GAAG,CACd,CAAC,IAAI,EAAE,EAAE,CACP,UAAU,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,kBAAkB,IAAI,MAAM,CAAC,KAAK,EAAE,CACjF,CAAC;AACJ,CAAC"}
|
|
@@ -10,7 +10,8 @@ export interface FrontendAssets {
|
|
|
10
10
|
meshWorkerJs: string;
|
|
11
11
|
swJs: string;
|
|
12
12
|
manifestJson: string;
|
|
13
|
-
icons:
|
|
13
|
+
/** The PWA icons by file name. A map, not an object: the name comes from the request path, and an object would also answer a name that is a member of every object (`constructor`, `toString`). */
|
|
14
|
+
icons: ReadonlyMap<string, Buffer>;
|
|
14
15
|
}
|
|
15
16
|
/** The frontend build output is absent from the directory it should be in. */
|
|
16
17
|
export declare class FrontendNotBuiltError extends Error {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-assets.d.ts","sourceRoot":"","sources":["../../../../src/bridges/user/web/web-assets.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,+EAA+E;IAC/E,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"web-assets.d.ts","sourceRoot":"","sources":["../../../../src/bridges/user/web/web-assets.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,+EAA+E;IAC/E,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,mMAAmM;IACnM,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC;AAED,8EAA8E;AAC9E,qBAAa,qBAAsB,SAAQ,KAAK;aAClB,QAAQ,EAAE,MAAM;gBAAhB,QAAQ,EAAE,MAAM;CAM7C;AAiBD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,CAyBnE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,GACf,MAAM,cAAc,CAMtB"}
|
|
@@ -40,9 +40,9 @@ export function loadFrontendAssets(assetDir) {
|
|
|
40
40
|
const indexHtml = readIfPresent(path.join(assetDir, "index.html"));
|
|
41
41
|
if (indexHtml === undefined)
|
|
42
42
|
throw new FrontendNotBuiltError(assetDir);
|
|
43
|
-
const icons =
|
|
43
|
+
const icons = new Map();
|
|
44
44
|
for (const filename of ICON_FILENAMES) {
|
|
45
|
-
icons
|
|
45
|
+
icons.set(filename, fs.readFileSync(path.join(assetDir, "icons", filename)));
|
|
46
46
|
}
|
|
47
47
|
return {
|
|
48
48
|
indexHtml,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-assets.js","sourceRoot":"","sources":["../../../../src/bridges/user/web/web-assets.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,6DAA6D;AAC7D,MAAM,cAAc,GAAG;IACrB,gBAAgB;IAChB,kBAAkB;IAClB,kBAAkB;CACV,CAAC;
|
|
1
|
+
{"version":3,"file":"web-assets.js","sourceRoot":"","sources":["../../../../src/bridges/user/web/web-assets.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,6DAA6D;AAC7D,MAAM,cAAc,GAAG;IACrB,gBAAgB;IAChB,kBAAkB;IAClB,kBAAkB;CACV,CAAC;AAaX,8EAA8E;AAC9E,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAClB;IAA5B,YAA4B,QAAgB;QAC1C,KAAK,CACH,kCAAkC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,mLAAmL,CACvP,CAAC;QAHwB,aAAQ,GAAR,QAAQ,CAAQ;QAI1C,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AAED,SAAS,aAAa,CAAC,IAAY;IACjC,IAAI,CAAC;QACH,OAAO,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;Q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AAyB,CACvC,QAAgB;IAEhB,IAAI,MAAkC,CAAC;IACvC,OAAO,GAAG,EAAE;QACV,MAAM,KAAK,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QACxC,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-console-static.d.ts","sourceRoot":"","sources":["../../../../src/bridges/user/web/web-console-static.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAC;AAEvC,gEAAgE;AAChE,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"web-console-static.d.ts","sourceRoot":"","sources":["../../../../src/bridges/user/web/web-console-static.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAC;AAEvC,gEAAgE;AAChE,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAwBhD;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,GAAG,SAAS,CAM1D;AAgBD;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,IAAI,CAAC,cAAc,GACvB,OAAO,CA0BT"}
|
|
@@ -9,21 +9,22 @@ import * as path from "node:path";
|
|
|
9
9
|
export const WEB_CONSOLE_MOUNT = "/web-console";
|
|
10
10
|
const HTTP_OK = 200;
|
|
11
11
|
const HTTP_NOT_FOUND = 404;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
".
|
|
15
|
-
".
|
|
16
|
-
".
|
|
17
|
-
".
|
|
18
|
-
".
|
|
19
|
-
".
|
|
20
|
-
".
|
|
21
|
-
".
|
|
22
|
-
".
|
|
23
|
-
".
|
|
24
|
-
".
|
|
25
|
-
".
|
|
26
|
-
|
|
12
|
+
/** Content type by extension. A map: the extension comes from the requested name, and an object would also answer a name that is a member of every object. */
|
|
13
|
+
const CONTENT_TYPES = new Map([
|
|
14
|
+
[".html", "text/html; charset=utf-8"],
|
|
15
|
+
[".js", "application/javascript; charset=utf-8"],
|
|
16
|
+
[".mjs", "application/javascript; charset=utf-8"],
|
|
17
|
+
[".css", "text/css; charset=utf-8"],
|
|
18
|
+
[".json", "application/json; charset=utf-8"],
|
|
19
|
+
[".map", "application/json; charset=utf-8"],
|
|
20
|
+
[".svg", "image/svg+xml"],
|
|
21
|
+
[".png", "image/png"],
|
|
22
|
+
[".ico", "image/x-icon"],
|
|
23
|
+
[".woff", "font/woff"],
|
|
24
|
+
[".woff2", "font/woff2"],
|
|
25
|
+
[".txt", "text/plain; charset=utf-8"],
|
|
26
|
+
[".wasm", "application/wasm"],
|
|
27
|
+
]);
|
|
27
28
|
const DEFAULT_CONTENT_TYPE = "application/octet-stream";
|
|
28
29
|
/**
|
|
29
30
|
* Resolves the configured web-console dist directory, if any.
|
|
@@ -39,6 +40,20 @@ export function resolveWebConsoleDist() {
|
|
|
39
40
|
return undefined;
|
|
40
41
|
return dist;
|
|
41
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* The real path of `file`, when it is a regular file that lies inside `dist` once every symbolic link in both paths has been followed, and undefined for anything else: a missing file, a directory, a name that cannot be resolved, or a link, anywhere along the path, that leads outside the directory. The name is checked after resolution, never before, so a link inside the directory cannot be used to read a file outside it.
|
|
45
|
+
*/
|
|
46
|
+
function realFileWithin(dist, file) {
|
|
47
|
+
try {
|
|
48
|
+
const realDist = fs.realpathSync(dist);
|
|
49
|
+
const realFile = fs.realpathSync(file);
|
|
50
|
+
const inside = realFile.startsWith(`${realDist}${path.sep}`);
|
|
51
|
+
return inside && fs.statSync(realFile).isFile() ? realFile : undefined;
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
42
57
|
/**
|
|
43
58
|
* Serves a request under the web-console mount from a resolved dist directory.
|
|
44
59
|
*
|
|
@@ -53,18 +68,15 @@ export function serveWebConsole(distDir, pathname, res) {
|
|
|
53
68
|
const relative = suffix === "" || suffix === "/" ? "index.html" : suffix.slice(1);
|
|
54
69
|
const resolvedDist = path.resolve(distDir);
|
|
55
70
|
const resolvedFile = path.resolve(resolvedDist, relative);
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
if (!withinDist ||
|
|
59
|
-
!fs.existsSync(resolvedFile) ||
|
|
60
|
-
!fs.statSync(resolvedFile).isFile()) {
|
|
71
|
+
const servable = realFileWithin(resolvedDist, resolvedFile);
|
|
72
|
+
if (servable === undefined) {
|
|
61
73
|
res.writeHead(HTTP_NOT_FOUND);
|
|
62
74
|
res.end("Not found");
|
|
63
75
|
return true;
|
|
64
76
|
}
|
|
65
|
-
const contentType = CONTENT_TYPES
|
|
77
|
+
const contentType = CONTENT_TYPES.get(path.extname(servable)) ?? DEFAULT_CONTENT_TYPE;
|
|
66
78
|
res.writeHead(HTTP_OK, { "Content-Type": contentType });
|
|
67
|
-
res.end(fs.readFileSync(
|
|
79
|
+
res.end(fs.readFileSync(servable));
|
|
68
80
|
return true;
|
|
69
81
|
}
|
|
70
82
|
//# sourceMappingURL=web-console-static.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-console-static.js","sourceRoot":"","sources":["../../../../src/bridges/user/web/web-console-static.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,gEAAgE;AAChE,MAAM,CAAC,MAAM,iBAAiB,GAAG,cAAc,CAAC;AAEhD,MAAM,OAAO,GAAG,GAAG,CAAC;AACpB,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"web-console-static.js","sourceRoot":"","sources":["../../../../src/bridges/user/web/web-console-static.ts"],"names":[],"mapp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,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,GAAG,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;QAC9B,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,WAAW,GACf,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,oBAAoB,CAAC;IACpE,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,CAAC,CAAC;IACxD,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;IACnC,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Claims travel as wire-mesh session frames (MeshTransport.broadcastCoordinatorClaim/sendCoordinatorClaim), and only over sessions to peers on this machine, because both duties the role assigns are facts about one machine: a PID probe can only see local processes and the cc-peer front can only reach local Claude Code sessions.
|
|
5
5
|
*
|
|
6
|
-
* When a claim is made: a store claims only when it knows of no incumbent and is the first on the machine as far as it can tell. A store that bound the well-known port with no first-contact presence configured can meet other stores only through that port, so it claims at once; one that may be reachable through first contact (it bound the port, or could neither join nor bind it) first waits one claim wait for an incumbent's announcement, so a store arriving at an existing mesh never takes the role at an equal term before the holder's claim reaches it. Both ends of every machine-local session announce the incumbent they know as the session is enrolled. When the incumbent departs, the lowest device-id among the peers this side has a machine-local session to claims at once at a raised term, and every other survivor claims too if, one claim wait later, the claim it accepts still names a holder it has no session to, which covers a lowest-id peer that is itself gone or was never reachable.
|
|
6
|
+
* When a claim is made: a store claims only when it knows of no incumbent and is the first on the machine as far as it can tell. A store that bound the well-known port with no first-contact presence configured can meet other stores only through that port, so it claims at once; one that may be reachable through first contact (it bound the port, or could neither join nor bind it) first waits one claim wait for an incumbent's announcement, so a store arriving at an existing mesh never takes the role at an equal term before the holder's claim reaches it. Both ends of every machine-local session announce the incumbent they know as the session is enrolled. When the incumbent departs, the lowest device-id among the peers this side has a machine-local session to claims at once at a raised term, and every other survivor claims too if, one claim wait later, the claim it accepts still names a holder it has no session to, which covers a lowest-id peer that is itself gone or was never reachable. A claim that is accepted names a holder that is here when it is accepted, so the wait after an accepted claim never starts: the claim waits are the one after a departure and the one at start-up.
|
|
7
|
+
*
|
|
8
|
+
* Whose claims count: claims are accepted from the peers this machine already trusts with a machine-local session, and this module does not authenticate them further. A claim is evaluated only when its holder is this side, the peer that sent it (the session's authenticated device-id, never a field of the frame), or a peer this side has a machine-local session to. A claim gossiped onward by a peer other than its holder is therefore still accepted wherever the holder is reachable, which is every peer of a fully connected machine. Any other claim waits until its holder's session is enrolled and is dropped after one claim wait, and is not evaluated at all when, by then, its sender has no machine-local session. Waiting claims are bounded per sender: each machine-local peer has at most PENDING_CLAIMS_PER_SENDER of them, at most one per holder, kept in the election's own order (higher term first, an equal term by lowest holder id), and a claim whose term no later claim could supersede is not kept.
|
|
7
9
|
*/
|
|
8
10
|
import type { CoordinatorFrame } from "wire-mesh-core/generated/protocol";
|
|
9
11
|
import type { ConnectionHandle, MeshTransport } from "./transport.js";
|
|
@@ -39,6 +41,8 @@ export declare class CoordinatorRole {
|
|
|
39
41
|
private takeoverStreak;
|
|
40
42
|
/** The claim, as `term:holder`, each peer was last answered with. A peer whose view lags keeps sending the claims it knows, and answering each one with the same incumbent only multiplies the traffic: the answer is repeated only when the incumbent changes or the peer's session is enrolled afresh, since the earlier answer may have been lost with the old session. */
|
|
41
43
|
private readonly answered;
|
|
44
|
+
/** The claims set aside, by the device-id of the session that sent each, best first in the election's own order. */
|
|
45
|
+
private readonly pending;
|
|
42
46
|
constructor(deps: Readonly<CoordinatorRoleDeps>);
|
|
43
47
|
private get election();
|
|
44
48
|
/** Whether this side holds the role now. */
|
|
@@ -51,12 +55,21 @@ export declare class CoordinatorRole {
|
|
|
51
55
|
claimIfVacantAfterWait(): void;
|
|
52
56
|
/** Tells a peer whose machine-local session was just enrolled which claim this side accepts, so a joiner learns the incumbent instead of claiming over it. A no-op while this side knows of none. */
|
|
53
57
|
announceTo(handle: Readonly<ConnectionHandle>): Promise<void>;
|
|
54
|
-
/** Evaluates a claim a peer gossiped. An accepted claim is gossiped on to every peer so the supersession reaches peers the sender is not connected to,
|
|
58
|
+
/** Evaluates a claim a peer gossiped. An accepted claim is gossiped on to every peer so the supersession reaches peers the sender is not connected to, a claim whose holder is not here waits for that holder to enrol and is dropped after one claim wait; a stale or tiebreak-losing claim is answered with the incumbent so its sender converges, and a claim whose term no later claim could supersede is dropped unevaluated, neither gossiped nor answered. Receiving the incumbent itself is neither, and is dropped without a reply, which is what stops two peers that agree from echoing it forever. */
|
|
55
59
|
handleClaim(handle: Readonly<ConnectionHandle>, frame: Readonly<CoordinatorFrame>): Promise<void>;
|
|
56
60
|
/** Recovers the role when the departed peer held it. The lowest device-id among the peers this side has a machine-local session to claims at once at a raised term; every other survivor waits one claim wait and claims itself if the claim it then accepts still names a holder it has no session to, then runs onDelayedTakeover (the caller's single-authority announcement of the departed holder, which a delayed successor makes too). */
|
|
57
61
|
handleDeparture(peerId: string, onDelayedTakeover: () => Promise<void>): Promise<void>;
|
|
58
62
|
/** Stops taking part and gives the duties up if this side held them, once any transition still running has finished. Idempotent. */
|
|
59
63
|
stop(): Promise<void>;
|
|
64
|
+
/** Whether the holder a claim names is this side, the peer that sent it, or a peer this side has a machine-local session to. The sender is the handle's authenticated device-id, so a peer cannot name itself as someone else. */
|
|
65
|
+
private holderIsHere;
|
|
66
|
+
/** Keeps a claim whose holder is not here until that holder's session is enrolled, and drops it after one claim wait. The sender keeps at most PENDING_CLAIMS_PER_SENDER of them, one per holder, so a new claim for a holder already waiting replaces it only at a higher term, and when the sender is over its share the claim the election ranks last goes. */
|
|
67
|
+
private setAside;
|
|
68
|
+
/** Removes one waiting claim and its timer. */
|
|
69
|
+
private forget;
|
|
70
|
+
/** Takes every waiting claim that names `holder`, best first, except those whose sender no longer has a machine-local session here. */
|
|
71
|
+
private takePendingFor;
|
|
72
|
+
private dropAllPending;
|
|
60
73
|
private isLowestSurvivor;
|
|
61
74
|
/** Whether the claim this side accepts leaves the role without a holder it can reach: there is no claim at all, or it names a device that is neither this side nor a peer this side has a machine-local session to. */
|
|
62
75
|
private incumbentUnreachable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coordinator-role.d.ts","sourceRoot":"","sources":["../../src/core/coordinator-role.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"coordinator-role.d.ts","sourceRoot":"","sources":["../../src/core/coordinator-role.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAYH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAKtE,yGAAyG;AACzG,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,mRAAmR;AACnR,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,IAAI,CAC1B,aAAa,EACb,2BAA2B,GAAG,sBAAsB,GAAG,iBAAiB,CACzE,CAAC;IACF,0XAA0X;IAC1X,WAAW,EAAE,MAAM,CAAC;IACpB,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,gFAAgF;IAChF,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACnC;AA+BD,qBAAa,eAAe;IAiBd,OAAO,CAAC,QAAQ,CAAC,IAAI;IAhBjC,4KAA4K;IAC5K,OAAO,CAAC,gBAAgB,CAAkC;IAC1D,oKA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AMtB,OAAO,CAAC,gBAAgB;IAUxB,uNAAuN;IACvN,OAAO,CAAC,oBAAoB;IAO5B,4OAA4O;IAC5O,OAAO,CAAC,cAAc;YAkBR,KAAK;IAMnB,OAAO,CAAC,eAAe;IAMvB,wNAAwN;YAC1M,WAAW;IAMzB,mSAAmS;YACrR,YAAY;CAM3B"}
|
|
@@ -3,16 +3,27 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Claims travel as wire-mesh session frames (MeshTransport.broadcastCoordinatorClaim/sendCoordinatorClaim), and only over sessions to peers on this machine, because both duties the role assigns are facts about one machine: a PID probe can only see local processes and the cc-peer front can only reach local Claude Code sessions.
|
|
5
5
|
*
|
|
6
|
-
* When a claim is made: a store claims only when it knows of no incumbent and is the first on the machine as far as it can tell. A store that bound the well-known port with no first-contact presence configured can meet other stores only through that port, so it claims at once; one that may be reachable through first contact (it bound the port, or could neither join nor bind it) first waits one claim wait for an incumbent's announcement, so a store arriving at an existing mesh never takes the role at an equal term before the holder's claim reaches it. Both ends of every machine-local session announce the incumbent they know as the session is enrolled. When the incumbent departs, the lowest device-id among the peers this side has a machine-local session to claims at once at a raised term, and every other survivor claims too if, one claim wait later, the claim it accepts still names a holder it has no session to, which covers a lowest-id peer that is itself gone or was never reachable.
|
|
6
|
+
* When a claim is made: a store claims only when it knows of no incumbent and is the first on the machine as far as it can tell. A store that bound the well-known port with no first-contact presence configured can meet other stores only through that port, so it claims at once; one that may be reachable through first contact (it bound the port, or could neither join nor bind it) first waits one claim wait for an incumbent's announcement, so a store arriving at an existing mesh never takes the role at an equal term before the holder's claim reaches it. Both ends of every machine-local session announce the incumbent they know as the session is enrolled. When the incumbent departs, the lowest device-id among the peers this side has a machine-local session to claims at once at a raised term, and every other survivor claims too if, one claim wait later, the claim it accepts still names a holder it has no session to, which covers a lowest-id peer that is itself gone or was never reachable. A claim that is accepted names a holder that is here when it is accepted, so the wait after an accepted claim never starts: the claim waits are the one after a departure and the one at start-up.
|
|
7
|
+
*
|
|
8
|
+
* Whose claims count: claims are accepted from the peers this machine already trusts with a machine-local session, and this module does not authenticate them further. A claim is evaluated only when its holder is this side, the peer that sent it (the session's authenticated device-id, never a field of the frame), or a peer this side has a machine-local session to. A claim gossiped onward by a peer other than its holder is therefore still accepted wherever the holder is reachable, which is every peer of a fully connected machine. Any other claim waits until its holder's session is enrolled and is dropped after one claim wait, and is not evaluated at all when, by then, its sender has no machine-local session. Waiting claims are bounded per sender: each machine-local peer has at most PENDING_CLAIMS_PER_SENDER of them, at most one per holder, kept in the election's own order (higher term first, an equal term by lowest holder id), and a claim whose term no later claim could supersede is not kept.
|
|
7
9
|
*/
|
|
8
|
-
import { CoordinatorElection, compareDeviceIds, } from "wire-mesh-core/domain/coordinator-election";
|
|
10
|
+
import { CoordinatorElection, compareDeviceIds, isSupersedableTerm, } from "wire-mesh-core/domain/coordinator-election";
|
|
9
11
|
import { deviceIdFromHex, deviceIdToHex, } from "wire-mesh-core/domain/device-id";
|
|
10
12
|
/** The longest delay setTimeout accepts: past it the timer fires at once, which would turn a long backoff into a burst of takeovers. */
|
|
11
13
|
const MAX_TIMER_MS = 0x7fff_ffff;
|
|
14
|
+
/** Orders waiting claims as the election ranks claims: a higher term first, and at an equal term the lower holder id, compared as the election compares it. */
|
|
15
|
+
function rankedFirst(left, right) {
|
|
16
|
+
if (left.frame.term !== right.frame.term) {
|
|
17
|
+
return right.frame.term - left.frame.term;
|
|
18
|
+
}
|
|
19
|
+
return compareDeviceIds(left.frame.coordinator, right.frame.coordinator);
|
|
20
|
+
}
|
|
12
21
|
function sameClaim(frame, claim) {
|
|
13
22
|
return (frame.term === claim.term &&
|
|
14
23
|
compareDeviceIds(frame.coordinator, claim.coordinator) === 0);
|
|
15
24
|
}
|
|
25
|
+
/** How many claims one machine-local peer may have waiting for their holders to enrol, one per holder. */
|
|
26
|
+
const PENDING_CLAIMS_PER_SENDER = 4;
|
|
16
27
|
export class CoordinatorRole {
|
|
17
28
|
deps;
|
|
18
29
|
/** Built on first use rather than at construction, because MeshStore's peerId is assigned after its constructor runs (every bridge sets it to the identity's device-id). */
|
|
@@ -28,6 +39,8 @@ export class CoordinatorRole {
|
|
|
28
39
|
takeoverStreak = 0;
|
|
29
40
|
/** The claim, as `term:holder`, each peer was last answered with. A peer whose view lags keeps sending the claims it knows, and answering each one with the same incumbent only multiplies the traffic: the answer is repeated only when the incumbent changes or the peer's session is enrolled afresh, since the earlier answer may have been lost with the old session. */
|
|
30
41
|
answered = new Map();
|
|
42
|
+
/** The claims set aside, by the device-id of the session that sent each, best first in the election's own order. */
|
|
43
|
+
pending = new Map();
|
|
31
44
|
constructor(deps) {
|
|
32
45
|
this.deps = deps;
|
|
33
46
|
}
|
|
@@ -63,23 +76,41 @@ export class CoordinatorRole {
|
|
|
63
76
|
/** Tells a peer whose machine-local session was just enrolled which claim this side accepts, so a joiner learns the incumbent instead of claiming over it. A no-op while this side knows of none. */
|
|
64
77
|
async announceTo(handle) {
|
|
65
78
|
this.answered.delete(handle.id);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
79
|
+
// Taken before the first await, so a claim released here is neither dropped by its timer nor taken twice while the announcement is being sent.
|
|
80
|
+
const released = this.takePendingFor(handle.id);
|
|
81
|
+
try {
|
|
82
|
+
const frame = this.electionInstance?.announceCurrent();
|
|
83
|
+
if (frame !== undefined) {
|
|
84
|
+
await this.deps.requireTransport().sendCoordinatorClaim(handle, frame);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
this.deps.onError(error);
|
|
89
|
+
}
|
|
90
|
+
// The session just enrolled may be the holder claims were set aside for. One claim failing to evaluate never costs the others theirs.
|
|
91
|
+
for (const waiting of released) {
|
|
92
|
+
try {
|
|
93
|
+
await this.handleClaim(waiting.handle, waiting.frame);
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
this.deps.onError(error);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
70
99
|
}
|
|
71
|
-
/** Evaluates a claim a peer gossiped. An accepted claim is gossiped on to every peer so the supersession reaches peers the sender is not connected to,
|
|
100
|
+
/** Evaluates a claim a peer gossiped. An accepted claim is gossiped on to every peer so the supersession reaches peers the sender is not connected to, a claim whose holder is not here waits for that holder to enrol and is dropped after one claim wait; a stale or tiebreak-losing claim is answered with the incumbent so its sender converges, and a claim whose term no later claim could supersede is dropped unevaluated, neither gossiped nor answered. Receiving the incumbent itself is neither, and is dropped without a reply, which is what stops two peers that agree from echoing it forever. */
|
|
72
101
|
async handleClaim(handle, frame) {
|
|
73
102
|
if (this.stopped)
|
|
74
103
|
return;
|
|
104
|
+
if (!this.holderIsHere(handle, frame)) {
|
|
105
|
+
this.setAside(handle, frame);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
75
108
|
const result = this.election.evaluate(frame);
|
|
76
109
|
if (result.outcome === "accepted") {
|
|
77
110
|
this.answered.clear();
|
|
78
111
|
this.cancelClaimWait();
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
else
|
|
82
|
-
this.takeoverStreak = 0;
|
|
112
|
+
// The holder of an accepted claim is here, so there is no incumbent to wait out.
|
|
113
|
+
this.takeoverStreak = 0;
|
|
83
114
|
await this.deps.requireTransport().broadcastCoordinatorClaim(frame);
|
|
84
115
|
}
|
|
85
116
|
else if (result.outcome === "retained" &&
|
|
@@ -109,8 +140,75 @@ export class CoordinatorRole {
|
|
|
109
140
|
async stop() {
|
|
110
141
|
this.stopped = true;
|
|
111
142
|
this.cancelClaimWait();
|
|
143
|
+
this.dropAllPending();
|
|
112
144
|
await this.syncHolding();
|
|
113
145
|
}
|
|
146
|
+
/** Whether the holder a claim names is this side, the peer that sent it, or a peer this side has a machine-local session to. The sender is the handle's authenticated device-id, so a peer cannot name itself as someone else. */
|
|
147
|
+
holderIsHere(handle, frame) {
|
|
148
|
+
const holder = deviceIdToHex(frame.coordinator);
|
|
149
|
+
return (holder === this.deps.getPeerId() ||
|
|
150
|
+
holder === handle.id ||
|
|
151
|
+
this.deps.requireTransport().electionPeerIds().has(holder));
|
|
152
|
+
}
|
|
153
|
+
/** Keeps a claim whose holder is not here until that holder's session is enrolled, and drops it after one claim wait. The sender keeps at most PENDING_CLAIMS_PER_SENDER of them, one per holder, so a new claim for a holder already waiting replaces it only at a higher term, and when the sender is over its share the claim the election ranks last goes. */
|
|
154
|
+
setAside(handle, frame) {
|
|
155
|
+
// A claim whose term no later claim could supersede is dropped by the election unevaluated, wherever its holder is, so it never takes a place here.
|
|
156
|
+
if (!isSupersedableTerm(frame.term))
|
|
157
|
+
return;
|
|
158
|
+
const holder = deviceIdToHex(frame.coordinator);
|
|
159
|
+
const mine = this.pending.get(handle.id) ?? [];
|
|
160
|
+
const same = mine.find((entry) => entry.holder === holder);
|
|
161
|
+
if (same !== undefined) {
|
|
162
|
+
if (same.frame.term >= frame.term)
|
|
163
|
+
return;
|
|
164
|
+
this.forget(handle.id, same);
|
|
165
|
+
}
|
|
166
|
+
const timer = setTimeout(() => {
|
|
167
|
+
const waiting = (this.pending.get(handle.id) ?? []).find((entry) => entry.holder === holder && entry.frame === frame);
|
|
168
|
+
if (waiting !== undefined)
|
|
169
|
+
this.forget(handle.id, waiting);
|
|
170
|
+
}, this.deps.claimWaitMs);
|
|
171
|
+
// Never what keeps a process alive: a store shutting down stops the role anyway.
|
|
172
|
+
timer.unref();
|
|
173
|
+
const kept = [
|
|
174
|
+
...(this.pending.get(handle.id) ?? []),
|
|
175
|
+
{ handle, frame, holder, timer },
|
|
176
|
+
].sort(rankedFirst);
|
|
177
|
+
this.pending.set(handle.id, kept);
|
|
178
|
+
for (const extra of kept.slice(PENDING_CLAIMS_PER_SENDER)) {
|
|
179
|
+
this.forget(handle.id, extra);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/** Removes one waiting claim and its timer. */
|
|
183
|
+
forget(sender, entry) {
|
|
184
|
+
clearTimeout(entry.timer);
|
|
185
|
+
const rest = (this.pending.get(sender) ?? []).filter((other) => other !== entry);
|
|
186
|
+
if (rest.length === 0)
|
|
187
|
+
this.pending.delete(sender);
|
|
188
|
+
else
|
|
189
|
+
this.pending.set(sender, rest);
|
|
190
|
+
}
|
|
191
|
+
/** Takes every waiting claim that names `holder`, best first, except those whose sender no longer has a machine-local session here. */
|
|
192
|
+
takePendingFor(holder) {
|
|
193
|
+
const senders = this.deps.requireTransport().electionPeerIds();
|
|
194
|
+
const taken = [];
|
|
195
|
+
for (const [sender, entries] of [...this.pending]) {
|
|
196
|
+
for (const entry of entries) {
|
|
197
|
+
if (entry.holder !== holder)
|
|
198
|
+
continue;
|
|
199
|
+
this.forget(sender, entry);
|
|
200
|
+
if (senders.has(sender))
|
|
201
|
+
taken.push(entry);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return taken.sort(rankedFirst);
|
|
205
|
+
}
|
|
206
|
+
dropAllPending() {
|
|
207
|
+
for (const [sender, entries] of [...this.pending]) {
|
|
208
|
+
for (const entry of entries)
|
|
209
|
+
this.forget(sender, entry);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
114
212
|
isLowestSurvivor(departedPeerId) {
|
|
115
213
|
const selfId = this.deps.getPeerId();
|
|
116
214
|
const self = deviceIdFromHex(selfId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coordinator-role.js","sourceRoot":"","sources":["../../src/core/coordinator-role.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"coordinator-role.js","sourceRoot":"","sources":["../../src/core/coordinator-role.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,GAEnB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EACL,eAAe,EACf,aAAa,GACd,MAAM,iCAAiC,CAAC;AAIzC,wIAAwI;AACxI,MAAM,YAAY,GAAG,WAAW,CAAC;AAwBjC,+JAA+J;AAC/J,SAAS,WAAW,CAAC,IAAkB,EAAE,KAAmB;IAC1D,IAAI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AAC,SAAS,KAAK,SAAS;YAAE,OAAO;QACzC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,wNAAwN;IAChN,KAAK,CAAC,WAAW;QACvB,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;QACpE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC/C,MAAM,IAAI,CAAC;IACb,CAAC;IAED,mSAAmS;IAC3R,KAAK,CAAC,YAAY;QACxB,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,gBAAgB,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;QACxE,IAAI,KAAK,KAAK,IAAI,CAAC,OAAO;YAAE,OAAO;QACnC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5D,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Work started and not awaited, which must never end the process by rejecting: a peer decides what its messages contain, so an exception while handling one is reported, not left as an unhandled rejection.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Attaches a rejection handler to `work`. A rejection goes to the error handler `getOnError` returns when it settles (read then, not now, so a handler assigned after the work started is the one used), and to stderr when there is none, so it is never silent.
|
|
6
|
+
*/
|
|
7
|
+
export declare function reportRejection(work: Readonly<Promise<unknown>>, getOnError: () => ((error: Error) => void) | undefined): void;
|
|
8
|
+
/** What a handler of consumeEach answers: read the next item, or end the loop here. */
|
|
9
|
+
export type ConsumeStep = "continue" | "stop";
|
|
10
|
+
/**
|
|
11
|
+
* Reads `items` until the stream ends, handing each to `handle` in arrival order, one at a time. A failure of `handle` is reported through `getOnError` (see reportRejection) and the loop carries on: one item a peer sent that cannot be handled must not stop every later one on the same session. A handler that returns "stop" ends the loop at once, as `break` would. A failure of the stream itself ends the loop and is reported the same way. Never rejects.
|
|
12
|
+
*/
|
|
13
|
+
export declare function consumeEach<T>(items: Readonly<AsyncIterable<T>>, handle: (item: T) => Promise<ConsumeStep> | ConsumeStep, getOnError: () => ((error: Error) => void) | undefined): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=detached-work.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detached-work.d.ts","sourceRoot":"","sources":["../../src/core/detached-work.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAChC,UAAU,EAAE,MAAM,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC,GAAG,SAAS,GACrD,IAAI,CAUN;AAYD,uFAAuF;AACvF,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,MAAM,CAAC;AAE9C;;GAEG;AACH,wBAAsB,WAAW,CAAC,CAAC,EACjC,KAAK,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EACjC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,WAAW,CAAC,GAAG,WAAW,EACvD,UAAU,EAAE,MAAM,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC,GAAG,SAAS,GACrD,OAAO,CAAC,IAAI,CAAC,CAYf"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Work started and not awaited, which must never end the process by rejecting: a peer decides what its messages contain, so an exception while handling one is reported, not left as an unhandled rejection.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Attaches a rejection handler to `work`. A rejection goes to the error handler `getOnError` returns when it settles (read then, not now, so a handler assigned after the work started is the one used), and to stderr when there is none, so it is never silent.
|
|
6
|
+
*/
|
|
7
|
+
export function reportRejection(work, getOnError) {
|
|
8
|
+
work.catch((error) => {
|
|
9
|
+
const failure = error instanceof Error ? error : new Error(String(error));
|
|
10
|
+
const onError = getOnError();
|
|
11
|
+
if (onError !== undefined) {
|
|
12
|
+
onError(failure);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
process.stderr.write(`agent-comms: ${failure.message}\n`);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function report(error, getOnError) {
|
|
19
|
+
reportRejection(Promise.reject(error instanceof Error ? error : new Error(String(error))), getOnError);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Reads `items` until the stream ends, handing each to `handle` in arrival order, one at a time. A failure of `handle` is reported through `getOnError` (see reportRejection) and the loop carries on: one item a peer sent that cannot be handled must not stop every later one on the same session. A handler that returns "stop" ends the loop at once, as `break` would. A failure of the stream itself ends the loop and is reported the same way. Never rejects.
|
|
23
|
+
*/
|
|
24
|
+
export async function consumeEach(items, handle, getOnError) {
|
|
25
|
+
try {
|
|
26
|
+
for await (const item of items) {
|
|
27
|
+
try {
|
|
28
|
+
if ((await handle(item)) === "stop")
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
report(error, getOnError);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
report(error, getOnError);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=detached-work.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detached-work.js","sourceRoot":"","sources":["../../src/core/detached-work.ts"],"names":[],"mappings":"AAAA;;GAEG;AA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CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"election-sessions.d.ts","sourceRoot":"","sources":["../../src/core/election-sessions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"election-sessions.d.ts","sourceRoot":"","sources":["../../src/core/election-sessions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAE1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAQxE,qBAAa,gBAAgB;IAUzB,OAAO,CAAC,QAAQ,CAAC,MAAM;IATzB,4EAA4E;IAC5E,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAGrB;IACJ,6PAA6P;IAC7P,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgD;gBAGtD,MAAM,EAAE,QAAQ,CAC/B,IAAI,CACF,eAAe,EACf,oBAAoB,GAAG,2BAA2B,GAAG,SAAS,CAC/D,CACF;IAGH,+QAA+Q;IAC/Q,KAAK,CACH,OAAO,EAAE,mBAAmB,EAC5B,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GACjC,IAAI;IAaP,mNAAmN;IACnN,KAAK,CACH,OAAO,EAAE,mBAAmB,EAC5B,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GACjC,IAAI;IAKP,gEAAgE;IAChE,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI;IAK1C,KAAK,IAAI,IAAI;IAKb,yIAAyI;IACzI,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAInC,qIAAqI;IACrI,OAAO,IAAI,WAAW,CAAC,MAAM,CAAC;IAI9B,oNAAoN;IAC9M,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAQjE,iNAAiN;IAC3M,MAAM,CACV,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAChC,OAAO,CAAC,IAAI,CAAC;IAUhB,yUAAyU;YAC3T,QAAQ;CA8BvB"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Every session this transport opens is watched from the moment it opens, whether or not it is ever enrolled: a frame is delivered only when its session is enrolled at the moment the frame is read, and is dropped otherwise. So a quarantined session's claims from before its introduce are discarded rather than replayed once it introduces itself, and a session that is never enrolled does not accumulate the frames its peer sends.
|
|
7
7
|
*/
|
|
8
|
+
import { consumeEach } from "./detached-work.js";
|
|
8
9
|
export class ElectionSessions {
|
|
9
10
|
events;
|
|
10
11
|
/** Each enrolled session, with the handle its claims are reported under. */
|
|
@@ -16,13 +17,12 @@ export class ElectionSessions {
|
|
|
16
17
|
}
|
|
17
18
|
/** Starts reading every coordinator-frame the session's peer gossips, for as long as the session lives, handing each to onCoordinatorClaim only while the session is enrolled. Called exactly once per session, as soon as it is opened and before anything could enrol it. */
|
|
18
19
|
watch(session, handle) {
|
|
19
|
-
void (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
this.events.onCoordinatorClaim(handle, frame);
|
|
23
|
-
}
|
|
20
|
+
void consumeEach(session.coordinatorFrames, (frame) => {
|
|
21
|
+
if (this.enrolled.has(session)) {
|
|
22
|
+
this.events.onCoordinatorClaim(handle, frame);
|
|
24
23
|
}
|
|
25
|
-
|
|
24
|
+
return "continue";
|
|
25
|
+
}, () => this.events.onError);
|
|
26
26
|
}
|
|
27
27
|
/** Enrols a trusted machine-local session, then fires onElectionSessionEnrolled so this side tells the peer which claim it accepts. Both ends of every machine-local session enrol it, so each tells the other. */
|
|
28
28
|
enrol(session, handle) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"election-sessions.js","sourceRoot":"","sources":["../../src/core/election-sessions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"election-sessions.js","sourceRoot":"","sources":["../../src/core/election-sessions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AASjD,MAAM,OAAO,gBAAgB;IAUR;IATnB,4EAA4E;IAC3D,QAAQ,GAAG,IAAI,GAAG,EAGhC,CAAC;IACJ,6PAA6P;IAC5O,QAAQ,GAAG,IAAI,GAAG,EAAqC,CAAC;IAEzE,YACmB,MAKhB;QALgB,WAAM,GAAN,MAAM,CAKtB;IACA,CAAC;IAEJ,+QAA+Q;IAC/Q,KAAK,CACH,OAA4B,EAC5B,MAAkC;QAElC,KAAK,WAAW,CACd,OAAO,CAAC,iBAAiB,EACzB,CAAC,KAAK,EAAE,EAAE;YACR,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC/B,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;YAChD,CAAC;YACD,OAAO,UAAU,CAAC;QACpB,CAAC,EACD,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAC1B,CAAC;IACJ,CAAC;IAED,mNAAmN;IACnN,KAAK,CACH,OAA4B,EAC5B,MAAkC;QAElC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAChD,CAAC;IAED,gEAAgE;IAChE,MAAM,CAAC,OAA4B;QACjC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;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