@cotal-ai/cli 0.121.6 → 0.121.7
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.
- package/dist/commands/down-live-lease.d.ts.map +1 -1
- package/dist/commands/down-live-lease.js +29 -6
- package/dist/commands/down-live-lease.js.map +1 -1
- package/dist/commands/up.d.ts +1 -0
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +16 -4
- package/dist/commands/up.js.map +1 -1
- package/dist/lib/broker-service.js +1 -1
- package/dist/lib/broker-service.js.map +1 -1
- package/dist/lib/service-presets.d.ts.map +1 -1
- package/dist/lib/service-presets.js +3 -1
- package/dist/lib/service-presets.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"down-live-lease.d.ts","sourceRoot":"","sources":["../../src/commands/down-live-lease.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"down-live-lease.d.ts","sourceRoot":"","sources":["../../src/commands/down-live-lease.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D;0DAC0D;AAC1D,wBAAsB,aAAa,CAAC,CAAC,EACnC,EAAE,EAAE,cAAc,EAClB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,UAAU,UAAQ,GACjB,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAiBxB;AAID,OAAO,EAA8C,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAmB9H,wBAAsB,2BAA2B,CAC/C,UAAU,EAAE,SAAS,YAAY,EAAE,EACnC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAaf"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/** A manager or delivery daemon whose pidfile is gone while its lease is still live.
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* A daemon that is running keeps renewing, and `down` must not stop the broker under it. A daemon
|
|
3
|
+
* that exited without releasing, such as one whose broker stalled past its broker-gone window,
|
|
4
|
+
* leaves a row that nobody renews, so a row counts only once it is written again within the bucket
|
|
5
|
+
* TTL. A bucket that does not exist, or a broker that does not answer, is not a
|
|
4
6
|
* live daemon. */
|
|
5
7
|
import { existsSync } from "node:fs";
|
|
6
8
|
import { jetstreamManager } from "@nats-io/jetstream";
|
|
@@ -19,9 +21,24 @@ export async function directKvValue(nc, stream, subject, allowEmpty = false) {
|
|
|
19
21
|
}
|
|
20
22
|
return JSON.parse(Buffer.from(body.message.data, "base64").toString("utf8"));
|
|
21
23
|
}
|
|
22
|
-
import { dialerFor, deliveryBucket, isReachable, MANAGER_LEASE_KEY, managerBucket, standaloneConnectOpts } from "@cotal-ai/core";
|
|
24
|
+
import { awaitLeaseExpiry, dialerFor, deliveryBucket, isReachable, LEASE_EXPIRY_GRACE_MS, LEASE_TTL_MS, leaseRemainingMs, MANAGER_LEASE_KEY, MANAGER_LEASE_TTL_MS, managerBucket, standaloneConnectOpts } from "@cotal-ai/core";
|
|
23
25
|
import { CommandFailure, findMesh, localProcessPath } from "@cotal-ai/workspace";
|
|
24
26
|
import { connectOrExit, userViewAuthOrExit } from "../lib/connect.js";
|
|
27
|
+
import { c } from "../ui.js";
|
|
28
|
+
/** One KV subject's last row as its revision and broker write time, without creating a consumer.
|
|
29
|
+
* A missing subject or a DEL/PURGE tombstone is no row. */
|
|
30
|
+
async function directKvRow(nc, stream, subject) {
|
|
31
|
+
const response = await nc.request(`$JS.API.STREAM.MSG.GET.${stream}`, JSON.stringify({ last_by_subj: subject }), { timeout: 5_000 });
|
|
32
|
+
const body = JSON.parse(new TextDecoder().decode(response.data));
|
|
33
|
+
if (body.error?.code === 404)
|
|
34
|
+
return undefined;
|
|
35
|
+
if (body.error)
|
|
36
|
+
throw new Error(`lease read failed: ${body.error.description ?? "JetStream error"}`);
|
|
37
|
+
const headers = body.message?.hdrs ? Buffer.from(body.message.hdrs, "base64").toString("utf8") : "";
|
|
38
|
+
if (!body.message || /^KV-Operation:\s*(?:DEL|PURGE)\s*$/im.test(headers))
|
|
39
|
+
return undefined;
|
|
40
|
+
return { revision: body.message.seq, created: Date.parse(body.message.time) };
|
|
41
|
+
}
|
|
25
42
|
export async function refuseLiveUnrecordedDaemons(components, context) {
|
|
26
43
|
const live = await liveUnrecordedDaemonNames(components, context);
|
|
27
44
|
if (!live.length)
|
|
@@ -50,7 +67,7 @@ async function liveUnrecordedDaemonNames(components, context) {
|
|
|
50
67
|
});
|
|
51
68
|
try {
|
|
52
69
|
const jsm = await jetstreamManager(nc);
|
|
53
|
-
const live = async (bucket, leasePrefix) => {
|
|
70
|
+
const live = async (label, bucket, leasePrefix, ttlMs) => {
|
|
54
71
|
let subjects;
|
|
55
72
|
try {
|
|
56
73
|
const info = await jsm.streams.info(`KV_${bucket}`, { subjects_filter: `$KV.${bucket}.>` });
|
|
@@ -64,7 +81,13 @@ async function liveUnrecordedDaemonNames(components, context) {
|
|
|
64
81
|
// The manager bucket also holds mesh config. Only a current `lease.<instance>` is a daemon.
|
|
65
82
|
const leases = leasePrefix === undefined ? subjects : subjects.filter((subject) => subject.startsWith(`$KV.${bucket}.${leasePrefix}.`));
|
|
66
83
|
for (const subject of leases) {
|
|
67
|
-
|
|
84
|
+
const read = () => directKvRow(nc, `KV_${bucket}`, subject);
|
|
85
|
+
const row = await read();
|
|
86
|
+
if (row === undefined)
|
|
87
|
+
continue;
|
|
88
|
+
console.error(c.dim(`• ${label} has no pidfile; waiting up to ${Math.ceil((leaseRemainingMs(row.created, ttlMs) + LEASE_EXPIRY_GRACE_MS) / 1000)}s to see whether its lease is renewed`));
|
|
89
|
+
// A row the broker is late to expire but nobody wrote for a whole TTL has no renewer either.
|
|
90
|
+
if (await awaitLeaseExpiry({ read, ...row, ttlMs }) === "rewritten")
|
|
68
91
|
return true;
|
|
69
92
|
}
|
|
70
93
|
return false;
|
|
@@ -73,7 +96,7 @@ async function liveUnrecordedDaemonNames(components, context) {
|
|
|
73
96
|
for (const component of watched) {
|
|
74
97
|
const manager = component.name === "manager";
|
|
75
98
|
const bucket = manager ? managerBucket(context.space) : deliveryBucket(context.space);
|
|
76
|
-
if (await live(bucket, manager ? MANAGER_LEASE_KEY : undefined))
|
|
99
|
+
if (await live(component.label, bucket, manager ? MANAGER_LEASE_KEY : undefined, manager ? MANAGER_LEASE_TTL_MS : LEASE_TTL_MS))
|
|
77
100
|
found.push(component.label);
|
|
78
101
|
}
|
|
79
102
|
// Both daemons, when both are live. Object key order must not drop the manager behind delivery.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"down-live-lease.js","sourceRoot":"","sources":["../../src/commands/down-live-lease.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"down-live-lease.js","sourceRoot":"","sources":["../../src/commands/down-live-lease.ts"],"names":[],"mappings":"AAAA;;;;;mBAKmB;AACnB,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD;0DAC0D;AAC1D,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,EAAkB,EAClB,MAAc,EACd,OAAe,EACf,UAAU,GAAG,KAAK;IAElB,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,OAAO,CAC/B,0BAA0B,MAAM,EAAE,EAClC,IAAI,CAAC,SAAS,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,EACzC,EAAE,OAAO,EAAE,KAAK,EAAE,CACnB,CAAC;IACF,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAG9D,CAAC;IACF,IAAI,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,sCAAsC,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,iBAAiB,EAAE,CAAC,CA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C,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAChH,CAAC;YAAS,CAAC;QACT,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACnC,CAAC;AACH,CAAC"}
|
package/dist/commands/up.d.ts
CHANGED
|
@@ -238,6 +238,7 @@ export declare function startMeshDetached(opts: DetachOpts): Promise<{
|
|
|
238
238
|
authService: boolean;
|
|
239
239
|
deliveryResponderBound: boolean | null;
|
|
240
240
|
delivery: boolean;
|
|
241
|
+
deliveryLost?: string;
|
|
241
242
|
manager: boolean;
|
|
242
243
|
}>;
|
|
243
244
|
/** A space name maps to one mesh in the registry (the key `--space`/`use`/`down` act on). Before
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"up.d.ts","sourceRoot":"","sources":["../../src/commands/up.ts"],"names":[],"mappings":"AAsBA,OAAO,EAWL,KAAK,eAAe,EAmCpB,KAAK,YAAY,EAIjB,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAoEL,KAAK,SAAS,EA0Bd,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"up.d.ts","sourceRoot":"","sources":["../../src/commands/up.ts"],"names":[],"mappings":"AAsBA,OAAO,EAWL,KAAK,eAAe,EAmCpB,KAAK,YAAY,EAIjB,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAoEL,KAAK,SAAS,EA0Bd,KAAK,eAAe,EAgCrB,MAAM,qBAAqB,CAAC;AAmB7B,OAAO,EAA4C,KAAK,gBAAgB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,GAAG,SAAS,EAAE,YAAY,UAAU,KAAG,IAAoC,CAAC"}
|
package/dist/commands/up.js
CHANGED
|
@@ -9,7 +9,7 @@ import { basename, dirname, isAbsolute, join, resolve } from "node:path";
|
|
|
9
9
|
import { isReachable, dialerFor, DEFAULT_SERVER, DEFAULT_SPACE, SERVICE_AUTHORITY_MAX_BYTES, SERVICE_CALLER_PAYLOAD_FLOOR, createSpaceAuth, serverConfig, openServerConfig, validateTlsMaterial, credsProblem, mintCreds, mintLifecycleUid, DEV_OWNER, mintConnectionEvictorCreds, mintMembershipObserverCreds, newIdentity, setupSpaceStreams, removeIssuedStoresBeforeRetention, IssuedStoreBeforeRetentionError, IssuedStoreRecreateRefusal, reconcileSpaceTtls, ttlBuckets, standaloneConnectOpts, requireBrokerFloor, parseServerVersion, presenceBucket, MEMBERSHIP_MAX_BYTES, spaceDeletionStreams, isJetStreamMissing, seedChannelRegistry, ensureDefaultDeliveryClass, UndecodableRegistryEntry, assertValidChannel, isConcreteChannel, validateChannelConfig, validateChannelDefaults, LEASE_TTL_MS, mkSecretDir, openPrivateAppend, realDirNoSymlink, writeSecretFile, writeSecretFileAtomic, utf16Problem, } from "@cotal-ai/core";
|
|
10
10
|
import { JetStreamApiCodes, jetstreamManager, StorageType } from "@nats-io/jetstream";
|
|
11
11
|
import { Kvm } from "@nats-io/kv";
|
|
12
|
-
import { assertManagerName, readManagerName, readManagerSeatCap, recordManagerName, recordManagerSeatCap, parseSeatCapFlag, seatCapText, assertRecordIdentity, formatRecord, identityRecord, parseRecord, CommandFailure, codeSpan, commandFailureReport, isCommandFailure, protectedLocalDirectory, jsonFlag, plainFlag, renderReport, assertSingleSpaceBroker, assertUserAuthInfo, authDir, brokerAddressForDisplay, brokerPolicyPath, getSoleSpaceAuth, soleSpaceOf, getSpaceAuth, hasUserAuthState, listSpaceAccounts, preloadSpaceAccounts, putSpaceAuth, brokerAddressKey, canonicalRoot, rootPathProblem, rootControlProblem, clearCurrent, findMesh, findPreparedSpace, homeCotalDir, getCurrent, loadMeshes, preparedSpaceAt, removePreparedSpace, localMeshesForRoot, keepsRegistration, oneLine, presentationOf, writeResult, connectionEvictorCredsKey, membershipConfigPath, membershipObserverCredsKey, membershipRwCredsKey, MEMBERSHIP_CONFIG_KIND, MEMBERSHIP_RW_CREDS_KIND, parsePositiveIntegerFlag, recordMesh, retainedLegacyBroker, meshesForRoot, removeMesh, rotateSystemCreds, setCurrent, staleSystemCreds, SYSTEM_CREDS_FILES, userAuthStateDir, userAuthSpacesOnDisk, workspaceSecretStore, acquireMaintenanceLock, assertStoreIdentity, assessMaintenanceClaim, assessRestoreClaim, beginOrdinaryResume, bindOrdinaryResumeListener, consumeRetiredMaintenance, markOrdinaryResumeActive, markOrdinaryResumeDegraded, replaceDeadOrdinaryResumeListener, localProcessOwnerStatus, readMaintenanceJournal, rootNamesNoSpace, readMaintenanceResumeDocument, seatCheckpointDir, readStoreIdentity, recordOrdinaryResumeManagerCommit, releaseMaintenanceLock, retireOrdinaryResume, settleTokenHandoff, sweepTokenHandoff, writeTokenHandoff, sameStoreIdentity, cutController, readBrokerPolicy, writeBrokerPolicy, removePidPair, writePidPair, isLoopbackHost, connectUserControlOrThrow, userViewAuth, recordOperationSpace, recordsElsewhereError, recordOperationWarning, retainSystemSigningSeed, restoreLeftOut, SPACE_NAME_MAX, spaceNameTooLong, MIN_FILE_STORE, NATS_PIDFILE, UNTRUSTED_CERTIFICATE, exitCode, } from "@cotal-ai/workspace";
|
|
12
|
+
import { assertManagerName, readManagerName, readManagerSeatCap, recordManagerName, recordManagerSeatCap, parseSeatCapFlag, seatCapText, assertRecordIdentity, formatRecord, identityRecord, parseRecord, CommandFailure, codeSpan, commandFailureReport, isCommandFailure, protectedLocalDirectory, jsonFlag, plainFlag, renderReport, assertSingleSpaceBroker, assertUserAuthInfo, authDir, brokerAddressForDisplay, brokerPolicyPath, getSoleSpaceAuth, soleSpaceOf, getSpaceAuth, hasUserAuthState, listSpaceAccounts, preloadSpaceAccounts, putSpaceAuth, brokerAddressKey, canonicalRoot, rootPathProblem, rootControlProblem, clearCurrent, findMesh, findPreparedSpace, homeCotalDir, getCurrent, loadMeshes, preparedSpaceAt, removePreparedSpace, localMeshesForRoot, keepsRegistration, oneLine, presentationOf, writeResult, connectionEvictorCredsKey, membershipConfigPath, membershipObserverCredsKey, membershipRwCredsKey, MEMBERSHIP_CONFIG_KIND, MEMBERSHIP_RW_CREDS_KIND, parsePositiveIntegerFlag, recordMesh, retainedLegacyBroker, meshesForRoot, removeMesh, rotateSystemCreds, setCurrent, staleSystemCreds, SYSTEM_CREDS_FILES, userAuthStateDir, userAuthSpacesOnDisk, workspaceSecretStore, acquireMaintenanceLock, assertStoreIdentity, assessMaintenanceClaim, assessRestoreClaim, beginOrdinaryResume, bindOrdinaryResumeListener, consumeRetiredMaintenance, markOrdinaryResumeActive, markOrdinaryResumeDegraded, replaceDeadOrdinaryResumeListener, localProcessOwnerStatus, readMaintenanceJournal, rootNamesNoSpace, readMaintenanceResumeDocument, seatCheckpointDir, readStoreIdentity, recordOrdinaryResumeManagerCommit, releaseMaintenanceLock, retireOrdinaryResume, settleTokenHandoff, sweepTokenHandoff, writeTokenHandoff, sameStoreIdentity, cutController, readBrokerPolicy, writeBrokerPolicy, removePidPair, writePidPair, isLoopbackHost, connectUserControlOrThrow, userViewAuth, recordOperationSpace, recordsElsewhereError, recordOperationWarning, retainSystemSigningSeed, restoreLeftOut, SPACE_NAME_MAX, spaceNameTooLong, MIN_FILE_STORE, NATS_PIDFILE, UNTRUSTED_CERTIFICATE, exitCode, canonicalLocalProcessPath, DELIVERY_LOGFILE, } from "@cotal-ai/workspace";
|
|
13
13
|
import { FlagValueRefusal } from "../lib/flag-value-refusal.js";
|
|
14
14
|
import { ensureAuthService, resolveAuthProvider, stopAuthService } from "../lib/auth-proc.js";
|
|
15
15
|
import { resolveSpace } from "../lib/status.js";
|
|
@@ -2004,7 +2004,7 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
2004
2004
|
await claimSpace(receiptSpace, server, cotalRoot());
|
|
2005
2005
|
if (!quietRestore)
|
|
2006
2006
|
console.log(`${renderReport({ space: receiptSpace, sections: [] }, "rich", process.stdout)}\n`);
|
|
2007
|
-
const { pid, executable, authService, controlPlane, delivery, manager } = await startMeshDetached({
|
|
2007
|
+
const { pid, executable, authService, controlPlane: planeReturned, delivery, deliveryLost, manager } = await startMeshDetached({
|
|
2008
2008
|
transport,
|
|
2009
2009
|
server,
|
|
2010
2010
|
storeDir: values["store-dir"],
|
|
@@ -2034,6 +2034,10 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
2034
2034
|
...(quietRestore ? { quietBoot: true } : {}),
|
|
2035
2035
|
});
|
|
2036
2036
|
// Transport policy is committed inside startMeshDetached before delivery launch (S5+S9).
|
|
2037
|
+
// A delivery daemon this boot started and lost degrades the control plane, as one that never came up does.
|
|
2038
|
+
if (deliveryLost !== undefined)
|
|
2039
|
+
reportDegradedControlPlane(deliveryLost);
|
|
2040
|
+
const controlPlane = planeReturned && deliveryLost === undefined;
|
|
2037
2041
|
const detached = { pid, delivery, authService: wantUser && authService, manager, machineHome: canonicalRoot(cotalRoot()) === canonicalRoot(homedir()), ...(values.root ? { root: cotalRoot() } : {}) };
|
|
2038
2042
|
if (!quietRestore) {
|
|
2039
2043
|
console.log(c.dim(`Started ${executable}.`));
|
|
@@ -3690,10 +3694,13 @@ tlsRequired, mgr) {
|
|
|
3690
3694
|
// Non-fatal (live messaging is unaffected) — but never SILENT: without the manager,
|
|
3691
3695
|
// `spawn --detach` / cotal_spawn have no responder, and the operator must hear it here,
|
|
3692
3696
|
// not as an unexplained "no manager reachable" later.
|
|
3693
|
-
|
|
3697
|
+
reportDegradedControlPlane(e.message);
|
|
3694
3698
|
return undefined;
|
|
3695
3699
|
}
|
|
3696
3700
|
}
|
|
3701
|
+
function reportDegradedControlPlane(why) {
|
|
3702
|
+
console.error(c.dim(`! control plane degraded: ${why} - durable delivery/manager may be down; spawn and retirement require a functioning control plane`));
|
|
3703
|
+
}
|
|
3697
3704
|
/**
|
|
3698
3705
|
* Publish a spawned listener's pid, and bind a maintenance-bound one to its attempt, before anything
|
|
3699
3706
|
* waits on it. A launch that dies before its listener serves then leaves `nats.pid` for `cotal down`
|
|
@@ -3957,6 +3964,10 @@ opts) {
|
|
|
3957
3964
|
});
|
|
3958
3965
|
if (opts.noManager && useAuth && controlPlane)
|
|
3959
3966
|
recordOperationWarning(await noManagerCredentialWarning(cotalRoot(), space));
|
|
3967
|
+
const delivery = useAuth && deliveryUp(space);
|
|
3968
|
+
// A daemon this boot started can still stop before the boot ends, such as on a SIGTERM while the
|
|
3969
|
+
// manager starts, and it removes its own record as it goes.
|
|
3970
|
+
const lost = controlPlane?.delivery?.started && !delivery ? controlPlane.delivery : undefined;
|
|
3960
3971
|
return {
|
|
3961
3972
|
server,
|
|
3962
3973
|
pid: child.pid ?? 0,
|
|
@@ -3964,7 +3975,8 @@ opts) {
|
|
|
3964
3975
|
controlPlane: controlPlane !== undefined,
|
|
3965
3976
|
authService,
|
|
3966
3977
|
deliveryResponderBound: useAuth ? controlPlane?.responderBound === true : null,
|
|
3967
|
-
delivery
|
|
3978
|
+
delivery,
|
|
3979
|
+
...(lost ? { deliveryLost: `the delivery daemon started for space "${space}" (pid ${lost.pid}) exited before this boot finished. It logged its reason to ${canonicalLocalProcessPath(DELIVERY_LOGFILE, { root: cotalRoot(), space })}` } : {}),
|
|
3968
3980
|
manager: managerUp(space),
|
|
3969
3981
|
};
|
|
3970
3982
|
}
|