@cotal-ai/core 0.166.2 → 0.167.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 (76) hide show
  1. package/dist/agent-endpoint.d.ts +242 -0
  2. package/dist/agent-endpoint.d.ts.map +1 -0
  3. package/dist/agent-endpoint.js +183 -0
  4. package/dist/agent-endpoint.js.map +1 -0
  5. package/dist/backup-config.d.ts +2 -2
  6. package/dist/endpoint-call.d.ts +34 -1
  7. package/dist/endpoint-call.d.ts.map +1 -1
  8. package/dist/endpoint-call.js +209 -116
  9. package/dist/endpoint-call.js.map +1 -1
  10. package/dist/endpoint-cluster.d.ts +6 -1
  11. package/dist/endpoint-cluster.d.ts.map +1 -1
  12. package/dist/endpoint-cluster.js +25 -1
  13. package/dist/endpoint-cluster.js.map +1 -1
  14. package/dist/endpoint-delivery-lease.d.ts +184 -0
  15. package/dist/endpoint-delivery-lease.d.ts.map +1 -0
  16. package/dist/endpoint-delivery-lease.js +270 -0
  17. package/dist/endpoint-delivery-lease.js.map +1 -0
  18. package/dist/endpoint-envelope.d.ts +4 -3
  19. package/dist/endpoint-envelope.d.ts.map +1 -1
  20. package/dist/endpoint-envelope.js +19 -2
  21. package/dist/endpoint-envelope.js.map +1 -1
  22. package/dist/endpoint-grants.d.ts +31 -1
  23. package/dist/endpoint-grants.d.ts.map +1 -1
  24. package/dist/endpoint-grants.js +62 -1
  25. package/dist/endpoint-grants.js.map +1 -1
  26. package/dist/endpoint-presence.d.ts +296 -0
  27. package/dist/endpoint-presence.d.ts.map +1 -0
  28. package/dist/endpoint-presence.js +784 -0
  29. package/dist/endpoint-presence.js.map +1 -0
  30. package/dist/endpoint-publish-denial.d.ts +6 -0
  31. package/dist/endpoint-publish-denial.d.ts.map +1 -1
  32. package/dist/endpoint-publish-denial.js +13 -0
  33. package/dist/endpoint-publish-denial.js.map +1 -1
  34. package/dist/endpoint-serve.d.ts +76 -2
  35. package/dist/endpoint-serve.d.ts.map +1 -1
  36. package/dist/endpoint-serve.js +340 -147
  37. package/dist/endpoint-serve.js.map +1 -1
  38. package/dist/endpoint-service.d.ts +5 -1
  39. package/dist/endpoint-service.d.ts.map +1 -1
  40. package/dist/endpoint-service.js +2 -1
  41. package/dist/endpoint-service.js.map +1 -1
  42. package/dist/endpoint-subjects.d.ts +76 -2
  43. package/dist/endpoint-subjects.d.ts.map +1 -1
  44. package/dist/endpoint-subjects.js +113 -2
  45. package/dist/endpoint-subjects.js.map +1 -1
  46. package/dist/endpoint-verbs.d.ts +1 -1
  47. package/dist/endpoint-verbs.d.ts.map +1 -1
  48. package/dist/endpoint-verbs.js +1 -1
  49. package/dist/endpoint-verbs.js.map +1 -1
  50. package/dist/endpoint.d.ts +118 -190
  51. package/dist/endpoint.d.ts.map +1 -1
  52. package/dist/endpoint.js +323 -791
  53. package/dist/endpoint.js.map +1 -1
  54. package/dist/index.d.ts +1 -0
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +1 -0
  57. package/dist/index.js.map +1 -1
  58. package/dist/kv-scan.d.ts +2 -1
  59. package/dist/kv-scan.d.ts.map +1 -1
  60. package/dist/kv-scan.js +4 -2
  61. package/dist/kv-scan.js.map +1 -1
  62. package/dist/peer-label.d.ts +6 -5
  63. package/dist/peer-label.d.ts.map +1 -1
  64. package/dist/peer-label.js +7 -6
  65. package/dist/peer-label.js.map +1 -1
  66. package/dist/provision.d.ts +11 -1
  67. package/dist/provision.d.ts.map +1 -1
  68. package/dist/provision.js +41 -11
  69. package/dist/provision.js.map +1 -1
  70. package/dist/subjects.d.ts +3 -2
  71. package/dist/subjects.d.ts.map +1 -1
  72. package/dist/subjects.js +10 -2
  73. package/dist/subjects.js.map +1 -1
  74. package/dist/types.d.ts +11 -0
  75. package/dist/types.d.ts.map +1 -1
  76. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"endpoint-cluster.js","sourceRoot":"","sources":["../src/endpoint-cluster.ts"],"names":[],"mappings":"AAAA;;;;;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,CAAC,CAAC;IACjC,kBAAkB,CAAC,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;IACvD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,oBAAoB,CAAC,oDAAoD,CAAC,CAAC;IAChH,OAAO,UAAU,CAAC;QAChB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,GAAG,CAAC,QAAQ,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvF,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAU,EAAE;QAC3B,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC7B,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC;YACpD,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC;SACjC,CAAC,CAAC;KACJ,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,184 @@
1
+ import type { KV } from "@nats-io/kv";
2
+ import type { NatsConnection } from "@nats-io/transport-node";
3
+ import type { AgentCard } from "./types.js";
4
+ import { type DeliveryLeaseInfo } from "./lease.js";
5
+ type LeaseWatch = Awaited<ReturnType<KV["watch"]>>;
6
+ /** Connection and consumer custody shared with the endpoint's other broker readers. */
7
+ export interface EndpointDeliveryLeaseDeps {
8
+ card: () => AgentCard;
9
+ space: () => string;
10
+ connection: () => NatsConnection | undefined;
11
+ epoch: () => number;
12
+ notLiveMsg: () => string;
13
+ deleteWatchConsumer: (iter: LeaseWatch) => Promise<void>;
14
+ recoverable: (error: Error) => void;
15
+ emit: (event: string, error: Error) => boolean;
16
+ }
17
+ /** Delivery lease ownership, readiness and watch intent for one endpoint instance. */
18
+ export declare class EndpointDeliveryLease {
19
+ private readonly deps;
20
+ private deliveryKv?;
21
+ /** This endpoint instance's LEASE INCARNATION: which run of this principal a lease row was written
22
+ * by. Minted per construction and never re-derived, because the credential cannot supply it, the
23
+ * daemon's cred is a file on disk that every restart re-reads, so `card.id` is stable across
24
+ * processes by design. See {@link DeliveryLeaseInfo.incarnation}. */
25
+ private readonly leaseIncarnation;
26
+ /** When this endpoint last WON each shard's lease create. Every later write of that row carries it
27
+ * unchanged, while `since` is re-stamped. See {@link DeliveryLeaseInfo.acquiredAt}. */
28
+ private readonly leaseAcquiredAt;
29
+ /** The daemon's lease-loss watch (#1596): the INTENT that survives a connection rebuild, plus the
30
+ * live iterator. See {@link watchDeliveryLease}. */
31
+ private leaseWatchIntent?;
32
+ private leaseWatchIter?;
33
+ /** Consumer deletes of retired lease watches still in flight. The stop handle cannot await its
34
+ * delete, so endpoint shutdown and a live-epoch rebuild await these before they close the connection
35
+ * that carries them (#3966). */
36
+ private readonly leaseWatchDeletes;
37
+ /** Lease-watch binds still awaiting the broker. One that lands after endpoint shutdown or a rebuild
38
+ * moved the epoch retires its watch and starts that delete itself, so the same two paths wait for
39
+ * these first. Each is bounded by the JetStream request timeout. */
40
+ private readonly leaseWatchBinds;
41
+ constructor(deps: EndpointDeliveryLeaseDeps);
42
+ private get card();
43
+ private get space();
44
+ private get nc();
45
+ private get presenceEpoch();
46
+ private notLiveMsg;
47
+ private emitRecoverable;
48
+ private emit;
49
+ get hasWatchIntent(): boolean;
50
+ resetConnection(): void;
51
+ /** Lazily open the delivery lease/readiness KV (pre-created at `cotal up`; bind, never create). */
52
+ private deliveryRegistry;
53
+ private encodeLease;
54
+ /** Is this shard's lease row one THIS ENDPOINT INSTANCE wrote? The question a daemon whose renew
55
+ * just failed has to answer before it decides whether it still owns the shard.
56
+ *
57
+ * Both halves are required. `holder` alone is not sufficient (a successor daemon re-reading the
58
+ * same creds file presents the same principal, so its row would read as ours), and `incarnation`
59
+ * alone is not sufficient either, it is a bare uuid with no claim to the principal, so a row
60
+ * bearing ours but a foreign holder is not something we should ever adopt. A row with NO
61
+ * incarnation predates the field and cannot be proven ours, which is the safe reading: it leads
62
+ * to the takeover path rather than to serving on someone else's claim. */
63
+ ownsDeliveryLease(info: DeliveryLeaseInfo): boolean;
64
+ /** Acquire the single-flight delivery lease for a shard via an ATOMIC CAS create, marked NOT-ready.
65
+ * THROWS if a live lease exists - a loud refusal-to-bind (the daemon exits), never a retry, so two
66
+ * daemons can't split a durable's delivery. A crashed holder's lease auto-expires (bucket TTL),
67
+ * freeing a re-acquire. Acquired BEFORE binding (single-flight gate); {@link markDeliveryLeaseReady}
68
+ * flips it ready AFTER the loops + `ctl.delivery` are bound. Returns the lease revision. */
69
+ acquireDeliveryLease(shardIndex: number): Promise<number>;
70
+ /** Flip the held lease to READY (CAS `kv.update`) AFTER `startPlane3` has bound the loops + the
71
+ * `ctl.delivery` responder - so "lease ready" proves the responder is up, not just that the slot was
72
+ * claimed. Returns the new revision. */
73
+ markDeliveryLeaseReady(shardIndex: number, revision: number): Promise<number>;
74
+ /** Flip the held lease back to NOT-ready, the counterpart to {@link markDeliveryLeaseReady}, for a
75
+ * holder that has UNBOUND its loops and control responder but has not given up the shard.
76
+ *
77
+ * `ready` is a claim about the RESPONDER, not about the row's existence: `ensureDelivery` waits on
78
+ * it and the channel-health surface reports it. A daemon that goes quiet to re-check its ownership
79
+ * still holds the key, so without this the space would be told a responder is up while nothing is
80
+ * bound, a readiness lie of exactly the kind #1318 is about, just pointed the other way. Keeping
81
+ * the row (rather than deleting it) is deliberate: the shard is still claimed, so no third daemon
82
+ * should be invited in; what is being withdrawn is only the claim to be answering. */
83
+ markDeliveryLeaseNotReady(shardIndex: number, revision: number): Promise<number>;
84
+ /** Renew the held lease (CAS `kv.update` against `revision`, keeping `ready:true`) to refresh it before
85
+ * the bucket TTL expires it. Returns the new revision. Throws if the revision moved (lost the lease -
86
+ * the daemon should exit). */
87
+ renewDeliveryLease(shardIndex: number, revision: number): Promise<number>;
88
+ /** Release the held lease on clean shutdown so a replacement daemon re-acquires immediately (a
89
+ * crash just lets the bucket TTL expire it).
90
+ *
91
+ * THE REVISION IS WHAT MAKES THIS A RELEASE RATHER THAN A DELETE. An unconditional delete removes
92
+ * whatever row is there, and by shutdown time the row is not necessarily still ours: the exit
93
+ * paths that matter most are precisely the ones where another daemon has taken the shard, so the
94
+ * departing process would delete the REPLACEMENT's lease on its way out and leave the shard with
95
+ * no holder at all. Passing the revision this endpoint last owned makes the delete a compare-and-
96
+ * swap (`previousSeq` becomes JetStream's `ExpectedLastSubjectSequence`), so a row that has moved
97
+ * on is left alone.
98
+ *
99
+ * A RELEASE THAT DID NOT COMMIT REJECTS. The broker's CAS refusal and any broker failure reach the
100
+ * caller, because only the caller knows whether that matters: a shutdown that must finish anyway
101
+ * catches it, and a close that reports whether a successor can start learns the outcome here.
102
+ *
103
+ * THE ARGUMENT IS REQUIRED, AND EXPLICITLY NULLABLE RATHER THAN OPTIONAL. `undefined` means "this
104
+ * process no longer holds a revision it can argue for", which is the takeover paths' honest
105
+ * answer and correctly releases nothing, the bucket TTL is the crash-safe authority and expires
106
+ * a genuinely stale row. But if that were the DEFAULT, every existing `releaseDeliveryLease(0)`
107
+ * call site would keep compiling and silently stop releasing: the same omission hole
108
+ * `standaloneConnectOpts` closed by deleting its `= {}`. Measured, not theorised, this landed as
109
+ * a red in `smoke:delivery-lease`, where a caller that genuinely held the lease released nothing
110
+ * and the next acquire was refused. A caller must now say which it means. */
111
+ releaseDeliveryLease(shardIndex: number, revision: number | undefined): Promise<void>;
112
+ /** Read a shard's delivery lease (the daemon-availability signal), or `undefined` if none is live.
113
+ * READ-ONLY surface - drives Component 6's `cotal_channels` delivery-health field (an agent reads it
114
+ * under its own cred, which holds lease-bucket read but no write). */
115
+ readDeliveryLease(shardIndex: number): Promise<DeliveryLeaseInfo | undefined>;
116
+ /** Watch THIS shard's lease key and nothing else, for the daemon's loss trigger (#1596).
117
+ *
118
+ * A KV watch is the native JetStream push for "the row changed hands NOW": a filtered ordered
119
+ * consumer on the lease bucket delivers the row's own writes the moment the broker applies them,
120
+ * instead of the daemon waiting for its next renew tick to notice. The watch is a TRIGGER, never a
121
+ * decision: every event is handed to `onEvent` with the row as the broker now states it (PUT) or
122
+ * the fact it is gone (DEL/PURGE, `info` undefined), and the caller re-runs the SAME decision tree
123
+ * its renew tick would (`leaseAction`, `mayServeOn`, `readOwnLease`-style ownership tests). An
124
+ * event the daemon itself caused (its acquire, its renew, its ready flip) is an ordinary input to
125
+ * that tree - the row still reads `held` by this endpoint - so it never quiesces on its own write;
126
+ * no event filtering happens here.
127
+ *
128
+ * Like the presence watch, this survives a connection rebuild as INTENT: the iterator dies with
129
+ * its connection and the endpoint connection bind rebinds it onto the fresh one, so a reconnect can
130
+ * never leave the daemon blind to the row for the rest of its life. The rebind replays the
131
+ * bucket's current last-per-subject state, so a change that landed during the null window is
132
+ * delivered on the fresh watch. Resolves a stop handle. */
133
+ watchDeliveryLease(shardIndex: number, onEvent: (info: DeliveryLeaseInfo | undefined) => void): Promise<() => void>;
134
+ stopDeliveryLeaseWatch(): void;
135
+ /** Stop a lease watch and delete its ordered consumer, which the stop alone leaves on the broker
136
+ * until its five-minute inactive threshold (#3966). A connection that closed on its own cannot
137
+ * carry the delete, so that consumer is left to the threshold. A failed delete is a warning: the
138
+ * broker still reaps the consumer, and the daemon's synchronous stop handle has no caller to
139
+ * reject. */
140
+ private retireDeliveryLeaseWatch;
141
+ /** Wait for the lease-watch binds still in flight, then for every retired watch's consumer delete.
142
+ * endpoint shutdown and a live-epoch rebuild run this before they close the connection those deletes
143
+ * need (#3966). */
144
+ settleDeliveryLeaseWatches(): Promise<void>;
145
+ /** Bind the lease watch on the current connection. A bind that lands after a newer watch replaced
146
+ * its intent, or after a stop or connection teardown moved the epoch, retires its watch instead of
147
+ * installing it: the epoch it was bound for is gone, and a rebuilt one binds its own. */
148
+ bindDeliveryLeaseWatch(): Promise<void>;
149
+ private bindDeliveryLeaseWatchOnce;
150
+ /** The principal recorded as holding a shard's delivery lease, read by THIS process from the row,
151
+ * or `undefined` when no row is live or the read failed.
152
+ *
153
+ * THE POINT IS WHO ESTABLISHES THE FACT. Everything a requester learns from a request/reply rail
154
+ * is something a responder chose to send, and the delivery-admin rail is queue-grouped, so any
155
+ * process permitted to serve it decides what arrives. The lease row is the other kind of fact: a
156
+ * KV key whose only writer is the `delivery` credential's own `lease.*` grant, read here under
157
+ * THIS endpoint's credential, which no reply on any rail participates in. A caller comparing an
158
+ * answerer against the holder needs that, rather than the answerer's word for which one it is.
159
+ *
160
+ * `undefined` is a genuine unknown and is NEVER a statement that nobody holds the shard: a read
161
+ * that throws (a denied or unreadable bucket, a broker that will not answer) must not collapse
162
+ * into "nothing is there". Callers must treat it as a failure to determine (#1694). */
163
+ deliveryLeaseHolder(shardIndex: number): Promise<string | undefined>;
164
+ /** The lease row AND the KV revision it is at. The revision is the CAS token every renew and the
165
+ * CAS release are argued against, so a caller re-establishing ownership after a failed renew
166
+ * needs the BROKER's sequence, not the one it last cached: a renew can fail with its write
167
+ * already applied (a lost reply, a reconnect mid-request), which leaves the cached revision one
168
+ * behind forever and every subsequent CAS refused over a sequence this process itself moved ,
169
+ * read as somebody else's takeover, which is the #1318 misreading in a second costume.
170
+ *
171
+ * ABSENT and UNREADABLE are different facts and this method keeps them apart (#1694): `undefined`
172
+ * means NO row is live (no key, or DEL/PURGE), while a key that EXISTS but does not parse as a
173
+ * {@link DeliveryLeaseInfo} THROWS. Folding the parse failure into `undefined` made a live-but-
174
+ * corrupt row read as "nothing there", and the store-identity challenge's absence settlement
175
+ * then certified a remint over a row it could not read. A caller that wants the old swallow
176
+ * (an owner testing "is this provably MINE") still gets its safe answer: an unparseable row is
177
+ * not provably anyone's, and catching here reads as `false` exactly as before. */
178
+ readDeliveryLeaseEntry(shardIndex: number): Promise<{
179
+ info: DeliveryLeaseInfo;
180
+ revision: number;
181
+ } | undefined>;
182
+ }
183
+ export {};
184
+ //# sourceMappingURL=endpoint-delivery-lease.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint-delivery-lease.d.ts","sourceRoot":"","sources":["../src/endpoint-delivery-lease.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAwB,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAG1E,KAAK,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAEnD,uFAAuF;AACvF,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,SAAS,CAAC;IACtB,KAAK,EAAE,MAAM,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,cAAc,GAAG,SAAS,CAAC;IAC7C,KAAK,EAAE,MAAM,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,MAAM,CAAC;IACzB,mBAAmB,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACpC,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC;CAChD;AAED,sFAAsF;AACtF,qBAAa,qBAAqB;IAgCpB,OAAO,CAAC,QAAQ,CAAC,IAAI;IA9BjC,OAAO,CAAC,UAAU,CAAC,CAAK;IAGxB;;;0EAGsE;IACtE,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAgB;IAGjD;4FACwF;IACxF,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA6B;IA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E;IACjE,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IAKnF;;;;;;;;;;;;;;;;gEAgB4D;IACtD,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,iBAAiB,GAAG,SAAS,KAAK,IAAI,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC;IAWzH,sBAAsB,IAAI,IAAI;IAM9B;;;;kBAIc;IACd,OAAO,CAAC,wBAAwB;IAWhC;;wBAEoB;IACd,0BAA0B,IAAI,OAAO,CAAC,IAAI,CAAC;IAMjD;;8FAE0F;IAC1F,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;YASzB,0BAA0B;IAmBxC;;;;;;;;;;;;4FAYwF;IAClF,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAM1E;;;;;;;;;;;;;uFAamF;IAC7E,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,iBAAiB,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;CAMrH"}
@@ -0,0 +1,270 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { openDeliveryRegistry } from "./lease.js";
3
+ import { leaseKey } from "./subjects.js";
4
+ /** Delivery lease ownership, readiness and watch intent for one endpoint instance. */
5
+ export class EndpointDeliveryLease {
6
+ deps;
7
+ deliveryKv;
8
+ /** This endpoint instance's LEASE INCARNATION: which run of this principal a lease row was written
9
+ * by. Minted per construction and never re-derived, because the credential cannot supply it, the
10
+ * daemon's cred is a file on disk that every restart re-reads, so `card.id` is stable across
11
+ * processes by design. See {@link DeliveryLeaseInfo.incarnation}. */
12
+ leaseIncarnation = randomUUID();
13
+ /** When this endpoint last WON each shard's lease create. Every later write of that row carries it
14
+ * unchanged, while `since` is re-stamped. See {@link DeliveryLeaseInfo.acquiredAt}. */
15
+ leaseAcquiredAt = new Map();
16
+ /** The daemon's lease-loss watch (#1596): the INTENT that survives a connection rebuild, plus the
17
+ * live iterator. See {@link watchDeliveryLease}. */
18
+ leaseWatchIntent;
19
+ leaseWatchIter;
20
+ /** Consumer deletes of retired lease watches still in flight. The stop handle cannot await its
21
+ * delete, so endpoint shutdown and a live-epoch rebuild await these before they close the connection
22
+ * that carries them (#3966). */
23
+ leaseWatchDeletes = new Set();
24
+ /** Lease-watch binds still awaiting the broker. One that lands after endpoint shutdown or a rebuild
25
+ * moved the epoch retires its watch and starts that delete itself, so the same two paths wait for
26
+ * these first. Each is bounded by the JetStream request timeout. */
27
+ leaseWatchBinds = new Set();
28
+ constructor(deps) {
29
+ this.deps = deps;
30
+ }
31
+ get card() { return this.deps.card(); }
32
+ get space() { return this.deps.space(); }
33
+ get nc() { return this.deps.connection(); }
34
+ get presenceEpoch() { return this.deps.epoch(); }
35
+ notLiveMsg() { return this.deps.notLiveMsg(); }
36
+ emitRecoverable(error) { this.deps.recoverable(error); }
37
+ emit(event, error) { return this.deps.emit(event, error); }
38
+ get hasWatchIntent() { return this.leaseWatchIntent !== undefined; }
39
+ resetConnection() { this.deliveryKv = undefined; }
40
+ /** Lazily open the delivery lease/readiness KV (pre-created at `cotal up`; bind, never create). */
41
+ async deliveryRegistry() {
42
+ if (!this.nc)
43
+ throw new Error(this.notLiveMsg());
44
+ this.deliveryKv ??= await openDeliveryRegistry(this.nc, this.space);
45
+ return this.deliveryKv;
46
+ }
47
+ encodeLease(shardIndex, ready, acquiredAt = this.leaseAcquiredAt.get(shardIndex)) {
48
+ return new TextEncoder().encode(JSON.stringify({ holder: this.card.id, incarnation: this.leaseIncarnation, acquiredAt, since: Date.now(), ready }));
49
+ }
50
+ /** Is this shard's lease row one THIS ENDPOINT INSTANCE wrote? The question a daemon whose renew
51
+ * just failed has to answer before it decides whether it still owns the shard.
52
+ *
53
+ * Both halves are required. `holder` alone is not sufficient (a successor daemon re-reading the
54
+ * same creds file presents the same principal, so its row would read as ours), and `incarnation`
55
+ * alone is not sufficient either, it is a bare uuid with no claim to the principal, so a row
56
+ * bearing ours but a foreign holder is not something we should ever adopt. A row with NO
57
+ * incarnation predates the field and cannot be proven ours, which is the safe reading: it leads
58
+ * to the takeover path rather than to serving on someone else's claim. */
59
+ ownsDeliveryLease(info) {
60
+ return info.holder === this.card.id && info.incarnation !== undefined && info.incarnation === this.leaseIncarnation;
61
+ }
62
+ /** Acquire the single-flight delivery lease for a shard via an ATOMIC CAS create, marked NOT-ready.
63
+ * THROWS if a live lease exists - a loud refusal-to-bind (the daemon exits), never a retry, so two
64
+ * daemons can't split a durable's delivery. A crashed holder's lease auto-expires (bucket TTL),
65
+ * freeing a re-acquire. Acquired BEFORE binding (single-flight gate); {@link markDeliveryLeaseReady}
66
+ * flips it ready AFTER the loops + `ctl.delivery` are bound. Returns the lease revision. */
67
+ async acquireDeliveryLease(shardIndex) {
68
+ // Recorded only once the create wins: a refused create leaves the held row, and so its time, as it was.
69
+ const acquiredAt = Date.now();
70
+ const revision = await (await this.deliveryRegistry()).create(leaseKey(shardIndex), this.encodeLease(shardIndex, false, acquiredAt));
71
+ this.leaseAcquiredAt.set(shardIndex, acquiredAt);
72
+ return revision;
73
+ }
74
+ /** Flip the held lease to READY (CAS `kv.update`) AFTER `startPlane3` has bound the loops + the
75
+ * `ctl.delivery` responder - so "lease ready" proves the responder is up, not just that the slot was
76
+ * claimed. Returns the new revision. */
77
+ async markDeliveryLeaseReady(shardIndex, revision) {
78
+ return (await this.deliveryRegistry()).update(leaseKey(shardIndex), this.encodeLease(shardIndex, true), revision);
79
+ }
80
+ /** Flip the held lease back to NOT-ready, the counterpart to {@link markDeliveryLeaseReady}, for a
81
+ * holder that has UNBOUND its loops and control responder but has not given up the shard.
82
+ *
83
+ * `ready` is a claim about the RESPONDER, not about the row's existence: `ensureDelivery` waits on
84
+ * it and the channel-health surface reports it. A daemon that goes quiet to re-check its ownership
85
+ * still holds the key, so without this the space would be told a responder is up while nothing is
86
+ * bound, a readiness lie of exactly the kind #1318 is about, just pointed the other way. Keeping
87
+ * the row (rather than deleting it) is deliberate: the shard is still claimed, so no third daemon
88
+ * should be invited in; what is being withdrawn is only the claim to be answering. */
89
+ async markDeliveryLeaseNotReady(shardIndex, revision) {
90
+ return (await this.deliveryRegistry()).update(leaseKey(shardIndex), this.encodeLease(shardIndex, false), revision);
91
+ }
92
+ /** Renew the held lease (CAS `kv.update` against `revision`, keeping `ready:true`) to refresh it before
93
+ * the bucket TTL expires it. Returns the new revision. Throws if the revision moved (lost the lease -
94
+ * the daemon should exit). */
95
+ async renewDeliveryLease(shardIndex, revision) {
96
+ return (await this.deliveryRegistry()).update(leaseKey(shardIndex), this.encodeLease(shardIndex, true), revision);
97
+ }
98
+ /** Release the held lease on clean shutdown so a replacement daemon re-acquires immediately (a
99
+ * crash just lets the bucket TTL expire it).
100
+ *
101
+ * THE REVISION IS WHAT MAKES THIS A RELEASE RATHER THAN A DELETE. An unconditional delete removes
102
+ * whatever row is there, and by shutdown time the row is not necessarily still ours: the exit
103
+ * paths that matter most are precisely the ones where another daemon has taken the shard, so the
104
+ * departing process would delete the REPLACEMENT's lease on its way out and leave the shard with
105
+ * no holder at all. Passing the revision this endpoint last owned makes the delete a compare-and-
106
+ * swap (`previousSeq` becomes JetStream's `ExpectedLastSubjectSequence`), so a row that has moved
107
+ * on is left alone.
108
+ *
109
+ * A RELEASE THAT DID NOT COMMIT REJECTS. The broker's CAS refusal and any broker failure reach the
110
+ * caller, because only the caller knows whether that matters: a shutdown that must finish anyway
111
+ * catches it, and a close that reports whether a successor can start learns the outcome here.
112
+ *
113
+ * THE ARGUMENT IS REQUIRED, AND EXPLICITLY NULLABLE RATHER THAN OPTIONAL. `undefined` means "this
114
+ * process no longer holds a revision it can argue for", which is the takeover paths' honest
115
+ * answer and correctly releases nothing, the bucket TTL is the crash-safe authority and expires
116
+ * a genuinely stale row. But if that were the DEFAULT, every existing `releaseDeliveryLease(0)`
117
+ * call site would keep compiling and silently stop releasing: the same omission hole
118
+ * `standaloneConnectOpts` closed by deleting its `= {}`. Measured, not theorised, this landed as
119
+ * a red in `smoke:delivery-lease`, where a caller that genuinely held the lease released nothing
120
+ * and the next acquire was refused. A caller must now say which it means. */
121
+ async releaseDeliveryLease(shardIndex, revision) {
122
+ if (revision === undefined)
123
+ return;
124
+ await (await this.deliveryRegistry()).delete(leaseKey(shardIndex), { previousSeq: revision });
125
+ }
126
+ /** Read a shard's delivery lease (the daemon-availability signal), or `undefined` if none is live.
127
+ * READ-ONLY surface - drives Component 6's `cotal_channels` delivery-health field (an agent reads it
128
+ * under its own cred, which holds lease-bucket read but no write). */
129
+ async readDeliveryLease(shardIndex) {
130
+ return (await this.readDeliveryLeaseEntry(shardIndex))?.info;
131
+ }
132
+ /** Watch THIS shard's lease key and nothing else, for the daemon's loss trigger (#1596).
133
+ *
134
+ * A KV watch is the native JetStream push for "the row changed hands NOW": a filtered ordered
135
+ * consumer on the lease bucket delivers the row's own writes the moment the broker applies them,
136
+ * instead of the daemon waiting for its next renew tick to notice. The watch is a TRIGGER, never a
137
+ * decision: every event is handed to `onEvent` with the row as the broker now states it (PUT) or
138
+ * the fact it is gone (DEL/PURGE, `info` undefined), and the caller re-runs the SAME decision tree
139
+ * its renew tick would (`leaseAction`, `mayServeOn`, `readOwnLease`-style ownership tests). An
140
+ * event the daemon itself caused (its acquire, its renew, its ready flip) is an ordinary input to
141
+ * that tree - the row still reads `held` by this endpoint - so it never quiesces on its own write;
142
+ * no event filtering happens here.
143
+ *
144
+ * Like the presence watch, this survives a connection rebuild as INTENT: the iterator dies with
145
+ * its connection and the endpoint connection bind rebinds it onto the fresh one, so a reconnect can
146
+ * never leave the daemon blind to the row for the rest of its life. The rebind replays the
147
+ * bucket's current last-per-subject state, so a change that landed during the null window is
148
+ * delivered on the fresh watch. Resolves a stop handle. */
149
+ async watchDeliveryLease(shardIndex, onEvent) {
150
+ this.leaseWatchIntent = { shardIndex, onEvent };
151
+ await this.bindDeliveryLeaseWatch();
152
+ return () => {
153
+ if (this.leaseWatchIntent?.onEvent !== onEvent)
154
+ return; // a later watch owns the slot
155
+ this.leaseWatchIntent = undefined;
156
+ this.stopDeliveryLeaseWatch();
157
+ };
158
+ }
159
+ stopDeliveryLeaseWatch() {
160
+ if (this.leaseWatchIter)
161
+ this.retireDeliveryLeaseWatch(this.leaseWatchIter);
162
+ this.leaseWatchIter = undefined;
163
+ }
164
+ /** Stop a lease watch and delete its ordered consumer, which the stop alone leaves on the broker
165
+ * until its five-minute inactive threshold (#3966). A connection that closed on its own cannot
166
+ * carry the delete, so that consumer is left to the threshold. A failed delete is a warning: the
167
+ * broker still reaps the consumer, and the daemon's synchronous stop handle has no caller to
168
+ * reject. */
169
+ retireDeliveryLeaseWatch(iter) {
170
+ try {
171
+ iter.stop();
172
+ }
173
+ catch { /* already closed with its connection */ }
174
+ if (!this.nc || this.nc.isClosed())
175
+ return;
176
+ const deleting = this.deps.deleteWatchConsumer(iter).catch((e) => this.emitRecoverable(new Error(`a retired delivery lease watch consumer was not deleted (${e.message}); the broker reaps it at its inactive threshold`)));
177
+ this.leaseWatchDeletes.add(deleting);
178
+ void deleting.then(() => this.leaseWatchDeletes.delete(deleting));
179
+ }
180
+ /** Wait for the lease-watch binds still in flight, then for every retired watch's consumer delete.
181
+ * endpoint shutdown and a live-epoch rebuild run this before they close the connection those deletes
182
+ * need (#3966). */
183
+ async settleDeliveryLeaseWatches() {
184
+ await Promise.allSettled(this.leaseWatchBinds);
185
+ await Promise.all(this.leaseWatchDeletes);
186
+ }
187
+ /** Bind the lease watch on the current connection. A bind that lands after a newer watch replaced
188
+ * its intent, or after a stop or connection teardown moved the epoch, retires its watch instead of
189
+ * installing it: the epoch it was bound for is gone, and a rebuilt one binds its own. */
190
+ bindDeliveryLeaseWatch() {
191
+ const binding = this.bindDeliveryLeaseWatchOnce();
192
+ const settled = () => { this.leaseWatchBinds.delete(binding); };
193
+ this.leaseWatchBinds.add(binding);
194
+ void binding.then(settled, settled);
195
+ return binding;
196
+ }
197
+ async bindDeliveryLeaseWatchOnce() {
198
+ const intent = this.leaseWatchIntent;
199
+ const epoch = this.presenceEpoch;
200
+ const iter = await (await this.deliveryRegistry()).watch({ key: leaseKey(intent.shardIndex) });
201
+ if (this.leaseWatchIntent !== intent || epoch !== this.presenceEpoch) {
202
+ this.retireDeliveryLeaseWatch(iter);
203
+ return;
204
+ }
205
+ this.leaseWatchIter = iter;
206
+ void (async () => {
207
+ for await (const e of iter) {
208
+ if (this.leaseWatchIter !== iter)
209
+ break;
210
+ if (e.operation === "DEL" || e.operation === "PURGE") {
211
+ intent.onEvent(undefined);
212
+ continue;
213
+ }
214
+ try {
215
+ intent.onEvent(e.json());
216
+ }
217
+ catch {
218
+ intent.onEvent(undefined);
219
+ }
220
+ }
221
+ })().catch((e) => this.emit("error", e));
222
+ }
223
+ /** The principal recorded as holding a shard's delivery lease, read by THIS process from the row,
224
+ * or `undefined` when no row is live or the read failed.
225
+ *
226
+ * THE POINT IS WHO ESTABLISHES THE FACT. Everything a requester learns from a request/reply rail
227
+ * is something a responder chose to send, and the delivery-admin rail is queue-grouped, so any
228
+ * process permitted to serve it decides what arrives. The lease row is the other kind of fact: a
229
+ * KV key whose only writer is the `delivery` credential's own `lease.*` grant, read here under
230
+ * THIS endpoint's credential, which no reply on any rail participates in. A caller comparing an
231
+ * answerer against the holder needs that, rather than the answerer's word for which one it is.
232
+ *
233
+ * `undefined` is a genuine unknown and is NEVER a statement that nobody holds the shard: a read
234
+ * that throws (a denied or unreadable bucket, a broker that will not answer) must not collapse
235
+ * into "nothing is there". Callers must treat it as a failure to determine (#1694). */
236
+ async deliveryLeaseHolder(shardIndex) {
237
+ try {
238
+ return (await this.readDeliveryLeaseEntry(shardIndex))?.info.holder;
239
+ }
240
+ catch {
241
+ return undefined;
242
+ }
243
+ }
244
+ /** The lease row AND the KV revision it is at. The revision is the CAS token every renew and the
245
+ * CAS release are argued against, so a caller re-establishing ownership after a failed renew
246
+ * needs the BROKER's sequence, not the one it last cached: a renew can fail with its write
247
+ * already applied (a lost reply, a reconnect mid-request), which leaves the cached revision one
248
+ * behind forever and every subsequent CAS refused over a sequence this process itself moved ,
249
+ * read as somebody else's takeover, which is the #1318 misreading in a second costume.
250
+ *
251
+ * ABSENT and UNREADABLE are different facts and this method keeps them apart (#1694): `undefined`
252
+ * means NO row is live (no key, or DEL/PURGE), while a key that EXISTS but does not parse as a
253
+ * {@link DeliveryLeaseInfo} THROWS. Folding the parse failure into `undefined` made a live-but-
254
+ * corrupt row read as "nothing there", and the store-identity challenge's absence settlement
255
+ * then certified a remint over a row it could not read. A caller that wants the old swallow
256
+ * (an owner testing "is this provably MINE") still gets its safe answer: an unparseable row is
257
+ * not provably anyone's, and catching here reads as `false` exactly as before. */
258
+ async readDeliveryLeaseEntry(shardIndex) {
259
+ const e = await (await this.deliveryRegistry()).get(leaseKey(shardIndex));
260
+ if (!e || e.operation === "DEL" || e.operation === "PURGE")
261
+ return undefined;
262
+ try {
263
+ return { info: e.json(), revision: e.revision };
264
+ }
265
+ catch (err) {
266
+ throw new Error(`delivery lease row "${leaseKey(shardIndex)}" exists but does not parse as a lease record (${err.message}) - it is unreadable, not absent`);
267
+ }
268
+ }
269
+ }
270
+ //# sourceMappingURL=endpoint-delivery-lease.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint-delivery-lease.js","sourceRoot":"","sources":["../src/endpoint-delivery-lease.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIzC,OAAO,EAAE,oBAAoB,EAA0B,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAgBzC,sFAAsF;AACtF,MAAM,OAAO,qBAAqB;IAgCH;IA9BrB,UAAU,CAAM;IAGxB;;;0EAGsE;IACrD,gBAAgB,GAAG,UAAU,EAAE,CAAC;IAGjD;4FACwF;IACvE,eAAe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C,uBAAuB,QAAQ,CAAC,UAAU,CAAC,kDAAmD,GAAa,CAAC,OAAO,kCAAkC,CAAC,CAAC;QAAC,CAAC;IACzL,CAAC;CACF"}
@@ -13,7 +13,7 @@
13
13
  * registration-time `contract-invalid`).
14
14
  */
15
15
  import type { ContractValidator } from "./contract-validator.js";
16
- import { type ParsedEpRequest } from "./endpoint-subjects.js";
16
+ import { type ParsedEpPrincipalRequest, type ParsedEpRequest } from "./endpoint-subjects.js";
17
17
  import type { ControlReply, EndpointRef } from "./types.js";
18
18
  import { EpEnvelopeError, type EpError } from "./endpoint-error.js";
19
19
  export { EP_ERROR_CODES, EpEnvelopeError, EP_UNBOUND_RESPONDER, respondedButUnbound, EP_UNANSWERED, unansweredRequest, unansweredRail, EP_REGISTRY_READ_FAILED, registryReadFailed, EP_NO_LIVE_INSTANCES, noLiveInstances, EP_UNDECLARED_ARG, undeclaredArg, undeclaredArgInstance, EP_BIND_REFUSED, replyRefusedBeforeEffect, bindRefusalMarked, EP_TARGET_UNMAPPED, replyTargetUnmapped, EP_LIFECYCLE_BLOCKED, lifecycleBlocked, lifecycleBlockedDetail, lifecycleBlockedFrom, renderLifecycleBlocked, EP_SEAT_CAP, seatCapDetail, seatCapRefused, seatCapFrom, type EpErrorCode, type EpError, type EpErrorDetail, type EpUnboundResponderDetail, type EpUnansweredDetail, type EpRegistryReadFailedDetail, type EpNoLiveInstancesDetail, type EpUndeclaredArgDetail, type EpBindRefusedDetail, type EpLifecycleBlockedDetail, type LifecycleBlockedFacts, type EpSeatCapDetail, type SeatCapFacts, type LifecycleBlockedOp, type LifecycleHeadState, type LifecycleGateState, type EpEffectOutcome } from "./endpoint-error.js";
@@ -136,8 +136,9 @@ export declare function parseEndpointRequest(raw: unknown): EndpointRequest;
136
136
  * `handle` mode, subject-equal actor + lifecycleUid) for the targeted forms; `from.id` MUST
137
137
  * equal the subject sender principal (`sender-mismatch`). Currency of `target.actor`/
138
138
  * `target.lifecycleUid` against the live mapping is the handler's fresh-read (`expired`),
139
- * deliberately not checkable here. */
140
- export declare function checkRequestSubjectAgreement(env: EndpointRequest, subject: ParsedEpRequest): void;
139
+ * deliberately not checkable here. On the principal route (SPEC 13.21) the body carries no
140
+ * target (`target-mismatch`) and no bind (`bad-request`), and a deadline is required. */
141
+ export declare function checkRequestSubjectAgreement(env: EndpointRequest, subject: ParsedEpRequest | ParsedEpPrincipalRequest): void;
141
142
  /** The contract-class agreement check (`class-mismatch`): the envelope's declared class MUST
142
143
  * equal the command's contract class. Split out because it needs the contract in hand. */
143
144
  export declare function assertClassMatches(env: EndpointRequest, declaredClass: EpClass): void;
@@ -1 +1 @@
1
- {"version":3,"file":"endpoint-envelope.d.ts","sourceRoot":"","sources":["../src/endpoint-envelope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAA2B,MAAM,yBAAyB,CAAC;AAE1F,OAAO,EAA0E,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEtI,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAI5D,OAAO,EAAkB,eAAe,EAA4C,KAAK,OAAO,EAA4C,MAAM,qBAAqB,CAAC;AACxK,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,aAAa,EAAE,iBAAiB,EAAE,cAAc,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,eAAe,EAAE,iBAAiB,EAAE,aAAa,EAAE,qBAAqB,EAAE,eAAe,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,KAAK,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,wBAAwB,EAAE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AG,OAAO,CAYtH;AAED;;;;;;4CAM4C;AAC5C,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAUlF"}
@@ -226,12 +226,25 @@ export function parseEndpointRequest(raw) {
226
226
  * `handle` mode, subject-equal actor + lifecycleUid) for the targeted forms; `from.id` MUST
227
227
  * equal the subject sender principal (`sender-mismatch`). Currency of `target.actor`/
228
228
  * `target.lifecycleUid` against the live mapping is the handler's fresh-read (`expired`),
229
- * deliberately not checkable here. */
229
+ * deliberately not checkable here. On the principal route (SPEC 13.21) the body carries no
230
+ * target (`target-mismatch`) and no bind (`bad-request`), and a deadline is required. */
230
231
  export function checkRequestSubjectAgreement(env, subject) {
231
232
  if (env.op.endpoint !== subject.endpoint)
232
233
  fail("op-mismatch", `op.endpoint "${env.op.endpoint}" does not agree with the subject endpoint "${subject.endpoint}"`);
233
234
  if (env.op.command !== subject.command)
234
235
  fail("op-mismatch", `op.command "${env.op.command}" does not agree with the subject command "${subject.command}"`);
236
+ // The principal route (SPEC 13.21): the subject head is the target and its runtime id pins the
237
+ // process, so a body that names either is refused, never ignored. A call has a deadline.
238
+ if (subject.plane === "principal-request") {
239
+ if (env.target !== undefined)
240
+ fail("target-mismatch", "a body target on the principal route is target-mismatch: the subject head is the target (SPEC 13.21)");
241
+ if (env.bind !== undefined)
242
+ fail("bad-request", "a bind on the principal route is refused: the runtime id in the subject pins the process (SPEC 13.21)");
243
+ if (env.deadlineMs === undefined)
244
+ fail("bad-request", "deadlineMs is required on the principal route (SPEC 13.21)");
245
+ assertSender(env, subject.caller);
246
+ return;
247
+ }
235
248
  // §13.3: deadlineMs is a MUST for call, SCATTER, and journal submissions. Call and journal
236
249
  // are enforced at parse time; scatter is only knowable here, where the route is in hand.
237
250
  if (subject.route === "all" && env.deadlineMs === undefined)
@@ -263,7 +276,11 @@ export function checkRequestSubjectAgreement(env, subject) {
263
276
  if ((t.mode === "handle" || t.mode === "exact") && (env.target.actor !== t.tActor || env.target.lifecycleUid !== t.tUid))
264
277
  fail("target-mismatch", `in ${t.mode} mode the body target actor and lifecycleUid must equal the subject target triple`);
265
278
  }
266
- const sender = `${subject.caller.owner}.${subject.caller.actor}`;
279
+ assertSender(env, subject.caller);
280
+ }
281
+ /** `from.id` MUST equal the subject's sender principal (`sender-mismatch`, §13.3). */
282
+ function assertSender(env, caller) {
283
+ const sender = `${caller.owner}.${caller.actor}`;
267
284
  if (env.from.id !== sender)
268
285
  fail("sender-mismatch", `from.id "${env.from.id}" does not equal the subject sender principal "${sender}"`);
269
286
  }