@serfab/cadre-core 0.7.1 → 0.9.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/README.md +11 -10
- package/dist/cadre-node.d.ts +818 -19
- package/dist/cadre-node.js +1952 -99
- package/dist/cadre-node.js.map +1 -1
- package/dist/canonical-datetime.d.ts +33 -0
- package/dist/canonical-datetime.js +38 -0
- package/dist/canonical-datetime.js.map +1 -0
- package/dist/canonical-json.d.ts +12 -0
- package/dist/canonical-json.js +33 -0
- package/dist/canonical-json.js.map +1 -0
- package/dist/control-cohort.d.ts +63 -0
- package/dist/control-cohort.js +80 -0
- package/dist/control-cohort.js.map +1 -0
- package/dist/control-database.d.ts +279 -8
- package/dist/control-database.js +563 -134
- package/dist/control-database.js.map +1 -1
- package/dist/control-formation-recorder.d.ts +89 -0
- package/dist/control-formation-recorder.js +139 -0
- package/dist/control-formation-recorder.js.map +1 -0
- package/dist/control-schema.d.ts +12 -0
- package/dist/control-schema.js +223 -0
- package/dist/control-schema.js.map +1 -0
- package/dist/control-stream.d.ts +54 -0
- package/dist/control-stream.js +104 -0
- package/dist/control-stream.js.map +1 -0
- package/dist/device-token.d.ts +50 -0
- package/dist/device-token.js +66 -0
- package/dist/device-token.js.map +1 -0
- package/dist/diagnostics/connection-path.d.ts +118 -0
- package/dist/diagnostics/connection-path.js +204 -0
- package/dist/diagnostics/connection-path.js.map +1 -0
- package/dist/diagnostics/webrtc-turn-tracker.d.ts +50 -0
- package/dist/diagnostics/webrtc-turn-tracker.js +196 -0
- package/dist/diagnostics/webrtc-turn-tracker.js.map +1 -0
- package/dist/ed25519-key.d.ts +42 -0
- package/dist/ed25519-key.js +51 -0
- package/dist/ed25519-key.js.map +1 -0
- package/dist/hibernation-manager.d.ts +79 -0
- package/dist/hibernation-manager.js +173 -23
- package/dist/hibernation-manager.js.map +1 -1
- package/dist/index.d.ts +25 -4
- package/dist/index.js +59 -4
- package/dist/index.js.map +1 -1
- package/dist/key-store-file.d.ts +52 -0
- package/dist/key-store-file.js +194 -0
- package/dist/key-store-file.js.map +1 -0
- package/dist/key-store.d.ts +75 -0
- package/dist/key-store.js +66 -0
- package/dist/key-store.js.map +1 -0
- package/dist/peer-authorization.d.ts +48 -0
- package/dist/peer-authorization.js +66 -0
- package/dist/peer-authorization.js.map +1 -0
- package/dist/peer-record.d.ts +89 -0
- package/dist/peer-record.js +117 -0
- package/dist/peer-record.js.map +1 -0
- package/dist/push-credentials.d.ts +34 -0
- package/dist/push-credentials.js +81 -0
- package/dist/push-credentials.js.map +1 -0
- package/dist/push-fanout.d.ts +137 -0
- package/dist/push-fanout.js +197 -0
- package/dist/push-fanout.js.map +1 -0
- package/dist/push-node.d.ts +38 -0
- package/dist/push-node.js +48 -0
- package/dist/push-node.js.map +1 -0
- package/dist/push-notifier-apns.d.ts +61 -0
- package/dist/push-notifier-apns.js +199 -0
- package/dist/push-notifier-apns.js.map +1 -0
- package/dist/push-notifier-fcm.d.ts +44 -0
- package/dist/push-notifier-fcm.js +182 -0
- package/dist/push-notifier-fcm.js.map +1 -0
- package/dist/push-notifier-shared.d.ts +18 -0
- package/dist/push-notifier-shared.js +25 -0
- package/dist/push-notifier-shared.js.map +1 -0
- package/dist/push-notifier.d.ts +52 -0
- package/dist/push-notifier.js +22 -0
- package/dist/push-notifier.js.map +1 -0
- package/dist/schema-verification.d.ts +11 -2
- package/dist/schema-verification.js +15 -4
- package/dist/schema-verification.js.map +1 -1
- package/dist/seed-bootstrap.d.ts +228 -21
- package/dist/seed-bootstrap.js +489 -168
- package/dist/seed-bootstrap.js.map +1 -1
- package/dist/seed-trust-policy.d.ts +63 -0
- package/dist/seed-trust-policy.js +56 -0
- package/dist/seed-trust-policy.js.map +1 -0
- package/dist/strand-addr-protocol.d.ts +132 -0
- package/dist/strand-addr-protocol.js +313 -0
- package/dist/strand-addr-protocol.js.map +1 -0
- package/dist/strand-cohort.d.ts +54 -0
- package/dist/strand-cohort.js +38 -0
- package/dist/strand-cohort.js.map +1 -0
- package/dist/strand-database.d.ts +54 -6
- package/dist/strand-database.js +88 -100
- package/dist/strand-database.js.map +1 -1
- package/dist/strand-formation-manager.d.ts +79 -19
- package/dist/strand-formation-manager.js +196 -104
- package/dist/strand-formation-manager.js.map +1 -1
- package/dist/strand-formation-protocol.d.ts +162 -0
- package/dist/strand-formation-protocol.js +279 -0
- package/dist/strand-formation-protocol.js.map +1 -0
- package/dist/strand-instance-manager.d.ts +73 -4
- package/dist/strand-instance-manager.js +167 -41
- package/dist/strand-instance-manager.js.map +1 -1
- package/dist/strand-member-key.d.ts +29 -0
- package/dist/strand-member-key.js +38 -0
- package/dist/strand-member-key.js.map +1 -0
- package/dist/strand-member-registry.d.ts +98 -0
- package/dist/strand-member-registry.js +129 -0
- package/dist/strand-member-registry.js.map +1 -0
- package/dist/strand-membership-writer.d.ts +361 -0
- package/dist/strand-membership-writer.js +449 -0
- package/dist/strand-membership-writer.js.map +1 -0
- package/dist/strand-solicitation.d.ts +77 -2
- package/dist/strand-solicitation.js +25 -4
- package/dist/strand-solicitation.js.map +1 -1
- package/dist/strand-wake-payload.d.ts +30 -0
- package/dist/strand-wake-payload.js +20 -0
- package/dist/strand-wake-payload.js.map +1 -0
- package/dist/strand-wake-protocol.d.ts +114 -0
- package/dist/strand-wake-protocol.js +257 -0
- package/dist/strand-wake-protocol.js.map +1 -0
- package/dist/strand-watcher.d.ts +6 -2
- package/dist/strand-watcher.js +57 -17
- package/dist/strand-watcher.js.map +1 -1
- package/dist/types.d.ts +436 -33
- package/dist/types.js +22 -5
- package/dist/types.js.map +1 -1
- package/package.json +18 -8
- package/src/cadre-node.ts +2981 -948
- package/src/canonical-datetime.ts +39 -0
- package/src/canonical-json.ts +30 -0
- package/src/control-cohort.ts +103 -0
- package/src/control-database.ts +948 -383
- package/src/control-formation-recorder.ts +151 -0
- package/src/control-schema.ts +222 -0
- package/src/control-stream.ts +128 -0
- package/src/device-token.ts +89 -0
- package/src/diagnostics/connection-path.ts +277 -0
- package/src/diagnostics/webrtc-turn-tracker.ts +222 -0
- package/src/ed25519-key.ts +69 -0
- package/src/hibernation-manager.ts +197 -28
- package/src/index.ts +275 -79
- package/src/key-store-file.ts +203 -0
- package/src/key-store.ts +99 -0
- package/src/peer-authorization.ts +81 -0
- package/src/peer-record.ts +146 -0
- package/src/push-credentials.ts +84 -0
- package/src/push-fanout.ts +272 -0
- package/src/push-node.ts +64 -0
- package/src/push-notifier-apns.ts +247 -0
- package/src/push-notifier-fcm.ts +220 -0
- package/src/push-notifier-shared.ts +28 -0
- package/src/push-notifier.ts +52 -0
- package/src/schema-verification.ts +18 -4
- package/src/seed-bootstrap.ts +563 -223
- package/src/seed-trust-policy.ts +107 -0
- package/src/strand-addr-protocol.ts +410 -0
- package/src/strand-cohort.ts +77 -0
- package/src/strand-database.ts +113 -141
- package/src/strand-formation-manager.ts +233 -142
- package/src/strand-formation-protocol.ts +391 -0
- package/src/strand-instance-manager.ts +207 -56
- package/src/strand-member-key.ts +39 -0
- package/src/strand-member-registry.ts +177 -0
- package/src/strand-membership-writer.ts +640 -0
- package/src/strand-solicitation.ts +93 -4
- package/src/strand-wake-payload.ts +32 -0
- package/src/strand-wake-protocol.ts +331 -0
- package/src/strand-watcher.ts +61 -17
- package/src/types.ts +1032 -582
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strand-solicitation.js","sourceRoot":"","sources":["../src/strand-solicitation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAQvD,OAAO,EACL,sBAAsB,EAEvB,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"strand-solicitation.js","sourceRoot":"","sources":["../src/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AAK,GAAG,UAAU,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;QAChF,MAAM,UAAU,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,YAAY,CAAC,CAAC;QAEvD,GAAG,CAAC,0CAA0C,EAAE,KAAK,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC;QAEjF,OAAO;YACL,KAAK;YACL,MAAM;YACN,UAAU;YACV,SAAS;SACV,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,uBAAuB,CAC3B,KAAa,EACb,YAAoB,EACpB,QAAgB;QAEhB,IAAI,IAAI,CAAC,sBAAsB,EAAE,CAAC;YAChC,MAAM,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;YAC7E,GAAG,CAAC,8CAA8C,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* strand-wake-payload.ts — the canonical wire contract for a strand-wake data
|
|
3
|
+
* message, shared by the server-side sender (`PushNotifier`, this package) and
|
|
4
|
+
* the mobile receiver (`@serfab/reference-app-rn`'s `push-wake.ts`).
|
|
5
|
+
*
|
|
6
|
+
* A strand-wake is a data-only push delivered to an OS-suspended phone over its
|
|
7
|
+
* platform channel (FCM/APNs) when a control-network dial cannot reach the
|
|
8
|
+
* hibernating process. It names the strand that has pending activity so the phone
|
|
9
|
+
* can run one `serviceWake` cycle and re-hibernate.
|
|
10
|
+
*
|
|
11
|
+
* This module is intentionally dependency-free (no node/RN/browser-specific
|
|
12
|
+
* imports) so it sits cleanly on the cross-platform `cadre-core` entry and can be
|
|
13
|
+
* re-exported by the RN receive module without dragging any platform code across
|
|
14
|
+
* the send/receive boundary. The defensive `parseStrandWakePayload` parser stays
|
|
15
|
+
* on the receive side (it guards untrusted wire input); the sender constructs
|
|
16
|
+
* payloads from typed fields and never parses.
|
|
17
|
+
*/
|
|
18
|
+
/** Discriminator value carried by a strand-wake data message. */
|
|
19
|
+
export declare const STRAND_WAKE_TYPE = "strand-wake";
|
|
20
|
+
/**
|
|
21
|
+
* A data-only push payload telling a suspended phone that `strandId` has pending
|
|
22
|
+
* activity. Delivered addressed to the phone's resolved `DeviceToken`.
|
|
23
|
+
*/
|
|
24
|
+
export interface StrandWakePayload {
|
|
25
|
+
type: typeof STRAND_WAKE_TYPE;
|
|
26
|
+
/** The strand the wake is for. */
|
|
27
|
+
strandId: string;
|
|
28
|
+
/** Why the wake was sent (e.g. `'activity'`). Free-form, for diagnostics. */
|
|
29
|
+
reason: string;
|
|
30
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* strand-wake-payload.ts — the canonical wire contract for a strand-wake data
|
|
3
|
+
* message, shared by the server-side sender (`PushNotifier`, this package) and
|
|
4
|
+
* the mobile receiver (`@serfab/reference-app-rn`'s `push-wake.ts`).
|
|
5
|
+
*
|
|
6
|
+
* A strand-wake is a data-only push delivered to an OS-suspended phone over its
|
|
7
|
+
* platform channel (FCM/APNs) when a control-network dial cannot reach the
|
|
8
|
+
* hibernating process. It names the strand that has pending activity so the phone
|
|
9
|
+
* can run one `serviceWake` cycle and re-hibernate.
|
|
10
|
+
*
|
|
11
|
+
* This module is intentionally dependency-free (no node/RN/browser-specific
|
|
12
|
+
* imports) so it sits cleanly on the cross-platform `cadre-core` entry and can be
|
|
13
|
+
* re-exported by the RN receive module without dragging any platform code across
|
|
14
|
+
* the send/receive boundary. The defensive `parseStrandWakePayload` parser stays
|
|
15
|
+
* on the receive side (it guards untrusted wire input); the sender constructs
|
|
16
|
+
* payloads from typed fields and never parses.
|
|
17
|
+
*/
|
|
18
|
+
/** Discriminator value carried by a strand-wake data message. */
|
|
19
|
+
export const STRAND_WAKE_TYPE = 'strand-wake';
|
|
20
|
+
//# sourceMappingURL=strand-wake-payload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strand-wake-payload.js","sourceRoot":"","sources":["../src/strand-wake-payload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,iEAAiE;AACjE,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Control-network push-wake transport.
|
|
3
|
+
*
|
|
4
|
+
* Lets a same-cadre peer — typically an always-on server that participates in a
|
|
5
|
+
* strand and sees new activity — signal a hibernating cadre peer to bring that
|
|
6
|
+
* strand online, pull pending activity, and re-hibernate. Push-wake travels the
|
|
7
|
+
* **control network** (the per-party network connecting this party's own cadre
|
|
8
|
+
* nodes), which is the only network a hibernating peer keeps connected.
|
|
9
|
+
*
|
|
10
|
+
* Modeled directly on `seed-bootstrap.ts`: a dedicated libp2p protocol id,
|
|
11
|
+
* 4-byte big-endian length-prefixed JSON frames, `node.handle` for the receiver,
|
|
12
|
+
* `node.dialProtocol` for the sender, and the shared `ControlStream` primitives
|
|
13
|
+
* from `control-stream.ts`. The exchange is a single request → single ack on one
|
|
14
|
+
* stream (like seed delivery), so each side reads to EOF (under a read timeout)
|
|
15
|
+
* and decodes one frame via the shared {@link decodeLengthPrefixedFrame} guard.
|
|
16
|
+
*
|
|
17
|
+
* **Authorization (v1):** the control network already restricts membership —
|
|
18
|
+
* only this party's cadre peers connect (schema-gated `CadrePeer`). A wake is
|
|
19
|
+
* low-risk: it only causes the receiver to spend resources coming online for a
|
|
20
|
+
* strand it already participates in. So the receiver verifies the remote peer is
|
|
21
|
+
* a `CadrePeer` member (via the injected `isMember` gate) and requires no
|
|
22
|
+
* signature beyond control-network membership. A richer per-request signature is
|
|
23
|
+
* deliberately out of scope for v1.
|
|
24
|
+
*/
|
|
25
|
+
import type { Libp2p } from '@libp2p/interface';
|
|
26
|
+
import type { Multiaddr } from '@multiformats/multiaddr';
|
|
27
|
+
import type { StrandInstance, WakeRequest, WakeAck } from './types.js';
|
|
28
|
+
/** Protocol id for control-network push-wake (parallel to `/sereus/seed/1.0.0`). */
|
|
29
|
+
export declare const WAKE_PROTOCOL = "/sereus/strand-wake/1.0.0";
|
|
30
|
+
/**
|
|
31
|
+
* Dependencies the {@link StrandWakeService} receiver needs from its host
|
|
32
|
+
* (`CadreNode`), injected so the service is testable without a full node.
|
|
33
|
+
*/
|
|
34
|
+
export interface StrandWakeServiceOptions {
|
|
35
|
+
/** Membership gate: is the remote peer a `CadrePeer` member of this cadre? */
|
|
36
|
+
isMember(remotePeerId: string): Promise<boolean>;
|
|
37
|
+
/** Look up a local strand instance by id (undefined if not participated in). */
|
|
38
|
+
getStrand(strandId: string): StrandInstance | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Trigger the local wake path for a hibernating/idle strand. Wired to
|
|
41
|
+
* `CadreNode.wakeStrand` (→ `HibernationManager` → `resumeStrand`), whose
|
|
42
|
+
* resume coalescing prevents a push-wake racing a concurrent check-in.
|
|
43
|
+
*/
|
|
44
|
+
wake(strandId: string): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Time to wait for the inbound wake frame before aborting the read (ms).
|
|
47
|
+
* Defaults to {@link DEFAULT_WAKE_READ_TIMEOUT_MS}. Bounds a buggy/compromised
|
|
48
|
+
* own-cadre node that opens a stream and never half-closes its write end.
|
|
49
|
+
*/
|
|
50
|
+
readTimeoutMs?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Cap on concurrent inbound wake streams (defaults to
|
|
53
|
+
* {@link DEFAULT_MAX_CONCURRENT_WAKES}). Over the cap, a non-accepting ack is
|
|
54
|
+
* returned without invoking the wake path.
|
|
55
|
+
*/
|
|
56
|
+
maxConcurrent?: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Receiver side of the push-wake protocol. Registers a `WAKE_PROTOCOL` handler
|
|
60
|
+
* on the control node and, for each inbound {@link WakeRequest}, gates on cadre
|
|
61
|
+
* membership, then resumes the named strand if it is hibernating/idle and we
|
|
62
|
+
* participate in it — replying with a {@link WakeAck}.
|
|
63
|
+
*/
|
|
64
|
+
export declare class StrandWakeService {
|
|
65
|
+
private readonly options;
|
|
66
|
+
private readonly readTimeoutMs;
|
|
67
|
+
private readonly maxConcurrent;
|
|
68
|
+
private node;
|
|
69
|
+
/** In-flight inbound wake streams, used to enforce {@link maxConcurrent}. */
|
|
70
|
+
private activeStreams;
|
|
71
|
+
constructor(options: StrandWakeServiceOptions);
|
|
72
|
+
/** Number of in-flight inbound wake streams. */
|
|
73
|
+
get activeCount(): number;
|
|
74
|
+
/** Register the wake protocol handler on the control node. */
|
|
75
|
+
initialize(node: Libp2p): void;
|
|
76
|
+
/** Unregister the handler and release the node reference. */
|
|
77
|
+
shutdown(): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Read the inbound request, decide + execute the wake, and write the ack.
|
|
80
|
+
*
|
|
81
|
+
* Three hardening layers, all reported as a non-accepting ack rather than a
|
|
82
|
+
* dropped/hung stream: a concurrency cap (over {@link maxConcurrent}, reply
|
|
83
|
+
* without touching the wake path), a read timeout (a peer that never
|
|
84
|
+
* half-closes is aborted inside {@link readFrame}/`readStreamToEnd`), and the
|
|
85
|
+
* existing malformed/oversized-frame guard.
|
|
86
|
+
*/
|
|
87
|
+
private handleStream;
|
|
88
|
+
/**
|
|
89
|
+
* Decide and execute the wake for a decoded request. Exposed (not private) so
|
|
90
|
+
* the decision matrix can be unit-tested directly.
|
|
91
|
+
*
|
|
92
|
+
* - Non-member sender → rejected (`accepted: false`).
|
|
93
|
+
* - Unknown / not-participated strand → rejected.
|
|
94
|
+
* - Hibernating or idle strand → resumed via the wake path, then `accepted`.
|
|
95
|
+
* - Already-live strand → no-op, `accepted` with current status.
|
|
96
|
+
*/
|
|
97
|
+
processWakeRequest(request: WakeRequest, remotePeerId: string): Promise<WakeAck>;
|
|
98
|
+
}
|
|
99
|
+
/** Options for {@link dialWake}. */
|
|
100
|
+
export interface DialWakeOptions {
|
|
101
|
+
/** Per-dial timeout in ms (default {@link DEFAULT_WAKE_TIMEOUT_MS}). */
|
|
102
|
+
timeoutMs?: number;
|
|
103
|
+
/** Override the protocol id (defaults to {@link WAKE_PROTOCOL}). */
|
|
104
|
+
protocolId?: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Sender side: dial a target's control-network address(es), send a
|
|
108
|
+
* {@link WakeRequest} over `WAKE_PROTOCOL`, and return the peer's {@link WakeAck}.
|
|
109
|
+
*
|
|
110
|
+
* Tries each candidate address in order (signaling/relay first, as produced by
|
|
111
|
+
* `CadreNode.resolvePeerAddrs`) until one dials, so a NAT'd peer is reachable via
|
|
112
|
+
* its circuit-relay address. Throws if no address is dialable.
|
|
113
|
+
*/
|
|
114
|
+
export declare function dialWake(node: Libp2p, addrs: Multiaddr[], request: WakeRequest, options?: DialWakeOptions): Promise<WakeAck>;
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Control-network push-wake transport.
|
|
3
|
+
*
|
|
4
|
+
* Lets a same-cadre peer — typically an always-on server that participates in a
|
|
5
|
+
* strand and sees new activity — signal a hibernating cadre peer to bring that
|
|
6
|
+
* strand online, pull pending activity, and re-hibernate. Push-wake travels the
|
|
7
|
+
* **control network** (the per-party network connecting this party's own cadre
|
|
8
|
+
* nodes), which is the only network a hibernating peer keeps connected.
|
|
9
|
+
*
|
|
10
|
+
* Modeled directly on `seed-bootstrap.ts`: a dedicated libp2p protocol id,
|
|
11
|
+
* 4-byte big-endian length-prefixed JSON frames, `node.handle` for the receiver,
|
|
12
|
+
* `node.dialProtocol` for the sender, and the shared `ControlStream` primitives
|
|
13
|
+
* from `control-stream.ts`. The exchange is a single request → single ack on one
|
|
14
|
+
* stream (like seed delivery), so each side reads to EOF (under a read timeout)
|
|
15
|
+
* and decodes one frame via the shared {@link decodeLengthPrefixedFrame} guard.
|
|
16
|
+
*
|
|
17
|
+
* **Authorization (v1):** the control network already restricts membership —
|
|
18
|
+
* only this party's cadre peers connect (schema-gated `CadrePeer`). A wake is
|
|
19
|
+
* low-risk: it only causes the receiver to spend resources coming online for a
|
|
20
|
+
* strand it already participates in. So the receiver verifies the remote peer is
|
|
21
|
+
* a `CadrePeer` member (via the injected `isMember` gate) and requires no
|
|
22
|
+
* signature beyond control-network membership. A richer per-request signature is
|
|
23
|
+
* deliberately out of scope for v1.
|
|
24
|
+
*/
|
|
25
|
+
import debug from 'debug';
|
|
26
|
+
import { decodeLengthPrefixedFrame } from './seed-bootstrap.js';
|
|
27
|
+
import { writeFrame, withTimeout, readStreamToEnd } from './control-stream.js';
|
|
28
|
+
const log = debug('sereus:cadre:strand-wake');
|
|
29
|
+
/** Protocol id for control-network push-wake (parallel to `/sereus/seed/1.0.0`). */
|
|
30
|
+
export const WAKE_PROTOCOL = '/sereus/strand-wake/1.0.0';
|
|
31
|
+
/**
|
|
32
|
+
* Maximum wake frame size. Wake messages are tiny (a strand id + short reason),
|
|
33
|
+
* so this is a defensive cap — far below the 1MB seed ceiling — that bounds the
|
|
34
|
+
* bytes a peer can make the receiver buffer per stream.
|
|
35
|
+
*/
|
|
36
|
+
const MAX_WAKE_SIZE = 64 * 1024;
|
|
37
|
+
/** Default time to wait for the ack before abandoning a wake dial (ms). */
|
|
38
|
+
const DEFAULT_WAKE_TIMEOUT_MS = 10000;
|
|
39
|
+
/** Default time the receiver waits for an inbound wake frame before aborting (ms). */
|
|
40
|
+
const DEFAULT_WAKE_READ_TIMEOUT_MS = 10000;
|
|
41
|
+
/** Default cap on concurrent inbound wake streams a single peer can pin open. */
|
|
42
|
+
const DEFAULT_MAX_CONCURRENT_WAKES = 100;
|
|
43
|
+
/**
|
|
44
|
+
* Read a libp2p stream to EOF and decode the single length-prefixed JSON frame
|
|
45
|
+
* it carries. Bounded by `timeoutMs` (a never-half-closing peer is aborted, not
|
|
46
|
+
* awaited forever) and capped at {@link MAX_WAKE_SIZE}, reusing the shared
|
|
47
|
+
* {@link decodeLengthPrefixedFrame} guard for the prefix/length checks.
|
|
48
|
+
*/
|
|
49
|
+
async function readFrame(stream, timeoutMs) {
|
|
50
|
+
const data = await readStreamToEnd(stream, { maxBytes: MAX_WAKE_SIZE, timeoutMs, label: 'Wake' });
|
|
51
|
+
const body = decodeLengthPrefixedFrame(data, MAX_WAKE_SIZE);
|
|
52
|
+
return JSON.parse(new TextDecoder().decode(body));
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Receiver side of the push-wake protocol. Registers a `WAKE_PROTOCOL` handler
|
|
56
|
+
* on the control node and, for each inbound {@link WakeRequest}, gates on cadre
|
|
57
|
+
* membership, then resumes the named strand if it is hibernating/idle and we
|
|
58
|
+
* participate in it — replying with a {@link WakeAck}.
|
|
59
|
+
*/
|
|
60
|
+
export class StrandWakeService {
|
|
61
|
+
constructor(options) {
|
|
62
|
+
this.node = null;
|
|
63
|
+
/** In-flight inbound wake streams, used to enforce {@link maxConcurrent}. */
|
|
64
|
+
this.activeStreams = 0;
|
|
65
|
+
this.options = options;
|
|
66
|
+
this.readTimeoutMs = options.readTimeoutMs ?? DEFAULT_WAKE_READ_TIMEOUT_MS;
|
|
67
|
+
this.maxConcurrent = options.maxConcurrent ?? DEFAULT_MAX_CONCURRENT_WAKES;
|
|
68
|
+
}
|
|
69
|
+
/** Number of in-flight inbound wake streams. */
|
|
70
|
+
get activeCount() {
|
|
71
|
+
return this.activeStreams;
|
|
72
|
+
}
|
|
73
|
+
/** Register the wake protocol handler on the control node. */
|
|
74
|
+
initialize(node) {
|
|
75
|
+
this.node = node;
|
|
76
|
+
// `runOnLimitedConnection: true` is REQUIRED for the relay path: a NAT'd
|
|
77
|
+
// receiver is reached over a circuit-relay connection, which libp2p marks
|
|
78
|
+
// "limited" (the relay caps its data/duration). Without this the receiver
|
|
79
|
+
// would refuse the inbound wake stream on exactly the connection the
|
|
80
|
+
// protocol is designed to use (see the relay note on `dialWake`).
|
|
81
|
+
void node.handle(WAKE_PROTOCOL, async (rawStream, rawConnection) => {
|
|
82
|
+
const remotePeerId = rawConnection.remotePeer.toString();
|
|
83
|
+
await this.handleStream(rawStream, remotePeerId);
|
|
84
|
+
}, { runOnLimitedConnection: true });
|
|
85
|
+
log('StrandWakeService registered handler: %s', WAKE_PROTOCOL);
|
|
86
|
+
}
|
|
87
|
+
/** Unregister the handler and release the node reference. */
|
|
88
|
+
async shutdown() {
|
|
89
|
+
if (this.node) {
|
|
90
|
+
await this.node.unhandle(WAKE_PROTOCOL);
|
|
91
|
+
this.node = null;
|
|
92
|
+
log('StrandWakeService shutdown');
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Read the inbound request, decide + execute the wake, and write the ack.
|
|
97
|
+
*
|
|
98
|
+
* Three hardening layers, all reported as a non-accepting ack rather than a
|
|
99
|
+
* dropped/hung stream: a concurrency cap (over {@link maxConcurrent}, reply
|
|
100
|
+
* without touching the wake path), a read timeout (a peer that never
|
|
101
|
+
* half-closes is aborted inside {@link readFrame}/`readStreamToEnd`), and the
|
|
102
|
+
* existing malformed/oversized-frame guard.
|
|
103
|
+
*/
|
|
104
|
+
async handleStream(stream, remotePeerId) {
|
|
105
|
+
log('Incoming wake request from: %s', remotePeerId);
|
|
106
|
+
if (this.activeStreams >= this.maxConcurrent) {
|
|
107
|
+
log('Rejecting wake from %s: %d concurrent streams at cap %d', remotePeerId, this.activeStreams, this.maxConcurrent);
|
|
108
|
+
const ack = { accepted: false, reason: 'Too many concurrent wake requests' };
|
|
109
|
+
try {
|
|
110
|
+
writeFrame(stream, ack);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
// Ignore send errors on the reject path.
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
await stream.close();
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
// Ignore close errors.
|
|
120
|
+
}
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
this.activeStreams++;
|
|
124
|
+
try {
|
|
125
|
+
const request = await readFrame(stream, this.readTimeoutMs);
|
|
126
|
+
const ack = await this.processWakeRequest(request, remotePeerId);
|
|
127
|
+
writeFrame(stream, ack);
|
|
128
|
+
}
|
|
129
|
+
catch (err) {
|
|
130
|
+
log('Error handling wake request from %s: %o', remotePeerId, err);
|
|
131
|
+
const ack = {
|
|
132
|
+
accepted: false,
|
|
133
|
+
reason: err instanceof Error ? err.message : 'Unknown error',
|
|
134
|
+
};
|
|
135
|
+
try {
|
|
136
|
+
writeFrame(stream, ack);
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
// Ignore send errors on the error path.
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
finally {
|
|
143
|
+
this.activeStreams--;
|
|
144
|
+
try {
|
|
145
|
+
await stream.close();
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
// Ignore close errors.
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Decide and execute the wake for a decoded request. Exposed (not private) so
|
|
154
|
+
* the decision matrix can be unit-tested directly.
|
|
155
|
+
*
|
|
156
|
+
* - Non-member sender → rejected (`accepted: false`).
|
|
157
|
+
* - Unknown / not-participated strand → rejected.
|
|
158
|
+
* - Hibernating or idle strand → resumed via the wake path, then `accepted`.
|
|
159
|
+
* - Already-live strand → no-op, `accepted` with current status.
|
|
160
|
+
*/
|
|
161
|
+
async processWakeRequest(request, remotePeerId) {
|
|
162
|
+
// Control-network membership is the v1 authorization: only this party's
|
|
163
|
+
// cadre peers may ask us to wake.
|
|
164
|
+
if (!(await this.options.isMember(remotePeerId))) {
|
|
165
|
+
log('Rejecting wake from non-member %s', remotePeerId);
|
|
166
|
+
return { accepted: false, reason: 'Sender is not a cadre member' };
|
|
167
|
+
}
|
|
168
|
+
const instance = this.options.getStrand(request.strandId);
|
|
169
|
+
if (!instance) {
|
|
170
|
+
log('Rejecting wake for unknown/unparticipated strand %s', request.strandId);
|
|
171
|
+
return { accepted: false, reason: 'Strand not found or not participated in' };
|
|
172
|
+
}
|
|
173
|
+
if (instance.status === 'hibernating' || instance.status === 'idle') {
|
|
174
|
+
log('Waking strand %s on push from %s (reason=%s)', request.strandId, remotePeerId, request.reason ?? 'unspecified');
|
|
175
|
+
await this.options.wake(request.strandId);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
log('Strand %s already %s; push-wake is a no-op', request.strandId, instance.status);
|
|
179
|
+
}
|
|
180
|
+
// The wake path mutates the shared instance, so re-read its current status.
|
|
181
|
+
return { accepted: true, status: instance.status };
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Sender side: dial a target's control-network address(es), send a
|
|
186
|
+
* {@link WakeRequest} over `WAKE_PROTOCOL`, and return the peer's {@link WakeAck}.
|
|
187
|
+
*
|
|
188
|
+
* Tries each candidate address in order (signaling/relay first, as produced by
|
|
189
|
+
* `CadreNode.resolvePeerAddrs`) until one dials, so a NAT'd peer is reachable via
|
|
190
|
+
* its circuit-relay address. Throws if no address is dialable.
|
|
191
|
+
*/
|
|
192
|
+
export async function dialWake(node, addrs, request, options = {}) {
|
|
193
|
+
if (addrs.length === 0) {
|
|
194
|
+
throw new Error('No dialable address for wake target');
|
|
195
|
+
}
|
|
196
|
+
const protocolId = options.protocolId ?? WAKE_PROTOCOL;
|
|
197
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_WAKE_TIMEOUT_MS;
|
|
198
|
+
let lastError = null;
|
|
199
|
+
for (const addr of addrs) {
|
|
200
|
+
// One controller per attempt: on timeout, `withTimeout`'s `onTimeout` aborts
|
|
201
|
+
// it, which aborts the in-flight dialProtocol (via the dial `signal`) and the
|
|
202
|
+
// live stream — so neither the connect nor the unbounded ack-read leaks.
|
|
203
|
+
const controller = new AbortController();
|
|
204
|
+
try {
|
|
205
|
+
return await withTimeout(timeoutMs, `Wake dial ${addr.toString()}`, () => sendWake(node, addr, protocolId, request, timeoutMs, controller.signal), () => controller.abort());
|
|
206
|
+
}
|
|
207
|
+
catch (err) {
|
|
208
|
+
lastError = err instanceof Error ? err : new Error(String(err));
|
|
209
|
+
log('Wake dial to %s failed: %o', addr.toString(), err);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
throw lastError ?? new Error('Wake dial failed');
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Open one stream, send the request, half-close, and read the ack.
|
|
216
|
+
*
|
|
217
|
+
* `signal` is the per-attempt abort signal from {@link dialWake}: it is passed to
|
|
218
|
+
* `dialProtocol` so a timeout during connect aborts the dial, and once the stream
|
|
219
|
+
* is open an abort listener resets the live stream — releasing the otherwise
|
|
220
|
+
* unbounded ack-read. `readFrame` still applies `timeoutMs` as a backstop for the
|
|
221
|
+
* case where an abort does not propagate (e.g. a stream double whose `abort()` is
|
|
222
|
+
* a no-op).
|
|
223
|
+
*/
|
|
224
|
+
async function sendWake(node, addr, protocolId, request, timeoutMs, signal) {
|
|
225
|
+
// `runOnLimitedConnection: true`: the target may be reachable only over a
|
|
226
|
+
// circuit-relay connection (the signaling-first addr), which libp2p marks
|
|
227
|
+
// "limited". The wake exchange is a single tiny request→ack well within the
|
|
228
|
+
// relay's data/duration cap, so opening it on the limited connection is safe
|
|
229
|
+
// and is the whole point of dialing the relay address.
|
|
230
|
+
const rawStream = await node.dialProtocol(addr, protocolId, { runOnLimitedConnection: true, signal });
|
|
231
|
+
const stream = rawStream;
|
|
232
|
+
const abortErr = new Error('Wake dial aborted by timeout');
|
|
233
|
+
const onAbort = () => stream.abort(abortErr);
|
|
234
|
+
// If the timeout already fired during connect, release the freshly-opened stream now.
|
|
235
|
+
if (signal.aborted) {
|
|
236
|
+
onAbort();
|
|
237
|
+
throw abortErr;
|
|
238
|
+
}
|
|
239
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
240
|
+
try {
|
|
241
|
+
writeFrame(stream, request);
|
|
242
|
+
// close() half-closes the write end (EOF) while the read end stays open for
|
|
243
|
+
// the ack — the same libp2p 3.x pattern as seed delivery.
|
|
244
|
+
await stream.close();
|
|
245
|
+
const ack = await readFrame(stream, timeoutMs);
|
|
246
|
+
log('Wake ack from %s: accepted=%s status=%s', addr.toString(), ack.accepted, ack.status ?? '-');
|
|
247
|
+
return ack;
|
|
248
|
+
}
|
|
249
|
+
catch (err) {
|
|
250
|
+
stream.abort(err instanceof Error ? err : new Error(String(err)));
|
|
251
|
+
throw err;
|
|
252
|
+
}
|
|
253
|
+
finally {
|
|
254
|
+
signal.removeEventListener('abort', onAbort);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=strand-wake-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strand-wake-protocol.js","sourceRoot":"","sources":["../src/strand-wake-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAsB,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEnG,MAAM,GAAG,GAAG,KAAK,CAAC,0BAA0B,CAAC,CAAC;AAE9C,oFAAoF;AACpF,MAAM,CAAC,MAAM,aAAa,GAAG,2BAA2B,CAAC;AAEzD;;;;GAIG;AACH,MAAM,aAAa,GAAG,EAAE,GAAG,IAAI,CAAC;AAEhC,2EAA2E;AAC3E,MAAM,uBAAuB,GAAG,KAAM,CAAC;AAEvC,sFAAsF;AACtF,MAAM,4BAA4B,GAAG,KAAM,CAAC;AAE5C,iFAAiF;AACjF,MAAM,4BAA4B,GAAG,GAAG,CAAC;AAEzC;;;;;GAKG;AACH,KAAK,UAAU,SAAS,CAAI,MAA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AAC,KAAK,EAAE,CAAC;QACrB,MAAM,GAAG,GAAG,MAAM,SAAS,CAAU,MAAM,EAAE,SAAS,CAAC,CAAC;QACxD,GAAG,CAAC,yCAAyC,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC;QACjG,OAAO,GAAG,CAAC;IACb,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,KAAK,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAClE,MAAM,GAAG,CAAC;IACZ,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC"}
|
package/dist/strand-watcher.d.ts
CHANGED
|
@@ -40,14 +40,18 @@ export declare class StrandWatcher {
|
|
|
40
40
|
private readonly queryable;
|
|
41
41
|
private readonly sAppIdLookup?;
|
|
42
42
|
private knownStrands;
|
|
43
|
+
/** Ids admitted under a `defer` decision; re-evaluated each poll until they resolve. */
|
|
44
|
+
private provisional;
|
|
43
45
|
private pollTimer;
|
|
44
46
|
private initialPollTimer;
|
|
45
47
|
private running;
|
|
46
48
|
constructor(queryable: StrandQueryable, callbacks: StrandWatcherCallbacks, filter?: StrandFilter, pollInterval?: number, sAppIdLookup?: SAppIdLookup);
|
|
47
49
|
/**
|
|
48
|
-
*
|
|
50
|
+
* Evaluate a strand against the current filter, distinguishing a not-yet-known
|
|
51
|
+
* sAppId (`defer`) from a known non-match (`reject`). A `defer` admission is
|
|
52
|
+
* provisional and re-checked on subsequent polls.
|
|
49
53
|
*/
|
|
50
|
-
private
|
|
54
|
+
private evaluateFilter;
|
|
51
55
|
/**
|
|
52
56
|
* Poll for strand changes
|
|
53
57
|
*/
|
package/dist/strand-watcher.js
CHANGED
|
@@ -9,6 +9,8 @@ const log = debug('sereus:cadre:strand-watcher');
|
|
|
9
9
|
export class StrandWatcher {
|
|
10
10
|
constructor(queryable, callbacks, filter = { mode: 'all' }, pollInterval = 5000, sAppIdLookup) {
|
|
11
11
|
this.knownStrands = new Map();
|
|
12
|
+
/** Ids admitted under a `defer` decision; re-evaluated each poll until they resolve. */
|
|
13
|
+
this.provisional = new Set();
|
|
12
14
|
this.pollTimer = null;
|
|
13
15
|
this.initialPollTimer = null;
|
|
14
16
|
this.running = false;
|
|
@@ -20,31 +22,35 @@ export class StrandWatcher {
|
|
|
20
22
|
log('StrandWatcher created with filter: %o, interval: %dms', filter, pollInterval);
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
|
-
*
|
|
25
|
+
* Evaluate a strand against the current filter, distinguishing a not-yet-known
|
|
26
|
+
* sAppId (`defer`) from a known non-match (`reject`). A `defer` admission is
|
|
27
|
+
* provisional and re-checked on subsequent polls.
|
|
24
28
|
*/
|
|
25
|
-
|
|
29
|
+
evaluateFilter(strand) {
|
|
26
30
|
switch (this.filter.mode) {
|
|
27
31
|
case 'all':
|
|
28
|
-
return
|
|
32
|
+
return 'pass';
|
|
29
33
|
case 'none':
|
|
30
|
-
return
|
|
34
|
+
return 'reject';
|
|
31
35
|
case 'strandId':
|
|
32
|
-
return strand.Id === this.filter.strandId;
|
|
36
|
+
return strand.Id === this.filter.strandId ? 'pass' : 'reject';
|
|
33
37
|
case 'sAppId': {
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
if (!this.sAppIdLookup) {
|
|
39
|
+
// No way to ever decide - admit permanently (no lookup configured).
|
|
40
|
+
return 'pass';
|
|
41
|
+
}
|
|
42
|
+
const sAppId = this.sAppIdLookup.getSAppId(strand.Id);
|
|
36
43
|
if (sAppId === undefined) {
|
|
37
|
-
//
|
|
38
|
-
// The strand will need to be re-evaluated when sApp info is available
|
|
44
|
+
// sAppId not yet known - admit provisionally and re-evaluate next poll.
|
|
39
45
|
log('sAppId unknown for strand %s - deferring filter decision', strand.Id);
|
|
40
|
-
return
|
|
46
|
+
return 'defer';
|
|
41
47
|
}
|
|
42
48
|
const matches = sAppId === this.filter.sAppId;
|
|
43
49
|
log('sAppId filter: strand %s has sAppId %s, filter wants %s, match=%s', strand.Id, sAppId, this.filter.sAppId, matches);
|
|
44
|
-
return matches;
|
|
50
|
+
return matches ? 'pass' : 'reject';
|
|
45
51
|
}
|
|
46
52
|
default:
|
|
47
|
-
return
|
|
53
|
+
return 'pass';
|
|
48
54
|
}
|
|
49
55
|
}
|
|
50
56
|
/**
|
|
@@ -58,22 +64,55 @@ export class StrandWatcher {
|
|
|
58
64
|
const currentMap = new Map(currentStrands.map(s => [s.Id, s]));
|
|
59
65
|
// Find added strands
|
|
60
66
|
for (const strand of currentStrands) {
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
if (this.knownStrands.has(strand.Id))
|
|
68
|
+
continue;
|
|
69
|
+
const decision = this.evaluateFilter(strand);
|
|
70
|
+
if (decision === 'reject')
|
|
71
|
+
continue;
|
|
72
|
+
log('Strand added: %s', strand.Id);
|
|
73
|
+
this.knownStrands.set(strand.Id, strand);
|
|
74
|
+
if (decision === 'defer') {
|
|
75
|
+
// Provisional admission: sAppId unknown, re-check on later polls.
|
|
76
|
+
this.provisional.add(strand.Id);
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
await this.callbacks.onStrandAdded(strand);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
log('Error handling strand add for %s: %o', strand.Id, error);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Re-evaluate provisional admissions whose sAppId may now be resolvable.
|
|
86
|
+
// Snapshot ids so we can mutate provisional/knownStrands inside the loop.
|
|
87
|
+
for (const strandId of [...this.provisional]) {
|
|
88
|
+
const strand = currentMap.get(strandId);
|
|
89
|
+
if (!strand)
|
|
90
|
+
continue; // handled by the removed-strand loop below
|
|
91
|
+
const decision = this.evaluateFilter(strand);
|
|
92
|
+
if (decision === 'pass') {
|
|
93
|
+
// Resolved to a match - admission is now final.
|
|
94
|
+
this.provisional.delete(strandId);
|
|
95
|
+
}
|
|
96
|
+
else if (decision === 'reject') {
|
|
97
|
+
// Resolved to a non-match - stop the provisionally-admitted strand.
|
|
98
|
+
log('Provisional strand rejected on re-evaluation: %s', strandId);
|
|
99
|
+
this.knownStrands.delete(strandId);
|
|
100
|
+
this.provisional.delete(strandId);
|
|
64
101
|
try {
|
|
65
|
-
await this.callbacks.
|
|
102
|
+
await this.callbacks.onStrandRemoved(strandId);
|
|
66
103
|
}
|
|
67
104
|
catch (error) {
|
|
68
|
-
log('Error handling strand
|
|
105
|
+
log('Error handling strand remove for %s: %o', strandId, error);
|
|
69
106
|
}
|
|
70
107
|
}
|
|
108
|
+
// decision === 'defer': still unknown, leave provisional for next poll.
|
|
71
109
|
}
|
|
72
110
|
// Find removed strands
|
|
73
111
|
for (const [strandId] of this.knownStrands) {
|
|
74
112
|
if (!currentMap.has(strandId)) {
|
|
75
113
|
log('Strand removed: %s', strandId);
|
|
76
114
|
this.knownStrands.delete(strandId);
|
|
115
|
+
this.provisional.delete(strandId);
|
|
77
116
|
try {
|
|
78
117
|
await this.callbacks.onStrandRemoved(strandId);
|
|
79
118
|
}
|
|
@@ -127,6 +166,7 @@ export class StrandWatcher {
|
|
|
127
166
|
this.pollTimer = null;
|
|
128
167
|
}
|
|
129
168
|
this.knownStrands.clear();
|
|
169
|
+
this.provisional.clear();
|
|
130
170
|
log('StrandWatcher stopped');
|
|
131
171
|
}
|
|
132
172
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strand-watcher.js","sourceRoot":"","sources":["../src/strand-watcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,GAAG,GAAG,KAAK,CAAC,6BAA6B,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"str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