@delali/sirannon-db 0.3.4-next.62 → 0.3.4

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 (108) hide show
  1. package/README.md +79 -56
  2. package/dist/backup/index.d.ts +44 -45
  3. package/dist/backup/index.mjs +7 -7
  4. package/dist/backup-scheduler/index.d.ts +42 -41
  5. package/dist/backup-scheduler/index.mjs +4 -4
  6. package/dist/baseline-Co3iIsN_.d.ts +19 -0
  7. package/dist/change-tracker-DqCdeEyx.d.ts +128 -0
  8. package/dist/{chunk-VOSJBZ6Q.mjs → chunk-2ES3DT4A.mjs} +71 -33
  9. package/dist/{chunk-6CMCO7S4.mjs → chunk-2O3PP4CF.mjs} +1 -1
  10. package/dist/{chunk-E7Q7HE46.mjs → chunk-3BZLZ47R.mjs} +26 -26
  11. package/dist/chunk-4KASJKKK.mjs +2501 -0
  12. package/dist/{chunk-MYNI2WFS.mjs → chunk-52XW3Z76.mjs} +40 -8
  13. package/dist/chunk-55YRLSM2.mjs +57 -0
  14. package/dist/{chunk-KDAHYFW7.mjs → chunk-6AOJCNRU.mjs} +5 -5
  15. package/dist/{chunk-KXTYR2OQ.mjs → chunk-A3PHCO6W.mjs} +39 -111
  16. package/dist/chunk-ADNWEHGZ.mjs +299 -0
  17. package/dist/{chunk-2QLXDHAP.mjs → chunk-BLMRNSUG.mjs} +11 -2
  18. package/dist/chunk-BVMZJOVM.mjs +5 -0
  19. package/dist/{chunk-IWGIYDMZ.mjs → chunk-BZWDPF4G.mjs} +1 -1
  20. package/dist/{chunk-YVF2ZJTE.mjs → chunk-CZL4D3BM.mjs} +1 -1
  21. package/dist/{chunk-7SC2TZAS.mjs → chunk-DX4WGJL7.mjs} +2 -2
  22. package/dist/{chunk-45MKELYA.mjs → chunk-ESTZZPT5.mjs} +132 -13
  23. package/dist/{chunk-QP5L5DFJ.mjs → chunk-FJPR2CJX.mjs} +3 -3
  24. package/dist/chunk-HR7K3GZW.mjs +36 -0
  25. package/dist/{chunk-LXCGPZPA.mjs → chunk-IEKIYO4V.mjs} +1 -1
  26. package/dist/{chunk-TUD5CJ76.mjs → chunk-KB4OLJAD.mjs} +26 -19
  27. package/dist/{chunk-PBRXXISQ.mjs → chunk-KINDFBQP.mjs} +3 -2
  28. package/dist/{chunk-E6IMX7RS.mjs → chunk-KJLNYOOL.mjs} +2 -2
  29. package/dist/{chunk-BTTFW4Z4.mjs → chunk-KU32OT4H.mjs} +2 -10
  30. package/dist/{chunk-JQWGHSEH.mjs → chunk-NVSQ2T5Q.mjs} +71 -70
  31. package/dist/{chunk-W4EUTJNT.mjs → chunk-NZGSDALX.mjs} +94 -96
  32. package/dist/{chunk-U445A3C4.mjs → chunk-QGVRRKB2.mjs} +1 -1
  33. package/dist/{chunk-GYCEJNU4.mjs → chunk-R7GBXNTO.mjs} +1 -1
  34. package/dist/{chunk-7C36BCSN.mjs → chunk-VDN6FHU4.mjs} +1 -1
  35. package/dist/{chunk-6IYS4WLH.mjs → chunk-VO3ZWA2G.mjs} +142 -115
  36. package/dist/chunk-WOMADPM4.mjs +12 -0
  37. package/dist/{chunk-OUSWVNWT.mjs → chunk-YCMB6GR4.mjs} +1 -1
  38. package/dist/{chunk-YNTDOFTN.mjs → chunk-YW7IKQ7T.mjs} +1 -1
  39. package/dist/{chunk-M2BEAH5I.mjs → chunk-ZN4HI5FK.mjs} +126 -72
  40. package/dist/{chunk-SBL6GN43.mjs → chunk-ZYWI45EN.mjs} +1 -1
  41. package/dist/client/index.d.ts +135 -137
  42. package/dist/client/index.mjs +177 -82
  43. package/dist/client/topology.d.ts +31 -31
  44. package/dist/client/topology.mjs +42 -23
  45. package/dist/client-base-BxTocU1x.d.ts +398 -0
  46. package/dist/client-streams-YKANXMWO.mjs +112 -0
  47. package/dist/codegen/cli.mjs +4 -4
  48. package/dist/codegen/index.d.ts +36 -29
  49. package/dist/codegen/index.mjs +4 -4
  50. package/dist/core/index.d.ts +130 -115
  51. package/dist/core/index.mjs +387 -297
  52. package/dist/core/writer-worker.mjs +3 -3
  53. package/dist/database-CGDsXW1K.d.ts +959 -0
  54. package/dist/database-backup-DcLhxoa1.d.ts +143 -0
  55. package/dist/driver/better-sqlite3.d.ts +11 -10
  56. package/dist/driver/better-sqlite3.mjs +11 -11
  57. package/dist/driver/bun.d.ts +9 -8
  58. package/dist/driver/expo.d.ts +6 -7
  59. package/dist/driver/node.d.ts +11 -10
  60. package/dist/driver/node.mjs +13 -11
  61. package/dist/driver/wa-sqlite.d.ts +6 -6
  62. package/dist/errors-CJUkQ-KL.d.ts +199 -0
  63. package/dist/file-migrations/index.d.ts +20 -18
  64. package/dist/file-migrations/index.mjs +3 -3
  65. package/dist/forward-rpc-VRWFZXHN.mjs +44 -0
  66. package/dist/operation-registry-CGhNT-Sn.d.ts +96 -0
  67. package/dist/primary-wins-CHNOYuN7.d.ts +81 -0
  68. package/dist/protocol-DFpNNsIT.d.ts +153 -0
  69. package/dist/query-types-5B02ixH0.d.ts +129 -0
  70. package/dist/react/index.d.ts +22 -22
  71. package/dist/replication/coordinator/etcd.d.ts +37 -31
  72. package/dist/replication/coordinator/etcd.mjs +296 -131
  73. package/dist/replication/index.d.ts +201 -161
  74. package/dist/replication/index.mjs +630 -529
  75. package/dist/restore-options-CH8mE-Tb.d.ts +84 -0
  76. package/dist/server/index.d.ts +201 -191
  77. package/dist/server/index.mjs +736 -619
  78. package/dist/server-options-aYtCkefX.d.ts +317 -0
  79. package/dist/server-streams-24XL4T43.mjs +254 -0
  80. package/dist/sirannon-J3EgPVD7.d.ts +179 -0
  81. package/dist/transport/grpc.d.ts +37 -24
  82. package/dist/transport/grpc.mjs +83 -3199
  83. package/dist/transport/memory.d.ts +25 -26
  84. package/dist/transport/memory.mjs +18 -9
  85. package/dist/types-BrAiDGOb.d.ts +505 -0
  86. package/dist/types-CEJG0eFS.d.ts +88 -0
  87. package/dist/types-Dc8oWlxj.d.ts +1580 -0
  88. package/dist/types-DqODKeOq.d.ts +123 -0
  89. package/dist/types-guEKSzMr.d.ts +367 -0
  90. package/package.json +7 -7
  91. package/dist/baseline-D93hcIEE.d.ts +0 -17
  92. package/dist/change-tracker-CjRFuZdB.d.ts +0 -144
  93. package/dist/client-base-Cmd9EVme.d.ts +0 -397
  94. package/dist/database-BLQvqjsw.d.ts +0 -917
  95. package/dist/database-backup-B7oszQ2n.d.ts +0 -141
  96. package/dist/errors-Dei4GdBb.d.ts +0 -196
  97. package/dist/operation-registry-oiPuSYI6.d.ts +0 -94
  98. package/dist/primary-wins-B0np8JS3.d.ts +0 -85
  99. package/dist/protocol-HI-nY8DD.d.ts +0 -152
  100. package/dist/query-types-p1liOP-b.d.ts +0 -127
  101. package/dist/restore-options-CksYsH1l.d.ts +0 -83
  102. package/dist/server-options-Bj5iJnjx.d.ts +0 -292
  103. package/dist/sirannon-BPxC5tC2.d.ts +0 -178
  104. package/dist/types-B0EhgDbr.d.ts +0 -340
  105. package/dist/types-CbjfRwrK.d.ts +0 -499
  106. package/dist/types-CjhxcjhA.d.ts +0 -123
  107. package/dist/types-DPSmjU54.d.ts +0 -1518
  108. package/dist/types-DTO4CYhW.d.ts +0 -88
@@ -1,14 +1,14 @@
1
- import { verifyBackupRecord } from './chunk-7SC2TZAS.mjs';
2
- import { BackupManager, BackupScheduler, DEFAULT_PIECE_BYTES, sendFileInPieces } from './chunk-JQWGHSEH.mjs';
3
- import { DEFAULT_BACKUP_NAME_PREFIX, defaultStagingDir, DEFAULT_CAPTURE_INTERVAL_MS, DEFAULT_FULL_COPY_INTERVAL_MS } from './chunk-LXCGPZPA.mjs';
1
+ import { verifyBackupRecord } from './chunk-DX4WGJL7.mjs';
2
+ import { BackupManager, BackupScheduler, DEFAULT_PIECE_BYTES, sendFileInPieces } from './chunk-NVSQ2T5Q.mjs';
3
+ import { DEFAULT_BACKUP_NAME_PREFIX, defaultStagingDir, DEFAULT_CAPTURE_INTERVAL_MS, DEFAULT_FULL_COPY_INTERVAL_MS } from './chunk-IEKIYO4V.mjs';
4
4
  import { WORKER_CANCELLED_CODE, WORKER_COPY_STOPPED_CODE, deserializeError } from './chunk-MVSES6MS.mjs';
5
- import { readCycleState, writeCycleState, removeCycleState, stagedCapturePath, captureAndCheckpointTurn } from './chunk-KDAHYFW7.mjs';
6
- import { checkpointLog } from './chunk-U445A3C4.mjs';
7
- import { logPathFor } from './chunk-E6IMX7RS.mjs';
8
- import { destinationWithDeadline, DEFAULT_DESTINATION_TIMEOUT_MS, reportQuietly } from './chunk-GYCEJNU4.mjs';
9
- import { DEFAULT_CHAIN_NAME, readBackupChains, appendChainRecord, appendChainHead, readChainHeadAt, readChainHeads } from './chunk-YVF2ZJTE.mjs';
5
+ import { readCycleState, writeCycleState, removeCycleState, stagedCapturePath, captureAndCheckpointTurn } from './chunk-6AOJCNRU.mjs';
6
+ import { checkpointLog } from './chunk-QGVRRKB2.mjs';
7
+ import { logPathFor } from './chunk-KJLNYOOL.mjs';
8
+ import { destinationWithDeadline, DEFAULT_DESTINATION_TIMEOUT_MS, reportQuietly } from './chunk-R7GBXNTO.mjs';
9
+ import { DEFAULT_CHAIN_NAME, readBackupChains, appendChainRecord, appendChainHead, readChainHeadAt, readChainHeads } from './chunk-CZL4D3BM.mjs';
10
10
  import { randomHex } from './chunk-QBBLSQHQ.mjs';
11
- import { SirannonError, ExtensionError } from './chunk-PBRXXISQ.mjs';
11
+ import { SirannonError, ExtensionError } from './chunk-KINDFBQP.mjs';
12
12
  import { Worker } from 'worker_threads';
13
13
  import { existsSync } from 'fs';
14
14
  import { resolve, dirname, join, sep } from 'path';
@@ -562,7 +562,7 @@ var BackupCycleStatusRecorder = class {
562
562
  latestRun;
563
563
  latestSkip;
564
564
  latestError;
565
- /** Marks a turn as under way and clears the progress the previous turn recorded. */
565
+ /** Marks a turn as in progress and clears the progress that the previous turn recorded. */
566
566
  turnStarted() {
567
567
  this.turnRunning = true;
568
568
  this.turnStartedAt = Date.now();
@@ -574,24 +574,24 @@ var BackupCycleStatusRecorder = class {
574
574
  this.turnStartedAt = 0;
575
575
  this.latestProgress = void 0;
576
576
  }
577
- /** Records how far the turn under way has got. */
577
+ /** Records the progress of the current turn. */
578
578
  progressed(progress) {
579
579
  this.latestProgress = progress;
580
580
  }
581
- /** Records what a finished turn wrote. */
581
+ /** Records the report of a finished backup. */
582
582
  ran(report) {
583
583
  this.latestRun = report;
584
584
  }
585
- /** Records a turn the cycle passed over. */
585
+ /** Records a skipped turn. */
586
586
  skipped(skip) {
587
587
  this.latestSkip = skip;
588
588
  }
589
589
  /**
590
- * Records a failure, under the code a caller matches on, along with how far
591
- * the run had got and which chain it was extending.
590
+ * Records a failure with its error code, the progress of the current backup,
591
+ * and the chain that the cycle extends.
592
592
  *
593
- * @param err - What the turn failed with.
594
- * @param chainId - The chain the cycle was extending, where it held one.
593
+ * @param err - The error that stops the turn.
594
+ * @param chainId - The chain that the cycle extends, where it holds one.
595
595
  */
596
596
  failed(err, chainId) {
597
597
  const at = Date.now();
@@ -605,10 +605,10 @@ var BackupCycleStatusRecorder = class {
605
605
  };
606
606
  }
607
607
  /**
608
- * Reads everything recorded so far.
608
+ * Returns everything recorded so far.
609
609
  *
610
- * @param chainId - The chain the cycle is extending, where it has one.
611
- * @returns What the cycle is doing, and what its recent turns produced.
610
+ * @param chainId - The chain that the cycle extends, where it holds one.
611
+ * @returns What the cycle is doing now, and the outcome of its recent turns.
612
612
  */
613
613
  read(chainId) {
614
614
  return {
@@ -631,24 +631,24 @@ var BackupTurnLog = class {
631
631
  record = new BackupCycleStatusRecorder();
632
632
  announced = /* @__PURE__ */ new Set();
633
633
  /**
634
- * Records a finished run and passes it to the caller.
634
+ * Records a finished backup and passes its report to the caller.
635
635
  *
636
- * @param report - What that run produced.
636
+ * @param report - The report of the backup.
637
637
  */
638
638
  ran(report) {
639
639
  this.record.ran(report);
640
640
  reportQuietly(this.audience.onRun, report);
641
641
  }
642
642
  /**
643
- * Records how far the run under way has reached and passes that to the caller.
643
+ * Records the progress of the current backup and passes it to the caller.
644
644
  *
645
- * @param progress - The counters that run has reached.
645
+ * @param progress - The current counters of that backup.
646
646
  */
647
647
  progressed(progress) {
648
648
  this.record.progressed(progress);
649
649
  reportQuietly(this.audience.onProgress, progress);
650
650
  }
651
- /** Marks a turn as under way, and forgets whatever failures the previous turn announced. */
651
+ /** Marks a turn as in progress, and clears the failures that the previous turn reported. */
652
652
  turnStarted() {
653
653
  this.announced.clear();
654
654
  this.record.turnStarted();
@@ -658,10 +658,10 @@ var BackupTurnLog = class {
658
658
  this.record.turnFinished();
659
659
  }
660
660
  /**
661
- * Records a failure as the turn's outcome and passes it to the caller.
661
+ * Records a failure as the outcome of the turn and passes it to the caller.
662
662
  *
663
- * @param err - What the turn failed with.
664
- * @param chainId - The chain to record it against, where the cycle holds one.
663
+ * @param err - The error that stops the turn.
664
+ * @param chainId - The chain to record the failure against, where the cycle holds one.
665
665
  */
666
666
  failed(err, chainId) {
667
667
  this.announced.add(err);
@@ -670,19 +670,19 @@ var BackupTurnLog = class {
670
670
  reportQuietly(this.audience.onError, failure);
671
671
  }
672
672
  /**
673
- * Answers whether this turn has already passed one failure to the caller.
673
+ * Returns whether this turn has already reported a given failure to the caller.
674
674
  *
675
675
  * @param err - The failure to look for.
676
- * @returns Whether the caller has already heard about that failure.
676
+ * @returns Whether this turn has already reported that failure.
677
677
  */
678
678
  hasAnnounced(err) {
679
679
  return this.announced.has(err);
680
680
  }
681
681
  /**
682
- * Records a turn the cycle passed over and passes it to the caller, stating
683
- * how much log this node was still holding as it skipped.
682
+ * Records a skipped turn and passes it to the caller, with the size of the
683
+ * write-ahead log on this node at the skip.
684
684
  *
685
- * @param skip - Why the cycle passed the turn over.
685
+ * @param skip - The reason that the cycle skips the turn.
686
686
  */
687
687
  async skipped(skip) {
688
688
  const held = await uncapturedLogBytes(this.logPath);
@@ -691,10 +691,10 @@ var BackupTurnLog = class {
691
691
  reportQuietly(this.audience.onSkip, passed);
692
692
  }
693
693
  /**
694
- * Reads everything recorded so far.
694
+ * Returns everything recorded so far.
695
695
  *
696
- * @param chainId - The chain the cycle is extending, where it has one.
697
- * @returns What the cycle is doing, and what its recent turns produced.
696
+ * @param chainId - The chain that the cycle extends, where it holds one.
697
+ * @returns What the cycle is doing now, and the outcome of its recent turns.
698
698
  */
699
699
  read(chainId) {
700
700
  return this.record.read(chainId);
@@ -705,10 +705,10 @@ var BackupTurnLog = class {
705
705
  var BackupCycleTimer = class {
706
706
  handle = null;
707
707
  /**
708
- * Starts repeating. At an interval of zero or less the cycle takes a turn
709
- * only when somebody asks it to.
708
+ * Starts the timer. At an interval of zero or less, the timer stays off and
709
+ * the cycle takes a turn only when a caller requests one.
710
710
  *
711
- * @param intervalMs - Milliseconds between one turn and the next.
711
+ * @param intervalMs - The number of milliseconds between one turn and the next.
712
712
  * @param tick - Called on every interval.
713
713
  */
714
714
  arm(intervalMs, tick) {
@@ -717,7 +717,7 @@ var BackupCycleTimer = class {
717
717
  this.handle = setInterval(tick, intervalMs);
718
718
  this.handle.unref?.();
719
719
  }
720
- /** Stops repeating. */
720
+ /** Stops the timer. */
721
721
  disarm() {
722
722
  if (!this.handle) return;
723
723
  clearInterval(this.handle);
@@ -727,10 +727,10 @@ var BackupCycleTimer = class {
727
727
  var SerialTurns = class {
728
728
  inFlight = Promise.resolve();
729
729
  /**
730
- * Starts an operation once every turn asked for before it has settled.
730
+ * Starts an operation once every turn requested before it settles.
731
731
  *
732
732
  * @param op - The turn to take.
733
- * @returns Whatever that turn produced.
733
+ * @returns The result of that turn.
734
734
  */
735
735
  run(op) {
736
736
  const turn = this.inFlight.then(op, op);
@@ -948,10 +948,10 @@ var BackupCycle = class {
948
948
  this.preferredNode = request.preferredNode ?? "replica";
949
949
  }
950
950
  /**
951
- * Picks a chain up where the previous run left it, or starts a new one with a
952
- * full copy, and then repeats on the interval. A chain picked up takes an
953
- * ordinary turn, so the frames written while this node was down reach the
954
- * destination rather than waiting for the first interval.
951
+ * Resumes the chain that the state file records, or starts a new chain with a
952
+ * full copy, and then repeats the turn on the interval. On a resumed chain,
953
+ * Sirannon takes an ordinary turn straight away, so it sends the frames written
954
+ * while this node was down to the destination before the first interval ends.
955
955
  */
956
956
  async start() {
957
957
  await mkdir(this.stagingDir, { recursive: true });
@@ -970,19 +970,19 @@ var BackupCycle = class {
970
970
  if (!this.stopped) this.timer.arm(this.intervalMs, () => void this.tick());
971
971
  }
972
972
  /**
973
- * Takes one turn now. A turn sends any capture still waiting, reads the
973
+ * Takes one turn now. In a turn, Sirannon sends any staged capture, reads the
974
974
  * frames written since the previous turn, and then checkpoints the log.
975
975
  *
976
- * One turn waits at a time. A call made while a turn is under way queues one
977
- * behind it, and every call after that joins the queued turn, which reads the
978
- * log once it begins and so covers their writes as well. Without that bound,
979
- * a caller asking repeatedly during a long full copy would build a queue of
980
- * turns with nothing left for any of them to capture.
976
+ * At most one turn waits in the queue. A call during a turn in progress
977
+ * queues one turn after it, and every later call returns that queued turn,
978
+ * which reads the log when it begins and so captures the writes of every one
979
+ * of those callers. Without that limit, repeated calls during a long full
980
+ * copy would build a queue of turns with nothing left to capture.
981
981
  *
982
- * A turn on a node whose group backs up from somewhere else writes nothing
983
- * and reports a skip.
982
+ * On a node whose replication group takes its backups from another node, a
983
+ * turn writes nothing and reports a skip.
984
984
  *
985
- * @returns What the turn wrote, or undefined where it wrote nothing.
985
+ * @returns The report of what the turn writes, or undefined where it writes nothing.
986
986
  */
987
987
  runOnce() {
988
988
  const queued = this.queued;
@@ -996,9 +996,8 @@ var BackupCycle = class {
996
996
  return turn;
997
997
  }
998
998
  /**
999
- * Stops the cycle. It captures the log one final time first, so the writes
1000
- * made since the previous turn reach the destination before the database
1001
- * closes behind it.
999
+ * Stops the cycle after one final turn, so that Sirannon sends the writes
1000
+ * made since the previous turn to the destination before the database closes.
1002
1001
  */
1003
1002
  async stop() {
1004
1003
  if (this.stopped) return;
@@ -1017,7 +1016,7 @@ var BackupCycle = class {
1017
1016
  });
1018
1017
  }
1019
1018
  /**
1020
- * Lists what the destination holds.
1019
+ * Returns every chain at the destination.
1021
1020
  *
1022
1021
  * @returns Every chain, newest first, each with its full copy and its change pieces.
1023
1022
  */
@@ -1025,34 +1024,33 @@ var BackupCycle = class {
1025
1024
  return readBackupChains(this.request.destination, this.chainName);
1026
1025
  }
1027
1026
  /**
1028
- * Reads what the cycle is doing at this moment, and what its recent turns
1029
- * produced.
1027
+ * Returns what the cycle is doing now and the outcome of its recent turns.
1030
1028
  *
1031
- * A caller following a long full copy reads this without having to wait on
1032
- * the turn, and it answers between turns as well.
1029
+ * It returns straight away, both during a long full copy and between turns.
1033
1030
  *
1034
- * @returns Whether a turn is under way, how far it has got, and the last run, skip, and failure.
1031
+ * @returns Whether a turn is in progress, the progress of that turn, and the last run, skip, and failure.
1035
1032
  */
1036
1033
  status() {
1037
1034
  return this.turnLog.read(this.state?.chainId);
1038
1035
  }
1039
1036
  /**
1040
- * Reads one of this chain's backups back out of the destination and compares
1041
- * it against the record the backup that wrote it left behind.
1037
+ * Reads one backup from the destination and checks it against its record in
1038
+ * the chains at that destination.
1042
1039
  *
1043
- * @param name - Name the backup is stored under.
1044
- * @returns The pieces read, the bytes they add up to, and the digest where the backup recorded one.
1040
+ * @param name - The name that Sirannon stores the backup under.
1041
+ * @returns The number of pieces read, their total size in bytes, and the fingerprint where the record holds one.
1045
1042
  */
1046
1043
  async verify(name) {
1047
1044
  return verifyBackupRecord(this.request.destination, await this.chains(), name);
1048
1045
  }
1049
1046
  /**
1050
- * Runs one turn and passes whatever broke it to the operator. A deeper step
1051
- * announces some failures itself and then raises them, so this announces a
1052
- * failure only where no step has announced it already. The operator therefore
1053
- * hears each failure exactly once. Sirannon empties a log the turn has
1054
- * outgrown once all of that is done, and the report of writes reaching no
1055
- * backup replaces whatever failure the turn recorded.
1047
+ * Runs one turn and reports to the operator any error that stops it. Some
1048
+ * deeper steps report a failure themselves before they throw it, so this
1049
+ * reports an error only where no step has reported it already, and the
1050
+ * operator receives each failure once. When the turn captures nothing and the
1051
+ * log has grown past the limit, Sirannon then empties the log, and the
1052
+ * resulting report of the writes that no backup holds replaces any failure
1053
+ * that the turn recorded.
1056
1054
  */
1057
1055
  runTurn(op) {
1058
1056
  return this.turns.run(async () => {
@@ -1072,7 +1070,7 @@ var BackupCycle = class {
1072
1070
  }
1073
1071
  });
1074
1072
  }
1075
- /** What the stand-down path needs of this cycle to let go of its chain. */
1073
+ /** The callbacks and paths that the stand-down code uses to release the chain of this cycle. */
1076
1074
  get standDownRequest() {
1077
1075
  return {
1078
1076
  request: this.request,
@@ -1087,7 +1085,7 @@ var BackupCycle = class {
1087
1085
  report: (err) => this.report(err)
1088
1086
  };
1089
1087
  }
1090
- /** Empties a log this turn captured nothing from, past the operator's limit. */
1088
+ /** Empties the log when this turn captures nothing from it and it has grown past the limit that the operator sets. */
1091
1089
  async releaseLogPastLimit() {
1092
1090
  if (this.stopped) return;
1093
1091
  try {
@@ -1097,10 +1095,11 @@ var BackupCycle = class {
1097
1095
  }
1098
1096
  }
1099
1097
  /**
1100
- * Asks whether this node takes the turn it is starting. A node the group
1101
- * backs up from somewhere else stands down from its chain and empties its
1102
- * log instead. A node that could not read its group holds everything where
1103
- * it is, because the frames it has yet to capture are still in no backup.
1098
+ * Returns whether this node takes the turn that it is starting. Where the
1099
+ * replication group takes its backups from another node, this node stands
1100
+ * down from its chain and empties its log. Where Sirannon cannot read the
1101
+ * group, this node keeps its chain and its log as they are, because no backup
1102
+ * holds the frames that it has yet to capture.
1104
1103
  */
1105
1104
  async takesTheTurn() {
1106
1105
  const decision = await decideBackupTurn(this.request.replicationGroup, this.preferredNode);
@@ -1115,7 +1114,7 @@ var BackupCycle = class {
1115
1114
  }
1116
1115
  return false;
1117
1116
  }
1118
- /** Passes a skipped turn on, where the cycle has a reason to give for it. */
1117
+ /** Reports a skipped turn when the decision carries a reason for it. */
1119
1118
  async reportSkip(skip) {
1120
1119
  if (skip) await this.turnLog.skipped(skip);
1121
1120
  }
@@ -1144,13 +1143,12 @@ var BackupCycle = class {
1144
1143
  this.state = null;
1145
1144
  }
1146
1145
  /**
1147
- * Runs one turn. A log that restarted before the capture reached it leaves a
1148
- * chain nothing can extend, so this starts a fresh one. The caller still gets
1149
- * the error: those writes are in no backup, and an operator has to hear that.
1150
- * Where the replacement chain also fails to start, Sirannon records that
1151
- * second failure against the chain the restart broke, because the cycle holds
1152
- * no chain of its own by then and an operator reading the status has to know
1153
- * which one they have lost.
1146
+ * Runs one turn. When the turn fails with `BACKUP_LOG_REWOUND` or
1147
+ * `BACKUP_CHAIN_BROKEN`, no later piece can extend the chain, so this starts a
1148
+ * new chain. The caller still receives the error, because no backup holds the
1149
+ * lost writes. Where the new chain also fails to start, Sirannon records that
1150
+ * second failure against the broken chain, because the cycle holds no chain by
1151
+ * then and the operator needs the status to name the chain that they lost.
1154
1152
  */
1155
1153
  async turnOrStartOver() {
1156
1154
  try {
@@ -1178,15 +1176,15 @@ var BackupCycle = class {
1178
1176
  return last;
1179
1177
  }
1180
1178
  /**
1181
- * Passes a failure to the operator and records it as the turn's outcome.
1179
+ * Reports a failure to the operator and records it as the outcome of the
1180
+ * turn, against the chain that the cycle holds now.
1182
1181
  *
1183
- * @param err - What the turn failed with.
1184
- * @param chainId - The chain to record it against, which defaults to the one the cycle holds now.
1182
+ * @param err - The error that stops the turn.
1185
1183
  */
1186
1184
  report(err) {
1187
1185
  this.turnLog.failed(err, this.state?.chainId);
1188
1186
  }
1189
- /** Records a failure against a chain the cycle may already have let go of. */
1187
+ /** Records a failure against a chain that the cycle may already have released. */
1190
1188
  reportAgainstChain(err, chainId) {
1191
1189
  this.turnLog.failed(err, chainId);
1192
1190
  }
@@ -1219,10 +1217,10 @@ var BackupCycle = class {
1219
1217
  this.captured = true;
1220
1218
  }
1221
1219
  /**
1222
- * Sends the capture staged against the chain this cycle holds. A turn offers
1223
- * a capture the destination has already refused no second time, because that
1224
- * second offer waits out the destination deadline again and delays every turn
1225
- * behind it.
1220
+ * Sends the capture staged against the chain that this cycle holds. Once the
1221
+ * destination refuses a capture, Sirannon skips the send for the rest of the
1222
+ * turn, because a second try would wait out the destination deadline again
1223
+ * and delay every turn queued after it.
1226
1224
  */
1227
1225
  async sendWaitingCapture() {
1228
1226
  if (this.sendRefused) return void 0;
@@ -1,4 +1,4 @@
1
- import { SirannonError } from './chunk-PBRXXISQ.mjs';
1
+ import { SirannonError } from './chunk-KINDFBQP.mjs';
2
2
  import { createHash } from 'crypto';
3
3
 
4
4
  // src/core/backup/checkpoint.ts
@@ -1,5 +1,5 @@
1
1
  import { invokeCallerCallback } from './chunk-QBBLSQHQ.mjs';
2
- import { SirannonError } from './chunk-PBRXXISQ.mjs';
2
+ import { SirannonError } from './chunk-KINDFBQP.mjs';
3
3
 
4
4
  // src/core/backup/cycle-callbacks.ts
5
5
  function reportQuietly(callback, value) {
@@ -1,4 +1,4 @@
1
- import { MigrationError } from './chunk-PBRXXISQ.mjs';
1
+ import { MigrationError } from './chunk-KINDFBQP.mjs';
2
2
 
3
3
  // src/core/migrations/lazy-down.ts
4
4
  var LAZY_DOWN_SQL = /* @__PURE__ */ Symbol("sirannon.file-migration.lazy-down");