@cotal-ai/manager 0.170.0 → 0.171.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credential-renewal.js","sourceRoot":"","sources":["../src/credential-renewal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,SAAS,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,aAAa,EAAE,6BAA6B,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,0BAA0B,EAA0G,MAAM,gBAAgB,CAAC;AACtb,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,kBAAkB,EAAsB,MAAM,qBAAqB,CAAC;AAE5M,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAuB,MAAM,yBAAyB,CAAC;AAChG,OAAO,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAC3F,OAAO,EAAE,gCAAgC,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;;;kGAGkG;AAClG,MAAM,gCAAgC,GAAG,MAAM,CAAC;AAEhD;;;;;;;;;;;;;;;;mFAgBmF;AACnF,MAAM,UAAU,mBAAmB,CAAC,UAAkB;IACpD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,C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QAAQ,EAAE,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;gBACnI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;oBAAE,SAAS;gBAChC,MAAM,GAAG,iBAAiB,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;YACzD,CAAC;YAAC,MAAM,CAAC;gBACP,SAAS,CAAC,iFAAiF;YAC7F,CAAC;YACD,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC;YACxF,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS;gBAC5B,OAAO,CAAC,KAAK,CACX,qBAAqB,IAAI,YAAY,IAAI,yNAAyN,CACnQ,CAAC;iBACC,IAAI,MAAM,CAAC,KAAK,KAAK,aAAa;gBACrC,OAAO,CAAC,KAAK,CACX,qBAAqB,IAAI,YAAY,IAAI,qJAAqJ,CAC/L,CAAC;QACN,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,158 @@
1
+ import type { Manager } from "./manager.js";
2
+ import type { ActionContext, EpIssuanceGate, GoalRef, Identity } from "@cotal-ai/core";
3
+ import type { KV } from "@nats-io/kv";
4
+ import type { NatsConnection } from "@nats-io/transport-node";
5
+ /** What {@link GoalWriter} reads from the Manager. Every entry is read at use, so a field the Manager
6
+ * assigns after construction is always current, and a Manager method a test replaces is the one that runs. */
7
+ export interface GoalWriterDeps {
8
+ auth: () => Manager["auth"];
9
+ goalAcceptances: () => Manager["goalAcceptances"];
10
+ goalWriter: () => Manager["goalWriter"];
11
+ setGoalWriter: (value: Manager["goalWriter"]) => void;
12
+ goalWriterCreds: () => Manager["goalWriterCreds"];
13
+ setGoalWriterCreds: (value: Manager["goalWriterCreds"]) => void;
14
+ goalWriterIdentity: () => Manager["goalWriterIdentity"];
15
+ leaseStopping: () => Manager["leaseStopping"];
16
+ managerInstanceId: () => Manager["managerInstanceId"];
17
+ readinessTimeoutMs: () => Manager["readinessTimeoutMs"];
18
+ remoteAuthority: () => Manager["remoteAuthority"];
19
+ serviceServe: () => Manager["serviceServe"];
20
+ space: () => Manager["space"];
21
+ turnRelay: () => Manager["turnRelay"];
22
+ goalReconcileDone: () => Manager["goalReconcileDone"];
23
+ setGoalReconcileDone: (value: Manager["goalReconcileDone"]) => void;
24
+ adoptTurnGoal: (...args: Parameters<Manager["adoptTurnGoal"]>) => ReturnType<Manager["adoptTurnGoal"]>;
25
+ boundedReconnect: (...args: Parameters<Manager["boundedReconnect"]>) => ReturnType<Manager["boundedReconnect"]>;
26
+ dial: (...args: Parameters<Manager["dial"]>) => ReturnType<Manager["dial"]>;
27
+ noticeSeatTurns: (...args: Parameters<Manager["noticeSeatTurns"]>) => ReturnType<Manager["noticeSeatTurns"]>;
28
+ renewRemoteBeforeRedial: (...args: Parameters<Manager["renewRemoteBeforeRedial"]>) => ReturnType<Manager["renewRemoteBeforeRedial"]>;
29
+ retireConnection: (...args: Parameters<Manager["retireConnection"]>) => ReturnType<Manager["retireConnection"]>;
30
+ trackTransport: (...args: Parameters<Manager["trackTransport"]>) => ReturnType<Manager["trackTransport"]>;
31
+ withEndpointServeExecutor: <T>(fn: (kvs: {
32
+ recordsKv: KV;
33
+ authKv: KV;
34
+ nc: NatsConnection;
35
+ }) => Promise<T>) => Promise<T>;
36
+ }
37
+ /** The goal-writer's standing connection, its credential, and the goal index it reconciles at boot. */
38
+ export declare class GoalWriter {
39
+ private readonly deps;
40
+ constructor(deps: GoalWriterDeps);
41
+ private get auth();
42
+ private get goalAcceptances();
43
+ private get goalWriter();
44
+ private set goalWriter(value);
45
+ private get goalWriterCreds();
46
+ private set goalWriterCreds(value);
47
+ private get goalWriterIdentity();
48
+ private get leaseStopping();
49
+ private get managerInstanceId();
50
+ private get readinessTimeoutMs();
51
+ private get remoteAuthority();
52
+ private get serviceServe();
53
+ private get space();
54
+ private get turnRelay();
55
+ private get goalReconcileDone();
56
+ private set goalReconcileDone(value);
57
+ private adoptTurnGoal;
58
+ private boundedReconnect;
59
+ private dial;
60
+ private noticeSeatTurns;
61
+ private renewRemoteBeforeRedial;
62
+ private retireConnection;
63
+ private trackTransport;
64
+ private withEndpointServeExecutor;
65
+ /** Mint the standing `goal-writer` credential and STAGE it into this
66
+ * instance's §13.1 revocation family (`epcred.<e>.<iid>`), over the passed executor's `authKv`
67
+ * (the scoped `endpoint-serve-executor`, which holds the epcred write grant). The GRANT profile
68
+ * stays goal-writer-only (Q2, disjoint from the serve credential); only the FAMILY membership
69
+ * is shared, so the registration barrier's existing enumerate+revoke+evict catches the
70
+ * goal-writer on takeover/retire with NO barrier code change. Used both at registration (the run
71
+ * block's `authKv`) and at renewal (a fresh executor's), re-minting the SAME stable nkey with a
72
+ * fresh bounded exp: `mintCreds` stamps a random `issuance:` tag on `goal-writer` (`userTags`),
73
+ * so each issuance signs distinct bytes and stages a distinct ledger row (per-JWT `credentialId`
74
+ * digest) even within one second. */
75
+ mintAndStageGoalWriter(authKv: KV): Promise<string>;
76
+ /** #2073: dial the goal-writer's ONE standing connection and rebuild everything derived from it
77
+ * (the fence-resolving action context, the issuance-gate reader) — shared by the initial start
78
+ * and the closed-connection recovery ({@link onGoalWriterConnectionClosed}), so a redial never
79
+ * leaves the context bound to a dead socket. */
80
+ dialGoalWriter(gw: {
81
+ nc: NatsConnection;
82
+ ctx: ActionContext;
83
+ creds?: string;
84
+ identity: Identity;
85
+ gate?: EpIssuanceGate;
86
+ }): Promise<void>;
87
+ /** #2073: the goal-writer rail's closed-connection fault, the same bounded shape the serve rail
88
+ * uses ({@link onServeConnectionClosed}) through the same {@link boundedReconnect} helper:
89
+ * re-dial with the current credential (a transport blip needs nothing new), re-mint through the
90
+ * existing goal-writer renewal branch when the credential itself has expired, then re-attach.
91
+ * Unlike the serve rail this never exits the process on exhaustion (brief step 4: only the serve
92
+ * rail is the control plane the report lost) — it logs and leaves the credential to the next
93
+ * scheduled renewal pass. */
94
+ private onGoalWriterConnectionClosed;
95
+ /** Spawn-as-action: stand up the standing self-mediated goal-writer connection +
96
+ * ActionContext. Mode-dual, mirroring {@link registerManagerService}: an AUTH mesh uses the
97
+ * scoped `goal-writer` credential already minted + family-STAGED inside registration's run block
98
+ * ({@link mintAndStageGoalWriter} — DISJOINT grant from the serve cred, SHARED §13.1 revocation
99
+ * family); an OPEN mesh uses a bare connection (no credential system to mint from - the broker
100
+ * enforces nothing). The connection presents the CURRENT credential on every (re)connect (a
101
+ * renewal is adopted without reconnecting the whole endpoint); the ActionContext bonds its
102
+ * KV + JS + JSM to this one connection and space (SPEC 13.4), so a composition mixup cannot splice
103
+ * goal state across brokers. */
104
+ startGoalWriter(): Promise<void>;
105
+ /** Retire the goal-writer connection (best-effort, both exit paths). */
106
+ stopGoalWriter(): Promise<void>;
107
+ /** The boot reconcile: a fresh incarnation (a manager restart takes a NEW
108
+ * instanceId, so the in-memory acceptance map starts empty) inherits the endpoint's accepted-but-
109
+ * unterminal goals from any predecessor. The local signer enumerates with an ephemeral PROVISIONER.
110
+ * A remote manager calls the authenticated host-owned scan, which keeps the sealed consumer and its
111
+ * lifecycle authority on the host; the instance executor, goal-writer, and supervisor hold NO records
112
+ * consumer grant. Settle each orphan so an accepted goal is NEVER dropped across a restart. Open mesh:
113
+ * a bare connection (the broker enforces nothing). Runs ONCE at start, BEFORE spawn-as-action begins
114
+ * accepting (the `goalReconcileDone` gate), so it never races a live goal's acceptance. Never
115
+ * fatal — a reconcile failure is logged and the gate opens either way. */
116
+ reconcileGoalIndex(): Promise<void>;
117
+ /** Settle ONE inherited goal by evidence: no goal record (a crash between the index write and the
118
+ * goal-record create) leaves the pointer untouched (never settle a goal that was never accepted,
119
+ * and clearing it would race a live goal mid-creation); a TERMINAL goal clears the index
120
+ * (converged — the predecessor committed but died before clearing); a NON-TERMINAL goal settles
121
+ * `uncertain` (the accepting incarnation is gone, so the success signal will never reach us — the
122
+ * bounded readiness outcome the plan maps the window to). Within the readiness window it arms a
123
+ * bounded, unref'd timer to settle at the deadline (an early uncertain would steal a still-possible
124
+ * success the substrate guards against). */
125
+ private reconcileOneGoal;
126
+ /** Publish a goal PROGRESS event on the caller-scoped epe subtree, over the SERVE
127
+ * connection (which holds the `epe.<e>.<iid>.<epoch>.>` egress grant; the goal-writer deliberately
128
+ * does not). The terminal rides a final event `phase:"terminal"` (the caller follows epe to
129
+ * the terminal; the durable result fact + inspect/ps are the reconcile authority). A dropped event
130
+ * is non-fatal (the terminal is authoritative in the journal). */
131
+ emitGoalProgress(ref: GoalRef, epoch: number, event: Record<string, unknown>): void;
132
+ /** The own-gate currency belt: before the goal-writer commits a terminal fact, the manager reads
133
+ * its OWN issuance gate epoch and REFUSES the commit if superseded. This NARROWS the window; it
134
+ * is not the fence. Layer 1 below is closed by the sibling-mint fence; layers 2 and 3 are not
135
+ * closed by any planned slice and must not be described as temporary.
136
+ *
137
+ * THE RESIDUAL, STACKED:
138
+ * 1. SIBLING-MINT INJECTION. A §13.1 barrier's revoke/evict loop closes only over the family
139
+ * SNAPSHOT IT ENUMERATED, so a sibling mint that observes the gate and stages a ledger row
140
+ * WITHOUT the observe/open/commit fence can be staged and released AFTER that enumerate and
141
+ * never be revoked. This layer is closed exactly where BOTH sibling mint sites
142
+ * ({@link mintAndStageGoalWriter}, {@link mintAndStageSessionLedger}) route their stage
143
+ * through `commitSiblingIssuance` (the revision-pinned CAS that makes a losing mint release
144
+ * nothing), and open exactly where they do not — state the mechanism, never the branch.
145
+ * 2. THE BARRIER WINDOW. A gate FREEZE neither kills this connection nor advances the epoch,
146
+ * and this belt compares `processEpoch` alone, so it still PASSES from barrier start until
147
+ * the reopen. A ledger revoke marks a row; it does not re-check a live JWT mid-publish. The
148
+ * durable kill is the CLUSTER-VERIFIED EVICTION, so a deposed manager can INITIATE new
149
+ * terminal publishes from barrier start until eviction is verified — not merely finish bytes
150
+ * already on the wire. Successor EXISTENCE and corpse DEATH are different phases, so the
151
+ * barrier's ordering licenses no conclusion about when the corpse stops being able to write.
152
+ * 3. OPEN MESH. No credential family exists, so the revoke/evict loop is vacuous and this belt
153
+ * is COOPERATIVE only: a non-conformant process simply does not run it.
154
+ * The named follow-up that would close 2 and 3 is the gate-linearized commit (routing the
155
+ * terminal through the issuance gate's own CAS), deliberately deferred as substrate territory. */
156
+ assertGoalWriterEpochCurrent(epoch: number): Promise<void>;
157
+ }
158
+ //# sourceMappingURL=goal-writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"goal-writer.d.ts","sourceRoot":"","sources":["../src/goal-writer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAkB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAGvG,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D;+GAC+G;AAC/G,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5B,eAAe,EAAE,MAAM,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAClD,UAAU,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC;IACxC,aAAa,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IACtD,eAAe,EAAE,MAAM,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAClD,kBAAkB,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IAChE,kBAAkB,EAAE,MAAM,OAAO,CAAC,oBAAoB,CAAC,CAA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,IAAI;IACZ,OAAO,CAAC,eAAe;IACvB,OAAO,CAAC,uBAAuB;IAC/B,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,yBAAyB;IAEjC;;;;;;;;;0CASsC;IAChC,sBAAsB,CAAC,MAAM,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IA6BzD;;;qDAGiD;IAC3C,cAAc,CAClB,EAAE,EAAE;QAAE,EAAE,EAAE,cAAc,CAAC;QAAC,GAAG,EAAE,aAAa,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,QAAQ,CAAC;QAAC,IAAI,CAAC,EAAE,cAAc,CAAA;KAAE,GACxG,OAAO,CAAC,IAAI,CAAC;IAkChB;;;;;;kCAM8B;YAChB,4BAA4B;IAkB1C;;;;;;;;qCAQiC;IAC3B,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAUtC,wEAAwE;IAClE,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAMrC;;;;;;;;+EAQ2E;IACrE,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAkDzC;;;;;;;iDAO6C;YAC/B,gBAAgB;IA8B9B;;;;uEAImE;IACnE,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAYnF;;;;;;;;;;;;;;;;;;;;;;;uGAuBmG;IAC7F,4BAA4B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CASjE"}
@@ -0,0 +1,342 @@
1
+ import { goalKey } from "./turn-relay.js";
2
+ import { MANAGER_ENDPOINT } from "./manager-service-contract.js";
3
+ import { DEV_OWNER, EpEnvelopeError, GOAL_TERMINAL_STATES, actionContext, clearGoalIndex, commitSiblingIssuance, credentialIdOf, drainAndClose, ensureAuthorityStores, epAuthBucket, epeSubject, goalProgressTopic, inspectCredHealth, listGoalIndex, mintCreds, newIdentity, principalKey, readGoalSpec, readGoalStatus, recordsBucket, rejectionText, serveIssuanceGateKv, settleGoalUncertain, standaloneConnectOpts } from "@cotal-ai/core";
4
+ import { jetstreamManager } from "@nats-io/jetstream";
5
+ import { Kvm } from "@nats-io/kv";
6
+ /** The goal-writer's standing connection, its credential, and the goal index it reconciles at boot. */
7
+ export class GoalWriter {
8
+ deps;
9
+ constructor(deps) {
10
+ this.deps = deps;
11
+ }
12
+ // The Manager members these bodies read, under their Manager names. Each reads through its dep at
13
+ // use, so a field the Manager assigns later is current and a method a test replaces on the Manager
14
+ // is the one that runs.
15
+ get auth() { return this.deps.auth(); }
16
+ get goalAcceptances() { return this.deps.goalAcceptances(); }
17
+ get goalWriter() { return this.deps.goalWriter(); }
18
+ set goalWriter(value) { this.deps.setGoalWriter(value); }
19
+ get goalWriterCreds() { return this.deps.goalWriterCreds(); }
20
+ set goalWriterCreds(value) { this.deps.setGoalWriterCreds(value); }
21
+ get goalWriterIdentity() { return this.deps.goalWriterIdentity(); }
22
+ get leaseStopping() { return this.deps.leaseStopping(); }
23
+ get managerInstanceId() { return this.deps.managerInstanceId(); }
24
+ get readinessTimeoutMs() { return this.deps.readinessTimeoutMs(); }
25
+ get remoteAuthority() { return this.deps.remoteAuthority(); }
26
+ get serviceServe() { return this.deps.serviceServe(); }
27
+ get space() { return this.deps.space(); }
28
+ get turnRelay() { return this.deps.turnRelay(); }
29
+ get goalReconcileDone() { return this.deps.goalReconcileDone(); }
30
+ set goalReconcileDone(value) { this.deps.setGoalReconcileDone(value); }
31
+ adoptTurnGoal(...args) { return this.deps.adoptTurnGoal(...args); }
32
+ boundedReconnect(...args) { return this.deps.boundedReconnect(...args); }
33
+ dial(...args) { return this.deps.dial(...args); }
34
+ noticeSeatTurns(...args) { return this.deps.noticeSeatTurns(...args); }
35
+ renewRemoteBeforeRedial(...args) { return this.deps.renewRemoteBeforeRedial(...args); }
36
+ retireConnection(...args) { return this.deps.retireConnection(...args); }
37
+ trackTransport(...args) { return this.deps.trackTransport(...args); }
38
+ withEndpointServeExecutor(fn) { return this.deps.withEndpointServeExecutor(fn); }
39
+ /** Mint the standing `goal-writer` credential and STAGE it into this
40
+ * instance's §13.1 revocation family (`epcred.<e>.<iid>`), over the passed executor's `authKv`
41
+ * (the scoped `endpoint-serve-executor`, which holds the epcred write grant). The GRANT profile
42
+ * stays goal-writer-only (Q2, disjoint from the serve credential); only the FAMILY membership
43
+ * is shared, so the registration barrier's existing enumerate+revoke+evict catches the
44
+ * goal-writer on takeover/retire with NO barrier code change. Used both at registration (the run
45
+ * block's `authKv`) and at renewal (a fresh executor's), re-minting the SAME stable nkey with a
46
+ * fresh bounded exp: `mintCreds` stamps a random `issuance:` tag on `goal-writer` (`userTags`),
47
+ * so each issuance signs distinct bytes and stages a distinct ledger row (per-JWT `credentialId`
48
+ * digest) even within one second. */
49
+ async mintAndStageGoalWriter(authKv) {
50
+ const auth = this.auth;
51
+ const identity = this.goalWriterIdentity;
52
+ // The issuance gate + §13.1 revocation family are keyed by the REGISTRATION instanceId
53
+ // (the persisted logical id), NOT the per-process lifecycleUid — the barrier
54
+ // enumerates `epcred.<e>.<managerInstanceId>`, so the goal-writer must stage into that family.
55
+ const iid = this.managerInstanceId;
56
+ const creds = await mintCreds(auth, identity, "goal-writer", { goalWriter: { endpoint: MANAGER_ENDPOINT } });
57
+ const exp = inspectCredHealth(creds).exp;
58
+ if (exp === undefined)
59
+ throw new Error(`the goal-writer credential for ${MANAGER_ENDPOINT}/${iid} is unbounded; the §13.1 ledger row requires an expiry`);
60
+ const fence = serveIssuanceGateKv(authKv, this.space, { endpoint: MANAGER_ENDPOINT, instanceId: iid });
61
+ const observed = await fence.observe();
62
+ if (observed === null)
63
+ throw new Error(`the issuance gate for ${MANAGER_ENDPOINT}/${iid} vanished; the goal-writer cannot join its §13.1 revocation family`);
64
+ // The §13.1 open-and-commit fence, the SAME one the serve credential's own mint runs: a frozen
65
+ // gate refuses, and a gate that moved under us loses the CAS and revokes the staged row. Without
66
+ // it a barrier mid-takeover (already past its enumeration) would let this credential land
67
+ // ACTIVE in a family nothing revokes again.
68
+ await commitSiblingIssuance(fence, observed, {
69
+ credentialId: credentialIdOf(creds),
70
+ credentialKey: identity.id,
71
+ holderPrincipal: principalKey(DEV_OWNER, identity.id).key,
72
+ endpoint: MANAGER_ENDPOINT, lifecycleUid: iid, sourceChain: ["root"], state: "active", exp,
73
+ generation: observed.generation, processEpoch: observed.processEpoch,
74
+ registrationRevision: observed.registrationRevision, nameAuthorityRevision: observed.nameAuthorityRevision,
75
+ });
76
+ return creds;
77
+ }
78
+ /** #2073: dial the goal-writer's ONE standing connection and rebuild everything derived from it
79
+ * (the fence-resolving action context, the issuance-gate reader) — shared by the initial start
80
+ * and the closed-connection recovery ({@link onGoalWriterConnectionClosed}), so a redial never
81
+ * leaves the context bound to a dead socket. */
82
+ async dialGoalWriter(gw) {
83
+ const nc = await this.dial({
84
+ ...((this.auth || this.remoteAuthority) ? standaloneConnectOpts({ creds: () => gw.creds, tls: false }) : {}),
85
+ inboxPrefix: `_INBOX_${gw.identity.id}`,
86
+ maxReconnectAttempts: -1,
87
+ });
88
+ nc.closed().then((err) => { void this.onGoalWriterConnectionClosed(err ?? undefined); });
89
+ this.trackTransport(nc);
90
+ gw.nc = nc;
91
+ // The (i) fence resolver (SPEC 13.6): resolve an executing instance's CURRENT gate
92
+ // epoch. This manager reconciles only ITS OWN goals, so it resolves its own
93
+ // registration instanceId to this incarnation's serve-grant epoch; a foreign/retired instance
94
+ // is `null` (no current terminal to surface). A successor incarnation carries an ADVANCED epoch
95
+ // here, so its reads pick the current-epoch subject and the predecessor's terminal is fenced out.
96
+ gw.ctx = await actionContext(nc, this.space);
97
+ // The own-issuance-gate READER for the currency belt, on BOTH mesh modes. Reads
98
+ // `epgate.<e>.<iid>` over this connection; observe-only (stage/commit/revoke are never called
99
+ // through it — the goal-writer holds no gate/epcred WRITE grant, so a mis-call would
100
+ // broker-deny anyway).
101
+ //
102
+ // OPEN MESH IS NOT EXEMPT, and this is load-bearing. An open-mesh registration mints no
103
+ // credentials, so the §13.1 takeover barrier's revoke-and-evict loop enumerates an EMPTY family
104
+ // and is VACUOUS — yet it still advances processEpoch. The gate row itself DOES exist there
105
+ // (`provisionEndpointGateOpen`, over the authority stores the open serve path ensures), and a
106
+ // bare connection CAN read it (executed probe). So this belt is the ONLY thing standing between
107
+ // a deposed open-mesh incarnation and a wrong terminal on the one create-only result subject.
108
+ //
109
+ // NAME IT HONESTLY: on an open mesh this is a COOPERATIVE fence. The broker enforces nothing, so
110
+ // a hostile or non-conformant process can simply not run the check — the same guarantee class as
111
+ // every other open-mesh property. It is also a read-then-CAS, so it NARROWS the commit window
112
+ // rather than closing it. An AUTH mesh gets durable closure from the §13.1 barrier (revoke +
113
+ // cluster-verified eviction BEFORE the epoch advance); an open mesh gets none.
114
+ gw.gate = serveIssuanceGateKv(await new Kvm(nc).open(epAuthBucket(this.space)), this.space, { endpoint: MANAGER_ENDPOINT, instanceId: this.managerInstanceId });
115
+ }
116
+ /** #2073: the goal-writer rail's closed-connection fault, the same bounded shape the serve rail
117
+ * uses ({@link onServeConnectionClosed}) through the same {@link boundedReconnect} helper:
118
+ * re-dial with the current credential (a transport blip needs nothing new), re-mint through the
119
+ * existing goal-writer renewal branch when the credential itself has expired, then re-attach.
120
+ * Unlike the serve rail this never exits the process on exhaustion (brief step 4: only the serve
121
+ * rail is the control plane the report lost) — it logs and leaves the credential to the next
122
+ * scheduled renewal pass. */
123
+ async onGoalWriterConnectionClosed(err) {
124
+ if (this.leaseStopping)
125
+ return;
126
+ console.error(`! manager goal-writer connection closed: ${err?.message ?? "unknown reason"}`);
127
+ const gw = this.goalWriter;
128
+ const recovered = await this.boundedReconnect("goal-writer", async () => {
129
+ if (!gw)
130
+ return false;
131
+ if (this.remoteAuthority)
132
+ await this.renewRemoteBeforeRedial("goal-writer", () => gw.creds);
133
+ else if (gw.creds !== undefined && inspectCredHealth(gw.creds).state !== "healthy") {
134
+ gw.creds = await this.withEndpointServeExecutor(({ authKv }) => this.mintAndStageGoalWriter(authKv));
135
+ this.goalWriterCreds = gw.creds;
136
+ }
137
+ await this.dialGoalWriter(gw);
138
+ console.error("manager goal-writer re-dialed");
139
+ return true;
140
+ }, inspectCredHealth(gw?.creds ?? "").state === "expired");
141
+ if (this.leaseStopping || recovered)
142
+ return;
143
+ console.error("! manager goal-writer could not be re-dialed; leaving the credential to the next renewal pass");
144
+ }
145
+ /** Spawn-as-action: stand up the standing self-mediated goal-writer connection +
146
+ * ActionContext. Mode-dual, mirroring {@link registerManagerService}: an AUTH mesh uses the
147
+ * scoped `goal-writer` credential already minted + family-STAGED inside registration's run block
148
+ * ({@link mintAndStageGoalWriter} — DISJOINT grant from the serve cred, SHARED §13.1 revocation
149
+ * family); an OPEN mesh uses a bare connection (no credential system to mint from - the broker
150
+ * enforces nothing). The connection presents the CURRENT credential on every (re)connect (a
151
+ * renewal is adopted without reconnecting the whole endpoint); the ActionContext bonds its
152
+ * KV + JS + JSM to this one connection and space (SPEC 13.4), so a composition mixup cannot splice
153
+ * goal state across brokers. */
154
+ async startGoalWriter() {
155
+ const identity = (this.auth || this.remoteAuthority) ? this.goalWriterIdentity : newIdentity();
156
+ // The mutable holder captured by the authenticator (mirrors the serve connection): a half-TTL
157
+ // renewal updates `gw.creds` and the next (re)connect presents the refreshed credential.
158
+ const gw = { nc: undefined, ctx: undefined, creds: (this.auth || this.remoteAuthority) ? this.goalWriterCreds : undefined, identity };
159
+ await this.dialGoalWriter(gw);
160
+ this.goalWriter = gw;
161
+ console.error(`manager goal-writer standing (endpoint ${MANAGER_ENDPOINT}, ${(this.auth || this.remoteAuthority) ? "scoped cred, §13.1 family-staged" : "open/bare"})`);
162
+ }
163
+ /** Retire the goal-writer connection (best-effort, both exit paths). */
164
+ async stopGoalWriter() {
165
+ const gw = this.goalWriter;
166
+ if (!gw)
167
+ return;
168
+ this.goalWriter = undefined;
169
+ await this.retireConnection(gw.nc);
170
+ }
171
+ /** The boot reconcile: a fresh incarnation (a manager restart takes a NEW
172
+ * instanceId, so the in-memory acceptance map starts empty) inherits the endpoint's accepted-but-
173
+ * unterminal goals from any predecessor. The local signer enumerates with an ephemeral PROVISIONER.
174
+ * A remote manager calls the authenticated host-owned scan, which keeps the sealed consumer and its
175
+ * lifecycle authority on the host; the instance executor, goal-writer, and supervisor hold NO records
176
+ * consumer grant. Settle each orphan so an accepted goal is NEVER dropped across a restart. Open mesh:
177
+ * a bare connection (the broker enforces nothing). Runs ONCE at start, BEFORE spawn-as-action begins
178
+ * accepting (the `goalReconcileDone` gate), so it never races a live goal's acceptance. Never
179
+ * fatal — a reconcile failure is logged and the gate opens either way. */
180
+ async reconcileGoalIndex() {
181
+ const gw = this.goalWriter;
182
+ if (!gw) {
183
+ this.goalReconcileDone = true;
184
+ return;
185
+ }
186
+ try {
187
+ let entries = [];
188
+ if (this.remoteAuthority) {
189
+ entries = (await this.remoteAuthority.scanGoalIndex()).map((entry) => ({
190
+ ref: { endpoint: entry.endpoint, caller: { owner: entry.owner, actor: entry.actor, uid: entry.uid }, goalId: entry.goalId },
191
+ iid: entry.iid,
192
+ ...(entry.allocated !== undefined ? { allocated: entry.allocated } : {}),
193
+ ...(entry.note !== undefined ? { note: entry.note } : {}),
194
+ }));
195
+ }
196
+ else {
197
+ const nc = this.auth
198
+ ? await this.dial({ ...standaloneConnectOpts({ creds: await mintCreds(this.auth, newIdentity(), "provisioner"), /* not yet wired to a recorded transport */ tls: false }), maxReconnectAttempts: 0 })
199
+ : await this.dial({ maxReconnectAttempts: 0 });
200
+ try {
201
+ const kvm = new Kvm(nc);
202
+ await ensureAuthorityStores(await jetstreamManager(nc), kvm, this.space);
203
+ entries = await listGoalIndex(await kvm.open(recordsBucket(this.space)), MANAGER_ENDPOINT);
204
+ }
205
+ finally {
206
+ await drainAndClose(nc);
207
+ }
208
+ }
209
+ // Single-manager: EVERY inherited entry belongs to a DEAD predecessor (only one manager
210
+ // at a time), so all are reconciled. The `iid` field is the hook the multi-instance sweep
211
+ // filters on (skip a goal whose accepting `iid` is a still-LIVE sibling — never settle its goal).
212
+ for (const entry of entries) {
213
+ const key = goalKey(entry.ref);
214
+ if (this.goalAcceptances.has(key) || this.turnRelay.hasAcceptance(key))
215
+ continue; // never settle a goal THIS incarnation drives
216
+ try {
217
+ // A note marks a TURN entry: its relay is rebuilt (the hold is its bounded ending), never
218
+ // settled uncertain — the spawn arm's readiness window is the wrong ending for a relay.
219
+ if (entry.note !== undefined)
220
+ await this.adoptTurnGoal(entry);
221
+ else
222
+ await this.reconcileOneGoal(entry.ref, entry.iid);
223
+ }
224
+ catch (e) {
225
+ console.error(`! goal reconcile for ${entry.ref.goalId}: ${rejectionText(e)}`);
226
+ }
227
+ }
228
+ if (entries.length)
229
+ console.error(`goal-index boot reconcile: swept ${entries.length} inherited goal(s)`);
230
+ }
231
+ catch (e) {
232
+ console.error(`! goal-index boot reconcile failed: ${rejectionText(e)} - accepted goals from a predecessor may stay unsettled until the next restart`);
233
+ }
234
+ finally {
235
+ this.goalReconcileDone = true;
236
+ this.turnRelay.markReconciled(Date.now());
237
+ // A seat that pulled during the window was refused, and a predecessor may have died before
238
+ // its notice went out, so every seat holding a rebuilt turn is told once.
239
+ const seats = this.turnRelay.pendingSeats();
240
+ for (const seat of seats)
241
+ this.noticeSeatTurns(seat);
242
+ }
243
+ }
244
+ /** Settle ONE inherited goal by evidence: no goal record (a crash between the index write and the
245
+ * goal-record create) leaves the pointer untouched (never settle a goal that was never accepted,
246
+ * and clearing it would race a live goal mid-creation); a TERMINAL goal clears the index
247
+ * (converged — the predecessor committed but died before clearing); a NON-TERMINAL goal settles
248
+ * `uncertain` (the accepting incarnation is gone, so the success signal will never reach us — the
249
+ * bounded readiness outcome the plan maps the window to). Within the readiness window it arms a
250
+ * bounded, unref'd timer to settle at the deadline (an early uncertain would steal a still-possible
251
+ * success the substrate guards against). */
252
+ async reconcileOneGoal(ref, acceptedByIid) {
253
+ const gw = this.goalWriter;
254
+ if (!gw)
255
+ return;
256
+ const status = await readGoalStatus(gw.ctx, ref);
257
+ if (status === undefined)
258
+ return; // index points at no goal record: a dead pointer, left for honesty
259
+ if (GOAL_TERMINAL_STATES.includes(status.value.state)) {
260
+ await clearGoalIndex(gw.ctx, ref);
261
+ return;
262
+ }
263
+ const spec = await readGoalSpec(gw.ctx, ref);
264
+ if (spec === undefined)
265
+ return; // a status without its spec is garbled — leave for the next boot
266
+ // NEVER A CROSS-INSTANCE SETTLE. The accepting incarnation is recorded on the INDEX ENTRY
267
+ // itself (`iid`, written at accept), which is the honest coordinate: a same-instanceId restart
268
+ // inherits its predecessor's orphans, and a goal accepted by a DIFFERENT (possibly still-live)
269
+ // sibling is left for its owner. This replaces the goal spec's `executor` pin, which existed
270
+ // only to epoch-scope the terminal subject and is gone with it (§13.2 reserved subjects).
271
+ if (acceptedByIid !== this.managerInstanceId) {
272
+ console.error(`goal reconcile ${ref.goalId}: accepted by instance "${acceptedByIid}", not this incarnation "${this.managerInstanceId}"; left for its owner (never a cross-instance settle)`);
273
+ return;
274
+ }
275
+ const settle = async () => {
276
+ // A SUCCESSOR settling work it inherited: the committer is THIS incarnation at its CURRENT
277
+ // serve epoch, which is strictly greater than the goal's acceptedEpoch — the `committed >
278
+ // accepted` arm of the attribution rule, and the reason that arm has to exist.
279
+ await settleGoalUncertain(gw.ctx, { ref, now: Date.now(), committer: { instanceId: this.managerInstanceId, epoch: this.serviceServe?.grant.epoch ?? 0 } }); // first-terminal-wins: a racing terminal returns the winner, no throw
280
+ await clearGoalIndex(gw.ctx, ref);
281
+ };
282
+ const remaining = spec.value.acceptedAt + (spec.value.readinessDeadlineMs ?? this.readinessTimeoutMs) - Date.now();
283
+ if (remaining <= 0) {
284
+ await settle();
285
+ return;
286
+ }
287
+ console.error(`goal reconcile ${ref.goalId}: within the readiness window (${remaining}ms) - arming a bounded settle`);
288
+ const t = setTimeout(() => { settle().catch((e) => console.error(`! goal reconcile settle ${ref.goalId}: ${rejectionText(e)}`)); }, remaining + 100);
289
+ t.unref?.();
290
+ }
291
+ /** Publish a goal PROGRESS event on the caller-scoped epe subtree, over the SERVE
292
+ * connection (which holds the `epe.<e>.<iid>.<epoch>.>` egress grant; the goal-writer deliberately
293
+ * does not). The terminal rides a final event `phase:"terminal"` (the caller follows epe to
294
+ * the terminal; the durable result fact + inspect/ps are the reconcile authority). A dropped event
295
+ * is non-fatal (the terminal is authoritative in the journal). */
296
+ emitGoalProgress(ref, epoch, event) {
297
+ const nc = this.serviceServe?.nc;
298
+ if (!nc)
299
+ return;
300
+ try {
301
+ nc.publish(epeSubject(this.space, MANAGER_ENDPOINT, this.managerInstanceId, epoch, goalProgressTopic(ref)), new TextEncoder().encode(JSON.stringify({ v: 1, goalId: ref.goalId, ...event })));
302
+ }
303
+ catch (e) {
304
+ console.error(`! goal progress emit for ${ref.goalId} failed: ${rejectionText(e)}`);
305
+ }
306
+ }
307
+ /** The own-gate currency belt: before the goal-writer commits a terminal fact, the manager reads
308
+ * its OWN issuance gate epoch and REFUSES the commit if superseded. This NARROWS the window; it
309
+ * is not the fence. Layer 1 below is closed by the sibling-mint fence; layers 2 and 3 are not
310
+ * closed by any planned slice and must not be described as temporary.
311
+ *
312
+ * THE RESIDUAL, STACKED:
313
+ * 1. SIBLING-MINT INJECTION. A §13.1 barrier's revoke/evict loop closes only over the family
314
+ * SNAPSHOT IT ENUMERATED, so a sibling mint that observes the gate and stages a ledger row
315
+ * WITHOUT the observe/open/commit fence can be staged and released AFTER that enumerate and
316
+ * never be revoked. This layer is closed exactly where BOTH sibling mint sites
317
+ * ({@link mintAndStageGoalWriter}, {@link mintAndStageSessionLedger}) route their stage
318
+ * through `commitSiblingIssuance` (the revision-pinned CAS that makes a losing mint release
319
+ * nothing), and open exactly where they do not — state the mechanism, never the branch.
320
+ * 2. THE BARRIER WINDOW. A gate FREEZE neither kills this connection nor advances the epoch,
321
+ * and this belt compares `processEpoch` alone, so it still PASSES from barrier start until
322
+ * the reopen. A ledger revoke marks a row; it does not re-check a live JWT mid-publish. The
323
+ * durable kill is the CLUSTER-VERIFIED EVICTION, so a deposed manager can INITIATE new
324
+ * terminal publishes from barrier start until eviction is verified — not merely finish bytes
325
+ * already on the wire. Successor EXISTENCE and corpse DEATH are different phases, so the
326
+ * barrier's ordering licenses no conclusion about when the corpse stops being able to write.
327
+ * 3. OPEN MESH. No credential family exists, so the revoke/evict loop is vacuous and this belt
328
+ * is COOPERATIVE only: a non-conformant process simply does not run it.
329
+ * The named follow-up that would close 2 and 3 is the gate-linearized commit (routing the
330
+ * terminal through the issuance gate's own CAS), deliberately deferred as substrate territory. */
331
+ async assertGoalWriterEpochCurrent(epoch) {
332
+ const gate = this.goalWriter?.gate;
333
+ if (!gate)
334
+ return; // no goal-writer standing yet
335
+ const observed = await gate.observe();
336
+ if (observed === null)
337
+ throw new EpEnvelopeError("expired", `the manager's issuance gate for ${MANAGER_ENDPOINT}/${this.managerInstanceId} is gone; a retired incarnation never commits a goal terminal (SPEC 13.1/13.6)`);
338
+ if (observed.processEpoch !== epoch)
339
+ throw new EpEnvelopeError("expired", `the manager's issuance gate epoch is ${observed.processEpoch} but this goal was accepted under epoch ${epoch}; a superseded incarnation never commits a goal terminal (SPEC 13.6)`);
340
+ }
341
+ }
342
+ //# sourceMappingURL=goal-writer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"goal-writer.js","sourceRoot":"","sources":["../src/goal-writer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,oBAAoB,EAAE,aAAa,EAAE,cAAc,EAAE,qBAAqB,EAAE,cAAc,EAAE,aAAa,EAAE,qBAAqB,EAAE,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,EAAE,SA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