@cotal-ai/cli 0.151.0 → 0.151.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/chat/view.d.ts.map +1 -1
  2. package/dist/chat/view.js +3 -1
  3. package/dist/chat/view.js.map +1 -1
  4. package/dist/command.d.ts.map +1 -1
  5. package/dist/command.js +9 -0
  6. package/dist/command.js.map +1 -1
  7. package/dist/commands/backup-read.js +1 -1
  8. package/dist/commands/backup-read.js.map +1 -1
  9. package/dist/commands/config.d.ts.map +1 -1
  10. package/dist/commands/config.js +14 -6
  11. package/dist/commands/config.js.map +1 -1
  12. package/dist/commands/down.d.ts.map +1 -1
  13. package/dist/commands/down.js +49 -1
  14. package/dist/commands/down.js.map +1 -1
  15. package/dist/commands/endpoint.d.ts.map +1 -1
  16. package/dist/commands/endpoint.js +30 -3
  17. package/dist/commands/endpoint.js.map +1 -1
  18. package/dist/commands/ext.d.ts.map +1 -1
  19. package/dist/commands/ext.js +10 -1
  20. package/dist/commands/ext.js.map +1 -1
  21. package/dist/commands/revoke-credential.d.ts.map +1 -1
  22. package/dist/commands/revoke-credential.js +12 -6
  23. package/dist/commands/revoke-credential.js.map +1 -1
  24. package/dist/commands/service-registry.d.ts.map +1 -1
  25. package/dist/commands/service-registry.js +31 -9
  26. package/dist/commands/service-registry.js.map +1 -1
  27. package/dist/commands/stack-down.d.ts.map +1 -1
  28. package/dist/commands/stack-down.js +8 -0
  29. package/dist/commands/stack-down.js.map +1 -1
  30. package/dist/commands/stack-up.js +1 -1
  31. package/dist/commands/stack-up.js.map +1 -1
  32. package/dist/commands/up.d.ts +6 -7
  33. package/dist/commands/up.d.ts.map +1 -1
  34. package/dist/commands/up.js +45 -50
  35. package/dist/commands/up.js.map +1 -1
  36. package/dist/index.d.ts +1 -0
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +2 -1
  39. package/dist/index.js.map +1 -1
  40. package/dist/lib/backup-artifact.d.ts.map +1 -1
  41. package/dist/lib/backup-artifact.js +9 -1
  42. package/dist/lib/backup-artifact.js.map +1 -1
  43. package/dist/lib/foreground-hold.d.ts +12 -0
  44. package/dist/lib/foreground-hold.d.ts.map +1 -0
  45. package/dist/lib/foreground-hold.js +63 -0
  46. package/dist/lib/foreground-hold.js.map +1 -0
  47. package/dist/lib/service-presets.d.ts +3 -0
  48. package/dist/lib/service-presets.d.ts.map +1 -1
  49. package/dist/lib/service-presets.js +45 -14
  50. package/dist/lib/service-presets.js.map +1 -1
  51. package/dist/lib/spawn-defaults.d.ts +3 -2
  52. package/dist/lib/spawn-defaults.d.ts.map +1 -1
  53. package/dist/lib/spawn-defaults.js +9 -5
  54. package/dist/lib/spawn-defaults.js.map +1 -1
  55. package/dist/lib/stack-journal.d.ts +3 -0
  56. package/dist/lib/stack-journal.d.ts.map +1 -1
  57. package/dist/lib/stack-journal.js +12 -0
  58. package/dist/lib/stack-journal.js.map +1 -1
  59. package/package.json +4 -4
@@ -43,14 +43,13 @@ export declare function validateUpArguments(args: ParsedArgs): void;
43
43
  * create trust in an arbitrary directory. Validation runs before the dispatcher seeds extensions. */
44
44
  export declare function preparedUpRoot(value: string): string;
45
45
  /** Foreground controller stack: the terminal holds the stack's lifetime until SIGINT or SIGTERM,
46
- * which runs the same guarded whole-stack stop as bare `down`. `start`, when given, is the startup
47
- * this terminal already holds: a signal during it lets the start settle, then runs that stop. A
48
- * failed start still runs the stop, and its failure is thrown once the stop returns. The hold's end
49
- * sets the exit code: 0 when another command completed the stop or preserve, 130 or 143 after a
50
- * signal, whatever the start receipt set. */
46
+ * which runs the same guarded whole-stack stop as bare `down`. A hangup leaves the stack running and
47
+ * exits 129, naming `cotal down`. `start`, when given, is the startup this terminal already holds: a
48
+ * signal during it lets the start settle, then a stop signal runs that stop and a hangup leaves what
49
+ * the start left. A failed start still runs the stop, and its failure is thrown once the stop returns.
50
+ * The hold's end sets the exit code: 0 when another command completed the stop or preserve, 129 after
51
+ * a hangup, 130 or 143 after a stop signal, whatever the start receipt set. */
51
52
  export declare function holdForegroundStack(root: string, start?: () => Promise<void>): Promise<void>;
52
- /** The process of another foreground `up` that holds `root`'s stack, while that exact process runs. */
53
- export declare function foregroundHolder(root: string): number | undefined;
54
53
  /** The registered `up` command. When a background run is the main process of a systemd unit, it
55
54
  * names that unit and the `--foreground` remedy once startup returns: controller stack, retained
56
55
  * launcher, refresh and restore alike. It never changes the run's mode. Internal callers of
@@ -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,EAsEL,KAAK,SAAS,EA0Bd,KAAK,eAAe,EAiCrB,MAAM,qBAAqB,CAAC;AAmB7B,OAAO,EAA4C,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAa3G,OAAO,EAYL,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAEnB,MAAM,eAAe,CAAC;AAsBvB,OAAO,EAqBL,KAAK,eAAe,EAErB,MAAM,mBAAmB,CAAC;AAS3B;;8FAE8F;AAC9F,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;IAC9B,SAAS,EAAE,eAAe,CAAC,WAAW,CAAC,CAAC;IACxC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,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EAAE,MAAM,GAAG,MAAM,CAQlD;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAGrC,IAAI,EAAE,UAAU,GACf,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,OAAO,CAAC;IAAC,sBAAsB,EAAE,OAAO,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CA0C/M;AAuLD;;;;;;oGAMoG;AACpG,wBAAsB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsD3F;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAElF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEnF;AAED;;;;;;;;;;GAUG;AACH,KAAK,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AAExC;;mCAEmC;AACnC,eAAO,MAAM,oBAAoB,GAAI,GAAG,SAAS,EAAE,YAAY,UAAU,KAAG,IAAoC,CAAC"}
@@ -4,12 +4,12 @@ import { AsyncLocalStorage } from "node:async_hooks";
4
4
  import { createHash, randomUUID } from "node:crypto";
5
5
  import { createConnection, createServer, isIP } from "node:net";
6
6
  import { homedir, hostname } from "node:os";
7
- import { accessSync, constants, mkdirSync, readFileSync, existsSync, statSync, closeSync, lstatSync, realpathSync, readdirSync, rmdirSync, unlinkSync, } from "node:fs";
7
+ import { accessSync, constants, mkdirSync, readFileSync, existsSync, statSync, closeSync, lstatSync, realpathSync, readdirSync, rmdirSync, } from "node:fs";
8
8
  import { basename, dirname, isAbsolute, join, resolve } from "node:path";
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, spaceDeletionStreams, isJetStreamMissing, seedChannelRegistry, ensureDefaultDeliveryClass, UndecodableRegistryEntry, assertValidChannel, isConcreteChannel, validateChannelConfig, validateChannelDefaults, LEASE_TTL_MS, EpEnvelopeError, mkSecretDir, openPrivateAppend, realDirNoSymlink, writeSecretFile, writeSecretFileAtomic, utf16Problem, } from "@cotal-ai/core";
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, spaceDeletionStreams, isJetStreamMissing, seedChannelRegistry, ensureDefaultDeliveryClass, UndecodableRegistryEntry, assertValidChannel, isConcreteChannel, validateChannelConfig, validateChannelDefaults, LEASE_TTL_MS, EpEnvelopeError, mkSecretDir, openPrivateAppend, realDirNoSymlink, writeSecretFile, 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, WEB_CREDS_KIND, webCredsKey, 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, NATS_PIDFILE, UNTRUSTED_CERTIFICATE, exitCode, canonicalLocalProcessPath, DELIVERY_LOGFILE, terminalWidth, } from "@cotal-ai/workspace";
12
+ import { assertManagerName, readManagerName, readManagerSeatCap, recordManagerName, recordManagerSeatCap, parseSeatCapFlag, seatCapText, 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, WEB_CREDS_KIND, webCredsKey, 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, NATS_PIDFILE, UNTRUSTED_CERTIFICATE, exitCode, canonicalLocalProcessPath, DELIVERY_LOGFILE, terminalWidth, } 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";
@@ -43,6 +43,7 @@ import { checkLocalSpace } from "./space-registration.js";
43
43
  import { cleanedManifestStart, namedOpenConfig, retainedOpenSpace } from "../lib/legacy-start.js";
44
44
  import { bindReaches, canonicalServer, controllerStackApplies, recheckExistingStore, requestedStackMode, requestsTls, stackUp, stackUpForegroundNotice, stackUpInterruptNotice, keptOnUp, selectedOnUp, unparsableDaemonCredsNotice, } from "./stack-up.js";
45
45
  import { handOverStartupNotice, noticeOnInterrupt, releaseStartupNotice } from "../lib/interrupt-notice.js";
46
+ import { claimForegroundHold, foregroundHolder, releaseForegroundHold } from "../lib/foreground-hold.js";
46
47
  import { settleInterruptedLaunches } from "../lib/service-process.js";
47
48
  import { assertUserStackTransport, preflightUserStack } from "./stack-user-auth.js";
48
49
  import { stackDown } from "./stack-down.js";
@@ -571,12 +572,22 @@ function stopForegroundStack(root, signal) {
571
572
  process.stderr.write(`${renderReport(commandFailureReport(isCommandFailure(error) ? error : new CommandFailure("unknown", "OPERATION_UNKNOWN", "the foreground stack stop did not confirm its outcome; its members were retained")), "rich", process.stderr)}\n`);
572
573
  }).finally(() => { process.exitCode = signal === "SIGINT" ? 130 : 143; });
573
574
  }
575
+ /** A hangup, such as a closed terminal, is not a stop. The stack keeps running and the notice names
576
+ * the command that stops it. Release this process's hold before the immediate exit, which does not
577
+ * unwind the surrounding finally, so a later foreground `up` can take the running stack over. */
578
+ function hangupForegroundStack(root) {
579
+ process.stderr.write(`The terminal closed. This stack in ${root} is still running; \`cotal down\` stops it.\n`);
580
+ process.exitCode = 129;
581
+ releaseForegroundHold(root);
582
+ process.exit(129);
583
+ }
574
584
  /** Foreground controller stack: the terminal holds the stack's lifetime until SIGINT or SIGTERM,
575
- * which runs the same guarded whole-stack stop as bare `down`. `start`, when given, is the startup
576
- * this terminal already holds: a signal during it lets the start settle, then runs that stop. A
577
- * failed start still runs the stop, and its failure is thrown once the stop returns. The hold's end
578
- * sets the exit code: 0 when another command completed the stop or preserve, 130 or 143 after a
579
- * signal, whatever the start receipt set. */
585
+ * which runs the same guarded whole-stack stop as bare `down`. A hangup leaves the stack running and
586
+ * exits 129, naming `cotal down`. `start`, when given, is the startup this terminal already holds: a
587
+ * signal during it lets the start settle, then a stop signal runs that stop and a hangup leaves what
588
+ * the start left. A failed start still runs the stop, and its failure is thrown once the stop returns.
589
+ * The hold's end sets the exit code: 0 when another command completed the stop or preserve, 129 after
590
+ * a hangup, 130 or 143 after a stop signal, whatever the start receipt set. */
580
591
  export async function holdForegroundStack(root, start) {
581
592
  claimForegroundHold(root);
582
593
  try {
@@ -597,11 +608,14 @@ async function holdStack(root, start) {
597
608
  if (requested)
598
609
  return;
599
610
  requested = signal;
600
- process.stderr.write("Stop requested; the whole-stack stop runs once the start settles\n");
611
+ process.stderr.write(signal === "SIGHUP"
612
+ ? "The terminal closed; the start settles, then the stack is left running\n"
613
+ : "Stop requested; the whole-stack stop runs once the start settles\n");
601
614
  };
602
- const interrupt = () => request("SIGINT"), terminate = () => request("SIGTERM");
615
+ const interrupt = () => request("SIGINT"), terminate = () => request("SIGTERM"), hangup = () => request("SIGHUP");
603
616
  process.on("SIGINT", interrupt);
604
617
  process.on("SIGTERM", terminate);
618
+ process.on("SIGHUP", hangup);
605
619
  handOverStartupNotice();
606
620
  let failure;
607
621
  try {
@@ -610,9 +624,11 @@ async function holdStack(root, start) {
610
624
  catch (error) {
611
625
  failure = { error };
612
626
  }
613
- releaseStart = () => { process.off("SIGINT", interrupt); process.off("SIGTERM", terminate); };
627
+ releaseStart = () => { process.off("SIGINT", interrupt); process.off("SIGTERM", terminate); process.off("SIGHUP", hangup); };
614
628
  if (requested || failure)
615
629
  releaseStart();
630
+ if (requested === "SIGHUP")
631
+ hangupForegroundStack(root);
616
632
  if (requested)
617
633
  await stopForegroundStack(root, requested);
618
634
  if (failure)
@@ -640,6 +656,7 @@ async function holdStack(root, start) {
640
656
  stopping = true;
641
657
  process.off("SIGINT", interrupt);
642
658
  process.off("SIGTERM", terminate);
659
+ process.off("SIGHUP", hangup);
643
660
  clearInterval(lifetime);
644
661
  process.stderr.write(`${renderReport({ sections: [{ title: "Foreground stack released", blocks: [{ kind: "lines", lines: [`Another command completed a ${operation.kind === "down" ? "stop" : "preserve"} of this stack (operation ${operation.id}). This terminal no longer holds it.`] }] }] }, "rich", process.stderr)}\n`);
645
662
  process.exitCode = 0;
@@ -651,49 +668,21 @@ async function holdStack(root, start) {
651
668
  stopping = true;
652
669
  process.off("SIGINT", interrupt);
653
670
  process.off("SIGTERM", terminate);
671
+ process.off("SIGHUP", hangup);
654
672
  clearInterval(lifetime);
655
673
  void stopForegroundStack(root, signal).finally(resolveHold);
656
674
  };
657
675
  const interrupt = () => stop("SIGINT");
658
676
  const terminate = () => stop("SIGTERM");
677
+ const hangup = () => { if (!stopping)
678
+ hangupForegroundStack(root); };
659
679
  process.on("SIGINT", interrupt);
660
680
  process.on("SIGTERM", terminate);
681
+ process.on("SIGHUP", hangup);
661
682
  releaseStart();
662
683
  handOverStartupNotice();
663
684
  });
664
685
  }
665
- /** Where a foreground `up` records the process that holds its stack's lifetime. */
666
- const foregroundHoldPath = (root) => join(root, ".cotal", "stack-foreground.hold");
667
- /** The process of another foreground `up` that holds `root`'s stack, while that exact process runs. */
668
- export function foregroundHolder(root) {
669
- let raw;
670
- try {
671
- raw = readFileSync(foregroundHoldPath(root), "utf8");
672
- }
673
- catch {
674
- return undefined;
675
- }
676
- const read = parseRecord(raw);
677
- if (read.kind !== "record" || read.record.pid === process.pid)
678
- return undefined;
679
- return assertRecordIdentity(read.record).kind === "match" ? read.record.pid : undefined;
680
- }
681
- /** Record this process as the foreground holder of `root`'s stack. A host that cannot pin a process
682
- * start records nothing, so no later `up` refuses on a pid that may have been reused. */
683
- function claimForegroundHold(root) {
684
- const record = identityRecord(process.pid);
685
- if ("token" in record)
686
- writeSecretFileAtomic(foregroundHoldPath(root), `${formatRecord(record)}\n`);
687
- }
688
- /** Remove this process's foreground hold record, and leave one another process wrote. */
689
- function releaseForegroundHold(root) {
690
- try {
691
- const read = parseRecord(readFileSync(foregroundHoldPath(root), "utf8"));
692
- if (read.kind === "record" && read.record.pid === process.pid)
693
- unlinkSync(foregroundHoldPath(root));
694
- }
695
- catch { /* nothing recorded */ }
696
- }
697
686
  /** The registered `up` command. When a background run is the main process of a systemd unit, it
698
687
  * names that unit and the `--foreground` remedy once startup returns: controller stack, retained
699
688
  * launcher, refresh and restore alike. It never changes the run's mode. Internal callers of
@@ -2195,11 +2184,16 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
2195
2184
  // the failure is logged, never swallowed silently. Teardown is AWAITED before the broker is
2196
2185
  // signalled, so it never races a broker that is already going away.
2197
2186
  let stopping = false;
2187
+ // The signal that asked for the stop. The broker is then signalled SIGTERM, so its own exit
2188
+ // status is not the command's: SIGINT exits 130 and SIGTERM exits 143, as a controller stack's
2189
+ // foreground stop does.
2190
+ let stopSignal;
2198
2191
  let teardown;
2199
- const stop = () => {
2192
+ const stop = (signal) => {
2200
2193
  if (stopping)
2201
2194
  return; // a second Ctrl-C during teardown must not start a second teardown
2202
2195
  stopping = true;
2196
+ stopSignal = signal;
2203
2197
  // Once the broker has exited, its handler below is already running this teardown and reads
2204
2198
  // `stopping` when it is done.
2205
2199
  if (child.exitCode !== null || child.signalCode !== null)
@@ -2220,10 +2214,11 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
2220
2214
  child.kill("SIGTERM");
2221
2215
  })();
2222
2216
  };
2223
- process.on("SIGINT", stop);
2224
- process.on("SIGTERM", stop);
2225
- // The broker is gone — drop it from the registry (and the `current` pointer if it was the default)
2226
- // so a later `cotal spawn` doesn't try to join a dead mesh.
2217
+ process.on("SIGINT", () => stop("SIGINT"));
2218
+ process.on("SIGTERM", () => stop("SIGTERM"));
2219
+ // The broker is gone. Drop the registration this stop recorded, and the `current` pointer when it
2220
+ // names that registration, so a later `cotal spawn` does not join a dead mesh. A space named after
2221
+ // its folder keeps both, as `cotal down` does, so the name stays the folder's.
2227
2222
  child.on("exit", async (code, signal) => {
2228
2223
  if (failedListeners.has(child))
2229
2224
  return;
@@ -2246,13 +2241,13 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
2246
2241
  // this broker by design (it is the operator's, and only they remove it), so unrecording it on
2247
2242
  // our exit would delete a registration this process never owned.
2248
2243
  const mine = findMesh(space);
2249
- if (mine && mine.origin !== "manual" && mine.server === server && mine.root === cotalRoot()) {
2244
+ if (mine && mine.origin !== "manual" && mine.server === server && mine.root === cotalRoot() && !keepsRegistration(mine)) {
2250
2245
  removeMesh(space);
2251
2246
  if (getCurrent() === space)
2252
2247
  clearCurrent();
2253
2248
  }
2254
2249
  if (activationFinished)
2255
- process.exit(code ?? 0);
2250
+ process.exit(stopSignal === "SIGTERM" ? 143 : 130);
2256
2251
  }
2257
2252
  else {
2258
2253
  // The record is kept ON PURPOSE: it still names the store this broker opened, so a repair