@cotal-ai/core 0.169.0 → 0.171.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/dist/agent-endpoint.d.ts +146 -5
- package/dist/agent-endpoint.d.ts.map +1 -1
- package/dist/agent-endpoint.js +69 -12
- package/dist/agent-endpoint.js.map +1 -1
- package/dist/agent-file.d.ts +9 -5
- package/dist/agent-file.d.ts.map +1 -1
- package/dist/agent-file.js +18 -8
- package/dist/agent-file.js.map +1 -1
- package/dist/anycast-requests.d.ts +8 -1
- package/dist/anycast-requests.d.ts.map +1 -1
- package/dist/anycast-requests.js +47 -0
- package/dist/anycast-requests.js.map +1 -1
- package/dist/backup-config.d.ts +5 -2
- package/dist/backup-config.d.ts.map +1 -1
- package/dist/backup-config.js +7 -2
- package/dist/backup-config.js.map +1 -1
- package/dist/backup.d.ts +6 -0
- package/dist/backup.d.ts.map +1 -1
- package/dist/backup.js +11 -4
- package/dist/backup.js.map +1 -1
- package/dist/connector-setup.d.ts +2 -0
- package/dist/connector-setup.d.ts.map +1 -1
- package/dist/endpoint-action.d.ts +2 -2
- package/dist/endpoint-action.js +6 -7
- package/dist/endpoint-action.js.map +1 -1
- package/dist/endpoint-binding.d.ts.map +1 -1
- package/dist/endpoint-binding.js +2 -0
- package/dist/endpoint-binding.js.map +1 -1
- package/dist/endpoint-boot-memberships.d.ts +71 -0
- package/dist/endpoint-boot-memberships.d.ts.map +1 -0
- package/dist/endpoint-boot-memberships.js +119 -0
- package/dist/endpoint-boot-memberships.js.map +1 -0
- package/dist/endpoint-channel-discovery.d.ts +102 -0
- package/dist/endpoint-channel-discovery.d.ts.map +1 -0
- package/dist/endpoint-channel-discovery.js +170 -0
- package/dist/endpoint-channel-discovery.js.map +1 -0
- package/dist/endpoint-control-plane.d.ts +204 -0
- package/dist/endpoint-control-plane.d.ts.map +1 -0
- package/dist/endpoint-control-plane.js +627 -0
- package/dist/endpoint-control-plane.js.map +1 -0
- package/dist/endpoint-durable-backstop.d.ts +249 -0
- package/dist/endpoint-durable-backstop.d.ts.map +1 -0
- package/dist/endpoint-durable-backstop.js +485 -0
- package/dist/endpoint-durable-backstop.js.map +1 -0
- package/dist/endpoint-journal.d.ts.map +1 -1
- package/dist/endpoint-journal.js +14 -6
- package/dist/endpoint-journal.js.map +1 -1
- package/dist/endpoint-liveness.d.ts +105 -0
- package/dist/endpoint-liveness.d.ts.map +1 -0
- package/dist/endpoint-liveness.js +223 -0
- package/dist/endpoint-liveness.js.map +1 -0
- package/dist/endpoint-messaging.d.ts +229 -0
- package/dist/endpoint-messaging.d.ts.map +1 -0
- package/dist/endpoint-messaging.js +420 -0
- package/dist/endpoint-messaging.js.map +1 -0
- package/dist/endpoint-presence.d.ts +15 -0
- package/dist/endpoint-presence.d.ts.map +1 -1
- package/dist/endpoint-presence.js +35 -0
- package/dist/endpoint-presence.js.map +1 -1
- package/dist/endpoint-provisioning.d.ts +73 -0
- package/dist/endpoint-provisioning.d.ts.map +1 -0
- package/dist/endpoint-provisioning.js +122 -0
- package/dist/endpoint-provisioning.js.map +1 -0
- package/dist/endpoint-subscriptions.d.ts +199 -0
- package/dist/endpoint-subscriptions.d.ts.map +1 -0
- package/dist/endpoint-subscriptions.js +543 -0
- package/dist/endpoint-subscriptions.js.map +1 -0
- package/dist/endpoint.d.ts +42 -124
- package/dist/endpoint.d.ts.map +1 -1
- package/dist/endpoint.js +299 -1903
- package/dist/endpoint.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/provision-jwt.d.ts.map +1 -1
- package/dist/provision-jwt.js +1 -0
- package/dist/provision-jwt.js.map +1 -1
- package/dist/provision-permission-builders.d.ts +356 -0
- package/dist/provision-permission-builders.d.ts.map +1 -0
- package/dist/provision-permission-builders.js +1383 -0
- package/dist/provision-permission-builders.js.map +1 -0
- package/dist/provision-permissions.d.ts +3 -48
- package/dist/provision-permissions.d.ts.map +1 -1
- package/dist/provision-permissions.js +12 -1378
- package/dist/provision-permissions.js.map +1 -1
- package/dist/run-host.d.ts +4 -1
- package/dist/run-host.d.ts.map +1 -1
- package/dist/run-record.d.ts +4 -0
- package/dist/run-record.d.ts.map +1 -1
- package/dist/run-record.js +36 -0
- package/dist/run-record.js.map +1 -1
- package/dist/space-quiescence-resources.d.ts +30 -0
- package/dist/space-quiescence-resources.d.ts.map +1 -0
- package/dist/space-quiescence-resources.js +45 -0
- package/dist/space-quiescence-resources.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,543 @@
|
|
|
1
|
+
// The dynamic subscription region of CotalEndpoint (join, leave, channel listing and the membership
|
|
2
|
+
// feed watches), as an internal component. Moved verbatim from endpoint.ts; the endpoint keeps the
|
|
3
|
+
// public methods and forwards to them. Not re-exported by the index.
|
|
4
|
+
import { ClosedConnectionError, TimeoutError } from "@nats-io/transport-node";
|
|
5
|
+
import { jetstreamManager, JetStreamApiCodes } from "@nats-io/jetstream";
|
|
6
|
+
import { Kvm } from "@nats-io/kv";
|
|
7
|
+
import { Bucket, KvWatchInclude } from "@nats-io/kv/internal";
|
|
8
|
+
import { effectiveDeliveryClass } from "./channels.js";
|
|
9
|
+
import { isPublishPermissionDenied } from "./endpoint.js";
|
|
10
|
+
import { isJetStreamMissing } from "./jetstream-missing.js";
|
|
11
|
+
import { lastKvEntries } from "./kv-scan.js";
|
|
12
|
+
import { chatStream, dmStream, isChannelFamily, isConcreteChannel, isPrincipalOwnerToken, membershipBucket, MEMBERSHIP_FEED_KEY, parseSubject } from "./subjects.js";
|
|
13
|
+
/** One feed entry, decoded the way {@link CotalEndpoint.readMembership} decodes it: the reserved
|
|
14
|
+
* heartbeat key carries `asOf`, every other key is one agent's record, and an undecodable record
|
|
15
|
+
* is a member change with no record (never a crash in the consumer callback). */
|
|
16
|
+
function membershipChange(e, update) {
|
|
17
|
+
const operation = e.operation;
|
|
18
|
+
if (e.key === MEMBERSHIP_FEED_KEY) {
|
|
19
|
+
let asOf;
|
|
20
|
+
if (operation === "PUT") {
|
|
21
|
+
try {
|
|
22
|
+
asOf = e.json().observedAt;
|
|
23
|
+
}
|
|
24
|
+
catch { /* heartbeat garbled; leave undefined */ }
|
|
25
|
+
}
|
|
26
|
+
return { type: "heartbeat", revision: e.revision, update, asOf };
|
|
27
|
+
}
|
|
28
|
+
let member;
|
|
29
|
+
if (operation === "PUT") {
|
|
30
|
+
try {
|
|
31
|
+
const rec = e.json();
|
|
32
|
+
member = { id: e.key, live: rec.live ?? [], durable: rec.durable ?? [], observedAt: rec.observedAt };
|
|
33
|
+
}
|
|
34
|
+
catch { /* undecodable: delivered as a change with no record */ }
|
|
35
|
+
}
|
|
36
|
+
return { type: "member", id: e.key, operation, revision: e.revision, update, member };
|
|
37
|
+
}
|
|
38
|
+
/** One endpoint's dynamic subscriptions: join and leave mid-session, the channel and retention
|
|
39
|
+
* listings, and the membership feed's snapshot read and watches with their consumer cleanup.
|
|
40
|
+
* Internal: `CotalEndpoint` keeps the public methods and forwards to it. */
|
|
41
|
+
export class EndpointSubscriptions {
|
|
42
|
+
deps;
|
|
43
|
+
constructor(deps) {
|
|
44
|
+
this.deps = deps;
|
|
45
|
+
}
|
|
46
|
+
get nc() { return this.deps.nc(); }
|
|
47
|
+
get jsm() { return this.deps.jsm(); }
|
|
48
|
+
get space() { return this.deps.space(); }
|
|
49
|
+
get card() { return this.deps.card(); }
|
|
50
|
+
get stopped() { return this.deps.stopped(); }
|
|
51
|
+
get authed() { return this.deps.authed(); }
|
|
52
|
+
get channels() { return this.deps.channels(); }
|
|
53
|
+
get channelConfigs() { return this.deps.channelConfigs(); }
|
|
54
|
+
get channelDefaults() { return this.deps.channelDefaults(); }
|
|
55
|
+
get chatSubDenied() { return this.deps.chatSubDenied(); }
|
|
56
|
+
get plane3Channels() { return this.deps.plane3Channels(); }
|
|
57
|
+
get readsChannelsOnDemand() { return this.deps.readsChannelsOnDemand(); }
|
|
58
|
+
get membershipFeedKv() { return this.deps.membershipFeedKv(); }
|
|
59
|
+
set membershipFeedKv(kv) { this.deps.setMembershipFeedKv(kv); }
|
|
60
|
+
get membershipFeedWatches() { return this.deps.membershipFeedWatches(); }
|
|
61
|
+
get watchDeletePermissions() { return this.deps.watchDeletePermissions(); }
|
|
62
|
+
notLiveMsg() { return this.deps.notLiveMsg(); }
|
|
63
|
+
readChannels() { return this.deps.readChannels(); }
|
|
64
|
+
armJoin(channels) { return this.deps.armJoin(channels); }
|
|
65
|
+
backfillArmed(frontiers, floorSeq) { return this.deps.backfillArmed(frontiers, floorSeq); }
|
|
66
|
+
subscribeChat(channel) { this.deps.subscribeChat(channel); }
|
|
67
|
+
unsubscribeChat(channel) { this.deps.unsubscribeChat(channel); }
|
|
68
|
+
confirmChatSub() { return this.deps.confirmChatSub(); }
|
|
69
|
+
durableJoinChannel(channel) { return this.deps.durableJoinChannel(channel); }
|
|
70
|
+
durableLeaveChannel(channel, generation, lifecycleUid) { return this.deps.durableLeaveChannel(channel, generation, lifecycleUid); }
|
|
71
|
+
fetchMemberships(channel) { return this.deps.fetchMemberships(channel); }
|
|
72
|
+
recordOwnWatchConsumer(info) { return this.deps.recordOwnWatchConsumer(info); }
|
|
73
|
+
watchConsumerDeleteDenied(stream, name, owner) { return this.deps.watchConsumerDeleteDenied(stream, name, owner); }
|
|
74
|
+
deleteMembershipConsumer(jsm, stream, name) { return this.deps.deleteMembershipConsumer(jsm, stream, name); }
|
|
75
|
+
emit(event, ...args) { return this.deps.emit(event, ...args); }
|
|
76
|
+
/** The channels this endpoint is currently subscribed to (live — reflects join/leave). */
|
|
77
|
+
joinedChannels() {
|
|
78
|
+
return [...this.channels];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Join a channel mid-session: open a native core subscription (manager-free live read, broker-
|
|
82
|
+
* confirmed against `sub.allow`), capture the stream frontier as the join watermark, backfill its
|
|
83
|
+
* history if replay is on, and — for a `durable`-class channel or a family such as `review.>` when a
|
|
84
|
+
* delivery daemon is present — request a Plane-3 durable backstop (via `ctl.delivery`). Any other
|
|
85
|
+
* pattern stays live only, with a `reason`. Idempotent: re-joining is a no-op (no
|
|
86
|
+
* re-backfill). Returns the backfill count + whether the durable backstop is active (+ a `reason`
|
|
87
|
+
* when a durable channel couldn't get one).
|
|
88
|
+
*/
|
|
89
|
+
async joinChannel(channel) {
|
|
90
|
+
if (!this.jsm)
|
|
91
|
+
throw new Error(this.notLiveMsg());
|
|
92
|
+
if (this.channels.includes(channel))
|
|
93
|
+
return { joined: false, backfilled: 0, durable: this.plane3Channels.has(channel) };
|
|
94
|
+
// The delivery class below comes from the cache, so a seat reads it current before joining.
|
|
95
|
+
if (this.readsChannelsOnDemand)
|
|
96
|
+
await this.readChannels();
|
|
97
|
+
// Arm the watermark BEFORE going live: the backfill reads ≤ frontier and the core-sub only ever
|
|
98
|
+
// delivers post-subscribe live messages (> frontier), so the two never overlap.
|
|
99
|
+
const armed = await this.armJoin([channel]);
|
|
100
|
+
// Live read (SPEC v0.3): open the native core subscription — MANAGER-FREE, broker-enforced by
|
|
101
|
+
// sub.allow. This is what lets an agent join a channel's live feed on its own. The sub.allow
|
|
102
|
+
// refusal is async — broker-confirm before committing local join state; the subscribe handler
|
|
103
|
+
// ALSO drops a channel on ANY refusal (incl. a late one), so this is not a timing gamble (#13).
|
|
104
|
+
this.subscribeChat(channel);
|
|
105
|
+
try {
|
|
106
|
+
await this.confirmChatSub();
|
|
107
|
+
}
|
|
108
|
+
catch (e) {
|
|
109
|
+
// The confirm boundary (flush) failed — the connection drained/closed mid-join, so we have NO
|
|
110
|
+
// confirmation the subscribe was accepted. Fail closed: undo the half-open join rather than
|
|
111
|
+
// returning as if it were confirmed (a reconnect re-confirms from this.channels, which we never
|
|
112
|
+
// pushed to). unsubscribeChat clears chatSubs.
|
|
113
|
+
this.unsubscribeChat(channel);
|
|
114
|
+
throw new Error(`cannot join "${channel}": live subscription could not be confirmed (${e.message})`);
|
|
115
|
+
}
|
|
116
|
+
if (this.chatSubDenied.has(channel)) {
|
|
117
|
+
this.unsubscribeChat(channel);
|
|
118
|
+
throw new Error(`cannot join "${channel}": not within this agent's read ACL (allowSubscribe)`);
|
|
119
|
+
}
|
|
120
|
+
this.channels.push(channel);
|
|
121
|
+
// Durable backstop. The live core-sub above already delivers (manager-free). For a `durable`-class
|
|
122
|
+
// channel, request a Plane-3 per-member backstop from the server-side delivery daemon (durableJoin via ctl.delivery) so a post reaches a
|
|
123
|
+
// busy/offline turn — the core-sub stays as the live wake-hint, dedup-coalesced with the Plane-3
|
|
124
|
+
// copy by id-dedup. No manager (open dev / manager-less) ⇒ joined LIVE only, surfaced via `reason`
|
|
125
|
+
// (never silent). A `live`-class channel takes no backstop (joined live is the contract). A family
|
|
126
|
+
// (`review.>`) always asks for its row: each channel under it decides its own class at fan-out
|
|
127
|
+
// (#5404). Any other pattern has no backstop, and says so.
|
|
128
|
+
let durable = false;
|
|
129
|
+
let reason;
|
|
130
|
+
const family = isChannelFamily(channel);
|
|
131
|
+
if (!family && !isConcreteChannel(channel))
|
|
132
|
+
reason = "a pattern with * or the root > has no stored copies; follow a concrete channel or a family such as review.>";
|
|
133
|
+
else if (family || effectiveDeliveryClass(this.channelConfigs.get(channel), this.channelDefaults) === "durable") {
|
|
134
|
+
try {
|
|
135
|
+
const r = await this.durableJoinChannel(channel);
|
|
136
|
+
if (r.durable) {
|
|
137
|
+
this.plane3Channels.set(channel, r.generation ?? 0);
|
|
138
|
+
durable = true;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
reason = r.reason ?? "durable backstop unavailable";
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
catch (e) {
|
|
145
|
+
// No privileged writer (no delivery daemon) or the write was rejected — joined live, backstop
|
|
146
|
+
// unavailable. NOT a join failure: the live subscription is up and authorized.
|
|
147
|
+
reason = `durable backstop unavailable (${e.message})`;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const backfilled = await this.backfillArmed(armed);
|
|
151
|
+
return { joined: true, backfilled, durable, ...(reason !== undefined ? { reason } : {}) };
|
|
152
|
+
}
|
|
153
|
+
/** Leave a channel mid-session — MANAGER-FREE for the live read: close the core subscription. For a
|
|
154
|
+
* Plane-3 durable channel, the membership is tombstoned FIRST at the leave cursor (SPEC §7: leave is
|
|
155
|
+
* a hard read boundary for the backstop — a pre-leave entry stays deliverable, `seq > leaveCursor` is
|
|
156
|
+
* denied). FAIL-CLOSED: if the tombstone can't be confirmed the call throws and the leave is NOT
|
|
157
|
+
* applied (live sub stays up, local mirror intact) so the caller can retry — never close the live
|
|
158
|
+
* read while the backstop keeps delivering. `legacyDiscoveryMessage` lets the caller supply the
|
|
159
|
+
* remedy when membership discovery predates lifecycle support, without changing the refusal. */
|
|
160
|
+
async leaveChannel(channel, legacyDiscoveryMessage) {
|
|
161
|
+
if (!this.jsm)
|
|
162
|
+
throw new Error(this.notLiveMsg());
|
|
163
|
+
let left = this.channels.includes(channel);
|
|
164
|
+
if (this.readsChannelsOnDemand)
|
|
165
|
+
await this.readChannels();
|
|
166
|
+
// Auth + durable-class ⇒ a Plane-3 membership may exist; tombstone it BEFORE touching local state.
|
|
167
|
+
// Discover the channel's rows across this principal's lifecycles, including memberships absent
|
|
168
|
+
// from the local mirror. Keep each row's generation guard. fetchMemberships throws on a
|
|
169
|
+
// responder-present error, so a leave whose
|
|
170
|
+
// tombstone can't be confirmed propagates (live sub stays up, mirror intact) for the caller to retry
|
|
171
|
+
// — reporting `left` while the trusted reader keeps transferring to DLV is the fail-open leak. A
|
|
172
|
+
// genuine no-responder (open / no delivery daemon, no Plane-3) means there is no membership to tombstone.
|
|
173
|
+
if (this.authed && (isChannelFamily(channel) || effectiveDeliveryClass(this.channelConfigs.get(channel), this.channelDefaults) === "durable")) {
|
|
174
|
+
const memberships = await this.fetchMemberships(channel);
|
|
175
|
+
if (memberships === undefined && this.plane3Channels.has(channel))
|
|
176
|
+
await this.durableLeaveChannel(channel, this.plane3Channels.get(channel));
|
|
177
|
+
for (const member of memberships ?? []) {
|
|
178
|
+
// A daemon before 0.166.0 answers with this lifecycle's rows and no lifecycleUid, so it cannot
|
|
179
|
+
// show an earlier lifecycle's row. Refuse with the remedy rather than leave that row open.
|
|
180
|
+
if (member.lifecycleUid === undefined)
|
|
181
|
+
throw new Error(legacyDiscoveryMessage ?? "the delivery daemon predates lifecycle-aware membership discovery, so this durable leave was not applied and the channel stays joined; restart the daemon at this version (`cotal up` runs it)");
|
|
182
|
+
await this.durableLeaveChannel(channel, member.generation, member.lifecycleUid);
|
|
183
|
+
left = true;
|
|
184
|
+
}
|
|
185
|
+
if (memberships !== undefined)
|
|
186
|
+
this.plane3Channels.delete(channel);
|
|
187
|
+
}
|
|
188
|
+
this.unsubscribeChat(channel);
|
|
189
|
+
const i = this.channels.indexOf(channel);
|
|
190
|
+
if (i >= 0)
|
|
191
|
+
this.channels.splice(i, 1);
|
|
192
|
+
return { left };
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* What the chat stream still holds and what removes the rest. `perSender` is the stream's
|
|
196
|
+
* per-subject cap: a subject is one sender on one channel, and past the cap that sender's oldest
|
|
197
|
+
* message on the channel is discarded. `maxAgeMs` is the stream's age limit. Each is `null` when
|
|
198
|
+
* the stream sets none. `senders` counts each sender's retained messages per channel, so a sender
|
|
199
|
+
* at the cap marks a channel whose retained history has lost that sender's older messages while
|
|
200
|
+
* other senders' messages from the same time remain. `stream` is false when the chat stream does
|
|
201
|
+
* not exist, which holds nothing. `lastSeq` is the stream's newest sequence, 0 when it has none.
|
|
202
|
+
*/
|
|
203
|
+
async chatRetention() {
|
|
204
|
+
if (!this.nc)
|
|
205
|
+
throw new Error(this.notLiveMsg());
|
|
206
|
+
const mgr = await jetstreamManager(this.nc);
|
|
207
|
+
let info;
|
|
208
|
+
try {
|
|
209
|
+
info = await mgr.streams.info(chatStream(this.space), { subjects_filter: ">" });
|
|
210
|
+
}
|
|
211
|
+
catch (e) {
|
|
212
|
+
// As in listChannels: an absent CHAT stream holds nothing yet; any other failure stays loud.
|
|
213
|
+
if (!isJetStreamMissing(e, JetStreamApiCodes.StreamNotFound))
|
|
214
|
+
throw e;
|
|
215
|
+
return { perSender: null, maxAgeMs: null, oldestAt: null, senders: [], stream: false, lastSeq: 0 };
|
|
216
|
+
}
|
|
217
|
+
const senders = [];
|
|
218
|
+
for (const [subject, messages] of Object.entries(info.state.subjects ?? {})) {
|
|
219
|
+
const p = parseSubject(subject);
|
|
220
|
+
if (p?.kind === "chat" && isPrincipalOwnerToken(p.owner))
|
|
221
|
+
senders.push({ channel: p.rest, sender: p.sender, messages });
|
|
222
|
+
}
|
|
223
|
+
const cap = info.config.max_msgs_per_subject;
|
|
224
|
+
const age = info.config.max_age;
|
|
225
|
+
return {
|
|
226
|
+
perSender: typeof cap === "number" && cap > 0 ? cap : null,
|
|
227
|
+
maxAgeMs: typeof age === "number" && age > 0 ? Math.round(age / 1_000_000) : null,
|
|
228
|
+
// The stream's oldest post, of any channel; every post sent before it is gone.
|
|
229
|
+
oldestAt: info.state.messages > 0 ? info.state.first_ts : null,
|
|
230
|
+
senders: senders.sort((a, b) => a.channel.localeCompare(b.channel) || a.sender.localeCompare(b.sender)),
|
|
231
|
+
stream: true,
|
|
232
|
+
lastSeq: info.state.last_seq,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
/** Whether this space's direct-message stream is on its broker. A missing stream is false.
|
|
236
|
+
* Any other failure, including a permission denial, is raised. */
|
|
237
|
+
async dmStreamPresent() {
|
|
238
|
+
if (!this.nc)
|
|
239
|
+
throw new Error(this.notLiveMsg());
|
|
240
|
+
try {
|
|
241
|
+
await (await jetstreamManager(this.nc)).streams.info(dmStream(this.space));
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
catch (e) {
|
|
245
|
+
if (!isJetStreamMissing(e, JetStreamApiCodes.StreamNotFound))
|
|
246
|
+
throw e;
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
/** One coherent channel model for dashboards: every channel that has messages OR a registry
|
|
251
|
+
* entry (configured-but-empty), each tagged with its {@link ChannelConfig}. Works even on
|
|
252
|
+
* observer endpoints (no consumers needed). */
|
|
253
|
+
async listChannels() {
|
|
254
|
+
if (!this.nc)
|
|
255
|
+
throw new Error(this.notLiveMsg());
|
|
256
|
+
if (this.readsChannelsOnDemand)
|
|
257
|
+
await this.readChannels();
|
|
258
|
+
const mgr = await jetstreamManager(this.nc);
|
|
259
|
+
// Subjects carry the sender (chat.<sender>.<channel>), so collapse across senders: sum
|
|
260
|
+
// each channel's counts regardless of who published.
|
|
261
|
+
const counts = new Map();
|
|
262
|
+
try {
|
|
263
|
+
const info = await mgr.streams.info(chatStream(this.space), { subjects_filter: ">" });
|
|
264
|
+
if (info.state.subjects) {
|
|
265
|
+
for (const [subject, count] of Object.entries(info.state.subjects)) {
|
|
266
|
+
const p = parseSubject(subject);
|
|
267
|
+
// Same surfacing-boundary defense as the message guards: parseSubject splits only, so an
|
|
268
|
+
// old-shape alias (`chat.<nkey>.team.backend`) structurally parses with a raw-nkey owner and a
|
|
269
|
+
// misattributed channel. Reject a non-principal owner token here too, or retained pre-flip
|
|
270
|
+
// subjects would inflate this channel-count surface with phantom channels.
|
|
271
|
+
if (p?.kind === "chat" && isPrincipalOwnerToken(p.owner))
|
|
272
|
+
counts.set(p.rest, (counts.get(p.rest) ?? 0) + count);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
catch (e) {
|
|
277
|
+
// A genuinely absent CHAT stream means there are no retained message counts yet. Every other
|
|
278
|
+
// failure, especially a STREAM.INFO permission denial, means the count view could not be read
|
|
279
|
+
// and must stay loud rather than returning a valid-looking registry-only subset.
|
|
280
|
+
if (!isJetStreamMissing(e, JetStreamApiCodes.StreamNotFound))
|
|
281
|
+
throw e;
|
|
282
|
+
}
|
|
283
|
+
const channels = new Set([...counts.keys(), ...this.channelConfigs.keys()]);
|
|
284
|
+
return [...channels]
|
|
285
|
+
.map((channel) => ({
|
|
286
|
+
channel,
|
|
287
|
+
messages: counts.get(channel) ?? 0,
|
|
288
|
+
config: this.channelConfigs.get(channel),
|
|
289
|
+
}))
|
|
290
|
+
.sort((a, b) => a.channel.localeCompare(b.channel));
|
|
291
|
+
}
|
|
292
|
+
/** Lazily open the DERIVED membership FEED KV (`cotal_membership_<space>`; admin/observer read, the
|
|
293
|
+
* delivery daemon writes it) — the display-only who-is-subscribed view. Distinct from the authoritative
|
|
294
|
+
* {@link membersRegistry} (`cotal_members_<space>`, the Plane-3 durable-membership source of truth): the
|
|
295
|
+
* two names look alike, so this one is explicitly "feed". Read-only here; agents hold no grant. */
|
|
296
|
+
async membershipFeedRegistry() {
|
|
297
|
+
if (!this.nc)
|
|
298
|
+
throw new Error(this.notLiveMsg());
|
|
299
|
+
this.membershipFeedKv ??= await new Kvm(this.nc).open(membershipBucket(this.space));
|
|
300
|
+
return this.membershipFeedKv;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Snapshot the broker-sourced channel-membership feed (admin/observer read): every agent's
|
|
304
|
+
* `{live, durable}` record plus `asOf` — the feed's freshness heartbeat (epoch ms of the daemon's last
|
|
305
|
+
* successful poll, from the reserved {@link MEMBERSHIP_FEED_KEY}). `live` patterns are kept as-is
|
|
306
|
+
* (wildcards preserved); the consumer expands them against the channel registry. `asOf` is undefined
|
|
307
|
+
* when the feed has never been written (no daemon → the dashboard degrades to traffic-only).
|
|
308
|
+
*/
|
|
309
|
+
async readMembership() {
|
|
310
|
+
const kv = await this.membershipFeedRegistry();
|
|
311
|
+
const members = [];
|
|
312
|
+
let asOf;
|
|
313
|
+
// Paged batched Direct Gets, as the on-demand presence read: a few round trips regardless of N,
|
|
314
|
+
// a short page refused rather than reported as the whole feed, and no consumer bound. The scan
|
|
315
|
+
// this replaced bound an ordered consumer per read whose delete the observer and admin profiles
|
|
316
|
+
// may not send (#691), so every dashboard poll left a consumer to the broker's inactive threshold
|
|
317
|
+
// and a refused `CONSUMER.DELETE` line in its log (#4123).
|
|
318
|
+
let entries;
|
|
319
|
+
try {
|
|
320
|
+
entries = await lastKvEntries(kv);
|
|
321
|
+
}
|
|
322
|
+
catch (e) {
|
|
323
|
+
if (!isPublishPermissionDenied(e))
|
|
324
|
+
throw e;
|
|
325
|
+
throw new Error(`membership read refused for ${this.card.id}: this credential may not publish $JS.API.DIRECT.GET.KV_${membershipBucket(this.space)}, the membership feed read (SPEC Appendix B). A credential minted by an older issuer can lack this grant even when newly minted; upgrade the manager or auth service that issues credentials, then mint a new credential. Reusing credentials or reconnecting does not add the grant.`, { cause: e });
|
|
326
|
+
}
|
|
327
|
+
for (const e of entries) {
|
|
328
|
+
if (e.key === MEMBERSHIP_FEED_KEY) {
|
|
329
|
+
try {
|
|
330
|
+
asOf = e.json().observedAt;
|
|
331
|
+
}
|
|
332
|
+
catch { /* heartbeat garbled; leave undefined */ }
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
try {
|
|
336
|
+
const rec = e.json();
|
|
337
|
+
members.push({ id: e.key, live: rec.live ?? [], durable: rec.durable ?? [], observedAt: rec.observedAt });
|
|
338
|
+
}
|
|
339
|
+
catch { /* skip undecodable */ }
|
|
340
|
+
}
|
|
341
|
+
return { asOf, members };
|
|
342
|
+
}
|
|
343
|
+
/** Watch the membership feed for changes (admin/observer): `onChange` receives every KV entry as a
|
|
344
|
+
* {@link MembershipChange} — the decoded member record (or its deletion), or the feed heartbeat's
|
|
345
|
+
* `asOf` — so a caller keeps its snapshot current without re-reading the bucket; the entries replayed
|
|
346
|
+
* when the watch (re)arms carry `update: false` and end with a `replayed` change. The async stop
|
|
347
|
+
* handle disarms local delivery before resolving. It deletes the broker consumer when permitted;
|
|
348
|
+
* a known-ungranted delete leaves it to native inactivity reclamation. A feed the cred can't read
|
|
349
|
+
* (or absent) surfaces as an `error` event and the dashboard keeps its last snapshot. */
|
|
350
|
+
async watchMembership(onChange, onClosed) {
|
|
351
|
+
if (this.stopped)
|
|
352
|
+
throw new Error("endpoint stopped - cannot watch membership");
|
|
353
|
+
const watch = { onChange, onClosed, stopped: false, arm: Promise.resolve() };
|
|
354
|
+
this.membershipFeedWatches.add(watch);
|
|
355
|
+
watch.arm = watch.arm.catch(() => { }).then(() => this.armMembershipWatch(watch));
|
|
356
|
+
try {
|
|
357
|
+
await watch.arm;
|
|
358
|
+
}
|
|
359
|
+
catch (err) {
|
|
360
|
+
watch.stopped = true;
|
|
361
|
+
this.membershipFeedWatches.delete(watch);
|
|
362
|
+
await this.disarmMembershipWatch(watch);
|
|
363
|
+
throw err;
|
|
364
|
+
}
|
|
365
|
+
return { stop: async () => {
|
|
366
|
+
if (watch.stopPromise)
|
|
367
|
+
return watch.stopPromise;
|
|
368
|
+
watch.stopped = true;
|
|
369
|
+
watch.stopPromise = new Promise((resolve, reject) => {
|
|
370
|
+
watch.resolveStop = resolve;
|
|
371
|
+
watch.rejectStop = reject;
|
|
372
|
+
});
|
|
373
|
+
watch.arm = watch.arm.catch(() => { }).then(async () => {
|
|
374
|
+
await this.disarmMembershipWatch(watch);
|
|
375
|
+
await this.deleteRetainedMembershipConsumer(watch);
|
|
376
|
+
this.finishMembershipWatchStop(watch);
|
|
377
|
+
}).catch((err) => {
|
|
378
|
+
// A real authorization/server failure remains loud. A terminal close is retained rather than
|
|
379
|
+
// rejected by the cleanup helpers, so its promise stays pending for fresh-epoch cleanup.
|
|
380
|
+
watch.rejectStop?.(err);
|
|
381
|
+
});
|
|
382
|
+
return watch.stopPromise;
|
|
383
|
+
} };
|
|
384
|
+
}
|
|
385
|
+
/** Bind one caller-owned membership-watch intent to the CURRENT connection. Arming is serialized
|
|
386
|
+
* per intent, so a public watch call cannot race a reconnect rearm into two consumers. */
|
|
387
|
+
async armMembershipWatch(watch) {
|
|
388
|
+
if (watch.stopped)
|
|
389
|
+
return;
|
|
390
|
+
const kv = await this.membershipFeedRegistry();
|
|
391
|
+
await this.deleteRetainedMembershipConsumer(watch);
|
|
392
|
+
if (!(kv instanceof Bucket))
|
|
393
|
+
throw new Error("membership watch needs the @nats-io/kv Bucket implementation");
|
|
394
|
+
const cc = kv._buildCC(">", KvWatchInclude.LastValue, { headers_only: false });
|
|
395
|
+
const consumer = await kv.js.consumers.getPushConsumer(kv.stream, cc);
|
|
396
|
+
const info = await consumer.info(true);
|
|
397
|
+
this.recordOwnWatchConsumer(info);
|
|
398
|
+
// The broker resource exists now. Record its identity BEFORE consume() so a concurrent stop or
|
|
399
|
+
// connection close always leaves enough state for strict cleanup or fresh-epoch retry.
|
|
400
|
+
watch.consumer = consumer;
|
|
401
|
+
const permission = this.nc && this.watchDeletePermissions.get(this.nc);
|
|
402
|
+
if (permission)
|
|
403
|
+
this.watchDeletePermissions.set(consumer, permission);
|
|
404
|
+
watch.consumerStream = info.stream_name;
|
|
405
|
+
watch.consumerName = info.name;
|
|
406
|
+
// The replay is the bucket's last value per key, bound at `info`; it ends with the entry that
|
|
407
|
+
// leaves nothing pending (the same rule as nats.js `watch()`'s `initializedFn`).
|
|
408
|
+
let replaying = info.num_pending > 0;
|
|
409
|
+
let iter;
|
|
410
|
+
try {
|
|
411
|
+
iter = await consumer.consume({ callback: (jm) => {
|
|
412
|
+
if (watch.stopped || watch.consumer !== consumer)
|
|
413
|
+
return;
|
|
414
|
+
const entry = kv.jmToWatchEntry(jm, !replaying);
|
|
415
|
+
watch.onChange(membershipChange(entry, !replaying));
|
|
416
|
+
if (replaying && jm.info.pending === 0) {
|
|
417
|
+
replaying = false;
|
|
418
|
+
watch.onChange({ type: "replayed", revision: entry.revision });
|
|
419
|
+
}
|
|
420
|
+
} });
|
|
421
|
+
}
|
|
422
|
+
catch (err) {
|
|
423
|
+
await this.disarmMembershipWatch(watch);
|
|
424
|
+
throw err;
|
|
425
|
+
}
|
|
426
|
+
watch.iter = iter;
|
|
427
|
+
if (watch.stopped) {
|
|
428
|
+
await this.disarmMembershipWatch(watch);
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
if (!replaying)
|
|
432
|
+
watch.onChange({ type: "replayed", revision: 0 }); // an empty feed replays nothing
|
|
433
|
+
iter.closed().then(() => {
|
|
434
|
+
if (watch.stopped || watch.consumer !== consumer)
|
|
435
|
+
return;
|
|
436
|
+
const err = new Error("membership watch closed");
|
|
437
|
+
watch.onClosed?.(err);
|
|
438
|
+
this.emit("error", err);
|
|
439
|
+
}).catch(() => { });
|
|
440
|
+
}
|
|
441
|
+
/** Delete identity retained across a failed/closed-epoch consumer object using the CURRENT connection. */
|
|
442
|
+
async deleteRetainedMembershipConsumer(watch) {
|
|
443
|
+
if (!watch.consumerStream || !watch.consumerName)
|
|
444
|
+
return;
|
|
445
|
+
// A terminal close is not deletion success and not a public-stop failure. Keep the identity
|
|
446
|
+
// endpoint-owned; rearmMembershipWatches retries it through the next live JetStream manager.
|
|
447
|
+
if (!this.nc || this.nc.isClosed())
|
|
448
|
+
return;
|
|
449
|
+
if (this.watchConsumerDeleteDenied(watch.consumerStream, watch.consumerName, this.nc)) {
|
|
450
|
+
watch.consumerStream = undefined;
|
|
451
|
+
watch.consumerName = undefined;
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
const jsm = await jetstreamManager(this.nc);
|
|
455
|
+
if (await this.deleteMembershipConsumer(jsm, watch.consumerStream, watch.consumerName)) {
|
|
456
|
+
watch.consumerStream = undefined;
|
|
457
|
+
watch.consumerName = undefined;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
finishMembershipWatchStop(watch) {
|
|
461
|
+
if (!watch.stopped || watch.consumer || watch.iter || watch.consumerStream || watch.consumerName)
|
|
462
|
+
return;
|
|
463
|
+
this.membershipFeedWatches.delete(watch);
|
|
464
|
+
watch.resolveStop?.();
|
|
465
|
+
watch.resolveStop = undefined;
|
|
466
|
+
watch.rejectStop = undefined;
|
|
467
|
+
}
|
|
468
|
+
/** Stop the local iterator, then delete when permitted. A known-ungranted delete releases local
|
|
469
|
+
* cleanup custody without a request; the broker reclaims the consumer at its inactive threshold. */
|
|
470
|
+
async disarmMembershipWatch(watch) {
|
|
471
|
+
const iter = watch.iter;
|
|
472
|
+
const consumer = watch.consumer;
|
|
473
|
+
watch.iter = undefined;
|
|
474
|
+
watch.consumer = undefined;
|
|
475
|
+
try {
|
|
476
|
+
iter?.stop();
|
|
477
|
+
}
|
|
478
|
+
catch { /* already closed */ }
|
|
479
|
+
if (consumer) {
|
|
480
|
+
if (watch.consumerStream && watch.consumerName && this.watchConsumerDeleteDenied(watch.consumerStream, watch.consumerName, consumer)) {
|
|
481
|
+
watch.consumerStream = undefined;
|
|
482
|
+
watch.consumerName = undefined;
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
try {
|
|
486
|
+
const deleted = await consumer.delete();
|
|
487
|
+
if (deleted) {
|
|
488
|
+
watch.consumerStream = undefined;
|
|
489
|
+
watch.consumerName = undefined;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
catch (err) {
|
|
493
|
+
if (membershipConsumerReleased(err)) {
|
|
494
|
+
watch.consumerStream = undefined;
|
|
495
|
+
watch.consumerName = undefined;
|
|
496
|
+
}
|
|
497
|
+
else {
|
|
498
|
+
const closedEpoch = err instanceof ClosedConnectionError;
|
|
499
|
+
const timeout = err instanceof TimeoutError;
|
|
500
|
+
// Cleanup of an ordered consumer: a delete timeout means the broker did not answer in time,
|
|
501
|
+
// not that the endpoint is unusable. The broker reaps an idle/ephemeral consumer anyway.
|
|
502
|
+
// Throwing here killed a live observer over a slow VPN (#1047). Catch, surface, continue.
|
|
503
|
+
if (timeout || closedEpoch) {
|
|
504
|
+
this.emit("error", err);
|
|
505
|
+
}
|
|
506
|
+
else {
|
|
507
|
+
throw err;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
// A terminal close leaves stream/name intact. The endpoint-owned stopped intent is retried
|
|
511
|
+
// through the fresh JetStream manager before its public stop promise may resolve.
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
/** Rebind every live membership-watch intent after a connection rebuild. */
|
|
516
|
+
async rearmMembershipWatches() {
|
|
517
|
+
await Promise.all([...this.membershipFeedWatches].map(async (watch) => {
|
|
518
|
+
// clearConnectionScoped already resets a rejected prior arm before scheduling disarm. At this
|
|
519
|
+
// point the queue is the completing cleanup promise; append fresh-epoch cleanup first.
|
|
520
|
+
watch.arm = watch.arm.catch(() => { }).then(async () => {
|
|
521
|
+
await this.disarmMembershipWatch(watch);
|
|
522
|
+
await this.deleteRetainedMembershipConsumer(watch);
|
|
523
|
+
if (!watch.stopped)
|
|
524
|
+
await this.armMembershipWatch(watch);
|
|
525
|
+
});
|
|
526
|
+
try {
|
|
527
|
+
await watch.arm;
|
|
528
|
+
this.finishMembershipWatchStop(watch);
|
|
529
|
+
}
|
|
530
|
+
catch (err) {
|
|
531
|
+
this.emit("error", err);
|
|
532
|
+
}
|
|
533
|
+
}));
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
/** A membership-watch delete that leaves nothing to retry: the consumer or its stream is already
|
|
537
|
+
* gone, or the broker refused the delete because the reading profile holds no stream-wide
|
|
538
|
+
* CONSUMER.DELETE (#691) and reaps the consumer at its inactive threshold. */
|
|
539
|
+
export function membershipConsumerReleased(err) {
|
|
540
|
+
return (isJetStreamMissing(err, JetStreamApiCodes.ConsumerNotFound, JetStreamApiCodes.StreamNotFound)
|
|
541
|
+
|| isPublishPermissionDenied(err));
|
|
542
|
+
}
|
|
543
|
+
//# sourceMappingURL=endpoint-subscriptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint-subscriptions.js","sourceRoot":"","sources":["../src/endpoint-subscriptions.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,mGAAmG;AACnG,qEAAqE;AACrE,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAuB,MAAM,yBAAyB,CAAC;AACnG,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAA2E,MAAM,oBAAoB,CAAC;AAClJ,OAAO,EAAE,GAAG,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