@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.
Files changed (97) hide show
  1. package/dist/agent-endpoint.d.ts +146 -5
  2. package/dist/agent-endpoint.d.ts.map +1 -1
  3. package/dist/agent-endpoint.js +69 -12
  4. package/dist/agent-endpoint.js.map +1 -1
  5. package/dist/agent-file.d.ts +9 -5
  6. package/dist/agent-file.d.ts.map +1 -1
  7. package/dist/agent-file.js +18 -8
  8. package/dist/agent-file.js.map +1 -1
  9. package/dist/anycast-requests.d.ts +8 -1
  10. package/dist/anycast-requests.d.ts.map +1 -1
  11. package/dist/anycast-requests.js +47 -0
  12. package/dist/anycast-requests.js.map +1 -1
  13. package/dist/backup-config.d.ts +5 -2
  14. package/dist/backup-config.d.ts.map +1 -1
  15. package/dist/backup-config.js +7 -2
  16. package/dist/backup-config.js.map +1 -1
  17. package/dist/backup.d.ts +6 -0
  18. package/dist/backup.d.ts.map +1 -1
  19. package/dist/backup.js +11 -4
  20. package/dist/backup.js.map +1 -1
  21. package/dist/connector-setup.d.ts +2 -0
  22. package/dist/connector-setup.d.ts.map +1 -1
  23. package/dist/endpoint-action.d.ts +2 -2
  24. package/dist/endpoint-action.js +6 -7
  25. package/dist/endpoint-action.js.map +1 -1
  26. package/dist/endpoint-binding.d.ts.map +1 -1
  27. package/dist/endpoint-binding.js +2 -0
  28. package/dist/endpoint-binding.js.map +1 -1
  29. package/dist/endpoint-boot-memberships.d.ts +71 -0
  30. package/dist/endpoint-boot-memberships.d.ts.map +1 -0
  31. package/dist/endpoint-boot-memberships.js +119 -0
  32. package/dist/endpoint-boot-memberships.js.map +1 -0
  33. package/dist/endpoint-channel-discovery.d.ts +102 -0
  34. package/dist/endpoint-channel-discovery.d.ts.map +1 -0
  35. package/dist/endpoint-channel-discovery.js +170 -0
  36. package/dist/endpoint-channel-discovery.js.map +1 -0
  37. package/dist/endpoint-control-plane.d.ts +204 -0
  38. package/dist/endpoint-control-plane.d.ts.map +1 -0
  39. package/dist/endpoint-control-plane.js +627 -0
  40. package/dist/endpoint-control-plane.js.map +1 -0
  41. package/dist/endpoint-durable-backstop.d.ts +249 -0
  42. package/dist/endpoint-durable-backstop.d.ts.map +1 -0
  43. package/dist/endpoint-durable-backstop.js +485 -0
  44. package/dist/endpoint-durable-backstop.js.map +1 -0
  45. package/dist/endpoint-journal.d.ts.map +1 -1
  46. package/dist/endpoint-journal.js +14 -6
  47. package/dist/endpoint-journal.js.map +1 -1
  48. package/dist/endpoint-liveness.d.ts +105 -0
  49. package/dist/endpoint-liveness.d.ts.map +1 -0
  50. package/dist/endpoint-liveness.js +223 -0
  51. package/dist/endpoint-liveness.js.map +1 -0
  52. package/dist/endpoint-messaging.d.ts +229 -0
  53. package/dist/endpoint-messaging.d.ts.map +1 -0
  54. package/dist/endpoint-messaging.js +420 -0
  55. package/dist/endpoint-messaging.js.map +1 -0
  56. package/dist/endpoint-presence.d.ts +15 -0
  57. package/dist/endpoint-presence.d.ts.map +1 -1
  58. package/dist/endpoint-presence.js +35 -0
  59. package/dist/endpoint-presence.js.map +1 -1
  60. package/dist/endpoint-provisioning.d.ts +73 -0
  61. package/dist/endpoint-provisioning.d.ts.map +1 -0
  62. package/dist/endpoint-provisioning.js +122 -0
  63. package/dist/endpoint-provisioning.js.map +1 -0
  64. package/dist/endpoint-subscriptions.d.ts +199 -0
  65. package/dist/endpoint-subscriptions.d.ts.map +1 -0
  66. package/dist/endpoint-subscriptions.js +543 -0
  67. package/dist/endpoint-subscriptions.js.map +1 -0
  68. package/dist/endpoint.d.ts +42 -124
  69. package/dist/endpoint.d.ts.map +1 -1
  70. package/dist/endpoint.js +299 -1903
  71. package/dist/endpoint.js.map +1 -1
  72. package/dist/index.d.ts +1 -0
  73. package/dist/index.d.ts.map +1 -1
  74. package/dist/index.js +1 -0
  75. package/dist/index.js.map +1 -1
  76. package/dist/provision-jwt.d.ts.map +1 -1
  77. package/dist/provision-jwt.js +1 -0
  78. package/dist/provision-jwt.js.map +1 -1
  79. package/dist/provision-permission-builders.d.ts +356 -0
  80. package/dist/provision-permission-builders.d.ts.map +1 -0
  81. package/dist/provision-permission-builders.js +1383 -0
  82. package/dist/provision-permission-builders.js.map +1 -0
  83. package/dist/provision-permissions.d.ts +3 -48
  84. package/dist/provision-permissions.d.ts.map +1 -1
  85. package/dist/provision-permissions.js +12 -1378
  86. package/dist/provision-permissions.js.map +1 -1
  87. package/dist/run-host.d.ts +4 -1
  88. package/dist/run-host.d.ts.map +1 -1
  89. package/dist/run-record.d.ts +4 -0
  90. package/dist/run-record.d.ts.map +1 -1
  91. package/dist/run-record.js +36 -0
  92. package/dist/run-record.js.map +1 -1
  93. package/dist/space-quiescence-resources.d.ts +30 -0
  94. package/dist/space-quiescence-resources.d.ts.map +1 -0
  95. package/dist/space-quiescence-resources.js +45 -0
  96. package/dist/space-quiescence-resources.js.map +1 -0
  97. package/package.json +1 -1
@@ -0,0 +1,119 @@
1
+ // The boot durable memberships of CotalEndpoint, as an internal component. Moved verbatim from
2
+ // endpoint.ts; the endpoint keeps the public methods and forwards to them. Not re-exported by the index.
3
+ import { isChannelFamily, isConcreteChannel } from "./subjects.js";
4
+ /** One endpoint's boot durable memberships: the first-connect self-join of its durable boot channels,
5
+ * the capped-backoff reconcile that restores one after a daemon outage, and the membership read and
6
+ * check the leave path and the delivery-health surface use. Internal: `CotalEndpoint` keeps the
7
+ * public methods and forwards to it. */
8
+ export class EndpointBootMemberships {
9
+ deps;
10
+ constructor(deps) {
11
+ this.deps = deps;
12
+ }
13
+ get channels() { return this.deps.channels(); }
14
+ get plane3Channels() { return this.deps.plane3Channels(); }
15
+ get pendingBootJoins() { return this.deps.pendingBootJoins(); }
16
+ get stopped() { return this.deps.stopped(); }
17
+ requestDelivery(op, args, timeoutMs) { return this.deps.requestDelivery(op, args, timeoutMs); }
18
+ requireLifecycleUid(what) { return this.deps.requireLifecycleUid(what); }
19
+ deliveryClassFresh(channel) { return this.deps.deliveryClassFresh(channel); }
20
+ durableJoinChannel(channel) { return this.deps.durableJoinChannel(channel); }
21
+ membershipPause(attempt) { return this.deps.membershipPause(attempt); }
22
+ isNoResponders(e) { return this.deps.isNoResponders(e); }
23
+ emitRecoverable(err) { this.deps.emitRecoverable(err); }
24
+ /** Agent-side: current lifecycle memberships, or all principal-owned rows for an explicit channel,
25
+ * from the delivery service. The agent holds no read on the privileged members KV. `undefined` ⇒ NO control responder
26
+ * (open / no delivery daemon, so there is no Plane-3 and no memberships). THROWS on a responder-present RPC
27
+ * failure, so a caller can FAIL-CLOSED rather than mistaking a transient error for "no membership". */
28
+ async fetchMemberships(channel) {
29
+ let reply;
30
+ try {
31
+ reply = await this.requestDelivery("listMemberships", { lifecycleUid: this.requireLifecycleUid("listing durable memberships"), ...(channel === undefined ? {} : { channel }) }, 5_000);
32
+ }
33
+ catch (e) {
34
+ if (this.isNoResponders(e))
35
+ return undefined; // no delivery daemon — open / daemon-less, no Plane-3
36
+ throw e; // responder present but errored — surface it (leaveChannel fails closed)
37
+ }
38
+ if (!reply.ok)
39
+ throw new Error(reply.error ?? "listMemberships failed");
40
+ return reply.data?.memberships ?? [];
41
+ }
42
+ /** Agent-side, first connect (auth): SELF-JOIN this session's durable boot channels via the
43
+ * server-side delivery daemon — replacing the old manager-written boot membership. Each concrete
44
+ * `durable`-class boot channel, and each family such as `review.>`, gets a `durableJoin` whose
45
+ * returned generation seeds the leave mirror
46
+ * + durable-state surface; an already-active membership (a relaunch) is idempotent (no re-catch-up).
47
+ * If the daemon is down/absent at first connect (or reports a transient `durable:false`), the channel
48
+ * is handed to {@link reconcileBootJoin} for capped-backoff retry — so the backstop is RESTORED once
49
+ * the daemon recovers, not left silently live-only. Until a membership exists the channel renders
50
+ * degraded in `cotal_channels` ({@link hasDurableMembership}). */
51
+ async armBootDurableMemberships() {
52
+ for (const channel of this.channels) {
53
+ if (this.plane3Channels.has(channel))
54
+ continue;
55
+ // A family (`review.>`) asks for its row whatever the default class: each channel under it decides
56
+ // its own at fan-out (#5404). Any other pattern has no durable membership.
57
+ if (!isChannelFamily(channel)) {
58
+ if (!isConcreteChannel(channel))
59
+ continue;
60
+ // A missing channel row legitimately resolves through the defaults. A failed/denied registry
61
+ // read does not prove the channel is live-only, so let it fail startup loudly.
62
+ const cls = await this.deliveryClassFresh(channel);
63
+ if (cls !== "durable")
64
+ continue;
65
+ }
66
+ try {
67
+ const r = await this.durableJoinChannel(channel);
68
+ if (r.durable)
69
+ this.plane3Channels.set(channel, r.generation ?? 0);
70
+ else
71
+ void this.reconcileBootJoin(channel); // present but not yet durable — reconcile to recovery
72
+ }
73
+ catch (e) {
74
+ if (!this.isNoResponders(e))
75
+ this.emitRecoverable(e); // no daemon ⇒ retry until it recovers
76
+ void this.reconcileBootJoin(channel);
77
+ }
78
+ }
79
+ }
80
+ /** Retry a boot durable self-join with capped backoff until a membership EXISTS (success → seed
81
+ * `plane3Channels`) or the channel is left / the endpoint stops. Mirrors {@link closeRefusedMembership}:
82
+ * a one-shot first-connect attempt that swallowed a daemon outage would leave the boot channel live-only
83
+ * forever after the daemon recovers (and the lease-based health could then read "active" with no owner
84
+ * membership). This loop is the reconcile that closes that gap. Idempotent — a channel already pending
85
+ * is not double-driven; survives reconnect (it re-issues `durableJoinChannel` on the current connection). */
86
+ async reconcileBootJoin(channel) {
87
+ if (this.pendingBootJoins.has(channel))
88
+ return; // already reconciling
89
+ this.pendingBootJoins.add(channel);
90
+ for (let attempt = 0;; attempt++) {
91
+ await this.membershipPause(attempt);
92
+ if (this.stopped || !this.channels.includes(channel) || this.plane3Channels.has(channel)) {
93
+ this.pendingBootJoins.delete(channel);
94
+ return; // stopped, left, or another path established it
95
+ }
96
+ try {
97
+ const r = await this.durableJoinChannel(channel);
98
+ if (r.durable) {
99
+ this.plane3Channels.set(channel, r.generation ?? 0);
100
+ this.pendingBootJoins.delete(channel);
101
+ return;
102
+ }
103
+ // present but durable:false (e.g. catch-up window evicted) — keep retrying; the channel stays
104
+ // honestly degraded meanwhile, never silently "active".
105
+ }
106
+ catch (e) {
107
+ if (attempt === 0 && !this.isNoResponders(e))
108
+ this.emitRecoverable(new Error(`channel "${channel}": boot durable self-join not yet established - retrying until the delivery daemon is reachable (${e.message})`));
109
+ }
110
+ }
111
+ }
112
+ /** True if this session holds an established Plane-3 durable membership for `channel` (in `plane3Channels`).
113
+ * Drives the membership-aware delivery-health surface: a joined durable channel that is NOT yet a member
114
+ * (boot self-join pending / daemon down) must render degraded, never "active" off a live lease alone. */
115
+ hasDurableMembership(channel) {
116
+ return this.plane3Channels.has(channel);
117
+ }
118
+ }
119
+ //# sourceMappingURL=endpoint-boot-memberships.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint-boot-memberships.js","sourceRoot":"","sources":["../src/endpoint-boot-memberships.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,yGAAyG;AACzG,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAmBnE;;;yCAGyC;AACzC,MAAM,OAAO,uBAAuB;IACL;IAA7B,YAA6B,IAAiC;QAAjC,SAAI,GAAJ,IAAI,CAA6B;IAAG,CAAC;IAElE,IAAY,QAAQ,KAAK,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IACvD,IAAY,cAAc,KAAK,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;IACnE,IAAY,gBAAgB,KAAK,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;IACvE,IAAY,OAAO,KAAK,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAC7C,eAAe,CAAC,EAAU,EAAE,IAA6B,EAAE,SAAkB,IAAI,OAAO,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IAC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,CAAC;IAC1C,CAAC;CACF"}
@@ -0,0 +1,102 @@
1
+ import type { NatsConnection } from "@nats-io/transport-node";
2
+ import { type ConsumerInfo } from "@nats-io/jetstream";
3
+ import type { KV } from "@nats-io/kv";
4
+ import type { AgentCard, ChannelConfig, ChannelDefaults, DeliveryClass } from "./types.js";
5
+ /** What the channel discovery component reads from its endpoint. State is read when it is used,
6
+ * never copied, and every method is looked up on the endpoint at call time. */
7
+ export interface EndpointChannelDiscoveryDeps {
8
+ nc: () => NatsConnection | undefined;
9
+ space: () => string;
10
+ card: () => AgentCard;
11
+ doConsume: () => boolean;
12
+ doWatch: () => boolean;
13
+ doWatchChannels: () => boolean;
14
+ channelKv: () => KV | undefined;
15
+ setChannelWatchIter: (iter: Awaited<ReturnType<KV["watch"]>>) => void;
16
+ channelConfigs: () => Map<string, ChannelConfig>;
17
+ channelDefaults: () => ChannelDefaults;
18
+ setChannelDefaults: (defaults: ChannelDefaults) => void;
19
+ channelRead: () => Promise<void> | undefined;
20
+ setChannelRead: (read: Promise<void> | undefined) => void;
21
+ channelReadGeneration: () => number;
22
+ setChannelReadGeneration: (n: number) => void;
23
+ channelReadApplied: () => number;
24
+ setChannelReadApplied: (n: number) => void;
25
+ notLiveMsg: () => string;
26
+ bindKvWatch: (kv: KV) => Promise<{
27
+ iter: Awaited<ReturnType<KV["watch"]>>;
28
+ info: ConsumerInfo;
29
+ } | undefined>;
30
+ emitRecoverable: (err: Error) => void;
31
+ emit: (event: string, ...args: unknown[]) => boolean;
32
+ }
33
+ /** One endpoint's view of the channel registry: the on-demand read, the cache lookups and the
34
+ * replay and delivery-class policy they answer, and the registry watch or one-shot read that keeps
35
+ * the cache. Internal: `CotalEndpoint` keeps the public methods and forwards to it. */
36
+ export declare class EndpointChannelDiscovery {
37
+ private readonly deps;
38
+ constructor(deps: EndpointChannelDiscoveryDeps);
39
+ private get nc();
40
+ private get space();
41
+ private get card();
42
+ private get doConsume();
43
+ private get doWatch();
44
+ private get doWatchChannels();
45
+ private get channelKv();
46
+ private set channelWatchIter(value);
47
+ private get channelConfigs();
48
+ private get channelDefaults();
49
+ private set channelDefaults(value);
50
+ private get channelRead();
51
+ private set channelRead(value);
52
+ private get channelReadGeneration();
53
+ private set channelReadGeneration(value);
54
+ private get channelReadApplied();
55
+ private set channelReadApplied(value);
56
+ private notLiveMsg;
57
+ private bindKvWatch;
58
+ private emitRecoverable;
59
+ private emit;
60
+ /** A consumer that reads presence on demand reads the channel registry on demand too: it holds no
61
+ * watch on either, so a seat binds no consumer per member on these buckets (SPEC §6, §7). */
62
+ get readsChannelsOnDemand(): boolean;
63
+ /**
64
+ * Read the channel registry from the broker now, for a consumer that reads presence on demand. One
65
+ * batched Direct Get that binds no consumer, decoded as the watch decodes; the result replaces the
66
+ * cache, so an entry removed since the last read is gone. {@link listChannels} and a join or leave
67
+ * read through here first; other cache readers see the last read.
68
+ *
69
+ * Calls made while a read is in flight share it, and every other call reads anew. A failed read
70
+ * throws and changes nothing. A credential that may not make the read is refused with the grant it lacks.
71
+ */
72
+ readChannels(): Promise<void>;
73
+ /** This channel's registry config from the local cache (undefined if unset). */
74
+ getChannelConfig(channel: string): ChannelConfig | undefined;
75
+ /** Effective replay-on-join policy for a channel: per-channel override ?? space default ??
76
+ * true. Reads the live cache, so it reflects runtime registry edits. */
77
+ channelReplay(channel: string): boolean;
78
+ /** Effective replay window for a channel (per-channel override ?? space default), or undefined
79
+ * for the full retained window. Only meaningful when {@link channelReplay} is true. */
80
+ channelReplayWindow(channel: string): string | undefined;
81
+ /** A channel's effective replay policy read straight from the registry bucket, for a caller that
82
+ * reads it right after start, before any watch cache has caught up, or that watches nothing. A
83
+ * wildcard reads the space defaults only. A space with no registry bucket has the built-in policy.
84
+ * `registered` says whether the channel has its own registry entry. */
85
+ channelReplayPolicy(channel: string): Promise<{
86
+ replay: boolean;
87
+ window: string | null;
88
+ registered: boolean;
89
+ }>;
90
+ /** Effective delivery class for a channel (per-channel override ?? space default ?? "durable"),
91
+ * from the live watch cache — drives the non-gating delivery-health surface (only durable-class
92
+ * channels have a Plane-3 backstop to report on). */
93
+ channelDeliveryClass(channel: string): DeliveryClass;
94
+ /** Watch the channel registry: replay existing keys, then stream updates, into the local
95
+ * cache. A failed bind throws out of connect; an entry that does not decode or validate is
96
+ * reported as a `warning` and dropped, so its channel resolves to the default policy. */
97
+ startChannelWatch(): Promise<void>;
98
+ /** {@link EndpointOptions.readOnce}: fill the channel cache from one read of the registry. */
99
+ readChannelsOnce(): Promise<void>;
100
+ private handleChannelEntry;
101
+ }
102
+ //# sourceMappingURL=endpoint-channel-discovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint-channel-discovery.d.ts","sourceRoot":"","sources":["../src/endpoint-channel-discovery.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,KAAK,EAAE,EAAE,EAAW,MAAM,aAAa,CAAC;AAa/C,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3F;gFACgF;AAChF,MAAM,WAAW,4BAA4B;IAC3C,EAAE,EAAE,MAAM,cAAc,GAAG,SAAS,CAAC;IACrC,KAAK,EAAE,MAAM,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,SAAS,CAAC;IACtB,SAAS,EAAE,MAAM,OAAO,CAAC;IACzB,OAAO,EAAE,MAAM,OAAO,CAAC;IACvB,eAAe,EAAE,MAAM,OAAO,CAAC;IAC/B,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAChC,mBAAmB,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IACtE,cAAc,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,aA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veReplay, effectiveDeliveryClass, readChannelConfig, readChannelDefaults, decodeChannelEntry, } from "./channels.js";
3
+ import { isPublishPermissionDenied } from "./endpoint.js";
4
+ import { isJetStreamMissing } from "./jetstream-missing.js";
5
+ import { lastKvEntries } from "./kv-scan.js";
6
+ import { CHANNEL_DEFAULTS_KEY, channelBucket, isConcreteChannel } from "./subjects.js";
7
+ /** One endpoint's view of the channel registry: the on-demand read, the cache lookups and the
8
+ * replay and delivery-class policy they answer, and the registry watch or one-shot read that keeps
9
+ * the cache. Internal: `CotalEndpoint` keeps the public methods and forwards to it. */
10
+ export class EndpointChannelDiscovery {
11
+ deps;
12
+ constructor(deps) {
13
+ this.deps = deps;
14
+ }
15
+ get nc() { return this.deps.nc(); }
16
+ get space() { return this.deps.space(); }
17
+ get card() { return this.deps.card(); }
18
+ get doConsume() { return this.deps.doConsume(); }
19
+ get doWatch() { return this.deps.doWatch(); }
20
+ get doWatchChannels() { return this.deps.doWatchChannels(); }
21
+ get channelKv() { return this.deps.channelKv(); }
22
+ set channelWatchIter(iter) { this.deps.setChannelWatchIter(iter); }
23
+ get channelConfigs() { return this.deps.channelConfigs(); }
24
+ get channelDefaults() { return this.deps.channelDefaults(); }
25
+ set channelDefaults(defaults) { this.deps.setChannelDefaults(defaults); }
26
+ get channelRead() { return this.deps.channelRead(); }
27
+ set channelRead(read) { this.deps.setChannelRead(read); }
28
+ get channelReadGeneration() { return this.deps.channelReadGeneration(); }
29
+ set channelReadGeneration(n) { this.deps.setChannelReadGeneration(n); }
30
+ get channelReadApplied() { return this.deps.channelReadApplied(); }
31
+ set channelReadApplied(n) { this.deps.setChannelReadApplied(n); }
32
+ notLiveMsg() { return this.deps.notLiveMsg(); }
33
+ bindKvWatch(kv) { return this.deps.bindKvWatch(kv); }
34
+ emitRecoverable(err) { this.deps.emitRecoverable(err); }
35
+ emit(event, ...args) { return this.deps.emit(event, ...args); }
36
+ /** A consumer that reads presence on demand reads the channel registry on demand too: it holds no
37
+ * watch on either, so a seat binds no consumer per member on these buckets (SPEC §6, §7). */
38
+ get readsChannelsOnDemand() {
39
+ return this.doConsume && this.doWatchChannels && !this.doWatch;
40
+ }
41
+ /**
42
+ * Read the channel registry from the broker now, for a consumer that reads presence on demand. One
43
+ * batched Direct Get that binds no consumer, decoded as the watch decodes; the result replaces the
44
+ * cache, so an entry removed since the last read is gone. {@link listChannels} and a join or leave
45
+ * read through here first; other cache readers see the last read.
46
+ *
47
+ * Calls made while a read is in flight share it, and every other call reads anew. A failed read
48
+ * throws and changes nothing. A credential that may not make the read is refused with the grant it lacks.
49
+ */
50
+ async readChannels() {
51
+ if (!this.readsChannelsOnDemand)
52
+ throw new Error("readChannels is for a consumer that reads presence on demand; this endpoint watches the channel registry or keeps no cache of it");
53
+ const kv = this.channelKv;
54
+ if (!kv)
55
+ throw new Error(this.notLiveMsg());
56
+ if (this.channelRead)
57
+ return this.channelRead;
58
+ const generation = ++this.channelReadGeneration;
59
+ const read = (async () => {
60
+ let entries;
61
+ try {
62
+ entries = await lastKvEntries(kv);
63
+ }
64
+ catch (e) {
65
+ if (!isPublishPermissionDenied(e))
66
+ throw e;
67
+ throw new Error(`channel registry read refused for ${this.card.id}: this credential may not publish $JS.API.DIRECT.GET.KV_${channelBucket(this.space)}, the on-demand registry 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 });
68
+ }
69
+ if (generation <= this.channelReadApplied)
70
+ return;
71
+ this.channelReadApplied = generation;
72
+ this.channelConfigs.clear();
73
+ this.channelDefaults = {};
74
+ for (const e of entries)
75
+ this.handleChannelEntry(e);
76
+ })();
77
+ this.channelRead = read;
78
+ const settled = () => { if (this.channelRead === read)
79
+ this.channelRead = undefined; };
80
+ read.then(settled, settled);
81
+ return read;
82
+ }
83
+ /** This channel's registry config from the local cache (undefined if unset). */
84
+ getChannelConfig(channel) {
85
+ return this.channelConfigs.get(channel);
86
+ }
87
+ /** Effective replay-on-join policy for a channel: per-channel override ?? space default ??
88
+ * true. Reads the live cache, so it reflects runtime registry edits. */
89
+ channelReplay(channel) {
90
+ return effectiveReplay(this.channelConfigs.get(channel), this.channelDefaults);
91
+ }
92
+ /** Effective replay window for a channel (per-channel override ?? space default), or undefined
93
+ * for the full retained window. Only meaningful when {@link channelReplay} is true. */
94
+ channelReplayWindow(channel) {
95
+ return this.channelConfigs.get(channel)?.replayWindow ?? this.channelDefaults.replayWindow;
96
+ }
97
+ /** A channel's effective replay policy read straight from the registry bucket, for a caller that
98
+ * reads it right after start, before any watch cache has caught up, or that watches nothing. A
99
+ * wildcard reads the space defaults only. A space with no registry bucket has the built-in policy.
100
+ * `registered` says whether the channel has its own registry entry. */
101
+ async channelReplayPolicy(channel) {
102
+ if (!this.nc)
103
+ throw new Error(this.notLiveMsg());
104
+ const kv = this.channelKv ?? (await openChannelRegistry(this.nc, this.space, { create: false }));
105
+ let cfg;
106
+ let defaults;
107
+ try {
108
+ [cfg, defaults] = await Promise.all([
109
+ isConcreteChannel(channel) ? readChannelConfig(kv, channel) : Promise.resolve(undefined),
110
+ readChannelDefaults(kv),
111
+ ]);
112
+ }
113
+ catch (e) {
114
+ // `open` binds lazily, so a space with no registry bucket surfaces on the first read.
115
+ if (!isJetStreamMissing(e, JetStreamApiCodes.StreamNotFound))
116
+ throw e;
117
+ }
118
+ return { replay: effectiveReplay(cfg, defaults), window: cfg?.replayWindow ?? defaults?.replayWindow ?? null, registered: cfg !== undefined };
119
+ }
120
+ /** Effective delivery class for a channel (per-channel override ?? space default ?? "durable"),
121
+ * from the live watch cache — drives the non-gating delivery-health surface (only durable-class
122
+ * channels have a Plane-3 backstop to report on). */
123
+ channelDeliveryClass(channel) {
124
+ return effectiveDeliveryClass(this.channelConfigs.get(channel), this.channelDefaults);
125
+ }
126
+ /** Watch the channel registry: replay existing keys, then stream updates, into the local
127
+ * cache. A failed bind throws out of connect; an entry that does not decode or validate is
128
+ * reported as a `warning` and dropped, so its channel resolves to the default policy. */
129
+ async startChannelWatch() {
130
+ if (!this.channelKv)
131
+ return;
132
+ const bound = await this.bindKvWatch(this.channelKv);
133
+ if (!bound)
134
+ return;
135
+ const { iter } = bound;
136
+ this.channelWatchIter = iter;
137
+ void (async () => {
138
+ for await (const e of iter)
139
+ this.handleChannelEntry(e);
140
+ })().catch((e) => this.emit("error", e));
141
+ }
142
+ /** {@link EndpointOptions.readOnce}: fill the channel cache from one read of the registry. */
143
+ async readChannelsOnce() {
144
+ if (!this.channelKv)
145
+ return;
146
+ for (const e of await lastKvEntries(this.channelKv))
147
+ this.handleChannelEntry(e);
148
+ }
149
+ handleChannelEntry(e) {
150
+ // Cleared before the decode, so an entry that does not decode resolves to the default as the
151
+ // fresh registry reads do.
152
+ const isDefaults = e.key === CHANNEL_DEFAULTS_KEY;
153
+ if (isDefaults)
154
+ this.channelDefaults = {};
155
+ else
156
+ this.channelConfigs.delete(e.key);
157
+ if (e.operation === "DEL" || e.operation === "PURGE")
158
+ return;
159
+ try {
160
+ if (isDefaults)
161
+ this.channelDefaults = decodeChannelEntry(e);
162
+ else
163
+ this.channelConfigs.set(e.key, decodeChannelEntry(e));
164
+ }
165
+ catch (err) {
166
+ this.emitRecoverable(new Error(`dropped channel registry entry for key ${JSON.stringify(e.key)}: ${err.message}`));
167
+ }
168
+ }
169
+ }
170
+ //# sourceMappingURL=endpoint-channel-discovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint-channel-discovery.js","sourceRoot":"","sources":["../src/endpoint-channel-discovery.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAqB,MAAM,oBAAoB,CAAC;AAE1E,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MA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,CAAC,IAAI,CAAC,SAAS,CAAC;YAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAClF,CAAC;IAEO,kBAAkB,CAAC,CAAU;QACnC,6FAA6F;QAC7F,2BAA2B;QAC3B,MAAM,UAAU,GAAG,CAAC,CAAC,GAAG,KAAK,oBAAoB,CAAC;QAClD,IAAI,UAAU;YAAE,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;;YACrC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACvC,IAAI,CAAC,CAAC,SAAS,KAAK,KAAK,IAAI,CAAC,CAAC,SAAS,KAAK,OAAO;YAAE,OAAO;QAC7D,IAAI,CAAC;YACH,IAAI,UAAU;gBAAE,IAAI,CAAC,eAAe,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC;;gBACxD,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7D,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,eAAe,CAAC,IAAI,KAAK,CAAC,0CAA0C,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,KAAM,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAChI,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,204 @@
1
+ import { type Msg, type NatsConnection, type Subscription } from "@nats-io/transport-node";
2
+ import { type ResolvedService, type SubmitAndFollowGoalOptions } from "./endpoint-invoke.js";
3
+ import type { EpCaller, IssuedCaller } from "./endpoint-subjects.js";
4
+ import { type RegistryEndpointsInput, type RegistryEndpointsOutput } from "./registry-contract.js";
5
+ import type { EpVerbTarget, EpAttributedReply } from "./endpoint-verbs.js";
6
+ import type { ControlReply, ControlRequest, ControlRequestInit, EndpointRef } from "./types.js";
7
+ /** One goal follower {@link EndpointControlPlane.followServiceGoal} registers with its endpoint. */
8
+ type GoalFollower = {
9
+ cancel: () => void;
10
+ reconnected: (nc: NatsConnection) => void;
11
+ };
12
+ /** What the control plane reads from its endpoint. State is read when it is used, never copied, and
13
+ * every method is looked up on the endpoint at call time. */
14
+ export interface EndpointControlPlaneDeps {
15
+ nc: () => NatsConnection | undefined;
16
+ space: () => string;
17
+ owner: () => string;
18
+ actor: () => string;
19
+ stopped: () => boolean;
20
+ authed: () => boolean;
21
+ connId: () => string;
22
+ presentedExp: () => number | undefined;
23
+ issuedGeneration: () => string | undefined;
24
+ acceptedToken: () => string | undefined;
25
+ rebuildPromise: () => Promise<void> | undefined;
26
+ subs: () => Subscription[];
27
+ resolvedServices: () => Map<string, ResolvedService>;
28
+ resolvedCommandServices: () => Map<string, Map<string, ResolvedService>>;
29
+ serviceInvocations: () => WeakMap<NatsConnection, Set<Promise<void>>>;
30
+ requestsAwaitingReply: () => Map<NatsConnection, Set<(error: Error) => void>>;
31
+ activeGoalFollowers: () => Set<GoalFollower>;
32
+ splitsRecovered: () => number;
33
+ setSplitsRecovered: (count: number) => void;
34
+ notLiveMsg: () => string;
35
+ requireLifecycleUid: (what: string) => string;
36
+ reportSubscriptionDenial: (error: unknown) => boolean;
37
+ ref: () => EndpointRef;
38
+ reconnect: () => Promise<void>;
39
+ emit: (event: string, ...args: unknown[]) => boolean;
40
+ }
41
+ /** The request/reply control plane of one endpoint (serve, answer and request control, with the
42
+ * bound reply every request rides) and its service-invocation client (describe, list, invoke,
43
+ * and follow a goal). Internal: `CotalEndpoint` keeps the public methods and forwards to it. */
44
+ export declare class EndpointControlPlane {
45
+ private readonly deps;
46
+ constructor(deps: EndpointControlPlaneDeps);
47
+ private get nc();
48
+ private get space();
49
+ private get owner();
50
+ private get actor();
51
+ private get stopped();
52
+ private get authed();
53
+ private get connId();
54
+ private get presentedExp();
55
+ private get issuedGeneration();
56
+ private get acceptedToken();
57
+ private get rebuildPromise();
58
+ private get subs();
59
+ private get resolvedServices();
60
+ private get resolvedCommandServices();
61
+ private get serviceInvocations();
62
+ private get requestsAwaitingReply();
63
+ private get activeGoalFollowers();
64
+ private get splitsRecovered();
65
+ private set splitsRecovered(value);
66
+ private notLiveMsg;
67
+ private requireLifecycleUid;
68
+ private reportSubscriptionDenial;
69
+ private ref;
70
+ private reconnect;
71
+ private emit;
72
+ /** Serve control requests for a service. Returns the subscription so a caller that re-registers on
73
+ * reconnect (the delivery daemon) can drop the stale one. `boundReply` is REQUIRED for any service
74
+ * whose responder holds a wildcard publish grant over the service subtree (the delivery daemon's
75
+ * `ctl.delivery.*.*.reply.>`): without it, an authenticated caller could set its reply target to a
76
+ * PEER's reply lane (`ctl.delivery.<victim>.reply.<n>`) and turn the responder into a confused
77
+ * deputy — the broker does NOT permission-check the requester's embedded reply subject. With it, a
78
+ * reply is published only when `m.reply` is under the AUTHENTICATED request subject
79
+ * (`${m.subject}.reply.…`), binding the reply to the broker-policed sender token.
80
+ *
81
+ * Requests are answered one at a time, in arrival order. A request `concurrent` accepts is answered
82
+ * in its own time instead: it waits for none of the requests in front of it, including one still
83
+ * running, and holds up none behind it. Only for a request that shares no state with the service's
84
+ * other requests. */
85
+ serveControl(service: string, handler: (req: ControlRequest) => Promise<ControlReply> | ControlReply, opts?: {
86
+ boundReply?: boolean;
87
+ concurrent?: (req: ControlRequest) => boolean;
88
+ }): import("@nats-io/transport-node").Subscription;
89
+ /** Answer one control request for {@link serveControl}: the sender guard, the handler, and the reply. */
90
+ private answerControl;
91
+ /** Keep native named-reply and NoResponders handling, but settle when its connection closes:
92
+ * nats.js can close a no-mux subscription without settling its request. One close observer per
93
+ * connection avoids retaining a closed-promise callback for every completed request. */
94
+ requestBoundReply(nc: NatsConnection, subject: string, body: string, reply: string, timeoutMs: number): Promise<Msg>;
95
+ /** Send a control request to a service and await its reply (client side). Like {@link requestDelivery},
96
+ * the reply rides a BOUNDED subject UNDER the request subject (`ctl.<service>.<id>.reply.<uuid>`), not
97
+ * the per-id `_INBOX`.
98
+ * `noMux` lets us name the reply subject while keeping NoResponders detection. The random suffix is
99
+ * defense-in-depth (a predictable suffix would let a peer target an in-flight named reply sub). The
100
+ * reply sits under the sender's OWN request subject, so the responder's `boundReply` guard accepts it. */
101
+ requestControl(service: string, req: ControlRequestInit, timeoutMs?: number): Promise<ControlReply>;
102
+ /** The caller this connection's endpoint requests ride as: the legacy triple, or the issued
103
+ * caller with its discovered generation (SPEC 13.15). It names the reply rail this connection's
104
+ * credential reads, which is where a manager's turn notice for it lands (SPEC 14.3). */
105
+ serviceRailCaller(): EpCaller;
106
+ /** This endpoint's v0.4 caller triple (§13.2) — the identity its minted ep-rail rows pin. The
107
+ * owner/actor principal is mode-correct by construction (static: DEV_OWNER + the connection
108
+ * identity; user mode: the bearer's callout-derived pair), and the lifecycle UID is the
109
+ * launcher-supplied incarnation the rows are keyed on (ledger-consistent: the §13.1 presence
110
+ * lifecycle-proof refuses a divergent uid before any publish). */
111
+ private serviceCaller;
112
+ /** Follow this caller's goal on its standing connection, subscribing before submission.
113
+ * A submitter may use a separate short-lived control credential for the same caller triple;
114
+ * the accepted action's readiness budget can outlive that credential. This endpoint retains
115
+ * its existing credential renewal and caller-scoped progress grants. */
116
+ followServiceGoal(endpoint: string, submit: (signal?: AbortSignal) => Promise<EpAttributedReply>, deadlineMs?: number, opts?: Pick<SubmitAndFollowGoalOptions, "reconcile" | "signal" | "prepare">): Promise<EpAttributedReply>;
117
+ /** Drop every cached handle for one endpoint after refresh or a currency split. */
118
+ private clearResolvedService;
119
+ /** Hold connection recovery through the whole pre-acceptance phase, including the progress
120
+ * subscription flush. Release on setup failure or the command's answer, never on goal terminal. */
121
+ private beginServiceInvocation;
122
+ private waitServiceRecovery;
123
+ /** The resolved, digest-verified command surface of `endpoint` as this connection's caller sees
124
+ * it. Unpinned calls cache the complete discovery surface, and `refresh` drops both the full
125
+ * handle and any command-specific invocation handles. `instanceId` selects one instance without
126
+ * reading or populating either class cache, as a pinned invoke does. The caller's existing
127
+ * credential must permit that route. */
128
+ describeService(endpoint: string, opts?: {
129
+ deadlineMs?: number;
130
+ signal?: AbortSignal;
131
+ refresh?: boolean;
132
+ instanceId?: string;
133
+ }): Promise<ResolvedService>;
134
+ /** The caller a registry listing rides (SPEC 13.15). An issued connection lists as itself. Any
135
+ * other connection reads the listing generation the issuer bound to the credential it presented,
136
+ * under the token its connection id and that credential's expiry derive. `undefined`: that
137
+ * credential carries no listing binding, because it predates listing issuance or has no expiry. */
138
+ listingCaller(): Promise<IssuedCaller | undefined>;
139
+ /** One page of the registry's `endpoints` answer (SPEC 13.20) over this connection
140
+ * ({@link listRegistryEndpoints}). The describe rides this connection's own caller; the question
141
+ * rides the listing caller on an authed mesh. `unbound`: this credential carries no listing
142
+ * binding. */
143
+ listEndpoints(input: RegistryEndpointsInput, opts?: {
144
+ deadlineMs?: number;
145
+ signal?: AbortSignal;
146
+ }): Promise<{
147
+ unbound: true;
148
+ } | {
149
+ unbound?: false;
150
+ reply: EpAttributedReply;
151
+ page?: RegistryEndpointsOutput;
152
+ }>;
153
+ /** Ask the registry over `nc` under `listing`: this connection, or another of this caller triple
154
+ * such as a manager-call connection. The describe rides this connection, whose view holds the
155
+ * registry's describe. Every endpoint the page lists has its cached describe dropped, so the next
156
+ * describe of it reads the surface afresh. `unbound`: the broker refused the question under
157
+ * `listing`, whose credential holds no listing row. */
158
+ listEndpointsOver(nc: NatsConnection, listing: IssuedCaller | undefined, input: RegistryEndpointsInput, opts?: {
159
+ deadlineMs?: number;
160
+ signal?: AbortSignal;
161
+ }): Promise<{
162
+ unbound: true;
163
+ } | {
164
+ unbound?: false;
165
+ reply: EpAttributedReply;
166
+ page?: RegistryEndpointsOutput;
167
+ }>;
168
+ /** GENERIC v0.4 service invoke over this endpoint's own connection: resolve
169
+ * the named endpoint's registered surface — describe, §13.7 store fetch, digest-verified
170
+ * recompile ({@link resolveService}; cached per endpoint name) — and invoke one command. The
171
+ * resolve is describe-bound currency, and a call that reaches the wrong incarnation is recovered
172
+ * two ways depending on WHO caught it — the difference between knowing the command did not run
173
+ * and only knowing someone answered:
174
+ * - the RESPONDER fenced it on the request's `bind` (§13.2, an `ok:false` reply marked
175
+ * {@link replyRefusedBeforeEffect}): the command did not run, so the bind is dropped and the
176
+ * call re-issued for any command, up to {@link BIND_SPLIT_REISSUES} times while each re-issue
177
+ * is refused the same way. If a re-issue cannot be resolved, the refusal
178
+ * surfaces — still saying the command did not run — naming the resolve failure as why the
179
+ * repair could not be attempted. An unpinned targeted call that reached a member holding no
180
+ * mapping for its target ({@link replyTargetUnmapped}) is repaired the same way, and when the
181
+ * re-issues run out, the latest such refusal is the one surfaced.
182
+ * - this CLIENT caught it on the reply ({@link respondedButUnbound}: a different instance,
183
+ * `failed-precondition`; the same instance at any other epoch, `expired`), which is what a
184
+ * responder too old to know the field produces. A live instance received and answered it, so
185
+ * the bind is dropped but the call is re-issued only for a command on the
186
+ * {@link isRepeatSafeCommand} allowlist; anything else surfaces, since a second attempt could
187
+ * duplicate its effect.
188
+ * A broker permission refusal marked `not-executed` rebuilds the connection and retries once
189
+ * within the original deadline. A second refusal stands. Responder errors and calls that may
190
+ * have run never trigger this repair.
191
+ * Errors from the responder come back structurally on the attributed reply
192
+ * (`reply.ok === false`); transport/validation refusals throw {@link EpEnvelopeError}. */
193
+ invokeService(endpoint: string, command: string, args?: Record<string, unknown>, opts?: {
194
+ target?: EpVerbTarget;
195
+ deadlineMs?: number;
196
+ follow?: boolean;
197
+ signal?: AbortSignal;
198
+ instanceId?: string;
199
+ classInstanceId?: string;
200
+ }): Promise<EpAttributedReply>;
201
+ private invokeServiceOnce;
202
+ }
203
+ export {};
204
+ //# sourceMappingURL=endpoint-control-plane.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint-control-plane.d.ts","sourceRoot":"","sources":["../src/endpoint-control-plane.ts"],"names":[],"mappings":"AAIA,OAAO,EAAyB,KAAK,GAAG,EAAE,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGlH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