@cotal-ai/auth 0.56.1 → 0.58.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.
@@ -1,3 +1,4 @@
1
+ import { type EpServeGrant } from "@cotal-ai/core";
1
2
  import { runAgentRetirementBarrier, type RetirementDeps } from "./retirement-barrier.js";
2
3
  import { type LifecycleRegistry } from "./lifecycle-registry.js";
3
4
  /** The LISTENER profile (SPEC 13.9 "Auth endpoint rail" row): serve + bounded replies on the auth
@@ -42,6 +43,15 @@ export declare function openAuthAdminListener(opts: {
42
43
  reg: LifecycleRegistry;
43
44
  retirement: RetirementDeps;
44
45
  barrierFlight: RetirementFlights;
46
+ /** The plane's #399 M2-registered instance id and current process epoch (`authServeGrant.epoch`)
47
+ * — the SAME instance/epoch the registration ceremony fenced. The gate's process-epoch reader is
48
+ * the fence now; there is no separate fixed responder identity to mint. */
49
+ instanceId: string;
50
+ epoch: number;
51
+ /** The M2-authorized serve artifact for this instance/epoch (`authServeGrant`, `service.ts:513`)
52
+ * — `serveEndpoint` consumes it directly; it is the ONE authority source for what this
53
+ * credential may serve (SPEC 13.9). */
54
+ grant: EpServeGrant;
45
55
  log: (line: string) => void;
46
56
  }): Promise<AuthAdminListener>;
47
57
  //# sourceMappingURL=auth-admin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth-admin.d.ts","sourceRoot":"","sources":["../src/auth-admin.ts"],"names":[],"mappings":"AAwEA,OAAO,EAAE,yBAAyB,EAAE,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzF,OAAO,EAA8C,KAAK,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAW7G;;gEAEgE;AAChE,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,SAAS,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC/C;IAAE,OAAO,EAAE,MA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AE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAClD,GAAG,EAAE,iBAAiB,CAAC;IACvB,UAAU,EAAE,cAAc,CAAC;IAC3B,aAAa,EAAE,iBAAiB,CAAC;IACjC;;gFAE4E;IAC5E,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd;;4CAEwC;IACxC,KAAK,EAAE,YAAY,CAAC;IACpB,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA6I7B"}
@@ -1,29 +1,75 @@
1
+ /**
2
+ * The AUTH service's ENDPOINT listener (#29 piece 3; Cotal #350): the GENERIC "retire a lifecycle
3
+ * (owner, actor, lifecycleUid)" operation, served by the auth plane itself — the despawn→retirement
4
+ * trigger's serve side, and the D5 split's other half (retirement is the AUTH plane's operation; it
5
+ * never rides the DELIVERY daemon's rail).
6
+ *
7
+ * THE RAIL: `ep.one.auth.retire-lifecycle.handle.<tO>.<tA>.<tUid>.<cO>.<cA>.<cUid>.<nonce>`.
8
+ * It used to serve on `ctl.auth-admin.<owner>.<actor>`. §13.11 retires the v0 `ctl` rail in full
9
+ * ("MUST NOT be handled") and grants it no scoping language, so the rows serving this rail there
10
+ * were defects — new normative rows written onto a deleted rail — and #350 ruled them rewritten
11
+ * onto the v0.4 endpoint surface rather than carved out of the cut.
12
+ *
13
+ * AUTHZ (RAIL-TIME, fresh per request, never mint-only):
14
+ * - Caller attribution is SUBJECT-derived and broker-enforced: the caller triple
15
+ * `<cO>.<cA>.<cUid>` rides the subject, and only a credential minted with that triple's
16
+ * request-publish grant can reach it (the `retirement-requester` profile).
17
+ * - The SERVE-ISSUANCE GATE check: the caller names a gate row by (serveEndpoint,
18
+ * serveInstanceId) and declares its epoch. The row must exist, not be retired, and carry the
19
+ * declared epoch — a superseded predecessor (a restart advanced the epoch) is refused.
20
+ * - THE PRINCIPAL CROSS-CHECK: the named row's `principal` must equal the SUBJECT-derived caller
21
+ * principal. This is what makes the two body fields safe to keep: they only SELECT a row, they
22
+ * no longer authorize, so naming a foreign row buys a refusal rather than an authorization.
23
+ * Before #350 the two-token `ctl` subject could not express the caller's identity beyond an
24
+ * alias, and the rail accepted ANY registered instance's gate — a holder of the manager
25
+ * principal could be authorized by a row belonging to someone else.
26
+ * - This is ALIAS-LEVEL binding, not incarnation-level: the gate row is keyed by the PERSISTED
27
+ * `instanceId` (stable across restarts) and its schema is closed with no uid field, while the
28
+ * caller triple's `<cUid>` is per-process. A same-principal zombie predecessor that learns the
29
+ * current epoch value still passes both checks. Binding the publishing incarnation needs a
30
+ * gate-row schema change — deliberately out of this cut, and its own decision.
31
+ * - The GENERIC surface never names a caller class (a manager despawn is ONE caller); the gate
32
+ * check is this service's serve-time authz, not subject grammar.
33
+ *
34
+ * IDEMPOTENCE (the confirmed four-outcome table, surfaced as OPERATOR results): already-retired
35
+ * (uid match) → success; a frozen gate under the SAME opId → the barrier resumes it; a FOREIGN
36
+ * operation holding the gate → refuse naming the operation; a different current uid → refuse
37
+ * (stale trigger). The requester sends a STABLE opId across retries, so an epCall retry never
38
+ * mints a second operation.
39
+ *
40
+ * UX (the piece-3 faces): every refusal is WHAT/WHY/NEXT in operator vocabulary — each authz
41
+ * refusal states the despawn was a FULL NO-OP (the target is unchanged and still running,
42
+ * nothing was applied) with `cotal supervise` → retry as the NEXT; the vocabulary bridge
43
+ * ("despawn started this agent's retirement") lives at the CLI surface that renders these.
44
+ *
45
+ * SEAL COMPOSITION (critic's three checks): the listener holds NO scanner/plane authority — the
46
+ * retirement runs through the injected {@link RetirementDeps}, whose drain rides the plane's ONE
47
+ * sealed records scanner exactly like the boot resume; the gate read is a leader read, no
48
+ * consumer-create anywhere; the requester credential is request + reply-inbox ONLY.
49
+ */
1
50
  import { Kvm } from "@nats-io/kv";
2
- import { AUTH_ENDPOINT, EP_CMD_RETIRE_LIFECYCLE, EpEnvelopeError, assertLifecycleToken, deriveReplySubject, endpointToken, epAuthBucket, epClassQueueGroup, epResponderReplyPattern, assertCommandToken, spacePrefix, mintLifecycleUid, managedRetirementOpId, parseEpSubject, principalKey, retirementFrontierStreams, serveIssuanceGateKv, } from "@cotal-ai/core";
51
+ import { AUTH_ENDPOINT, EP_CMD_RETIRE_LIFECYCLE, EpEnvelopeError, epAuthBucket, epServeGrantRows, managedRetirementOpId, principalKey, retirementFrontierStreams, serveEndpoint, serveIssuanceGateKv, } from "@cotal-ai/core";
52
+ import { authCommandDefs } from "./auth-service-contract.js";
3
53
  import { openAuthorityClient } from "./authority-client.js";
4
54
  import { runAgentRetirementBarrier } from "./retirement-barrier.js";
5
55
  import { observeGate, readLifecycleHeadForOperation } from "./lifecycle-registry.js";
6
- const enc = new TextEncoder();
7
- const dec = new TextDecoder();
8
- /** The auth endpoint's one class rail, per-command (never a cross-command `>`): the grant and the
9
- * runtime subscription are built from THIS, so a widened subscription cannot outrun its grant. */
10
- function authClassRail(space) {
11
- return `${spacePrefix(space)}.ep.one.${endpointToken(AUTH_ENDPOINT)}.${assertCommandToken(EP_CMD_RETIRE_LIFECYCLE)}.>`;
12
- }
13
56
  /** The LISTENER profile (SPEC 13.9 "Auth endpoint rail" row): serve + bounded replies on the auth
14
57
  * endpoint's class rail, plus the ONE leader-served gate read the authz check performs.
15
58
  * No store writes, no consumer authority, no scanner reach. */
16
59
  export function authAdminListenerGrants(space, connId, responder) {
60
+ // The generic serve rows for this instance/epoch (reply plane, events, timer schedule, record
61
+ // writes on publish; the class/all/inst rails plus the derived `describe` and the epoch-pinned
62
+ // timer fire row on subscribe) — the SAME assembly `serveEndpoint` callers use, replacing the
63
+ // hand-built reply-pattern/class-rail rows above (M3, #399).
64
+ const serveRows = epServeGrantRows(space, {
65
+ endpoint: AUTH_ENDPOINT,
66
+ instanceId: responder.instanceId,
67
+ epoch: responder.epoch,
68
+ ephemeralCommands: [EP_CMD_RETIRE_LIFECYCLE],
69
+ });
17
70
  return {
18
71
  publish: [
19
- // REPLIES ONLY, and on the REPLY PLANE — which is a stronger statement than the `ctl` rail
20
- // could make. There, request and reply shared one subtree, so the grant had to carve replies
21
- // out of it by shape (`*.*.reply.>`) to stop a compromised listener self-publishing a request
22
- // as the lease holder and passing its own subject-derived check (self-forge). Here the planes
23
- // are DISJOINT: `ep.reply.…` cannot express a request subject at all, so the self-forge is
24
- // closed by the grammar rather than by a pattern. The instance triple and epoch are pinned;
25
- // only the caller suffixes span (addressing is confined by nonce possession, §13.2).
26
- epResponderReplyPattern(space, AUTH_ENDPOINT, responder.instanceId, responder.epoch),
72
+ ...serveRows.pub,
27
73
  "$JS.API.INFO",
28
74
  // The ONE leader-served read the authz check performs: the serve-issuance GATE, a point-get
29
75
  // of `epgate.<endpoint>.<instanceId>` proving the requesting manager instance's serve grant
@@ -31,52 +77,7 @@ export function authAdminListenerGrants(space, connId, responder) {
31
77
  // authority, no store writes.
32
78
  `$JS.API.STREAM.MSG.GET.KV_${epAuthBucket(space)}`,
33
79
  ],
34
- // The class rail, QUEUE-QUALIFIED and per-command (§13.9, `endpoint-grants.ts:293-300`): the
35
- // NATS `"<subject> <queue>"` grant form. A PLAIN subject row would let this credential
36
- // plain-subscribe the class rail and observe EVERY request's nonce — the property the queue
37
- // qualification exists to protect. The runtime's queue subscription is not a substitute: it
38
- // constrains what this process does, not what the credential permits.
39
- subscribe: [`${authClassRail(space)} ${epClassQueueGroup(AUTH_ENDPOINT)}`, `_INBOX_${connId}.>`],
40
- };
41
- }
42
- const RETIRE_ARG_KEYS = ["opId", "serveEndpoint", "serveInstanceId", "serveEpoch"];
43
- /** The request id a reply MUST echo. This is the MINIMAL correctness guard from the full
44
- * `EndpointRequest`/`EndpointReply` envelope, which this rail does NOT yet carry (named residual:
45
- * the rail moved to `ep` SUBJECTS while still exchanging the ctl-era `{op,args}` / `{ok,data,error}`
46
- * bodies, and SPEC 1421 states those envelopes are DELETED). Without the echo, a caller binding a
47
- * reply on (endpoint, nonce) alone can accept a malformed or WRONG-ID `{ok:true}` and clear a
48
- * retirement hold on it. The full envelope migration is its own cut; this edge is not deferrable. */
49
- function parseRequestId(raw) {
50
- if (typeof raw !== "string" || !/^[A-Za-z0-9_-]{1,64}$/.test(raw))
51
- throw new EpEnvelopeError("failed-precondition", `the request requires an "id" ([A-Za-z0-9_-]{1,64}); the reply echoes it so a caller cannot accept another request's answer`);
52
- return raw;
53
- }
54
- function parseRetireArgs(raw) {
55
- const shape = "{ opId, serveEndpoint, serveInstanceId, serveEpoch }";
56
- if (raw === null || typeof raw !== "object")
57
- throw new EpEnvelopeError("failed-precondition", `retireLifecycle requires args ${shape}`);
58
- const a = raw;
59
- // The TARGET (owner, actor, lifecycleUid) is no longer an argument: `handle` mode carries it in
60
- // the subject, broker-enforced and grant-pinned, so the handler reads it from there. Sending it
61
- // in the body is now a CLOSED-SHAPE violation rather than a redundancy to reconcile — which
62
- // removes the whole body-vs-subject mismatch class instead of managing it.
63
- for (const k of Object.keys(a))
64
- if (!RETIRE_ARG_KEYS.includes(k))
65
- throw new EpEnvelopeError("failed-precondition", `retireLifecycle args carry the unknown field "${k}" (closed shape; the target rides the SUBJECT)`);
66
- if (typeof a.opId !== "string" ||
67
- typeof a.serveEndpoint !== "string" || typeof a.serveInstanceId !== "string" ||
68
- typeof a.serveEpoch !== "number" || !Number.isInteger(a.serveEpoch) || a.serveEpoch < 0)
69
- throw new EpEnvelopeError("failed-precondition", `retireLifecycle requires args ${shape} (serveEpoch a non-negative integer)`);
70
- return {
71
- // opId is OPERATION IDENTITY, not an authz input: the terminal rail independently derives it
72
- // from the broker-pinned lifecycle target below. This parse only enforces the token grammar.
73
- opId: assertLifecycleToken(a.opId, "opId"),
74
- // LOOKUP COORDINATES, not authz inputs: they select WHICH gate row to read. The row they
75
- // select must then survive the principal cross-check below, so naming a foreign row buys a
76
- // refusal, never an authorization.
77
- serveEndpoint: endpointToken(a.serveEndpoint),
78
- serveInstanceId: assertLifecycleToken(a.serveInstanceId, "serveInstanceId"),
79
- serveEpoch: a.serveEpoch,
80
+ subscribe: [...serveRows.sub, `_INBOX_${connId}.>`],
80
81
  };
81
82
  }
82
83
  /** The terminal rail's operation-identity authorization. The requester credential pins the target
@@ -106,13 +107,11 @@ export function joinOrStartRetirement(flights, reg, op, retirement) {
106
107
  */
107
108
  export async function openAuthAdminListener(opts) {
108
109
  const { space, log } = opts;
109
- // The auth plane's responder identity. The plane is SINGLE per space by construction (§13.13:
110
- // at most one authority plane holds the sealed scanners, by a broker-visible claim), so the
111
- // instance id is per-process and the epoch is fixed: there is no successor to fence and no
112
- // registration whose epoch could advance beneath us. It exists because the reply plane pins the
113
- // responder triple in the grant; callers read replies through a filter that wildcards these
114
- // positions (`ep.reply.*.*.*.<cO>.<cA>.<cUid>.*`), so they never need to learn it.
115
- const responder = { instanceId: mintLifecycleUid(), epoch: 0 };
110
+ // The auth plane's responder identity is the #399 M2-registered instance/epoch (the SAME triple
111
+ // `registerServiceInstance` fenced and `authorizeServeGrant` minted a serve grant for). The reply
112
+ // plane pins this triple in the grant; callers read replies through a filter that wildcards the
113
+ // caller-suffix positions (`ep.reply.*.*.*.<cO>.<cA>.<cUid>.*`), so they never need to learn it.
114
+ const responder = { instanceId: opts.instanceId, epoch: opts.epoch };
116
115
  const client = await openAuthorityClient({
117
116
  server: opts.server, space, dataAccount: opts.dataAccount,
118
117
  label: `cotal:auth-admin:${space}`,
@@ -129,56 +128,6 @@ export async function openAuthAdminListener(opts) {
129
128
  await client.close();
130
129
  throw e;
131
130
  }
132
- const sub = client.nc.subscribe(authClassRail(space), {
133
- queue: epClassQueueGroup(AUTH_ENDPOINT),
134
- callback: (err, msg) => {
135
- if (err)
136
- return;
137
- void (async () => {
138
- // The reply target is DERIVED from the parsed request, never taken from the wire. On the
139
- // `ctl` rail this was a guard: the listener held a subtree-wide reply grant, so a
140
- // caller-selected foreign reply target had to be refused by inspecting `msg.reply`. Here
141
- // there is no argument through which a payload-supplied reply target could arrive — the
142
- // guard became structural, so the check it replaced cannot be forgotten.
143
- const parsed = parseEpSubject(msg.subject);
144
- if (parsed === null || parsed.plane !== "request") {
145
- // null = MUST NOT handle (§13.2). Never a reply: an unparseable subject has no
146
- // derivable reply target, and answering one would be the confused deputy itself.
147
- log(`auth-admin: dropped an unparseable request subject ${msg.subject}`);
148
- return;
149
- }
150
- const request = parsed;
151
- // The echoed id is stamped HERE, outside the handler, so EVERY reply carries it - including
152
- // the thrown-error path. A reply the caller cannot bind to its own request is one it must
153
- // ignore, so an unstamped error reply would silently become a timeout instead of a refusal.
154
- let echoId;
155
- try {
156
- echoId = parseRequestId(JSON.parse(dec.decode(msg.data)).id);
157
- }
158
- catch {
159
- echoId = undefined;
160
- }
161
- let reply;
162
- try {
163
- reply = await handle(request, msg.data);
164
- }
165
- catch (e) {
166
- reply = { ok: false, error: e instanceof Error ? e.message : String(e) };
167
- }
168
- // A request with no usable id gets an unbindable reply BY CONSTRUCTION: the caller requires
169
- // the echo, so it will refuse this answer rather than accept an unattributable one.
170
- if (echoId !== undefined)
171
- reply.id = echoId;
172
- const target = deriveReplySubject(space, request, responder);
173
- try {
174
- client.nc.publish(target, enc.encode(JSON.stringify(reply)));
175
- }
176
- catch (e) {
177
- log(`auth-admin: reply publish failed on ${target}: ${e instanceof Error ? e.message : String(e)}`);
178
- }
179
- })();
180
- },
181
- });
182
131
  // SINGLE-FLIGHT the barrier EXECUTION per opId (audit #1): each request still runs its OWN fresh
183
132
  // lease re-check + idempotence, but concurrent same-opId requests (a manager nudge + a retry, or a boot
184
133
  // resume racing the rail) share ONE runAgentRetirementBarrier, so the barrier body never dual-executes
@@ -190,103 +139,103 @@ export async function openAuthAdminListener(opts) {
190
139
  // Owned by the plane and shared with the loopback managed-retire door, so the rail and the door
191
140
  // never run two barrier executions of one opId in this process (#2070).
192
141
  const barrierFlight = opts.barrierFlight;
193
- const handle = async (request, body) => {
194
- if (request.command !== EP_CMD_RETIRE_LIFECYCLE)
195
- return { ok: false, error: `command "${request.command}" not supported on the auth endpoint` };
196
- // The TARGET comes from the subject (`handle` mode, arity 3) — broker-enforced and
197
- // grant-pinned, so it is not a claim the caller can vary independently of what it may publish.
198
- if (request.target === null || request.target.mode !== "handle")
199
- return { ok: false, error: `retire-lifecycle requires a handle target (<owner>.<actor>.<lifecycleUid>) in the subject` };
200
- const target = { owner: request.target.tOwner, actor: request.target.tActor, lifecycleUid: request.target.tUid };
201
- // The CALLER principal likewise comes from the subject, and is now an AUTHZ INPUT (the
202
- // cross-check below), not just the audit line it was on the `ctl` rail.
203
- const requester = principalKey(request.caller.owner, request.caller.actor).key;
204
- let req;
205
- try {
206
- req = JSON.parse(dec.decode(body));
207
- }
208
- catch {
209
- return { ok: false, error: "auth-admin: the request body is not JSON" };
210
- }
211
- if (req.op !== "retireLifecycle")
212
- return { ok: false, error: `op "${String(req.op)}" not supported on the auth admin service` };
213
- const args = parseRetireArgs(req.args);
214
- // TARGET comes from the broker-authorized subject. Bind the body's opId to it BEFORE the serve
215
- // gate, lifecycle head, intent, or barrier is touched, so mint-time validation is not the only
216
- // fence and the same target can never start a second durable terminal operation.
217
- authorizeRetirementOperation(target.lifecycleUid, args.opId);
218
- // THE RAIL-TIME REGISTRATION RE-CHECK (fresh, leader-served, fail-closed) — P2 item 3 (3b-3):
219
- // the requesting manager instance's SERVE GRANT must be current. Read the serve-issuance gate
220
- // (registration-record-derived, REPLACING the old name-derived manager-lease holder check): the
221
- // requester declares its (serveEndpoint, serveInstanceId, serveEpoch); an absent/retired gate means
222
- // no registered instance, and a gate whose current processEpoch moved past the declared one means
223
- // the requester was SUPERSEDED (a deposed predecessor after a restart) — refused as a full no-op.
224
- // The row this NAMES must also BELONG to the subject-derived caller principal (the cross-check
225
- // below). Before #350 it did not have to: every instance of one space shares the manager
226
- // principal, and the two-token `ctl` subject could not express the caller beyond that alias, so
227
- // any current instance's gate authorized. That is no longer true, and the coordinates above no
228
- // longer authorize — they only select which row to read.
229
- // ALIAS-LEVEL, not incarnation-level: a DIFFERENT INSTANCE OF THE SAME PRINCIPAL still passes
230
- // (the gate is keyed by the persisted instanceId and its row carries no lifecycle uid). What is
231
- // refused is a row belonging to a DIFFERENT PRINCIPAL.
232
- let serveGate;
233
- try {
234
- serveGate = await serveIssuanceGateKv(epAuthKv, space, { endpoint: args.serveEndpoint, instanceId: args.serveInstanceId }).observe();
235
- }
236
- catch (e) {
237
- return { ok: false, error: `the retirement request cannot be authorized right now: the manager serve-issuance gate could not be read (${e instanceof Error ? e.message : String(e)}). Nothing was applied - the agent is unchanged. NEXT: check the broker and retry the despawn.` };
238
- }
239
- if (serveGate === null || serveGate.state === "retired")
240
- return { ok: false, error: `no manager instance currently holds a serve registration for "${space}" (instance ${args.serveInstanceId} is ${serveGate === null ? "unregistered" : "retired"}), so nothing may retire agents. The despawn was a FULL no-op - the agent is unchanged and still running. NEXT: start or recover the manager (\`cotal supervise\`), then retry the despawn.` };
241
- // THE PRINCIPAL CROSS-CHECK (#350). The two serve coordinates above only SELECTED this row;
242
- // they do not authorize. The row must belong to the SUBJECT-derived caller principal — which
243
- // the broker enforced when it admitted the publish. Without this, naming any currently
244
- // registered instance's row authorizes the caller, which is what the `ctl` rail did: its
245
- // two-token subject could not express the caller beyond an alias, so there was nothing to
246
- // compare the row against.
247
- // ALIAS-LEVEL, not incarnation-level: the gate is keyed by the PERSISTED instanceId and its
248
- // schema carries no uid, while the caller triple's uid is per-process. A same-principal zombie
249
- // predecessor holding the current epoch value still passes. Closing that needs a gate-row
250
- // schema change; it is deliberately not in this cut.
251
- if (serveGate.principal !== requester)
252
- return { ok: false, error: `the retirement request was REFUSED: the serve registration named (${args.serveEndpoint}/${args.serveInstanceId}) belongs to ${serveGate.principal}, not to the requesting principal ${requester}. A caller may only be authorized by its OWN serve registration. The despawn was a FULL no-op - the agent is unchanged and still running. NEXT: name your OWN principal's serve registration (any current instance of ${requester} will do), or call as the principal that owns this one.` };
253
- if (serveGate.processEpoch !== args.serveEpoch)
254
- return { ok: false, error: `the requesting manager instance ${args.serveInstanceId} was SUPERSEDED (it registered at epoch ${args.serveEpoch}, the current serve grant is epoch ${serveGate.processEpoch}), so this despawn was REFUSED as a FULL no-op - the agent is unchanged and still running, nothing was torn down. NEXT: recover the manager (\`cotal supervise\`), then retry the despawn under the current serving instance.` };
255
- // IDEMPOTENCE (the four-outcome table, in operator vocabulary).
256
- const head = await readLifecycleHeadForOperation(opts.reg, target.owner, target.actor);
257
- if (head === undefined)
258
- return { ok: false, error: `no lifecycle exists for "${target.owner}/${target.actor}"; there is nothing to retire.` };
259
- if (head.mapping.state === "retired" && head.mapping.lifecycleUid === target.lifecycleUid)
260
- return { ok: true, data: { alreadyRetired: true, lifecycleUid: target.lifecycleUid } };
261
- if (head.mapping.lifecycleUid !== target.lifecycleUid)
262
- return { ok: false, error: `the despawn names a stale incarnation of "${target.owner}/${target.actor}" (current is ${head.mapping.lifecycleUid}); nothing was retired. NEXT: refresh the agent list and retry against the current incarnation.` };
263
- const gate = await observeGate(opts.reg, target.lifecycleUid);
264
- if (gate !== undefined && gate.row.state === "frozen" && gate.row.op !== undefined && gate.row.op.opId !== args.opId)
265
- return { ok: false, error: `another operation (${gate.row.op.kind} ${gate.row.op.opId}) already holds "${target.owner}/${target.actor}"; this despawn did not start a second one. NEXT: wait for that operation to finish (or its resume on the next auth-service boot), then retry.` };
266
- // EXECUTE (create-or-resume: the barrier's own freeze CAS + durable intent make the same
267
- // opId resumable and a re-request idempotent). The drain, cleaner, and repair credentials
268
- // all come from the plane's reviewed deps - this listener holds none of those rights.
269
- const existing = barrierFlight.get(args.opId);
270
- // A despawn cannot know the target's pool work, and the barrier never takes a pool hint: it
271
- // DISCOVERS the real (endpoint, pools) cleaner inventory from the target's own accepted pool
272
- // obligations (#F). Discovery is never a gap - the barrier never closes a frontier over
273
- // un-cleaned accepted pool work (SPEC 13.1/13.9).
274
- const flight = joinOrStartRetirement(barrierFlight, opts.reg, {
275
- owner: target.owner, actor: target.actor, lifecycleUid: target.lifecycleUid, opId: args.opId,
276
- frontierStreams: retirementFrontierStreams(space),
277
- }, opts.retirement);
278
- if (flight === undefined)
279
- return { ok: false, error: `operation id ${args.opId} is already in flight for a different lifecycle (${existing?.owner}/${existing?.actor} ${existing?.lifecycleUid}); this despawn of "${target.owner}/${target.actor}" (${target.lifecycleUid}) was a FULL no-op - nothing was retired and it is still running. NEXT: retry the despawn (the manager derives a distinct operation id per lifecycle).` };
280
- const result = await flight;
281
- log(`auth-admin: retired ${target.owner}/${target.actor} (${target.lifecycleUid}) by despawn request from ${requester} (op ${args.opId})`);
282
- return { ok: true, data: { retired: true, lifecycleUid: target.lifecycleUid, opId: result.opId, evictedPrincipals: result.evictedPrincipals } };
142
+ // The FRESH target resolver (§13.3/§13.9) for the `exact`-mode `retire-lifecycle` target: the
143
+ // lifecycle registry's own leader-served mapping read is the current-mapping authority.
144
+ const resolveTarget = async (t) => {
145
+ const head = await readLifecycleHeadForOperation(opts.reg, t.owner, t.actor);
146
+ return head === undefined ? undefined : { lifecycleUid: head.mapping.lifecycleUid, mappingRevision: head.revision };
283
147
  };
284
- return {
285
- close: async () => {
148
+ const handlers = {
149
+ retireLifecycle: async (ctx) => {
150
+ // The TARGET comes from the subject (`exact` mode, arity 3) — broker-enforced and
151
+ // grant-pinned, not a claim the caller can vary independently of what it may publish.
152
+ const t = ctx.subject.target;
153
+ if (t === null || t.mode !== "exact")
154
+ throw new EpEnvelopeError("failed-precondition", `retire-lifecycle requires an exact target (<owner>.<actor>.<lifecycleUid>) in the subject`);
155
+ const target = { owner: t.tOwner, actor: t.tActor, lifecycleUid: t.tUid };
156
+ // The CALLER principal likewise comes from the subject, and is an AUTHZ INPUT (the
157
+ // cross-check below), not just an audit line.
158
+ const requester = principalKey(ctx.subject.caller.owner, ctx.subject.caller.actor).key;
159
+ const args = ctx.request.args;
160
+ // TARGET comes from the broker-authorized subject. Bind the body's opId to it BEFORE the
161
+ // serve gate, lifecycle head, intent, or barrier is touched, so mint-time validation is not
162
+ // the only fence and the same target can never start a second durable terminal operation.
163
+ authorizeRetirementOperation(target.lifecycleUid, args.opId);
164
+ // THE RAIL-TIME REGISTRATION RE-CHECK (fresh, leader-served, fail-closed) — P2 item 3 (3b-3):
165
+ // the requesting manager instance's SERVE GRANT must be current. Read the serve-issuance gate
166
+ // (registration-record-derived, REPLACING the old name-derived manager-lease holder check): the
167
+ // requester declares its (serveEndpoint, serveInstanceId, serveEpoch); an absent/retired gate means
168
+ // no registered instance, and a gate whose current processEpoch moved past the declared one means
169
+ // the requester was SUPERSEDED (a deposed predecessor after a restart) — refused as a full no-op.
170
+ // The row this NAMES must also BELONG to the subject-derived caller principal (the cross-check
171
+ // below). Before #350 it did not have to: every instance of one space shares the manager
172
+ // principal, and the two-token `ctl` subject could not express the caller beyond that alias, so
173
+ // any current instance's gate authorized. That is no longer true, and the coordinates above no
174
+ // longer authorize — they only select which row to read.
175
+ // ALIAS-LEVEL, not incarnation-level: a DIFFERENT INSTANCE OF THE SAME PRINCIPAL still passes
176
+ // (the gate is keyed by the persisted instanceId and its row carries no lifecycle uid). What is
177
+ // refused is a row belonging to a DIFFERENT PRINCIPAL.
178
+ let serveGate;
286
179
  try {
287
- sub.unsubscribe();
180
+ serveGate = await serveIssuanceGateKv(epAuthKv, space, { endpoint: args.serveEndpoint, instanceId: args.serveInstanceId }).observe();
181
+ }
182
+ catch (e) {
183
+ throw new EpEnvelopeError("unavailable", `the retirement request cannot be authorized right now: the manager serve-issuance gate could not be read (${e instanceof Error ? e.message : String(e)}). Nothing was applied - the agent is unchanged. NEXT: check the broker and retry the despawn.`);
288
184
  }
289
- catch { /* connection already down */ }
185
+ if (serveGate === null || serveGate.state === "retired")
186
+ throw new EpEnvelopeError("failed-precondition", `no manager instance currently holds a serve registration for "${space}" (instance ${args.serveInstanceId} is ${serveGate === null ? "unregistered" : "retired"}), so nothing may retire agents. The despawn was a FULL no-op - the agent is unchanged and still running. NEXT: start or recover the manager (\`cotal supervise\`), then retry the despawn.`);
187
+ // THE PRINCIPAL CROSS-CHECK (#350). The two serve coordinates above only SELECTED this row;
188
+ // they do not authorize. The row must belong to the SUBJECT-derived caller principal — which
189
+ // the broker enforced when it admitted the publish. Without this, naming any currently
190
+ // registered instance's row authorizes the caller, which is what the `ctl` rail did: its
191
+ // two-token subject could not express the caller beyond an alias, so there was nothing to
192
+ // compare the row against.
193
+ // ALIAS-LEVEL, not incarnation-level: the gate is keyed by the PERSISTED instanceId and its
194
+ // schema carries no uid, while the caller triple's uid is per-process. A same-principal zombie
195
+ // predecessor holding the current epoch value still passes. Closing that needs a gate-row
196
+ // schema change; it is deliberately not in this cut.
197
+ if (serveGate.principal !== requester)
198
+ throw new EpEnvelopeError("permission-denied", `the retirement request was REFUSED: the serve registration named (${args.serveEndpoint}/${args.serveInstanceId}) belongs to ${serveGate.principal}, not to the requesting principal ${requester}. A caller may only be authorized by its OWN serve registration. The despawn was a FULL no-op - the agent is unchanged and still running. NEXT: name your OWN principal's serve registration (any current instance of ${requester} will do), or call as the principal that owns this one.`);
199
+ if (serveGate.processEpoch !== args.serveEpoch)
200
+ throw new EpEnvelopeError("expired", `the requesting manager instance ${args.serveInstanceId} was SUPERSEDED (it registered at epoch ${args.serveEpoch}, the current serve grant is epoch ${serveGate.processEpoch}), so this despawn was REFUSED as a FULL no-op - the agent is unchanged and still running, nothing was torn down. NEXT: recover the manager (\`cotal supervise\`), then retry the despawn under the current serving instance.`);
201
+ // IDEMPOTENCE (the four-outcome table, in operator vocabulary).
202
+ const head = await readLifecycleHeadForOperation(opts.reg, target.owner, target.actor);
203
+ if (head === undefined)
204
+ throw new EpEnvelopeError("failed-precondition", `no lifecycle exists for "${target.owner}/${target.actor}"; there is nothing to retire.`);
205
+ if (head.mapping.state === "retired" && head.mapping.lifecycleUid === target.lifecycleUid)
206
+ return { retired: true, lifecycleUid: target.lifecycleUid, opId: args.opId, evictedPrincipals: [] };
207
+ if (head.mapping.lifecycleUid !== target.lifecycleUid)
208
+ throw new EpEnvelopeError("expired", `the despawn names a stale incarnation of "${target.owner}/${target.actor}" (current is ${head.mapping.lifecycleUid}); nothing was retired. NEXT: refresh the agent list and retry against the current incarnation.`);
209
+ const gate = await observeGate(opts.reg, target.lifecycleUid);
210
+ if (gate !== undefined && gate.row.state === "frozen" && gate.row.op !== undefined && gate.row.op.opId !== args.opId)
211
+ throw new EpEnvelopeError("conflict", `another operation (${gate.row.op.kind} ${gate.row.op.opId}) already holds "${target.owner}/${target.actor}"; this despawn did not start a second one. NEXT: wait for that operation to finish (or its resume on the next auth-service boot), then retry.`);
212
+ // EXECUTE (create-or-resume: the barrier's own freeze CAS + durable intent make the same
213
+ // opId resumable and a re-request idempotent). The drain, cleaner, and repair credentials
214
+ // all come from the plane's reviewed deps - this listener holds none of those rights.
215
+ const existing = barrierFlight.get(args.opId);
216
+ // A despawn cannot know the target's pool work, and the barrier never takes a pool hint: it
217
+ // DISCOVERS the real (endpoint, pools) cleaner inventory from the target's own accepted pool
218
+ // obligations (#F). Discovery is never a gap - the barrier never closes a frontier over
219
+ // un-cleaned accepted pool work (SPEC 13.1/13.9).
220
+ const flight = joinOrStartRetirement(barrierFlight, opts.reg, {
221
+ owner: target.owner, actor: target.actor, lifecycleUid: target.lifecycleUid, opId: args.opId,
222
+ frontierStreams: retirementFrontierStreams(space),
223
+ }, opts.retirement);
224
+ if (flight === undefined)
225
+ throw new EpEnvelopeError("conflict", `operation id ${args.opId} is already in flight for a different lifecycle (${existing?.owner}/${existing?.actor} ${existing?.lifecycleUid}); this despawn of "${target.owner}/${target.actor}" (${target.lifecycleUid}) was a FULL no-op - nothing was retired and it is still running. NEXT: retry the despawn (the manager derives a distinct operation id per lifecycle).`);
226
+ const result = await flight;
227
+ log(`auth-admin: retired ${target.owner}/${target.actor} (${target.lifecycleUid}) by despawn request from ${requester} (op ${args.opId})`);
228
+ return { retired: true, lifecycleUid: target.lifecycleUid, opId: result.opId, evictedPrincipals: result.evictedPrincipals };
229
+ },
230
+ };
231
+ // §13.9: the descriptor is PUBLIC. The broker grant on the request subject (who holds the
232
+ // caller triple's request-publish row, minted only by the `retirement-requester` profile) is the
233
+ // load-bearing authority tier; describe merely lists command names/schemas, which leaks nothing
234
+ // a holder of that grant does not already need to know to call successfully.
235
+ const handle = serveEndpoint(client.nc, space, opts.grant, authCommandDefs(handlers), { public: true }, { resolveTarget });
236
+ return {
237
+ close: async () => {
238
+ await handle.stop();
290
239
  await client.close();
291
240
  },
292
241
  };
@@ -1 +1 @@
1
- {"version":3,"file":"auth-admin.js","sourceRoot":"","sources":["../src/auth-admin.ts"],"names":[],"mappings":"AAkDA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,yBAAyB,EACzB,mBAAmB,GAEpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAwB,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,yBAAyB,EAAuB,MAAM,yBAAyB,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,6BAA6B,EAA0B,MAAM,yBAAyB,CAAC;AAE7G,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;AAC9B,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;AAE9B;mGACmG;AACnG,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC,WAAW,aAAa,CAAC,aAAa,CAAC,IAAI,kBAAkB,CAAC,uBAAuB,CAAC,IAAI,CAAC;AACzH,CAAC;AAED;;gEAEgE;AAChE,MAAM,UAAU,uBAAuB,CACrC,KAAa,EACb,MAAc,EACd,SAAgD;IAEhD,OAAO;QACL,OAAO,EAAE;YACP,2FAA2F;YAC3F,6FAA6F;YA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AAK,IAAI,EAAE;YAChB,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YACpB,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * The AUTH plane's v0.4 SERVICE CONTRACT (#399 M2): the §13.7 cluster document + compiled command
3
+ * contract for the `retire-lifecycle` op the auth plane serves on the `ep.*` rails. Shaped like
4
+ * `implementations/manager/src/manager-service-contract.ts` (the manager's own contract module):
5
+ * ONE `CommandRow`, its compiled input/output pair, and the cluster-document/artifact/command-def
6
+ * builders a `serveEndpoint` registration needs.
7
+ *
8
+ * This module is PURE DATA + schema (no broker, no barrier, no wire I/O): the registration and
9
+ * serve WIRING lives in the plane (`openAuthAuthorityPlane` / `openAuthAdminListener`).
10
+ */
11
+ import { type CompiledContract, type EpAuthzMode, type EpCommandDef, type EpServeContext } from "@cotal-ai/core";
12
+ /** The auth plane's endpoint NAME (matches `AUTH_ENDPOINT` in `@cotal-ai/core`). */
13
+ export declare const AUTH_SERVICE_ENDPOINT = "auth";
14
+ /** The auth cluster document's URN (§13.7 content-addressed authority). */
15
+ export declare const AUTH_CLUSTER_URN = "ai.cotal.auth";
16
+ /** Per-command compiled contract pairs, exported for CALLERS (mirrors `MANAGER_CONTRACTS`). Lazy:
17
+ * a pair compiles on its first access, so importing the module alone pays no Ajv compile. */
18
+ export declare const AUTH_CONTRACTS: Readonly<Record<string, {
19
+ input: CompiledContract;
20
+ output: CompiledContract;
21
+ }>>;
22
+ /** Every §13.7 contract artifact the auth plane PUBLISHES to the EPC store at registration: each
23
+ * DISTINCT schema root plus its single-member closure manifest. */
24
+ export declare function authContractArtifactValues(): unknown[];
25
+ /** The §13.7 cluster DOCUMENT: the content-addressed authority for the auth plane's served
26
+ * command surface. Revision 1: the single `retire-lifecycle` command. */
27
+ export declare function authClusterDocument(): {
28
+ urn: string;
29
+ revision: number;
30
+ attributes: unknown[];
31
+ events: unknown[];
32
+ commands: Array<{
33
+ name: string;
34
+ class: "ephemeral";
35
+ targeted: boolean;
36
+ modes?: EpAuthzMode[];
37
+ capability: string;
38
+ inputDigest: string;
39
+ outputDigest: string;
40
+ }>;
41
+ };
42
+ /** The two-digest §13.7 content addressing for the auth document (mirrors
43
+ * `managerClusterArtifacts`): both artifacts publish to the `epc` store at their own digest;
44
+ * `clusterDigests` in the service spec carries the closure digest. */
45
+ export declare function authClusterArtifacts(): {
46
+ document: ReturnType<typeof authClusterDocument>;
47
+ rootDigest: string;
48
+ manifest: {
49
+ v: 1;
50
+ root: string;
51
+ members: string[];
52
+ };
53
+ closureDigest: string;
54
+ };
55
+ /** The handler the auth plane supplies to back `retire-lifecycle`. Receives the serve CONTEXT
56
+ * (broker-authenticated subject shape beside the validated args/target); returns the command's
57
+ * output value (the compiled output contract validates it at the serve boundary). Kept as a
58
+ * narrow interface so the contract module stays broker-free. */
59
+ export interface AuthServiceHandlers {
60
+ retireLifecycle(ctx: EpServeContext): unknown | Promise<unknown>;
61
+ }
62
+ /** Build the `EpCommandDef[]` `serveEndpoint` consumes. */
63
+ export declare function authCommandDefs(handlers: AuthServiceHandlers): EpCommandDef[];
64
+ //# sourceMappingURL=auth-service-contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-service-contract.d.ts","sourceRoot":"","sources":["../src/auth-service-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAExB,oFAAoF;AACpF,eAAO,MAAM,qBAAqB,SAAS,CAAC;AAE5C,2EAA2E;AAC3E,eAAO,MAAM,gBAAgB,kBAAkB,CAAC;AAsEhD;8FAC8F;AAC9F,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,gBAAgB,CAAC;IAAC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