@rizom/ops 0.2.0-alpha.417 → 0.2.0-alpha.419

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rizom/ops",
3
- "version": "0.2.0-alpha.417",
3
+ "version": "0.2.0-alpha.419",
4
4
  "description": "Operator CLI for managing private brain fleet registry repos",
5
5
  "keywords": [
6
6
  "brains",
@@ -570,6 +570,33 @@ function shellSafe(value: string, name: string): string {
570
570
  return value;
571
571
  }
572
572
 
573
+ /**
574
+ * Run inside the current runtime before capture. The snapshot proves itself
575
+ * (transactional copies, quick_check, checksums), so it needs a serving
576
+ * runtime with no queued work, not a healthy one: a deploy is often the fix
577
+ * for whatever a plugin reports as degraded. Degradation is named, not refused.
578
+ */
579
+ export function renderPredeployReadinessProgram(
580
+ healthUrl: string = "http://127.0.0.1:8080/health/ready",
581
+ ): string {
582
+ return `const response = await fetch(${JSON.stringify(healthUrl)});
583
+ const health = await response.json();
584
+ const queue = health.resources?.queue;
585
+ if (response.status !== 200 || health.status !== "ready") {
586
+ console.error("pre-deploy snapshot: current runtime is not ready");
587
+ process.exit(1);
588
+ }
589
+ if (queue && (queue.totals?.pending !== 0 || queue.totals?.processing !== 0 || queue.staleLeaseCount !== 0)) {
590
+ console.error("pre-deploy snapshot: job queue is not idle");
591
+ process.exit(1);
592
+ }
593
+ if (health.operationalStatus !== "operational") {
594
+ const degraded = (health.checks ?? []).filter((check) => check.status !== "healthy").map((check) => check.name);
595
+ console.error("pre-deploy snapshot: runtime is degraded (" + degraded.join(", ") + "); backing it up anyway");
596
+ }
597
+ `;
598
+ }
599
+
573
600
  export function renderPredeployBackupRemoteScript(options?: {
574
601
  captureProgramBase64?: string;
575
602
  }): string {
@@ -620,12 +647,7 @@ if [ "$status" != running ] || [ "$health" != healthy ]; then
620
647
  fi
621
648
 
622
649
  docker exec "$container" bun -e '
623
- const response = await fetch("http://127.0.0.1:8080/health/ready");
624
- const health = await response.json();
625
- const queue = health.resources?.queue;
626
- if (response.status !== 200 || health.status !== "ready" || health.operationalStatus !== "operational") process.exit(1);
627
- if (queue && (queue.totals?.pending !== 0 || queue.totals?.processing !== 0 || queue.staleLeaseCount !== 0)) process.exit(1);
628
- '
650
+ ${renderPredeployReadinessProgram()}'
629
651
 
630
652
  required_databases=(
631
653
  "$state_root/brain.db"
@@ -57,7 +57,7 @@ They are scaffolded from `@rizom/ops`, then versioned in this repo like any othe
57
57
 
58
58
  ## Verified pre-deploy rollback snapshots
59
59
 
60
- Deploy creates and verifies one target-scoped rollback snapshot after SSH and image readiness, immediately before optional stale-lock release and `kamal setup`. A snapshot failure stops the workflow before container replacement. A genuinely new server with no runtime or persistent state reports `not applicable`; persistent state without an identifiable runtime fails closed.
60
+ Deploy creates and verifies one target-scoped rollback snapshot after SSH and image readiness, immediately before optional stale-lock release and `kamal setup`. A snapshot failure stops the workflow before container replacement. The current runtime must be ready with an idle job queue; degradation a plugin reports is named in the log and backed up, not refused, because a deploy is often its fix. A genuinely new server with no runtime or persistent state reports `not applicable`; persistent state without an identifiable runtime fails closed.
61
61
 
62
62
  Each snapshot contains transaction-consistent online captures of the six canonical SQLite databases, database hashes and `quick_check` results, the deployed `brain.yaml`, sanitized container and mount metadata, and the Directory Sync checkout. Git capture includes all refs, an observed remote head, staged and unstaged binary patches, and mode-preserving archives of untracked and ignored files. Capture performs no checkout mutation or remote write.
63
63