@cotal-ai/cli 0.100.1 → 0.101.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.
- package/dist/chat/chat-view.d.ts.map +1 -1
- package/dist/chat/chat-view.js +5 -1
- package/dist/chat/chat-view.js.map +1 -1
- package/dist/chat/engine.d.ts +2 -1
- package/dist/chat/engine.d.ts.map +1 -1
- package/dist/chat/engine.js +2 -1
- package/dist/chat/engine.js.map +1 -1
- package/dist/chat/frontend.d.ts.map +1 -1
- package/dist/chat/frontend.js +13 -7
- package/dist/chat/frontend.js.map +1 -1
- package/dist/chat/native-session.d.ts +22 -3
- package/dist/chat/native-session.d.ts.map +1 -1
- package/dist/chat/native-session.js +91 -19
- package/dist/chat/native-session.js.map +1 -1
- package/dist/chat/open-session.d.ts +1 -0
- package/dist/chat/open-session.d.ts.map +1 -1
- package/dist/chat/open-session.js +1 -1
- package/dist/chat/open-session.js.map +1 -1
- package/dist/chat/picker.d.ts +5 -0
- package/dist/chat/picker.d.ts.map +1 -1
- package/dist/chat/picker.js +23 -10
- package/dist/chat/picker.js.map +1 -1
- package/dist/chat/plain.d.ts.map +1 -1
- package/dist/chat/plain.js +36 -10
- package/dist/chat/plain.js.map +1 -1
- package/dist/chat/session.d.ts +5 -0
- package/dist/chat/session.d.ts.map +1 -1
- package/dist/chat/static-session.d.ts +1 -0
- package/dist/chat/static-session.d.ts.map +1 -1
- package/dist/chat/static-session.js +24 -8
- package/dist/chat/static-session.js.map +1 -1
- package/dist/chat/stdio-io.d.ts +2 -0
- package/dist/chat/stdio-io.d.ts.map +1 -1
- package/dist/chat/stdio-io.js +6 -6
- package/dist/chat/stdio-io.js.map +1 -1
- package/dist/chat/stdio.d.ts +3 -2
- package/dist/chat/stdio.d.ts.map +1 -1
- package/dist/chat/stdio.js +26 -25
- package/dist/chat/stdio.js.map +1 -1
- package/dist/chat/user-session.d.ts +1 -0
- package/dist/chat/user-session.d.ts.map +1 -1
- package/dist/chat/user-session.js +1 -1
- package/dist/chat/user-session.js.map +1 -1
- package/dist/chat/view.d.ts +5 -4
- package/dist/chat/view.d.ts.map +1 -1
- package/dist/chat/view.js +10 -8
- package/dist/chat/view.js.map +1 -1
- package/dist/command.d.ts +5 -0
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +295 -82
- package/dist/command.js.map +1 -1
- package/dist/commands/agents.d.ts +29 -5
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +100 -35
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/backup-maintenance.d.ts.map +1 -1
- package/dist/commands/backup-maintenance.js +54 -21
- package/dist/commands/backup-maintenance.js.map +1 -1
- package/dist/commands/backup-read.d.ts.map +1 -1
- package/dist/commands/backup-read.js +13 -16
- package/dist/commands/backup-read.js.map +1 -1
- package/dist/commands/backup-restore.d.ts.map +1 -1
- package/dist/commands/backup-restore.js +20 -4
- package/dist/commands/backup-restore.js.map +1 -1
- package/dist/commands/backup.d.ts.map +1 -1
- package/dist/commands/backup.js +157 -29
- package/dist/commands/backup.js.map +1 -1
- package/dist/commands/channel-members.d.ts +1 -1
- package/dist/commands/channel-members.d.ts.map +1 -1
- package/dist/commands/channel-members.js +115 -29
- package/dist/commands/channel-members.js.map +1 -1
- package/dist/commands/channels.d.ts +11 -1
- package/dist/commands/channels.d.ts.map +1 -1
- package/dist/commands/channels.js +109 -20
- package/dist/commands/channels.js.map +1 -1
- package/dist/commands/chat.d.ts +11 -3
- package/dist/commands/chat.d.ts.map +1 -1
- package/dist/commands/chat.js +50 -22
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/clean.d.ts +10 -5
- package/dist/commands/clean.d.ts.map +1 -1
- package/dist/commands/clean.js +245 -42
- package/dist/commands/clean.js.map +1 -1
- package/dist/commands/completion.d.ts +15 -2
- package/dist/commands/completion.d.ts.map +1 -1
- package/dist/commands/completion.js +91 -26
- package/dist/commands/completion.js.map +1 -1
- package/dist/commands/config.d.ts +24 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +91 -15
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/console.d.ts.map +1 -1
- package/dist/commands/console.js +5 -4
- package/dist/commands/console.js.map +1 -1
- package/dist/commands/describe.d.ts +4 -2
- package/dist/commands/describe.d.ts.map +1 -1
- package/dist/commands/describe.js +4 -4
- package/dist/commands/describe.js.map +1 -1
- package/dist/commands/doctor.d.ts +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +261 -34
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/down-manifest.d.ts.map +1 -1
- package/dist/commands/down-manifest.js +9 -6
- package/dist/commands/down-manifest.js.map +1 -1
- package/dist/commands/down-services.d.ts +17 -16
- package/dist/commands/down-services.d.ts.map +1 -1
- package/dist/commands/down-services.js +29 -53
- package/dist/commands/down-services.js.map +1 -1
- package/dist/commands/down.d.ts +2 -2
- package/dist/commands/down.d.ts.map +1 -1
- package/dist/commands/down.js +96 -67
- package/dist/commands/down.js.map +1 -1
- package/dist/commands/endpoint-deregister.d.ts.map +1 -1
- package/dist/commands/endpoint-deregister.js +2 -2
- package/dist/commands/endpoint-deregister.js.map +1 -1
- package/dist/commands/endpoint.d.ts +2 -1
- package/dist/commands/endpoint.d.ts.map +1 -1
- package/dist/commands/endpoint.js +2 -2
- package/dist/commands/endpoint.js.map +1 -1
- package/dist/commands/endpoints.d.ts +1 -0
- package/dist/commands/endpoints.d.ts.map +1 -1
- package/dist/commands/endpoints.js +20 -5
- package/dist/commands/endpoints.js.map +1 -1
- package/dist/commands/feedback.d.ts.map +1 -1
- package/dist/commands/feedback.js +40 -2
- package/dist/commands/feedback.js.map +1 -1
- package/dist/commands/help.d.ts.map +1 -1
- package/dist/commands/help.js +2 -1
- package/dist/commands/help.js.map +1 -1
- package/dist/commands/history-clear.d.ts.map +1 -1
- package/dist/commands/history-clear.js +67 -51
- package/dist/commands/history-clear.js.map +1 -1
- package/dist/commands/history.d.ts +17 -2
- package/dist/commands/history.d.ts.map +1 -1
- package/dist/commands/history.js +221 -34
- package/dist/commands/history.js.map +1 -1
- package/dist/commands/join.d.ts +2 -0
- package/dist/commands/join.d.ts.map +1 -1
- package/dist/commands/join.js +132 -80
- package/dist/commands/join.js.map +1 -1
- package/dist/commands/meshes-add.d.ts +19 -4
- package/dist/commands/meshes-add.d.ts.map +1 -1
- package/dist/commands/meshes-add.js +114 -15
- package/dist/commands/meshes-add.js.map +1 -1
- package/dist/commands/meshes-wizard.d.ts +1 -0
- package/dist/commands/meshes-wizard.d.ts.map +1 -1
- package/dist/commands/meshes-wizard.js +45 -13
- package/dist/commands/meshes-wizard.js.map +1 -1
- package/dist/commands/meshes.d.ts +1 -1
- package/dist/commands/meshes.d.ts.map +1 -1
- package/dist/commands/meshes.js +76 -47
- package/dist/commands/meshes.js.map +1 -1
- package/dist/commands/mint.d.ts.map +1 -1
- package/dist/commands/mint.js +212 -19
- package/dist/commands/mint.js.map +1 -1
- package/dist/commands/models.d.ts +5 -1
- package/dist/commands/models.d.ts.map +1 -1
- package/dist/commands/models.js +21 -13
- package/dist/commands/models.js.map +1 -1
- package/dist/commands/persona-remote.d.ts.map +1 -1
- package/dist/commands/persona-remote.js +38 -19
- package/dist/commands/persona-remote.js.map +1 -1
- package/dist/commands/persona.d.ts +1 -1
- package/dist/commands/persona.d.ts.map +1 -1
- package/dist/commands/persona.js +92 -23
- package/dist/commands/persona.js.map +1 -1
- package/dist/commands/personas.d.ts.map +1 -1
- package/dist/commands/personas.js +59 -40
- package/dist/commands/personas.js.map +1 -1
- package/dist/commands/reset-space-apply.d.ts.map +1 -1
- package/dist/commands/reset-space-apply.js +69 -17
- package/dist/commands/reset-space-apply.js.map +1 -1
- package/dist/commands/reset-store-apply.d.ts +16 -0
- package/dist/commands/reset-store-apply.d.ts.map +1 -1
- package/dist/commands/reset-store-apply.js +122 -23
- package/dist/commands/reset-store-apply.js.map +1 -1
- package/dist/commands/reset.d.ts.map +1 -1
- package/dist/commands/reset.js +8 -7
- package/dist/commands/reset.js.map +1 -1
- package/dist/commands/revoke-credential.d.ts +5 -0
- package/dist/commands/revoke-credential.d.ts.map +1 -0
- package/dist/commands/revoke-credential.js +128 -0
- package/dist/commands/revoke-credential.js.map +1 -0
- package/dist/commands/send.d.ts +11 -3
- package/dist/commands/send.d.ts.map +1 -1
- package/dist/commands/send.js +284 -47
- package/dist/commands/send.js.map +1 -1
- package/dist/commands/service-actions.d.ts +2 -1
- package/dist/commands/service-actions.d.ts.map +1 -1
- package/dist/commands/service-actions.js +117 -21
- package/dist/commands/service-actions.js.map +1 -1
- package/dist/commands/service-log-follow.js +1 -1
- package/dist/commands/service-log-follow.js.map +1 -1
- package/dist/commands/service-registry.d.ts +1 -1
- package/dist/commands/service-registry.d.ts.map +1 -1
- package/dist/commands/service-registry.js +74 -30
- package/dist/commands/service-registry.js.map +1 -1
- package/dist/commands/service-set-stop.d.ts.map +1 -1
- package/dist/commands/service-set-stop.js +3 -2
- package/dist/commands/service-set-stop.js.map +1 -1
- package/dist/commands/setup-start.d.ts.map +1 -1
- package/dist/commands/setup-start.js +46 -5
- package/dist/commands/setup-start.js.map +1 -1
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +28 -13
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/space-delete.d.ts.map +1 -1
- package/dist/commands/space-delete.js +130 -41
- package/dist/commands/space-delete.js.map +1 -1
- package/dist/commands/space-registration.d.ts +13 -6
- package/dist/commands/space-registration.d.ts.map +1 -1
- package/dist/commands/space-registration.js +167 -46
- package/dist/commands/space-registration.js.map +1 -1
- package/dist/commands/space.d.ts +15 -1
- package/dist/commands/space.d.ts.map +1 -1
- package/dist/commands/space.js +66 -24
- package/dist/commands/space.js.map +1 -1
- package/dist/commands/spawn-preview.d.ts.map +1 -1
- package/dist/commands/spawn-preview.js +48 -10
- package/dist/commands/spawn-preview.js.map +1 -1
- package/dist/commands/spawn.d.ts +36 -13
- package/dist/commands/spawn.d.ts.map +1 -1
- package/dist/commands/spawn.js +263 -129
- package/dist/commands/spawn.js.map +1 -1
- package/dist/commands/stack-down.d.ts +9 -3
- package/dist/commands/stack-down.d.ts.map +1 -1
- package/dist/commands/stack-down.js +344 -64
- package/dist/commands/stack-down.js.map +1 -1
- package/dist/commands/stack-gone.d.ts +17 -0
- package/dist/commands/stack-gone.d.ts.map +1 -0
- package/dist/commands/stack-gone.js +218 -0
- package/dist/commands/stack-gone.js.map +1 -0
- package/dist/commands/stack-up.d.ts +64 -4
- package/dist/commands/stack-up.d.ts.map +1 -1
- package/dist/commands/stack-up.js +482 -55
- package/dist/commands/stack-up.js.map +1 -1
- package/dist/commands/status.d.ts +76 -2
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +550 -112
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/team-agent-apply.d.ts.map +1 -1
- package/dist/commands/team-agent-apply.js +4 -3
- package/dist/commands/team-agent-apply.js.map +1 -1
- package/dist/commands/team-agent-remove.d.ts.map +1 -1
- package/dist/commands/team-agent-remove.js +4 -4
- package/dist/commands/team-agent-remove.js.map +1 -1
- package/dist/commands/team-boot-controller.d.ts.map +1 -1
- package/dist/commands/team-boot-controller.js +8 -2
- package/dist/commands/team-boot-controller.js.map +1 -1
- package/dist/commands/team-channel-remove.d.ts.map +1 -1
- package/dist/commands/team-channel-remove.js +26 -10
- package/dist/commands/team-channel-remove.js.map +1 -1
- package/dist/commands/team-deploy-apply.d.ts.map +1 -1
- package/dist/commands/team-deploy-apply.js +4 -3
- package/dist/commands/team-deploy-apply.js.map +1 -1
- package/dist/commands/team-mixed-remove.js +5 -5
- package/dist/commands/team-mixed-remove.js.map +1 -1
- package/dist/commands/team.d.ts.map +1 -1
- package/dist/commands/team.js +94 -32
- package/dist/commands/team.js.map +1 -1
- package/dist/commands/telemetry.d.ts +1 -1
- package/dist/commands/telemetry.d.ts.map +1 -1
- package/dist/commands/telemetry.js +5 -3
- package/dist/commands/telemetry.js.map +1 -1
- package/dist/commands/topology.d.ts.map +1 -1
- package/dist/commands/topology.js +11 -7
- package/dist/commands/topology.js.map +1 -1
- package/dist/commands/up.d.ts +6 -6
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +963 -240
- package/dist/commands/up.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +9 -3
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/use.d.ts +5 -1
- package/dist/commands/use.d.ts.map +1 -1
- package/dist/commands/use.js +55 -12
- package/dist/commands/use.js.map +1 -1
- package/dist/commands/watch.d.ts +4 -1
- package/dist/commands/watch.d.ts.map +1 -1
- package/dist/commands/watch.js +15 -3
- package/dist/commands/watch.js.map +1 -1
- package/dist/commands/who.d.ts +2 -0
- package/dist/commands/who.d.ts.map +1 -1
- package/dist/commands/who.js +18 -5
- package/dist/commands/who.js.map +1 -1
- package/dist/commands/whoami.d.ts +44 -5
- package/dist/commands/whoami.d.ts.map +1 -1
- package/dist/commands/whoami.js +168 -16
- package/dist/commands/whoami.js.map +1 -1
- package/dist/console/app.d.ts +1 -1
- package/dist/console/app.d.ts.map +1 -1
- package/dist/console/app.js +15 -9
- package/dist/console/app.js.map +1 -1
- package/dist/console/launch.d.ts +25 -0
- package/dist/console/launch.d.ts.map +1 -0
- package/dist/console/launch.js +56 -0
- package/dist/console/launch.js.map +1 -0
- package/dist/console/ui/CommandPalette.d.ts +5 -4
- package/dist/console/ui/CommandPalette.d.ts.map +1 -1
- package/dist/console/ui/CommandPalette.js +136 -45
- package/dist/console/ui/CommandPalette.js.map +1 -1
- package/dist/console/ui/Help.js +1 -1
- package/dist/console/ui/Help.js.map +1 -1
- package/dist/console/ui/Modal.d.ts +10 -0
- package/dist/console/ui/Modal.d.ts.map +1 -0
- package/dist/console/ui/Modal.js +8 -0
- package/dist/console/ui/Modal.js.map +1 -0
- package/dist/console/ui/NewAgent.d.ts +14 -0
- package/dist/console/ui/NewAgent.d.ts.map +1 -0
- package/dist/console/ui/NewAgent.js +114 -0
- package/dist/console/ui/NewAgent.js.map +1 -0
- package/dist/console/ui/StatusBar.d.ts +1 -2
- package/dist/console/ui/StatusBar.d.ts.map +1 -1
- package/dist/console/ui/StatusBar.js +6 -8
- package/dist/console/ui/StatusBar.js.map +1 -1
- package/dist/console/ui/topo/Map.d.ts.map +1 -1
- package/dist/console/ui/topo/Map.js +1 -2
- package/dist/console/ui/topo/Map.js.map +1 -1
- package/dist/console/ui/topo/Matrix.js +2 -2
- package/dist/console/ui/topo/Matrix.js.map +1 -1
- package/dist/console/ui/topo/Sequence.d.ts.map +1 -1
- package/dist/console/ui/topo/Sequence.js +5 -4
- package/dist/console/ui/topo/Sequence.js.map +1 -1
- package/dist/console/ui/topo/model.d.ts +2 -1
- package/dist/console/ui/topo/model.d.ts.map +1 -1
- package/dist/console/ui/topo/model.js +4 -3
- package/dist/console/ui/topo/model.js.map +1 -1
- package/dist/exec-endpoint/service-adapter.d.ts.map +1 -1
- package/dist/exec-endpoint/service-adapter.js +13 -3
- package/dist/exec-endpoint/service-adapter.js.map +1 -1
- package/dist/ext-loader.d.ts +4 -0
- package/dist/ext-loader.d.ts.map +1 -1
- package/dist/ext-loader.js +6 -0
- package/dist/ext-loader.js.map +1 -1
- package/dist/help.d.ts.map +1 -1
- package/dist/help.js +44 -23
- package/dist/help.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +59 -54
- package/dist/index.js.map +1 -1
- package/dist/lib/agent-skills.d.ts.map +1 -1
- package/dist/lib/agent-skills.js +2 -1
- package/dist/lib/agent-skills.js.map +1 -1
- package/dist/lib/attach-client.js +2 -2
- package/dist/lib/attach-client.js.map +1 -1
- package/dist/lib/backup-artifact.d.ts +36 -8
- package/dist/lib/backup-artifact.d.ts.map +1 -1
- package/dist/lib/backup-artifact.js +156 -26
- package/dist/lib/backup-artifact.js.map +1 -1
- package/dist/lib/broker-service.d.ts +27 -3
- package/dist/lib/broker-service.d.ts.map +1 -1
- package/dist/lib/broker-service.js +135 -27
- package/dist/lib/broker-service.js.map +1 -1
- package/dist/lib/broker-store-health.d.ts +89 -0
- package/dist/lib/broker-store-health.d.ts.map +1 -0
- package/dist/lib/broker-store-health.js +171 -0
- package/dist/lib/broker-store-health.js.map +1 -0
- package/dist/lib/cancel.d.ts +4 -4
- package/dist/lib/cancel.d.ts.map +1 -1
- package/dist/lib/cancel.js +5 -5
- package/dist/lib/cancel.js.map +1 -1
- package/dist/lib/completion-install.d.ts +11 -2
- package/dist/lib/completion-install.d.ts.map +1 -1
- package/dist/lib/completion-install.js +79 -21
- package/dist/lib/completion-install.js.map +1 -1
- package/dist/lib/completion-scripts.d.ts.map +1 -1
- package/dist/lib/completion-scripts.js +2 -2
- package/dist/lib/completion-scripts.js.map +1 -1
- package/dist/lib/completion.d.ts +5 -1
- package/dist/lib/completion.d.ts.map +1 -1
- package/dist/lib/completion.js +10 -0
- package/dist/lib/completion.js.map +1 -1
- package/dist/lib/concrete-channel.d.ts +6 -0
- package/dist/lib/concrete-channel.d.ts.map +1 -0
- package/dist/lib/concrete-channel.js +17 -0
- package/dist/lib/concrete-channel.js.map +1 -0
- package/dist/lib/confirmation-required.d.ts +3 -12
- package/dist/lib/confirmation-required.d.ts.map +1 -1
- package/dist/lib/confirmation-required.js +9 -8
- package/dist/lib/confirmation-required.js.map +1 -1
- package/dist/lib/connect.d.ts +9 -0
- package/dist/lib/connect.d.ts.map +1 -1
- package/dist/lib/connect.js +27 -0
- package/dist/lib/connect.js.map +1 -1
- package/dist/lib/control.d.ts +42 -12
- package/dist/lib/control.d.ts.map +1 -1
- package/dist/lib/control.js +130 -31
- package/dist/lib/control.js.map +1 -1
- package/dist/lib/controller-restore.d.ts.map +1 -1
- package/dist/lib/controller-restore.js +12 -7
- package/dist/lib/controller-restore.js.map +1 -1
- package/dist/lib/credential-authority.d.ts.map +1 -1
- package/dist/lib/credential-authority.js +3 -0
- package/dist/lib/credential-authority.js.map +1 -1
- package/dist/lib/credential-exports.d.ts +17 -0
- package/dist/lib/credential-exports.d.ts.map +1 -0
- package/dist/lib/credential-exports.js +21 -0
- package/dist/lib/credential-exports.js.map +1 -0
- package/dist/lib/debug-flag.d.ts +4 -0
- package/dist/lib/debug-flag.d.ts.map +1 -0
- package/dist/lib/debug-flag.js +7 -0
- package/dist/lib/debug-flag.js.map +1 -0
- package/dist/lib/default-persona.d.ts +2 -0
- package/dist/lib/default-persona.d.ts.map +1 -1
- package/dist/lib/default-persona.js +2 -0
- package/dist/lib/default-persona.js.map +1 -1
- package/dist/lib/delivery-proc.d.ts +1 -1
- package/dist/lib/delivery-proc.d.ts.map +1 -1
- package/dist/lib/delivery-proc.js +5 -4
- package/dist/lib/delivery-proc.js.map +1 -1
- package/dist/lib/delivery-responder.d.ts +7 -3
- package/dist/lib/delivery-responder.d.ts.map +1 -1
- package/dist/lib/delivery-responder.js +8 -4
- package/dist/lib/delivery-responder.js.map +1 -1
- package/dist/lib/denied-write.d.ts +8 -0
- package/dist/lib/denied-write.d.ts.map +1 -0
- package/dist/lib/denied-write.js +24 -0
- package/dist/lib/denied-write.js.map +1 -0
- package/dist/lib/endpoint-capability-gates.js +2 -2
- package/dist/lib/endpoint-capability-gates.js.map +1 -1
- package/dist/lib/flag-value-refusal.d.ts +8 -0
- package/dist/lib/flag-value-refusal.d.ts.map +1 -0
- package/dist/lib/flag-value-refusal.js +10 -0
- package/dist/lib/flag-value-refusal.js.map +1 -0
- package/dist/lib/install-umask.d.ts +5 -0
- package/dist/lib/install-umask.d.ts.map +1 -1
- package/dist/lib/install-umask.js +25 -0
- package/dist/lib/install-umask.js.map +1 -1
- package/dist/lib/interrupt-notice.d.ts +23 -1
- package/dist/lib/interrupt-notice.d.ts.map +1 -1
- package/dist/lib/interrupt-notice.js +27 -6
- package/dist/lib/interrupt-notice.js.map +1 -1
- package/dist/lib/interrupt-report.d.ts +7 -0
- package/dist/lib/interrupt-report.d.ts.map +1 -0
- package/dist/lib/interrupt-report.js +24 -0
- package/dist/lib/interrupt-report.js.map +1 -0
- package/dist/lib/isolated-broker.d.ts +1 -1
- package/dist/lib/isolated-broker.d.ts.map +1 -1
- package/dist/lib/isolated-broker.js +17 -8
- package/dist/lib/isolated-broker.js.map +1 -1
- package/dist/lib/legacy-start.d.ts +8 -6
- package/dist/lib/legacy-start.d.ts.map +1 -1
- package/dist/lib/legacy-start.js +36 -36
- package/dist/lib/legacy-start.js.map +1 -1
- package/dist/lib/manager-choice.d.ts +45 -4
- package/dist/lib/manager-choice.d.ts.map +1 -1
- package/dist/lib/manager-choice.js +214 -24
- package/dist/lib/manager-choice.js.map +1 -1
- package/dist/lib/manager-proc.d.ts.map +1 -1
- package/dist/lib/manager-proc.js +7 -6
- package/dist/lib/manager-proc.js.map +1 -1
- package/dist/lib/manifest/index.d.ts +5 -1
- package/dist/lib/manifest/index.d.ts.map +1 -1
- package/dist/lib/manifest/index.js +50 -5
- package/dist/lib/manifest/index.js.map +1 -1
- package/dist/lib/manifest/preflight.d.ts +4 -0
- package/dist/lib/manifest/preflight.d.ts.map +1 -1
- package/dist/lib/manifest/preflight.js +18 -1
- package/dist/lib/manifest/preflight.js.map +1 -1
- package/dist/lib/manifest/resolve.d.ts +8 -0
- package/dist/lib/manifest/resolve.d.ts.map +1 -1
- package/dist/lib/manifest/resolve.js +104 -11
- package/dist/lib/manifest/resolve.js.map +1 -1
- package/dist/lib/missing-flags.js +1 -1
- package/dist/lib/missing-flags.js.map +1 -1
- package/dist/lib/nats-bin.d.ts +28 -5
- package/dist/lib/nats-bin.d.ts.map +1 -1
- package/dist/lib/nats-bin.js +85 -7
- package/dist/lib/nats-bin.js.map +1 -1
- package/dist/lib/nearest-word.d.ts +14 -0
- package/dist/lib/nearest-word.d.ts.map +1 -0
- package/dist/lib/nearest-word.js +76 -0
- package/dist/lib/nearest-word.js.map +1 -0
- package/dist/lib/no-expiry-record.d.ts +8 -0
- package/dist/lib/no-expiry-record.d.ts.map +1 -0
- package/dist/lib/no-expiry-record.js +27 -0
- package/dist/lib/no-expiry-record.js.map +1 -0
- package/dist/lib/paths.d.ts +31 -0
- package/dist/lib/paths.d.ts.map +1 -1
- package/dist/lib/paths.js +92 -2
- package/dist/lib/paths.js.map +1 -1
- package/dist/lib/persona-files.d.ts +29 -6
- package/dist/lib/persona-files.d.ts.map +1 -1
- package/dist/lib/persona-files.js +179 -36
- package/dist/lib/persona-files.js.map +1 -1
- package/dist/lib/personas.d.ts +18 -1
- package/dist/lib/personas.d.ts.map +1 -1
- package/dist/lib/personas.js +65 -6
- package/dist/lib/personas.js.map +1 -1
- package/dist/lib/prompts.d.ts +7 -1
- package/dist/lib/prompts.d.ts.map +1 -1
- package/dist/lib/prompts.js +43 -3
- package/dist/lib/prompts.js.map +1 -1
- package/dist/lib/registry-errors.d.ts +2 -1
- package/dist/lib/registry-errors.d.ts.map +1 -1
- package/dist/lib/registry-errors.js +6 -2
- package/dist/lib/registry-errors.js.map +1 -1
- package/dist/lib/reset-space-plan.d.ts +2 -0
- package/dist/lib/reset-space-plan.d.ts.map +1 -1
- package/dist/lib/reset-space-plan.js +1 -1
- package/dist/lib/reset-space-plan.js.map +1 -1
- package/dist/lib/restore.d.ts +45 -3
- package/dist/lib/restore.d.ts.map +1 -1
- package/dist/lib/restore.js +248 -35
- package/dist/lib/restore.js.map +1 -1
- package/dist/lib/rolled-back-runs.d.ts +36 -0
- package/dist/lib/rolled-back-runs.d.ts.map +1 -0
- package/dist/lib/rolled-back-runs.js +96 -0
- package/dist/lib/rolled-back-runs.js.map +1 -0
- package/dist/lib/service-definitions.d.ts +16 -3
- package/dist/lib/service-definitions.d.ts.map +1 -1
- package/dist/lib/service-definitions.js +99 -27
- package/dist/lib/service-definitions.js.map +1 -1
- package/dist/lib/service-instances.d.ts +13 -1
- package/dist/lib/service-instances.d.ts.map +1 -1
- package/dist/lib/service-instances.js +56 -12
- package/dist/lib/service-instances.js.map +1 -1
- package/dist/lib/service-presets.d.ts.map +1 -1
- package/dist/lib/service-presets.js +16 -0
- package/dist/lib/service-presets.js.map +1 -1
- package/dist/lib/service-process.d.ts +51 -8
- package/dist/lib/service-process.d.ts.map +1 -1
- package/dist/lib/service-process.js +385 -48
- package/dist/lib/service-process.js.map +1 -1
- package/dist/lib/space-streams.d.ts +18 -0
- package/dist/lib/space-streams.d.ts.map +1 -0
- package/dist/lib/space-streams.js +35 -0
- package/dist/lib/space-streams.js.map +1 -0
- package/dist/lib/spawn-defaults.d.ts +25 -1
- package/dist/lib/spawn-defaults.d.ts.map +1 -1
- package/dist/lib/spawn-defaults.js +37 -1
- package/dist/lib/spawn-defaults.js.map +1 -1
- package/dist/lib/stack-journal.d.ts +157 -14
- package/dist/lib/stack-journal.d.ts.map +1 -1
- package/dist/lib/stack-journal.js +406 -49
- package/dist/lib/stack-journal.js.map +1 -1
- package/dist/lib/stack-listeners.d.ts +17 -0
- package/dist/lib/stack-listeners.d.ts.map +1 -0
- package/dist/lib/stack-listeners.js +54 -0
- package/dist/lib/stack-listeners.js.map +1 -0
- package/dist/lib/stack-members.d.ts +13 -0
- package/dist/lib/stack-members.d.ts.map +1 -0
- package/dist/lib/stack-members.js +24 -0
- package/dist/lib/stack-members.js.map +1 -0
- package/dist/lib/stack-resume.d.ts.map +1 -1
- package/dist/lib/stack-resume.js +5 -2
- package/dist/lib/stack-resume.js.map +1 -1
- package/dist/lib/stack-runs.d.ts +34 -0
- package/dist/lib/stack-runs.d.ts.map +1 -0
- package/dist/lib/stack-runs.js +75 -0
- package/dist/lib/stack-runs.js.map +1 -0
- package/dist/lib/status.d.ts +11 -0
- package/dist/lib/status.d.ts.map +1 -1
- package/dist/lib/status.js +4 -5
- package/dist/lib/status.js.map +1 -1
- package/dist/lib/stdout-owner.d.ts +12 -3
- package/dist/lib/stdout-owner.d.ts.map +1 -1
- package/dist/lib/stdout-owner.js +33 -5
- package/dist/lib/stdout-owner.js.map +1 -1
- package/dist/lib/store-dir.d.ts +68 -4
- package/dist/lib/store-dir.d.ts.map +1 -1
- package/dist/lib/store-dir.js +253 -17
- package/dist/lib/store-dir.js.map +1 -1
- package/dist/lib/team-additive-attempt.d.ts +1 -1
- package/dist/lib/team-channel-removal.d.ts.map +1 -1
- package/dist/lib/team-channel-removal.js +4 -0
- package/dist/lib/team-channel-removal.js.map +1 -1
- package/dist/lib/team-deploy-inspection.d.ts +13 -0
- package/dist/lib/team-deploy-inspection.d.ts.map +1 -1
- package/dist/lib/team-deploy-inspection.js +12 -0
- package/dist/lib/team-deploy-inspection.js.map +1 -1
- package/dist/lib/team-text.d.ts +6 -0
- package/dist/lib/team-text.d.ts.map +1 -0
- package/dist/lib/team-text.js +36 -0
- package/dist/lib/team-text.js.map +1 -0
- package/dist/lib/transient.d.ts +14 -8
- package/dist/lib/transient.d.ts.map +1 -1
- package/dist/lib/transient.js +72 -11
- package/dist/lib/transient.js.map +1 -1
- package/dist/lib/unusable-file.d.ts +13 -0
- package/dist/lib/unusable-file.d.ts.map +1 -0
- package/dist/lib/unusable-file.js +12 -0
- package/dist/lib/unusable-file.js.map +1 -0
- package/dist/lib/up-report.d.ts +6 -0
- package/dist/lib/up-report.d.ts.map +1 -1
- package/dist/lib/up-report.js +13 -0
- package/dist/lib/up-report.js.map +1 -1
- package/dist/lib/verdict.d.ts +14 -0
- package/dist/lib/verdict.d.ts.map +1 -0
- package/dist/lib/verdict.js +15 -0
- package/dist/lib/verdict.js.map +1 -0
- package/dist/managed-handoff.d.ts +11 -6
- package/dist/managed-handoff.d.ts.map +1 -1
- package/dist/managed-handoff.js +27 -18
- package/dist/managed-handoff.js.map +1 -1
- package/dist/render.d.ts +5 -2
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +44 -10
- package/dist/render.js.map +1 -1
- package/dist/telemetry.d.ts +4 -3
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +14 -6
- package/dist/telemetry.js.map +1 -1
- package/dist/ui.d.ts +3 -2
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +6 -4
- package/dist/ui.js.map +1 -1
- package/dist/view/mesh-view.d.ts.map +1 -1
- package/dist/view/mesh-view.js +4 -1
- package/dist/view/mesh-view.js.map +1 -1
- package/dist/watch-data.d.ts +9 -1
- package/dist/watch-data.d.ts.map +1 -1
- package/dist/watch-data.js +17 -3
- package/dist/watch-data.js.map +1 -1
- package/dist/watch-json.js +4 -3
- package/dist/watch-json.js.map +1 -1
- package/package.json +5 -5
package/dist/lib/restore.js
CHANGED
|
@@ -4,13 +4,17 @@ import { hostname } from "node:os";
|
|
|
4
4
|
import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
5
5
|
import { jetstreamManager } from "@nats-io/jetstream";
|
|
6
6
|
import { Kvm } from "@nats-io/kv";
|
|
7
|
-
import { canonicalBackupStreamConfig, consumerConfigFromCheckpoint, deliveryBucket, downloadStreamSnapshot, finalizeStreamRestore, hardenPrivate, initiateStreamRestore, LEASE_TTL_MS, managerBucket, MANAGER_LEASE_TTL_MS, membershipBucket, MEMBERSHIP_MAX_BYTES, PRESENCE_STORAGE, presenceBucket, recordsBucket, recreateConsumerCheckpoint, spaceBackupInventory, uploadStreamRestoreChunk, validateSpaceAuth, validateSpaceBackupInventory, validateBackupStreamState, validateCanonicalBackupStreamConfig, createEndpointStreams, ensureArtifactStore, hardenedAuthorityStreamNames, } from "@cotal-ai/core";
|
|
8
|
-
import { CommandFailure, acquireMaintenanceLock, assessRestoreClaim, bindRestoreListener, bindRestoreTarget, cutController, getSpaceAuth, markRestoreActive, settleTokenHandoff, markRestoreDegraded, moveSamePathRestoreSource, prepareAlternateRestore, prepareMissingSourceRestore, prepareSamePathRestore, localProcessOwnerStatus, readMaintenanceJournal, readMaintenanceResumeDocument, recordRestoreAttemptResources, recordRestoreManagerCommit, replaceDeadRestoreListener, repairRestoreDegradedToActive, releaseMaintenanceLock, workspaceSecretStore, writeRestoreCommitIntent, readStoreIdentity, } from "@cotal-ai/workspace";
|
|
9
|
-
import { readStagedCheckpoints, stageArtifact } from "./backup-artifact.js";
|
|
7
|
+
import { canonicalBackupStreamConfig, consumerConfigFromCheckpoint, deliveryBucket, downloadStreamSnapshot, finalizeStreamRestore, hardenPrivate, initiateStreamRestore, LEASE_TTL_MS, managerBucket, MANAGER_LEASE_TTL_MS, membershipBucket, MEMBERSHIP_MAX_BYTES, PRESENCE_STORAGE, presenceBucket, recordsBucket, recreateConsumerCheckpoint, spaceBackupInventory, uploadStreamRestoreChunk, validateSpaceAuth, validateSpaceBackupInventory, validateBackupStreamState, validateCanonicalBackupStreamConfig, createEndpointStreams, ensureArtifactStore, hardenedAuthorityStreamNames, wfjStreamName, } from "@cotal-ai/core";
|
|
8
|
+
import { CommandFailure, acquireMaintenanceLock, assessMaintenanceClaim, assessRestoreClaim, bindRestoreListener, bindRestoreTarget, cutController, getSpaceAuth, markRestoreActive, settleTokenHandoff, markRestoreDegraded, moveSamePathRestoreSource, prepareAlternateRestore, prepareMissingSourceRestore, prepareSamePathRestore, localProcessOwnerStatus, readMaintenanceJournal, restoreLeftOut, restoreReplacedNewerCut, restoreRolledBackRuns, readMaintenanceResumeDocument, recordRestoreAttemptResources, recordRestoreManagerCommit, replaceDeadRestoreListener, repairRestoreDegradedToActive, releaseMaintenanceLock, shellPath, workspaceSecretStore, writeRestoreCommitIntent, readStoreIdentity, } from "@cotal-ai/workspace";
|
|
9
|
+
import { ArtifactFileFault, artifactStreams, BACKUP_MANIFEST_FORMAT_V1, missingBackupPath, missingBackupPathText, notAnArtifactRefusal, readStagedCheckpoints, stageArtifact } from "./backup-artifact.js";
|
|
10
10
|
import { authorityFingerprint } from "./maintenance-files.js";
|
|
11
11
|
import { attemptProcessesGone, connectIsolatedBroker, ensurePrivateAttemptsDir, startIsolatedBroker, sweepAttemptResidue } from "./isolated-broker.js";
|
|
12
|
+
import { readPreviousRunJournals, readRunJournals, rolledBackRuns } from "./rolled-back-runs.js";
|
|
12
13
|
import { noticeOnInterrupt } from "./interrupt-notice.js";
|
|
14
|
+
import { displayCmd } from "./self-exec.js";
|
|
15
|
+
import { assertEndpointUnreachable } from "./endpoint-cut.js";
|
|
13
16
|
import { acquireStackOperationLock } from "./stack-journal.js";
|
|
17
|
+
import { foreignEntriesRefusal, oldStoreForeignEntries } from "./store-dir.js";
|
|
14
18
|
import { admitAndRestoreSeatCheckpoints } from "./seat-resume.js";
|
|
15
19
|
import { assertControllerRestorable, reconfigureControllerBroker, rollbackRestoreWithBroker } from "./controller-restore.js";
|
|
16
20
|
import { assertControllerCoupling, newControllerAttemptLaunch } from "./controller-resume.js";
|
|
@@ -60,6 +64,7 @@ export function rehydratePreparedRestore(root, journal) {
|
|
|
60
64
|
runtime: launchString(journal.launch, "runtime"),
|
|
61
65
|
detached: journal.launch.detached === true,
|
|
62
66
|
selection: restoreOnly,
|
|
67
|
+
restoredStreams: journaledRestoredStreams(journal.launch, journal.space, journal.mode),
|
|
63
68
|
inventory: resume.inventory,
|
|
64
69
|
serverName,
|
|
65
70
|
serverNonce,
|
|
@@ -164,11 +169,37 @@ function canonicalServerEndpoint(value) {
|
|
|
164
169
|
throw new Error(`restore listener endpoint is not canonicalizable: ${value}`);
|
|
165
170
|
return `${endpoint.protocol}//${endpoint.hostname.toLowerCase()}:${endpoint.port || "4222"}`;
|
|
166
171
|
}
|
|
172
|
+
/** Whether `path` is a link that resolves to `target`. A dangling link resolves nowhere. */
|
|
173
|
+
function linksTo(path, target) {
|
|
174
|
+
if (!lstatSync(path, { throwIfNoEntry: false })?.isSymbolicLink())
|
|
175
|
+
return false;
|
|
176
|
+
try {
|
|
177
|
+
return realpathSync.native(path) === target;
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
167
183
|
function contains(parent, child) {
|
|
168
184
|
const path = relative(parent, child);
|
|
169
185
|
const separator = process.platform === "win32" ? "\\" : "/";
|
|
170
186
|
return path === "" || (path !== ".." && !path.startsWith(`..${separator}`) && !isAbsolute(path));
|
|
171
187
|
}
|
|
188
|
+
/** The refusal for a restore artifact that is, holds or sits inside the store the restore replaces
|
|
189
|
+
* or this root's maintenance folder, where it stages its attempt, or `undefined` when it is clear
|
|
190
|
+
* of both. `artifact` and `store` are real paths. */
|
|
191
|
+
function artifactOverlapRefusal(root, artifact, store) {
|
|
192
|
+
for (const [path, what, why] of [
|
|
193
|
+
[store, "the preserved store", " it would replace"],
|
|
194
|
+
[realpathSync.native(join(root, ".cotal", "maintenance")), "this root's maintenance folder", ", where it stages its attempt"],
|
|
195
|
+
]) {
|
|
196
|
+
if (!contains(path, artifact) && !contains(artifact, path))
|
|
197
|
+
continue;
|
|
198
|
+
const relation = artifact === path ? "is" : contains(path, artifact) ? "is inside" : "holds";
|
|
199
|
+
return new CommandFailure("refused", "USAGE_INVALID", `the restore artifact ${artifact} ${relation} ${what}${relation === "is" ? "" : ` ${path}`}${why}; nothing was restored`, { target: { root, directory: artifact, overlaps: path }, remedy: `name a backup artifact folder outside ${path}`, selfContained: true });
|
|
200
|
+
}
|
|
201
|
+
return undefined;
|
|
202
|
+
}
|
|
172
203
|
/** An explicit `--store-dir` names the directory a restore creates and owns for its rollback, so it
|
|
173
204
|
* must not exist yet and its parent must. Either mistake is a usage refusal before anything is
|
|
174
205
|
* staged. The preserved source itself is the same-path restore. */
|
|
@@ -231,10 +262,10 @@ async function validateManifest(manifest, flags, ready, currentAuthority) {
|
|
|
231
262
|
throw new Error("--open conflicts with the backup auth mode");
|
|
232
263
|
if (flags["user-auth"] && manifest.mode !== "user")
|
|
233
264
|
throw new Error("--user-auth conflicts with the backup auth mode");
|
|
234
|
-
const
|
|
235
|
-
const selected = flags["restore-only"] === "registry" ?
|
|
265
|
+
const held = artifactStreams(manifest);
|
|
266
|
+
const selected = flags["restore-only"] === "registry" ? spaceBackupInventory(manifest.space).registry : held;
|
|
236
267
|
const actual = manifest.streams.map((entry) => entry.stream);
|
|
237
|
-
if (new Set(actual).size !== actual.length || JSON.stringify([...actual].sort()) !== JSON.stringify([...
|
|
268
|
+
if (new Set(actual).size !== actual.length || JSON.stringify([...actual].sort()) !== JSON.stringify([...held].sort()))
|
|
238
269
|
throw new Error("backup manifest stream inventory does not match its selection");
|
|
239
270
|
for (const stream of selected) {
|
|
240
271
|
const record = manifest.streams.find((entry) => entry.stream === stream);
|
|
@@ -251,10 +282,21 @@ async function validateManifest(manifest, flags, ready, currentAuthority) {
|
|
|
251
282
|
// on a 30-day cadence, "you rotated after taking this backup" is the common case, not an exotic
|
|
252
283
|
// one. Without this the operator sees an opaque fingerprint mismatch on the artifact they were
|
|
253
284
|
// counting on during a disaster.
|
|
285
|
+
// Checked before any transition, as the space is above: a refusal, not an unknown outcome.
|
|
254
286
|
const sameAccount = manifest.authority?.account !== undefined && manifest.authority.account === currentAuthority.account;
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
287
|
+
// A registry restore does not check the trust state, so an artifact that holds the registry
|
|
288
|
+
// still restores that here, and the Next says how.
|
|
289
|
+
const registry = spaceBackupInventory(manifest.space).registry.every((stream) => held.includes(stream))
|
|
290
|
+
? `; its channel registry still restores here with cotal backup restore ${shellPath(resolve(flags.restore))} --only registry, and chat and DM history and workflow runs then start empty`
|
|
291
|
+
: "";
|
|
292
|
+
throw new CommandFailure("refused", "CONFLICT", sameAccount
|
|
293
|
+
? "backup authority fingerprint does not match current trust state: the data account is unchanged, so the OPERATOR/SYSTEM half of the trust chain moved - this artifact predates a system-account rotation (`cotal up --rotate-sys`) and is bound to the retired chain; the preserved cut was not changed"
|
|
294
|
+
: "backup authority fingerprint does not match current trust state: this full artifact was taken under another trust state, such as another machine's or a reset root's; the preserved cut was not changed", {
|
|
295
|
+
target: { space: ready.space },
|
|
296
|
+
remedy: (sameAccount
|
|
297
|
+
? "restore it into a root holding that chain, or use a backup taken after the rotation"
|
|
298
|
+
: "a full backup restores only into a root that still holds the trust state it was taken under: restore it there, or use a full backup taken on this root") + registry,
|
|
299
|
+
});
|
|
258
300
|
}
|
|
259
301
|
}
|
|
260
302
|
}
|
|
@@ -392,10 +434,13 @@ async function recreateCheckpoint(broker, space, checkpoint) {
|
|
|
392
434
|
await nc.drain().catch(() => { });
|
|
393
435
|
}
|
|
394
436
|
}
|
|
395
|
-
async function createOmittedInfrastructure(broker, space,
|
|
437
|
+
async function createOmittedInfrastructure(broker, space, restored) {
|
|
396
438
|
const inventory = spaceBackupInventory(space);
|
|
397
|
-
|
|
398
|
-
|
|
439
|
+
// The workflow stores are endpoint stores: createEndpointStreams below creates the ones the
|
|
440
|
+
// artifact did not hold and verifies the restored ones.
|
|
441
|
+
const workflow = inventory.backedUp.filter((entry) => entry.class === "workflow").map((entry) => entry.name);
|
|
442
|
+
const create = inventory.full.filter((name) => !restored.includes(name) && !workflow.includes(name));
|
|
443
|
+
const excluded = [...workflow, ...inventory.excluded.map((entry) => entry.name)];
|
|
399
444
|
const login = await broker.addLogin({
|
|
400
445
|
profile: "infrastructure",
|
|
401
446
|
streams: [...create, ...excluded],
|
|
@@ -415,8 +460,9 @@ async function createOmittedInfrastructure(broker, space, registryOnly) {
|
|
|
415
460
|
await kvm.create(membershipBucket(space), { history: 1, max_bytes: MEMBERSHIP_MAX_BYTES });
|
|
416
461
|
await kvm.create(deliveryBucket(space), { ttl: LEASE_TTL_MS });
|
|
417
462
|
await kvm.create(managerBucket(space), { ttl: MANAGER_LEASE_TTL_MS });
|
|
418
|
-
//
|
|
419
|
-
//
|
|
463
|
+
// The other endpoint stores are nonportable control state. Recreate them empty, with any workflow
|
|
464
|
+
// store the artifact did not hold, through the same production seam as ordinary space setup,
|
|
465
|
+
// which verifies the restored workflow stores.
|
|
420
466
|
await createEndpointStreams(jsm, kvm, space);
|
|
421
467
|
// The artifact Object Store is EXCLUDED from the backup artifact, which does not mean restore
|
|
422
468
|
// ignores it: the assertion below covers `excluded` too, so a restored space must come back
|
|
@@ -453,13 +499,13 @@ async function createOmittedInfrastructure(broker, space, registryOnly) {
|
|
|
453
499
|
}
|
|
454
500
|
}
|
|
455
501
|
async function restoreAndValidate(broker, space, staged, snapshotDir, pass, onlyRegistry, checkpoints, completeInfrastructure) {
|
|
456
|
-
const wanted = onlyRegistry ? spaceBackupInventory(space).registry :
|
|
502
|
+
const wanted = onlyRegistry ? spaceBackupInventory(space).registry : artifactStreams(staged.manifest);
|
|
457
503
|
for (const name of wanted)
|
|
458
504
|
await restoreStream(broker, space, snapshotDir, pass, staged.manifest.streams.find((entry) => entry.stream === name));
|
|
459
505
|
for (const name of wanted)
|
|
460
506
|
await validateRestoredStream(broker, space, staged.manifest.streams.find((entry) => entry.stream === name), 0);
|
|
461
507
|
if (completeInfrastructure)
|
|
462
|
-
await createOmittedInfrastructure(broker, space,
|
|
508
|
+
await createOmittedInfrastructure(broker, space, wanted);
|
|
463
509
|
if (!onlyRegistry)
|
|
464
510
|
for (const checkpoint of checkpoints)
|
|
465
511
|
await recreateCheckpoint(broker, space, checkpoint);
|
|
@@ -508,15 +554,82 @@ export function preservedSourceState(root, source) {
|
|
|
508
554
|
export function movedFolderRefusal(root, space, recordedStore, moved, then) {
|
|
509
555
|
return new CommandFailure("refused", "CONFLICT", `this folder was moved from ${moved.recordedRoot} after its state was preserved: the maintenance journal records the preserved store at ${recordedStore}, and that store is now ${moved.store}`, { target: { root, space, recordedRoot: moved.recordedRoot, recordedStore, store: moved.store }, remedy: `move this folder back to ${moved.recordedRoot}, then ${then} there` });
|
|
510
556
|
}
|
|
557
|
+
/** The streams a restore attempt restored, from its launch record. A record written before full
|
|
558
|
+
* backups held workflow runs names none, and those attempts restored a v1 artifact's streams. */
|
|
559
|
+
export function journaledRestoredStreams(launch, space, mode) {
|
|
560
|
+
const recorded = launch.restoredStreams;
|
|
561
|
+
const selection = launchString(launch, "restoreOnly") === "registry" ? "registry" : "full";
|
|
562
|
+
if (recorded === undefined)
|
|
563
|
+
return [...artifactStreams({ format: BACKUP_MANIFEST_FORMAT_V1, space, selection, mode })];
|
|
564
|
+
if (!Array.isArray(recorded) || recorded.some((name) => typeof name !== "string"))
|
|
565
|
+
throw new Error("restore launch record has an invalid restoredStreams");
|
|
566
|
+
return recorded;
|
|
567
|
+
}
|
|
568
|
+
const CLASS_WORDS = {
|
|
569
|
+
registry: "channel registry", messages: "messages", authorization: "channel ACLs and members", workflow: "workflow runs",
|
|
570
|
+
transient: "presence", derived: "membership", lease: "leases", control: "endpoint control stores", artifact: "artifact store",
|
|
571
|
+
};
|
|
572
|
+
/** What a restore brought back from the artifact and what it recreated empty, by stream, and the
|
|
573
|
+
* same in words. A full restore that brought back no workflow store carries a note that says why:
|
|
574
|
+
* a user-mode artifact holds none, and an older artifact was made before full backups held runs. */
|
|
575
|
+
export function restoreComposition(space, restored, mode) {
|
|
576
|
+
const inventory = spaceBackupInventory(space);
|
|
577
|
+
const all = [...inventory.backedUp, ...inventory.excluded];
|
|
578
|
+
const empty = all.filter((entry) => !restored.includes(entry.name));
|
|
579
|
+
const words = (entries) => [...new Set(entries.map((entry) => CLASS_WORDS[entry.class]))].join(", ") || "none";
|
|
580
|
+
const workflow = inventory.backedUp.filter((entry) => entry.class === "workflow").map((entry) => entry.name);
|
|
581
|
+
return {
|
|
582
|
+
restored: [...restored],
|
|
583
|
+
recreatedEmpty: empty.map((entry) => entry.name),
|
|
584
|
+
restoredWords: words(all.filter((entry) => restored.includes(entry.name))),
|
|
585
|
+
emptyWords: words(empty),
|
|
586
|
+
...(restored.length > inventory.registry.length && !workflow.some((name) => restored.includes(name))
|
|
587
|
+
? { note: mode === "user" ? USER_MODE_NO_RUNS : OLDER_FORMAT_NO_RUNS } : {}),
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
const USER_MODE_NO_RUNS = "A user-mode backup holds no workflow runs, because the records store's lifecycle heads name credential rows in the auth store, which a backup does not carry; the workflow run stores were recreated empty.";
|
|
591
|
+
const OLDER_FORMAT_NO_RUNS = "This backup was made before full backups held workflow runs, so it holds none; the workflow run stores were recreated empty.";
|
|
511
592
|
/** The step that moves a full restore attempt on from `state`, for a refusal to name. A committed or
|
|
512
|
-
* degraded attempt goes forward through bare `up`, which continues it.
|
|
513
|
-
|
|
593
|
+
* degraded attempt goes forward through bare `up`, which continues it. `leftOut` is what the restore
|
|
594
|
+
* left only in its previous store ({@link restoreLeftOut}). */
|
|
595
|
+
export function restoreNextStep(state, attemptId, leftOut) {
|
|
514
596
|
if (state === "restore-ready")
|
|
515
597
|
return `roll the pre-commit attempt back with cotal backup recover ${attemptId} --yes; preview it first with --dry-run`;
|
|
598
|
+
// That restore's cleanup also deletes the store that holds the only copy of what it left out, so
|
|
599
|
+
// it runs only with --discard-history.
|
|
600
|
+
if (state === "active" && leftOut)
|
|
601
|
+
return `the restore completed: cotal backup cleanup-fallback ${attemptId} --yes --discard-history retires its journal and deletes the previous store, the only copy of the ${leftOut} it left out; preview it first with --dry-run`;
|
|
516
602
|
if (state === "active")
|
|
517
603
|
return `the restore completed: retire its journal with cotal backup cleanup-fallback ${attemptId} --yes; preview it first with --dry-run`;
|
|
518
604
|
return `recover forward with bare cotal up from this root, which continues attempt ${attemptId}; fallback cleanup follows once it is active`;
|
|
519
605
|
}
|
|
606
|
+
/** A ready journal's next step. Resume and backup use the store at its recorded path, so a folder
|
|
607
|
+
* moved after the cut is told to move back, and a missing store is named. */
|
|
608
|
+
function readyNextStep(root, source) {
|
|
609
|
+
const where = preservedSourceState(root, source);
|
|
610
|
+
if (where.state === "moved")
|
|
611
|
+
return `this folder was moved from ${where.recordedRoot} after its state was preserved: move it back there, then create a backup or resume with bare ${displayCmd()} up`;
|
|
612
|
+
if (where.state === "missing")
|
|
613
|
+
return `the preserved store recorded at ${source.path} is missing: if this folder was moved, move it back; if the store is lost, restore a backup with ${displayCmd()} backup restore <dir> --accept-missing-source`;
|
|
614
|
+
return `create a backup with ${displayCmd()} backup create <dir>, or resume with bare ${displayCmd()} up`;
|
|
615
|
+
}
|
|
616
|
+
/** The next step for a cut a backup create still claims: wait while it runs, or release it once it
|
|
617
|
+
* stopped before it finished. */
|
|
618
|
+
function claimedNextStep(root, claim) {
|
|
619
|
+
const recover = `${displayCmd()} backup recover ${claim.attemptId} --yes`;
|
|
620
|
+
if (assessMaintenanceClaim(claim, { unrecordedOwnersDead: attemptProcessesGone(root) }) === "stale")
|
|
621
|
+
return `backup attempt ${claim.attemptId} stopped before it finished: release it with ${recover}`;
|
|
622
|
+
return `backup attempt ${claim.attemptId} holds this root until ${claim.deadline} (process ${claim.coordinator.pid}); if it was stopped, run ${recover} once it has exited`;
|
|
623
|
+
}
|
|
624
|
+
/** The attempt a root's maintenance journal holds and the step that moves it on, as `cotal status`
|
|
625
|
+
* shows it and a command that refuses over that journal names it. */
|
|
626
|
+
export function maintenanceNextStep(root, journal) {
|
|
627
|
+
const attemptId = "restore" in journal ? journal.restore.attemptId : journal.state === "claimed" ? journal.claim.attemptId : journal.cut.attemptId;
|
|
628
|
+
const next = "restore" in journal ? restoreNextStep(journal.state, attemptId, restoreLeftOut(journal))
|
|
629
|
+
: journal.state === "ready" ? readyNextStep(root, journal.source)
|
|
630
|
+
: journal.state === "claimed" ? claimedNextStep(root, journal.claim) : null;
|
|
631
|
+
return { attemptId, next };
|
|
632
|
+
}
|
|
520
633
|
/** The refusal while a restore's or backup's claim is not provably stale: what holds it, until
|
|
521
634
|
* when, and when `backup recover` can release it. The refusing command changed nothing. */
|
|
522
635
|
export function heldClaim(root, attemptId, claim, command, assessment) {
|
|
@@ -527,12 +640,57 @@ export function heldClaim(root, attemptId, claim, command, assessment) {
|
|
|
527
640
|
const [holder, remedy] = assessment === "ambiguous"
|
|
528
641
|
? [`its processes on host ${coordinator.host} cannot be proven gone from this host`, `prove its ${kind} process and brokers on ${coordinator.host} have exited, then run ${recover}`]
|
|
529
642
|
: coordinatorRuns
|
|
530
|
-
? [`its ${kind} process ${coordinator.pid} is still running`, `wait for that ${kind} to finish; if it was stopped, run ${recover} once process ${coordinator.pid} has exited`]
|
|
643
|
+
? [`its ${kind} process ${coordinator.pid} is still running, started at ${coordinator.startedAt}`, `wait for that ${kind} to finish; if it was stopped, run ${recover} once process ${coordinator.pid} has exited`]
|
|
531
644
|
: running.length
|
|
532
645
|
? [`its ${kind} process ${coordinator.pid} has exited, and its brokers (pid ${running.join(", ")}) are still stopping`, `run ${recover} again once they have exited`]
|
|
533
646
|
: [`its ${kind} process ${coordinator.pid} has exited, but a broker it started cannot be proven gone`, `run ${recover} after ${deadline}`];
|
|
534
647
|
return new CommandFailure("refused", "LIFECYCLE_BLOCKED", `${command} is refused: ${kind} attempt ${attemptId} holds this root until ${deadline}, and ${holder}; nothing was changed`, { target: { root, attemptId, deadline, holderPid: coordinator.pid }, remedy });
|
|
535
648
|
}
|
|
649
|
+
/** What a restore attempt left only in the store it set aside ({@link restoreLeftOut}), whether that
|
|
650
|
+
* includes what was written after its artifact ({@link restoreReplacedNewerCut}), and that store, as
|
|
651
|
+
* the root's journal records them. Undefined when it left nothing out or the journal no longer names
|
|
652
|
+
* the attempt. */
|
|
653
|
+
export function restoreOnlyCopy(root, attemptId) {
|
|
654
|
+
try {
|
|
655
|
+
const journal = readMaintenanceJournal(root);
|
|
656
|
+
if (!journal || !("restore" in journal) || journal.restore.attemptId !== attemptId)
|
|
657
|
+
return undefined;
|
|
658
|
+
const leftOut = restoreLeftOut(journal);
|
|
659
|
+
return leftOut ? { leftOut, newer: restoreReplacedNewerCut(journal), rolledBack: restoreRolledBackRuns(journal), ...(journal.restore.previousSource ? { previousStore: journal.restore.previousSource.identity.path } : {}) } : undefined;
|
|
660
|
+
}
|
|
661
|
+
catch {
|
|
662
|
+
return undefined;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
/** What a restore over a newer cut says about each run it rolled back ({@link restoreRolledBackRuns}):
|
|
666
|
+
* the steps settled after the artifact that are open again, and that the previous store holds the
|
|
667
|
+
* only copy of how they settled. Answering a reopened step again is allowed. */
|
|
668
|
+
export function rolledBackNotes(rolledBack) {
|
|
669
|
+
const lines = rolledBack.runs.map((row) => {
|
|
670
|
+
if (row.missing)
|
|
671
|
+
return `Run ${row.run} started after this backup, so the restore removed it; only the previous store holds it.`;
|
|
672
|
+
if (!row.reopened.length)
|
|
673
|
+
return `Run ${row.run} went back to where this backup left it; what it recorded after that is only in the previous store.`;
|
|
674
|
+
const one = row.reopened.length === 1;
|
|
675
|
+
const answered = row.reopened.every((key) => /^(checkpoint|ask)\b/.test(key.slice(key.lastIndexOf("/") + 1)));
|
|
676
|
+
const kept = answered ? (one ? "That answer is" : "Those answers are") : (one ? "Its outcome is" : "Their outcomes are");
|
|
677
|
+
return `Run ${row.run} went back to where this backup left it: ${row.reopened.join(", ")} ${one ? "was" : "were"} ${answered ? "answered" : "settled"} after that and ${one ? "is" : "are"} open again. ${kept} only in the previous store.`;
|
|
678
|
+
});
|
|
679
|
+
return rolledBack.more ? [...lines, `${rolledBack.more} more runs went back as well.`] : lines;
|
|
680
|
+
}
|
|
681
|
+
/** What a restore's receipt says about what it left out. A registry-only restore brings back channel
|
|
682
|
+
* settings only, and every other stream starts empty; a full restore of an artifact with no runs has
|
|
683
|
+
* a composition note that says why, and one of an artifact older than the state it replaced says
|
|
684
|
+
* that what was written after the artifact is not restored. The store it set aside holds the only
|
|
685
|
+
* copy, which cleanup-fallback deletes only with `--discard-history`. */
|
|
686
|
+
export function leftOutNotes(attemptId, selection, onlyCopy) {
|
|
687
|
+
if (!onlyCopy)
|
|
688
|
+
return [];
|
|
689
|
+
const kept = onlyCopy.previousStore ? `The previous store at ${onlyCopy.previousStore} holds the only copy of ${selection === "registry" ? "them" : `the ${onlyCopy.leftOut}`}. \`cotal backup cleanup-fallback ${attemptId}\` deletes it only with --discard-history.` : undefined;
|
|
690
|
+
if (selection !== "registry")
|
|
691
|
+
return [...(onlyCopy.newer ? ["This backup was made before the state it replaced was preserved, so the chat and DM history and workflow runs written after it are not restored.", ...rolledBackNotes(onlyCopy.rolledBack)] : []), ...(kept ? [kept] : [])];
|
|
692
|
+
return ["A registry-only restore brings back channel settings only, so chat and DM history and workflow runs start empty.", kept ?? "No previous store was retained."];
|
|
693
|
+
}
|
|
536
694
|
/** The restore attempt the root's journal holds, with the step that moves it on, so a failure can
|
|
537
695
|
* name the full attempt a recovery command needs. An unreadable journal names none. */
|
|
538
696
|
export function heldRestoreAttempt(root) {
|
|
@@ -545,12 +703,12 @@ export function heldRestoreAttempt(root) {
|
|
|
545
703
|
}
|
|
546
704
|
if (!journal || !("restore" in journal))
|
|
547
705
|
return undefined;
|
|
548
|
-
return { attemptId: journal.restore.attemptId, journalState: journal.state, remedy: restoreNextStep(journal.state, journal.restore.attemptId) };
|
|
706
|
+
return { attemptId: journal.restore.attemptId, journalState: journal.state, remedy: restoreNextStep(journal.state, journal.restore.attemptId, restoreLeftOut(journal)) };
|
|
549
707
|
}
|
|
550
708
|
/** A root with no stopped preserved cut to restore into. Nothing was staged, moved or claimed. */
|
|
551
709
|
function notRestorable(root, journal) {
|
|
552
710
|
const remedy = !journal ? "restore needs the stopped preserved cut from `cotal down --preserve-state` on this root"
|
|
553
|
-
: "restore" in journal ? restoreNextStep(journal.state, journal.restore.attemptId)
|
|
711
|
+
: "restore" in journal ? restoreNextStep(journal.state, journal.restore.attemptId, restoreLeftOut(journal))
|
|
554
712
|
: "this root's maintenance attempt must finish first; check it with cotal status";
|
|
555
713
|
return new CommandFailure("refused", "LIFECYCLE_BLOCKED", `restore requires stable ready maintenance state, found ${journal?.state ?? "none"}`, { target: { root, ...(journal ? { state: journal.state } : {}) }, remedy });
|
|
556
714
|
}
|
|
@@ -566,9 +724,24 @@ export async function prepareRestore(root, flags, progress) {
|
|
|
566
724
|
const deadline = new Date(Date.now() + RESTORE_TIMEOUT_MS);
|
|
567
725
|
// With no journal there is no cut to restore into. Refuse before the lock creates the maintenance
|
|
568
726
|
// directory, so a refused restore leaves the folder as it found it and `up` there sees no state.
|
|
569
|
-
|
|
727
|
+
const recorded = readMaintenanceJournal(root);
|
|
728
|
+
if (!recorded)
|
|
570
729
|
throw notRestorable(root, undefined);
|
|
571
|
-
|
|
730
|
+
// A path that names nothing is refused here too, saying whether its folder or the artifact is missing.
|
|
731
|
+
const named = resolve(flags.restore);
|
|
732
|
+
const missing = missingBackupPath(named);
|
|
733
|
+
if (missing)
|
|
734
|
+
throw new CommandFailure("refused", "TARGET_NOT_FOUND", `${missingBackupPathText(named, missing)}; nothing was restored`, { target: { root, directory: named, folder: dirname(named), missing }, remedy: "name an existing backup artifact folder; cotal backup verify <dir> checks one before a restore" });
|
|
735
|
+
// So is a path that cannot be an artifact, saying what it is: one that is, holds or sits inside
|
|
736
|
+
// the store the restore replaces or the folder it stages in, a file, or a folder no create wrote.
|
|
737
|
+
const namedPath = realpathSync.native(named);
|
|
738
|
+
const overlap = artifactOverlapRefusal(root, namedPath, recorded.source.path);
|
|
739
|
+
if (overlap)
|
|
740
|
+
throw overlap;
|
|
741
|
+
const notArtifact = notAnArtifactRefusal(root, namedPath, "nothing was restored", { root });
|
|
742
|
+
if (notArtifact)
|
|
743
|
+
throw notArtifact;
|
|
744
|
+
let lock = acquireStackOperationLock(root, "restore");
|
|
572
745
|
let staged;
|
|
573
746
|
let transitioned = false;
|
|
574
747
|
let targetBound = false;
|
|
@@ -628,18 +801,38 @@ export async function prepareRestore(root, flags, progress) {
|
|
|
628
801
|
const currentAuthority = await authorityFingerprint(root, journal.space, journal.mode);
|
|
629
802
|
const stageParent = ensurePrivateAttemptsDir(root).path;
|
|
630
803
|
const artifactPath = realpathSync.native(resolve(flags.restore));
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
if (
|
|
634
|
-
throw
|
|
635
|
-
|
|
804
|
+
// Again under the lock: a link in the path may name another folder now, and the journal is reread.
|
|
805
|
+
const lockedOverlap = artifactOverlapRefusal(root, artifactPath, journal.source.path);
|
|
806
|
+
if (lockedOverlap)
|
|
807
|
+
throw lockedOverlap;
|
|
808
|
+
// The cut records its source by real path, so a default .cotal/nats that links there is that
|
|
809
|
+
// source and is restored in place, not taken for an alternate target.
|
|
810
|
+
const defaultStore = join(root, ".cotal", "nats");
|
|
811
|
+
targetPath = resolve(flags["store-dir"] ?? (controller || linksTo(defaultStore, journal.source.path) ? journal.source.path : defaultStore));
|
|
636
812
|
if (flags["store-dir"] !== undefined)
|
|
637
813
|
assertNewStorePath(targetPath, journal.source.path);
|
|
638
814
|
assertRestoreTargetPath(journal.source.path, artifactPath, stageParent, targetPath);
|
|
815
|
+
// A restore into the preserved store's own path moves that store aside whole, so a file in it that
|
|
816
|
+
// no Cotal store writes would move with it; it is refused before anything moves. A store restored
|
|
817
|
+
// elsewhere stays where it is, and its cleanup refuses instead.
|
|
818
|
+
if (targetPath === journal.source.path) {
|
|
819
|
+
const foreign = oldStoreForeignEntries(journal.source.path);
|
|
820
|
+
if (foreign.length)
|
|
821
|
+
throw foreignEntriesRefusal(journal.source.path, foreign, "the preserved store", "a restore into it moves that store aside whole, so nothing was restored", "the restore", { root, space: journal.space });
|
|
822
|
+
}
|
|
639
823
|
// The journal is ready with no live claim, and the artifact/target are proven disjoint from
|
|
640
824
|
// the attempts directory: any attempts-dir content is dead-attempt residue.
|
|
641
825
|
sweepAttemptResidue(root);
|
|
642
|
-
|
|
826
|
+
let artifact;
|
|
827
|
+
// A faulty artifact is refused before anything moves, naming the file and fault verify names.
|
|
828
|
+
try {
|
|
829
|
+
artifact = stageArtifact(artifactPath, stageParent);
|
|
830
|
+
}
|
|
831
|
+
catch (error) {
|
|
832
|
+
if (!(error instanceof ArtifactFileFault))
|
|
833
|
+
throw error;
|
|
834
|
+
throw new CommandFailure("refused", "SCHEMA_INVALID", `${error.message}; nothing was restored`, { target: { root, directory: artifactPath, file: error.file, fault: error.fault }, remedy: "this copy cannot be restored as it is: check it with cotal backup verify, or restore another copy of the same artifact; the preserved cut is unchanged" });
|
|
835
|
+
}
|
|
643
836
|
staged = artifact;
|
|
644
837
|
await validateManifest(artifact.manifest, flags, journal, currentAuthority);
|
|
645
838
|
const checkpoints = readStagedCheckpoints(artifact);
|
|
@@ -653,12 +846,14 @@ export async function prepareRestore(root, flags, progress) {
|
|
|
653
846
|
// The partial selection is a property of the artifact, not only of the flag: a registry-only
|
|
654
847
|
// artifact restored without --restore-only registry must still create omitted infrastructure.
|
|
655
848
|
const onlyRegistry = flags["restore-only"] === "registry" || artifact.manifest.selection === "registry";
|
|
849
|
+
// Journaled, so cleanup-fallback knows the previous store holds the only copy of what was left out.
|
|
850
|
+
const selection = onlyRegistry ? "registry" : "full";
|
|
656
851
|
// Retained agents relaunch under their preserved runtime; a contradicting override must fail
|
|
657
852
|
// in preflight, before any mutation or listener exposure.
|
|
658
853
|
if (!onlyRegistry && flags.runtime && inventoryRuntimes[0] && flags.runtime !== inventoryRuntimes[0])
|
|
659
854
|
throw new Error(`--runtime ${flags.runtime} contradicts the preserved agent runtime ${inventoryRuntimes[0]}; omit it or restore registry-only`);
|
|
660
855
|
const effectiveRuntime = flags.runtime ?? inventoryRuntimes[0] ?? "pty";
|
|
661
|
-
const wanted = onlyRegistry ? spaceBackupInventory(journal.space).registry :
|
|
856
|
+
const wanted = onlyRegistry ? spaceBackupInventory(journal.space).registry : artifactStreams(artifact.manifest);
|
|
662
857
|
for (const checkpoint of onlyRegistry ? [] : checkpoints) {
|
|
663
858
|
if (!wanted.includes(checkpoint.stream))
|
|
664
859
|
throw new Error(`checkpoint ${checkpoint.stream}/${checkpoint.name} is outside the restored selection`);
|
|
@@ -678,6 +873,13 @@ export async function prepareRestore(root, flags, progress) {
|
|
|
678
873
|
if (JSON.stringify(authorityBeforeMutation) !== JSON.stringify(currentAuthority))
|
|
679
874
|
throw new Error("current trust state changed during restore validation");
|
|
680
875
|
await validateManifest(artifact.manifest, flags, journal, authorityBeforeMutation);
|
|
876
|
+
const resumeLaunch = (resume.launch ?? {});
|
|
877
|
+
const effectiveServer = canonicalServerEndpoint(controller ? journal.cut.launch.server : flags.server ?? (typeof resumeLaunch.server === "string" ? resumeLaunch.server : "nats://127.0.0.1:4222"));
|
|
878
|
+
// The restored broker binds this address after commit intent, so another listener there would
|
|
879
|
+
// leave the attempt degraded. It is refused here, before anything moves, as backup create does.
|
|
880
|
+
await assertEndpointUnreachable(effectiveServer).catch((error) => {
|
|
881
|
+
throw new CommandFailure("refused", "CONFLICT", `${error.message}; the restored broker needs that address, so the preserved cut was not changed`, { target: { root, space: journal.space, server: effectiveServer }, remedy: `stop the process that listens on ${effectiveServer}, then run the restore again` });
|
|
882
|
+
});
|
|
681
883
|
const sourceExists = (() => {
|
|
682
884
|
try {
|
|
683
885
|
lstatSync(journal.source.path);
|
|
@@ -701,15 +903,15 @@ export async function prepareRestore(root, flags, progress) {
|
|
|
701
903
|
if (!sourceExists) {
|
|
702
904
|
if (!flags["accept-missing-source"])
|
|
703
905
|
throw new CommandFailure("refused", "TARGET_NOT_FOUND", `the preserved source ${journal.source.path} is missing; nothing was changed`, { target: { root, space: journal.space, source: journal.source.path }, remedy: "put the preserved store back at that path, or, once you have verified it is lost, repeat the restore with --accept-missing-source to rebuild it from this backup" });
|
|
704
|
-
prepareMissingSourceRestore(lock, { attemptId, targetPath, claim });
|
|
906
|
+
prepareMissingSourceRestore(lock, { attemptId, targetPath, claim, selection });
|
|
705
907
|
}
|
|
706
908
|
else if (targetPath === journal.source.path) {
|
|
707
909
|
const fallbackPath = join(dirname(targetPath), `.cotal-restore-fallback-${attemptId}`);
|
|
708
|
-
prepareSamePathRestore(lock, { attemptId, targetPath, fallbackPath, claim });
|
|
910
|
+
prepareSamePathRestore(lock, { attemptId, targetPath, fallbackPath, claim, selection });
|
|
709
911
|
moveSamePathRestoreSource(lock);
|
|
710
912
|
}
|
|
711
913
|
else {
|
|
712
|
-
prepareAlternateRestore(lock, { attemptId, targetPath, claim });
|
|
914
|
+
prepareAlternateRestore(lock, { attemptId, targetPath, claim, selection });
|
|
713
915
|
}
|
|
714
916
|
transitioned = true;
|
|
715
917
|
createOwnedDirectory(targetPath);
|
|
@@ -797,8 +999,17 @@ export async function prepareRestore(root, flags, progress) {
|
|
|
797
999
|
releaseMaintenanceLock(lock);
|
|
798
1000
|
lock = undefined;
|
|
799
1001
|
await restoreAndValidate(broker, journal.space, artifact, sanitized.path, "target", onlyRegistry, checkpoints, true);
|
|
1002
|
+
// A cut preserved after this artifact was made holds history the artifact lacks, and the store
|
|
1003
|
+
// this restore sets aside keeps its only copy. The runs it rolled back are named from the step
|
|
1004
|
+
// journals of both stores: the restored one here, the set-aside one from a private clone.
|
|
1005
|
+
const previousCutNewer = sourceExists && Date.parse(journal.cut.intentAt) > Date.parse(artifact.manifest.createdAt);
|
|
1006
|
+
const restoredRuns = previousCutNewer && wanted.includes(wfjStreamName(journal.space)) ? await readRunJournals(broker, journal.space) : undefined;
|
|
800
1007
|
await broker.stop();
|
|
801
1008
|
broker = undefined;
|
|
1009
|
+
const previousStore = restoredRuns ? readMaintenanceJournal(root)?.restore.previousSource?.identity.path : undefined;
|
|
1010
|
+
const rolledBack = restoredRuns && previousStore
|
|
1011
|
+
? rolledBackRuns(await readPreviousRunJournals({ root, previousStore, attemptId, space: journal.space, mode: journal.mode, ...(auth ? { auth } : {}), deadline, record: recordResources }), restoredRuns)
|
|
1012
|
+
: undefined;
|
|
802
1013
|
// The seats this restore is about to resume owe the same admission and the same restore as an
|
|
803
1014
|
// ordinary one: the retained inventory here is this root's own preserved cut, and the manager
|
|
804
1015
|
// operation it ends in is the same `resumePreserved`. Run them after the store is restored and
|
|
@@ -815,8 +1026,6 @@ export async function prepareRestore(root, flags, progress) {
|
|
|
815
1026
|
// intent, so a failure up to here still rolls the definition back first.
|
|
816
1027
|
if (controller && sourceExists && targetPath !== journal.source.path)
|
|
817
1028
|
reconfigureControllerBroker(lock);
|
|
818
|
-
const resumeLaunch = (resume.launch ?? {});
|
|
819
|
-
const effectiveServer = canonicalServerEndpoint(controller ? journal.cut.launch.server : flags.server ?? (typeof resumeLaunch.server === "string" ? resumeLaunch.server : "nats://127.0.0.1:4222"));
|
|
820
1029
|
const effectiveHost = controller ? new URL(effectiveServer).hostname : flags.host ?? (() => {
|
|
821
1030
|
try {
|
|
822
1031
|
return new URL(effectiveServer).hostname;
|
|
@@ -838,7 +1047,10 @@ export async function prepareRestore(root, flags, progress) {
|
|
|
838
1047
|
detached: Boolean(flags.detach),
|
|
839
1048
|
restoreSource: resolve(flags.restore),
|
|
840
1049
|
restoreOnly: flags["restore-only"] ?? artifact.manifest.selection,
|
|
1050
|
+
restoredStreams: [...wanted],
|
|
841
1051
|
acceptMissingSource: Boolean(flags["accept-missing-source"]),
|
|
1052
|
+
...(previousCutNewer ? { previousCutNewer: true } : {}),
|
|
1053
|
+
...(rolledBack?.runs.length ? { rolledBackRuns: rolledBack.runs, ...(rolledBack.more ? { rolledBackRunsMore: rolledBack.more } : {}) } : {}),
|
|
842
1054
|
serverName,
|
|
843
1055
|
serverNonce,
|
|
844
1056
|
// Durable evidence of consent, as the ordinary resume journals it: an operator asking later
|
|
@@ -864,6 +1076,7 @@ export async function prepareRestore(root, flags, progress) {
|
|
|
864
1076
|
runtime: effectiveRuntime,
|
|
865
1077
|
detached: Boolean(flags.detach),
|
|
866
1078
|
selection: onlyRegistry ? "registry" : artifact.manifest.selection,
|
|
1079
|
+
restoredStreams: wanted,
|
|
867
1080
|
inventory: resume.inventory,
|
|
868
1081
|
serverName,
|
|
869
1082
|
serverNonce,
|