@cotal-ai/core 0.84.0 → 0.86.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 (161) hide show
  1. package/dist/agent-file.d.ts.map +1 -1
  2. package/dist/agent-file.js +10 -3
  3. package/dist/agent-file.js.map +1 -1
  4. package/dist/base64url.d.ts +5 -0
  5. package/dist/base64url.d.ts.map +1 -0
  6. package/dist/base64url.js +14 -0
  7. package/dist/base64url.js.map +1 -0
  8. package/dist/browser-control.d.ts +97 -0
  9. package/dist/browser-control.d.ts.map +1 -0
  10. package/dist/browser-control.js +66 -0
  11. package/dist/browser-control.js.map +1 -0
  12. package/dist/browser-validators-build.d.ts +23 -0
  13. package/dist/browser-validators-build.d.ts.map +1 -0
  14. package/dist/browser-validators-build.js +149 -0
  15. package/dist/browser-validators-build.js.map +1 -0
  16. package/dist/canonical-json.d.ts +14 -0
  17. package/dist/canonical-json.d.ts.map +1 -0
  18. package/dist/canonical-json.js +121 -0
  19. package/dist/canonical-json.js.map +1 -0
  20. package/dist/canonical.d.ts +2 -10
  21. package/dist/canonical.d.ts.map +1 -1
  22. package/dist/canonical.js +2 -108
  23. package/dist/canonical.js.map +1 -1
  24. package/dist/checkpoint-answer.d.ts.map +1 -1
  25. package/dist/checkpoint-answer.js +3 -4
  26. package/dist/checkpoint-answer.js.map +1 -1
  27. package/dist/connector-setup.d.ts +10 -1
  28. package/dist/connector-setup.d.ts.map +1 -1
  29. package/dist/connector.d.ts +8 -2
  30. package/dist/connector.d.ts.map +1 -1
  31. package/dist/connector.js.map +1 -1
  32. package/dist/digest-id.d.ts +4 -0
  33. package/dist/digest-id.d.ts.map +1 -0
  34. package/dist/digest-id.js +7 -0
  35. package/dist/digest-id.js.map +1 -0
  36. package/dist/endpoint-action.d.ts.map +1 -1
  37. package/dist/endpoint-action.js +2 -16
  38. package/dist/endpoint-action.js.map +1 -1
  39. package/dist/endpoint-auth-digest.d.ts +7 -0
  40. package/dist/endpoint-auth-digest.d.ts.map +1 -0
  41. package/dist/endpoint-auth-digest.js +13 -0
  42. package/dist/endpoint-auth-digest.js.map +1 -0
  43. package/dist/endpoint-call.d.ts +176 -0
  44. package/dist/endpoint-call.d.ts.map +1 -0
  45. package/dist/endpoint-call.js +490 -0
  46. package/dist/endpoint-call.js.map +1 -0
  47. package/dist/endpoint-caller.d.ts +113 -0
  48. package/dist/endpoint-caller.d.ts.map +1 -0
  49. package/dist/endpoint-caller.js +260 -0
  50. package/dist/endpoint-caller.js.map +1 -0
  51. package/dist/endpoint-checkpoint.d.ts.map +1 -1
  52. package/dist/endpoint-checkpoint.js +5 -14
  53. package/dist/endpoint-checkpoint.js.map +1 -1
  54. package/dist/endpoint-envelope.d.ts +0 -6
  55. package/dist/endpoint-envelope.d.ts.map +1 -1
  56. package/dist/endpoint-envelope.js +17 -18
  57. package/dist/endpoint-envelope.js.map +1 -1
  58. package/dist/endpoint-guard.d.ts.map +1 -1
  59. package/dist/endpoint-guard.js +2 -10
  60. package/dist/endpoint-guard.js.map +1 -1
  61. package/dist/endpoint-invoke.d.ts +36 -119
  62. package/dist/endpoint-invoke.d.ts.map +1 -1
  63. package/dist/endpoint-invoke.js +56 -300
  64. package/dist/endpoint-invoke.js.map +1 -1
  65. package/dist/endpoint-publish-denial.d.ts +1 -1
  66. package/dist/endpoint-publish-denial.d.ts.map +1 -1
  67. package/dist/endpoint-publish-denial.js +1 -1
  68. package/dist/endpoint-publish-denial.js.map +1 -1
  69. package/dist/endpoint-receipt.d.ts.map +1 -1
  70. package/dist/endpoint-receipt.js +2 -16
  71. package/dist/endpoint-receipt.js.map +1 -1
  72. package/dist/endpoint-subjects.d.ts.map +1 -1
  73. package/dist/endpoint-subjects.js.map +1 -1
  74. package/dist/endpoint-traits.d.ts.map +1 -1
  75. package/dist/endpoint-traits.js +3 -20
  76. package/dist/endpoint-traits.js.map +1 -1
  77. package/dist/endpoint-verbs.d.ts +18 -151
  78. package/dist/endpoint-verbs.d.ts.map +1 -1
  79. package/dist/endpoint-verbs.js +4 -500
  80. package/dist/endpoint-verbs.js.map +1 -1
  81. package/dist/endpoint-work.d.ts.map +1 -1
  82. package/dist/endpoint-work.js +2 -17
  83. package/dist/endpoint-work.js.map +1 -1
  84. package/dist/endpoint.d.ts +39 -15
  85. package/dist/endpoint.d.ts.map +1 -1
  86. package/dist/endpoint.js +90 -42
  87. package/dist/endpoint.js.map +1 -1
  88. package/dist/index.d.ts +5 -0
  89. package/dist/index.d.ts.map +1 -1
  90. package/dist/index.js +5 -0
  91. package/dist/index.js.map +1 -1
  92. package/dist/issued-accepted.d.ts +27 -0
  93. package/dist/issued-accepted.d.ts.map +1 -0
  94. package/dist/issued-accepted.js +62 -0
  95. package/dist/issued-accepted.js.map +1 -0
  96. package/dist/issued-authority.d.ts +3 -18
  97. package/dist/issued-authority.d.ts.map +1 -1
  98. package/dist/issued-authority.js +4 -55
  99. package/dist/issued-authority.js.map +1 -1
  100. package/dist/lifecycle-state.d.ts +3 -0
  101. package/dist/lifecycle-state.d.ts.map +1 -1
  102. package/dist/lifecycle-state.js +7 -0
  103. package/dist/lifecycle-state.js.map +1 -1
  104. package/dist/manager-caller.d.ts.map +1 -1
  105. package/dist/manager-caller.js +2 -1
  106. package/dist/manager-caller.js.map +1 -1
  107. package/dist/one-line.d.ts +6 -0
  108. package/dist/one-line.d.ts.map +1 -0
  109. package/dist/one-line.js +8 -0
  110. package/dist/one-line.js.map +1 -0
  111. package/dist/peer-label.d.ts +16 -0
  112. package/dist/peer-label.d.ts.map +1 -0
  113. package/dist/peer-label.js +15 -0
  114. package/dist/peer-label.js.map +1 -0
  115. package/dist/permission-denied.d.ts +8 -0
  116. package/dist/permission-denied.d.ts.map +1 -0
  117. package/dist/permission-denied.js +15 -0
  118. package/dist/permission-denied.js.map +1 -0
  119. package/dist/presence-text.d.ts +6 -0
  120. package/dist/presence-text.d.ts.map +1 -0
  121. package/dist/presence-text.js +25 -0
  122. package/dist/presence-text.js.map +1 -0
  123. package/dist/provision.d.ts.map +1 -1
  124. package/dist/provision.js +8 -2
  125. package/dist/provision.js.map +1 -1
  126. package/dist/resolve.d.ts +2 -13
  127. package/dist/resolve.d.ts.map +1 -1
  128. package/dist/resolve.js +2 -12
  129. package/dist/resolve.js.map +1 -1
  130. package/dist/run-driver-grants.d.ts +5 -0
  131. package/dist/run-driver-grants.d.ts.map +1 -1
  132. package/dist/run-driver-grants.js +16 -4
  133. package/dist/run-driver-grants.js.map +1 -1
  134. package/dist/run-migration.d.ts +21 -0
  135. package/dist/run-migration.d.ts.map +1 -1
  136. package/dist/run-migration.js +2 -27
  137. package/dist/run-migration.js.map +1 -1
  138. package/dist/run-notice.d.ts +20 -0
  139. package/dist/run-notice.d.ts.map +1 -1
  140. package/dist/run-notice.js +3 -28
  141. package/dist/run-notice.js.map +1 -1
  142. package/dist/schema-bounds.d.ts +24 -0
  143. package/dist/schema-bounds.d.ts.map +1 -0
  144. package/dist/schema-bounds.js +74 -0
  145. package/dist/schema-bounds.js.map +1 -0
  146. package/dist/schema-profile.d.ts +11 -24
  147. package/dist/schema-profile.d.ts.map +1 -1
  148. package/dist/schema-profile.js +16 -73
  149. package/dist/schema-profile.js.map +1 -1
  150. package/dist/startup-confirm.d.ts +9 -5
  151. package/dist/startup-confirm.d.ts.map +1 -1
  152. package/dist/startup-confirm.js +51 -18
  153. package/dist/startup-confirm.js.map +1 -1
  154. package/dist/subjects.d.ts.map +1 -1
  155. package/dist/subjects.js +1 -2
  156. package/dist/subjects.js.map +1 -1
  157. package/dist/turn-contract.d.ts +94 -0
  158. package/dist/turn-contract.d.ts.map +1 -0
  159. package/dist/turn-contract.js +62 -0
  160. package/dist/turn-contract.js.map +1 -0
  161. package/package.json +14 -1
@@ -0,0 +1,113 @@
1
+ import type { NatsConnection } from "@nats-io/transport-node";
2
+ import type { CompiledContract } from "./schema-profile.js";
3
+ import { type EpVerbTarget, type EpAttributedReply } from "./endpoint-call.js";
4
+ import { type EpCaller } from "./endpoint-subjects.js";
5
+ export declare const dec: import("util").TextDecoder, enc: import("util").TextEncoder;
6
+ /** Delivery margin above an action owner's accepted readiness budget. Spawn's established generic
7
+ * invariant was 40s client > 30s manager; preserve that measured 10s separation when a connector
8
+ * declares a different budget instead of inventing a second timeout policy. */
9
+ export declare const GOAL_FOLLOW_MARGIN_MS = 10000;
10
+ /** A resolved command contract: the compiled input/output validators (recompiled from the store,
11
+ * digest-verified against the registered declaration) plus the command's §13.2 admission facts. */
12
+ export interface ResolvedCommand {
13
+ command: string;
14
+ contract: {
15
+ input: CompiledContract;
16
+ output: CompiledContract;
17
+ };
18
+ class: string;
19
+ targeted: boolean;
20
+ modes: readonly string[];
21
+ capability: string;
22
+ }
23
+ /** An endpoint's resolved invocation surface: every command the caller may see, with recompiled
24
+ * digest-verified contracts. Built from a fresh `describe` + store fetch. Carries the `caller`
25
+ * triple the describe ran as, so {@link invokeCommand} reuses the same authenticated identity,
26
+ * and the ANSWERING incarnation's identity off the describe reply SUBJECT (broker-authenticated:
27
+ * the §13.9 serve publish row pins `instanceId`+`epoch`, a responder cannot stamp another's) -
28
+ * {@link invokeCommand}'s default currency check binds the invoke to this incarnation. */
29
+ export interface ResolvedService {
30
+ endpoint: string;
31
+ owner: string;
32
+ caller: EpCaller;
33
+ responder: {
34
+ instanceId: string;
35
+ epoch: number;
36
+ };
37
+ commands: Map<string, ResolvedCommand>;
38
+ /** Set when the service was resolved PINNED to one instance's `inst` route (`--on`):
39
+ * {@link invokeCommand} then routes commands to that exact instance, never the class `one` queue,
40
+ * so a multi-manager space can be addressed per-instance. Absent ⇒ class anycast (the default). */
41
+ pinnedInstanceId?: string;
42
+ }
43
+ /**
44
+ * The reserved `describe` command as a raw request/reply (§13.7: describe pins NO contract, so it
45
+ * carries no `op` digests — {@link epCall} always stamps digests and the serve boundary rejects a
46
+ * digest-bearing describe as `contract-mismatch`, so this is a purpose-built raw path). It
47
+ * REQUEST-BINDS its reply exactly as {@link epCall}'s `parseAttributedReply` does (§13.2): the
48
+ * responder grant `epResponderReplyPattern` spans EVERY caller suffix, so any live responder can
49
+ * publish on the caller's rail at any nonce — acceptance therefore checks the reply SUBJECT's
50
+ * endpoint + nonce AND the body's echoed request id, not just "first `{ok:true}` on the rail".
51
+ * A reply that fails any of these is IGNORED (not rejected: an attacker racing a wrong-nonce reply
52
+ * must not be able to fail an honest describe), and the wait continues to the deadline. A signal
53
+ * that aborts with a `TimeoutError` ends the wait as that deadline would.
54
+ */
55
+ export declare function describeEndpoint(nc: NatsConnection, space: string, endpoint: string, caller: EpCaller, opts?: {
56
+ deadlineMs?: number;
57
+ instanceId?: string;
58
+ signal?: AbortSignal;
59
+ }): Promise<{
60
+ answer: DescribeAnswer;
61
+ responder: {
62
+ instanceId: string;
63
+ epoch: number;
64
+ };
65
+ }>;
66
+ /** The describe answer shape a caller reads (a subset — the fields the resolver needs). */
67
+ interface DescribeAnswer {
68
+ public: boolean;
69
+ descriptor: {
70
+ endpoint: string;
71
+ owner: string;
72
+ clusters: {
73
+ digest: string;
74
+ commands: string[];
75
+ }[];
76
+ };
77
+ }
78
+ /** How many times a call is re-issued after a `not-executed` bind refusal. Every
79
+ * re-issue is a first attempt, so this is a loop guard and not a duplication guard. Each attempt
80
+ * splits with probability (m-1)/m in a space of m managers, so seventeen attempts leave a
81
+ * three-manager space about 1 in 1000 where the unrepaired call failed 2 in 3 (#398). An attempt
82
+ * costs an answered describe and invoke, never an elapsed deadline. */
83
+ export declare const BIND_SPLIT_REISSUES = 16;
84
+ /**
85
+ * INVOKE one named command on a resolved service: validate nothing here (the compiled input
86
+ * contract in {@link epCall}'s request builder gates args before publish, and the responder's
87
+ * digest-bound boundary re-validates), route on the `one` rail, return the attributed reply. A
88
+ * command absent from the resolved surface is `not-found` (the caller cannot see it, or it does
89
+ * not exist); a targeted command needs its `target`.
90
+ *
91
+ * Currency: `opts.currentEpoch` (e.g. the registry-read `serviceEpochReader`) when supplied;
92
+ * otherwise the DESCRIBE-BOUND default - accept exactly the incarnation that answered this
93
+ * service's resolve (its broker-authenticated `instanceId`+`epoch` off the describe reply
94
+ * subject) and refuse `failed-precondition` when a DIFFERENT instance wins the `one` queue
95
+ * (a superseded-or-split responder; re-resolve to adopt a legitimate successor). The bind needs
96
+ * no registry read grant, and it is strictly stronger than no check: two live instances of a
97
+ * single-instance endpoint can never both pass one resolved handle.
98
+ */
99
+ export declare function invokeCommand(nc: NatsConnection, space: string, service: ResolvedService, command: string, args: Record<string, unknown> | undefined, opts: {
100
+ target?: EpVerbTarget;
101
+ deadlineMs?: number;
102
+ signal?: AbortSignal;
103
+ currentEpoch?: (instanceId: string) => Promise<number> | number;
104
+ /** A caller-pinned envelope id (see {@link EpVerbOp.id}): a goal-accepting command binds its
105
+ * goal under it, which is what lets a durable caller resubmit idempotently. */
106
+ id?: string;
107
+ }): Promise<EpAttributedReply>;
108
+ /** The refusal a goal-following call meets on a handle whose endpoint serves no `goal-result`: an
109
+ * accepted goal could never be read back to its terminal (SPEC 13.6), so nothing is submitted.
110
+ * `undefined` when the handle can follow. */
111
+ export declare function goalFollowRefusal(service: ResolvedService): EpAttributedReply | undefined;
112
+ export {};
113
+ //# sourceMappingURL=endpoint-caller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint-caller.d.ts","sourceRoot":"","sources":["../src/endpoint-caller.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAgB,MAAM,yBAAyB,CAAC;AAG5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAU,KAAK,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAwE,KAAK,QAAQ,EAAgB,MAAM,wBAAwB,CAAC;AAE3I,eAAO,MAAM,GAAG,4BAAoB,EAAE,GAAG,4BAAoB,CAAC;AAmB9D;;gFAEgF;AAChF,eAAO,MAAM,qBAAqB,QAAS,CAAC;AAE5C;oGACoG;AACpG,MAAM,WAAW,eA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MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;SAAE,EAAE,CAAA;KAAE,CAAC;CACrG;AAED;;;;wEAIwE;AACxE,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,aAAa,CACjC,EAAE,EAAE,cAAc,EAClB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EACzC,IAAI,EAAE;IACJ,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IAChE;oFACgF;IAChF,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,GACA,OAAO,CAAC,iBAAiB,CAAC,CA6E5B;AAED;;8CAE8C;AAC9C,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,GAAG,iBAAiB,GAAG,SAAS,CASzF"}
@@ -0,0 +1,260 @@
1
+ /** The node-free half of the generic caller path: `describeEndpoint`, `invokeCommand` and
2
+ * `goalFollowRefusal`, shared by `endpoint-invoke` and the browser entry. Moved unchanged from
3
+ * `endpoint-invoke.ts`; the store fetch, recompile and split repair stay there. */
4
+ import { base64url } from "./base64url.js";
5
+ import { openPublishDenialWatch } from "./endpoint-publish-denial.js";
6
+ import { EpEnvelopeError, EP_UNBOUND_RESPONDER, EP_UNANSWERED, parseEndpointReply } from "./endpoint-envelope.js";
7
+ import { epCall } from "./endpoint-call.js";
8
+ import { epRequestSubject, epCallerReplyFilter, epPlaneTokens, parseEpSubject } from "./endpoint-subjects.js";
9
+ export const dec = new TextDecoder(), enc = new TextEncoder();
10
+ const nonce = () => base64url(globalThis.crypto.getRandomValues(new Uint8Array(24)));
11
+ /** A describe is the reserved read-only discovery bootstrap, so an unanswered request may be
12
+ * re-published within its ORIGINAL deadline. Core NATS does not retain a request sent before a
13
+ * responder subscribes; without this bounded retry, a responder that registers one moment later
14
+ * is invisible until the caller pays the whole deadline. Commands are never retried here. */
15
+ const DESCRIBE_RETRY_MS = 250;
16
+ /** Format a caught value on a path that cannot afford to throw (timer/callback). A
17
+ * poisoned `Error.message` getter or `toString` must not escape the catch; the
18
+ * fallback is the detail, never a reason to skip the rejection. */
19
+ function caughtText(e, fallback) {
20
+ try {
21
+ return e instanceof Error ? e.message : String(e);
22
+ }
23
+ catch {
24
+ return fallback;
25
+ }
26
+ }
27
+ /** Delivery margin above an action owner's accepted readiness budget. Spawn's established generic
28
+ * invariant was 40s client > 30s manager; preserve that measured 10s separation when a connector
29
+ * declares a different budget instead of inventing a second timeout policy. */
30
+ export const GOAL_FOLLOW_MARGIN_MS = 10_000;
31
+ /**
32
+ * The reserved `describe` command as a raw request/reply (§13.7: describe pins NO contract, so it
33
+ * carries no `op` digests — {@link epCall} always stamps digests and the serve boundary rejects a
34
+ * digest-bearing describe as `contract-mismatch`, so this is a purpose-built raw path). It
35
+ * REQUEST-BINDS its reply exactly as {@link epCall}'s `parseAttributedReply` does (§13.2): the
36
+ * responder grant `epResponderReplyPattern` spans EVERY caller suffix, so any live responder can
37
+ * publish on the caller's rail at any nonce — acceptance therefore checks the reply SUBJECT's
38
+ * endpoint + nonce AND the body's echoed request id, not just "first `{ok:true}` on the rail".
39
+ * A reply that fails any of these is IGNORED (not rejected: an attacker racing a wrong-nonce reply
40
+ * must not be able to fail an honest describe), and the wait continues to the deadline. A signal
41
+ * that aborts with a `TimeoutError` ends the wait as that deadline would.
42
+ */
43
+ export async function describeEndpoint(nc, space, endpoint, caller, opts = {}) {
44
+ opts.signal?.throwIfAborted();
45
+ const deadlineMs = opts.deadlineMs ?? 10_000;
46
+ const n = nonce();
47
+ const requestId = nonce();
48
+ // `--on <instance>`: PIN the describe to one instance's `inst` route so a multi-manager
49
+ // space resolves the exact instance addressed, not whichever wins the class `one` queue. Default =
50
+ // class anycast (mode "one"), unchanged for every existing caller.
51
+ const route = opts.instanceId !== undefined ? { mode: "inst", instanceId: opts.instanceId } : { mode: "one" };
52
+ const subject = epRequestSubject(space, { route, endpoint, command: "describe", caller, nonce: n });
53
+ // The plane this describe rides, recorded on the unanswered marker so a surface that renders a
54
+ // reachability verdict can scope it (SPEC 13.15: the legacy and versioned rails are disjoint subject spaces,
55
+ // an endpoint serves both, and a caller holds rows on one of them only). Silence on the versioned rail is
56
+ // therefore consistent with a responder that predates the versioned rail and serves `ep` alone.
57
+ const rail = epPlaneTokens(caller).join(".");
58
+ const env = {
59
+ v: 1, id: requestId, op: { endpoint, command: "describe" }, class: "ephemeral",
60
+ replyExpected: true, deadlineMs, from: { id: `${caller.owner}.${caller.actor}`, name: caller.actor },
61
+ };
62
+ let sub;
63
+ let timer;
64
+ let retryTimer;
65
+ let denialWatch;
66
+ let onAbort;
67
+ const startedAt = performance.now();
68
+ const unanswered = (ms) => new EpEnvelopeError("deadline-exceeded", `no describe reply from ${endpoint}${opts.instanceId !== undefined ? ` instance ${opts.instanceId}` : ""} within ${ms}ms on the ${rail} rail`, [{ kind: EP_UNANSWERED, endpoint, command: "describe", rail }]);
69
+ const cancelled = new Promise((_, reject) => {
70
+ onAbort = () => reject(opts.signal?.reason?.name === "TimeoutError"
71
+ ? unanswered(Math.round(performance.now() - startedAt))
72
+ : new EpEnvelopeError("unavailable", `describe(${endpoint}) observation cancelled`));
73
+ opts.signal?.addEventListener("abort", onAbort, { once: true });
74
+ });
75
+ try {
76
+ // REGISTER THE PERMISSION WATCH BEFORE THE PUBLISH IT IS WATCHING. See
77
+ // {@link openPublishDenialWatch}: a refused publish is otherwise indistinguishable
78
+ // from an unanswered describe.
79
+ denialWatch = openPublishDenialWatch(nc, subject, () => new EpEnvelopeError("permission-denied", `the describe for ${endpoint} was REFUSED BY THE BROKER, not unanswered: this caller's credential does not authorize publishing to "${subject}"${opts.instanceId !== undefined ? ` (the instance rail for ${opts.instanceId}: an instance-addressed call needs a credential minted with that instance, not a class-rail one)` : ""}. The responder may be perfectly healthy; the grant is what is missing (SPEC 13.2)`, undefined, "not-executed"), "describe");
80
+ const got = new Promise((resolve, reject) => {
81
+ sub = nc.subscribe(epCallerReplyFilter(space, caller), {
82
+ callback: (err, msg) => {
83
+ if (err) {
84
+ reject(new EpEnvelopeError("unavailable", `describe reply subscription failed: ${err.message}`));
85
+ return;
86
+ }
87
+ // REQUEST-BIND off the reply SUBJECT first (§13.2): the responder triple + nonce are
88
+ // broker-pinned by the serve publish grant. A reply for a DIFFERENT endpoint, or on a
89
+ // nonce that is not the one we published (the rail is shared across our concurrent
90
+ // requests, and a hostile responder can publish at any nonce), is NOT ours — ignore it
91
+ // and keep waiting, never fail the honest describe on an injected reply.
92
+ const parsed = parseEpSubject(msg.subject);
93
+ if (!parsed || parsed.plane !== "reply" || parsed.endpoint !== endpoint || parsed.nonce !== n)
94
+ return;
95
+ // Then the body: it must parse as an EndpointReply and ECHO our request id on this
96
+ // nonce-scoped rail (§13.3) — the second half of the confused-deputy binding.
97
+ let reply;
98
+ try {
99
+ reply = parseEndpointReply(JSON.parse(dec.decode(msg.data)));
100
+ }
101
+ catch {
102
+ return;
103
+ } // a malformed body on our nonce is not a usable answer; wait for a valid one
104
+ if (reply.id !== requestId)
105
+ return;
106
+ resolve({ body: reply, responder: { instanceId: parsed.instanceId, epoch: parsed.epoch } });
107
+ },
108
+ });
109
+ const request = enc.encode(JSON.stringify(env));
110
+ nc.publish(subject, request);
111
+ // The first publish may precede the responder's subscription during startup. Re-publish the
112
+ // SAME read-only describe under the SAME request binding until one answer wins or the original
113
+ // deadline expires; this neither extends the budget nor retries the command being resolved.
114
+ // `publish` throws synchronously after close/drain. A timer throw escapes the caller's promise
115
+ // and crashes the process, so make transport loss settle this describe instead.
116
+ retryTimer = setInterval(() => {
117
+ try {
118
+ nc.publish(subject, request);
119
+ }
120
+ catch (e) {
121
+ reject(new EpEnvelopeError("unavailable", `the describe retry for ${endpoint} could not publish: ${caughtText(e, "unknown publish failure")}`));
122
+ }
123
+ }, DESCRIBE_RETRY_MS);
124
+ });
125
+ const timeout = new Promise((_, reject) => { timer = setTimeout(() => reject(unanswered(deadlineMs)), deadlineMs); });
126
+ const { body: reply, responder } = await Promise.race([got, timeout, denialWatch.denied, cancelled]);
127
+ if (reply.ok !== true) {
128
+ // A responder ANSWERED with a refusal: it is rethrown under the responder's own code (which
129
+ // may be `unavailable`) and deliberately without the EP_UNANSWERED marker the deadline above
130
+ // carries, so a consumer keyed on that marker never reads an answering responder as absent.
131
+ const e = reply.error;
132
+ throw new EpEnvelopeError(e?.code ?? "unavailable", `describe(${endpoint}) failed: ${e?.message ?? "unknown"}`);
133
+ }
134
+ return { answer: reply.data, responder };
135
+ }
136
+ finally {
137
+ sub?.unsubscribe();
138
+ if (timer !== undefined)
139
+ clearTimeout(timer);
140
+ if (retryTimer !== undefined)
141
+ clearInterval(retryTimer);
142
+ if (onAbort)
143
+ opts.signal?.removeEventListener("abort", onAbort);
144
+ // Release on EVERY exit, success included. See {@link openPublishDenialWatch}.
145
+ denialWatch?.release();
146
+ }
147
+ }
148
+ /** How many times a call is re-issued after a `not-executed` bind refusal. Every
149
+ * re-issue is a first attempt, so this is a loop guard and not a duplication guard. Each attempt
150
+ * splits with probability (m-1)/m in a space of m managers, so seventeen attempts leave a
151
+ * three-manager space about 1 in 1000 where the unrepaired call failed 2 in 3 (#398). An attempt
152
+ * costs an answered describe and invoke, never an elapsed deadline. */
153
+ export const BIND_SPLIT_REISSUES = 16;
154
+ /**
155
+ * INVOKE one named command on a resolved service: validate nothing here (the compiled input
156
+ * contract in {@link epCall}'s request builder gates args before publish, and the responder's
157
+ * digest-bound boundary re-validates), route on the `one` rail, return the attributed reply. A
158
+ * command absent from the resolved surface is `not-found` (the caller cannot see it, or it does
159
+ * not exist); a targeted command needs its `target`.
160
+ *
161
+ * Currency: `opts.currentEpoch` (e.g. the registry-read `serviceEpochReader`) when supplied;
162
+ * otherwise the DESCRIBE-BOUND default - accept exactly the incarnation that answered this
163
+ * service's resolve (its broker-authenticated `instanceId`+`epoch` off the describe reply
164
+ * subject) and refuse `failed-precondition` when a DIFFERENT instance wins the `one` queue
165
+ * (a superseded-or-split responder; re-resolve to adopt a legitimate successor). The bind needs
166
+ * no registry read grant, and it is strictly stronger than no check: two live instances of a
167
+ * single-instance endpoint can never both pass one resolved handle.
168
+ */
169
+ export async function invokeCommand(nc, space, service, command, args, opts) {
170
+ const resolved = service.commands.get(command);
171
+ if (resolved === undefined)
172
+ throw new EpEnvelopeError("not-found", `command "${command}" is not in ${service.endpoint}'s visible surface; describe lists ${[...service.commands.keys()].sort().join(", ") || "(none)"}`);
173
+ if (resolved.targeted && opts.target === undefined)
174
+ throw new EpEnvelopeError("bad-request", `command "${command}" is targeted (modes: ${resolved.modes.join(", ")}); an invoke needs its target`);
175
+ if (!resolved.targeted && opts.target !== undefined)
176
+ throw new EpEnvelopeError("bad-request", `command "${command}" is untargeted; an invoke must not carry a target`);
177
+ const caller = service.caller;
178
+ // "No args" marshals to the CONTRACT's canonical empty form: absent args ride as null on the
179
+ // wire, so when this command's input rejects null but accepts the empty object (e.g. an
180
+ // all-optional `{type:"object"}` input like despawn's), send `{}` — that IS the caller's
181
+ // intent in that contract's vocabulary (a targeted CLI stop has nothing left after the alias
182
+ // becomes the target block). Contract-derived, never a guess: an input that requires fields
183
+ // accepts neither form and still refuses loud at the pre-publish validation below.
184
+ let sendArgs = args;
185
+ if (sendArgs === undefined && !resolved.contract.input.validate(null) && resolved.contract.input.validate({}))
186
+ sendArgs = {};
187
+ const describeBound = (instanceId) => {
188
+ if (instanceId !== service.responder.instanceId) {
189
+ // The refusal is unchanged; what it SAYS is not. One message used to cover two situations
190
+ // that call for opposite responses, and it described only the rarer one.
191
+ //
192
+ // PINNED: the caller named an instance and a different one answered. Genuinely wrong.
193
+ //
194
+ // UNPINNED: the caller addressed the CLASS. The describe and the invoke are two independent
195
+ // trips through the same anycast queue, so in a multi-instance space they routinely land on
196
+ // different instances and this fires on an ordinary, correct request - not on a supersession.
197
+ // Calling that "superseded-or-split" sends the reader hunting a restart that never happened.
198
+ // The old text's remedy is also not executable by the surfaces that print it most (`stop`,
199
+ // `despawn` and `attach` have no adopt path and no pin), so it advised an action the caller
200
+ // could not take. Say which case this is, and stop asserting a cause that is usually wrong.
201
+ // The marker, not the prose, is what stops an automatic re-invoke: reaching here means a
202
+ // responder ANSWERED (executed or refused; the reply does not say which), so a retry is a
203
+ // second attempt that may duplicate an effect rather than a repair. Callers that recover
204
+ // from `failed-precondition` by re-resolving must consult `respondedButUnbound`.
205
+ // The remedy is stated in core vocabulary (address one instance), never as a CLI flag: core
206
+ // cannot know whether its caller has one, and most `invokeService` callers (a connector's
207
+ // tools, a manifest deploy) do not. The CLI names its own flag when it renders this.
208
+ throw new EpEnvelopeError("failed-precondition", service.pinnedInstanceId !== undefined
209
+ ? `the ${service.endpoint} instance ${instanceId} answered but this handle is PINNED to ${service.pinnedInstanceId}; a pinned call names its instance and never accepts another. ${instanceId} did receive and answer the request, so if "${command}" mutates, that effect may already have landed - verify before re-issuing (SPEC 13.2)`
210
+ : `the ${service.endpoint} instance ${instanceId} won the class queue but this UNPINNED handle resolved against ${service.responder.instanceId}; the describe and the invoke are separate trips through the same queue, so in a multi-instance space this is an ordinary split and not necessarily a supersession - the handle cannot currently adopt a different winner. THIS SAYS NOTHING ABOUT WHETHER THE COMMAND RAN: ${instanceId} received the request and answered it, possibly after this error was raised. For a read that is harmless and re-issuing is safe; if "${command}" mutates, verify the outcome ('ps'/'inspect'/roster) before re-issuing, because a retry that assumes failure duplicates the effect. A call that addresses one instance does not split (SPEC 13.2)`, [{ kind: EP_UNBOUND_RESPONDER, endpoint: service.endpoint, command, answeredBy: instanceId, boundTo: service.responder.instanceId, pinned: service.pinnedInstanceId !== undefined }]);
211
+ }
212
+ return service.responder.epoch;
213
+ };
214
+ // `--on`: a PINNED service routes to its exact instance's `inst` rail (the same instance the
215
+ // describe resolved to, at its resolved epoch), never the class `one` queue — so the command reaches
216
+ // the addressed manager in a multi-manager space. Unpinned ⇒ class anycast `one` (unchanged). The
217
+ // describeBound currency check still holds: an inst-routed reply carries that instance's id.
218
+ const route = service.pinnedInstanceId !== undefined
219
+ ? { mode: "inst", instanceId: service.pinnedInstanceId, epoch: service.responder.epoch }
220
+ : { mode: "one" };
221
+ // The bind travels WITH the request, so the responder can refuse before running the command
222
+ // rather than leaving `describeBound` to report the split afterwards. It is sent exactly when
223
+ // this handle's own resolve is the currency reference — that is the caller saying "this
224
+ // incarnation or none", and it is the same population the check below already refuses. A caller
225
+ // that supplied its own `currentEpoch` is asking a REGISTRY whether the answerer is current, and
226
+ // deliberately accepts any current member; binding it would refuse calls that succeed today.
227
+ const bind = opts.currentEpoch === undefined
228
+ ? { instanceId: service.pinnedInstanceId ?? service.responder.instanceId, epoch: service.responder.epoch }
229
+ : undefined;
230
+ return epCall(nc, space, route, {
231
+ endpoint: service.endpoint, command, contract: resolved.contract, caller,
232
+ ...(sendArgs !== undefined ? { args: sendArgs } : {}),
233
+ ...(opts.target ? { target: opts.target } : {}),
234
+ ...(bind !== undefined ? { bind } : {}),
235
+ ...(opts.id !== undefined ? { id: opts.id } : {}),
236
+ }, {
237
+ deadlineMs: opts.deadlineMs ?? 10_000,
238
+ signal: opts.signal,
239
+ currentEpoch: opts.currentEpoch ?? describeBound,
240
+ // What the currency hook returns decides how a stale-epoch refusal is worded and marked: the
241
+ // describe-bound default is this handle's own bind (a responder ahead of it is a successor and
242
+ // the handle is the stale side); a caller-supplied hook is a registry read by epCall's contract.
243
+ currencyReference: opts.currentEpoch ? "registry" : "bind",
244
+ });
245
+ }
246
+ /** The refusal a goal-following call meets on a handle whose endpoint serves no `goal-result`: an
247
+ * accepted goal could never be read back to its terminal (SPEC 13.6), so nothing is submitted.
248
+ * `undefined` when the handle can follow. */
249
+ export function goalFollowRefusal(service) {
250
+ if (service.commands.has("goal-result"))
251
+ return undefined;
252
+ return {
253
+ reply: { v: 1, id: globalThis.crypto.randomUUID(), ok: false, error: {
254
+ code: "failed-precondition", outcome: "not-executed",
255
+ message: `endpoint "${service.endpoint}" does not support "goal-result"; upgrade manager to enable durable goal following (SPEC 13.6)`,
256
+ } },
257
+ responder: { endpoint: service.endpoint, instanceId: service.responder.instanceId, epoch: service.responder.epoch },
258
+ };
259
+ }
260
+ //# sourceMappingURL=endpoint-caller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint-caller.js","sourceRoot":"","sources":["../src/endpoint-caller.ts"],"names":[],"mappings":"AAAA;;oFAEoF;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAElH,OAAO,EAAE,MAAM,EAA6C,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,aAAa,EAAE,cAAc,EAA+B,MAAM,wBAAwB,CAAC;AAE3I,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,EAAE,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;AAC9D,MAAM,KAAK,GAAG,GAAW,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC7F;;;8FAG8F;AAC9F,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAE9B;;oEAEoE;AACpE,SAAS,UAAU,CAAC,CAAU,EAAE,QAAgB;IAC9C,IAAI,CAAC;QACH,OAAO,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CA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gBAAgB,CACpC,EAAE,EAAE,EAAE,EACN,EAAE,EAAE,eAAe,EACnB,GAAG,EAAE,gBAAgB,EACrB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE;IAAE,GAAG,EAAE,aAAa,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GACxC,OAAO,CAAC,oBAAoB,CAAC,CAiB/B;AA8CD;;;;;;sEAMsE;AACtE,wBAAsB,2BAA2B,CAC/C,EAAE,EAAE,EAAE,EACN,EAAE,EAAE,eAAe,EACnB,GAAG,EAAE,gBAAgB,EACrB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE;IAAE,GAAG,EAAE,aAAa,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC9D,OAAO,CAAC;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAuBtD"}
@@ -1,6 +1,7 @@
1
1
  import { jetstream, jetstreamManager } from "@nats-io/jetstream";
2
2
  import { headers as natsHeaders } from "@nats-io/transport-node";
3
3
  import { EpEnvelopeError } from "./endpoint-envelope.js";
4
+ import { withDeadline } from "./deadline.js";
4
5
  import { canonicalJson } from "./canonical.js";
5
6
  import { epfSubject, eptSubject, parseEpSubject, assertIdToken } from "./endpoint-subjects.js";
6
7
  import { RECORD_KINDS, recordSpecKey, recordStatusKey, createRecordEntry, updateRecordEntry, assertStatusValue, readRecordLeader, isCasLoss } from "./endpoint-records.js";
@@ -555,20 +556,10 @@ export async function startTimerWriter(nc, space_, opts = {}) {
555
556
  done,
556
557
  };
557
558
  }
558
- /** Race the fresh-check against the writer's budget: a stuck status authority is a bounded
559
- * `unavailable` refusal, never a hung writer. Races `Promise.resolve(p)` unconditionally so a
560
- * non-native thenable cannot bypass the deadline. */
561
- async function withStatusBudget(p, budgetMs, what) {
562
- let timer;
563
- const deadline = new Promise((_, reject) => {
564
- timer = setTimeout(() => reject(new EpEnvelopeError("unavailable", `${what} did not answer within ${budgetMs}ms; the timer writer is bounded and fails closed (SPEC 13.2)`)), budgetMs);
565
- });
566
- try {
567
- return await Promise.race([Promise.resolve(p), deadline]);
568
- }
569
- finally {
570
- clearTimeout(timer);
571
- }
559
+ /** Bound a writer read by the writer's budget: a stuck status authority is a bounded
560
+ * `unavailable` refusal, never a hung writer. */
561
+ function withStatusBudget(p, budgetMs, what) {
562
+ return withDeadline(p, budgetMs, () => new EpEnvelopeError("unavailable", `${what} did not answer within ${budgetMs}ms; the timer writer is bounded and fails closed (SPEC 13.2)`));
572
563
  }
573
564
  /** LEADER-SERVED status read for the writer's fresh-check (distsys 8dcad72 M2): the fence the
574
565
  * arm decision rests on needs read-your-writes against the leader. `kv.get` on the